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 "AliESDtrack.h"
44 #include "AliESDtrackCuts.h"
45 #include "AliTriggerAnalysis.h"
46 #include "AliESDVZERO.h"
47 #include "AliVCaloCells.h"
48 #include "AliAnalysisManager.h"
49 #include "AliInputEventHandler.h"
50 #include "AliAODMCParticle.h"
53 // ---- Detectors ----
54 #include "AliPHOSGeoUtils.h"
55 #include "AliEMCALGeometry.h"
56 #include "AliEMCALRecoUtils.h"
58 // ---- CaloTrackCorr ---
59 #include "AliCalorimeterUtils.h"
60 #include "AliCaloTrackReader.h"
62 #include "AliAODJet.h"
63 #include "AliAODJetEventBackground.h"
65 ClassImp(AliCaloTrackReader)
68 //________________________________________
69 AliCaloTrackReader::AliCaloTrackReader() :
70 TObject(), fEventNumber(-1), //fCurrentFileName(""),
71 fDataType(0), fDebug(0),
72 fFiducialCut(0x0), fCheckFidCut(kFALSE),
73 fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(0),
74 fComparePtHardAndClusterPt(0),fPtHardAndClusterPtFactor(0),
75 fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
76 fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
77 fUseEMCALTimeCut(1), fUseParamTimeCut(0), fUseTrackTimeCut(0),
78 fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
79 fEMCALParamTimeCutMin(), fEMCALParamTimeCutMax(),
80 fTrackTimeCutMin(-10000), fTrackTimeCutMax(10000),
83 fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
84 fEMCALCells(0x0), fPHOSCells(0x0),
85 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
86 fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
87 fFillEMCALCells(0), fFillPHOSCells(0),
88 fRecalculateClusters(kFALSE),fCorrectELinearity(kTRUE),
89 fSelectEmbeddedClusters(kFALSE),
90 fTrackStatus(0), fTrackFilterMask(0), fTrackFilterMaskComplementary(0),
91 fESDtrackCuts(0), fESDtrackComplementaryCuts(0), fConstrainTrack(kFALSE),
92 fSelectHybridTracks(0), fSelectPrimaryTracks(0),
93 fSelectSPDHitTracks(0), fSelectFractionTPCSharedClusters(0), fCutTPCSharedClustersFraction(0),
94 fTrackMult(0), fTrackMultEtaCut(0.9),
95 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
96 fDeltaAODFileName(""), fFiredTriggerClassName(""),
98 fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
99 fEventTrigMinBias(0), fEventTrigCentral(0),
100 fEventTrigSemiCentral(0), fEventTrigEMCALL0(0),
101 fEventTrigEMCALL1Gamma1(0), fEventTrigEMCALL1Gamma2(0),
102 fEventTrigEMCALL1Jet1(0), fEventTrigEMCALL1Jet2(0),
103 fBitEGA(0), fBitEJE(0),
106 fTaskName(""), fCaloUtils(0x0),
107 fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
108 fListMixedTracksEvents(), fListMixedCaloEvents(),
109 fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
110 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE),
111 fEMCALClustersListName(""), fZvtxCut(0.),
112 fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
114 fRemoveBadTriggerEvents(0), fTriggerPatchClusterMatch(0),
115 fTriggerPatchTimeWindow(), fTriggerEventThreshold(0),
116 fTriggerClusterBC(0), fTriggerClusterIndex(0), fTriggerClusterId(0),
117 fIsExoticEvent(0), fIsBadCellEvent(0), fIsBadMaxCellEvent(0),
118 fIsTriggerMatch(0), fIsTriggerMatchOpenCut(),
119 fTriggerClusterTimeRecal(kTRUE), fRemoveUnMatchedTriggers(kTRUE),
120 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE),
121 fDoVertexBCEventSelection(kFALSE),
122 fDoRejectNoTrackEvents(kFALSE),
123 fUseEventsWithPrimaryVertex(kFALSE),
124 fTriggerAnalysis (0x0), 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)
140 //Initialize parameters
144 //_______________________________________
145 AliCaloTrackReader::~AliCaloTrackReader()
149 delete fFiducialCut ;
153 fAODBranchList->Delete();
154 delete fAODBranchList ;
159 if(fDataType!=kMC)fCTSTracks->Clear() ;
160 else fCTSTracks->Delete() ;
166 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
167 else fEMCALClusters->Delete() ;
168 delete fEMCALClusters ;
173 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
174 else fPHOSClusters->Delete() ;
175 delete fPHOSClusters ;
180 for (Int_t i = 0; i < fNMixedEvent; i++)
182 delete [] fVertex[i] ;
188 delete fESDtrackCuts;
189 delete fESDtrackComplementaryCuts;
190 delete fTriggerAnalysis;
194 if(fDataType!=kMC) fNonStandardJets->Clear("C") ;
195 else fNonStandardJets->Delete() ;
196 delete fNonStandardJets ;
198 delete fBackgroundJets ;
200 fRejectEventsWithBit.Reset();
201 fAcceptEventsWithBit.Reset();
203 // Pointers not owned, done by the analysis frame
204 // if(fInputEvent) delete fInputEvent ;
205 // if(fOutputEvent) delete fOutputEvent ;
206 // if(fMC) delete fMC ;
207 // Pointer not owned, deleted by maker
208 // if (fCaloUtils) delete fCaloUtils ;
212 //________________________________________________________________________
213 Bool_t AliCaloTrackReader::AcceptDCA(Float_t pt, Float_t dca)
215 // Accept track if DCA is smaller than function
217 Float_t cut = fTrackDCACut[0]+fTrackDCACut[1]/TMath::Power(pt,fTrackDCACut[2]);
219 if(TMath::Abs(dca) < cut)
226 //_____________________________________________________
227 Bool_t AliCaloTrackReader::AcceptEventWithTriggerBit()
229 // Accept events that pass the physics selection
230 // depending on an array of trigger bits set during the configuration
232 Int_t nAccept = fAcceptEventsWithBit.GetSize();
234 //printf("N accept %d\n", nAccept);
237 return kTRUE ; // accept the event
239 UInt_t trigFired = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
241 for(Int_t ibit = 0; ibit < nAccept; ibit++)
243 Bool_t accept = (trigFired & fAcceptEventsWithBit.At(ibit));
245 //printf("accept %d, ibit %d, bit %d \n",accept, ibit,fAcceptEventsWithBit.At(ibit));
246 if(accept) return kTRUE ; // accept the event
249 return kFALSE ; // reject the event
253 //_____________________________________________________
254 Bool_t AliCaloTrackReader::RejectEventWithTriggerBit()
256 // Reject events that pass the physics selection
257 // depending on an array of trigger bits set during the configuration
259 Int_t nReject = fRejectEventsWithBit.GetSize();
261 //printf("N reject %d\n", nReject);
264 return kTRUE ; // accept the event
266 UInt_t trigFired = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
268 for(Int_t ibit = 0; ibit < nReject; ibit++)
270 Bool_t reject = (trigFired & fRejectEventsWithBit.At(ibit));
272 //printf("reject %d, ibit %d, bit %d \n",reject, ibit,fRejectEventsWithBit.At(ibit));
273 if(reject) return kFALSE ; // reject the event
276 return kTRUE ; // accept the event
280 //_____________________________________________
281 Bool_t AliCaloTrackReader::CheckEventTriggers()
283 // Do different selection of the event
284 // depending on trigger name, event type, goodness of the EMCal trigger ...
286 //-----------------------------------------------------------
287 // Reject events depending on the trigger name and event type
288 //-----------------------------------------------------------
291 if(fInputEvent->GetHeader())
292 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
294 if( fFiredTriggerClassName !="" && !fAnaLED)
296 //printf("Event type %d\n",eventType);
298 return kFALSE; //Only physics event, do not use for simulated events!!!
301 printf("AliCaloTrackReader::CheckEventTriggers() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
302 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
304 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
305 else if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Accepted triggered event\n");
309 // kStartOfRun = 1, // START_OF_RUN
310 // kEndOfRun = 2, // END_OF_RUN
311 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
312 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
313 // kStartOfBurst = 5, // START_OF_BURST
314 // kEndOfBurst = 6, // END_OF_BURST
315 // kPhysicsEvent = 7, // PHYSICS_EVENT
316 // kCalibrationEvent = 8, // CALIBRATION_EVENT
317 // kFormatError = 9, // EVENT_FORMAT_ERROR
318 // kStartOfData = 10, // START_OF_DATA
319 // kEndOfData = 11, // END_OF_DATA
320 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
321 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
323 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::CheckEventTriggers() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
324 if(eventType!=8)return kFALSE;
327 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass Trigger name rejection \n");
329 //-------------------------------------------------------------------------------------
330 // Reject or accept events depending on the trigger bit
331 //-------------------------------------------------------------------------------------
333 Bool_t okA = AcceptEventWithTriggerBit();
334 Bool_t okR = RejectEventWithTriggerBit();
336 //printf("AliCaloTrackReader::FillInputEvent() - Accept event? %d, Reject event %d? \n",okA,okR);
338 if(!okA || !okR) return kFALSE;
340 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass event bit rejection \n");
342 //----------------------------------------------------------------------
343 // Do not count events that were likely triggered by an exotic cluster
345 //----------------------------------------------------------------------
347 // Set a bit with the event kind, MB, L0, L1 ...
348 SetEventTriggerBit();
350 if( IsEventEMCALL1() || IsEventEMCALL0() )
352 // Reject triggered events when there is coincidence on both EMCal trigger thresholds,
353 // but the requested trigger is the low trigger threshold
354 // This can be done with AcceptEventWithTriggerBit() and RejectEventWithTriggerBit(),
355 // but let's fix it here for the moment
356 if(IsEventEMCALL1Jet1 () && IsEventEMCALL1Jet2 () && fFiredTriggerClassName.Contains("EJ2")) return kFALSE;
357 if(IsEventEMCALL1Gamma1() && IsEventEMCALL1Gamma2() && fFiredTriggerClassName.Contains("EG2")) return kFALSE;
359 //Get Patches that triggered
360 TArrayI patches = GetTriggerPatches(fTriggerPatchTimeWindow[0],fTriggerPatchTimeWindow[1]);
362 MatchTriggerCluster(patches);
366 // If requested, remove badly triggeed events, but only when the EMCal trigger bit is set
367 if(fRemoveBadTriggerEvents)
370 printf("AliCaloTrackReader::CheckEventTriggers() - ACCEPT triggered event? \n exotic? %d - bad cell %d - bad Max cell %d - BC %d - Matched %d\n",
371 fIsExoticEvent,fIsBadCellEvent, fIsBadMaxCellEvent, fTriggerClusterBC,fIsTriggerMatch);
372 if (fIsExoticEvent) return kFALSE;
373 else if(fIsBadCellEvent) return kFALSE;
374 else if(fRemoveUnMatchedTriggers && !fIsTriggerMatch) return kFALSE ;
375 else if(fTriggerClusterBC != 0) return kFALSE;
376 if(fDebug > 0) printf("\t *** YES for %s\n",GetFiredTriggerClasses().Data());
380 printf("AliCaloTrackReader::CheckEventTriggers() - Pass EMCal triggered event rejection \n");
383 //-------------------------------------------------------------------------------------
384 //Select events only fired by a certain trigger configuration if it is provided
385 //-------------------------------------------------------------------------------------
386 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
388 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
392 //-------------------------------------------------------------------------------------
393 // Reject event if large clusters with large energy
394 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
395 // If clusterzer NxN or V2 it does not help
396 //-------------------------------------------------------------------------------------
397 Int_t run = fInputEvent->GetRunNumber();
398 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
400 Bool_t reject = RejectLEDEvents();
402 if(reject) return kFALSE;
404 if(fDebug > 0) printf("AliCaloTrackReader::CheckEventTriggers() - Pass LED event rejection \n");
406 }// Remove LED events
411 //________________________________________________
412 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
414 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
417 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
419 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
422 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
423 Int_t nTriggerJets = pygeh->NTriggerJets();
424 Float_t ptHard = pygeh->GetPtHard();
427 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
429 Float_t tmpjet[]={0,0,0,0};
430 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
432 pygeh->TriggerJet(ijet, tmpjet);
433 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
436 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
438 //Compare jet pT and pt Hard
439 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
441 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
442 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
454 //____________________________________________________________________
455 Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
457 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
460 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
462 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
463 Float_t ptHard = pygeh->GetPtHard();
465 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
466 for (Int_t iclus = 0; iclus < nclusters; iclus++)
468 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
469 Float_t ecluster = clus->E();
471 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
473 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
485 //____________________________________________
486 AliStack* AliCaloTrackReader::GetStack() const
488 //Return pointer to stack
493 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
498 //______________________________________________
499 AliHeader* AliCaloTrackReader::GetHeader() const
501 //Return pointer to header
504 return fMC->Header();
508 printf("AliCaloTrackReader::Header is not available\n");
513 //____________________________________________________
514 void AliCaloTrackReader::SetGeneratorMinMaxParticles()
516 // In case of access only to hijing particles in cocktail
517 // get the min and max labels
518 // TODO: Check when generator is not the first one ...
523 if (ReadStack() && fMC)
525 AliGenEventHeader * eventHeader = fMC->GenEventHeader();
527 if(!fAcceptOnlyHIJINGLabels) return ;
529 // TODO Check if it works from here ...
531 AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
533 if(!cocktail) return ;
535 TList *genHeaders = cocktail->GetHeaders();
537 Int_t nGenerators = genHeaders->GetEntries();
538 //printf("N generators %d \n", nGenerators);
540 for(Int_t igen = 0; igen < nGenerators; igen++)
542 AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
543 TString name = eventHeader2->GetName();
545 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
547 fNMCProducedMin = fNMCProducedMax;
548 fNMCProducedMax+= eventHeader2->NProduced();
550 if(name.Contains("Hijing",TString::kIgnoreCase)) return ;
554 else if(ReadAODMCParticles() && GetAODMCHeader())
556 Int_t nGenerators = GetAODMCHeader()->GetNCocktailHeaders();
557 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",nGenerators);
559 if( nGenerators <= 0) return ;
561 if(!fAcceptOnlyHIJINGLabels) return ;
563 for(Int_t igen = 0; igen < nGenerators; igen++)
565 AliGenEventHeader * eventHeader = GetAODMCHeader()->GetCocktailHeader(igen) ;
566 TString name = eventHeader->GetName();
568 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader->ClassName(), name.Data(), eventHeader->GetTitle());
570 fNMCProducedMin = fNMCProducedMax;
571 fNMCProducedMax+= eventHeader->NProduced();
573 if(name.Contains("Hijing",TString::kIgnoreCase)) return ;
580 //______________________________________________________________
581 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
583 // Return pointer to Generated event header
584 // If requested and cocktail, search for the hijing generator
586 if (ReadStack() && fMC)
588 AliGenEventHeader * eventHeader = fMC->GenEventHeader();
590 if(!fAcceptOnlyHIJINGLabels) return eventHeader ;
592 // TODO Check if it works from here ...
594 AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
596 if(!cocktail) return 0x0 ;
598 TList *genHeaders = cocktail->GetHeaders();
600 Int_t nGenerators = genHeaders->GetEntries();
601 //printf("N generators %d \n", nGenerators);
603 for(Int_t igen = 0; igen < nGenerators; igen++)
605 AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
606 TString name = eventHeader2->GetName();
608 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
610 if(name.Contains("Hijing",TString::kIgnoreCase)) return eventHeader2 ;
616 else if(ReadAODMCParticles() && GetAODMCHeader())
618 Int_t nGenerators = GetAODMCHeader()->GetNCocktailHeaders();
619 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",nGenerators);
621 if( nGenerators <= 0) return 0x0;
623 if(!fAcceptOnlyHIJINGLabels) return GetAODMCHeader()->GetCocktailHeader(0);
625 for(Int_t igen = 0; igen < nGenerators; igen++)
627 AliGenEventHeader * eventHeader = GetAODMCHeader()->GetCocktailHeader(igen) ;
628 TString name = eventHeader->GetName();
630 //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader->ClassName(), name.Data(), eventHeader->GetTitle());
632 if(name.Contains("Hijing",TString::kIgnoreCase)) return eventHeader ;
640 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
645 //____________________________________________________________________
646 TClonesArray* AliCaloTrackReader::GetAODMCParticles() const
648 //Return list of particles in AOD. Do it for the corresponding input event.
650 TClonesArray * rv = NULL ;
651 if(fDataType == kAOD)
654 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
656 rv = (TClonesArray*)evt->FindListObject("mcparticles");
658 printf("AliCaloTrackReader::GetAODMCParticles() - Null AOD event \n");
662 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
668 //________________________________________________________
669 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
671 //Return MC header in AOD. Do it for the corresponding input event.
673 AliAODMCHeader *mch = NULL;
675 if(fDataType == kAOD)
677 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
678 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
682 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
688 //___________________________________________________________
689 Int_t AliCaloTrackReader::GetVertexBC(const AliVVertex * vtx)
693 Int_t vertexBC=vtx->GetBC();
694 if(!fRecalculateVertexBC) return vertexBC;
696 // In old AODs BC not stored, recalculate it
697 // loop over the global track and select those which have small DCA to primary vertex (e.g. primary).
698 // If at least one of these primaries has valid BC != 0, then this vertex is a pile-up candidate.
700 Double_t bz = fInputEvent->GetMagneticField();
702 Int_t ntr = GetCTSTracks()->GetEntriesFast();
703 //printf("N Tracks %d\n",ntr);
705 for(Int_t i = 0 ; i < ntr ; i++)
707 AliVTrack * track = (AliVTrack*) (GetCTSTracks()->At(i));
709 //Check if has TOF info, if not skip
710 ULong_t status = track->GetStatus();
711 Bool_t okTOF = (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ;
712 vertexBC = track->GetTOFBunchCrossing(bz);
713 Float_t pt = track->Pt();
718 Double_t dca[2] = {1e6,1e6};
719 Double_t covar[3] = {1e6,1e6,1e6};
720 track->PropagateToDCA(vtx,bz,100.,dca,covar);
722 if(AcceptDCA(pt,dca[0]))
724 if (vertexBC !=0 && fVertexBC != AliVTrack::kTOFBCNA) return vertexBC;
725 else if(vertexBC == 0) bc0 = kTRUE;
729 if( bc0 ) vertexBC = 0 ;
730 else vertexBC = AliVTrack::kTOFBCNA ;
736 //_____________________________
737 void AliCaloTrackReader::Init()
739 //Init reader. Method to be called in AliAnaPartCorrMaker
741 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
743 if(fReadStack && fReadAODMCParticles)
745 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
747 fReadAODMCParticles = kFALSE;
751 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
755 //_______________________________________
756 void AliCaloTrackReader::InitParameters()
758 //Initialize the parameters of the analysis.
764 fEMCALPtMax = 1000. ;
768 // dca_xy cut = 0.0105+0.0350/TMath::Power(pt,1.1);
769 fTrackDCACut[0] = 0.0105;
770 fTrackDCACut[1] = 0.0350;
771 fTrackDCACut[2] = 1.1;
773 //Do not filter the detectors input by default.
777 fFillEMCALCells = kFALSE;
778 fFillPHOSCells = kFALSE;
780 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
781 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
782 fDeltaAODFileName = "deltaAODPartCorr.root";
783 fFiredTriggerClassName = "";
784 fEventTriggerMask = AliVEvent::kAny;
785 fMixEventTriggerMask = AliVEvent::kAnyINT;
786 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
788 fAcceptFastCluster = kTRUE;
791 //We want tracks fitted in the detectors:
792 //fTrackStatus=AliESDtrack::kTPCrefit;
793 //fTrackStatus|=AliESDtrack::kITSrefit;
795 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
796 fTrackFilterMaskComplementary = 0; // in case of hybrid tracks, without using the standard method
798 fSelectFractionTPCSharedClusters = kTRUE;
799 fCutTPCSharedClustersFraction = 0.4,
802 fESDtrackComplementaryCuts = 0;
804 fConstrainTrack = kFALSE ; // constrain tracks to vertex
806 fV0ADC[0] = 0; fV0ADC[1] = 0;
807 fV0Mul[0] = 0; fV0Mul[1] = 0;
813 fPtHardAndJetPtFactor = 7.;
814 fPtHardAndClusterPtFactor = 1.;
817 fCentralityClass = "V0M";
819 fCentralityBin[0] = fCentralityBin[1]=-1;
821 fEventPlaneMethod = "V0";
823 // Allocate memory (not sure this is the right place)
824 fCTSTracks = new TObjArray();
825 fEMCALClusters = new TObjArray();
826 fPHOSClusters = new TObjArray();
827 fTriggerAnalysis = new AliTriggerAnalysis;
828 fAODBranchList = new TList ;
830 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
831 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
833 // Parametrized time cut (LHC11d)
834 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
835 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
837 // Parametrized time cut (LHC11c)
838 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
839 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
841 fTimeStampRunMin = -1;
842 fTimeStampRunMax = 1e12;
843 fTimeStampEventFracMin = -1;
844 fTimeStampEventFracMax = 2;
846 for(Int_t i = 0; i < 19; i++)
848 fEMCalBCEvent [i] = 0;
849 fEMCalBCEventCut[i] = 0;
850 fTrackBCEvent [i] = 0;
851 fTrackBCEventCut[i] = 0;
854 // Trigger match-rejection
855 fTriggerPatchTimeWindow[0] = 8;
856 fTriggerPatchTimeWindow[1] = 9;
858 fTriggerClusterBC = -10000 ;
859 fTriggerEventThreshold = 2.;
860 fTriggerClusterIndex = -1;
861 fTriggerClusterId = -1;
864 fInputNonStandardJetBranchName = "jets";
865 fFillInputNonStandardJetBranch = kFALSE;
866 if(!fNonStandardJets) fNonStandardJets = new TClonesArray("AliAODJet",100);
867 fInputBackgroundJetBranchName = "jets";
868 fFillInputBackgroundJetBranch = kFALSE;
869 if(!fBackgroundJets) fBackgroundJets = new AliAODJetEventBackground();
873 //___________________________________________________________________
874 Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
876 // Check if it is a cluster from EMCAL. For old AODs cluster type has
877 // different number and need to patch here
879 if(fDataType==kAOD && fOldAOD)
881 if (cluster->GetType() == 2) return kTRUE;
886 return cluster->IsEMCAL();
891 //___________________________________________________________________
892 Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
894 //Check if it is a cluster from PHOS.For old AODs cluster type has
895 // different number and need to patch here
897 if(fDataType==kAOD && fOldAOD)
899 Int_t type = cluster->GetType();
900 if (type == 0 || type == 1) return kTRUE;
905 return cluster->IsPHOS();
910 //________________________________________________________________________
911 Bool_t AliCaloTrackReader::IsHIJINGLabel(Int_t label)
914 // Find if cluster/track was generated by HIJING
916 AliGenHijingEventHeader* hijingHeader = dynamic_cast<AliGenHijingEventHeader *> (GetGenEventHeader());
918 //printf("header %p, label %d\n",hijingHeader,label);
920 if(!hijingHeader || label < 0 ) return kFALSE;
923 //printf("pass a), N produced %d\n",nproduced);
925 if(label >= fNMCProducedMin && label < fNMCProducedMax)
927 //printf(" accept!, label is smaller than produced, N %d\n",nproduced);
934 if(!GetStack()) return kFALSE;
936 Int_t nprimaries = GetStack()->GetNtrack();
938 if(label > nprimaries) return kFALSE;
940 TParticle * mom = GetStack()->Particle(label);
943 Int_t iParent = mom->GetFirstMother();
946 if(iParent >= fNMCProducedMin && iParent < fNMCProducedMax)
948 //printf("\t accept, mother is %d \n",iParent)
953 mom = GetStack()->Particle(iMom);
954 iParent = mom->GetFirstMother();
962 TClonesArray* mcparticles = GetAODMCParticles();
964 if(!mcparticles) return kFALSE;
966 Int_t nprimaries = mcparticles->GetEntriesFast();
968 if(label > nprimaries) return kFALSE;
970 //printf("pass b) N primaries %d \n",nprimaries);
972 if(label >= fNMCProducedMin && label < fNMCProducedMax)
977 // Find grand parent, check if produced in the good range
978 AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
981 Int_t iParent = mom->GetMother();
984 if(iParent >= fNMCProducedMin && iParent < fNMCProducedMax)
986 //printf("\t accept, mother is %d, with nProduced %d \n",iParent, nproduced);
991 mom = (AliAODMCParticle *) mcparticles->At(iMom);
992 iParent = mom->GetMother();
996 //printf("pass c), no match found \n");
1003 //__________________________________________________________________________
1004 Bool_t AliCaloTrackReader::IsInTimeWindow(Double_t tof, Float_t energy) const
1006 // Cluster time selection window
1008 // Parametrized cut depending on E
1009 if(fUseParamTimeCut)
1011 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
1012 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
1013 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
1014 if( tof < minCut || tof > maxCut ) return kFALSE ;
1017 //In any case, the time should to be larger than the fixed window ...
1018 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
1023 //________________________________________________
1024 Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
1026 // Check if event is from pile-up determined by SPD
1027 // Default values: (3, 0.8, 3., 2., 5.)
1028 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
1029 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
1030 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
1034 //__________________________________________________
1035 Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
1037 // Check if event is from pile-up determined by EMCal
1038 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
1042 //________________________________________________________
1043 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
1045 // Check if event is from pile-up determined by SPD and EMCal
1046 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
1050 //_______________________________________________________
1051 Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
1053 // Check if event is from pile-up determined by SPD or EMCal
1054 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
1058 //___________________________________________________________
1059 Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
1061 // Check if event is from pile-up determined by SPD and not by EMCal
1062 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
1066 //___________________________________________________________
1067 Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
1069 // Check if event is from pile-up determined by EMCal, not by SPD
1070 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
1074 //______________________________________________________________
1075 Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
1077 // Check if event not from pile-up determined neither by SPD nor by EMCal
1078 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
1082 //___________________________________________________________________________________
1083 Bool_t AliCaloTrackReader::FillInputEvent(Int_t iEntry, const char * /*curFileName*/)
1085 //Fill the event counter and input lists that are needed, called by the analysis maker.
1087 fEventNumber = iEntry;
1088 fTriggerClusterIndex = -1;
1089 fTriggerClusterId = -1;
1090 fIsTriggerMatch = kFALSE;
1091 fTriggerClusterBC = -10000;
1092 fIsExoticEvent = kFALSE;
1093 fIsBadCellEvent = kFALSE;
1094 fIsBadMaxCellEvent = kFALSE;
1096 fIsTriggerMatchOpenCut[0] = kFALSE ;
1097 fIsTriggerMatchOpenCut[1] = kFALSE ;
1098 fIsTriggerMatchOpenCut[2] = kFALSE ;
1100 //fCurrentFileName = TString(currentFileName);
1103 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
1107 Bool_t accept = CheckEventTriggers();
1108 if(!accept) return kFALSE;
1110 //---------------------------------------------------------------------------
1111 // In case of analysis of events with jets, skip those with jet pt > 5 pt hard
1112 // To be used on for MC data in pT hard bins
1113 //---------------------------------------------------------------------------
1114 if(fComparePtHardAndJetPt)
1116 if(!ComparePtHardAndJetPt()) return kFALSE ;
1119 if(fComparePtHardAndClusterPt)
1121 if(!ComparePtHardAndClusterPt()) return kFALSE ;
1124 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass Pt Hard rejection \n");
1128 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
1129 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
1131 //------------------------------------------------------
1132 //Event rejection depending on vertex, pileup, v0and
1133 //------------------------------------------------------
1134 if(fDataType==kESD && fTimeStampEventSelect)
1136 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
1139 Int_t timeStamp = esd->GetTimeStamp();
1140 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
1142 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, timeStampFrac);
1144 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
1146 //printf("\t accept time stamp\n");
1149 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass Time Stamp rejection \n");
1151 //------------------------------------------------------
1152 //Event rejection depending on vertex, pileup, v0and
1153 //------------------------------------------------------
1155 if(fUseEventsWithPrimaryVertex)
1157 if( !CheckForPrimaryVertex() ) return kFALSE;
1158 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
1159 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
1160 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
1163 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass primary vertex rejection \n");
1165 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
1167 if(fDoEventSelection)
1169 // Do not analyze events with pileup
1170 Bool_t bPileup = IsPileUpFromSPD();
1171 //IsPileupFromSPDInMultBins() // method to try
1172 //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]);
1173 if(bPileup) return kFALSE;
1175 if(fDoV0ANDEventSelection)
1177 Bool_t bV0AND = kTRUE;
1178 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
1180 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
1181 //else bV0AND = //FIXME FOR AODs
1182 if(!bV0AND) return kFALSE;
1184 }// Event selection/AliceSoft/AliRoot/trunk/PWG/CaloTrackCorrBase/AliCaloTrackReader.h
1186 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass Pile-Up, V0AND event rejection \n");
1188 //------------------------------------------------------
1190 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
1191 //If we need a centrality bin, we select only those events in the corresponding bin.
1192 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
1194 Int_t cen = GetEventCentrality();
1195 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
1198 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass centrality rejection \n");
1201 //Fill the arrays with cluster/tracks/cells data
1203 if(!fEventTriggerAtSE)
1205 // In case of mixing analysis, accept MB events, not only Trigger
1206 // Track and cluster arrays filled for MB in order to create the pool in the corresponding analysis
1207 // via de method in the base class FillMixedEventPool()
1209 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
1210 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
1212 if(!inputHandler) return kFALSE ; // to content coverity
1214 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
1215 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
1217 if(!isTrigger && !isMB) return kFALSE;
1219 //printf("Selected triggered event : %s\n",GetFiredTriggerClasses().Data());
1222 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass uninteresting triggered events rejection in case of mixing analysis \n");
1225 // Get the main vertex BC, in case not available
1226 // it is calculated in FillCTS checking the BC of tracks
1227 // with DCA small (if cut applied, if open)
1228 fVertexBC=fInputEvent->GetPrimaryVertex()->GetBC();
1230 if(fAcceptOnlyHIJINGLabels) SetGeneratorMinMaxParticles();
1232 //printf("N min %d, N max %d\n",fNMCProducedMin,fNMCProducedMax);
1237 //Accept events with at least one track
1238 if(fTrackMult == 0 && fDoRejectNoTrackEvents) return kFALSE ;
1241 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass rejection of null track events \n");
1244 if(fDoVertexBCEventSelection)
1246 if(fVertexBC!=0 && fVertexBC!=AliVTrack::kTOFBCNA) return kFALSE ;
1249 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass rejection of events with vertex at BC!=0 \n");
1253 FillInputEMCALCells();
1256 FillInputPHOSCells();
1266 //one specified jet branch
1267 if(fFillInputNonStandardJetBranch)
1268 FillInputNonStandardJets();
1269 if(fFillInputBackgroundJetBranch)
1270 FillInputBackgroundJets();
1276 //__________________________________________________
1277 Int_t AliCaloTrackReader::GetEventCentrality() const
1279 //Return current event centrality
1283 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
1284 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
1285 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
1288 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
1296 //_____________________________________________________
1297 Double_t AliCaloTrackReader::GetEventPlaneAngle() const
1299 //Return current event centrality
1303 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
1305 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
1307 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
1310 else if(GetEventPlaneMethod().Contains("V0") )
1312 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
1314 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
1318 ep+=TMath::Pi()/2; // put same range as for <Q> method
1322 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
1325 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
1326 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
1333 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
1339 //__________________________________________________________
1340 void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
1342 //Return vertex position to be used for single event analysis
1343 vertex[0]=fVertex[0][0];
1344 vertex[1]=fVertex[0][1];
1345 vertex[2]=fVertex[0][2];
1348 //__________________________________________________________________________
1349 void AliCaloTrackReader::GetVertex(Double_t vertex[3], Int_t evtIndex) const
1351 //Return vertex position for mixed event, recover the vertex in a particular event.
1353 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
1357 //________________________________________
1358 void AliCaloTrackReader::FillVertexArray()
1361 //Fill data member with vertex
1362 //In case of Mixed event, multiple vertices
1364 //Delete previous vertex
1367 for (Int_t i = 0; i < fNMixedEvent; i++)
1369 delete [] fVertex[i] ;
1374 fVertex = new Double_t*[fNMixedEvent] ;
1375 for (Int_t i = 0; i < fNMixedEvent; i++)
1377 fVertex[i] = new Double_t[3] ;
1378 fVertex[i][0] = 0.0 ;
1379 fVertex[i][1] = 0.0 ;
1380 fVertex[i][2] = 0.0 ;
1384 { //Single event analysis
1388 if(fInputEvent->GetPrimaryVertex())
1390 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1394 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1395 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1396 }//Primary vertex pointer do not exist
1400 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1404 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
1407 { // MultiEvent analysis
1408 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1410 if (fMixedEvent->GetVertexOfEvent(iev))
1411 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
1413 { // no vertex found !!!!
1414 AliWarning("No vertex found");
1418 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
1425 //_____________________________________
1426 void AliCaloTrackReader::FillInputCTS()
1428 //Return array with Central Tracking System (CTS) tracks
1430 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1432 Double_t pTrack[3] = {0,0,0};
1434 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1437 Double_t bz = GetInputEvent()->GetMagneticField();
1439 for(Int_t i = 0; i < 19; i++)
1441 fTrackBCEvent [i] = 0;
1442 fTrackBCEventCut[i] = 0;
1445 Bool_t bc0 = kFALSE;
1446 if(fRecalculateVertexBC) fVertexBC=AliVTrack::kTOFBCNA;
1448 for (Int_t itrack = 0; itrack < nTracks; itrack++)
1449 {////////////// track loop
1450 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
1452 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
1453 ULong_t status = track->GetStatus();
1455 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
1460 Float_t dcaTPC =-999;
1462 if (fDataType==kESD)
1464 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1468 if(fESDtrackCuts->AcceptTrack(esdTrack))
1470 track->GetPxPyPz(pTrack) ;
1474 if(esdTrack->GetConstrainedParam())
1476 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1477 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1478 esdTrack->GetConstrainedPxPyPz(pTrack);
1482 } // use constrained tracks
1484 if(fSelectSPDHitTracks)
1485 {//Not much sense to use with TPC only or Hybrid tracks
1486 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1489 // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
1490 else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
1492 // constrain the track
1493 if(esdTrack->GetConstrainedParam())
1495 esdTrack->Set(esdTrack->GetConstrainedParam()->GetX(),esdTrack->GetConstrainedParam()->GetAlpha(),esdTrack->GetConstrainedParam()->GetParameter(),esdTrack->GetConstrainedParam()->GetCovariance());
1497 track->GetPxPyPz(pTrack) ;
1505 else if(fDataType==kAOD)
1507 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
1511 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1512 aodtrack->GetType(),AliAODTrack::kPrimary,
1513 aodtrack->IsHybridGlobalConstrainedGlobal());
1515 if (fSelectHybridTracks && fTrackFilterMaskComplementary == 0)
1517 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
1521 Bool_t accept = aodtrack->TestFilterBit(fTrackFilterMask);
1523 if(!fSelectHybridTracks && !accept) continue ;
1525 if(fSelectHybridTracks)
1527 Bool_t acceptcomplement = aodtrack->TestFilterBit(fTrackFilterMaskComplementary);
1528 if (!accept && !acceptcomplement) continue ;
1532 if(fSelectSPDHitTracks)
1533 {//Not much sense to use with TPC only or Hybrid tracks
1534 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1537 if ( fSelectFractionTPCSharedClusters )
1539 Double_t frac = Double_t(aodtrack->GetTPCnclsS()) / Double_t(aodtrack->GetTPCncls());
1540 if (frac > fCutTPCSharedClustersFraction)
1542 if (fDebug > 2 )printf("\t Reject track, shared cluster fraction %f > %f\n",frac, fCutTPCSharedClustersFraction);
1547 if ( fSelectPrimaryTracks )
1549 if ( aodtrack->GetType()!= AliAODTrack::kPrimary )
1551 if (fDebug > 2 ) printf("\t Remove not primary track\n");
1556 if (fDebug > 2 ) printf("\t accepted track! \n");
1558 //In case of AODs, TPC tracks cannot be propagated back to primary vertex,
1560 dcaTPC = aodtrack->DCA();
1562 track->GetPxPyPz(pTrack) ;
1564 } // aod track exists
1569 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
1571 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
1572 Double_t tof = -1000;
1573 Int_t trackBC = -1000 ;
1577 trackBC = track->GetTOFBunchCrossing(bz);
1578 SetTrackEventBC(trackBC+9);
1580 tof = track->GetTOFsignal()*1e-3;
1585 //normal way to get the dca, cut on dca_xy
1588 Double_t dca[2] = {1e6,1e6};
1589 Double_t covar[3] = {1e6,1e6,1e6};
1590 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1591 if( okDCA) okDCA = AcceptDCA(momentum.Pt(),dca[0]);
1594 //printf("AliCaloTrackReader::FillInputCTS() - Reject track pt %2.2f, dca_xy %2.4f, BC %d\n",momentum.Pt(),dca[0],trackBC);
1602 //SetTrackEventBCcut(bc);
1603 SetTrackEventBCcut(trackBC+9);
1605 //After selecting tracks with small DCA, pointing to vertex, set vertex BC depeding on tracks BC
1606 if(fRecalculateVertexBC)
1608 if (trackBC !=0 && trackBC != AliVTrack::kTOFBCNA) fVertexBC = trackBC;
1609 else if(trackBC == 0) bc0 = kTRUE;
1612 //In any case, the time should to be larger than the fixed window ...
1613 if( fUseTrackTimeCut && (trackBC!=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
1615 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
1618 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1622 //Count the tracks in eta < 0.9
1623 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1624 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1626 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1628 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
1630 if(fDebug > 2 && momentum.Pt() > 0.1)
1631 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks pt %3.2f, phi %3.2f, eta %3.2f\n",
1632 momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1634 if (fMixedEvent) track->SetID(itrack);
1636 if(fAcceptOnlyHIJINGLabels && !IsHIJINGLabel(track->GetLabel())) continue ;
1638 fCTSTracks->Add(track);
1642 if(fVertexBC ==0 || fVertexBC == AliVTrack::kTOFBCNA)
1644 if( bc0 ) fVertexBC = 0 ;
1645 else fVertexBC = AliVTrack::kTOFBCNA ;
1650 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
1654 //_______________________________________________________________________________
1655 void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, Int_t iclus)
1657 //Fill the EMCAL data in the array, do it
1661 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1663 if(fRecalculateClusters)
1665 //Recalibrate the cluster energy
1666 if(GetCaloUtils()->IsRecalibrationOn())
1668 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
1671 //printf("Recalibrated Energy %f\n",clus->E());
1673 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1674 GetCaloUtils()->RecalculateClusterPID(clus);
1678 //Recalculate distance to bad channels, if new list of bad channels provided
1679 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1681 //Recalculate cluster position
1682 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1684 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1685 //clus->GetPosition(pos);
1686 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1690 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1692 Double_t tof = clus->GetTOF();
1694 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1696 if(fDataType==AliCaloTrackReader::kESD)
1698 tof = fEMCALCells->GetCellTime(absIdMax);
1701 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1705 }// Time recalibration
1708 //Reject clusters with bad channels, close to borders and exotic;
1709 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
1711 //Mask all cells in collumns facing ALICE thick material if requested
1712 if(GetCaloUtils()->GetNMaskCellColumns())
1718 Bool_t shared = kFALSE;
1719 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1720 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1723 if(fSelectEmbeddedClusters)
1725 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
1726 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1730 //clus->GetPosition(pos);
1731 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1733 //Correct non linearity
1734 if(fCorrectELinearity && GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1736 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1738 //In case of MC analysis, to match resolution/calibration in real data
1739 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1740 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1741 clus->SetE(rdmEnergy);
1744 Double_t tof = clus->GetTOF()*1e9;
1746 Int_t bc = TMath::Nint(tof/50) + 9;
1747 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1749 SetEMCalEventBC(bc);
1751 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1753 TLorentzVector momentum ;
1755 clus->GetMomentum(momentum, fVertex[vindex]);
1757 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1759 SetEMCalEventBCcut(bc);
1761 if(!IsInTimeWindow(tof,clus->E()))
1763 fNPileUpClusters++ ;
1764 if(fUseEMCALTimeCut) return ;
1767 fNNonPileUpClusters++;
1769 if(fDebug > 2 && momentum.E() > 0.1)
1770 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1771 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1774 clus->SetID(iclus) ;
1776 if(fAcceptOnlyHIJINGLabels && !IsHIJINGLabel( clus->GetLabel() )) return ;
1778 // if(fAcceptOnlyHIJINGLabels)
1780 // printf("Accept label %d?\n",clus->GetLabel());
1782 // if( !IsHIJINGLabel( clus->GetLabel() ) ) { printf("\t Reject label\n") ; return ; }
1783 // else printf("\t Accept label\n") ;
1786 fEMCALClusters->Add(clus);
1790 //_______________________________________
1791 void AliCaloTrackReader::FillInputEMCAL()
1793 //Return array with EMCAL clusters in aod format
1795 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1797 // First recalibrate cells, time or energy
1798 // if(GetCaloUtils()->IsRecalibrationOn())
1799 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1801 // fInputEvent->GetBunchCrossNumber());
1803 fNPileUpClusters = 0; // Init counter
1804 fNNonPileUpClusters = 0; // Init counter
1805 for(Int_t i = 0; i < 19; i++)
1807 fEMCalBCEvent [i] = 0;
1808 fEMCalBCEventCut[i] = 0;
1811 //Loop to select clusters in fiducial cut and fill container with aodClusters
1812 if(fEMCALClustersListName=="")
1814 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1815 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1817 AliVCluster * clus = 0;
1818 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1820 if (IsEMCALCluster(clus))
1822 FillInputEMCALAlgorithm(clus, iclus);
1827 //Recalculate track matching
1828 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
1830 }//Get the clusters from the input event
1833 TClonesArray * clusterList = 0x0;
1835 if (fInputEvent->FindListObject(fEMCALClustersListName))
1837 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
1839 else if(fOutputEvent)
1841 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1846 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1850 Int_t nclusters = clusterList->GetEntriesFast();
1851 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1853 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1854 //printf("E %f\n",clus->E());
1855 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1856 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
1859 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1860 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1862 fNPileUpClusters = 0; // Init counter
1863 fNNonPileUpClusters = 0; // Init counter
1864 for(Int_t i = 0; i < 19; i++)
1866 fEMCalBCEvent [i] = 0;
1867 fEMCalBCEventCut[i] = 0;
1870 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1872 AliVCluster * clus = 0;
1874 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1876 if (IsEMCALCluster(clus))
1880 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1881 Double_t tof = clus->GetTOF();
1882 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1885 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1887 //Reject clusters with bad channels, close to borders and exotic;
1888 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1890 Int_t bc = TMath::Nint(tof/50) + 9;
1891 SetEMCalEventBC(bc);
1893 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1895 TLorentzVector momentum ;
1897 clus->GetMomentum(momentum, fVertex[0]);
1899 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1901 SetEMCalEventBCcut(bc);
1903 if(!IsInTimeWindow(tof,clus->E()))
1904 fNPileUpClusters++ ;
1906 fNNonPileUpClusters++;
1912 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1914 // Recalculate track matching, not necessary if already done in the reclusterization task.
1915 // in case it was not done ...
1916 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
1920 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
1924 //______________________________________
1925 void AliCaloTrackReader::FillInputPHOS()
1927 //Return array with PHOS clusters in aod format
1929 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
1931 //Loop to select clusters in fiducial cut and fill container with aodClusters
1932 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
1933 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1935 AliVCluster * clus = 0;
1936 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1938 if (IsPHOSCluster(clus))
1940 //Check if the cluster contains any bad channel and if close to calorimeter borders
1943 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1944 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1946 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1949 if(fRecalculateClusters)
1951 //Recalibrate the cluster energy
1952 if(GetCaloUtils()->IsRecalibrationOn())
1954 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1959 TLorentzVector momentum ;
1961 clus->GetMomentum(momentum, fVertex[vindex]);
1963 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1965 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
1967 if(fDebug > 2 && momentum.E() > 0.1)
1968 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1969 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1974 clus->SetID(iclus) ;
1977 if(fAcceptOnlyHIJINGLabels && !IsHIJINGLabel(clus->GetLabel())) continue ;
1979 fPHOSClusters->Add(clus);
1985 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1989 //____________________________________________
1990 void AliCaloTrackReader::FillInputEMCALCells()
1992 //Return array with EMCAL cells in aod format
1994 fEMCALCells = fInputEvent->GetEMCALCells();
1998 //___________________________________________
1999 void AliCaloTrackReader::FillInputPHOSCells()
2001 //Return array with PHOS cells in aod format
2003 fPHOSCells = fInputEvent->GetPHOSCells();
2007 //_______________________________________
2008 void AliCaloTrackReader::FillInputVZERO()
2010 //Fill VZERO information in data member, add all the channels information.
2011 AliVVZERO* v0 = fInputEvent->GetVZEROData();
2012 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
2016 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
2017 for (Int_t i = 0; i < 32; i++)
2020 {//Only available in ESDs
2021 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
2022 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
2025 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
2026 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
2029 printf("AliCaloTrackReader::FillInputVZERO() - ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
2034 printf("AliCaloTrackReader::FillInputVZERO() - Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
2038 //_________________________________________________
2039 void AliCaloTrackReader::FillInputNonStandardJets()
2042 //fill array with non standard jets
2046 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputNonStandardJets()\n");
2048 //check if branch name is given
2049 if(!fInputNonStandardJetBranchName.Length())
2051 Printf("No non-standard jet branch name specified. Specify among existing ones.");
2052 fInputEvent->Print();
2056 fNonStandardJets = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(fInputNonStandardJetBranchName.Data()));
2058 if(!fNonStandardJets)
2060 //check if jet branch exist; exit if not
2061 Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fInputNonStandardJetBranchName.Data());
2062 fInputEvent->Print();
2068 printf("AliCaloTrackReader::FillInputNonStandardJets() - aod input jets %d\n", fNonStandardJets->GetEntriesFast() );
2073 //_________________________________________________
2074 void AliCaloTrackReader::FillInputBackgroundJets()
2077 //fill array with Background jets
2081 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputBackgroundJets()\n");
2083 //check if branch name is given
2084 if(!fInputBackgroundJetBranchName.Length())
2086 Printf("No background jet branch name specified. Specify among existing ones.");
2087 fInputEvent->Print();
2091 fBackgroundJets = (AliAODJetEventBackground*)(fInputEvent->FindListObject(fInputBackgroundJetBranchName.Data()));
2093 if(!fBackgroundJets)
2095 //check if jet branch exist; exit if not
2096 Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fInputBackgroundJetBranchName.Data());
2097 fInputEvent->Print();
2103 printf("AliCaloTrackReader::FillInputBackgroundJets()\n");
2104 fBackgroundJets->Print("");
2111 //________________________________________________
2112 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
2114 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
2117 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
2118 if(!event) return kTRUE;
2120 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
2125 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
2128 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
2130 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
2134 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
2136 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
2145 //________________________________________________________________________________
2146 TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
2148 // Select the patches that triggered
2149 // Depend on L0 or L1
2152 Int_t trigtimes[30], globCol, globRow,ntimes, i;
2153 Int_t absId = -1; //[100];
2158 // get object pointer
2159 AliVCaloTrigger *caloTrigger = GetInputEvent()->GetCaloTrigger( "EMCAL" );
2161 //printf("CaloTrigger Entries %d\n",caloTrigger->GetEntries() );
2163 // class is not empty
2164 if( caloTrigger->GetEntries() > 0 )
2166 // must reset before usage, or the class will fail
2167 caloTrigger->Reset();
2169 // go throuth the trigger channels
2170 while( caloTrigger->Next() )
2172 // get position in global 2x2 tower coordinates
2173 caloTrigger->GetPosition( globCol, globRow );
2176 if(IsEventEMCALL0())
2178 // get dimension of time arrays
2179 caloTrigger->GetNL0Times( ntimes );
2181 // no L0s in this channel
2182 // presence of the channel in the iterator still does not guarantee that L0 was produced!!
2187 caloTrigger->GetL0Times( trigtimes );
2188 //printf("Get L0 patch : n times %d - trigger time window %d - %d\n",ntimes, tmin,tmax);
2190 // go through the array
2191 for( i = 0; i < ntimes; i++ )
2193 // check if in cut - 8,9 shall be accepted in 2011
2194 if( trigtimes[i] >= tmin && trigtimes[i] <= tmax )
2196 //printf("Accepted trigger time %d \n",trigtimes[i]);
2197 //if(nTrig > 99) continue;
2198 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol,globRow, absId);
2199 //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
2200 patches.Set(nPatch+1);
2201 patches.AddAt(absId,nPatch++);
2203 } // trigger time array
2205 else if(IsEventEMCALL1()) // L1
2208 caloTrigger->GetTriggerBits(bit);
2211 caloTrigger->GetL1TimeSum(sum);
2213 Bool_t isEGA1 = ((bit >> fBitEGA ) & 0x1) && IsEventEMCALL1Gamma1() ;
2214 Bool_t isEGA2 = ((bit >> (fBitEGA+1)) & 0x1) && IsEventEMCALL1Gamma2() ;
2215 Bool_t isEJE1 = ((bit >> fBitEJE ) & 0x1) && IsEventEMCALL1Jet1 () ;
2216 Bool_t isEJE2 = ((bit >> (fBitEJE+1)) & 0x1) && IsEventEMCALL1Jet2 () ;
2218 if(!isEGA1 && !isEJE1 && !isEGA2 && !isEJE2) continue;
2220 Int_t patchsize = -1;
2221 if (isEGA1 || isEGA2) patchsize = 2;
2222 else if (isEJE1 || isEJE2) patchsize = 16;
2224 //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",
2225 // bit,sum,patchsize,isEGA1,isEGA2,isEJE1,isEJE2,fBitEGA,fBitEJE,IsEventEMCALL1Gamma(),IsEventEMCALL1Jet());
2228 // add 2x2 (EGA) or 16x16 (EJE) patches
2229 for(Int_t irow=0; irow < patchsize; irow++)
2231 for(Int_t icol=0; icol < patchsize; icol++)
2233 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol+icol,globRow+irow, absId);
2234 //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
2235 patches.Set(nPatch+1);
2236 patches.AddAt(absId,nPatch++);
2242 } // trigger iterator
2243 } // go through triggers
2245 if(patches.GetSize()<=0) printf("AliCaloTrackReader::GetTriggerPatches() - No patch found! for triggers: %s and selected <%s>\n",
2246 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data());
2247 //else printf(">>>>> N patches %d, test %d,first %d, last %d\n",patches.GetSize(), nPatch, patches.At(0), patches.At(patches.GetSize()-1));
2252 //______________________________________________________________________
2253 void AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
2255 // Finds the cluster that triggered
2257 // Init info from previous event
2258 fTriggerClusterIndex = -1;
2259 fTriggerClusterId = -1;
2260 fTriggerClusterBC = -10000;
2261 fIsExoticEvent = kFALSE;
2262 fIsBadCellEvent = kFALSE;
2263 fIsBadMaxCellEvent = kFALSE;
2265 fIsTriggerMatch = kFALSE;
2266 fIsTriggerMatchOpenCut[0] = kFALSE;
2267 fIsTriggerMatchOpenCut[1] = kFALSE;
2268 fIsTriggerMatchOpenCut[2] = kFALSE;
2270 // Do only analysis for triggered events
2271 if(!IsEventEMCALL1() && !IsEventEMCALL0())
2273 fTriggerClusterBC = 0;
2277 //printf("***** Try to match trigger to cluster %d **** L0 %d, L1 %d\n",fTriggerPatchClusterMatch,IsEventEMCALL0(),IsEventEMCALL1());
2279 //Recover the list of clusters
2280 TClonesArray * clusterList = 0;
2281 if (fInputEvent->FindListObject(fEMCALClustersListName))
2283 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
2285 else if(fOutputEvent)
2287 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
2290 // Get number of clusters and of trigger patches
2291 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
2293 nclusters = clusterList->GetEntriesFast();
2295 Int_t nPatch = patches.GetSize();
2296 Float_t exoDiffTime = GetCaloUtils()->GetEMCALRecoUtils()->GetExoticCellDiffTimeCut();
2298 //Init some variables used in the cluster loop
2299 Float_t tofPatchMax = 100000;
2300 Float_t ePatchMax =-1;
2302 Float_t tofMax = 100000;
2306 Int_t idclusMax =-1;
2307 Bool_t badClMax = kFALSE;
2308 Bool_t badCeMax = kFALSE;
2309 Bool_t exoMax = kFALSE;
2310 // Int_t absIdMaxTrig= -1;
2311 Int_t absIdMaxMax = -1;
2313 Int_t nOfHighECl = 0 ;
2315 Float_t minE = fTriggerEventThreshold / 2.;
2316 // This method is not really suitable for JET trigger
2317 // but in case, reduce the energy cut since we do not trigger on high energy particle
2318 if(IsEventEMCALL1Jet() || minE < 1) minE = 1;
2320 //printf("Min trigger Energy threshold %f\n",minE);
2322 // Loop on the clusters, check if there is any that falls into one of the patches
2323 for (Int_t iclus = 0; iclus < nclusters; iclus++)
2325 AliVCluster * clus = 0;
2326 if(clusterList) clus = (AliVCluster*) clusterList->At(iclus);
2327 else clus = fInputEvent->GetCaloCluster(iclus);
2329 if ( !clus ) continue ;
2331 if ( !IsEMCALCluster(clus)) continue ;
2333 //Skip clusters with too low energy to be triggering
2334 if ( clus->E() < minE ) continue ;
2337 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fInputEvent->GetEMCALCells(), clus,frac);
2339 Bool_t badCluster = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),
2340 clus->GetCellsAbsId(),clus->GetNCells());
2341 UShort_t cellMax[] = {(UShort_t) absIdMax};
2342 Bool_t badCell = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),cellMax,1);
2344 // if cell is bad, it can happen that time calibration is not available,
2345 // when calculating if it is exotic, this can make it to be exotic by default
2346 // open it temporarily for this cluster
2348 GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(10000000);
2350 Bool_t exotic = GetCaloUtils()->GetEMCALRecoUtils()->IsExoticCluster(clus, fInputEvent->GetEMCALCells());
2352 // Set back the time cut on exotics
2354 GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(exoDiffTime);
2356 // Energy threshold for exotic Ecross typically at 4 GeV,
2357 // for lower energy, check that there are more than 1 cell in the cluster
2358 if(!exotic && clus->GetNCells() < 2) exotic = kTRUE;
2360 Float_t energy = clus->E();
2361 Int_t idclus = clus->GetID();
2363 Double_t tof = clus->GetTOF();
2364 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn() && fTriggerClusterTimeRecal)
2365 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
2368 //printf("cluster %d, ID %d, E %2.2f, tof %2.2f, AbsId max %d, exotic %d, bad Cluster %d, bad Cell %d\n",
2369 // iclus,idclus, energy,tof,absIdMax, exotic, badCluster,badCell);
2371 // Find the highest energy cluster, avobe trigger threshold
2372 // in the event in case no match to trigger is found
2377 badClMax = badCluster;
2382 absIdMaxMax = absIdMax;
2385 // count the good clusters in the event avobe the trigger threshold
2386 // to check the exotic events
2387 if(!badCluster && !exotic)
2390 // Find match to trigger
2391 if(fTriggerPatchClusterMatch && nPatch>0)
2393 for(Int_t iabsId =0; iabsId < nPatch; iabsId++)
2396 GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patches.At(iabsId), absIDCell);
2397 //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
2398 // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
2400 for(Int_t ipatch = 0; ipatch < 4; ipatch++)
2402 if(absIdMax == absIDCell[ipatch])
2404 //printf("*** Patches : absId %d, E %2.1f, tof %f \n",absIdMax,clus->E(), tof);
2405 if(energy > ePatchMax)
2409 fIsBadCellEvent = badCluster;
2410 fIsBadMaxCellEvent = badCell;
2411 fIsExoticEvent = exotic;
2412 fTriggerClusterIndex = iclus;
2413 fTriggerClusterId = idclus;
2414 fIsTriggerMatch = kTRUE;
2415 // absIdMaxTrig = absIdMax;
2419 }// trigger patch loop
2420 } // Do trigger patch matching
2424 // If there was no match, assign as trigger
2425 // the highest energy cluster in the event
2426 if(!fIsTriggerMatch)
2428 tofPatchMax = tofMax;
2430 fIsBadCellEvent = badClMax;
2431 fIsBadMaxCellEvent = badCeMax;
2432 fIsExoticEvent = exoMax;
2433 fTriggerClusterIndex = clusMax;
2434 fTriggerClusterId = idclusMax;
2437 Double_t tofPatchMaxUS = TMath::Abs(tofPatchMax);
2439 if (tofPatchMaxUS < 28 ) fTriggerClusterBC = 0 ;
2440 else if(tofPatchMaxUS < 75 ) fTriggerClusterBC = 1 ;
2441 else if(tofPatchMaxUS < 125) fTriggerClusterBC = 2 ;
2442 else if(tofPatchMaxUS < 175) fTriggerClusterBC = 3 ;
2443 else if(tofPatchMaxUS < 225) fTriggerClusterBC = 4 ;
2444 else if(tofPatchMaxUS < 275) fTriggerClusterBC = 5 ;
2447 //printf("AliCaloTrackReader::MatchTriggerCluster() - Large BC - tof %2.3f - Index %d\n",tofPatchMaxUS,fTriggerClusterIndex);
2448 if(fTriggerClusterIndex >= 0) fTriggerClusterBC = 6 ;
2451 fTriggerClusterIndex = -2;
2452 fTriggerClusterId = -2;
2456 if(tofPatchMax < 0) fTriggerClusterBC*=-1;
2459 // 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",
2460 // fTriggerClusterIndex, fTriggerClusterId,ePatchMax, tofPatchMax,
2461 // fTriggerClusterBC, fIsBadCellEvent,fIsBadMaxCellEvent,fIsExoticEvent, fIsTriggerMatch, nOfHighECl,absIdMaxMax);
2463 // 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",
2464 // clusMax, idclusMax, eMax,tofMax, badClMax, badCeMax,exoMax);
2466 //Redo matching but open cuts
2467 if(!fIsTriggerMatch && fTriggerClusterId >= 0)
2469 // Open time patch time
2470 TArrayI patchOpen = GetTriggerPatches(7,10);
2473 Int_t patchAbsIdOpenTime = -1;
2474 for(Int_t iabsId =0; iabsId < patchOpen.GetSize(); iabsId++)
2477 patchAbsIdOpenTime = patchOpen.At(iabsId);
2478 GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patchAbsIdOpenTime, absIDCell);
2479 //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
2480 // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
2482 for(Int_t ipatch = 0; ipatch < 4; ipatch++)
2484 if(absIdMaxMax == absIDCell[ipatch])
2486 fIsTriggerMatchOpenCut[0] = kTRUE;
2490 }// trigger patch loop
2492 // Check neighbour patches
2493 Int_t patchAbsId = -1;
2494 Int_t globalCol = -1;
2495 Int_t globalRow = -1;
2496 GetCaloUtils()->GetEMCALGeometry()->GetFastORIndexFromCellIndex(absIdMaxMax, patchAbsId);
2497 GetCaloUtils()->GetEMCALGeometry()->GetPositionInEMCALFromAbsFastORIndex(patchAbsId,globalCol,globalRow);
2499 // Check patches with strict time cut
2500 Int_t patchAbsIdNeigh = -1;
2501 for(Int_t icol = globalCol-1; icol <= globalCol+1; icol++)
2503 if(icol < 0 || icol > 47) continue;
2505 for(Int_t irow = globalRow; irow <= globalRow+1; irow++)
2507 if(irow < 0 || irow > 63) continue;
2509 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, patchAbsIdNeigh);
2511 if ( patchAbsIdNeigh < 0 ) continue;
2513 for(Int_t iabsId =0; iabsId < patches.GetSize(); iabsId++)
2515 if(patchAbsIdNeigh == patches.At(iabsId))
2517 fIsTriggerMatchOpenCut[1] = kTRUE;
2520 }// trigger patch loop
2525 // Check patches with open time cut
2526 Int_t patchAbsIdNeighOpenTime = -1;
2527 for(Int_t icol = globalCol-1; icol <= globalCol+1; icol++)
2529 if(icol < 0 || icol > 47) continue;
2531 for(Int_t irow = globalRow; irow <= globalRow+1; irow++)
2533 if(irow < 0 || irow > 63) continue;
2535 GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, patchAbsIdNeighOpenTime);
2537 if ( patchAbsIdNeighOpenTime < 0 ) continue;
2539 for(Int_t iabsId =0; iabsId < patchOpen.GetSize(); iabsId++)
2541 if(patchAbsIdNeighOpenTime == patchOpen.At(iabsId))
2543 fIsTriggerMatchOpenCut[2] = kTRUE;
2546 }// trigger patch loop
2551 // printf("No match, new match: Open time %d-%d, open Neigh %d-%d, both open %d-%d\n",fIsTriggerMatchOpenCut[0],patchAbsIdOpenTime,
2552 // fIsTriggerMatchOpenCut[1],patchAbsIdNeigh,
2553 // fIsTriggerMatchOpenCut[2],patchAbsIdNeighOpenTime);
2557 }// No trigger match found
2558 //printf("Trigger BC %d, Id %d, Index %d\n",fTriggerClusterBC,fTriggerClusterId,fTriggerClusterIndex);
2562 //________________________________________________________
2563 void AliCaloTrackReader::Print(const Option_t * opt) const
2566 //Print some relevant parameters set for the analysis
2570 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
2571 printf("Task name : %s\n", fTaskName.Data()) ;
2572 printf("Data type : %d\n", fDataType) ;
2573 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
2574 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
2575 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
2576 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
2577 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
2578 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
2579 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
2580 printf("Use CTS = %d\n", fFillCTS) ;
2581 printf("Use EMCAL = %d\n", fFillEMCAL) ;
2582 printf("Use PHOS = %d\n", fFillPHOS) ;
2583 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
2584 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
2585 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
2586 printf("AODs Track filter mask = %d or hybrid %d (if filter bit comp %d), select : SPD hit %d, primary %d\n",
2587 (Int_t) fTrackFilterMask, fSelectHybridTracks, (Int_t) fTrackFilterMaskComplementary, fSelectSPDHitTracks,fSelectPrimaryTracks) ;
2588 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
2589 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
2590 printf("Recalculate Clusters = %d, E linearity = %d\n", fRecalculateClusters, fCorrectELinearity) ;
2592 printf("Use Triggers selected in SE base class %d; If not what Trigger Mask? %d; MB Trigger Mask for mixed %d \n",
2593 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
2595 if(fComparePtHardAndClusterPt)
2596 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
2598 if(fComparePtHardAndClusterPt)
2599 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
2601 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
2602 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
2603 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
2609 //__________________________________________
2610 Bool_t AliCaloTrackReader::RejectLEDEvents()
2612 // LED Events in period LHC11a contaminated sample, simple method
2613 // to reject such events
2615 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
2616 Int_t ncellsSM3 = 0;
2617 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
2619 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
2620 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
2621 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
2624 Int_t ncellcut = 21;
2625 if(GetFiredTriggerClasses().Contains("EMC")) ncellcut = 35;
2627 if(ncellsSM3 >= ncellcut)
2630 printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d, cut %d, trig %s\n",
2631 ncellsSM3,ncellcut,GetFiredTriggerClasses().Data());
2639 //_________________________________________________________
2640 void AliCaloTrackReader::RemapMCLabelForAODs(Int_t & label)
2642 // MC label for Cells not remapped after ESD filtering, do it here.
2644 if(label < 0) return ;
2646 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
2649 TClonesArray * arr = dynamic_cast<TClonesArray*>(evt->FindListObject("mcparticles")) ;
2652 if(label < arr->GetEntriesFast())
2654 AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(label));
2655 if(!particle) return ;
2657 if(label == particle->Label()) return ; // label already OK
2658 //else printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label %d - AOD stack %d \n",label, particle->Label());
2660 //else printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label %d > AOD labels %d \n",label, arr->GetEntriesFast());
2662 // loop on the particles list and check if there is one with the same label
2663 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
2665 AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(ind));
2666 if(!particle) continue ;
2668 if(label == particle->Label())
2671 //printf("AliAnalysisTaskEMCALClusterize::RemapMCLabelForAODs() - New Label Index %d \n",label);
2678 //printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label not found set to -1 \n");
2683 //___________________________________
2684 void AliCaloTrackReader::ResetLists()
2686 // Reset lists, called by the analysis maker
2688 if(fCTSTracks) fCTSTracks -> Clear();
2689 if(fEMCALClusters) fEMCALClusters -> Clear("C");
2690 if(fPHOSClusters) fPHOSClusters -> Clear("C");
2692 fV0ADC[0] = 0; fV0ADC[1] = 0;
2693 fV0Mul[0] = 0; fV0Mul[1] = 0;
2695 if(fNonStandardJets) fNonStandardJets -> Clear("C");
2696 fBackgroundJets->Reset();
2700 //___________________________________________
2701 void AliCaloTrackReader::SetEventTriggerBit()
2703 // Tag event depeding on trigger name
2705 fEventTrigMinBias = kFALSE;
2706 fEventTrigCentral = kFALSE;
2707 fEventTrigSemiCentral = kFALSE;
2708 fEventTrigEMCALL0 = kFALSE;
2709 fEventTrigEMCALL1Gamma1 = kFALSE;
2710 fEventTrigEMCALL1Gamma2 = kFALSE;
2711 fEventTrigEMCALL1Jet1 = kFALSE;
2712 fEventTrigEMCALL1Jet2 = kFALSE;
2715 printf("AliCaloTrackReader::SetEventTriggerBit() - Select trigger mask bit %d - Trigger Event %s - Select <%s>\n",
2716 fEventTriggerMask,GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data());
2718 if(fEventTriggerMask <=0 )// in case no mask set
2720 // EMC triggered event? Which type?
2721 if( GetFiredTriggerClasses().Contains("-B-") || GetFiredTriggerClasses().Contains("-S-") || GetFiredTriggerClasses().Contains("-I-") )
2723 if ( GetFiredTriggerClasses().Contains("EGA" ) ||
2724 GetFiredTriggerClasses().Contains("EG1" ) )
2726 fEventTrigEMCALL1Gamma1 = kTRUE;
2727 if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
2729 else if( GetFiredTriggerClasses().Contains("EG2" ) )
2731 fEventTrigEMCALL1Gamma2 = kTRUE;
2732 if( !fFiredTriggerClassName.Contains("EG2") ) fEventTrigEMCALL1Gamma2 = kFALSE;
2734 else if( GetFiredTriggerClasses().Contains("EJE" ) ||
2735 GetFiredTriggerClasses().Contains("EJ1" ) )
2737 fEventTrigEMCALL1Jet1 = kTRUE;
2738 if( GetFiredTriggerClasses().Contains("EJ1" ) && !fFiredTriggerClassName.Contains("EJ1") )
2739 fEventTrigEMCALL1Jet1 = kFALSE;
2741 else if( GetFiredTriggerClasses().Contains("EJ2" ) )
2743 fEventTrigEMCALL1Jet2 = kTRUE;
2744 if( !fFiredTriggerClassName.Contains("EJ2") ) fEventTrigEMCALL1Jet2 = kFALSE;
2746 else if( GetFiredTriggerClasses().Contains("CEMC") &&
2747 !GetFiredTriggerClasses().Contains("EGA" ) &&
2748 !GetFiredTriggerClasses().Contains("EJE" ) &&
2749 !GetFiredTriggerClasses().Contains("EG1" ) &&
2750 !GetFiredTriggerClasses().Contains("EJ1" ) &&
2751 !GetFiredTriggerClasses().Contains("EG2" ) &&
2752 !GetFiredTriggerClasses().Contains("EJ2" ) )
2754 fEventTrigEMCALL0 = kTRUE;
2757 //Min bias event trigger?
2758 if (GetFiredTriggerClasses().Contains("CCENT_R2-B-NOPF-ALLNOTRD"))
2760 fEventTrigCentral = kTRUE;
2762 else if(GetFiredTriggerClasses().Contains("CSEMI_R1-B-NOPF-ALLNOTRD"))
2764 fEventTrigSemiCentral = kTRUE;
2766 else if((GetFiredTriggerClasses().Contains("CINT") || GetFiredTriggerClasses().Contains("CPBI2_B1") ) &&
2767 GetFiredTriggerClasses().Contains("-NOPF-ALLNOTRD") )
2769 fEventTrigMinBias = kTRUE;
2776 if ( fEventTriggerMask & AliVEvent::kEMCEGA )
2778 //printf("EGA trigger bit\n");
2779 if (GetFiredTriggerClasses().Contains("EG"))
2781 if (GetFiredTriggerClasses().Contains("EGA")) fEventTrigEMCALL1Gamma1 = kTRUE;
2784 if(GetFiredTriggerClasses().Contains("EG1")) fEventTrigEMCALL1Gamma1 = kTRUE;
2785 if(GetFiredTriggerClasses().Contains("EG2")) fEventTrigEMCALL1Gamma2 = kTRUE;
2790 else if( fEventTriggerMask & AliVEvent::kEMCEJE )
2792 //printf("EGA trigger bit\n");
2793 if (GetFiredTriggerClasses().Contains("EJ"))
2795 if (GetFiredTriggerClasses().Contains("EJE")) fEventTrigEMCALL1Jet1 = kTRUE;
2798 if(GetFiredTriggerClasses().Contains("EJ1")) fEventTrigEMCALL1Jet1 = kTRUE;
2799 if(GetFiredTriggerClasses().Contains("EJ2")) fEventTrigEMCALL1Jet2 = kTRUE;
2804 else if((fEventTriggerMask & AliVEvent::kEMC7) ||
2805 (fEventTriggerMask & AliVEvent::kEMC1) )
2807 //printf("L0 trigger bit\n");
2808 fEventTrigEMCALL0 = kTRUE;
2811 else if( fEventTriggerMask & AliVEvent::kCentral )
2813 //printf("MB semi central trigger bit\n");
2814 fEventTrigSemiCentral = kTRUE;
2817 else if( fEventTriggerMask & AliVEvent::kSemiCentral )
2819 //printf("MB central trigger bit\n");
2820 fEventTrigCentral = kTRUE;
2822 // Min Bias pp, PbPb, pPb
2823 else if((fEventTriggerMask & AliVEvent::kMB ) ||
2824 (fEventTriggerMask & AliVEvent::kINT7) ||
2825 (fEventTriggerMask & AliVEvent::kINT8) ||
2826 (fEventTriggerMask & AliVEvent::kAnyINT) )
2828 //printf("MB trigger bit\n");
2829 fEventTrigMinBias = kTRUE;
2834 printf("AliCaloTrackReader::SetEventTriggerBit() - Event bits: \n \t MB %d, Cen %d, Sem %d, L0 %d, L1G1 %d, L1G2 %d, L1J1 %d, L1J2 %d \n",
2835 fEventTrigMinBias, fEventTrigCentral, fEventTrigSemiCentral,
2836 fEventTrigEMCALL0 , fEventTrigEMCALL1Gamma1, fEventTrigEMCALL1Gamma2,
2837 fEventTrigEMCALL1Jet1 , fEventTrigEMCALL1Jet2);
2839 if(fBitEGA == 0 && fBitEJE ==0)
2841 // Init the trigger bit once, correct depending on AliESDAODCaloTrigger header version
2846 TFile* file = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
2848 const TList *clist = file->GetStreamerInfoCache();
2852 TStreamerInfo *cinfo = (TStreamerInfo*)clist->FindObject("AliESDCaloTrigger");
2853 Int_t verid = 5; // newer ESD header version
2856 cinfo = (TStreamerInfo*)clist->FindObject("AliAODCaloTrigger");
2857 verid = 2; // newer AOD header version
2861 Int_t classversionid = cinfo->GetClassVersion();
2862 //printf("********* Header class version %d *********** \n",classversionid);
2864 if (classversionid >= verid)
2869 } else printf("AliCaloTrackReader()::SetEventTriggerBit() - Streamer info for trigger class not available, bit not changed\n");
2870 } else printf("AliCaloTrackReader::SetEventTriggerBit() - Streamer list not available!, bit not changed\n");
2872 } // set once the EJE, EGA trigger bit
2876 //____________________________________________________________
2877 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
2879 fInputEvent = input;
2880 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
2882 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
2884 //Delete previous vertex
2887 for (Int_t i = 0; i < fNMixedEvent; i++)
2889 delete [] fVertex[i] ;
2894 fVertex = new Double_t*[fNMixedEvent] ;
2895 for (Int_t i = 0; i < fNMixedEvent; i++)
2897 fVertex[i] = new Double_t[3] ;
2898 fVertex[i][0] = 0.0 ;
2899 fVertex[i][1] = 0.0 ;
2900 fVertex[i][2] = 0.0 ;
2904 //____________________________________________________________
2905 void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
2909 if(fESDtrackCuts) delete fESDtrackCuts ;
2911 fESDtrackCuts = cuts ;
2915 //_________________________________________________________________________
2916 void AliCaloTrackReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
2918 // Set Track cuts for complementary tracks (hybrids)
2920 if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
2922 fESDtrackComplementaryCuts = cuts ;