Berkeley Nuclear Data Software
CloverGainDriftAna.h
Go to the documentation of this file.
1 #include "PostProcBase.h"
2 
3 
4 #include "TH2.h"
5 #include "TGraph.h"
6 
7 namespace NSDAna
8 {
11 {
12 public:
13  int16_t detID;
14  int16_t elementID;
15  uint16_t amp;
16  int32_t wallTime;
17 };
18 
26 class CloverGainDriftAna : public PostProcBase<clovGainTreeEntry>
27 {
28 public:
33  int addFile(string a_filename);
36  std::vector<TH2*> buildTimeHistory();
38  void setStartDate(int a_year,
39  int a_month,
40  int a_day
41  );
43  void setStopDate(int a_year,
44  int a_month,
45  int a_day
46  );
47  void setStartBin(int a_bin);
48  void setStopBin(int a_bin);
49  void setTStep(int a_tStepS);
51  void setSearchStart(double m_searchStart);
53  void setSearchStop(double m_searchStop );
55  void setSearchStep(double m_searchStep );
56 
61  void readTreeIntoMemory(double a_dsFactor = 1,
62  double a_minAmp = -1
63  );
64  // allows for loading single leaf into memory
65  void readTreeIntoMemory(int a_cloverID, int a_leafID);
68  std::ostream& printTimeChunkList(std::ostream& a_stream,
69  int a_detID,
70  int a_elementID
71  );
75  TH1* getHistForTimeChunk(int a_detID,
76  int a_elementID,
77  int a_mapLocation,
78  double a_ampScalar=1.0
79  );
84  TH2* getHistFromMap(int a_detID,
85  int a_elementID);
89  void writeMapHistsToFile(std::string a_fileName);
93  std::map<double,double> getHistShapeTest(int a_detID,
94  int a_elementID,
95  int a_mapLocation1,
96  int a_mapLocation2,
97  double a_searchStart = -1.0,
98  double a_searchStop = -1.0,
99  double a_searchStep = -1.0
100  );
101 
104  TGraph* getHistShapeTestPlot(int a_detID,
105  int a_elementID,
106  int a_mapLocation1,
107  int a_mapLocation2
108  );
109 
112  std::pair<double,double> getGainCorrectionFactor (int a_detID,
113  int a_elementID,
114  int a_mapLocation1,
115  int a_mapLocation2
116  );
119  std::map<uint32_t,double> getGainCorrectionFactors(int a_detID,
120  int a_elementID,
121  int a_mapLocation
122  );
127  std::map<uint32_t,double> recalcGainCorrectionFactors(int a_detID,
128  int a_elementID,
129  int a_mapLocation,
130  int a_mapRegionStart,
131  int a_mapRegionStop,
132  double a_searchStart,
133  double a_searchStop,
134  double a_searchStep
135  );
139  TGraph* plotGCState(int a_detID,
140  int a_elementID
141  );
143  virtual std::ostream& printJSONFormat(int a_detID,
144  int a_elementID,
145  std::ostream& a_stream = std::cout
146  ) const;
149  void saveGCFactorJSON(int a_detID,
150  int a_elementID,
151  std::string a_fileName
152  );
153 
154  TH2* getCorrectedHist(int a_detID,
155  int a_elementID
156  );
157 
158  TH2* getCorrectedMap(int a_detID,
159  int a_elementID
160  );
164  void setGCFactors(int a_detID,
165  int a_elementID,
166  int a_startMapElement,
167  int a_stopMapElement,
168  double a_gcFactor
169  );
170 private:
172  void setTreeName();
173  //not useful for this overload
174  void setBranchName(){};
176  int32_t m_startTime;
178  int32_t m_stopTime;
180  int m_ampBins;
182  double m_searchStart;
184  double m_searchStop ;
186  double m_searchStep ;
188  TH2* buildEmptyTimeHistoryHist(int a_detID, int a_elementID);
189 
192  TH2* buildEmptyMapHist(int a_detID, int a_elementID,int a_mapLength);
193 
198  typedef std::map<uint32_t, std::vector<uint16_t> > timeHistogram;
201  std::map<std::pair<uint16_t,uint16_t>,timeHistogram > m_detTimeHistory;
202  bool m_treeRead;
204  std::map<string,int> m_histNames;
206  std::map<std::pair<uint16_t,uint16_t>,
207  std::map<uint32_t,double> > m_gainCorrection;
208  //once a correction has been determined, this should be true.
209  std::map<std::pair<uint16_t,uint16_t>,bool> m_hasCorrection;
210  //used to track when hitting boundary conditions
211  std::map<std::pair<uint16_t,uint16_t>,std::map<uint32_t,bool> > m_nearBoundary;
212 
213 
214  int m_startBin;
215  int m_stopBin;
216 
217  int m_tStep;
218 
219 
220 };
221 
222 }
Definition: CloverGainDriftAna.h:27
void readTreeIntoMemory(double a_dsFactor=1, double a_minAmp=-1)
Definition: CloverGainDriftAna.cpp:221
void setSearchStop(double m_searchStop)
the stopping fraction of the search defaults to 1.02
Definition: CloverGainDriftAna.cpp:208
virtual std::ostream & printJSONFormat(int a_detID, int a_elementID, std::ostream &a_stream=std::cout) const
prints the current state of the gain corrections to the specified stream
Definition: CloverGainDriftAna.cpp:752
void setGCFactors(int a_detID, int a_elementID, int a_startMapElement, int a_stopMapElement, double a_gcFactor)
Definition: CloverGainDriftAna.cpp:887
std::map< double, double > getHistShapeTest(int a_detID, int a_elementID, int a_mapLocation1, int a_mapLocation2, double a_searchStart=-1.0, double a_searchStop=-1.0, double a_searchStep=-1.0)
Definition: CloverGainDriftAna.cpp:426
void setStopBin(int a_bin)
Definition: CloverGainDriftAna.cpp:193
std::ostream & printTimeChunkList(std::ostream &a_stream, int a_detID, int a_elementID)
Definition: CloverGainDriftAna.cpp:287
std::pair< double, double > getGainCorrectionFactor(int a_detID, int a_elementID, int a_mapLocation1, int a_mapLocation2)
Definition: CloverGainDriftAna.cpp:524
void writeMapHistsToFile(std::string a_fileName)
Definition: CloverGainDriftAna.cpp:399
int addFile(string a_filename)
Definition: CloverGainDriftAna.cpp:41
void setStartBin(int a_bin)
Definition: CloverGainDriftAna.cpp:188
TGraph * plotGCState(int a_detID, int a_elementID)
Definition: CloverGainDriftAna.cpp:710
TH2 * getCorrectedMap(int a_detID, int a_elementID)
Definition: CloverGainDriftAna.cpp:834
void setTStep(int a_tStepS)
Definition: CloverGainDriftAna.cpp:198
std::vector< TH2 * > buildTimeHistory()
Definition: CloverGainDriftAna.cpp:109
void setSearchStart(double m_searchStart)
the starting fraction of the search defaults to 0.98
Definition: CloverGainDriftAna.cpp:203
CloverGainDriftAna()
puts the class into a working state without much functionality
Definition: CloverGainDriftAna.cpp:17
TH2 * getCorrectedHist(int a_detID, int a_elementID)
Definition: CloverGainDriftAna.cpp:785
void setStartDate(int a_year, int a_month, int a_day)
set the start bin of the histogram to the supplied date and time
Definition: CloverGainDriftAna.cpp:155
TH2 * getHistFromMap(int a_detID, int a_elementID)
Definition: CloverGainDriftAna.cpp:364
std::map< uint32_t, double > recalcGainCorrectionFactors(int a_detID, int a_elementID, int a_mapLocation, int a_mapRegionStart, int a_mapRegionStop, double a_searchStart, double a_searchStop, double a_searchStep)
Definition: CloverGainDriftAna.cpp:620
void setStopDate(int a_year, int a_month, int a_day)
sets the last bin of the histograms to the supplied date
Definition: CloverGainDriftAna.cpp:171
TGraph * getHistShapeTestPlot(int a_detID, int a_elementID, int a_mapLocation1, int a_mapLocation2)
Definition: CloverGainDriftAna.cpp:499
void saveGCFactorJSON(int a_detID, int a_elementID, std::string a_fileName)
Definition: CloverGainDriftAna.cpp:772
TH1 * getHistForTimeChunk(int a_detID, int a_elementID, int a_mapLocation, double a_ampScalar=1.0)
Definition: CloverGainDriftAna.cpp:309
std::map< uint32_t, double > getGainCorrectionFactors(int a_detID, int a_elementID, int a_mapLocation)
Definition: CloverGainDriftAna.cpp:554
void setSearchStep(double m_searchStep)
the resolution of the grid search defaults to 0.0001
Definition: CloverGainDriftAna.cpp:213
Definition: PostProcBase.h:21
Definition: CloverGainDriftAna.h:8
used to leverage the overloaded postProcClass
Definition: CloverGainDriftAna.h:11
int32_t wallTime
Definition: CloverGainDriftAna.h:16
uint16_t amp
Definition: CloverGainDriftAna.h:15
int16_t elementID
Definition: CloverGainDriftAna.h:14
int16_t detID
Definition: CloverGainDriftAna.h:13