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.8),
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 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
97 fTriggerAnalysis (0x0), fTimeStampEventSelect(0),
98 fTimeStampEventFracMin(0), fTimeStampEventFracMax(0),
99 fTimeStampRunMin(0), fTimeStampRunMax(0),
100 fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
101 fCentralityClass(""), fCentralityOpt(0),
102 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
106 //Initialize parameters
110 //_______________________________________
111 AliCaloTrackReader::~AliCaloTrackReader()
115 delete fFiducialCut ;
119 fAODBranchList->Delete();
120 delete fAODBranchList ;
125 if(fDataType!=kMC)fCTSTracks->Clear() ;
126 else fCTSTracks->Delete() ;
132 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
133 else fEMCALClusters->Delete() ;
134 delete fEMCALClusters ;
139 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
140 else fPHOSClusters->Delete() ;
141 delete fPHOSClusters ;
146 for (Int_t i = 0; i < fNMixedEvent; i++)
148 delete [] fVertex[i] ;
154 delete fESDtrackCuts;
155 delete fESDtrackComplementaryCuts;
156 delete fTriggerAnalysis;
158 // Pointers not owned, done by the analysis frame
159 // if(fInputEvent) delete fInputEvent ;
160 // if(fOutputEvent) delete fOutputEvent ;
161 // if(fMC) delete fMC ;
162 // Pointer not owned, deleted by maker
163 // if (fCaloUtils) delete fCaloUtils ;
167 //________________________________________________
168 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
170 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
173 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
175 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
178 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
179 Int_t nTriggerJets = pygeh->NTriggerJets();
180 Float_t ptHard = pygeh->GetPtHard();
183 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
185 Float_t tmpjet[]={0,0,0,0};
186 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
188 pygeh->TriggerJet(ijet, tmpjet);
189 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
192 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
194 //Compare jet pT and pt Hard
195 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
197 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
198 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
210 //____________________________________________________________________
211 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
213 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
216 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
218 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
219 Float_t ptHard = pygeh->GetPtHard();
221 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
222 for (Int_t iclus = 0; iclus < nclusters; iclus++)
224 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
225 Float_t ecluster = clus->E();
227 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
229 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
241 //____________________________________________
242 AliStack* AliCaloTrackReader::GetStack() const
244 //Return pointer to stack
249 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
254 //__________________________________________________
255 TString AliCaloTrackReader::GetFiredTriggerClasses()
257 // List of triggered classes in a TString
259 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
260 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
262 if (esdevent) return esdevent->GetFiredTriggerClasses();
263 else if(aodevent) return aodevent->GetFiredTriggerClasses();
264 else return ""; // Mixed Event, MC event, does not have this trigger info
268 //______________________________________________
269 AliHeader* AliCaloTrackReader::GetHeader() const
271 //Return pointer to header
274 return fMC->Header();
278 printf("AliCaloTrackReader::Header is not available\n");
283 //______________________________________________________________
284 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
286 //Return pointer to Generated event header
287 if (ReadStack() && fMC)
289 return fMC->GenEventHeader();
291 else if(ReadAODMCParticles() && GetAODMCHeader())
293 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
294 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
295 return GetAODMCHeader()->GetCocktailHeader(0) ;
301 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
306 //____________________________________________________________________
307 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
309 //Return list of particles in AOD. Do it for the corresponding input event.
311 TClonesArray * rv = NULL ;
312 if(fDataType == kAOD)
317 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
319 rv = (TClonesArray*)evt->FindListObject("mcparticles");
321 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
327 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
333 //________________________________________________________
334 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
336 //Return MC header in AOD. Do it for the corresponding input event.
338 AliAODMCHeader *mch = NULL;
340 if(fDataType == kAOD)
342 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
343 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
347 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
353 //_____________________________
354 void AliCaloTrackReader::Init()
356 //Init reader. Method to be called in AliAnaPartCorrMaker
358 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
360 if(fReadStack && fReadAODMCParticles)
362 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
364 fReadAODMCParticles = kFALSE;
367 // Init geometry, I do not like much to do it like this ...
368 if(fImportGeometryFromFile && !gGeoManager)
370 if(fImportGeometryFilePath=="") // If not specified, set a default location
371 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
373 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
374 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
378 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
382 //_______________________________________
383 void AliCaloTrackReader::InitParameters()
385 //Initialize the parameters of the analysis.
391 fEMCALPtMax = 1000. ;
395 fTrackDCACut[0] = 3; //xy, quite large
396 fTrackDCACut[1] = 3; //z, quite large
397 fTrackDCACut[2] = 3; //TPC constrained, quite large
399 //Do not filter the detectors input by default.
403 fFillEMCALCells = kFALSE;
404 fFillPHOSCells = kFALSE;
406 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
407 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
408 fDeltaAODFileName = "deltaAODPartCorr.root";
409 fFiredTriggerClassName = "";
410 fEventTriggerMask = AliVEvent::kAny;
411 fMixEventTriggerMask = AliVEvent::kAnyINT;
412 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
414 fAcceptFastCluster = kTRUE;
417 //We want tracks fitted in the detectors:
418 //fTrackStatus=AliESDtrack::kTPCrefit;
419 //fTrackStatus|=AliESDtrack::kITSrefit;
421 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
424 fESDtrackComplementaryCuts = 0;
426 fConstrainTrack = kFALSE ; // constrain tracks to vertex
428 fV0ADC[0] = 0; fV0ADC[1] = 0;
429 fV0Mul[0] = 0; fV0Mul[1] = 0;
435 fPtHardAndJetPtFactor = 7.;
436 fPtHardAndClusterPtFactor = 1.;
439 fCentralityClass = "V0M";
441 fCentralityBin[0] = fCentralityBin[1]=-1;
443 fEventPlaneMethod = "V0";
445 // Allocate memory (not sure this is the right place)
446 fCTSTracks = new TObjArray();
447 fEMCALClusters = new TObjArray();
448 fPHOSClusters = new TObjArray();
449 fTriggerAnalysis = new AliTriggerAnalysis;
450 fAODBranchList = new TList ;
452 fImportGeometryFromFile = kFALSE;
454 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
455 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
457 // Parametrized time cut (LHC11d)
458 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
459 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
461 // Parametrized time cut (LHC11c)
462 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
463 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
465 fTimeStampRunMin = -1;
466 fTimeStampRunMax = 1000000000000;
467 fTimeStampEventFracMin = -1;
468 fTimeStampEventFracMax = 2;
472 //___________________________________________________________
473 Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
475 // Cluster time selection window
477 // Parametrized cut depending on E
480 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
481 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
482 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
483 if( tof < minCut || tof > maxCut ) return kFALSE ;
486 //In any case, the time should to be larger than the fixed window ...
487 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
492 //________________________________________________
493 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
495 // Check if event is from pile-up determined by SPD
496 // Default values: (3, 0.8, 3., 2., 5.)
497 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
498 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
499 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
503 //__________________________________________________
504 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
506 // Check if event is from pile-up determined by EMCal
507 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
511 //________________________________________________________
512 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
514 // Check if event is from pile-up determined by SPD and EMCal
515 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
519 //_______________________________________________________
520 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
522 // Check if event is from pile-up determined by SPD or EMCal
523 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
527 //___________________________________________________________
528 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
530 // Check if event is from pile-up determined by SPD and not by EMCal
531 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
535 //___________________________________________________________
536 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
538 // Check if event is from pile-up determined by EMCal, not by SPD
539 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
543 //______________________________________________________________
544 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
546 // Check if event not from pile-up determined neither by SPD nor by EMCal
547 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
551 //________________________________________________________
552 void AliCaloTrackReader::Print(const Option_t * opt) const
555 //Print some relevant parameters set for the analysis
559 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
560 printf("Task name : %s\n", fTaskName.Data()) ;
561 printf("Data type : %d\n", fDataType) ;
562 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
563 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
564 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
565 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
566 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
567 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
568 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
569 printf("Use CTS = %d\n", fFillCTS) ;
570 printf("Use EMCAL = %d\n", fFillEMCAL) ;
571 printf("Use PHOS = %d\n", fFillPHOS) ;
572 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
573 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
574 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
575 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
576 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
577 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
578 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
580 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
581 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
583 if(fComparePtHardAndClusterPt)
584 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
586 if(fComparePtHardAndClusterPt)
587 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
589 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
590 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
591 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
597 //_________________________________________________________________________
598 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
599 const char * /*currentFileName*/)
601 //Fill the event counter and input lists that are needed, called by the analysis maker.
603 fEventNumber = iEntry;
604 //fCurrentFileName = TString(currentFileName);
607 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
611 //Select events only fired by a certain trigger configuration if it is provided
613 if(fInputEvent->GetHeader())
614 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
616 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
618 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
622 //-------------------------------------------------------------------------------------
623 // Reject event if large clusters with large energy
624 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
625 // If clusterzer NxN or V2 it does not help
626 //-------------------------------------------------------------------------------------
627 Int_t run = fInputEvent->GetRunNumber();
628 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
630 //printf("Event %d\n",GetEventNumber());
632 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
634 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
636 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
637 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
638 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
642 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
644 if(ncellsSM3 >= ncellcut)
646 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d\n",ncellsSM3);
649 }// Remove LED events
651 // Reject pure LED events?
652 if( fFiredTriggerClassName !="" && !fAnaLED)
654 //printf("Event type %d\n",eventType);
656 return kFALSE; //Only physics event, do not use for simulated events!!!
659 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
660 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
662 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
663 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
667 // kStartOfRun = 1, // START_OF_RUN
668 // kEndOfRun = 2, // END_OF_RUN
669 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
670 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
671 // kStartOfBurst = 5, // START_OF_BURST
672 // kEndOfBurst = 6, // END_OF_BURST
673 // kPhysicsEvent = 7, // PHYSICS_EVENT
674 // kCalibrationEvent = 8, // CALIBRATION_EVENT
675 // kFormatError = 9, // EVENT_FORMAT_ERROR
676 // kStartOfData = 10, // START_OF_DATA
677 // kEndOfData = 11, // END_OF_DATA
678 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
679 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
681 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
682 if(eventType!=8)return kFALSE;
685 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
686 if(fComparePtHardAndJetPt)
688 if(!ComparePtHardAndJetPt()) return kFALSE ;
691 if(fComparePtHardAndClusterPt)
693 if(!ComparePtHardAndClusterPt()) return kFALSE ;
698 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
699 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
701 //------------------------------------------------------
702 //Event rejection depending on vertex, pileup, v0and
703 //------------------------------------------------------
704 if(fDataType==kESD && fTimeStampEventSelect)
706 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
707 Int_t timeStamp = esd->GetTimeStamp();
708 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
710 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, timeStampFrac);
712 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
714 //printf("\t accept time stamp\n");
718 //------------------------------------------------------
719 //Event rejection depending on vertex, pileup, v0and
720 //------------------------------------------------------
722 if(fUseEventsWithPrimaryVertex)
724 if( !CheckForPrimaryVertex() ) return kFALSE;
725 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
726 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
727 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
730 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
732 if(fDoEventSelection)
734 if(!fCaloFilterPatch)
736 // Do not analyze events with pileup
737 Bool_t bPileup = IsPileUpFromSPD();
738 //IsPileupFromSPDInMultBins() // method to try
739 //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]);
740 if(bPileup) return kFALSE;
742 if(fDoV0ANDEventSelection)
744 Bool_t bV0AND = kTRUE;
745 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
747 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
748 //else bV0AND = //FIXME FOR AODs
749 if(!bV0AND) return kFALSE;
754 if(fInputEvent->GetNumberOfCaloClusters() > 0)
756 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
757 if(calo->GetNLabels() == 4)
759 Int_t * selection = calo->GetLabels();
760 Bool_t bPileup = selection[0];
761 if(bPileup) return kFALSE;
763 Bool_t bGoodV = selection[1];
764 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
766 if(fDoV0ANDEventSelection)
768 Bool_t bV0AND = selection[2];
769 if(!bV0AND) return kFALSE;
772 fTrackMult = selection[3];
773 if(fTrackMult == 0) return kFALSE;
777 //First filtered AODs, track multiplicity stored there.
778 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
779 if(fTrackMult == 0) return kFALSE;
781 }//at least one cluster
784 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
785 //Remove events with vertex (0,0,0), bad vertex reconstruction
786 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;
788 //First filtered AODs, track multiplicity stored there.
789 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
790 if(fTrackMult == 0) return kFALSE;
792 }// CaloFileter patch
794 //------------------------------------------------------
796 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
797 //If we need a centrality bin, we select only those events in the corresponding bin.
798 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
800 Int_t cen = GetEventCentrality();
801 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
804 //Fill the arrays with cluster/tracks/cells data
807 FillInputEMCALCells();
810 FillInputPHOSCells();
814 if(fEventTriggerAtSE)
819 //Accept events with at least one track
820 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
829 // In case of mixing analysis, all triggers accepted, but trigger particles selected
830 // only for the specific trigered events selected here. Mixing done only for MB events,
831 // tracks array filled also for those events and not the others.
833 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
834 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
836 if(!inputHandler) return kFALSE ; // to content coverity
838 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
839 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
841 if(fFillCTS && (isMB || isTrigger))
844 //Accept events with at least one track
845 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
860 //___________________________________
861 void AliCaloTrackReader::ResetLists()
863 // Reset lists, called by the analysis maker
865 if(fCTSTracks) fCTSTracks -> Clear();
866 if(fEMCALClusters) fEMCALClusters -> Clear("C");
867 if(fPHOSClusters) fPHOSClusters -> Clear("C");
869 fV0ADC[0] = 0; fV0ADC[1] = 0;
870 fV0Mul[0] = 0; fV0Mul[1] = 0;
874 //____________________________________________________________
875 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
878 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
880 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
882 //Delete previous vertex
885 for (Int_t i = 0; i < fNMixedEvent; i++)
887 delete [] fVertex[i] ;
892 fVertex = new Double_t*[fNMixedEvent] ;
893 for (Int_t i = 0; i < fNMixedEvent; i++)
895 fVertex[i] = new Double_t[3] ;
896 fVertex[i][0] = 0.0 ;
897 fVertex[i][1] = 0.0 ;
898 fVertex[i][2] = 0.0 ;
902 //__________________________________________________
903 Int_t AliCaloTrackReader::GetEventCentrality() const
905 //Return current event centrality
909 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
910 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
911 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
914 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
922 //_____________________________________________________
923 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
925 //Return current event centrality
929 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
931 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
933 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
936 else if(GetEventPlaneMethod().Contains("V0") )
938 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
940 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
944 ep+=TMath::Pi()/2; // put same range as for <Q> method
948 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
951 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
952 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
959 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
965 //__________________________________________________________
966 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
968 //Return vertex position to be used for single event analysis
969 vertex[0]=fVertex[0][0];
970 vertex[1]=fVertex[0][1];
971 vertex[2]=fVertex[0][2];
974 //____________________________________________________________
975 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
976 const Int_t evtIndex) const
978 //Return vertex position for mixed event, recover the vertex in a particular event.
980 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
984 //________________________________________
985 void AliCaloTrackReader::FillVertexArray()
988 //Fill data member with vertex
989 //In case of Mixed event, multiple vertices
991 //Delete previous vertex
994 for (Int_t i = 0; i < fNMixedEvent; i++)
996 delete [] fVertex[i] ;
1001 fVertex = new Double_t*[fNMixedEvent] ;
1002 for (Int_t i = 0; i < fNMixedEvent; i++)
1004 fVertex[i] = new Double_t[3] ;
1005 fVertex[i][0] = 0.0 ;
1006 fVertex[i][1] = 0.0 ;
1007 fVertex[i][2] = 0.0 ;
1011 { //Single event analysis
1015 if(fInputEvent->GetPrimaryVertex())
1017 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1021 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1022 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1023 }//Primary vertex pointer do not exist
1027 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1031 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
1034 { // MultiEvent analysis
1035 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1037 if (fMixedEvent->GetVertexOfEvent(iev))
1038 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1040 { // no vertex found !!!!
1041 AliWarning("No vertex found");
1045 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1052 //_____________________________________
1053 void AliCaloTrackReader::FillInputCTS()
1055 //Return array with Central Tracking System (CTS) tracks
1057 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1059 Double_t pTrack[3] = {0,0,0};
1061 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1064 Double_t bz = GetInputEvent()->GetMagneticField();
1066 for(Int_t i = 0; i < 19; i++)
1068 fTrackBCEvent [i] = 0;
1069 fTrackBCEventCut[i] = 0;
1072 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1073 {////////////// track loop
1074 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1076 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1077 ULong_t status = track->GetStatus();
1079 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1084 if (fDataType==kESD)
1086 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1090 if(fESDtrackCuts->AcceptTrack(esdTrack))
1092 track->GetPxPyPz(pTrack) ;
1096 if(esdTrack->GetConstrainedParam())
1098 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1099 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1100 esdTrack->GetConstrainedPxPyPz(pTrack);
1104 } // use constrained tracks
1106 if(fSelectSPDHitTracks)
1107 {//Not much sense to use with TPC only or Hybrid tracks
1108 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1111 // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
1112 else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
1114 // constrain the track
1115 if(esdTrack->GetConstrainedParam())
1117 esdTrack->Set(esdTrack->GetConstrainedParam()->GetX(),esdTrack->GetConstrainedParam()->GetAlpha(),esdTrack->GetConstrainedParam()->GetParameter(),esdTrack->GetConstrainedParam()->GetCovariance());
1119 track->GetPxPyPz(pTrack) ;
1127 else if(fDataType==kAOD)
1129 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1133 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1134 aodtrack->GetType(),AliAODTrack::kPrimary,
1135 aodtrack->IsHybridGlobalConstrainedGlobal());
1138 if (fSelectHybridTracks)
1140 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1144 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1147 if(fSelectSPDHitTracks)
1148 {//Not much sense to use with TPC only or Hybrid tracks
1149 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1152 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1154 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
1156 track->GetPxPyPz(pTrack) ;
1158 } // aod track exists
1163 //Count the tracks in eta < 0.9
1164 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1165 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1167 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1169 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
1170 Double_t tof = -1000;
1172 Int_t trackBC = -1000 ;
1176 trackBC = track->GetTOFBunchCrossing(bz);
1177 SetTrackEventBC(trackBC+9);
1179 tof = track->GetTOFsignal()*1e-3;
1180 //printf("track TOF %e\n",tof);
1181 //bc = TMath::Nint((tof-25)/50) + 9;
1182 //printf("track pt %f, tof %2.2f, bc=%d\n",track->Pt(),tof,bc);
1183 //SetTrackEventBC(bc);
1187 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1189 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
1193 //SetTrackEventBCcut(bc);
1194 SetTrackEventBCcut(trackBC+9);
1196 //In any case, the time should to be larger than the fixed window ...
1197 if( fUseTrackTimeCut && (trackBC!=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1199 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
1202 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1208 //In case of hybrid tracks on AODs, constrained TPC tracks cannot be propagated back to primary vertex
1209 AliAODTrack * aodTrack = dynamic_cast<AliAODTrack*>(track);
1210 Float_t dcaCons = -999;
1213 dcaCons = aodTrack->DCA();
1214 //vtxBC = aodTrack->GetProdVertex()->GetBC();
1217 if(TMath::Abs(dcaCons) > fTrackDCACut[2] ) continue ;
1221 //non contrained TPC tracks (tracks with ITS points) on AODs
1224 Double_t dca[2] = {1e6,1e6};
1225 Double_t covar[3] = {1e6,1e6,1e6};
1226 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1228 TMath::Abs(dca[0]) > fTrackDCACut[0] ||
1229 TMath::Abs(dca[1]) > fTrackDCACut[1] ) continue ;
1233 if(fDebug > 2 && momentum.Pt() > 0.1)
1234 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1235 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1237 if (fMixedEvent) track->SetID(itrack);
1239 fCTSTracks->Add(track);
1244 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1248 //__________________________________________________________________
1249 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1252 //Fill the EMCAL data in the array, do it
1256 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1258 //Reject clusters with bad channels, close to borders and exotic;
1259 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1261 //Mask all cells in collumns facing ALICE thick material if requested
1262 if(GetCaloUtils()->GetNMaskCellColumns())
1268 Bool_t shared = kFALSE;
1269 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1270 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1273 if(fSelectEmbeddedClusters)
1275 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1276 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1280 //clus->GetPosition(pos);
1281 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1283 if(fRecalculateClusters)
1285 //Recalibrate the cluster energy
1286 if(GetCaloUtils()->IsRecalibrationOn())
1288 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1291 //printf("Recalibrated Energy %f\n",clus->E());
1293 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1294 GetCaloUtils()->RecalculateClusterPID(clus);
1298 //Recalculate distance to bad channels, if new list of bad channels provided
1299 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1301 //Recalculate cluster position
1302 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1304 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1305 //clus->GetPosition(pos);
1306 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1310 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1312 Double_t tof = clus->GetTOF();
1314 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1316 if(fDataType==AliCaloTrackReader::kESD)
1318 tof = fEMCALCells->GetCellTime(absIdMax);
1321 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1325 }// Time recalibration
1328 //Correct non linearity
1329 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1331 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1332 //printf("Linearity Corrected Energy %f\n",clus->E());
1334 //In case of MC analysis, to match resolution/calibration in real data
1335 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1336 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1337 clus->SetE(rdmEnergy);
1340 Double_t tof = clus->GetTOF()*1e9;
1342 Int_t bc = TMath::Nint(tof/50) + 9;
1343 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1345 SetEMCalEventBC(bc);
1347 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1349 TLorentzVector momentum ;
1351 clus->GetMomentum(momentum, fVertex[vindex]);
1353 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1355 SetEMCalEventBCcut(bc);
1357 if(!IsInTimeWindow(tof,clus->E()))
1359 fNPileUpClusters++ ;
1360 if(fUseEMCALTimeCut) return ;
1363 fNNonPileUpClusters++;
1365 if(fDebug > 2 && momentum.E() > 0.1)
1366 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1367 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1370 clus->SetID(iclus) ;
1372 fEMCALClusters->Add(clus);
1376 //_______________________________________
1377 void AliCaloTrackReader::FillInputEMCAL()
1379 //Return array with EMCAL clusters in aod format
1381 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1383 // First recalibrate cells, time or energy
1384 // if(GetCaloUtils()->IsRecalibrationOn())
1385 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1387 // fInputEvent->GetBunchCrossNumber());
1389 fNPileUpClusters = 0; // Init counter
1390 fNNonPileUpClusters = 0; // Init counter
1391 for(Int_t i = 0; i < 19; i++)
1393 fEMCalBCEvent [i] = 0;
1394 fEMCalBCEventCut[i] = 0;
1397 //Loop to select clusters in fiducial cut and fill container with aodClusters
1398 if(fEMCALClustersListName=="")
1400 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1401 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1403 AliVCluster * clus = 0;
1404 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1406 if (IsEMCALCluster(clus))
1408 FillInputEMCALAlgorithm(clus, iclus);
1413 //Recalculate track matching
1414 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1416 }//Get the clusters from the input event
1419 TClonesArray * clusterList = 0x0;
1421 if (fInputEvent->FindListObject(fEMCALClustersListName))
1423 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1425 else if(fOutputEvent)
1427 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1432 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1436 Int_t nclusters = clusterList->GetEntriesFast();
1437 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1439 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1440 //printf("E %f\n",clus->E());
1441 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1442 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1445 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1446 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1448 fNPileUpClusters = 0; // Init counter
1449 fNNonPileUpClusters = 0; // Init counter
1450 for(Int_t i = 0; i < 19; i++)
1452 fEMCalBCEvent [i] = 0;
1453 fEMCalBCEventCut[i] = 0;
1456 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1458 AliVCluster * clus = 0;
1460 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1462 if (IsEMCALCluster(clus))
1466 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1467 Double_t tof = clus->GetTOF();
1468 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1471 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1473 //Reject clusters with bad channels, close to borders and exotic;
1474 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1476 Int_t bc = TMath::Nint(tof/50) + 9;
1477 SetEMCalEventBC(bc);
1479 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1481 TLorentzVector momentum ;
1483 clus->GetMomentum(momentum, fVertex[0]);
1485 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1487 SetEMCalEventBCcut(bc);
1489 if(!IsInTimeWindow(tof,clus->E()))
1490 fNPileUpClusters++ ;
1492 fNNonPileUpClusters++;
1498 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1500 // Recalculate track matching, not necessary if already done in the reclusterization task.
1501 // in case it was not done ...
1502 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1506 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1510 //______________________________________
1511 void AliCaloTrackReader::FillInputPHOS()
1513 //Return array with PHOS clusters in aod format
1515 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1517 //Loop to select clusters in fiducial cut and fill container with aodClusters
1518 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1519 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1521 AliVCluster * clus = 0;
1522 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1524 if (IsPHOSCluster(clus))
1526 //Check if the cluster contains any bad channel and if close to calorimeter borders
1529 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1530 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1532 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1535 if(fRecalculateClusters)
1537 //Recalibrate the cluster energy
1538 if(GetCaloUtils()->IsRecalibrationOn())
1540 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1545 TLorentzVector momentum ;
1547 clus->GetMomentum(momentum, fVertex[vindex]);
1549 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1551 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1553 if(fDebug > 2 && momentum.E() > 0.1)
1554 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1555 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1560 clus->SetID(iclus) ;
1563 fPHOSClusters->Add(clus);
1569 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1573 //____________________________________________
1574 void AliCaloTrackReader::FillInputEMCALCells()
1576 //Return array with EMCAL cells in aod format
1578 fEMCALCells = fInputEvent->GetEMCALCells();
1582 //___________________________________________
1583 void AliCaloTrackReader::FillInputPHOSCells()
1585 //Return array with PHOS cells in aod format
1587 fPHOSCells = fInputEvent->GetPHOSCells();
1591 //_______________________________________
1592 void AliCaloTrackReader::FillInputVZERO()
1594 //Fill VZERO information in data member, add all the channels information.
1595 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1596 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1600 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1601 for (Int_t i = 0; i < 32; i++)
1604 {//Only available in ESDs
1605 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1606 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1609 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1610 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1613 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1618 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1623 //___________________________________________________________________
1624 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1626 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1627 // different number and need to patch here
1629 if(fDataType==kAOD && fOldAOD)
1631 if (cluster->GetType() == 2) return kTRUE;
1636 return cluster->IsEMCAL();
1641 //___________________________________________________________________
1642 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1644 //Check if it is a cluster from PHOS.For old AODs cluster type has
1645 // different number and need to patch here
1647 if(fDataType==kAOD && fOldAOD)
1649 Int_t type = cluster->GetType();
1650 if (type == 0 || type == 1) return kTRUE;
1655 return cluster->IsPHOS();
1660 //________________________________________________
1661 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1663 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1666 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1667 if(!event) return kTRUE;
1669 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1674 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1677 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1679 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1683 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1685 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1694 //____________________________________________________________
1695 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1699 if(fESDtrackCuts) delete fESDtrackCuts ;
1701 fESDtrackCuts = cuts ;
1705 //_________________________________________________________________________
1706 void AliCaloTrackReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
1708 // Set Track cuts for complementary tracks (hybrids)
1710 if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
1712 fESDtrackComplementaryCuts = cuts ;