extra tokens at end of #include directive
[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),
f37fa8d2 62 fCTSPtMin(0), fEMCALPtMin(0),fPHOSPtMin(0), 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),
cfaba834 67 fFillEMCALCells(0),fFillPHOSCells(0),
68 fRemoveSuspiciousClusters(kFALSE), 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.),
80 fDoEventSelection(kFALSE), fDoV0ANDEventSelection(kFALSE),
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 ;
1c5acb87 311 fCTSPtMin = 0.2 ;
29b2ceec 312 fEMCALPtMin = 0.2 ;
313 fPHOSPtMin = 0.2 ;
1c5acb87 314
902aa95c 315 //Do not filter the detectors input by default.
316 fFillEMCAL = kFALSE;
317 fFillPHOS = kFALSE;
318 fFillCTS = kFALSE;
1c5acb87 319 fFillEMCALCells = kFALSE;
591cc579 320 fFillPHOSCells = kFALSE;
1c5acb87 321
1e68a3f4 322 //fSecondInputFileName = "" ;
323 //fSecondInputFirstEvent = 0 ;
591cc579 324 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
325 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
42dc8e7d 326 fDeltaAODFileName = "deltaAODPartCorr.root";
72d2488e 327 fFiredTriggerClassName = "";
765d44e7 328
c1ac3823 329 fAnaLED = kFALSE;
0ae57829 330
331 //We want tracks fitted in the detectors:
3a58eee6 332 //fTrackStatus=AliESDtrack::kTPCrefit;
333 //fTrackStatus|=AliESDtrack::kITSrefit;
334
335 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
336
798a9b04 337 fV0ADC[0] = 0; fV0ADC[1] = 0;
338 fV0Mul[0] = 0; fV0Mul[1] = 0;
339
0b13c1f9 340 fZvtxCut = 10.;
341
32fd29fe 342 //Centrality
343 fCentralityBin[0]=fCentralityBin[1]=-1;
344
cfaba834 345 //Cluster smearing
346 fSmearClusterEnergy = kFALSE;
347 fSmearClusterParam[0] = 0.07; // * sqrt E term
348 fSmearClusterParam[1] = 0.02; // * E term
349 fSmearClusterParam[2] = 0.00; // constant
350
4e2b43d8 351}
1c5acb87 352
353//________________________________________________________________
354void AliCaloTrackReader::Print(const Option_t * opt) const
355{
356
357 //Print some relevant parameters set for the analysis
358 if(! opt)
359 return;
360
361 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
486258c9 362 printf("Task name : %s\n", fTaskName.Data()) ;
1c5acb87 363 printf("Data type : %d\n", fDataType) ;
364 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
365 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
366 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
367 printf("Use CTS = %d\n", fFillCTS) ;
368 printf("Use EMCAL = %d\n", fFillEMCAL) ;
369 printf("Use PHOS = %d\n", fFillPHOS) ;
370 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
371 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
591cc579 372 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
3a58eee6 373 printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
f37fa8d2 374 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
1e68a3f4 375
591cc579 376 if(fComparePtHardAndJetPt)
377 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
378
1e68a3f4 379// if(fSecondInputFileName!="") {
380// printf("Second Input File Name = %s\n", fSecondInputFileName.Data()) ;
381// printf("Second Input First Event = %d\n", fSecondInputFirstEvent) ;
382// }
591cc579 383
42dc8e7d 384 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
42dc8e7d 385 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
32fd29fe 386 if(GetCentrality())
387 printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
388
1c5acb87 389 printf(" \n") ;
32fd29fe 390
1c5acb87 391}
392
393//___________________________________________________
1510eee3 394Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * /*currentFileName*/) {
6639984f 395 //Fill the event counter and input lists that are needed, called by the analysis maker.
902aa95c 396
6639984f 397 fEventNumber = iEntry;
1510eee3 398 //fCurrentFileName = TString(currentFileName);
be1f5fa4 399 if(!fInputEvent) {
f7c2338a 400 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
be1f5fa4 401 return kFALSE;
402 }
72d2488e 403 //Select events only fired by a certain trigger configuration if it is provided
be1f5fa4 404 Int_t eventType = 0;
405 if(fInputEvent->GetHeader())
406 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
c1ac3823 407 if( fFiredTriggerClassName !="" && !fAnaLED){
c8fe2783 408 if(eventType!=7)
409 return kFALSE; //Only physics event, do not use for simulated events!!!
7ec23b5a 410 if(fDebug > 0)
411 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
412 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
413 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
72d2488e 414 }
c1ac3823 415 else if(fAnaLED){
416// kStartOfRun = 1, // START_OF_RUN
417// kEndOfRun = 2, // END_OF_RUN
418// kStartOfRunFiles = 3, // START_OF_RUN_FILES
419// kEndOfRunFiles = 4, // END_OF_RUN_FILES
420// kStartOfBurst = 5, // START_OF_BURST
421// kEndOfBurst = 6, // END_OF_BURST
422// kPhysicsEvent = 7, // PHYSICS_EVENT
423// kCalibrationEvent = 8, // CALIBRATION_EVENT
424// kFormatError = 9, // EVENT_FORMAT_ERROR
425// kStartOfData = 10, // START_OF_DATA
426// kEndOfData = 11, // END_OF_DATA
427// kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
428// kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
429
430 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
431 if(eventType!=8)return kFALSE;
432 }
433
29b2ceec 434 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
435 if(fComparePtHardAndJetPt && GetStack()) {
7ec23b5a 436 if(!ComparePtHardAndJetPt()) return kFALSE ;
29b2ceec 437 }
591cc579 438
439 //In case of mixing events with other AOD file
1e68a3f4 440 // if(fDataType == kAOD && fSecondInputAODTree){
441//
442// if(fDebug > 1)
443// printf("AliCaloTrackReader::FillInputEvent() - Get event %d from second input AOD file \n", iEntry+fSecondInputFirstEvent);
444// if(fSecondInputAODTree->GetEntriesFast() <= iEntry+fSecondInputFirstEvent) {
445// if(fSecondInputAODTree->GetEntriesFast() == iEntry+fSecondInputFirstEvent)
446// printf("AliCaloTrackReader::FillInputEvent() - Skip events from event %d, no more events in second AOD file \n", iEntry);
447// return kFALSE;
448// }
449//
450// //Get the Event
451// Int_t nbytes = fSecondInputAODTree->GetEvent(iEntry+fSecondInputFirstEvent);
452// if ( nbytes == 0 ) {//If nothing in AOD
453// printf("AliCaloTrackReader::FillInputEvent() - Nothing in Second AOD input, STOP\n");
454// abort() ;
455// }
456//
457// }
09e819c9 458
48c37e02 459 //Fill Vertex array
460 FillVertexArray();
461 //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
462 if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;
463
464 //------------------------------------------------------
465 //Event rejection depending on vertex, pileup, v0and
466 //------------------------------------------------------
467 if(fDoEventSelection){
468 if(!fCaloFilterPatch){
469 //Do not analyze events with pileup
470 Bool_t bPileup = fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
471 //Bool_t bPileup = event->IsPileupFromSPD();
472 if(bPileup) return kFALSE;
473
474 if(fDoV0ANDEventSelection){
475 Bool_t bV0AND = kTRUE;
ad30b142 476 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (fInputEvent);
477 if(esd)
478 bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND);
48c37e02 479 //else bV0AND = //FIXME FOR AODs
480 if(!bV0AND) return kFALSE;
481 }
482
483 if(!CheckForPrimaryVertex()) return kFALSE;
484 }//CaloFilter patch
485 else{
486 if(fInputEvent->GetNumberOfCaloClusters() > 0) {
487 AliVCluster * calo = fInputEvent->GetCaloCluster(0);
488 if(calo->GetNLabels() == 4){
489 Int_t * selection = calo->GetLabels();
490 Bool_t bPileup = selection[0];
491 if(bPileup) return kFALSE;
492
493 Bool_t bGoodV = selection[1];
494 if(!bGoodV) return kFALSE;
495
496 if(fDoV0ANDEventSelection){
497 Bool_t bV0AND = selection[2];
498 if(!bV0AND) return kFALSE;
499 }
500
501 fTrackMult = selection[3];
502 if(fTrackMult == 0) return kFALSE;
503 } else {
504 //First filtered AODs, track multiplicity stored there.
505 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
506 if(fTrackMult == 0) return kFALSE;
507 }
508 }//at least one cluster
509 else {
cfaba834 510 //printf("AliCaloTrackReader::FillInputEvent() - No clusters in event\n");
48c37e02 511 //Remove events with vertex (0,0,0), bad vertex reconstruction
512 if(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;
513
514 //First filtered AODs, track multiplicity stored there.
515 fTrackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
516 if(fTrackMult == 0) return kFALSE;
517 }// no cluster
518 }// CaloFileter patch
519 }// Event selection
520 //------------------------------------------------------
521
32fd29fe 522 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
523 //If we need a centrality bin, we select only those events in the corresponding bin.
524 if(GetCentrality() && fCentralityBin[0]>=0 && fCentralityBin[1]>=0 && fCentralityOpt==100){
525 Int_t cen = GetEventCentrality();
526 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return kFALSE; //reject events out of bin.
527 }
528
f8006433 529 //Fill the arrays with cluster/tracks/cells data
530 if(fFillEMCALCells)
c8fe2783 531 FillInputEMCALCells();
532 if(fFillPHOSCells)
533 FillInputPHOSCells();
09e819c9 534
90995603 535 if(fFillCTS){
c8fe2783 536 FillInputCTS();
90995603 537 //Accept events with at least one track
48c37e02 538 if(fTrackMult == 0 && fDoEventSelection) return kFALSE;
af7b3903 539 }
540
c8fe2783 541 if(fFillEMCAL)
542 FillInputEMCAL();
543 if(fFillPHOS)
544 FillInputPHOS();
09e819c9 545
798a9b04 546 FillInputVZERO();
7ec23b5a 547
29b2ceec 548 return kTRUE ;
1c5acb87 549}
550
551//__________________________________________________
552void AliCaloTrackReader::ResetLists() {
553 // Reset lists, called by the analysis maker
554
be518ab0 555 if(fCTSTracks) fCTSTracks -> Clear();
556 if(fEMCALClusters) fEMCALClusters -> Clear("C");
557 if(fPHOSClusters) fPHOSClusters -> Clear("C");
238ce8e7 558// if(fEMCALCells) fEMCALCells -> Clear("");
559// if(fPHOSCells) fPHOSCells -> Clear("");
798a9b04 560
561 fV0ADC[0] = 0; fV0ADC[1] = 0;
562 fV0Mul[0] = 0; fV0Mul[1] = 0;
563
1c5acb87 564}
c8fe2783 565
566//____________________________________________________________________________
567void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
568{
569 fInputEvent = input;
570 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
571 if (fMixedEvent) {
572 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
573 }
eb310db0 574
575 //Delete previous vertex
576 if(fVertex){
577 for (Int_t i = 0; i < fNMixedEvent; i++) {
578 delete [] fVertex[i] ;
579 }
580 delete [] fVertex ;
581 }
582
c8fe2783 583 fVertex = new Double_t*[fNMixedEvent] ;
584 for (Int_t i = 0; i < fNMixedEvent; i++) {
585 fVertex[i] = new Double_t[3] ;
586 fVertex[i][0] = 0.0 ;
587 fVertex[i][1] = 0.0 ;
588 fVertex[i][2] = 0.0 ;
589 }
590}
591
32fd29fe 592//__________________________________________________
593Int_t AliCaloTrackReader::GetEventCentrality() const {
594 //Return current event centrality
595
596 if(GetCentrality()){
597 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass);
598 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);
599 else if(fCentralityOpt==5) return GetCentrality()->GetCentralityClass5(fCentralityClass);
600 else {
601 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 5, 10 or 100\n",fCentralityOpt);
602 return 0;
603 }
604 }
605 else return 0;
606
607}
608
c8fe2783 609//____________________________________________________________________________
f8006433 610void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const {
611 //Return vertex position to be used for single event analysis
612 vertex[0]=fVertex[0][0];
613 vertex[1]=fVertex[0][1];
614 vertex[2]=fVertex[0][2];
615}
616
617//____________________________________________________________________________
618void AliCaloTrackReader::GetVertex(Double_t vertex[3], const Int_t evtIndex) const {
619 //Return vertex position for mixed event, recover the vertex in a particular event.
620
621 //Int_t evtIndex = 0; // for single events only one vertex stored in position 0, default value
622 //if (fMixedEvent && clusterID >=0) {
623 // evtIndex=GetMixedEvent()->EventIndexForCaloCluster(clusterID) ;
624 //}
625
626 vertex[0]=fVertex[evtIndex][0]; vertex[1]=fVertex[evtIndex][1]; vertex[2]=fVertex[evtIndex][2];
627
628}
629//
630
631
632//____________________________________________________________________________
633void AliCaloTrackReader::FillVertexArray() {
634
635 //Fill data member with vertex
636 //In case of Mixed event, multiple vertices
637
638 //Delete previous vertex
639 if(fVertex){
640 for (Int_t i = 0; i < fNMixedEvent; i++) {
641 delete [] fVertex[i] ;
642 }
643 delete [] fVertex ;
644 }
645
646 fVertex = new Double_t*[fNMixedEvent] ;
647 for (Int_t i = 0; i < fNMixedEvent; i++) {
648 fVertex[i] = new Double_t[3] ;
649 fVertex[i][0] = 0.0 ;
650 fVertex[i][1] = 0.0 ;
651 fVertex[i][2] = 0.0 ;
652 }
653
654 if (!fMixedEvent) { //Single event analysis
79395d30 655 if(fDataType!=kMC){
656
657 if(fInputEvent->GetPrimaryVertex()){
658 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
659 }
660 else {
661 printf("AliCaloTrackReader::FillVertexArray() - NULL primary vertex\n");
662 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
663 }//Primary vertex pointer do not exist
664
665 } else {//MC read event
edffc439 666 fVertex[0][0]=0.; fVertex[0][1]=0.; fVertex[0][2]=0.;
667 }
668
f8006433 669 if(fDebug > 1)
670 printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
671
672 } else { // MultiEvent analysis
673 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
8e7bdfa9 674 if (fMixedEvent->GetVertexOfEvent(iev))
675 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
676 else { // no vertex found !!!!
677 AliWarning("No vertex found");
678 }
679
f8006433 680 if(fDebug > 1)
681 printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
682
683 }
c8fe2783 684 }
f8006433 685
c8fe2783 686}
687
f37fa8d2 688//____________________________________________________________________________
c8fe2783 689void AliCaloTrackReader::FillInputCTS() {
f37fa8d2 690 //Return array with Central Tracking System (CTS) tracks
691
692 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
693
c8fe2783 694 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
c8fe2783 695 Double_t p[3];
3a58eee6 696 fTrackMult = 0;
697 Int_t nstatus = 0;
c8fe2783 698 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
699 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
3a58eee6 700
701 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
c8fe2783 702 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
703 continue ;
704
3a58eee6 705 nstatus++;
706
707 if(fDataType==kESD && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;
708
3b13c34c 709 // Track filter selection
710 //if (fTrackFilter) {
711 // selectInfo = fTrackFilter->IsSelected(esdTrack);
712 // if (!selectInfo && !(esd->GetPrimaryVertex())->UsesTrack(esdTrack->GetID())) continue;
713 // }
714
3a58eee6 715 //Count the tracks in eta < 0.9
716 //printf("Eta %f cut %f\n",TMath::Abs(track->Eta()),fTrackMultEtaCut);
717 if(TMath::Abs(track->Eta())< fTrackMultEtaCut) fTrackMult++;
718
c8fe2783 719 track->GetPxPyPz(p) ;
720 TLorentzVector momentum(p[0],p[1],p[2],0);
721
722 if(fCTSPtMin < momentum.Pt()){
723
724 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
725 continue;
726
727 if(fDebug > 2 && momentum.Pt() > 0.1)
f37fa8d2 728 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 729 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
730
731 if (fMixedEvent) {
732 track->SetID(itrack);
733 }
f37fa8d2 734
be518ab0 735 fCTSTracks->Add(track);
f37fa8d2 736
c8fe2783 737 }//Pt and Fiducial cut passed.
738 }// track loop
739
be518ab0 740 //fCTSTracksNormalInputEntries = fCTSTracks->GetEntriesFast();
3a58eee6 741 if(fDebug > 1)
be518ab0 742 printf("AliCaloTrackReader::FillInputCTS() - aod entries %d, input tracks %d, pass status %d, multipliticy %d\n", fCTSTracks->GetEntriesFast(), nTracks, nstatus, fTrackMult);//fCTSTracksNormalInputEntries);
c8fe2783 743
744 // //If second input event available, add the clusters.
745 // if(fSecondInputAODTree && fSecondInputAODEvent){
746 // nTracks = fSecondInputAODEvent->GetNumberOfTracks() ;
f37fa8d2 747 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - Add second input tracks, entries %d\n", nTracks) ;
c8fe2783 748 // for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
749 // AliAODTrack * track = ((AliAODEvent*)fSecondInputAODEvent)->GetTrack(itrack) ; // retrieve track from esd
750 //
751 // //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
752 // if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
753 //
754 // track->GetPxPyPz(p) ;
755 // TLorentzVector momentum(p[0],p[1],p[2],0);
756 //
757 // if(fCTSPtMin < momentum.Pt()){
758 //
759 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
760 //
f37fa8d2 761 // 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 762 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
763 //
be518ab0 764 // fCTSTracks->Add(track);
c8fe2783 765 //
766 // }//Pt and Fiducial cut passed.
767 // }// track loop
768 //
be518ab0 769 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - aod normal entries %d, after second input %d\n", fCTSTracksNormalInputEntries, fCTSTracks->GetEntriesFast());
c8fe2783 770 // } //second input loop
771 //
772}
773
c4eec29f 774//____________________________________________________________________________
775void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, const Int_t iclus) {
776 //Fill the EMCAL data in the array, do it
777
778 Int_t vindex = 0 ;
779 if (fMixedEvent)
780 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
781
782 //Check if the cluster contains any bad channel and if close to calorimeter borders
783 if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells()))
784 return;
785 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex))
786 return;
787
48c37e02 788 //Remove suspicious clusters
789 if(fRemoveSuspiciousClusters){
790 Int_t ncells = clus->GetNCells();
791 Float_t energy = clus->E();
792 Float_t minNCells = 1+energy/3;//-x*x*0.0033
793 if(ncells < minNCells) {
794 //if(energy > 2)printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Remove cluster: e %2.2f, Ncells %d, min Ncells %2.1f\n",energy,ncells,minNCells);
795 return;
796 }
797// else {
798// if(energy > 2)printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Keep cluster: e %2.2f, Ncells %d, min Ncells %2.1f\n",energy,ncells,minNCells);
799// }
800 }
801
cfaba834 802
c4eec29f 803 TLorentzVector momentum ;
804
805 clus->GetMomentum(momentum, fVertex[vindex]);
806
807 if(fEMCALPtMin < momentum.Pt()){
808
809 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL"))
810 return;
811
812 if(fDebug > 2 && momentum.E() > 0.1)
813 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
814 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
815
816 //Float_t pos[3];
817 //clus->GetPosition(pos);
818 //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
819
820 //Recalibrate the cluster energy
821 if(GetCaloUtils()->IsRecalibrationOn()) {
822 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
823 clus->SetE(energy);
824 //printf("Recalibrated Energy %f\n",clus->E());
825 GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
826 GetCaloUtils()->RecalculateClusterPID(clus);
827
828 }
829
830 //Recalculate distance to bad channels, if new list of bad channels provided
831 GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
832
833 //Recalculate cluster position
834 if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
835 GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus);
836 //clus->GetPosition(pos);
837 //printf("After Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
838 }
839
840 //Correct non linearity
841 if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
842 GetCaloUtils()->CorrectClusterEnergy(clus) ;
843 //printf("Linearity Corrected Energy %f\n",clus->E());
844 }
845
cfaba834 846 //In case of MC analysis, to match resolution/calibration in real data
847 if(fSmearClusterEnergy){
848 Float_t energy = clus->E();
c50cb1c5 849 Float_t rdmEnergy = fRandom.Gaus(energy,fSmearClusterParam[0]*TMath::Sqrt(energy)+
850 fSmearClusterParam[1]*energy+fSmearClusterParam[2]);
cfaba834 851 clus->SetE(rdmEnergy);
852 if(fDebug > 2) printf("\t Energy %f, smeared %f\n", energy, clus->E());
853 }
854
c4eec29f 855 if (fMixedEvent)
856 clus->SetID(iclus) ;
857
be518ab0 858 fEMCALClusters->Add(clus);
c4eec29f 859 }
860}
861
862//____________________________________________________________________________
c8fe2783 863void AliCaloTrackReader::FillInputEMCAL() {
f37fa8d2 864 //Return array with EMCAL clusters in aod format
c8fe2783 865
f37fa8d2 866 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
867
868 //Loop to select clusters in fiducial cut and fill container with aodClusters
c4eec29f 869 if(fEMCALClustersListName==""){
870 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
871 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
872 AliVCluster * clus = 0;
873 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
874 if (IsEMCALCluster(clus)){
875 FillInputEMCALAlgorithm(clus, iclus);
876 }//EMCAL cluster
877 }// cluster exists
878 }// cluster loop
385b7abf 879
880 //Recalculate track matching
881 if(fDataType==kESD)GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);
882
c4eec29f 883 }//Get the clusters from the input event
884 else {
885 TClonesArray * clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
886 if(!clusterList){
887 printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
888 return;
889 }
890 Int_t nclusters = clusterList->GetEntriesFast();
891 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
892 AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
893 //printf("E %f\n",clus->E());
e615d952 894 if (clus) FillInputEMCALAlgorithm(clus, iclus);
895 else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
385b7abf 896
c4eec29f 897 }// cluster loop
385b7abf 898
899 //Recalculate track matching, not necessary, already done in the reclusterization task
900 //GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent,clusterList);
901
c4eec29f 902 }
385b7abf 903
be518ab0 904 //fEMCALClustersNormalInputEntries = fEMCALClusters->GetEntriesFast();
905 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fEMCALClusters->GetEntriesFast());//fEMCALClustersNormalInputEntries);
c8fe2783 906
907 //If second input event available, add the clusters.
908 // if(fSecondInputAODTree && fSecondInputAODEvent){
909 // GetSecondInputAODVertex(v);
910 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
f37fa8d2 911 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - Add second input clusters, entries %d\n", nclusters) ;
c8fe2783 912 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
913 // AliAODCaloCluster * clus = 0;
914 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
915 // if (clus->IsEMCAL()){
916 // TLorentzVector momentum ;
917 // clus->GetMomentum(momentum, v);
918 //
919 // if(fEMCALPtMin < momentum.Pt()){
920 //
921 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) continue;
922 //
f37fa8d2 923 // 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 924 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
be518ab0 925 // fEMCALClusters->Add(clus);
c8fe2783 926 // }//Pt and Fiducial cut passed.
927 // }//EMCAL cluster
928 // }// cluster exists
929 // }// cluster loop
930 //
be518ab0 931 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod normal entries %d, after second input %d\n", fEMCALClustersNormalInputEntries, fEMCALClusters->GetEntriesFast());
c8fe2783 932 //
933 // } //second input loop
934}
935
936 //____________________________________________________________________________
937void AliCaloTrackReader::FillInputPHOS() {
f37fa8d2 938 //Return array with PHOS clusters in aod format
c8fe2783 939
f37fa8d2 940 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
941
942 //Loop to select clusters in fiducial cut and fill container with aodClusters
c8fe2783 943 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
944 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
945 AliVCluster * clus = 0;
946 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
f37fa8d2 947 if (IsPHOSCluster(clus)){
948 //Check if the cluster contains any bad channel and if close to calorimeter borders
c8fe2783 949 Int_t vindex = 0 ;
950 if (fMixedEvent)
951 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
952 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
953 continue;
954 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
955 continue;
956
957 TLorentzVector momentum ;
958
959 clus->GetMomentum(momentum, fVertex[vindex]);
960
961 if(fPHOSPtMin < momentum.Pt()){
962
963 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS"))
964 continue;
965
966 if(fDebug > 2 && momentum.E() > 0.1)
f37fa8d2 967 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 968 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
969
970 //Recalibrate the cluster energy
971 if(GetCaloUtils()->IsRecalibrationOn()) {
972 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
973 clus->SetE(energy);
974 }
975
976 if (fMixedEvent) {
977 clus->SetID(iclus) ;
978 }
979
be518ab0 980 fPHOSClusters->Add(clus);
f37fa8d2 981
c8fe2783 982 }//Pt and Fiducial cut passed.
983 }//PHOS cluster
984 }//cluster exists
985 }//esd cluster loop
986
be518ab0 987 //fPHOSClustersNormalInputEntries = fPHOSClusters->GetEntriesFast() ;
988 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fPHOSClusters->GetEntriesFast());//fPHOSClustersNormalInputEntries);
c8fe2783 989
990 //If second input event available, add the clusters.
991 // if(fSecondInputAODTree && fSecondInputAODEvent){
992 // GetSecondInputAODVertex(v);
993 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
f37fa8d2 994 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - Add second input clusters, entries %d\n", nclusters);
c8fe2783 995 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
996 // AliAODCaloCluster * clus = 0;
997 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
998 // if (clus->IsPHOS()){
999 // TLorentzVector momentum ;
1000 // clus->GetMomentum(momentum, v);
1001 //
1002 // if(fPHOSPtMin < momentum.Pt()){
1003 //
1004 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
1005 //
f37fa8d2 1006 // 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 1007 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
be518ab0 1008 // fPHOSClusters->Add(clus);
c8fe2783 1009 // }//Pt and Fiducial cut passed.
1010 // }//PHOS cluster
1011 // }// cluster exists
1012 // }// cluster loop
be518ab0 1013 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod normal entries %d, after second input %d\n", fPHOSClustersNormalInputEntries, fPHOSClusters->GetEntriesFast());
c8fe2783 1014 // } //second input loop
1015
1016}
1017
f37fa8d2 1018//____________________________________________________________________________
c8fe2783 1019void AliCaloTrackReader::FillInputEMCALCells() {
1020 //Return array with EMCAL cells in aod format
1021
1022 fEMCALCells = fInputEvent->GetEMCALCells();
1023
1024}
1025
f37fa8d2 1026//____________________________________________________________________________
c8fe2783 1027void AliCaloTrackReader::FillInputPHOSCells() {
1028 //Return array with PHOS cells in aod format
1029
1030 fPHOSCells = fInputEvent->GetPHOSCells();
1031
1032}
1033
be518ab0 1034//____________________________________________________________________________
1035void AliCaloTrackReader::FillInputVZERO(){
1036 //Fill VZERO information in data member, add all the channels information.
1037 AliVVZERO* v0 = fInputEvent->GetVZEROData();
1038 //printf("Init V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1039
1040 if (v0)
1041 {
1042 AliESDVZERO* esdV0 = dynamic_cast<AliESDVZERO*> (v0);
1043 for (Int_t i = 0; i < 32; i++)
1044 {
1045 if(esdV0){//Only available in ESDs
1046 fV0ADC[0] += (Int_t)esdV0->GetAdcV0C(i);
1047 fV0ADC[1] += (Int_t)esdV0->GetAdcV0A(i);
1048 }
1049 fV0Mul[0] += (Int_t)v0->GetMultiplicityV0C(i);
1050 fV0Mul[1] += (Int_t)v0->GetMultiplicityV0A(i);
1051 }
1052 if(fDebug > 0)
1053 printf("V0: ADC (%d,%d), Multiplicity (%d,%d) \n",fV0ADC[0],fV0ADC[1],fV0Mul[0],fV0Mul[1]);
1054 }
1055 else
1056 {
713a258b 1057 if(fDebug > 0)
1058 printf("Cannot retrieve V0 ESD! Run w/ null V0 charges\n ");
be518ab0 1059 }
1060}
1061
798a9b04 1062
f37fa8d2 1063//____________________________________________________________________________
1064Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const {
1065 // Check if it is a cluster from EMCAL. For old AODs cluster type has
1066 // different number and need to patch here
1067
1068 if(fDataType==kAOD && fOldAOD)
1069 {
1070 if (cluster->GetType() == 2) return kTRUE;
1071 else return kFALSE;
1072 }
1073 else
1074 {
1075 return cluster->IsEMCAL();
1076 }
1077
1078}
1079
1080//____________________________________________________________________________
1081Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const {
1082 //Check if it is a cluster from PHOS.For old AODs cluster type has
1083 // different number and need to patch here
1084
1085 if(fDataType==kAOD && fOldAOD)
1086 {
1087 Int_t type = cluster->GetType();
1088 if (type == 0 || type == 1) return kTRUE;
1089 else return kFALSE;
1090 }
1091 else
1092 {
1093 return cluster->IsPHOS();
1094 }
1095
1096}
1097
48c37e02 1098//____________________________________________________________________________
1099Bool_t AliCaloTrackReader::CheckForPrimaryVertex(){
1100 //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
1101 //Only for ESDs ...
ad30b142 1102
48c37e02 1103 AliESDEvent * event = dynamic_cast<AliESDEvent*> (fInputEvent);
ad30b142 1104 if(!event) return kFALSE;
1105
1106 if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {
1107 return kTRUE;
1108 }
1109
1110 if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {
1111 // SPD vertex
1112 if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {
1113 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
48c37e02 1114 return kTRUE;
ad30b142 1115
48c37e02 1116 }
ad30b142 1117 if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {
1118 // cout<<"bad vertex type::"<< event->GetPrimaryVertex()->GetName() << endl;
1119 return kFALSE;
48c37e02 1120 }
48c37e02 1121 }
1122
ad30b142 1123 return kFALSE;
48c37e02 1124
1125}
1126
1127
1128