]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSComparisonV2.C
Transition to NewIO
[u/mrichter/AliRoot.git] / ITS / AliITSComparisonV2.C
index 52a2a70110d1172566c23c36b0f40d6132bcdfd6..9dcdb9ff60aae6ba9a7a5d1240da446322974076 100644 (file)
@@ -3,15 +3,20 @@
   #include <fstream.h>
 
   #include "AliRun.h"
+  #include "AliRunLoader.h"
+  #include "AliLoader.h"
+  #include "AliITSLoader.h"
   #include "AliITS.h"
   #include "AliITSgeom.h"
   #include "AliITStrackerV2.h"
   #include "AliITStrackV2.h"
   #include "AliITSclusterV2.h"
+  #include "AliMagF.h"
 
   #include "TFile.h"
   #include "TTree.h"
   #include "TH1.h"
+  #include "TH2.h"
   #include "TObjArray.h"
   #include "TStyle.h"
   #include "TCanvas.h"
@@ -29,34 +34,55 @@ struct GoodTrackITS {
 
 Int_t AliITSComparisonV2(Int_t event=0) {
    cerr<<"Doing comparison...\n";
-
+   if (gAlice) 
+    {
+      delete gAlice->GetRunLoader();
+      delete gAlice; 
+      gAlice=0;
+    }
+   
+   AliRunLoader *rl = AliRunLoader::Open("galice.root");
+   if (!rl) 
+     {
+       cerr<<"AliITSComparisonV2.C :Can't start sesion !\n";
+       return 1;
+     }
+   rl->LoadgAlice();
+   if (rl->GetAliRun()) 
+    AliKalmanTrack::SetConvConst(1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField());
+   else
+    {
+       cerr<<"AliITSComparisonV2.C :Can't get AliRun !\n";
+       return 1;
+    }
+   rl->UnloadgAlice();
+    
+   AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
+   if (itsl == 0x0)
+     {
+       cerr<<"AliITSComparisonV2.C : Can not find TPCLoader\n";
+       delete rl;
+       return 3;
+     }
+   
    const Int_t MAX=15000;
-   Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const Int_t event);
+   Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const char* evfoldname = AliConfig::fgkDefaultEventFolderName);//declaration only
 
    Int_t nentr=0; TObjArray tarray(2000);
    {/* Load tracks */ 
-     TFile *tf=TFile::Open("AliITStracksV2.root");
-     if (!tf->IsOpen()) {cerr<<"Can't open AliITStracksV2.root !\n"; return 3;}
-     char tname[100]; sprintf(tname,"TreeT_ITS_%d",event);
-     TTree *tracktree=(TTree*)tf->Get(tname);
+     itsl->LoadTracks();
+     TTree *tracktree=itsl->TreeT();
      if (!tracktree) {cerr<<"Can't get a tree with ITS tracks !\n"; return 4;}
      TBranch *tbranch=tracktree->GetBranch("tracks");
      nentr=(Int_t)tracktree->GetEntries();
+
      for (Int_t i=0; i<nentr; i++) {
         AliITStrackV2 *iotrack=new AliITStrackV2;
         tbranch->SetAddress(&iotrack);
         tracktree->GetEvent(i);
         tarray.AddLast(iotrack);
-        /*if (itsLabel != 1234) continue;
-        Int_t nc=iotrack->GetNumberOfClusters();
-        for (Int_t k=0; k<nc; k++) {
-          Int_t index=iotrack->GetClusterIndex(k);
-          AliITSclusterV2 *c=tracker.GetCluster(index);
-          cout<<c->GetLabel(0)<<' '<<c->GetLabel(1)<<' '<<c->GetLabel(2)<<endl;
-       }*/
      }
-     delete tracktree; //Thanks to Mariana Bondila
-     tf->Close();
+     itsl->UnloadTracks();
    }
 
    /* Generate a list of "good" tracks */
