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>
30 #include <TStreamerInfo.h>
32 // ---- ANALYSIS system ----
33 #include "AliMCEvent.h"
34 #include "AliAODMCHeader.h"
35 #include "AliGenPythiaEventHeader.h"
36 #include "AliGenCocktailEventHeader.h"
37 #include "AliGenHijingEventHeader.h"
38 #include "AliESDEvent.h"
39 #include "AliAODEvent.h"
40 #include "AliVTrack.h"
41 #include "AliVParticle.h"
42 #include "AliMixedEvent.h"
43 //#include "AliTriggerAnalysis.h"
44 #include "AliESDVZERO.h"
45 #include "AliVCaloCells.h"
46 #include "AliAnalysisManager.h"
47 #include "AliInputEventHandler.h"
48 #include "AliAODMCParticle.h"
51 // ---- Detectors ----
52 #include "AliPHOSGeoUtils.h"
53 #include "AliEMCALGeometry.h"
54 #include "AliEMCALRecoUtils.h"
56 // ---- CaloTrackCorr ---
57 #include "AliCalorimeterUtils.h"
58 #include "AliCaloTrackReader.h"
60 #include "AliAODJet.h"
61 #include "AliAODJetEventBackground.h"
63 ClassImp(AliCaloTrackReader)
66 //________________________________________
67 AliCaloTrackReader::AliCaloTrackReader() :
68 TObject(), fEventNumber(-1), //fCurrentFileName(""),
69 fDataType(0), fDebug(0),
70 fFiducialCut(0x0), fCheckFidCut(kFALSE),
71 fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(0),
72 fComparePtHardAndClusterPt(0),fPtHardAndClusterPtFactor(0),
73 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
74 fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
75 fUseEMCALTimeCut(1), fUseParamTimeCut(0),
76 fUseTrackTimeCut(0), fAccessTrackTOF(0),
77 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
78 fEMCALParamTimeCutMin(), fEMCALParamTimeCutMax(),
79 fTrackTimeCutMin(-10000), fTrackTimeCutMax(10000),
82 fCTSTracks(0x0), fEMCALClusters(0x0),
83 fDCALClusters(0x0), fPHOSClusters(0x0),
84 fEMCALCells(0x0), fPHOSCells(0x0),
85 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
86 fFillCTS(0), fFillEMCAL(0),
87 fFillDCAL(0), fFillPHOS(0),
88 fFillEMCALCells(0), fFillPHOSCells(0),
89 fRecalculateClusters(kFALSE),fCorrectELinearity(kTRUE),
90 fSelectEmbeddedClusters(kFALSE),
91 fTrackStatus(0), fSelectSPDHitTracks(0),
92 fTrackMult(0), fTrackMultEtaCut(0.9),
93 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
94 fDeltaAODFileName(""), fFiredTriggerClassName(""),
96 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
97 fEventTrigMinBias(0), fEventTrigCentral(0),
98 fEventTrigSemiCentral(0), fEventTrigEMCALL0(0),
99 fEventTrigEMCALL1Gamma1(0), fEventTrigEMCALL1Gamma2(0),
100 fEventTrigEMCALL1Jet1(0), fEventTrigEMCALL1Jet2(0),
101 fBitEGA(0), fBitEJE(0),
104 fTaskName(""), fCaloUtils(0x0),
105 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
106 fListMixedTracksEvents(), fListMixedCaloEvents(),
107 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
108 fWriteOutputDeltaAOD(kFALSE),
109 fEMCALClustersListName(""), fZvtxCut(0.),
110 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
112 fRemoveBadTriggerEvents(0), fTriggerPatchClusterMatch(1),
113 fTriggerPatchTimeWindow(), fTriggerL0EventThreshold(0),
114 fTriggerL1EventThreshold(0), fTriggerL1EventThresholdFix(0),
115 fTriggerClusterBC(0), fTriggerClusterIndex(0), fTriggerClusterId(0),
116 fIsExoticEvent(0), fIsBadCellEvent(0), fIsBadMaxCellEvent(0),
117 fIsTriggerMatch(0), fIsTriggerMatchOpenCut(),
118 fTriggerClusterTimeRecal(kTRUE), fRemoveUnMatchedTriggers(kTRUE),
119 fDoPileUpEventRejection(kFALSE), fDoV0ANDEventSelection(kFALSE),
120 fDoVertexBCEventSelection(kFALSE),
121 fDoRejectNoTrackEvents(kFALSE),
122 fUseEventsWithPrimaryVertex(kFALSE),
123 //fTriggerAnalysis (0x0),
124 fTimeStampEventSelect(0),
125 fTimeStampEventFracMin(0), fTimeStampEventFracMax(0),
126 fTimeStampRunMin(0), fTimeStampRunMax(0),
127 fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
128 fVertexBC(-200), fRecalculateVertexBC(0),
129 fCentralityClass(""), fCentralityOpt(0),
130 fEventPlaneMethod(""),
131 fAcceptOnlyHIJINGLabels(0), fNMCProducedMin(0), fNMCProducedMax(0),
132 fFillInputNonStandardJetBranch(kFALSE),
133 fNonStandardJets(new TClonesArray("AliAODJet",100)),fInputNonStandardJetBranchName("jets"),
134 fFillInputBackgroundJetBranch(kFALSE),
135 fBackgroundJets(0x0),fInputBackgroundJetBranchName("jets"),
136 fAcceptEventsWithBit(0), fRejectEventsWithBit(0), fRejectEMCalTriggerEventsWith2Tresholds(0),
141 //Initialize parameters
144 //_______________________________________
145 AliCaloTrackReader::~AliCaloTrackReader()
151 //_______________________________________
152 void AliCaloTrackReader::DeletePointers()
156 delete fFiducialCut ;
160 fAODBranchList->Delete();
161 delete fAODBranchList ;
166 if(fDataType!=kMC)fCTSTracks->Clear() ;
167 else fCTSTracks->Delete() ;
173 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
174 else fEMCALClusters->Delete() ;
175 delete fEMCALClusters ;
180 if(fDataType!=kMC)fDCALClusters->Clear("C") ;
181 else fDCALClusters->Delete() ;
182 delete fDCALClusters ;
187 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
188 else fPHOSClusters->Delete() ;
189 delete fPHOSClusters ;
194 for (Int_t i = 0; i < fNMixedEvent; i++)
196 delete [] fVertex[i] ;
202 //delete fTriggerAnalysis;
206 if(fDataType!=kMC) fNonStandardJets->Clear("C") ;
207 else fNonStandardJets->Delete() ;
208 delete fNonStandardJets ;
210 delete fBackgroundJets ;
212 fRejectEventsWithBit.Reset();
213 fAcceptEventsWithBit.Reset();
215 // Pointers not owned, done by the analysis frame
216 // if(fInputEvent) delete fInputEvent ;
217 // if(fOutputEvent) delete fOutputEvent ;
218 // if(fMC) delete fMC ;
219 // Pointer not owned, deleted by maker
220 // if (fCaloUtils) delete fCaloUtils ;
224 //________________________________________________________________________
225 Bool_t AliCaloTrackReader::AcceptDCA(Float_t pt, Float_t dca)
227 // Accept track if DCA is smaller than function
229 Float_t cut = fTrackDCACut[0]+fTrackDCACut[1]/TMath::Power(pt,fTrackDCACut[2]);
231 if(TMath::Abs(dca) < cut)
238 //_____________________________________________________
239 Bool_t AliCaloTrackReader::AcceptEventWithTriggerBit()
241 // Accept events that pass the physics selection
242 // depending on an array of trigger bits set during the configuration
244 Int_t nAccept = fAcceptEventsWithBit.GetSize();
246 //printf("N accept %d\n", nAccept);
249 return kTRUE ; // accept the event
251 UInt_t trigFired = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
253 for(Int_t ibit = 0; ibit < nAccept; ibit++)
255 Bool_t accept = (trigFired & fAcceptEventsWithBit.At(ibit));
257 //printf("accept %d, ibit %d, bit %d \n",accept, ibit,fAcceptEventsWithBit.At(ibit));
258 if(accept) return kTRUE ; // accept the event
261 return kFALSE ; // reject the event
265 //_____________________________________________________
266 Bool_t AliCaloTrackReader::RejectEventWithTriggerBit()
268 // Reject events that pass the physics selection
269 // depending on an array of trigger bits set during the configuration
271 Int_t nReject = fRejectEventsWithBit.GetSize();
273 //printf("N reject %d\n", nReject);
276 return kTRUE ; // accept the event
278 UInt_t trigFired = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
280 for(Int_t ibit = 0; ibit < nReject; ibit++)
282 Bool_t reject = (trigFired & fRejectEventsWithBit.At(ibit));
284 //printf("reject %d, ibit %d, bit %d \n",reject, ibit,fRejectEventsWithBit.At(ibit));
285 if(reject) return kFALSE ; // reject the event
288 return kTRUE ; // accept the event
292 //_____________________________________________
293 Bool_t AliCaloTrackReader::CheckEventTriggers()
295 // Do different selection of the event
296 // depending on trigger name, event type, goodness of the EMCal trigger ...
298 //-----------------------------------------------------------
299 // Reject events depending on the trigger name and event type
300 //-----------------------------------------------------------
303 if(fInputEvent->GetHeader())
304 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
306 if( fFiredTriggerClassName !="" && !fAnaLED)
308 //printf("Event type %d\n",eventType);
310 return kFALSE; //Only physics event, do not use for simulated events!!!
313 printf("AliCaloTrackReader::CheckEventTriggers() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
314 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
316 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
317 else if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Accepted triggered event\n");
321 // kStartOfRun = 1, // START_OF_RUN
322 // kEndOfRun = 2, // END_OF_RUN
323 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
324 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
325 // kStartOfBurst = 5, // START_OF_BURST
326 // kEndOfBurst = 6, // END_OF_BURST
327 // kPhysicsEvent = 7, // PHYSICS_EVENT
328 // kCalibrationEvent = 8, // CALIBRATION_EVENT
329 // kFormatError = 9, // EVENT_FORMAT_ERROR
330 // kStartOfData = 10, // START_OF_DATA
331 // kEndOfData = 11, // END_OF_DATA
332 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
333 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
335 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::CheckEventTriggers() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
336 if(eventType!=8)return kFALSE;
339 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass Trigger name rejection \n");
341 //-----------------------------------------------------------------
342 // In case of mixing analysis, select here the trigger of the event
343 //-----------------------------------------------------------------
344 UInt_t isTrigger = kFALSE;
345 UInt_t isMB = kFALSE;
346 if(!fEventTriggerAtSE)
348 // In case of mixing analysis, accept MB events, not only Trigger
349 // Track and cluster arrays filled for MB in order to create the pool in the corresponding analysis
350 // via de method in the base class FillMixedEventPool()
352 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
353 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
355 if(!inputHandler) return kFALSE ; // to content coverity
357 isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
358 isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
360 if(!isTrigger && !isMB) return kFALSE;
362 //printf("Selected triggered event : %s\n",GetFiredTriggerClasses().Data());
363 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass uninteresting triggered events rejection in case of mixing analysis \n");
366 //-------------------------------------------------------------------------------------
367 // Reject or accept events depending on the trigger bit
368 //-------------------------------------------------------------------------------------
370 Bool_t okA = AcceptEventWithTriggerBit();
371 Bool_t okR = RejectEventWithTriggerBit();
373 //printf("AliCaloTrackReader::FillInputEvent() - Accept event? %d, Reject event %d? \n",okA,okR);
375 if(!okA || !okR) return kFALSE;
377 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass event bit rejection \n");
379 //----------------------------------------------------------------------
380 // Do not count events that were likely triggered by an exotic cluster
382 //----------------------------------------------------------------------
384 // Set a bit with the event kind, MB, L0, L1 ...
385 SetEventTriggerBit();
387 // In case of Mixing, avoid checking the triggers in the min bias events
388 if(!fEventTriggerAtSE && (isMB && !isTrigger)) return kTRUE;
390 if( (IsEventEMCALL1() || IsEventEMCALL0()) && fTriggerPatchClusterMatch)
392 if(fRejectEMCalTriggerEventsWith2Tresholds)
394 // Reject triggered events when there is coincidence on both EMCal trigger thresholds,
395 // but the requested trigger is the low trigger threshold
396 if(IsEventEMCALL1Jet1 () && IsEventEMCALL1Jet2 () && fFiredTriggerClassName.Contains("EJ2")) return kFALSE;
397 if(IsEventEMCALL1Gamma1() && IsEventEMCALL1Gamma2() && fFiredTriggerClassName.Contains("EG2")) return kFALSE;
400 //Get Patches that triggered
401 TArrayI patches = GetTriggerPatches(fTriggerPatchTimeWindow[0],fTriggerPatchTimeWindow[1]);
403 MatchTriggerCluster(patches);
407 // If requested, remove badly triggeed events, but only when the EMCal trigger bit is set
408 if(fRemoveBadTriggerEvents)
411 printf("AliCaloTrackReader::CheckEventTriggers() - ACCEPT triggered event? \n exotic? %d - bad cell %d - bad Max cell %d - BC %d - Matched %d\n",
412 fIsExoticEvent,fIsBadCellEvent, fIsBadMaxCellEvent, fTriggerClusterBC,fIsTriggerMatch);
413 if (fIsExoticEvent) return kFALSE;
414 else if(fIsBadCellEvent) return kFALSE;
415 else if(fRemoveUnMatchedTriggers && !fIsTriggerMatch) return kFALSE ;
416 else if(fTriggerClusterBC != 0) return kFALSE;
417 if(fDebug > 0) printf("\t *** YES for %s\n",GetFiredTriggerClasses().Data());
420 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass EMCal triggered event rejection \n");
423 //-------------------------------------------------------------------------------------
424 //Select events only fired by a certain trigger configuration if it is provided
425 //-------------------------------------------------------------------------------------
426 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
428 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
432 //-------------------------------------------------------------------------------------
433 // Reject event if large clusters with large energy
434 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
435 // If clusterzer NxN or V2 it does not help
436 //-------------------------------------------------------------------------------------
437 Int_t run = fInputEvent->GetRunNumber();
438 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
440 Bool_t reject = RejectLEDEvents();
442 if(reject) return kFALSE;
444 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass LED event rejection \n");
446 }// Remove LED events
451 //________________________________________________
452 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
454 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
457 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
459 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
462 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
463 Int_t nTriggerJets = pygeh->NTriggerJets();
464 Float_t ptHard = pygeh->GetPtHard();
467 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
469 Float_t tmpjet[]={0,0,0,0};
470 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
472 pygeh->TriggerJet(ijet, tmpjet);
473 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
476 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
478 //Compare jet pT and pt Hard
479 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
481 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
482 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
494 //____________________________________________________________________
495 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
497 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
500 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
502 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
503 Float_t ptHard = pygeh->GetPtHard();
505 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
506 for (Int_t iclus = 0; iclus < nclusters; iclus++)
508 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
509 Float_t ecluster = clus->E();
511 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
513 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
525 //____________________________________________
526 AliStack* AliCaloTrackReader::GetStack() const
528 //Return pointer to stack
533 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
538 //______________________________________________
539 AliHeader* AliCaloTrackReader::GetHeader() const
541 //Return pointer to header
544 return fMC->Header();
548 printf("AliCaloTrackReader::Header is not available\n");
553 //____________________________________________________
554 void AliCaloTrackReader::SetGeneratorMinMaxParticles()
556 // In case of access only to hijing particles in cocktail
557 // get the min and max labels
558 // TODO: Check when generator is not the first one ...
563 if (ReadStack() && fMC)
565 AliGenEventHeader * eventHeader = fMC->GenEventHeader();
567 if(!fAcceptOnlyHIJINGLabels) return ;
569 // TODO Check if it works from here ...
571 AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
573 if(!cocktail) return ;
575 TList *genHeaders = cocktail->GetHeaders();
577 Int_t nGenerators = genHeaders->GetEntries();
578 //printf("N generators %d \n", nGenerators);
580 for(Int_t igen = 0; igen < nGenerators; igen++)
582 AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
583 TString name = eventHeader2->GetName();
585 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
587 fNMCProducedMin = fNMCProducedMax;
588 fNMCProducedMax+= eventHeader2->NProduced();
590 if(name.Contains("Hijing",TString::kIgnoreCase)) return ;
594 else if(ReadAODMCParticles() && GetAODMCHeader())
596 Int_t nGenerators = GetAODMCHeader()->GetNCocktailHeaders();
597 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",nGenerators);
599 if( nGenerators <= 0) return ;
601 if(!fAcceptOnlyHIJINGLabels) return ;
603 for(Int_t igen = 0; igen < nGenerators; igen++)
605 AliGenEventHeader * eventHeader = GetAODMCHeader()->GetCocktailHeader(igen) ;
606 TString name = eventHeader->GetName();
608 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader->ClassName(), name.Data(), eventHeader->GetTitle());
610 fNMCProducedMin = fNMCProducedMax;
611 fNMCProducedMax+= eventHeader->NProduced();
613 if(name.Contains("Hijing",TString::kIgnoreCase)) return ;
620 //______________________________________________________________
621 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
623 // Return pointer to Generated event header
624 // If requested and cocktail, search for the hijing generator
626 if (ReadStack() && fMC)
628 AliGenEventHeader * eventHeader = fMC->GenEventHeader();
630 if(!fAcceptOnlyHIJINGLabels) return eventHeader ;
632 // TODO Check if it works from here ...
634 AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
636 if(!cocktail) return 0x0 ;
638 TList *genHeaders = cocktail->GetHeaders();
640 Int_t nGenerators = genHeaders->GetEntries();
641 //printf("N generators %d \n", nGenerators);
643 for(Int_t igen = 0; igen < nGenerators; igen++)
645 AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
646 TString name = eventHeader2->GetName();
648 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
650 if(name.Contains("Hijing",TString::kIgnoreCase)) return eventHeader2 ;
656 else if(ReadAODMCParticles() && GetAODMCHeader())
658 Int_t nGenerators = GetAODMCHeader()->GetNCocktailHeaders();
659 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",nGenerators);
661 if( nGenerators <= 0) return 0x0;
663 if(!fAcceptOnlyHIJINGLabels) return GetAODMCHeader()->GetCocktailHeader(0);
665 for(Int_t igen = 0; igen < nGenerators; igen++)
667 AliGenEventHeader * eventHeader = GetAODMCHeader()->GetCocktailHeader(igen) ;
668 TString name = eventHeader->GetName();
670 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader->ClassName(), name.Data(), eventHeader->GetTitle());
672 if(name.Contains("Hijing",TString::kIgnoreCase)) return eventHeader ;
680 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
685 //_________________________________________________________
686 TClonesArray* AliCaloTrackReader::GetAODMCParticles() const
688 //Return list of particles in AOD, implemented in AliCaloTrackAODReader.
690 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
695 //________________________________________________________
696 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
698 //Return MC header in AOD, implemented in AliCaloTrackAODReader.
700 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
705 //___________________________________________________________
706 Int_t AliCaloTrackReader::GetVertexBC(const AliVVertex * vtx)
710 Int_t vertexBC=vtx->GetBC();
711 if(!fRecalculateVertexBC) return vertexBC;
713 // In old AODs BC not stored, recalculate it
714 // loop over the global track and select those which have small DCA to primary vertex (e.g. primary).
715 // If at least one of these primaries has valid BC != 0, then this vertex is a pile-up candidate.
717 Double_t bz = fInputEvent->GetMagneticField();
719 Int_t ntr = GetCTSTracks()->GetEntriesFast();
720 //printf("N Tracks %d\n",ntr);
722 for(Int_t i = 0 ; i < ntr ; i++)
724 AliVTrack * track = (AliVTrack*) (GetCTSTracks()->At(i));
726 //Check if has TOF info, if not skip
727 ULong_t status = track->GetStatus();
728 Bool_t okTOF = (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ;
729 vertexBC = track->GetTOFBunchCrossing(bz);
730 Float_t pt = track->Pt();
735 Double_t dca[2] = {1e6,1e6};
736 Double_t covar[3] = {1e6,1e6,1e6};
737 track->PropagateToDCA(vtx,bz,100.,dca,covar);
739 if(AcceptDCA(pt,dca[0]))
741 if (vertexBC !=0 && fVertexBC != AliVTrack::kTOFBCNA) return vertexBC;
742 else if(vertexBC == 0) bc0 = kTRUE;
746 if( bc0 ) vertexBC = 0 ;
747 else vertexBC = AliVTrack::kTOFBCNA ;
753 //_____________________________
754 void AliCaloTrackReader::Init()
756 //Init reader. Method to be called in AliAnaCaloTrackCorrMaker
758 if(fReadStack && fReadAODMCParticles)
760 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
762 fReadAODMCParticles = kFALSE;
766 //_______________________________________
767 void AliCaloTrackReader::InitParameters()
769 //Initialize the parameters of the analysis.
775 fEMCALPtMax = 1000. ;
779 // dca_xy cut = 0.0105+0.0350/TMath::Power(pt,1.1);
780 fTrackDCACut[0] = 0.0105;
781 fTrackDCACut[1] = 0.0350;
782 fTrackDCACut[2] = 1.1;
784 //Do not filter the detectors input by default.
789 fFillEMCALCells = kFALSE;
790 fFillPHOSCells = kFALSE;
792 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
793 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
794 fDeltaAODFileName = "deltaAODPartCorr.root";
795 fFiredTriggerClassName = "";
796 fEventTriggerMask = AliVEvent::kAny;
797 fMixEventTriggerMask = AliVEvent::kAnyINT;
798 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
800 fAcceptFastCluster = kTRUE;
803 //We want tracks fitted in the detectors:
804 //fTrackStatus=AliESDtrack::kTPCrefit;
805 //fTrackStatus|=AliESDtrack::kITSrefit;
808 fV0ADC[0] = 0; fV0ADC[1] = 0;
809 fV0Mul[0] = 0; fV0Mul[1] = 0;
815 fPtHardAndJetPtFactor = 7.;
816 fPtHardAndClusterPtFactor = 1.;
819 fCentralityClass = "V0M";
820 fCentralityOpt = 100;
821 fCentralityBin[0] = fCentralityBin[1]=-1;
823 fEventPlaneMethod = "V0";
825 // Allocate memory (not sure this is the right place)
826 fCTSTracks = new TObjArray();
827 fEMCALClusters = new TObjArray();
828 fDCALClusters = new TObjArray();
829 fPHOSClusters = new TObjArray();
830 //fTriggerAnalysis = new AliTriggerAnalysis;
831 fAODBranchList = new TList ;
833 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
834 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
836 // Parametrized time cut (LHC11d)
837 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
838 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
840 // Parametrized time cut (LHC11c)
841 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
842 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
844 fTimeStampRunMin = -1;
845 fTimeStampRunMax = 1e12;
846 fTimeStampEventFracMin = -1;
847 fTimeStampEventFracMax = 2;
849 for(Int_t i = 0; i < 19; i++)
851 fEMCalBCEvent [i] = 0;
852 fEMCalBCEventCut[i] = 0;
853 fTrackBCEvent [i] = 0;
854 fTrackBCEventCut[i] = 0;
857 // Trigger match-rejection
858 fTriggerPatchTimeWindow[0] = 8;
859 fTriggerPatchTimeWindow[1] = 9;
861 fTriggerClusterBC = -10000 ;
862 fTriggerL0EventThreshold = 2.;
863 fTriggerL1EventThreshold = 4.;
864 fTriggerClusterIndex = -1;
865 fTriggerClusterId = -1;
868 fInputNonStandardJetBranchName = "jets";
869 fFillInputNonStandardJetBranch = kFALSE;
870 if(!fNonStandardJets) fNonStandardJets = new TClonesArray("AliAODJet",100);
871 fInputBackgroundJetBranchName = "jets";
872 fFillInputBackgroundJetBranch = kFALSE;
873 if(!fBackgroundJets) fBackgroundJets = new AliAODJetEventBackground();
877 //________________________________________________________________________
878 Bool_t AliCaloTrackReader::IsHIJINGLabel(Int_t label)
881 // Find if cluster/track was generated by HIJING
883 AliGenHijingEventHeader* hijingHeader = dynamic_cast<AliGenHijingEventHeader *> (GetGenEventHeader());
885 //printf("header %p, label %d\n",hijingHeader,label);
887 if(!hijingHeader || label < 0 ) return kFALSE;
890 //printf("pass a), N produced %d\n",nproduced);
892 if(label >= fNMCProducedMin && label < fNMCProducedMax)
894 //printf(" accept!, label is smaller than produced, N %d\n",nproduced);
901 if(!GetStack()) return kFALSE;
903 Int_t nprimaries = GetStack()->GetNtrack();
905 if(label > nprimaries) return kFALSE;
907 TParticle * mom = GetStack()->Particle(label);
910 Int_t iParent = mom->GetFirstMother();
913 if(iParent >= fNMCProducedMin && iParent < fNMCProducedMax)
915 //printf("\t accept, mother is %d \n",iParent)
920 mom = GetStack()->Particle(iMom);
921 iParent = mom->GetFirstMother();
929 TClonesArray* mcparticles = GetAODMCParticles();
931 if(!mcparticles) return kFALSE;
933 Int_t nprimaries = mcparticles->GetEntriesFast();
935 if(label > nprimaries) return kFALSE;
937 //printf("pass b) N primaries %d \n",nprimaries);
939 if(label >= fNMCProducedMin && label < fNMCProducedMax)
944 // Find grand parent, check if produced in the good range
945 AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
948 Int_t iParent = mom->GetMother();
951 if(iParent >= fNMCProducedMin && iParent < fNMCProducedMax)
953 //printf("\t accept, mother is %d, with nProduced %d \n",iParent, nproduced);
958 mom = (AliAODMCParticle *) mcparticles->At(iMom);
959 iParent = mom->GetMother();
963 //printf("pass c), no match found \n");
970 //__________________________________________________________________________
971 Bool_t AliCaloTrackReader::IsInTimeWindow(Double_t tof, Float_t energy) const
973 // Cluster time selection window
975 // Parametrized cut depending on E
978 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
979 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
980 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
981 if( tof < minCut || tof > maxCut ) return kFALSE ;
984 //In any case, the time should to be larger than the fixed window ...
985 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
990 //________________________________________________
991 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
993 // Check if event is from pile-up determined by SPD
994 // Default values: (3, 0.8, 3., 2., 5.)
995 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
996 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
997 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
1001 //__________________________________________________
1002 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
1004 // Check if event is from pile-up determined by EMCal
1005 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
1009 //________________________________________________________
1010 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
1012 // Check if event is from pile-up determined by SPD and EMCal
1013 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
1017 //_______________________________________________________
1018 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
1020 // Check if event is from pile-up determined by SPD or EMCal
1021 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
1025 //___________________________________________________________
1026 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
1028 // Check if event is from pile-up determined by SPD and not by EMCal
1029 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
1033 //___________________________________________________________
1034 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
1036 // Check if event is from pile-up determined by EMCal, not by SPD
1037 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
1041 //______________________________________________________________
1042 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
1044 // Check if event not from pile-up determined neither by SPD nor by EMCal
1045 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
1049 //___________________________________________________________________________________
1050 Bool_t AliCaloTrackReader::FillInputEvent(Int_t iEntry, const char * /*curFileName*/)
1052 //Fill the event counter and input lists that are needed, called by the analysis maker.
1054 fEventNumber = iEntry;
1055 fTriggerClusterIndex = -1;
1056 fTriggerClusterId = -1;
1057 fIsTriggerMatch = kFALSE;
1058 fTriggerClusterBC = -10000;
1059 fIsExoticEvent = kFALSE;
1060 fIsBadCellEvent = kFALSE;
1061 fIsBadMaxCellEvent = kFALSE;
1063 fIsTriggerMatchOpenCut[0] = kFALSE ;
1064 fIsTriggerMatchOpenCut[1] = kFALSE ;
1065 fIsTriggerMatchOpenCut[2] = kFALSE ;
1067 //fCurrentFileName = TString(currentFileName);
1070 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
1074 //-----------------------------------------------
1075 // Select the event depending on the trigger type
1076 // and other event characteristics
1077 // like the goodness of the EMCal trigger
1078 //-----------------------------------------------
1080 Bool_t accept = CheckEventTriggers();
1081 if(!accept) return kFALSE;
1083 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass Event trigger selection \n");
1085 //---------------------------------------------------------------------------
1086 // In case of analysis of events with jets, skip those with jet pt > 5 pt hard
1087 // To be used on for MC data in pT hard bins
1088 //---------------------------------------------------------------------------
1090 if(fComparePtHardAndJetPt)
1092 if(!ComparePtHardAndJetPt()) return kFALSE ;
1093 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass Pt Hard - Jet rejection \n");
1096 if(fComparePtHardAndClusterPt)
1098 if(!ComparePtHardAndClusterPt()) return kFALSE ;
1099 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass Pt Hard - Cluster rejection \n");
1102 //------------------------------------------------------
1103 // Event rejection depending on time stamp
1104 //------------------------------------------------------
1106 if(fDataType==kESD && fTimeStampEventSelect)
1108 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
1111 Int_t timeStamp = esd->GetTimeStamp();
1112 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
1114 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, timeStampFrac);
1116 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
1118 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass Time Stamp rejection \n");
1121 //------------------------------------------------------
1122 // Event rejection depending on vertex, pileup, v0and
1123 //------------------------------------------------------
1127 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
1128 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
1130 if(fUseEventsWithPrimaryVertex)
1132 if( !CheckForPrimaryVertex() ) return kFALSE; // algorithm in ESD/AOD Readers
1133 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
1134 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
1135 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
1138 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass primary vertex rejection \n");
1140 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
1142 if(fDoPileUpEventRejection)
1144 // Do not analyze events with pileup
1145 Bool_t bPileup = IsPileUpFromSPD();
1146 //IsPileupFromSPDInMultBins() // method to try
1147 //printf("pile-up %d, %d, %2.2f, %2.2f, %2.2f, %2.2f\n",bPileup, (Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
1148 if(bPileup) return kFALSE;
1150 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass Pile-Up event rejection \n");
1153 if(fDoV0ANDEventSelection)
1155 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1157 Bool_t bV0AND = ((v0->GetV0ADecision()==1) && (v0->GetV0CDecision()==1));
1158 //bV0AND = fTriggerAnalysis->IsOfflineTriggerFired((AliESDEvent*)fInputEvent, AliTriggerAnalysis::kV0AND);
1159 //printf("V0AND event? %d\n",bV0AND);
1163 printf("AliCaloTrackReader::FillInputEvent() - Reject event by V0AND\n");
1166 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass V0AND event rejection \n");
1169 //------------------------------------------------------
1170 // Check if there is a centrality value, PbPb analysis,
1171 // and if a centrality bin selection is requested
1172 //------------------------------------------------------
1174 //If we need a centrality bin, we select only those events in the corresponding bin.
1175 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
1177 Int_t cen = GetEventCentrality();
1178 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
1180 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass centrality rejection \n");
1183 //---------------------------------------------------------------------------
1184 // In case of MC analysis, set the range of interest in the MC particles list
1185 // The particle selection is done inside the FillInputDetector() methods
1186 //---------------------------------------------------------------------------
1187 if(fAcceptOnlyHIJINGLabels) SetGeneratorMinMaxParticles();
1189 //printf("N min %d, N max %d\n",fNMCProducedMin,fNMCProducedMax);
1191 //-------------------------------------------------------
1192 // Get the main vertex BC, in case not available
1193 // it is calculated in FillCTS checking the BC of tracks
1194 //------------------------------------------------------
1195 fVertexBC = fInputEvent->GetPrimaryVertex()->GetBC();
1197 //-----------------------------------------------
1198 // Fill the arrays with cluster/tracks/cells data
1199 //-----------------------------------------------
1204 //Accept events with at least one track
1205 if(fTrackMult == 0 && fDoRejectNoTrackEvents) return kFALSE ;
1207 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass rejection of null track events \n");
1210 if(fDoVertexBCEventSelection)
1212 if(fVertexBC != 0 && fVertexBC != AliVTrack::kTOFBCNA) return kFALSE ;
1214 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Pass rejection of events with vertex at BC!=0 \n");
1218 FillInputEMCALCells();
1221 FillInputPHOSCells();
1223 if(fFillEMCAL || fFillDCAL)
1231 //one specified jet branch
1232 if(fFillInputNonStandardJetBranch)
1233 FillInputNonStandardJets();
1234 if(fFillInputBackgroundJetBranch)
1235 FillInputBackgroundJets();
1237 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Event accepted for analysis \n");
1242 //__________________________________________________
1243 Int_t AliCaloTrackReader::GetEventCentrality() const
1245 //Return current event centrality
1249 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
1250 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
1251 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
1254 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
1262 //_____________________________________________________
1263 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
1265 //Return current event centrality
1269 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
1271 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
1273 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
1276 else if(GetEventPlaneMethod().Contains("V0") )
1278 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
1280 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
1284 ep+=TMath::Pi()/2; // put same range as for <Q> method
1288 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
1291 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
1292 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
1299 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
1305 //__________________________________________________________
1306 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
1308 //Return vertex position to be used for single event analysis
1309 vertex[0]=fVertex[0][0];
1310 vertex[1]=fVertex[0][1];
1311 vertex[2]=fVertex[0][2];
1314 //__________________________________________________________________________
1315 void AliCaloTrackReader::GetVertex(Double_t vertex[3], Int_t evtIndex) const
1317 //Return vertex position for mixed event, recover the vertex in a particular event.
1319 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
1323 //________________________________________
1324 void AliCaloTrackReader::FillVertexArray()
1327 //Fill data member with vertex
1328 //In case of Mixed event, multiple vertices
1330 //Delete previous vertex
1333 for (Int_t i = 0; i < fNMixedEvent; i++)
1335 delete [] fVertex[i] ;
1340 fVertex = new Double_t*[fNMixedEvent] ;
1341 for (Int_t i = 0; i < fNMixedEvent; i++)
1343 fVertex[i] = new Double_t[3] ;
1344 fVertex[i][0] = 0.0 ;
1345 fVertex[i][1] = 0.0 ;
1346 fVertex[i][2] = 0.0 ;
1350 { //Single event analysis
1354 if(fInputEvent->GetPrimaryVertex())
1356 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1360 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1361 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1362 }//Primary vertex pointer do not exist
1366 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1370 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
1373 { // MultiEvent analysis
1374 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1376 if (fMixedEvent->GetVertexOfEvent(iev))
1377 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1379 AliWarning("No vertex found");
1382 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",
1383 iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1389 //_____________________________________
1390 void AliCaloTrackReader::FillInputCTS()
1392 //Return array with Central Tracking System (CTS) tracks
1394 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1396 Double_t pTrack[3] = {0,0,0};
1398 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1401 Double_t bz = GetInputEvent()->GetMagneticField();
1403 for(Int_t i = 0; i < 19; i++)
1405 fTrackBCEvent [i] = 0;
1406 fTrackBCEventCut[i] = 0;
1409 Bool_t bc0 = kFALSE;
1410 if(fRecalculateVertexBC) fVertexBC = AliVTrack::kTOFBCNA;
1412 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1413 {////////////// track loop
1414 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1416 if(fAcceptOnlyHIJINGLabels && !IsHIJINGLabel(track->GetLabel())) continue ;
1418 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1419 ULong_t status = track->GetStatus();
1421 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1426 // Select the tracks depending on cuts of AOD or ESD
1427 if(!SelectTrack(track, pTrack)) continue ;
1430 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
1431 Double_t tof = -1000;
1432 Int_t trackBC = -1000 ;
1438 trackBC = track->GetTOFBunchCrossing(bz);
1439 SetTrackEventBC(trackBC+9);
1441 tof = track->GetTOFsignal()*1e-3;
1443 //After selecting tracks with small DCA, pointing to vertex, set vertex BC depeding on tracks BC
1444 if(fRecalculateVertexBC)
1446 if (trackBC != 0 && trackBC != AliVTrack::kTOFBCNA) fVertexBC = trackBC;
1447 else if(trackBC == 0) bc0 = kTRUE;
1450 //In any case, the time should to be larger than the fixed window ...
1451 if( fUseTrackTimeCut && (trackBC !=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1453 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
1456 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1460 fMomentum.SetPxPyPzE(pTrack[0],pTrack[1],pTrack[2],0);
1466 Float_t dcaTPC =-999;
1467 //In case of AODs, TPC tracks cannot be propagated back to primary vertex,
1468 if( fDataType == kAOD ) dcaTPC = ((AliAODTrack*) track)->DCA();
1470 //normal way to get the dca, cut on dca_xy
1473 Double_t dca[2] = {1e6,1e6};
1474 Double_t covar[3] = {1e6,1e6,1e6};
1475 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1476 if( okDCA) okDCA = AcceptDCA(fMomentum.Pt(),dca[0]);
1479 //printf("AliCaloTrackReader::FillInputCTS() - Reject track pt %2.2f, dca_xy %2.4f\n",fMomentum.Pt(),dca[0]);
1485 //Count the tracks in eta < 0.9
1486 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1488 if(fCTSPtMin > fMomentum.Pt() || fCTSPtMax < fMomentum.Pt()) continue ;
1490 // Check effect of cuts on track BC
1491 if(fAccessTrackTOF && okTOF) SetTrackEventBCcut(trackBC+9);
1493 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(fMomentum.Eta(),fMomentum.Phi(),kCTS)) continue;
1495 if(fDebug > 2 && fMomentum.Pt() > 0.1)
1496 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks pt %3.2f, phi %3.2f, eta %3.2f\n",
1497 fMomentum.Pt(),fMomentum.Phi()*TMath::RadToDeg(),fMomentum.Eta());
1499 if (fMixedEvent) track->SetID(itrack);
1502 fCTSTracks->Add(track);
1506 if( fRecalculateVertexBC && (fVertexBC == 0 || fVertexBC == AliVTrack::kTOFBCNA))
1508 if( bc0 ) fVertexBC = 0 ;
1509 else fVertexBC = AliVTrack::kTOFBCNA ;
1513 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1517 //_______________________________________________________________________________
1518 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, Int_t iclus)
1520 //Fill the EMCAL data in the array, do it
1522 // Accept clusters with the proper label, TO DO, use the new more General methods!!!
1523 if(fAcceptOnlyHIJINGLabels && !IsHIJINGLabel( clus->GetLabel() )) return ;
1527 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1530 clus->GetMomentum(fMomentum, fVertex[vindex]);
1532 if( (fDebug > 2 && fMomentum.E() > 0.1) || fDebug > 10 )
1533 printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Input cluster E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1534 fMomentum.E(),fMomentum.Pt(),fMomentum.Phi()*TMath::RadToDeg(),fMomentum.Eta());
1536 if(fRecalculateClusters)
1538 //Recalibrate the cluster energy
1539 if(GetCaloUtils()->IsRecalibrationOn())
1541 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1544 //printf("Recalibrated Energy %f\n",clus->E());
1546 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1547 GetCaloUtils()->RecalculateClusterPID(clus);
1551 //Recalculate distance to bad channels, if new list of bad channels provided
1552 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1554 //Recalculate cluster position
1555 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1557 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1558 //clus->GetPosition(pos);
1559 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1563 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1565 Double_t tof = clus->GetTOF();
1567 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1569 if(fDataType==AliCaloTrackReader::kESD)
1571 tof = fEMCALCells->GetCellTime(absIdMax);
1574 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1578 }// Time recalibration
1581 //Reject clusters with bad channels, close to borders and exotic;
1582 Bool_t goodCluster = GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,
1583 GetCaloUtils()->GetEMCALGeometry(),
1584 GetEMCALCells(),fInputEvent->GetBunchCrossNumber());
1588 if( (fDebug > 2 && fMomentum.E() > 0.1) || fDebug > 10 )
1589 printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Bad cluster E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1590 fMomentum.E(),fMomentum.Pt(),fMomentum.Phi()*TMath::RadToDeg(),fMomentum.Eta());
1595 //Mask all cells in collumns facing ALICE thick material if requested
1596 if(GetCaloUtils()->GetNMaskCellColumns())
1602 Bool_t shared = kFALSE;
1603 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1604 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1607 if(fSelectEmbeddedClusters)
1609 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1610 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1614 //clus->GetPosition(pos);
1615 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1617 //Correct non linearity or smear energy
1618 if(fCorrectELinearity && GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1620 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1622 if( (fDebug > 5 && fMomentum.E() > 0.1) || fDebug > 10 )
1623 printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Correct Non Lin: Old E %3.2f, New E %3.2f\n",
1624 fMomentum.E(),clus->E());
1626 // In case of MC analysis, to match resolution/calibration in real data
1627 // Not needed anymore, just leave for MC studies on systematics
1628 if( GetCaloUtils()->GetEMCALRecoUtils()->IsClusterEnergySmeared() )
1630 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1632 if( (fDebug > 5 && fMomentum.E() > 0.1) || fDebug > 10 )
1633 printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Smear energy: Old E %3.2f, New E %3.2f\n",
1634 clus->E(),rdmEnergy);
1636 clus->SetE(rdmEnergy);
1640 Double_t tof = clus->GetTOF()*1e9;
1642 Int_t bc = TMath::Nint(tof/50) + 9;
1643 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1645 SetEMCalEventBC(bc);
1647 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1649 clus->GetMomentum(fMomentum, fVertex[vindex]);
1651 SetEMCalEventBCcut(bc);
1653 if(!IsInTimeWindow(tof,clus->E()))
1655 fNPileUpClusters++ ;
1656 if(fUseEMCALTimeCut) return ;
1659 fNNonPileUpClusters++;
1661 if((fDebug > 2 && fMomentum.E() > 0.1) || fDebug > 10)
1662 printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1663 fMomentum.E(),fMomentum.Pt(),fMomentum.Phi()*TMath::RadToDeg(),fMomentum.Eta());
1666 clus->SetID(iclus) ;
1668 // Select cluster fiducial region
1669 Bool_t bEMCAL = kFALSE;
1670 Bool_t bDCAL = kFALSE;
1673 if(fFillEMCAL && fFiducialCut->IsInFiducialCut(fMomentum.Eta(),fMomentum.Phi(),kEMCAL)) bEMCAL = kTRUE ;
1674 if(fFillDCAL && fFiducialCut->IsInFiducialCut(fMomentum.Eta(),fMomentum.Phi(),kDCAL )) bDCAL = kTRUE ;
1682 // Fill the corresponding array. Usually just filling EMCal array with upper or lower clusters is enough, but maybe we want to do EMCal-DCal correlations.
1683 if (bEMCAL) fEMCALClusters->Add(clus);
1684 else if(bDCAL ) fDCALClusters ->Add(clus);
1688 //_______________________________________
1689 void AliCaloTrackReader::FillInputEMCAL()
1691 //Return array with EMCAL clusters in aod format
1693 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1695 // First recalibrate cells, time or energy
1696 // if(GetCaloUtils()->IsRecalibrationOn())
1697 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1699 // fInputEvent->GetBunchCrossNumber());
1701 fNPileUpClusters = 0; // Init counter
1702 fNNonPileUpClusters = 0; // Init counter
1703 for(Int_t i = 0; i < 19; i++)
1705 fEMCalBCEvent [i] = 0;
1706 fEMCalBCEventCut[i] = 0;
1709 //Loop to select clusters in fiducial cut and fill container with aodClusters
1710 if(fEMCALClustersListName=="")
1712 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1713 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1715 AliVCluster * clus = 0;
1716 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1718 if (clus->IsEMCAL())
1720 FillInputEMCALAlgorithm(clus, iclus);
1725 //Recalculate track matching
1726 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1728 }//Get the clusters from the input event
1731 TClonesArray * clusterList = 0x0;
1733 if (fInputEvent->FindListObject(fEMCALClustersListName))
1735 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1737 else if(fOutputEvent)
1739 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1744 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1748 Int_t nclusters = clusterList->GetEntriesFast();
1749 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1751 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1752 //printf("E %f\n",clus->E());
1753 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1754 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1757 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1758 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1760 fNPileUpClusters = 0; // Init counter
1761 fNNonPileUpClusters = 0; // Init counter
1762 for(Int_t i = 0; i < 19; i++)
1764 fEMCalBCEvent [i] = 0;
1765 fEMCalBCEventCut[i] = 0;
1768 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1770 AliVCluster * clus = 0;
1772 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1774 if (clus->IsEMCAL())
1778 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1779 Double_t tof = clus->GetTOF();
1780 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1783 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1785 //Reject clusters with bad channels, close to borders and exotic;
1786 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1788 Int_t bc = TMath::Nint(tof/50) + 9;
1789 SetEMCalEventBC(bc);
1791 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1793 clus->GetMomentum(fMomentum, fVertex[0]);
1795 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(fMomentum.Eta(),fMomentum.Phi(),kEMCAL)) return ;
1797 SetEMCalEventBCcut(bc);
1799 if(!IsInTimeWindow(tof,clus->E()))
1800 fNPileUpClusters++ ;
1802 fNNonPileUpClusters++;
1808 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1810 // Recalculate track matching, not necessary if already done in the reclusterization task.
1811 // in case it was not done ...
1812 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1816 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1820 //______________________________________
1821 void AliCaloTrackReader::FillInputPHOS()
1823 //Return array with PHOS clusters in aod format
1825 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1827 //Loop to select clusters in fiducial cut and fill container with aodClusters
1828 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1829 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1831 AliVCluster * clus = 0;
1832 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1836 if(fAcceptOnlyHIJINGLabels && !IsHIJINGLabel(clus->GetLabel())) continue ;
1838 //Check if the cluster contains any bad channel and if close to calorimeter borders
1841 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1842 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1844 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells()))
1847 if(fRecalculateClusters)
1849 //Recalibrate the cluster energy
1850 if(GetCaloUtils()->IsRecalibrationOn())
1852 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1857 clus->GetMomentum(fMomentum, fVertex[vindex]);
1859 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(fMomentum.Eta(),fMomentum.Phi(),kPHOS)) continue;
1861 if(fPHOSPtMin > fMomentum.E() || fPHOSPtMax < fMomentum.E()) continue;
1863 if(fDebug > 2 && fMomentum.E() > 0.1)
1864 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1865 fMomentum.E(),fMomentum.Pt(),fMomentum.Phi()*TMath::RadToDeg(),fMomentum.Eta());
1870 clus->SetID(iclus) ;
1873 fPHOSClusters->Add(clus);
1879 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1883 //____________________________________________
1884 void AliCaloTrackReader::FillInputEMCALCells()
1886 //Return array with EMCAL cells in aod format
1888 fEMCALCells = fInputEvent->GetEMCALCells();
1892 //___________________________________________
1893 void AliCaloTrackReader::FillInputPHOSCells()
1895 //Return array with PHOS cells in aod format
1897 fPHOSCells = fInputEvent->GetPHOSCells();
1901 //_______________________________________
1902 void AliCaloTrackReader::FillInputVZERO()
1904 //Fill VZERO information in data member, add all the channels information.
1905 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1906 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1910 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1911 for (Int_t i = 0; i < 32; i++)
1914 {//Only available in ESDs
1915 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1916 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1919 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1920 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1923 printf("AliCaloTrackReader::FillInputVZERO() - ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1928 printf("AliCaloTrackReader::FillInputVZERO() - Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
1932 //_________________________________________________
1933 void AliCaloTrackReader::FillInputNonStandardJets()
1936 //fill array with non standard jets
1940 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputNonStandardJets()\n");
1942 //check if branch name is given
1943 if(!fInputNonStandardJetBranchName.Length())
1945 Printf("No non-standard jet branch name specified. Specify among existing ones.");
1946 fInputEvent->Print();
1950 fNonStandardJets = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(fInputNonStandardJetBranchName.Data()));
1952 if(!fNonStandardJets)
1954 //check if jet branch exist; exit if not
1955 Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fInputNonStandardJetBranchName.Data());
1956 fInputEvent->Print();
1962 printf("AliCaloTrackReader::FillInputNonStandardJets() - aod input jets %d\n", fNonStandardJets->GetEntriesFast() );
1967 //_________________________________________________
1968 void AliCaloTrackReader::FillInputBackgroundJets()
1971 //fill array with Background jets
1975 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputBackgroundJets()\n");
1977 //check if branch name is given
1978 if(!fInputBackgroundJetBranchName.Length())
1980 Printf("No background jet branch name specified. Specify among existing ones.");
1981 fInputEvent->Print();
1985 fBackgroundJets = (AliAODJetEventBackground*)(fInputEvent->FindListObject(fInputBackgroundJetBranchName.Data()));
1987 if(!fBackgroundJets)
1989 //check if jet branch exist; exit if not
1990 Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fInputBackgroundJetBranchName.Data());
1991 fInputEvent->Print();
1997 printf("AliCaloTrackReader::FillInputBackgroundJets()\n");
1998 fBackgroundJets->Print("");
2004 //________________________________________________________________________________
2005 TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
2007 // Select the patches that triggered
2008 // Depend on L0 or L1
2011 Int_t trigtimes[30], globCol, globRow,ntimes, i;
2012 Int_t absId = -1; //[100];
2017 // get object pointer
2018 AliVCaloTrigger *caloTrigger = GetInputEvent()->GetCaloTrigger( "EMCAL" );
2020 // Recover the threshold of the event that triggered, only possible for L1
2021 if(!fTriggerL1EventThresholdFix)
2025 if (IsEventEMCALL1Gamma1()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(1);
2026 else if(IsEventEMCALL1Gamma2()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(3);
2027 else if(IsEventEMCALL1Jet1 ()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(0);
2028 else if(IsEventEMCALL1Jet2 ()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(2);
2030 // printf("L1 trigger Threshold Jet1 %f, Gamma1 %f, Jet2 %f, Gamma2 %f\n",
2031 // 0.07874*caloTrigger->GetL1Threshold(0),
2032 // 0.07874*caloTrigger->GetL1Threshold(1),
2033 // 0.07874*caloTrigger->GetL1Threshold(2),
2034 // 0.07874*caloTrigger->GetL1Threshold(3));
2038 // Old AOD data format, in such case, order of thresholds different!!!
2039 if (IsEventEMCALL1Gamma1()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(0);
2040 else if(IsEventEMCALL1Gamma2()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(2);
2041 else if(IsEventEMCALL1Jet1 ()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(1);
2042 else if(IsEventEMCALL1Jet2 ()) fTriggerL1EventThreshold = 0.07874*caloTrigger->GetL1Threshold(3);
2044 // printf("L1 trigger Threshold Jet1 %f, Gamma1 %f, Jet2 %f, Gamma2 %f\n",
2045 // 0.07874*caloTrigger->GetL1Threshold(1),
2046 // 0.07874*caloTrigger->GetL1Threshold(0),
2047 // 0.07874*caloTrigger->GetL1Threshold(3),
2048 // 0.07874*caloTrigger->GetL1Threshold(2));
2052 //printf("CaloTrigger Entries %d\n",caloTrigger->GetEntries() );
2054 // class is not empty
2055 if( caloTrigger->GetEntries() > 0 )
2057 // must reset before usage, or the class will fail
2058 caloTrigger->Reset();
2060 // go throuth the trigger channels
2061 while( caloTrigger->Next() )
2063 // get position in global 2x2 tower coordinates
2064 caloTrigger->GetPosition( globCol, globRow );
2067 if(IsEventEMCALL0())
2069 // get dimension of time arrays
2070 caloTrigger->GetNL0Times( ntimes );
2072 // no L0s in this channel
2073 // presence of the channel in the iterator still does not guarantee that L0 was produced!!
2078 caloTrigger->GetL0Times( trigtimes );
2079 //printf("Get L0 patch : n times %d - trigger time window %d - %d\n",ntimes, tmin,tmax);
2081 // go through the array
2082 for( i = 0; i < ntimes; i++ )
2084 // check if in cut - 8,9 shall be accepted in 2011
2085 if( trigtimes[i] >= tmin && trigtimes[i] <= tmax )
2087 //printf("Accepted trigger time %d \n",trigtimes[i]);
2088 //if(nTrig > 99) continue;
2089 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol,globRow, absId);
2090 //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
2091 patches.Set(nPatch+1);
2092 patches.AddAt(absId,nPatch++);
2094 } // trigger time array
2096 else if(IsEventEMCALL1()) // L1
2099 caloTrigger->GetTriggerBits(bit);
2102 caloTrigger->GetL1TimeSum(sum);
2104 Bool_t isEGA1 = ((bit >> fBitEGA ) & 0x1) && IsEventEMCALL1Gamma1() ;
2105 Bool_t isEGA2 = ((bit >> (fBitEGA+1)) & 0x1) && IsEventEMCALL1Gamma2() ;
2106 Bool_t isEJE1 = ((bit >> fBitEJE ) & 0x1) && IsEventEMCALL1Jet1 () ;
2107 Bool_t isEJE2 = ((bit >> (fBitEJE+1)) & 0x1) && IsEventEMCALL1Jet2 () ;
2109 //if((bit>> fBitEGA )&0x1) printf("Trig Bit %d - bit %d - EG1 %d - EG2 %d\n",fBitEGA ,bit,IsEventEMCALL1Gamma1(),IsEventEMCALL1Gamma2());
2110 //if((bit>>(fBitEGA+1))&0x1) printf("Trig Bit %d - bit %d - EG1 %d - EG2 %d\n",fBitEGA+1,bit,IsEventEMCALL1Gamma1(),IsEventEMCALL1Gamma2());
2112 if(!isEGA1 && !isEJE1 && !isEGA2 && !isEJE2) continue;
2114 Int_t patchsize = -1;
2115 if (isEGA1 || isEGA2) patchsize = 2;
2116 else if (isEJE1 || isEJE2) patchsize = 16;
2118 //printf("**** Get L1 Patch: Bit %x, sum %d, patchsize %d, EGA1 %d, EGA2 %d, EJE1 %d, EJE2 %d, EGA bit %d, EJE bit %d, Trigger Gamma %d, Trigger Jet %d\n",
2119 // bit,sum,patchsize,isEGA1,isEGA2,isEJE1,isEJE2,fBitEGA,fBitEJE,IsEventEMCALL1Gamma(),IsEventEMCALL1Jet());
2122 // add 2x2 (EGA) or 16x16 (EJE) patches
2123 for(Int_t irow=0; irow < patchsize; irow++)
2125 for(Int_t icol=0; icol < patchsize; icol++)
2127 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol+icol,globRow+irow, absId);
2128 //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
2129 patches.Set(nPatch+1);
2130 patches.AddAt(absId,nPatch++);
2136 } // trigger iterator
2137 } // go through triggers
2139 if(patches.GetSize()<=0) printf("AliCaloTrackReader::GetTriggerPatches() - No patch found! for triggers: %s and selected <%s>\n",
2140 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data());
2141 //else printf(">>>>> N patches %d, test %d,first %d, last %d\n",patches.GetSize(), nPatch, patches.At(0), patches.At(patches.GetSize()-1));
2146 //______________________________________________________________________
2147 void AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
2149 // Finds the cluster that triggered
2151 // Init info from previous event
2152 fTriggerClusterIndex = -1;
2153 fTriggerClusterId = -1;
2154 fTriggerClusterBC = -10000;
2155 fIsExoticEvent = kFALSE;
2156 fIsBadCellEvent = kFALSE;
2157 fIsBadMaxCellEvent = kFALSE;
2159 fIsTriggerMatch = kFALSE;
2160 fIsTriggerMatchOpenCut[0] = kFALSE;
2161 fIsTriggerMatchOpenCut[1] = kFALSE;
2162 fIsTriggerMatchOpenCut[2] = kFALSE;
2164 // Do only analysis for triggered events
2165 if(!IsEventEMCALL1() && !IsEventEMCALL0())
2167 fTriggerClusterBC = 0;
2171 //printf("***** Try to match trigger to cluster %d **** L0 %d, L1 %d\n",fTriggerPatchClusterMatch,IsEventEMCALL0(),IsEventEMCALL1());
2173 //Recover the list of clusters
2174 TClonesArray * clusterList = 0;
2175 if (fInputEvent->FindListObject(fEMCALClustersListName))
2177 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
2179 else if(fOutputEvent)
2181 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
2184 // Get number of clusters and of trigger patches
2185 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
2187 nclusters = clusterList->GetEntriesFast();
2189 Int_t nPatch = patches.GetSize();
2190 Float_t exoDiffTime = GetCaloUtils()->GetEMCALRecoUtils()->GetExoticCellDiffTimeCut();
2192 //Init some variables used in the cluster loop
2193 Float_t tofPatchMax = 100000;
2194 Float_t ePatchMax =-1;
2196 Float_t tofMax = 100000;
2200 Int_t idclusMax =-1;
2201 Bool_t badClMax = kFALSE;
2202 Bool_t badCeMax = kFALSE;
2203 Bool_t exoMax = kFALSE;
2204 // Int_t absIdMaxTrig= -1;
2205 Int_t absIdMaxMax = -1;
2207 Int_t nOfHighECl = 0 ;
2209 Float_t triggerThreshold = fTriggerL1EventThreshold;
2210 if(IsEventEMCALL0()) triggerThreshold = fTriggerL0EventThreshold;
2211 //printf("Threshold %f\n",triggerThreshold);
2212 Float_t minE = triggerThreshold / 2.;
2214 // This method is not really suitable for JET trigger
2215 // but in case, reduce the energy cut since we do not trigger on high energy particle
2216 if(IsEventEMCALL1Jet() || minE < 1) minE = 1;
2218 //printf("Min trigger Energy threshold %f\n",minE);
2220 // Loop on the clusters, check if there is any that falls into one of the patches
2221 for (Int_t iclus = 0; iclus < nclusters; iclus++)
2223 AliVCluster * clus = 0;
2224 if(clusterList) clus = (AliVCluster*) clusterList->At(iclus);
2225 else clus = fInputEvent->GetCaloCluster(iclus);
2227 if ( !clus ) continue ;
2229 if ( !clus->IsEMCAL() ) continue ;
2231 //Skip clusters with too low energy to be triggering
2232 if ( clus->E() < minE ) continue ;
2235 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fInputEvent->GetEMCALCells(), clus,frac);
2237 Bool_t badCluster = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),
2238 clus->GetCellsAbsId(),clus->GetNCells());
2239 UShort_t cellMax[] = {(UShort_t) absIdMax};
2240 Bool_t badCell = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),cellMax,1);
2242 // if cell is bad, it can happen that time calibration is not available,
2243 // when calculating if it is exotic, this can make it to be exotic by default
2244 // open it temporarily for this cluster
2246 GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(10000000);
2248 Bool_t exotic = GetCaloUtils()->GetEMCALRecoUtils()->IsExoticCluster(clus, fInputEvent->GetEMCALCells());
2250 // Set back the time cut on exotics
2252 GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(exoDiffTime);
2254 // Energy threshold for exotic Ecross typically at 4 GeV,
2255 // for lower energy, check that there are more than 1 cell in the cluster
2256 if(!exotic && clus->GetNCells() < 2) exotic = kTRUE;
2258 Float_t energy = clus->E();
2259 Int_t idclus = clus->GetID();
2261 Double_t tof = clus->GetTOF();
2262 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn() && fTriggerClusterTimeRecal)
2263 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
2266 //printf("cluster %d, ID %d, E %2.2f, tof %2.2f, AbsId max %d, exotic %d, bad Cluster %d, bad Cell %d\n",
2267 // iclus,idclus, energy,tof,absIdMax, exotic, badCluster,badCell);
2269 // Find the highest energy cluster, avobe trigger threshold
2270 // in the event in case no match to trigger is found
2275 badClMax = badCluster;
2280 absIdMaxMax = absIdMax;
2283 // count the good clusters in the event avobe the trigger threshold
2284 // to check the exotic events
2285 if(!badCluster && !exotic)
2288 // Find match to trigger
2289 if(fTriggerPatchClusterMatch && nPatch>0)
2291 for(Int_t iabsId =0; iabsId < nPatch; iabsId++)
2294 GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patches.At(iabsId), absIDCell);
2295 //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
2296 // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
2298 for(Int_t ipatch = 0; ipatch < 4; ipatch++)
2300 if(absIdMax == absIDCell[ipatch])
2302 //printf("*** Patches : absId %d, E %2.1f, tof %f \n",absIdMax,clus->E(), tof);
2303 if(energy > ePatchMax)
2307 fIsBadCellEvent = badCluster;
2308 fIsBadMaxCellEvent = badCell;
2309 fIsExoticEvent = exotic;
2310 fTriggerClusterIndex = iclus;
2311 fTriggerClusterId = idclus;
2312 fIsTriggerMatch = kTRUE;
2313 // absIdMaxTrig = absIdMax;
2317 }// trigger patch loop
2318 } // Do trigger patch matching
2322 // If there was no match, assign as trigger
2323 // the highest energy cluster in the event
2324 if(!fIsTriggerMatch)
2326 tofPatchMax = tofMax;
2328 fIsBadCellEvent = badClMax;
2329 fIsBadMaxCellEvent = badCeMax;
2330 fIsExoticEvent = exoMax;
2331 fTriggerClusterIndex = clusMax;
2332 fTriggerClusterId = idclusMax;
2335 Double_t tofPatchMaxUS = TMath::Abs(tofPatchMax);
2337 if (tofPatchMaxUS < 28 ) fTriggerClusterBC = 0 ;
2338 else if(tofPatchMaxUS < 75 ) fTriggerClusterBC = 1 ;
2339 else if(tofPatchMaxUS < 125) fTriggerClusterBC = 2 ;
2340 else if(tofPatchMaxUS < 175) fTriggerClusterBC = 3 ;
2341 else if(tofPatchMaxUS < 225) fTriggerClusterBC = 4 ;
2342 else if(tofPatchMaxUS < 275) fTriggerClusterBC = 5 ;
2345 //printf("AliCaloTrackReader::MatchTriggerCluster() - Large BC - tof %2.3f - Index %d\n",tofPatchMaxUS,fTriggerClusterIndex);
2346 if(fTriggerClusterIndex >= 0) fTriggerClusterBC = 6 ;
2349 fTriggerClusterIndex = -2;
2350 fTriggerClusterId = -2;
2354 if(tofPatchMax < 0) fTriggerClusterBC*=-1;
2357 // printf("AliCaloTrackReader::MatchTriggerCluster(TArrayI patches) - Trigger cluster: index %d, ID %d, E = %2.2f, tof = %2.2f (BC = %d), bad cluster? %d, bad cell? %d, exotic? %d, patch match? %d, n High E cluster %d, absId Max %d\n",
2358 // fTriggerClusterIndex, fTriggerClusterId,ePatchMax, tofPatchMax,
2359 // fTriggerClusterBC, fIsBadCellEvent,fIsBadMaxCellEvent,fIsExoticEvent, fIsTriggerMatch, nOfHighECl,absIdMaxMax);
2361 // if(!fIsTriggerMatch) printf("\t highest energy cluster: index %d, ID %d, E = %2.2f, tof = %2.2f, bad cluster? %d, bad cell? %d, exotic? %d\n",
2362 // clusMax, idclusMax, eMax,tofMax, badClMax, badCeMax,exoMax);
2364 //Redo matching but open cuts
2365 if(!fIsTriggerMatch && fTriggerClusterId >= 0)
2367 // Open time patch time
2368 TArrayI patchOpen = GetTriggerPatches(7,10);
2371 Int_t patchAbsIdOpenTime = -1;
2372 for(Int_t iabsId =0; iabsId < patchOpen.GetSize(); iabsId++)
2375 patchAbsIdOpenTime = patchOpen.At(iabsId);
2376 GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patchAbsIdOpenTime, absIDCell);
2377 //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
2378 // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
2380 for(Int_t ipatch = 0; ipatch < 4; ipatch++)
2382 if(absIdMaxMax == absIDCell[ipatch])
2384 fIsTriggerMatchOpenCut[0] = kTRUE;
2388 }// trigger patch loop
2390 // Check neighbour patches
2391 Int_t patchAbsId = -1;
2392 Int_t globalCol = -1;
2393 Int_t globalRow = -1;
2394 GetCaloUtils()->GetEMCALGeometry()->GetFastORIndexFromCellIndex(absIdMaxMax, patchAbsId);
2395 GetCaloUtils()->GetEMCALGeometry()->GetPositionInEMCALFromAbsFastORIndex(patchAbsId,globalCol,globalRow);
2397 // Check patches with strict time cut
2398 Int_t patchAbsIdNeigh = -1;
2399 for(Int_t icol = globalCol-1; icol <= globalCol+1; icol++)
2401 if(icol < 0 || icol > 47) continue;
2403 for(Int_t irow = globalRow; irow <= globalRow+1; irow++)
2405 if(irow < 0 || irow > 63) continue;
2407 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, patchAbsIdNeigh);
2409 if ( patchAbsIdNeigh < 0 ) continue;
2411 for(Int_t iabsId =0; iabsId < patches.GetSize(); iabsId++)
2413 if(patchAbsIdNeigh == patches.At(iabsId))
2415 fIsTriggerMatchOpenCut[1] = kTRUE;
2418 }// trigger patch loop
2423 // Check patches with open time cut
2424 Int_t patchAbsIdNeighOpenTime = -1;
2425 for(Int_t icol = globalCol-1; icol <= globalCol+1; icol++)
2427 if(icol < 0 || icol > 47) continue;
2429 for(Int_t irow = globalRow; irow <= globalRow+1; irow++)
2431 if(irow < 0 || irow > 63) continue;
2433 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, patchAbsIdNeighOpenTime);
2435 if ( patchAbsIdNeighOpenTime < 0 ) continue;
2437 for(Int_t iabsId =0; iabsId < patchOpen.GetSize(); iabsId++)
2439 if(patchAbsIdNeighOpenTime == patchOpen.At(iabsId))
2441 fIsTriggerMatchOpenCut[2] = kTRUE;
2444 }// trigger patch loop
2449 // printf("No match, new match: Open time %d-%d, open Neigh %d-%d, both open %d-%d\n",fIsTriggerMatchOpenCut[0],patchAbsIdOpenTime,
2450 // fIsTriggerMatchOpenCut[1],patchAbsIdNeigh,
2451 // fIsTriggerMatchOpenCut[2],patchAbsIdNeighOpenTime);
2455 }// No trigger match found
2456 //printf("Trigger BC %d, Id %d, Index %d\n",fTriggerClusterBC,fTriggerClusterId,fTriggerClusterIndex);
2460 //________________________________________________________
2461 void AliCaloTrackReader::Print(const Option_t * opt) const
2464 //Print some relevant parameters set for the analysis
2468 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
2469 printf("Task name : %s\n", fTaskName.Data()) ;
2470 printf("Data type : %d\n", fDataType) ;
2471 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
2472 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
2473 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
2474 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
2475 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
2476 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
2477 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
2478 printf("Use CTS = %d\n", fFillCTS) ;
2479 printf("Use EMCAL = %d\n", fFillEMCAL) ;
2480 printf("Use DCAL = %d\n", fFillDCAL) ;
2481 printf("Use PHOS = %d\n", fFillPHOS) ;
2482 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
2483 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
2484 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
2485 //printf("AODs Track filter mask = %d or hybrid %d (if filter bit comp %d), select : SPD hit %d, primary %d\n",
2486 // (Int_t) fTrackFilterMask, fSelectHybridTracks, (Int_t) fTrackFilterMaskComplementary, fSelectSPDHitTracks,fSelectPrimaryTracks) ;
2487 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
2488 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
2489 printf("Recalculate Clusters = %d, E linearity = %d\n", fRecalculateClusters, fCorrectELinearity) ;
2491 printf("Use Triggers selected in SE base class %d; If not what Trigger Mask? %d; MB Trigger Mask for mixed %d \n",
2492 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
2494 if(fComparePtHardAndClusterPt)
2495 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
2497 if(fComparePtHardAndClusterPt)
2498 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
2500 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
2501 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
2502 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
2508 //__________________________________________
2509 Bool_t AliCaloTrackReader::RejectLEDEvents()
2511 // LED Events in period LHC11a contaminated sample, simple method
2512 // to reject such events
2514 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
2515 Int_t ncellsSM3 = 0;
2516 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
2518 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
2519 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
2520 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
2523 Int_t ncellcut = 21;
2524 if(GetFiredTriggerClasses().Contains("EMC")) ncellcut = 35;
2526 if(ncellsSM3 >= ncellcut)
2529 printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d, cut %d, trig %s\n",
2530 ncellsSM3,ncellcut,GetFiredTriggerClasses().Data());
2538 //_________________________________________________________
2539 void AliCaloTrackReader::RemapMCLabelForAODs(Int_t & label)
2541 // MC label for Cells not remapped after ESD filtering, do it here.
2543 if(label < 0) return ;
2545 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
2548 TClonesArray * arr = dynamic_cast<TClonesArray*>(evt->FindListObject("mcparticles")) ;
2551 if(label < arr->GetEntriesFast())
2553 AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(label));
2554 if(!particle) return ;
2556 if(label == particle->Label()) return ; // label already OK
2557 //else printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label %d - AOD stack %d \n",label, particle->Label());
2559 //else printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label %d > AOD labels %d \n",label, arr->GetEntriesFast());
2561 // loop on the particles list and check if there is one with the same label
2562 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
2564 AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(ind));
2565 if(!particle) continue ;
2567 if(label == particle->Label())
2570 //printf("AliAnalysisTaskEMCALClusterize::RemapMCLabelForAODs() - New Label Index %d \n",label);
2577 //printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label not found set to -1 \n");
2582 //___________________________________
2583 void AliCaloTrackReader::ResetLists()
2585 // Reset lists, called by the analysis maker
2587 if(fCTSTracks) fCTSTracks -> Clear();
2588 if(fEMCALClusters) fEMCALClusters -> Clear("C");
2589 if(fPHOSClusters) fPHOSClusters -> Clear("C");
2591 fV0ADC[0] = 0; fV0ADC[1] = 0;
2592 fV0Mul[0] = 0; fV0Mul[1] = 0;
2594 if(fNonStandardJets) fNonStandardJets -> Clear("C");
2595 fBackgroundJets->Reset();
2599 //___________________________________________
2600 void AliCaloTrackReader::SetEventTriggerBit()
2602 // Tag event depeding on trigger name
2604 fEventTrigMinBias = kFALSE;
2605 fEventTrigCentral = kFALSE;
2606 fEventTrigSemiCentral = kFALSE;
2607 fEventTrigEMCALL0 = kFALSE;
2608 fEventTrigEMCALL1Gamma1 = kFALSE;
2609 fEventTrigEMCALL1Gamma2 = kFALSE;
2610 fEventTrigEMCALL1Jet1 = kFALSE;
2611 fEventTrigEMCALL1Jet2 = kFALSE;
2614 printf("AliCaloTrackReader::SetEventTriggerBit() - Select trigger mask bit %d - Trigger Event %s - Select <%s>\n",
2615 fEventTriggerMask,GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data());
2617 if(fEventTriggerMask <=0 )// in case no mask set
2619 // EMC triggered event? Which type?
2620 if( GetFiredTriggerClasses().Contains("-B-") || GetFiredTriggerClasses().Contains("-S-") || GetFiredTriggerClasses().Contains("-I-") )
2622 if ( GetFiredTriggerClasses().Contains("EGA" ) ||
2623 GetFiredTriggerClasses().Contains("EG1" ) )
2625 fEventTrigEMCALL1Gamma1 = kTRUE;
2626 if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
2628 else if( GetFiredTriggerClasses().Contains("EG2" ) )
2630 fEventTrigEMCALL1Gamma2 = kTRUE;
2631 if( !fFiredTriggerClassName.Contains("EG2") ) fEventTrigEMCALL1Gamma2 = kFALSE;
2633 else if( GetFiredTriggerClasses().Contains("EJE" ) ||
2634 GetFiredTriggerClasses().Contains("EJ1" ) )
2636 fEventTrigEMCALL1Jet1 = kTRUE;
2637 if( GetFiredTriggerClasses().Contains("EJ1" ) && !fFiredTriggerClassName.Contains("EJ1") )
2638 fEventTrigEMCALL1Jet1 = kFALSE;
2640 else if( GetFiredTriggerClasses().Contains("EJ2" ) )
2642 fEventTrigEMCALL1Jet2 = kTRUE;
2643 if( !fFiredTriggerClassName.Contains("EJ2") ) fEventTrigEMCALL1Jet2 = kFALSE;
2645 else if( GetFiredTriggerClasses().Contains("CEMC") &&
2646 !GetFiredTriggerClasses().Contains("EGA" ) &&
2647 !GetFiredTriggerClasses().Contains("EJE" ) &&
2648 !GetFiredTriggerClasses().Contains("EG1" ) &&
2649 !GetFiredTriggerClasses().Contains("EJ1" ) &&
2650 !GetFiredTriggerClasses().Contains("EG2" ) &&
2651 !GetFiredTriggerClasses().Contains("EJ2" ) )
2653 fEventTrigEMCALL0 = kTRUE;
2656 //Min bias event trigger?
2657 if (GetFiredTriggerClasses().Contains("CCENT_R2-B-NOPF-ALLNOTRD"))
2659 fEventTrigCentral = kTRUE;
2661 else if(GetFiredTriggerClasses().Contains("CSEMI_R1-B-NOPF-ALLNOTRD"))
2663 fEventTrigSemiCentral = kTRUE;
2665 else if((GetFiredTriggerClasses().Contains("CINT") || GetFiredTriggerClasses().Contains("CPBI2_B1") ) &&
2666 GetFiredTriggerClasses().Contains("-NOPF-ALLNOTRD") )
2668 fEventTrigMinBias = kTRUE;
2675 if ( fEventTriggerMask & AliVEvent::kEMCEGA )
2677 //printf("EGA trigger bit\n");
2678 if (GetFiredTriggerClasses().Contains("EG"))
2680 if (GetFiredTriggerClasses().Contains("EGA")) fEventTrigEMCALL1Gamma1 = kTRUE;
2683 if(GetFiredTriggerClasses().Contains("EG1")) fEventTrigEMCALL1Gamma1 = kTRUE;
2684 if(GetFiredTriggerClasses().Contains("EG2")) fEventTrigEMCALL1Gamma2 = kTRUE;
2689 else if( fEventTriggerMask & AliVEvent::kEMCEJE )
2691 //printf("EGA trigger bit\n");
2692 if (GetFiredTriggerClasses().Contains("EJ"))
2694 if (GetFiredTriggerClasses().Contains("EJE")) fEventTrigEMCALL1Jet1 = kTRUE;
2697 if(GetFiredTriggerClasses().Contains("EJ1")) fEventTrigEMCALL1Jet1 = kTRUE;
2698 if(GetFiredTriggerClasses().Contains("EJ2")) fEventTrigEMCALL1Jet2 = kTRUE;
2703 else if((fEventTriggerMask & AliVEvent::kEMC7) ||
2704 (fEventTriggerMask & AliVEvent::kEMC1) )
2706 //printf("L0 trigger bit\n");
2707 fEventTrigEMCALL0 = kTRUE;
2710 else if( fEventTriggerMask & AliVEvent::kCentral )
2712 //printf("MB semi central trigger bit\n");
2713 fEventTrigSemiCentral = kTRUE;
2716 else if( fEventTriggerMask & AliVEvent::kSemiCentral )
2718 //printf("MB central trigger bit\n");
2719 fEventTrigCentral = kTRUE;
2721 // Min Bias pp, PbPb, pPb
2722 else if((fEventTriggerMask & AliVEvent::kMB ) ||
2723 (fEventTriggerMask & AliVEvent::kINT7) ||
2724 (fEventTriggerMask & AliVEvent::kINT8) ||
2725 (fEventTriggerMask & AliVEvent::kAnyINT) )
2727 //printf("MB trigger bit\n");
2728 fEventTrigMinBias = kTRUE;
2733 printf("AliCaloTrackReader::SetEventTriggerBit() - Event bits: \n \t MB %d, Cen %d, Sem %d, L0 %d, L1G1 %d, L1G2 %d, L1J1 %d, L1J2 %d \n",
2734 fEventTrigMinBias, fEventTrigCentral, fEventTrigSemiCentral,
2735 fEventTrigEMCALL0 , fEventTrigEMCALL1Gamma1, fEventTrigEMCALL1Gamma2,
2736 fEventTrigEMCALL1Jet1 , fEventTrigEMCALL1Jet2);
2738 if(fBitEGA == 0 && fBitEJE ==0)
2740 // Init the trigger bit once, correct depending on AliESDAODCaloTrigger header version
2745 TFile* file = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
2747 const TList *clist = file->GetStreamerInfoCache();
2751 TStreamerInfo *cinfo = (TStreamerInfo*)clist->FindObject("AliESDCaloTrigger");
2752 Int_t verid = 5; // newer ESD header version
2755 cinfo = (TStreamerInfo*)clist->FindObject("AliAODCaloTrigger");
2756 verid = 3; // newer AOD header version
2761 Int_t classversionid = cinfo->GetClassVersion();
2762 //printf("********* Header class version %d *********** \n",classversionid);
2764 if (classversionid >= verid)
2769 } else printf("AliCaloTrackReader()::SetEventTriggerBit() - Streamer info for trigger class not available, bit not changed\n");
2770 } else printf("AliCaloTrackReader::SetEventTriggerBit() - Streamer list not available!, bit not changed\n");
2772 } // set once the EJE, EGA trigger bit
2776 //____________________________________________________________
2777 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
2779 fInputEvent = input;
2780 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
2782 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
2784 //Delete previous vertex
2787 for (Int_t i = 0; i < fNMixedEvent; i++)
2789 delete [] fVertex[i] ;
2794 fVertex = new Double_t*[fNMixedEvent] ;
2795 for (Int_t i = 0; i < fNMixedEvent; i++)
2797 fVertex[i] = new Double_t[3] ;
2798 fVertex[i][0] = 0.0 ;
2799 fVertex[i][1] = 0.0 ;
2800 fVertex[i][2] = 0.0 ;