]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliCaloTrackReader.cxx
1) Do not fill aod file if not requested
[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"
1c5acb87 34
35//---- ANALYSIS system ----
36#include "AliCaloTrackReader.h"
477d6cee 37#include "AliMCEvent.h"
591cc579 38#include "AliAODMCHeader.h"
39#include "AliGenPythiaEventHeader.h"
c8fe2783 40#include "AliVEvent.h"
8dacfd76 41#include "AliAODEvent.h"
c8fe2783 42#include "AliVTrack.h"
43#include "AliVParticle.h"
44#include "AliMixedEvent.h"
1c5acb87 45
46ClassImp(AliCaloTrackReader)
47
48
49//____________________________________________________________________________
50 AliCaloTrackReader::AliCaloTrackReader() :
a79a2424 51 TObject(), fEventNumber(-1), fCurrentFileName(""),fDataType(0), fDebug(0),
decca433 52 fFiducialCut(0x0), fCheckFidCut(kFALSE), fComparePtHardAndJetPt(kFALSE), fPtHardAndJetPtFactor(7),
f37fa8d2 53 fCTSPtMin(0), fEMCALPtMin(0),fPHOSPtMin(0), fAODBranchList(new TList ),
591cc579 54 fAODCTS(new TObjArray()), fAODEMCAL(new TObjArray()), fAODPHOS(new TObjArray()),
1c5acb87 55 fEMCALCells(0x0), fPHOSCells(0x0),
477d6cee 56 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
1c5acb87 57 fFillCTS(0),fFillEMCAL(0),fFillPHOS(0),
591cc579 58 fFillEMCALCells(0),fFillPHOSCells(0),
1e68a3f4 59// fSecondInputAODTree(0x0), fSecondInputAODEvent(0x0),
60// fSecondInputFileName(""),fSecondInputFirstEvent(0),
61// fAODCTSNormalInputEntries(0), fAODEMCALNormalInputEntries(0),
62// fAODPHOSNormalInputEntries(0),
63 fTrackStatus(0),
afabc52f 64 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
1e68a3f4 65 fDeltaAODFileName("deltaAODPartCorr.root"),fFiredTriggerClassName(""),
c8fe2783 66 fAnaLED(kFALSE),fTaskName(""),fCaloUtils(0x0),
f37fa8d2 67 fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL),
68 fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE)
1c5acb87 69{
70 //Ctor
71
72 //Initialize parameters
73 InitParameters();
74}
78219bac 75/*
1c5acb87 76//____________________________________________________________________________
765d44e7 77AliCaloTrackReader::AliCaloTrackReader(const AliCaloTrackReader & reader) :
78 TObject(reader), fEventNumber(reader.fEventNumber), fCurrentFileName(reader.fCurrentFileName),
79 fDataType(reader.fDataType), fDebug(reader.fDebug),
80 fFiducialCut(reader.fFiducialCut),
81 fComparePtHardAndJetPt(reader.fComparePtHardAndJetPt),
82 fPtHardAndJetPtFactor(reader.fPtHardAndJetPtFactor),
83 fCTSPtMin(reader.fCTSPtMin), fEMCALPtMin(reader.fEMCALPtMin),fPHOSPtMin(reader.fPHOSPtMin),
f37fa8d2 84 fAODBranchList(new TList()),
765d44e7 85 fAODCTS(new TObjArray(*reader.fAODCTS)),
86 fAODEMCAL(new TObjArray(*reader.fAODEMCAL)),
87 fAODPHOS(new TObjArray(*reader.fAODPHOS)),
88 fEMCALCells(new TNamed(*reader.fEMCALCells)),
89 fPHOSCells(new TNamed(*reader.fPHOSCells)),
90 fInputEvent(reader.fInputEvent), fOutputEvent(reader.fOutputEvent), fMC(reader.fMC),
91 fFillCTS(reader.fFillCTS),fFillEMCAL(reader.fFillEMCAL),fFillPHOS(reader.fFillPHOS),
92 fFillEMCALCells(reader.fFillEMCALCells),fFillPHOSCells(reader.fFillPHOSCells),
93 fSecondInputAODTree(reader.fSecondInputAODTree),
94 fSecondInputAODEvent(reader.fSecondInputAODEvent),
95 fSecondInputFileName(reader.fSecondInputFileName),
96 fSecondInputFirstEvent(reader.fSecondInputFirstEvent),
97 fAODCTSNormalInputEntries(reader.fAODCTSNormalInputEntries),
98 fAODEMCALNormalInputEntries(reader.fAODEMCALNormalInputEntries),
99 fAODPHOSNormalInputEntries(reader.fAODPHOSNormalInputEntries),
100 fTrackStatus(reader.fTrackStatus),
101 fReadStack(reader.fReadStack), fReadAODMCParticles(reader.fReadAODMCParticles),
765d44e7 102 fFiredTriggerClassName(reader.fFiredTriggerClassName),
103 fAnaLED(reader.fAnaLED),
104 fTaskName(reader.fTaskName),
105 fCaloUtils(new AliCalorimeterUtils(*reader.fCaloUtils))
1c5acb87 106{
03190ad7 107 // cpy ctor
1c5acb87 108}
78219bac 109*/
1c5acb87 110//_________________________________________________________________________
03190ad7 111//AliCaloTrackReader & AliCaloTrackReader::operator = (const AliCaloTrackReader & source)
112//{
113// // assignment operator
114//
115// if(&source == this) return *this;
116//
117// fDataType = source.fDataType ;
118// fDebug = source.fDebug ;
119// fEventNumber = source.fEventNumber ;
120// fCurrentFileName = source.fCurrentFileName ;
121// fFiducialCut = source.fFiducialCut;
122//
123// fComparePtHardAndJetPt = source.fComparePtHardAndJetPt;
124// fPtHardAndJetPtFactor = source.fPtHardAndJetPtFactor;
125//
126// fCTSPtMin = source.fCTSPtMin ;
127// fEMCALPtMin = source.fEMCALPtMin ;
128// fPHOSPtMin = source.fPHOSPtMin ;
129//
130// fAODCTS = new TObjArray(*source.fAODCTS) ;
131// fAODEMCAL = new TObjArray(*source.fAODEMCAL) ;
132// fAODPHOS = new TObjArray(*source.fAODPHOS) ;
133// fEMCALCells = new TNamed(*source.fEMCALCells) ;
134// fPHOSCells = new TNamed(*source.fPHOSCells) ;
135//
136// fInputEvent = source.fInputEvent;
137// fOutputEvent = source.fOutputEvent;
138// fMC = source.fMC;
139//
140// fFillCTS = source.fFillCTS;
141// fFillEMCAL = source.fFillEMCAL;
142// fFillPHOS = source.fFillPHOS;
143// fFillEMCALCells = source.fFillEMCALCells;
144// fFillPHOSCells = source.fFillPHOSCells;
145//
146// fSecondInputAODTree = source.fSecondInputAODTree;
147// fSecondInputAODEvent = source.fSecondInputAODEvent;
148// fSecondInputFileName = source.fSecondInputFileName;
149// fSecondInputFirstEvent = source.fSecondInputFirstEvent;
150//
151// fAODCTSNormalInputEntries = source.fAODCTSNormalInputEntries;
152// fAODEMCALNormalInputEntries = source.fAODEMCALNormalInputEntries;
153// fAODPHOSNormalInputEntries = source.fAODPHOSNormalInputEntries;
154//
155// fTrackStatus = source.fTrackStatus;
156// fReadStack = source.fReadStack;
157// fReadAODMCParticles = source.fReadAODMCParticles;
158//
03190ad7 159// fDeltaAODFileName = source.fDeltaAODFileName;
160//
161// fFiredTriggerClassName = source.fFiredTriggerClassName ;
162//
03190ad7 163// return *this;
164//
165//}
1c5acb87 166
167//_________________________________
168AliCaloTrackReader::~AliCaloTrackReader() {
169 //Dtor
170
ff45398a 171 if(fFiducialCut) delete fFiducialCut ;
29b2ceec 172
f37fa8d2 173 if(fAODBranchList){
174 fAODBranchList->Delete();
175 delete fAODBranchList ;
176 }
177
1c5acb87 178 if(fAODCTS){
179 fAODCTS->Clear() ;
180 delete fAODCTS ;
181 }
182
183 if(fAODEMCAL){
184 fAODEMCAL->Clear() ;
185 delete fAODEMCAL ;
186 }
187
188 if(fAODPHOS){
189 fAODPHOS->Clear() ;
190 delete fAODPHOS ;
191 }
192
193 if(fEMCALCells){
194 fEMCALCells->Clear() ;
195 delete fEMCALCells ;
196 }
197
198 if(fPHOSCells){
199 fPHOSCells->Clear() ;
200 delete fPHOSCells ;
201 }
c8fe2783 202 if (fMixedEvent) {
203 for (Int_t i = 0; i < fNMixedEvent; i++) {
204 delete [] fVertex[i] ;
205 }
206 }
207 delete [] fVertex ;
591cc579 208
7787a778 209// Pointers not owned, done by the analysis frame
210// if(fInputEvent) delete fInputEvent ;
211// if(fOutputEvent) delete fOutputEvent ;
212// if(fMC) delete fMC ;
591cc579 213
7787a778 214// if(fSecondInputAODTree){
215// fSecondInputAODTree->Clear();
216// delete fSecondInputAODTree;
217// }
218//
219// if(fSecondInputAODEvent) delete fSecondInputAODEvent ;
c1ac3823 220
7787a778 221 // Pointer not owned, deleted by maker
222 //if (fCaloUtils) delete fCaloUtils ;
c1ac3823 223
224}
477d6cee 225
591cc579 226//_________________________________________________________________________
227Bool_t AliCaloTrackReader::ComparePtHardAndJetPt(){
228 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
229 // Only for PYTHIA.
230 if(!fReadStack) return kTRUE; //Information not filtered to AOD
231
232 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader")){
233 TParticle * jet = new TParticle;
234 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
235 Int_t nTriggerJets = pygeh->NTriggerJets();
236 Float_t ptHard = pygeh->GetPtHard();
237
238 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
239 Float_t tmpjet[]={0,0,0,0};
240 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
241 pygeh->TriggerJet(ijet, tmpjet);
242 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
243 //Compare jet pT and pt Hard
244 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
245 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard) {
246 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
247 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
248 return kFALSE;
249 }
250 }
251 }
252
253 return kTRUE ;
254
255}
256
1c5acb87 257//____________________________________________________________________________
258AliStack* AliCaloTrackReader::GetStack() const {
259 //Return pointer to stack
260 if(fMC)
261 return fMC->Stack();
262 else{
477d6cee 263 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
1c5acb87 264 return 0x0 ;
265 }
266}
267
268//____________________________________________________________________________
269AliHeader* AliCaloTrackReader::GetHeader() const {
270 //Return pointer to header
271 if(fMC)
272 return fMC->Header();
273 else{
477d6cee 274 printf("AliCaloTrackReader::Header is not available\n");
1c5acb87 275 return 0x0 ;
276 }
277}
278//____________________________________________________________________________
279AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const {
280 //Return pointer to Generated event header
281 if(fMC)
282 return fMC->GenEventHeader();
283 else{
477d6cee 284 printf("AliCaloTrackReader::GenEventHeader is not available\n");
1c5acb87 285 return 0x0 ;
286 }
287}
288
591cc579 289//____________________________________________________________________________
290TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const {
1e68a3f4 291 //Return list of particles in AOD. Do it for the corresponding input event.
292
c8fe2783 293 TClonesArray * rv = NULL ;
1e68a3f4 294 if(fDataType == kAOD){
295
c8fe2783 296 if(input == 0){
1e68a3f4 297 //Normal input AOD
298 AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
299 if(evt)
300 rv = (TClonesArray*)evt->FindListObject("mcparticles");
301 else
302 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
303
304 } //else if(input == 1 && fSecondInputAODEvent){ //Second input AOD
305// rv = (TClonesArray*) fSecondInputAODEvent->FindListObject("mcparticles");
306// }
307
c8fe2783 308 } else {
1e68a3f4 309 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
c8fe2783 310 }
1e68a3f4 311
c8fe2783 312 return rv ;
591cc579 313}
314
315//____________________________________________________________________________
316AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const {
317 //Return MC header in AOD. Do it for the corresponding input event.
1e68a3f4 318 AliAODMCHeader *mch = NULL;
591cc579 319 if(fDataType == kAOD){
320 //Normal input AOD
1e68a3f4 321 if(input == 0) {
322 mch = (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
323 }
324// //Second input AOD
325// else if(input == 1){
326// mch = (AliAODMCHeader*) fSecondInputAODEvent->FindListObject("mcheader");
327// }
591cc579 328 else {
329 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
591cc579 330 }
331 }
332 else {
333 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
591cc579 334 }
1e68a3f4 335
336 return mch;
591cc579 337}
338
339//_______________________________________________________________
340void AliCaloTrackReader::Init()
341{
342 //Init reader. Method to be called in AliAnaPartCorrMaker
343
344 //Get the file with second input events if the filename is given
345 //Get the tree and connect the AODEvent. Only with AODs
f1f0bd84 346
591cc579 347 if(fReadStack && fReadAODMCParticles){
348 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
349 fReadStack = kFALSE;
350 fReadAODMCParticles = kFALSE;
351 }
352
1e68a3f4 353// if(fSecondInputFileName!=""){
354// if(fDataType == kAOD){
355// TFile * input2 = new TFile(fSecondInputFileName,"read");
356// printf("AliCaloTrackReader::Init() - Second input file opened: %s, size %d \n", input2->GetName(), (Int_t) input2->GetSize());
357// fSecondInputAODTree = (TTree*) input2->Get("aodTree");
358// if(fSecondInputAODTree) printf("AliCaloTrackReader::Init() - Second input tree opened: %s, entries %d \n",
359// fSecondInputAODTree->GetName(), (Int_t) fSecondInputAODTree->GetEntries());
360// else{
361// printf("AliCaloTrackReader::Init() - Second input tree not available, STOP \n");
362// abort();
363// }
364// fSecondInputAODEvent = new AliAODEvent;
365// fSecondInputAODEvent->ReadFromTree(fSecondInputAODTree);
366// if(fSecondInputFirstEvent >= fSecondInputAODTree->GetEntriesFast()){
367// printf("AliCaloTrackReader::Init() - Requested first event of second input %d, is larger than number of events %d, STOP\n",
368// fSecondInputFirstEvent, (Int_t) fSecondInputAODTree->GetEntriesFast());
369// abort();
370// }
371// }
372// else printf("AliCaloTrackReader::Init() - Second input not added, reader is not AOD\n");
373// }
591cc579 374}
765d44e7 375
1c5acb87 376//_______________________________________________________________
377void AliCaloTrackReader::InitParameters()
378{
1c5acb87 379 //Initialize the parameters of the analysis.
591cc579 380 fDataType = kESD ;
1c5acb87 381 fCTSPtMin = 0.2 ;
29b2ceec 382 fEMCALPtMin = 0.2 ;
383 fPHOSPtMin = 0.2 ;
1c5acb87 384
902aa95c 385 //Do not filter the detectors input by default.
386 fFillEMCAL = kFALSE;
387 fFillPHOS = kFALSE;
388 fFillCTS = kFALSE;
1c5acb87 389 fFillEMCALCells = kFALSE;
591cc579 390 fFillPHOSCells = kFALSE;
1c5acb87 391
1e68a3f4 392 //fSecondInputFileName = "" ;
393 //fSecondInputFirstEvent = 0 ;
591cc579 394 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
395 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
42dc8e7d 396 fDeltaAODFileName = "deltaAODPartCorr.root";
72d2488e 397 fFiredTriggerClassName = "";
765d44e7 398
c1ac3823 399 fAnaLED = kFALSE;
4e2b43d8 400}
1c5acb87 401
402//________________________________________________________________
403void AliCaloTrackReader::Print(const Option_t * opt) const
404{
405
406 //Print some relevant parameters set for the analysis
407 if(! opt)
408 return;
409
410 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
486258c9 411 printf("Task name : %s\n", fTaskName.Data()) ;
1c5acb87 412 printf("Data type : %d\n", fDataType) ;
413 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
414 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
415 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
416 printf("Use CTS = %d\n", fFillCTS) ;
417 printf("Use EMCAL = %d\n", fFillEMCAL) ;
418 printf("Use PHOS = %d\n", fFillPHOS) ;
419 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
420 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
591cc579 421 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
f37fa8d2 422 printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
1e68a3f4 423
591cc579 424 if(fComparePtHardAndJetPt)
425 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
426
1e68a3f4 427// if(fSecondInputFileName!="") {
428// printf("Second Input File Name = %s\n", fSecondInputFileName.Data()) ;
429// printf("Second Input First Event = %d\n", fSecondInputFirstEvent) ;
430// }
591cc579 431
42dc8e7d 432 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
42dc8e7d 433 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
1c5acb87 434 printf(" \n") ;
435}
436
437//___________________________________________________
29b2ceec 438Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * currentFileName) {
6639984f 439 //Fill the event counter and input lists that are needed, called by the analysis maker.
902aa95c 440
6639984f 441 fEventNumber = iEntry;
a79a2424 442 fCurrentFileName = TString(currentFileName);
be1f5fa4 443 if(!fInputEvent) {
f7c2338a 444 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
be1f5fa4 445 return kFALSE;
446 }
72d2488e 447 //Select events only fired by a certain trigger configuration if it is provided
be1f5fa4 448 Int_t eventType = 0;
449 if(fInputEvent->GetHeader())
450 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
c1ac3823 451 if( fFiredTriggerClassName !="" && !fAnaLED){
c8fe2783 452 if(eventType!=7)
453 return kFALSE; //Only physics event, do not use for simulated events!!!
7ec23b5a 454 if(fDebug > 0)
455 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
456 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
457 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
72d2488e 458 }
c1ac3823 459 else if(fAnaLED){
460// kStartOfRun = 1, // START_OF_RUN
461// kEndOfRun = 2, // END_OF_RUN
462// kStartOfRunFiles = 3, // START_OF_RUN_FILES
463// kEndOfRunFiles = 4, // END_OF_RUN_FILES
464// kStartOfBurst = 5, // START_OF_BURST
465// kEndOfBurst = 6, // END_OF_BURST
466// kPhysicsEvent = 7, // PHYSICS_EVENT
467// kCalibrationEvent = 8, // CALIBRATION_EVENT
468// kFormatError = 9, // EVENT_FORMAT_ERROR
469// kStartOfData = 10, // START_OF_DATA
470// kEndOfData = 11, // END_OF_DATA
471// kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
472// kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
473
474 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
475 if(eventType!=8)return kFALSE;
476 }
477
29b2ceec 478 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
479 if(fComparePtHardAndJetPt && GetStack()) {
7ec23b5a 480 if(!ComparePtHardAndJetPt()) return kFALSE ;
29b2ceec 481 }
591cc579 482
483 //In case of mixing events with other AOD file
1e68a3f4 484 // if(fDataType == kAOD && fSecondInputAODTree){
485//
486// if(fDebug > 1)
487// printf("AliCaloTrackReader::FillInputEvent() - Get event %d from second input AOD file \n", iEntry+fSecondInputFirstEvent);
488// if(fSecondInputAODTree->GetEntriesFast() <= iEntry+fSecondInputFirstEvent) {
489// if(fSecondInputAODTree->GetEntriesFast() == iEntry+fSecondInputFirstEvent)
490// printf("AliCaloTrackReader::FillInputEvent() - Skip events from event %d, no more events in second AOD file \n", iEntry);
491// return kFALSE;
492// }
493//
494// //Get the Event
495// Int_t nbytes = fSecondInputAODTree->GetEvent(iEntry+fSecondInputFirstEvent);
496// if ( nbytes == 0 ) {//If nothing in AOD
497// printf("AliCaloTrackReader::FillInputEvent() - Nothing in Second AOD input, STOP\n");
498// abort() ;
499// }
500//
501// }
09e819c9 502
c8fe2783 503
504 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
505 if (!fMixedEvent) {
506 GetVertex() ;
507 }
508 else
509 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
510 }
511
512 if(fFillEMCALCells)
513 FillInputEMCALCells();
514 if(fFillPHOSCells)
515 FillInputPHOSCells();
09e819c9 516
c8fe2783 517 if(fFillCTS)
518 FillInputCTS();
519 if(fFillEMCAL)
520 FillInputEMCAL();
521 if(fFillPHOS)
522 FillInputPHOS();
09e819c9 523
7ec23b5a 524
29b2ceec 525 return kTRUE ;
1c5acb87 526}
527
528//__________________________________________________
529void AliCaloTrackReader::ResetLists() {
530 // Reset lists, called by the analysis maker
531
477d6cee 532 if(fAODCTS) fAODCTS -> Clear();
1c5acb87 533 if(fAODEMCAL) fAODEMCAL -> Clear();
477d6cee 534 if(fAODPHOS) fAODPHOS -> Clear();
1c5acb87 535 if(fEMCALCells) fEMCALCells -> Clear();
477d6cee 536 if(fPHOSCells) fPHOSCells -> Clear();
7ec23b5a 537
1c5acb87 538}
c8fe2783 539
540//____________________________________________________________________________
541void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
542{
543 fInputEvent = input;
544 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
545 if (fMixedEvent) {
546 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
547 }
548 fVertex = new Double_t*[fNMixedEvent] ;
549 for (Int_t i = 0; i < fNMixedEvent; i++) {
550 fVertex[i] = new Double_t[3] ;
551 fVertex[i][0] = 0.0 ;
552 fVertex[i][1] = 0.0 ;
553 fVertex[i][2] = 0.0 ;
554 }
555}
556
557//____________________________________________________________________________
558Double_t * AliCaloTrackReader::GetVertex() {
559 //Return vertex position
560 if (fMixedEvent)
561 return NULL ;
562 if(fInputEvent->GetPrimaryVertex())
563 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
564 else {
565 printf("AliCaloTrackReader::GetVertex() - No vertex available, InputEvent()->GetPrimaryVertex() = 0, return (0,0,0)\n");
566 fVertex[0][0]=0.0; fVertex[0][1]=0.0; fVertex[0][2]=0.0;
567 }
568 return fVertex[0] ;
569}
570
f37fa8d2 571//____________________________________________________________________________
c8fe2783 572void AliCaloTrackReader::FillInputCTS() {
f37fa8d2 573 //Return array with Central Tracking System (CTS) tracks
574
575 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputCTS()\n");
576
c8fe2783 577 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
c8fe2783 578 Double_t p[3];
579 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
580 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
581
582 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
583 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
584 continue ;
585
586 track->GetPxPyPz(p) ;
587 TLorentzVector momentum(p[0],p[1],p[2],0);
588
589 if(fCTSPtMin < momentum.Pt()){
590
591 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
592 continue;
593
594 if(fDebug > 2 && momentum.Pt() > 0.1)
f37fa8d2 595 printf("AliCaloTrackReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 596 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
597
598 if (fMixedEvent) {
599 track->SetID(itrack);
600 }
f37fa8d2 601
602 fAODCTS->Add(track);
603
c8fe2783 604 }//Pt and Fiducial cut passed.
605 }// track loop
606
1e68a3f4 607 //fAODCTSNormalInputEntries = fAODCTS->GetEntriesFast();
f37fa8d2 608 if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - aod entries %d\n", fAODCTS->GetEntriesFast());//fAODCTSNormalInputEntries);
c8fe2783 609
610 // //If second input event available, add the clusters.
611 // if(fSecondInputAODTree && fSecondInputAODEvent){
612 // nTracks = fSecondInputAODEvent->GetNumberOfTracks() ;
f37fa8d2 613 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - Add second input tracks, entries %d\n", nTracks) ;
c8fe2783 614 // for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
615 // AliAODTrack * track = ((AliAODEvent*)fSecondInputAODEvent)->GetTrack(itrack) ; // retrieve track from esd
616 //
617 // //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
618 // if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
619 //
620 // track->GetPxPyPz(p) ;
621 // TLorentzVector momentum(p[0],p[1],p[2],0);
622 //
623 // if(fCTSPtMin < momentum.Pt()){
624 //
625 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
626 //
f37fa8d2 627 // 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 628 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
629 //
f37fa8d2 630 // fAODCTS->Add(track);
c8fe2783 631 //
632 // }//Pt and Fiducial cut passed.
633 // }// track loop
634 //
f37fa8d2 635 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputCTS() - aod normal entries %d, after second input %d\n", fAODCTSNormalInputEntries, fAODCTS->GetEntriesFast());
c8fe2783 636 // } //second input loop
637 //
638}
639
640 //____________________________________________________________________________
641void AliCaloTrackReader::FillInputEMCAL() {
f37fa8d2 642 //Return array with EMCAL clusters in aod format
c8fe2783 643
f37fa8d2 644 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
645
646 //Loop to select clusters in fiducial cut and fill container with aodClusters
c8fe2783 647 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
648 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
649 AliVCluster * clus = 0;
650 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
f37fa8d2 651 if (IsEMCALCluster(clus)){
c8fe2783 652
1e68a3f4 653 //Check if the cluster contains any bad channel and if close to calorimeter borders
c8fe2783 654 Int_t vindex = 0 ;
655 if (fMixedEvent)
656 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
657
658 if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells()))
659 continue;
660 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex))
661 continue;
662
663 TLorentzVector momentum ;
664
665 clus->GetMomentum(momentum, fVertex[vindex]);
666
667 if(fEMCALPtMin < momentum.Pt()){
668
669 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL"))
670 continue;
671
672 if(fDebug > 2 && momentum.E() > 0.1)
f37fa8d2 673 printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 674 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
675
1e68a3f4 676 //Recalibrate the cluster energy
c8fe2783 677 if(GetCaloUtils()->IsRecalibrationOn()) {
678 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetEMCALCells());
679 clus->SetE(energy);
680 }
681
682 if (fMixedEvent) {
683 clus->SetID(iclus) ;
684 }
f37fa8d2 685
686 fAODEMCAL->Add(clus);
687
c8fe2783 688 }//Pt and Fiducial cut passed.
689 }//EMCAL cluster
690 }// cluster exists
691 }// cluster loop
1e68a3f4 692 //fAODEMCALNormalInputEntries = fAODEMCAL->GetEntriesFast();
f37fa8d2 693 if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod entries %d\n", fAODEMCAL->GetEntriesFast());//fAODEMCALNormalInputEntries);
c8fe2783 694
695 //If second input event available, add the clusters.
696 // if(fSecondInputAODTree && fSecondInputAODEvent){
697 // GetSecondInputAODVertex(v);
698 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
f37fa8d2 699 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - Add second input clusters, entries %d\n", nclusters) ;
c8fe2783 700 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
701 // AliAODCaloCluster * clus = 0;
702 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
703 // if (clus->IsEMCAL()){
704 // TLorentzVector momentum ;
705 // clus->GetMomentum(momentum, v);
706 //
707 // if(fEMCALPtMin < momentum.Pt()){
708 //
709 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) continue;
710 //
f37fa8d2 711 // 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 712 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
f37fa8d2 713 // fAODEMCAL->Add(clus);
c8fe2783 714 // }//Pt and Fiducial cut passed.
715 // }//EMCAL cluster
716 // }// cluster exists
717 // }// cluster loop
718 //
f37fa8d2 719 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputEMCAL() - aod normal entries %d, after second input %d\n", fAODEMCALNormalInputEntries, fAODEMCAL->GetEntriesFast());
c8fe2783 720 //
721 // } //second input loop
722}
723
724 //____________________________________________________________________________
725void AliCaloTrackReader::FillInputPHOS() {
f37fa8d2 726 //Return array with PHOS clusters in aod format
c8fe2783 727
f37fa8d2 728 if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputPHOS()\n");
729
730 //Loop to select clusters in fiducial cut and fill container with aodClusters
c8fe2783 731 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
732 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
733 AliVCluster * clus = 0;
734 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
f37fa8d2 735 if (IsPHOSCluster(clus)){
736 //Check if the cluster contains any bad channel and if close to calorimeter borders
c8fe2783 737 Int_t vindex = 0 ;
738 if (fMixedEvent)
739 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
740 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
741 continue;
742 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
743 continue;
744
745 TLorentzVector momentum ;
746
747 clus->GetMomentum(momentum, fVertex[vindex]);
748
749 if(fPHOSPtMin < momentum.Pt()){
750
751 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS"))
752 continue;
753
754 if(fDebug > 2 && momentum.E() > 0.1)
f37fa8d2 755 printf("AliCaloTrackReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
c8fe2783 756 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
757
758 //Recalibrate the cluster energy
759 if(GetCaloUtils()->IsRecalibrationOn()) {
760 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
761 clus->SetE(energy);
762 }
763
764 if (fMixedEvent) {
765 clus->SetID(iclus) ;
766 }
767
f37fa8d2 768 fAODPHOS->Add(clus);
769
c8fe2783 770 }//Pt and Fiducial cut passed.
771 }//PHOS cluster
772 }//cluster exists
773 }//esd cluster loop
774
1e68a3f4 775 //fAODPHOSNormalInputEntries = fAODPHOS->GetEntriesFast() ;
f37fa8d2 776 if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod entries %d\n", fAODPHOS->GetEntriesFast());//fAODPHOSNormalInputEntries);
c8fe2783 777
778 //If second input event available, add the clusters.
779 // if(fSecondInputAODTree && fSecondInputAODEvent){
780 // GetSecondInputAODVertex(v);
781 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
f37fa8d2 782 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - Add second input clusters, entries %d\n", nclusters);
c8fe2783 783 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
784 // AliAODCaloCluster * clus = 0;
785 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
786 // if (clus->IsPHOS()){
787 // TLorentzVector momentum ;
788 // clus->GetMomentum(momentum, v);
789 //
790 // if(fPHOSPtMin < momentum.Pt()){
791 //
792 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
793 //
f37fa8d2 794 // 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 795 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
f37fa8d2 796 // fAODPHOS->Add(clus);
c8fe2783 797 // }//Pt and Fiducial cut passed.
798 // }//PHOS cluster
799 // }// cluster exists
800 // }// cluster loop
f37fa8d2 801 // if(fDebug > 1) printf("AliCaloTrackReader::FillInputPHOS() - aod normal entries %d, after second input %d\n", fAODPHOSNormalInputEntries, fAODPHOS->GetEntriesFast());
c8fe2783 802 // } //second input loop
803
804}
805
f37fa8d2 806//____________________________________________________________________________
c8fe2783 807void AliCaloTrackReader::FillInputEMCALCells() {
808 //Return array with EMCAL cells in aod format
809
810 fEMCALCells = fInputEvent->GetEMCALCells();
811
812}
813
f37fa8d2 814//____________________________________________________________________________
c8fe2783 815void AliCaloTrackReader::FillInputPHOSCells() {
816 //Return array with PHOS cells in aod format
817
818 fPHOSCells = fInputEvent->GetPHOSCells();
819
820}
821
f37fa8d2 822//____________________________________________________________________________
823Bool_t AliCaloTrackReader::IsEMCALCluster(AliVCluster* cluster) const {
824 // Check if it is a cluster from EMCAL. For old AODs cluster type has
825 // different number and need to patch here
826
827 if(fDataType==kAOD && fOldAOD)
828 {
829 if (cluster->GetType() == 2) return kTRUE;
830 else return kFALSE;
831 }
832 else
833 {
834 return cluster->IsEMCAL();
835 }
836
837}
838
839//____________________________________________________________________________
840Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const {
841 //Check if it is a cluster from PHOS.For old AODs cluster type has
842 // different number and need to patch here
843
844 if(fDataType==kAOD && fOldAOD)
845 {
846 Int_t type = cluster->GetType();
847 if (type == 0 || type == 1) return kTRUE;
848 else return kFALSE;
849 }
850 else
851 {
852 return cluster->IsPHOS();
853 }
854
855}
856
857
858