@@ -78,7 +104,7 @@ Int_t AliITSComparisonV2(Int_t event=0) {
       if (!in.eof()) cerr<<"Read error (good_tracks_its) !\n";
    } else {
       cerr<<"Marking good tracks (this will take a while)...\n";
-      ngood=good_tracks_its(gt,MAX,event);
+      ngood=good_tracks_its(gt,MAX,AliConfig::fgkDefaultEventFolderName);
       ofstream out("good_tracks_its");
       if (out) {
        for (Int_t ngd=0; ngd<ngood; ngd++)
@@ -88,7 +114,6 @@ Int_t AliITSComparisonV2(Int_t event=0) {
       } else cerr<<"Can not open file (good_tracks_its) !\n";
       out.close();
    }
-   cerr<<"Number of good tracks : "<<ngood<<endl;
 
    TH1F *hp=new TH1F("hp","PHI resolution",50,-20.,20.); hp->SetFillColor(4);
    TH1F *hl=new TH1F("hl","LAMBDA resolution",50,-20,20);hl->SetFillColor(4);
@@ -97,7 +122,6 @@ Int_t AliITSComparisonV2(Int_t event=0) {
    TH1F *hmpt=new TH1F("hmpt","Transverse impact parameter",30,-300,300); 
    hmpt->SetFillColor(6);
    TH1F *hz=new TH1F("hz","Longitudinal impact parameter",30,-300,300); 
-   //hmpt->SetFillColor(6);
 
    AliITStrackV2 *trk=(AliITStrackV2*)tarray.UncheckedAt(0);
    Double_t pmin=0.1*(100/0.299792458/0.2/trk->GetConvConst());
@@ -111,34 +135,57 @@ Int_t AliITSComparisonV2(Int_t event=0) {
    TH1F *hf=new TH1F("hf","Efficiency for fake tracks",30,pmin,pmax);
    hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
 
-   TH1F *hptw=new TH1F("hptw","Weghted pt",30,pmax,pmin);
+   //TH1F *hptw=new TH1F("hptw","Weghted pt",30,pmax,pmin);
+
+   TH1F *he =new TH1F("he","dE/dX for pions with 0.4<p<0.5 GeV/c",50,0.,100.);
+   TH2F *hep=new TH2F("hep","dE/dX vs momentum",50,0.,2.,50,0.,200.);
+   hep->SetMarkerStyle(8);
+   hep->SetMarkerSize(0.4);
+
 
-   while (ngood--) {
-      Int_t lab=gt[ngood].lab, tlab=-1;
-      Double_t pxg=gt[ngood].px, pyg=gt[ngood].py, pzg=gt[ngood].pz;
+   Int_t notf[MAX], nnotf=0;
+   Int_t fake[MAX], nfake=0;
+   Int_t mult[MAX], numb[MAX], nmult=0;
+
+   Int_t ng;
+   for (ng=0; ng<ngood; ng++) {
+      Int_t lab=gt[ng].lab, tlab=-1;
+      Double_t pxg=gt[ng].px, pyg=gt[ng].py, pzg=gt[ng].pz;
       Double_t ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
 
-      if (ptg<pmin) continue;
 
-      hgood->Fill(ptg);
+      if (ptg>pmin) hgood->Fill(ptg);
 
       AliITStrackV2 *track=0;
+      Int_t cnt=0;
       Int_t j;
       for (j=0; j<nentr; j++) {
-          track=(AliITStrackV2*)tarray.UncheckedAt(j);
-          tlab=track->GetLabel();
-          if (lab==TMath::Abs(tlab)) break;
+          AliITStrackV2 *trk=(AliITStrackV2*)tarray.UncheckedAt(j);
+          Int_t lbl=trk->GetLabel();
+          if (lab==TMath::Abs(lbl)) {
+           if (cnt==0) {track=trk; tlab=lbl;}
+            cnt++;
+          }
       }
-      if (j==nentr) {
-       cerr<<"Track "<<lab<<" was not found !\n";
+      if (cnt==0) {
+        notf[nnotf++]=lab;
         continue;
+      } else if (cnt>1){
+        mult[nmult]=lab;
+        numb[nmult]=cnt; nmult++;        
+      }
+
+      if (ptg>pmin) {
+        if (lab==tlab) hfound->Fill(ptg);
+        else {
+          fake[nfake++]=lab;
+          hfake->Fill(ptg); 
+        }
       }
+
       track->PropagateTo(3.,0.0028,65.19);
       track->PropagateToVertex();
 
-      if (lab==tlab) hfound->Fill(ptg);
-      else { hfake->Fill(ptg); cerr<<lab<<" fake\n";}
-
       Double_t xv,par[5]; track->GetExternalParameters(xv,par);
       Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
       if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
@@ -155,20 +202,45 @@ Int_t AliITSComparisonV2(Int_t event=0) {
       Double_t d=10000*track->GetD();
       hmpt->Fill(d);
 
-      hptw->Fill(ptg,TMath::Abs(d));
+      //hptw->Fill(ptg,TMath::Abs(d));
 
       Double_t z=10000*track->GetZ();
       hz->Fill(z);
 
-//if (TMath::Abs(gt[ngood].code)==11 && ptg>4.)
       hpt->Fill((pt_1 - 1/ptg)/(1/ptg)*100.);
 
+      Float_t mom=1./(pt_1*TMath::Cos(lam));
+      Float_t dedx=track->GetdEdx();
+      hep->Fill(mom,dedx,1.);
+      if (TMath::Abs(gt[ng].code)==211)
+         if (mom>0.4 && mom<0.5) he->Fill(dedx,1.);
    }
 
-   Stat_t ng=hgood->GetEntries(); cerr<<"Good tracks "<<ng<<endl;
-   Stat_t nf=hfound->GetEntries();
-   if (ng!=0) 
-      cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
+
+   cout<<"\nList of Not found tracks :\n";
+   for (ng=0; ng<nnotf; ng++){
+     cout<<notf[ng]<<"\t";
+     if ((ng%9)==8) cout<<"\n";
+   }
+   cout<<"\n\nList of fake  tracks :\n";
+   for (ng=0; ng<nfake; ng++){
+     cout<<fake[ng]<<"\t";
+     if ((ng%9)==8) cout<<"\n";
+   }
+   cout<<"\n\nList of multiple found tracks :\n";
+   for (ng=0; ng<nmult; ng++) {
+       cout<<"id.   "<<mult[ng]
+           <<"     found - "<<numb[ng]<<"times\n";
+   }
+   cout<<endl;
+
+   cerr<<"Number of good tracks : "<<ngood<<endl;
+   cerr<<"Number of found tracks : "<<nentr<<endl;
+
+   ng=(Int_t)hgood->GetEntries(); //cerr<<"Good tracks "<<ng<<endl;
+   if (ng!=0)  
+   cerr<<"Integral efficiency is about "<<hfound->GetEntries()/ng*100.<<" %\n";
+   cerr<<endl;
 
    gStyle->SetOptStat(111110);
    gStyle->SetOptFit(1);
@@ -227,26 +299,55 @@ Int_t AliITSComparisonV2(Int_t event=0) {
    text->SetTextSize(0.05);
    text->Draw();
 
+//     PH taken from v3-09-09, but not used
+//    TCanvas *c2=new TCanvas("c2","",320,32,530,590);
+
+//    TPad *p6=new TPad("p6","",0.,0.,1.,.5); p6->Draw();
+//    p6->cd(); p6->SetFillColor(42); p6->SetFrameFillColor(10); 
+//    he->SetFillColor(2); he->SetFillStyle(3005);  
+//    he->SetXTitle("Arbitrary Units"); 
+//    he->Fit("gaus"); c2->cd();
+
+//    TPad *p7=new TPad("p7","",0.,0.5,1.,1.); p7->Draw(); 
+//    p7->cd(); p7->SetFillColor(42); p7->SetFrameFillColor(10);
+//    hep->SetXTitle("p (Gev/c)"); hep->SetYTitle("dE/dX (Arb. Units)"); 
+//    hep->Draw(); c1->cd();
+   
+
    return 0;
 }
 
-Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const Int_t event) {
-   if (gAlice) {delete gAlice; gAlice=0;}
+Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const char* evfoldname) {
+
+   Int_t nt=0;
+
+   AliRunLoader* rl = AliRunLoader::GetRunLoader(evfoldname);
+   if (rl == 0x0)
+    {
+      ::Fatal("AliTPCComparison.C::good_tracks_its",
+              "Can not find Run Loader in Folder Named %s",
+              evfoldname);
+    }
+
+   AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
+   if (itsl == 0x0)
+     {
+       cerr<<"AliITSComparisonV2.C : Can not find TPCLoader\n";
+       delete rl;
+       return 3;
+     }
+   
+   rl->LoadgAlice();
+   rl->LoadHeader();
+   Int_t np = rl->GetHeader()->GetNtrack();
 
-   TFile *file=TFile::Open("galice.root");
-   if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
-   if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
-     cerr<<"gAlice have not been found on galice.root !\n";
-     exit(5);
-   }
 
-   Int_t np=gAlice->GetEvent(event);
 
    Int_t *good=new Int_t[np];
    Int_t k;
    for (k=0; k<np; k++) good[k]=0;
 
-   AliITS *ITS=(AliITS*)gAlice->GetDetector("ITS");
+   AliITS *ITS=(AliITS*)rl->GetAliRun()->GetDetector("ITS");
    if (!ITS) {
       cerr<<"can't get ITS !\n"; exit(8);
    }
@@ -255,12 +356,8 @@ Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const Int_t event) {
       cerr<<"can't get ITS geometry !\n"; exit(9);
    }
 
-   TFile *cf=TFile::Open("AliITSclustersV2.root");
-   if (!cf->IsOpen()){
-      cerr<<"Can't open AliITSclustersV2.root !\n"; exit(6);
-   }
-   char cname[100]; sprintf(cname,"TreeC_ITS_%d",event);
-   TTree *cTree=(TTree*)cf->Get(cname);
+   itsl->LoadRawClusters();
+   TTree *cTree=itsl->TreeC();
    if (!cTree) {
       cerr<<"Can't get cTree !\n"; exit(7);
    }
@@ -291,19 +388,28 @@ Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const Int_t event) {
      }
    }
    clusters->Delete(); delete clusters;
-   delete cTree; //Thanks to Mariana Bondila
-   cf->Close();
-
+   itsl->UnloadRawClusters();
+   
    ifstream in("good_tracks_tpc");
    if (!in) {
      cerr<<"can't get good_tracks_tpc !\n"; exit(11);
    }
+   
+   rl->LoadKinematics();
+   AliStack* stack = rl->Stack();
    Int_t nt=0;
    Double_t px,py,pz,x,y,z;
    Int_t code,lab;
    while (in>>lab>>code>>px>>py>>pz>>x>>y>>z) {
       if (good[lab] != 0x3F) continue;
-      TParticle *p = (TParticle*)gAlice->Particle(lab);
+      TParticle *p = (TParticle*)stack->Particle(lab);
+      if (p == 0x0)
+       {
+         cerr<<"Can not get particle "<<lab<<endl;
+         nt++;
+         if (nt==max) {cerr<<"Too many good tracks !\n"; break;}
+         continue;
+       }
       gt[nt].lab=lab;
       gt[nt].code=p->GetPdgCode();
 //**** px py pz - in global coordinate system
@@ -315,8 +421,9 @@ Int_t good_tracks_its(GoodTrackITS *gt, const Int_t max, const Int_t event) {
 
    delete[] good;
 
-   delete gAlice; gAlice=0;
-   file->Close();
+   rl->UnloadKinematics();
+   rl->UnloadHeader();
+   rl->UnloadgAlice();
 
    return nt;
 }