From 5d60c8f946bf3aaf6d252b95d20ed5a07a3d6285 Mon Sep 17 00:00:00 2001 From: loizides Date: Mon, 14 Jun 2004 17:03:59 +0000 Subject: [PATCH] Added ESD reader for HLT tracks. Also added dynamic switch between reading of ESD objects in file or ESD tree. --- JETAN/AliJetParticlesReader.cxx | 210 ++--------------------------- JETAN/AliJetParticlesReader.h | 16 ++- JETAN/AliJetParticlesReaderESD.cxx | 86 +++++++----- JETAN/AliJetParticlesReaderESD.h | 33 ++--- JETAN/AliJetParticlesReaderHLT.cxx | 135 +++++++++++++++++++ JETAN/AliJetParticlesReaderHLT.h | 35 +++++ JETAN/JetAnalysisLinkDef.h | 1 + JETAN/libJETAN.pkg | 2 +- 8 files changed, 261 insertions(+), 257 deletions(-) create mode 100644 JETAN/AliJetParticlesReaderHLT.cxx create mode 100644 JETAN/AliJetParticlesReaderHLT.h diff --git a/JETAN/AliJetParticlesReader.cxx b/JETAN/AliJetParticlesReader.cxx index 8e443483d22..1e975d35f1c 100644 --- a/JETAN/AliJetParticlesReader.cxx +++ b/JETAN/AliJetParticlesReader.cxx @@ -2,15 +2,19 @@ //_________________________________________________________________________ /////////////////////////////////////////////////////////////////////////// -// -// class AliJetParticlesReader -// -// loizides@ikf.uni-frankfurt.de +// // +// class AliJetParticlesReader // +// // +// This reader reads tracks from Event Summary Data // +// taken from Piotr.Skowronski@cern.ch // +// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html // +// // +// loizides@ikf.uni-frankfurt.de // /////////////////////////////////////////////////////////////////////////// +#include #include #include -#include #include #include @@ -34,6 +38,7 @@ AliJetParticlesReader::AliJetParticlesReader() fEtaMin(-1),fEtaMax(1), fPhiMin(0),fPhiMax(2*TMath::Pi()) { + //Constructor } AliJetParticlesReader::AliJetParticlesReader(TObjArray *dirs) @@ -54,13 +59,13 @@ AliJetParticlesReader::AliJetParticlesReader(TObjArray *dirs) AliJetParticlesReader::~AliJetParticlesReader() { + //Constructor if((fOwner) && (fEventParticles)) delete fEventParticles; } Int_t AliJetParticlesReader::Next() { //moves to next event - //if asked to read up to event nb. fLast, //and it is overcome, report no more events if ((fNEventsRead > fLast) && (fLast > 0) ) return kFALSE; @@ -79,7 +84,6 @@ Int_t AliJetParticlesReader::Next() TString& AliJetParticlesReader::GetDirName(Int_t entry) { //returns directory name of entry to read - TString* retval;//return value if (fDirs == 0) { @@ -117,195 +121,3 @@ TString& AliJetParticlesReader::GetDirName(Int_t entry) return dir->String(); } - -#if 0 -/*************************************************************************************/ - -void AliHBTReader::AddParticleCut(AliHBTParticleCut* cut) -{ - //sets the new cut - - if (!cut) //if cut is NULL return with error - { - Error("AddParticleType","NULL pointers are not accepted any more.\nIf You want to accept all particles of this type, set an empty cut "); - return; - } - AliHBTParticleCut *c = (AliHBTParticleCut*)cut->Clone(); - fCuts->Add(c); -} -/********************************************************************/ - -AliHBTEvent* AliHBTReader::GetParticleEvent(Int_t n) - { - //returns Nth event with simulated particles - if (ReadsParticles() == kFALSE) - { - Error("GetParticleEvent","This reader is not able to provide simulated particles."); - return 0; - } - - if (!fIsRead) - { - if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun(); - if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun(); - - if (Read(fParticles,fTracks)) - { - Error("GetParticleEvent","Error in reading"); - return 0x0; - } - else fIsRead = kTRUE; - } - return fParticles->GetEvent(n); - } -/********************************************************************/ - -AliHBTEvent* AliHBTReader::GetTrackEvent(Int_t n) - { - //returns Nth event with reconstructed tracks - if (ReadsTracks() == kFALSE) - { - Error("GetTrackEvent","This reader is not able to provide recosntructed tracks."); - return 0; - } - if (!fIsRead) - { - if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun(); - if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun(); - - if(Read(fParticles,fTracks)) - { - Error("GetTrackEvent","Error in reading"); - return 0x0; - } - else fIsRead = kTRUE; - } - return fTracks->GetEvent(n); - } -/********************************************************************/ - -Int_t AliHBTReader::GetNumberOfPartEvents() - { - //returns number of events of particles - if (ReadsParticles() == kFALSE) - { - Error("GetNumberOfPartEvents","This reader is not able to provide simulated particles."); - return 0; - } - - if (!fIsRead) - { - if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun(); - if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun(); - - if (Read(fParticles,fTracks)) - { - Error("GetNumberOfPartEvents","Error in reading"); - return 0; - } - else fIsRead = kTRUE; - } - return fParticles->GetNumberOfEvents(); - } -/********************************************************************/ - -Int_t AliHBTReader::GetNumberOfTrackEvents() - { - //returns number of events of tracks - if (ReadsTracks() == kFALSE) - { - Error("GetNumberOfTrackEvents","This reader is not able to provide recosntructed tracks."); - return 0; - } - if (!fIsRead) - { - if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun(); - if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun(); - - if(Read(fParticles,fTracks)) - { - Error("GetNumberOfTrackEvents","Error in reading"); - return 0; - } - else fIsRead = kTRUE; - } - return fTracks->GetNumberOfEvents(); - } -/********************************************************************/ - -Int_t AliHBTReader::Read(AliHBTRun* particles, AliHBTRun *tracks) -{ - //reads data and puts put to the particles and tracks objects - //reurns 0 if everything is OK - // - Info("Read",""); - - if ( ReadsParticles() && (particles == 0x0) ) //check if an object is instatiated - { - Error("Read"," particles object must be instatiated before passing it to the reader"); - return 1; - } - if ( ReadsTracks() && (tracks == 0x0) ) //check if an object is instatiated - { - Error("Read"," tracks object must be instatiated before passing it to the reader"); - return 1; - } - - if (ReadsParticles()) particles->Reset();//clear runs == delete all old events - if (ReadsTracks()) tracks->Reset(); - - Rewind(); - - Int_t i = 0; - while(Next() == kFALSE) - { - if (ReadsTracks()) tracks->SetEvent(i,fTracksEvent); - if (ReadsParticles()) particles->SetEvent(i,fParticlesEvent); - i++; - } - return 0; -} -/*************************************************************************************/ - -Bool_t AliHBTReader::Pass(AliHBTParticle* p) -{ - //Method examines whether particle meets all cut and particle type criteria - - if(p==0x0)//of corse we not pass NULL pointers - { - Warning("Pass()","No Pasaran! We never accept NULL pointers"); - return kTRUE; - } - //if no particle is specified, we pass all particles - //excluding NULL pointers, of course - if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles - for(Int_t i=0; iGetEntriesFast(); i++) - { - AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i)); - if(!cut.Pass(p)) return kFALSE; //accepted - } - - return kTRUE;//not accepted -} -/*************************************************************************************/ - -Bool_t AliHBTReader::Pass(Int_t pid) -{ -//this method checks if any of existing cuts accepts this pid particles -//or any cuts accepts all particles - - if(pid == 0) - return kTRUE; - - if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles - - for(Int_t i=0; iGetEntriesFast(); i++) - { - AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i)); - //if some of cuts accepts all particles or some accepts particles of this type, accept - if ( (cut.GetPID() == 0) || (cut.GetPID() == pid) ) return kFALSE; - } - return kTRUE; -} - -#endif diff --git a/JETAN/AliJetParticlesReader.h b/JETAN/AliJetParticlesReader.h index 8aec9eb58bd..029fff1258e 100644 --- a/JETAN/AliJetParticlesReader.h +++ b/JETAN/AliJetParticlesReader.h @@ -5,10 +5,15 @@ //_________________________________________________________________________ /////////////////////////////////////////////////////////////////////////// -// -// class AliJetReader -// -// loizides@ikf.uni-frankfurt.de +// // +// class AliJetReader // +// File reader for ESD // +// // +// This reader reads tracks from Event Summary Data // +// taken from Piotr.Skowronski@cern.ch // +// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html // +// // +// loizides@ikf.uni-frankfurt.de // /////////////////////////////////////////////////////////////////////////// #include @@ -53,7 +58,8 @@ class AliJetParticlesReader: public TNamed protected: virtual Int_t ReadNext() = 0; //this methods reads next event and - //put result in fParticles + //put result in fParticles + TString& GetDirName(Int_t entry); AliJetEventParticles* fEventParticles; //array with read particles diff --git a/JETAN/AliJetParticlesReaderESD.cxx b/JETAN/AliJetParticlesReaderESD.cxx index 68f0568aabc..dbf28dd8bfd 100644 --- a/JETAN/AliJetParticlesReaderESD.cxx +++ b/JETAN/AliJetParticlesReaderESD.cxx @@ -29,7 +29,9 @@ ClassImp(AliJetParticlesReaderESD) AliJetParticlesReaderESD::AliJetParticlesReaderESD(const Char_t* esdfilename) : AliJetParticlesReader(), fESDFileName(esdfilename), + fESD(0), fFile(0), + fTree(0), fKeyIterator(0), fPassFlag(AliESDtrack::kTPCrefit) { @@ -43,7 +45,9 @@ AliJetParticlesReaderESD::AliJetParticlesReaderESD( const Char_t* esdfilename) : AliJetParticlesReader(dirs), fESDFileName(esdfilename), + fESD(0), fFile(0), + fTree(0), fKeyIterator(0), fPassFlag(AliESDtrack::kTPCrefit) { @@ -56,6 +60,8 @@ AliJetParticlesReaderESD::~AliJetParticlesReaderESD() { //desctructor if(fFile) delete fFile; + if(fESD) delete fESD; + if(fTree) delete fTree; if(fKeyIterator) delete fKeyIterator; } @@ -76,47 +82,63 @@ Int_t AliJetParticlesReaderESD::ReadNext() continue; } - fKeyIterator = new TIter(fFile->GetListOfKeys()); fCurrentEvent = 0; - //fFile->Dump(); //fFile->GetListOfKeys()->Print(); + + if(fTree) delete fTree; + fTree = dynamic_cast(fFile->Get("esdTree")); + if(fTree) + fTree->SetBranchAddress("ESD",&fESD); + else + fKeyIterator = new TIter(fFile->GetListOfKeys()); } - TKey* key = (TKey*)fKeyIterator->Next(); - if (key == 0) + if(fTree) { - fCurrentDir++; - delete fKeyIterator; - fKeyIterator = 0; - delete fFile; //we have to assume there are no more ESD objects in the fFile - fFile = 0; - continue; + if(fCurrentEvent>=fTree->GetEntries()) + { + fCurrentDir++; + delete fTree; + fTree = 0; + delete fFile; + fFile = 0; + continue; + } + fTree->GetEvent(fCurrentEvent); + } + else + { // "old" way via ESD objects stored in root file + TKey* key = (TKey*)fKeyIterator->Next(); + if (key == 0) + { + fCurrentDir++; + delete fKeyIterator; + fKeyIterator = 0; + delete fFile; //we have to assume there are no more ESD objects in the fFile + fFile = 0; + continue; + } + TString esdname = "ESD"; + esdname+=fCurrentEvent; + if(fESD) delete fESD; + fESD = dynamic_cast(fFile->Get(esdname)); + if (fESD == 0) + { + Info("ReadNext","Can not find AliESD object named %s",esdname.Data()); + fCurrentDir++; + delete fKeyIterator; + fKeyIterator = 0; + delete fFile;//we have to assume there is no more ESD objects in the fFile + fFile = 0; + continue; + } } - - TString esdname = "ESD"; - esdname+=fCurrentEvent; - AliESD* esd = dynamic_cast(fFile->Get(esdname)); - if (esd == 0) - { - //Info("ReadNext","This key is not an AliESD object %s",key->GetName()); - Info("ReadNext","Can not find AliESD object named %s",esdname.Data()); - - fCurrentDir++; - delete fKeyIterator; - fKeyIterator = 0; - delete fFile;//we have to assume there is no more ESD objects in the fFile - fFile = 0; - continue; - } - - ReadESD(esd); - + ReadESD(fESD); fCurrentEvent++; fNEventsRead++; - delete esd; return kTRUE;//success -> read one event } while(fCurrentDir < GetNumberOfDirs()); - //end of loop over directories specified in fDirs Obj Array + //end of loop over directories specified in fDirs Obj Array return kFALSE; //no more directories to read } @@ -178,7 +200,7 @@ Int_t AliJetParticlesReaderESD::ReadESD(AliESD* esd) if ((kesdtrack->GetStatus() & fPassFlag) == kFALSE) { - Info("ReadNext","Particle skipped."); + Info("ReadNext","Particle skipped: %ud.",kesdtrack->GetStatus()); continue; } diff --git a/JETAN/AliJetParticlesReaderESD.h b/JETAN/AliJetParticlesReaderESD.h index a82cba59122..3458998f7c5 100644 --- a/JETAN/AliJetParticlesReaderESD.h +++ b/JETAN/AliJetParticlesReaderESD.h @@ -4,13 +4,13 @@ //___________________________________________________________________________ ///////////////////////////////////////////////////////////////////////////// // // -// Multi file reader for ESD // +// File reader for ESD // // // // This reader reads tracks from Event Summary Data // -// do not read particles // -// Piotr.Skowronski@cern.ch // +// taken from Piotr.Skowronski@cern.ch // // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html // // // +// loizides@ikf.uni-frankfurt.de // ///////////////////////////////////////////////////////////////////////////// #include @@ -18,6 +18,7 @@ #include "AliJetParticlesReader.h" class TFile; +class TTree; class AliESD; class AliJetParticlesReaderESD: public AliJetParticlesReader @@ -27,33 +28,25 @@ class AliJetParticlesReaderESD: public AliJetParticlesReader AliJetParticlesReaderESD(TObjArray* dirs,const Char_t* esdfilename = "AliESDs.root"); void SetCompareFlag(ULong_t f){fPassFlag=f;} - void SetCompareFlagTPC() - {fPassFlag=AliESDtrack::kTPCrefit & AliESDtrack::kTPCrefit;} - -#if 0 - kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008, - kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080, - kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800, - kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000, - kPHOSpid=0x10000, kRICHpid=0x20000, - kTRDStop=0x20000000, - kESDpid=0x40000000, - kTIME=0x80000000 -#endif + void SetCompareFlagTPC() {fPassFlag=AliESDtrack::kTPCrefit;} virtual ~AliJetParticlesReaderESD(); - //Int_t Next(); + //Int_t Next(); //in base class void Rewind(); + const AliESD* GetCurrentESD() const {return fESD;} + protected: - Int_t ReadESD(AliESD* esd); //read esd file/objects - Int_t ReadNext(); //read the next event - TFile* OpenFile(Int_t evno); //opens file to be read for given event + virtual Int_t ReadESD(AliESD* esd); //read esd file/objects + Int_t ReadNext(); //read the next event + TFile* OpenFile(Int_t evno); //opens file to be read for given event Bool_t IsAcceptedParticle(Float_t px, Float_t py, Float_t pz) const; TString fESDFileName; // name of the file with tracks + AliESD *fESD; //! pointer to current esd object TFile* fFile; //! pointer to current ESD file + TTree* fTree; //! pointer to current tree with ESD objects TIter* fKeyIterator; //! key iterator through file ULong_t fPassFlag; //flag to compare esd flag with diff --git a/JETAN/AliJetParticlesReaderHLT.cxx b/JETAN/AliJetParticlesReaderHLT.cxx new file mode 100644 index 00000000000..509e3d1d7a7 --- /dev/null +++ b/JETAN/AliJetParticlesReaderHLT.cxx @@ -0,0 +1,135 @@ +// $Id$ + +//___________________________________________________________________________ +///////////////////////////////////////////////////////////////////////////// +// // +// File reader for HLT tracks ESD // +// // +// loizides@ikf.uni-frankfurt.de // +///////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "AliJetParticlesReaderHLT.h" + +ClassImp(AliJetParticlesReaderHLT) + +AliJetParticlesReaderHLT::AliJetParticlesReaderHLT(Bool_t bMapper, const Char_t* esdfilename) : + AliJetParticlesReaderESD(esdfilename), + fTrackerType(bMapper) +{ + //constructor +} + +/********************************************************************/ + +AliJetParticlesReaderHLT::AliJetParticlesReaderHLT( + Bool_t bMapper, + TObjArray* dirs, + const Char_t* esdfilename) : + AliJetParticlesReaderESD(dirs,esdfilename), + fTrackerType(bMapper) +{ + //constructor +} + +/********************************************************************/ + +AliJetParticlesReaderHLT::~AliJetParticlesReaderHLT() +{ + //desctructor +} + +Int_t AliJetParticlesReaderHLT::ReadESD(AliESD* esd) +{ + //Reads one ESD + + if (esd == 0) + { + Error("ReadESD","ESD is NULL"); + return kFALSE; + } + + Info("ReadESD","Reading Event %d",fCurrentEvent); + if((!fOwner) || (fEventParticles==0)) + fEventParticles = new AliJetEventParticles(); + + Double_t vertexpos[3];//vertex position + const AliESDVertex* kvertex = esd->GetVertex(); + if (kvertex == 0) + { + Info("ReadESD","ESD returned NULL pointer to vertex - assuming (0.0,0.0,0.0)"); + vertexpos[0] = 0.0; + vertexpos[1] = 0.0; + vertexpos[2] = 0.0; + } + else + { + kvertex->GetXYZ(vertexpos); + } + + fEventParticles->SetVertex(vertexpos[0],vertexpos[1],vertexpos[2]); + + if(fTrackerType){ + const Int_t kntr =esd->GetNumberOfHLTHoughTracks(); + Info("ReadESD","Found %d conformal tracks.",kntr); + for (Int_t i = 0;iGetHLTConfMapTrack(i); + + if (kesdtrack == 0) + { + Error("ReadESD","Can not get track %d", i); + continue; + } + + //const Float_t kpid=kesdtrack->GetPID(); + //const Int_t knhits=kesdtrack->GetNHits(); + const Float_t kpx=kesdtrack->GetPx(); + const Float_t kpy=kesdtrack->GetPy(); + const Float_t kpz=kesdtrack->GetPz(); + const Float_t kpt=kesdtrack->GetPt(); + const Float_t kp=TMath::Sqrt(kpz*kpz+kpt*kpt); + const Float_t keta=0.5*TMath::Log((kp+kpz+1e-30)/(kp-kpz+1e-30)); + const Float_t kphi=TMath::Pi()+TMath::ATan2(-kpy,-kpx); + + if(IsAcceptedParticle(kpt,kphi,keta)) + fEventParticles->AddParticle(kpx,kpy,kpz,kp,i,kesdtrack->GetMCid(),kpt,kphi,keta); + + } //loop over conf tracks + } else { + const Int_t kntr=esd->GetNumberOfHLTHoughTracks(); + Info("ReadESD","Found %d hough tracks.",kntr); + + for (Int_t i = 0;iGetHLTHoughTrack(i); + + if (kesdtrack == 0) + { + Error("ReadESD","Can not get track %d", i); + continue; + } + + //const Float_t kweight=kesdtrack->GetWeight(); + const Float_t kpx=kesdtrack->GetPx(); + const Float_t kpy=kesdtrack->GetPy(); + const Float_t kpz=kesdtrack->GetPz(); + + const Float_t kpt=kesdtrack->GetPt(); + const Float_t kp=TMath::Sqrt(kpz*kpz+kpt*kpt); + const Float_t keta=0.5*TMath::Log((kp+kpz+1e-30)/(kp-kpz+1e-30)); + const Float_t kphi=TMath::Pi()+TMath::ATan2(-kpy,-kpx); + + if(IsAcceptedParticle(kpt,kphi,keta)) + fEventParticles->AddParticle(kpx,kpy,kpz,kp,i,kesdtrack->GetMCid(),kpt,kphi,keta); + } //loop over hough tracks + } + return kTRUE; +} diff --git a/JETAN/AliJetParticlesReaderHLT.h b/JETAN/AliJetParticlesReaderHLT.h new file mode 100644 index 00000000000..01d3dc67559 --- /dev/null +++ b/JETAN/AliJetParticlesReaderHLT.h @@ -0,0 +1,35 @@ +#ifndef ALIJETPARTICLESREADERHLT_H +#define ALIJETPARTICLESREADERHLT_H + +//___________________________________________________________________________ +///////////////////////////////////////////////////////////////////////////// +// // +// File reader for HLT tracks ESD // +// // +// loizides@ikf.uni-frankfurt.de // +///////////////////////////////////////////////////////////////////////////// + +//#include +//#include +#include "AliJetParticlesReaderESD.h" + +//class TFile; +//class AliESD; + +class AliJetParticlesReaderHLT: public AliJetParticlesReaderESD +{ + public: + AliJetParticlesReaderHLT(Bool_t bMapper, const Char_t* esdfilename = "AliESDs.root") ; + AliJetParticlesReaderHLT(Bool_t bMapper, TObjArray* dirs, const Char_t* esdfilename = "AliESDs.root"); + + virtual ~AliJetParticlesReaderHLT(); + + protected: + Int_t ReadESD(AliESD* esd); //read esd file/objects + + Bool_t fTrackerType; //track type: 0==Conformal Tracker, 1==Hough Tracker + + ClassDef(AliJetParticlesReaderHLT,1) // +}; + +#endif diff --git a/JETAN/JetAnalysisLinkDef.h b/JETAN/JetAnalysisLinkDef.h index a462ad48cf7..353c736234e 100644 --- a/JETAN/JetAnalysisLinkDef.h +++ b/JETAN/JetAnalysisLinkDef.h @@ -11,4 +11,5 @@ #pragma link C++ class AliJetParticlesReader+; #pragma link C++ class AliJetParticlesReaderESD+; #pragma link C++ class AliJetParticlesReaderKine+; +#pragma link C++ class AliJetParticlesReaderHLT+; #endif diff --git a/JETAN/libJETAN.pkg b/JETAN/libJETAN.pkg index d2df92002fa..20d732a91e7 100644 --- a/JETAN/libJETAN.pkg +++ b/JETAN/libJETAN.pkg @@ -2,7 +2,7 @@ SRCS = AliJetParticle.cxx AliJet.cxx AliJetEvent.cxx AliJetEventParticles.cxx \ AliJetParticlesReader.cxx AliJetParticlesReaderESD.cxx \ - AliJetParticlesReaderKine.cxx + AliJetParticlesReaderKine.cxx AliJetParticlesReaderHLT.cxx HDRS:= $(SRCS:.cxx=.h) -- 2.39.3