remove setting moved to AliEMCALRecoUtils
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / 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 **************************************************************************/
15/* $Id: $ */
16
17//_________________________________________________________________________
18// Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and
19// Central Barrel Tracking detectors (CTS).
ff45398a 20// Not all MC particles/tracks/clusters are kept, some kinematical/fiducial restrictions are done.
591cc579 21// Mother class of : AliCaloTrackESDReader: Fills ESD data in 3 TObjArrays (PHOS, EMCAL, CTS)
22// : AliCaloTrackMCReader: Fills Kinematics data in 3 TObjArrays (PHOS, EMCAL, CTS)
f37fa8d2 23// : AliCaloTrackReader: Fills AOD data in 3 TObjArrays (PHOS, EMCAL, CTS)
1e68a3f4 24//
25// This part is commented: Mixing analysis can be done, input AOD with events
26// is opened in the AliCaloTrackReader::Init()
27
1c5acb87 28//-- Author: Gustavo Conesa (LNF-INFN)
29//////////////////////////////////////////////////////////////////////////////
30
31
32// --- ROOT system ---
591cc579 33#include "TFile.h"
cfaba834 34#include "TRandom3.h"
1c5acb87 35
36//---- ANALYSIS system ----
477d6cee 37#include "AliMCEvent.h"
591cc579 38#include "AliAODMCHeader.h"
39#include "AliGenPythiaEventHeader.h"
48c37e02 40#include "AliESDEvent.h"
8dacfd76 41#include "AliAODEvent.h"
c8fe2783 42#include "AliVTrack.h"
43#include "AliVParticle.h"
44#include "AliMixedEvent.h"
0ae57829 45#include "AliESDtrack.h"
3a58eee6 46#include "AliESDtrackCuts.h"
48c37e02 47#include "AliTriggerAnalysis.h"
37285e29 48#include "AliESDVZERO.h"
1c5acb87 49
cfaba834 50//---- PartCorr/EMCAL ---
51#include "AliEMCALRecoUtils.h"
52#include "AliCaloTrackReader.h"
53
1c5acb87 54ClassImp(AliCaloTrackReader)
55
56
57//____________________________________________________________________________
58 AliCaloTrackReader::AliCaloTrackReader() :
1510eee3 59 TObject(), fEventNumber(-1), //fCurrentFileName(""),
60 fDataType(0), fDebug(0),
decca433 61 fFiducialCut(0x0), fCheckFidCut(kFALSE), fComparePtHardAndJetPt(kFALSE), fPtHardAndJetPtFactor(7),
98ec971d 62 fCTSPtMin(0), fEMCALPtMin(0),fPHOSPtMin(0), fCTSPtMax(1000), fEMCALPtMax(1000),fPHOSPtMax(1000), fAODBranchList(new TList ),
be518ab0 63 fCTSTracks(new TObjArray()), fEMCALClusters(new TObjArray()), fPHOSClusters(new TObjArray()),
1c5acb87 64 fEMCALCells(0x0), fPHOSCells(0x0),
477d6cee 65 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
1c5acb87 66 fFillCTS(0),fFillEMCAL(0),fFillPHOS(0),
6060ed91 67 fFillEMCALCells(0),fFillPHOSCells(0), fSelectEmbeddedClusters(kFALSE),
a38a48f2 68 fSmearClusterEnergy(kFALSE), fRandom(),
1e68a3f4 69// fSecondInputAODTree(0x0), fSecondInputAODEvent(0x0),
70// fSecondInputFileName(""),fSecondInputFirstEvent(0),
be518ab0 71// fCTSTracksNormalInputEntries(0), fEMCALClustersNormalInputEntries(0),
72// fPHOSClustersNormalInputEntries(0),
90995603 73 fTrackStatus(0), fESDtrackCuts(0), fTrackMult(0), fTrackMultEtaCut(0.8),
afabc52f 74 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
1e68a3f4 75 fDeltaAODFileName("deltaAODPartCorr.root"),fFiredTriggerClassName(""),
c8fe2783 76 fAnaLED(kFALSE),fTaskName(""),fCaloUtils(0x0),
f37fa8d2 77 fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL),
c4eec29f 78 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE),fCaloFilterPatch(kFALSE),
48c37e02 79 fEMCALClustersListName(""),fZvtxCut(0.),
20218aea 80 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE), fUseEventsWithPrimaryVertex(kFALSE),
48c37e02 81 fTriggerAnalysis (new AliTriggerAnalysis), fCentralityClass("V0M"),fCentralityOpt(10)
cfaba834 82
af7b3903 83{
1c5acb87 84 //Ctor
85
86 //Initialize parameters
87 InitParameters();
88}
1c5acb87 89
90//_________________________________
91AliCaloTrackReader::~AliCaloTrackReader() {
92 //Dtor
93
ff45398a 94 if(fFiducialCut) delete fFiducialCut ;
29b2ceec 95
f37fa8d2 96 if(fAODBranchList){
97 fAODBranchList->Delete();
98 delete fAODBranchList ;
99 }
100
be518ab0 101 if(fCTSTracks){
102 if(fDataType!=kMC)fCTSTracks->Clear() ;
103 else fCTSTracks->Delete() ;
104 delete fCTSTracks ;
1c5acb87 105 }
106
be518ab0 107 if(fEMCALClusters){
108 if(fDataType!=kMC)fEMCALClusters->Clear("C") ;
109 else fEMCALClusters->Delete() ;
110 delete fEMCALClusters ;
1c5acb87 111 }
112
be518ab0 113 if(fPHOSClusters){
114 if(fDataType!=kMC)fPHOSClusters->Clear("C") ;
115 else fPHOSClusters->Delete() ;
116 delete fPHOSClusters ;
1c5acb87 117 }
118
238ce8e7 119// if(fEMCALCells){
120// delete fEMCALCells ;
121// }
122//
123// if(fPHOSCells){
124// delete fPHOSCells ;
125// }
eb310db0 126
7e25653f 127 if(fVertex){
128 for (Int_t i = 0; i < fNMixedEvent; i++) {
129 delete [] fVertex[i] ;
130
131 }
132 delete [] fVertex ;
133 }
134
48c37e02 135 if(fESDtrackCuts) delete fESDtrackCuts;
136 if(fTriggerAnalysis) delete fTriggerAnalysis;
3a58eee6 137
7787a778 138// Pointers not owned, done by the analysis frame
139// if(fInputEvent) delete fInputEvent ;
140// if(fOutputEvent) delete fOutputEvent ;
141// if(fMC) delete fMC ;
591cc579 142
7787a778 143// if(fSecondInputAODTree){
144// fSecondInputAODTree->Clear();
145// delete fSecondInputAODTree;
146// }
147//
148// if(fSecondInputAODEvent) delete fSecondInputAODEvent ;
c1ac3823 149
7787a778 150 // Pointer not owned, deleted by maker
151 //if (fCaloUtils) delete fCaloUtils ;
c1ac3823 152
153}
477d6cee 154
591cc579 155//_________________________________________________________________________
156Bool_t AliCaloTrackReader::ComparePtHardAndJetPt(){
90995603 157 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
158 // Only for PYTHIA.
159 if(!fReadStack) return kTRUE; //Information not filtered to AOD
160
161 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader")){
162 TParticle * jet = 0;
163 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
164 Int_t nTriggerJets = pygeh->NTriggerJets();
165 Float_t ptHard = pygeh->GetPtHard();
166
167 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
898c9d44 168 Float_t tmpjet[]={0,0,0,0};
90995603 169 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
170 pygeh->TriggerJet(ijet, tmpjet);
171 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
172 //Compare jet pT and pt Hard
173 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
174 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard) {
cfaba834 175 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
176 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
177 return kFALSE;
90995603 178 }
179 }
898c9d44 180 if(jet) delete jet;
90995603 181 }
182
183 return kTRUE ;
184
591cc579 185}
186
1c5acb87 187//____________________________________________________________________________
188AliStack* AliCaloTrackReader::GetStack() const {
189 //Return pointer to stack
190 if(fMC)
191 return fMC->Stack();
192 else{
477d6cee 193 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
1c5acb87 194 return 0x0 ;
195 }
196}
197
198//____________________________________________________________________________
199AliHeader* AliCaloTrackReader::GetHeader() const {
200 //Return pointer to header
201 if(fMC)
202 return fMC->Header();
203 else{
477d6cee 204 printf("AliCaloTrackReader::Header is not available\n");
1c5acb87 205 return 0x0 ;
206 }
207}
208//____________________________________________________________________________
209AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const {
210 //Return pointer to Generated event header
211 if(fMC)
212 return fMC->GenEventHeader();
213 else{
477d6cee 214 printf("AliCaloTrackReader::GenEventHeader is not available\n");
1c5acb87 215 return 0x0 ;
216 }
217}
218
591cc579 219//____________________________________________________________________________
220TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const {
1e68a3f4 221 //Return list of particles in AOD. Do it for the corresponding input event.
222
c8fe2783 223 TClonesArray * rv = NULL ;
1e68a3f4 224 if(fDataType == kAOD){
225
c8fe2783 226 if(input == 0){
1e68a3f4 227 //Normal input AOD
228 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
229 if(evt)
230 rv = (TClonesArray*)evt->FindListObject("mcparticles");
231 else
232 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
233
234 } //else if(input == 1 && fSecondInputAODEvent){ //Second input AOD
235// rv = (TClonesArray*) fSecondInputAODEvent->FindListObject("mcparticles");
236// }
237
c8fe2783 238 } else {
1e68a3f4 239 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
c8fe2783 240 }
1e68a3f4 241
c8fe2783 242 return rv ;
591cc579 243}
244
245//____________________________________________________________________________
246AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const {
90995603 247 //Return MC header in AOD. Do it for the corresponding input event.
1e68a3f4 248 AliAODMCHeader *mch = NULL;
90995603 249 if(fDataType == kAOD){
250 //Normal input AOD
251 if(input == 0) {
1e68a3f4 252 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
253 }
90995603 254 // //Second input AOD
255 // else if(input == 1){
256 // mch = (AliAODMCHeader*) fSecondInputAODEvent->FindListObject("mcheader");
257 // }
258 else {
259 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
260 }
261 }
262 else {
263 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
264 }
1e68a3f4 265
266 return mch;
591cc579 267}
268
269//_______________________________________________________________
270void AliCaloTrackReader::Init()
271{
90995603 272 //Init reader. Method to be called in AliAnaPartCorrMaker
273
274 //Get the file with second input events if the filename is given
275 //Get the tree and connect the AODEvent. Only with AODs
276
277 if(fReadStack && fReadAODMCParticles){
278 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
279 fReadStack = kFALSE;
280 fReadAODMCParticles = kFALSE;
281 }
282
1e68a3f4 283// if(fSecondInputFileName!=""){
284// if(fDataType == kAOD){
285// TFile * input2 = new TFile(fSecondInputFileName,"read");
286// printf("AliCaloTrackReader::Init() - Second input file opened: %s, size %d \n", input2->GetName(), (Int_t) input2->GetSize());
287// fSecondInputAODTree = (TTree*) input2->Get("aodTree");
288// if(fSecondInputAODTree) printf("AliCaloTrackReader::Init() - Second input tree opened: %s, entries %d \n",
289// fSecondInputAODTree->GetName(), (Int_t) fSecondInputAODTree->GetEntries());
290// else{
291// printf("AliCaloTrackReader::Init() - Second input tree not available, STOP \n");
292// abort();
293// }
294// fSecondInputAODEvent = new AliAODEvent;
295// fSecondInputAODEvent->ReadFromTree(fSecondInputAODTree);
296// if(fSecondInputFirstEvent >= fSecondInputAODTree->GetEntriesFast()){
297// printf("AliCaloTrackReader::Init() - Requested first event of second input %d, is larger than number of events %d, STOP\n",
298// fSecondInputFirstEvent, (Int_t) fSecondInputAODTree->GetEntriesFast());
299// abort();
300// }
301// }
302// else printf("AliCaloTrackReader::Init() - Second input not added, reader is not AOD\n");
303// }
591cc579 304}
765d44e7 305
1c5acb87 306//_______________________________________________________________
307void AliCaloTrackReader::InitParameters()
308{
1c5acb87 309 //Initialize the parameters of the analysis.
591cc579 310 fDataType = kESD ;
98ec971d 311 fCTSPtMin = 0.1 ;
312 fEMCALPtMin = 0.1 ;
313 fPHOSPtMin = 0.1 ;
314 fCTSPtMax = 1000. ;
315 fEMCALPtMax = 1000. ;
316 fPHOSPtMax = 1000. ;
317
902aa95c 318 //Do not filter the detectors input by default.
319 fFillEMCAL = kFALSE;
320 fFillPHOS = kFALSE;
321 fFillCTS = kFALSE;
1c5acb87 322 fFillEMCALCells = kFALSE;
591cc579 323 fFillPHOSCells = kFALSE;
1c5acb87 324
1e68a3f4 325 //fSecondInputFileName = "" ;
326 //fSecondInputFirstEvent = 0 ;
591cc579 327 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
328 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
42dc8e7d 329 fDeltaAODFileName = "deltaAODPartCorr.root";
72d2488e 330 fFiredTriggerClassName = "";
765d44e7 331
c1ac3823 332 fAnaLED = kFALSE;
0ae57829 333
334 //We want tracks fitted in the detectors:
3a58eee6 335 //fTrackStatus=AliESDtrack::kTPCrefit;
336 //fTrackStatus|=AliESDtrack::kITSrefit;
337
338 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
339
798a9b04 340 fV0ADC[0] = 0; fV0ADC[1] = 0;
341 fV0Mul[0] = 0; fV0Mul[1] = 0;
342
0b13c1f9 343 fZvtxCut = 10.;
344
32fd29fe 345 //Centrality
346 fCentralityBin[0]=fCentralityBin[1]=-1;
347
cfaba834 348 //Cluster smearing
349 fSmearClusterEnergy = kFALSE;
350 fSmearClusterParam[0] = 0.07; // * sqrt E term
351 fSmearClusterParam[1] = 0.02; // * E term
352 fSmearClusterParam[2] = 0.00; // constant
353
4e2b43d8 354}
1c5acb87 355
356//________________________________________________________________
357void AliCaloTrackReader::Print(const Option_t * opt) const
358{
359
360 //Print some relevant parameters set for the analysis
361 if(! opt)
362 return;
363
364 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
486258c9 365 printf("Task name : %s\n", fTaskName.Data()) ;
1c5acb87 366 printf("Data type : %d\n", fDataType) ;
367 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
368 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
369 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
98ec971d 370 printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
371 printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
372 printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
1c5acb87 373 printf("Use CTS = %d\n", fFillCTS) ;
374 printf("Use EMCAL = %d\n", fFillEMCAL) ;
375 printf("Use PHOS = %d\n", fFillPHOS) ;
376 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
377 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
591cc579 378 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
3a58eee6 379 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
f37fa8d2 380 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
1e68a3f4 381
591cc579 382 if(fComparePtHardAndJetPt)
383 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
384
1e68a3f4 385// if(fSecondInputFileName!="") {
386// printf("Second Input File Name = %s\n", fSecondInputFileName.Data()) ;
387// printf("Second Input First Event = %d\n", fSecondInputFirstEvent) ;
388// }
591cc579 389
42dc8e7d 390 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
42dc8e7d 391 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
8a3f4796 392 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
32fd29fe 393
1c5acb87 394 printf(" \n") ;
32fd29fe 395
1c5acb87 396}
397
398//___________________________________________________
1510eee3 399Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * /*currentFileName*/) {
6639984f 400 //Fill the event counter and input lists that are needed, called by the analysis maker.
902aa95c 401
6639984f 402 fEventNumber = iEntry;
1510eee3 403 //fCurrentFileName = TString(currentFileName);
be1f5fa4 404 if(!fInputEvent) {
f7c2338a 405 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
be1f5fa4 406 return kFALSE;
407 }
72d2488e 408 //Select events only fired by a certain trigger configuration if it is provided
be1f5fa4 409 Int_t eventType = 0;
410 if(fInputEvent->GetHeader())
411 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
4d8a2fe1 412
c1ac3823 413 if( fFiredTriggerClassName !="" && !fAnaLED){
c8fe2783 414 if(eventType!=7)
415 return kFALSE; //Only physics event, do not use for simulated events!!!
7ec23b5a 416 if(fDebug > 0)
417 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
418 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
419 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
4d8a2fe1 420 else if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent() - Accepted triggered event\n");
72d2488e 421 }
c1ac3823 422 else if(fAnaLED){
423// kStartOfRun = 1, // START_OF_RUN
424// kEndOfRun = 2, // END_OF_RUN
425// kStartOfRunFiles = 3, // START_OF_RUN_FILES
426// kEndOfRunFiles = 4, // END_OF_RUN_FILES
427// kStartOfBurst = 5, // START_OF_BURST
428// kEndOfBurst = 6, // END_OF_BURST
429// kPhysicsEvent = 7, // PHYSICS_EVENT
430// kCalibrationEvent = 8, // CALIBRATION_EVENT
431// kFormatError = 9, // EVENT_FORMAT_ERROR
432// kStartOfData = 10, // START_OF_DATA
433// kEndOfData = 11, // END_OF_DATA
434// kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
435// kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
436
437 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
438 if(eventType!=8)return kFALSE;
439 }
440
29b2ceec 441 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
442 if(fComparePtHardAndJetPt && GetStack()) {
7ec23b5a 443 if(!ComparePtHardAndJetPt()) return kFALSE ;
29b2ceec 444 }
591cc579 445
446 //In case of mixing events with other AOD file
1e68a3f4 447 // if(fDataType == kAOD && fSecondInputAODTree){
448//
449// if(fDebug > 1)
450// printf("AliCaloTrackReader::FillInputEvent() - Get event %d from second input AOD file \n", iEntry+fSecondInputFirstEvent);
451// if(fSecondInputAODTree->GetEntriesFast() <= iEntry+fSecondInputFirstEvent) {
452// if(fSecondInputAODTree->GetEntriesFast() == iEntry+fSecondInputFirstEvent)
453// printf("AliCaloTrackReader::FillInputEvent() - Skip events from event %d, no more events in second AOD file \n", iEntry);
454// return kFALSE;
455// }
456//
457// //Get the Event
458// Int_t nbytes = fSecondInputAODTree->GetEvent(iEntry+fSecondInputFirstEvent);
459// if ( nbytes == 0 ) {//If nothing in AOD
460// printf("AliCaloTrackReader::FillInputEvent() - Nothing in Second AOD input, STOP\n");
461// abort() ;
462// }
463//
464// }
09e819c9 465
48c37e02 466 //Fill Vertex array
467 FillVertexArray();
468 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
469 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
470
471 //------------------------------------------------------
472 //Event rejection depending on vertex, pileup, v0and
473 //------------------------------------------------------
474 if(fDoEventSelection){
475 if(!fCaloFilterPatch){
476 //Do not analyze events with pileup
477 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
478 //Bool_t bPileup = event->IsPileupFromSPD();
479 if(bPileup) return kFALSE;
480
481 if(fDoV0ANDEventSelection){
482 Bool_t bV0AND = kTRUE;
ad30b142 483 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
484 if(esd)
485 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
48c37e02 486 //else bV0AND = //FIXME FOR AODs
487 if(!bV0AND) return kFALSE;
488 }
489
20218aea 490 if(fUseEventsWithPrimaryVertex && !CheckForPrimaryVertex()) return kFALSE;
ba1eeb1f 491
48c37e02 492 }//CaloFilter patch
493 else{
494 if(fInputEvent->GetNumberOfCaloClusters() > 0) {
495 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
496 if(calo->GetNLabels() == 4){
497 Int_t * selection = calo->GetLabels();
498 Bool_t bPileup = selection[0];
499 if(bPileup) return kFALSE;
500
501 Bool_t bGoodV = selection[1];
20218aea 502 if(fUseEventsWithPrimaryVertex && !bGoodV) return kFALSE;
48c37e02 503
504 if(fDoV0ANDEventSelection){
505 Bool_t bV0AND = selection[2];
506 if(!bV0AND) return kFALSE;
507 }
508
509 fTrackMult = selection[3];
510 if(fTrackMult == 0) return kFALSE;
511 } else {
512 //First filtered AODs, track multiplicity stored there.
513 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
514 if(fTrackMult == 0) return kFALSE;
515 }
516 }//at least one cluster
517 else {
cfaba834 518 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
48c37e02 519 //Remove events with vertex (0,0,0), bad vertex reconstruction
20218aea 520 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 521
522 //First filtered AODs, track multiplicity stored there.
523 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
524 if(fTrackMult == 0) return kFALSE;
525 }// no cluster
526 }// CaloFileter patch
527 }// Event selection
528 //------------------------------------------------------
529
32fd29fe 530 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
531 //If we need a centrality bin, we select only those events in the corresponding bin.
532 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100){
533 Int_t cen = GetEventCentrality();
534 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
535 }
536
f8006433 537 //Fill the arrays with cluster/tracks/cells data
538 if(fFillEMCALCells)
c8fe2783 539 FillInputEMCALCells();
540 if(fFillPHOSCells)
541 FillInputPHOSCells();
09e819c9 542
90995603 543 if(fFillCTS){
c8fe2783 544 FillInputCTS();
90995603 545 //Accept events with at least one track
48c37e02 546 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
af7b3903 547 }
548
c8fe2783 549 if(fFillEMCAL)
550 FillInputEMCAL();
551 if(fFillPHOS)
552 FillInputPHOS();
09e819c9 553
798a9b04 554 FillInputVZERO();
7ec23b5a 555
29b2ceec 556 return kTRUE ;
1c5acb87 557}
558
559//__________________________________________________
560void AliCaloTrackReader::ResetLists() {
561 // Reset lists, called by the analysis maker
562
6060ed91 563 if(fCTSTracks) fCTSTracks -> Clear();
be518ab0 564 if(fEMCALClusters) fEMCALClusters -> Clear("C");
565 if(fPHOSClusters) fPHOSClusters -> Clear("C");
238ce8e7 566// if(fEMCALCells) fEMCALCells -> Clear("");
567// if(fPHOSCells) fPHOSCells -> Clear("");
798a9b04 568
569 fV0ADC[0] = 0; fV0ADC[1] = 0;
570 fV0Mul[0] = 0; fV0Mul[1] = 0;
571
1c5acb87 572}
c8fe2783 573
574//____________________________________________________________________________
575void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
576{
577 fInputEvent = input;
578 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
579 if (fMixedEvent) {
580 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
581 }
eb310db0 582
583 //Delete previous vertex
584 if(fVertex){
585 for (Int_t i = 0; i < fNMixedEvent; i++) {
586 delete [] fVertex[i] ;
587 }
588 delete [] fVertex ;
589 }
590
c8fe2783 591 fVertex = new Double_t*[fNMixedEvent] ;
592 for (Int_t i = 0; i < fNMixedEvent; i++) {
593 fVertex[i] = new Double_t[3] ;
594 fVertex[i][0] = 0.0 ;
595 fVertex[i][1] = 0.0 ;
596 fVertex[i][2] = 0.0 ;
597 }
598}
599
32fd29fe 600//__________________________________________________
601Int_t AliCaloTrackReader::GetEventCentrality() const {
602 //Return current event centrality
603
604 if(GetCentrality()){
20218aea 605 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass); // 100 bins max
606 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);// 10 bins max
607 else if(fCentralityOpt==20) return GetCentrality()->GetCentralityClass5(fCentralityClass); // 20 bins max
32fd29fe 608 else {
20218aea 609 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 10, 20 or 100\n",fCentralityOpt);
32fd29fe 610 return 0;
611 }
612 }
613 else return 0;
614
615}
616
c8fe2783 617//____________________________________________________________________________
f8006433 618void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const {
619 //Return vertex position to be used for single event analysis
620 vertex[0]=fVertex[0][0];
621 vertex[1]=fVertex[0][1];
622 vertex[2]=fVertex[0][2];
623}
624
625//____________________________________________________________________________
626void AliCaloTrackReader::GetVertex(Double_t vertex[3], const Int_t evtIndex) const {
627 //Return vertex position for mixed event, recover the vertex in a particular event.
628
629 //Int_t evtIndex = 0; // for single events only one vertex stored in position 0, default value
630 //if (fMixedEvent && clusterID >=0) {
631 // evtIndex=GetMixedEvent()->EventIndexForCaloCluster(clusterID) ;
632 //}
633
634 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
635
636}
637//
638
639
640//____________________________________________________________________________
641void AliCaloTrackReader::FillVertexArray() {
642
643 //Fill data member with vertex
644 //In case of Mixed event, multiple vertices
645
646 //Delete previous vertex
647 if(fVertex){
648 for (Int_t i = 0; i < fNMixedEvent; i++) {
649 delete [] fVertex[i] ;
650 }
651 delete [] fVertex ;
652 }
653
654 fVertex = new Double_t*[fNMixedEvent] ;
655 for (Int_t i = 0; i < fNMixedEvent; i++) {
656 fVertex[i] = new Double_t[3] ;
657 fVertex[i][0] = 0.0 ;
658 fVertex[i][1] = 0.0 ;
659 fVertex[i][2] = 0.0 ;
660 }
661
662 if (!fMixedEvent) { //Single event analysis
79395d30 663 if(fDataType!=kMC){
664
665 if(fInputEvent->GetPrimaryVertex()){
666 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
667 }
668 else {
669 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
670 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
671 }//Primary vertex pointer do not exist
672
673 } else {//MC read event
edffc439 674 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
675 }
676
f8006433 677 if(fDebug > 1)
678 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
679
680 } else { // MultiEvent analysis
681 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
8e7bdfa9 682 if (fMixedEvent->GetVertexOfEvent(iev))
683 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
684 else { // no vertex found !!!!
685 AliWarning("No vertex found");
686 }
687
f8006433 688 if(fDebug > 1)
689 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
690
691 }
c8fe2783 692 }
f8006433 693
c8fe2783 694}
695
f37fa8d2 696//____________________________________________________________________________
c8fe2783 697void AliCaloTrackReader::FillInputCTS() {
f37fa8d2 698 //Return array with Central Tracking System (CTS) tracks
699
700 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
701
c8fe2783 702 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
c8fe2783 703 Double_t p[3];
3a58eee6 704 fTrackMult = 0;
705 Int_t nstatus = 0;
c8fe2783 706 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
707 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
3a58eee6 708
709 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
c8fe2783 710 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
711 continue ;
712
3a58eee6 713 nstatus++;
714
715 if(fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;
716
3b13c34c 717 // Track filter selection
718 //if (fTrackFilter) {
719 // selectInfo = fTrackFilter->IsSelected(esdTrack);
720 // if (!selectInfo && !(esd->GetPrimaryVertex())->UsesTrack(esdTrack->GetID())) continue;
721 // }
722
3a58eee6 723 //Count the tracks in eta < 0.9
724 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
725 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
726
c8fe2783 727 track->GetPxPyPz(p) ;
728 TLorentzVector momentum(p[0],p[1],p[2],0);
729
98ec971d 730 if(fCTSPtMin < momentum.Pt() && fCTSPtMax > momentum.Pt()){
c8fe2783 731
732 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
733 continue;
734
735 if(fDebug > 2 && momentum.Pt() > 0.1)
f37fa8d2 736 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 737 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
738
739 if (fMixedEvent) {
740 track->SetID(itrack);
741 }
f37fa8d2 742
be518ab0 743 fCTSTracks->Add(track);
f37fa8d2 744
c8fe2783 745 }//Pt and Fiducial cut passed.
746 }// track loop
747
be518ab0 748 //fCTSTracksNormalInputEntries = fCTSTracks->GetEntriesFast();
3a58eee6 749 if(fDebug > 1)
be518ab0 750 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
c8fe2783 751
752 // //If second input event available, add the clusters.
753 // if(fSecondInputAODTree && fSecondInputAODEvent){
754 // nTracks = fSecondInputAODEvent->GetNumberOfTracks() ;
f37fa8d2 755 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - Add second input tracks, entries %d\n", nTracks) ;
c8fe2783 756 // for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
757 // AliAODTrack * track = ((AliAODEvent*)fSecondInputAODEvent)->GetTrack(itrack) ; // retrieve track from esd
758 //
759 // //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
760 // if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
761 //
762 // track->GetPxPyPz(p) ;
763 // TLorentzVector momentum(p[0],p[1],p[2],0);
764 //
765 // if(fCTSPtMin < momentum.Pt()){
766 //
767 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
768 //
f37fa8d2 769 // if(fDebug > 2 && momentum.Pt() > 0.1) printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 770 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
771 //
be518ab0 772 // fCTSTracks->Add(track);
c8fe2783 773 //
774 // }//Pt and Fiducial cut passed.
775 // }// track loop
776 //
be518ab0 777 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - aod normal entries %d, after second input %d\n", fCTSTracksNormalInputEntries, fCTSTracks->GetEntriesFast());
c8fe2783 778 // } //second input loop
779 //
780}
781
c4eec29f 782//____________________________________________________________________________
783void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, const Int_t iclus) {
784 //Fill the EMCAL data in the array, do it
785
786 Int_t vindex = 0 ;
787 if (fMixedEvent)
788 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
789
c4eec29f 790
a38a48f2 791 //Reject clusters with bad channels, close to borders and exotic;
792 if(!GetCaloUtils()->GetEMCALRecoUtils()->IsGoodCluster(clus,GetCaloUtils()->GetEMCALGeometry(),GetEMCALCells())) return;
793// //Check if the cluster contains any bad channel and if close to calorimeter borders
794// if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells()))
795// return;
796// if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex))
797// return;
798//
48c37e02 799
6060ed91 800 if(fSelectEmbeddedClusters){
1407394b 801 if(clus->GetNLabels()==0 || clus->GetLabel() < 0) return;
6060ed91 802 //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
803 }
cfaba834 804
c4eec29f 805 TLorentzVector momentum ;
806
807 clus->GetMomentum(momentum, fVertex[vindex]);
808
98ec971d 809 if(fEMCALPtMin < momentum.E() && fEMCALPtMax > momentum.E()){
c4eec29f 810
811 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL"))
812 return;
813
814 if(fDebug > 2 && momentum.E() > 0.1)
815 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
816 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
817
818 //Float_t pos[3];
819 //clus->GetPosition(pos);
820 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
821
822 //Recalibrate the cluster energy
823 if(GetCaloUtils()->IsRecalibrationOn()) {
824 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
825 clus->SetE(energy);
826 //printf("Recalibrated Energy %f\n",clus->E());
827 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
828 GetCaloUtils()->RecalculateClusterPID(clus);
829
830 }
831
832 //Recalculate distance to bad channels, if new list of bad channels provided
833 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
834
835 //Recalculate cluster position
836 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
837 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
838 //clus->GetPosition(pos);
839 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
840 }
841
842 //Correct non linearity
843 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
844 GetCaloUtils()->CorrectClusterEnergy(clus) ;
845 //printf("Linearity Corrected Energy %f\n",clus->E());
846 }
847
cfaba834 848 //In case of MC analysis, to match resolution/calibration in real data
849 if(fSmearClusterEnergy){
850 Float_t energy = clus->E();
c50cb1c5 851 Float_t rdmEnergy = fRandom.Gaus(energy,fSmearClusterParam[0]*TMath::Sqrt(energy)+
852 fSmearClusterParam[1]*energy+fSmearClusterParam[2]);
cfaba834 853 clus->SetE(rdmEnergy);
854 if(fDebug > 2) printf("\t Energy %f, smeared %f\n", energy, clus->E());
855 }
856
c4eec29f 857 if (fMixedEvent)
858 clus->SetID(iclus) ;
859
be518ab0 860 fEMCALClusters->Add(clus);
c4eec29f 861 }
862}
863
864//____________________________________________________________________________
c8fe2783 865void AliCaloTrackReader::FillInputEMCAL() {
f37fa8d2 866 //Return array with EMCAL clusters in aod format
c8fe2783 867
f37fa8d2 868 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
869
870 //Loop to select clusters in fiducial cut and fill container with aodClusters
c4eec29f 871 if(fEMCALClustersListName==""){
872 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
873 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
874 AliVCluster * clus = 0;
875 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
876 if (IsEMCALCluster(clus)){
877 FillInputEMCALAlgorithm(clus, iclus);
878 }//EMCAL cluster
879 }// cluster exists
880 }// cluster loop
385b7abf 881
882 //Recalculate track matching
a38a48f2 883 GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
385b7abf 884
c4eec29f 885 }//Get the clusters from the input event
886 else {
887 TClonesArray * clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
888 if(!clusterList){
1407394b 889 //printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? Try input event <%s>\n",fEMCALClustersListName.Data());
890 //List not in output event, try input event
891 clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
892 if(!clusterList){
893 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
894 return;
895 }
c4eec29f 896 }
897 Int_t nclusters = clusterList->GetEntriesFast();
898 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
899 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
900 //printf("E %f\n",clus->E());
e615d952 901 if (clus) FillInputEMCALAlgorithm(clus, iclus);
902 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
385b7abf 903
c4eec29f 904 }// cluster loop
385b7abf 905
906 //Recalculate track matching, not necessary, already done in the reclusterization task
907 //GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
908
c4eec29f 909 }
385b7abf 910
be518ab0 911 //fEMCALClustersNormalInputEntries = fEMCALClusters->GetEntriesFast();
912 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());//fEMCALClustersNormalInputEntries);
c8fe2783 913
914 //If second input event available, add the clusters.
915 // if(fSecondInputAODTree && fSecondInputAODEvent){
916 // GetSecondInputAODVertex(v);
917 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
f37fa8d2 918 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - Add second input clusters, entries %d\n", nclusters) ;
c8fe2783 919 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
920 // AliAODCaloCluster * clus = 0;
921 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
922 // if (clus->IsEMCAL()){
923 // TLorentzVector momentum ;
924 // clus->GetMomentum(momentum, v);
925 //
926 // if(fEMCALPtMin < momentum.Pt()){
927 //
928 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) continue;
929 //
f37fa8d2 930 // if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 931 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
be518ab0 932 // fEMCALClusters->Add(clus);
c8fe2783 933 // }//Pt and Fiducial cut passed.
934 // }//EMCAL cluster
935 // }// cluster exists
936 // }// cluster loop
937 //
be518ab0 938 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod normal entries %d, after second input %d\n", fEMCALClustersNormalInputEntries, fEMCALClusters->GetEntriesFast());
c8fe2783 939 //
940 // } //second input loop
941}
942
943 //____________________________________________________________________________
944void AliCaloTrackReader::FillInputPHOS() {
f37fa8d2 945 //Return array with PHOS clusters in aod format
c8fe2783 946
f37fa8d2 947 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
948
949 //Loop to select clusters in fiducial cut and fill container with aodClusters
c8fe2783 950 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
951 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
952 AliVCluster * clus = 0;
953 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
f37fa8d2 954 if (IsPHOSCluster(clus)){
955 //Check if the cluster contains any bad channel and if close to calorimeter borders
c8fe2783 956 Int_t vindex = 0 ;
957 if (fMixedEvent)
958 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
959 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
960 continue;
961 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
962 continue;
963
964 TLorentzVector momentum ;
965
966 clus->GetMomentum(momentum, fVertex[vindex]);
967
98ec971d 968 if(fPHOSPtMin < momentum.E() && fPHOSPtMax > momentum.E()){
c8fe2783 969
970 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS"))
971 continue;
972
973 if(fDebug > 2 && momentum.E() > 0.1)
f37fa8d2 974 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 975 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
976
977 //Recalibrate the cluster energy
978 if(GetCaloUtils()->IsRecalibrationOn()) {
979 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
980 clus->SetE(energy);
981 }
982
983 if (fMixedEvent) {
984 clus->SetID(iclus) ;
985 }
986
be518ab0 987 fPHOSClusters->Add(clus);
f37fa8d2 988
c8fe2783 989 }//Pt and Fiducial cut passed.
990 }//PHOS cluster
991 }//cluster exists
992 }//esd cluster loop
993
be518ab0 994 //fPHOSClustersNormalInputEntries = fPHOSClusters->GetEntriesFast() ;
995 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());//fPHOSClustersNormalInputEntries);
c8fe2783 996
997 //If second input event available, add the clusters.
998 // if(fSecondInputAODTree && fSecondInputAODEvent){
999 // GetSecondInputAODVertex(v);
1000 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
f37fa8d2 1001 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - Add second input clusters, entries %d\n", nclusters);
c8fe2783 1002 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
1003 // AliAODCaloCluster * clus = 0;
1004 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
1005 // if (clus->IsPHOS()){
1006 // TLorentzVector momentum ;
1007 // clus->GetMomentum(momentum, v);
1008 //
1009 // if(fPHOSPtMin < momentum.Pt()){
1010 //
1011 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1012 //
f37fa8d2 1013 // if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 1014 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
be518ab0 1015 // fPHOSClusters->Add(clus);
c8fe2783 1016 // }//Pt and Fiducial cut passed.
1017 // }//PHOS cluster
1018 // }// cluster exists
1019 // }// cluster loop
be518ab0 1020 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod normal entries %d, after second input %d\n", fPHOSClustersNormalInputEntries, fPHOSClusters->GetEntriesFast());
c8fe2783 1021 // } //second input loop
1022
1023}
1024
f37fa8d2 1025//____________________________________________________________________________
c8fe2783 1026void AliCaloTrackReader::FillInputEMCALCells() {
1027 //Return array with EMCAL cells in aod format
1028
1029 fEMCALCells = fInputEvent->GetEMCALCells();
1030
1031}
1032
f37fa8d2 1033//____________________________________________________________________________
c8fe2783 1034void AliCaloTrackReader::FillInputPHOSCells() {
1035 //Return array with PHOS cells in aod format
1036
1037 fPHOSCells = fInputEvent->GetPHOSCells();
1038
1039}
1040
be518ab0 1041//____________________________________________________________________________
1042void AliCaloTrackReader::FillInputVZERO(){
1043 //Fill VZERO information in data member, add all the channels information.
1044 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1045 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1046
1047 if (v0)
1048 {
1049 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1050 for (Int_t i = 0; i < 32; i++)
1051 {
1052 if(esdV0){//Only available in ESDs
1053 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1054 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1055 }
1056 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1057 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1058 }
1059 if(fDebug > 0)
1060 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1061 }
1062 else
1063 {
713a258b 1064 if(fDebug > 0)
1065 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
be518ab0 1066 }
1067}
1068
798a9b04 1069
f37fa8d2 1070//____________________________________________________________________________
1071Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const {
1072 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1073 // different number and need to patch here
1074
1075 if(fDataType==kAOD && fOldAOD)
1076 {
1077 if (cluster->GetType() == 2) return kTRUE;
1078 else return kFALSE;
1079 }
1080 else
1081 {
1082 return cluster->IsEMCAL();
1083 }
1084
1085}
1086
1087//____________________________________________________________________________
1088Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const {
1089 //Check if it is a cluster from PHOS.For old AODs cluster type has
1090 // different number and need to patch here
1091
1092 if(fDataType==kAOD && fOldAOD)
1093 {
1094 Int_t type = cluster->GetType();
1095 if (type == 0 || type == 1) return kTRUE;
1096 else return kFALSE;
1097 }
1098 else
1099 {
1100 return cluster->IsPHOS();
1101 }
1102
1103}
1104
48c37e02 1105//____________________________________________________________________________
1106Bool_t AliCaloTrackReader::CheckForPrimaryVertex(){
1107 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1108 //Only for ESDs ...
ad30b142 1109
48c37e02 1110 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
20218aea 1111 if(!event) return kTRUE;
ad30b142 1112
1113 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {
1114 return kTRUE;
1115 }
1116
1117 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {
1118 // SPD vertex
1119 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {
1120 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
48c37e02 1121 return kTRUE;
ad30b142 1122
48c37e02 1123 }
ad30b142 1124 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {
1125 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1126 return kFALSE;
48c37e02 1127 }
48c37e02 1128 }
1129
ad30b142 1130 return kFALSE;
48c37e02 1131
1132}
1133
1134
1135