StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructAnalysisMaker.h
1 /***************************************************************************
2  *
3  *$Id: StEStructAnalysisMaker.h,v 1.10 2015/08/29 03:23:47 perev Exp $
4  *
5  *
6  *
7  ***************************************************************************
8  *
9  * Description: This is a maker for general EStruct Analysis.
10  * Requires at least 1 reader and 1 analysis
11  *
12  **************************************************************************/
13 
14 #ifndef StEStructAnalysisMaker_HH
15 #define StEStructAnalysisMaker_HH
16 
17 #include "Stiostream.h"
18 
19 #include "StMaker.h"
20 //
21 //-> include pure virtual interface
22 #include "StEStructEventReader.h"
23 #include "StEStructAnalysis.h"
24 #include "StEStructCuts.h"
25 
26 #include "StEStructQAHists.h"
27 class StEStructEvent;
28 #include "StMuDSTMaker/COMMON/StMuTimer.h"
29 //class StMuTimer;
30 
31 
32 
34 
35 public:
36  StEStructAnalysisMaker(const Char_t *name="ESTRUCT 2pt");
37 
38  virtual ~StEStructAnalysisMaker();
39 
40  void Clear(Option_t *option="");
41  Int_t Init();
42  Int_t Make();
43  Int_t Make(StEStructEvent *ev);
44  Int_t Finish();
45 
46  void SetReaderAnalysisPair(StEStructEventReader* reader, StEStructAnalysis * analysis);
47  void SetEventReader(StEStructEventReader* reader);
48  void SetAnalysis(StEStructAnalysis * analysis);
49  void SetAnalyses(StEStructAnalysis ** analyses, int n);
50  void SetQAHists(StEStructQAHists* qa);
51  bool quickSort(int *arr, int elements);
52  bool quickSort(double *arr, int elements);
53  void SetSorting(bool sort);
54  int GetSortedIndex(int i);
55  int getAnalysisIndex();
56  void writeQAHists(const char* fileName);
57 
58  void writeDiagnostics(int opt=0); // a holder for diagnostic info
59  void toggleMemoryInfo();
60  int getNumberOfEventsLooped();
61  int getNumberOfEventsProcessed();
62 
63  StMuTimer* getTimer();
64  void startTimer();
65  void stopTimer();
66 
67  void logAllStats(ostream& os);
68  void logCutStats(StEStructCuts* cuts, ostream& os, int index);
69 
70  void logAnalysisTime(ostream& os);
71  void logInputEvents(ostream& os);
72  void logOutputEvents(ostream& os);
73  void logOutputRate(ostream& os);
74  void logAnalysisStats(ostream& os);
75 
76  void SetReactionPlaneAnalysis(char* weightFile); // Sets the flag to do a reaction plane analysis
77 // void SetPhiWgtAnalysis(); // Sets the flag to do PhiWgt calculation
78 
79  void compiledLoop();
80  StEStructAnalysis* mCurrentAnalysis;
81 
82 
83  virtual const char *GetCVS() const
84  {static const char cvs[]="$Id: StEStructAnalysisMaker.h,v 1.10 2015/08/29 03:23:47 perev Exp $ built " __DATE__ " " __TIME__ ; return cvs;}
85 //-------------------------------------------------
86 
87 
88 private:
89 
90  Bool_t doPrintMemoryInfo;
91  StMuTimer* mtimer;
92  UInt_t mEventLoopCounter;
93  UInt_t mEventProcessedCounter;
94  int* mEventProcessedPerType;
95  int numAnalysis;
96  Bool_t doReactionPlaneAnalysis; //Flag to indicate whether or not to find the reaction plane
97  char* mWeightFile; //File that contains phi weights
98 // Bool_t doPhiWgtAnalysis; //Flag to indicate whether to calculate PhiWgts this pass
99  bool mSorting;
100  int* mIndex;
101  // --> new pointers for data I/O, cuts, and analysis
102 
103  StEStructEventReader* mreader;
104  StEStructAnalysis* manalysis[100];
105 
106  //pointers to an event ... don't need this now but may be useful
107  StEStructEvent* pEStructEvent; // pointer to uEvent data
108 
109  StEStructQAHists* mQAHists;
110 
111  public:
112 
113  ClassDef(StEStructAnalysisMaker,1)
114 };
115 
116 
117 inline StMuTimer* StEStructAnalysisMaker::getTimer(){ return mtimer; };
118 //inline void SetReactionPlaneAnalysis() { doReactionPlaneAnalysis = true; };
119 
120 inline void StEStructAnalysisMaker::SetReaderAnalysisPair(StEStructEventReader* reader, StEStructAnalysis* analysis){
121  SetEventReader(reader);
122  SetAnalysis(analysis);
123 }
124 
125 inline void StEStructAnalysisMaker::SetEventReader(StEStructEventReader* reader){
126  mreader = reader;
127 }
128 
129 inline void StEStructAnalysisMaker::SetAnalysis(StEStructAnalysis* analysis){
130  manalysis[numAnalysis]=analysis; numAnalysis++;
131 };
132 
133 inline void StEStructAnalysisMaker::SetAnalyses(StEStructAnalysis ** analyses, int n){
134  for(int i=0;i<n;i++) {
135  manalysis[i]=analyses[i];
136  manalysis[i]->setEventReader(mreader);
137  }
138  numAnalysis=n;
139 };
140 
141 inline void StEStructAnalysisMaker::SetQAHists(StEStructQAHists* qa){
142  if(!qa) return;
143  if(mQAHists)delete mQAHists;
144  mQAHists = qa;
145 }
146 
147 inline void StEStructAnalysisMaker::SetSorting(bool sort){
148  mSorting = sort;
149 }
150 
151 inline void StEStructAnalysisMaker::toggleMemoryInfo(){
152  if(doPrintMemoryInfo){
153  doPrintMemoryInfo=false;
154  return;
155  }
156  doPrintMemoryInfo=true;
157 }
158 
159 
160 inline int StEStructAnalysisMaker::getNumberOfEventsLooped(){ return mEventLoopCounter; }
161 inline int StEStructAnalysisMaker::getNumberOfEventsProcessed(){ return mEventProcessedCounter; }
162 
163 inline void StEStructAnalysisMaker::logCutStats(StEStructCuts* cuts, ostream& os, int index){
164  cuts->printCuts(os,index);
165 }
166 
167 
168 //-------------------------------------------------------------------
169 inline void StEStructAnalysisMaker::logAllStats(ostream& os){
170  logAnalysisTime(os);
171  logInputEvents(os);
172  logOutputEvents(os);
173  logOutputRate(os);
174  logAnalysisStats(os);
175 }
176 
177 inline void StEStructAnalysisMaker::logAnalysisTime(ostream& os){
178  if(!mtimer) return;
179  os<<"<processStat \"analysisTime\">"<<mtimer->elapsedTime();
180  os<<"</processStat>"<<endl;
181 }
182 
183 inline void StEStructAnalysisMaker::logInputEvents(ostream& os){
184  os<<"<processStat \"inputEvents\">"<<mEventLoopCounter;
185  os<<"</processStat>"<<endl;
186 }
187 
188 inline void StEStructAnalysisMaker::logOutputEvents(ostream& os){
189  os<<"<processStat \"outputEvents\">"<<mEventProcessedCounter;
190  os<<"</processStat>"<<endl;
191 }
192 
193 inline void StEStructAnalysisMaker::logOutputRate(ostream& os){
194  if(!mtimer || mtimer->elapsedTime()<0.01)return;
195 
196  os<<"<processStat \"outputRate\">"<<mEventProcessedCounter/mtimer->elapsedTime();
197  os<<"</processStat>"<<endl;
198 }
199 
200 inline void StEStructAnalysisMaker::logAnalysisStats(ostream& os){
201  for(int i=0;i<numAnalysis;i++) manalysis[i]->logStats(os);
202 }
203 
204 #endif
205 
206 /***********************************************************************
207  *
208  * $Log: StEStructAnalysisMaker.h,v $
209  * Revision 1.10 2015/08/29 03:23:47 perev
210  * __DATE
211  *
212  * Revision 1.9 2012/11/16 21:19:05 prindle
213  * Moved EventCuts, TrackCuts to EventReader. Affects most readers.
214  * Added support to write and read EStructEvents.
215  * Cuts: 3D histo support, switch to control filling of histogram for reading EStructEvents
216  * EventCuts: A few new cuts
217  * MuDstReader: Add 2D to some histograms, treat ToFCut, PrimaryCuts, VertexRadius histograms like other cut histograms.
218  * QAHists: Add refMult
219  * TrackCuts: Add some hijing cuts.
220  *
221  * Revision 1.8 2010/03/02 21:43:37 prindle
222  * Use outerHelix() for global tracks
223  * Add sensible triggerId histograms
224  * Starting to add support to sort events (available for Hijing)
225  *
226  * Revision 1.7 2006/04/26 18:48:58 dkettler
227  *
228  * Added reaction plane determination for the analysis
229  *
230  * Revision 1.6 2006/04/04 22:05:03 porter
231  * a handful of changes:
232  * - changed the StEStructAnalysisMaker to contain 1 reader not a list of readers
233  * - added StEStructQAHists object to contain histograms that did exist in macros or elsewhere
234  * - made centrality event cut taken from StEStructCentrality singleton
235  * - put in ability to get any max,min val from the cut class - one must call setRange in class
236  *
237  * Revision 1.5 2005/09/29 17:40:25 msd
238  * Changed empty analysis to create plots for determining centrality bins
239  *
240  * Revision 1.4 2005/09/14 17:08:27 msd
241  * Fixed compiler warnings, a few tweaks and upgrades
242  *
243  * Revision 1.3 2005/09/07 20:18:39 prindle
244  * AnalysisMaker: Keep track of currentAnalysis (for use in doEStruct macro)
245  * EventCuts.h: Added trigger cuts including cucu and year 4.
246  * MuDstReader: Added dE/dx histograms. Re-arranged code to count tracks
247  * before making centrality cut.
248  * TrackCuts: Random changes. Moved some variables from private to public.o
249  *
250  * Revision 1.2 2004/06/25 03:10:28 porter
251  * added a new common statistics output and added electron cut with momentum slices
252  *
253  * Revision 1.1 2003/10/15 18:20:32 porter
254  * initial check in of Estruct Analysis maker codes.
255  *
256  *
257  *********************************************************************/
258 
void Clear(Option_t *option="")
User defined functions.