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