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