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 ---
32 //---- ANALYSIS system ----
33 #include "AliMCEvent.h"
34 #include "AliAODMCHeader.h"
35 #include "AliGenPythiaEventHeader.h"
36 #include "AliESDEvent.h"
37 #include "AliAODEvent.h"
38 #include "AliVTrack.h"
39 #include "AliVParticle.h"
40 #include "AliMixedEvent.h"
41 #include "AliESDtrack.h"
42 #include "AliESDtrackCuts.h"
43 #include "AliTriggerAnalysis.h"
44 #include "AliESDVZERO.h"
46 //---- PartCorr/EMCAL ---
47 #include "AliEMCALRecoUtils.h"
48 #include "AliCaloTrackReader.h"
50 ClassImp(AliCaloTrackReader)
53 //____________________________________________________________________________
54 AliCaloTrackReader::AliCaloTrackReader() :
55 TObject(), fEventNumber(-1), //fCurrentFileName(""),
56 fDataType(0), fDebug(0),
57 fFiducialCut(0x0), fCheckFidCut(kFALSE), fComparePtHardAndJetPt(kFALSE), fPtHardAndJetPtFactor(7),
58 fCTSPtMin(0), fEMCALPtMin(0),fPHOSPtMin(0),
59 fCTSPtMax(1000), fEMCALPtMax(1000),fPHOSPtMax(1000), fAODBranchList(new TList ),
60 fCTSTracks(new TObjArray()), fEMCALClusters(new TObjArray()), fPHOSClusters(new TObjArray()),
61 fEMCALCells(0x0), fPHOSCells(0x0),
62 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
63 fFillCTS(0),fFillEMCAL(0),fFillPHOS(0),
64 fFillEMCALCells(0),fFillPHOSCells(0), fSelectEmbeddedClusters(kFALSE),
65 fSmearClusterEnergy(kFALSE), fRandom(),
66 fTrackStatus(0), fTrackFilterMask(0), fESDtrackCuts(0), fTrackMult(0), fTrackMultEtaCut(0.8),
67 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
68 fDeltaAODFileName("deltaAODPartCorr.root"),fFiredTriggerClassName(""),
69 fAnaLED(kFALSE),fTaskName(""),fCaloUtils(0x0),
70 fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL),
71 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE),fCaloFilterPatch(kFALSE),
72 fEMCALClustersListName(""),fZvtxCut(0.),
73 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
74 fTriggerAnalysis (new AliTriggerAnalysis), fCentralityClass("V0M"),fCentralityOpt(10),
75 fEventPlaneMethod("Q")
80 //Initialize parameters
84 //_________________________________
85 AliCaloTrackReader::~AliCaloTrackReader() {
91 fAODBranchList->Delete();
92 delete fAODBranchList ;
96 if(fDataType!=kMC)fCTSTracks->Clear() ;
97 else fCTSTracks->Delete() ;
102 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
103 else fEMCALClusters->Delete() ;
104 delete fEMCALClusters ;
108 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
109 else fPHOSClusters->Delete() ;
110 delete fPHOSClusters ;
114 for (Int_t i = 0; i < fNMixedEvent; i++) {
115 delete [] fVertex[i] ;
121 delete fESDtrackCuts;
122 delete fTriggerAnalysis;
124 // Pointers not owned, done by the analysis frame
125 // if(fInputEvent) delete fInputEvent ;
126 // if(fOutputEvent) delete fOutputEvent ;
127 // if(fMC) delete fMC ;
128 // Pointer not owned, deleted by maker
129 // if (fCaloUtils) delete fCaloUtils ;
133 //_________________________________________________________________________
134 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt(){
135 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
137 if(!fReadStack) return kTRUE; //Information not filtered to AOD
139 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader")){
141 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
142 Int_t nTriggerJets = pygeh->NTriggerJets();
143 Float_t ptHard = pygeh->GetPtHard();
145 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
146 Float_t tmpjet[]={0,0,0,0};
147 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
148 pygeh->TriggerJet(ijet, tmpjet);
149 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
150 //Compare jet pT and pt Hard
151 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
152 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard) {
153 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
154 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
165 //____________________________________________________________________________
166 AliStack* AliCaloTrackReader::GetStack() const {
167 //Return pointer to stack
171 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
176 //____________________________________________________________________________
177 AliHeader* AliCaloTrackReader::GetHeader() const {
178 //Return pointer to header
180 return fMC->Header();
182 printf("AliCaloTrackReader::Header is not available\n");
186 //____________________________________________________________________________
187 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const {
188 //Return pointer to Generated event header
190 return fMC->GenEventHeader();
192 printf("AliCaloTrackReader::GenEventHeader is not available\n");
197 //____________________________________________________________________________
198 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const {
199 //Return list of particles in AOD. Do it for the corresponding input event.
201 TClonesArray * rv = NULL ;
202 if(fDataType == kAOD){
206 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
208 rv = (TClonesArray*)evt->FindListObject("mcparticles");
210 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
215 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
221 //____________________________________________________________________________
222 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const {
223 //Return MC header in AOD. Do it for the corresponding input event.
224 AliAODMCHeader *mch = NULL;
225 if(fDataType == kAOD){
228 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
230 // //Second input AOD
231 // else if(input == 1){
232 // mch = (AliAODMCHeader*) fSecondInputAODEvent->FindListObject("mcheader");
235 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
239 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
245 //_______________________________________________________________
246 void AliCaloTrackReader::Init()
248 //Init reader. Method to be called in AliAnaPartCorrMaker
250 if(fReadStack && fReadAODMCParticles){
251 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
253 fReadAODMCParticles = kFALSE;
258 //_______________________________________________________________
259 void AliCaloTrackReader::InitParameters()
261 //Initialize the parameters of the analysis.
267 fEMCALPtMax = 1000. ;
270 //Do not filter the detectors input by default.
274 fFillEMCALCells = kFALSE;
275 fFillPHOSCells = kFALSE;
277 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
278 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
279 fDeltaAODFileName = "deltaAODPartCorr.root";
280 fFiredTriggerClassName = "";
284 //We want tracks fitted in the detectors:
285 //fTrackStatus=AliESDtrack::kTPCrefit;
286 //fTrackStatus|=AliESDtrack::kITSrefit;
287 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
289 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
291 fV0ADC[0] = 0; fV0ADC[1] = 0;
292 fV0Mul[0] = 0; fV0Mul[1] = 0;
297 fCentralityBin[0]=fCentralityBin[1]=-1;
300 fSmearClusterEnergy = kFALSE;
301 fSmearClusterParam[0] = 0.07; // * sqrt E term
302 fSmearClusterParam[1] = 0.02; // * E term
303 fSmearClusterParam[2] = 0.00; // constant
307 //________________________________________________________________
308 void AliCaloTrackReader::Print(const Option_t * opt) const
311 //Print some relevant parameters set for the analysis
315 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
316 printf("Task name : %s\n", fTaskName.Data()) ;
317 printf("Data type : %d\n", fDataType) ;
318 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
319 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
320 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
321 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
322 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
323 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
324 printf("Use CTS = %d\n", fFillCTS) ;
325 printf("Use EMCAL = %d\n", fFillEMCAL) ;
326 printf("Use PHOS = %d\n", fFillPHOS) ;
327 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
328 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
329 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
330 printf("Track filter mask (AODs) = %d\n", (Int_t) fTrackFilterMask) ;
331 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
332 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
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( fFiredTriggerClassName !="" && !fAnaLED){
362 return kFALSE; //Only physics event, do not use for simulated events!!!
364 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
365 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
366 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
367 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
370 // kStartOfRun = 1, // START_OF_RUN
371 // kEndOfRun = 2, // END_OF_RUN
372 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
373 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
374 // kStartOfBurst = 5, // START_OF_BURST
375 // kEndOfBurst = 6, // END_OF_BURST
376 // kPhysicsEvent = 7, // PHYSICS_EVENT
377 // kCalibrationEvent = 8, // CALIBRATION_EVENT
378 // kFormatError = 9, // EVENT_FORMAT_ERROR
379 // kStartOfData = 10, // START_OF_DATA
380 // kEndOfData = 11, // END_OF_DATA
381 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
382 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
384 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
385 if(eventType!=8)return kFALSE;
388 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
389 if(fComparePtHardAndJetPt && GetStack()) {
390 if(!ComparePtHardAndJetPt()) return kFALSE ;
395 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
396 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
398 //------------------------------------------------------
399 //Event rejection depending on vertex, pileup, v0and
400 //------------------------------------------------------
401 if(fDoEventSelection){
402 if(!fCaloFilterPatch){
403 //Do not analyze events with pileup
404 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
405 //Bool_t bPileup = event->IsPileupFromSPD();
406 if(bPileup) return kFALSE;
408 if(fDoV0ANDEventSelection){
409 Bool_t bV0AND = kTRUE;
410 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
412 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
413 //else bV0AND = //FIXME FOR AODs
414 if(!bV0AND) return kFALSE;
417 if(fUseEventsWithPrimaryVertex && !CheckForPrimaryVertex()) return kFALSE;
421 if(fInputEvent->GetNumberOfCaloClusters() > 0) {
422 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
423 if(calo->GetNLabels() == 4){
424 Int_t * selection = calo->GetLabels();
425 Bool_t bPileup = selection[0];
426 if(bPileup) return kFALSE;
428 Bool_t bGoodV = selection[1];
429 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
431 if(fDoV0ANDEventSelection){
432 Bool_t bV0AND = selection[2];
433 if(!bV0AND) return kFALSE;
436 fTrackMult = selection[3];
437 if(fTrackMult == 0) return kFALSE;
439 //First filtered AODs, track multiplicity stored there.
440 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
441 if(fTrackMult == 0) return kFALSE;
443 }//at least one cluster
445 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
446 //Remove events with vertex (0,0,0), bad vertex reconstruction
447 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;
449 //First filtered AODs, track multiplicity stored there.
450 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
451 if(fTrackMult == 0) return kFALSE;
453 }// CaloFileter patch
455 //------------------------------------------------------
457 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
458 //If we need a centrality bin, we select only those events in the corresponding bin.
459 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100){
460 Int_t cen = GetEventCentrality();
461 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
464 //Fill the arrays with cluster/tracks/cells data
466 FillInputEMCALCells();
468 FillInputPHOSCells();
472 //Accept events with at least one track
473 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
486 //__________________________________________________
487 void AliCaloTrackReader::ResetLists() {
488 // Reset lists, called by the analysis maker
490 if(fCTSTracks) fCTSTracks -> Clear();
491 if(fEMCALClusters) fEMCALClusters -> Clear("C");
492 if(fPHOSClusters) fPHOSClusters -> Clear("C");
493 // if(fEMCALCells) fEMCALCells -> Clear("");
494 // if(fPHOSCells) fPHOSCells -> Clear("");
496 fV0ADC[0] = 0; fV0ADC[1] = 0;
497 fV0Mul[0] = 0; fV0Mul[1] = 0;
501 //____________________________________________________________________________
502 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
505 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
507 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
510 //Delete previous vertex
512 for (Int_t i = 0; i < fNMixedEvent; i++) {
513 delete [] fVertex[i] ;
518 fVertex = new Double_t*[fNMixedEvent] ;
519 for (Int_t i = 0; i < fNMixedEvent; i++) {
520 fVertex[i] = new Double_t[3] ;
521 fVertex[i][0] = 0.0 ;
522 fVertex[i][1] = 0.0 ;
523 fVertex[i][2] = 0.0 ;
527 //__________________________________________________
528 Int_t AliCaloTrackReader::GetEventCentrality() const {
529 //Return current event centrality
532 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
533 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
534 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
536 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
544 //____________________________________________________________________________
545 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const {
546 //Return vertex position to be used for single event analysis
547 vertex[0]=fVertex[0][0];
548 vertex[1]=fVertex[0][1];
549 vertex[2]=fVertex[0][2];
552 //____________________________________________________________________________
553 void AliCaloTrackReader::GetVertex(Double_t vertex[3], const Int_t evtIndex) const {
554 //Return vertex position for mixed event, recover the vertex in a particular event.
556 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
560 //____________________________________________________________________________
561 void AliCaloTrackReader::FillVertexArray() {
563 //Fill data member with vertex
564 //In case of Mixed event, multiple vertices
566 //Delete previous vertex
568 for (Int_t i = 0; i < fNMixedEvent; i++) {
569 delete [] fVertex[i] ;
574 fVertex = new Double_t*[fNMixedEvent] ;
575 for (Int_t i = 0; i < fNMixedEvent; i++) {
576 fVertex[i] = new Double_t[3] ;
577 fVertex[i][0] = 0.0 ;
578 fVertex[i][1] = 0.0 ;
579 fVertex[i][2] = 0.0 ;
582 if (!fMixedEvent) { //Single event analysis
585 if(fInputEvent->GetPrimaryVertex()){
586 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
589 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
590 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
591 }//Primary vertex pointer do not exist
593 } else {//MC read event
594 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
598 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
600 } else { // MultiEvent analysis
601 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
602 if (fMixedEvent->GetVertexOfEvent(iev))
603 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
604 else { // no vertex found !!!!
605 AliWarning("No vertex found");
609 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
616 //____________________________________________________________________________
617 void AliCaloTrackReader::FillInputCTS() {
618 //Return array with Central Tracking System (CTS) tracks
620 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
622 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
626 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
627 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
629 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
630 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
635 if (fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track))
639 else if(fDataType==kAOD)
641 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
644 printf("AliCaloTrackReader::FillInputCTS():AOD track type: %c \n", aodtrack->GetType());
645 if (fDataType!=kMC && aodtrack->TestFilterMask(fTrackFilterMask)==kFALSE) continue;
646 if(aodtrack->GetType()!=AliAODTrack::kPrimary) continue;
650 //Count the tracks in eta < 0.9
651 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
652 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
654 track->GetPxPyPz(p) ;
655 TLorentzVector momentum(p[0],p[1],p[2],0);
657 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt()){
659 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
662 if(fDebug > 2 && momentum.Pt() > 0.1)
663 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
664 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
667 track->SetID(itrack);
670 fCTSTracks->Add(track);
672 }//Pt and Fiducial cut passed.
675 //fCTSTracksNormalInputEntries = fCTSTracks->GetEntriesFast();
677 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
681 //____________________________________________________________________________
682 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, const Int_t iclus) {
683 //Fill the EMCAL data in the array, do it
687 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
690 //Reject clusters with bad channels, close to borders and exotic;
691 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells())) return;
692 // //Check if the cluster contains any bad channel and if close to calorimeter borders
693 // if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells()))
695 // if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex))
699 //Mask all cells in collumns facing ALICE thick material if requested
700 if(GetCaloUtils()->GetNMaskCellColumns()){
705 Bool_t shared = kFALSE;
706 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
707 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
710 if(fSelectEmbeddedClusters){
711 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
712 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
715 TLorentzVector momentum ;
717 clus->GetMomentum(momentum, fVertex[vindex]);
719 if(fEMCALPtMin < momentum.E() && fEMCALPtMax > momentum.E()){
721 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL"))
724 if(fDebug > 2 && momentum.E() > 0.1)
725 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
726 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
729 //clus->GetPosition(pos);
730 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
732 //Recalibrate the cluster energy
733 if(GetCaloUtils()->IsRecalibrationOn()) {
734 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
736 //printf("Recalibrated Energy %f\n",clus->E());
737 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
738 GetCaloUtils()->RecalculateClusterPID(clus);
741 //Recalculate distance to bad channels, if new list of bad channels provided
742 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
744 //Recalculate cluster position
745 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
746 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
747 //clus->GetPosition(pos);
748 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
751 //Correct non linearity
752 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
753 GetCaloUtils()->CorrectClusterEnergy(clus) ;
754 //printf("Linearity Corrected Energy %f\n",clus->E());
757 //In case of MC analysis, to match resolution/calibration in real data
758 if(fSmearClusterEnergy){
759 Float_t energy = clus->E();
760 Float_t rdmEnergy = fRandom.Gaus(energy,fSmearClusterParam[0]*TMath::Sqrt(energy)+
761 fSmearClusterParam[1]*energy+fSmearClusterParam[2]);
762 clus->SetE(rdmEnergy);
763 if(fDebug > 2) printf("\t Energy %f, smeared %f\n", energy, clus->E());
769 fEMCALClusters->Add(clus);
773 //____________________________________________________________________________
774 void AliCaloTrackReader::FillInputEMCAL() {
775 //Return array with EMCAL clusters in aod format
777 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
779 //Loop to select clusters in fiducial cut and fill container with aodClusters
780 if(fEMCALClustersListName==""){
781 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
782 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
783 AliVCluster * clus = 0;
784 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
785 if (IsEMCALCluster(clus)){
786 FillInputEMCALAlgorithm(clus, iclus);
791 //Recalculate track matching
792 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
794 }//Get the clusters from the input event
796 TClonesArray * clusterList = 0x0;
797 if(fOutputEvent) clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
799 //printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? Try input event <%s>\n",fEMCALClustersListName.Data());
800 //List not in output event, try input event
801 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
803 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
807 Int_t nclusters = clusterList->GetEntriesFast();
808 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
809 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
810 //printf("E %f\n",clus->E());
811 if (clus) FillInputEMCALAlgorithm(clus, iclus);
812 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
816 //Recalculate track matching, not necessary, already done in the reclusterization task
817 //GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
821 //fEMCALClustersNormalInputEntries = fEMCALClusters->GetEntriesFast();
822 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());//fEMCALClustersNormalInputEntries);
826 //____________________________________________________________________________
827 void AliCaloTrackReader::FillInputPHOS() {
828 //Return array with PHOS clusters in aod format
830 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
832 //Loop to select clusters in fiducial cut and fill container with aodClusters
833 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
834 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
835 AliVCluster * clus = 0;
836 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
837 if (IsPHOSCluster(clus)){
838 //Check if the cluster contains any bad channel and if close to calorimeter borders
841 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
842 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
844 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
847 TLorentzVector momentum ;
849 clus->GetMomentum(momentum, fVertex[vindex]);
851 if(fPHOSPtMin < momentum.E() && fPHOSPtMax > momentum.E()){
853 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS"))
856 if(fDebug > 2 && momentum.E() > 0.1)
857 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
858 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
860 //Recalibrate the cluster energy
861 if(GetCaloUtils()->IsRecalibrationOn()) {
862 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
870 fPHOSClusters->Add(clus);
872 }//Pt and Fiducial cut passed.
877 //fPHOSClustersNormalInputEntries = fPHOSClusters->GetEntriesFast() ;
878 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());//fPHOSClustersNormalInputEntries);
882 //____________________________________________________________________________
883 void AliCaloTrackReader::FillInputEMCALCells() {
884 //Return array with EMCAL cells in aod format
886 fEMCALCells = fInputEvent->GetEMCALCells();
890 //____________________________________________________________________________
891 void AliCaloTrackReader::FillInputPHOSCells() {
892 //Return array with PHOS cells in aod format
894 fPHOSCells = fInputEvent->GetPHOSCells();
898 //____________________________________________________________________________
899 void AliCaloTrackReader::FillInputVZERO(){
900 //Fill VZERO information in data member, add all the channels information.
901 AliVVZERO* v0 = fInputEvent->GetVZEROData();
902 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
906 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
907 for (Int_t i = 0; i < 32; i++)
909 if(esdV0){//Only available in ESDs
910 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
911 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
913 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
914 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
917 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
922 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
927 //____________________________________________________________________________
928 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const {
929 // Check if it is a cluster from EMCAL. For old AODs cluster type has
930 // different number and need to patch here
932 if(fDataType==kAOD && fOldAOD)
934 if (cluster->GetType() == 2) return kTRUE;
939 return cluster->IsEMCAL();
944 //____________________________________________________________________________
945 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const {
946 //Check if it is a cluster from PHOS.For old AODs cluster type has
947 // different number and need to patch here
949 if(fDataType==kAOD && fOldAOD)
951 Int_t type = cluster->GetType();
952 if (type == 0 || type == 1) return kTRUE;
957 return cluster->IsPHOS();
962 //____________________________________________________________________________
963 Bool_t AliCaloTrackReader::CheckForPrimaryVertex(){
964 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
967 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
968 if(!event) return kTRUE;
970 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {
974 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {
976 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {
977 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
981 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {
982 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;