]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/CaloTrackCorrBase/AliCaloTrackReader.cxx
add posibility to accept ESD events depending on time stamp
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliCaloTrackReader.cxx
CommitLineData
1c5acb87 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
1c5acb87 15
16//_________________________________________________________________________
17// Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and
18// Central Barrel Tracking detectors (CTS).
ff45398a 19// Not all MC particles/tracks/clusters are kept, some kinematical/fiducial restrictions are done.
591cc579 20// Mother class of : AliCaloTrackESDReader: Fills ESD data in 3 TObjArrays (PHOS, EMCAL, CTS)
743aa53a 21// : AliCaloTrackMCReader : Fills Kinematics data in 3 TObjArrays (PHOS, EMCAL, CTS)
22// : AliCaloTrackAODReader: Fills AOD data in 3 TObjArrays (PHOS, EMCAL, CTS)
1c5acb87 23//-- Author: Gustavo Conesa (LNF-INFN)
24//////////////////////////////////////////////////////////////////////////////
25
26
27// --- ROOT system ---
49b53920 28#include <TFile.h>
de0b770d 29#include <TGeoManager.h>
1c5acb87 30
c5693f62 31// ---- ANALYSIS system ----
477d6cee 32#include "AliMCEvent.h"
591cc579 33#include "AliAODMCHeader.h"
34#include "AliGenPythiaEventHeader.h"
48c37e02 35#include "AliESDEvent.h"
8dacfd76 36#include "AliAODEvent.h"
c8fe2783 37#include "AliVTrack.h"
38#include "AliVParticle.h"
39#include "AliMixedEvent.h"
0ae57829 40#include "AliESDtrack.h"
3a58eee6 41#include "AliESDtrackCuts.h"
48c37e02 42#include "AliTriggerAnalysis.h"
37285e29 43#include "AliESDVZERO.h"
c5693f62 44#include "AliVCaloCells.h"
029dea5a 45#include "AliAnalysisManager.h"
46#include "AliInputEventHandler.h"
1c5acb87 47
c5693f62 48// ---- Detectors ----
49#include "AliPHOSGeoUtils.h"
50#include "AliEMCALGeometry.h"
f3138ecf 51#include "AliEMCALRecoUtils.h"
c5693f62 52
0de1814a 53// ---- CaloTrackCorr ---
c5693f62 54#include "AliCalorimeterUtils.h"
cfaba834 55#include "AliCaloTrackReader.h"
56
1c5acb87 57ClassImp(AliCaloTrackReader)
58
59
836b6989 60//________________________________________
61AliCaloTrackReader::AliCaloTrackReader() :
62TObject(), fEventNumber(-1), //fCurrentFileName(""),
63fDataType(0), fDebug(0),
64fFiducialCut(0x0), fCheckFidCut(kFALSE),
de0b770d 65fComparePtHardAndJetPt(0), fPtHardAndJetPtFactor(0),
dbb3de7b 66fComparePtHardAndClusterPt(0),fPtHardAndClusterPtFactor(0),
836b6989 67fCTSPtMin(0), fEMCALPtMin(0), fPHOSPtMin(0),
4b7f6e01 68fCTSPtMax(0), fEMCALPtMax(0), fPHOSPtMax(0),
69fUseEMCALTimeCut(1), fUseParamTimeCut(0), fUseTrackTimeCut(0),
d2655d46 70fEMCALTimeCutMin(-10000), fEMCALTimeCutMax(10000),
ff440946 71fEMCALParamTimeCutMin(), fEMCALParamTimeCutMax(),
975b29fa 72fTrackTimeCutMin(-10000), fTrackTimeCutMax(10000),
689d9f15 73fUseTrackDCACut(0),
f3138ecf 74fAODBranchList(0x0),
75fCTSTracks(0x0), fEMCALClusters(0x0), fPHOSClusters(0x0),
836b6989 76fEMCALCells(0x0), fPHOSCells(0x0),
77fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
78fFillCTS(0), fFillEMCAL(0), fFillPHOS(0),
79fFillEMCALCells(0), fFillPHOSCells(0),
80fRecalculateClusters(kFALSE),fSelectEmbeddedClusters(kFALSE),
21812953 81fTrackStatus(0), fTrackFilterMask(0),
f5500c7a 82fESDtrackCuts(0), fConstrainTrack(kFALSE),
83fSelectHybridTracks(0), fSelectSPDHitTracks(kFALSE),
836b6989 84fTrackMult(0), fTrackMultEtaCut(0.8),
85fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
029dea5a 86fDeltaAODFileName(""), fFiredTriggerClassName(""),
790dea42 87fEventTriggerMask(0), fMixEventTriggerMask(0), fEventTriggerAtSE(0),
029dea5a 88fAnaLED(kFALSE),
836b6989 89fTaskName(""), fCaloUtils(0x0),
de0b770d 90fMixedEvent(NULL), fNMixedEvent(0), fVertex(NULL),
d783becb 91fListMixedTracksEvents(), fListMixedCaloEvents(),
92fLastMixedTracksEvent(-1), fLastMixedCaloEvent(-1),
836b6989 93fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE), fCaloFilterPatch(kFALSE),
94fEMCALClustersListName(""), fZvtxCut(0.),
55d66f31 95fAcceptFastCluster(kFALSE), fRemoveLEDEvents(kTRUE),
836b6989 96fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
034e885b 97fTriggerAnalysis (0x0), fTimeStampEventSelect(0),
98fTimeStampEventFracMin(0), fTimeStampEventFracMax(0),
99fTimeStampRunMin(0), fTimeStampRunMax(0),
3c1a2e95 100fNPileUpClusters(-1), fNNonPileUpClusters(-1), fNPileUpClustersCut(3),
de0b770d 101fCentralityClass(""), fCentralityOpt(0),
102fEventPlaneMethod(""), fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
af7b3903 103{
1c5acb87 104 //Ctor
f3138ecf 105
1c5acb87 106 //Initialize parameters
107 InitParameters();
108}
1c5acb87 109
836b6989 110//_______________________________________
111AliCaloTrackReader::~AliCaloTrackReader()
112{
1c5acb87 113 //Dtor
114
743aa53a 115 delete fFiducialCut ;
29b2ceec 116
d2655d46 117 if(fAODBranchList)
118 {
f37fa8d2 119 fAODBranchList->Delete();
120 delete fAODBranchList ;
121 }
122
d2655d46 123 if(fCTSTracks)
124 {
be518ab0 125 if(fDataType!=kMC)fCTSTracks->Clear() ;
126 else fCTSTracks->Delete() ;
127 delete fCTSTracks ;
1c5acb87 128 }
129
d2655d46 130 if(fEMCALClusters)
131 {
be518ab0 132 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
133 else fEMCALClusters->Delete() ;
134 delete fEMCALClusters ;
1c5acb87 135 }
136
029dea5a 137 if(fPHOSClusters)
138 {
be518ab0 139 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
140 else fPHOSClusters->Delete() ;
141 delete fPHOSClusters ;
1c5acb87 142 }
143
d2655d46 144 if(fVertex)
145 {
146 for (Int_t i = 0; i < fNMixedEvent; i++)
147 {
7e25653f 148 delete [] fVertex[i] ;
836b6989 149
7e25653f 150 }
151 delete [] fVertex ;
152 }
836b6989 153
743aa53a 154 delete fESDtrackCuts;
155 delete fTriggerAnalysis;
3a58eee6 156
836b6989 157 // Pointers not owned, done by the analysis frame
158 // if(fInputEvent) delete fInputEvent ;
159 // if(fOutputEvent) delete fOutputEvent ;
160 // if(fMC) delete fMC ;
161 // Pointer not owned, deleted by maker
162 // if (fCaloUtils) delete fCaloUtils ;
163
c1ac3823 164}
477d6cee 165
836b6989 166//________________________________________________
167Bool_t AliCaloTrackReader::ComparePtHardAndJetPt()
168{
dbb3de7b 169 // Check the event, if the requested ptHard is much smaller than the jet pT, then there is a problem.
90995603 170 // Only for PYTHIA.
a20fbb55 171
172 //printf("AliCaloTrackReader::ComparePtHardAndJetPt() - GenHeaderName : %s\n",GetGenEventHeader()->ClassName());
90995603 173
d2655d46 174 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
175 {
90995603 176 TParticle * jet = 0;
177 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
178 Int_t nTriggerJets = pygeh->NTriggerJets();
179 Float_t ptHard = pygeh->GetPtHard();
180
a20fbb55 181 if(fDebug > 1)
182 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
183
898c9d44 184 Float_t tmpjet[]={0,0,0,0};
d2655d46 185 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++)
186 {
90995603 187 pygeh->TriggerJet(ijet, tmpjet);
188 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
a20fbb55 189
190 if(fDebug > 1)
191 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - jet %d; pycell jet pT %f\n",ijet, jet->Pt());
192
90995603 193 //Compare jet pT and pt Hard
d2655d46 194 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard)
195 {
a20fbb55 196 printf("AliCaloTrackReader::ComparePtHardAndJetPt() - Reject jet event with : pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
197 ptHard, jet->Pt(), fPtHardAndJetPtFactor);
cfaba834 198 return kFALSE;
90995603 199 }
200 }
a20fbb55 201
898c9d44 202 if(jet) delete jet;
90995603 203 }
204
205 return kTRUE ;
206
591cc579 207}
208
dbb3de7b 209//____________________________________________________________________
210Bool_t AliCaloTrackReader::ComparePtHardAndClusterPt()
211{
212 // Check the event, if the requested ptHard is smaller than the calorimeter cluster E, then there is a problem.
213 // Only for PYTHIA.
214
215 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader"))
216 {
217 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
218 Float_t ptHard = pygeh->GetPtHard();
219
220 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
221 for (Int_t iclus = 0; iclus < nclusters; iclus++)
222 {
223 AliVCluster * clus = fInputEvent->GetCaloCluster(iclus) ;
224 Float_t ecluster = clus->E();
225
226 if(ecluster > fPtHardAndClusterPtFactor*ptHard)
227 {
228 printf("AliCaloTrackReader::ComparePtHardAndClusterPt() - Reject : ecluster %2.2f, calo %d, factor %2.2f, ptHard %f\n",ecluster,clus->GetType(),fPtHardAndClusterPtFactor,ptHard);
229
230 return kFALSE;
231 }
232 }
233
234 }
235
236 return kTRUE ;
237
238}
239
836b6989 240//____________________________________________
241AliStack* AliCaloTrackReader::GetStack() const
242{
1c5acb87 243 //Return pointer to stack
244 if(fMC)
245 return fMC->Stack();
d2655d46 246 else
247 {
477d6cee 248 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
1c5acb87 249 return 0x0 ;
250 }
251}
252
43074325 253//__________________________________________________
254TString AliCaloTrackReader::GetFiredTriggerClasses()
255{
256 // List of triggered classes in a TString
257
258 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (GetInputEvent());
259 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (GetInputEvent());
260
261 if (esdevent) return esdevent->GetFiredTriggerClasses();
262 else if(aodevent) return aodevent->GetFiredTriggerClasses();
263 else return ""; // Mixed Event, MC event, does not have this trigger info
264
265}
266
836b6989 267//______________________________________________
268AliHeader* AliCaloTrackReader::GetHeader() const
269{
1c5acb87 270 //Return pointer to header
271 if(fMC)
029dea5a 272 {
1c5acb87 273 return fMC->Header();
029dea5a 274 }
275 else
276 {
477d6cee 277 printf("AliCaloTrackReader::Header is not available\n");
1c5acb87 278 return 0x0 ;
279 }
280}
836b6989 281
282//______________________________________________________________
283AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const
284{
1c5acb87 285 //Return pointer to Generated event header
f1da7b44 286 if (ReadStack() && fMC)
029dea5a 287 {
1c5acb87 288 return fMC->GenEventHeader();
029dea5a 289 }
f1da7b44 290 else if(ReadAODMCParticles() && GetAODMCHeader())
291 {
292 //printf("AliCaloTrackReader::GetGenEventHeader() - N headers %d\n",GetAODMCHeader()->GetNCocktailHeaders());
293 if( GetAODMCHeader()->GetNCocktailHeaders() > 0)
294 return GetAODMCHeader()->GetCocktailHeader(0) ;
a20fbb55 295 else
f1da7b44 296 return 0x0;
297 }
298 else
299 {
ec58c056 300 //printf("AliCaloTrackReader::GetGenEventHeader() - MC header not available! \n");
f1da7b44 301 return 0;
1c5acb87 302 }
303}
304
836b6989 305//____________________________________________________________________
306TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const
307{
1e68a3f4 308 //Return list of particles in AOD. Do it for the corresponding input event.
309
c8fe2783 310 TClonesArray * rv = NULL ;
029dea5a 311 if(fDataType == kAOD)
312 {
313 if(input == 0)
314 {
1e68a3f4 315 //Normal input AOD
316 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
317 if(evt)
318 rv = (TClonesArray*)evt->FindListObject("mcparticles");
319 else
320 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
743aa53a 321 }
1e68a3f4 322
029dea5a 323 }
324 else
325 {
836b6989 326 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
c8fe2783 327 }
1e68a3f4 328
c8fe2783 329 return rv ;
591cc579 330}
331
a20fbb55 332//________________________________________________________
333AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader() const
836b6989 334{
90995603 335 //Return MC header in AOD. Do it for the corresponding input event.
d2655d46 336
1e68a3f4 337 AliAODMCHeader *mch = NULL;
d2655d46 338
339 if(fDataType == kAOD)
340 {
a20fbb55 341 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
342 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
90995603 343 }
d2655d46 344 else
345 {
90995603 346 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
347 }
1e68a3f4 348
349 return mch;
591cc579 350}
351
836b6989 352//_____________________________
591cc579 353void AliCaloTrackReader::Init()
354{
90995603 355 //Init reader. Method to be called in AliAnaPartCorrMaker
de0b770d 356
357 //printf(" AliCaloTrackReader::Init() %p \n",gGeoManager);
358
55d66f31 359 if(fReadStack && fReadAODMCParticles)
360 {
90995603 361 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
de0b770d 362 fReadStack = kFALSE;
90995603 363 fReadAODMCParticles = kFALSE;
364 }
365
de0b770d 366 // Init geometry, I do not like much to do it like this ...
55d66f31 367 if(fImportGeometryFromFile && !gGeoManager)
368 {
2d8f2b73 369 if(fImportGeometryFilePath=="") // If not specified, set a default location
eef481c6 370 fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
2d8f2b73 371
55d66f31 372 printf("AliCaloTrackReader::Init() - Import %s\n",fImportGeometryFilePath.Data());
373 TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!!
de0b770d 374 }
375
591cc579 376}
765d44e7 377
836b6989 378//_______________________________________
1c5acb87 379void AliCaloTrackReader::InitParameters()
380{
1c5acb87 381 //Initialize the parameters of the analysis.
591cc579 382 fDataType = kESD ;
98ec971d 383 fCTSPtMin = 0.1 ;
384 fEMCALPtMin = 0.1 ;
385 fPHOSPtMin = 0.1 ;
386 fCTSPtMax = 1000. ;
387 fEMCALPtMax = 1000. ;
388 fPHOSPtMax = 1000. ;
389
689d9f15 390 //Track DCA cuts
391 fTrackDCACut[0] = 3; //xy, quite large
392 fTrackDCACut[1] = 3; //z, quite large
393 fTrackDCACut[2] = 3; //TPC constrained, quite large
394
902aa95c 395 //Do not filter the detectors input by default.
396 fFillEMCAL = kFALSE;
397 fFillPHOS = kFALSE;
398 fFillCTS = kFALSE;
1c5acb87 399 fFillEMCALCells = kFALSE;
591cc579 400 fFillPHOSCells = kFALSE;
836b6989 401
591cc579 402 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
403 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
42dc8e7d 404 fDeltaAODFileName = "deltaAODPartCorr.root";
743aa53a 405 fFiredTriggerClassName = "";
029dea5a 406 fEventTriggerMask = AliVEvent::kAny;
790dea42 407 fMixEventTriggerMask = AliVEvent::kAnyINT;
029dea5a 408 fEventTriggerAtSE = kTRUE; // Use only events that pass event selection at SE base class
836b6989 409
de0b770d 410 fAcceptFastCluster = kTRUE;
411 fAnaLED = kFALSE;
0ae57829 412
413 //We want tracks fitted in the detectors:
3a58eee6 414 //fTrackStatus=AliESDtrack::kTPCrefit;
de0b770d 415 //fTrackStatus|=AliESDtrack::kITSrefit;
416 fTrackStatus = 0;
a5fb4114 417 fTrackFilterMask = 128; //For AODs, but what is the difference between fTrackStatus and fTrackFilterMask?
3a58eee6 418
a5fb4114 419 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
836b6989 420
a9b8c1d0 421 fConstrainTrack = kFALSE ; // constrain tracks to vertex
422
798a9b04 423 fV0ADC[0] = 0; fV0ADC[1] = 0;
424 fV0Mul[0] = 0; fV0Mul[1] = 0;
836b6989 425
0b13c1f9 426 fZvtxCut = 10.;
427
de0b770d 428 fNMixedEvent = 1;
429
dbb3de7b 430 fPtHardAndJetPtFactor = 7.;
431 fPtHardAndClusterPtFactor = 1.;
432
32fd29fe 433 //Centrality
de0b770d 434 fCentralityClass = "V0M";
435 fCentralityOpt = 10;
436 fCentralityBin[0] = fCentralityBin[1]=-1;
836b6989 437
9929c80b 438 fEventPlaneMethod = "V0";
de0b770d 439
f3138ecf 440 // Allocate memory (not sure this is the right place)
441 fCTSTracks = new TObjArray();
442 fEMCALClusters = new TObjArray();
443 fPHOSClusters = new TObjArray();
444 fTriggerAnalysis = new AliTriggerAnalysis;
445 fAODBranchList = new TList ;
446
de0b770d 447 fImportGeometryFromFile = kFALSE;
f3138ecf 448
3c1a2e95 449 fPileUpParamSPD[0] = 3 ; fPileUpParamSPD[1] = 0.8 ;
450 fPileUpParamSPD[2] = 3.0 ; fPileUpParamSPD[3] = 2.0 ; fPileUpParamSPD[4] = 5.0;
4b75cb39 451
ff440946 452 // Parametrized time cut (LHC11d)
453 fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 3.5 ; fEMCALParamTimeCutMin[3] = 1. ;
454 fEMCALParamTimeCutMax[0] = 5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.45; fEMCALParamTimeCutMax[3] = 1.25;
455
456 // Parametrized time cut (LHC11c)
457 //fEMCALParamTimeCutMin[0] =-5; fEMCALParamTimeCutMin[1] =-1 ; fEMCALParamTimeCutMin[2] = 1.87; fEMCALParamTimeCutMin[3] = 0.4;
458 //fEMCALParamTimeCutMax[0] = 3.5; fEMCALParamTimeCutMax[1] = 50; fEMCALParamTimeCutMax[2] = 0.15; fEMCALParamTimeCutMax[3] = 1.6;
4e2b43d8 459}
1c5acb87 460
3c1a2e95 461//___________________________________________________________
462Bool_t AliCaloTrackReader::IsInTimeWindow(const Double_t tof, const Float_t energy) const
463{
464 // Cluster time selection window
465
466 // Parametrized cut depending on E
467 if(fUseParamTimeCut)
468 {
469 Float_t minCut= fEMCALParamTimeCutMin[0]+fEMCALParamTimeCutMin[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMin[2])/fEMCALParamTimeCutMin[3]);
470 Float_t maxCut= fEMCALParamTimeCutMax[0]+fEMCALParamTimeCutMax[1]*TMath::Exp(-(energy-fEMCALParamTimeCutMax[2])/fEMCALParamTimeCutMax[3]);
471 //printf("tof %f, minCut %f, maxCut %f\n",tof,minCut,maxCut);
472 if( tof < minCut || tof > maxCut ) return kFALSE ;
473 }
474
475 //In any case, the time should to be larger than the fixed window ...
476 if( tof < fEMCALTimeCutMin || tof > fEMCALTimeCutMax ) return kFALSE ;
477
478 return kTRUE ;
479}
64c78c5f 480
481//________________________________________________
482Bool_t AliCaloTrackReader::IsPileUpFromSPD() const
483{
484 // Check if event is from pile-up determined by SPD
485 // Default values: (3, 0.8, 3., 2., 5.)
3c1a2e95 486 return fInputEvent->IsPileupFromSPD((Int_t) fPileUpParamSPD[0] , fPileUpParamSPD[1] ,
487 fPileUpParamSPD[2] , fPileUpParamSPD[3] , fPileUpParamSPD[4] );
488 //printf("Param : %d, %2.2f, %2.2f, %2.2f, %2.2f\n",(Int_t) fPileUpParamSPD[0], fPileUpParamSPD[1], fPileUpParamSPD[2], fPileUpParamSPD[3], fPileUpParamSPD[4]);
489
490}
491
492//__________________________________________________
493Bool_t AliCaloTrackReader::IsPileUpFromEMCal() const
494{
495 // Check if event is from pile-up determined by EMCal
496 if(fNPileUpClusters > fNPileUpClustersCut) return kTRUE ;
497 else return kFALSE;
498}
499
500//________________________________________________________
501Bool_t AliCaloTrackReader::IsPileUpFromSPDAndEMCal() const
502{
503 // Check if event is from pile-up determined by SPD and EMCal
504 if( IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
505 else return kFALSE;
506}
099de61e 507
3c1a2e95 508//_______________________________________________________
509Bool_t AliCaloTrackReader::IsPileUpFromSPDOrEMCal() const
510{
511 // Check if event is from pile-up determined by SPD or EMCal
512 if( IsPileUpFromSPD() || IsPileUpFromEMCal()) return kTRUE ;
513 else return kFALSE;
514}
515
516//___________________________________________________________
517Bool_t AliCaloTrackReader::IsPileUpFromSPDAndNotEMCal() const
518{
519 // Check if event is from pile-up determined by SPD and not by EMCal
520 if( IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
521 else return kFALSE;
522}
523
524//___________________________________________________________
525Bool_t AliCaloTrackReader::IsPileUpFromEMCalAndNotSPD() const
526{
527 // Check if event is from pile-up determined by EMCal, not by SPD
528 if( !IsPileUpFromSPD() && IsPileUpFromEMCal()) return kTRUE ;
529 else return kFALSE;
530}
531
532//______________________________________________________________
533Bool_t AliCaloTrackReader::IsPileUpFromNotSPDAndNotEMCal() const
534{
535 // Check if event not from pile-up determined neither by SPD nor by EMCal
536 if( !IsPileUpFromSPD() && !IsPileUpFromEMCal()) return kTRUE ;
537 else return kFALSE;
64c78c5f 538}
539
836b6989 540//________________________________________________________
1c5acb87 541void AliCaloTrackReader::Print(const Option_t * opt) const
542{
836b6989 543
1c5acb87 544 //Print some relevant parameters set for the analysis
545 if(! opt)
546 return;
836b6989 547
029dea5a 548 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
549 printf("Task name : %s\n", fTaskName.Data()) ;
550 printf("Data type : %d\n", fDataType) ;
1c5acb87 551 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
552 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
553 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
98ec971d 554 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
555 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
556 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
d2655d46 557 printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
029dea5a 558 printf("Use CTS = %d\n", fFillCTS) ;
559 printf("Use EMCAL = %d\n", fFillEMCAL) ;
560 printf("Use PHOS = %d\n", fFillPHOS) ;
561 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
562 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
591cc579 563 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
f5500c7a 564 printf("AODs Track filter mask = %d or hybrid %d, SPD hit %d\n", (Int_t) fTrackFilterMask,fSelectHybridTracks,fSelectSPDHitTracks) ;
3a58eee6 565 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
029dea5a 566 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
567 printf("Recalculate Clusters = %d\n", fRecalculateClusters) ;
568
790dea42 569 printf("Use Triggers selected in SE base class %d; If not what trigger Mask? %d; Trigger max for mixed %d \n",
570 fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
3bfc4732 571
dbb3de7b 572 if(fComparePtHardAndClusterPt)
591cc579 573 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
836b6989 574
dbb3de7b 575 if(fComparePtHardAndClusterPt)
576 printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
577
42dc8e7d 578 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
42dc8e7d 579 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
8a3f4796 580 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
836b6989 581
1c5acb87 582 printf(" \n") ;
32fd29fe 583
1c5acb87 584}
585
836b6989 586//_________________________________________________________________________
587Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry,
588 const char * /*currentFileName*/)
589{
6639984f 590 //Fill the event counter and input lists that are needed, called by the analysis maker.
de0b770d 591
6639984f 592 fEventNumber = iEntry;
1510eee3 593 //fCurrentFileName = TString(currentFileName);
55d66f31 594 if(!fInputEvent)
595 {
f7c2338a 596 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
be1f5fa4 597 return kFALSE;
598 }
55d66f31 599
72d2488e 600 //Select events only fired by a certain trigger configuration if it is provided
be1f5fa4 601 Int_t eventType = 0;
602 if(fInputEvent->GetHeader())
603 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
836b6989 604
55d66f31 605 if (GetFiredTriggerClasses().Contains("FAST") && !GetFiredTriggerClasses().Contains("ALL") && !fAcceptFastCluster)
606 {
836b6989 607 if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent - Do not count events from fast cluster, trigger name %s\n",fFiredTriggerClassName.Data());
cd2e4ce6 608 return kFALSE;
609 }
610
611 //-------------------------------------------------------------------------------------
612 // Reject event if large clusters with large energy
613 // Use only for LHC11a data for the moment, and if input is clusterizer V1 or V1+unfolding
614 // If clusterzer NxN or V2 it does not help
615 //-------------------------------------------------------------------------------------
55d66f31 616 Int_t run = fInputEvent->GetRunNumber();
a1897f1e 617 if( fRemoveLEDEvents && run > 146857 && run < 146861 )
55d66f31 618 {
f5036bcb 619 //printf("Event %d\n",GetEventNumber());
cd2e4ce6 620
621 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
75153e10 622 Int_t ncellsSM3 = 0;
55d66f31 623 for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
624 {
cd2e4ce6 625 Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
55d66f31 626 Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
75153e10 627 if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
cd2e4ce6 628 }
629
630 Int_t ncellcut = 21;
631 if(fFiredTriggerClassName.Contains("EMC")) ncellcut = 35;
632
a1897f1e 633 if(ncellsSM3 >= ncellcut)
55d66f31 634 {
a1897f1e 635 if(fDebug > 0) printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d\n",ncellsSM3);
cd2e4ce6 636 return kFALSE;
637 }
638 }// Remove LED events
639
640 // Reject pure LED events?
55d66f31 641 if( fFiredTriggerClassName !="" && !fAnaLED)
642 {
f59ee2a0 643 //printf("Event type %d\n",eventType);
c8fe2783 644 if(eventType!=7)
645 return kFALSE; //Only physics event, do not use for simulated events!!!
f59ee2a0 646
647 if(fDebug > 0)
7ec23b5a 648 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
836b6989 649 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
f59ee2a0 650
7ec23b5a 651 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
4d8a2fe1 652 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
72d2488e 653 }
55d66f31 654 else if(fAnaLED)
655 {
836b6989 656 // kStartOfRun = 1, // START_OF_RUN
657 // kEndOfRun = 2, // END_OF_RUN
658 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
659 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
660 // kStartOfBurst = 5, // START_OF_BURST
661 // kEndOfBurst = 6, // END_OF_BURST
662 // kPhysicsEvent = 7, // PHYSICS_EVENT
663 // kCalibrationEvent = 8, // CALIBRATION_EVENT
664 // kFormatError = 9, // EVENT_FORMAT_ERROR
665 // kStartOfData = 10, // START_OF_DATA
666 // kEndOfData = 11, // END_OF_DATA
667 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
668 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
669
c1ac3823 670 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
671 if(eventType!=8)return kFALSE;
672 }
cd2e4ce6 673
29b2ceec 674 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
a20fbb55 675 if(fComparePtHardAndJetPt)
55d66f31 676 {
7ec23b5a 677 if(!ComparePtHardAndJetPt()) return kFALSE ;
29b2ceec 678 }
836b6989 679
dbb3de7b 680 if(fComparePtHardAndClusterPt)
681 {
682 if(!ComparePtHardAndClusterPt()) return kFALSE ;
683 }
684
48c37e02 685 //Fill Vertex array
686 FillVertexArray();
687 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
688 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
689
034e885b 690 //------------------------------------------------------
691 //Event rejection depending on vertex, pileup, v0and
692 //------------------------------------------------------
693 if(fDataType==kESD && fTimeStampEventSelect)
694 {
695 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
696 Int_t timeStamp = esd->GetTimeStamp();
697 Float_t timeStampFrac = 1.*(timeStamp-fTimeStampRunMin) / (fTimeStampRunMax-fTimeStampRunMin);
698
699 //printf("stamp0 %d, max0 %d, frac %f\n", timeStamp-fTimeStampRunMin,fTimeStampRunMax-fTimeStampRunMin, //timeStampFrac);
700
701 if(timeStampFrac < fTimeStampEventFracMin || timeStampFrac > fTimeStampEventFracMax) return kFALSE;
702
703 //printf("\t accept time stamp\n");
704 }
705
706
48c37e02 707 //------------------------------------------------------
708 //Event rejection depending on vertex, pileup, v0and
709 //------------------------------------------------------
d2655d46 710
711 if(fUseEventsWithPrimaryVertex)
712 {
713 if( !CheckForPrimaryVertex() ) return kFALSE;
714 if( TMath::Abs(fVertex[0][0] ) < 1.e-6 &&
715 TMath::Abs(fVertex[0][1] ) < 1.e-6 &&
716 TMath::Abs(fVertex[0][2] ) < 1.e-6 ) return kFALSE;
717 }
718
099de61e 719 //printf("Reader : IsPileUp %d, Multi %d\n",IsPileUpFromSPD(),fInputEvent->IsPileupFromSPDInMultBins());
720
55d66f31 721 if(fDoEventSelection)
722 {
723 if(!fCaloFilterPatch)
724 {
4b75cb39 725 // Do not analyze events with pileup
64c78c5f 726 Bool_t bPileup = IsPileUpFromSPD();
4b75cb39 727 //IsPileupFromSPDInMultBins() // method to try
3c1a2e95 728 //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]);
48c37e02 729 if(bPileup) return kFALSE;
730
55d66f31 731 if(fDoV0ANDEventSelection)
732 {
48c37e02 733 Bool_t bV0AND = kTRUE;
ad30b142 734 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
735 if(esd)
736 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
48c37e02 737 //else bV0AND = //FIXME FOR AODs
738 if(!bV0AND) return kFALSE;
739 }
48c37e02 740 }//CaloFilter patch
55d66f31 741 else
742 {
743 if(fInputEvent->GetNumberOfCaloClusters() > 0)
744 {
48c37e02 745 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
029dea5a 746 if(calo->GetNLabels() == 4)
747 {
48c37e02 748 Int_t * selection = calo->GetLabels();
749 Bool_t bPileup = selection[0];
750 if(bPileup) return kFALSE;
751
752 Bool_t bGoodV = selection[1];
20218aea 753 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
48c37e02 754
029dea5a 755 if(fDoV0ANDEventSelection)
756 {
48c37e02 757 Bool_t bV0AND = selection[2];
758 if(!bV0AND) return kFALSE;
759 }
760
761 fTrackMult = selection[3];
762 if(fTrackMult == 0) return kFALSE;
029dea5a 763 }
764 else
765 {
48c37e02 766 //First filtered AODs, track multiplicity stored there.
767 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
768 if(fTrackMult == 0) return kFALSE;
769 }
770 }//at least one cluster
029dea5a 771 else
772 {
cfaba834 773 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
48c37e02 774 //Remove events with vertex (0,0,0), bad vertex reconstruction
20218aea 775 if(fUseEventsWithPrimaryVertex && TMath::Abs(fVertex[0][0]) < 1.e-6 && TMath::Abs(fVertex[0][1]) < 1.e-6 && TMath::Abs(fVertex[0][2]) < 1.e-6) return kFALSE;
48c37e02 776
777 //First filtered AODs, track multiplicity stored there.
778 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
779 if(fTrackMult == 0) return kFALSE;
780 }// no cluster
781 }// CaloFileter patch
782 }// Event selection
783 //------------------------------------------------------
836b6989 784
32fd29fe 785 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
786 //If we need a centrality bin, we select only those events in the corresponding bin.
55d66f31 787 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100)
788 {
32fd29fe 789 Int_t cen = GetEventCentrality();
790 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
791 }
792
f8006433 793 //Fill the arrays with cluster/tracks/cells data
029dea5a 794
836b6989 795 if(fFillEMCALCells)
c8fe2783 796 FillInputEMCALCells();
029dea5a 797
c8fe2783 798 if(fFillPHOSCells)
799 FillInputPHOSCells();
836b6989 800
798a9b04 801 FillInputVZERO();
029dea5a 802
803 if(fEventTriggerAtSE)
804 {
805 if(fFillCTS)
806 {
807 FillInputCTS();
808 //Accept events with at least one track
809 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
810 }
811 if(fFillEMCAL)
812 FillInputEMCAL();
813 if(fFillPHOS)
814 FillInputPHOS();
815 }
816 else
817 {
818 // In case of mixing analysis, all triggers accepted, but trigger particles selected
819 // only for the specific trigered events selected here. Mixing done only for MB events,
820 // tracks array filled also for those events and not the others.
821
822 AliAnalysisManager *manager = AliAnalysisManager::GetAnalysisManager();
823 AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
824
c6b4facc 825 if(!inputHandler) return kFALSE ; // to content coverity
826
029dea5a 827 UInt_t isTrigger = inputHandler->IsEventSelected() & fEventTriggerMask;
790dea42 828 UInt_t isMB = inputHandler->IsEventSelected() & fMixEventTriggerMask;
029dea5a 829
9929c80b 830 if(fFillCTS && (isMB || isTrigger))
029dea5a 831 {
832 FillInputCTS();
833 //Accept events with at least one track
834 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
835 }
836
837 if(isTrigger)
838 {
839 if(fFillEMCAL)
840 FillInputEMCAL();
841 if(fFillPHOS)
842 FillInputPHOS();
843 }
844 }
845
29b2ceec 846 return kTRUE ;
1c5acb87 847}
848
836b6989 849//___________________________________
850void AliCaloTrackReader::ResetLists()
851{
1c5acb87 852 // Reset lists, called by the analysis maker
836b6989 853
6060ed91 854 if(fCTSTracks) fCTSTracks -> Clear();
836b6989 855 if(fEMCALClusters) fEMCALClusters -> Clear("C");
856 if(fPHOSClusters) fPHOSClusters -> Clear("C");
857
798a9b04 858 fV0ADC[0] = 0; fV0ADC[1] = 0;
859 fV0Mul[0] = 0; fV0Mul[1] = 0;
836b6989 860
1c5acb87 861}
c8fe2783 862
836b6989 863//____________________________________________________________
c8fe2783 864void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
865{
866 fInputEvent = input;
867 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
029dea5a 868 if (fMixedEvent)
c8fe2783 869 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
836b6989 870
eb310db0 871 //Delete previous vertex
029dea5a 872 if(fVertex)
873 {
874 for (Int_t i = 0; i < fNMixedEvent; i++)
875 {
eb310db0 876 delete [] fVertex[i] ;
877 }
878 delete [] fVertex ;
879 }
880
c8fe2783 881 fVertex = new Double_t*[fNMixedEvent] ;
029dea5a 882 for (Int_t i = 0; i < fNMixedEvent; i++)
883 {
c8fe2783 884 fVertex[i] = new Double_t[3] ;
885 fVertex[i][0] = 0.0 ;
886 fVertex[i][1] = 0.0 ;
887 fVertex[i][2] = 0.0 ;
888 }
889}
890
32fd29fe 891//__________________________________________________
836b6989 892Int_t AliCaloTrackReader::GetEventCentrality() const
893{
32fd29fe 894 //Return current event centrality
895
029dea5a 896 if(GetCentrality())
897 {
9929c80b 898 if (fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
899 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
900 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
029dea5a 901 else
902 {
9929c80b 903 printf("AliCaloTrackReader::GetEventCentrality() - Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
904 return -1;
32fd29fe 905 }
906 }
9929c80b 907 else return -1;
908
909}
910
911//_____________________________________________________
912Double_t AliCaloTrackReader::GetEventPlaneAngle() const
913{
914 //Return current event centrality
915
916 if(GetEventPlane())
917 {
918 Float_t ep = GetEventPlane()->GetEventplane(GetEventPlaneMethod(), GetInputEvent());
919
920 if(GetEventPlaneMethod()=="Q" && (ep < 0 || ep > TMath::Pi()))
921 {
b14c2b20 922 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <Q> method : %f\n",ep);
9929c80b 923 return -1000;
924 }
925 else if(GetEventPlaneMethod().Contains("V0") )
926 {
927 if((ep > TMath::Pi()/2 || ep < -TMath::Pi()/2))
928 {
b14c2b20 929 if(fDebug > 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Bad EP for <%s> method : %f\n",GetEventPlaneMethod().Data(), ep);
9929c80b 930 return -1000;
931 }
932
933 ep+=TMath::Pi()/2; // put same range as for <Q> method
934
935 }
936
937 //printf("AliCaloTrackReader::GetEventPlaneAngle() = %f\n",ep);
b14c2b20 938 if(fDebug > 0 )
939 {
940 if (ep > TMath::Pi()) printf("AliCaloTrackReader::GetEventPlaneAngle() - Too large angle = %f\n",ep);
941 else if(ep < 0 ) printf("AliCaloTrackReader::GetEventPlaneAngle() - Negative angle = %f\n" ,ep);
942 }
9929c80b 943
8fd30003 944 return ep;
9929c80b 945 }
946 else
947 {
b14c2b20 948 if(fDataType!=kMC && fDebug > 0) printf("AliCaloTrackReader::GetEventPlaneAngle() - No EP pointer\n");
9929c80b 949 return -1000;
950 }
32fd29fe 951
952}
953
836b6989 954//__________________________________________________________
955void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const
956{
f8006433 957 //Return vertex position to be used for single event analysis
958 vertex[0]=fVertex[0][0];
959 vertex[1]=fVertex[0][1];
960 vertex[2]=fVertex[0][2];
961}
962
836b6989 963//____________________________________________________________
964void AliCaloTrackReader::GetVertex(Double_t vertex[3],
965 const Int_t evtIndex) const
966{
f8006433 967 //Return vertex position for mixed event, recover the vertex in a particular event.
968
f8006433 969 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
970
971}
f8006433 972
836b6989 973//________________________________________
974void AliCaloTrackReader::FillVertexArray()
975{
f8006433 976
977 //Fill data member with vertex
978 //In case of Mixed event, multiple vertices
979
980 //Delete previous vertex
d2655d46 981 if(fVertex)
982 {
983 for (Int_t i = 0; i < fNMixedEvent; i++)
984 {
f8006433 985 delete [] fVertex[i] ;
986 }
987 delete [] fVertex ;
988 }
989
990 fVertex = new Double_t*[fNMixedEvent] ;
d2655d46 991 for (Int_t i = 0; i < fNMixedEvent; i++)
992 {
f8006433 993 fVertex[i] = new Double_t[3] ;
994 fVertex[i][0] = 0.0 ;
995 fVertex[i][1] = 0.0 ;
996 fVertex[i][2] = 0.0 ;
997 }
998
d2655d46 999 if (!fMixedEvent)
1000 { //Single event analysis
1001 if(fDataType!=kMC)
1002 {
836b6989 1003
d2655d46 1004 if(fInputEvent->GetPrimaryVertex())
1005 {
79395d30 1006 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
1007 }
d2655d46 1008 else
1009 {
79395d30 1010 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
1011 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1012 }//Primary vertex pointer do not exist
1013
d2655d46 1014 } else
1015 {//MC read event
edffc439 1016 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
1017 }
836b6989 1018
f8006433 1019 if(fDebug > 1)
1020 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
836b6989 1021
d2655d46 1022 } else
1023 { // MultiEvent analysis
1024 for (Int_t iev = 0; iev < fNMixedEvent; iev++)
1025 {
8e7bdfa9 1026 if (fMixedEvent->GetVertexOfEvent(iev))
1027 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
d2655d46 1028 else
1029 { // no vertex found !!!!
8e7bdfa9 1030 AliWarning("No vertex found");
1031 }
836b6989 1032
f8006433 1033 if(fDebug > 1)
1034 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
836b6989 1035
f8006433 1036 }
c8fe2783 1037 }
f8006433 1038
c8fe2783 1039}
1040
836b6989 1041//_____________________________________
1042void AliCaloTrackReader::FillInputCTS()
1043{
f37fa8d2 1044 //Return array with Central Tracking System (CTS) tracks
1045
1046 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
1047
da91abdb 1048 Double_t pTrack[3] = {0,0,0};
1049
1050 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
1051 fTrackMult = 0;
3a58eee6 1052 Int_t nstatus = 0;
4b7f6e01 1053 Double_t bz = GetInputEvent()->GetMagneticField();
1054
975b29fa 1055 for(Int_t i = 0; i < 19; i++)
1056 {
1057 fTrackBCEvent [i] = 0;
1058 fTrackBCEventCut[i] = 0;
1059 }
1060 for (Int_t itrack = 0; itrack < nTracks; itrack++)
d2655d46 1061 {////////////// track loop
c8fe2783 1062 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
836b6989 1063
3a58eee6 1064 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
975b29fa 1065 ULong_t status = track->GetStatus();
1066
1067 if (fTrackStatus && !((status & fTrackStatus) == fTrackStatus))
c8fe2783 1068 continue ;
1069
3a58eee6 1070 nstatus++;
1071
a9b8c1d0 1072 if (fDataType==kESD)
a5fb4114 1073 {
a9b8c1d0 1074 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
1075
1076 if(esdTrack && fESDtrackCuts->AcceptTrack(esdTrack))
1077 {
1078 track->GetPxPyPz(pTrack) ;
1079
1080 if(fConstrainTrack)
1081 {
1082 if(esdTrack->GetConstrainedParam())
1083 {
1084 const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
1085 esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
1086 esdTrack->GetConstrainedPxPyPz(pTrack);
1087 }
1088 else continue;
da91abdb 1089
a9b8c1d0 1090 } // use constrained tracks
da91abdb 1091
f5500c7a 1092 if(fSelectSPDHitTracks)
1093 {//Not much sense to use with TPC only or Hybrid tracks
1094 if(!esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1)) continue ;
1095 }
a9b8c1d0 1096 }
1097 else continue;
1098
da91abdb 1099 } // ESD
a5fb4114 1100 else if(fDataType==kAOD)
1101 {
743aa53a 1102 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
a9b8c1d0 1103
d2655d46 1104 if(aodtrack)
1105 {
21812953 1106 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS():AOD track type: %d (primary %d), hybrid? %d \n",
1107 aodtrack->GetType(),AliAODTrack::kPrimary,
1108 aodtrack->IsHybridGlobalConstrainedGlobal());
1109
da91abdb 1110
1111 if (fSelectHybridTracks)
21812953 1112 {
da91abdb 1113 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) continue ;
21812953 1114 }
da91abdb 1115 else
1116 {
1117 if ( aodtrack->TestFilterBit(fTrackFilterMask)==kFALSE) continue ;
1118 }
1119
f5500c7a 1120 if(fSelectSPDHitTracks)
1121 {//Not much sense to use with TPC only or Hybrid tracks
1122 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) continue ;
1123 }
1124
da91abdb 1125 if (aodtrack->GetType()!= AliAODTrack::kPrimary) continue ;
1126
1127 if (fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS(): \t accepted track! \n");
a9b8c1d0 1128
1129 track->GetPxPyPz(pTrack) ;
da91abdb 1130
1131 } // aod track exists
1132 else continue ;
1133
1134 } // AOD
3b13c34c 1135
3a58eee6 1136 //Count the tracks in eta < 0.9
1137 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
1138 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
1139
a9b8c1d0 1140 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
c8fe2783 1141
2346528f 1142 Bool_t okTOF = ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) ;
975b29fa 1143 Double_t tof = -1000;
4b7f6e01 1144 //Int_t bc = -1000;
1145 Int_t trackBC = -1000 ;
1146
975b29fa 1147 if(okTOF)
d2655d46 1148 {
4b7f6e01 1149 trackBC = track->GetTOFBunchCrossing(bz);
1150 SetTrackEventBC(trackBC+9);
1151
975b29fa 1152 tof = track->GetTOFsignal()*1e-3;
975b29fa 1153 //printf("track TOF %e\n",tof);
4b7f6e01 1154 //bc = TMath::Nint((tof-25)/50) + 9;
975b29fa 1155 //printf("track pt %f, tof %2.2f, bc=%d\n",track->Pt(),tof,bc);
4b7f6e01 1156 //SetTrackEventBC(bc);
1157
975b29fa 1158 }
1159
1160 if(fCTSPtMin > momentum.Pt() || fCTSPtMax < momentum.Pt()) continue ;
1161
1162 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
689d9f15 1163
975b29fa 1164 if(okTOF)
1165 {
4b7f6e01 1166 //SetTrackEventBCcut(bc);
1167 SetTrackEventBCcut(trackBC+9);
1168
975b29fa 1169 //In any case, the time should to be larger than the fixed window ...
a37847d7 1170 if( fUseTrackTimeCut && (trackBC!=0 || tof < fTrackTimeCutMin || tof > fTrackTimeCutMax) )
975b29fa 1171 {
a37847d7 1172 //printf("Remove track time %f and bc = %d\n",tof,trackBC);
975b29fa 1173 continue ;
1174 }
a37847d7 1175 //else printf("Accept track time %f and bc = %d\n",tof,trackBC);
1176
975b29fa 1177 }
2346528f 1178
689d9f15 1179 if(fUseTrackDCACut)
1180 {
1181 //In case of hybrid tracks on AODs, constrained TPC tracks cannot be propagated back to primary vertex
1182 AliAODTrack * aodTrack = dynamic_cast<AliAODTrack*>(track);
1183 Float_t dcaCons = -999;
1184 if(aodTrack)
1185 {
1186 dcaCons = aodTrack->DCA();
1187 //vtxBC = aodTrack->GetProdVertex()->GetBC();
1188 if(dcaCons > -999)
1189 {
1190 if(TMath::Abs(dcaCons) > fTrackDCACut[2] ) continue ;
1191 }
1192 }
1193
1194 //non contrained TPC tracks (tracks with ITS points) on AODs
1195 if(dcaCons==-999)
1196 {
1197 Double_t dca[2] = {1e6,1e6};
1198 Double_t covar[3] = {1e6,1e6,1e6};
1199 Bool_t okDCA = track->PropagateToDCA(fInputEvent->GetPrimaryVertex(),bz,100.,dca,covar);
1200 if( !okDCA ||
1201 TMath::Abs(dca[0]) > fTrackDCACut[0] ||
1202 TMath::Abs(dca[1]) > fTrackDCACut[1] ) continue ;
1203 }
1204 }// DCA cuts
1205
975b29fa 1206 if(fDebug > 2 && momentum.Pt() > 0.1)
1207 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1208 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1209
1210 if (fMixedEvent) track->SetID(itrack);
1211
1212 fCTSTracks->Add(track);
1213
c8fe2783 1214 }// track loop
1215
975b29fa 1216 if(fDebug > 1)
be518ab0 1217 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
836b6989 1218
c8fe2783 1219}
1220
836b6989 1221//__________________________________________________________________
1222void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus,
1223 const Int_t iclus)
1224{
c4eec29f 1225 //Fill the EMCAL data in the array, do it
f46af216 1226
c4eec29f 1227 Int_t vindex = 0 ;
1228 if (fMixedEvent)
1229 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1230
a38a48f2 1231 //Reject clusters with bad channels, close to borders and exotic;
a7e5a381 1232 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) return;
48c37e02 1233
a5fb4114 1234 //Mask all cells in collumns facing ALICE thick material if requested
d2655d46 1235 if(GetCaloUtils()->GetNMaskCellColumns())
1236 {
a5fb4114 1237 Int_t absId = -1;
1238 Int_t iSupMod = -1;
1239 Int_t iphi = -1;
1240 Int_t ieta = -1;
1241 Bool_t shared = kFALSE;
1242 GetCaloUtils()->GetEMCALRecoUtils()->GetMaxEnergyCell(GetCaloUtils()->GetEMCALGeometry(), GetEMCALCells(),clus,absId,iSupMod,ieta,iphi,shared);
1243 if(GetCaloUtils()->MaskFrameCluster(iSupMod, ieta)) return;
1244 }
1245
029dea5a 1246 if(fSelectEmbeddedClusters)
1247 {
1407394b 1248 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
6060ed91 1249 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
1250 }
836b6989 1251
b487d080 1252 //Float_t pos[3];
1253 //clus->GetPosition(pos);
1254 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
cfaba834 1255
d2655d46 1256 if(fRecalculateClusters)
1257 {
b487d080 1258 //Recalibrate the cluster energy
d2655d46 1259 if(GetCaloUtils()->IsRecalibrationOn())
1260 {
b487d080 1261 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
9e8998b1 1262
b487d080 1263 clus->SetE(energy);
1264 //printf("Recalibrated Energy %f\n",clus->E());
9e8998b1 1265
b487d080 1266 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
1267 GetCaloUtils()->RecalculateClusterPID(clus);
9e8998b1 1268
b487d080 1269 } // recalculate E
1270
1271 //Recalculate distance to bad channels, if new list of bad channels provided
1272 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
1273
1274 //Recalculate cluster position
d2655d46 1275 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn())
1276 {
b487d080 1277 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
1278 //clus->GetPosition(pos);
1279 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
1280 }
c4eec29f 1281
f46af216 1282 // Recalculate TOF
d2655d46 1283 if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn())
1284 {
f46af216 1285 Double_t tof = clus->GetTOF();
1286 Float_t frac =-1;
1287 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1288
d2655d46 1289 if(fDataType==AliCaloTrackReader::kESD)
1290 {
f46af216 1291 tof = fEMCALCells->GetCellTime(absIdMax);
1292 }
1293
1294 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1295
1296 clus->SetTOF(tof);
1297
1298 }// Time recalibration
1299 }
b487d080 1300
1301 //Correct non linearity
d2655d46 1302 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn())
1303 {
b487d080 1304 GetCaloUtils()->CorrectClusterEnergy(clus) ;
1305 //printf("Linearity Corrected Energy %f\n",clus->E());
1306
1307 //In case of MC analysis, to match resolution/calibration in real data
1308 Float_t rdmEnergy = GetCaloUtils()->GetEMCALRecoUtils()->SmearClusterEnergy(clus);
1309 // printf("\t Energy %f, smeared %f\n", clus->E(),rdmEnergy);
1310 clus->SetE(rdmEnergy);
c4eec29f 1311 }
b487d080 1312
975b29fa 1313 Double_t tof = clus->GetTOF()*1e9;
1314
1315 Int_t bc = TMath::Nint(tof/50) + 9;
1316 //printf("tof %2.2f, bc+5=%d\n",tof,bc);
1317
1318 SetEMCalEventBC(bc);
1319
1320 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) return ;
1321
b487d080 1322 TLorentzVector momentum ;
1323
975b29fa 1324 clus->GetMomentum(momentum, fVertex[vindex]);
b487d080 1325
ff440946 1326 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
ca0c58aa 1327
975b29fa 1328 SetEMCalEventBCcut(bc);
ff440946 1329
975b29fa 1330 if(!IsInTimeWindow(tof,clus->E()))
ff440946 1331 {
3c1a2e95 1332 fNPileUpClusters++ ;
4b7f6e01 1333 if(fUseEMCALTimeCut) return ;
ff440946 1334 }
3c1a2e95 1335 else
1336 fNNonPileUpClusters++;
975b29fa 1337
b487d080 1338 if(fDebug > 2 && momentum.E() > 0.1)
1339 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1340 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
836b6989 1341
b487d080 1342 if (fMixedEvent)
1343 clus->SetID(iclus) ;
1344
1345 fEMCALClusters->Add(clus);
f46af216 1346
c4eec29f 1347}
1348
836b6989 1349//_______________________________________
1350void AliCaloTrackReader::FillInputEMCAL()
1351{
f37fa8d2 1352 //Return array with EMCAL clusters in aod format
c8fe2783 1353
f37fa8d2 1354 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
1355
3bfc4732 1356 // First recalibrate cells, time or energy
1357 // if(GetCaloUtils()->IsRecalibrationOn())
1358 // GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCells(GetCaloUtils()->GetEMCALGeometry(),
1359 // GetEMCALCells(),
1360 // fInputEvent->GetBunchCrossNumber());
1361
3c1a2e95 1362 fNPileUpClusters = 0; // Init counter
1363 fNNonPileUpClusters = 0; // Init counter
975b29fa 1364 for(Int_t i = 0; i < 19; i++)
1365 {
1366 fEMCalBCEvent [i] = 0;
1367 fEMCalBCEventCut[i] = 0;
1368 }
3c1a2e95 1369
f37fa8d2 1370 //Loop to select clusters in fiducial cut and fill container with aodClusters
029dea5a 1371 if(fEMCALClustersListName=="")
1372 {
c4eec29f 1373 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
d2655d46 1374 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1375 {
c4eec29f 1376 AliVCluster * clus = 0;
d2655d46 1377 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1378 {
029dea5a 1379 if (IsEMCALCluster(clus))
1380 {
c4eec29f 1381 FillInputEMCALAlgorithm(clus, iclus);
1382 }//EMCAL cluster
1383 }// cluster exists
1384 }// cluster loop
385b7abf 1385
1386 //Recalculate track matching
a38a48f2 1387 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
385b7abf 1388
c4eec29f 1389 }//Get the clusters from the input event
d2655d46 1390 else
1391 {
a757b40b 1392 TClonesArray * clusterList = 0x0;
7842c845 1393
1394 if (fInputEvent->FindListObject(fEMCALClustersListName))
1395 {
24026a5c 1396 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
7842c845 1397 }
1398 else if(fOutputEvent)
24026a5c 1399 {
7842c845 1400 clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
1401 }
1402
d2655d46 1403 if(!clusterList)
1404 {
1407394b 1405 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
1406 return;
c4eec29f 1407 }
ca0c58aa 1408
c4eec29f 1409 Int_t nclusters = clusterList->GetEntriesFast();
d2655d46 1410 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1411 {
c4eec29f 1412 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
1413 //printf("E %f\n",clus->E());
e615d952 1414 if (clus) FillInputEMCALAlgorithm(clus, iclus);
1415 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
c4eec29f 1416 }// cluster loop
385b7abf 1417
24026a5c 1418 // Recalculate the pile-up time, in case long time clusters removed during clusterization
1419 //printf("Input event INIT : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1420
1421 fNPileUpClusters = 0; // Init counter
1422 fNNonPileUpClusters = 0; // Init counter
975b29fa 1423 for(Int_t i = 0; i < 19; i++)
1424 {
1425 fEMCalBCEvent [i] = 0;
1426 fEMCalBCEventCut[i] = 0;
1427 }
24026a5c 1428
1429 for (Int_t iclus = 0; iclus < fInputEvent->GetNumberOfCaloClusters(); iclus++)
1430 {
1431 AliVCluster * clus = 0;
1432
1433 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1434 {
1435 if (IsEMCALCluster(clus))
1436 {
1437
24026a5c 1438 Float_t frac =-1;
1439 Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fEMCALCells, clus,frac);
1440 Double_t tof = clus->GetTOF();
1441 GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
1442 tof*=1e9;
1443
1444 //printf("Input event cluster : AbsIdMax %d, E %2.2f, time %2.2f \n", absIdMax,clus->E(),tof);
1445
1446 //Reject clusters with bad channels, close to borders and exotic;
1447 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells(),fInputEvent->GetBunchCrossNumber())) continue;
1448
975b29fa 1449 Int_t bc = TMath::Nint(tof/50) + 9;
1450 SetEMCalEventBC(bc);
1451
1452 if(fEMCALPtMin > clus->E() || fEMCALPtMax < clus->E()) continue ;
1453
1454 TLorentzVector momentum ;
1455
1456 clus->GetMomentum(momentum, fVertex[0]);
1457
1458 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) return ;
1459
1460 SetEMCalEventBCcut(bc);
1461
24026a5c 1462 if(!IsInTimeWindow(tof,clus->E()))
24026a5c 1463 fNPileUpClusters++ ;
24026a5c 1464 else
1465 fNNonPileUpClusters++;
975b29fa 1466
24026a5c 1467 }
1468 }
1469 }
1470
1471 //printf("Input event : Pile-up clusters %d, NO pile-up %d\n",fNPileUpClusters,fNNonPileUpClusters);
1472
cb5780f4 1473 // Recalculate track matching, not necessary if already done in the reclusterization task.
1474 // in case it was not done ...
1475 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
385b7abf 1476
c4eec29f 1477 }
3c1a2e95 1478
1479 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d, n pile-up clusters %d, n non pile-up %d \n", fEMCALClusters->GetEntriesFast(),fNPileUpClusters,fNNonPileUpClusters);
c8fe2783 1480
c8fe2783 1481}
1482
836b6989 1483//______________________________________
1484void AliCaloTrackReader::FillInputPHOS()
1485{
f37fa8d2 1486 //Return array with PHOS clusters in aod format
c8fe2783 1487
f37fa8d2 1488 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
b487d080 1489
f37fa8d2 1490 //Loop to select clusters in fiducial cut and fill container with aodClusters
c8fe2783 1491 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
d2655d46 1492 for (Int_t iclus = 0; iclus < nclusters; iclus++)
1493 {
c8fe2783 1494 AliVCluster * clus = 0;
d2655d46 1495 if ( (clus = fInputEvent->GetCaloCluster(iclus)) )
1496 {
029dea5a 1497 if (IsPHOSCluster(clus))
1498 {
f37fa8d2 1499 //Check if the cluster contains any bad channel and if close to calorimeter borders
c8fe2783 1500 Int_t vindex = 0 ;
1501 if (fMixedEvent)
1502 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
1503 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
1504 continue;
1505 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
1506 continue;
836b6989 1507
d2655d46 1508 if(fRecalculateClusters)
1509 {
b487d080 1510 //Recalibrate the cluster energy
d2655d46 1511 if(GetCaloUtils()->IsRecalibrationOn())
1512 {
b487d080 1513 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
1514 clus->SetE(energy);
1515 }
b487d080 1516 }
c8fe2783 1517
1518 TLorentzVector momentum ;
1519
1520 clus->GetMomentum(momentum, fVertex[vindex]);
1521
ca0c58aa 1522 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1523
1524 if(fPHOSPtMin > momentum.E() || fPHOSPtMax < momentum.E()) continue;
b487d080 1525
1526 if(fDebug > 2 && momentum.E() > 0.1)
1527 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
1528 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
1529
b487d080 1530
d2655d46 1531 if (fMixedEvent)
1532 {
b487d080 1533 clus->SetID(iclus) ;
1534 }
1535
1536 fPHOSClusters->Add(clus);
1537
c8fe2783 1538 }//PHOS cluster
1539 }//cluster exists
1540 }//esd cluster loop
1541
b487d080 1542 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());
1543
c8fe2783 1544}
1545
836b6989 1546//____________________________________________
1547void AliCaloTrackReader::FillInputEMCALCells()
1548{
743aa53a 1549 //Return array with EMCAL cells in aod format
c8fe2783 1550
1551 fEMCALCells = fInputEvent->GetEMCALCells();
1552
1553}
1554
836b6989 1555//___________________________________________
1556void AliCaloTrackReader::FillInputPHOSCells()
1557{
743aa53a 1558 //Return array with PHOS cells in aod format
c8fe2783 1559
1560 fPHOSCells = fInputEvent->GetPHOSCells();
1561
1562}
1563
836b6989 1564//_______________________________________
1565void AliCaloTrackReader::FillInputVZERO()
1566{
be518ab0 1567 //Fill VZERO information in data member, add all the channels information.
1568 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1569 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1570
1571 if (v0)
1572 {
1573 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1574 for (Int_t i = 0; i < 32; i++)
1575 {
029dea5a 1576 if(esdV0)
1577 {//Only available in ESDs
be518ab0 1578 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1579 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1580 }
029dea5a 1581
be518ab0 1582 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1583 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1584 }
1585 if(fDebug > 0)
1586 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1587 }
1588 else
1589 {
713a258b 1590 if(fDebug > 0)
1591 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
be518ab0 1592 }
1593}
1594
798a9b04 1595
c5693f62 1596//___________________________________________________________________
1597Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const
1598{
f37fa8d2 1599 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1600 // different number and need to patch here
836b6989 1601
f37fa8d2 1602 if(fDataType==kAOD && fOldAOD)
1603 {
1604 if (cluster->GetType() == 2) return kTRUE;
1605 else return kFALSE;
1606 }
1607 else
1608 {
1609 return cluster->IsEMCAL();
1610 }
836b6989 1611
f37fa8d2 1612}
1613
c5693f62 1614//___________________________________________________________________
1615Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const
1616{
f37fa8d2 1617 //Check if it is a cluster from PHOS.For old AODs cluster type has
1618 // different number and need to patch here
1619
1620 if(fDataType==kAOD && fOldAOD)
1621 {
1622 Int_t type = cluster->GetType();
1623 if (type == 0 || type == 1) return kTRUE;
1624 else return kFALSE;
1625 }
1626 else
1627 {
1628 return cluster->IsPHOS();
1629 }
1630
1631}
1632
c5693f62 1633//________________________________________________
1634Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
1635{
48c37e02 1636 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1637 //Only for ESDs ...
ad30b142 1638
48c37e02 1639 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
20218aea 1640 if(!event) return kTRUE;
ad30b142 1641
d2655d46 1642 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0)
1643 {
ad30b142 1644 return kTRUE;
1645 }
1646
d2655d46 1647 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1)
1648 {
ad30b142 1649 // SPD vertex
d2655d46 1650 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0)
1651 {
ad30b142 1652 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
48c37e02 1653 return kTRUE;
ad30b142 1654
48c37e02 1655 }
d2655d46 1656 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1)
1657 {
ad30b142 1658 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1659 return kFALSE;
48c37e02 1660 }
48c37e02 1661 }
1662
ad30b142 1663 return kFALSE;
48c37e02 1664
1665}
1666
c5693f62 1667//____________________________________________________________
1668void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
1669{
1670 // Set Track cuts
1671
1672 if(fESDtrackCuts) delete fESDtrackCuts ;
1673
1674 fESDtrackCuts = cuts ;
836b6989 1675
c5693f62 1676}
48c37e02 1677