]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliJetParticlesReaderESD.cxx
Bugfix.
[u/mrichter/AliRoot.git] / JETAN / AliJetParticlesReaderESD.cxx
index b6b9e1765ae96f721cf42de17e9e795600ba2b10..30394dd38669409c96df4443e73f0614386789f8 100644 (file)
@@ -11,6 +11,7 @@
 //                                                                  //
 //////////////////////////////////////////////////////////////////////
 
+#include <Riostream.h>
 #include <TMath.h>
 #include <TPDGCode.h>
 #include <TString.h>
@@ -70,85 +71,6 @@ AliJetParticlesReaderESD::~AliJetParticlesReaderESD()
   if(fFile) delete fFile;
 }
 
-
-Int_t AliJetParticlesReaderESD::ReadNext()
-{
-  //reads next event from fFile
-
-  do   // is OK even if 0 dirs specified, 
-    {  // in that case we try to read from "./"
-      if (fFile == 0)
-       {
-         fFile = OpenFile(fCurrentDir);
-         if (fFile == 0)
-           {
-             Error("ReadNext","Can't get fFile for dir no. %d",fCurrentDir);
-             fCurrentDir++;
-             continue;
-           }
-     
-         fCurrentEvent = 0;
-         //fFile->GetListOfKeys()->Print();
-         
-         if(fTree) delete fTree;
-         fTree = dynamic_cast<TTree*>(fFile->Get("esdTree"));
-         if(fTree)
-           fTree->SetBranchAddress("ESD",&fESD);
-         else
-           fKeyIterator = new TIter(fFile->GetListOfKeys());  
-       } 
-
-      if(fTree)
-       {
-         if(AliKalmanTrack::GetConvConst()<=0.)
-           AliKalmanTrack::SetMagneticField(0.5);
-         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<AliESD*>(fFile->Get(esdname));
-         if (fESD == 0)
-           {
-             Info("ReadNext","Can't 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(fESD);
-      fCurrentEvent++;
-      fNEventsRead++;
-      return kTRUE;//success -> read one event
-    }  while(fCurrentDir < GetNumberOfDirs());
-      //end of loop over directories specified in fDirs Obj Array  
-  return kFALSE; //no more directories to read
-}
-
 /**********************************************************/
 
 Int_t AliJetParticlesReaderESD::ReadESD(AliESD* esd)
@@ -216,7 +138,7 @@ Int_t AliJetParticlesReaderESD::ReadESD(AliESD* esd)
         continue;
       }
 
-     if ((kesdtrack->GetStatus() & fPassFlag) != fPassFlag)
+     if ((kesdtrack->GetStatus() & fPassFlag)) // != fPassFlag)
       {
        Info("ReadNext","Particle skipped: %ud.",kesdtrack->GetStatus());
         continue;
@@ -271,6 +193,86 @@ void AliJetParticlesReaderESD::Rewind()
 
 /**********************************************************/
 
+Int_t AliJetParticlesReaderESD::ReadNext()
+{
+  //reads next event from fFile
+
+  do   // is OK even if 0 dirs specified, 
+    {  // in that case we try to read from "./"
+      if (fFile == 0)
+       {
+         fFile = OpenFile(fCurrentDir);
+         if (fFile == 0)
+           {
+             Error("ReadNext","Can't get fFile for dir no. %d",fCurrentDir);
+             fCurrentDir++;
+             continue;
+           }
+     
+         fCurrentEvent = 0;
+         //fFile->GetListOfKeys()->Print();
+         
+         if(fTree) delete fTree;
+         fTree = dynamic_cast<TTree*>(fFile->Get("esdTree"));
+         if(fTree)
+           fTree->SetBranchAddress("ESD",&fESD);
+         else
+           fKeyIterator = new TIter(fFile->GetListOfKeys());  
+       } 
+
+      if(fTree)
+       {
+         if(AliKalmanTrack::GetConvConst()<=0.)
+           AliKalmanTrack::SetMagneticField(0.5);
+         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<AliESD*>(fFile->Get(esdname));
+         if (fESD == 0)
+           {
+             Info("ReadNext","Can't 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(fESD);
+      fCurrentEvent++;
+      fNEventsRead++;
+      return kTRUE;//success -> read one event
+    }  while(fCurrentDir < GetNumberOfDirs());
+      //end of loop over directories specified in fDirs Obj Array  
+  return kFALSE; //no more directories to read
+}
+
+/**********************************************************/
+
 TFile* AliJetParticlesReaderESD::OpenFile(Int_t n)
 {
   //opens fFile with kine tree