]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliV0FindVertices.C
Tests and example macros working with ESD (Yu.Belikov)
[u/mrichter/AliRoot.git] / ITS / AliV0FindVertices.C
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"
+  #include "TKey.h"
   #include "TStopwatch.h"
 
   #include "AliRun.h"
+  #include "AliKalmanTrack.h"
+  #include "AliMagF.h"
+  #include "AliESD.h"
   #include "AliRunLoader.h"
-  #include "AliITSLoader.h"
 #endif
 
 extern AliRun *gAlice;
@@ -19,19 +26,23 @@ Int_t AliV0FindVertices(Int_t nev=5) {
       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;
    }
-   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 
@@ -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();
+
+   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++) {
-     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();
     
+   itsf->Close();
+   v0f->Close();
+
    delete rl;
 
    return rc;