]>
Commit | Line | Data |
---|---|---|
8f8eda94 | 1 | /**************************************************************************\r |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r | |
3 | * *\r | |
4 | * Author: The ALICE Off-line Project. *\r | |
5 | * Contributors are mentioned in the code where appropriate. *\r | |
6 | * *\r | |
7 | * Permission to use, copy, modify and distribute this software and its *\r | |
8 | * documentation strictly for non-commercial purposes is hereby granted *\r | |
9 | * without fee, provided that the above copyright notice appears in all *\r | |
10 | * copies and that both the copyright notice and this permission notice *\r | |
11 | * appear in the supporting documentation. The authors make no claims *\r | |
12 | * about the suitability of this software for any purpose. It is *\r | |
13 | * provided "as is" without express or implied warranty. *\r | |
14 | **************************************************************************/\r | |
15 | /* $Id: $ */\r | |
16 | \r | |
17 | //_________________________________________________________________________\r | |
18 | // Count events with different selections\r | |
19 | //\r | |
20 | // It produces a histogram with the number of events with 9 bins:\r | |
21 | // 0: all events (that passed the physics selection if it was on)\r | |
22 | // 1: same but cross check that event pointer did exist\r | |
23 | // 2: passes vertex cut\r | |
24 | // 3: passes track number cut, tracks for eta < 0.8\r | |
25 | // 4: 3 && 2\r | |
26 | // 5: pass VAND\r | |
27 | // 6: 5 && 2\r | |
28 | // 7: 5 && 3\r | |
29 | // 8: 5 && 3 && 2\r | |
30 | // 9: not pileup from SPD\r | |
31 | // 10: Good vertex\r | |
32 | // 11: 10 && 5\r | |
33 | // 12: 10 && 3\r | |
34 | // 13: 10 && 2\r | |
35 | // 14: 10 && 2 && 3 && 5\r | |
36 | // 15: 10 && 9\r | |
37 | // 16: 9 && 5\r | |
38 | //\r | |
39 | // Author: Gustavo Conesa Balbastre (LPSC)\r | |
40 | // \r | |
41 | //_________________________________________________________________________\r | |
42 | \r | |
43 | #include "TH2F.h"\r | |
44 | #include "AliAODHeader.h"\r | |
45 | #include "AliTriggerAnalysis.h"\r | |
46 | #include "AliESDEvent.h"\r | |
47 | #include "AliESDtrackCuts.h"\r | |
48 | #include "AliAnalysisManager.h"\r | |
49 | #include "AliInputEventHandler.h"\r | |
50 | \r | |
51 | #include "AliAnalysisTaskCounter.h"\r | |
52 | ClassImp(AliAnalysisTaskCounter)\r | |
53 | \r | |
54 | //________________________________________________________________________\r | |
55 | AliAnalysisTaskCounter::AliAnalysisTaskCounter(const char *name) \r | |
56 | : AliAnalysisTaskSE(name), \r | |
57 | fZVertexCut(10.),\r | |
58 | fTrackMultEtaCut(0.8),\r | |
59 | fCaloFilterPatch(kFALSE),\r | |
60 | fOutputContainer(0x0), \r | |
61 | fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),\r | |
62 | fTriggerAnalysis (new AliTriggerAnalysis),\r | |
63 | fhNEvents(0),\r | |
64 | fhXVertex(0),fhYVertex(0),fhZVertex(0),\r | |
65 | fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0)\r | |
66 | {\r | |
67 | //ctor\r | |
68 | DefineOutput(1, TList::Class());\r | |
69 | }\r | |
70 | \r | |
71 | //________________________________________________________________________\r | |
72 | AliAnalysisTaskCounter::AliAnalysisTaskCounter() \r | |
73 | : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskCounter"),\r | |
74 | fZVertexCut(10.),\r | |
75 | fTrackMultEtaCut(0.8),\r | |
76 | fCaloFilterPatch(kFALSE),\r | |
77 | fOutputContainer(0x0), \r | |
78 | fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),\r | |
79 | fTriggerAnalysis (new AliTriggerAnalysis),\r | |
80 | fhNEvents(0),\r | |
81 | fhXVertex(0),fhYVertex(0),fhZVertex(0),\r | |
82 | fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0)\r | |
83 | {\r | |
84 | // ctor\r | |
85 | DefineOutput(1, TList::Class());\r | |
86 | }\r | |
87 | \r | |
88 | //__________________________________________________\r | |
89 | AliAnalysisTaskCounter::~AliAnalysisTaskCounter()\r | |
90 | {\r | |
91 | //Destructor\r | |
92 | if(fOutputContainer){\r | |
93 | fOutputContainer->Delete() ; \r | |
94 | delete fOutputContainer ;\r | |
95 | }\r | |
96 | \r | |
97 | if(fESDtrackCuts) delete fESDtrackCuts;\r | |
98 | if(fTriggerAnalysis) delete fTriggerAnalysis;\r | |
99 | \r | |
100 | }\r | |
101 | \r | |
102 | \r | |
103 | //-------------------------------------------------------------------\r | |
104 | void AliAnalysisTaskCounter::UserCreateOutputObjects()\r | |
105 | {\r | |
106 | // Init histograms\r | |
107 | \r | |
108 | fOutputContainer = new TList();\r | |
109 | \r | |
110 | fhZVertex = new TH1F("hZVertex", " Z vertex distribution" , 200 , -50 , 50 ) ;\r | |
111 | fhZVertex->SetXTitle("v_{z} (cm)");\r | |
112 | fOutputContainer->Add(fhZVertex);\r | |
113 | \r | |
114 | fhZGoodVertex = new TH1F("hZGoodVertex", " Good Z vertex distribution" , 200 , -50 , 50 ) ;\r | |
115 | fhZGoodVertex->SetXTitle("v_{z} (cm)");\r | |
116 | fOutputContainer->Add(fhZGoodVertex);\r | |
117 | \r | |
118 | fhXVertex = new TH1F("hXVertex", " X vertex distribution" , 200 , -2 , 2 ) ;\r | |
119 | fhXVertex->SetXTitle("v_{x} (cm)");\r | |
120 | fOutputContainer->Add(fhXVertex);\r | |
121 | \r | |
122 | fhXGoodVertex = new TH1F("hXGoodVertex", " Good X vertex distribution" , 200 , -2 , 2 ) ;\r | |
123 | fhXGoodVertex->SetXTitle("v_{x} (cm)");\r | |
124 | fOutputContainer->Add(fhXGoodVertex);\r | |
125 | \r | |
126 | fhYVertex = new TH1F("hYVertex", " Y vertex distribution" , 200 , -2 , 2 ) ;\r | |
127 | fhYVertex->SetXTitle("v_{y} (cm)");\r | |
128 | fOutputContainer->Add(fhYVertex);\r | |
129 | \r | |
130 | fhYGoodVertex = new TH1F("hYGoodVertex", " Good Y vertex distribution" , 200 , -2 , 2 ) ;\r | |
131 | fhYGoodVertex->SetXTitle("v_{y} (cm)");\r | |
132 | fOutputContainer->Add(fhYGoodVertex);\r | |
133 | \r | |
134 | \r | |
135 | fhNEvents = new TH1I("hNEvents", "Number of analyzed events", 17, 0, 17) ;\r | |
136 | fhNEvents->SetXTitle("Selection");\r | |
137 | fhNEvents->SetYTitle("# events");\r | |
138 | fhNEvents->GetXaxis()->SetBinLabel(1 ,"1 = PS");\r | |
139 | fhNEvents->GetXaxis()->SetBinLabel(2 ,"2 = 1 & ESD");\r | |
140 | fhNEvents->GetXaxis()->SetBinLabel(3 ,"3 = 2 & |Z|<10");\r | |
141 | fhNEvents->GetXaxis()->SetBinLabel(4 ,"4 = 2 & |eta|<0.8");\r | |
142 | fhNEvents->GetXaxis()->SetBinLabel(5 ,"5 = 3 & 4");\r | |
143 | fhNEvents->GetXaxis()->SetBinLabel(6 ,"6 = 2 & V0AND");\r | |
144 | fhNEvents->GetXaxis()->SetBinLabel(7 ,"7 = 3 & 6");\r | |
145 | fhNEvents->GetXaxis()->SetBinLabel(8 ,"8 = 4 & 6");\r | |
146 | fhNEvents->GetXaxis()->SetBinLabel(9 ,"9 = 5 & 6");\r | |
147 | fhNEvents->GetXaxis()->SetBinLabel(10,"10 = 2 & not pileup");\r | |
148 | fhNEvents->GetXaxis()->SetBinLabel(11,"11 = 2 & good vertex");\r | |
149 | fhNEvents->GetXaxis()->SetBinLabel(12,"12 = 3 & 11");\r | |
150 | fhNEvents->GetXaxis()->SetBinLabel(13,"13 = 4 & 11");\r | |
151 | fhNEvents->GetXaxis()->SetBinLabel(14,"14 = 6 & 11");\r | |
152 | fhNEvents->GetXaxis()->SetBinLabel(15,"15 = 9 & 11");\r | |
153 | fhNEvents->GetXaxis()->SetBinLabel(16,"16 = 10 & 11");\r | |
154 | fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 6 & 10");\r | |
155 | \r | |
156 | fOutputContainer->Add(fhNEvents);\r | |
157 | \r | |
158 | fOutputContainer->SetOwner(kTRUE);\r | |
159 | \r | |
160 | PostData(1,fOutputContainer);\r | |
161 | \r | |
162 | }\r | |
163 | \r | |
164 | //________________________________________________________________________\r | |
165 | void AliAnalysisTaskCounter::UserExec(Option_t *) \r | |
166 | {\r | |
167 | // Main loop\r | |
168 | // Called for each event\r | |
169 | \r | |
170 | //printf("___ Event __ %d __\n",(Int_t)Entry());\r | |
171 | \r | |
172 | fhNEvents->Fill(0.5); \r | |
173 | \r | |
174 | AliVEvent * event = InputEvent();\r | |
175 | if (!event) {\r | |
176 | printf("AliAnalysisTaskCounter::UserExec() - ERROR: event not available \n");\r | |
177 | return;\r | |
178 | }\r | |
179 | AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (event);\r | |
180 | \r | |
181 | fhNEvents->Fill(1.5); \r | |
182 | \r | |
183 | //Initialize bools\r | |
184 | Bool_t bSelectVZ = kFALSE;\r | |
185 | Bool_t bV0AND = kFALSE; \r | |
186 | Bool_t bPileup = kFALSE;\r | |
187 | Bool_t bGoodV = kFALSE;\r | |
188 | Bool_t bSelectTrack = kFALSE; \r | |
189 | Int_t trackMult = 0;\r | |
190 | \r | |
191 | //---------------------------------\r | |
192 | //Get the primary vertex, cut on Z\r | |
193 | //---------------------------------\r | |
194 | Double_t v[3];\r | |
195 | event->GetPrimaryVertex()->GetXYZ(v) ;\r | |
196 | fhXVertex->Fill(v[0]);\r | |
197 | fhYVertex->Fill(v[1]);\r | |
198 | fhZVertex->Fill(v[2]);\r | |
199 | \r | |
200 | if(TMath::Abs(v[2]) < fZVertexCut) {\r | |
201 | bSelectVZ=kTRUE;\r | |
202 | fhNEvents->Fill(2.5); \r | |
203 | }\r | |
204 | //else printf("Vertex out %f \n",v[2]);\r | |
205 | \r | |
206 | \r | |
207 | //--------------------------------------------------\r | |
208 | //Tweak for calorimeter only productions\r | |
209 | //--------------------------------------------------\r | |
210 | if(fCaloFilterPatch && !esdevent){ \r | |
211 | if(event->GetNumberOfCaloClusters() > 0) {\r | |
212 | AliVCluster * calo = event->GetCaloCluster(0);\r | |
213 | if(calo->GetNLabels() == 4){\r | |
214 | Int_t * selection = calo->GetLabels();\r | |
215 | bPileup = selection[0];\r | |
216 | bGoodV = selection[1]; \r | |
217 | bV0AND = selection[2]; \r | |
218 | trackMult = selection[3];\r | |
219 | //if(selection[0] || selection[1] || selection[2])\r | |
220 | //printf(" pu %d, gv %d, v0 %d, track mult %d\n ", selection[0], selection[1], selection[2], selection[3]);\r | |
221 | if(trackMult > 0 ) \r | |
222 | bSelectTrack = kFALSE;\r | |
223 | } else {\r | |
224 | //First filtered AODs, track multiplicity stored there. \r | |
225 | trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();\r | |
226 | }\r | |
227 | }else{//at least one cluster\r | |
228 | //printf("AliAnalysisTaskCounter::UserExec() - No clusters in event\n");\r | |
229 | //Remove events with vertex (0,0,0), bad vertex reconstruction\r | |
230 | if(TMath::Abs(v[0]) < 1.e-6 && TMath::Abs(v[1]) < 1.e-6 && TMath::Abs(v[2]) < 1.e-6) bGoodV = kFALSE;\r | |
231 | \r | |
232 | //First filtered AODs, track multiplicity stored there. \r | |
233 | trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();\r | |
234 | }\r | |
235 | }\r | |
236 | else {\r | |
237 | //--------------------------------------------------\r | |
238 | //Count tracks, cut on number of tracks in eta < 0.8\r | |
239 | //--------------------------------------------------\r | |
240 | Int_t nTracks = event->GetNumberOfTracks() ;\r | |
241 | for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop\r | |
242 | AliVTrack * track = (AliVTrack*)event->GetTrack(itrack) ; // retrieve track from esd\r | |
243 | \r | |
244 | //Only for ESDs\r | |
245 | if(esdevent && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;\r | |
246 | \r | |
247 | //Do not count tracks out of acceptance cut\r | |
248 | if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++;\r | |
249 | }\r | |
250 | }\r | |
251 | \r | |
252 | //printf("AliAnalysisTaskCounter::UserExec() - Track Mult %d \n",trackMult);\r | |
253 | \r | |
254 | //--------------------------------------------------\r | |
255 | // At least one track\r | |
256 | //--------------------------------------------------\r | |
257 | if (trackMult > 0) {\r | |
258 | bSelectTrack = kTRUE; \r | |
259 | fhNEvents->Fill(3.5);\r | |
260 | if(bSelectVZ) fhNEvents->Fill(4.5);\r | |
261 | }\r | |
262 | \r | |
263 | //---------------------------------\r | |
264 | // V0AND\r | |
265 | //---------------------------------\r | |
266 | if(esdevent && !fCaloFilterPatch) bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esdevent, AliTriggerAnalysis::kV0AND);\r | |
267 | //else if(aodevent && !fCaloFilterPatch) bV0AND = //FIXME FOR AODs\r | |
268 | \r | |
269 | if(bV0AND)\r | |
270 | {\r | |
271 | fhNEvents->Fill(5.5);\r | |
272 | if (bSelectVZ) fhNEvents->Fill(6.5);\r | |
273 | if (bSelectTrack) fhNEvents->Fill(7.5);\r | |
274 | if (bSelectVZ && bSelectTrack) fhNEvents->Fill(8.5);\r | |
275 | }\r | |
276 | \r | |
277 | //---------------------------------\r | |
278 | // Pileup\r | |
279 | //---------------------------------\r | |
280 | if(!fCaloFilterPatch)\r | |
281 | bPileup = event->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile\r | |
282 | //bPileup = event->IsPileupFromSPD(); \r | |
283 | if (!bPileup){\r | |
284 | fhNEvents->Fill(9.5);\r | |
285 | if(bV0AND) fhNEvents->Fill(16.5);\r | |
286 | }\r | |
287 | \r | |
288 | //---------------------------------\r | |
289 | // Good vertex\r | |
290 | //---------------------------------\r | |
291 | if(esdevent && !fCaloFilterPatch) bGoodV = CheckForPrimaryVertex();\r | |
292 | if(bGoodV) \r | |
293 | {\r | |
294 | fhXGoodVertex->Fill(v[0]);\r | |
295 | fhYGoodVertex->Fill(v[1]);\r | |
296 | fhZGoodVertex->Fill(v[2]);\r | |
297 | \r | |
298 | fhNEvents->Fill(10.5);\r | |
299 | if(bSelectVZ) fhNEvents->Fill(11.5);\r | |
300 | if(bSelectTrack) fhNEvents->Fill(12.5);\r | |
301 | if(bV0AND) fhNEvents->Fill(13.5);\r | |
302 | if(bSelectVZ && bSelectTrack && bV0AND) \r | |
303 | fhNEvents->Fill(14.5); \r | |
304 | if(!bPileup) fhNEvents->Fill(15.5); \r | |
305 | }\r | |
306 | \r | |
307 | //printf("AliAnalysisTaskCounter::UserExec() : z vertex %d, good vertex %d, v0and %d, pile up %d, track mult %d\n ", bSelectVZ, bGoodV, bV0AND, bPileup, trackMult);\r | |
308 | \r | |
309 | PostData(1,fOutputContainer);\r | |
310 | \r | |
311 | }\r | |
312 | \r | |
313 | //____________________________________________________________________________\r | |
314 | Bool_t AliAnalysisTaskCounter::CheckForPrimaryVertex(){\r | |
315 | //Check if the vertex was well reconstructed, copy from V0Reader of conversion group\r | |
316 | //It only works for ESDs\r | |
317 | \r | |
318 | AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent());\r | |
ad30b142 | 319 | if(!event) return 0;\r |
320 | \r | |
8f8eda94 | 321 | if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {\r |
322 | return 1;\r | |
323 | }\r | |
324 | \r | |
325 | if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {\r | |
326 | // SPD vertex\r | |
327 | if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {\r | |
328 | //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;\r | |
329 | return 1;\r | |
330 | \r | |
331 | }\r | |
332 | if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {\r | |
333 | // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;\r | |
334 | return 0;\r | |
335 | }\r | |
336 | }\r | |
337 | return 0;\r | |
338 | //return fInputEvent->GetPrimaryVertex()->GetNContributors()>0;\r | |
339 | }\r | |
340 | \r | |
341 | \r | |
342 | \r | |
343 | //_____________________________________________________\r | |
344 | void AliAnalysisTaskCounter::FinishTaskOutput()\r | |
345 | {\r | |
346 | // Put in the output some event summary histograms\r | |
347 | \r | |
348 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();\r | |
349 | AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());\r | |
350 | if (!inputH) return; \r | |
351 | TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics()); \r | |
352 | TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));\r | |
353 | \r | |
354 | if(histStat)\r | |
355 | fOutputContainer->Add(histStat);\r | |
356 | else\r | |
357 | printf("AliAnalysisTaskCounter::FinishTaskOutput() - Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists \n");\r | |
358 | \r | |
359 | if(histBin0)\r | |
360 | fOutputContainer->Add(histBin0); \r | |
361 | \r | |
362 | }\r |