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 **************************************************************************/
17 //_________________________________________________________________________
18 // Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and
19 // Central Barrel Tracking detectors (CTS).
20 // Not all MC particles/tracks/clusters are kept, some kinematical/fiducial restrictions are done.
21 // Mother class of : AliCaloTrackESDReader: Fills ESD data in 3 TObjArrays (PHOS, EMCAL, CTS)
22 // : AliCaloTrackMCReader : Fills Kinematics data in 3 TObjArrays (PHOS, EMCAL, CTS)
23 // : AliCaloTrackAODReader: Fills AOD data in 3 TObjArrays (PHOS, EMCAL, CTS)
24 //-- Author: Gustavo Conesa (LNF-INFN)
25 //////////////////////////////////////////////////////////////////////////////
28 // --- ROOT system ---
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"
45 //---- PartCorr/EMCAL ---
46 #include "AliEMCALRecoUtils.h"
47 #include "AliCaloTrackReader.h"
49 ClassImp(AliCaloTrackReader)
52 //____________________________________________________________________________
53 AliCaloTrackReader::AliCaloTrackReader() :
54 TObject(), fEventNumber(-1), //fCurrentFileName(""),
55 fDataType(0), fDebug(0),
56 fFiducialCut(0x0), fCheckFidCut(kFALSE),
57 fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(7),
58 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
59 fCTSPtMax(1000), fEMCALPtMax(1000), fPHOSPtMax(1000),
60 fAODBranchList(new TList ),
61 fCTSTracks(new TObjArray()), fEMCALClusters(new TObjArray()), fPHOSClusters(new TObjArray()),
62 fEMCALCells(0x0), fPHOSCells(0x0),
63 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
64 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
65 fFillEMCALCells(0), fFillPHOSCells(0),
66 fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
67 fTrackStatus(0), fTrackFilterMask(0), fESDtrackCuts(0),
68 fTrackMult(0), fTrackMultEtaCut(0.8),
69 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
70 fDeltaAODFileName("deltaAODPartCorr.root"),
71 fFiredTriggerClassName(""), fAnaLED(kFALSE),
72 fTaskName(""), fCaloUtils(0x0),
73 fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL),
74 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
75 fEMCALClustersListName(""), fZvtxCut(0.),
76 fAcceptFastCluster(kTRUE), fRemoveLEDEvents(kFALSE),
77 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
78 fTriggerAnalysis (new AliTriggerAnalysis),
79 fCentralityClass("V0M"), fCentralityOpt(10),
80 fEventPlaneMethod("Q")
85 //Initialize parameters
89 //_________________________________
90 AliCaloTrackReader::~AliCaloTrackReader() {
96 fAODBranchList->Delete();
97 delete fAODBranchList ;
101 if(fDataType!=kMC)fCTSTracks->Clear() ;
102 else fCTSTracks->Delete() ;
107 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
108 else fEMCALClusters->Delete() ;
109 delete fEMCALClusters ;
113 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
114 else fPHOSClusters->Delete() ;
115 delete fPHOSClusters ;
119 for (Int_t i = 0; i < fNMixedEvent; i++) {
120 delete [] fVertex[i] ;
126 delete fESDtrackCuts;
127 delete fTriggerAnalysis;
129 // Pointers not owned, done by the analysis frame
130 // if(fInputEvent) delete fInputEvent ;
131 // if(fOutputEvent) delete fOutputEvent ;
132 // if(fMC) delete fMC ;
133 // Pointer not owned, deleted by maker
134 // if (fCaloUtils) delete fCaloUtils ;
138 //_________________________________________________________________________
139 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt(){
140 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
142 if(!fReadStack) return kTRUE; //Information not filtered to AOD
144 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader")){
146 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
147 Int_t nTriggerJets = pygeh->NTriggerJets();
148 Float_t ptHard = pygeh->GetPtHard();
150 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
151 Float_t tmpjet[]={0,0,0,0};
152 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
153 pygeh->TriggerJet(ijet, tmpjet);
154 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
155 //Compare jet pT and pt Hard
156 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
157 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard) {
158 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
159 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
170 //____________________________________________________________________________
171 AliStack* AliCaloTrackReader::GetStack() const {
172 //Return pointer to stack
176 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
181 //____________________________________________________________________________
182 AliHeader* AliCaloTrackReader::GetHeader() const {
183 //Return pointer to header
185 return fMC->Header();
187 printf("AliCaloTrackReader::Header is not available\n");
191 //____________________________________________________________________________
192 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const {
193 //Return pointer to Generated event header
195 return fMC->GenEventHeader();
197 printf("AliCaloTrackReader::GenEventHeader is not available\n");
202 //____________________________________________________________________________
203 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const {
204 //Return list of particles in AOD. Do it for the corresponding input event.
206 TClonesArray * rv = NULL ;
207 if(fDataType == kAOD){
211 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
213 rv = (TClonesArray*)evt->FindListObject("mcparticles");
215 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
220 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
226 //____________________________________________________________________________
227 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const {
228 //Return MC header in AOD. Do it for the corresponding input event.
229 AliAODMCHeader *mch = NULL;
230 if(fDataType == kAOD){
233 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
235 // //Second input AOD
236 // else if(input == 1){
237 // mch = (AliAODMCHeader*) fSecondInputAODEvent->FindListObject("mcheader");
240 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
244 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
250 //_______________________________________________________________
251 void AliCaloTrackReader::Init()
253 //Init reader. Method to be called in AliAnaPartCorrMaker
255 if(fReadStack && fReadAODMCParticles){
256 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
258 fReadAODMCParticles = kFALSE;
263 //_______________________________________________________________
264 void AliCaloTrackReader::InitParameters()
266 //Initialize the parameters of the analysis.
272 fEMCALPtMax = 1000. ;
275 //Do not filter the detectors input by default.
279 fFillEMCALCells = kFALSE;
280 fFillPHOSCells = kFALSE;
282 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
283 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
284 fDeltaAODFileName = "deltaAODPartCorr.root";
285 fFiredTriggerClassName = "";
289 //We want tracks fitted in the detectors:
290 //fTrackStatus=AliESDtrack::kTPCrefit;
291 //fTrackStatus|=AliESDtrack::kITSrefit;
292 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
294 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
296 fV0ADC[0] = 0; fV0ADC[1] = 0;
297 fV0Mul[0] = 0; fV0Mul[1] = 0;
302 fCentralityBin[0]=fCentralityBin[1]=-1;
306 //________________________________________________________________
307 void AliCaloTrackReader::Print(const Option_t * opt) const
310 //Print some relevant parameters set for the analysis
314 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
315 printf("Task name : %s\n", fTaskName.Data()) ;
316 printf("Data type : %d\n", fDataType) ;
317 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
318 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
319 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
320 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
321 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
322 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
323 printf("Use CTS = %d\n", fFillCTS) ;
324 printf("Use EMCAL = %d\n", fFillEMCAL) ;
325 printf("Use PHOS = %d\n", fFillPHOS) ;
326 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
327 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
328 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
329 printf("Track filter mask (AODs) = %d\n", (Int_t) fTrackFilterMask) ;
330 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
331 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
332 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
334 if(fComparePtHardAndJetPt)
335 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
337 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
338 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
339 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
345 //___________________________________________________
346 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * /*currentFileName*/) {
347 //Fill the event counter and input lists that are needed, called by the analysis maker.
349 fEventNumber = iEntry;
350 //fCurrentFileName = TString(currentFileName);
352 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
355 //Select events only fired by a certain trigger configuration if it is provided
357 if(fInputEvent->GetHeader())
358 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
360 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster) {
361 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
365 //-------------------------------------------------------------------------------------
366 // Reject event if large clusters with large energy
367 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
368 // If clusterzer NxN or V2 it does not help
369 //-------------------------------------------------------------------------------------
370 if(fRemoveLEDEvents){
373 //printf("Event %d\n",GetEventNumber());
374 for (Int_t i = 0; i < fInputEvent->GetNumberOfCaloClusters(); i++)
376 AliVCluster *clus = fInputEvent->GetCaloCluster(i);
378 if ((clus->E() > 500 && clus->GetNCells() > 200 ) || clus->GetNCells() > 200) {
379 Int_t absID = clus->GetCellsAbsId()[0];
380 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
381 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);
387 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
390 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++){
391 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
392 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
393 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
394 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==4) ncellsSM4++;
398 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
400 if(ncellsSM3 >= ncellcut || ncellsSM4 >= 100) {
401 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d and SM4 %d\n",ncellsSM3, ncellsSM4);
404 }// Remove LED events
406 // Reject pure LED events?
407 if( fFiredTriggerClassName !="" && !fAnaLED){
409 return kFALSE; //Only physics event, do not use for simulated events!!!
411 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
412 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
413 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
414 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
417 // kStartOfRun = 1, // START_OF_RUN
418 // kEndOfRun = 2, // END_OF_RUN
419 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
420 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
421 // kStartOfBurst = 5, // START_OF_BURST
422 // kEndOfBurst = 6, // END_OF_BURST
423 // kPhysicsEvent = 7, // PHYSICS_EVENT
424 // kCalibrationEvent = 8, // CALIBRATION_EVENT
425 // kFormatError = 9, // EVENT_FORMAT_ERROR
426 // kStartOfData = 10, // START_OF_DATA
427 // kEndOfData = 11, // END_OF_DATA
428 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
429 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
431 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
432 if(eventType!=8)return kFALSE;
435 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
436 if(fComparePtHardAndJetPt && GetStack()) {
437 if(!ComparePtHardAndJetPt()) return kFALSE ;
442 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
443 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
445 //------------------------------------------------------
446 //Event rejection depending on vertex, pileup, v0and
447 //------------------------------------------------------
448 if(fDoEventSelection){
449 if(!fCaloFilterPatch){
450 //Do not analyze events with pileup
451 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
452 //Bool_t bPileup = event->IsPileupFromSPD();
453 if(bPileup) return kFALSE;
455 if(fDoV0ANDEventSelection){
456 Bool_t bV0AND = kTRUE;
457 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
459 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
460 //else bV0AND = //FIXME FOR AODs
461 if(!bV0AND) return kFALSE;
464 if(fUseEventsWithPrimaryVertex && !CheckForPrimaryVertex()) return kFALSE;
468 if(fInputEvent->GetNumberOfCaloClusters() > 0) {
469 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
470 if(calo->GetNLabels() == 4){
471 Int_t * selection = calo->GetLabels();
472 Bool_t bPileup = selection[0];
473 if(bPileup) return kFALSE;
475 Bool_t bGoodV = selection[1];
476 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
478 if(fDoV0ANDEventSelection){
479 Bool_t bV0AND = selection[2];
480 if(!bV0AND) return kFALSE;
483 fTrackMult = selection[3];
484 if(fTrackMult == 0) return kFALSE;
486 //First filtered AODs, track multiplicity stored there.
487 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
488 if(fTrackMult == 0) return kFALSE;
490 }//at least one cluster
492 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
493 //Remove events with vertex (0,0,0), bad vertex reconstruction
494 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;
496 //First filtered AODs, track multiplicity stored there.
497 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
498 if(fTrackMult == 0) return kFALSE;
500 }// CaloFileter patch
502 //------------------------------------------------------
504 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
505 //If we need a centrality bin, we select only those events in the corresponding bin.
506 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100){
507 Int_t cen = GetEventCentrality();
508 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
511 //Fill the arrays with cluster/tracks/cells data
513 FillInputEMCALCells();
515 FillInputPHOSCells();
519 //Accept events with at least one track
520 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
533 //__________________________________________________
534 void AliCaloTrackReader::ResetLists() {
535 // Reset lists, called by the analysis maker
537 if(fCTSTracks) fCTSTracks -> Clear();
538 if(fEMCALClusters) fEMCALClusters -> Clear("C");
539 if(fPHOSClusters) fPHOSClusters -> Clear("C");
540 // if(fEMCALCells) fEMCALCells -> Clear("");
541 // if(fPHOSCells) fPHOSCells -> Clear("");
543 fV0ADC[0] = 0; fV0ADC[1] = 0;
544 fV0Mul[0] = 0; fV0Mul[1] = 0;
548 //____________________________________________________________________________
549 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
552 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
554 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
557 //Delete previous vertex
559 for (Int_t i = 0; i < fNMixedEvent; i++) {
560 delete [] fVertex[i] ;
565 fVertex = new Double_t*[fNMixedEvent] ;
566 for (Int_t i = 0; i < fNMixedEvent; i++) {
567 fVertex[i] = new Double_t[3] ;
568 fVertex[i][0] = 0.0 ;
569 fVertex[i][1] = 0.0 ;
570 fVertex[i][2] = 0.0 ;
574 //__________________________________________________
575 Int_t AliCaloTrackReader::GetEventCentrality() const {
576 //Return current event centrality
579 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
580 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
581 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
583 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
591 //____________________________________________________________________________
592 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const {
593 //Return vertex position to be used for single event analysis
594 vertex[0]=fVertex[0][0];
595 vertex[1]=fVertex[0][1];
596 vertex[2]=fVertex[0][2];
599 //____________________________________________________________________________
600 void AliCaloTrackReader::GetVertex(Double_t vertex[3], const Int_t evtIndex) const {
601 //Return vertex position for mixed event, recover the vertex in a particular event.
603 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
607 //____________________________________________________________________________
608 void AliCaloTrackReader::FillVertexArray() {
610 //Fill data member with vertex
611 //In case of Mixed event, multiple vertices
613 //Delete previous vertex
615 for (Int_t i = 0; i < fNMixedEvent; i++) {
616 delete [] fVertex[i] ;
621 fVertex = new Double_t*[fNMixedEvent] ;
622 for (Int_t i = 0; i < fNMixedEvent; i++) {
623 fVertex[i] = new Double_t[3] ;
624 fVertex[i][0] = 0.0 ;
625 fVertex[i][1] = 0.0 ;
626 fVertex[i][2] = 0.0 ;
629 if (!fMixedEvent) { //Single event analysis
632 if(fInputEvent->GetPrimaryVertex()){
633 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
636 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
637 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
638 }//Primary vertex pointer do not exist
640 } else {//MC read event
641 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
645 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
647 } else { // MultiEvent analysis
648 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
649 if (fMixedEvent->GetVertexOfEvent(iev))
650 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
651 else { // no vertex found !!!!
652 AliWarning("No vertex found");
656 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
663 //____________________________________________________________________________
664 void AliCaloTrackReader::FillInputCTS() {
665 //Return array with Central Tracking System (CTS) tracks
667 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
669 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
673 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
674 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
676 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
677 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
682 if (fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track))
686 else if(fDataType==kAOD)
688 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
691 printf("AliCaloTrackReader::FillInputCTS():AOD track type: %c \n", aodtrack->GetType());
692 if (fDataType!=kMC && aodtrack->TestFilterMask(fTrackFilterMask)==kFALSE) continue;
693 if(aodtrack->GetType()!=AliAODTrack::kPrimary) continue;
697 //Count the tracks in eta < 0.9
698 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
699 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
701 track->GetPxPyPz(p) ;
702 TLorentzVector momentum(p[0],p[1],p[2],0);
704 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt()){
706 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
709 if(fDebug > 2 && momentum.Pt() > 0.1)
710 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
711 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
714 track->SetID(itrack);
717 fCTSTracks->Add(track);
719 }//Pt and Fiducial cut passed.
722 //fCTSTracksNormalInputEntries = fCTSTracks->GetEntriesFast();
724 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
728 //____________________________________________________________________________
729 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, const Int_t iclus) {
730 //Fill the EMCAL data in the array, do it
734 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
736 //Reject clusters with bad channels, close to borders and exotic;
737 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
739 //Mask all cells in collumns facing ALICE thick material if requested
740 if(GetCaloUtils()->GetNMaskCellColumns()){
745 Bool_t shared = kFALSE;
746 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
747 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
750 if(fSelectEmbeddedClusters){
751 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
752 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
756 //clus->GetPosition(pos);
757 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
759 if(fRecalculateClusters){
760 //Recalibrate the cluster energy
761 if(GetCaloUtils()->IsRecalibrationOn()) {
763 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
766 //printf("Recalibrated Energy %f\n",clus->E());
768 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
769 GetCaloUtils()->RecalculateClusterPID(clus);
773 //Recalculate distance to bad channels, if new list of bad channels provided
774 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
776 //Recalculate cluster position
777 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
778 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
779 //clus->GetPosition(pos);
780 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
785 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn()) {
787 Double_t tof = clus->GetTOF();
789 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
791 if(fDataType==AliCaloTrackReader::kESD){
792 tof = fEMCALCells->GetCellTime(absIdMax);
795 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
799 }// Time recalibration
801 //Correct non linearity
802 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
803 GetCaloUtils()->CorrectClusterEnergy(clus) ;
804 //printf("Linearity Corrected Energy %f\n",clus->E());
806 //In case of MC analysis, to match resolution/calibration in real data
807 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
808 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
809 clus->SetE(rdmEnergy);
812 TLorentzVector momentum ;
814 clus->GetMomentum(momentum, fVertex[vindex]);
816 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return;
818 if(fEMCALPtMin > momentum.E() || fEMCALPtMax < momentum.E()) return;
820 if(fDebug > 2 && momentum.E() > 0.1)
821 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
822 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
827 fEMCALClusters->Add(clus);
831 //____________________________________________________________________________
832 void AliCaloTrackReader::FillInputEMCAL() {
833 //Return array with EMCAL clusters in aod format
835 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
837 // First recalibrate cells, time or energy
838 // if(GetCaloUtils()->IsRecalibrationOn())
839 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
841 // fInputEvent->GetBunchCrossNumber());
843 //Loop to select clusters in fiducial cut and fill container with aodClusters
844 if(fEMCALClustersListName==""){
845 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
846 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
847 AliVCluster * clus = 0;
848 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
849 if (IsEMCALCluster(clus)){
850 FillInputEMCALAlgorithm(clus, iclus);
855 //Recalculate track matching
856 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
858 }//Get the clusters from the input event
860 TClonesArray * clusterList = 0x0;
861 if(fOutputEvent) clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
863 //printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? Try input event <%s>\n",fEMCALClustersListName.Data());
864 //List not in output event, try input event
865 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
867 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
872 Int_t nclusters = clusterList->GetEntriesFast();
873 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
874 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
875 //printf("E %f\n",clus->E());
876 if (clus) FillInputEMCALAlgorithm(clus, iclus);
877 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
881 // Recalculate track matching, not necessary if already done in the reclusterization task.
882 // in case it was not done ...
883 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
887 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());
891 //____________________________________________________________________________
892 void AliCaloTrackReader::FillInputPHOS() {
893 //Return array with PHOS clusters in aod format
895 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
897 //Loop to select clusters in fiducial cut and fill container with aodClusters
898 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
899 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
900 AliVCluster * clus = 0;
901 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
902 if (IsPHOSCluster(clus)){
903 //Check if the cluster contains any bad channel and if close to calorimeter borders
906 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
907 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
909 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
912 if(fRecalculateClusters){
914 //Recalibrate the cluster energy
915 if(GetCaloUtils()->IsRecalibrationOn()) {
916 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
922 TLorentzVector momentum ;
924 clus->GetMomentum(momentum, fVertex[vindex]);
926 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
928 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
930 if(fDebug > 2 && momentum.E() > 0.1)
931 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
932 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
939 fPHOSClusters->Add(clus);
945 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
949 //____________________________________________________________________________
950 void AliCaloTrackReader::FillInputEMCALCells() {
951 //Return array with EMCAL cells in aod format
953 fEMCALCells = fInputEvent->GetEMCALCells();
957 //____________________________________________________________________________
958 void AliCaloTrackReader::FillInputPHOSCells() {
959 //Return array with PHOS cells in aod format
961 fPHOSCells = fInputEvent->GetPHOSCells();
965 //____________________________________________________________________________
966 void AliCaloTrackReader::FillInputVZERO(){
967 //Fill VZERO information in data member, add all the channels information.
968 AliVVZERO* v0 = fInputEvent->GetVZEROData();
969 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
973 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
974 for (Int_t i = 0; i < 32; i++)
976 if(esdV0){//Only available in ESDs
977 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
978 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
980 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
981 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
984 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
989 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
994 //____________________________________________________________________________
995 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const {
996 // Check if it is a cluster from EMCAL. For old AODs cluster type has
997 // different number and need to patch here
999 if(fDataType==kAOD && fOldAOD)
1001 if (cluster->GetType() == 2) return kTRUE;
1006 return cluster->IsEMCAL();
1011 //____________________________________________________________________________
1012 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const {
1013 //Check if it is a cluster from PHOS.For old AODs cluster type has
1014 // different number and need to patch here
1016 if(fDataType==kAOD && fOldAOD)
1018 Int_t type = cluster->GetType();
1019 if (type == 0 || type == 1) return kTRUE;
1024 return cluster->IsPHOS();
1029 //____________________________________________________________________________
1030 Bool_t AliCaloTrackReader::CheckForPrimaryVertex(){
1031 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1034 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
1035 if(!event) return kTRUE;
1037 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {
1041 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {
1043 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {
1044 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
1048 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {
1049 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;