]>
Commit | Line | Data |
---|---|---|
0b080dc9 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
dd094cf8 | 4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
dd094cf8 | 15 | |
16 | //_________________________________________________________________________ | |
17 | // Count events with different selections | |
18 | // | |
19 | // It produces a histogram with the number of events with 9 bins: | |
20 | // 0: all events (that passed the physics selection if it was on) | |
21 | // 1: same but cross check that event pointer did exist | |
22 | // 2: passes vertex cut | |
23 | // 3: passes track number cut, tracks for eta < 0.8 | |
24 | // 4: 3 && 2 | |
25 | // 5: pass VAND | |
26 | // 6: 5 && 2 | |
27 | // 7: 5 && 3 | |
28 | // 8: 5 && 3 && 2 | |
29 | // 9: not pileup from SPD | |
30 | // 10: Good vertex | |
31 | // 11: 10 && 5 | |
32 | // 12: 10 && 3 | |
33 | // 13: 10 && 2 | |
34 | // 14: 10 && 2 && 3 && 5 | |
35 | // 15: 10 && 9 | |
36 | // 16: 9 && 5 | |
37 | // | |
38 | // Author: Gustavo Conesa Balbastre (LPSC) | |
39 | // | |
40 | //_________________________________________________________________________ | |
46f9f991 | 41 | #include <TSystem.h> |
42 | #include <TFile.h> | |
43 | #include <TKey.h> | |
44 | #include <TH2F.h> | |
45 | #include <TProfile.h> | |
46 | #include <TProfile2D.h> | |
47 | #include <TList.h> | |
48 | #include <TClonesArray.h> | |
dd094cf8 | 49 | #include "AliAODHeader.h" |
50 | #include "AliTriggerAnalysis.h" | |
51 | #include "AliESDEvent.h" | |
cd2e4ce6 | 52 | #include "AliAODEvent.h" |
dd094cf8 | 53 | #include "AliESDtrackCuts.h" |
54 | #include "AliAnalysisManager.h" | |
55 | #include "AliInputEventHandler.h" | |
56 | ||
57 | #include "AliAnalysisTaskCounter.h" | |
58 | ClassImp(AliAnalysisTaskCounter) | |
59 | ||
0de1814a | 60 | //______________________________________________________________ |
dd094cf8 | 61 | AliAnalysisTaskCounter::AliAnalysisTaskCounter(const char *name) |
62 | : AliAnalysisTaskSE(name), | |
cd2e4ce6 | 63 | fAcceptFastCluster(kTRUE), |
64 | fZVertexCut(10.), | |
dd094cf8 | 65 | fTrackMultEtaCut(0.8), |
46f9f991 | 66 | fAvgTrials(-1), |
997b261e | 67 | fOutputContainer(0x0), |
dd094cf8 | 68 | fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()), |
69 | fTriggerAnalysis (new AliTriggerAnalysis), | |
46f9f991 | 70 | fCurrFileName(0), |
71 | fhNEvents(0), | |
cd2e4ce6 | 72 | fhXVertex(0), fhYVertex(0), fhZVertex(0), |
e19ca838 | 73 | fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0), |
46f9f991 | 74 | fhCentrality(0), fhEventPlaneAngle(0), |
75 | fh1Xsec(0), fh1Trials(0) | |
dd094cf8 | 76 | { |
77 | //ctor | |
78 | DefineOutput(1, TList::Class()); | |
79 | } | |
80 | ||
0de1814a | 81 | //______________________________________________ |
dd094cf8 | 82 | AliAnalysisTaskCounter::AliAnalysisTaskCounter() |
83 | : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskCounter"), | |
cd2e4ce6 | 84 | fAcceptFastCluster(kTRUE), |
dd094cf8 | 85 | fZVertexCut(10.), |
86 | fTrackMultEtaCut(0.8), | |
46f9f991 | 87 | fAvgTrials(-1), |
997b261e | 88 | fOutputContainer(0x0), |
dd094cf8 | 89 | fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()), |
90 | fTriggerAnalysis (new AliTriggerAnalysis), | |
46f9f991 | 91 | fCurrFileName(0), |
dd094cf8 | 92 | fhNEvents(0), |
cd2e4ce6 | 93 | fhXVertex(0), fhYVertex(0), fhZVertex(0), |
e19ca838 | 94 | fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0), |
46f9f991 | 95 | fhCentrality(0), fhEventPlaneAngle(0), |
96 | fh1Xsec(0), fh1Trials(0) | |
dd094cf8 | 97 | { |
98 | // ctor | |
99 | DefineOutput(1, TList::Class()); | |
100 | } | |
101 | ||
102 | //__________________________________________________ | |
103 | AliAnalysisTaskCounter::~AliAnalysisTaskCounter() | |
104 | { | |
105 | //Destructor | |
0792da48 | 106 | |
107 | if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return; | |
108 | ||
109 | if(fOutputContainer) | |
110 | { | |
dd094cf8 | 111 | fOutputContainer->Delete() ; |
112 | delete fOutputContainer ; | |
113 | } | |
114 | ||
115 | if(fESDtrackCuts) delete fESDtrackCuts; | |
116 | if(fTriggerAnalysis) delete fTriggerAnalysis; | |
117 | ||
118 | } | |
119 | ||
120 | ||
0de1814a | 121 | //____________________________________________________ |
dd094cf8 | 122 | void AliAnalysisTaskCounter::UserCreateOutputObjects() |
123 | { | |
124 | // Init histograms | |
125 | ||
126 | fOutputContainer = new TList(); | |
127 | ||
46f9f991 | 128 | fh1Xsec = new TH1F("hXsec","xsec from pyxsec.root",1,0,1); |
129 | fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>"); | |
130 | fOutputContainer->Add(fh1Xsec); | |
131 | ||
132 | fh1Trials = new TH1F("hTrials","trials root file",1,0,1); | |
133 | fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}"); | |
134 | fOutputContainer->Add(fh1Trials); | |
135 | ||
dd094cf8 | 136 | fhZVertex = new TH1F("hZVertex", " Z vertex distribution" , 200 , -50 , 50 ) ; |
137 | fhZVertex->SetXTitle("v_{z} (cm)"); | |
138 | fOutputContainer->Add(fhZVertex); | |
139 | ||
140 | fhZGoodVertex = new TH1F("hZGoodVertex", " Good Z vertex distribution" , 200 , -50 , 50 ) ; | |
141 | fhZGoodVertex->SetXTitle("v_{z} (cm)"); | |
142 | fOutputContainer->Add(fhZGoodVertex); | |
143 | ||
144 | fhXVertex = new TH1F("hXVertex", " X vertex distribution" , 200 , -2 , 2 ) ; | |
145 | fhXVertex->SetXTitle("v_{x} (cm)"); | |
146 | fOutputContainer->Add(fhXVertex); | |
147 | ||
148 | fhXGoodVertex = new TH1F("hXGoodVertex", " Good X vertex distribution" , 200 , -2 , 2 ) ; | |
149 | fhXGoodVertex->SetXTitle("v_{x} (cm)"); | |
150 | fOutputContainer->Add(fhXGoodVertex); | |
151 | ||
152 | fhYVertex = new TH1F("hYVertex", " Y vertex distribution" , 200 , -2 , 2 ) ; | |
153 | fhYVertex->SetXTitle("v_{y} (cm)"); | |
154 | fOutputContainer->Add(fhYVertex); | |
155 | ||
156 | fhYGoodVertex = new TH1F("hYGoodVertex", " Good Y vertex distribution" , 200 , -2 , 2 ) ; | |
157 | fhYGoodVertex->SetXTitle("v_{y} (cm)"); | |
158 | fOutputContainer->Add(fhYGoodVertex); | |
159 | ||
e19ca838 | 160 | fhCentrality = new TH1F("hCentrality","Number of events in centrality bin, |vz|<10 cm, method <V0M> ",100,0.,100.) ; |
161 | fhCentrality->SetXTitle("Centrality bin"); | |
162 | fOutputContainer->Add(fhCentrality) ; | |
dd094cf8 | 163 | |
0792da48 | 164 | fhEventPlaneAngle=new TH1F("hEventPlaneAngle","Number of events in event plane, |vz|<10 cm, method <V0> ",100,0.,TMath::Pi()) ; |
165 | fhEventPlaneAngle->SetXTitle("EP angle (rad)"); | |
166 | fOutputContainer->Add(fhEventPlaneAngle) ; | |
167 | ||
cd2e4ce6 | 168 | fhNEvents = new TH1I("hNEvents", "Number of analyzed events", 21, 0, 21) ; |
dd094cf8 | 169 | fhNEvents->SetXTitle("Selection"); |
170 | fhNEvents->SetYTitle("# events"); | |
171 | fhNEvents->GetXaxis()->SetBinLabel(1 ,"1 = PS"); | |
172 | fhNEvents->GetXaxis()->SetBinLabel(2 ,"2 = 1 & ESD"); | |
173 | fhNEvents->GetXaxis()->SetBinLabel(3 ,"3 = 2 & |Z|<10"); | |
174 | fhNEvents->GetXaxis()->SetBinLabel(4 ,"4 = 2 & |eta|<0.8"); | |
175 | fhNEvents->GetXaxis()->SetBinLabel(5 ,"5 = 3 & 4"); | |
176 | fhNEvents->GetXaxis()->SetBinLabel(6 ,"6 = 2 & V0AND"); | |
177 | fhNEvents->GetXaxis()->SetBinLabel(7 ,"7 = 3 & 6"); | |
178 | fhNEvents->GetXaxis()->SetBinLabel(8 ,"8 = 4 & 6"); | |
179 | fhNEvents->GetXaxis()->SetBinLabel(9 ,"9 = 5 & 6"); | |
180 | fhNEvents->GetXaxis()->SetBinLabel(10,"10 = 2 & not pileup"); | |
181 | fhNEvents->GetXaxis()->SetBinLabel(11,"11 = 2 & good vertex"); | |
182 | fhNEvents->GetXaxis()->SetBinLabel(12,"12 = 3 & 11"); | |
183 | fhNEvents->GetXaxis()->SetBinLabel(13,"13 = 4 & 11"); | |
184 | fhNEvents->GetXaxis()->SetBinLabel(14,"14 = 6 & 11"); | |
185 | fhNEvents->GetXaxis()->SetBinLabel(15,"15 = 9 & 11"); | |
186 | fhNEvents->GetXaxis()->SetBinLabel(16,"16 = 10 & 11"); | |
187 | fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 6 & 10"); | |
0b080dc9 | 188 | fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 1 & |Z|<50"); |
cd2e4ce6 | 189 | fhNEvents->GetXaxis()->SetBinLabel(18,"18 = Reject EMCAL 1"); |
0b080dc9 | 190 | fhNEvents->GetXaxis()->SetBinLabel(19,"19 = 18 & 2"); |
cd2e4ce6 | 191 | fhNEvents->GetXaxis()->SetBinLabel(20,"20 = Reject EMCAL 2"); |
192 | fhNEvents->GetXaxis()->SetBinLabel(21,"20 = 20 & 2"); | |
dd094cf8 | 193 | |
194 | fOutputContainer->Add(fhNEvents); | |
195 | ||
196 | fOutputContainer->SetOwner(kTRUE); | |
197 | ||
198 | PostData(1,fOutputContainer); | |
199 | ||
200 | } | |
201 | ||
46f9f991 | 202 | |
0de1814a | 203 | //_______________________________________________ |
dd094cf8 | 204 | void AliAnalysisTaskCounter::UserExec(Option_t *) |
205 | { | |
206 | // Main loop | |
207 | // Called for each event | |
208 | ||
209 | //printf("___ Event __ %d __\n",(Int_t)Entry()); | |
210 | ||
46f9f991 | 211 | Notify(); |
212 | ||
dd094cf8 | 213 | fhNEvents->Fill(0.5); |
214 | ||
215 | AliVEvent * event = InputEvent(); | |
dd094cf8 | 216 | AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (event); |
cd2e4ce6 | 217 | AliAODEvent * aodevent = dynamic_cast<AliAODEvent*> (event); |
218 | ||
997b261e | 219 | TString triggerclasses = event->GetFiredTriggerClasses(); |
cd2e4ce6 | 220 | |
997b261e | 221 | //printf("Trigger class fired: %s \n",event->GetFiredTriggerClasses().Data()); |
222 | ||
0de1814a | 223 | if (triggerclasses.Contains("FAST") && !triggerclasses.Contains("ALL") && !fAcceptFastCluster) |
224 | { | |
cd2e4ce6 | 225 | //printf("Do not count events from fast cluster, trigger name %s\n",triggerclasses.Data()); |
226 | return; | |
227 | } | |
dd094cf8 | 228 | |
229 | fhNEvents->Fill(1.5); | |
230 | ||
231 | //Initialize bools | |
232 | Bool_t bSelectVZ = kFALSE; | |
233 | Bool_t bV0AND = kFALSE; | |
234 | Bool_t bPileup = kFALSE; | |
235 | Bool_t bGoodV = kFALSE; | |
236 | Bool_t bSelectTrack = kFALSE; | |
237 | Int_t trackMult = 0; | |
238 | ||
239 | //--------------------------------- | |
240 | //Get the primary vertex, cut on Z | |
241 | //--------------------------------- | |
242 | Double_t v[3]; | |
243 | event->GetPrimaryVertex()->GetXYZ(v) ; | |
244 | fhXVertex->Fill(v[0]); | |
245 | fhYVertex->Fill(v[1]); | |
246 | fhZVertex->Fill(v[2]); | |
247 | ||
0de1814a | 248 | if(TMath::Abs(v[2]) < fZVertexCut) |
249 | { | |
dd094cf8 | 250 | bSelectVZ=kTRUE; |
251 | fhNEvents->Fill(2.5); | |
252 | } | |
253 | //else printf("Vertex out %f \n",v[2]); | |
254 | ||
dd094cf8 | 255 | //-------------------------------------------------- |
997b261e | 256 | //Count tracks, cut on number of tracks in eta < 0.8 |
dd094cf8 | 257 | //-------------------------------------------------- |
997b261e | 258 | Int_t nTracks = event->GetNumberOfTracks() ; |
259 | for (Int_t itrack = 0; itrack < nTracks; itrack++) | |
260 | {////////////// track loop | |
261 | AliVTrack * track = (AliVTrack*)event->GetTrack(itrack) ; // retrieve track from esd | |
262 | ||
263 | //ESDs | |
264 | if(esdevent && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue; | |
265 | ||
266 | //AODs | |
267 | if(aodevent && !((AliAODTrack*)track)->IsHybridGlobalConstrainedGlobal()) continue ; | |
268 | ||
269 | //Do not count tracks out of acceptance cut | |
270 | if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++; | |
dd094cf8 | 271 | } |
272 | ||
273 | //printf("AliAnalysisTaskCounter::UserExec() - Track Mult %d \n",trackMult); | |
274 | ||
275 | //-------------------------------------------------- | |
276 | // At least one track | |
277 | //-------------------------------------------------- | |
d2655d46 | 278 | if (trackMult > 0) |
279 | { | |
dd094cf8 | 280 | bSelectTrack = kTRUE; |
281 | fhNEvents->Fill(3.5); | |
282 | if(bSelectVZ) fhNEvents->Fill(4.5); | |
283 | } | |
284 | ||
285 | //--------------------------------- | |
286 | // V0AND | |
287 | //--------------------------------- | |
997b261e | 288 | |
289 | if(esdevent) bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esdevent, AliTriggerAnalysis::kV0AND); | |
dd094cf8 | 290 | |
291 | if(bV0AND) | |
292 | { | |
293 | fhNEvents->Fill(5.5); | |
294 | if (bSelectVZ) fhNEvents->Fill(6.5); | |
295 | if (bSelectTrack) fhNEvents->Fill(7.5); | |
296 | if (bSelectVZ && bSelectTrack) fhNEvents->Fill(8.5); | |
297 | } | |
298 | ||
299 | //--------------------------------- | |
300 | // Pileup | |
301 | //--------------------------------- | |
997b261e | 302 | bPileup = event->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile |
303 | //bPileup = event->IsPileupFromSPD(); | |
0de1814a | 304 | |
305 | if (!bPileup) | |
306 | { | |
dd094cf8 | 307 | fhNEvents->Fill(9.5); |
308 | if(bV0AND) fhNEvents->Fill(16.5); | |
309 | } | |
310 | ||
311 | //--------------------------------- | |
312 | // Good vertex | |
313 | //--------------------------------- | |
997b261e | 314 | bGoodV = CheckForPrimaryVertex(); |
d2655d46 | 315 | |
316 | //Remove events with vertex (0,0,0), bad vertex reconstruction | |
317 | if(TMath::Abs(v[0]) < 1.e-6 && | |
318 | TMath::Abs(v[1]) < 1.e-6 && | |
319 | TMath::Abs(v[2]) < 1.e-6) bGoodV = kFALSE; | |
320 | ||
dd094cf8 | 321 | if(bGoodV) |
322 | { | |
323 | fhXGoodVertex->Fill(v[0]); | |
324 | fhYGoodVertex->Fill(v[1]); | |
325 | fhZGoodVertex->Fill(v[2]); | |
326 | ||
327 | fhNEvents->Fill(10.5); | |
328 | if(bSelectVZ) fhNEvents->Fill(11.5); | |
329 | if(bSelectTrack) fhNEvents->Fill(12.5); | |
330 | if(bV0AND) fhNEvents->Fill(13.5); | |
331 | if(bSelectVZ && bSelectTrack && bV0AND) | |
332 | fhNEvents->Fill(14.5); | |
333 | if(!bPileup) fhNEvents->Fill(15.5); | |
e19ca838 | 334 | |
0792da48 | 335 | if(TMath::Abs(v[2]) < 10.) |
e19ca838 | 336 | { |
0792da48 | 337 | if(InputEvent()->GetCentrality()) |
338 | fhCentrality->Fill(InputEvent()->GetCentrality()->GetCentralityPercentile("V0M")); | |
339 | ||
340 | if(InputEvent()->GetEventplane()) | |
341 | { | |
342 | Float_t ep = InputEvent()->GetEventplane()->GetEventplane("V0", InputEvent()); | |
343 | ||
344 | ep+=TMath::Pi()/2.; // put same range as for <Q> method, [0,pi] | |
345 | ||
346 | fhEventPlaneAngle->Fill(ep); | |
347 | } | |
e19ca838 | 348 | } |
349 | ||
dd094cf8 | 350 | } |
351 | ||
352 | //printf("AliAnalysisTaskCounter::UserExec() : z vertex %d, good vertex %d, v0and %d, pile up %d, track mult %d\n ", bSelectVZ, bGoodV, bV0AND, bPileup, trackMult); | |
353 | ||
0b080dc9 | 354 | // Events that could be rejected in EMCAL |
cd2e4ce6 | 355 | // LHC11a, SM4 and some SM3 events cut with this |
356 | Bool_t bEMCALRejected = kFALSE; | |
0b080dc9 | 357 | for (Int_t i = 0; i < InputEvent()->GetNumberOfCaloClusters(); i++) |
358 | { | |
359 | AliVCluster *clus = InputEvent()->GetCaloCluster(i); | |
360 | if(clus->IsEMCAL()){ | |
0de1814a | 361 | if ((clus->E() > 500 && clus->GetNCells() > 200 ) || clus->GetNCells() > 200) |
362 | { | |
cd2e4ce6 | 363 | |
0b080dc9 | 364 | //printf("Counter: Reject event with cluster: E %f, ncells %d\n",clus->E(),clus->GetNCells()); |
cd2e4ce6 | 365 | |
0b080dc9 | 366 | fhNEvents->Fill(17.5); |
367 | if(bSelectVZ) fhNEvents->Fill(18.5); | |
cd2e4ce6 | 368 | bEMCALRejected = kTRUE; |
0b080dc9 | 369 | break; |
370 | } | |
0b080dc9 | 371 | } |
372 | } | |
373 | ||
cd2e4ce6 | 374 | //LHC11a, 3 last runs, cut with this |
0de1814a | 375 | if(!bEMCALRejected) |
376 | { | |
cd2e4ce6 | 377 | // Count number of cells in SM3 with energy larger than 0.1, cut on this number |
75153e10 | 378 | Int_t ncellsSM3 = 0; |
379 | Int_t ncellsSM4 = 0; | |
0de1814a | 380 | for(Int_t icell = 0; icell < event->GetEMCALCells()->GetNumberOfCells(); icell++) |
381 | { | |
75153e10 | 382 | if(event->GetEMCALCells()->GetAmplitude(icell) > 0.1 && event->GetEMCALCells()->GetCellNumber(icell)/(24*48)==3) ncellsSM3++; |
383 | if(event->GetEMCALCells()->GetAmplitude(icell) > 0.1 && event->GetEMCALCells()->GetCellNumber(icell)/(24*48)==4) ncellsSM4++; | |
cd2e4ce6 | 384 | } |
385 | ||
386 | Int_t ncellcut = 21; | |
387 | if(triggerclasses.Contains("EMC")) ncellcut = 35; | |
388 | ||
0de1814a | 389 | if( ncellsSM3 >= ncellcut || ncellsSM4 >= 100 ) |
390 | { | |
cd2e4ce6 | 391 | //printf("Counter: reject event with ncells in SM3: ncells %d\n",ncells); |
392 | ||
393 | fhNEvents->Fill(19.5); | |
394 | if(bSelectVZ) fhNEvents->Fill(20.5); | |
395 | } | |
396 | ||
397 | } | |
398 | ||
dd094cf8 | 399 | PostData(1,fOutputContainer); |
400 | ||
401 | } | |
402 | ||
46f9f991 | 403 | |
0de1814a | 404 | //____________________________________________________ |
405 | Bool_t AliAnalysisTaskCounter::CheckForPrimaryVertex() | |
406 | { | |
dd094cf8 | 407 | //Check if the vertex was well reconstructed, copy from V0Reader of conversion group |
408 | //It only works for ESDs | |
409 | ||
410 | AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent()); | |
d2655d46 | 411 | if(!event) return 1; |
dd094cf8 | 412 | |
0de1814a | 413 | if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) |
414 | { | |
dd094cf8 | 415 | return 1; |
416 | } | |
417 | ||
0de1814a | 418 | if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) |
419 | { | |
dd094cf8 | 420 | // SPD vertex |
0de1814a | 421 | if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) |
422 | { | |
dd094cf8 | 423 | //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; |
424 | return 1; | |
425 | ||
426 | } | |
0de1814a | 427 | if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) |
428 | { | |
dd094cf8 | 429 | // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; |
430 | return 0; | |
431 | } | |
432 | } | |
0de1814a | 433 | |
dd094cf8 | 434 | return 0; |
435 | //return fInputEvent->GetPrimaryVertex()->GetNContributors()>0; | |
436 | } | |
437 | ||
438 | ||
dd094cf8 | 439 | //_____________________________________________________ |
440 | void AliAnalysisTaskCounter::FinishTaskOutput() | |
441 | { | |
442 | // Put in the output some event summary histograms | |
443 | ||
444 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); | |
445 | AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler()); | |
446 | if (!inputH) return; | |
447 | TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics()); | |
448 | TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0")); | |
449 | ||
450 | if(histStat) | |
451 | fOutputContainer->Add(histStat); | |
49b5c49b | 452 | else if(DebugLevel() > 1) |
dd094cf8 | 453 | printf("AliAnalysisTaskCounter::FinishTaskOutput() - Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists \n"); |
454 | ||
455 | if(histBin0) | |
456 | fOutputContainer->Add(histBin0); | |
457 | ||
458 | } | |
46f9f991 | 459 | |
460 | ||
461 | //_____________________________________ | |
462 | Bool_t AliAnalysisTaskCounter::Notify() | |
463 | { | |
464 | // | |
465 | // Implemented Notify() to read the cross sections | |
466 | // and number of trials from pyxsec.root | |
467 | // | |
468 | ||
469 | // Fetch the aod also from the input in, | |
470 | // have todo it in notify | |
471 | ||
472 | Float_t xsection = 0; | |
473 | Float_t trials = 1; | |
474 | fAvgTrials = -1; | |
475 | ||
476 | TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree(); | |
477 | if(!tree) return kFALSE; | |
478 | ||
479 | TFile *curfile = tree->GetCurrentFile(); | |
480 | ||
481 | if(!curfile) return kFALSE; | |
482 | ||
483 | if(fCurrFileName == curfile->GetName()) return kFALSE; | |
484 | ||
485 | fCurrFileName = TString(curfile->GetName()); | |
486 | ||
487 | if(!fh1Xsec||!fh1Trials) | |
488 | { | |
489 | Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__); | |
490 | return kFALSE; | |
491 | } | |
492 | ||
e3f791f6 | 493 | Bool_t ok = PythiaInfoFromFile(fCurrFileName,xsection,trials); |
494 | ||
495 | if(!ok) return kFALSE; | |
46f9f991 | 496 | |
497 | fh1Xsec->Fill("<#sigma>",xsection); | |
498 | ||
499 | // construct a poor man average trials | |
500 | Float_t nEntries = (Float_t)tree->GetTree()->GetEntries(); | |
501 | ||
502 | if(trials >= nEntries && nEntries > 0.) fAvgTrials = trials/nEntries; | |
503 | ||
504 | fh1Trials->Fill("#sum{ntrials}",trials); | |
505 | ||
506 | printf("AliAnalysisTaskCounter::Notify() - xs %f, trial %f, avg trials %f\n",xsection,trials, fAvgTrials); | |
507 | ||
508 | if(fDebug) Printf("Reading File %s",fInputHandler->GetTree()->GetCurrentFile()->GetName()); | |
509 | ||
510 | return kTRUE; | |
511 | } | |
512 | ||
513 | //_____________________________________________________________________________________________________ | |
514 | Bool_t AliAnalysisTaskCounter::PythiaInfoFromFile(TString file,Float_t & xsec,Float_t & trials) | |
515 | { | |
516 | // | |
517 | // get the cross section and the trails either from pyxsec.root or from pysec_hists.root | |
518 | // This is to called in Notify and should provide the path to the AOD/ESD file | |
519 | ||
520 | xsec = 0; | |
521 | trials = 1; | |
522 | ||
523 | if(file.Contains("root_archive.zip#")) | |
524 | { | |
525 | Ssiz_t pos1 = file.Index("root_archive",12,0,TString::kExact); | |
526 | Ssiz_t pos = file.Index("#",1,pos1,TString::kExact); | |
527 | Ssiz_t pos2 = file.Index(".root",5,TString::kExact); | |
528 | file.Replace(pos+1,pos2-pos1,""); | |
529 | } | |
530 | else | |
531 | { | |
532 | // not an archive take the basename.... | |
533 | file.ReplaceAll(gSystem->BaseName(file.Data()),""); | |
534 | } | |
535 | ||
536 | //Printf("%s",file.Data()); | |
537 | ||
538 | TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root")); // problem that we cannot really test the existance of a file in a archive so we have to lvie with open error message from root | |
539 | if(!fxsec) | |
540 | { | |
541 | // next trial fetch the histgram file | |
542 | fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root")); | |
543 | if(!fxsec) | |
544 | { | |
545 | // not a severe condition but inciate that we have no information | |
546 | return kFALSE; | |
547 | } | |
548 | else | |
549 | { | |
550 | // find the tlist we want to be independtent of the name so use the Tkey | |
551 | TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0); | |
552 | if(!key) | |
553 | { | |
554 | fxsec->Close(); | |
555 | return kFALSE; | |
556 | } | |
557 | ||
558 | TList *list = dynamic_cast<TList*>(key->ReadObj()); | |
559 | if(!list) | |
560 | { | |
561 | fxsec->Close(); | |
562 | return kFALSE; | |
563 | } | |
564 | ||
565 | xsec = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1); | |
566 | trials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1); | |
567 | fxsec->Close(); | |
568 | } | |
569 | } // no tree pyxsec.root | |
570 | else | |
571 | { | |
572 | TTree *xtree = (TTree*)fxsec->Get("Xsection"); | |
573 | if(!xtree) | |
574 | { | |
575 | fxsec->Close(); | |
576 | return kFALSE; | |
577 | } | |
578 | ||
579 | UInt_t ntrials = 0; | |
580 | Double_t xsection = 0; | |
581 | xtree->SetBranchAddress("xsection",&xsection); | |
582 | xtree->SetBranchAddress("ntrials",&ntrials); | |
583 | xtree->GetEntry(0); | |
584 | trials = ntrials; | |
585 | xsec = xsection; | |
586 | fxsec->Close(); | |
587 | } | |
588 | ||
589 | return kTRUE; | |
72704df1 | 590 | } |
591 |