]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemto/AliFemtoCutMonitorHandler.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemto / AliFemtoCutMonitorHandler.cxx
1 ///////////////////////////////////////////////////////////////////////////
2 //                                                                       //
3 // AliFemtoCutMonitorHandler: a handler for cut monitors                 //
4 // You add cut monitors to the collection which are stored in two        //
5 // separate collections - one which stores characteristics of the        //
6 // entities (tracks, particles, pairs, events) that pass the respective  //
7 // cuts and the other for the ones that fail the cut.                    //
8 //                                                                       //
9 ///////////////////////////////////////////////////////////////////////////
10
11 #include <TList.h>
12 #include "AliFemtoCutMonitorHandler.h"
13 #include "AliFemtoTypes.h"
14
15 #ifdef __ROOT__
16 ClassImp(AliFemtoCutMonitorHandler)
17 #endif
18 // ---------------------------------------------------------------------------
19 AliFemtoCutMonitorHandler::AliFemtoCutMonitorHandler():
20   fCollectionsEmpty(0), fPassColl(0), fFailColl(0)
21 {
22   // Default constructor
23   cout << " *** AliFemtoCutMonitorHandler::AliFemtoCutMonitorHandler() " << endl;
24   fCollectionsEmpty = 0;
25   fPassColl = new AliFemtoCutMonitorCollection();
26   fFailColl = new AliFemtoCutMonitorCollection();
27 }
28 // ---------------------------------------------------------------------------
29 AliFemtoCutMonitorHandler::AliFemtoCutMonitorHandler(const AliFemtoCutMonitorHandler& aHan):
30   fCollectionsEmpty(0), fPassColl(0), fFailColl(0)
31 {
32   // Copy constructor
33   fCollectionsEmpty = aHan.fCollectionsEmpty;
34   fPassColl = new AliFemtoCutMonitorCollection();
35   AliFemtoCutMonitorIterator iter;
36   for (iter=aHan.fPassColl->begin(); iter!=aHan.fPassColl->end(); iter++){
37     fPassColl->push_back(*iter);
38   }
39   fFailColl = new AliFemtoCutMonitorCollection();
40   for (iter=aHan.fFailColl->begin(); iter!=aHan.fFailColl->end(); iter++){
41     fFailColl->push_back(*iter);
42   }
43 }
44
45 // ---------------------------------------------------------------------------
46 AliFemtoCutMonitorHandler::~AliFemtoCutMonitorHandler() { 
47   // Default destructor
48   delete fPassColl;
49   delete fFailColl;
50 }   
51 //__________________________
52 AliFemtoCutMonitorHandler& AliFemtoCutMonitorHandler::operator=(const AliFemtoCutMonitorHandler& aHan)
53 {
54   // assignment operator
55   if (this == &aHan)
56     return *this;
57
58   AliFemtoCutMonitorIterator iter;
59   if (fPassColl) {
60     fPassColl->clear();
61     delete fPassColl;
62   }
63   if (fFailColl) {
64     fFailColl->clear();
65     delete fFailColl;
66   }
67   fPassColl = new AliFemtoCutMonitorCollection();
68   for (iter=aHan.fPassColl->begin(); iter!=aHan.fPassColl->end(); iter++){
69     fPassColl->push_back(*iter);
70   }
71   fFailColl = new AliFemtoCutMonitorCollection();
72   for (iter=aHan.fFailColl->begin(); iter!=aHan.fFailColl->end(); iter++){
73     fFailColl->push_back(*iter);
74   }
75   return *this;
76 }
77
78 // ---------------------------------------------------------------------------
79 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoEvent* event, bool pass) { 
80   // fill event cut monitors
81   if (fCollectionsEmpty) return;
82   AliFemtoCutMonitorIterator iter;
83   AliFemtoCutMonitor* tCM;
84   if ( pass) {
85     for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
86       tCM = *iter;
87       tCM->Fill(event);
88     }
89   } else {
90     for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
91       tCM = *iter;
92       tCM->Fill(event);
93     }
94   }
95 }
96 // ---------------------------------------------------------------------------
97 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoTrack* track, bool pass) { 
98   // Fill track cut monitors
99   if (fCollectionsEmpty) return;
100   AliFemtoCutMonitorIterator iter;
101   AliFemtoCutMonitor* tCM;
102   if ( pass) {
103     for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
104       tCM = *iter;
105       tCM->Fill(track);
106     }
107   } else {
108     for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
109       tCM = *iter;
110       tCM->Fill(track);
111     }
112   }
113 }
114 // ---------------------------------------------------------------------------
115 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoV0* v0, bool pass) { 
116   // fill V0 cut monitors
117   if (fCollectionsEmpty) return;
118   AliFemtoCutMonitorIterator iter;
119   AliFemtoCutMonitor* tCM;
120   if ( pass) {
121     for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
122       tCM = *iter;
123       tCM->Fill(v0);
124     }
125   } else {
126     for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
127       tCM = *iter;
128       tCM->Fill(v0);
129     }
130   }
131 }
132 // ---------------------------------------------------------------------------
133 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoKink* kink, bool pass) { 
134   // fill kink cut monitors
135   if (fCollectionsEmpty) return;
136   AliFemtoCutMonitorIterator iter;
137   AliFemtoCutMonitor* tCM;
138   if ( pass) {
139     for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
140       tCM = *iter;
141       tCM->Fill(kink);
142     }
143   } else {
144     for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
145       tCM = *iter;
146       tCM->Fill(kink);
147     }
148   }
149 }
150 // ---------------------------------Gael/12/04/02-----------------------------
151 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoPair* pair, bool pass) { 
152   // fill pair cut monitors
153   if (fCollectionsEmpty) return;
154   AliFemtoCutMonitorIterator iter;
155   AliFemtoCutMonitor* tCM;
156   if ( pass) {
157     for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
158       tCM = *iter;
159       tCM->Fill(pair);
160     }
161   } else {
162     for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
163       tCM = *iter;
164       tCM->Fill(pair);
165     }
166   }
167 }
168 // ---------------------------------Gael/19/06/02-----------------------------
169 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoParticleCollection* partColl) {
170   // fill particle collection cut monitor 
171   if (fCollectionsEmpty) return;
172   AliFemtoCutMonitorIterator iter;
173   AliFemtoCutMonitor* tCM;
174   
175   for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
176     tCM = *iter;
177     tCM->Fill(partColl);
178   }
179 }
180 // ------------------------------------Gael/19/06/02-------------------------
181 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoEvent* event,const AliFemtoParticleCollection* partColl) {
182   // Fill event particle collection
183   //cout<<"In AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoEvent* event, AliFemtoPicoEvent* picoEvent)"<<endl;
184   if (fCollectionsEmpty) return;
185   AliFemtoCutMonitorIterator iter;
186   AliFemtoCutMonitor* tCM;
187   
188   for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
189     tCM = *iter;
190     tCM->Fill(event,partColl);
191   }
192 }
193
194 void AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoParticleCollection* partColl1, const AliFemtoParticleCollection* partColl2) {
195   // Fill event particle collection
196   //cout<<"***In AliFemtoCutMonitorHandler::FillCutMonitor(const AliFemtoEvent* event, AliFemtoPicoEvent* picoEvent)"<<endl;
197   if (fCollectionsEmpty) return;
198   AliFemtoCutMonitorIterator iter;
199   AliFemtoCutMonitor* tCM;
200   
201   for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
202     tCM = *iter;
203     tCM->Fill(partColl1,partColl2);
204   }
205 }
206
207 // ---------------------------------------------------------------------------
208 void AliFemtoCutMonitorHandler::Finish() { 
209   // Perform finish operations on cut monitors
210   AliFemtoCutMonitorIterator iter;
211   for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
212     (*iter)->Finish();
213   }
214   for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
215     (*iter)->Finish();
216   }
217 }
218 // ---------------------------------------------------------------------------
219 void AliFemtoCutMonitorHandler::AddCutMonitor(AliFemtoCutMonitor* cutMoni1, AliFemtoCutMonitor* cutMoni2) { 
220   // Add cut monitors to collections
221   fPassColl->push_back(cutMoni1);
222   fFailColl->push_back(cutMoni2);
223   fCollectionsEmpty=false;
224 }
225 // ---------------------------------------------------------------------------
226 void AliFemtoCutMonitorHandler::AddCutMonitor(AliFemtoCutMonitor* cutMoni) { 
227   // make a copy of the cut monitor
228   cout << " make a copy of the cutmonitor and push both into the collections " << endl;
229   cout << " not yet implemented" << endl;
230   fPassColl->push_back(cutMoni);
231   cout << " only pass collection pushed" << endl;
232   fCollectionsEmpty=false;
233 }
234 // ---------------------------------------------------------------------------
235 void AliFemtoCutMonitorHandler::AddCutMonitorPass(AliFemtoCutMonitor* cutMoni) { 
236   // add monitors to pass
237   fPassColl->push_back(cutMoni);
238   fCollectionsEmpty=false;
239 }
240 // ---------------------------------------------------------------------------
241 void AliFemtoCutMonitorHandler::AddCutMonitorFail(AliFemtoCutMonitor* cutMoni) { 
242   // add monitors to fail
243   fFailColl->push_back(cutMoni);
244   fCollectionsEmpty=false;
245 }
246 // ---------------------------------------------------------------------------
247 AliFemtoCutMonitor* AliFemtoCutMonitorHandler::PassMonitor(int n) { 
248   // return pass monitor number n
249   AliFemtoCutMonitorIterator iter = fPassColl->begin();
250   if ( (int)fPassColl->size() <= n ) return NULL;
251   for ( int i=0; i<n; i++)
252     iter++;
253   return *iter;
254 }
255 // ---------------------------------------------------------------------------
256 AliFemtoCutMonitor* AliFemtoCutMonitorHandler::FailMonitor(int n) { 
257   // return fail monitor number n
258   AliFemtoCutMonitorIterator iter = fFailColl->begin();
259   if ( (int)fFailColl->size() <= n ) return NULL;
260   for ( int i=0; i<n; i++)
261     iter++;
262   return *iter;
263 }
264 //_____________________________________________________________________________
265 TList *AliFemtoCutMonitorHandler::GetOutputList()
266 {
267   TList *tOutputList = new TList();
268
269   for (unsigned int ipass=0; ipass<fPassColl->size(); ipass++) {
270     TList *tLp = PassMonitor(ipass)->GetOutputList();
271
272     TIter nextLp(tLp);
273     while (TObject *obj = nextLp()) {
274       tOutputList->Add(obj);
275     }
276     
277     delete tLp;
278   }
279
280   for (unsigned int ipass=0; ipass<fFailColl->size(); ipass++) {
281     TList *tLf = FailMonitor(ipass)->GetOutputList();
282
283     TIter nextLf(tLf);
284     while (TObject *obj = nextLf()) {
285       tOutputList->Add(obj);
286     }
287     
288     delete tLf;
289   }
290
291   return tOutputList;
292 }
293 //_____________________________________________________________________________
294 void AliFemtoCutMonitorHandler::EventBegin(const AliFemtoEvent* aEvent) 
295
296   if (fCollectionsEmpty) return;
297
298   AliFemtoCutMonitorIterator iter;
299   AliFemtoCutMonitor* tCM;
300
301   for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
302     tCM = *iter;
303     tCM->EventBegin(aEvent);
304   }
305   
306   for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
307     tCM = *iter;
308     tCM->EventBegin(aEvent);
309   }
310 }
311 //_____________________________________________________________________________
312 void AliFemtoCutMonitorHandler::EventEnd(const AliFemtoEvent* aEvent) 
313
314   if (fCollectionsEmpty) return;
315
316   AliFemtoCutMonitorIterator iter;
317   AliFemtoCutMonitor* tCM;
318
319   for (iter=fPassColl->begin(); iter!=fPassColl->end(); iter++){
320     tCM = *iter;
321     tCM->EventEnd(aEvent);
322   }
323   
324   for (iter=fFailColl->begin(); iter!=fFailColl->end(); iter++){
325     tCM = *iter;
326     tCM->EventEnd(aEvent);
327   }
328 }
329
330
331  
332