-//Author: Anders Strand Vestbo
-//Last Modified: 5.01.2001
+//$Id$
-#include <stdio.h>
-#include <math.h>
-#include <fstream.h>
+// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
+//*-- Copyright © ASV
+
+#include "AliL3StandardIncludes.h"
#include <TFile.h>
#include <TH1.h>
#include <TParticle.h>
#include <TTree.h>
#include <TClonesArray.h>
-#include "AliRun.h"
-#include "AliSimDigits.h"
-#include "AliTPC.h"
-#include "AliTPCClustersArray.h"
-#include "AliTPCClustersRow.h"
-#include "AliTPCcluster.h"
-#include "AliTPCParam.h"
-#include "AliComplexCluster.h"
+#include <AliRun.h>
+#include <AliSimDigits.h>
+#include <AliTPC.h>
+#include <AliTPCcluster.h>
+#include <AliTPCClustersArray.h>
+#include <AliTPCClustersRow.h>
+#include <AliTPCParam.h>
+#include <AliComplexCluster.h>
+
+#if GCCVERSION == 3
+#include <fstream>
+#include <iosfwd>
+#else
+#include <fstream.h>
+#endif
-#include "AliL3Defs.h"
+#include "AliL3Logging.h"
#include "AliL3Transform.h"
#include "AliL3SpacePointData.h"
#include "AliL3Track.h"
#include "AliL3FileHandler.h"
#include "AliL3TrackArray.h"
#include "AliL3Evaluate.h"
-#include "AliL3Logging.h"
-//AliL3Evaluate
-//Class for tracking evaluation.
+#if GCCVERSION == 3
+using namespace std;
+#endif
+
+//_____________________________________________________________
+// AliL3Evaluate
+//
+// Evaluation class for tracking. Plots efficiencies etc..
+//
+
ClassImp(AliL3Evaluate)
fMcId = 0;
fMinSlice=0;
fMaxSlice=0;
- fTransform = new AliL3Transform();
}
AliL3Evaluate::AliL3Evaluate(Char_t *mcfile,Int_t *slice)
fEventFile = new TFile(mcfile,"READ");
- fParam = (AliTPCParam*)fEventFile->Get("75x40_100x60");
- fTransform = new AliL3Transform();
+ fParam = (AliTPCParam*)fEventFile->Get(AliL3Transform::GetParamName());
fMinSlice = slice[0];
fMaxSlice = slice[1];
{
//ctor to use if you do not need any rootfile.
-
fMinSlice = slice[0];
fMaxSlice = slice[1];
- fTransform = new AliL3Transform();
-
}
AliL3Evaluate::~AliL3Evaluate()
fDigitsFile->Close();
delete fDigitsFile;
}
- if(fTransform) delete fTransform;
if(fTracks) delete fTracks;
if(fPtRes) delete fPtRes;
if(fNGoodTracksPt) delete fNGoodTracksPt;
void AliL3Evaluate::Setup(Char_t *trackfile,Char_t *path)
{
//Read in the hit and track information from produced files.
+ AliL3Transform::Init(path);
fGoodFound = 0;
fGoodGen = 0;
void AliL3Evaluate::SetupSlow(Char_t *trackfile,Char_t *digitsfile,Char_t *path)
{
//Setup for using the slow simulator.
+ AliL3Transform::Init(path);
fDigitsFile = new TFile(digitsfile,"READ");
if(!fDigitsFile->IsOpen())
void AliL3Evaluate::SetupFast(Char_t *trackfile,Char_t *mcClusterfile,Char_t *path)
{
//Setup for using the fast simulator.
+ AliL3Transform::Init(path);
fIsSlow = false;
GetFastClusterIDs(path);
{
if(fIsSlow)
{
+ Char_t dname[100];
+ sprintf(dname,"TreeD_%s_0",AliL3Transform::GetParamName());
fDigitsFile->cd();
- fDigitsTree = (TTree*)fDigitsFile->Get("TreeD_75x40_100x60_0");
+ fDigitsTree = (TTree*)fDigitsFile->Get(dname);
if(!fDigitsTree)
{
LOG(AliL3Log::kError,"AliL3Evaluate::InitMC","Digits Tree")
if(!fDigitsTree->GetEvent(i)) continue;
Int_t se,ro,slice,slicerow;
fParam->AdjustSectorRow(fDigits->GetID(),se,ro);
- fTransform->Sector2Slice(slice,slicerow,se,ro);
+ AliL3Transform::Sector2Slice(slice,slicerow,se,ro);
fRowid[slice][slicerow] = i;
}
}
}
-
-
void AliL3Evaluate::DefineGoodTracks(Int_t *slice,Int_t *padrow,Int_t good_number,Char_t *fname)
{
//Loop over MC particles, and mark the good ones
Int_t sec,row,sl,lr;
AliSegmentID *s = carray.LoadEntry(i);
fParam->AdjustSectorRow(s->GetID(),sec,row);
- fTransform->Sector2Slice(sl,lr,sec,row);
+ AliL3Transform::Sector2Slice(sl,lr,sec,row);
if(sl != slice[0]) {carray.ClearRow(sec,row); continue;}
if(lr < padrow[0]) {carray.ClearRow(sec,row); continue;}
<<"TPC version "<<ver<<" does not match."<<ENDLOG;
Int_t *count = new Int_t[np]; //np number of particles.
Int_t i;
+ Float_t xyz[3];
for (i=0; i<np; i++) count[i]=0;
for(Int_t sl=slice[0]; sl<=slice[1]; sl++)
{
do {
Int_t it=fDigits->CurrentRow(), ip=fDigits->CurrentColumn();
Short_t dig = fDigits->GetDigit(it,ip);
+
+ if(dig<=fParam->GetZeroSup()) continue;
+ /*
+ if(it < fParam->GetMaxTBin()-1 && it > 0)
+ if(fDigits->GetDigit(it+1,ip) <= fParam->GetZeroSup()
+ && fDigits->GetDigit(it-1,ip) <= fParam->GetZeroSup())
+ continue;
+ */
+ AliL3Transform::Raw2Local(xyz,sec,row,ip,it);
+ if(fParam->GetPadRowRadii(sec,row)<230./250.*fabs(xyz[2]))
+ continue;
+
Int_t idx0=fDigits->GetTrackID(it,ip,0);
Int_t idx1=fDigits->GetTrackID(it,ip,1);
Int_t idx2=fDigits->GetTrackID(it,ip,2);
//printf("Checking particle %d with code %d\n",i,p->GetPdgCode());
if (p->GetFirstMother()>=0) continue; //secondary particle
- if (good[i] < good_number) continue;
+ if (good[i] < good_number || good[i]>176) continue;
if (p->Pt()<fMinGoodPt) continue;
if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
printf("Found good particle %d, nHits %d\n",i,good[i]);
{
//Make efficiency plots for tracking on several slices.
- Int_t row[2] = {0,175};
+ Int_t row[2] = {AliL3Transform::GetFirstRow(0),AliL3Transform::GetLastRow(5)};
SetMinPoints(min_points);
Int_t slice[2] = {fMinSlice,fMaxSlice};
DefineGoodTracks(slice,row,good_number,fname);
AssignIDs();
- CreateHistos(20,0,5);
+ CreateHistos(5,0,2);
printf("filling histos\n");
FillEffHistos();
printf("done fillling\n");
//Returns the MCtrackID of the belonging clusters.
//If MCLabel < 0, means that track is fake.
//Fake track means that more than 10 percent of clusters are assigned incorrectly.
-
+
+#ifdef do_mc
Int_t num_of_clusters = track->GetNumberOfPoints();
S *s=new S[num_of_clusters];
Int_t i;
UInt_t *hitnum = track->GetHitNumbers();
UInt_t id;
- Int_t **trackID = GetClusterIDs(track);
+ //Int_t **trackID = GetClusterIDs(track);
Int_t lab=123456789;
for (i=0; i<num_of_clusters; i++)
}
//Get the label of the cluster:
- //printf("label %d %d %d\n",trackID[i][0],trackID[i][1],trackID[i][2]);
- lab=abs(trackID[i][0]);
+
+ lab=abs(points[pos].fTrackID[0]);
Int_t j;
for (j=0; j<num_of_clusters; j++)
if (s[j].lab==lab || s[j].max==0) break;
continue;
}
- if (abs(trackID[i][1]) == lab ||
- abs(trackID[i][2]) == lab ) max++;
+ if (abs(points[pos].fTrackID[1]) == lab ||
+ abs(points[pos].fTrackID[2]) == lab ) max++;
}
//check if more than 10% of the clusters are incorrectly assigned (fake track):
return -lab;
}
- for(Int_t j=0; j<track->GetNumberOfPoints(); j++)
- delete [] trackID[j];
- delete [] trackID;
return lab;
-}
+#else //If we are running with mc_ids or not
+ return 0;
+#endif
+}
Int_t **AliL3Evaluate::GetClusterIDs(AliL3Track *track)
{
//sector = points[pos].fSector;
padrow = points[pos].fPadRow;
Int_t se,ro;
- fTransform->Slice2Sector(slice,padrow,se,ro);
- fTransform->Global2Raw(xyz,se,ro);
+ AliL3Transform::Slice2Sector(slice,padrow,se,ro);
+ AliL3Transform::Global2Raw(xyz,se,ro);
if(fIsSlow)
{
printf("finished creating histos\n");
}
+/*
void AliL3Evaluate::FillEffHistos()
{
//Fill the efficiency histograms.
-
+
for(Int_t i=0; i<fGoodGen; i++)
{
Double_t ptg=fGoodTracks[i].pt,pzg=fGoodTracks[i].pz;
Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi();
- printf("filling particle with pt %f and dipangle %f\n",ptg,dipangle);
+ //printf("filling particle with pt %f and dipangle %f\n",ptg,dipangle);
fNGoodTracksPt->Fill(ptg);
fNGoodTracksEta->Fill(dipangle);
Int_t found = 0;
Int_t tracklabel;
tracklabel = track->GetMCid();
- printf("evaluating track id %d\n",tracklabel);
+ //printf("evaluating track id %d\n",tracklabel);
if(TMath::Abs(tracklabel) != fGoodTracks[i].label) continue;
found=1;
if(tracklabel == fGoodTracks[i].label) {fNFoundTracksPt->Fill(ptg); fNFoundTracksEta->Fill(dipangle);}
}
}
}
+*/
+
+void AliL3Evaluate::FillEffHistos()
+{
+ //Fill the efficiency histograms.
+
+ cout<<endl<<"Note: Doing NAIVE evaluation "<<endl;
+ for(Int_t i=0; i<fGoodGen; i++)
+ {
+ Double_t ptg=fGoodTracks[i].pt,pzg=fGoodTracks[i].pz;
+ Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi();
+ //printf("filling particle with pt %f and dipangle %f\n",ptg,dipangle);
+ fNGoodTracksPt->Fill(ptg);
+ fNGoodTracksEta->Fill(dipangle);
+
+ }
+
+ for(Int_t k=0; k<fTracks->GetNTracks(); k++)
+ {
+ AliL3Track *track = fTracks->GetCheckedTrack(k);
+ if(!track) continue;
+ Int_t nHits = track->GetNumberOfPoints();
+ if(nHits < fMinPointsOnTrack) break;
+ if(track->GetPt()<fMinGoodPt) continue;
+ if(fabs(track->GetPseudoRapidity())>0.9) continue;
+
+ fNFoundTracksPt->Fill(track->GetPt()); fNFoundTracksEta->Fill(track->GetPseudoRapidity());
+ //Float_t pt=track->GetPt();
+ //fPtRes->Fill((pt-ptg)/ptg*100.);
+ //fNtuppel->Fill(ptg,pt,nHits);
+
+ }
+}
void AliL3Evaluate::CalcEffHistos(){
LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
<<AliL3Log::kDec<<"Fake tracks relative is about "<<nfake/ngood*100<<ENDLOG;
+ LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
+ <<AliL3Log::kDec<<"Naive efficiency "<<(Double_t)fGoodFound/(Double_t)fGoodGen<<ENDLOG;
+
+
fNFoundTracksPt->Sumw2(); fNGoodTracksPt->Sumw2();
fTrackEffPt->Divide(fNFoundTracksPt,fNGoodTracksPt,1,1.,"b");
fFakeTrackEffPt->Divide(fNFakeTracksPt,fNGoodTracksPt,1,1.,"b");
xyz[1] = points[pos].fY;
xyz[2] = points[pos].fZ;
padrow = points[pos].fPadRow;
- //fTransform->Global2Local(xyz,slice);
+ //AliL3Transform::Global2Local(xyz,slice);
Float_t xyz_cross[3];
track->GetCrossingPoint(padrow,xyz_cross);
//The input file to this function, contains the exact clusters calculated
//in AliTPC::Hits2ExactClusters.
-
+ cout<<"Evaluating points"<<endl;
TNtuple *ntuppel = new TNtuple("ntuppel","residuals","slice:padrow:resy:resz:zHit:pt");
- TFile *exfile = new TFile(rootfile);
-
- AliTPCParam *param = (AliTPCParam*)exfile->Get("75x40_100x60");
+ TFile *exfile = TFile::Open(rootfile);
+ if(!exfile)
+ {
+ cerr<<"Error opening rootfile "<<rootfile<<endl;
+ return 0;
+ }
+
+ AliTPCParam *param = (AliTPCParam*)exfile->Get(AliL3Transform::GetParamName());
//Get the exact clusters from file:
AliTPCClustersArray *arr = new AliTPCClustersArray;
Bool_t clusterok = arr->ConnectTree(treeName);//Segment Tree (for offline clusters)
if(!clusterok) {printf("AliL3Evaluate::EvaluatePoints : Error in clusterloading\n"); return 0;}
+ cout<<"Entering loop with "<<(Int_t)arr->GetTree()->GetEntries()<<endl;
for(Int_t i=0; i<arr->GetTree()->GetEntries(); i++)
{
//Get the exact clusters for this row:
//Get the found clusters:
Int_t slice,padrow;
- fTransform->Sector2Slice(slice,padrow,cursec,currow);
+ AliL3Transform::Sector2Slice(slice,padrow,cursec,currow);
if(slice<fMinSlice || slice>fMaxSlice) continue;
AliL3SpacePointData *points = fClusters[slice][0];
Float_t xyz_cl[3] = {points[c].fX,points[c].fY,points[c].fZ};
Float_t xyz_ex[3];
- fTransform->Global2Raw(xyz_cl,cursec,currow);
+ AliL3Transform::Global2Raw(xyz_cl,cursec,currow);
if(fDigits->GetTrackID((Int_t)rint(xyz_cl[2]),(Int_t)rint(xyz_cl[1]),0)!=mcId &&
fDigits->GetTrackID((Int_t)rint(xyz_cl[2]),(Int_t)rint(xyz_cl[1]),1)!=mcId &&
fDigits->GetTrackID((Int_t)rint(xyz_cl[2]),(Int_t)rint(xyz_cl[1]),2)!=mcId)
continue;
- fTransform->Raw2Local(xyz_ex,cursec,currow,cluster->fY,cluster->fX);
- fTransform->Raw2Local(xyz_cl,cursec,currow,xyz_cl[1],xyz_cl[2]);
+ AliL3Transform::Raw2Local(xyz_ex,cursec,currow,cluster->fY,cluster->fX);
+ AliL3Transform::Raw2Local(xyz_cl,cursec,currow,xyz_cl[1],xyz_cl[2]);
Float_t resy = xyz_cl[1] - xyz_ex[1];//cluster->GetY()
Float_t resz = xyz_cl[2] - xyz_ex[2];//cluster->GetZ()
return ntuppel;
}
-/*
-TNtuple *AliL3Evaluate::EvaluateGEANT()
+
+void AliL3Evaluate::GetCFeff(Char_t *outfile)
{
- TNtuple *ntuppel = new TNtuple("ntuppel","residuals","resy:ptgen:padrow:zHit:slice");
- Int_t good_number=175;
- Int_t row[2] = {0,175};
-
- Float_t xyz_cross[3];
- Float_t xyz_cl[3];
+ TNtuple *ntuppel = new TNtuple("ntuppel","Cluster finder efficiency","row:ncrossings:nclusters");
+
+ AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
- for(Int_t slice=fMinSlice; slice<=fMaxSlice; slice++)
+ TPC->SetParam(fParam);
+
+ Int_t ver = TPC->IsVersion();
+ LOG(AliL3Log::kInformational,"AliL3Evaluate::GetCFeff","TPC version")
+ <<"TPC version "<<ver<<" found on file"<<ENDLOG;
+
+ Int_t zero=TPC->GetParam()->GetZeroSup();
+
+ Int_t np = gAlice->GetNtrack();
+
+ Int_t crossed,recs;
+ Int_t *count = new Int_t[np]; //np number of particles.
+ Int_t i;
+ Float_t xyz[3];
+ for (i=0; i<np; i++) count[i]=0;
+ for(Int_t sl=fMinSlice; sl<=fMaxSlice; sl++)
{
- Int_t *particle_id = new Int_t[fParticles->GetEntriesFast()];
- TObjArray *good_particles = DefineGoodTracks(slice,row,good_number,particle_id);
-
- if(fMCclusterfile)
- {
- fMCclusterfile->Close();
- delete fMCclusterfile;
- fMCclusterfile = new TFile("/nfs/david/subatom/alice/data/V3.04/fast/clusters/hg_8k_v0_s1-3_e0_cl.root");
- fMCclusterfile->cd();
- }
- AliTPCClustersArray arr;
- arr.Setup(fParam);
- arr.SetClusterType("AliTPCcluster");
- Bool_t clusterok = arr.ConnectTree("Segment Tree");
- if(!clusterok)
- LOG(AliL3Log::kError,"AliL3Evaluate::DefineGoodTracks","Cluster Array")
- <<"Error loading clusters from rootfile"<<ENDLOG;
-
- for(Int_t ci=0; ci<arr.GetTree()->GetEntries(); ci++)
+ for (i=0; i<=175; i++)
{
- Int_t sec,row,sl,lr;
- AliSegmentID *s = arr.LoadEntry(ci);
- fParam->AdjustSectorRow(s->GetID(),sec,row);
- fTransform->Sector2Slice(sl,lr,sec,row);
- if(sl != slice) {arr.ClearRow(sec,row); continue;}
- //if(lr!=pr) {carray.ClearRow(sec,row); continue;}
- AliTPCClustersRow *cRow = arr.GetRow(sec,row);
- printf("evaluating slice %d row %d\n",slice,lr);
- for(Int_t j=0; j<cRow->GetArray()->GetEntriesFast(); j++)
+ crossed=0;
+ recs=0;
+ Int_t index = fRowid[sl][i];
+ if (!fDigitsTree->GetEvent(index)) continue;
+ Int_t sec,row;
+ fParam->AdjustSectorRow(fDigits->GetID(),sec,row);
+ fDigits->First();
+ do {
+ Int_t it=fDigits->CurrentRow(), ip=fDigits->CurrentColumn();
+ Short_t dig = fDigits->GetDigit(it,ip);
+
+ if(dig<=fParam->GetZeroSup()) continue;
+ if(it < fParam->GetMaxTBin()-1 && it > 0)
+ if(fDigits->GetDigit(it+1,ip) <= fParam->GetZeroSup()
+ && fDigits->GetDigit(it-1,ip) <= fParam->GetZeroSup())
+ continue;
+
+ AliL3Transform::Raw2Local(xyz,sec,row,ip,it);
+ if(fParam->GetPadRowRadii(sec,row)<230./250.*fabs(xyz[2]))
+ continue;
+
+
+ Int_t idx0=fDigits->GetTrackID(it,ip,0);
+ Int_t idx1=fDigits->GetTrackID(it,ip,1);
+ Int_t idx2=fDigits->GetTrackID(it,ip,2);
+
+ if (idx0>=0 && dig>=zero) count[idx0]+=1;
+ if (idx1>=0 && dig>=zero) count[idx1]+=1;
+ if (idx2>=0 && dig>=zero) count[idx2]+=1;
+ } while (fDigits->Next());
+
+ for (Int_t j=0; j<np; j++)
{
-
- AliTPCcluster *cluster=(AliTPCcluster*)(*cRow)[j];
- xyz_cl[1] = cluster->GetY();
- xyz_cl[2] = cluster->GetZ();
- Int_t lab=cluster->GetLabel(0);
- if(lab<0) continue;
-
- for(Int_t pa=0; pa<good_particles->GetEntriesFast(); pa++)
+ if (count[j]>1) //at least two digits at this padrow
{
- if(particle_id[pa]!=lab) continue;
- TParticle *part = (TParticle*)good_particles->UncheckedAt(pa);
- GetParticleCrossingPoint(part,slice,lr,xyz_cross);
- Double_t yres = xyz_cl[1] - xyz_cross[1];
- ntuppel->Fill(yres,part->Pt(),lr,xyz_cl[2],slice);
+ crossed++;
+ count[j]=0;
}
}
- if(arr.GetRow(sec,row))
- arr.ClearRow(sec,row);
+ AliL3SpacePointData *points = fClusters[sl][0];
+ for(UInt_t k=0; k<fNcl[sl][0]; k++)
+ {
+ if(points[k].fPadRow!=i) continue;
+ recs++;
+ }
+ ntuppel->Fill(i,crossed,recs);
}
- delete [] particle_id;
- delete good_particles;
+
}
- return ntuppel;
+ delete[] count;
+
+ TFile *file = TFile::Open(outfile,"RECREATE");
+ ntuppel->Write();
+ file->Close();
+
}
-*/
+
Bool_t AliL3Evaluate::GetParticleCrossingPoint(TParticle *part,Int_t slice,Int_t padrow,Float_t *xyz)
{
//Calcluate the crossing point between a generated particle and given padrow.
-
- Double_t kappa = 0.2*0.0029980/part->Pt();
+ Double_t kappa = AliL3Transform::GetBField()*0.0029980/part->Pt();
Double_t radius = 1/fabs(kappa);
if(part->GetPdgCode() > 0) kappa = -kappa;
Float_t angl[1] = {part->Phi()};
- fTransform->Global2LocalAngle(angl,slice);
+ AliL3Transform::Global2LocalAngle(angl,slice);
Double_t charge = -1.*kappa;
- Double_t trackPhi0 = angl[0] + charge*0.5*Pi/fabs(charge);
+ Double_t trackPhi0 = angl[0] + charge*0.5*AliL3Transform::Pi()/fabs(charge);
Double_t x0=0;
Double_t y0=0;
//printf("radius %f xc %f yc %f\n",radius,xc,yc);
- Double_t xHit = fTransform->Row2X(padrow);
+ Double_t xHit = AliL3Transform::Row2X(padrow);
xyz[0] = xHit;
Double_t aa = (xHit - xc)*(xHit - xc);
Double_t r2 = radius*radius;
Double_t yHit = xyz[1];
Double_t angle1 = atan2((yHit - yc),(xHit - xc));
- if(angle1 < 0) angle1 += 2.*Pi;
+ if(angle1 < 0) angle1 += 2.*AliL3Transform::Pi();
Double_t angle2 = atan2((0 - yc),(0 - xc));
- if(angle2 < 0) angle2 += 2.*Pi;
+ if(angle2 < 0) angle2 += 2.*AliL3Transform::Pi();
Double_t diff_angle = angle1 - angle2;
- diff_angle = fmod(diff_angle,2*Pi);
- if((charg*diff_angle) > 0) diff_angle = diff_angle - charg*2.*Pi;
+ diff_angle = fmod(diff_angle,2*AliL3Transform::Pi());
+ if((charg*diff_angle) > 0) diff_angle = diff_angle - charg*2.*AliL3Transform::Pi();
Double_t s_tot = fabs(diff_angle)*radius;
Double_t zHit = 0 + s_tot*tgl;
xyz[2] = zHit;