1 ////////////////////////////////////////////////////////////////////////////////
3 // AliFemtoEventReaderAOD - the reader class for the Alice AOD //
4 // Reads in AOD information and converts it into internal AliFemtoEvent //
5 // Authors: Marek Chojnacki mchojnacki@knf.pw.edu.pl //
6 // Adam Kisiel kisiel@mps.ohio-state.edu //
8 ////////////////////////////////////////////////////////////////////////////////
10 #include "AliFemtoEventReaderAOD.h"
14 #include "AliAODEvent.h"
15 #include "AliAODTrack.h"
16 #include "AliAODVertex.h"
18 #include "AliFmPhysicalHelixD.h"
19 #include "AliFmThreeVectorF.h"
21 #include "SystemOfUnits.h"
23 #include "AliFemtoEvent.h"
24 #include "AliFemtoModelHiddenInfo.h"
26 ClassImp(AliFemtoEventReaderAOD)
28 #if !(ST_NO_NAMESPACES)
29 using namespace units;
33 //____________________________
34 //constructor with 0 parameters , look at default settings
35 AliFemtoEventReaderAOD::AliFemtoEventReaderAOD():
48 // default constructor
49 fAllTrue.ResetAllBits(kTRUE);
50 fAllFalse.ResetAllBits(kFALSE);
53 AliFemtoEventReaderAOD::AliFemtoEventReaderAOD(const AliFemtoEventReaderAOD &aReader) :
54 AliFemtoEventReader(),
68 fInputFile = aReader.fInputFile;
69 fFileName = aReader.fFileName;
70 fNumberofEvent = aReader.fNumberofEvent;
71 fCurEvent = aReader.fCurEvent;
72 fEvent = new AliAODEvent();
73 fAodFile = new TFile(aReader.fAodFile->GetName());
74 fAllTrue.ResetAllBits(kTRUE);
75 fAllFalse.ResetAllBits(kFALSE);
76 fFilterBit = aReader.fFilterBit;
77 fPWG2AODTracks = aReader.fPWG2AODTracks;
81 AliFemtoEventReaderAOD::~AliFemtoEventReaderAOD()
88 fPWG2AODTracks->Delete();
89 delete fPWG2AODTracks;
94 AliFemtoEventReaderAOD& AliFemtoEventReaderAOD::operator=(const AliFemtoEventReaderAOD& aReader)
96 // assignment operator
100 fInputFile = aReader.fInputFile;
101 fFileName = aReader.fFileName;
102 fNumberofEvent = aReader.fNumberofEvent;
103 fCurEvent = aReader.fCurEvent;
104 if (fTree) delete fTree;
105 if (fEvent) delete fEvent;
106 fEvent = new AliAODEvent();
107 if (fAodFile) delete fAodFile;
108 fAodFile = new TFile(aReader.fAodFile->GetName());
109 fAllTrue.ResetAllBits(kTRUE);
110 fAllFalse.ResetAllBits(kFALSE);
111 fFilterBit = aReader.fFilterBit;
112 fPWG2AODTracks = aReader.fPWG2AODTracks;
117 AliFemtoString AliFemtoEventReaderAOD::Report()
119 // create reader report
120 AliFemtoString temp = "\n This is the AliFemtoEventReaderAOD\n";
125 void AliFemtoEventReaderAOD::SetInputFile(const char* inputFile)
127 //setting the name of file where names of AOD file are written
128 //it takes only this files which have good trees
130 fInputFile=string(inputFile);
131 cout<<"Input File set on "<<fInputFile<<endl;
132 ifstream infile(inputFile);
134 fTree = new TChain("aodTree");
136 if(infile.good()==true)
138 //checking if all give files have good tree inside
139 while (infile.eof()==false)
141 infile.getline(buffer,256);
142 TFile *aodFile=TFile::Open(buffer,"READ");
145 TTree* tree = (TTree*) aodFile->Get("aodTree");
148 cout<<"putting file "<<string(buffer)<<" into analysis"<<endl;
149 fTree->AddFile(buffer);
159 AliFemtoEvent* AliFemtoEventReaderAOD::ReturnHbtEvent()
161 // read in a next hbt event from the chain
162 // convert it to AliFemtoEvent and return
163 // for further analysis
164 AliFemtoEvent *hbtEvent = 0;
166 if (fCurEvent==fNumberofEvent)//open next file
168 if(fNumberofEvent==0)
170 fEvent=new AliAODEvent();
171 fEvent->ReadFromTree(fTree);
173 // Check for the existence of the additional information
174 fPWG2AODTracks = (TClonesArray *) fEvent->GetList()->FindObject("pwg2aodtracks");
176 if (fPWG2AODTracks) {
177 cout << "Found additional PWG2 specific information in the AOD!" << endl;
178 cout << "Reading only tracks with the additional information" << endl;
181 fNumberofEvent=fTree->GetEntries();
182 cout<<"Number of Entries in file "<<fNumberofEvent<<endl;
185 else //no more data to read
187 cout<<"no more files "<<hbtEvent<<endl;
193 cout<<"starting to read event "<<fCurEvent<<endl;
194 fTree->GetEvent(fCurEvent);//getting next event
195 cout << "Read event " << fEvent << " from file " << fTree << endl;
197 hbtEvent = new AliFemtoEvent;
199 CopyAODtoFemtoEvent(hbtEvent);
206 void AliFemtoEventReaderAOD::CopyAODtoFemtoEvent(AliFemtoEvent *tEvent)
208 // A function that reads in the AOD event
209 // and transfers the neccessary information into
210 // the internal AliFemtoEvent
212 // setting global event characteristics
213 tEvent->SetRunNumber(fEvent->GetRunNumber());
214 tEvent->SetMagneticField(fEvent->GetMagneticField()*kilogauss);//to check if here is ok
215 tEvent->SetZDCN1Energy(fEvent->GetZDCN1Energy());
216 tEvent->SetZDCP1Energy(fEvent->GetZDCP1Energy());
217 tEvent->SetZDCN2Energy(fEvent->GetZDCN2Energy());
218 tEvent->SetZDCP2Energy(fEvent->GetZDCP2Energy());
219 tEvent->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0));
220 tEvent->SetZDCParticipants(-1);
221 tEvent->SetTriggerMask(fEvent->GetTriggerMask());
222 tEvent->SetTriggerCluster(fEvent->GetTriggerCluster());
224 // Primary Vertex position
226 fEvent->GetPrimaryVertex()->GetPosition(fV1);
228 AliFmThreeVectorF vertex(fV1[0],fV1[1],fV1[2]);
229 tEvent->SetPrimVertPos(vertex);
231 //starting to reading tracks
232 int nofTracks=0; //number of reconstructed tracks in event
234 // Check to see whether the additional info exists
236 nofTracks=fPWG2AODTracks->GetEntries();
238 nofTracks=fEvent->GetNumberOfTracks();
240 int realnofTracks=0; // number of track which we use in a analysis
241 cout << "Event has " << nofTracks << " tracks " << endl;
243 for (int i=0;i<nofTracks;i++)
245 AliFemtoTrack* trackCopy = new AliFemtoTrack();
247 if (fPWG2AODTracks) {
248 // Read tracks from the additional pwg2 specific AOD part
250 // Note that in that case all the AOD tracks without the
251 // additional information will be ignored !
252 AliPWG2AODTrack *pwg2aodtrack = (AliPWG2AODTrack *) fPWG2AODTracks->At(i);
254 // Getting the AOD track through the ref of the additional info
255 AliAODTrack *aodtrack = pwg2aodtrack->GetRefAODTrack();
256 if (!aodtrack->TestFilterBit(fFilterBit))
259 CopyAODtoFemtoTrack(aodtrack, trackCopy, pwg2aodtrack);
262 aodtrack->PxPyPz(pxyz);//reading noconstarined momentum
263 const AliFmThreeVectorD ktP(pxyz[0],pxyz[1],pxyz[2]);
264 // Check the sanity of the tracks - reject zero momentum tracks
265 if (ktP.mag() == 0) {
271 // No additional information exists
272 // Read in the normal AliAODTracks
273 const AliAODTrack *aodtrack=fEvent->GetTrack(i); // getting the AODtrack directly
275 if (!aodtrack->TestFilterBit(fFilterBit))
278 CopyAODtoFemtoTrack(aodtrack, trackCopy, 0);
281 aodtrack->PxPyPz(pxyz);//reading noconstarined momentum
282 const AliFmThreeVectorD ktP(pxyz[0],pxyz[1],pxyz[2]);
283 // Check the sanity of the tracks - reject zero momentum tracks
284 if (ktP.mag() == 0) {
291 tEvent->TrackCollection()->push_back(trackCopy);//adding track to analysis
292 realnofTracks++;//real number of tracks
295 tEvent->SetNumberOfTracks(realnofTracks);//setting number of track which we read in event
297 cout<<"end of reading nt "<<nofTracks<<" real number "<<realnofTracks<<endl;
300 void AliFemtoEventReaderAOD::CopyAODtoFemtoTrack(const AliAODTrack *tAodTrack,
301 AliFemtoTrack *tFemtoTrack,
302 AliPWG2AODTrack *tPWG2AODTrack)
304 // Copy the track information from the AOD into the internal AliFemtoTrack
305 // If it exists, use the additional information from the PWG2 AOD
307 // Primary Vertex position
309 fEvent->GetPrimaryVertex()->GetPosition(fV1);
311 tFemtoTrack->SetCharge(tAodTrack->Charge());
313 //in aliroot we have AliPID
314 //0-electron 1-muon 2-pion 3-kaon 4-proton 5-photon 6-pi0 7-neutron 8-kaon0 9-eleCon
315 //we use only 5 first
317 // AOD pid has 10 components
319 tAodTrack->GetPID(aodpid);
320 tFemtoTrack->SetPidProbElectron(aodpid[0]);
321 tFemtoTrack->SetPidProbMuon(aodpid[1]);
322 tFemtoTrack->SetPidProbPion(aodpid[2]);
323 tFemtoTrack->SetPidProbKaon(aodpid[3]);
324 tFemtoTrack->SetPidProbProton(aodpid[4]);
327 tAodTrack->PxPyPz(pxyz);//reading noconstrained momentum
328 AliFemtoThreeVector v(pxyz[0],pxyz[1],pxyz[2]);
329 tFemtoTrack->SetP(v);//setting momentum
330 tFemtoTrack->SetPt(sqrt(pxyz[0]*pxyz[0]+pxyz[1]*pxyz[1]));
331 const AliFmThreeVectorD kOrigin(fV1[0],fV1[1],fV1[2]);
332 //setting track helix
333 const AliFmThreeVectorD ktP(pxyz[0],pxyz[1],pxyz[2]);
334 AliFmPhysicalHelixD helix(ktP,kOrigin,(double)(fEvent->GetMagneticField())*kilogauss,(double)(tFemtoTrack->Charge()));
335 tFemtoTrack->SetHelix(helix);
338 tFemtoTrack->SetTrackId(tAodTrack->GetID());
339 tFemtoTrack->SetFlags(1);
340 tFemtoTrack->SetLabel(tAodTrack->GetLabel());
342 // Track quality information
344 tAodTrack->GetCovMatrix(covmat);
345 tFemtoTrack->SetImpactD(covmat[0]);
346 tFemtoTrack->SetImpactZ(covmat[2]);
347 tFemtoTrack->SetCdd(covmat[3]);
348 tFemtoTrack->SetCdz(covmat[4]);
349 tFemtoTrack->SetCzz(covmat[5]);
350 // This information is only available in the ESD
351 // We put in fake values or reasonable estimates
352 tFemtoTrack->SetITSchi2(tAodTrack->Chi2perNDF());
353 tFemtoTrack->SetITSncls(1);
354 tFemtoTrack->SetTPCchi2(tAodTrack->Chi2perNDF());
355 tFemtoTrack->SetTPCncls(1);
356 tFemtoTrack->SetTPCnclsF(-1);
357 tFemtoTrack->SetTPCsignalN(-1);
358 tFemtoTrack->SetTPCsignalS(-1);
361 // Copy the PWG2 specific information if it exists
362 tFemtoTrack->SetTPCClusterMap(tPWG2AODTrack->GetTPCClusterMap());
363 tFemtoTrack->SetTPCSharedMap(tPWG2AODTrack->GetTPCSharedMap());
365 double xtpc[3] = {0,0,0};
366 tPWG2AODTrack->GetTPCNominalEntrancePoint(xtpc);
367 tFemtoTrack->SetNominalTPCEntrancePoint(xtpc);
368 tPWG2AODTrack->GetTPCNominalExitPoint(xtpc);
369 tFemtoTrack->SetNominalTPCExitPoint(xtpc);
372 // If not use dummy values
373 tFemtoTrack->SetTPCClusterMap(fAllTrue);
374 tFemtoTrack->SetTPCSharedMap(fAllFalse);
376 double xtpc[3] = {0,0,0};
377 tFemtoTrack->SetNominalTPCEntrancePoint(xtpc);
378 tFemtoTrack->SetNominalTPCExitPoint(xtpc);
382 for (int ik=0; ik<3; ik++) {
385 tFemtoTrack->SetKinkIndexes(indexes);
388 void AliFemtoEventReaderAOD::SetFilterBit(UInt_t ibit)
390 fFilterBit = (1 << (ibit));