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 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
70 fEMCALParamTimeCutMin(), fEMCALParamTimeCutMax(),
71 fUseParamTimeCut(kFALSE),
73 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
74 fEMCALCells(0x0), fPHOSCells(0x0),
75 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
76 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
77 fFillEMCALCells(0), fFillPHOSCells(0),
78 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
79 fTrackStatus(0), fTrackFilterMask(0),
80 fESDtrackCuts(0), fConstrainTrack(kFALSE),
81 fSelectHybridTracks(0), fSelectSPDHitTracks(kFALSE),
82 fTrackMult(0), fTrackMultEtaCut(0.8),
83 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
84 fDeltaAODFileName(""), fFiredTriggerClassName(""),
85 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
87 fTaskName(""), fCaloUtils(0x0),
88 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
89 fListMixedTracksEvents(), fListMixedCaloEvents(),
90 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
91 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
92 fEMCALClustersListName(""), fZvtxCut(0.),
93 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
94 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
95 fTriggerAnalysis (0x0),
96 fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
97 fCentralityClass(""), fCentralityOpt(0),
98 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
102 //Initialize parameters
106 //_______________________________________
107 AliCaloTrackReader::~AliCaloTrackReader()
111 delete fFiducialCut ;
115 fAODBranchList->Delete();
116 delete fAODBranchList ;
121 if(fDataType!=kMC)fCTSTracks->Clear() ;
122 else fCTSTracks->Delete() ;
128 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
129 else fEMCALClusters->Delete() ;
130 delete fEMCALClusters ;
135 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
136 else fPHOSClusters->Delete() ;
137 delete fPHOSClusters ;
142 for (Int_t i = 0; i < fNMixedEvent; i++)
144 delete [] fVertex[i] ;
150 delete fESDtrackCuts;
151 delete fTriggerAnalysis;
153 // Pointers not owned, done by the analysis frame
154 // if(fInputEvent) delete fInputEvent ;
155 // if(fOutputEvent) delete fOutputEvent ;
156 // if(fMC) delete fMC ;
157 // Pointer not owned, deleted by maker
158 // if (fCaloUtils) delete fCaloUtils ;
162 //________________________________________________
163 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
165 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
168 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
170 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
173 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
174 Int_t nTriggerJets = pygeh->NTriggerJets();
175 Float_t ptHard = pygeh->GetPtHard();
178 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
180 Float_t tmpjet[]={0,0,0,0};
181 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
183 pygeh->TriggerJet(ijet, tmpjet);
184 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
187 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
189 //Compare jet pT and pt Hard
190 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
192 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
193 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
205 //____________________________________________________________________
206 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
208 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
211 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
213 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
214 Float_t ptHard = pygeh->GetPtHard();
216 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
217 for (Int_t iclus = 0; iclus < nclusters; iclus++)
219 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
220 Float_t ecluster = clus->E();
222 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
224 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
236 //____________________________________________
237 AliStack* AliCaloTrackReader::GetStack() const
239 //Return pointer to stack
244 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
249 //__________________________________________________
250 TString AliCaloTrackReader::GetFiredTriggerClasses()
252 // List of triggered classes in a TString
254 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
255 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
257 if (esdevent) return esdevent->GetFiredTriggerClasses();
258 else if(aodevent) return aodevent->GetFiredTriggerClasses();
259 else return ""; // Mixed Event, MC event, does not have this trigger info
263 //______________________________________________
264 AliHeader* AliCaloTrackReader::GetHeader() const
266 //Return pointer to header
269 return fMC->Header();
273 printf("AliCaloTrackReader::Header is not available\n");
278 //______________________________________________________________
279 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
281 //Return pointer to Generated event header
282 if (ReadStack() && fMC)
284 return fMC->GenEventHeader();
286 else if(ReadAODMCParticles() && GetAODMCHeader())
288 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
289 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
290 return GetAODMCHeader()->GetCocktailHeader(0) ;
296 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
301 //____________________________________________________________________
302 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
304 //Return list of particles in AOD. Do it for the corresponding input event.
306 TClonesArray * rv = NULL ;
307 if(fDataType == kAOD)
312 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
314 rv = (TClonesArray*)evt->FindListObject("mcparticles");
316 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
322 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
328 //________________________________________________________
329 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
331 //Return MC header in AOD. Do it for the corresponding input event.
333 AliAODMCHeader *mch = NULL;
335 if(fDataType == kAOD)
337 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
338 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
342 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
348 //_____________________________
349 void AliCaloTrackReader::Init()
351 //Init reader. Method to be called in AliAnaPartCorrMaker
353 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
355 if(fReadStack && fReadAODMCParticles)
357 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
359 fReadAODMCParticles = kFALSE;
362 // Init geometry, I do not like much to do it like this ...
363 if(fImportGeometryFromFile && !gGeoManager)
365 if(fImportGeometryFilePath=="") // If not specified, set a default location
366 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
368 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
369 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
374 //_______________________________________
375 void AliCaloTrackReader::InitParameters()
377 //Initialize the parameters of the analysis.
383 fEMCALPtMax = 1000. ;
386 //Do not filter the detectors input by default.
390 fFillEMCALCells = kFALSE;
391 fFillPHOSCells = kFALSE;
393 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
394 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
395 fDeltaAODFileName = "deltaAODPartCorr.root";
396 fFiredTriggerClassName = "";
397 fEventTriggerMask = AliVEvent::kAny;
398 fMixEventTriggerMask = AliVEvent::kAnyINT;
399 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
401 fAcceptFastCluster = kTRUE;
404 //We want tracks fitted in the detectors:
405 //fTrackStatus=AliESDtrack::kTPCrefit;
406 //fTrackStatus|=AliESDtrack::kITSrefit;
408 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
410 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
412 fConstrainTrack = kFALSE ; // constrain tracks to vertex
414 fV0ADC[0] = 0; fV0ADC[1] = 0;
415 fV0Mul[0] = 0; fV0Mul[1] = 0;
421 fPtHardAndJetPtFactor = 7.;
422 fPtHardAndClusterPtFactor = 1.;
425 fCentralityClass = "V0M";
427 fCentralityBin[0] = fCentralityBin[1]=-1;
429 fEventPlaneMethod = "V0";
431 // Allocate memory (not sure this is the right place)
432 fCTSTracks = new TObjArray();
433 fEMCALClusters = new TObjArray();
434 fPHOSClusters = new TObjArray();
435 fTriggerAnalysis = new AliTriggerAnalysis;
436 fAODBranchList = new TList ;
438 fImportGeometryFromFile = kFALSE;
440 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
441 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
443 // Parametrized time cut (LHC11d)
444 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
445 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
447 // Parametrized time cut (LHC11c)
448 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
449 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
452 //___________________________________________________________
453 Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
455 // Cluster time selection window
457 // Parametrized cut depending on E
460 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
461 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
462 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
463 if( tof < minCut || tof > maxCut ) return kFALSE ;
466 //In any case, the time should to be larger than the fixed window ...
467 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
472 //________________________________________________
473 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
475 // Check if event is from pile-up determined by SPD
476 // Default values: (3, 0.8, 3., 2., 5.)
477 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
478 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
479 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
483 //__________________________________________________
484 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
486 // Check if event is from pile-up determined by EMCal
487 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
491 //________________________________________________________
492 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
494 // Check if event is from pile-up determined by SPD and EMCal
495 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
499 //_______________________________________________________
500 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
502 // Check if event is from pile-up determined by SPD or EMCal
503 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
507 //___________________________________________________________
508 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
510 // Check if event is from pile-up determined by SPD and not by EMCal
511 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
515 //___________________________________________________________
516 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
518 // Check if event is from pile-up determined by EMCal, not by SPD
519 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
523 //______________________________________________________________
524 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
526 // Check if event not from pile-up determined neither by SPD nor by EMCal
527 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
531 //________________________________________________________
532 void AliCaloTrackReader::Print(const Option_t * opt) const
535 //Print some relevant parameters set for the analysis
539 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
540 printf("Task name : %s\n", fTaskName.Data()) ;
541 printf("Data type : %d\n", fDataType) ;
542 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
543 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
544 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
545 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
546 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
547 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
548 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
549 printf("Use CTS = %d\n", fFillCTS) ;
550 printf("Use EMCAL = %d\n", fFillEMCAL) ;
551 printf("Use PHOS = %d\n", fFillPHOS) ;
552 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
553 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
554 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
555 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
556 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
557 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
558 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
560 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
561 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
563 if(fComparePtHardAndClusterPt)
564 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
566 if(fComparePtHardAndClusterPt)
567 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
569 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
570 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
571 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
577 //_________________________________________________________________________
578 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
579 const char * /*currentFileName*/)
581 //Fill the event counter and input lists that are needed, called by the analysis maker.
583 fEventNumber = iEntry;
584 //fCurrentFileName = TString(currentFileName);
587 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
591 //Select events only fired by a certain trigger configuration if it is provided
593 if(fInputEvent->GetHeader())
594 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
596 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
598 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
602 //-------------------------------------------------------------------------------------
603 // Reject event if large clusters with large energy
604 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
605 // If clusterzer NxN or V2 it does not help
606 //-------------------------------------------------------------------------------------
607 Int_t run = fInputEvent->GetRunNumber();
608 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
610 //printf("Event %d\n",GetEventNumber());
612 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
614 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
616 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
617 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
618 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
622 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
624 if(ncellsSM3 >= ncellcut)
626 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d\n",ncellsSM3);
629 }// Remove LED events
631 // Reject pure LED events?
632 if( fFiredTriggerClassName !="" && !fAnaLED)
634 //printf("Event type %d\n",eventType);
636 return kFALSE; //Only physics event, do not use for simulated events!!!
639 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
640 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
642 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
643 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
647 // kStartOfRun = 1, // START_OF_RUN
648 // kEndOfRun = 2, // END_OF_RUN
649 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
650 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
651 // kStartOfBurst = 5, // START_OF_BURST
652 // kEndOfBurst = 6, // END_OF_BURST
653 // kPhysicsEvent = 7, // PHYSICS_EVENT
654 // kCalibrationEvent = 8, // CALIBRATION_EVENT
655 // kFormatError = 9, // EVENT_FORMAT_ERROR
656 // kStartOfData = 10, // START_OF_DATA
657 // kEndOfData = 11, // END_OF_DATA
658 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
659 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
661 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
662 if(eventType!=8)return kFALSE;
665 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
666 if(fComparePtHardAndJetPt)
668 if(!ComparePtHardAndJetPt()) return kFALSE ;
671 if(fComparePtHardAndClusterPt)
673 if(!ComparePtHardAndClusterPt()) return kFALSE ;
678 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
679 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
681 //------------------------------------------------------
682 //Event rejection depending on vertex, pileup, v0and
683 //------------------------------------------------------
685 if(fUseEventsWithPrimaryVertex)
687 if( !CheckForPrimaryVertex() ) return kFALSE;
688 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
689 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
690 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
693 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
695 if(fDoEventSelection)
697 if(!fCaloFilterPatch)
699 // Do not analyze events with pileup
700 Bool_t bPileup = IsPileUpFromSPD();
701 //IsPileupFromSPDInMultBins() // method to try
702 //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]);
703 if(bPileup) return kFALSE;
705 if(fDoV0ANDEventSelection)
707 Bool_t bV0AND = kTRUE;
708 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
710 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
711 //else bV0AND = //FIXME FOR AODs
712 if(!bV0AND) return kFALSE;
717 if(fInputEvent->GetNumberOfCaloClusters() > 0)
719 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
720 if(calo->GetNLabels() == 4)
722 Int_t * selection = calo->GetLabels();
723 Bool_t bPileup = selection[0];
724 if(bPileup) return kFALSE;
726 Bool_t bGoodV = selection[1];
727 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
729 if(fDoV0ANDEventSelection)
731 Bool_t bV0AND = selection[2];
732 if(!bV0AND) return kFALSE;
735 fTrackMult = selection[3];
736 if(fTrackMult == 0) return kFALSE;
740 //First filtered AODs, track multiplicity stored there.
741 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
742 if(fTrackMult == 0) return kFALSE;
744 }//at least one cluster
747 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
748 //Remove events with vertex (0,0,0), bad vertex reconstruction
749 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;
751 //First filtered AODs, track multiplicity stored there.
752 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
753 if(fTrackMult == 0) return kFALSE;
755 }// CaloFileter patch
757 //------------------------------------------------------
759 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
760 //If we need a centrality bin, we select only those events in the corresponding bin.
761 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
763 Int_t cen = GetEventCentrality();
764 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
767 //Fill the arrays with cluster/tracks/cells data
770 FillInputEMCALCells();
773 FillInputPHOSCells();
777 if(fEventTriggerAtSE)
782 //Accept events with at least one track
783 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
792 // In case of mixing analysis, all triggers accepted, but trigger particles selected
793 // only for the specific trigered events selected here. Mixing done only for MB events,
794 // tracks array filled also for those events and not the others.
796 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
797 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
799 if(!inputHandler) return kFALSE ; // to content coverity
801 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
802 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
804 if(fFillCTS && (isMB || isTrigger))
807 //Accept events with at least one track
808 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
823 //___________________________________
824 void AliCaloTrackReader::ResetLists()
826 // Reset lists, called by the analysis maker
828 if(fCTSTracks) fCTSTracks -> Clear();
829 if(fEMCALClusters) fEMCALClusters -> Clear("C");
830 if(fPHOSClusters) fPHOSClusters -> Clear("C");
832 fV0ADC[0] = 0; fV0ADC[1] = 0;
833 fV0Mul[0] = 0; fV0Mul[1] = 0;
837 //____________________________________________________________
838 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
841 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
843 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
845 //Delete previous vertex
848 for (Int_t i = 0; i < fNMixedEvent; i++)
850 delete [] fVertex[i] ;
855 fVertex = new Double_t*[fNMixedEvent] ;
856 for (Int_t i = 0; i < fNMixedEvent; i++)
858 fVertex[i] = new Double_t[3] ;
859 fVertex[i][0] = 0.0 ;
860 fVertex[i][1] = 0.0 ;
861 fVertex[i][2] = 0.0 ;
865 //__________________________________________________
866 Int_t AliCaloTrackReader::GetEventCentrality() const
868 //Return current event centrality
872 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
873 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
874 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
877 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
885 //_____________________________________________________
886 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
888 //Return current event centrality
892 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
894 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
896 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
899 else if(GetEventPlaneMethod().Contains("V0") )
901 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
903 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
907 ep+=TMath::Pi()/2; // put same range as for <Q> method
911 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
914 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
915 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
922 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
928 //__________________________________________________________
929 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
931 //Return vertex position to be used for single event analysis
932 vertex[0]=fVertex[0][0];
933 vertex[1]=fVertex[0][1];
934 vertex[2]=fVertex[0][2];
937 //____________________________________________________________
938 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
939 const Int_t evtIndex) const
941 //Return vertex position for mixed event, recover the vertex in a particular event.
943 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
947 //________________________________________
948 void AliCaloTrackReader::FillVertexArray()
951 //Fill data member with vertex
952 //In case of Mixed event, multiple vertices
954 //Delete previous vertex
957 for (Int_t i = 0; i < fNMixedEvent; i++)
959 delete [] fVertex[i] ;
964 fVertex = new Double_t*[fNMixedEvent] ;
965 for (Int_t i = 0; i < fNMixedEvent; i++)
967 fVertex[i] = new Double_t[3] ;
968 fVertex[i][0] = 0.0 ;
969 fVertex[i][1] = 0.0 ;
970 fVertex[i][2] = 0.0 ;
974 { //Single event analysis
978 if(fInputEvent->GetPrimaryVertex())
980 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
984 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
985 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
986 }//Primary vertex pointer do not exist
990 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
994 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
997 { // MultiEvent analysis
998 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1000 if (fMixedEvent->GetVertexOfEvent(iev))
1001 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1003 { // no vertex found !!!!
1004 AliWarning("No vertex found");
1008 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1015 //_____________________________________
1016 void AliCaloTrackReader::FillInputCTS()
1018 //Return array with Central Tracking System (CTS) tracks
1020 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1022 Double_t pTrack[3] = {0,0,0};
1024 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1028 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1029 {////////////// track loop
1030 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1032 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1033 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
1038 if (fDataType==kESD)
1040 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1042 if(esdTrack && fESDtrackCuts->AcceptTrack(esdTrack))
1044 track->GetPxPyPz(pTrack) ;
1048 if(esdTrack->GetConstrainedParam())
1050 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1051 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1052 esdTrack->GetConstrainedPxPyPz(pTrack);
1056 } // use constrained tracks
1058 if(fSelectSPDHitTracks)
1059 {//Not much sense to use with TPC only or Hybrid tracks
1060 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1066 else if(fDataType==kAOD)
1068 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1072 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1073 aodtrack->GetType(),AliAODTrack::kPrimary,
1074 aodtrack->IsHybridGlobalConstrainedGlobal());
1077 if (fSelectHybridTracks)
1079 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1083 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1086 if(fSelectSPDHitTracks)
1087 {//Not much sense to use with TPC only or Hybrid tracks
1088 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1091 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1093 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
1095 track->GetPxPyPz(pTrack) ;
1097 } // aod track exists
1102 //Count the tracks in eta < 0.9
1103 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1104 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1106 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1108 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt())
1110 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
1113 if(fDebug > 2 && momentum.Pt() > 0.1)
1114 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1115 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1119 track->SetID(itrack);
1122 fCTSTracks->Add(track);
1124 }//Pt and Fiducial cut passed.
1128 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1132 //__________________________________________________________________
1133 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1136 //Fill the EMCAL data in the array, do it
1140 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1142 //Reject clusters with bad channels, close to borders and exotic;
1143 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1145 //Mask all cells in collumns facing ALICE thick material if requested
1146 if(GetCaloUtils()->GetNMaskCellColumns())
1152 Bool_t shared = kFALSE;
1153 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1154 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1157 if(fSelectEmbeddedClusters)
1159 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1160 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1164 //clus->GetPosition(pos);
1165 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1167 if(fRecalculateClusters)
1169 //Recalibrate the cluster energy
1170 if(GetCaloUtils()->IsRecalibrationOn())
1172 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1175 //printf("Recalibrated Energy %f\n",clus->E());
1177 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1178 GetCaloUtils()->RecalculateClusterPID(clus);
1182 //Recalculate distance to bad channels, if new list of bad channels provided
1183 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1185 //Recalculate cluster position
1186 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1188 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1189 //clus->GetPosition(pos);
1190 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1194 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1196 Double_t tof = clus->GetTOF();
1198 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1200 if(fDataType==AliCaloTrackReader::kESD)
1202 tof = fEMCALCells->GetCellTime(absIdMax);
1205 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1209 }// Time recalibration
1212 //Correct non linearity
1213 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1215 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1216 //printf("Linearity Corrected Energy %f\n",clus->E());
1218 //In case of MC analysis, to match resolution/calibration in real data
1219 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1220 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1221 clus->SetE(rdmEnergy);
1224 TLorentzVector momentum ;
1226 clus->GetMomentum(momentum, fVertex[vindex]);
1228 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1230 if(fEMCALPtMin > momentum.E() || fEMCALPtMax < momentum.E()) return ;
1232 Double_t tof = clus->GetTOF()*1e9;
1234 if(!IsInTimeWindow(tof,momentum.E()))
1236 fNPileUpClusters++ ;
1240 fNNonPileUpClusters++;
1242 if(fDebug > 2 && momentum.E() > 0.1)
1243 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1244 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1247 clus->SetID(iclus) ;
1249 fEMCALClusters->Add(clus);
1253 //_______________________________________
1254 void AliCaloTrackReader::FillInputEMCAL()
1256 //Return array with EMCAL clusters in aod format
1258 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1260 // First recalibrate cells, time or energy
1261 // if(GetCaloUtils()->IsRecalibrationOn())
1262 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1264 // fInputEvent->GetBunchCrossNumber());
1266 fNPileUpClusters = 0; // Init counter
1267 fNNonPileUpClusters = 0; // Init counter
1269 //Loop to select clusters in fiducial cut and fill container with aodClusters
1270 if(fEMCALClustersListName=="")
1272 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1273 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1275 AliVCluster * clus = 0;
1276 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1278 if (IsEMCALCluster(clus))
1280 FillInputEMCALAlgorithm(clus, iclus);
1285 //Recalculate track matching
1286 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1288 }//Get the clusters from the input event
1291 TClonesArray * clusterList = 0x0;
1293 if (fInputEvent->FindListObject(fEMCALClustersListName))
1295 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1297 else if(fOutputEvent)
1299 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1304 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1308 Int_t nclusters = clusterList->GetEntriesFast();
1309 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1311 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1312 //printf("E %f\n",clus->E());
1313 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1314 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1317 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1318 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1320 fNPileUpClusters = 0; // Init counter
1321 fNNonPileUpClusters = 0; // Init counter
1323 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1325 AliVCluster * clus = 0;
1327 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1329 if (IsEMCALCluster(clus))
1332 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1335 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1336 Double_t tof = clus->GetTOF();
1337 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1340 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1342 //Reject clusters with bad channels, close to borders and exotic;
1343 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1345 if(!IsInTimeWindow(tof,clus->E()))
1347 fNPileUpClusters++ ;
1350 fNNonPileUpClusters++;
1355 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1357 // Recalculate track matching, not necessary if already done in the reclusterization task.
1358 // in case it was not done ...
1359 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1363 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1367 //______________________________________
1368 void AliCaloTrackReader::FillInputPHOS()
1370 //Return array with PHOS clusters in aod format
1372 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1374 //Loop to select clusters in fiducial cut and fill container with aodClusters
1375 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1376 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1378 AliVCluster * clus = 0;
1379 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1381 if (IsPHOSCluster(clus))
1383 //Check if the cluster contains any bad channel and if close to calorimeter borders
1386 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1387 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1389 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1392 if(fRecalculateClusters)
1394 //Recalibrate the cluster energy
1395 if(GetCaloUtils()->IsRecalibrationOn())
1397 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1402 TLorentzVector momentum ;
1404 clus->GetMomentum(momentum, fVertex[vindex]);
1406 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1408 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1410 if(fDebug > 2 && momentum.E() > 0.1)
1411 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1412 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1417 clus->SetID(iclus) ;
1420 fPHOSClusters->Add(clus);
1426 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1430 //____________________________________________
1431 void AliCaloTrackReader::FillInputEMCALCells()
1433 //Return array with EMCAL cells in aod format
1435 fEMCALCells = fInputEvent->GetEMCALCells();
1439 //___________________________________________
1440 void AliCaloTrackReader::FillInputPHOSCells()
1442 //Return array with PHOS cells in aod format
1444 fPHOSCells = fInputEvent->GetPHOSCells();
1448 //_______________________________________
1449 void AliCaloTrackReader::FillInputVZERO()
1451 //Fill VZERO information in data member, add all the channels information.
1452 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1453 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1457 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1458 for (Int_t i = 0; i < 32; i++)
1461 {//Only available in ESDs
1462 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1463 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1466 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1467 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1470 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1475 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1480 //___________________________________________________________________
1481 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1483 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1484 // different number and need to patch here
1486 if(fDataType==kAOD && fOldAOD)
1488 if (cluster->GetType() == 2) return kTRUE;
1493 return cluster->IsEMCAL();
1498 //___________________________________________________________________
1499 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1501 //Check if it is a cluster from PHOS.For old AODs cluster type has
1502 // different number and need to patch here
1504 if(fDataType==kAOD && fOldAOD)
1506 Int_t type = cluster->GetType();
1507 if (type == 0 || type == 1) return kTRUE;
1512 return cluster->IsPHOS();
1517 //________________________________________________
1518 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1520 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1523 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1524 if(!event) return kTRUE;
1526 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1531 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1534 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1536 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1540 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1542 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1551 //____________________________________________________________
1552 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1556 if(fESDtrackCuts) delete fESDtrackCuts ;
1558 fESDtrackCuts = cuts ;