First version of writing aod files. Reader for aod files. AliAOD::fParticles chnged...
authorskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Aug 2004 15:59:05 +0000 (15:59 +0000)
committerskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Aug 2004 15:59:05 +0000 (15:59 +0000)
ANALYSIS/ANALYSISLinkDef.h
ANALYSIS/AliAOD.cxx
ANALYSIS/AliAOD.h
ANALYSIS/AliAODParticle.cxx
ANALYSIS/AliAODParticle.h
ANALYSIS/AliReaderAOD.cxx [new file with mode: 0644]
ANALYSIS/AliReaderAOD.h [new file with mode: 0644]
ANALYSIS/AliVAODParticle.cxx
ANALYSIS/AliVAODParticle.h
ANALYSIS/WriteAOD.C [new file with mode: 0644]
ANALYSIS/libANALYSIS.pkg

index 2b621ed7562e5cbb3f2ae28b44960d644d2cf314..19943e6c05b819628b4f66ffe9821292addf0a22 100644 (file)
@@ -22,6 +22,7 @@
 
 #pragma link C++ class AliReader+;
 #pragma link C++ class AliReaderESD+;
+#pragma link C++ class AliReaderAOD+;
 #pragma link C++ class AliReaderKineTree+;
 
 #pragma link C++ class AliFlowAnalysis+;
index 49e8d8d87350004610ab9723bd8fe3ff722df950..d5ba94478e6365e2c0ba0b4e5c30d4be8ab150a3 100644 (file)
@@ -1,3 +1,4 @@
+#include "AliAOD.h"
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
 /////////////////////////////////////////////////////////////
 
 #include <TParticle.h>
-#include "AliAOD.h"
+#include <TClass.h>
+#include <TString.h>
 #include "AliAODParticle.h"
 #include "AliTrackPoints.h"
 
 ClassImp(AliAOD)
 
 AliAOD::AliAOD():
- fParticles(10),
+ fParticles(0x0),
  fIsRandomized(kFALSE),
  fPrimaryVertexX(0.0),
  fPrimaryVertexY(0.0),
- fPrimaryVertexZ(0.0)
+ fPrimaryVertexZ(0.0),
+ fParticleClass(0x0)
 {
  //ctor
- SetOwner(kTRUE);
+// Info("AliAOD()","Entered");
+// SetOwner(kTRUE);
+// Info("AliAOD()","Exited");
+}
+/**************************************************************************/
+
+AliAOD::~AliAOD()
+{
+  //Destructor
+  //fParticleClass does not belong to AliAOD -> Do not delete it
+  delete fParticles;
+  
+}
+/**************************************************************************/
+
+void AliAOD::SetParticleClassName(const char* classname)
+{
+//Sets type of particle that is going to be stored 
+  if (gROOT == 0x0) Fatal("SetParticleClassName","ROOT System not initialized");
+  TClass* pclass = gROOT->GetClass(classname);
+  if ( pclass == 0x0 )
+   {
+     Error("SetParticleClass","Can not get TClass for class named %s",classname);
+     return;
+   }
+  SetParticleClass(pclass);
+}
+/**************************************************************************/
+
+void AliAOD::SetParticleClass(TClass* pclass)
+{
+//Sets type of particle that is going to be stored 
+
+  if ( pclass == 0x0 )
+   {
+     Error("SetParticleClass","Parameter is NULL.");
+     return;
+   }
+   
+  if ( pclass->InheritsFrom("AliVAODParticle") == kFALSE )
+   {
+     Error("SetParticleClass","Class named %s does not inherit from AliVAODParticle",pclass->GetName());
+     return;
+   }
+  if (pclass != fParticleClass)
+   {
+     fParticleClass = pclass;
+     if (fParticleClass) delete fParticles;
+     fParticles = new TClonesArray(fParticleClass);
+   }
 }
 
 /**************************************************************************/
@@ -49,16 +101,46 @@ void  AliAOD::AddParticle(TParticle* part, Int_t idx)
      Error("AddParticle(TParticle*,Int_t)","pointer to particle is NULL");
      return;
    }
+
+  if (fParticles == 0x0) SetParticleClassName("AliAODParticle");
   AddParticle( new AliAODParticle(*part,idx) );
 }
 /**************************************************************************/
 
