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),
66 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
68 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
69 fEMCALCells(0x0), fPHOSCells(0x0),
70 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
71 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
72 fFillEMCALCells(0), fFillPHOSCells(0),
73 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
74 fTrackStatus(0), fTrackFilterMask(0), fESDtrackCuts(0),
75 fTrackMult(0), fTrackMultEtaCut(0.8),
76 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
77 fDeltaAODFileName(""), fFiredTriggerClassName(""), fAnaLED(kFALSE),
78 fTaskName(""), fCaloUtils(0x0),
79 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
80 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
81 fEMCALClustersListName(""), fZvtxCut(0.),
82 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
83 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
84 fTriggerAnalysis (0x0),
85 fCentralityClass(""), fCentralityOpt(0),
86 fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
90 //Initialize parameters
94 //_______________________________________
95 AliCaloTrackReader::~AliCaloTrackReader()
103 fAODBranchList->Delete();
104 delete fAODBranchList ;
109 if(fDataType!=kMC)fCTSTracks->Clear() ;
110 else fCTSTracks->Delete() ;
116 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
117 else fEMCALClusters->Delete() ;
118 delete fEMCALClusters ;
123 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
124 else fPHOSClusters->Delete() ;
125 delete fPHOSClusters ;
130 for (Int_t i = 0; i < fNMixedEvent; i++)
132 delete [] fVertex[i] ;
138 delete fESDtrackCuts;
139 delete fTriggerAnalysis;
141 // Pointers not owned, done by the analysis frame
142 // if(fInputEvent) delete fInputEvent ;
143 // if(fOutputEvent) delete fOutputEvent ;
144 // if(fMC) delete fMC ;
145 // Pointer not owned, deleted by maker
146 // if (fCaloUtils) delete fCaloUtils ;
150 //________________________________________________
151 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
153 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
155 if(!fReadStack) return kTRUE; //Information not filtered to AOD
157 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
160 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
161 Int_t nTriggerJets = pygeh->NTriggerJets();
162 Float_t ptHard = pygeh->GetPtHard();
164 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
165 Float_t tmpjet[]={0,0,0,0};
166 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
168 pygeh->TriggerJet(ijet, tmpjet);
169 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
170 //Compare jet pT and pt Hard
171 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
172 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
174 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
175 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
186 //____________________________________________
187 AliStack* AliCaloTrackReader::GetStack() const
189 //Return pointer to stack
194 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
199 //__________________________________________________
200 TString AliCaloTrackReader::GetFiredTriggerClasses()
202 // List of triggered classes in a TString
204 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
205 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
207 if (esdevent) return esdevent->GetFiredTriggerClasses();
208 else if(aodevent) return aodevent->GetFiredTriggerClasses();
209 else return ""; // Mixed Event, MC event, does not have this trigger info
213 //______________________________________________
214 AliHeader* AliCaloTrackReader::GetHeader() const
216 //Return pointer to header
218 return fMC->Header();
220 printf("AliCaloTrackReader::Header is not available\n");
225 //______________________________________________________________
226 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
228 //Return pointer to Generated event header
230 return fMC->GenEventHeader();
232 printf("AliCaloTrackReader::GenEventHeader is not available\n");
237 //____________________________________________________________________
238 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
240 //Return list of particles in AOD. Do it for the corresponding input event.
242 TClonesArray * rv = NULL ;
243 if(fDataType == kAOD){
247 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
249 rv = (TClonesArray*)evt->FindListObject("mcparticles");
251 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
256 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
262 //___________________________________________________________________
263 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const
265 //Return MC header in AOD. Do it for the corresponding input event.
267 AliAODMCHeader *mch = NULL;
269 if(fDataType == kAOD)
274 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
278 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
283 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
289 //_____________________________
290 void AliCaloTrackReader::Init()
292 //Init reader. Method to be called in AliAnaPartCorrMaker
294 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
296 if(fReadStack && fReadAODMCParticles)
298 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
300 fReadAODMCParticles = kFALSE;
303 // Init geometry, I do not like much to do it like this ...
304 if(fImportGeometryFromFile && !gGeoManager)
306 if(fImportGeometryFilePath=="") // If not specified, set a default location
307 fImportGeometryFilePath = "$ALICE_ROOT/PWGGA/EMCALTasks/macros/geometry.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
309 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
310 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
315 //_______________________________________
316 void AliCaloTrackReader::InitParameters()
318 //Initialize the parameters of the analysis.
324 fEMCALPtMax = 1000. ;
327 //Do not filter the detectors input by default.
331 fFillEMCALCells = kFALSE;
332 fFillPHOSCells = kFALSE;
334 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
335 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
336 fDeltaAODFileName = "deltaAODPartCorr.root";
337 fFiredTriggerClassName = "";
339 fAcceptFastCluster = kTRUE;
342 //We want tracks fitted in the detectors:
343 //fTrackStatus=AliESDtrack::kTPCrefit;
344 //fTrackStatus|=AliESDtrack::kITSrefit;
346 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
348 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
350 fV0ADC[0] = 0; fV0ADC[1] = 0;
351 fV0Mul[0] = 0; fV0Mul[1] = 0;
357 fPtHardAndJetPtFactor = 7;
360 fCentralityClass = "V0M";
362 fCentralityBin[0] = fCentralityBin[1]=-1;
364 fEventPlaneMethod = "Q";
366 // Allocate memory (not sure this is the right place)
367 fCTSTracks = new TObjArray();
368 fEMCALClusters = new TObjArray();
369 fPHOSClusters = new TObjArray();
370 fTriggerAnalysis = new AliTriggerAnalysis;
371 fAODBranchList = new TList ;
373 fImportGeometryFromFile = kFALSE;
377 //________________________________________________________
378 void AliCaloTrackReader::Print(const Option_t * opt) const
381 //Print some relevant parameters set for the analysis
385 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
386 printf("Task name : %s\n", fTaskName.Data()) ;
387 printf("Data type : %d\n", fDataType) ;
388 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
389 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
390 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
391 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
392 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
393 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
394 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
395 printf("Use CTS = %d\n", fFillCTS) ;
396 printf("Use EMCAL = %d\n", fFillEMCAL) ;
397 printf("Use PHOS = %d\n", fFillPHOS) ;
398 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
399 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
400 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
401 printf("Track filter mask (AODs) = %d\n", (Int_t) fTrackFilterMask) ;
402 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
403 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
404 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
406 if(fComparePtHardAndJetPt)
407 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
409 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
410 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
411 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
417 //_________________________________________________________________________
418 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
419 const char * /*currentFileName*/)
421 //Fill the event counter and input lists that are needed, called by the analysis maker.
423 fEventNumber = iEntry;
424 //fCurrentFileName = TString(currentFileName);
427 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
431 //Select events only fired by a certain trigger configuration if it is provided
433 if(fInputEvent->GetHeader())
434 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
436 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
438 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
442 //-------------------------------------------------------------------------------------
443 // Reject event if large clusters with large energy
444 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
445 // If clusterzer NxN or V2 it does not help
446 //-------------------------------------------------------------------------------------
447 Int_t run = fInputEvent->GetRunNumber();
448 if( fRemoveLEDEvents && run > 140000 && run <= 146860 )
450 //printf("Event %d\n",GetEventNumber());
451 for (Int_t i = 0; i < fInputEvent->GetNumberOfCaloClusters(); i++)
453 AliVCluster *clus = fInputEvent->GetCaloCluster(i);
456 if ((clus->E() > 500 && clus->GetNCells() > 200 ) || clus->GetNCells() > 200)
458 Int_t absID = clus->GetCellsAbsId()[0];
459 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
460 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);
466 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
469 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
471 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
472 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
473 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
474 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==4) ncellsSM4++;
478 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
480 if(ncellsSM3 >= ncellcut || ncellsSM4 >= 100)
482 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d and SM4 %d\n",ncellsSM3, ncellsSM4);
485 }// Remove LED events
487 // Reject pure LED events?
488 if( fFiredTriggerClassName !="" && !fAnaLED)
491 return kFALSE; //Only physics event, do not use for simulated events!!!
493 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
494 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
495 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
496 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
500 // kStartOfRun = 1, // START_OF_RUN
501 // kEndOfRun = 2, // END_OF_RUN
502 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
503 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
504 // kStartOfBurst = 5, // START_OF_BURST
505 // kEndOfBurst = 6, // END_OF_BURST
506 // kPhysicsEvent = 7, // PHYSICS_EVENT
507 // kCalibrationEvent = 8, // CALIBRATION_EVENT
508 // kFormatError = 9, // EVENT_FORMAT_ERROR
509 // kStartOfData = 10, // START_OF_DATA
510 // kEndOfData = 11, // END_OF_DATA
511 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
512 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
514 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
515 if(eventType!=8)return kFALSE;
518 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
519 if(fComparePtHardAndJetPt && GetStack())
521 if(!ComparePtHardAndJetPt()) return kFALSE ;
526 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
527 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
529 //------------------------------------------------------
530 //Event rejection depending on vertex, pileup, v0and
531 //------------------------------------------------------
533 if(fUseEventsWithPrimaryVertex)
535 if( !CheckForPrimaryVertex() ) return kFALSE;
536 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
537 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
538 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
541 if(fDoEventSelection)
543 if(!fCaloFilterPatch)
545 //Do not analyze events with pileup
546 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
547 //Bool_t bPileup = event->IsPileupFromSPD();
548 if(bPileup) return kFALSE;
550 if(fDoV0ANDEventSelection)
552 Bool_t bV0AND = kTRUE;
553 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
555 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
556 //else bV0AND = //FIXME FOR AODs
557 if(!bV0AND) return kFALSE;
562 if(fInputEvent->GetNumberOfCaloClusters() > 0)
564 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
565 if(calo->GetNLabels() == 4){
566 Int_t * selection = calo->GetLabels();
567 Bool_t bPileup = selection[0];
568 if(bPileup) return kFALSE;
570 Bool_t bGoodV = selection[1];
571 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
573 if(fDoV0ANDEventSelection){
574 Bool_t bV0AND = selection[2];
575 if(!bV0AND) return kFALSE;
578 fTrackMult = selection[3];
579 if(fTrackMult == 0) return kFALSE;
581 //First filtered AODs, track multiplicity stored there.
582 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
583 if(fTrackMult == 0) return kFALSE;
585 }//at least one cluster
587 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
588 //Remove events with vertex (0,0,0), bad vertex reconstruction
589 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;
591 //First filtered AODs, track multiplicity stored there.
592 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
593 if(fTrackMult == 0) return kFALSE;
595 }// CaloFileter patch
597 //------------------------------------------------------
599 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
600 //If we need a centrality bin, we select only those events in the corresponding bin.
601 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
603 Int_t cen = GetEventCentrality();
604 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
607 //Fill the arrays with cluster/tracks/cells data
609 FillInputEMCALCells();
611 FillInputPHOSCells();
615 //Accept events with at least one track
616 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
629 //___________________________________
630 void AliCaloTrackReader::ResetLists()
632 // Reset lists, called by the analysis maker
634 if(fCTSTracks) fCTSTracks -> Clear();
635 if(fEMCALClusters) fEMCALClusters -> Clear("C");
636 if(fPHOSClusters) fPHOSClusters -> Clear("C");
638 fV0ADC[0] = 0; fV0ADC[1] = 0;
639 fV0Mul[0] = 0; fV0Mul[1] = 0;
643 //____________________________________________________________
644 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
647 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
649 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
652 //Delete previous vertex
654 for (Int_t i = 0; i < fNMixedEvent; i++) {
655 delete [] fVertex[i] ;
660 fVertex = new Double_t*[fNMixedEvent] ;
661 for (Int_t i = 0; i < fNMixedEvent; i++) {
662 fVertex[i] = new Double_t[3] ;
663 fVertex[i][0] = 0.0 ;
664 fVertex[i][1] = 0.0 ;
665 fVertex[i][2] = 0.0 ;
669 //__________________________________________________
670 Int_t AliCaloTrackReader::GetEventCentrality() const
672 //Return current event centrality
675 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
676 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
677 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
679 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
687 //__________________________________________________________
688 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
690 //Return vertex position to be used for single event analysis
691 vertex[0]=fVertex[0][0];
692 vertex[1]=fVertex[0][1];
693 vertex[2]=fVertex[0][2];
696 //____________________________________________________________
697 void AliCaloTrackReader::GetVertex(Double_t vertex[3],
698 const Int_t evtIndex) const
700 //Return vertex position for mixed event, recover the vertex in a particular event.
702 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
706 //________________________________________
707 void AliCaloTrackReader::FillVertexArray()
710 //Fill data member with vertex
711 //In case of Mixed event, multiple vertices
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 { //Single event analysis
737 if(fInputEvent->GetPrimaryVertex())
739 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
743 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
744 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
745 }//Primary vertex pointer do not exist
749 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
753 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
756 { // MultiEvent analysis
757 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
759 if (fMixedEvent->GetVertexOfEvent(iev))
760 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
762 { // no vertex found !!!!
763 AliWarning("No vertex found");
767 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
774 //_____________________________________
775 void AliCaloTrackReader::FillInputCTS()
777 //Return array with Central Tracking System (CTS) tracks
779 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
781 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
785 for (Int_t itrack = 0; itrack < nTracks; itrack++)
786 {////////////// track loop
787 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
789 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
790 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
795 if (fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track))
799 else if(fDataType==kAOD)
801 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
805 printf("AliCaloTrackReader::FillInputCTS():AOD track type: %c \n", aodtrack->GetType());
806 if (fDataType!=kMC && aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue;
807 if (aodtrack->GetType()!=AliAODTrack::kPrimary) continue;
811 //Count the tracks in eta < 0.9
812 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
813 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
815 track->GetPxPyPz(p) ;
816 TLorentzVector momentum(p[0],p[1],p[2],0);
818 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt())
820 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
823 if(fDebug > 2 && momentum.Pt() > 0.1)
824 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
825 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
829 track->SetID(itrack);
832 fCTSTracks->Add(track);
834 }//Pt and Fiducial cut passed.
838 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
842 //__________________________________________________________________
843 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
846 //Fill the EMCAL data in the array, do it
850 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
852 //Reject clusters with bad channels, close to borders and exotic;
853 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
855 //Mask all cells in collumns facing ALICE thick material if requested
856 if(GetCaloUtils()->GetNMaskCellColumns())
862 Bool_t shared = kFALSE;
863 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
864 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
867 if(fSelectEmbeddedClusters){
868 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
869 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
873 //clus->GetPosition(pos);
874 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
876 if(fRecalculateClusters)
878 //Recalibrate the cluster energy
879 if(GetCaloUtils()->IsRecalibrationOn())
881 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
884 //printf("Recalibrated Energy %f\n",clus->E());
886 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
887 GetCaloUtils()->RecalculateClusterPID(clus);
891 //Recalculate distance to bad channels, if new list of bad channels provided
892 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
894 //Recalculate cluster position
895 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
897 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
898 //clus->GetPosition(pos);
899 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
903 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
905 Double_t tof = clus->GetTOF();
907 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
909 if(fDataType==AliCaloTrackReader::kESD)
911 tof = fEMCALCells->GetCellTime(absIdMax);
914 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
918 }// Time recalibration
921 //Correct non linearity
922 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
924 GetCaloUtils()->CorrectClusterEnergy(clus) ;
925 //printf("Linearity Corrected Energy %f\n",clus->E());
927 //In case of MC analysis, to match resolution/calibration in real data
928 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
929 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
930 clus->SetE(rdmEnergy);
933 TLorentzVector momentum ;
935 clus->GetMomentum(momentum, fVertex[vindex]);
937 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return;
939 if(fEMCALPtMin > momentum.E() || fEMCALPtMax < momentum.E()) return;
941 Double_t tof = clus->GetTOF()*1e9;
942 if(tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax) return;
944 if(fDebug > 2 && momentum.E() > 0.1)
945 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
946 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
951 fEMCALClusters->Add(clus);
955 //_______________________________________
956 void AliCaloTrackReader::FillInputEMCAL()
958 //Return array with EMCAL clusters in aod format
960 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
962 // First recalibrate cells, time or energy
963 // if(GetCaloUtils()->IsRecalibrationOn())
964 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
966 // fInputEvent->GetBunchCrossNumber());
968 //Loop to select clusters in fiducial cut and fill container with aodClusters
969 if(fEMCALClustersListName==""){
970 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
971 for (Int_t iclus = 0; iclus < nclusters; iclus++)
973 AliVCluster * clus = 0;
974 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
976 if (IsEMCALCluster(clus)){
977 FillInputEMCALAlgorithm(clus, iclus);
982 //Recalculate track matching
983 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
985 }//Get the clusters from the input event
988 TClonesArray * clusterList = 0x0;
989 if(fOutputEvent) clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
992 //printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? Try input event <%s>\n",fEMCALClustersListName.Data());
993 //List not in output event, try input event
994 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
997 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1002 Int_t nclusters = clusterList->GetEntriesFast();
1003 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1005 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1006 //printf("E %f\n",clus->E());
1007 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1008 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1011 // Recalculate track matching, not necessary if already done in the reclusterization task.
1012 // in case it was not done ...
1013 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1017 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());
1021 //______________________________________
1022 void AliCaloTrackReader::FillInputPHOS()
1024 //Return array with PHOS clusters in aod format
1026 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1028 //Loop to select clusters in fiducial cut and fill container with aodClusters
1029 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1030 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1032 AliVCluster * clus = 0;
1033 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1035 if (IsPHOSCluster(clus)){
1036 //Check if the cluster contains any bad channel and if close to calorimeter borders
1039 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1040 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1042 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1045 if(fRecalculateClusters)
1047 //Recalibrate the cluster energy
1048 if(GetCaloUtils()->IsRecalibrationOn())
1050 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1055 TLorentzVector momentum ;
1057 clus->GetMomentum(momentum, fVertex[vindex]);
1059 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1061 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1063 if(fDebug > 2 && momentum.E() > 0.1)
1064 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1065 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1070 clus->SetID(iclus) ;
1073 fPHOSClusters->Add(clus);
1079 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1083 //____________________________________________
1084 void AliCaloTrackReader::FillInputEMCALCells()
1086 //Return array with EMCAL cells in aod format
1088 fEMCALCells = fInputEvent->GetEMCALCells();
1092 //___________________________________________
1093 void AliCaloTrackReader::FillInputPHOSCells()
1095 //Return array with PHOS cells in aod format
1097 fPHOSCells = fInputEvent->GetPHOSCells();
1101 //_______________________________________
1102 void AliCaloTrackReader::FillInputVZERO()
1104 //Fill VZERO information in data member, add all the channels information.
1105 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1106 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1110 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1111 for (Int_t i = 0; i < 32; i++)
1113 if(esdV0){//Only available in ESDs
1114 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1115 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1117 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1118 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1121 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1126 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1131 //___________________________________________________________________
1132 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1134 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1135 // different number and need to patch here
1137 if(fDataType==kAOD && fOldAOD)
1139 if (cluster->GetType() == 2) return kTRUE;
1144 return cluster->IsEMCAL();
1149 //___________________________________________________________________
1150 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1152 //Check if it is a cluster from PHOS.For old AODs cluster type has
1153 // different number and need to patch here
1155 if(fDataType==kAOD && fOldAOD)
1157 Int_t type = cluster->GetType();
1158 if (type == 0 || type == 1) return kTRUE;
1163 return cluster->IsPHOS();
1168 //________________________________________________
1169 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1171 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1174 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1175 if(!event) return kTRUE;
1177 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1182 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1185 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1187 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1191 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1193 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1202 //____________________________________________________________
1203 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1207 if(fESDtrackCuts) delete fESDtrackCuts ;
1209 fESDtrackCuts = cuts ;