From 0e5fdb2c18545ffa3b41b25e66d5959afed088ee Mon Sep 17 00:00:00 2001 From: skowron Date: Mon, 28 Jun 2004 09:16:23 +0000 Subject: [PATCH] Kinematics reader moved from HBTAN and adapted to AOD schema --- ANALYSIS/ANALYSISLinkDef.h | 2 +- ANALYSIS/AliReaderKineTree.cxx | 188 +++++++++++++++++++++++++++++++++ ANALYSIS/AliReaderKineTree.h | 51 +++++++++ ANALYSIS/libANALYSIS.pkg | 2 +- 4 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 ANALYSIS/AliReaderKineTree.cxx create mode 100644 ANALYSIS/AliReaderKineTree.h diff --git a/ANALYSIS/ANALYSISLinkDef.h b/ANALYSIS/ANALYSISLinkDef.h index ea3704bd01c..d4222b7a5c7 100644 --- a/ANALYSIS/ANALYSISLinkDef.h +++ b/ANALYSIS/ANALYSISLinkDef.h @@ -22,7 +22,7 @@ #pragma link C++ class AliReader+; #pragma link C++ class AliReaderESD+; - +#pragma link C++ class AliReaderKineTree+; #pragma link C++ class AliFlowAnalysis+; diff --git a/ANALYSIS/AliReaderKineTree.cxx b/ANALYSIS/AliReaderKineTree.cxx new file mode 100644 index 00000000000..ad44bf8cd65 --- /dev/null +++ b/ANALYSIS/AliReaderKineTree.cxx @@ -0,0 +1,188 @@ +#include "AliReaderKineTree.h" +//_______________________________________________________________________ +///////////////////////////////////////////////////////////////////////// +// +// class AliReaderKineTree +// +// Reader for Kinematics +// +// Piotr.Skowronski@cern.ch +// +///////////////////////////////////////////////////////////////////////// + +#include +#include + +#include +#include + +#include "AliAOD.h" +#include "AliAODParticle.h" + +ClassImp(AliReaderKineTree) +/**********************************************************/ +const TString AliReaderKineTree::fgkEventFolderName("ReaderKineTree"); + +AliReaderKineTree::AliReaderKineTree(): + fFileName("galice.root"), + fRunLoader(0x0) +{ + //ctor +} +/**********************************************************/ + +AliReaderKineTree::AliReaderKineTree(TString& fname): + fFileName(fname), + fRunLoader(0x0) +{ + //ctor +} +/**********************************************************/ + +AliReaderKineTree::AliReaderKineTree(TObjArray* dirs,const Char_t *filename): + AliReader(dirs), + fFileName(filename), + fRunLoader(0x0) +{ + //ctor +} + +/**********************************************************/ +AliReaderKineTree::AliReaderKineTree(const AliReaderKineTree& in): + AliReader(in), + fFileName(in.fFileName), + fRunLoader(0x0) +{ + //cpy ctor +} + +/**********************************************************/ + +AliReaderKineTree::~AliReaderKineTree() +{ + //dtor + delete fRunLoader; +} +/**********************************************************/ +AliReaderKineTree& AliReaderKineTree::operator=(const AliReaderKineTree& in) +{ +//Assiment operator + if (this == &in) return *this; + AliReader::operator=(in); + delete fRunLoader; + fRunLoader = 0x0; + return * this; +} +/**********************************************************/ + +void AliReaderKineTree::Rewind() +{ +//Rewinds to the beginning + delete fRunLoader; + fRunLoader = 0x0; + fCurrentDir = 0; + fNEventsRead= 0; +} +/**********************************************************/ + +Int_t AliReaderKineTree::ReadNext() +{ + //Reads Kinematics Tree + + Info("Read",""); + if (fEventSim == 0x0) fEventSim = new AliAOD(); + fEventSim->Reset(); + + do //do{}while; is OK even if 0 dirs specified. In that case we try to read from "./" + { + if (fRunLoader == 0x0) + if (OpenNextFile()) + { + fCurrentDir++; + continue; + } + + if (fCurrentEvent == fRunLoader->GetNumberOfEvents()) + { + //read next directory + delete fRunLoader;//close current session + fRunLoader = 0x0;//assure pointer is null + fCurrentDir++;//go to next dir + continue;//directory counter is increased inside in case of error + } + + Info("ReadNext","Reading Event %d",fCurrentEvent); + + fRunLoader->GetEvent(fCurrentEvent); + + AliStack* stack = fRunLoader->Stack(); + if (!stack) + { + Error("ReadNext","Can not get stack for event %d",fCurrentEvent); + continue; + } + Int_t npart = stack->GetNtrack(); + for (Int_t i = 0;iParticle(i); +// if (p->GetFirstMother() >= 0) continue; do not apply with pythia etc + + if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type + //if not take next partilce + + AliAODParticle* part = new AliAODParticle(*p,i); + if(Pass(part)) { delete part; continue;}//check if meets all criteria of any of our cuts + //if it does not delete it and take next good track + fEventSim->AddParticle(part);//put particle in event + } + Info("ReadNext","Read %d particles from event %d (event %d in dir %d).", + fEventSim->GetNumberOfParticles(), + fNEventsRead,fCurrentEvent,fCurrentDir); + + fCurrentEvent++; + fNEventsRead++; + return 0; + }while(fCurrentDir < GetNumberOfDirs());//end of loop over directories specified in fDirs Obj Array + + return 1; +} +/**********************************************************/ + +Int_t AliReaderKineTree::OpenNextFile() +{ +//opens file with kine tree + Info("OpenNextFile","________________________________________________________"); + + const TString& dirname = GetDirName(fCurrentDir); + if (dirname == "") + { + Error("OpenNextFile","Can not get directory name"); + return 1; + } + TString filename = dirname +"/"+ fFileName; + + fRunLoader = AliRunLoader::Open(filename.Data(),fgkEventFolderName,"READ"); + + if ( fRunLoader == 0x0) + { + Error("OpenNextFile","Can't open session from file %s",filename.Data()); + return 1; + } + + if (fRunLoader->GetNumberOfEvents() <= 0) + { + Error("OpenNextFile","There is no events in this directory."); + delete fRunLoader; + fRunLoader = 0x0; + return 2; + } + + if (fRunLoader->LoadKinematics()) + { + Error("OpenNextFile","Error occured while loading kinematics."); + return 3; + } + + fCurrentEvent = 0; + return 0; +} diff --git a/ANALYSIS/AliReaderKineTree.h b/ANALYSIS/AliReaderKineTree.h new file mode 100644 index 00000000000..79c22b35841 --- /dev/null +++ b/ANALYSIS/AliReaderKineTree.h @@ -0,0 +1,51 @@ +#ifndef AliReaderKineTree_H +#define AliReaderKineTree_H +//_______________________________________________________________________ +///////////////////////////////////////////////////////////////////////// +// +// class AliReaderKineTree +// +// Reader for Kinematics +// +// Piotr.Skowronski@cern.ch +// +///////////////////////////////////////////////////////////////////////// +#include "AliReader.h" +#include + +class TFile; +class AliStack; +class AliRunLoader; + +class AliReaderKineTree: public AliReader + { + public: + AliReaderKineTree(); + + AliReaderKineTree(TString&); + AliReaderKineTree(TObjArray*,const Char_t *filename="galice.root"); + AliReaderKineTree(const AliReaderKineTree& in); + + virtual ~AliReaderKineTree(); + + AliReaderKineTree& operator=(const AliReaderKineTree& in); + + void Rewind(); + + Bool_t ReadsRec() const {return kFALSE;} + Bool_t ReadsSim() const {return kTRUE;} + + protected: + Int_t ReadNext();//reads tracks and particles and puts them in runs + Int_t OpenNextFile(); + + TString fFileName;//file name + AliRunLoader* fRunLoader;//!Pointer to loader + + static const TString fgkEventFolderName; //Event folder name that session are mounter + + private: + ClassDef(AliReaderKineTree,2) + }; + +#endif diff --git a/ANALYSIS/libANALYSIS.pkg b/ANALYSIS/libANALYSIS.pkg index d6783949106..e13cad4e8e2 100644 --- a/ANALYSIS/libANALYSIS.pkg +++ b/ANALYSIS/libANALYSIS.pkg @@ -3,7 +3,7 @@ SRCS= AliAOD.cxx AliEventBuffer.cxx \ AliAODPair.cxx AliAODPairCut.cxx \ AliAODParticleCut.cxx AliAODRun.cxx \ AliRunAnalysis.cxx AliAnalysis.cxx AliEventCut.cxx \ - AliReader.cxx AliReaderESD.cxx\ + AliReader.cxx AliReaderESD.cxx AliReaderKineTree.cxx\ AliTrackPoints.cxx AliClusterMap.cxx \ AliD0toKpi.cxx AliD0toKpiAnalysis.cxx AliFlowAnalysis.cxx \ -- 2.39.3