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"
47 #include "AliAODMCParticle.h"
49 // ---- Detectors ----
50 #include "AliPHOSGeoUtils.h"
51 #include "AliEMCALGeometry.h"
52 #include "AliEMCALRecoUtils.h"
54 // ---- CaloTrackCorr ---
55 #include "AliCalorimeterUtils.h"
56 #include "AliCaloTrackReader.h"
58 ClassImp(AliCaloTrackReader)
61 //________________________________________
62 AliCaloTrackReader::AliCaloTrackReader() :
63 TObject(), fEventNumber(-1), //fCurrentFileName(""),
64 fDataType(0), fDebug(0),
65 fFiducialCut(0x0), fCheckFidCut(kFALSE),
66 fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(0),
67 fComparePtHardAndClusterPt(0),fPtHardAndClusterPtFactor(0),
68 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
69 fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
70 fUseEMCALTimeCut(1), fUseParamTimeCut(0), fUseTrackTimeCut(0),
71 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
72 fEMCALParamTimeCutMin(), fEMCALParamTimeCutMax(),
73 fTrackTimeCutMin(-10000), fTrackTimeCutMax(10000),
76 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
77 fEMCALCells(0x0), fPHOSCells(0x0),
78 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
79 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
80 fFillEMCALCells(0), fFillPHOSCells(0),
81 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
82 fTrackStatus(0), fTrackFilterMask(0),
83 fESDtrackCuts(0), fESDtrackComplementaryCuts(0), fConstrainTrack(kFALSE),
84 fSelectHybridTracks(0), fSelectSPDHitTracks(kFALSE),
85 fTrackMult(0), fTrackMultEtaCut(0.9),
86 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
87 fDeltaAODFileName(""), fFiredTriggerClassName(""),
88 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
90 fTaskName(""), fCaloUtils(0x0),
91 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
92 fListMixedTracksEvents(), fListMixedCaloEvents(),
93 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
94 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
95 fEMCALClustersListName(""), fZvtxCut(0.),
96 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
97 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE),
98 fDoVertexBCEventSelection(kFALSE),
99 fDoRejectNoTrackEvents(kFALSE),
100 fUseEventsWithPrimaryVertex(kFALSE),
101 fTriggerAnalysis (0x0), fTimeStampEventSelect(0),
102 fTimeStampEventFracMin(0), fTimeStampEventFracMax(0),
103 fTimeStampRunMin(0), fTimeStampRunMax(0),
104 fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
105 fVertexBC(-200), fRecalculateVertexBC(0),
106 fCentralityClass(""), fCentralityOpt(0),
107 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
111 //Initialize parameters
115 //_______________________________________
116 AliCaloTrackReader::~AliCaloTrackReader()
120 delete fFiducialCut ;
124 fAODBranchList->Delete();
125 delete fAODBranchList ;
130 if(fDataType!=kMC)fCTSTracks->Clear() ;
131 else fCTSTracks->Delete() ;
137 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
138 else fEMCALClusters->Delete() ;
139 delete fEMCALClusters ;
144 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
145 else fPHOSClusters->Delete() ;
146 delete fPHOSClusters ;
151 for (Int_t i = 0; i < fNMixedEvent; i++)
153 delete [] fVertex[i] ;
159 delete fESDtrackCuts;
160 delete fESDtrackComplementaryCuts;
161 delete fTriggerAnalysis;
163 // Pointers not owned, done by the analysis frame
164 // if(fInputEvent) delete fInputEvent ;
165 // if(fOutputEvent) delete fOutputEvent ;
166 // if(fMC) delete fMC ;
167 // Pointer not owned, deleted by maker
168 // if (fCaloUtils) delete fCaloUtils ;
172 //________________________________________________________________________
173 Bool_t AliCaloTrackReader::AcceptDCA(const Float_t pt, const Float_t dca)
175 // Accept track if DCA is smaller than function
177 Float_t cut = fTrackDCACut[0]+fTrackDCACut[1]/TMath::Power(pt,fTrackDCACut[2]);
179 if(TMath::Abs(dca) < cut)
186 //________________________________________________
187 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
189 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
192 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
194 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
197 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
198 Int_t nTriggerJets = pygeh->NTriggerJets();
199 Float_t ptHard = pygeh->GetPtHard();
202 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
204 Float_t tmpjet[]={0,0,0,0};
205 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
207 pygeh->TriggerJet(ijet, tmpjet);
208 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
211 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
213 //Compare jet pT and pt Hard
214 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
216 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
217 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
229 //____________________________________________________________________
230 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
232 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
235 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
237 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
238 Float_t ptHard = pygeh->GetPtHard();
240 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
241 for (Int_t iclus = 0; iclus < nclusters; iclus++)
243 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
244 Float_t ecluster = clus->E();
246 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
248 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
260 //_________________________________________________________________
261 void AliCaloTrackReader::CorrectMCLabelForAODs(AliVCluster * clus)
263 // AODs filter particles, not anymore correspondance with MC position in array
264 // Check if label is correct and if not, change it
266 Int_t * labels = clus->GetLabels();
268 for(UInt_t ilabel = 0; ilabel < clus->GetNLabels(); ilabel++)
270 Int_t orgLabel = labels[ilabel];
272 TClonesArray * arr = GetAODMCParticles() ;
276 printf("AliCaloTrackReader::CorrectMCLabelForAODs() - Input array not available\n");
280 AliAODMCParticle * particle = (AliAODMCParticle *)arr->At(orgLabel);
282 if(orgLabel != particle->Label())
284 // loop on the particles list and check if there is one with the same label
285 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
287 particle = (AliAODMCParticle *) arr->At(ind);
289 if(orgLabel == particle->Label()) labels[ilabel] = ind;
293 //if(orgLabel!=labels[ilabel]) printf("\t Label in %d - out %d \n",orgLabel, clus->GetLabels()[ilabel]);
298 //____________________________________________
299 AliStack* AliCaloTrackReader::GetStack() const
301 //Return pointer to stack
306 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
311 //__________________________________________________
312 TString AliCaloTrackReader::GetFiredTriggerClasses()
314 // List of triggered classes in a TString
316 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
317 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
319 if (esdevent) return esdevent->GetFiredTriggerClasses();
320 else if(aodevent) return aodevent->GetFiredTriggerClasses();
321 else return ""; // Mixed Event, MC event, does not have this trigger info
325 //______________________________________________
326 AliHeader* AliCaloTrackReader::GetHeader() const
328 //Return pointer to header
331 return fMC->Header();
335 printf("AliCaloTrackReader::Header is not available\n");
340 //______________________________________________________________
341 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
343 //Return pointer to Generated event header
344 if (ReadStack() && fMC)
346 return fMC->GenEventHeader();
348 else if(ReadAODMCParticles() && GetAODMCHeader())
350 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
351 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
352 return GetAODMCHeader()->GetCocktailHeader(0) ;
358 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
363 //____________________________________________________________________
364 TClonesArray* AliCaloTrackReader::GetAODMCParticles() const
366 //Return list of particles in AOD. Do it for the corresponding input event.
368 TClonesArray * rv = NULL ;
369 if(fDataType == kAOD)
372 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
374 rv = (TClonesArray*)evt->FindListObject("mcparticles");
376 printf("AliCaloTrackReader::GetAODMCParticles() - Null AOD event \n");
380 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
386 //________________________________________________________
387 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
389 //Return MC header in AOD. Do it for the corresponding input event.
391 AliAODMCHeader *mch = NULL;
393 if(fDataType == kAOD)
395 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
396 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
400 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
406 //___________________________________________________________
407 Int_t AliCaloTrackReader::GetVertexBC(const AliVVertex * vtx)
411 Int_t vertexBC=vtx->GetBC();
412 if(!fRecalculateVertexBC) return vertexBC;
414 // In old AODs BC not stored, recalculate it
415 // loop over the global track and select those which have small DCA to primary vertex (e.g. primary).
416 // If at least one of these primaries has valid BC != 0, then this vertex is a pile-up candidate.
418 Double_t bz = fInputEvent->GetMagneticField();
420 Int_t ntr = GetCTSTracks()->GetEntriesFast();
421 //printf("N Tracks %d\n",ntr);
423 for(Int_t i = 0 ; i < ntr ; i++)
425 AliVTrack * track = (AliVTrack*) (GetCTSTracks()->At(i));
427 //Check if has TOF info, if not skip
428 ULong_t status = track->GetStatus();
429 Bool_t okTOF = (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ;
430 vertexBC = track->GetTOFBunchCrossing(bz);
431 Float_t pt = track->Pt();
436 Double_t dca[2] = {1e6,1e6};
437 Double_t covar[3] = {1e6,1e6,1e6};
438 track->PropagateToDCA(vtx,bz,100.,dca,covar);
440 if(AcceptDCA(pt,dca[0]))
442 if (vertexBC !=0 && fVertexBC != AliVTrack::kTOFBCNA) return vertexBC;
443 else if(vertexBC == 0) bc0 = kTRUE;
447 if( bc0 ) vertexBC = 0 ;
448 else vertexBC = AliVTrack::kTOFBCNA ;
454 //_____________________________
455 void AliCaloTrackReader::Init()
457 //Init reader. Method to be called in AliAnaPartCorrMaker
459 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
461 if(fReadStack && fReadAODMCParticles)
463 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
465 fReadAODMCParticles = kFALSE;
468 // Init geometry, I do not like much to do it like this ...
469 if(fImportGeometryFromFile && !gGeoManager)
471 if(fImportGeometryFilePath=="") // If not specified, set a default location
472 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
474 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
475 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
479 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
483 //_______________________________________
484 void AliCaloTrackReader::InitParameters()
486 //Initialize the parameters of the analysis.
492 fEMCALPtMax = 1000. ;
496 // dca_xy cut = 0.0105+0.0350/TMath::Power(pt,1.1);
497 fTrackDCACut[0] = 0.0105;
498 fTrackDCACut[1] = 0.0350;
499 fTrackDCACut[2] = 1.1;
501 //Do not filter the detectors input by default.
505 fFillEMCALCells = kFALSE;
506 fFillPHOSCells = kFALSE;
508 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
509 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
510 fDeltaAODFileName = "deltaAODPartCorr.root";
511 fFiredTriggerClassName = "";
512 fEventTriggerMask = AliVEvent::kAny;
513 fMixEventTriggerMask = AliVEvent::kAnyINT;
514 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
516 fAcceptFastCluster = kTRUE;
519 //We want tracks fitted in the detectors:
520 //fTrackStatus=AliESDtrack::kTPCrefit;
521 //fTrackStatus|=AliESDtrack::kITSrefit;
523 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
526 fESDtrackComplementaryCuts = 0;
528 fConstrainTrack = kFALSE ; // constrain tracks to vertex
530 fV0ADC[0] = 0; fV0ADC[1] = 0;
531 fV0Mul[0] = 0; fV0Mul[1] = 0;
537 fPtHardAndJetPtFactor = 7.;
538 fPtHardAndClusterPtFactor = 1.;
541 fCentralityClass = "V0M";
543 fCentralityBin[0] = fCentralityBin[1]=-1;
545 fEventPlaneMethod = "V0";
547 // Allocate memory (not sure this is the right place)
548 fCTSTracks = new TObjArray();
549 fEMCALClusters = new TObjArray();
550 fPHOSClusters = new TObjArray();
551 fTriggerAnalysis = new AliTriggerAnalysis;
552 fAODBranchList = new TList ;
554 fImportGeometryFromFile = kFALSE;
556 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
557 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
559 // Parametrized time cut (LHC11d)
560 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
561 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
563 // Parametrized time cut (LHC11c)
564 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
565 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
567 fTimeStampRunMin = -1;
568 fTimeStampRunMax = 1e12;
569 fTimeStampEventFracMin = -1;
570 fTimeStampEventFracMax = 2;
572 for(Int_t i = 0; i < 19; i++)
574 fEMCalBCEvent [i] = 0;
575 fEMCalBCEventCut[i] = 0;
576 fTrackBCEvent [i] = 0;
577 fTrackBCEventCut[i] = 0;
582 //___________________________________________________________
583 Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
585 // Cluster time selection window
587 // Parametrized cut depending on E
590 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
591 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
592 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
593 if( tof < minCut || tof > maxCut ) return kFALSE ;
596 //In any case, the time should to be larger than the fixed window ...
597 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
602 //________________________________________________
603 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
605 // Check if event is from pile-up determined by SPD
606 // Default values: (3, 0.8, 3., 2., 5.)
607 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
608 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
609 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
613 //__________________________________________________
614 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
616 // Check if event is from pile-up determined by EMCal
617 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
621 //________________________________________________________
622 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
624 // Check if event is from pile-up determined by SPD and EMCal
625 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
629 //_______________________________________________________
630 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
632 // Check if event is from pile-up determined by SPD or EMCal
633 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
637 //___________________________________________________________
638 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
640 // Check if event is from pile-up determined by SPD and not by EMCal
641 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
645 //___________________________________________________________
646 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
648 // Check if event is from pile-up determined by EMCal, not by SPD
649 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
653 //______________________________________________________________
654 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
656 // Check if event not from pile-up determined neither by SPD nor by EMCal
657 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
661 //________________________________________________________
662 void AliCaloTrackReader::Print(const Option_t * opt) const
665 //Print some relevant parameters set for the analysis
669 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
670 printf("Task name : %s\n", fTaskName.Data()) ;
671 printf("Data type : %d\n", fDataType) ;
672 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
673 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
674 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
675 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
676 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
677 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
678 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
679 printf("Use CTS = %d\n", fFillCTS) ;
680 printf("Use EMCAL = %d\n", fFillEMCAL) ;
681 printf("Use PHOS = %d\n", fFillPHOS) ;
682 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
683 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
684 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
685 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
686 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
687 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
688 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
690 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
691 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
693 if(fComparePtHardAndClusterPt)
694 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
696 if(fComparePtHardAndClusterPt)
697 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
699 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
700 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
701 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
707 //_________________________________________________________________________
708 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
709 const char * /*currentFileName*/)
711 //Fill the event counter and input lists that are needed, called by the analysis maker.
713 fEventNumber = iEntry;
714 //fCurrentFileName = TString(currentFileName);
717 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
721 //Select events only fired by a certain trigger configuration if it is provided
723 if(fInputEvent->GetHeader())
724 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
726 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
728 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
732 //-------------------------------------------------------------------------------------
733 // Reject event if large clusters with large energy
734 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
735 // If clusterzer NxN or V2 it does not help
736 //-------------------------------------------------------------------------------------
737 Int_t run = fInputEvent->GetRunNumber();
738 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
740 //printf("Event %d\n",GetEventNumber());
742 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
744 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
746 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
747 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
748 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
752 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
754 if(ncellsSM3 >= ncellcut)
756 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d\n",ncellsSM3);
759 }// Remove LED events
761 // Reject pure LED events?
762 if( fFiredTriggerClassName !="" && !fAnaLED)
764 //printf("Event type %d\n",eventType);
766 return kFALSE; //Only physics event, do not use for simulated events!!!
769 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
770 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
772 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
773 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
777 // kStartOfRun = 1, // START_OF_RUN
778 // kEndOfRun = 2, // END_OF_RUN
779 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
780 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
781 // kStartOfBurst = 5, // START_OF_BURST
782 // kEndOfBurst = 6, // END_OF_BURST
783 // kPhysicsEvent = 7, // PHYSICS_EVENT
784 // kCalibrationEvent = 8, // CALIBRATION_EVENT
785 // kFormatError = 9, // EVENT_FORMAT_ERROR
786 // kStartOfData = 10, // START_OF_DATA
787 // kEndOfData = 11, // END_OF_DATA
788 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
789 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
791 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
792 if(eventType!=8)return kFALSE;
795 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
796 if(fComparePtHardAndJetPt)
798 if(!ComparePtHardAndJetPt()) return kFALSE ;
801 if(fComparePtHardAndClusterPt)
803 if(!ComparePtHardAndClusterPt()) return kFALSE ;
808 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
809 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
811 //------------------------------------------------------
812 //Event rejection depending on vertex, pileup, v0and
813 //------------------------------------------------------
814 if(fDataType==kESD && fTimeStampEventSelect)
816 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
819 Int_t timeStamp = esd->GetTimeStamp();
820 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
822 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, timeStampFrac);
824 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
826 //printf("\t accept time stamp\n");
830 //------------------------------------------------------
831 //Event rejection depending on vertex, pileup, v0and
832 //------------------------------------------------------
834 if(fUseEventsWithPrimaryVertex)
836 if( !CheckForPrimaryVertex() ) return kFALSE;
837 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
838 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
839 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
842 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
844 if(fDoEventSelection)
846 if(!fCaloFilterPatch)
848 // Do not analyze events with pileup
849 Bool_t bPileup = IsPileUpFromSPD();
850 //IsPileupFromSPDInMultBins() // method to try
851 //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]);
852 if(bPileup) return kFALSE;
854 if(fDoV0ANDEventSelection)
856 Bool_t bV0AND = kTRUE;
857 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
859 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
860 //else bV0AND = //FIXME FOR AODs
861 if(!bV0AND) return kFALSE;
866 if(fInputEvent->GetNumberOfCaloClusters() > 0)
868 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
869 if(calo->GetNLabels() == 4)
871 Int_t * selection = calo->GetLabels();
872 Bool_t bPileup = selection[0];
873 if(bPileup) return kFALSE;
875 Bool_t bGoodV = selection[1];
876 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
878 if(fDoV0ANDEventSelection)
880 Bool_t bV0AND = selection[2];
881 if(!bV0AND) return kFALSE;
884 fTrackMult = selection[3];
885 if(fTrackMult == 0) return kFALSE;
889 //First filtered AODs, track multiplicity stored there.
890 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
891 if(fTrackMult == 0) return kFALSE;
893 }//at least one cluster
896 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
897 //Remove events with vertex (0,0,0), bad vertex reconstruction
898 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;
900 //First filtered AODs, track multiplicity stored there.
901 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
902 if(fTrackMult == 0) return kFALSE;
904 }// CaloFileter patch
905 }// Event selection/AliceSoft/AliRoot/trunk/PWG/CaloTrackCorrBase/AliCaloTrackReader.h
906 //------------------------------------------------------
908 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
909 //If we need a centrality bin, we select only those events in the corresponding bin.
910 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
912 Int_t cen = GetEventCentrality();
913 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
916 //Fill the arrays with cluster/tracks/cells data
918 if(!fEventTriggerAtSE)
920 // In case of mixing analysis, accept MB events, not only Trigger
921 // Track and cluster arrays filled for MB in order to create the pool in the corresponding analysis
922 // via de method in the base class FillMixedEventPool()
924 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
925 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
927 if(!inputHandler) return kFALSE ; // to content coverity
929 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
930 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
932 if(!isTrigger && !isMB) return kFALSE;
934 //printf("Selected triggered event : %s\n",GetFiredTriggerClasses().Data());
937 // Get the main vertex BC, in case not available
938 // it is calculated in FillCTS checking the BC of tracks
939 // with DCA small (if cut applied, if open)
940 fVertexBC=fInputEvent->GetPrimaryVertex()->GetBC();
945 //Accept events with at least one track
946 if(fTrackMult == 0 && fDoRejectNoTrackEvents) return kFALSE ;
949 if(fDoVertexBCEventSelection)
951 if(fVertexBC!=0 && fVertexBC!=AliVTrack::kTOFBCNA) return kFALSE ;
955 FillInputEMCALCells();
958 FillInputPHOSCells();
972 //___________________________________
973 void AliCaloTrackReader::ResetLists()
975 // Reset lists, called by the analysis maker
977 if(fCTSTracks) fCTSTracks -> Clear();
978 if(fEMCALClusters) fEMCALClusters -> Clear("C");
979 if(fPHOSClusters) fPHOSClusters -> Clear("C");
981 fV0ADC[0] = 0; fV0ADC[1] = 0;
982 fV0Mul[0] = 0; fV0Mul[1] = 0;
986 //____________________________________________________________
987 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
990 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
992 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
994 //Delete previous vertex
997 for (Int_t i = 0; i < fNMixedEvent; i++)
999 delete [] fVertex[i] ;
1004 fVertex = new Double_t*[fNMixedEvent] ;
1005 for (Int_t i = 0; i < fNMixedEvent; i++)
1007 fVertex[i] = new Double_t[3] ;
1008 fVertex[i][0] = 0.0 ;
1009 fVertex[i][1] = 0.0 ;
1010 fVertex[i][2] = 0.0 ;
1014 //__________________________________________________
1015 Int_t AliCaloTrackReader::GetEventCentrality() const
1017 //Return current event centrality
1021 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
1022 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
1023 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
1026 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
1034 //_____________________________________________________
1035 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
1037 //Return current event centrality
1041 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
1043 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
1045 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
1048 else if(GetEventPlaneMethod().Contains("V0") )
1050 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
1052 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
1056 ep+=TMath::Pi()/2; // put same range as for <Q> method
1060 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
1063 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
1064 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
1071 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
1077 //__________________________________________________________
1078 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
1080 //Return vertex position to be used for single event analysis
1081 vertex[0]=fVertex[0][0];
1082 vertex[1]=fVertex[0][1];
1083 vertex[2]=fVertex[0][2];
1086 //____________________________________________________________
1087 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
1088 const Int_t evtIndex) const
1090 //Return vertex position for mixed event, recover the vertex in a particular event.
1092 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
1096 //________________________________________
1097 void AliCaloTrackReader::FillVertexArray()
1100 //Fill data member with vertex
1101 //In case of Mixed event, multiple vertices
1103 //Delete previous vertex
1106 for (Int_t i = 0; i < fNMixedEvent; i++)
1108 delete [] fVertex[i] ;
1113 fVertex = new Double_t*[fNMixedEvent] ;
1114 for (Int_t i = 0; i < fNMixedEvent; i++)
1116 fVertex[i] = new Double_t[3] ;
1117 fVertex[i][0] = 0.0 ;
1118 fVertex[i][1] = 0.0 ;
1119 fVertex[i][2] = 0.0 ;
1123 { //Single event analysis
1127 if(fInputEvent->GetPrimaryVertex())
1129 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1133 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1134 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1135 }//Primary vertex pointer do not exist
1139 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1143 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
1146 { // MultiEvent analysis
1147 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1149 if (fMixedEvent->GetVertexOfEvent(iev))
1150 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1152 { // no vertex found !!!!
1153 AliWarning("No vertex found");
1157 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1164 //_____________________________________
1165 void AliCaloTrackReader::FillInputCTS()
1167 //Return array with Central Tracking System (CTS) tracks
1169 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1171 Double_t pTrack[3] = {0,0,0};
1173 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1176 Double_t bz = GetInputEvent()->GetMagneticField();
1178 for(Int_t i = 0; i < 19; i++)
1180 fTrackBCEvent [i] = 0;
1181 fTrackBCEventCut[i] = 0;
1184 Bool_t bc0 = kFALSE;
1185 if(fRecalculateVertexBC) fVertexBC=AliVTrack::kTOFBCNA;
1187 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1188 {////////////// track loop
1189 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1191 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1192 ULong_t status = track->GetStatus();
1194 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1199 Float_t dcaTPC =-999;
1201 if (fDataType==kESD)
1203 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1207 if(fESDtrackCuts->AcceptTrack(esdTrack))
1209 track->GetPxPyPz(pTrack) ;
1213 if(esdTrack->GetConstrainedParam())
1215 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1216 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1217 esdTrack->GetConstrainedPxPyPz(pTrack);
1221 } // use constrained tracks
1223 if(fSelectSPDHitTracks)
1224 {//Not much sense to use with TPC only or Hybrid tracks
1225 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1228 // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
1229 else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
1231 // constrain the track
1232 if(esdTrack->GetConstrainedParam())
1234 esdTrack->Set(esdTrack->GetConstrainedParam()->GetX(),esdTrack->GetConstrainedParam()->GetAlpha(),esdTrack->GetConstrainedParam()->GetParameter(),esdTrack->GetConstrainedParam()->GetCovariance());
1236 track->GetPxPyPz(pTrack) ;
1244 else if(fDataType==kAOD)
1246 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1250 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1251 aodtrack->GetType(),AliAODTrack::kPrimary,
1252 aodtrack->IsHybridGlobalConstrainedGlobal());
1255 if (fSelectHybridTracks)
1257 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1261 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1264 if(fSelectSPDHitTracks)
1265 {//Not much sense to use with TPC only or Hybrid tracks
1266 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1269 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1271 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
1273 //In case of AODs, TPC tracks cannot be propagated back to primary vertex,
1275 dcaTPC = aodtrack->DCA();
1277 track->GetPxPyPz(pTrack) ;
1279 } // aod track exists
1284 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1286 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
1287 Double_t tof = -1000;
1288 Int_t trackBC = -1000 ;
1292 trackBC = track->GetTOFBunchCrossing(bz);
1293 SetTrackEventBC(trackBC+9);
1295 tof = track->GetTOFsignal()*1e-3;
1300 //normal way to get the dca, cut on dca_xy
1303 Double_t dca[2] = {1e6,1e6};
1304 Double_t covar[3] = {1e6,1e6,1e6};
1305 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1306 if( okDCA) okDCA = AcceptDCA(momentum.Pt(),dca[0]);
1309 //printf("AliCaloTrackReader::FillInputCTS() - Reject track pt %2.2f, dca_xy %2.4f, BC %d\n",momentum.Pt(),dca[0],trackBC);
1317 //SetTrackEventBCcut(bc);
1318 SetTrackEventBCcut(trackBC+9);
1320 //After selecting tracks with small DCA, pointing to vertex, set vertex BC depeding on tracks BC
1321 if(fRecalculateVertexBC)
1323 if (trackBC !=0 && trackBC != AliVTrack::kTOFBCNA) fVertexBC = trackBC;
1324 else if(trackBC == 0) bc0 = kTRUE;
1327 //In any case, the time should to be larger than the fixed window ...
1328 if( fUseTrackTimeCut && (trackBC!=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1330 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
1333 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1337 //Count the tracks in eta < 0.9
1338 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1339 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1341 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1343 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
1345 if(fDebug > 2 && momentum.Pt() > 0.1)
1346 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1347 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1349 if (fMixedEvent) track->SetID(itrack);
1351 fCTSTracks->Add(track);
1355 if(fVertexBC ==0 || fVertexBC == AliVTrack::kTOFBCNA)
1357 if( bc0 ) fVertexBC = 0 ;
1358 else fVertexBC = AliVTrack::kTOFBCNA ;
1362 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1366 //__________________________________________________________________
1367 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1370 //Fill the EMCAL data in the array, do it
1374 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1376 //Reject clusters with bad channels, close to borders and exotic;
1377 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1379 //Mask all cells in collumns facing ALICE thick material if requested
1380 if(GetCaloUtils()->GetNMaskCellColumns())
1386 Bool_t shared = kFALSE;
1387 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1388 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1391 if(fSelectEmbeddedClusters)
1393 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1394 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1398 //clus->GetPosition(pos);
1399 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1401 if(fRecalculateClusters)
1403 //Recalibrate the cluster energy
1404 if(GetCaloUtils()->IsRecalibrationOn())
1406 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1409 //printf("Recalibrated Energy %f\n",clus->E());
1411 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1412 GetCaloUtils()->RecalculateClusterPID(clus);
1416 //Recalculate distance to bad channels, if new list of bad channels provided
1417 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1419 //Recalculate cluster position
1420 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1422 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1423 //clus->GetPosition(pos);
1424 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1428 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1430 Double_t tof = clus->GetTOF();
1432 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1434 if(fDataType==AliCaloTrackReader::kESD)
1436 tof = fEMCALCells->GetCellTime(absIdMax);
1439 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1443 }// Time recalibration
1446 //Correct non linearity
1447 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1449 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1450 //printf("Linearity Corrected Energy %f\n",clus->E());
1452 //In case of MC analysis, to match resolution/calibration in real data
1453 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1454 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1455 clus->SetE(rdmEnergy);
1458 Double_t tof = clus->GetTOF()*1e9;
1460 Int_t bc = TMath::Nint(tof/50) + 9;
1461 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1463 SetEMCalEventBC(bc);
1465 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1467 TLorentzVector momentum ;
1469 clus->GetMomentum(momentum, fVertex[vindex]);
1471 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1473 SetEMCalEventBCcut(bc);
1475 if(!IsInTimeWindow(tof,clus->E()))
1477 fNPileUpClusters++ ;
1478 if(fUseEMCALTimeCut) return ;
1481 fNNonPileUpClusters++;
1483 if(fDebug > 2 && momentum.E() > 0.1)
1484 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1485 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1488 clus->SetID(iclus) ;
1490 //Correct MC label for AODs
1492 if(ReadAODMCParticles())
1493 CorrectMCLabelForAODs(clus);
1495 fEMCALClusters->Add(clus);
1499 //_______________________________________
1500 void AliCaloTrackReader::FillInputEMCAL()
1502 //Return array with EMCAL clusters in aod format
1504 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1506 // First recalibrate cells, time or energy
1507 // if(GetCaloUtils()->IsRecalibrationOn())
1508 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1510 // fInputEvent->GetBunchCrossNumber());
1512 fNPileUpClusters = 0; // Init counter
1513 fNNonPileUpClusters = 0; // Init counter
1514 for(Int_t i = 0; i < 19; i++)
1516 fEMCalBCEvent [i] = 0;
1517 fEMCalBCEventCut[i] = 0;
1520 //Loop to select clusters in fiducial cut and fill container with aodClusters
1521 if(fEMCALClustersListName=="")
1523 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1524 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1526 AliVCluster * clus = 0;
1527 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1529 if (IsEMCALCluster(clus))
1531 FillInputEMCALAlgorithm(clus, iclus);
1536 //Recalculate track matching
1537 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1539 }//Get the clusters from the input event
1542 TClonesArray * clusterList = 0x0;
1544 if (fInputEvent->FindListObject(fEMCALClustersListName))
1546 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1548 else if(fOutputEvent)
1550 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1555 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1559 Int_t nclusters = clusterList->GetEntriesFast();
1560 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1562 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1563 //printf("E %f\n",clus->E());
1564 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1565 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1568 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1569 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1571 fNPileUpClusters = 0; // Init counter
1572 fNNonPileUpClusters = 0; // Init counter
1573 for(Int_t i = 0; i < 19; i++)
1575 fEMCalBCEvent [i] = 0;
1576 fEMCalBCEventCut[i] = 0;
1579 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1581 AliVCluster * clus = 0;
1583 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1585 if (IsEMCALCluster(clus))
1589 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1590 Double_t tof = clus->GetTOF();
1591 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1594 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1596 //Reject clusters with bad channels, close to borders and exotic;
1597 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1599 Int_t bc = TMath::Nint(tof/50) + 9;
1600 SetEMCalEventBC(bc);
1602 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1604 TLorentzVector momentum ;
1606 clus->GetMomentum(momentum, fVertex[0]);
1608 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1610 SetEMCalEventBCcut(bc);
1612 if(!IsInTimeWindow(tof,clus->E()))
1613 fNPileUpClusters++ ;
1615 fNNonPileUpClusters++;
1621 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1623 // Recalculate track matching, not necessary if already done in the reclusterization task.
1624 // in case it was not done ...
1625 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1629 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1633 //______________________________________
1634 void AliCaloTrackReader::FillInputPHOS()
1636 //Return array with PHOS clusters in aod format
1638 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1640 //Loop to select clusters in fiducial cut and fill container with aodClusters
1641 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1642 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1644 AliVCluster * clus = 0;
1645 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1647 if (IsPHOSCluster(clus))
1649 //Check if the cluster contains any bad channel and if close to calorimeter borders
1652 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1653 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1655 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1658 if(fRecalculateClusters)
1660 //Recalibrate the cluster energy
1661 if(GetCaloUtils()->IsRecalibrationOn())
1663 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1668 TLorentzVector momentum ;
1670 clus->GetMomentum(momentum, fVertex[vindex]);
1672 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1674 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1676 if(fDebug > 2 && momentum.E() > 0.1)
1677 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1678 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1683 clus->SetID(iclus) ;
1686 if(ReadAODMCParticles())
1687 CorrectMCLabelForAODs(clus);
1689 fPHOSClusters->Add(clus);
1695 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1699 //____________________________________________
1700 void AliCaloTrackReader::FillInputEMCALCells()
1702 //Return array with EMCAL cells in aod format
1704 fEMCALCells = fInputEvent->GetEMCALCells();
1708 //___________________________________________
1709 void AliCaloTrackReader::FillInputPHOSCells()
1711 //Return array with PHOS cells in aod format
1713 fPHOSCells = fInputEvent->GetPHOSCells();
1717 //_______________________________________
1718 void AliCaloTrackReader::FillInputVZERO()
1720 //Fill VZERO information in data member, add all the channels information.
1721 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1722 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1726 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1727 for (Int_t i = 0; i < 32; i++)
1730 {//Only available in ESDs
1731 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1732 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1735 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1736 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1739 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1744 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1749 //___________________________________________________________________
1750 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1752 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1753 // different number and need to patch here
1755 if(fDataType==kAOD && fOldAOD)
1757 if (cluster->GetType() == 2) return kTRUE;
1762 return cluster->IsEMCAL();
1767 //___________________________________________________________________
1768 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1770 //Check if it is a cluster from PHOS.For old AODs cluster type has
1771 // different number and need to patch here
1773 if(fDataType==kAOD && fOldAOD)
1775 Int_t type = cluster->GetType();
1776 if (type == 0 || type == 1) return kTRUE;
1781 return cluster->IsPHOS();
1786 //________________________________________________
1787 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1789 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1792 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1793 if(!event) return kTRUE;
1795 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1800 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1803 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1805 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1809 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1811 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1820 //____________________________________________________________
1821 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1825 if(fESDtrackCuts) delete fESDtrackCuts ;
1827 fESDtrackCuts = cuts ;
1831 //_________________________________________________________________________
1832 void AliCaloTrackReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
1834 // Set Track cuts for complementary tracks (hybrids)
1836 if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
1838 fESDtrackComplementaryCuts = cuts ;