* with several nice improvements by: M.Ivanov, GSI, m.ivanov@gsi.de *
****************************************************************************/
-#ifndef __CINT__
+#if !defined(__CINT__) || defined(__MAKECINT__)
#include "alles.h"
#include "AliTPCtracker.h"
+ #include "AliRunLoader.h"
+ #include "AliTPCLoader.h"
+ #include "AliMagF.h"
+ #include "AliRun.h"
#endif
struct GoodTrackTPC {
Float_t x,y,z;
};
-Int_t AliTPCComparison(Int_t event=0) {
+Int_t
+good_tracks_tpc(GoodTrackTPC *gt, const Int_t max, const char* evfoldname);
+
+extern AliRun *gAlice;
+
+Int_t AliTPCComparison(Bool_t thcut=1.0) {
+
+ if (gAlice) {
+ delete gAlice->GetRunLoader();
+ delete gAlice;//if everything was OK here it is already NULL
+ gAlice = 0x0;
+ }
+
cerr<<"Doing comparison...\n";
const Int_t MAX=20000;
- Int_t good_tracks_tpc(GoodTrackTPC *gt, const Int_t max, const Int_t event);
+ Int_t good_tracks_tpc(
+ GoodTrackTPC *gt, const Int_t max,
+ const char* evfoldname = AliConfig::fgkDefaultEventFolderName
+ );//declaration only
gBenchmark->Start("AliTPCComparison");
- Int_t nentr=0,i=0; TObjArray tarray(MAX);
- { /*Load tracks*/
- TFile *tf=TFile::Open("AliTPCtracks.root");
- if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return 3;}
+ AliRunLoader *rl = AliRunLoader::Open("galice.root","COMPARISON");
+ if (!rl) {
+ cerr<<"Can't start sesion !\n";
+ return 1;
+ }
- char tname[100]; sprintf(tname,"TreeT_TPC_%d",event);
- TTree *tracktree=(TTree*)tf->Get(tname);
- if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n"; return 4;}
+ rl->LoadgAlice();
+ if (rl->GetAliRun())
+ AliKalmanTrack::SetConvConst(
+ 1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
+ );
+ else {
+ cerr<<"AliTPCComparison.C :Can't get AliRun !\n";
+ return 1;
+ }
+ rl->UnloadgAlice();
+
+ AliTPCLoader * tpcl = (AliTPCLoader *)rl->GetLoader("TPCLoader");
+ if (tpcl == 0x0) {
+ cerr<<"AliTPCComparison.C : Can not find TPCLoader\n";
+ delete rl;
+ return 3;
+ }
- TBranch *tbranch=tracktree->GetBranch("tracks");
- nentr=(Int_t)tracktree->GetEntries();
- AliTPCtrack *iotrack=0;
- for (i=0; i<nentr; i++) {
+ Int_t nentr=0,i=0; TObjArray tarray(MAX);
+ { /*Load tracks*/
+
+ tpcl->LoadTracks();
+
+ TTree *tracktree=tpcl->TreeT();
+ if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n"; return 4;}
+
+ TBranch *tbranch=tracktree->GetBranch("tracks");
+ nentr=(Int_t)tracktree->GetEntries();
+ AliTPCtrack *iotrack=0;
+ for (i=0; i<nentr; i++) {
iotrack=new AliTPCtrack;
tbranch->SetAddress(&iotrack);
tracktree->GetEvent(i);
tarray.AddLast(iotrack);
- }
- delete tracktree; //Thanks to Mariana Bondila
- tf->Close();
+ }
+ tpcl->UnloadTracks();
}
/* Generate a list of "good" tracks */
+
GoodTrackTPC gt[MAX];
Int_t ngood=0;
ifstream in("good_tracks_tpc");
while (in>>gt[ngood].lab>>gt[ngood].code>>
gt[ngood].px>>gt[ngood].py>>gt[ngood].pz>>
gt[ngood].x >>gt[ngood].y >>gt[ngood].z) {
- ngood++;
- cerr<<ngood<<'\r';
- if (ngood==MAX) {
- cerr<<"Too many good tracks !\n";
- break;
- }
+ Double_t rin = TMath::Sqrt( gt[ngood].x*gt[ngood].x+gt[ngood].y*gt[ngood].y);
+ if (rin<1) continue;
+ Double_t theta = gt[ngood].z/rin;
+ //theta =0;
+ if (TMath::Abs(theta)<thcut){
+ ngood++;
+ cerr<<ngood<<'\r';
+ if (ngood==MAX) {
+ cerr<<"Too many good tracks !\n";
+ break;
+ }
+ //ngood++;
+ // cerr<<ngood<<'\r';
+ // if (ngood==MAX) {
+ // cerr<<"Too many good tracks !\n";
+ // break;
+ }
}
if (!in.eof()) cerr<<"Read error (good_tracks_tpc) !\n";
} else {
- cerr<<"Marking good tracks (this will take a while)...\n";
- ngood=good_tracks_tpc(gt,MAX, event);
+ cerr<<"Marking good tracks (this will take a while)...\n";
+ ngood=good_tracks_tpc(gt,MAX,"COMPARISON");
ofstream out("good_tracks_tpc");
if (out) {
for (Int_t ngd=0; ngd<ngood; ngd++)
}
-
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);
TH1F *hpt=new TH1F("hpt","Relative Pt resolution",30,-10.,10.);
gBenchmark->Stop("AliTPCComparison");
gBenchmark->Show("AliTPCComparison");
-
+ delete rl;
return 0;
}
-Int_t good_tracks_tpc(GoodTrackTPC *gt, const Int_t max, const Int_t event) {
+Int_t
+good_tracks_tpc(GoodTrackTPC *gt, const Int_t max, const char* evfoldname) {
Int_t nt=0;
- 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);
+ AliRunLoader *rl = AliRunLoader::GetRunLoader(evfoldname);
+ if (rl == 0x0) {
+ ::Fatal("AliTPCComparison.C::good_tracks_tpc",
+ "Can not find Run Loader in Folder Named %s",
+ evfoldname);
}
-
- Int_t np=gAlice->GetEvent(event);
-
- AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
+ AliTPCLoader *tpcl = (AliTPCLoader *)rl->GetLoader("TPCLoader");
+ if (tpcl == 0x0) {
+ cerr<<"AliTPCHits2Digits.C : Can not find TPCLoader\n";
+ delete rl;
+ return 0;
+ }
+
+ rl->LoadgAlice();
+
+ AliTPC *TPC=(AliTPC*)rl->GetAliRun()->GetDetector("TPC");
Int_t ver = TPC->IsVersion();
cerr<<"TPC version "<<ver<<" has been found !\n";
- AliTPCParamSR *digp=(AliTPCParamSR*)file->Get("75x40_100x60_150x60");
+ rl->CdGAFile();
+ AliTPCParamSR *digp=(AliTPCParamSR*)gDirectory->Get("75x40_100x60_150x60");
if (!digp) { cerr<<"TPC parameters have not been found !\n"; exit(6); }
TPC->SetParam(digp);
-
+ rl->LoadHeader();
+
+ Int_t np = rl->GetHeader()->GetNtrack();
+
Int_t nrow_up=digp->GetNRowUp();
Int_t nrows=digp->GetNRowLow()+nrow_up;
switch (ver) {
case 1:
{
- char cname[100]; sprintf(cname,"TreeC_TPC_%d",event);
- TFile *cf=TFile::Open("AliTPCclusters.root");
- if (!cf->IsOpen()){cerr<<"Can't open AliTPCclusters.root !\n";exit(5);}
+ tpcl->LoadRecPoints();
AliTPCClustersArray *pca=new AliTPCClustersArray, &ca=*pca;
ca.Setup(digp);
ca.SetClusterType("AliTPCcluster");
- ca.ConnectTree(cname);
+ ca.ConnectTree(tpcl->TreeR());
Int_t nrows=Int_t(ca.GetTree()->GetEntries());
for (Int_t n=0; n<nrows; n++) {
AliSegmentID *s=ca.LoadEntry(n);
ca.ClearRow(sec,row);
}
delete pca;
- cf->Close();
+ tpcl->UnloadRecPoints();
}
break;
case 2:
{
- char dname[100]; sprintf(dname,"TreeD_75x40_100x60_150x60_%d",event);
- TTree *TD=(TTree*)gDirectory->Get(dname);
+ tpcl->LoadDigits();
+ TTree *TD=tpcl->TreeD();
+
AliSimDigits da, *digits=&da;
TD->GetBranch("Segment")->SetAddress(&digits);
}
}
delete[] count;
- delete TD; //Thanks to Mariana Bondila
+ tpcl->UnloadDigits();
}
break;
default:
cerr<<"Invalid TPC version !\n";
- file->Close();
+ delete rl;
exit(7);
}
-
+ rl->LoadKinematics();
+ AliStack* stack = rl->Stack();
/** select tracks which are "good" enough **/
for (i=0; i<np; i++) {
if ((good[i]&0x5000) != 0x5000)
if ((good[i]&0x2800) != 0x2800) continue;
if ((good[i]&0x7FF ) < good_number) continue;
- TParticle *p = (TParticle*)gAlice->Particle(i);
-
+ TParticle *p = (TParticle*)stack->Particle(i);
+ if (p == 0x0)
+ {
+ cerr<<"Can not get particle "<<i<<endl;
+ continue;
+ }
if (p->Pt()<0.100) continue;
if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
Int_t j=p->GetFirstMother();
if (j>=0) {
- TParticle *pp = (TParticle*)gAlice->Particle(j);
+ TParticle *pp = (TParticle*)stack->Particle(j);
+ if (pp == 0x0)
+ {
+ cerr<<"Can not get particle "<<j<<endl;
+ continue;
+ }
if (pp->GetFirstMother()>=0) continue;//only one decay is allowed
/* for cascade hyperons only
Int_t jj=pp->GetFirstMother();
if (jj>=0) {
- TParticle *ppp = (TParticle*)gAlice->Particle(jj);
+ TParticle *ppp = (TParticle*)stack->Particle(jj);
if (ppp->GetFirstMother()>=0) continue;//two decays are allowed
}
*/
if (nt==max) {cerr<<"Too many good tracks !\n"; break;}
cerr<<np-i<<" \r";
}
+ rl->UnloadKinematics();
/** check if there is also information at the entrance of the TPC **/
- TTree *TH=gAlice->TreeH(); np=(Int_t)TH->GetEntries();
+
+ tpcl->LoadHits();
+ TTree *TH=tpcl->TreeH();
+ TPC->SetTreeAddress();
+ np=(Int_t)TH->GetEntries();
for (i=0; i<np; i++) {
TPC->ResetHits();
TH->GetEvent(i);
}
delete[] good;
+
+ tpcl->UnloadHits();
+ rl->UnloadgAlice();
- delete gAlice; gAlice=0;
-
- file->Close();
gBenchmark->Stop("AliTPCComparison");
gBenchmark->Show("AliTPCComparison");
return nt;
}
-
-
-