]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Code clean-up, a lot of corrections to the usage of loaders (T.Kuhr)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Apr 2004 09:35:59 +0000 (09:35 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Apr 2004 09:35:59 +0000 (09:35 +0000)
START/AliSTART.cxx
START/AliSTART.h
START/AliSTARTDigitizer.cxx
START/AliSTARTLoader.cxx
START/AliSTARTLoader.h
START/AliSTARTdigit.h
START/AliSTARTvertex.cxx
START/AliSTARTvertex.h

index e6286d34c656e6ad56a34ad74a3938bdb360c803..e6146b35fce076be62148d6710254032413d10a6 100755 (executable)
@@ -52,6 +52,7 @@
 #include "AliLoader.h"
 #include "AliRun.h"
 #include "AliSTART.h"
 #include "AliLoader.h"
 #include "AliRun.h"
 #include "AliSTART.h"
+#include "AliSTARTLoader.h"
 #include "AliSTARTdigit.h"
 #include "AliSTARThit.h"
 #include "AliSTARThitPhoton.h"
 #include "AliSTARTdigit.h"
 #include "AliSTARThit.h"
 #include "AliSTARThitPhoton.h"
@@ -256,9 +257,24 @@ void AliSTART::SetTreeAddress()
   
 }
 
   
 }
 
+//______________________________________________________________________
+AliLoader* AliSTART::MakeLoader(const char* topfoldername)
+{ 
+  Info("MakeLoader", "Creating AliSTARTLoader. Top folder is %s.", topfoldername);
+  fLoader = new AliSTARTLoader(GetName(), topfoldername);
+  return fLoader;
+}
+
 //_____________________________________________________________________________
 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
 {
   return new AliSTARTDigitizer(manager);
 }
 
 //_____________________________________________________________________________
 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
 {
   return new AliSTARTDigitizer(manager);
 }
 
+//_____________________________________________________________________________
+void AliSTART::FillESD(AliESD* pESD)  const
+{
+  AliSTARTvertex reco;
+  reco.Reconstruct(fLoader->GetRunLoader(), pESD);
+}
+
index 64611ba4a2bbf58119d52ed6dbe405e380848db2..e38fc4eb119fd92071f0b1fe02b46f54061d2177 100755 (executable)
@@ -42,12 +42,13 @@ public:
    virtual void   StepManager(){}
    virtual void   ResetHits();
    virtual void   SetTreeAddress();
    virtual void   StepManager(){}
    virtual void   ResetHits();
    virtual void   SetTreeAddress();
+   virtual AliLoader* MakeLoader(const char* topfoldername);
   
   TClonesArray   *Photons() {return fPhotons;}
 
    virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const;
    //  virtual void   Reconstruct()    const{ AliSTARTvertex reco; reco.Reconstruct();}
   
   TClonesArray   *Photons() {return fPhotons;}
 
    virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const;
    //  virtual void   Reconstruct()    const{ AliSTARTvertex reco; reco.Reconstruct();}
-    virtual void          FillESD(AliESD* pESD)  const{ AliSTARTvertex reco; reco.Reconstruct(pESD);}
+   virtual void          FillESD(AliESD* pESD)  const;
 
 protected:
    Int_t fIdSens;    // Sensetive Cherenkov radiator
 
 protected:
    Int_t fIdSens;    // Sensetive Cherenkov radiator
index 22c086745e27ed7df69fd1f456c8d8b223b41fcf..1f9f8f93c182e91d63bbe4f98df7215602a0f84b 100644 (file)
@@ -122,17 +122,19 @@ void AliSTARTDigitizer::Exec(Option_t* /*option*/)
   //  Int_t thresholdAmpl=10;
 
   
   //  Int_t thresholdAmpl=10;
 
   
-  inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
-  
-
-  AliSTART *fSTART  = (AliSTART*) inRL->GetAliRun()->GetDetector("START");
   AliSTARThit  *startHit;
   TBranch *brHits=0;
   TBranch *brHitPhoton=0;
   AliSTARThit  *startHit;
   TBranch *brHits=0;
   TBranch *brHitPhoton=0;
+  pOutStartLoader->LoadDigits("UPDATE");//probably it is necessary to load them before
   fdigits= new AliSTARTdigit();
   fdigits= new AliSTARTdigit();
