]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliReader.cxx
Obsolete files removed.
[u/mrichter/AliRoot.git] / ANALYSIS / AliReader.cxx
index 41bbf115c8bb108bb7fb9c9ac66c83c0a55cda80..434f747f8c20ae3d3c9c65679e2b4e07779c78dc 100644 (file)
@@ -56,6 +56,8 @@
 #include <TRandom.h>
 #include <TH1.h>
 
+#include <TGliteXmlEventlist.h>
+
 #include "AliAODParticleCut.h"
 #include "AliAOD.h"
 #include "AliAODRun.h"
@@ -66,6 +68,7 @@ ClassImp(AliReader)
 /*************************************************************************************/
 
 AliReader::AliReader():
+ fEventList(0x0),
  fCuts(new TObjArray()),
  fDirs(0x0),
  fCurrentEvent(0),
@@ -87,6 +90,7 @@ AliReader::AliReader():
 /*************************************************************************************/
 
 AliReader::AliReader(TObjArray* dirs):
+ fEventList(0x0),
  fCuts(new TObjArray()),
  fDirs(dirs),
  fCurrentEvent(0),
@@ -108,6 +112,7 @@ AliReader::AliReader(TObjArray* dirs):
 /*************************************************************************************/
 AliReader::AliReader(const AliReader& in):
  TNamed(in),
+ fEventList((in.fEventList)?(TGliteXmlEventlist*)in.fEventList->Clone():0x0),
  fCuts((in.fCuts)?(TObjArray*)in.fCuts->Clone():0x0),
  fDirs((in.fDirs)?(TObjArray*)in.fDirs->Clone():0x0),
  fCurrentEvent(0),
@@ -138,6 +143,7 @@ AliReader::~AliReader()
  delete fEventSim;
  delete fEventRec;
  delete fTrackCounter;
+ delete fEventList;
 }
 /*************************************************************************************/
 
@@ -171,7 +177,7 @@ Int_t AliReader::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 kTRUE;
+  if ((fNEventsRead >= fLast) && (fLast > 0) ) return kTRUE;
   
   if (fTrackCounter == 0x0)//create Track Counter
    {
@@ -388,28 +394,38 @@ Bool_t  AliReader::Rejected(Int_t pid)
 }
 /*************************************************************************************/
 
-TString& AliReader::GetDirName(Int_t entry)
+TString AliReader::GetDirName(Int_t entry)
 {
 //returns directory name of next one to read
-  TString* retval;//return value
+  TString  retval;//return value
   if (fDirs ==  0x0)
-   {
-     retval = new TString(".");
-     return *retval;
+   { 
+     if (entry == 0)
+      {
+       retval = ".";
+       return retval;
+      }
+     else
+      {
+       return retval;
+      }  
    }
-
-  if ( (entry>fDirs->GetEntries()) || (entry<0))//if out of bounds return empty string
+  
+  
+  if ( (entry >= fDirs->GetEntries()) || (entry < 0))//if out of bounds return empty string
    {                                            //note that entry==0 is accepted even if array is empty (size=0)
-     Error("GetDirName","Name out of bounds");
-     retval = new TString();
-     return *retval;
+    if ( (fDirs->GetEntries() == 0) && (entry == 0) )
+      { 
+        retval = ".";
+        return retval;
+      }
+     if (AliVAODParticle::GetDebug() > 0)
+      {
+        Warning("GetDirName","Index %d out of bounds",entry);
+      }
+     return retval;
    }
 
-  if (fDirs->GetEntries() == 0)
-   { 
-     retval = new TString(".");
-     return *retval;
-   }
 
   TClass *objclass = fDirs->At(entry)->IsA();
   TClass *stringclass = TObjString::Class();
@@ -419,11 +435,11 @@ TString& AliReader::GetDirName(Int_t entry)
   if(dir == 0x0)
    {
      Error("GetDirName","Object in TObjArray is not a TObjString or its descendant");
-     retval = new TString();
-     return *retval;
+     return retval;
    }
   if (gDebug > 0) Info("GetDirName","Returned ok %s",dir->String().Data());
-  return dir->String();
+  retval = dir->String();
+  return retval;
 }
 /*************************************************************************************/
 
@@ -433,13 +449,26 @@ void AliReader::Blend()
   //is used to check if some distributions (of many particle properties) 
   //depend on the order of particles
   //(tracking gives particles Pt sorted)
-  
-  if (fEventSim == 0x0) return;
-  
-  for (Int_t i = 2; i < fEventSim->GetNumberOfParticles(); i++)
+  Int_t npart = 0;
+
+  if (fEventSim ) 
+   {
+     npart = fEventSim->GetNumberOfParticles();
+    } 
+  else 
+    if (fEventRec ) 
+     {
+        npart = fEventRec->GetNumberOfParticles();
+     }
+    else
+     {
+       return;
+     }
+  for (Int_t i = 2;  i < npart; i++)
    {
      Int_t with = gRandom->Integer(i);
-     fEventSim->SwapParticles(i,with);
+//     Info("Blend","%d %d",i, with);
+     if (fEventSim) fEventSim->SwapParticles(i,with);
      if (fEventRec) fEventRec->SwapParticles(i,with);
    }
 }