]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Tests and example macros working with ESD (Yu.Belikov)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Nov 2003 08:00:26 +0000 (08:00 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Nov 2003 08:00:26 +0000 (08:00 +0000)
ITS/AliCascadeFindVertices.C
ITS/AliITSFindTracksV2.C
ITS/AliITStestV2.C
ITS/AliV0FindVertices.C
TPC/AliTPCFindTracks.C

index 1b8e88b914f34c3ed11e30888aee2167b2e76c29..b85e761a9e583c2bae7dd51820c2cf87d9075e0e 100644 (file)
@@ -2,11 +2,14 @@
   #include <Riostream.h>
   #include "AliCascadeVertexer.h"
   #include "TFile.h"
   #include <Riostream.h>
   #include "AliCascadeVertexer.h"
   #include "TFile.h"
+  #include "TKey.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
+  #include "AliMagF.h"
+  #include "AliESD.h"
+  #include "AliKalmanTrack.h"
   #include "AliRunLoader.h"
   #include "AliRunLoader.h"
-  #include "AliITSLoader.h"
 #endif
 
 Int_t AliCascadeFindVertices(Int_t nev=5) {
 #endif
 
 Int_t AliCascadeFindVertices(Int_t nev=5) {
@@ -22,54 +25,68 @@ Int_t AliCascadeFindVertices(Int_t nev=5) {
       cerr<<"AliCascadeFindVertices.C : Can not open session RL=NULL"<< endl;
       return 1;
    }
       cerr<<"AliCascadeFindVertices.C : Can not open session RL=NULL"<< endl;
       return 1;
    }
-   AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
-   if (itsl == 0x0) {
-      cerr<<"AliCascadeFindVertices.C : Can not get ITS loader"<<endl;
-      return 2;
+
+   if (rl->LoadgAlice()) {
+      cerr<<"AliV0FindVertices.C : LoadgAlice returned error"<<endl;
+      delete rl;
+      return 3;
    }
    }
-   itsl->LoadTracks("read");
-   itsl->LoadV0s("read");
-   itsl->LoadCascades("recreate");
 
 
+   AliKalmanTrack::SetConvConst(
+      1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
+   );
+       
    Double_t cuts[]={33.,    // max. allowed chi2
                     0.05,   // min. allowed V0 impact parameter 
                     0.008,  // window around the Lambda mass 
                     0.035,  // min. allowed bachelor's impact parameter 
                     0.10,   // max. allowed DCA between a V0 and a track
    Double_t cuts[]={33.,    // max. allowed chi2
                     0.05,   // min. allowed V0 impact parameter 
                     0.008,  // window around the Lambda mass 
                     0.035,  // min. allowed bachelor's impact parameter 
                     0.10,   // max. allowed DCA between a V0 and a track
-                    0.9985, // max. allowed cosine of the cascade pointing angle
+                    0.9985,// max. allowed cosine of the cascade pointing angle
                     0.9,    // min. radius of the fiducial volume
                     2.9     // max. radius of the fiducial volume
                    };
    TStopwatch timer;
    AliCascadeVertexer *vertexer=new AliCascadeVertexer(cuts);
                     0.9,    // min. radius of the fiducial volume
                     2.9     // max. radius of the fiducial volume
                    };
    TStopwatch timer;
    AliCascadeVertexer *vertexer=new AliCascadeVertexer(cuts);
+
    Int_t rc=0;
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
    Int_t rc=0;
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
-   for (Int_t i=0; i<nev; i++) {
-     rl->GetEvent(i);
 
 
-     TTree *tTree=itsl->TreeT();
-     if (!tTree) {
-       cerr<<"AliCascadeFindVertices.C : Can't get the ITS track tree !"<<endl;
-       return 3;
-     }
-     TTree *vTree=itsl->TreeV0();
-     if (!vTree) {
-       cerr<<"AliCascadeFindVertices.C : Can't get the V0 tree !"<<endl;
-       return 4;
-     }
-     TTree *xTree=itsl->TreeX();
-     if (!xTree) {
-        itsl->MakeTree("X");
-        xTree=itsl->TreeX();
-     }
+   TFile *casf=TFile::Open("AliESDcas.root","RECREATE");
+   if ((!casf)||(!casf->IsOpen())) {
+      cerr<<"Can't AliESDcas.root !\n"; return 1;
+   }
+   TFile *v0f=TFile::Open("AliESDv0.root");
+   if ((!v0f)||(!v0f->IsOpen())) {
+      cerr<<"Can't AliESDv0.root !\n"; return 1;
+   }
+
+   TKey *key=0;
+   TIter next(v0f->GetListOfKeys());
+   for (Int_t i=0; i<nev; i++) {
+     v0f->cd();
+     if ((key=(TKey*)next())==0) break;
+     cerr<<"Processing event number: "<<i<<endl;
+     AliESD *event=(AliESD*)key->ReadObj();
 
 
-     rc=vertexer->V0sTracks2CascadeVertices(vTree,tTree,xTree);
+     rc=vertexer->V0sTracks2CascadeVertices(event);
 
 
-     itsl->WriteCascades("OVERWRITE");
+     if (rc==0) {
+        Char_t ename[100]; 
+        sprintf(ename,"%d",i);
+        casf->cd();
+        if (!event->Write(ename)) rc++;
+     } 
+     if (rc) {
+        cerr<<"Something bad happened...\n";
+     }
+     delete event;
    }
    delete vertexer;
    timer.Stop(); timer.Print();
     
    }
    delete vertexer;
    timer.Stop(); timer.Print();
     
+   v0f->Close();
+   casf->Close();
+
    delete rl;
 
    return rc;
    delete rl;
 
    return rc;
index 6fc08504ef510b87267f3a88be9a68c66301febd..43d3d7dca3abf353b81f9ef97ece73bc722ab0d3 100644 (file)
@@ -4,16 +4,18 @@
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
   #include "Riostream.h"
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
   #include "Riostream.h"
-
+  #include "TKey.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
+  #include "AliMagF.h"
   #include "AliRunLoader.h"
   #include "AliTPCLoader.h"
   #include "AliITSLoader.h"
   #include "AliITS.h"
   #include "AliITSgeom.h"
   #include "AliITStrackerV2.h"
   #include "AliRunLoader.h"
   #include "AliTPCLoader.h"
   #include "AliITSLoader.h"
   #include "AliITS.h"
   #include "AliITSgeom.h"
   #include "AliITStrackerV2.h"
+  #include "AliESD.h"
 #endif
 
 extern AliRun *gAlice;
 #endif
 
 extern AliRun *gAlice;
@@ -33,33 +35,23 @@ Int_t AliITSFindTracksV2(Int_t nev=5) {  //number of events to process
       return 3;
    }
      
       return 3;
    }
      
-   Int_t retval = rl->LoadgAlice();
-   if (retval) {
-      cerr<<"AliITSFindTracksV2.C : LoadgAlice returned error"<<endl;
-      delete rl;
-       return 3;
-   }
-   retval = rl->LoadHeader();
-   if (retval) {
-      cerr<<"AliITSFindTracksV2.C : LoadHeader returned error"<<endl;
-      delete rl;
-      return 3;
-   }
-   gAlice=rl->GetAliRun();
-       
    AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
    if (itsl == 0x0) {
       cerr<<"AliITSFindTracksV2.C : Can not get ITS loader"<<endl;
       return 4;
    }
 
    AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
    if (itsl == 0x0) {
       cerr<<"AliITSFindTracksV2.C : Can not get ITS loader"<<endl;
       return 4;
    }
 
-   AliTPCLoader* tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
-   if (tpcl == 0x0) {
-      cerr<<"AliITSFindTracksV2.C : can not get TPC loader"<<endl;
-      return 5;
+   if (rl->LoadgAlice()) {
+      cerr<<"AliITSFindTracksV2.C : LoadgAlice returned error"<<endl;
+      delete rl;
+      return 3;
    }
 
    }
 
-   AliITS *dITS = (AliITS*)gAlice->GetDetector("ITS");
+   AliKalmanTrack::SetConvConst(
+      1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
+   );
+       
+   AliITS *dITS = (AliITS*)rl->GetAliRun()->GetDetector("ITS");
    if (!dITS) {
       cerr<<"AliITSFindClusters.C : Can not find the ITS detector !"<<endl;
       return 6;
    if (!dITS) {
       cerr<<"AliITSFindClusters.C : Can not find the ITS detector !"<<endl;
       return 6;
@@ -68,15 +60,28 @@ Int_t AliITSFindTracksV2(Int_t nev=5) {  //number of events to process
 
    AliITStrackerV2 tracker(geom);
 
 
    AliITStrackerV2 tracker(geom);
 
-   tpcl->LoadTracks("read"); 
-   itsl->LoadTracks("recreate");
    itsl->LoadRecPoints("read");
 
    itsl->LoadRecPoints("read");
 
-   TStopwatch timer; 
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
    Int_t rc=0;
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
    Int_t rc=0;
+
+   TFile *itsf=TFile::Open("AliESDits.root","RECREATE");
+   if ((!itsf)||(!itsf->IsOpen())) {
+      cerr<<"Can't AliESDits.root !\n"; return 1;
+   }
+   TFile *tpcf=TFile::Open("AliESDtpc.root");
+   if ((!tpcf)||(!tpcf->IsOpen())) {
+      cerr<<"Can't AliESDtpc.root !\n"; return 1;
+   }
+   TKey *key=0;
+   TIter next(tpcf->GetListOfKeys());
+   TStopwatch timer; 
    for (Int_t i=0; i<nev; i++) {
    for (Int_t i=0; i<nev; i++) {
+       tpcf->cd();
+       if ((key=(TKey*)next())==0) break;
        cerr<<"Processing event number: "<<i<<endl;
        cerr<<"Processing event number: "<<i<<endl;
+       AliESD *event=(AliESD*)key->ReadObj();
+
        rl->GetEvent(i);
 
        TTree *cTree=itsl->TreeR();
        rl->GetEvent(i);
 
        TTree *cTree=itsl->TreeR();
@@ -84,25 +89,27 @@ Int_t AliITSFindTracksV2(Int_t nev=5) {  //number of events to process
          cerr<<"AliITSFindTracksV2.C : Can't get the clusters tree !"<<endl;
           return 4;
        }
          cerr<<"AliITSFindTracksV2.C : Can't get the clusters tree !"<<endl;
           return 4;
        }
-       TTree *tpcTree=tpcl->TreeT();
-       if (!tpcTree) {
-         cerr<<"AliITSFindTracksV2.C : Can't get the TPC track tree !"<<endl;
-          return 4;
-       }
-       TTree *itsTree=itsl->TreeT();
-       if (!itsTree) {
-          itsl->MakeTree("T");
-          itsTree=itsl->TreeT();
-       }
 
        tracker.LoadClusters(cTree);
 
        tracker.LoadClusters(cTree);
-       rc=tracker.Clusters2Tracks(tpcTree,itsTree);
+       rc=tracker.Clusters2Tracks(event);
        tracker.UnloadClusters();
 
        tracker.UnloadClusters();
 
-       itsl->WriteTracks("OVERWRITE");
+       if (rc==0) {
+          Char_t ename[100]; 
+          sprintf(ename,"%d",i);
+          itsf->cd();
+          if (!event->Write(ename)) rc++;
+       } 
+       if (rc) {
+          cerr<<"Something bad happened...\n";
+       }
+       delete event;
    }
    timer.Stop(); timer.Print();
 
    }
    timer.Stop(); timer.Print();
 
+   tpcf->Close();
+   itsf->Close();
+
    delete rl;
 
    return rc;
    delete rl;
 
    return rc;
index ade8c991e7ec978094be6f1fdf5a406d16725b6a..b8e3501480839bbc2cffb36759aeca74fa13a491 100644 (file)
@@ -36,7 +36,7 @@ Int_t AliITStestV2(Int_t nev=5, Char_t SlowOrFast='s') {
       AliITSSDigits2Digits();
    }
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSFindClustersV2.C");
       AliITSSDigits2Digits();
    }
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSFindClustersV2.C");
-   if (rc=AliITSFindClustersV2(SlowOrFast)) return rc;
+   if (rc=AliITSFindClustersV2(nev,SlowOrFast)) return rc;
 
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSFindTracksV2.C");
    if (rc=AliITSFindTracksV2()) return rc;
 
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSFindTracksV2.C");
    if (rc=AliITSFindTracksV2()) return rc;
index 4c286df4497f73edf2560f328c4f58e5a5c1dd89..338ae94c2f3202bc92c8f6c34d576e82d2b2bf1d 100644 (file)
@@ -1,12 +1,19 @@
+/****************************************************************************
+ *           Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch                 *
+ ****************************************************************************/
+
 #if !defined(__CINT__) || defined(__MAKECINT__)
   #include "Riostream.h"
   #include "AliV0vertexer.h"
   #include "TFile.h"
 #if !defined(__CINT__) || defined(__MAKECINT__)
   #include "Riostream.h"
   #include "AliV0vertexer.h"
   #include "TFile.h"
+  #include "TKey.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
+  #include "AliKalmanTrack.h"
+  #include "AliMagF.h"
+  #include "AliESD.h"
   #include "AliRunLoader.h"
   #include "AliRunLoader.h"
-  #include "AliITSLoader.h"
 #endif
 
 extern AliRun *gAlice;
 #endif
 
 extern AliRun *gAlice;
@@ -19,19 +26,23 @@ Int_t AliV0FindVertices(Int_t nev=5) {
       delete gAlice; 
       gAlice=0;
    } 
       delete gAlice; 
       gAlice=0;
    } 
+
    AliRunLoader* rl = AliRunLoader::Open("galice.root");
    if (rl == 0x0) {
       cerr<<"AliV0FindVertices.C : Can not open session RL=NULL"<< endl;
       return 1;
    }
    AliRunLoader* rl = AliRunLoader::Open("galice.root");
    if (rl == 0x0) {
       cerr<<"AliV0FindVertices.C : Can not open session RL=NULL"<< endl;
       return 1;
    }
-   AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
-   if (itsl == 0x0) {
-      cerr<<"AliV0FindVertices.C : Can not get ITS loader"<<endl;
-      return 2;
+
+   if (rl->LoadgAlice()) {
+      cerr<<"AliV0FindVertices.C : LoadgAlice returned error"<<endl;
+      delete rl;
+      return 3;
    }
    }
-   itsl->LoadTracks("read");
-   itsl->LoadV0s("recreate");
 
 
+   AliKalmanTrack::SetConvConst(
+      1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
+   );
+       
    Double_t cuts[]={33,  // max. allowed chi2
                     0.16,// min. allowed negative daughter's impact parameter 
                     0.05,// min. allowed positive daughter's impact parameter 
    Double_t cuts[]={33,  // max. allowed chi2
                     0.16,// min. allowed negative daughter's impact parameter 
                     0.05,// min. allowed positive daughter's impact parameter 
@@ -44,27 +55,43 @@ Int_t AliV0FindVertices(Int_t nev=5) {
    AliV0vertexer vtxer(cuts);
    Int_t rc=0;
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
    AliV0vertexer vtxer(cuts);
    Int_t rc=0;
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
+
+   TFile *v0f=TFile::Open("AliESDv0.root","RECREATE");
+   if ((!v0f)||(!v0f->IsOpen())) {
+      cerr<<"Can't AliESDv0.root !\n"; return 1;
+   }
+   TFile *itsf=TFile::Open("AliESDits.root");
+   if ((!itsf)||(!itsf->IsOpen())) {
+      cerr<<"Can't AliESDits.root !\n"; return 1;
+   }
+   TKey *key=0;
+   TIter next(itsf->GetListOfKeys());
    for (Int_t i=0; i<nev; i++) {
    for (Int_t i=0; i<nev; i++) {
-     rl->GetEvent(i);
-     //Double_t vtx[3]={0.,0.,0.}; vtxer.SetVertex(vtx); // primary vertex (cm)
+     itsf->cd();
+     if ((key=(TKey*)next())==0) break;
+     cerr<<"Processing event number: "<<i<<endl;
+     AliESD *event=(AliESD*)key->ReadObj();
 
 
-     TTree *tTree=itsl->TreeT();
-     if (!tTree) {
-        cerr<<"AliV0FindVertices.C : Can't get the ITS track tree !"<<endl;
-        return 3;
-     }
-     TTree *vTree=itsl->TreeV0();
-     if (!vTree) {
-        itsl->MakeTree("V0");
-        vTree=itsl->TreeV0();
-     }
+     //Double_t vtx[3]={0.,0.,0.}; vtxer.SetVertex(vtx); // primary vertex (cm)
 
 
-     rc=vtxer.Tracks2V0vertices(tTree,vTree);
+     rc=vtxer.Tracks2V0vertices(event);
 
 
-     itsl->WriteV0s("OVERWRITE");
+     if (rc==0) {
+        Char_t ename[100]; 
+        sprintf(ename,"%d",i);
+        v0f->cd();
+        if (!event->Write(ename)) rc++;
+     } 
+     if (rc) {
+        cerr<<"Something bad happened...\n";
+     }
+     delete event;
    }
    timer.Stop(); timer.Print();
     
    }
    timer.Stop(); timer.Print();
     
+   itsf->Close();
+   v0f->Close();
+
    delete rl;
 
    return rc;
    delete rl;
 
    return rc;
index aa4449b3cc2a2825e99812e1b47c16525b753774..7bc53ee6d3badebf11e98ff3f5aaa8e6c902fbb2 100644 (file)
@@ -10,6 +10,7 @@
   #include "AliMagF.h"
   #include "AliRunLoader.h"
   #include "AliTPCLoader.h"
   #include "AliMagF.h"
   #include "AliRunLoader.h"
   #include "AliTPCLoader.h"
+  #include "AliESD.h"
 
   #include "TFile.h"
   #include "TStopwatch.h"
 
   #include "TFile.h"
   #include "TStopwatch.h"
@@ -43,9 +44,11 @@ Int_t AliTPCFindTracks(Int_t nev=5) {
       cerr<<"Error occured while loading gAlice"<<endl;
       return 1;
    }
       cerr<<"Error occured while loading gAlice"<<endl;
       return 1;
    }
+
    AliKalmanTrack::SetConvConst(
    AliKalmanTrack::SetConvConst(
-      1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
+     1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
    );
    );
+
    rl->CdGAFile();
    AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
    if (!dig) { 
    rl->CdGAFile();
    AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
    if (!dig) { 
@@ -53,18 +56,22 @@ Int_t AliTPCFindTracks(Int_t nev=5) {
         return 1;
    }
 
         return 1;
    }
 
-   rl->UnloadgAlice();   
+   //rl->UnloadgAlice();   
 
    tpcl->LoadRecPoints("read");
 
    tpcl->LoadRecPoints("read");
-   tpcl->LoadTracks("recreate");
 
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
     
 
    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
     
+   TFile *ef=TFile::Open("AliESDtpc.root","RECREATE");
+   if ((!ef)||(!ef->IsOpen())) {
+      cerr<<"Can't AliESDtpc.root !\n"; return 1;
+   }
    TStopwatch timer;
    Int_t rc=0;
    AliTPCtracker tracker(dig);
    for (Int_t i=0;i<nev;i++){
      printf("Processing event %d\n",i);
    TStopwatch timer;
    Int_t rc=0;
    AliTPCtracker tracker(dig);
    for (Int_t i=0;i<nev;i++){
      printf("Processing event %d\n",i);
+     AliESD *event=new AliESD(); 
      rl->GetEvent(i);
 
      TTree *in=tpcl->TreeR();
      rl->GetEvent(i);
 
      TTree *in=tpcl->TreeR();
@@ -73,19 +80,26 @@ Int_t AliTPCFindTracks(Int_t nev=5) {
         return 4;
      }
 
         return 4;
      }
 
-     TTree *out=tpcl->TreeT();
-     if (!out) {
-        tpcl->MakeTree("T");
-        out=tpcl->TreeT();
+     tracker.LoadClusters(in);
+     rc=tracker.Clusters2Tracks(event);
+     tracker.UnloadClusters();
+
+    if (rc==0) {
+        Char_t ename[100]; 
+        sprintf(ename,"%d",i);
+        ef->cd();
+        if (!event->Write(ename)) rc++;
+     } 
+     if (rc) {
+        cerr<<"Something bad happened...\n";
      }
      }
-         
-     rc=tracker.Clusters2Tracks(in,out);
-
-     tpcl->WriteTracks("OVERWRITE");
+     delete event;
    }
 
    timer.Stop(); timer.Print();
  
    }
 
    timer.Stop(); timer.Print();
  
+   ef->Close();
+
    delete dig; //Thanks to Mariana Bondila
 
    delete rl;
    delete dig; //Thanks to Mariana Bondila
 
    delete rl;