+  pOutStartLoader->GetDigitsDataLoader()->GetBaseLoader(0)->Post(fdigits);
 
   Int_t nFiles=fManager->GetNinputs();
   for (Int_t inputFile=0; inputFile<nFiles;  inputFile++) {
 
   Int_t nFiles=fManager->GetNinputs();
   for (Int_t inputFile=0; inputFile<nFiles;  inputFile++) {
+    if (inputFile < nFiles-1) {
+      Warning("Exec", "ignoring input stream %d", inputFile);
+      continue;
+    }
 
     Float_t besttimeright=9999.;
     Float_t besttimeleft=9999.;
 
     Float_t besttimeright=9999.;
     Float_t besttimeleft=9999.;
@@ -147,9 +149,10 @@ void AliSTARTDigitizer::Exec(Option_t* /*option*/)
       }
 
     inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
       }
 
     inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+    if (!inRL->GetAliRun()) inRL->LoadgAlice();
+    AliSTART *fSTART  = (AliSTART*) inRL->GetAliRun()->GetDetector("START");
     pInStartLoader = inRL->GetLoader("STARTLoader");
     pInStartLoader->LoadHits("READ");//probably it is necessary to load them before
     pInStartLoader = inRL->GetLoader("STARTLoader");
     pInStartLoader->LoadHits("READ");//probably it is necessary to load them before
-    pOutStartLoader->LoadDigits("UPDATE");//probably it is necessary to load them before
     TClonesArray *fHits = fSTART->Hits ();
 
     TTree *th = pInStartLoader->TreeH();
     TClonesArray *fHits = fSTART->Hits ();
 
     TTree *th = pInStartLoader->TreeH();
@@ -257,15 +260,11 @@ void AliSTARTDigitizer::Exec(Option_t* /*option*/)
     else
       {timeAv=999999; timeDiff=99999;}
 
     else
       {timeAv=999999; timeDiff=99999;}
 
-// trick to find out output dir:
-
-    TDirectory *wd = gDirectory;
-    pOutStartLoader->GetDigitsDataLoader()->GetDirectory()->cd();
-    fdigits->Write("START_D");
-    wd->cd();
     pInStartLoader->UnloadHits();
     pInStartLoader->UnloadHits();
-    pOutStartLoader->UnloadDigits();
-  } //event loop
+  } //input streams loop
+
+  pOutStartLoader->WriteDigits("OVERWRITE");
+  pOutStartLoader->UnloadDigits();
 }
 
 
 }
 
 
index 2da2419d2b94893243df2d6b27ebe9847e4e10fe..57693771be5e11aa048479987e9b679494227e8e 100644 (file)
@@ -8,51 +8,32 @@
 // and evrtex position  (cm)                                                //
 /////////////////////////////////////////////////////////////////////////////
 #include "AliSTARTLoader.h"
 // and evrtex position  (cm)                                                //
 /////////////////////////////////////////////////////////////////////////////
 #include "AliSTARTLoader.h"
-#include <AliRunLoader.h>
-#include "AliDataLoader.h"
-
-#include <TTree.h>
-#include <TFile.h>
-
-#include <stdlib.h>
-#include <Riostream.h>
-#include <Riostream.h>
+#include "AliConfig.h"
+#include "AliRunLoader.h"
 
 
 ClassImp(AliSTARTLoader)
 
 /*****************************************************************************/ 
 
 
 ClassImp(AliSTARTLoader)
 
 /*****************************************************************************/ 
-AliSTARTLoader::AliSTARTLoader(const Char_t *name,const Char_t *topfoldername):
-  AliLoader(name,topfoldername)
-
+void AliSTARTLoader::InitObjectLoaders()
 {
 {
-//ctor   
-  cout<<" AliSTARTLoader "<<endl;
-
-
-   
+// use an object instead of a tree for digits and rec points
+
+  // D I G I T S  
+  if (fDataLoaders->At(kDigits)) {
+    delete fDataLoaders->Remove(fDataLoaders->At(kDigits));
+  }
+  AliDataLoader* dl = new AliDataLoader(fDetectorName + ".Digits.root","START_D", "Digits","O");//we want to have object data not tree
+  AliTaskLoader* tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetDigitizerTaskName(),dl,AliRunLoader::GetRunDigitizer(),kTRUE);
+  dl->SetBaseTaskLoader(tl);
+  fDataLoaders->AddAt(dl,kDigits);
+
+  // R E C O N S T R U C T E D   P O I N T S, here: V E R T E X
+  if (fDataLoaders->At(kRecPoints)) {
+    delete fDataLoaders->Remove(fDataLoaders->At(kRecPoints));
+  }
+  dl = new AliDataLoader(fDetectorName + ".RecPoints.root","START_V", "Reconstructed Points","O");//we want to have object data not tree
+  tl = new AliTaskLoader(fDetectorName + AliConfig::Instance()->GetReconstructionerTaskName(),dl,AliRunLoader::GetRunReconstructioner(),kTRUE);
+  dl->SetBaseTaskLoader(tl);
+  fDataLoaders->AddAt(dl,kRecPoints);  
 }
 }
