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>
30 #include <TStreamerInfo.h>
32 // ---- ANALYSIS system ----
33 #include "AliMCEvent.h"
34 #include "AliAODMCHeader.h"
35 #include "AliGenPythiaEventHeader.h"
36 #include "AliESDEvent.h"
37 #include "AliAODEvent.h"
38 #include "AliVTrack.h"
39 #include "AliVParticle.h"
40 #include "AliMixedEvent.h"
41 #include "AliESDtrack.h"
42 #include "AliESDtrackCuts.h"
43 #include "AliTriggerAnalysis.h"
44 #include "AliESDVZERO.h"
45 #include "AliVCaloCells.h"
46 #include "AliAnalysisManager.h"
47 #include "AliInputEventHandler.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(""),
89 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
90 fEventTrigMinBias(0), fEventTrigCentral(0),
91 fEventTrigSemiCentral(0), fEventTrigEMCALL0(0),
92 fEventTrigEMCALL1Gamma1(0), fEventTrigEMCALL1Gamma2(0),
93 fEventTrigEMCALL1Jet1(0), fEventTrigEMCALL1Jet2(0),
94 fBitEGA(0), fBitEJE(0),
97 fTaskName(""), fCaloUtils(0x0),
98 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
99 fListMixedTracksEvents(), fListMixedCaloEvents(),
100 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
101 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
102 fEMCALClustersListName(""), fZvtxCut(0.),
103 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
105 fRemoveBadTriggerEvents(0), fTriggerPatchClusterMatch(0),
106 fTriggerPatchTimeWindow(), fTriggerEventThreshold(0),
107 fTriggerClusterBC(0), fTriggerClusterIndex(0), fTriggerClusterId(0),
108 fIsExoticEvent(0), fIsBadCellEvent(0), fIsBadMaxCellEvent(0),
111 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE),
112 fDoVertexBCEventSelection(kFALSE),
113 fDoRejectNoTrackEvents(kFALSE),
114 fUseEventsWithPrimaryVertex(kFALSE),
115 fTriggerAnalysis (0x0), fTimeStampEventSelect(0),
116 fTimeStampEventFracMin(0), fTimeStampEventFracMax(0),
117 fTimeStampRunMin(0), fTimeStampRunMax(0),
118 fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
119 fVertexBC(-200), fRecalculateVertexBC(0),
120 fCentralityClass(""), fCentralityOpt(0),
121 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
125 //Initialize parameters
129 //_______________________________________
130 AliCaloTrackReader::~AliCaloTrackReader()
134 delete fFiducialCut ;
138 fAODBranchList->Delete();
139 delete fAODBranchList ;
144 if(fDataType!=kMC)fCTSTracks->Clear() ;
145 else fCTSTracks->Delete() ;
151 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
152 else fEMCALClusters->Delete() ;
153 delete fEMCALClusters ;
158 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
159 else fPHOSClusters->Delete() ;
160 delete fPHOSClusters ;
165 for (Int_t i = 0; i < fNMixedEvent; i++)
167 delete [] fVertex[i] ;
173 delete fESDtrackCuts;
174 delete fESDtrackComplementaryCuts;
175 delete fTriggerAnalysis;
177 // Pointers not owned, done by the analysis frame
178 // if(fInputEvent) delete fInputEvent ;
179 // if(fOutputEvent) delete fOutputEvent ;
180 // if(fMC) delete fMC ;
181 // Pointer not owned, deleted by maker
182 // if (fCaloUtils) delete fCaloUtils ;
186 //________________________________________________________________________
187 Bool_t AliCaloTrackReader::AcceptDCA(const Float_t pt, const Float_t dca)
189 // Accept track if DCA is smaller than function
191 Float_t cut = fTrackDCACut[0]+fTrackDCACut[1]/TMath::Power(pt,fTrackDCACut[2]);
193 if(TMath::Abs(dca) < cut)
200 //________________________________________________
201 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
203 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
206 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
208 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
211 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
212 Int_t nTriggerJets = pygeh->NTriggerJets();
213 Float_t ptHard = pygeh->GetPtHard();
216 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
218 Float_t tmpjet[]={0,0,0,0};
219 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
221 pygeh->TriggerJet(ijet, tmpjet);
222 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
225 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
227 //Compare jet pT and pt Hard
228 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
230 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
231 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
243 //____________________________________________________________________
244 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
246 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
249 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
251 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
252 Float_t ptHard = pygeh->GetPtHard();
254 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
255 for (Int_t iclus = 0; iclus < nclusters; iclus++)
257 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
258 Float_t ecluster = clus->E();
260 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
262 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
274 //____________________________________________
275 AliStack* AliCaloTrackReader::GetStack() const
277 //Return pointer to stack
282 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
287 //__________________________________________________
288 TString AliCaloTrackReader::GetFiredTriggerClasses()
290 // List of triggered classes in a TString
292 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
293 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
295 if (esdevent) return esdevent->GetFiredTriggerClasses();
296 else if(aodevent) return aodevent->GetFiredTriggerClasses();
297 else return ""; // Mixed Event, MC event, does not have this trigger info
301 //______________________________________________
302 AliHeader* AliCaloTrackReader::GetHeader() const
304 //Return pointer to header
307 return fMC->Header();
311 printf("AliCaloTrackReader::Header is not available\n");
316 //______________________________________________________________
317 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
319 //Return pointer to Generated event header
320 if (ReadStack() && fMC)
322 return fMC->GenEventHeader();
324 else if(ReadAODMCParticles() && GetAODMCHeader())
326 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
327 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
328 return GetAODMCHeader()->GetCocktailHeader(0) ;
334 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
339 //____________________________________________________________________
340 TClonesArray* AliCaloTrackReader::GetAODMCParticles() const
342 //Return list of particles in AOD. Do it for the corresponding input event.
344 TClonesArray * rv = NULL ;
345 if(fDataType == kAOD)
348 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
350 rv = (TClonesArray*)evt->FindListObject("mcparticles");
352 printf("AliCaloTrackReader::GetAODMCParticles() - Null AOD event \n");
356 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
362 //________________________________________________________
363 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
365 //Return MC header in AOD. Do it for the corresponding input event.
367 AliAODMCHeader *mch = NULL;
369 if(fDataType == kAOD)
371 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
372 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
376 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
382 //___________________________________________________________
383 Int_t AliCaloTrackReader::GetVertexBC(const AliVVertex * vtx)
387 Int_t vertexBC=vtx->GetBC();
388 if(!fRecalculateVertexBC) return vertexBC;
390 // In old AODs BC not stored, recalculate it
391 // loop over the global track and select those which have small DCA to primary vertex (e.g. primary).
392 // If at least one of these primaries has valid BC != 0, then this vertex is a pile-up candidate.
394 Double_t bz = fInputEvent->GetMagneticField();
396 Int_t ntr = GetCTSTracks()->GetEntriesFast();
397 //printf("N Tracks %d\n",ntr);
399 for(Int_t i = 0 ; i < ntr ; i++)
401 AliVTrack * track = (AliVTrack*) (GetCTSTracks()->At(i));
403 //Check if has TOF info, if not skip
404 ULong_t status = track->GetStatus();
405 Bool_t okTOF = (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ;
406 vertexBC = track->GetTOFBunchCrossing(bz);
407 Float_t pt = track->Pt();
412 Double_t dca[2] = {1e6,1e6};
413 Double_t covar[3] = {1e6,1e6,1e6};
414 track->PropagateToDCA(vtx,bz,100.,dca,covar);
416 if(AcceptDCA(pt,dca[0]))
418 if (vertexBC !=0 && fVertexBC != AliVTrack::kTOFBCNA) return vertexBC;
419 else if(vertexBC == 0) bc0 = kTRUE;
423 if( bc0 ) vertexBC = 0 ;
424 else vertexBC = AliVTrack::kTOFBCNA ;
430 //_____________________________
431 void AliCaloTrackReader::Init()
433 //Init reader. Method to be called in AliAnaPartCorrMaker
435 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
437 if(fReadStack && fReadAODMCParticles)
439 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
441 fReadAODMCParticles = kFALSE;
444 // Init geometry, I do not like much to do it like this ...
445 if(fImportGeometryFromFile && !gGeoManager)
447 if(fImportGeometryFilePath=="") // If not specified, set a default location
448 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
450 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
451 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
455 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
459 //_______________________________________
460 void AliCaloTrackReader::InitParameters()
462 //Initialize the parameters of the analysis.
468 fEMCALPtMax = 1000. ;
472 // dca_xy cut = 0.0105+0.0350/TMath::Power(pt,1.1);
473 fTrackDCACut[0] = 0.0105;
474 fTrackDCACut[1] = 0.0350;
475 fTrackDCACut[2] = 1.1;
477 //Do not filter the detectors input by default.
481 fFillEMCALCells = kFALSE;
482 fFillPHOSCells = kFALSE;
484 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
485 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
486 fDeltaAODFileName = "deltaAODPartCorr.root";
487 fFiredTriggerClassName = "";
488 fEventTriggerMask = AliVEvent::kAny;
489 fMixEventTriggerMask = AliVEvent::kAnyINT;
490 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
492 fAcceptFastCluster = kTRUE;
495 //We want tracks fitted in the detectors:
496 //fTrackStatus=AliESDtrack::kTPCrefit;
497 //fTrackStatus|=AliESDtrack::kITSrefit;
499 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
502 fESDtrackComplementaryCuts = 0;
504 fConstrainTrack = kFALSE ; // constrain tracks to vertex
506 fV0ADC[0] = 0; fV0ADC[1] = 0;
507 fV0Mul[0] = 0; fV0Mul[1] = 0;
513 fPtHardAndJetPtFactor = 7.;
514 fPtHardAndClusterPtFactor = 1.;
517 fCentralityClass = "V0M";
519 fCentralityBin[0] = fCentralityBin[1]=-1;
521 fEventPlaneMethod = "V0";
523 // Allocate memory (not sure this is the right place)
524 fCTSTracks = new TObjArray();
525 fEMCALClusters = new TObjArray();
526 fPHOSClusters = new TObjArray();
527 fTriggerAnalysis = new AliTriggerAnalysis;
528 fAODBranchList = new TList ;
530 fImportGeometryFromFile = kFALSE;
532 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
533 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
535 // Parametrized time cut (LHC11d)
536 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
537 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
539 // Parametrized time cut (LHC11c)
540 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
541 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
543 fTimeStampRunMin = -1;
544 fTimeStampRunMax = 1e12;
545 fTimeStampEventFracMin = -1;
546 fTimeStampEventFracMax = 2;
548 for(Int_t i = 0; i < 19; i++)
550 fEMCalBCEvent [i] = 0;
551 fEMCalBCEventCut[i] = 0;
552 fTrackBCEvent [i] = 0;
553 fTrackBCEventCut[i] = 0;
556 // Trigger match-rejection
557 fTriggerPatchTimeWindow[0] = 8;
558 fTriggerPatchTimeWindow[1] = 9;
560 fTriggerClusterBC = -10000 ;
561 fTriggerEventThreshold = 2.;
562 fTriggerClusterIndex = -1;
563 fTriggerClusterId = -1;
567 //___________________________________________________________
568 Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
570 // Cluster time selection window
572 // Parametrized cut depending on E
575 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
576 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
577 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
578 if( tof < minCut || tof > maxCut ) return kFALSE ;
581 //In any case, the time should to be larger than the fixed window ...
582 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
587 //________________________________________________
588 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
590 // Check if event is from pile-up determined by SPD
591 // Default values: (3, 0.8, 3., 2., 5.)
592 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
593 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
594 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
598 //__________________________________________________
599 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
601 // Check if event is from pile-up determined by EMCal
602 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
606 //________________________________________________________
607 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
609 // Check if event is from pile-up determined by SPD and EMCal
610 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
614 //_______________________________________________________
615 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
617 // Check if event is from pile-up determined by SPD or EMCal
618 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
622 //___________________________________________________________
623 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
625 // Check if event is from pile-up determined by SPD and not by EMCal
626 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
630 //___________________________________________________________
631 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
633 // Check if event is from pile-up determined by EMCal, not by SPD
634 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
638 //______________________________________________________________
639 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
641 // Check if event not from pile-up determined neither by SPD nor by EMCal
642 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
646 //________________________________________________________
647 void AliCaloTrackReader::Print(const Option_t * opt) const
650 //Print some relevant parameters set for the analysis
654 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
655 printf("Task name : %s\n", fTaskName.Data()) ;
656 printf("Data type : %d\n", fDataType) ;
657 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
658 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
659 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
660 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
661 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
662 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
663 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
664 printf("Use CTS = %d\n", fFillCTS) ;
665 printf("Use EMCAL = %d\n", fFillEMCAL) ;
666 printf("Use PHOS = %d\n", fFillPHOS) ;
667 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
668 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
669 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
670 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
671 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
672 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
673 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
675 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
676 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
678 if(fComparePtHardAndClusterPt)
679 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
681 if(fComparePtHardAndClusterPt)
682 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
684 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
685 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
686 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
692 //_________________________________________________________________________
693 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
694 const char * /*currentFileName*/)
696 //Fill the event counter and input lists that are needed, called by the analysis maker.
698 fEventNumber = iEntry;
699 fTriggerClusterIndex = -1;
700 fTriggerClusterId = -1;
701 fIsTriggerMatch = kFALSE;
702 fTriggerClusterBC = -10000;
703 fIsExoticEvent = kFALSE;
704 fIsBadCellEvent = kFALSE;
705 fIsBadMaxCellEvent = kFALSE;
707 //fCurrentFileName = TString(currentFileName);
710 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
714 //Select events only fired by a certain trigger configuration if it is provided
716 if(fInputEvent->GetHeader())
717 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
719 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
721 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
726 //-------------------------------------------------------------------------------------
727 // Reject event if large clusters with large energy
728 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
729 // If clusterzer NxN or V2 it does not help
730 //-------------------------------------------------------------------------------------
731 Int_t run = fInputEvent->GetRunNumber();
732 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
734 Bool_t reject = RejectLEDEvents();
735 if(reject) return kFALSE;
736 }// Remove LED events
738 //------------------------
739 // Reject pure LED events?
740 //-------------------------
741 if( fFiredTriggerClassName !="" && !fAnaLED)
743 //printf("Event type %d\n",eventType);
745 return kFALSE; //Only physics event, do not use for simulated events!!!
748 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
749 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
751 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
752 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
756 // kStartOfRun = 1, // START_OF_RUN
757 // kEndOfRun = 2, // END_OF_RUN
758 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
759 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
760 // kStartOfBurst = 5, // START_OF_BURST
761 // kEndOfBurst = 6, // END_OF_BURST
762 // kPhysicsEvent = 7, // PHYSICS_EVENT
763 // kCalibrationEvent = 8, // CALIBRATION_EVENT
764 // kFormatError = 9, // EVENT_FORMAT_ERROR
765 // kStartOfData = 10, // START_OF_DATA
766 // kEndOfData = 11, // END_OF_DATA
767 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
768 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
770 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
771 if(eventType!=8)return kFALSE;
774 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
775 if(fComparePtHardAndJetPt)
777 if(!ComparePtHardAndJetPt()) return kFALSE ;
780 if(fComparePtHardAndClusterPt)
782 if(!ComparePtHardAndClusterPt()) return kFALSE ;
787 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
788 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
790 //------------------------------------------------------
791 //Event rejection depending on vertex, pileup, v0and
792 //------------------------------------------------------
793 if(fDataType==kESD && fTimeStampEventSelect)
795 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
798 Int_t timeStamp = esd->GetTimeStamp();
799 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
801 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, timeStampFrac);
803 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
805 //printf("\t accept time stamp\n");
809 //------------------------------------------------------
810 //Event rejection depending on vertex, pileup, v0and
811 //------------------------------------------------------
813 if(fUseEventsWithPrimaryVertex)
815 if( !CheckForPrimaryVertex() ) return kFALSE;
816 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
817 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
818 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
821 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
823 if(fDoEventSelection)
825 if(!fCaloFilterPatch)
827 // Do not analyze events with pileup
828 Bool_t bPileup = IsPileUpFromSPD();
829 //IsPileupFromSPDInMultBins() // method to try
830 //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]);
831 if(bPileup) return kFALSE;
833 if(fDoV0ANDEventSelection)
835 Bool_t bV0AND = kTRUE;
836 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
838 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
839 //else bV0AND = //FIXME FOR AODs
840 if(!bV0AND) return kFALSE;
845 if(fInputEvent->GetNumberOfCaloClusters() > 0)
847 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
848 if(calo->GetNLabels() == 4)
850 Int_t * selection = calo->GetLabels();
851 Bool_t bPileup = selection[0];
852 if(bPileup) return kFALSE;
854 Bool_t bGoodV = selection[1];
855 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
857 if(fDoV0ANDEventSelection)
859 Bool_t bV0AND = selection[2];
860 if(!bV0AND) return kFALSE;
863 fTrackMult = selection[3];
864 if(fTrackMult == 0) return kFALSE;
868 //First filtered AODs, track multiplicity stored there.
869 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
870 if(fTrackMult == 0) return kFALSE;
872 }//at least one cluster
875 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
876 //Remove events with vertex (0,0,0), bad vertex reconstruction
877 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;
879 //First filtered AODs, track multiplicity stored there.
880 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
881 if(fTrackMult == 0) return kFALSE;
883 }// CaloFileter patch
884 }// Event selection/AliceSoft/AliRoot/trunk/PWG/CaloTrackCorrBase/AliCaloTrackReader.h
886 //------------------------------------------------------
888 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
889 //If we need a centrality bin, we select only those events in the corresponding bin.
890 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
892 Int_t cen = GetEventCentrality();
893 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
896 //Fill the arrays with cluster/tracks/cells data
898 if(!fEventTriggerAtSE)
900 // In case of mixing analysis, accept MB events, not only Trigger
901 // Track and cluster arrays filled for MB in order to create the pool in the corresponding analysis
902 // via de method in the base class FillMixedEventPool()
904 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
905 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
907 if(!inputHandler) return kFALSE ; // to content coverity
909 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
910 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
912 if(!isTrigger && !isMB) return kFALSE;
914 //printf("Selected triggered event : %s\n",GetFiredTriggerClasses().Data());
917 //----------------------------------------------------------------------
918 // Do not count events that where likely triggered by an exotic cluster
920 //----------------------------------------------------------------------
922 // Set a bit with the event kind, MB, L0, L1 ...
923 SetEventTriggerBit();
925 //Get Patches that triggered
926 TArrayI patches = GetTriggerPatches();
928 if(fRemoveExoticEvents)
930 RejectExoticEvents(patches);
933 //printf("AliCaloTrackReader::FillInputEvent() - REJECT exotic triggered event \n");
938 RejectTriggeredEventsByPileUp(patches);
939 //printf("AliCaloTrackReader::FillInputEvent(), Trigger BC = %d\n",fTriggerClusterBC);
941 if(fRemoveTriggerOutBCEvents)
943 if(fTriggerClusterBC != 0 && fTriggerClusterBC != 6)
945 //printf("\t REJECT, bad trigger cluster BC\n");
951 MatchTriggerCluster(patches);
953 if(fRemoveBadTriggerEvents)
955 //printf("ACCEPT triggered event? - exotic? %d - bad cell %d - bad Max cell %d - BC %d - Matched %d\n",
956 // fIsExoticEvent,fIsBadCellEvent, fIsBadMaxCellEvent, fTriggerClusterBC,fIsTriggerMatch);
957 if (fIsExoticEvent) return kFALSE;
958 else if(fIsBadCellEvent) return kFALSE;
959 else if(fTriggerClusterBC != 0) return kFALSE;
960 //printf("\t *** YES\n");
965 // Get the main vertex BC, in case not available
966 // it is calculated in FillCTS checking the BC of tracks
967 // with DCA small (if cut applied, if open)
968 fVertexBC=fInputEvent->GetPrimaryVertex()->GetBC();
973 //Accept events with at least one track
974 if(fTrackMult == 0 && fDoRejectNoTrackEvents) return kFALSE ;
977 if(fDoVertexBCEventSelection)
979 if(fVertexBC!=0 && fVertexBC!=AliVTrack::kTOFBCNA) return kFALSE ;
983 FillInputEMCALCells();
986 FillInputPHOSCells();
1000 //___________________________________
1001 void AliCaloTrackReader::ResetLists()
1003 // Reset lists, called by the analysis maker
1005 if(fCTSTracks) fCTSTracks -> Clear();
1006 if(fEMCALClusters) fEMCALClusters -> Clear("C");
1007 if(fPHOSClusters) fPHOSClusters -> Clear("C");
1009 fV0ADC[0] = 0; fV0ADC[1] = 0;
1010 fV0Mul[0] = 0; fV0Mul[1] = 0;
1014 //____________________________________________________________
1015 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
1017 fInputEvent = input;
1018 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
1020 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
1022 //Delete previous vertex
1025 for (Int_t i = 0; i < fNMixedEvent; i++)
1027 delete [] fVertex[i] ;
1032 fVertex = new Double_t*[fNMixedEvent] ;
1033 for (Int_t i = 0; i < fNMixedEvent; i++)
1035 fVertex[i] = new Double_t[3] ;
1036 fVertex[i][0] = 0.0 ;
1037 fVertex[i][1] = 0.0 ;
1038 fVertex[i][2] = 0.0 ;
1042 //__________________________________________________
1043 Int_t AliCaloTrackReader::GetEventCentrality() const
1045 //Return current event centrality
1049 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
1050 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
1051 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
1054 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
1062 //_____________________________________________________
1063 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
1065 //Return current event centrality
1069 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
1071 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
1073 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
1076 else if(GetEventPlaneMethod().Contains("V0") )
1078 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
1080 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
1084 ep+=TMath::Pi()/2; // put same range as for <Q> method
1088 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
1091 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
1092 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
1099 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
1105 //__________________________________________________________
1106 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
1108 //Return vertex position to be used for single event analysis
1109 vertex[0]=fVertex[0][0];
1110 vertex[1]=fVertex[0][1];
1111 vertex[2]=fVertex[0][2];
1114 //____________________________________________________________
1115 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
1116 const Int_t evtIndex) const
1118 //Return vertex position for mixed event, recover the vertex in a particular event.
1120 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
1124 //________________________________________
1125 void AliCaloTrackReader::FillVertexArray()
1128 //Fill data member with vertex
1129 //In case of Mixed event, multiple vertices
1131 //Delete previous vertex
1134 for (Int_t i = 0; i < fNMixedEvent; i++)
1136 delete [] fVertex[i] ;
1141 fVertex = new Double_t*[fNMixedEvent] ;
1142 for (Int_t i = 0; i < fNMixedEvent; i++)
1144 fVertex[i] = new Double_t[3] ;
1145 fVertex[i][0] = 0.0 ;
1146 fVertex[i][1] = 0.0 ;
1147 fVertex[i][2] = 0.0 ;
1151 { //Single event analysis
1155 if(fInputEvent->GetPrimaryVertex())
1157 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1161 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1162 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1163 }//Primary vertex pointer do not exist
1167 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1171 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
1174 { // MultiEvent analysis
1175 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1177 if (fMixedEvent->GetVertexOfEvent(iev))
1178 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1180 { // no vertex found !!!!
1181 AliWarning("No vertex found");
1185 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1192 //_____________________________________
1193 void AliCaloTrackReader::FillInputCTS()
1195 //Return array with Central Tracking System (CTS) tracks
1197 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1199 Double_t pTrack[3] = {0,0,0};
1201 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1204 Double_t bz = GetInputEvent()->GetMagneticField();
1206 for(Int_t i = 0; i < 19; i++)
1208 fTrackBCEvent [i] = 0;
1209 fTrackBCEventCut[i] = 0;
1212 Bool_t bc0 = kFALSE;
1213 if(fRecalculateVertexBC) fVertexBC=AliVTrack::kTOFBCNA;
1215 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1216 {////////////// track loop
1217 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1219 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1220 ULong_t status = track->GetStatus();
1222 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1227 Float_t dcaTPC =-999;
1229 if (fDataType==kESD)
1231 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1235 if(fESDtrackCuts->AcceptTrack(esdTrack))
1237 track->GetPxPyPz(pTrack) ;
1241 if(esdTrack->GetConstrainedParam())
1243 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1244 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1245 esdTrack->GetConstrainedPxPyPz(pTrack);
1249 } // use constrained tracks
1251 if(fSelectSPDHitTracks)
1252 {//Not much sense to use with TPC only or Hybrid tracks
1253 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1256 // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
1257 else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
1259 // constrain the track
1260 if(esdTrack->GetConstrainedParam())
1262 esdTrack->Set(esdTrack->GetConstrainedParam()->GetX(),esdTrack->GetConstrainedParam()->GetAlpha(),esdTrack->GetConstrainedParam()->GetParameter(),esdTrack->GetConstrainedParam()->GetCovariance());
1264 track->GetPxPyPz(pTrack) ;
1272 else if(fDataType==kAOD)
1274 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1278 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1279 aodtrack->GetType(),AliAODTrack::kPrimary,
1280 aodtrack->IsHybridGlobalConstrainedGlobal());
1283 if (fSelectHybridTracks)
1285 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1289 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1292 if(fSelectSPDHitTracks)
1293 {//Not much sense to use with TPC only or Hybrid tracks
1294 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1297 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1299 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
1301 //In case of AODs, TPC tracks cannot be propagated back to primary vertex,
1303 dcaTPC = aodtrack->DCA();
1305 track->GetPxPyPz(pTrack) ;
1307 } // aod track exists
1312 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1314 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
1315 Double_t tof = -1000;
1316 Int_t trackBC = -1000 ;
1320 trackBC = track->GetTOFBunchCrossing(bz);
1321 SetTrackEventBC(trackBC+9);
1323 tof = track->GetTOFsignal()*1e-3;
1328 //normal way to get the dca, cut on dca_xy
1331 Double_t dca[2] = {1e6,1e6};
1332 Double_t covar[3] = {1e6,1e6,1e6};
1333 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1334 if( okDCA) okDCA = AcceptDCA(momentum.Pt(),dca[0]);
1337 //printf("AliCaloTrackReader::FillInputCTS() - Reject track pt %2.2f, dca_xy %2.4f, BC %d\n",momentum.Pt(),dca[0],trackBC);
1345 //SetTrackEventBCcut(bc);
1346 SetTrackEventBCcut(trackBC+9);
1348 //After selecting tracks with small DCA, pointing to vertex, set vertex BC depeding on tracks BC
1349 if(fRecalculateVertexBC)
1351 if (trackBC !=0 && trackBC != AliVTrack::kTOFBCNA) fVertexBC = trackBC;
1352 else if(trackBC == 0) bc0 = kTRUE;
1355 //In any case, the time should to be larger than the fixed window ...
1356 if( fUseTrackTimeCut && (trackBC!=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1358 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
1361 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1365 //Count the tracks in eta < 0.9
1366 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1367 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1369 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1371 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
1373 if(fDebug > 2 && momentum.Pt() > 0.1)
1374 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1375 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1377 if (fMixedEvent) track->SetID(itrack);
1379 fCTSTracks->Add(track);
1383 if(fVertexBC ==0 || fVertexBC == AliVTrack::kTOFBCNA)
1385 if( bc0 ) fVertexBC = 0 ;
1386 else fVertexBC = AliVTrack::kTOFBCNA ;
1390 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1394 //__________________________________________________________________
1395 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1398 //Fill the EMCAL data in the array, do it
1402 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1404 if(fRecalculateClusters)
1406 //Recalibrate the cluster energy
1407 if(GetCaloUtils()->IsRecalibrationOn())
1409 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1412 //printf("Recalibrated Energy %f\n",clus->E());
1414 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1415 GetCaloUtils()->RecalculateClusterPID(clus);
1419 //Recalculate distance to bad channels, if new list of bad channels provided
1420 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1422 //Recalculate cluster position
1423 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1425 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1426 //clus->GetPosition(pos);
1427 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1431 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1433 Double_t tof = clus->GetTOF();
1435 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1437 if(fDataType==AliCaloTrackReader::kESD)
1439 tof = fEMCALCells->GetCellTime(absIdMax);
1442 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1446 }// Time recalibration
1449 //Reject clusters with bad channels, close to borders and exotic;
1450 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1452 //Mask all cells in collumns facing ALICE thick material if requested
1453 if(GetCaloUtils()->GetNMaskCellColumns())
1459 Bool_t shared = kFALSE;
1460 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1461 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1464 if(fSelectEmbeddedClusters)
1466 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1467 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1471 //clus->GetPosition(pos);
1472 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1474 //Correct non linearity
1475 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1477 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1478 //printf("Linearity Corrected Energy %f\n",clus->E());
1480 //In case of MC analysis, to match resolution/calibration in real data
1481 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1482 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1483 clus->SetE(rdmEnergy);
1486 Double_t tof = clus->GetTOF()*1e9;
1488 Int_t bc = TMath::Nint(tof/50) + 9;
1489 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1491 SetEMCalEventBC(bc);
1493 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1495 TLorentzVector momentum ;
1497 clus->GetMomentum(momentum, fVertex[vindex]);
1499 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1501 SetEMCalEventBCcut(bc);
1503 if(!IsInTimeWindow(tof,clus->E()))
1505 fNPileUpClusters++ ;
1506 if(fUseEMCALTimeCut) return ;
1509 fNNonPileUpClusters++;
1511 if(fDebug > 2 && momentum.E() > 0.1)
1512 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1513 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1516 clus->SetID(iclus) ;
1518 //Correct MC label for AODs
1520 fEMCALClusters->Add(clus);
1524 //_______________________________________
1525 void AliCaloTrackReader::FillInputEMCAL()
1527 //Return array with EMCAL clusters in aod format
1529 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1531 // First recalibrate cells, time or energy
1532 // if(GetCaloUtils()->IsRecalibrationOn())
1533 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1535 // fInputEvent->GetBunchCrossNumber());
1537 fNPileUpClusters = 0; // Init counter
1538 fNNonPileUpClusters = 0; // Init counter
1539 for(Int_t i = 0; i < 19; i++)
1541 fEMCalBCEvent [i] = 0;
1542 fEMCalBCEventCut[i] = 0;
1545 //Loop to select clusters in fiducial cut and fill container with aodClusters
1546 if(fEMCALClustersListName=="")
1548 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1549 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1551 AliVCluster * clus = 0;
1552 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1554 if (IsEMCALCluster(clus))
1556 FillInputEMCALAlgorithm(clus, iclus);
1561 //Recalculate track matching
1562 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1564 }//Get the clusters from the input event
1567 TClonesArray * clusterList = 0x0;
1569 if (fInputEvent->FindListObject(fEMCALClustersListName))
1571 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1573 else if(fOutputEvent)
1575 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1580 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1584 Int_t nclusters = clusterList->GetEntriesFast();
1585 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1587 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1588 //printf("E %f\n",clus->E());
1589 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1590 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1593 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1594 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1596 fNPileUpClusters = 0; // Init counter
1597 fNNonPileUpClusters = 0; // Init counter
1598 for(Int_t i = 0; i < 19; i++)
1600 fEMCalBCEvent [i] = 0;
1601 fEMCalBCEventCut[i] = 0;
1604 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1606 AliVCluster * clus = 0;
1608 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1610 if (IsEMCALCluster(clus))
1614 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1615 Double_t tof = clus->GetTOF();
1616 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1619 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1621 //Reject clusters with bad channels, close to borders and exotic;
1622 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1624 Int_t bc = TMath::Nint(tof/50) + 9;
1625 SetEMCalEventBC(bc);
1627 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1629 TLorentzVector momentum ;
1631 clus->GetMomentum(momentum, fVertex[0]);
1633 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1635 SetEMCalEventBCcut(bc);
1637 if(!IsInTimeWindow(tof,clus->E()))
1638 fNPileUpClusters++ ;
1640 fNNonPileUpClusters++;
1646 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1648 // Recalculate track matching, not necessary if already done in the reclusterization task.
1649 // in case it was not done ...
1650 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1654 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1658 //______________________________________
1659 void AliCaloTrackReader::FillInputPHOS()
1661 //Return array with PHOS clusters in aod format
1663 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1665 //Loop to select clusters in fiducial cut and fill container with aodClusters
1666 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1667 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1669 AliVCluster * clus = 0;
1670 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1672 if (IsPHOSCluster(clus))
1674 //Check if the cluster contains any bad channel and if close to calorimeter borders
1677 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1678 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1680 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1683 if(fRecalculateClusters)
1685 //Recalibrate the cluster energy
1686 if(GetCaloUtils()->IsRecalibrationOn())
1688 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1693 TLorentzVector momentum ;
1695 clus->GetMomentum(momentum, fVertex[vindex]);
1697 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1699 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1701 if(fDebug > 2 && momentum.E() > 0.1)
1702 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1703 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1708 clus->SetID(iclus) ;
1711 fPHOSClusters->Add(clus);
1717 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1721 //____________________________________________
1722 void AliCaloTrackReader::FillInputEMCALCells()
1724 //Return array with EMCAL cells in aod format
1726 fEMCALCells = fInputEvent->GetEMCALCells();
1730 //___________________________________________
1731 void AliCaloTrackReader::FillInputPHOSCells()
1733 //Return array with PHOS cells in aod format
1735 fPHOSCells = fInputEvent->GetPHOSCells();
1739 //_______________________________________
1740 void AliCaloTrackReader::FillInputVZERO()
1742 //Fill VZERO information in data member, add all the channels information.
1743 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1744 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1748 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1749 for (Int_t i = 0; i < 32; i++)
1752 {//Only available in ESDs
1753 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1754 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1757 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1758 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1761 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1766 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1771 //___________________________________________________________________
1772 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1774 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1775 // different number and need to patch here
1777 if(fDataType==kAOD && fOldAOD)
1779 if (cluster->GetType() == 2) return kTRUE;
1784 return cluster->IsEMCAL();
1789 //___________________________________________________________________
1790 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1792 //Check if it is a cluster from PHOS.For old AODs cluster type has
1793 // different number and need to patch here
1795 if(fDataType==kAOD && fOldAOD)
1797 Int_t type = cluster->GetType();
1798 if (type == 0 || type == 1) return kTRUE;
1803 return cluster->IsPHOS();
1808 //________________________________________________
1809 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1811 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1814 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1815 if(!event) return kTRUE;
1817 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1822 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1825 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1827 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1831 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1833 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1842 //_______________________________________________
1843 TArrayI AliCaloTrackReader::GetTriggerPatches()
1845 // Select the patches that triggered
1846 // Depend on L0 or L1
1849 Int_t trigtimes[30], globCol, globRow,ntimes, i;
1850 Int_t absId = -1; //[100];
1855 // get object pointer
1856 AliVCaloTrigger *caloTrigger = GetInputEvent()->GetCaloTrigger( "EMCAL" );
1858 // class is not empty
1859 if( caloTrigger->GetEntries() > 0 )
1861 // must reset before usage, or the class will fail
1862 caloTrigger->Reset();
1864 // go throuth the trigger channels
1865 while( caloTrigger->Next() )
1867 // get position in global 2x2 tower coordinates
1868 caloTrigger->GetPosition( globCol, globRow );
1871 if(IsEventEMCALL0())
1873 // get dimension of time arrays
1874 caloTrigger->GetNL0Times( ntimes );
1876 // no L0s in this channel
1877 // presence of the channel in the iterator still does not guarantee that L0 was produced!!
1882 caloTrigger->GetL0Times( trigtimes );
1884 //printf("trigger time window %d - %d\n",fTriggerPatchTimeWindow[0],fTriggerPatchTimeWindow[1]);
1885 // go through the array
1886 for( i = 0; i < ntimes; i++ )
1888 // check if in cut - 8,9 shall be accepted in 2011
1889 if( trigtimes[i] >= fTriggerPatchTimeWindow[0] && trigtimes[i] <= fTriggerPatchTimeWindow[1] )
1891 //printf("Accepted trigger time %d \n",trigtimes[i]);
1892 //if(nTrig > 99) continue;
1893 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol,globRow, absId);
1894 //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absIDTrig[nTrig]);
1895 patches.Set(nPatch+1);
1896 patches.AddAt(absId,nPatch++);
1898 } // trigger time array
1900 else if(IsEventEMCALL1()) // L1
1903 caloTrigger->GetTriggerBits(bit);
1905 Bool_t isEGA = ((bit >> fBitEGA) & 0x1) && IsEventEMCALL1Gamma() ;
1906 Bool_t isEJE = ((bit >> fBitEJE) & 0x1) && IsEventEMCALL1Jet () ;
1908 if(!isEGA && !isEJE) continue;
1910 Int_t patchsize = -1;
1911 if (isEGA) patchsize = 2;
1912 else if (isEJE) patchsize = 16;
1914 // add 2x2 (EGA) or 16x16 (EJE) patches
1915 for(Int_t irow=0; irow < patchsize; irow++)
1917 for(Int_t icol=0; icol < patchsize; icol++)
1919 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol+icol,globRow+irow, absId);
1920 //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absIDTrig[nTrig]);
1921 patches.Set(nPatch+1);
1922 patches.AddAt(absId,nPatch++);
1928 } // trigger iterator
1929 } // go thorough triggers
1931 //printf("N patches %d, test %d,first %d, last %d\n",patches.GetSize(), nPatch, patches.At(0), patches.At(patches.GetSize()-1));
1936 //______________________________________________________________________
1937 void AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
1939 // Finds the cluster that triggered
1941 // Init info from previous event
1942 fTriggerClusterIndex = -1;
1943 fTriggerClusterId = -1;
1944 fIsTriggerMatch = kFALSE;
1945 fTriggerClusterBC = -10000;
1946 fIsExoticEvent = kFALSE;
1947 fIsBadCellEvent = kFALSE;
1948 fIsBadMaxCellEvent = kFALSE;
1950 // Do only analysis for triggered events
1951 if(!IsEventEMCALL1() && !IsEventEMCALL0())
1953 fTriggerClusterBC = 0;
1957 //Recover the list of clusters
1958 TClonesArray * clusterList = 0;
1959 if (fInputEvent->FindListObject(fEMCALClustersListName))
1961 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1963 else if(fOutputEvent)
1965 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1968 // Get number of clusters and of trigger patches
1969 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1971 nclusters = clusterList->GetEntriesFast();
1973 Int_t nPatch = patches.GetSize();
1974 Float_t exoDiffTime = GetCaloUtils()->GetEMCALRecoUtils()->GetExoticCellDiffTimeCut();
1976 //Init some variables used in the cluster loop
1977 Float_t tofPatchMax = 100000;
1978 Float_t ePatchMax =-1;
1980 Float_t tofMax = 100000;
1984 Int_t idclusMax =-1;
1985 Bool_t badClMax = kFALSE;
1986 Bool_t badCeMax = kFALSE;
1987 Bool_t exoMax = kFALSE;
1989 Int_t nOfHighECl = 0 ;
1991 Float_t minE = fTriggerEventThreshold / 2.;
1992 // This method is not really suitable for JET trigger
1993 // but in case, reduce the energy cut since we do not trigger on high energy particle
1994 if(IsEventEMCALL1()) minE = 1;
1996 // Loop on the clusters, check if there is any that falls into one of the patches
1997 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1999 AliVCluster * clus = 0;
2000 if(clusterList) clus = (AliVCluster*) clusterList->At(iclus);
2001 else clus = fInputEvent->GetCaloCluster(iclus);
2003 if ( !clus ) continue ;
2005 if ( !IsEMCALCluster(clus)) continue ;
2007 //Skip clusters with too low energy to be triggering
2008 if ( clus->E() < minE ) continue ;
2011 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fInputEvent->GetEMCALCells(), clus,frac);
2013 Bool_t badCluster = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),
2014 clus->GetCellsAbsId(),clus->GetNCells());
2015 UShort_t cellMax[] = {absIdMax};
2016 Bool_t badCell = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),cellMax,1);
2018 // if cell is bad, it can happen that time calibration is not available,
2019 // when calculating if it is exotic, this can make it to be exotic by default
2020 // open it temporarily for this cluster
2022 GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(10000000);
2024 Bool_t exotic = GetCaloUtils()->GetEMCALRecoUtils()->IsExoticCluster(clus, fInputEvent->GetEMCALCells());
2026 // Set back the time cut on exotics
2028 GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(exoDiffTime);
2030 // Energy threshold for exotic Ecross typically at 4 GeV,
2031 // for lower energy, check that there are more than 1 cell in the cluster
2032 if(!exotic && clus->GetNCells() < 2) exotic = kTRUE;
2034 Float_t energy = clus->E();
2035 Int_t idclus = clus->GetID();
2037 Double_t tof = clus->GetTOF();
2038 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
2039 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
2042 //printf("cluster %d, ID %d, E %2.2f, tof %2.2f, AbsId max %d, exotic %d, bad Cluster %d, bad Cell %d\n",
2043 // iclus,idclus, energy,tof,absIdMax, exotic, badCluster,badCell);
2045 // Find the highest energy cluster, avobe trigger threshold
2046 // in the event in case no match to trigger is found
2051 badClMax = badCluster;
2058 // count the good clusters in the event avobe the trigger threshold
2059 // to check the exotic events
2060 if(!badCluster && !exotic)
2063 // Find match to trigger
2064 if(fTriggerPatchClusterMatch)
2066 for(Int_t iabsId =0; iabsId < nPatch; iabsId++)
2069 GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patches.At(iabsId), absIDCell);
2070 //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
2071 // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
2073 for(Int_t ipatch = 0; ipatch < 4; ipatch++)
2075 if(absIdMax == absIDCell[ipatch])
2077 //printf("*** Patches : absId %d, E %2.1f, tof %f \n",absIdMax,clus->E(), tof);
2078 if(energy > ePatchMax)
2082 fIsBadCellEvent = badCluster;
2083 fIsBadMaxCellEvent = badCell;
2084 fIsExoticEvent = exotic;
2085 fTriggerClusterIndex = iclus;
2086 fTriggerClusterId = idclus;
2087 fIsTriggerMatch = kTRUE;
2091 }// trigger patch loop
2092 } // Do trigger patch matching
2096 // If there was no match, assign as trigger
2097 // the highest energy cluster in the event
2098 if(!fIsTriggerMatch)
2100 tofPatchMax = tofMax;
2102 fIsBadCellEvent = badClMax;
2103 fIsBadMaxCellEvent = badCeMax;
2104 fIsExoticEvent = exoMax;
2105 fTriggerClusterIndex = clusMax;
2106 fTriggerClusterId = idclusMax;
2109 Double_t tofPatchMaxUS = TMath::Abs(tofPatchMax);
2111 if (tofPatchMaxUS < 28 ) fTriggerClusterBC = 0 ;
2112 else if(tofPatchMaxUS < 75 ) fTriggerClusterBC = 1 ;
2113 else if(tofPatchMaxUS < 125) fTriggerClusterBC = 2 ;
2114 else if(tofPatchMaxUS < 175) fTriggerClusterBC = 3 ;
2115 else if(tofPatchMaxUS < 225) fTriggerClusterBC = 4 ;
2116 else if(tofPatchMaxUS < 275) fTriggerClusterBC = 5 ;
2119 //printf("AliCaloTrackReader::MatchTriggerCluster() - Large BC - tof %2.3f - Index %d\n",tofPatchMaxUS,fTriggerClusterIndex);
2120 if(fTriggerClusterIndex >= 0) fTriggerClusterBC = 6 ;
2123 fTriggerClusterIndex = -2;
2124 fTriggerClusterId = -2;
2128 if(tofPatchMax < 0) fTriggerClusterBC*=-1;
2130 // printf("AliCaloTrackReader::MatchTriggerCluster(TArrayI patches) - Trigger cluster: index %d, ID %d, E = %2.2f, tof = %2.2f (BC = %d), bad cluster? %d, bad cell? %d, exotic? %d, patch match? %d, n High E cluster %d\n",
2131 // fTriggerClusterIndex, fTriggerClusterId,ePatchMax, tofPatchMax,
2132 // fTriggerClusterBC, fIsBadCellEvent,fIsBadMaxCellEvent,fIsExoticEvent, fIsTriggerMatch, nOfHighECl);
2134 // if(!fIsTriggerMatch) printf("\t highest energy cluster: index %d, ID %d, E = %2.2f, tof = %2.2f, bad cluster? %d, bad cell? %d, exotic? %d\n",clusMax, idclusMax, eMax,tofMax, badClMax, badCeMax,exoMax);
2137 //__________________________________________
2138 Bool_t AliCaloTrackReader::RejectLEDEvents()
2140 // LED Events in period LHC11a contaminated sample, simple method
2141 // to reject such events
2143 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
2144 Int_t ncellsSM3 = 0;
2145 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
2147 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
2148 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
2149 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
2152 Int_t ncellcut = 21;
2153 if(GetFiredTriggerClasses().Contains("EMC")) ncellcut = 35;
2155 if(ncellsSM3 >= ncellcut)
2158 printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d, cut %d, trig %s\n",
2159 ncellsSM3,ncellcut,GetFiredTriggerClasses().Data());
2167 //___________________________________________
2168 void AliCaloTrackReader::SetEventTriggerBit()
2170 // Tag event depeding on trigger name
2172 fEventTrigMinBias = kFALSE;
2173 fEventTrigCentral = kFALSE;
2174 fEventTrigSemiCentral = kFALSE;
2175 fEventTrigEMCALL0 = kFALSE;
2176 fEventTrigEMCALL1Gamma1 = kFALSE;
2177 fEventTrigEMCALL1Gamma2 = kFALSE;
2178 fEventTrigEMCALL1Jet1 = kFALSE;
2179 fEventTrigEMCALL1Jet2 = kFALSE;
2181 if(fEventTriggerMask <=0 )// in case no mask set
2183 // EMC triggered event? Which type?
2184 if( GetFiredTriggerClasses().Contains("-B-") || GetFiredTriggerClasses().Contains("-S-") || GetFiredTriggerClasses().Contains("-I-") )
2186 if ( GetFiredTriggerClasses().Contains("EGA" ) ||
2187 GetFiredTriggerClasses().Contains("EG1" ) )
2189 fEventTrigEMCALL1Gamma1 = kTRUE;
2190 if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
2192 else if( GetFiredTriggerClasses().Contains("EG2" ) )
2194 fEventTrigEMCALL1Gamma2 = kTRUE;
2195 if( !fFiredTriggerClassName.Contains("EG2") ) fEventTrigEMCALL1Gamma2 = kFALSE;
2197 else if( GetFiredTriggerClasses().Contains("EJE" ) ||
2198 GetFiredTriggerClasses().Contains("EJ1" ) )
2200 fEventTrigEMCALL1Jet1 = kTRUE;
2201 if( GetFiredTriggerClasses().Contains("EJ1" ) && !fFiredTriggerClassName.Contains("EJ1") )
2202 fEventTrigEMCALL1Jet1 = kFALSE;
2204 else if( GetFiredTriggerClasses().Contains("EJ2" ) )
2206 fEventTrigEMCALL1Jet2 = kTRUE;
2207 if( !fFiredTriggerClassName.Contains("EJ2") ) fEventTrigEMCALL1Jet2 = kFALSE;
2209 else if( GetFiredTriggerClasses().Contains("CEMC") &&
2210 !GetFiredTriggerClasses().Contains("EGA" ) &&
2211 !GetFiredTriggerClasses().Contains("EJE" ) &&
2212 !GetFiredTriggerClasses().Contains("EG1" ) &&
2213 !GetFiredTriggerClasses().Contains("EJ1" ) &&
2214 !GetFiredTriggerClasses().Contains("EG2" ) &&
2215 !GetFiredTriggerClasses().Contains("EJ2" ) )
2216 fEventTrigEMCALL0 = kTRUE;
2218 //Min bias event trigger?
2219 if (GetFiredTriggerClasses().Contains("CCENT_R2-B-NOPF-ALLNOTRD"))
2220 fEventTrigCentral = kTRUE;
2221 else if(GetFiredTriggerClasses().Contains("CSEMI_R1-B-NOPF-ALLNOTRD"))
2222 fEventTrigSemiCentral = kTRUE;
2223 else if((GetFiredTriggerClasses().Contains("CINT") || GetFiredTriggerClasses().Contains("CPBI2_B1") ) &&
2224 GetFiredTriggerClasses().Contains("-NOPF-ALLNOTRD") )
2225 fEventTrigMinBias = kTRUE;
2231 if ( fEventTriggerMask & AliVEvent::kEMCEGA )
2233 if (GetFiredTriggerClasses().Contains("EG1" ) ||
2234 GetFiredTriggerClasses().Contains("EGA" ) )
2236 fEventTrigEMCALL1Gamma1 = kTRUE;
2237 if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
2239 else if(GetFiredTriggerClasses().Contains("EG2" ))
2241 fEventTrigEMCALL1Gamma2 = kTRUE;
2242 if(!fFiredTriggerClassName.Contains("EG2") ) fEventTrigEMCALL1Gamma2 = kFALSE;
2246 else if( fEventTriggerMask & AliVEvent::kEMCEJE )
2248 if (GetFiredTriggerClasses().Contains("EJ1" )||
2249 GetFiredTriggerClasses().Contains("EJE" ) )
2251 fEventTrigEMCALL1Jet1 = kTRUE;
2252 if( GetFiredTriggerClasses().Contains("EJ1" ) && !fFiredTriggerClassName.Contains("EJ1") ) fEventTrigEMCALL1Jet1 = kFALSE;
2254 else if(GetFiredTriggerClasses().Contains("EJ2" ))
2256 fEventTrigEMCALL1Jet2 = kTRUE;
2257 if( !fFiredTriggerClassName.Contains("EJ2") ) fEventTrigEMCALL1Jet2 = kFALSE;
2261 else if((fEventTriggerMask & AliVEvent::kEMC7) ||
2262 (fEventTriggerMask & AliVEvent::kEMC1) )
2263 fEventTrigEMCALL0 = kTRUE;
2265 else if( fEventTriggerMask & AliVEvent::kCentral )
2266 fEventTrigSemiCentral = kTRUE;
2268 else if( fEventTriggerMask & AliVEvent::kSemiCentral )
2269 fEventTrigCentral = kTRUE;
2270 // Min Bias pp, PbPb, pPb
2271 else if((fEventTriggerMask & AliVEvent::kMB ) ||
2272 (fEventTriggerMask & AliVEvent::kINT7) ||
2273 (fEventTriggerMask & AliVEvent::kINT8) )
2274 fEventTrigMinBias = kTRUE;
2278 printf("AliCaloTrackReader::SetEventTriggerBit() - Event bits: \n \t MB %d, Cen %d, Sem %d, L0 %d, L1G1 %d, L1G2 %d, L1J1 %d, L1J2 %d \n",
2279 fEventTrigMinBias, fEventTrigCentral, fEventTrigSemiCentral,
2280 fEventTrigEMCALL0 , fEventTrigEMCALL1Gamma1, fEventTrigEMCALL1Gamma2,
2281 fEventTrigEMCALL1Jet1 , fEventTrigEMCALL1Jet2);
2283 if(fBitEGA == 0 && fBitEJE ==0)
2285 // Init the trigger bit once, correct depending on version
2289 TFile* file = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
2291 const TList *clist = file->GetStreamerInfoCache();
2295 TStreamerInfo *cinfo = (TStreamerInfo*)clist->FindObject("AliESDCaloTrigger");
2296 if(!cinfo) cinfo = (TStreamerInfo*)clist->FindObject("AliAODCaloTrigger");
2300 Int_t classversionid = cinfo->GetClassVersion();
2302 if (classversionid >= 5)
2307 } else printf("AliCaloTrackReader()::Init() - Streamer info for trigger class not available, bit not changed\n");
2308 } else printf("AliCaloTrackReader::Init() - Streamer list not available!, bit not changed\n");
2310 } // set once the EJE, EGA trigger bit
2315 //____________________________________________________________
2316 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
2320 if(fESDtrackCuts) delete fESDtrackCuts ;
2322 fESDtrackCuts = cuts ;
2326 //_________________________________________________________________________
2327 void AliCaloTrackReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
2329 // Set Track cuts for complementary tracks (hybrids)
2331 if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
2333 fESDtrackComplementaryCuts = cuts ;