Added class to read good tracks tpc.
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 31 Oct 2004 14:24:32 +0000 (14:24 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 31 Oct 2004 14:24:32 +0000 (14:24 +0000)
JETAN/AliJetEventParticles.cxx
JETAN/AliJetParticlesReaderKineGoodTPC.cxx [new file with mode: 0644]
JETAN/AliJetParticlesReaderKineGoodTPC.h [new file with mode: 0644]
JETAN/JetAnalysisLinkDef.h
JETAN/libJETAN.pkg

index 5a1b63c..5f71981 100644 (file)
@@ -197,6 +197,7 @@ void AliJetEventParticles::AddSignal(const AliJetEventParticles& source)
   fNUQJets=source.NUQTriggerJets();
   fXJet=source.GetXJet();
   fYJet=source.GetXJet();
+  fEventNr=source.GetEventNr();
 
   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
   for (Int_t i = 0; i < 10; i++) 
diff --git a/JETAN/AliJetParticlesReaderKineGoodTPC.cxx b/JETAN/AliJetParticlesReaderKineGoodTPC.cxx
new file mode 100644 (file)
index 0000000..ff43682
--- /dev/null
@@ -0,0 +1,138 @@
+// $Id$
+
+//_______________________________________________________________________
+/////////////////////////////////////////////////////////////////////////
+//
+// class AliJetParticlesReaderKineGoodTPC
+//
+// Reader for Good TPC tracks
+//
+// loizides@ikf.uni-frankfurt.de
+//
+/////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+#include <TFile.h>
+#include <TString.h>
+#include <TParticle.h>
+#include <TLorentzVector.h>
+#include <AliRunLoader.h>
+#include <AliStack.h>
+#include <AliHeader.h>
+#include <AliGenEventHeader.h>
+#include <AliGenPythiaEventHeader.h>
+#include <AliGenHijingEventHeader.h>
+#include "AliJetParticle.h"
+#include "AliJetEventParticles.h"
+#include "AliJetParticlesReaderKineGoodTPC.h"
+
+ClassImp(AliJetParticlesReaderKineGoodTPC)
+
+AliJetParticlesReaderKineGoodTPC::AliJetParticlesReaderKineGoodTPC() :
+  AliJetParticlesReader(),
+  fFileName("good_tracks_tpc"),
+  fInput(0)
+{
+  //constructor
+}
+
+AliJetParticlesReaderKineGoodTPC::AliJetParticlesReaderKineGoodTPC(TString& fname) :
+  AliJetParticlesReader(),
+  fFileName(fname),
+  fInput(0)
+{
+  //constructor
+}
+
+AliJetParticlesReaderKineGoodTPC::AliJetParticlesReaderKineGoodTPC(TObjArray* dirs, const Char_t *filename):
+  AliJetParticlesReader(dirs),
+  fFileName(filename),
+  fInput(0)
+{
+  //constructor
+}
+
+AliJetParticlesReaderKineGoodTPC::~AliJetParticlesReaderKineGoodTPC()
+{
+  //destructor
+  if(fInput) delete fInput;
+}
+
+void AliJetParticlesReaderKineGoodTPC::Rewind()
+{
+  //Rewinds to the beginning
+  if(fInput) delete fInput;
+  fInput       = 0;
+  fCurrentDir  = 0;
+  fNEventsRead = 0;  
+}
+
+Int_t AliJetParticlesReaderKineGoodTPC::ReadNext()
+{
+  //Reads good_tpc_tracks file
+  if((!fOwner) || (fEventParticles == 0)) 
+    fEventParticles = new AliJetEventParticles();
+  else
+     fEventParticles->Reset();
+
+  while(fCurrentDir < GetNumberOfDirs())
+    { 
+      if(!OpenFile(fCurrentDir)) 
+      { 
+       delete fInput; //close current session
+       fInput = 0;    //assure pointer is null
+       fCurrentDir++;
+       continue;
+      }
+    
+      Info("ReadNext","Reading Event %d",fCurrentEvent);
+
+      Int_t label,code;
+      Float_t px,py,pz,x,y,z;
+      Int_t i=0;
+      while (*fInput>>label>>code>>px>>py>>pz>>x>>y>>z)
+      {
+       const Float_t kp2=px*px+py*py+pz*pz;
+       if(kp2<1e-3)  continue;
+       const Float_t kpt=TMath::Sqrt(px*px+py*py);
+       const Float_t kp=TMath::Sqrt(kp2);
+       const Float_t keta=0.5*TMath::Log((kp+pz+1e-30)/(kp-pz+1e-30)); 
+       const Float_t kphi=TMath::Pi()+TMath::ATan2(-py,-px);
+       //cout << i << " " << label << " " << px << " " << py << " " << pz << endl;
+       if(IsAcceptedParticle(kpt,kphi,keta))
+         fEventParticles->AddParticle(px,py,pz,kp,i++,label,code,kpt,kphi,keta);
+      }
+
+      fCurrentEvent++;
+      fNEventsRead++;
+      return kTRUE;
+
+    }
+  return kFALSE;
+}
+
+Int_t AliJetParticlesReaderKineGoodTPC::OpenFile(Int_t n)
+{
+  if(fInput){ //change here if you want to 
+              //support more than one good file per dir
+    return kFALSE;
+  }
+
+  const TString& dirname = GetDirName(n);
+  if (dirname == "")
+    { 
+      Error("OpenNextFile","Can't get directory name with index %d",n);
+      return kFALSE;
+    }
+
+  TString filename = dirname +"/"+ fFileName;
+  fInput=new ifstream(filename);
+  if ( fInput->is_open() == 0)
+    {
+      Error("OpenNextFile","Can't open session from file %s",filename.Data());
+      return kFALSE;
+    }
+
+  fCurrentEvent = 0;
+  return kTRUE;
+}
diff --git a/JETAN/AliJetParticlesReaderKineGoodTPC.h b/JETAN/AliJetParticlesReaderKineGoodTPC.h
new file mode 100644 (file)
index 0000000..2a0d087
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef ALIJETPARTICLESREADERKINEGOODTPC_H
+#define ALIJETPARTICLESREADERKINEGOODTPC_H
+
+/* $Id$ */
+
+//_______________________________________________________________________
+/////////////////////////////////////////////////////////////////////////
+//
+// class AliJetParticlesReaderKineGoodTPC
+//
+// Reader for Good TPC tracks (generated by macron in TPC)
+//
+// loizides@ikf.uni-frankfurt.de
+//
+/////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+#include <TString.h>
+#include "AliJetParticlesReader.h"
+
+class AliJetParticlesReaderKineGoodTPC: public AliJetParticlesReader
+{
+  public:
+  AliJetParticlesReaderKineGoodTPC();
+  AliJetParticlesReaderKineGoodTPC(TString&);
+  AliJetParticlesReaderKineGoodTPC(TObjArray*, const Char_t *filename="good_tracks_tpc");
+  virtual ~AliJetParticlesReaderKineGoodTPC();
+
+  void Rewind();
+
+  protected:
+
+  Int_t  ReadNext();
+  Int_t  OpenFile(Int_t n);
+  Bool_t IsAcceptedParticle(Float_t pt, Float_t phi, Float_t eta) const;
+   
+  TString   fFileName;  //file name 
+  ifstream* fInput;     //!pointer to file
+
+  ClassDef(AliJetParticlesReaderKineGoodTPC,1)
+};
+
+inline Bool_t AliJetParticlesReaderKineGoodTPC::IsAcceptedParticle(Float_t pt, Float_t phi, Float_t eta) const
+{
+  if((pt<fPtMin)||(pt>fPtMax)) return kFALSE;
+  if((eta<fEtaMin)||(eta>fEtaMax)) return kFALSE;
+  if((phi<fPhiMin)||(phi>fPhiMax)) return kFALSE;
+
+  return kTRUE;
+}
+#endif
index 353c736..b174c2d 100644 (file)
@@ -11,5 +11,6 @@
 #pragma link C++ class AliJetParticlesReader+;
 #pragma link C++ class AliJetParticlesReaderESD+;
 #pragma link C++ class AliJetParticlesReaderKine+;
+#pragma link C++ class AliJetParticlesReaderKineGoodTPC+;
 #pragma link C++ class AliJetParticlesReaderHLT+;
 #endif
index fe60857..ab962ab 100644 (file)
@@ -2,7 +2,8 @@
 
 SRCS = AliJetParticle.cxx AliJet.cxx AliJetEvent.cxx AliJetEventParticles.cxx \
        AliJetParticlesReader.cxx AliJetParticlesReaderESD.cxx \
-       AliJetParticlesReaderKine.cxx AliJetParticlesReaderHLT.cxx
+       AliJetParticlesReaderKine.cxx AliJetParticlesReaderHLT.cxx \
+       AliJetParticlesReaderKineGoodTPC.cxx
 
 HDRS:= $(SRCS:.cxx=.h)