-/*****************************************************************************/ 
-
-AliSTARTLoader::AliSTARTLoader(const Char_t *name,TFolder *topfolder):
- AliLoader(name,topfolder)
-{
-//ctor   
-
-  cout<<"  My AliSTARTLoader!!!!! "<<endl;
-
-   
-}
-/*****************************************************************************/ 
-AliSTARTLoader::~AliSTARTLoader()
-{
- //destructor
-  UnloadDigits();
-  fDataLoaders->Remove(&fDigitsDataLoader);
-
-  UnloadRecPoints();
-  fDataLoaders->Remove(&fVertexDataLoader);
-
-}
-
index 32a875084caaa7f31ed79e9e6bd233e4aa920f7b..6c649676cc3966c3bda6ddc7912c411697fffb0b 100644 (file)
@@ -1,54 +1,27 @@
 #ifndef ALISTARTLOADER_H
 #define ALISTARTLOADER_H
 
 #ifndef ALISTARTLOADER_H
 #define ALISTARTLOADER_H
 
-#include <AliLoader.h>
-#include "AliDataLoader.h"
-#include "AliSTARTdigit.h"
-#include "AliSTARTvertex.h"
-class AliSTART;
-class AliSTARTLoader: public AliLoader
- {
+#include "AliLoader.h"
+
+class AliSTARTdigit;
+
+
+class AliSTARTLoader: public AliLoader {
  public:
  public:
-   AliSTARTLoader(){};
-   AliSTARTLoader(const Char_t *name,const Char_t *topfoldername);
-   AliSTARTLoader(const Char_t *name,TFolder *topfolder);
-   
-   virtual ~AliSTARTLoader();
+   AliSTARTLoader() : AliLoader() {};
+   AliSTARTLoader(const Char_t *detname,const Char_t *eventfoldername) : 
+     AliLoader(detname, eventfoldername) {InitObjectLoaders();};
+   AliSTARTLoader(const Char_t *detname,TFolder* eventfolder) :
+     AliLoader(detname, eventfolder) {InitObjectLoaders();};
+
    // Digits
    // Digits
-   virtual void   CleanDigits() {fDigitsDataLoader.GetBaseDataLoader()->Clean();}
-   Int_t          LoadDigits(Option_t* opt=""){return fDigitsDataLoader.GetBaseDataLoader()->Load(opt);}
-   
-   void           UnloadDigits(){fDigitsDataLoader.GetBaseDataLoader()->Unload();}
-   virtual Int_t  WriteDigits(Option_t* opt=""){return fDigitsDataLoader.GetBaseDataLoader()->WriteData(opt);}
-   virtual Int_t PostDigits(AliSTARTdigit *dgt){return fDigitsDataLoader.GetBaseDataLoader()->Post(dgt);}
-   
-   TObject*  Digits(){ return fDigitsDataLoader.GetBaseDataLoader()->Get();} // returns a pointer to the tree of  RawClusters
-   
-   
-   //Vertices
-   virtual void   CleanRecPoints() {fVertexDataLoader.GetBaseDataLoader()->Clean();}
-   Int_t          LoadRecPoints(Option_t* opt=""){return fVertexDataLoader.GetBaseDataLoader()->Load(opt);}
-   void           UnloadRecPoints(){fVertexDataLoader.GetBaseDataLoader()->Unload();}
-   virtual Int_t  WriteRecPoints(Option_t* opt=""){return fVertexDataLoader.GetBaseDataLoader()->WriteData(opt);}
-   //  AliSTARTVertex *GetVertex(){return static_cast <AliSTARTVertex*>(fVertexDataLoader.GetBaseDataLoader()->Get());}
-   virtual Int_t PostRecPoints(AliSTARTvertex *vrt){return fVertexDataLoader.GetBaseDataLoader()->Post(vrt);}
-   //  TObject*  Vertex(){ return fVertexDataLoader.GetBaseDataLoader()->Get();} // returns a pointer to the tree of  RawClusters
-   
-   protected:
-   // methods
-   
-   Int_t     PostDigits(){return fDigitsDataLoader.GetBaseDataLoader()->Post();}
-   Int_t     PostRecPoints(){return fVertexDataLoader.GetBaseDataLoader()->Post();}
-   
-
-   // DATA
-   AliDataLoader fDigitsDataLoader; //digits loader
-   
-   AliDataLoader fVertexDataLoader;  // RecPoints (vertex position) loader
-   
- public:
+   AliSTARTdigit*  Digits(){ return (AliSTARTdigit*) GetDigitsDataLoader()->GetBaseDataLoader()->Get();} // returns a pointer to the tree of  RawClusters
+
+ private:
+   void InitObjectLoaders();
+
    ClassDef(AliSTARTLoader,1)
    ClassDef(AliSTARTLoader,1)
-      };
+};
  
 #endif
 
  
 #endif
 
