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"
46 // ---- Detectors ----
47 #include "AliPHOSGeoUtils.h"
48 #include "AliEMCALGeometry.h"
49 #include "AliEMCALRecoUtils.h"
51 // ---- CaloTrackCorr ---
52 #include "AliCalorimeterUtils.h"
53 #include "AliCaloTrackReader.h"
55 ClassImp(AliCaloTrackReader)
58 //________________________________________
59 AliCaloTrackReader::AliCaloTrackReader() :
60 TObject(), fEventNumber(-1), //fCurrentFileName(""),
61 fDataType(0), fDebug(0),
62 fFiducialCut(0x0), fCheckFidCut(kFALSE),
63 fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(0),
64 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
65 fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
67 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
68 fEMCALCells(0x0), fPHOSCells(0x0),
69 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
70 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
71 fFillEMCALCells(0), fFillPHOSCells(0),
72 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
73 fTrackStatus(0), fTrackFilterMask(0), fESDtrackCuts(0),
74 fTrackMult(0), fTrackMultEtaCut(0.8),
75 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
76 fDeltaAODFileName(""), fFiredTriggerClassName(""), fAnaLED(kFALSE),
77 fTaskName(""), fCaloUtils(0x0),
78 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
79 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
80 fEMCALClustersListName(""), fZvtxCut(0.),
81 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
82 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
83 fTriggerAnalysis (0x0),
84 fCentralityClass(""), fCentralityOpt(0),
85 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
90 //Initialize parameters
94 //_______________________________________
95 AliCaloTrackReader::~AliCaloTrackReader()
102 fAODBranchList->Delete();
103 delete fAODBranchList ;
107 if(fDataType!=kMC)fCTSTracks->Clear() ;
108 else fCTSTracks->Delete() ;
113 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
114 else fEMCALClusters->Delete() ;
115 delete fEMCALClusters ;
119 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
120 else fPHOSClusters->Delete() ;
121 delete fPHOSClusters ;
125 for (Int_t i = 0; i < fNMixedEvent; i++) {
126 delete [] fVertex[i] ;
132 delete fESDtrackCuts;
133 delete fTriggerAnalysis;
135 // Pointers not owned, done by the analysis frame
136 // if(fInputEvent) delete fInputEvent ;
137 // if(fOutputEvent) delete fOutputEvent ;
138 // if(fMC) delete fMC ;
139 // Pointer not owned, deleted by maker
140 // if (fCaloUtils) delete fCaloUtils ;
144 //________________________________________________
145 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
147 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
149 if(!fReadStack) return kTRUE; //Information not filtered to AOD
151 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader")){
153 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
154 Int_t nTriggerJets = pygeh->NTriggerJets();
155 Float_t ptHard = pygeh->GetPtHard();
157 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
158 Float_t tmpjet[]={0,0,0,0};
159 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
160 pygeh->TriggerJet(ijet, tmpjet);
161 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
162 //Compare jet pT and pt Hard
163 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
164 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard) {
165 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
166 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
177 //____________________________________________
178 AliStack* AliCaloTrackReader::GetStack() const
180 //Return pointer to stack
184 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
189 //__________________________________________________
190 TString AliCaloTrackReader::GetFiredTriggerClasses()
192 // List of triggered classes in a TString
194 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
195 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
197 if (esdevent) return esdevent->GetFiredTriggerClasses();
198 else if(aodevent) return aodevent->GetFiredTriggerClasses();
199 else return ""; // Mixed Event, MC event, does not have this trigger info
203 //______________________________________________
204 AliHeader* AliCaloTrackReader::GetHeader() const
206 //Return pointer to header
208 return fMC->Header();
210 printf("AliCaloTrackReader::Header is not available\n");
215 //______________________________________________________________
216 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
218 //Return pointer to Generated event header
220 return fMC->GenEventHeader();
222 printf("AliCaloTrackReader::GenEventHeader is not available\n");
227 //____________________________________________________________________
228 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
230 //Return list of particles in AOD. Do it for the corresponding input event.
232 TClonesArray * rv = NULL ;
233 if(fDataType == kAOD){
237 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
239 rv = (TClonesArray*)evt->FindListObject("mcparticles");
241 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
246 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
252 //___________________________________________________________________
253 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const
255 //Return MC header in AOD. Do it for the corresponding input event.
256 AliAODMCHeader *mch = NULL;
257 if(fDataType == kAOD){
260 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
262 // //Second input AOD
263 // else if(input == 1){
264 // mch = (AliAODMCHeader*) fSecondInputAODEvent->FindListObject("mcheader");
267 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
271 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
277 //_____________________________
278 void AliCaloTrackReader::Init()
280 //Init reader. Method to be called in AliAnaPartCorrMaker
282 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
284 if(fReadStack && fReadAODMCParticles)
286 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
288 fReadAODMCParticles = kFALSE;
291 // Init geometry, I do not like much to do it like this ...
292 if(fImportGeometryFromFile && !gGeoManager)
294 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
295 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
300 //_______________________________________
301 void AliCaloTrackReader::InitParameters()
303 //Initialize the parameters of the analysis.
309 fEMCALPtMax = 1000. ;
312 //Do not filter the detectors input by default.
316 fFillEMCALCells = kFALSE;
317 fFillPHOSCells = kFALSE;
319 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
320 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
321 fDeltaAODFileName = "deltaAODPartCorr.root";
322 fFiredTriggerClassName = "";
324 fAcceptFastCluster = kTRUE;
327 //We want tracks fitted in the detectors:
328 //fTrackStatus=AliESDtrack::kTPCrefit;
329 //fTrackStatus|=AliESDtrack::kITSrefit;
331 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
333 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
335 fV0ADC[0] = 0; fV0ADC[1] = 0;
336 fV0Mul[0] = 0; fV0Mul[1] = 0;
342 fPtHardAndJetPtFactor = 7;
345 fCentralityClass = "V0M";
347 fCentralityBin[0] = fCentralityBin[1]=-1;
349 fEventPlaneMethod = "Q";
351 // Allocate memory (not sure this is the right place)
352 fCTSTracks = new TObjArray();
353 fEMCALClusters = new TObjArray();
354 fPHOSClusters = new TObjArray();
355 fTriggerAnalysis = new AliTriggerAnalysis;
356 fAODBranchList = new TList ;
358 fImportGeometryFromFile = kFALSE;
359 fImportGeometryFilePath = "$ALICE_ROOT/PWGGA/EMCALTasks/macros/geometry.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
363 //________________________________________________________
364 void AliCaloTrackReader::Print(const Option_t * opt) const
367 //Print some relevant parameters set for the analysis
371 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
372 printf("Task name : %s\n", fTaskName.Data()) ;
373 printf("Data type : %d\n", fDataType) ;
374 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
375 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
376 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
377 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
378 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
379 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
380 printf("Use CTS = %d\n", fFillCTS) ;
381 printf("Use EMCAL = %d\n", fFillEMCAL) ;
382 printf("Use PHOS = %d\n", fFillPHOS) ;
383 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
384 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
385 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
386 printf("Track filter mask (AODs) = %d\n", (Int_t) fTrackFilterMask) ;
387 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
388 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
389 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
391 if(fComparePtHardAndJetPt)
392 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
394 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
395 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
396 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
402 //_________________________________________________________________________
403 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
404 const char * /*currentFileName*/)
406 //Fill the event counter and input lists that are needed, called by the analysis maker.
408 fEventNumber = iEntry;
409 //fCurrentFileName = TString(currentFileName);
412 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
416 //Select events only fired by a certain trigger configuration if it is provided
418 if(fInputEvent->GetHeader())
419 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
421 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
423 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
427 //-------------------------------------------------------------------------------------
428 // Reject event if large clusters with large energy
429 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
430 // If clusterzer NxN or V2 it does not help
431 //-------------------------------------------------------------------------------------
432 Int_t run = fInputEvent->GetRunNumber();
433 if( fRemoveLEDEvents && run > 140000 && run <= 146860 )
435 //printf("Event %d\n",GetEventNumber());
436 for (Int_t i = 0; i < fInputEvent->GetNumberOfCaloClusters(); i++)
438 AliVCluster *clus = fInputEvent->GetCaloCluster(i);
441 if ((clus->E() > 500 && clus->GetNCells() > 200 ) || clus->GetNCells() > 200)
443 Int_t absID = clus->GetCellsAbsId()[0];
444 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
445 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);
451 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
454 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
456 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
457 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
458 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
459 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==4) ncellsSM4++;
463 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
465 if(ncellsSM3 >= ncellcut || ncellsSM4 >= 100)
467 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d and SM4 %d\n",ncellsSM3, ncellsSM4);
470 }// Remove LED events
472 // Reject pure LED events?
473 if( fFiredTriggerClassName !="" && !fAnaLED)
476 return kFALSE; //Only physics event, do not use for simulated events!!!
478 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
479 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
480 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
481 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
485 // kStartOfRun = 1, // START_OF_RUN
486 // kEndOfRun = 2, // END_OF_RUN
487 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
488 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
489 // kStartOfBurst = 5, // START_OF_BURST
490 // kEndOfBurst = 6, // END_OF_BURST
491 // kPhysicsEvent = 7, // PHYSICS_EVENT
492 // kCalibrationEvent = 8, // CALIBRATION_EVENT
493 // kFormatError = 9, // EVENT_FORMAT_ERROR
494 // kStartOfData = 10, // START_OF_DATA
495 // kEndOfData = 11, // END_OF_DATA
496 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
497 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
499 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
500 if(eventType!=8)return kFALSE;
503 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
504 if(fComparePtHardAndJetPt && GetStack())
506 if(!ComparePtHardAndJetPt()) return kFALSE ;
511 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
512 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
514 //------------------------------------------------------
515 //Event rejection depending on vertex, pileup, v0and
516 //------------------------------------------------------
517 if(fDoEventSelection)
519 if(!fCaloFilterPatch)
521 //Do not analyze events with pileup
522 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
523 //Bool_t bPileup = event->IsPileupFromSPD();
524 if(bPileup) return kFALSE;
526 if(fDoV0ANDEventSelection)
528 Bool_t bV0AND = kTRUE;
529 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
531 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
532 //else bV0AND = //FIXME FOR AODs
533 if(!bV0AND) return kFALSE;
536 if(fUseEventsWithPrimaryVertex && !CheckForPrimaryVertex()) return kFALSE;
541 if(fInputEvent->GetNumberOfCaloClusters() > 0)
543 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
544 if(calo->GetNLabels() == 4){
545 Int_t * selection = calo->GetLabels();
546 Bool_t bPileup = selection[0];
547 if(bPileup) return kFALSE;
549 Bool_t bGoodV = selection[1];
550 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
552 if(fDoV0ANDEventSelection){
553 Bool_t bV0AND = selection[2];
554 if(!bV0AND) return kFALSE;
557 fTrackMult = selection[3];
558 if(fTrackMult == 0) return kFALSE;
560 //First filtered AODs, track multiplicity stored there.
561 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
562 if(fTrackMult == 0) return kFALSE;
564 }//at least one cluster
566 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
567 //Remove events with vertex (0,0,0), bad vertex reconstruction
568 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;
570 //First filtered AODs, track multiplicity stored there.
571 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
572 if(fTrackMult == 0) return kFALSE;
574 }// CaloFileter patch
576 //------------------------------------------------------
578 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
579 //If we need a centrality bin, we select only those events in the corresponding bin.
580 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
582 Int_t cen = GetEventCentrality();
583 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
586 //Fill the arrays with cluster/tracks/cells data
588 FillInputEMCALCells();
590 FillInputPHOSCells();
594 //Accept events with at least one track
595 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
608 //___________________________________
609 void AliCaloTrackReader::ResetLists()
611 // Reset lists, called by the analysis maker
613 if(fCTSTracks) fCTSTracks -> Clear();
614 if(fEMCALClusters) fEMCALClusters -> Clear("C");
615 if(fPHOSClusters) fPHOSClusters -> Clear("C");
617 fV0ADC[0] = 0; fV0ADC[1] = 0;
618 fV0Mul[0] = 0; fV0Mul[1] = 0;
622 //____________________________________________________________
623 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
626 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
628 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
631 //Delete previous vertex
633 for (Int_t i = 0; i < fNMixedEvent; i++) {
634 delete [] fVertex[i] ;
639 fVertex = new Double_t*[fNMixedEvent] ;
640 for (Int_t i = 0; i < fNMixedEvent; i++) {
641 fVertex[i] = new Double_t[3] ;
642 fVertex[i][0] = 0.0 ;
643 fVertex[i][1] = 0.0 ;
644 fVertex[i][2] = 0.0 ;
648 //__________________________________________________
649 Int_t AliCaloTrackReader::GetEventCentrality() const
651 //Return current event centrality
654 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
655 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
656 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
658 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
666 //__________________________________________________________
667 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
669 //Return vertex position to be used for single event analysis
670 vertex[0]=fVertex[0][0];
671 vertex[1]=fVertex[0][1];
672 vertex[2]=fVertex[0][2];
675 //____________________________________________________________
676 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
677 const Int_t evtIndex) const
679 //Return vertex position for mixed event, recover the vertex in a particular event.
681 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
685 //________________________________________
686 void AliCaloTrackReader::FillVertexArray()
689 //Fill data member with vertex
690 //In case of Mixed event, multiple vertices
692 //Delete previous vertex
694 for (Int_t i = 0; i < fNMixedEvent; i++) {
695 delete [] fVertex[i] ;
700 fVertex = new Double_t*[fNMixedEvent] ;
701 for (Int_t i = 0; i < fNMixedEvent; i++) {
702 fVertex[i] = new Double_t[3] ;
703 fVertex[i][0] = 0.0 ;
704 fVertex[i][1] = 0.0 ;
705 fVertex[i][2] = 0.0 ;
708 if (!fMixedEvent) { //Single event analysis
711 if(fInputEvent->GetPrimaryVertex()){
712 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
715 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
716 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
717 }//Primary vertex pointer do not exist
719 } else {//MC read event
720 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
724 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
726 } else { // MultiEvent analysis
727 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
728 if (fMixedEvent->GetVertexOfEvent(iev))
729 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
730 else { // no vertex found !!!!
731 AliWarning("No vertex found");
735 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
742 //_____________________________________
743 void AliCaloTrackReader::FillInputCTS()
745 //Return array with Central Tracking System (CTS) tracks
747 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
749 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
753 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
754 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
756 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
757 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
762 if (fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track))
766 else if(fDataType==kAOD)
768 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
771 printf("AliCaloTrackReader::FillInputCTS():AOD track type: %c \n", aodtrack->GetType());
772 if (fDataType!=kMC && aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue;
773 if(aodtrack->GetType()!=AliAODTrack::kPrimary) continue;
777 //Count the tracks in eta < 0.9
778 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
779 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
781 track->GetPxPyPz(p) ;
782 TLorentzVector momentum(p[0],p[1],p[2],0);
784 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt()){
786 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
789 if(fDebug > 2 && momentum.Pt() > 0.1)
790 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
791 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
794 track->SetID(itrack);
797 fCTSTracks->Add(track);
799 }//Pt and Fiducial cut passed.
802 //fCTSTracksNormalInputEntries = fCTSTracks->GetEntriesFast();
804 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
808 //__________________________________________________________________
809 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
812 //Fill the EMCAL data in the array, do it
816 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
818 //Reject clusters with bad channels, close to borders and exotic;
819 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
821 //Mask all cells in collumns facing ALICE thick material if requested
822 if(GetCaloUtils()->GetNMaskCellColumns()){
827 Bool_t shared = kFALSE;
828 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
829 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
832 if(fSelectEmbeddedClusters){
833 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
834 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
838 //clus->GetPosition(pos);
839 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
841 if(fRecalculateClusters){
842 //Recalibrate the cluster energy
843 if(GetCaloUtils()->IsRecalibrationOn()) {
845 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
848 //printf("Recalibrated Energy %f\n",clus->E());
850 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
851 GetCaloUtils()->RecalculateClusterPID(clus);
855 //Recalculate distance to bad channels, if new list of bad channels provided
856 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
858 //Recalculate cluster position
859 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
860 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
861 //clus->GetPosition(pos);
862 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
867 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn()) {
869 Double_t tof = clus->GetTOF();
871 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
873 if(fDataType==AliCaloTrackReader::kESD){
874 tof = fEMCALCells->GetCellTime(absIdMax);
877 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
881 }// Time recalibration
883 //Correct non linearity
884 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
885 GetCaloUtils()->CorrectClusterEnergy(clus) ;
886 //printf("Linearity Corrected Energy %f\n",clus->E());
888 //In case of MC analysis, to match resolution/calibration in real data
889 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
890 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
891 clus->SetE(rdmEnergy);
894 TLorentzVector momentum ;
896 clus->GetMomentum(momentum, fVertex[vindex]);
898 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return;
900 if(fEMCALPtMin > momentum.E() || fEMCALPtMax < momentum.E()) return;
902 if(fDebug > 2 && momentum.E() > 0.1)
903 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
904 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
909 fEMCALClusters->Add(clus);
913 //_______________________________________
914 void AliCaloTrackReader::FillInputEMCAL()
916 //Return array with EMCAL clusters in aod format
918 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
920 // First recalibrate cells, time or energy
921 // if(GetCaloUtils()->IsRecalibrationOn())
922 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
924 // fInputEvent->GetBunchCrossNumber());
926 //Loop to select clusters in fiducial cut and fill container with aodClusters
927 if(fEMCALClustersListName==""){
928 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
929 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
930 AliVCluster * clus = 0;
931 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
932 if (IsEMCALCluster(clus)){
933 FillInputEMCALAlgorithm(clus, iclus);
938 //Recalculate track matching
939 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
941 }//Get the clusters from the input event
943 TClonesArray * clusterList = 0x0;
944 if(fOutputEvent) clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
946 //printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? Try input event <%s>\n",fEMCALClustersListName.Data());
947 //List not in output event, try input event
948 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
950 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
955 Int_t nclusters = clusterList->GetEntriesFast();
956 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
957 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
958 //printf("E %f\n",clus->E());
959 if (clus) FillInputEMCALAlgorithm(clus, iclus);
960 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
964 // Recalculate track matching, not necessary if already done in the reclusterization task.
965 // in case it was not done ...
966 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
970 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());
974 //______________________________________
975 void AliCaloTrackReader::FillInputPHOS()
977 //Return array with PHOS clusters in aod format
979 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
981 //Loop to select clusters in fiducial cut and fill container with aodClusters
982 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
983 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
984 AliVCluster * clus = 0;
985 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
986 if (IsPHOSCluster(clus)){
987 //Check if the cluster contains any bad channel and if close to calorimeter borders
990 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
991 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
993 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
996 if(fRecalculateClusters){
998 //Recalibrate the cluster energy
999 if(GetCaloUtils()->IsRecalibrationOn()) {
1000 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1006 TLorentzVector momentum ;
1008 clus->GetMomentum(momentum, fVertex[vindex]);
1010 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1012 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1014 if(fDebug > 2 && momentum.E() > 0.1)
1015 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1016 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1020 clus->SetID(iclus) ;
1023 fPHOSClusters->Add(clus);
1029 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1033 //____________________________________________
1034 void AliCaloTrackReader::FillInputEMCALCells()
1036 //Return array with EMCAL cells in aod format
1038 fEMCALCells = fInputEvent->GetEMCALCells();
1042 //___________________________________________
1043 void AliCaloTrackReader::FillInputPHOSCells()
1045 //Return array with PHOS cells in aod format
1047 fPHOSCells = fInputEvent->GetPHOSCells();
1051 //_______________________________________
1052 void AliCaloTrackReader::FillInputVZERO()
1054 //Fill VZERO information in data member, add all the channels information.
1055 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1056 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1060 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1061 for (Int_t i = 0; i < 32; i++)
1063 if(esdV0){//Only available in ESDs
1064 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1065 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1067 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1068 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1071 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1076 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1081 //___________________________________________________________________
1082 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1084 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1085 // different number and need to patch here
1087 if(fDataType==kAOD && fOldAOD)
1089 if (cluster->GetType() == 2) return kTRUE;
1094 return cluster->IsEMCAL();
1099 //___________________________________________________________________
1100 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1102 //Check if it is a cluster from PHOS.For old AODs cluster type has
1103 // different number and need to patch here
1105 if(fDataType==kAOD && fOldAOD)
1107 Int_t type = cluster->GetType();
1108 if (type == 0 || type == 1) return kTRUE;
1113 return cluster->IsPHOS();
1118 //________________________________________________
1119 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1121 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1124 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1125 if(!event) return kTRUE;
1127 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {
1131 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {
1133 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {
1134 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1138 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {
1139 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1148 //____________________________________________________________
1149 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1153 if(fESDtrackCuts) delete fESDtrackCuts ;
1155 fESDtrackCuts = cuts ;