+void  AliAOD::AddParticle(AliVAODParticle* particle)
+{
+ //add particle to AOD
+ //MAKES ITS OWN COPY OF THE PARTICLE!!! (AOD is not going to keep and delete input pointer)
+  if (fParticles == 0x0) SetParticleClassName("AliAODParticle");
+
+  Int_t idx = fParticles->GetLast() + 1;
+  TClonesArray& arr = *fParticles;
+  
+  AliVAODParticle* pp = (AliVAODParticle*)fParticleClass->New(arr[idx]);
+  pp->operator=(*particle);
+  
+}
+/**************************************************************************/
+
 void  AliAOD::AddParticle(Int_t pdg, Int_t idx,
                           Double_t px, Double_t py, Double_t pz, Double_t etot,
                           Double_t vx, Double_t vy, Double_t vz, Double_t time)
 {
-  //adds particle to event
-  AddParticle(new  AliAODParticle(pdg,idx,px,py,pz,etot,vx,vy,vz,time));
+  //adds particle to event (standard AOD class)
+
+  if (fParticles == 0x0) SetParticleClassName("AliAODParticle");
+
+  Int_t newpartidx = fParticles->GetLast() + 1;
+  TClonesArray& arr = *fParticles;
+  
+  AliVAODParticle* p =  (AliVAODParticle*)fParticleClass->New(arr[newpartidx]);
+  
+  p->SetPdgCode(pdg);
+  p->SetUID(idx);
+  p->SetMomentum(px,py,pz,etot);
+  p->SetProductionVertex(vx,vy,vz,time);
+  
 }
 /**************************************************************************/
 
@@ -67,23 +149,25 @@ void AliAOD::SwapParticles(Int_t i, Int_t j)
 //swaps particles positions; used by AliHBTEvent::Blend
   if ( (i<0) || (i>=GetNumberOfParticles()) ) return;
   if ( (j<0) || (j>=GetNumberOfParticles()) ) return;
-
-  AliVAODParticle* tmp = (AliVAODParticle*)fParticles.At(i);
-  fParticles.AddAt(fParticles.At(j),i);
-  fParticles.AddAt(tmp,j);
+  
+  AliVAODParticle* tmpobj = (AliVAODParticle*)fParticleClass->New();
+  AliVAODParticle& tmp = *tmpobj;
+  AliVAODParticle& first = *(GetParticle(i));
+  AliVAODParticle& second = *(GetParticle(j));
+  
+  tmp = first;
+  first = second;
+  second = tmp;
+  
 }
 /**************************************************************************/
 
 void  AliAOD::Reset()
 {
   //deletes all particles from the event
-   for(Int_t i =0; i<GetNumberOfParticles(); i++)
-    {
-      for (Int_t j = i+1; j<GetNumberOfParticles(); j++)
-        if ( fParticles.At(j) == fParticles.At(i) ) fParticles.RemoveAt(j);
-      delete fParticles.RemoveAt(i);
-    }
-//   fRandomized = kFALSE;
+   if (fParticles) fParticles->Clear("C");
+   
+   fIsRandomized = kFALSE;
 }
 /**************************************************************************/
 