index fca4beb074ed5fcacb48e24506ecaed57261a541..5fcb2a88380f257504c23d6c0154d9542a1dc47e 100644 (file)
@@ -33,6 +33,7 @@ class AliSTARTdigit: public TObject  {
     virtual void SetADCLeft (TArrayI &o);
     virtual void GetADCRight (TArrayI &o);
     virtual void GetADCLeft (TArrayI &o);
     virtual void SetADCLeft (TArrayI &o);
     virtual void GetADCRight (TArrayI &o);
     virtual void GetADCLeft (TArrayI &o);
+    virtual const char* GetName() const {return "START_D";}
   private: 
     //    Float_t fProcessKoef;  // for pp fProcessKoef=1 ; for Pb-Pb - 0.001
     Int_t fTimeAverage;     // Average time
   private: 
     //    Float_t fProcessKoef;  // for pp fProcessKoef=1 ; for Pb-Pb - 0.001
     Int_t fTimeAverage;     // Average time
index d2646c45cca5141c6372f44a00edd0109e55a114..7c12c1db2b2c000dadb0954e6d040d287fe87549 100644 (file)
@@ -24,6 +24,7 @@
 #include <AliRun.h>
 #include <AliRunLoader.h>
 #include "AliSTART.h"
 #include <AliRun.h>
 #include <AliRunLoader.h>
 #include "AliSTART.h"
+#include "AliSTARTLoader.h"
 #include "AliSTARTdigit.h"
 #include "AliSTARThit.h"
 #include "AliSTARTvertex.h"
 #include "AliSTARTdigit.h"
 #include "AliSTARThit.h"
 #include "AliSTARTvertex.h"
 
 ClassImp(AliSTARTvertex)
 
 
 ClassImp(AliSTARTvertex)
 
-AliSTARTvertex::AliSTARTvertex( Int_t * Zposit)
-{
-  //
-  //     The creator for the AliSTARTvertex class. This routine fills the
-  // AliSTARTvertex data members from the array vertex.
-  // The order of the elements in the vertex array are
-  //  fZposition = vertex[0],
-  //
-  Zposit = &fZposition ;
-}
-
-void AliSTARTvertex::Reconstruct(AliESD *pESD) 
+void AliSTARTvertex::Reconstruct(AliRunLoader* rl, AliESD *pESD) 
 {
   /***************************************************
   Resonstruct digits to vertex position
 {
   /***************************************************
   Resonstruct digits to vertex position
@@ -52,56 +41,46 @@ void AliSTARTvertex::Reconstruct(AliESD *pESD)
   Int_t timediff;
   Float_t timePs;
   
   Int_t timediff;
   Float_t timePs;
   
-  
-  AliRunLoader* rl = AliRunLoader::Open("galice.root");
-    //,AliConfig::fgkDefaultEventFolderName,"read");
-  if (rl == 0x0)
-   {
-     cerr<<"Can not open session for file galice.root\n";
-     return;
-   }
-  
-#ifdef DEBUG
- Info("Reconstruct","START!!!");
-#endif
-  AliLoader* pStartLoader = rl->GetLoader("STARTLoader");
- // Event ------------------------- LOOP  
-   
+  if (!rl) {
+    Error("Reconstruct", "No run loader");
+    return;
+  }
 
 
-  Int_t iNevents=rl->GetNumberOfEvents();
-  
-  for (Int_t evNumber=0; evNumber<iNevents; evNumber++)
-    {
-    rl->GetEvent(evNumber);
-  pStartLoader ->LoadDigits("READ");
-
-#ifdef DEBUG
-  gDirectory->ls();
-#endif
-    AliSTARTdigit* pDigits=(AliSTARTdigit*)gDirectory->Get("START_D");
-
-#ifdef DEBUG
-    pDigits->Dump();
-#endif  
-     if(pDigits->GetTimeDiff()<TMath::Abs(1000))
-      {
-       timediff=pDigits->GetTimeDiff();     //time in number of channels
-       timePs=(512-timediff)*2.5;       // time in Ps channel_width =10ps
-       // Float_t c = 299792458/1.e9;  //speed of light cm/ps
-       Float_t c = 0.3;  //speed of light mm/ps
-       Float_t Zposit=timePs*c;// for 0 vertex
-#ifdef DEBUG
-       cout<<"timediff "<< timediff<<" timePs "<<timePs<<" Zposit "<<Zposit<<endl;
-#endif 
-       pESD->SetT0zVertex(Zposit);
-
-#ifdef DEBUG
-       cout<<" vertex in ESD "<< pESD->GetT0zVertex()<<endl;
-#endif
-      } // vertex in 3 sigma
-     
-    } //event loop
+  if (rl->GetDebug()>1) Info("Reconstruct","START!!!");
+
+  AliSTARTLoader* pStartLoader = (AliSTARTLoader*) rl->GetLoader("STARTLoader");
+  pStartLoader->LoadDigits();
+  AliSTARTdigit* pDigits=pStartLoader->Digits();
+  if (!pDigits) {
+    Error("Reconstruct", "no digits found");
+    return;
+  }
+
+  if (rl->GetDebug()>1) pDigits->Dump();
+
+  if(pDigits->GetTimeDiff()<TMath::Abs(1000)) {
+    timediff=pDigits->GetTimeDiff();     //time in number of channels
+    timePs=(512-timediff)*2.5;       // time in Ps channel_width =10ps
+    // Float_t c = 299792458/1.e9;  //speed of light cm/ps
+    Float_t c = 0.3;  //speed of light mm/ps
+    Float_t Zposit=timePs*c;// for 0 vertex
+    
+    if (rl->GetDebug()>1) {
+      cout << "timediff " << timediff
+          <<" timePs " << timePs 
+          <<" Zposit "<<Zposit<<endl;
+    }
+    
+    fZposition = Zposit;
+    pESD->SetT0zVertex(Zposit);
+    
+    if (rl->GetDebug()>1) {
+      cout<<" vertex in ESD "<< pESD->GetT0zVertex()<<endl;
+    }
+    
+  } // vertex in 3 sigma
+  pStartLoader->UnloadDigits();
  }
 
 
  }
 
 
index 4d4256b1b6c560478cd2dff5364209c742cbd81b..16b0ff942d38dd55659c9b79b3e01e4168ae9901 100644 (file)
@@ -14,20 +14,18 @@ class AliSTARTvertex   : public TObject {
 
 
 ////////////////////////////////////////////////////////////////////////
 
 
 ////////////////////////////////////////////////////////////////////////
- private:
-  Int_t fZposition;        // Z position of vertex (mm)
- AliRunLoader* fRunLoader;
  public:
  public:
-    AliSTARTvertex() {}
-    AliSTARTvertex(Int_t *);
-    void Reconstruct(AliESD *pESD);
-    Int_t GetVertex();
-    virtual ~AliSTARTvertex() {}
-    void Set(Int_t);
+  AliSTARTvertex():TObject(),fZposition(0) {}
+  virtual ~AliSTARTvertex() {}
+
+  void Reconstruct(AliRunLoader* runLoader, AliESD *pESD);
+
+  Float_t GetVertex() const {return fZposition;}
+  void SetVertex(Float_t zPosition) {fZposition=zPosition;}
+
+ private:
+    Float_t fZposition;        // Z position of vertex (mm)
 
     ClassDef(AliSTARTvertex,1)  //Reconstructive vertex (Header) object 
 };
 
     ClassDef(AliSTARTvertex,1)  //Reconstructive vertex (Header) object 
 };
-inline Int_t AliSTARTvertex::GetVertex(){return fZposition;}
-inline void AliSTARTvertex::Set(Int_t Z_position)
-  {fZposition=Z_position;}
 #endif
 #endif