1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 //_________________________________________________________________________
18 // Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and
19 // Central Barrel Tracking detectors (CTS).
20 // Not all MC particles/tracks/clusters are kept, some kinematical/fiducial restrictions are done.
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)
23 // : AliCaloTrackAODReader: Fills AOD data in 3 TObjArrays (PHOS, EMCAL, CTS)
25 //-- Author: Gustavo Conesa (LNF-INFN)
26 //////////////////////////////////////////////////////////////////////////////
29 // --- ROOT system ---
32 //---- ANALYSIS system ----
33 #include "AliCaloTrackReader.h"
34 #include "AliMCEvent.h"
35 #include "AliAODMCHeader.h"
36 #include "AliGenPythiaEventHeader.h"
37 #include "AliVEvent.h"
38 #include "AliAODEvent.h"
39 #include "AliVTrack.h"
40 #include "AliVParticle.h"
41 #include "AliMixedEvent.h"
43 ClassImp(AliCaloTrackReader)
46 //____________________________________________________________________________
47 AliCaloTrackReader::AliCaloTrackReader() :
48 TObject(), fEventNumber(-1), fCurrentFileName(""),fDataType(0), fDebug(0),
49 fFiducialCut(0x0), fCheckFidCut(kFALSE), fComparePtHardAndJetPt(kFALSE), fPtHardAndJetPtFactor(7),
50 fCTSPtMin(0), fEMCALPtMin(0),fPHOSPtMin(0),
51 fAODCTS(new TObjArray()), fAODEMCAL(new TObjArray()), fAODPHOS(new TObjArray()),
52 fEMCALCells(0x0), fPHOSCells(0x0),
53 fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
54 fFillCTS(0),fFillEMCAL(0),fFillPHOS(0),
55 fFillEMCALCells(0),fFillPHOSCells(0),
56 fSecondInputAODTree(0x0), fSecondInputAODEvent(0x0),
57 fSecondInputFileName(""),fSecondInputFirstEvent(0),
58 fAODCTSNormalInputEntries(0), fAODEMCALNormalInputEntries(0),
59 fAODPHOSNormalInputEntries(0), fTrackStatus(0),
60 fReadStack(kFALSE), fReadAODMCParticles(kFALSE),
61 fCleanOutputStdAOD(kFALSE), fDeltaAODFileName("deltaAODPartCorr.root"),fFiredTriggerClassName(""),
62 fAnaLED(kFALSE),fTaskName(""),fCaloUtils(0x0),
63 fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL), fWriteOutputStdAOD(kFALSE)
67 //Initialize parameters
71 //____________________________________________________________________________
72 AliCaloTrackReader::AliCaloTrackReader(const AliCaloTrackReader & reader) :
73 TObject(reader), fEventNumber(reader.fEventNumber), fCurrentFileName(reader.fCurrentFileName),
74 fDataType(reader.fDataType), fDebug(reader.fDebug),
75 fFiducialCut(reader.fFiducialCut),
76 fComparePtHardAndJetPt(reader.fComparePtHardAndJetPt),
77 fPtHardAndJetPtFactor(reader.fPtHardAndJetPtFactor),
78 fCTSPtMin(reader.fCTSPtMin), fEMCALPtMin(reader.fEMCALPtMin),fPHOSPtMin(reader.fPHOSPtMin),
79 fAODCTS(new TObjArray(*reader.fAODCTS)),
80 fAODEMCAL(new TObjArray(*reader.fAODEMCAL)),
81 fAODPHOS(new TObjArray(*reader.fAODPHOS)),
82 fEMCALCells(new TNamed(*reader.fEMCALCells)),
83 fPHOSCells(new TNamed(*reader.fPHOSCells)),
84 fInputEvent(reader.fInputEvent), fOutputEvent(reader.fOutputEvent), fMC(reader.fMC),
85 fFillCTS(reader.fFillCTS),fFillEMCAL(reader.fFillEMCAL),fFillPHOS(reader.fFillPHOS),
86 fFillEMCALCells(reader.fFillEMCALCells),fFillPHOSCells(reader.fFillPHOSCells),
87 fSecondInputAODTree(reader.fSecondInputAODTree),
88 fSecondInputAODEvent(reader.fSecondInputAODEvent),
89 fSecondInputFileName(reader.fSecondInputFileName),
90 fSecondInputFirstEvent(reader.fSecondInputFirstEvent),
91 fAODCTSNormalInputEntries(reader.fAODCTSNormalInputEntries),
92 fAODEMCALNormalInputEntries(reader.fAODEMCALNormalInputEntries),
93 fAODPHOSNormalInputEntries(reader.fAODPHOSNormalInputEntries),
94 fTrackStatus(reader.fTrackStatus),
95 fReadStack(reader.fReadStack), fReadAODMCParticles(reader.fReadAODMCParticles),
96 fCleanOutputStdAOD(reader.fCleanOutputStdAOD), fDeltaAODFileName(reader.fDeltaAODFileName),
97 fFiredTriggerClassName(reader.fFiredTriggerClassName),
98 fAnaLED(reader.fAnaLED),
99 fTaskName(reader.fTaskName),
100 fCaloUtils(new AliCalorimeterUtils(*reader.fCaloUtils))
105 //_________________________________________________________________________
106 //AliCaloTrackReader & AliCaloTrackReader::operator = (const AliCaloTrackReader & source)
108 // // assignment operator
110 // if(&source == this) return *this;
112 // fDataType = source.fDataType ;
113 // fDebug = source.fDebug ;
114 // fEventNumber = source.fEventNumber ;
115 // fCurrentFileName = source.fCurrentFileName ;
116 // fFiducialCut = source.fFiducialCut;
118 // fComparePtHardAndJetPt = source.fComparePtHardAndJetPt;
119 // fPtHardAndJetPtFactor = source.fPtHardAndJetPtFactor;
121 // fCTSPtMin = source.fCTSPtMin ;
122 // fEMCALPtMin = source.fEMCALPtMin ;
123 // fPHOSPtMin = source.fPHOSPtMin ;
125 // fAODCTS = new TObjArray(*source.fAODCTS) ;
126 // fAODEMCAL = new TObjArray(*source.fAODEMCAL) ;
127 // fAODPHOS = new TObjArray(*source.fAODPHOS) ;
128 // fEMCALCells = new TNamed(*source.fEMCALCells) ;
129 // fPHOSCells = new TNamed(*source.fPHOSCells) ;
131 // fInputEvent = source.fInputEvent;
132 // fOutputEvent = source.fOutputEvent;
135 // fFillCTS = source.fFillCTS;
136 // fFillEMCAL = source.fFillEMCAL;
137 // fFillPHOS = source.fFillPHOS;
138 // fFillEMCALCells = source.fFillEMCALCells;
139 // fFillPHOSCells = source.fFillPHOSCells;
141 // fSecondInputAODTree = source.fSecondInputAODTree;
142 // fSecondInputAODEvent = source.fSecondInputAODEvent;
143 // fSecondInputFileName = source.fSecondInputFileName;
144 // fSecondInputFirstEvent = source.fSecondInputFirstEvent;
146 // fAODCTSNormalInputEntries = source.fAODCTSNormalInputEntries;
147 // fAODEMCALNormalInputEntries = source.fAODEMCALNormalInputEntries;
148 // fAODPHOSNormalInputEntries = source.fAODPHOSNormalInputEntries;
150 // fTrackStatus = source.fTrackStatus;
151 // fReadStack = source.fReadStack;
152 // fReadAODMCParticles = source.fReadAODMCParticles;
154 // fCleanOutputStdAOD = source.fCleanOutputStdAOD;
155 // fDeltaAODFileName = source.fDeltaAODFileName;
157 // fFiredTriggerClassName = source.fFiredTriggerClassName ;
163 //_________________________________
164 AliCaloTrackReader::~AliCaloTrackReader() {
167 if(fFiducialCut) delete fFiducialCut ;
185 fEMCALCells->Clear() ;
190 fPHOSCells->Clear() ;
194 for (Int_t i = 0; i < fNMixedEvent; i++) {
195 delete [] fVertex[i] ;
200 // Pointers not owned, done by the analysis frame
201 // if(fInputEvent) delete fInputEvent ;
202 // if(fOutputEvent) delete fOutputEvent ;
203 // if(fMC) delete fMC ;
205 // if(fSecondInputAODTree){
206 // fSecondInputAODTree->Clear();
207 // delete fSecondInputAODTree;
210 // if(fSecondInputAODEvent) delete fSecondInputAODEvent ;
212 // Pointer not owned, deleted by maker
213 //if (fCaloUtils) delete fCaloUtils ;
217 //_________________________________________________________________________
218 Bool_t AliCaloTrackReader::ComparePtHardAndJetPt(){
219 // Check the event, if the requested ptHard is much larger than the jet pT, then there is a problem.
221 if(!fReadStack) return kTRUE; //Information not filtered to AOD
223 if(!strcmp(GetGenEventHeader()->ClassName(), "AliGenPythiaEventHeader")){
224 TParticle * jet = new TParticle;
225 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) GetGenEventHeader();
226 Int_t nTriggerJets = pygeh->NTriggerJets();
227 Float_t ptHard = pygeh->GetPtHard();
229 //if(fDebug > 1) printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %f\n",nTriggerJets, ptHard);
230 Float_t tmpjet[]={0,0,0,0};
231 for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
232 pygeh->TriggerJet(ijet, tmpjet);
233 jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
234 //Compare jet pT and pt Hard
235 //if(fDebug > 1) printf("AliMCAnalysisUtils:: %d pycell jet pT %f\n",ijet, jet->Pt());
236 if(jet->Pt() > fPtHardAndJetPtFactor * ptHard) {
237 printf("AliMCAnalysisUtils::PythiaEventHeader: Njets: %d, pT Hard %2.2f, pycell jet pT %2.2f, rejection factor %1.1f\n",
238 nTriggerJets, ptHard, jet->Pt(), fPtHardAndJetPtFactor);
248 //____________________________________________________________________________
249 AliStack* AliCaloTrackReader::GetStack() const {
250 //Return pointer to stack
254 if(fDebug > 1) printf("AliCaloTrackReader::GetStack() - Stack is not available\n");
259 //____________________________________________________________________________
260 AliHeader* AliCaloTrackReader::GetHeader() const {
261 //Return pointer to header
263 return fMC->Header();
265 printf("AliCaloTrackReader::Header is not available\n");
269 //____________________________________________________________________________
270 AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const {
271 //Return pointer to Generated event header
273 return fMC->GenEventHeader();
275 printf("AliCaloTrackReader::GenEventHeader is not available\n");
280 //____________________________________________________________________________
281 TClonesArray* AliCaloTrackReader::GetAODMCParticles(Int_t input) const {
282 //Return list of particles in AOD. Do it for the corresponding input event.
283 TClonesArray * rv = NULL ;
284 // if(fDataType == kAOD){
286 AliAODEvent * evt = NULL ;
289 evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
290 rv = (TClonesArray*)evt->FindListObject("mcparticles");
291 } else if(input == 1 && fSecondInputAODEvent){ //Second input AOD
292 rv = (TClonesArray*) fSecondInputAODEvent->FindListObject("mcparticles");
294 printf("AliCaloTrackReader::GetAODMCParticles() - wrong AOD input index? %d, or non existing tree? \n",input);
297 printf("AliCaloTrackReader::GetAODMCParticles() - Input are not AODs\n");
302 //____________________________________________________________________________
303 AliAODMCHeader* AliCaloTrackReader::GetAODMCHeader(Int_t input) const {
304 //Return MC header in AOD. Do it for the corresponding input event.
305 if(fDataType == kAOD){
307 if(input == 0) return (AliAODMCHeader*)((AliAODEvent*)fInputEvent)->FindListObject("mcheader");
309 else if(input == 1) return (AliAODMCHeader*) fSecondInputAODEvent->FindListObject("mcheader");
311 printf("AliCaloTrackReader::GetAODMCHeader() - wrong AOD input index, %d\n",input);
316 printf("AliCaloTrackReader::GetAODMCHeader() - Input are not AODs\n");
321 //_______________________________________________________________
322 void AliCaloTrackReader::Init()
324 //Init reader. Method to be called in AliAnaPartCorrMaker
326 //Get the file with second input events if the filename is given
327 //Get the tree and connect the AODEvent. Only with AODs
329 if(fReadStack && fReadAODMCParticles){
330 printf("AliCaloTrackReader::Init() - Cannot access stack and mcparticles at the same time, change them \n");
332 fReadAODMCParticles = kFALSE;
335 if(fSecondInputFileName!=""){
336 if(fDataType == kAOD){
337 TFile * input2 = new TFile(fSecondInputFileName,"read");
338 printf("AliCaloTrackReader::Init() - Second input file opened: %s, size %d \n", input2->GetName(), (Int_t) input2->GetSize());
339 fSecondInputAODTree = (TTree*) input2->Get("aodTree");
340 if(fSecondInputAODTree) printf("AliCaloTrackReader::Init() - Second input tree opened: %s, entries %d \n",
341 fSecondInputAODTree->GetName(), (Int_t) fSecondInputAODTree->GetEntries());
343 printf("AliCaloTrackReader::Init() - Second input tree not available, STOP \n");
346 fSecondInputAODEvent = new AliAODEvent;
347 fSecondInputAODEvent->ReadFromTree(fSecondInputAODTree);
348 if(fSecondInputFirstEvent >= fSecondInputAODTree->GetEntriesFast()){
349 printf("AliCaloTrackReader::Init() - Requested first event of second input %d, is larger than number of events %d, STOP\n",
350 fSecondInputFirstEvent, (Int_t) fSecondInputAODTree->GetEntriesFast());
354 else printf("AliCaloTrackReader::Init() - Second input not added, reader is not AOD\n");
358 //_______________________________________________________________
359 void AliCaloTrackReader::InitParameters()
361 //Initialize the parameters of the analysis.
367 //Do not filter the detectors input by default.
371 fFillEMCALCells = kFALSE;
372 fFillPHOSCells = kFALSE;
374 fSecondInputFileName = "" ;
375 fSecondInputFirstEvent = 0 ;
376 fReadStack = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
377 fReadAODMCParticles = kFALSE; // Check in the constructor of the other readers if it was set or in the configuration file
378 fCleanOutputStdAOD = kFALSE; // Clean the standard clusters/tracks?
379 fDeltaAODFileName = "deltaAODPartCorr.root";
380 fFiredTriggerClassName = "";
385 //________________________________________________________________
386 void AliCaloTrackReader::Print(const Option_t * opt) const
389 //Print some relevant parameters set for the analysis
393 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
394 printf("Task name : %s\n", fTaskName.Data()) ;
395 printf("Data type : %d\n", fDataType) ;
396 printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
397 printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
398 printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
399 printf("Use CTS = %d\n", fFillCTS) ;
400 printf("Use EMCAL = %d\n", fFillEMCAL) ;
401 printf("Use PHOS = %d\n", fFillPHOS) ;
402 printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
403 printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
404 printf("Track status = %d\n", (Int_t) fTrackStatus) ;
405 if(fComparePtHardAndJetPt)
406 printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
408 if(fSecondInputFileName!="") {
409 printf("Second Input File Name = %s\n", fSecondInputFileName.Data()) ;
410 printf("Second Input First Event = %d\n", fSecondInputFirstEvent) ;
413 printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
414 printf("Clean std AOD = %d\n", fCleanOutputStdAOD) ;
415 printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
419 //___________________________________________________
420 Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * currentFileName) {
421 //Fill the event counter and input lists that are needed, called by the analysis maker.
423 fEventNumber = iEntry;
424 fCurrentFileName = TString(currentFileName);
426 if(fDebug >= 0) printf("AliCaloTrackReader::FillInputEvent() - Input event not available, skip event analysis\n");
429 //Select events only fired by a certain trigger configuration if it is provided
431 if(fInputEvent->GetHeader())
432 eventType = ((AliVHeader*)fInputEvent->GetHeader())->GetEventType();
433 if( fFiredTriggerClassName !="" && !fAnaLED){
435 return kFALSE; //Only physics event, do not use for simulated events!!!
437 printf("AliCaloTrackReader::FillInputEvent() - FiredTriggerClass <%s>, selected class <%s>, compare name %d\n",
438 GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data(), GetFiredTriggerClasses().Contains(fFiredTriggerClassName));
439 if( !GetFiredTriggerClasses().Contains(fFiredTriggerClassName) ) return kFALSE;
442 // kStartOfRun = 1, // START_OF_RUN
443 // kEndOfRun = 2, // END_OF_RUN
444 // kStartOfRunFiles = 3, // START_OF_RUN_FILES
445 // kEndOfRunFiles = 4, // END_OF_RUN_FILES
446 // kStartOfBurst = 5, // START_OF_BURST
447 // kEndOfBurst = 6, // END_OF_BURST
448 // kPhysicsEvent = 7, // PHYSICS_EVENT
449 // kCalibrationEvent = 8, // CALIBRATION_EVENT
450 // kFormatError = 9, // EVENT_FORMAT_ERROR
451 // kStartOfData = 10, // START_OF_DATA
452 // kEndOfData = 11, // END_OF_DATA
453 // kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
454 // kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
456 if(eventType!=7 && fDebug > 1 )printf("AliCaloTrackReader::FillInputEvent() - DO LED, Event Type <%d>, 8 Calibration \n", eventType);
457 if(eventType!=8)return kFALSE;
460 if(fOutputEvent && (fDataType != kAOD) && ((fOutputEvent->GetCaloClusters())->GetEntriesFast()!=0 ||(fOutputEvent->GetTracks())->GetEntriesFast()!=0)){
461 if (fFillCTS || fFillEMCAL || fFillPHOS) {
462 printf("AliCaloTrackReader::AODCaloClusters or AODTracks already filled by the filter, do not use the ESD reader, use the AOD reader, STOP\n");
467 //In case of analysis of events with jets, skip those with jet pt > 5 pt hard
468 if(fComparePtHardAndJetPt && GetStack()) {
469 if(!ComparePtHardAndJetPt()) return kFALSE ;
472 //In case of mixing events with other AOD file
473 if(fDataType == kAOD && fSecondInputAODTree){
476 printf("AliCaloTrackReader::FillInputEvent() - Get event %d from second input AOD file \n", iEntry+fSecondInputFirstEvent);
477 if(fSecondInputAODTree->GetEntriesFast() <= iEntry+fSecondInputFirstEvent) {
478 if(fSecondInputAODTree->GetEntriesFast() == iEntry+fSecondInputFirstEvent)
479 printf("AliCaloTrackReader::FillInputEvent() - Skip events from event %d, no more events in second AOD file \n", iEntry);
484 Int_t nbytes = fSecondInputAODTree->GetEvent(iEntry+fSecondInputFirstEvent);
485 if ( nbytes == 0 ) {//If nothing in AOD
486 printf("AliCaloTrackReader::FillInputEvent() - Nothing in Second AOD input, STOP\n");
493 for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
498 fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
502 FillInputEMCALCells();
504 FillInputPHOSCells();
517 //__________________________________________________
518 void AliCaloTrackReader::ResetLists() {
519 // Reset lists, called by the analysis maker
521 if(fAODCTS) fAODCTS -> Clear();
522 if(fAODEMCAL) fAODEMCAL -> Clear();
523 if(fAODPHOS) fAODPHOS -> Clear();
524 if(fEMCALCells) fEMCALCells -> Clear();
525 if(fPHOSCells) fPHOSCells -> Clear();
526 if(fCleanOutputStdAOD && fOutputEvent ){
527 //Only keep copied tracks and clusters if requested
528 fOutputEvent->GetTracks() ->Clear();
529 fOutputEvent->GetCaloClusters()->Clear();
534 //____________________________________________________________________________
535 void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
538 fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
540 fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
542 fVertex = new Double_t*[fNMixedEvent] ;
543 for (Int_t i = 0; i < fNMixedEvent; i++) {
544 fVertex[i] = new Double_t[3] ;
545 fVertex[i][0] = 0.0 ;
546 fVertex[i][1] = 0.0 ;
547 fVertex[i][2] = 0.0 ;
551 //____________________________________________________________________________
552 Double_t * AliCaloTrackReader::GetVertex() {
553 //Return vertex position
556 if(fInputEvent->GetPrimaryVertex())
557 fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]);
559 printf("AliCaloTrackReader::GetVertex() - No vertex available, InputEvent()->GetPrimaryVertex() = 0, return (0,0,0)\n");
560 fVertex[0][0]=0.0; fVertex[0][1]=0.0; fVertex[0][2]=0.0;
565 //____________________________________________________________________________
566 void AliCaloTrackReader::FillInputCTS() {
567 //Return array with Central Tracking System (CTS) tracks
568 if(fDebug > 2 ) printf("AliCaloTrackAODReader::FillInputCTS()\n");
569 Int_t nTracks = fInputEvent->GetNumberOfTracks() ;
572 for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
573 AliVTrack * track = (AliVTrack*)fInputEvent->GetTrack(itrack) ; // retrieve track from esd
575 //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
576 if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus))
579 track->GetPxPyPz(p) ;
580 TLorentzVector momentum(p[0],p[1],p[2],0);
582 if(fCTSPtMin < momentum.Pt()){
584 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS"))
587 if(fDebug > 2 && momentum.Pt() > 0.1)
588 printf("AliCaloTrackAODReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
589 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
592 track->SetID(itrack);
594 if(fWriteOutputStdAOD){
595 AliAODTrack * aodTrack = dynamic_cast<AliAODTrack*> (track) ;
597 AliAODTrack* newtrack = new((*(fOutputEvent->GetTracks()))[naod++]) AliAODTrack(*aodTrack);
598 fAODCTS->Add(newtrack); //Use AOD stored in output for references.
600 AliError("Can only write AOD tracks to output AOD !") ;
606 }//Pt and Fiducial cut passed.
609 fAODCTSNormalInputEntries = fAODCTS->GetEntriesFast();
610 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputCTS() - aod entries %d\n", fAODCTSNormalInputEntries);
612 // //If second input event available, add the clusters.
613 // if(fSecondInputAODTree && fSecondInputAODEvent){
614 // nTracks = fSecondInputAODEvent->GetNumberOfTracks() ;
615 // if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputCTS() - Add second input tracks, entries %d\n", nTracks) ;
616 // for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop
617 // AliAODTrack * track = ((AliAODEvent*)fSecondInputAODEvent)->GetTrack(itrack) ; // retrieve track from esd
619 // //Select tracks under certain conditions, TPCrefit, ITSrefit ... check the set bits
620 // if (fTrackStatus && !((track->GetStatus() & fTrackStatus) == fTrackStatus)) continue ;
622 // track->GetPxPyPz(p) ;
623 // TLorentzVector momentum(p[0],p[1],p[2],0);
625 // if(fCTSPtMin < momentum.Pt()){
627 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"CTS")) continue;
629 // if(fDebug > 2 && momentum.Pt() > 0.1) printf("AliCaloTrackAODReader::FillInputCTS() - Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
630 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
632 // if(fWriteOutputStdAOD){
633 // AliAODTrack* newtrack = new((*(fOutputEvent->GetTracks()))[naod++]) AliAODTrack(*track);
634 // fAODCTS->Add(newtrack); //Use AOD stored in output for references.
636 // else fAODCTS->Add(track);
638 // }//Pt and Fiducial cut passed.
641 // if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputCTS() - aod normal entries %d, after second input %d\n", fAODCTSNormalInputEntries, fAODCTS->GetEntriesFast());
642 // } //second input loop
646 //____________________________________________________________________________
647 void AliCaloTrackReader::FillInputEMCAL() {
648 //Return array with EMCAL clusters in aod format
649 if(fDebug > 2 ) printf("AliCaloTrackAODReader::FillInputEMCAL()\n");
651 Int_t naod = (fOutputEvent->GetCaloClusters())->GetEntriesFast();
652 //Loop to select clusters in fiducial cut and fill container with aodClusters
653 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
654 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
655 AliVCluster * clus = 0;
656 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
657 if (clus->IsEMCAL()){
659 //Check if the cluster contains any bad channel and if close to calorimeter borders
662 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
664 if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells()))
666 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex))
669 TLorentzVector momentum ;
671 clus->GetMomentum(momentum, fVertex[vindex]);
673 if(fEMCALPtMin < momentum.Pt()){
675 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL"))
678 if(fDebug > 2 && momentum.E() > 0.1)
679 printf("AliCaloTrackAODReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
680 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
682 //Recalibrate the cluster energy
683 if(GetCaloUtils()->IsRecalibrationOn()) {
684 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetEMCALCells());
691 if(fWriteOutputStdAOD){
692 AliAODCaloCluster * aodClus = dynamic_cast<AliAODCaloCluster*> (clus) ;
694 AliAODCaloCluster * newclus = new((*(fOutputEvent->GetCaloClusters()))[naod++])AliAODCaloCluster(*aodClus);
695 fAODEMCAL->Add(newclus);
697 AliError("Can only write AOD clusters to output AOD !") ;
700 fAODEMCAL->Add(clus);
702 }//Pt and Fiducial cut passed.
706 fAODEMCALNormalInputEntries = fAODEMCAL->GetEntriesFast();
707 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputEMCAL() - aod entries %d\n", fAODEMCALNormalInputEntries);
709 //If second input event available, add the clusters.
710 // if(fSecondInputAODTree && fSecondInputAODEvent){
711 // GetSecondInputAODVertex(v);
712 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
713 // if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputEMCAL() - Add second input clusters, entries %d\n", nclusters) ;
714 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
715 // AliAODCaloCluster * clus = 0;
716 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
717 // if (clus->IsEMCAL()){
718 // TLorentzVector momentum ;
719 // clus->GetMomentum(momentum, v);
721 // if(fEMCALPtMin < momentum.Pt()){
723 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) continue;
725 // if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackAODReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
726 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
727 // if(fWriteOutputStdAOD){
728 // AliAODCaloCluster * newclus = new((*(fOutputEvent->GetCaloClusters()))[naod++])AliAODCaloCluster(*clus);
729 // fAODEMCAL->Add(newclus);
731 // else fAODEMCAL->Add(clus);
732 // }//Pt and Fiducial cut passed.
734 // }// cluster exists
737 // if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputEMCAL() - aod normal entries %d, after second input %d\n", fAODEMCALNormalInputEntries, fAODEMCAL->GetEntriesFast());
739 // } //second input loop
742 //____________________________________________________________________________
743 void AliCaloTrackReader::FillInputPHOS() {
744 //Return array with PHOS clusters in aod format
745 if(fDebug > 2 ) printf("AliCaloTrackAODReader::FillInputPHOS()\n");
747 //Get vertex for momentum calculation
749 Int_t naod = (fOutputEvent->GetCaloClusters())->GetEntriesFast();
750 //Loop to select clusters in fiducial cut and fill container with aodClusters
751 Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
752 for (Int_t iclus = 0; iclus < nclusters; iclus++) {
753 AliVCluster * clus = 0;
754 if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
756 //Check if the cluster contains any bad channel and if close to calorimeter borders
759 vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
760 if( GetCaloUtils()->ClusterContainsBadChannel("PHOS",clus->GetCellsAbsId(), clus->GetNCells()))
762 if(!GetCaloUtils()->CheckCellFiducialRegion(clus, fInputEvent->GetPHOSCells(), fInputEvent, vindex))
765 TLorentzVector momentum ;
767 clus->GetMomentum(momentum, fVertex[vindex]);
769 if(fPHOSPtMin < momentum.Pt()){
771 if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS"))
774 if(fDebug > 2 && momentum.E() > 0.1)
775 printf("AliCaloTrackAODReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
776 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
778 //Recalibrate the cluster energy
779 if(GetCaloUtils()->IsRecalibrationOn()) {
780 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, (AliAODCaloCells*)GetPHOSCells());
788 if(fWriteOutputStdAOD){
789 AliAODCaloCluster * aodClus = dynamic_cast<AliAODCaloCluster*> (clus) ;
791 AliAODCaloCluster * newclus = new((*(fOutputEvent->GetCaloClusters()))[naod++])AliAODCaloCluster(*aodClus);
792 fAODPHOS->Add(newclus);
794 AliError("Can only write AOD clusters to output AOD !") ;
799 }//Pt and Fiducial cut passed.
804 fAODPHOSNormalInputEntries = fAODPHOS->GetEntriesFast() ;
805 if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS() - aod entries %d\n", fAODPHOSNormalInputEntries);
807 //If second input event available, add the clusters.
808 // if(fSecondInputAODTree && fSecondInputAODEvent){
809 // GetSecondInputAODVertex(v);
810 // nclusters = ((AliAODEvent*)fSecondInputAODEvent)->GetNumberOfCaloClusters();
811 // if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS() - Add second input clusters, entries %d\n", nclusters);
812 // for (Int_t iclus = 0; iclus < nclusters; iclus++) {
813 // AliAODCaloCluster * clus = 0;
814 // if ( (clus = ((AliAODEvent*)fSecondInputAODEvent)->GetCaloCluster(iclus)) ) {
815 // if (clus->IsPHOS()){
816 // TLorentzVector momentum ;
817 // clus->GetMomentum(momentum, v);
819 // if(fPHOSPtMin < momentum.Pt()){
821 // if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"PHOS")) continue;
823 // if(fDebug > 2 && momentum.E() > 0.1) printf("AliCaloTrackAODReader::FillInputPHOS() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
824 // momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
825 // if(fWriteOutputStdAOD){
826 // AliAODCaloCluster * newclus = new((*(fOutputEvent->GetCaloClusters()))[naod++])AliAODCaloCluster(*clus);
827 // fAODPHOS->Add(newclus);
829 // else fAODPHOS->Add(clus);
830 // }//Pt and Fiducial cut passed.
832 // }// cluster exists
834 // if(fDebug > 1) printf("AliCaloTrackAODReader::FillInputPHOS() - aod normal entries %d, after second input %d\n", fAODPHOSNormalInputEntries, fAODPHOS->GetEntriesFast());
835 // } //second input loop
839 //____________________________________________________________________________
840 void AliCaloTrackReader::FillInputEMCALCells() {
841 //Return array with EMCAL cells in aod format
843 fEMCALCells = fInputEvent->GetEMCALCells();
847 //____________________________________________________________________________
848 void AliCaloTrackReader::FillInputPHOSCells() {
849 //Return array with PHOS cells in aod format
851 fPHOSCells = fInputEvent->GetPHOSCells();