Corrected sintax of the commands in ProcessLine (Yves)
[u/mrichter/AliRoot.git] / ANALYSIS / AliReaderAOD.cxx
index f0748af..234f8dc 100644 (file)
@@ -1,4 +1,20 @@
-#include "AliReaderAOD.h"
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
 //______________________________________________________________________________
 ////////////////////////////////////////////////////////////////////////////////
 //                                                                            //
 //                                                                            //
 ////////////////////////////////////////////////////////////////////////////////
 
-ClassImp(AliReaderAOD)
 
 #include <TError.h>
 #include <TFile.h>
 #include <TTree.h>
 #include <TH1.h>
-#include "AliAOD.h"
 
+#include "AliAOD.h"
+#include "AliLog.h"
+#include "AliReaderAOD.h"
 
 const TString AliReaderAOD::fgkTreeName("TAOD");
 const TString AliReaderAOD::fgkReconstructedDataBranchName("reconstructed.");
 const TString AliReaderAOD::fgkSimulatedDataBranchName("simulated.");
 
+ClassImp(AliReaderAOD)
+
 AliReaderAOD::AliReaderAOD(const Char_t* aodfilename):
  fFileName(aodfilename),
  fReadSim(kFALSE),
@@ -100,12 +119,16 @@ Int_t AliReaderAOD::ReadNext()
          fTree = 0x0;
          delete fFile;
          fFile = 0x0;
+         
+         delete fSimBuffer;
+         delete fRecBuffer;
+         
          fSimBuffer = 0x0;
          fRecBuffer = 0x0;
          fCurrentDir++;
          continue;
        }
-       
+      
       Info("ReadNext","Getting event %d",fCurrentEvent);
       fTree->GetEvent(fCurrentEvent);
       Info("ReadNext","Getting event %d Done",fCurrentEvent);
@@ -122,8 +145,13 @@ Int_t AliReaderAOD::ReadNext()
        } 
 
       fCurrentEvent++;
-      if (retval == 0) fNEventsRead++;
+      if (retval != 0) 
+        {
+          //something wrong has happend during reading this event, take next
+          continue;
+        }
 
+      fNEventsRead++;
       return retval;//success -> read one event
       
     }while(fCurrentDir < GetNumberOfDirs());//end of loop over directories specified in fDirs Obj Array  
@@ -168,11 +196,31 @@ Int_t AliReaderAOD::ReadRecAndSim()
      }
 
     Int_t npart = fRecBuffer->GetNumberOfParticles();
+    
+    if (npart != fSimBuffer->GetNumberOfParticles())
+     {
+       Error("ReadRecAndSim","There is different number of simulated and reconstructed particles!",
+                              fSimBuffer->GetNumberOfParticles(),npart);
+       return 1;
+     } 
     for (Int_t i = 0; i < npart; i++)
      {
        AliVAODParticle* prec = fRecBuffer->GetParticle(i);
-       if (Rejected(prec)) continue;//we make cuts only on simulated data
-
+       AliVAODParticle* psim = fSimBuffer->GetParticle(i);
+       
+       if (prec == 0x0)
+        {
+          Error("ReadRecAndSim","Reconstructed Particle is NULL !!!");
+          continue;
+        }
+       if (psim == 0x0)
+        {
+          Error("ReadRecAndSim","Simulated Particle is NULL !!!");
+          continue;
+        }
+       
+       if (Rejected(prec)) continue;//we make cuts only on reconstructed data
+       
        fEventRec->AddParticle(prec);
        fEventSim->AddParticle( fSimBuffer->GetParticle(i));
      }
@@ -283,11 +331,8 @@ Int_t AliReaderAOD::OpenFile(Int_t n)
  const TString dirname = GetDirName(n);
  if (dirname == "")
   {
-    if (AliVAODParticle::GetDebug() > 2 )
-      {
-        Info("OpenFile","Got empty string as a directory name."); 
-      }
-   return 1;
+    AliDebug(3,"Got empty string as a directory name."); 
+    return 1;
   }
  
  TString filename = dirname +"/"+ fFileName;
@@ -305,15 +350,12 @@ Int_t AliReaderAOD::OpenFile(Int_t n)
     return 3;
   }
 
- Info("ReadNext","File Is Opened, Getting the TREE");
+ Info("ReadNext","File %s Is Opened, Getting the TREE",filename.Data());
  
  fTree = dynamic_cast<TTree*>(fFile->Get(fgkTreeName));
  if (fTree == 0x0)
   {
-    if (AliVAODParticle::GetDebug() > 2 )
-      {
-        Info("ReadNext","Can not find TTree object named %s",fgkTreeName.Data());
-      }
+    AliDebug(3,Form("Can not find TTree object named %s",fgkTreeName.Data()));
     delete fFile;
     fFile = 0x0;
     return 4;
@@ -429,8 +471,6 @@ Int_t AliReaderAOD::WriteAOD(AliReader* reader, const char* outfilename, const c
            simbuffer = event;
          } 
       }
-     recbuffer->GetParticle(0)->Print();
-     simbuffer->GetParticle(0)->Print();
      tree->Fill();
    }