@@ -109,10 +193,10 @@ Int_t AliAOD::GetNumberOfCharged(Double_t etamin, Double_t etamax) const
 {
   //reurns number of charged particles within given pseudorapidity range
   Int_t n = 0;
-  Int_t npart = fParticles.GetEntries();
+  Int_t npart = GetNumberOfParticles();
   for (Int_t i = 0; i < npart; i++)
    {
-     AliVAODParticle* p = (AliVAODParticle*)fParticles.At(i);
+     AliVAODParticle* p = GetParticle(i);
      Double_t eta = p->Eta();
      if ( (eta < etamin) || (eta > etamax) ) continue;
      if (p->Charge() != 0.0) n++;
@@ -132,13 +216,65 @@ void AliAOD::Move(Double_t x, Double_t y, Double_t z)
   fPrimaryVertexY += y;
   fPrimaryVertexZ += z;
 
-  Int_t npart = fParticles.GetEntries();
+  Int_t npart = GetNumberOfParticles();
   for (Int_t i = 0; i < npart; i++)
    {
-     AliVAODParticle* p = (AliVAODParticle*)fParticles.At(i);
+     AliVAODParticle* p = GetParticle(i);
      AliTrackPoints* tp  = p->GetTPCTrackPoints();
      if (tp) tp->Move(x,y,z);
      tp  = p->GetITSTrackPoints();
      if (tp) tp->Move(x,y,z);
    }
 }
+
+void AliAOD::Print(Option_t* /*option*/)
+{
+  //Prints AOD
+  TString ts;
+  TString msg("\n");
+  msg+="Particle Class: ";
+  if (fParticleClass)
+   {
+     msg+=fParticleClass->GetName();
+   }
+  else
+   {
+     msg+="Not specified yet";
+   } 
+  msg += "\n";
+  msg += "Vertex position X: ";
+  msg += fPrimaryVertexX;
+  msg += " Y:" ;
+  msg += fPrimaryVertexY;
+  msg += " Z:";
+  msg += fPrimaryVertexZ;
+  msg += "\n";
+  
+  msg += "Randomized: ";
+  msg += fIsRandomized;
+  msg += "\n";
+  
+  Info("Print","%s",msg.Data());
+  
+  Int_t npart = GetNumberOfParticles();
+  Info("Print","Npart: %d",npart);
+  for (Int_t i = 0; i < npart; i++)
+   {
+     Info("Print","Getting particle %d",i);
+     AliVAODParticle* p = GetParticle(i);
+     Info("Print","Printing particle %d, address %#x",i,p);
+     p->Dump();
+     p->Print();
+     Info("Print","particle %d printed",i);
+   }
+}
+
+void AliAOD::SetOwner(Bool_t /*owner*/)
+{
+//Sets the ownership of particles: if particles should be also deleted if AOD is deleted/reseted
+//Since fParticles is Clones and not Object Array, it is always the owner and this method does not have sense
+ MayNotUse("SetOwner");
+ //if fParticles->SetOwner(owner);
+}
index 4d83a01e36913e819006e9bea61f7c09e58abd01..2688f3ba657f8a62165c21e045a2ce32af029273 100644 (file)
@@ -12,7 +12,7 @@
 /////////////////////////////////////////////////////////////
 
 #include <TObject.h>
-#include <TObjArray.h>
+#include <TClonesArray.h>
 #include "AliVAODParticle.h"
 
 class TParticle;
@@ -20,13 +20,15 @@ class TParticle;
 class AliAOD: public TObject {
 public:
   AliAOD();
-  virtual ~AliAOD() { Reset(); }
+  virtual ~AliAOD();
 
-  virtual void             SetOwner(Bool_t owner){fParticles.SetOwner(owner);}
-  virtual TObjArray*       GetParticles() {return &fParticles;};
-  virtual Int_t            GetNumberOfParticles() const  {return fParticles.GetEntriesFast();}
-  virtual AliVAODParticle* GetParticle(Int_t index) const {return (AliVAODParticle*) fParticles[index];}
-  virtual void             AddParticle(AliVAODParticle* particle)  {fParticles.Add(particle);};
+  virtual TClonesArray*    GetParticles() {return fParticles;};
+  virtual void             SetParticleClassName(const char* classname);
+  virtual void             SetParticleClass(TClass* pclass);
+  
+  virtual Int_t            GetNumberOfParticles() const  {return (fParticles)?fParticles->GetEntriesFast():0;}
+  virtual AliVAODParticle* GetParticle(Int_t index) const {return  (fParticles)?(AliVAODParticle*)fParticles->At(index):0x0;}
+  virtual void             AddParticle(AliVAODParticle* particle);
   virtual void             AddParticle(TParticle* part, Int_t idx); //adds particle to the event
   virtual void             AddParticle(Int_t pdg, Int_t idx, Double_t px, Double_t py, Double_t pz, Double_t etot,
                                        Double_t vx, Double_t vy, Double_t vz, Double_t time);
@@ -41,13 +43,15 @@ public:
   
   Int_t                    GetNumberOfCharged(Double_t etamin = -10.0, Double_t etamax = 10.0) const;
   void                     Move(Double_t x, Double_t y, Double_t z);//moves all spacial coordinates about this vector
+  virtual void             SetOwner(Bool_t owner);
+  virtual void             Print(Option_t* /*option*/ = 0);
 private:
-  TObjArray                fParticles;   // array of AOD particles, AliAOD is owner of particles
+  TClonesArray            *fParticles;   // array of AOD particles, AliAOD is owner of particles
   Bool_t                   fIsRandomized;//flag indicating if positions of particles were randomized - used by HBTAN
   Double_t                 fPrimaryVertexX;//X position of the primary vertex
   Double_t                 fPrimaryVertexY;//Y position of the primary vertex
   Double_t                 fPrimaryVertexZ;//Z position of the primary vertex
-  
+  TClass*                  fParticleClass;//object that defines type of the particle       
   
   ClassDef(AliAOD,1)  // base class for AOD containers
 };
index bcb32b0cbaaccb15c3a31b0106233263a8a58190..be101d1496c0251b1458ddaf8e1fdcaad0c4e70a 100644 (file)
@@ -81,6 +81,7 @@ AliAODParticle::AliAODParticle(const AliAODParticle& in):
    fTPCTrackPoints(0x0),fITSTrackPoints(0x0),fClusterMap(0x0)
 {
  //Copy constructor
+// Info("AliAODParticle(const AliAODParticle& in)","");
  for(Int_t i = 0; i<fNPids; i++)
   {
     fPids[i] =  in.fPids[i];
@@ -106,7 +107,7 @@ AliAODParticle::AliAODParticle(const AliVAODParticle& in):
    fTPCTrackPoints(0x0),fITSTrackPoints(0x0),fClusterMap(0x0)
 {
  //Copy constructor
+ Info("AliAODParticle(const AliVAODParticle& in)","");
  for(Int_t i = 0; i<in.GetNumberOfPids(); i++)
   {
     SetPIDprobability(in.GetNthPid(i),in.GetNthPidProb(i));
@@ -165,15 +166,61 @@ void AliAODParticle::Clear(Option_t*)
 }
 //______________________________________________________________________________
 
+AliAODParticle& AliAODParticle::operator=(const AliVAODParticle& in)
+{
+//operator=
+//  Info("operator=(const AliVAODParticle& in)","AliAODParticle");
+  
+  delete [] fPids;
+  delete [] fPidProb;
+  fPids = 0x0;
+  fPidProb = 0x0;
+  Int_t npids = in.GetNumberOfPids();
+  for (Int_t i = 0; i < npids; i++)
+   {
+     SetPIDprobability(in.GetNthPid(i),in.GetNthPidProb(i));
+   }
+   
+  SetPdgCode(in.GetPdgCode(),in.GetPidProb());
+  
+  SetUID(in.GetUID());
+
+  fCalcMass = in.Mass();
+  
+  fPx = in.Px();
+  fPy = in.Py();
+  fPz = in.Pz();
+  fE = in.E(); 
+  fVx = in.Vx();
+  fVy = in.Vy();
+  fVz = in.Vz();
+  fVt = in.T();
+  
+  delete fTPCTrackPoints;
+  AliTrackPoints* tpts = in.GetTPCTrackPoints();
+  fTPCTrackPoints = (tpts)?(AliTrackPoints*)tpts->Clone():0x0;
+
+  delete fITSTrackPoints;
+  tpts = in.GetITSTrackPoints();  
+  fITSTrackPoints = (tpts)?(AliTrackPoints*)tpts->Clone():0x0;
+  
+  delete fClusterMap;
+  AliClusterMap* incmap = in.GetClusterMap();
+  fClusterMap =  (incmap)?(AliClusterMap*)incmap->Clone():0x0;
+  
+  return *this;
+}
+//______________________________________________________________________________
+
 AliAODParticle& AliAODParticle::operator=(const AliAODParticle& in)
 {
 //assigment operator
-  
+//  Info("operator=(const AliAODParticle& in)","AliAODParticle");
   fNPids = in.fNPids;
   delete [] fPids;
   delete [] fPidProb;
-  Int_t* fPids = new Int_t[fNPids];
-  Float_t* fPidProb = new Float_t[fNPids];
+  fPids = new Int_t[fNPids];
+  fPidProb = new Float_t[fNPids];
   for (Int_t i = 0; i < fNPids;i++)
    {
      fPids[i]    = in.fPids[i];
@@ -193,10 +240,10 @@ AliAODParticle& AliAODParticle::operator=(const AliAODParticle& in)
   fVt = in.T();
   
   delete fTPCTrackPoints;
-  fTPCTrackPoints = (in.fTPCTrackPoints)?(AliTrackPoints*)fTPCTrackPoints->Clone():0x0;
+  fTPCTrackPoints = (in.fTPCTrackPoints)?(AliTrackPoints*)in.fTPCTrackPoints->Clone():0x0;
 
   delete fITSTrackPoints;
-  fITSTrackPoints = (in.fITSTrackPoints)?(AliTrackPoints*)fITSTrackPoints->Clone():0x0;
+  fITSTrackPoints = (in.fITSTrackPoints)?(AliTrackPoints*)in.fITSTrackPoints->Clone():0x0;
   
   delete fClusterMap;
   fClusterMap =  (in.fClusterMap)?(AliClusterMap*)in.fClusterMap->Clone():0x0;
@@ -207,6 +254,7 @@ AliAODParticle& AliAODParticle::operator=(const AliAODParticle& in)
 
 void AliAODParticle::SetPdgCode(Int_t pdg,Float_t prob)
 {
+//Set PDG Code
   SetPIDprobability(pdg,prob);
   fPdgIdx = GetPidSlot(pdg);
 }
@@ -216,7 +264,7 @@ void AliAODParticle::SetPIDprobability(Int_t pdg, Float_t prob)
 {
 //Sets another pdg code and corresponding probabilty
 //Ids are set in decreasing order
-//Check if total prbaility is not ivercoming unity is performed
+//Check if total probability is not overcoming unity is performed
 //in case, warning is printed
   if (GetDebug() > 9) Info("SetPIDprobability","Setting PID %d prob %f",pdg,prob);
 
@@ -261,7 +309,7 @@ void AliAODParticle::SetPIDprobability(Int_t pdg, Float_t prob)
   totprob+=prob;
   
 
-  for (Int_t j = fNPids-1; j > i ;j--)//copy rest of old araays 
+  for (Int_t j = fNPids-1; j > i ;j--)//copy rest of old arays 
    {
      if (GetDebug() > 9) Info("SetPID","Copying from old entry %d to new entry %d",j-1,j);
      aPidProbNew[j] = fPidProb[j-1];
index 95aea067a0160985d6b2d85db221c03954a90f6f..f2d52fc71d6767fa2471ca9cbffe87cede11087c 100644 (file)
@@ -45,8 +45,9 @@ public:
   virtual ~AliAODParticle();
   
   AliAODParticle& operator=(const AliAODParticle& in); 
+  AliAODParticle& operator=(const AliVAODParticle& in); 
   
-  void           Clear(Option_t*);//Must be implemented in order to store this object in Clones Array
+  void           Clear(Option_t* /*option*/ ="");//Must be implemented in order to store this object in Clones Array
   
   TLorentzVector FourMomentum() const {TLorentzVector v(fPx,fPy,fPz,fE);return v;}
   TVector3       ProductionVertex() const {TVector3 v(fVx,fVy,fVz);return v;}
@@ -59,7 +60,7 @@ public:
   
   Int_t          GetPdgCode      () const { return (fPids)?fPids[fPdgIdx]:0;}
 
-  Double_t        GetPidProb      () const { return (fPidProb)?fPidProb[fPdgIdx]:0;}
+  Double_t       GetPidProb      () const { return (fPidProb)?fPidProb[fPdgIdx]:0;}
   
   Int_t          GetUID          () const { return fIdxInEvent;}
   Int_t          GetNumberOfPids () const { return fNPids;}
diff --git a/ANALYSIS/AliReaderAOD.cxx b/ANALYSIS/AliReaderAOD.cxx
new file mode 100644 (file)
index 0000000..38e884f
--- /dev/null
@@ -0,0 +1,68 @@
+#include "AliReaderAOD.h"
+
+ClassImp(AliReaderAOD)
+
+#include <TError.h>
+#include <TFile.h>
+#include <TTree.h>
+#include "AliAOD.h"
+
+Int_t AliReaderAOD::WriteAOD(AliReader* reader, const char* outfilename, Bool_t /*multcheck*/)
+{
+//reads tracks from runs and writes them to file
+  ::Info("AliReaderAOD::Write","________________________________________________________");
+  ::Info("AliReaderAOD::Write","________________________________________________________");
+  ::Info("AliReaderAOD::Write","________________________________________________________");
+  
+  if (reader == 0x0)
+   {
+     ::Error("AliReaderAOD::Write","Input Reader is NULL");
+     return -1;
+   }
+  TFile *outfile = TFile::Open(outfilename,"recreate");
+  if (outfile == 0x0)
+   {
+     ::Error("AliReaderAOD::Write","Can not open output file %s",outfilename);
+     return -1;
+   }
+
+  TTree *tree = new TTree("TAOD","Tree with tracks");
+  
+  TBranch *recbranch = 0x0, *simbranch = 0x0;
+
+  AliAOD* eventsim = new AliAOD();
+  AliAOD* eventrec = new AliAOD;
+  
+  eventsim->SetParticleClassName("AliAODParticle");
+  eventrec->SetParticleClassName("AliAODParticle");
+  
+  if (reader->ReadsSim()) simbranch = tree->Branch("simulated","AliAOD",&eventsim,32000,99);
+  if (reader->ReadsRec()) recbranch = tree->Branch("reconstructed","AliAOD",&eventrec,32000,99);
+
+  reader->Rewind();
+  while (reader->Next() == kFALSE)
+   {
+     
+     if (reader->ReadsSim())
+      {
+        eventsim = reader->GetEventSim();
+//        simbranch->SetAddress(&eventsim);
+      }
+     if (reader->ReadsRec())
+      {
+        eventrec = reader->GetEventRec();
+//        recbranch->SetAddress(&eventrec);
+      }
+     tree->Fill();
+     tree->Print();
+   }
+  
+  ::Info("AliReaderAOD::Write","Written %d events",tree->GetEntries());
+  outfile->cd();
+  tree->Write();
+  delete tree;
+  delete outfile;
+  return 0; 
+}
+
diff --git a/ANALYSIS/AliReaderAOD.h b/ANALYSIS/AliReaderAOD.h
new file mode 100644 (file)
index 0000000..7ccd47a
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef ALIREADERAOD_H
+#define ALIREADERAOD_H
+
+#include "AliReader.h"
+
+class AliReaderAOD: public AliReader
+{
+  public:
+    AliReaderAOD(const Char_t* aodfilename = "AliAOD.root"){}
+    virtual ~AliReaderAOD(){}
+
+    void          ReadSimulatedData(Bool_t flag){fReadSim = flag;}//switches reading MC data
+    Bool_t        ReadsRec() const {return kTRUE;}
+    Bool_t        ReadsSim() const {return fReadSim;}
+
+
+    static Int_t WriteAOD(AliReader* reader, const char* outfilename = "AliAOD.root", Bool_t multcheck = kFALSE);//reads tracks from runs and writes them to file
+    
+  protected:
+  private:
+    TString fFileName;//File name
+    
+    Bool_t  fReadSim;//indicates if to read simulated data
+    ClassDef(AliReaderAOD,1)
+};
+
+#endif
index e6fb52f7a8584d4bbb637bdfa05c3794a5585c09..537d0471f06f2b9b9fc2deb117433f3c1263a61b 100644 (file)
@@ -37,3 +37,32 @@ Int_t AliVAODParticle::fgDebug = 0;
 
 ClassImp(AliVAODParticle)
 
+void   AliVAODParticle::Clear(Option_t * /*option*/)
+{
+//Clear method
+//It is necessary for storing particles in clones array
+  Error("Clear","!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+  Error("Clear","error Error ERROR error Error ERROR");
+  Error("Clear","This Particle do not implement Clear Method");
+  Error("Clear","Clear Method must delete all dynamiclally allocalted memory");
+  Error("Clear","error Error ERROR error Error ERROR");
+  Error("Clear","!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+}
+//______________________________________________________________________________
+
+AliVAODParticle::AliVAODParticle(const AliVAODParticle& in):
+ TObject(in)
+{
+ //Copy constructor
+// Info("AliVAODParticle(const AliVAODParticle& in)","");
+}
+//______________________________________________________________________________
+
+
+AliVAODParticle& AliVAODParticle::operator=(const AliVAODParticle& /*in*/)
+{
+//assigment operator
+  Info("operator=(const AliVAODParticle& in)","Implement opertator= in your particle!!!");
+  return *this;
+}
+
index da0d4d159efb4e0cdc35bb365d206485f89e6a37..5e3af4728c50b2c745c79ebe6aa3e9f8769e4c33 100644 (file)
@@ -20,8 +20,13 @@ class AliClusterMap;
 
 class AliVAODParticle : public TObject {
 public:
-   AliVAODParticle(){}
-   virtual ~AliVAODParticle(){}
+  AliVAODParticle(){}
+  virtual ~AliVAODParticle(){}
+
+  AliVAODParticle(const AliVAODParticle& in);
+  virtual AliVAODParticle& operator=(const AliVAODParticle& in); 
+   
+
   // kinematics
   virtual TLorentzVector   FourMomentum() const = 0;
   virtual TVector3         Momentum() const {return FourMomentum().Vect();};
@@ -41,16 +46,18 @@ public:
   virtual void             SetProductionVertex(Double_t /*vx*/, Double_t /*vy*/, Double_t /*vz*/, Double_t /*t*/) = 0;
 
   // PID
-  virtual Double_t         Charge() const = 0;
+  virtual void             SetPdgCode(Int_t pdg, Float_t prob = 1.0) = 0;
   virtual Double_t         GetProbability(Int_t pdg) const = 0;
-  virtual Double_t         GetPidProb() const = 0;
+  virtual Double_t         GetPidProb() const = 0;//returns probability of being particle type defined by GetPdgCode() 
   virtual Int_t            GetMostProbable() const = 0;
   
   virtual Int_t            GetPdgCode() const = 0;//We need to assume some PID (f.e. energy calculation) 
-                                                  //sotimes one track can apear in analysis twise (e.g. ones as pion ones as kaon)
+                                                  //sometimes one track can apear in analysis twise (e.g. ones as pion ones as kaon)
   virtual Int_t            GetNumberOfPids() const = 0; //returns number of non zero PID probabilities
   virtual Int_t            GetNthPid         (Int_t idx) const = 0;//These two methods are made to be able to
   virtual Float_t          GetNthPidProb     (Int_t idx) const = 0;//copy pid information i.e. in copy ctors
+
+  virtual Double_t         Charge() const = 0;
   
   // vertices
   virtual TVector3         ProductionVertex() const = 0;
@@ -68,7 +75,7 @@ public:
   virtual Int_t            GetUID() const { return 0;}//returns unique ID of this track 
                                                       //(may happen than the same track is selected
                                                       //twise, f.g. as a pion and as a kaon than both have the same UID)
-                                                      
+  virtual void             SetUID(Int_t /*id*/){/* *this */}
   // type information
   virtual Bool_t           IsSimulated() {return kFALSE;};
   virtual Bool_t           IsTrack() {return kFALSE;};
@@ -82,7 +89,7 @@ public:
 
   static void    SetDebug(Int_t dbg=1){fgDebug=dbg;}
   static Int_t   GetDebug(){return fgDebug;}
-
+  virtual void   Clear(Option_t * /*option*/ ="");
 private:
   static Int_t fgDebug;//! debug level for all the analysis package
 
diff --git a/ANALYSIS/WriteAOD.C b/ANALYSIS/WriteAOD.C
new file mode 100644 (file)
index 0000000..6ac7008
--- /dev/null
@@ -0,0 +1,112 @@
+#if 0
+  #include "$(ALICE_ROOT)/TPC/alles.h"
+  #include "AliReader.h"
+  #include "AliReaderKineTree.h"
+  #include "AliAODParticleCut.h"
+  #include "AliAOD.h"
+  #include "AliAODPairCut.h"
+  #include "TSystem.h"
+  #include "TObjString.h"
+  #include "TString.h"
+  #include "AliPDG.h"
+#endif
+
+
+void WriteAOD(Option_t* datatype, Option_t* processopt="TracksAndParticles",
+                Int_t first = -1,Int_t last = -1,
+                char *outfile = "AOD.root")
+ {
+//datatype defines type of data to be read
+//  Kine  - analyzes Kine Tree: simulated particles
+//  ESD
+//  AOD
+
+// default: TracksAndParticles - process both recontructed tracks and sim. particles corresponding to them 
+//          Tracks - process only recontructed tracks
+//          Particles - process only simulated particles
+
+//Reads data from diroctories from first to last(including)
+// For examples if first=3 and last=5 it reads from
+//  ./3/
+//  ./4/
+//  ./5/
+//if first or last is negative (or both), it reads from current directory
+//
+//these names I use when analysis is done directly from CASTOR files via RFIO
+
+  const char* basedir=".";
+  const char* serie="";
+  const char* field = "";
+  cout<<"WriteAOD.C: datatype is "<<datatype<<" dir is basedir"<<endl;
+  // Dynamically link some shared libs                    
+  
+  cout<<"WriteAOD.C: Loading  ANALYSIS .....\n";
+  gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libANALYSIS");
+  cout<<"WriteAOD.C: ..... Loaded\n";
+  
+  Bool_t multcheck = kTRUE;
+  /***********************************************************/
+   
+  AliReader* reader;
+  Int_t kine = strcmp(datatype,"Kine");
+  Int_t ESD = strcmp(datatype,"ESD");
+  Int_t intern = strcmp(datatype,"AOD");
+
+  if(!kine)
+   {
+    reader = new AliReaderKineTree();
+    processopt="Particles"; //this reader by definition reads only simulated particles
+    multcheck = kFALSE;
+   }
+  else if(!ESD)
+   {
+    AliReaderESD* esdreader = new AliReaderESD();
+    esdreader->ReadSimulatedData(kTRUE);
+    reader = esdreader;
+    multcheck = kTRUE;
+   }
+
+  else if(!intern)
+   {
+    reader = new AliHBTReaderAOD("AOD.root");
+    multcheck = kTRUE;
+   }
+  else
+   {
+    cerr<<"Option "<<datatype<<"  not recognized. Exiting"<<endl;
+    return;
+   }
+
+  TObjArray* dirs=0;
+  if ( (first >= 0) && (last>=0) && ( (last-first)>=0 ) )
+   {//read from many dirs dirs
+     cout<<"WriteAOD.C: ..... Setting dirs first="<<first<<" last="<<last<<"\n";
+     char buff[50];
+     dirs = new TObjArray(last-first+1);
+     dirs->SetOwner();
+     for (Int_t i = first; i<=last; i++)
+      { 
+        sprintf(buff,"%s/%s/%s/%d",basedir,field,serie,i);
+        TObjString *odir= new TObjString(buff);
+        dirs->Add(odir);
+      }
+    }
+
+   reader->SetDirs(dirs);
+    
+   AliAODParticleCut* readerpartcut= new AliAODParticleCut();
+   readerpartcut->SetPtRange(0.0,10000.0);
+   readerpartcut->SetPID(kKPlus);
+   AliAODPIDCut* pidcut = new AliAODPIDCut(kKPlus,0.5);
+   readerpartcut->AddBasePartCut(pidcut);
+   
+   reader->AddParticleCut(readerpartcut);//read this particle type with this cut
+
+   cout<<"WriteAOD.C:   P R O C S E S S I N G .....\n\n";
+   AliReaderAOD::WriteAOD(reader,outfile,multcheck);
+   cout<<"\n\nWriteAOD.C:   F I N I S H E D\n";
+   
+   if (dirs) delete dirs;
+   delete reader;
+ }
+
index ab84f23bd1b5263568924684311edce7015fc73d..8085223f5e87225821c2ec072eddc9300d187cec 100644 (file)
@@ -5,7 +5,8 @@ SRCS= AliAOD.cxx AliEventBuffer.cxx \
       AliAODParticleCut.cxx AliAODParticleBaseCut.cxx \
       AliAODPairCut.cxx AliAODPairBaseCut.cxx \
       AliEventCut.cxx AliEventBaseCut.cxx \
-      AliReader.cxx AliReaderESD.cxx AliReaderKineTree.cxx\
+      AliReader.cxx AliReaderESD.cxx AliReaderKineTree.cxx \
+      AliReaderAOD.cxx \
       AliTrackPoints.cxx AliClusterMap.cxx \
       AliD0toKpi.cxx  AliD0toKpiAnalysis.cxx AliFlowAnalysis.cxx \