]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCComparison.C
Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / TPC / AliTPCComparison.C
index 41c708c5c83ad17ecdaaef30cbea905f7649e17d..e14f7cadace427589c90b6c0a94973e152bfb980 100644 (file)
@@ -22,7 +22,7 @@
   #include <TText.h>
   #include <TBenchmark.h>
   #include <TStyle.h>
-  #include <TKey.h>
+  #include <TFile.h>
   #include <TROOT.h>
 
   #include "AliStack.h"
@@ -30,7 +30,8 @@
   #include "AliTrackReference.h"
   #include "AliRunLoader.h"
   #include "AliRun.h"
-  #include "AliESD.h"
+  #include "AliESDEvent.h"
+  #include "AliESDtrack.h"
 
   #include "AliSimDigits.h"
   #include "AliTPC.h"
   #include "AliTPCClustersRow.h"
   #include "AliTPCcluster.h"
   #include "AliTPCLoader.h"
+
+  #include "AliCDBManager.h"
+  #include "AliTPCcalibDB.h"
 #endif
 
 Int_t GoodTracksTPC(const Char_t *dir=".");
 
-extern AliRun *gAlice;
 extern TBenchmark *gBenchmark;
 extern TROOT *gROOT;
 
@@ -146,17 +149,20 @@ Int_t AliTPCComparison
          return 5;
       }
    }
-   TKey *key=0;
-   TIter next(ef->GetListOfKeys());
+   AliESDEvent* event = new AliESDEvent();
+   TTree* esdTree = (TTree*) ef->Get("esdTree");
+   if (!esdTree) {
+      ::Error("AliTPCComparison.C", "no ESD tree found");
+      return 6;
+   }
+   event->ReadFromTree(esdTree);
 
 
    //******* Loop over events *********
    Int_t e=0;
-   while ((key=(TKey*)next())!=0) {
+   while (esdTree->GetEvent(e)) {
       cout<<endl<<endl<<"********* Processing event number: "<<e<<"*******\n";
 
-      AliESD *event=(AliESD*)key->ReadObj();
-
       Int_t nentr=event->GetNumberOfTracks();
       allfound+=nentr;
 
@@ -271,9 +277,10 @@ Int_t AliTPCComparison
       cout<<"Number of \"good\" tracks ="<<ngood<<endl;
 
       refs->Clear();
-      delete event;
   }// ***** End of the loop over events
 
+   delete event;
+   delete esdTree;
    ef->Close();
 
    delete tpcTree;
@@ -368,12 +375,6 @@ Int_t AliTPCComparison
 
 
 Int_t GoodTracksTPC(const Char_t *dir) {
-   if (gAlice) { 
-       delete gAlice->GetRunLoader();
-       delete gAlice;//if everything was OK here it is already NULL
-       gAlice = 0x0;
-   }
-
    Char_t fname[100];
    sprintf(fname,"%s/galice.root",dir);
 
@@ -406,14 +407,17 @@ Int_t GoodTracksTPC(const Char_t *dir) {
       return 3;
    } 
 
-   rl->CdGAFile();
-   AliTPCParamSR *digp=(AliTPCParamSR*)gDirectory->Get("75x40_100x60_150x60");
+
+   AliCDBManager *man=AliCDBManager::Instance();
+   man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+   man->SetRun(0);
+   AliTPCParamSR *digp=
+   (AliTPCParamSR*)(AliTPCcalibDB::Instance()->GetParameters());
    if (!digp) { 
-     ::Error("AliTPCHits2Digits.C","TPC parameters have not been found !");
+     ::Error("AliTPCComparison.C","TPC parameters have not been found !");
      delete rl;
      return 4; 
    }
-   TPC->SetParam(digp);
 
    Int_t nrow_up=digp->GetNRowUp();
    Int_t nrows=digp->GetNRowLow()+nrow_up;
@@ -548,8 +552,9 @@ Int_t GoodTracksTPC(const Char_t *dir) {
         if (p->Pt()<0.100) continue;
         if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
 
-        Double_t vx=p->Vx(),vy=p->Vy();
+        Double_t vx=p->Vx(),vy=p->Vy(),vz=p->Vz();
         if (TMath::Sqrt(vx*vx+vy*vy)>3.5) continue;
+        if (TMath::Abs(vz) > 50.) continue;
 
         AliTrackReference *ref=new((*refs)[nt]) AliTrackReference();
 
@@ -564,7 +569,7 @@ Int_t GoodTracksTPC(const Char_t *dir) {
 
      //**** check if there is also information at the entrance of the TPC
      TTree *TR=rl->TreeTR();
-     TBranch *branch=TR->GetBranch("TPC");
+     TBranch *branch=TR->GetBranch("TrackReferences");
      if (branch==0) {
         ::Error("GoodTracksTPC","No track references !");
         delete rl;
@@ -576,8 +581,18 @@ Int_t GoodTracksTPC(const Char_t *dir) {
      for (Int_t r=0; r<nr; r++) {
          //cerr<<r<<' '<<nr<<'\r';
          TR->GetEvent(r);
-         if (tpcRefs->GetEntriesFast()==0) continue;
-         AliTrackReference *tpcRef=(AliTrackReference*)tpcRefs->UncheckedAt(0);
+
+        Int_t nref = tpcRefs->GetEntriesFast();
+         if (!nref) continue;
+         AliTrackReference *tpcRef= 0x0;        
+        for (Int_t iref=0; iref<nref; ++iref) {
+          tpcRef = (AliTrackReference*)tpcRefs->UncheckedAt(iref);
+          if (tpcRef->DetectorId() == AliTrackReference::kTPC) break;
+          tpcRef = 0x0;
+        }
+
+        if (!tpcRef) continue;
+
          Int_t j;
         AliTrackReference *ref=0;
          for (j=0; j<nt; j++) {