1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // Count events with different selections
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
29 // 9: not pileup from SPD
34 // 14: 10 && 2 && 3 && 5
38 // Author: Gustavo Conesa Balbastre (LPSC)
40 //_________________________________________________________________________
43 #include "AliAODHeader.h"
44 #include "AliTriggerAnalysis.h"
45 #include "AliESDEvent.h"
46 #include "AliAODEvent.h"
47 #include "AliESDtrackCuts.h"
48 #include "AliAnalysisManager.h"
49 #include "AliInputEventHandler.h"
51 #include "AliAnalysisTaskCounter.h"
52 ClassImp(AliAnalysisTaskCounter)
54 //______________________________________________________________
55 AliAnalysisTaskCounter::AliAnalysisTaskCounter(const char *name)
56 : AliAnalysisTaskSE(name),
57 fAcceptFastCluster(kTRUE),
59 fTrackMultEtaCut(0.8),
60 fCaloFilterPatch(kFALSE),
61 fOutputContainer(0x0),
62 fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),
63 fTriggerAnalysis (new AliTriggerAnalysis),
65 fhXVertex(0), fhYVertex(0), fhZVertex(0),
66 fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0),
67 fhCentrality(0), fhEventPlaneAngle(0)
70 DefineOutput(1, TList::Class());
73 //______________________________________________
74 AliAnalysisTaskCounter::AliAnalysisTaskCounter()
75 : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskCounter"),
76 fAcceptFastCluster(kTRUE),
78 fTrackMultEtaCut(0.8),
79 fCaloFilterPatch(kFALSE),
80 fOutputContainer(0x0),
81 fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),
82 fTriggerAnalysis (new AliTriggerAnalysis),
84 fhXVertex(0), fhYVertex(0), fhZVertex(0),
85 fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0),
86 fhCentrality(0), fhEventPlaneAngle(0)
89 DefineOutput(1, TList::Class());
92 //__________________________________________________
93 AliAnalysisTaskCounter::~AliAnalysisTaskCounter()
97 if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
101 fOutputContainer->Delete() ;
102 delete fOutputContainer ;
105 if(fESDtrackCuts) delete fESDtrackCuts;
106 if(fTriggerAnalysis) delete fTriggerAnalysis;
111 //____________________________________________________
112 void AliAnalysisTaskCounter::UserCreateOutputObjects()
116 fOutputContainer = new TList();
118 fhZVertex = new TH1F("hZVertex", " Z vertex distribution" , 200 , -50 , 50 ) ;
119 fhZVertex->SetXTitle("v_{z} (cm)");
120 fOutputContainer->Add(fhZVertex);
122 fhZGoodVertex = new TH1F("hZGoodVertex", " Good Z vertex distribution" , 200 , -50 , 50 ) ;
123 fhZGoodVertex->SetXTitle("v_{z} (cm)");
124 fOutputContainer->Add(fhZGoodVertex);
126 fhXVertex = new TH1F("hXVertex", " X vertex distribution" , 200 , -2 , 2 ) ;
127 fhXVertex->SetXTitle("v_{x} (cm)");
128 fOutputContainer->Add(fhXVertex);
130 fhXGoodVertex = new TH1F("hXGoodVertex", " Good X vertex distribution" , 200 , -2 , 2 ) ;
131 fhXGoodVertex->SetXTitle("v_{x} (cm)");
132 fOutputContainer->Add(fhXGoodVertex);
134 fhYVertex = new TH1F("hYVertex", " Y vertex distribution" , 200 , -2 , 2 ) ;
135 fhYVertex->SetXTitle("v_{y} (cm)");
136 fOutputContainer->Add(fhYVertex);
138 fhYGoodVertex = new TH1F("hYGoodVertex", " Good Y vertex distribution" , 200 , -2 , 2 ) ;
139 fhYGoodVertex->SetXTitle("v_{y} (cm)");
140 fOutputContainer->Add(fhYGoodVertex);
142 fhCentrality = new TH1F("hCentrality","Number of events in centrality bin, |vz|<10 cm, method <V0M> ",100,0.,100.) ;
143 fhCentrality->SetXTitle("Centrality bin");
144 fOutputContainer->Add(fhCentrality) ;
146 fhEventPlaneAngle=new TH1F("hEventPlaneAngle","Number of events in event plane, |vz|<10 cm, method <V0> ",100,0.,TMath::Pi()) ;
147 fhEventPlaneAngle->SetXTitle("EP angle (rad)");
148 fOutputContainer->Add(fhEventPlaneAngle) ;
150 fhNEvents = new TH1I("hNEvents", "Number of analyzed events", 21, 0, 21) ;
151 fhNEvents->SetXTitle("Selection");
152 fhNEvents->SetYTitle("# events");
153 fhNEvents->GetXaxis()->SetBinLabel(1 ,"1 = PS");
154 fhNEvents->GetXaxis()->SetBinLabel(2 ,"2 = 1 & ESD");
155 fhNEvents->GetXaxis()->SetBinLabel(3 ,"3 = 2 & |Z|<10");
156 fhNEvents->GetXaxis()->SetBinLabel(4 ,"4 = 2 & |eta|<0.8");
157 fhNEvents->GetXaxis()->SetBinLabel(5 ,"5 = 3 & 4");
158 fhNEvents->GetXaxis()->SetBinLabel(6 ,"6 = 2 & V0AND");
159 fhNEvents->GetXaxis()->SetBinLabel(7 ,"7 = 3 & 6");
160 fhNEvents->GetXaxis()->SetBinLabel(8 ,"8 = 4 & 6");
161 fhNEvents->GetXaxis()->SetBinLabel(9 ,"9 = 5 & 6");
162 fhNEvents->GetXaxis()->SetBinLabel(10,"10 = 2 & not pileup");
163 fhNEvents->GetXaxis()->SetBinLabel(11,"11 = 2 & good vertex");
164 fhNEvents->GetXaxis()->SetBinLabel(12,"12 = 3 & 11");
165 fhNEvents->GetXaxis()->SetBinLabel(13,"13 = 4 & 11");
166 fhNEvents->GetXaxis()->SetBinLabel(14,"14 = 6 & 11");
167 fhNEvents->GetXaxis()->SetBinLabel(15,"15 = 9 & 11");
168 fhNEvents->GetXaxis()->SetBinLabel(16,"16 = 10 & 11");
169 fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 6 & 10");
170 fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 1 & |Z|<50");
171 fhNEvents->GetXaxis()->SetBinLabel(18,"18 = Reject EMCAL 1");
172 fhNEvents->GetXaxis()->SetBinLabel(19,"19 = 18 & 2");
173 fhNEvents->GetXaxis()->SetBinLabel(20,"20 = Reject EMCAL 2");
174 fhNEvents->GetXaxis()->SetBinLabel(21,"20 = 20 & 2");
176 fOutputContainer->Add(fhNEvents);
178 fOutputContainer->SetOwner(kTRUE);
180 PostData(1,fOutputContainer);
184 //_______________________________________________
185 void AliAnalysisTaskCounter::UserExec(Option_t *)
188 // Called for each event
190 //printf("___ Event __ %d __\n",(Int_t)Entry());
192 fhNEvents->Fill(0.5);
194 AliVEvent * event = InputEvent();
197 printf("AliAnalysisTaskCounter::UserExec() - ERROR: event not available \n");
201 AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (event);
202 AliAODEvent * aodevent = dynamic_cast<AliAODEvent*> (event);
204 TString triggerclasses = "";
205 if(esdevent) triggerclasses = esdevent->GetFiredTriggerClasses();
206 if(aodevent) triggerclasses = aodevent->GetFiredTriggerClasses();
208 if (triggerclasses.Contains("FAST") && !triggerclasses.Contains("ALL") && !fAcceptFastCluster)
210 //printf("Do not count events from fast cluster, trigger name %s\n",triggerclasses.Data());
214 fhNEvents->Fill(1.5);
217 Bool_t bSelectVZ = kFALSE;
218 Bool_t bV0AND = kFALSE;
219 Bool_t bPileup = kFALSE;
220 Bool_t bGoodV = kFALSE;
221 Bool_t bSelectTrack = kFALSE;
224 //---------------------------------
225 //Get the primary vertex, cut on Z
226 //---------------------------------
228 event->GetPrimaryVertex()->GetXYZ(v) ;
229 fhXVertex->Fill(v[0]);
230 fhYVertex->Fill(v[1]);
231 fhZVertex->Fill(v[2]);
233 if(TMath::Abs(v[2]) < fZVertexCut)
236 fhNEvents->Fill(2.5);
238 //else printf("Vertex out %f \n",v[2]);
241 //--------------------------------------------------
242 //Tweak for calorimeter only productions
243 //--------------------------------------------------
244 if(fCaloFilterPatch && !esdevent)
246 if(event->GetNumberOfCaloClusters() > 0)
248 AliVCluster * calo = event->GetCaloCluster(0);
249 if(calo->GetNLabels() == 4){
250 Int_t * selection = calo->GetLabels();
251 bPileup = selection[0];
252 bGoodV = selection[1];
253 bV0AND = selection[2];
254 trackMult = selection[3];
255 //if(selection[0] || selection[1] || selection[2])
256 //printf(" pu %d, gv %d, v0 %d, track mult %d\n ", selection[0], selection[1], selection[2], selection[3]);
258 bSelectTrack = kFALSE;
262 //First filtered AODs, track multiplicity stored there.
263 trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
267 { //at least one cluster
269 //First filtered AODs, track multiplicity stored there.
270 trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
275 //--------------------------------------------------
276 //Count tracks, cut on number of tracks in eta < 0.8
277 //--------------------------------------------------
278 Int_t nTracks = event->GetNumberOfTracks() ;
279 for (Int_t itrack = 0; itrack < nTracks; itrack++)
280 {////////////// track loop
281 AliVTrack * track = (AliVTrack*)event->GetTrack(itrack) ; // retrieve track from esd
284 if(esdevent && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;
286 //Do not count tracks out of acceptance cut
287 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++;
291 //printf("AliAnalysisTaskCounter::UserExec() - Track Mult %d \n",trackMult);
293 //--------------------------------------------------
294 // At least one track
295 //--------------------------------------------------
298 bSelectTrack = kTRUE;
299 fhNEvents->Fill(3.5);
300 if(bSelectVZ) fhNEvents->Fill(4.5);
303 //---------------------------------
305 //---------------------------------
306 if(esdevent && !fCaloFilterPatch) bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esdevent, AliTriggerAnalysis::kV0AND);
307 //else if(aodevent && !fCaloFilterPatch) bV0AND = //FIXME FOR AODs
311 fhNEvents->Fill(5.5);
312 if (bSelectVZ) fhNEvents->Fill(6.5);
313 if (bSelectTrack) fhNEvents->Fill(7.5);
314 if (bSelectVZ && bSelectTrack) fhNEvents->Fill(8.5);
317 //---------------------------------
319 //---------------------------------
320 if(!fCaloFilterPatch)
321 bPileup = event->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
322 //bPileup = event->IsPileupFromSPD();
326 fhNEvents->Fill(9.5);
327 if(bV0AND) fhNEvents->Fill(16.5);
330 //---------------------------------
332 //---------------------------------
333 if(!fCaloFilterPatch) bGoodV = CheckForPrimaryVertex();
335 //Remove events with vertex (0,0,0), bad vertex reconstruction
336 if(TMath::Abs(v[0]) < 1.e-6 &&
337 TMath::Abs(v[1]) < 1.e-6 &&
338 TMath::Abs(v[2]) < 1.e-6) bGoodV = kFALSE;
342 fhXGoodVertex->Fill(v[0]);
343 fhYGoodVertex->Fill(v[1]);
344 fhZGoodVertex->Fill(v[2]);
346 fhNEvents->Fill(10.5);
347 if(bSelectVZ) fhNEvents->Fill(11.5);
348 if(bSelectTrack) fhNEvents->Fill(12.5);
349 if(bV0AND) fhNEvents->Fill(13.5);
350 if(bSelectVZ && bSelectTrack && bV0AND)
351 fhNEvents->Fill(14.5);
352 if(!bPileup) fhNEvents->Fill(15.5);
354 if(TMath::Abs(v[2]) < 10.)
356 if(InputEvent()->GetCentrality())
357 fhCentrality->Fill(InputEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
359 if(InputEvent()->GetEventplane())
361 Float_t ep = InputEvent()->GetEventplane()->GetEventplane("V0", InputEvent());
363 ep+=TMath::Pi()/2.; // put same range as for <Q> method, [0,pi]
365 fhEventPlaneAngle->Fill(ep);
371 //printf("AliAnalysisTaskCounter::UserExec() : z vertex %d, good vertex %d, v0and %d, pile up %d, track mult %d\n ", bSelectVZ, bGoodV, bV0AND, bPileup, trackMult);
373 // Events that could be rejected in EMCAL
374 // LHC11a, SM4 and some SM3 events cut with this
375 Bool_t bEMCALRejected = kFALSE;
376 for (Int_t i = 0; i < InputEvent()->GetNumberOfCaloClusters(); i++)
378 AliVCluster *clus = InputEvent()->GetCaloCluster(i);
380 if ((clus->E() > 500 && clus->GetNCells() > 200 ) || clus->GetNCells() > 200)
383 //printf("Counter: Reject event with cluster: E %f, ncells %d\n",clus->E(),clus->GetNCells());
385 fhNEvents->Fill(17.5);
386 if(bSelectVZ) fhNEvents->Fill(18.5);
387 bEMCALRejected = kTRUE;
393 //LHC11a, 3 last runs, cut with this
396 // Count number of cells in SM3 with energy larger than 0.1, cut on this number
399 for(Int_t icell = 0; icell < event->GetEMCALCells()->GetNumberOfCells(); icell++)
401 if(event->GetEMCALCells()->GetAmplitude(icell) > 0.1 && event->GetEMCALCells()->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
402 if(event->GetEMCALCells()->GetAmplitude(icell) > 0.1 && event->GetEMCALCells()->GetCellNumber(icell)/(24*48)==4) ncellsSM4++;
406 if(triggerclasses.Contains("EMC")) ncellcut = 35;
408 if( ncellsSM3 >= ncellcut || ncellsSM4 >= 100 )
410 //printf("Counter: reject event with ncells in SM3: ncells %d\n",ncells);
412 fhNEvents->Fill(19.5);
413 if(bSelectVZ) fhNEvents->Fill(20.5);
418 PostData(1,fOutputContainer);
422 //____________________________________________________
423 Bool_t AliAnalysisTaskCounter::CheckForPrimaryVertex()
425 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
426 //It only works for ESDs
428 AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent());
431 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
436 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
439 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
441 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
445 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
447 // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
453 //return fInputEvent->GetPrimaryVertex()->GetNContributors()>0;
458 //_____________________________________________________
459 void AliAnalysisTaskCounter::FinishTaskOutput()
461 // Put in the output some event summary histograms
463 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
464 AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
466 TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics());
467 TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));
470 fOutputContainer->Add(histStat);
471 else if(DebugLevel() > 1)
472 printf("AliAnalysisTaskCounter::FinishTaskOutput() - Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists \n");
475 fOutputContainer->Add(histBin0);