Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / JETAN / AliJetReader.cxx
CommitLineData
99e5fe42 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 **************************************************************************/
139cbd96 15
16/* $Id$ */
99e5fe42 17
83a444b1 18//------------------------------------------------------------------------
99e5fe42 19// Jet reader base class
20// manages the reading of input for jet algorithms
b45b0c92 21// Authors: jgcn@mda.cinvestav.mx
139cbd96 22// magali.estienne@subatech.in2p3.fr
23// alexandre.shabetai@cern.ch
f45e6f72 24//
25// **February 2011
f445ed00 26// implemented standard geometry (AliEMCALGeometry) (was AliJetDummyGeo implented separately in ESDReader and AODReader
f45e6f72 27// local2master matrices are now get from $ALICE_ROOT/OADB/PWG4/JetReconstruction/EMCALlocal2master.root
28// you can choose the geometry (EMCAL_COMPLETE, EMCAL_FIRSTYEARv1, etc) via SetEMCALgeo2bLoad('Name_of_Geometry') in the Readerheader
29// different options for survey(ed) matrice are provided too
9990e729 30// ** August 2011
31// OADB path changed from '../OADB/PWG4/JetReconstruction/' to '../OADB/EMCAL/'
f45e6f72 32// marco.bregant@subatech.in2p3.fr
139cbd96 33// ** 2011
34// - AliJetESD/AODReader classes removed from JETAN. Reader now ESD/AOD independent. It uses VEvent in the AliJetFill* classes.
35// - EMCal utilities added for bad cells id, calibration, etc.
36//------------------------------------------------------------------------
99e5fe42 37
83a444b1 38// root
139cbd96 39#include <TFile.h>
40
83a444b1 41//AliRoot
139cbd96 42#include "AliVEvent.h"
43#include "AliAODEvent.h"
44#include "AliESDEvent.h"
99e5fe42 45#include "AliJetReader.h"
46#include "AliJetReaderHeader.h"
139cbd96 47#include "AliAnalysisManager.h"
48#include "AliJetFillCalTrkTrack.h"
49#include "AliJetFillCalTrkTrackMC.h"
50#include "AliJetCalTrk.h"
99e5fe42 51
3a7af7bd 52using std::cout;
53using std::endl;
99e5fe42 54ClassImp(AliJetReader)
55
56////////////////////////////////////////////////////////////////////////
139cbd96 57
8838ab7a 58
1b7d5d7e 59AliJetReader::AliJetReader():
139cbd96 60 fCalTrkEvent(0x0),
61 fFillEvent(0x0),
1b7d5d7e 62 fReaderHeader(0),
139cbd96 63 fFillEventwTrks(0x0),
64 fDebug(0),
65 fVEvent(0x0),
66 fMCEvent(0x0),
67 fOpt(0)
99e5fe42 68{
1b7d5d7e 69 // Default constructor
99e5fe42 70}
71
139cbd96 72//-----------------------------------------------------------------------
99e5fe42 73AliJetReader::~AliJetReader()
74{
75 // Destructor
139cbd96 76 if (fCalTrkEvent) {
77 fCalTrkEvent->Delete();
78 delete fCalTrkEvent;
8838ab7a 79 }
139cbd96 80
81 if (fFillEventwTrks) {
82 delete fFillEventwTrks;
026b032e 83 }
139cbd96 84
99e5fe42 85}
86
139cbd96 87//-----------------------------------------------------------------------
88void AliJetReader::InitTasks()
89{
90 // Initialization
91 fOpt = GetReaderHeader()->GetDetector();
92
93 TString datatype = fReaderHeader->GetDataType();
94 datatype.ToUpper();
95 Bool_t kIsKine = kFALSE;
96 if((!datatype.Contains("AOD") && datatype.Contains("MC")) ||
97 (!datatype.Contains("AOD") && datatype.Contains("MC2")) ){
98 kIsKine = kTRUE;
99 }
100 Bool_t kIsHighMult = GetReaderHeader()->GetIsHighMult();
101 fCalTrkEvent = new AliJetCalTrkEvent(fOpt,kIsKine,kIsHighMult);
102
103 // Initialize jet analysis
104 CreateTasks();
105
106}
99e5fe42 107
139cbd96 108//-----------------------------------------------------------------------
109Bool_t AliJetReader::ProcessEvent()
99e5fe42 110{
139cbd96 111 // Process one event
112 // Charged only or charged+neutral jets
113
114 Bool_t ok = ExecTasks();
115
116 if(!ok) {return kFALSE;}
117
118 return kTRUE;
119
99e5fe42 120}
f45e6f72 121
139cbd96 122//-----------------------------------------------------------------------
123void AliJetReader::SetInputEvent(const TObject* esd, const TObject* aod, const AliMCEvent* mc)
f45e6f72 124{
139cbd96 125 // set input event pointers
126 if( fReaderHeader->GetDataType().Contains("AOD") && aod) {fVEvent = (AliAODEvent*) aod;}
127 else if( fReaderHeader->GetDataType().Contains("ESD") && esd) {fVEvent = (AliESDEvent*) esd;}
128 else if ( fReaderHeader->GetDataType().Contains("MC") || fReaderHeader->GetDataType().Contains("MC2")) { fMCEvent = (AliMCEvent*) mc;}
129 else {printf("No input event ! ");}
f45e6f72 130
139cbd96 131}
f45e6f72 132
139cbd96 133//-----------------------------------------------------------------------
134Bool_t AliJetReader::CreateTasks()
135{
136 // For reader task initialization
f45e6f72 137
139cbd96 138 fDebug = fReaderHeader->GetDebug();
f45e6f72 139
139cbd96 140 fFillEvent = new AliJetFillCalTrkEvent();
141 if (fOpt>0) {
142 // Tracks
143 if(fOpt%2==!0 && fOpt!=0){
144 fFillEventwTrks = new AliJetFillCalTrkTrack();
145 fFillEventwTrks->SetReaderHeader(fReaderHeader);
146 }
147 }
148 else { // MC/Kine cases
149 fFillEventwTrks = new AliJetFillCalTrkTrackMC();
150 fFillEventwTrks->SetReaderHeader(fReaderHeader);
151 }
152
153 if(fDebug>1) cout << "Tasks instantiated at that stage ! " << endl;
154
155 return kTRUE;
f45e6f72 156
f45e6f72 157}
139cbd96 158
159//-----------------------------------------------------------------------
160Bool_t AliJetReader::ExecTasks()
161{
162 // Main function
163 // Fill the reader part
f45e6f72 164
139cbd96 165 fDebug = fReaderHeader->GetDebug();
166
167 if(!fVEvent && !fMCEvent) {
168 return kFALSE;
169 }
170
171 // TPC only or Digits+TPC or Clusters+TPC
172 if(fOpt%2==!0 || fOpt==0){
173 fFillEventwTrks->SetVEvent(fVEvent);
174 fFillEventwTrks->SetMCEvent(fMCEvent);
175 fFillEventwTrks->SetCalTrkEvent(fCalTrkEvent);
176 fFillEventwTrks->Exec("tpc");
177 }
178
f45e6f72 179 return kTRUE;
139cbd96 180
f45e6f72 181}
139cbd96 182
183//-----------------------------------------------------------------------
184void AliJetReader::WriteRHeaderToFile() const
185{
186 // write reader header
187 AliJetReaderHeader *rh = GetReaderHeader();
188 rh->Write();
189
190}
191
192//-----------------------------------------------------------------------
193void AliJetReader::WriteReaderHeader()
194{
195 // Write the Headers
196 TFile* f = new TFile("jets_local.root", "recreate");
197 WriteRHeaderToFile();
198 f->Close();
199
200}
201