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),
75 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
76 fEMCALCells(0x0), fPHOSCells(0x0),
77 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
78 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
79 fFillEMCALCells(0), fFillPHOSCells(0),
80 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
81 fTrackStatus(0), fTrackFilterMask(0),
82 fESDtrackCuts(0), fESDtrackComplementaryCuts(0), fConstrainTrack(kFALSE),
83 fSelectHybridTracks(0), fSelectSPDHitTracks(kFALSE),
84 fTrackMult(0), fTrackMultEtaCut(0.9),
85 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
86 fDeltaAODFileName(""), fFiredTriggerClassName(""),
87 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
89 fTaskName(""), fCaloUtils(0x0),
90 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
91 fListMixedTracksEvents(), fListMixedCaloEvents(),
92 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
93 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
94 fEMCALClustersListName(""), fZvtxCut(0.),
95 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
96 fRemoveExoticEvents(kFALSE), fExoticTrigger(3), fIsExoticEvent(kFALSE),
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 AliStack* AliCaloTrackReader::GetStack() const
263 //Return pointer to stack
268 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
273 //__________________________________________________
274 TString AliCaloTrackReader::GetFiredTriggerClasses()
276 // List of triggered classes in a TString
278 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
279 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
281 if (esdevent) return esdevent->GetFiredTriggerClasses();
282 else if(aodevent) return aodevent->GetFiredTriggerClasses();
283 else return ""; // Mixed Event, MC event, does not have this trigger info
287 //______________________________________________
288 AliHeader* AliCaloTrackReader::GetHeader() const
290 //Return pointer to header
293 return fMC->Header();
297 printf("AliCaloTrackReader::Header is not available\n");
302 //______________________________________________________________
303 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
305 //Return pointer to Generated event header
306 if (ReadStack() && fMC)
308 return fMC->GenEventHeader();
310 else if(ReadAODMCParticles() && GetAODMCHeader())
312 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
313 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
314 return GetAODMCHeader()->GetCocktailHeader(0) ;
320 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
325 //____________________________________________________________________
326 TClonesArray* AliCaloTrackReader::GetAODMCParticles() const
328 //Return list of particles in AOD. Do it for the corresponding input event.
330 TClonesArray * rv = NULL ;
331 if(fDataType == kAOD)
334 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
336 rv = (TClonesArray*)evt->FindListObject("mcparticles");
338 printf("AliCaloTrackReader::GetAODMCParticles() - Null AOD event \n");
342 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
348 //________________________________________________________
349 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
351 //Return MC header in AOD. Do it for the corresponding input event.
353 AliAODMCHeader *mch = NULL;
355 if(fDataType == kAOD)
357 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
358 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
362 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
368 //___________________________________________________________
369 Int_t AliCaloTrackReader::GetVertexBC(const AliVVertex * vtx)
373 Int_t vertexBC=vtx->GetBC();
374 if(!fRecalculateVertexBC) return vertexBC;
376 // In old AODs BC not stored, recalculate it
377 // loop over the global track and select those which have small DCA to primary vertex (e.g. primary).
378 // If at least one of these primaries has valid BC != 0, then this vertex is a pile-up candidate.
380 Double_t bz = fInputEvent->GetMagneticField();
382 Int_t ntr = GetCTSTracks()->GetEntriesFast();
383 //printf("N Tracks %d\n",ntr);
385 for(Int_t i = 0 ; i < ntr ; i++)
387 AliVTrack * track = (AliVTrack*) (GetCTSTracks()->At(i));
389 //Check if has TOF info, if not skip
390 ULong_t status = track->GetStatus();
391 Bool_t okTOF = (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ;
392 vertexBC = track->GetTOFBunchCrossing(bz);
393 Float_t pt = track->Pt();
398 Double_t dca[2] = {1e6,1e6};
399 Double_t covar[3] = {1e6,1e6,1e6};
400 track->PropagateToDCA(vtx,bz,100.,dca,covar);
402 if(AcceptDCA(pt,dca[0]))
404 if (vertexBC !=0 && fVertexBC != AliVTrack::kTOFBCNA) return vertexBC;
405 else if(vertexBC == 0) bc0 = kTRUE;
409 if( bc0 ) vertexBC = 0 ;
410 else vertexBC = AliVTrack::kTOFBCNA ;
416 //_____________________________
417 void AliCaloTrackReader::Init()
419 //Init reader. Method to be called in AliAnaPartCorrMaker
421 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
423 if(fReadStack && fReadAODMCParticles)
425 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
427 fReadAODMCParticles = kFALSE;
430 // Init geometry, I do not like much to do it like this ...
431 if(fImportGeometryFromFile && !gGeoManager)
433 if(fImportGeometryFilePath=="") // If not specified, set a default location
434 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
436 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
437 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
441 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
445 //_______________________________________
446 void AliCaloTrackReader::InitParameters()
448 //Initialize the parameters of the analysis.
454 fEMCALPtMax = 1000. ;
458 // dca_xy cut = 0.0105+0.0350/TMath::Power(pt,1.1);
459 fTrackDCACut[0] = 0.0105;
460 fTrackDCACut[1] = 0.0350;
461 fTrackDCACut[2] = 1.1;
463 //Do not filter the detectors input by default.
467 fFillEMCALCells = kFALSE;
468 fFillPHOSCells = kFALSE;
470 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
471 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
472 fDeltaAODFileName = "deltaAODPartCorr.root";
473 fFiredTriggerClassName = "";
474 fEventTriggerMask = AliVEvent::kAny;
475 fMixEventTriggerMask = AliVEvent::kAnyINT;
476 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
478 fAcceptFastCluster = kTRUE;
481 //We want tracks fitted in the detectors:
482 //fTrackStatus=AliESDtrack::kTPCrefit;
483 //fTrackStatus|=AliESDtrack::kITSrefit;
485 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
488 fESDtrackComplementaryCuts = 0;
490 fConstrainTrack = kFALSE ; // constrain tracks to vertex
492 fV0ADC[0] = 0; fV0ADC[1] = 0;
493 fV0Mul[0] = 0; fV0Mul[1] = 0;
499 fPtHardAndJetPtFactor = 7.;
500 fPtHardAndClusterPtFactor = 1.;
503 fCentralityClass = "V0M";
505 fCentralityBin[0] = fCentralityBin[1]=-1;
507 fEventPlaneMethod = "V0";
509 // Allocate memory (not sure this is the right place)
510 fCTSTracks = new TObjArray();
511 fEMCALClusters = new TObjArray();
512 fPHOSClusters = new TObjArray();
513 fTriggerAnalysis = new AliTriggerAnalysis;
514 fAODBranchList = new TList ;
516 fImportGeometryFromFile = kFALSE;
518 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
519 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
521 // Parametrized time cut (LHC11d)
522 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
523 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
525 // Parametrized time cut (LHC11c)
526 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
527 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
529 fTimeStampRunMin = -1;
530 fTimeStampRunMax = 1e12;
531 fTimeStampEventFracMin = -1;
532 fTimeStampEventFracMax = 2;
534 for(Int_t i = 0; i < 19; i++)
536 fEMCalBCEvent [i] = 0;
537 fEMCalBCEventCut[i] = 0;
538 fTrackBCEvent [i] = 0;
539 fTrackBCEventCut[i] = 0;
544 //___________________________________________________________
545 Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
547 // Cluster time selection window
549 // Parametrized cut depending on E
552 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
553 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
554 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
555 if( tof < minCut || tof > maxCut ) return kFALSE ;
558 //In any case, the time should to be larger than the fixed window ...
559 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
564 //________________________________________________
565 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
567 // Check if event is from pile-up determined by SPD
568 // Default values: (3, 0.8, 3., 2., 5.)
569 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
570 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
571 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
575 //__________________________________________________
576 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
578 // Check if event is from pile-up determined by EMCal
579 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
583 //________________________________________________________
584 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
586 // Check if event is from pile-up determined by SPD and EMCal
587 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
591 //_______________________________________________________
592 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
594 // Check if event is from pile-up determined by SPD or EMCal
595 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
599 //___________________________________________________________
600 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
602 // Check if event is from pile-up determined by SPD and not by EMCal
603 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
607 //___________________________________________________________
608 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
610 // Check if event is from pile-up determined by EMCal, not by SPD
611 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
615 //______________________________________________________________
616 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
618 // Check if event not from pile-up determined neither by SPD nor by EMCal
619 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
623 //________________________________________________________
624 void AliCaloTrackReader::Print(const Option_t * opt) const
627 //Print some relevant parameters set for the analysis
631 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
632 printf("Task name : %s\n", fTaskName.Data()) ;
633 printf("Data type : %d\n", fDataType) ;
634 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
635 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
636 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
637 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
638 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
639 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
640 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
641 printf("Use CTS = %d\n", fFillCTS) ;
642 printf("Use EMCAL = %d\n", fFillEMCAL) ;
643 printf("Use PHOS = %d\n", fFillPHOS) ;
644 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
645 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
646 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
647 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
648 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
649 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
650 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
652 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
653 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
655 if(fComparePtHardAndClusterPt)
656 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
658 if(fComparePtHardAndClusterPt)
659 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
661 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
662 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
663 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
669 //_________________________________________________________________________
670 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
671 const char * /*currentFileName*/)
673 //Fill the event counter and input lists that are needed, called by the analysis maker.
675 fEventNumber = iEntry;
676 //fCurrentFileName = TString(currentFileName);
679 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
683 //Select events only fired by a certain trigger configuration if it is provided
685 if(fInputEvent->GetHeader())
686 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
688 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
690 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
695 //---------------------------------------------------------------------
696 // Do not count events that where likely triggered by an exotic cluster
697 //---------------------------------------------------------------------
698 if(fRemoveExoticEvents && GetFiredTriggerClasses().Contains("EMC"))
700 RejectExoticEvents();
701 //printf("Is this event exotic? %d\n",fIsExoticEvent);
702 if(fIsExoticEvent) return kFALSE;
705 //-------------------------------------------------------------------------------------
706 // Reject event if large clusters with large energy
707 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
708 // If clusterzer NxN or V2 it does not help
709 //-------------------------------------------------------------------------------------
710 Int_t run = fInputEvent->GetRunNumber();
711 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
713 Bool_t reject = RejectLEDEvents();
714 if(reject) return kFALSE;
715 }// Remove LED events
717 //------------------------
718 // Reject pure LED events?
719 //-------------------------
720 if( fFiredTriggerClassName !="" && !fAnaLED)
722 //printf("Event type %d\n",eventType);
724 return kFALSE; //Only physics event, do not use for simulated events!!!
727 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
728 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
730 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
731 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
735 // kStartOfRun = 1, // START_OF_RUN
736 // kEndOfRun = 2, // END_OF_RUN
737 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
738 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
739 // kStartOfBurst = 5, // START_OF_BURST
740 // kEndOfBurst = 6, // END_OF_BURST
741 // kPhysicsEvent = 7, // PHYSICS_EVENT
742 // kCalibrationEvent = 8, // CALIBRATION_EVENT
743 // kFormatError = 9, // EVENT_FORMAT_ERROR
744 // kStartOfData = 10, // START_OF_DATA
745 // kEndOfData = 11, // END_OF_DATA
746 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
747 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
749 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
750 if(eventType!=8)return kFALSE;
753 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
754 if(fComparePtHardAndJetPt)
756 if(!ComparePtHardAndJetPt()) return kFALSE ;
759 if(fComparePtHardAndClusterPt)
761 if(!ComparePtHardAndClusterPt()) return kFALSE ;
766 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
767 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
769 //------------------------------------------------------
770 //Event rejection depending on vertex, pileup, v0and
771 //------------------------------------------------------
772 if(fDataType==kESD && fTimeStampEventSelect)
774 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
777 Int_t timeStamp = esd->GetTimeStamp();
778 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
780 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, timeStampFrac);
782 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
784 //printf("\t accept time stamp\n");
788 //------------------------------------------------------
789 //Event rejection depending on vertex, pileup, v0and
790 //------------------------------------------------------
792 if(fUseEventsWithPrimaryVertex)
794 if( !CheckForPrimaryVertex() ) return kFALSE;
795 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
796 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
797 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
800 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
802 if(fDoEventSelection)
804 if(!fCaloFilterPatch)
806 // Do not analyze events with pileup
807 Bool_t bPileup = IsPileUpFromSPD();
808 //IsPileupFromSPDInMultBins() // method to try
809 //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]);
810 if(bPileup) return kFALSE;
812 if(fDoV0ANDEventSelection)
814 Bool_t bV0AND = kTRUE;
815 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
817 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
818 //else bV0AND = //FIXME FOR AODs
819 if(!bV0AND) return kFALSE;
824 if(fInputEvent->GetNumberOfCaloClusters() > 0)
826 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
827 if(calo->GetNLabels() == 4)
829 Int_t * selection = calo->GetLabels();
830 Bool_t bPileup = selection[0];
831 if(bPileup) return kFALSE;
833 Bool_t bGoodV = selection[1];
834 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
836 if(fDoV0ANDEventSelection)
838 Bool_t bV0AND = selection[2];
839 if(!bV0AND) return kFALSE;
842 fTrackMult = selection[3];
843 if(fTrackMult == 0) return kFALSE;
847 //First filtered AODs, track multiplicity stored there.
848 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
849 if(fTrackMult == 0) return kFALSE;
851 }//at least one cluster
854 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
855 //Remove events with vertex (0,0,0), bad vertex reconstruction
856 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;
858 //First filtered AODs, track multiplicity stored there.
859 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
860 if(fTrackMult == 0) return kFALSE;
862 }// CaloFileter patch
863 }// Event selection/AliceSoft/AliRoot/trunk/PWG/CaloTrackCorrBase/AliCaloTrackReader.h
864 //------------------------------------------------------
866 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
867 //If we need a centrality bin, we select only those events in the corresponding bin.
868 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
870 Int_t cen = GetEventCentrality();
871 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
874 //Fill the arrays with cluster/tracks/cells data
876 if(!fEventTriggerAtSE)
878 // In case of mixing analysis, accept MB events, not only Trigger
879 // Track and cluster arrays filled for MB in order to create the pool in the corresponding analysis
880 // via de method in the base class FillMixedEventPool()
882 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
883 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
885 if(!inputHandler) return kFALSE ; // to content coverity
887 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
888 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
890 if(!isTrigger && !isMB) return kFALSE;
892 //printf("Selected triggered event : %s\n",GetFiredTriggerClasses().Data());
895 // Get the main vertex BC, in case not available
896 // it is calculated in FillCTS checking the BC of tracks
897 // with DCA small (if cut applied, if open)
898 fVertexBC=fInputEvent->GetPrimaryVertex()->GetBC();
903 //Accept events with at least one track
904 if(fTrackMult == 0 && fDoRejectNoTrackEvents) return kFALSE ;
907 if(fDoVertexBCEventSelection)
909 if(fVertexBC!=0 && fVertexBC!=AliVTrack::kTOFBCNA) return kFALSE ;
913 FillInputEMCALCells();
916 FillInputPHOSCells();
930 //___________________________________
931 void AliCaloTrackReader::ResetLists()
933 // Reset lists, called by the analysis maker
935 if(fCTSTracks) fCTSTracks -> Clear();
936 if(fEMCALClusters) fEMCALClusters -> Clear("C");
937 if(fPHOSClusters) fPHOSClusters -> Clear("C");
939 fV0ADC[0] = 0; fV0ADC[1] = 0;
940 fV0Mul[0] = 0; fV0Mul[1] = 0;
944 //____________________________________________________________
945 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
948 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
950 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
952 //Delete previous vertex
955 for (Int_t i = 0; i < fNMixedEvent; i++)
957 delete [] fVertex[i] ;
962 fVertex = new Double_t*[fNMixedEvent] ;
963 for (Int_t i = 0; i < fNMixedEvent; i++)
965 fVertex[i] = new Double_t[3] ;
966 fVertex[i][0] = 0.0 ;
967 fVertex[i][1] = 0.0 ;
968 fVertex[i][2] = 0.0 ;
972 //__________________________________________________
973 Int_t AliCaloTrackReader::GetEventCentrality() const
975 //Return current event centrality
979 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
980 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
981 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
984 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
992 //_____________________________________________________
993 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
995 //Return current event centrality
999 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
1001 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
1003 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
1006 else if(GetEventPlaneMethod().Contains("V0") )
1008 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
1010 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
1014 ep+=TMath::Pi()/2; // put same range as for <Q> method
1018 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
1021 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
1022 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
1029 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
1035 //__________________________________________________________
1036 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
1038 //Return vertex position to be used for single event analysis
1039 vertex[0]=fVertex[0][0];
1040 vertex[1]=fVertex[0][1];
1041 vertex[2]=fVertex[0][2];
1044 //____________________________________________________________
1045 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
1046 const Int_t evtIndex) const
1048 //Return vertex position for mixed event, recover the vertex in a particular event.
1050 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
1054 //________________________________________
1055 void AliCaloTrackReader::FillVertexArray()
1058 //Fill data member with vertex
1059 //In case of Mixed event, multiple vertices
1061 //Delete previous vertex
1064 for (Int_t i = 0; i < fNMixedEvent; i++)
1066 delete [] fVertex[i] ;
1071 fVertex = new Double_t*[fNMixedEvent] ;
1072 for (Int_t i = 0; i < fNMixedEvent; i++)
1074 fVertex[i] = new Double_t[3] ;
1075 fVertex[i][0] = 0.0 ;
1076 fVertex[i][1] = 0.0 ;
1077 fVertex[i][2] = 0.0 ;
1081 { //Single event analysis
1085 if(fInputEvent->GetPrimaryVertex())
1087 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1091 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1092 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1093 }//Primary vertex pointer do not exist
1097 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1101 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
1104 { // MultiEvent analysis
1105 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1107 if (fMixedEvent->GetVertexOfEvent(iev))
1108 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1110 { // no vertex found !!!!
1111 AliWarning("No vertex found");
1115 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1122 //_____________________________________
1123 void AliCaloTrackReader::FillInputCTS()
1125 //Return array with Central Tracking System (CTS) tracks
1127 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1129 Double_t pTrack[3] = {0,0,0};
1131 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1134 Double_t bz = GetInputEvent()->GetMagneticField();
1136 for(Int_t i = 0; i < 19; i++)
1138 fTrackBCEvent [i] = 0;
1139 fTrackBCEventCut[i] = 0;
1142 Bool_t bc0 = kFALSE;
1143 if(fRecalculateVertexBC) fVertexBC=AliVTrack::kTOFBCNA;
1145 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1146 {////////////// track loop
1147 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1149 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1150 ULong_t status = track->GetStatus();
1152 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1157 Float_t dcaTPC =-999;
1159 if (fDataType==kESD)
1161 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1165 if(fESDtrackCuts->AcceptTrack(esdTrack))
1167 track->GetPxPyPz(pTrack) ;
1171 if(esdTrack->GetConstrainedParam())
1173 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1174 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1175 esdTrack->GetConstrainedPxPyPz(pTrack);
1179 } // use constrained tracks
1181 if(fSelectSPDHitTracks)
1182 {//Not much sense to use with TPC only or Hybrid tracks
1183 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1186 // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
1187 else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
1189 // constrain the track
1190 if(esdTrack->GetConstrainedParam())
1192 esdTrack->Set(esdTrack->GetConstrainedParam()->GetX(),esdTrack->GetConstrainedParam()->GetAlpha(),esdTrack->GetConstrainedParam()->GetParameter(),esdTrack->GetConstrainedParam()->GetCovariance());
1194 track->GetPxPyPz(pTrack) ;
1202 else if(fDataType==kAOD)
1204 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1208 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1209 aodtrack->GetType(),AliAODTrack::kPrimary,
1210 aodtrack->IsHybridGlobalConstrainedGlobal());
1213 if (fSelectHybridTracks)
1215 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1219 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1222 if(fSelectSPDHitTracks)
1223 {//Not much sense to use with TPC only or Hybrid tracks
1224 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1227 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1229 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
1231 //In case of AODs, TPC tracks cannot be propagated back to primary vertex,
1233 dcaTPC = aodtrack->DCA();
1235 track->GetPxPyPz(pTrack) ;
1237 } // aod track exists
1242 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1244 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
1245 Double_t tof = -1000;
1246 Int_t trackBC = -1000 ;
1250 trackBC = track->GetTOFBunchCrossing(bz);
1251 SetTrackEventBC(trackBC+9);
1253 tof = track->GetTOFsignal()*1e-3;
1258 //normal way to get the dca, cut on dca_xy
1261 Double_t dca[2] = {1e6,1e6};
1262 Double_t covar[3] = {1e6,1e6,1e6};
1263 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1264 if( okDCA) okDCA = AcceptDCA(momentum.Pt(),dca[0]);
1267 //printf("AliCaloTrackReader::FillInputCTS() - Reject track pt %2.2f, dca_xy %2.4f, BC %d\n",momentum.Pt(),dca[0],trackBC);
1275 //SetTrackEventBCcut(bc);
1276 SetTrackEventBCcut(trackBC+9);
1278 //After selecting tracks with small DCA, pointing to vertex, set vertex BC depeding on tracks BC
1279 if(fRecalculateVertexBC)
1281 if (trackBC !=0 && trackBC != AliVTrack::kTOFBCNA) fVertexBC = trackBC;
1282 else if(trackBC == 0) bc0 = kTRUE;
1285 //In any case, the time should to be larger than the fixed window ...
1286 if( fUseTrackTimeCut && (trackBC!=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1288 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
1291 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1295 //Count the tracks in eta < 0.9
1296 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1297 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1299 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1301 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
1303 if(fDebug > 2 && momentum.Pt() > 0.1)
1304 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1305 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1307 if (fMixedEvent) track->SetID(itrack);
1309 fCTSTracks->Add(track);
1313 if(fVertexBC ==0 || fVertexBC == AliVTrack::kTOFBCNA)
1315 if( bc0 ) fVertexBC = 0 ;
1316 else fVertexBC = AliVTrack::kTOFBCNA ;
1320 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1324 //__________________________________________________________________
1325 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1328 //Fill the EMCAL data in the array, do it
1332 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1334 //Reject clusters with bad channels, close to borders and exotic;
1335 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1337 //Mask all cells in collumns facing ALICE thick material if requested
1338 if(GetCaloUtils()->GetNMaskCellColumns())
1344 Bool_t shared = kFALSE;
1345 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1346 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1349 if(fSelectEmbeddedClusters)
1351 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1352 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1356 //clus->GetPosition(pos);
1357 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1359 if(fRecalculateClusters)
1361 //Recalibrate the cluster energy
1362 if(GetCaloUtils()->IsRecalibrationOn())
1364 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1367 //printf("Recalibrated Energy %f\n",clus->E());
1369 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1370 GetCaloUtils()->RecalculateClusterPID(clus);
1374 //Recalculate distance to bad channels, if new list of bad channels provided
1375 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1377 //Recalculate cluster position
1378 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1380 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1381 //clus->GetPosition(pos);
1382 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1386 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1388 Double_t tof = clus->GetTOF();
1390 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1392 if(fDataType==AliCaloTrackReader::kESD)
1394 tof = fEMCALCells->GetCellTime(absIdMax);
1397 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1401 }// Time recalibration
1404 //Correct non linearity
1405 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1407 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1408 //printf("Linearity Corrected Energy %f\n",clus->E());
1410 //In case of MC analysis, to match resolution/calibration in real data
1411 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1412 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1413 clus->SetE(rdmEnergy);
1416 Double_t tof = clus->GetTOF()*1e9;
1418 Int_t bc = TMath::Nint(tof/50) + 9;
1419 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1421 SetEMCalEventBC(bc);
1423 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1425 TLorentzVector momentum ;
1427 clus->GetMomentum(momentum, fVertex[vindex]);
1429 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1431 SetEMCalEventBCcut(bc);
1433 if(!IsInTimeWindow(tof,clus->E()))
1435 fNPileUpClusters++ ;
1436 if(fUseEMCALTimeCut) return ;
1439 fNNonPileUpClusters++;
1441 if(fDebug > 2 && momentum.E() > 0.1)
1442 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1443 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1446 clus->SetID(iclus) ;
1448 //Correct MC label for AODs
1450 fEMCALClusters->Add(clus);
1454 //_______________________________________
1455 void AliCaloTrackReader::FillInputEMCAL()
1457 //Return array with EMCAL clusters in aod format
1459 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1461 // First recalibrate cells, time or energy
1462 // if(GetCaloUtils()->IsRecalibrationOn())
1463 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1465 // fInputEvent->GetBunchCrossNumber());
1467 fNPileUpClusters = 0; // Init counter
1468 fNNonPileUpClusters = 0; // Init counter
1469 for(Int_t i = 0; i < 19; i++)
1471 fEMCalBCEvent [i] = 0;
1472 fEMCalBCEventCut[i] = 0;
1475 //Loop to select clusters in fiducial cut and fill container with aodClusters
1476 if(fEMCALClustersListName=="")
1478 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1479 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1481 AliVCluster * clus = 0;
1482 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1484 if (IsEMCALCluster(clus))
1486 FillInputEMCALAlgorithm(clus, iclus);
1491 //Recalculate track matching
1492 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1494 }//Get the clusters from the input event
1497 TClonesArray * clusterList = 0x0;
1499 if (fInputEvent->FindListObject(fEMCALClustersListName))
1501 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1503 else if(fOutputEvent)
1505 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1510 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1514 Int_t nclusters = clusterList->GetEntriesFast();
1515 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1517 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1518 //printf("E %f\n",clus->E());
1519 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1520 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1523 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1524 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1526 fNPileUpClusters = 0; // Init counter
1527 fNNonPileUpClusters = 0; // Init counter
1528 for(Int_t i = 0; i < 19; i++)
1530 fEMCalBCEvent [i] = 0;
1531 fEMCalBCEventCut[i] = 0;
1534 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1536 AliVCluster * clus = 0;
1538 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1540 if (IsEMCALCluster(clus))
1544 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1545 Double_t tof = clus->GetTOF();
1546 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1549 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1551 //Reject clusters with bad channels, close to borders and exotic;
1552 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1554 Int_t bc = TMath::Nint(tof/50) + 9;
1555 SetEMCalEventBC(bc);
1557 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1559 TLorentzVector momentum ;
1561 clus->GetMomentum(momentum, fVertex[0]);
1563 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1565 SetEMCalEventBCcut(bc);
1567 if(!IsInTimeWindow(tof,clus->E()))
1568 fNPileUpClusters++ ;
1570 fNNonPileUpClusters++;
1576 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1578 // Recalculate track matching, not necessary if already done in the reclusterization task.
1579 // in case it was not done ...
1580 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1584 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1588 //______________________________________
1589 void AliCaloTrackReader::FillInputPHOS()
1591 //Return array with PHOS clusters in aod format
1593 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1595 //Loop to select clusters in fiducial cut and fill container with aodClusters
1596 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1597 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1599 AliVCluster * clus = 0;
1600 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1602 if (IsPHOSCluster(clus))
1604 //Check if the cluster contains any bad channel and if close to calorimeter borders
1607 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1608 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1610 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1613 if(fRecalculateClusters)
1615 //Recalibrate the cluster energy
1616 if(GetCaloUtils()->IsRecalibrationOn())
1618 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1623 TLorentzVector momentum ;
1625 clus->GetMomentum(momentum, fVertex[vindex]);
1627 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1629 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1631 if(fDebug > 2 && momentum.E() > 0.1)
1632 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1633 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1638 clus->SetID(iclus) ;
1641 fPHOSClusters->Add(clus);
1647 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1651 //____________________________________________
1652 void AliCaloTrackReader::FillInputEMCALCells()
1654 //Return array with EMCAL cells in aod format
1656 fEMCALCells = fInputEvent->GetEMCALCells();
1660 //___________________________________________
1661 void AliCaloTrackReader::FillInputPHOSCells()
1663 //Return array with PHOS cells in aod format
1665 fPHOSCells = fInputEvent->GetPHOSCells();
1669 //_______________________________________
1670 void AliCaloTrackReader::FillInputVZERO()
1672 //Fill VZERO information in data member, add all the channels information.
1673 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1674 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1678 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1679 for (Int_t i = 0; i < 32; i++)
1682 {//Only available in ESDs
1683 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1684 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1687 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1688 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1691 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1696 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1701 //___________________________________________________________________
1702 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1704 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1705 // different number and need to patch here
1707 if(fDataType==kAOD && fOldAOD)
1709 if (cluster->GetType() == 2) return kTRUE;
1714 return cluster->IsEMCAL();
1719 //___________________________________________________________________
1720 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1722 //Check if it is a cluster from PHOS.For old AODs cluster type has
1723 // different number and need to patch here
1725 if(fDataType==kAOD && fOldAOD)
1727 Int_t type = cluster->GetType();
1728 if (type == 0 || type == 1) return kTRUE;
1733 return cluster->IsPHOS();
1738 //________________________________________________
1739 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1741 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1744 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1745 if(!event) return kTRUE;
1747 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1752 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1755 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1757 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1761 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1763 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1772 //____________________________________________
1773 void AliCaloTrackReader::RejectExoticEvents()
1775 // Reject events triggered by exotic cells
1777 Int_t nOfHighECl = 0 ;
1779 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1780 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1782 AliVCluster * clus = 0;
1783 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1785 if (IsEMCALCluster(clus) && clus->E() > fExoticTrigger)
1787 Bool_t exotic = GetCaloUtils()->GetEMCALRecoUtils()->IsExoticCluster(clus, fInputEvent->GetEMCALCells());
1794 //printf("trigger %2.1f, n Exotic %d, n high energy %d\n", fExoticTrigger,nExo,nOfHighECl);
1796 if ((nExo>0)&&(nOfHighECl==0)) fIsExoticEvent = kTRUE ;
1797 else fIsExoticEvent = kFALSE;
1801 //__________________________________________
1802 Bool_t AliCaloTrackReader::RejectLEDEvents()
1804 // LED Events in period LHC11a contaminated sample, simple method
1805 // to reject such events
1807 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
1808 Int_t ncellsSM3 = 0;
1809 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
1811 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
1812 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
1813 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
1816 Int_t ncellcut = 21;
1817 if(GetFiredTriggerClasses().Contains("EMC")) ncellcut = 35;
1819 if(ncellsSM3 >= ncellcut)
1822 printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d, cut %d, trig %s\n",
1823 ncellsSM3,ncellcut,GetFiredTriggerClasses().Data());
1831 //____________________________________________________________
1832 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1836 if(fESDtrackCuts) delete fESDtrackCuts ;
1838 fESDtrackCuts = cuts ;
1842 //_________________________________________________________________________
1843 void AliCaloTrackReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
1845 // Set Track cuts for complementary tracks (hybrids)
1847 if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
1849 fESDtrackComplementaryCuts = cuts ;