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 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
67 fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
68 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
70 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
71 fEMCALCells(0x0), fPHOSCells(0x0),
72 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
73 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
74 fFillEMCALCells(0), fFillPHOSCells(0),
75 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
76 fTrackStatus(0), fTrackFilterMask(0),
77 fESDtrackCuts(0), fConstrainTrack(kFALSE), fSelectHybridTracks(0),
78 fTrackMult(0), fTrackMultEtaCut(0.8),
79 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
80 fDeltaAODFileName(""), fFiredTriggerClassName(""),
81 fEventTriggerMask(0), fEventTriggerAtSE(0),
83 fTaskName(""), fCaloUtils(0x0),
84 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
85 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
86 fEMCALClustersListName(""), fZvtxCut(0.),
87 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
88 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
89 fTriggerAnalysis (0x0),
90 fCentralityClass(""), fCentralityOpt(0),
91 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
95 //Initialize parameters
99 //_______________________________________
100 AliCaloTrackReader::~AliCaloTrackReader()
104 delete fFiducialCut ;
108 fAODBranchList->Delete();
109 delete fAODBranchList ;
114 if(fDataType!=kMC)fCTSTracks->Clear() ;
115 else fCTSTracks->Delete() ;
121 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
122 else fEMCALClusters->Delete() ;
123 delete fEMCALClusters ;
128 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
129 else fPHOSClusters->Delete() ;
130 delete fPHOSClusters ;
135 for (Int_t i = 0; i < fNMixedEvent; i++)
137 delete [] fVertex[i] ;
143 delete fESDtrackCuts;
144 delete fTriggerAnalysis;
146 // Pointers not owned, done by the analysis frame
147 // if(fInputEvent) delete fInputEvent ;
148 // if(fOutputEvent) delete fOutputEvent ;
149 // if(fMC) delete fMC ;
150 // Pointer not owned, deleted by maker
151 // if (fCaloUtils) delete fCaloUtils ;
155 //________________________________________________
156 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
158 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
160 if(!fReadStack) return kTRUE; //Information not filtered to AOD
162 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
165 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
166 Int_t nTriggerJets = pygeh->NTriggerJets();
167 Float_t ptHard = pygeh->GetPtHard();
169 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
170 Float_t tmpjet[]={0,0,0,0};
171 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
173 pygeh->TriggerJet(ijet, tmpjet);
174 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
175 //Compare jet pT and pt Hard
176 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
177 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
179 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
180 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
191 //____________________________________________
192 AliStack* AliCaloTrackReader::GetStack() const
194 //Return pointer to stack
199 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
204 //__________________________________________________
205 TString AliCaloTrackReader::GetFiredTriggerClasses()
207 // List of triggered classes in a TString
209 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
210 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
212 if (esdevent) return esdevent->GetFiredTriggerClasses();
213 else if(aodevent) return aodevent->GetFiredTriggerClasses();
214 else return ""; // Mixed Event, MC event, does not have this trigger info
218 //______________________________________________
219 AliHeader* AliCaloTrackReader::GetHeader() const
221 //Return pointer to header
224 return fMC->Header();
228 printf("AliCaloTrackReader::Header is not available\n");
233 //______________________________________________________________
234 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
236 //Return pointer to Generated event header
239 return fMC->GenEventHeader();
243 printf("AliCaloTrackReader::GenEventHeader is not available\n");
248 //____________________________________________________________________
249 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
251 //Return list of particles in AOD. Do it for the corresponding input event.
253 TClonesArray * rv = NULL ;
254 if(fDataType == kAOD)
259 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
261 rv = (TClonesArray*)evt->FindListObject("mcparticles");
263 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
269 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
275 //___________________________________________________________________
276 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const
278 //Return MC header in AOD. Do it for the corresponding input event.
280 AliAODMCHeader *mch = NULL;
282 if(fDataType == kAOD)
287 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
291 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
296 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
302 //_____________________________
303 void AliCaloTrackReader::Init()
305 //Init reader. Method to be called in AliAnaPartCorrMaker
307 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
309 if(fReadStack && fReadAODMCParticles)
311 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
313 fReadAODMCParticles = kFALSE;
316 // Init geometry, I do not like much to do it like this ...
317 if(fImportGeometryFromFile && !gGeoManager)
319 if(fImportGeometryFilePath=="") // If not specified, set a default location
320 fImportGeometryFilePath = "$ALICE_ROOT/PWGGA/EMCALTasks/macros/geometry.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
322 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
323 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
328 //_______________________________________
329 void AliCaloTrackReader::InitParameters()
331 //Initialize the parameters of the analysis.
337 fEMCALPtMax = 1000. ;
340 //Do not filter the detectors input by default.
344 fFillEMCALCells = kFALSE;
345 fFillPHOSCells = kFALSE;
347 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
348 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
349 fDeltaAODFileName = "deltaAODPartCorr.root";
350 fFiredTriggerClassName = "";
351 fEventTriggerMask = AliVEvent::kAny;
352 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
354 fAcceptFastCluster = kTRUE;
357 //We want tracks fitted in the detectors:
358 //fTrackStatus=AliESDtrack::kTPCrefit;
359 //fTrackStatus|=AliESDtrack::kITSrefit;
361 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
363 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
365 fConstrainTrack = kFALSE ; // constrain tracks to vertex
367 fV0ADC[0] = 0; fV0ADC[1] = 0;
368 fV0Mul[0] = 0; fV0Mul[1] = 0;
374 fPtHardAndJetPtFactor = 7;
377 fCentralityClass = "V0M";
379 fCentralityBin[0] = fCentralityBin[1]=-1;
381 fEventPlaneMethod = "V0";
383 // Allocate memory (not sure this is the right place)
384 fCTSTracks = new TObjArray();
385 fEMCALClusters = new TObjArray();
386 fPHOSClusters = new TObjArray();
387 fTriggerAnalysis = new AliTriggerAnalysis;
388 fAODBranchList = new TList ;
390 fImportGeometryFromFile = kFALSE;
394 //________________________________________________________
395 void AliCaloTrackReader::Print(const Option_t * opt) const
398 //Print some relevant parameters set for the analysis
402 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
403 printf("Task name : %s\n", fTaskName.Data()) ;
404 printf("Data type : %d\n", fDataType) ;
405 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
406 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
407 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
408 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
409 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
410 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
411 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
412 printf("Use CTS = %d\n", fFillCTS) ;
413 printf("Use EMCAL = %d\n", fFillEMCAL) ;
414 printf("Use PHOS = %d\n", fFillPHOS) ;
415 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
416 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
417 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
418 printf("AODs Track filter mask = %d or hybrid %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks) ;
419 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
420 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
421 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
423 printf("Use Triggers selected in SE base class %d; If not what trigger Mask %d? \n",
424 fEventTriggerAtSE, fEventTriggerMask);
426 if(fComparePtHardAndJetPt)
427 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
429 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
430 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
431 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
437 //_________________________________________________________________________
438 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
439 const char * /*currentFileName*/)
441 //Fill the event counter and input lists that are needed, called by the analysis maker.
443 fEventNumber = iEntry;
444 //fCurrentFileName = TString(currentFileName);
447 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
451 //Select events only fired by a certain trigger configuration if it is provided
453 if(fInputEvent->GetHeader())
454 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
456 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
458 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
462 //-------------------------------------------------------------------------------------
463 // Reject event if large clusters with large energy
464 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
465 // If clusterzer NxN or V2 it does not help
466 //-------------------------------------------------------------------------------------
467 Int_t run = fInputEvent->GetRunNumber();
468 if( fRemoveLEDEvents && run > 140000 && run <= 146860 )
470 //printf("Event %d\n",GetEventNumber());
471 for (Int_t i = 0; i < fInputEvent->GetNumberOfCaloClusters(); i++)
473 AliVCluster *clus = fInputEvent->GetCaloCluster(i);
476 if ((clus->E() > 500 && clus->GetNCells() > 200 ) || clus->GetNCells() > 200)
478 Int_t absID = clus->GetCellsAbsId()[0];
479 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
480 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - reject event %d with cluster : E %f, ncells %d, absId(0) %d, SM %d\n",GetEventNumber(),clus->E(), clus->GetNCells(),absID, sm);
486 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
489 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
491 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
492 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
493 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
494 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==4) ncellsSM4++;
498 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
500 if(ncellsSM3 >= ncellcut || ncellsSM4 >= 100)
502 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d and SM4 %d\n",ncellsSM3, ncellsSM4);
505 }// Remove LED events
507 // Reject pure LED events?
508 if( fFiredTriggerClassName !="" && !fAnaLED)
510 //printf("Event type %d\n",eventType);
512 return kFALSE; //Only physics event, do not use for simulated events!!!
515 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
516 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
518 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
519 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
523 // kStartOfRun = 1, // START_OF_RUN
524 // kEndOfRun = 2, // END_OF_RUN
525 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
526 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
527 // kStartOfBurst = 5, // START_OF_BURST
528 // kEndOfBurst = 6, // END_OF_BURST
529 // kPhysicsEvent = 7, // PHYSICS_EVENT
530 // kCalibrationEvent = 8, // CALIBRATION_EVENT
531 // kFormatError = 9, // EVENT_FORMAT_ERROR
532 // kStartOfData = 10, // START_OF_DATA
533 // kEndOfData = 11, // END_OF_DATA
534 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
535 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
537 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
538 if(eventType!=8)return kFALSE;
541 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
542 if(fComparePtHardAndJetPt && GetStack())
544 if(!ComparePtHardAndJetPt()) return kFALSE ;
549 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
550 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
552 //------------------------------------------------------
553 //Event rejection depending on vertex, pileup, v0and
554 //------------------------------------------------------
556 if(fUseEventsWithPrimaryVertex)
558 if( !CheckForPrimaryVertex() ) return kFALSE;
559 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
560 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
561 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
564 if(fDoEventSelection)
566 if(!fCaloFilterPatch)
568 //Do not analyze events with pileup
569 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
570 //Bool_t bPileup = event->IsPileupFromSPD();
571 if(bPileup) return kFALSE;
573 if(fDoV0ANDEventSelection)
575 Bool_t bV0AND = kTRUE;
576 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
578 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
579 //else bV0AND = //FIXME FOR AODs
580 if(!bV0AND) return kFALSE;
585 if(fInputEvent->GetNumberOfCaloClusters() > 0)
587 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
588 if(calo->GetNLabels() == 4)
590 Int_t * selection = calo->GetLabels();
591 Bool_t bPileup = selection[0];
592 if(bPileup) return kFALSE;
594 Bool_t bGoodV = selection[1];
595 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
597 if(fDoV0ANDEventSelection)
599 Bool_t bV0AND = selection[2];
600 if(!bV0AND) return kFALSE;
603 fTrackMult = selection[3];
604 if(fTrackMult == 0) return kFALSE;
608 //First filtered AODs, track multiplicity stored there.
609 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
610 if(fTrackMult == 0) return kFALSE;
612 }//at least one cluster
615 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
616 //Remove events with vertex (0,0,0), bad vertex reconstruction
617 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;
619 //First filtered AODs, track multiplicity stored there.
620 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
621 if(fTrackMult == 0) return kFALSE;
623 }// CaloFileter patch
625 //------------------------------------------------------
627 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
628 //If we need a centrality bin, we select only those events in the corresponding bin.
629 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
631 Int_t cen = GetEventCentrality();
632 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
635 //Fill the arrays with cluster/tracks/cells data
638 FillInputEMCALCells();
641 FillInputPHOSCells();
645 if(fEventTriggerAtSE)
650 //Accept events with at least one track
651 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
660 // In case of mixing analysis, all triggers accepted, but trigger particles selected
661 // only for the specific trigered events selected here. Mixing done only for MB events,
662 // tracks array filled also for those events and not the others.
664 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
665 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
667 if(!inputHandler) return kFALSE ; // to content coverity
669 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
670 UInt_t isMB = inputHandler->IsEventSelected() & AliVEvent::kMB;
672 if(fFillCTS && (isMB || isTrigger))
675 //Accept events with at least one track
676 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
691 //___________________________________
692 void AliCaloTrackReader::ResetLists()
694 // Reset lists, called by the analysis maker
696 if(fCTSTracks) fCTSTracks -> Clear();
697 if(fEMCALClusters) fEMCALClusters -> Clear("C");
698 if(fPHOSClusters) fPHOSClusters -> Clear("C");
700 fV0ADC[0] = 0; fV0ADC[1] = 0;
701 fV0Mul[0] = 0; fV0Mul[1] = 0;
705 //____________________________________________________________
706 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
709 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
711 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
713 //Delete previous vertex
716 for (Int_t i = 0; i < fNMixedEvent; i++)
718 delete [] fVertex[i] ;
723 fVertex = new Double_t*[fNMixedEvent] ;
724 for (Int_t i = 0; i < fNMixedEvent; i++)
726 fVertex[i] = new Double_t[3] ;
727 fVertex[i][0] = 0.0 ;
728 fVertex[i][1] = 0.0 ;
729 fVertex[i][2] = 0.0 ;
733 //__________________________________________________
734 Int_t AliCaloTrackReader::GetEventCentrality() const
736 //Return current event centrality
740 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
741 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
742 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
745 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
753 //_____________________________________________________
754 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
756 //Return current event centrality
760 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
762 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
764 printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
767 else if(GetEventPlaneMethod().Contains("V0") )
769 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
771 printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
775 ep+=TMath::Pi()/2; // put same range as for <Q> method
779 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
780 if(ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
782 return TMath::Abs(ep);
786 printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
792 //__________________________________________________________
793 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
795 //Return vertex position to be used for single event analysis
796 vertex[0]=fVertex[0][0];
797 vertex[1]=fVertex[0][1];
798 vertex[2]=fVertex[0][2];
801 //____________________________________________________________
802 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
803 const Int_t evtIndex) const
805 //Return vertex position for mixed event, recover the vertex in a particular event.
807 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
811 //________________________________________
812 void AliCaloTrackReader::FillVertexArray()
815 //Fill data member with vertex
816 //In case of Mixed event, multiple vertices
818 //Delete previous vertex
821 for (Int_t i = 0; i < fNMixedEvent; i++)
823 delete [] fVertex[i] ;
828 fVertex = new Double_t*[fNMixedEvent] ;
829 for (Int_t i = 0; i < fNMixedEvent; i++)
831 fVertex[i] = new Double_t[3] ;
832 fVertex[i][0] = 0.0 ;
833 fVertex[i][1] = 0.0 ;
834 fVertex[i][2] = 0.0 ;
838 { //Single event analysis
842 if(fInputEvent->GetPrimaryVertex())
844 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
848 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
849 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
850 }//Primary vertex pointer do not exist
854 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
858 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
861 { // MultiEvent analysis
862 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
864 if (fMixedEvent->GetVertexOfEvent(iev))
865 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
867 { // no vertex found !!!!
868 AliWarning("No vertex found");
872 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
879 //_____________________________________
880 void AliCaloTrackReader::FillInputCTS()
882 //Return array with Central Tracking System (CTS) tracks
884 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
886 Double_t pTrack[3] = {0,0,0};
888 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
892 for (Int_t itrack = 0; itrack < nTracks; itrack++)
893 {////////////// track loop
894 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
896 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
897 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
904 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
906 if(esdTrack && fESDtrackCuts->AcceptTrack(esdTrack))
908 track->GetPxPyPz(pTrack) ;
912 if(esdTrack->GetConstrainedParam())
914 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
915 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
916 esdTrack->GetConstrainedPxPyPz(pTrack);
920 } // use constrained tracks
926 else if(fDataType==kAOD)
928 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
932 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
933 aodtrack->GetType(),AliAODTrack::kPrimary,
934 aodtrack->IsHybridGlobalConstrainedGlobal());
937 if (fSelectHybridTracks)
939 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
943 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
946 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
948 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
950 track->GetPxPyPz(pTrack) ;
952 } // aod track exists
957 //Count the tracks in eta < 0.9
958 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
959 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
961 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
963 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt())
965 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
968 if(fDebug > 2 && momentum.Pt() > 0.1)
969 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
970 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
974 track->SetID(itrack);
977 fCTSTracks->Add(track);
979 }//Pt and Fiducial cut passed.
983 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
987 //__________________________________________________________________
988 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
991 //Fill the EMCAL data in the array, do it
995 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
997 //Reject clusters with bad channels, close to borders and exotic;
998 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1000 //Mask all cells in collumns facing ALICE thick material if requested
1001 if(GetCaloUtils()->GetNMaskCellColumns())
1007 Bool_t shared = kFALSE;
1008 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1009 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1012 if(fSelectEmbeddedClusters)
1014 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1015 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1019 //clus->GetPosition(pos);
1020 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1022 if(fRecalculateClusters)
1024 //Recalibrate the cluster energy
1025 if(GetCaloUtils()->IsRecalibrationOn())
1027 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1030 //printf("Recalibrated Energy %f\n",clus->E());
1032 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1033 GetCaloUtils()->RecalculateClusterPID(clus);
1037 //Recalculate distance to bad channels, if new list of bad channels provided
1038 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1040 //Recalculate cluster position
1041 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1043 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1044 //clus->GetPosition(pos);
1045 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1049 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1051 Double_t tof = clus->GetTOF();
1053 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1055 if(fDataType==AliCaloTrackReader::kESD)
1057 tof = fEMCALCells->GetCellTime(absIdMax);
1060 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1064 }// Time recalibration
1067 //Correct non linearity
1068 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1070 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1071 //printf("Linearity Corrected Energy %f\n",clus->E());
1073 //In case of MC analysis, to match resolution/calibration in real data
1074 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1075 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1076 clus->SetE(rdmEnergy);
1079 TLorentzVector momentum ;
1081 clus->GetMomentum(momentum, fVertex[vindex]);
1083 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return;
1085 if(fEMCALPtMin > momentum.E() || fEMCALPtMax < momentum.E()) return;
1087 Double_t tof = clus->GetTOF()*1e9;
1088 if(tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax) return;
1090 if(fDebug > 2 && momentum.E() > 0.1)
1091 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1092 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1095 clus->SetID(iclus) ;
1097 fEMCALClusters->Add(clus);
1101 //_______________________________________
1102 void AliCaloTrackReader::FillInputEMCAL()
1104 //Return array with EMCAL clusters in aod format
1106 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1108 // First recalibrate cells, time or energy
1109 // if(GetCaloUtils()->IsRecalibrationOn())
1110 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1112 // fInputEvent->GetBunchCrossNumber());
1114 //Loop to select clusters in fiducial cut and fill container with aodClusters
1115 if(fEMCALClustersListName=="")
1117 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1118 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1120 AliVCluster * clus = 0;
1121 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1123 if (IsEMCALCluster(clus))
1125 FillInputEMCALAlgorithm(clus, iclus);
1130 //Recalculate track matching
1131 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1133 }//Get the clusters from the input event
1136 TClonesArray * clusterList = 0x0;
1138 if (fInputEvent->FindListObject(fEMCALClustersListName))
1140 clusterList = dynamic_cast<TClonesArray*> (fInputEvent ->FindListObject(fEMCALClustersListName));
1142 else if(fOutputEvent)
1144 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1149 //printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? Try input event <%s>\n",fEMCALClustersListName.Data());
1150 //List not in output event, try input event
1151 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1154 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1159 Int_t nclusters = clusterList->GetEntriesFast();
1160 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1162 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1163 //printf("E %f\n",clus->E());
1164 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1165 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1168 // Recalculate track matching, not necessary if already done in the reclusterization task.
1169 // in case it was not done ...
1170 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1174 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());
1178 //______________________________________
1179 void AliCaloTrackReader::FillInputPHOS()
1181 //Return array with PHOS clusters in aod format
1183 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1185 //Loop to select clusters in fiducial cut and fill container with aodClusters
1186 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1187 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1189 AliVCluster * clus = 0;
1190 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1192 if (IsPHOSCluster(clus))
1194 //Check if the cluster contains any bad channel and if close to calorimeter borders
1197 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1198 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1200 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1203 if(fRecalculateClusters)
1205 //Recalibrate the cluster energy
1206 if(GetCaloUtils()->IsRecalibrationOn())
1208 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1213 TLorentzVector momentum ;
1215 clus->GetMomentum(momentum, fVertex[vindex]);
1217 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1219 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1221 if(fDebug > 2 && momentum.E() > 0.1)
1222 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1223 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1228 clus->SetID(iclus) ;
1231 fPHOSClusters->Add(clus);
1237 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1241 //____________________________________________
1242 void AliCaloTrackReader::FillInputEMCALCells()
1244 //Return array with EMCAL cells in aod format
1246 fEMCALCells = fInputEvent->GetEMCALCells();
1250 //___________________________________________
1251 void AliCaloTrackReader::FillInputPHOSCells()
1253 //Return array with PHOS cells in aod format
1255 fPHOSCells = fInputEvent->GetPHOSCells();
1259 //_______________________________________
1260 void AliCaloTrackReader::FillInputVZERO()
1262 //Fill VZERO information in data member, add all the channels information.
1263 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1264 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1268 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1269 for (Int_t i = 0; i < 32; i++)
1272 {//Only available in ESDs
1273 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1274 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1277 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1278 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1281 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1286 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1291 //___________________________________________________________________
1292 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1294 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1295 // different number and need to patch here
1297 if(fDataType==kAOD && fOldAOD)
1299 if (cluster->GetType() == 2) return kTRUE;
1304 return cluster->IsEMCAL();
1309 //___________________________________________________________________
1310 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1312 //Check if it is a cluster from PHOS.For old AODs cluster type has
1313 // different number and need to patch here
1315 if(fDataType==kAOD && fOldAOD)
1317 Int_t type = cluster->GetType();
1318 if (type == 0 || type == 1) return kTRUE;
1323 return cluster->IsPHOS();
1328 //________________________________________________
1329 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1331 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1334 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1335 if(!event) return kTRUE;
1337 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1342 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1345 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1347 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1351 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1353 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1362 //____________________________________________________________
1363 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1367 if(fESDtrackCuts) delete fESDtrackCuts ;
1369 fESDtrackCuts = cuts ;