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 // Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and
18 // Central Barrel Tracking detectors (CTS).
19 // Not all MC particles/tracks/clusters are kept, some kinematical/fiducial restrictions are done.
20 // Mother class of : AliCaloTrackESDReader: Fills ESD data in 3 TObjArrays (PHOS, EMCAL, CTS)
21 // : AliCaloTrackMCReader : Fills Kinematics data in 3 TObjArrays (PHOS, EMCAL, CTS)
22 // : AliCaloTrackAODReader: Fills AOD data in 3 TObjArrays (PHOS, EMCAL, CTS)
23 //-- Author: Gustavo Conesa (LNF-INFN)
24 //////////////////////////////////////////////////////////////////////////////
27 // --- ROOT system ---
29 #include <TGeoManager.h>
31 // ---- ANALYSIS system ----
32 #include "AliMCEvent.h"
33 #include "AliAODMCHeader.h"
34 #include "AliGenPythiaEventHeader.h"
35 #include "AliESDEvent.h"
36 #include "AliAODEvent.h"
37 #include "AliVTrack.h"
38 #include "AliVParticle.h"
39 #include "AliMixedEvent.h"
40 #include "AliESDtrack.h"
41 #include "AliESDtrackCuts.h"
42 #include "AliTriggerAnalysis.h"
43 #include "AliESDVZERO.h"
44 #include "AliVCaloCells.h"
45 #include "AliAnalysisManager.h"
46 #include "AliInputEventHandler.h"
48 // ---- Detectors ----
49 #include "AliPHOSGeoUtils.h"
50 #include "AliEMCALGeometry.h"
51 #include "AliEMCALRecoUtils.h"
53 // ---- CaloTrackCorr ---
54 #include "AliCalorimeterUtils.h"
55 #include "AliCaloTrackReader.h"
57 ClassImp(AliCaloTrackReader)
60 //________________________________________
61 AliCaloTrackReader::AliCaloTrackReader() :
62 TObject(), fEventNumber(-1), //fCurrentFileName(""),
63 fDataType(0), fDebug(0),
64 fFiducialCut(0x0), fCheckFidCut(kFALSE),
65 fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(0),
66 fComparePtHardAndClusterPt(0),fPtHardAndClusterPtFactor(0),
67 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
68 fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
69 fUseEMCALTimeCut(1), fUseParamTimeCut(0), fUseTrackTimeCut(0),
70 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
71 fEMCALParamTimeCutMin(), fEMCALParamTimeCutMax(),
72 fTrackTimeCutMin(-10000), fTrackTimeCutMax(10000),
74 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
75 fEMCALCells(0x0), fPHOSCells(0x0),
76 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
77 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
78 fFillEMCALCells(0), fFillPHOSCells(0),
79 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
80 fTrackStatus(0), fTrackFilterMask(0),
81 fESDtrackCuts(0), fConstrainTrack(kFALSE),
82 fSelectHybridTracks(0), fSelectSPDHitTracks(kFALSE),
83 fTrackMult(0), fTrackMultEtaCut(0.8),
84 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
85 fDeltaAODFileName(""), fFiredTriggerClassName(""),
86 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
88 fTaskName(""), fCaloUtils(0x0),
89 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
90 fListMixedTracksEvents(), fListMixedCaloEvents(),
91 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
92 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
93 fEMCALClustersListName(""), fZvtxCut(0.),
94 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
95 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
96 fTriggerAnalysis (0x0),
97 fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
98 fCentralityClass(""), fCentralityOpt(0),
99 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
103 //Initialize parameters
107 //_______________________________________
108 AliCaloTrackReader::~AliCaloTrackReader()
112 delete fFiducialCut ;
116 fAODBranchList->Delete();
117 delete fAODBranchList ;
122 if(fDataType!=kMC)fCTSTracks->Clear() ;
123 else fCTSTracks->Delete() ;
129 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
130 else fEMCALClusters->Delete() ;
131 delete fEMCALClusters ;
136 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
137 else fPHOSClusters->Delete() ;
138 delete fPHOSClusters ;
143 for (Int_t i = 0; i < fNMixedEvent; i++)
145 delete [] fVertex[i] ;
151 delete fESDtrackCuts;
152 delete fTriggerAnalysis;
154 // Pointers not owned, done by the analysis frame
155 // if(fInputEvent) delete fInputEvent ;
156 // if(fOutputEvent) delete fOutputEvent ;
157 // if(fMC) delete fMC ;
158 // Pointer not owned, deleted by maker
159 // if (fCaloUtils) delete fCaloUtils ;
163 //________________________________________________
164 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
166 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
169 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
171 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
174 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
175 Int_t nTriggerJets = pygeh->NTriggerJets();
176 Float_t ptHard = pygeh->GetPtHard();
179 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
181 Float_t tmpjet[]={0,0,0,0};
182 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
184 pygeh->TriggerJet(ijet, tmpjet);
185 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
188 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
190 //Compare jet pT and pt Hard
191 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
193 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
194 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
206 //____________________________________________________________________
207 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
209 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
212 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
214 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
215 Float_t ptHard = pygeh->GetPtHard();
217 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
218 for (Int_t iclus = 0; iclus < nclusters; iclus++)
220 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
221 Float_t ecluster = clus->E();
223 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
225 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
237 //____________________________________________
238 AliStack* AliCaloTrackReader::GetStack() const
240 //Return pointer to stack
245 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
250 //__________________________________________________
251 TString AliCaloTrackReader::GetFiredTriggerClasses()
253 // List of triggered classes in a TString
255 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
256 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
258 if (esdevent) return esdevent->GetFiredTriggerClasses();
259 else if(aodevent) return aodevent->GetFiredTriggerClasses();
260 else return ""; // Mixed Event, MC event, does not have this trigger info
264 //______________________________________________
265 AliHeader* AliCaloTrackReader::GetHeader() const
267 //Return pointer to header
270 return fMC->Header();
274 printf("AliCaloTrackReader::Header is not available\n");
279 //______________________________________________________________
280 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
282 //Return pointer to Generated event header
283 if (ReadStack() && fMC)
285 return fMC->GenEventHeader();
287 else if(ReadAODMCParticles() && GetAODMCHeader())
289 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
290 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
291 return GetAODMCHeader()->GetCocktailHeader(0) ;
297 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
302 //____________________________________________________________________
303 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
305 //Return list of particles in AOD. Do it for the corresponding input event.
307 TClonesArray * rv = NULL ;
308 if(fDataType == kAOD)
313 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
315 rv = (TClonesArray*)evt->FindListObject("mcparticles");
317 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
323 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
329 //________________________________________________________
330 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
332 //Return MC header in AOD. Do it for the corresponding input event.
334 AliAODMCHeader *mch = NULL;
336 if(fDataType == kAOD)
338 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
339 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
343 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
349 //_____________________________
350 void AliCaloTrackReader::Init()
352 //Init reader. Method to be called in AliAnaPartCorrMaker
354 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
356 if(fReadStack && fReadAODMCParticles)
358 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
360 fReadAODMCParticles = kFALSE;
363 // Init geometry, I do not like much to do it like this ...
364 if(fImportGeometryFromFile && !gGeoManager)
366 if(fImportGeometryFilePath=="") // If not specified, set a default location
367 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
369 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
370 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
375 //_______________________________________
376 void AliCaloTrackReader::InitParameters()
378 //Initialize the parameters of the analysis.
384 fEMCALPtMax = 1000. ;
387 //Do not filter the detectors input by default.
391 fFillEMCALCells = kFALSE;
392 fFillPHOSCells = kFALSE;
394 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
395 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
396 fDeltaAODFileName = "deltaAODPartCorr.root";
397 fFiredTriggerClassName = "";
398 fEventTriggerMask = AliVEvent::kAny;
399 fMixEventTriggerMask = AliVEvent::kAnyINT;
400 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
402 fAcceptFastCluster = kTRUE;
405 //We want tracks fitted in the detectors:
406 //fTrackStatus=AliESDtrack::kTPCrefit;
407 //fTrackStatus|=AliESDtrack::kITSrefit;
409 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
411 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
413 fConstrainTrack = kFALSE ; // constrain tracks to vertex
415 fV0ADC[0] = 0; fV0ADC[1] = 0;
416 fV0Mul[0] = 0; fV0Mul[1] = 0;
422 fPtHardAndJetPtFactor = 7.;
423 fPtHardAndClusterPtFactor = 1.;
426 fCentralityClass = "V0M";
428 fCentralityBin[0] = fCentralityBin[1]=-1;
430 fEventPlaneMethod = "V0";
432 // Allocate memory (not sure this is the right place)
433 fCTSTracks = new TObjArray();
434 fEMCALClusters = new TObjArray();
435 fPHOSClusters = new TObjArray();
436 fTriggerAnalysis = new AliTriggerAnalysis;
437 fAODBranchList = new TList ;
439 fImportGeometryFromFile = kFALSE;
441 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
442 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
444 // Parametrized time cut (LHC11d)
445 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
446 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
448 // Parametrized time cut (LHC11c)
449 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
450 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
453 //___________________________________________________________
454 Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
456 // Cluster time selection window
458 // Parametrized cut depending on E
461 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
462 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
463 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
464 if( tof < minCut || tof > maxCut ) return kFALSE ;
467 //In any case, the time should to be larger than the fixed window ...
468 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
473 //________________________________________________
474 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
476 // Check if event is from pile-up determined by SPD
477 // Default values: (3, 0.8, 3., 2., 5.)
478 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
479 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
480 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
484 //__________________________________________________
485 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
487 // Check if event is from pile-up determined by EMCal
488 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
492 //________________________________________________________
493 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
495 // Check if event is from pile-up determined by SPD and EMCal
496 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
500 //_______________________________________________________
501 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
503 // Check if event is from pile-up determined by SPD or EMCal
504 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
508 //___________________________________________________________
509 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
511 // Check if event is from pile-up determined by SPD and not by EMCal
512 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
516 //___________________________________________________________
517 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
519 // Check if event is from pile-up determined by EMCal, not by SPD
520 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
524 //______________________________________________________________
525 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
527 // Check if event not from pile-up determined neither by SPD nor by EMCal
528 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
532 //________________________________________________________
533 void AliCaloTrackReader::Print(const Option_t * opt) const
536 //Print some relevant parameters set for the analysis
540 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
541 printf("Task name : %s\n", fTaskName.Data()) ;
542 printf("Data type : %d\n", fDataType) ;
543 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
544 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
545 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
546 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
547 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
548 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
549 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
550 printf("Use CTS = %d\n", fFillCTS) ;
551 printf("Use EMCAL = %d\n", fFillEMCAL) ;
552 printf("Use PHOS = %d\n", fFillPHOS) ;
553 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
554 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
555 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
556 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
557 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
558 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
559 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
561 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
562 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
564 if(fComparePtHardAndClusterPt)
565 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
567 if(fComparePtHardAndClusterPt)
568 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
570 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
571 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
572 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
578 //_________________________________________________________________________
579 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
580 const char * /*currentFileName*/)
582 //Fill the event counter and input lists that are needed, called by the analysis maker.
584 fEventNumber = iEntry;
585 //fCurrentFileName = TString(currentFileName);
588 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
592 //Select events only fired by a certain trigger configuration if it is provided
594 if(fInputEvent->GetHeader())
595 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
597 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
599 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
603 //-------------------------------------------------------------------------------------
604 // Reject event if large clusters with large energy
605 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
606 // If clusterzer NxN or V2 it does not help
607 //-------------------------------------------------------------------------------------
608 Int_t run = fInputEvent->GetRunNumber();
609 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
611 //printf("Event %d\n",GetEventNumber());
613 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
615 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
617 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
618 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
619 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
623 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
625 if(ncellsSM3 >= ncellcut)
627 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d\n",ncellsSM3);
630 }// Remove LED events
632 // Reject pure LED events?
633 if( fFiredTriggerClassName !="" && !fAnaLED)
635 //printf("Event type %d\n",eventType);
637 return kFALSE; //Only physics event, do not use for simulated events!!!
640 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
641 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
643 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
644 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
648 // kStartOfRun = 1, // START_OF_RUN
649 // kEndOfRun = 2, // END_OF_RUN
650 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
651 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
652 // kStartOfBurst = 5, // START_OF_BURST
653 // kEndOfBurst = 6, // END_OF_BURST
654 // kPhysicsEvent = 7, // PHYSICS_EVENT
655 // kCalibrationEvent = 8, // CALIBRATION_EVENT
656 // kFormatError = 9, // EVENT_FORMAT_ERROR
657 // kStartOfData = 10, // START_OF_DATA
658 // kEndOfData = 11, // END_OF_DATA
659 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
660 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
662 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
663 if(eventType!=8)return kFALSE;
666 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
667 if(fComparePtHardAndJetPt)
669 if(!ComparePtHardAndJetPt()) return kFALSE ;
672 if(fComparePtHardAndClusterPt)
674 if(!ComparePtHardAndClusterPt()) return kFALSE ;
679 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
680 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
682 //------------------------------------------------------
683 //Event rejection depending on vertex, pileup, v0and
684 //------------------------------------------------------
686 if(fUseEventsWithPrimaryVertex)
688 if( !CheckForPrimaryVertex() ) return kFALSE;
689 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
690 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
691 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
694 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
696 if(fDoEventSelection)
698 if(!fCaloFilterPatch)
700 // Do not analyze events with pileup
701 Bool_t bPileup = IsPileUpFromSPD();
702 //IsPileupFromSPDInMultBins() // method to try
703 //printf("pile-up %d, %d, %2.2f, %2.2f, %2.2f, %2.2f\n",bPileup, (Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
704 if(bPileup) return kFALSE;
706 if(fDoV0ANDEventSelection)
708 Bool_t bV0AND = kTRUE;
709 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
711 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
712 //else bV0AND = //FIXME FOR AODs
713 if(!bV0AND) return kFALSE;
718 if(fInputEvent->GetNumberOfCaloClusters() > 0)
720 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
721 if(calo->GetNLabels() == 4)
723 Int_t * selection = calo->GetLabels();
724 Bool_t bPileup = selection[0];
725 if(bPileup) return kFALSE;
727 Bool_t bGoodV = selection[1];
728 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
730 if(fDoV0ANDEventSelection)
732 Bool_t bV0AND = selection[2];
733 if(!bV0AND) return kFALSE;
736 fTrackMult = selection[3];
737 if(fTrackMult == 0) return kFALSE;
741 //First filtered AODs, track multiplicity stored there.
742 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
743 if(fTrackMult == 0) return kFALSE;
745 }//at least one cluster
748 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
749 //Remove events with vertex (0,0,0), bad vertex reconstruction
750 if(fUseEventsWithPrimaryVertex && TMath::Abs(fVertex[0][0]) < 1.e-6 && TMath::Abs(fVertex[0][1]) < 1.e-6 && TMath::Abs(fVertex[0][2]) < 1.e-6) return kFALSE;
752 //First filtered AODs, track multiplicity stored there.
753 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
754 if(fTrackMult == 0) return kFALSE;
756 }// CaloFileter patch
758 //------------------------------------------------------
760 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
761 //If we need a centrality bin, we select only those events in the corresponding bin.
762 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
764 Int_t cen = GetEventCentrality();
765 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
768 //Fill the arrays with cluster/tracks/cells data
771 FillInputEMCALCells();
774 FillInputPHOSCells();
778 if(fEventTriggerAtSE)
783 //Accept events with at least one track
784 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
793 // In case of mixing analysis, all triggers accepted, but trigger particles selected
794 // only for the specific trigered events selected here. Mixing done only for MB events,
795 // tracks array filled also for those events and not the others.
797 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
798 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
800 if(!inputHandler) return kFALSE ; // to content coverity
802 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
803 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
805 if(fFillCTS && (isMB || isTrigger))
808 //Accept events with at least one track
809 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
824 //___________________________________
825 void AliCaloTrackReader::ResetLists()
827 // Reset lists, called by the analysis maker
829 if(fCTSTracks) fCTSTracks -> Clear();
830 if(fEMCALClusters) fEMCALClusters -> Clear("C");
831 if(fPHOSClusters) fPHOSClusters -> Clear("C");
833 fV0ADC[0] = 0; fV0ADC[1] = 0;
834 fV0Mul[0] = 0; fV0Mul[1] = 0;
838 //____________________________________________________________
839 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
842 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
844 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
846 //Delete previous vertex
849 for (Int_t i = 0; i < fNMixedEvent; i++)
851 delete [] fVertex[i] ;
856 fVertex = new Double_t*[fNMixedEvent] ;
857 for (Int_t i = 0; i < fNMixedEvent; i++)
859 fVertex[i] = new Double_t[3] ;
860 fVertex[i][0] = 0.0 ;
861 fVertex[i][1] = 0.0 ;
862 fVertex[i][2] = 0.0 ;
866 //__________________________________________________
867 Int_t AliCaloTrackReader::GetEventCentrality() const
869 //Return current event centrality
873 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
874 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
875 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
878 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
886 //_____________________________________________________
887 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
889 //Return current event centrality
893 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
895 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
897 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
900 else if(GetEventPlaneMethod().Contains("V0") )
902 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
904 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
908 ep+=TMath::Pi()/2; // put same range as for <Q> method
912 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
915 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
916 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
923 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
929 //__________________________________________________________
930 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
932 //Return vertex position to be used for single event analysis
933 vertex[0]=fVertex[0][0];
934 vertex[1]=fVertex[0][1];
935 vertex[2]=fVertex[0][2];
938 //____________________________________________________________
939 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
940 const Int_t evtIndex) const
942 //Return vertex position for mixed event, recover the vertex in a particular event.
944 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
948 //________________________________________
949 void AliCaloTrackReader::FillVertexArray()
952 //Fill data member with vertex
953 //In case of Mixed event, multiple vertices
955 //Delete previous vertex
958 for (Int_t i = 0; i < fNMixedEvent; i++)
960 delete [] fVertex[i] ;
965 fVertex = new Double_t*[fNMixedEvent] ;
966 for (Int_t i = 0; i < fNMixedEvent; i++)
968 fVertex[i] = new Double_t[3] ;
969 fVertex[i][0] = 0.0 ;
970 fVertex[i][1] = 0.0 ;
971 fVertex[i][2] = 0.0 ;
975 { //Single event analysis
979 if(fInputEvent->GetPrimaryVertex())
981 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
985 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
986 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
987 }//Primary vertex pointer do not exist
991 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
995 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
998 { // MultiEvent analysis
999 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1001 if (fMixedEvent->GetVertexOfEvent(iev))
1002 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1004 { // no vertex found !!!!
1005 AliWarning("No vertex found");
1009 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1016 //_____________________________________
1017 void AliCaloTrackReader::FillInputCTS()
1019 //Return array with Central Tracking System (CTS) tracks
1021 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1023 Double_t pTrack[3] = {0,0,0};
1025 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1028 Double_t bz = GetInputEvent()->GetMagneticField();
1030 for(Int_t i = 0; i < 19; i++)
1032 fTrackBCEvent [i] = 0;
1033 fTrackBCEventCut[i] = 0;
1035 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1036 {////////////// track loop
1037 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1039 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1040 ULong_t status = track->GetStatus();
1042 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1047 if (fDataType==kESD)
1049 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1051 if(esdTrack && fESDtrackCuts->AcceptTrack(esdTrack))
1053 track->GetPxPyPz(pTrack) ;
1057 if(esdTrack->GetConstrainedParam())
1059 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1060 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1061 esdTrack->GetConstrainedPxPyPz(pTrack);
1065 } // use constrained tracks
1067 if(fSelectSPDHitTracks)
1068 {//Not much sense to use with TPC only or Hybrid tracks
1069 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1075 else if(fDataType==kAOD)
1077 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1081 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1082 aodtrack->GetType(),AliAODTrack::kPrimary,
1083 aodtrack->IsHybridGlobalConstrainedGlobal());
1086 if (fSelectHybridTracks)
1088 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1092 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1095 if(fSelectSPDHitTracks)
1096 {//Not much sense to use with TPC only or Hybrid tracks
1097 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1100 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1102 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
1104 track->GetPxPyPz(pTrack) ;
1106 } // aod track exists
1111 //Count the tracks in eta < 0.9
1112 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1113 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1115 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1117 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) && ( (status & AliVTrack::kTIME) == AliVTrack::kTIME );
1118 Double_t tof = -1000;
1120 Int_t trackBC = -1000 ;
1124 trackBC = track->GetTOFBunchCrossing(bz);
1125 SetTrackEventBC(trackBC+9);
1127 tof = track->GetTOFsignal()*1e-3;
1128 //printf("track TOF %e\n",tof);
1129 //bc = TMath::Nint((tof-25)/50) + 9;
1130 //printf("track pt %f, tof %2.2f, bc=%d\n",track->Pt(),tof,bc);
1131 //SetTrackEventBC(bc);
1135 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1137 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
1141 //SetTrackEventBCcut(bc);
1142 SetTrackEventBCcut(trackBC+9);
1144 //In any case, the time should to be larger than the fixed window ...
1145 if( fUseTrackTimeCut && trackBC==0 && (tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1147 //printf("Remove track time %f\n",tof);
1152 if(fDebug > 2 && momentum.Pt() > 0.1)
1153 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1154 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1156 if (fMixedEvent) track->SetID(itrack);
1158 fCTSTracks->Add(track);
1163 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1167 //__________________________________________________________________
1168 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1171 //Fill the EMCAL data in the array, do it
1175 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1177 //Reject clusters with bad channels, close to borders and exotic;
1178 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1180 //Mask all cells in collumns facing ALICE thick material if requested
1181 if(GetCaloUtils()->GetNMaskCellColumns())
1187 Bool_t shared = kFALSE;
1188 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1189 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1192 if(fSelectEmbeddedClusters)
1194 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1195 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1199 //clus->GetPosition(pos);
1200 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1202 if(fRecalculateClusters)
1204 //Recalibrate the cluster energy
1205 if(GetCaloUtils()->IsRecalibrationOn())
1207 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1210 //printf("Recalibrated Energy %f\n",clus->E());
1212 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1213 GetCaloUtils()->RecalculateClusterPID(clus);
1217 //Recalculate distance to bad channels, if new list of bad channels provided
1218 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1220 //Recalculate cluster position
1221 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1223 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1224 //clus->GetPosition(pos);
1225 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1229 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1231 Double_t tof = clus->GetTOF();
1233 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1235 if(fDataType==AliCaloTrackReader::kESD)
1237 tof = fEMCALCells->GetCellTime(absIdMax);
1240 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1244 }// Time recalibration
1247 //Correct non linearity
1248 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1250 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1251 //printf("Linearity Corrected Energy %f\n",clus->E());
1253 //In case of MC analysis, to match resolution/calibration in real data
1254 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1255 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1256 clus->SetE(rdmEnergy);
1259 Double_t tof = clus->GetTOF()*1e9;
1261 Int_t bc = TMath::Nint(tof/50) + 9;
1262 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1264 SetEMCalEventBC(bc);
1266 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1268 TLorentzVector momentum ;
1270 clus->GetMomentum(momentum, fVertex[vindex]);
1272 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1274 SetEMCalEventBCcut(bc);
1276 if(!IsInTimeWindow(tof,clus->E()))
1278 fNPileUpClusters++ ;
1279 if(fUseEMCALTimeCut) return ;
1282 fNNonPileUpClusters++;
1284 if(fDebug > 2 && momentum.E() > 0.1)
1285 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1286 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1289 clus->SetID(iclus) ;
1291 fEMCALClusters->Add(clus);
1295 //_______________________________________
1296 void AliCaloTrackReader::FillInputEMCAL()
1298 //Return array with EMCAL clusters in aod format
1300 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1302 // First recalibrate cells, time or energy
1303 // if(GetCaloUtils()->IsRecalibrationOn())
1304 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1306 // fInputEvent->GetBunchCrossNumber());
1308 fNPileUpClusters = 0; // Init counter
1309 fNNonPileUpClusters = 0; // Init counter
1310 for(Int_t i = 0; i < 19; i++)
1312 fEMCalBCEvent [i] = 0;
1313 fEMCalBCEventCut[i] = 0;
1316 //Loop to select clusters in fiducial cut and fill container with aodClusters
1317 if(fEMCALClustersListName=="")
1319 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1320 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1322 AliVCluster * clus = 0;
1323 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1325 if (IsEMCALCluster(clus))
1327 FillInputEMCALAlgorithm(clus, iclus);
1332 //Recalculate track matching
1333 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1335 }//Get the clusters from the input event
1338 TClonesArray * clusterList = 0x0;
1340 if (fInputEvent->FindListObject(fEMCALClustersListName))
1342 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1344 else if(fOutputEvent)
1346 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1351 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1355 Int_t nclusters = clusterList->GetEntriesFast();
1356 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1358 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1359 //printf("E %f\n",clus->E());
1360 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1361 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1364 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1365 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1367 fNPileUpClusters = 0; // Init counter
1368 fNNonPileUpClusters = 0; // Init counter
1369 for(Int_t i = 0; i < 19; i++)
1371 fEMCalBCEvent [i] = 0;
1372 fEMCalBCEventCut[i] = 0;
1375 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1377 AliVCluster * clus = 0;
1379 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1381 if (IsEMCALCluster(clus))
1385 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1386 Double_t tof = clus->GetTOF();
1387 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1390 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1392 //Reject clusters with bad channels, close to borders and exotic;
1393 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1395 Int_t bc = TMath::Nint(tof/50) + 9;
1396 SetEMCalEventBC(bc);
1398 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1400 TLorentzVector momentum ;
1402 clus->GetMomentum(momentum, fVertex[0]);
1404 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1406 SetEMCalEventBCcut(bc);
1408 if(!IsInTimeWindow(tof,clus->E()))
1409 fNPileUpClusters++ ;
1411 fNNonPileUpClusters++;
1417 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1419 // Recalculate track matching, not necessary if already done in the reclusterization task.
1420 // in case it was not done ...
1421 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1425 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1429 //______________________________________
1430 void AliCaloTrackReader::FillInputPHOS()
1432 //Return array with PHOS clusters in aod format
1434 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1436 //Loop to select clusters in fiducial cut and fill container with aodClusters
1437 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1438 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1440 AliVCluster * clus = 0;
1441 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1443 if (IsPHOSCluster(clus))
1445 //Check if the cluster contains any bad channel and if close to calorimeter borders
1448 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1449 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1451 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1454 if(fRecalculateClusters)
1456 //Recalibrate the cluster energy
1457 if(GetCaloUtils()->IsRecalibrationOn())
1459 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1464 TLorentzVector momentum ;
1466 clus->GetMomentum(momentum, fVertex[vindex]);
1468 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1470 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1472 if(fDebug > 2 && momentum.E() > 0.1)
1473 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1474 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1479 clus->SetID(iclus) ;
1482 fPHOSClusters->Add(clus);
1488 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1492 //____________________________________________
1493 void AliCaloTrackReader::FillInputEMCALCells()
1495 //Return array with EMCAL cells in aod format
1497 fEMCALCells = fInputEvent->GetEMCALCells();
1501 //___________________________________________
1502 void AliCaloTrackReader::FillInputPHOSCells()
1504 //Return array with PHOS cells in aod format
1506 fPHOSCells = fInputEvent->GetPHOSCells();
1510 //_______________________________________
1511 void AliCaloTrackReader::FillInputVZERO()
1513 //Fill VZERO information in data member, add all the channels information.
1514 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1515 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1519 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1520 for (Int_t i = 0; i < 32; i++)
1523 {//Only available in ESDs
1524 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1525 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1528 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1529 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1532 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1537 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1542 //___________________________________________________________________
1543 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1545 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1546 // different number and need to patch here
1548 if(fDataType==kAOD && fOldAOD)
1550 if (cluster->GetType() == 2) return kTRUE;
1555 return cluster->IsEMCAL();
1560 //___________________________________________________________________
1561 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1563 //Check if it is a cluster from PHOS.For old AODs cluster type has
1564 // different number and need to patch here
1566 if(fDataType==kAOD && fOldAOD)
1568 Int_t type = cluster->GetType();
1569 if (type == 0 || type == 1) return kTRUE;
1574 return cluster->IsPHOS();
1579 //________________________________________________
1580 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1582 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1585 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1586 if(!event) return kTRUE;
1588 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1593 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1596 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1598 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1602 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1604 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1613 //____________________________________________________________
1614 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1618 if(fESDtrackCuts) delete fESDtrackCuts ;
1620 fESDtrackCuts = cuts ;