X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FAliTOFpidESD.cxx;h=6bb14e0b81fe8331c808f92ab0dd35c169b36a10;hb=035e7b9f34ef84cf9e00a4a331feb800802d381d;hp=2506b790e41c25fcd93f2f24e5a5d12f2b2fbbdc;hpb=c630aafd1da7fec82908f28924c025969497227d;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/AliTOFpidESD.cxx b/TOF/AliTOFpidESD.cxx index 2506b790e41..6bb14e0b81f 100644 --- a/TOF/AliTOFpidESD.cxx +++ b/TOF/AliTOFpidESD.cxx @@ -13,439 +13,176 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -//----------------------------------------------------------------- -// Implementation of the TOF PID class -// Very naive one... Should be made better by the detector experts... -// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch -//----------------------------------------------------------------- -#include "TFile.h" -#include "TTree.h" -#include "TClonesArray.h" +//-----------------------------------------------------------------// +// // +// Implementation of the TOF PID class // +// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch // +// // +//-----------------------------------------------------------------// -#include "AliTOFpidESD.h" -#include "AliESD.h" -#include "AliESDtrack.h" -#include "AliTOFdigit.h" +#include "TMath.h" +#include "AliLog.h" -#include -#include -#include "../STRUCT/AliBODY.h" -#include "../STRUCT/AliFRAMEv2.h" -#include "AliTOFv2FHoles.h" +#include "AliESDtrack.h" +#include "AliESDEvent.h" +#include "AliTOFpidESD.h" ClassImp(AliTOFpidESD) -static Int_t InitGeo() { - //gSystem->Load("libgeant321"); - //new TGeant3("C++ Interface to Geant3"); - - AliBODY *BODY = new AliBODY("BODY", "Alice envelop"); - BODY->CreateGeometry(); - - AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame"); - FRAME->SetHoles(1); - FRAME->CreateGeometry(); - - AliTOF *TOF = new AliTOFv2FHoles("TOF", "TOF with Holes"); - TOF->CreateGeometry(); - - return 0; -} - //_________________________________________________________________________ -AliTOFpidESD::AliTOFpidESD(Double_t *param) throw (const Char_t *) { +AliTOFpidESD::AliTOFpidESD(): + fSigma(0), + fRange(0), + fPmax(0) // zero at 0.5 GeV/c for pp +{ +} +//_________________________________________________________________________ +AliTOFpidESD::AliTOFpidESD(Double_t *param): + fSigma(param[0]), + fRange(param[1]), + fPmax(0) // zero at 0.5 GeV/c for pp +{ // // The main constructor // - if (InitGeo()) throw "AliTOFpidESD: can not initialize the geomtry !\n"; - - fR=376.; fDy=2.5; fDz=3.5; fN=0; fEventN=0; - - fSigma=param[0]; - fRange=param[1]; + // + //fPmax=TMath::Exp(-0.5*3*3)/fSigma; // ~3 sigma at 0.5 GeV/c for PbPb } -static Int_t DtoM(Int_t *dig, Float_t *g) { - const Int_t MAX=13; - Int_t lnam[MAX],lnum[MAX]; - - extern TVirtualMC *gMC; - - TGeant3 *geant3=(TGeant3*)gMC; - if (!geant3) {cerr<<"no geant3 found !\n"; return 1;} - - strncpy((Char_t*)(lnam+0),"ALIC",4); lnum[0]=1; - strncpy((Char_t*)(lnam+1),"B077",4); lnum[1]=1; - - //sector - switch (dig[0]) { - case 1: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=9; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 2: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=10; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 3: - strncpy((Char_t*)(lnam+2),"B074",4); lnum[2]=4; - strncpy((Char_t*)(lnam+3),"BTO2",4); lnum[3]=1; - if (dig[1]>3) lnum[3]=2; - break; - case 4: - strncpy((Char_t*)(lnam+2),"B074",4); lnum[2]=5; - strncpy((Char_t*)(lnam+3),"BTO2",4); lnum[3]=1; - if (dig[1]>3) lnum[3]=2; - break; - case 5: - strncpy((Char_t*)(lnam+2),"B074",4); lnum[2]=1; - strncpy((Char_t*)(lnam+3),"BTO2",4); lnum[3]=1; - if (dig[1]>3) lnum[3]=2; - break; - case 6: - strncpy((Char_t*)(lnam+2),"B074",4); lnum[2]=2; - strncpy((Char_t*)(lnam+3),"BTO2",4); lnum[3]=1; - if (dig[1]>3) lnum[3]=2; - break; - case 7: - strncpy((Char_t*)(lnam+2),"B074",4); lnum[2]=3; - strncpy((Char_t*)(lnam+3),"BTO2",4); lnum[3]=1; - if (dig[1]>3) lnum[3]=2; - break; - case 8: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=1; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 9: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=2; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 10: - strncpy((Char_t*)(lnam+2),"B075",4); lnum[2]=1; - strncpy((Char_t*)(lnam+3),"BTO3",4); lnum[3]=1; - if (dig[1]>4) lnum[3]=2; - break; - case 11: - strncpy((Char_t*)(lnam+2),"B075",4); lnum[2]=2; - strncpy((Char_t*)(lnam+3),"BTO3",4); lnum[3]=1; - if (dig[1]>4) lnum[3]=2; - break; - case 12: - strncpy((Char_t*)(lnam+2),"B075",4); lnum[2]=3; - strncpy((Char_t*)(lnam+3),"BTO3",4); lnum[3]=1; - if (dig[1]>4) lnum[3]=2; - break; - case 13: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=3; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 14: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=4; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 15: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=5; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 16: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=6; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 17: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=7; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - case 18: - strncpy((Char_t*)(lnam+2),"B071",4); lnum[2]=8; - strncpy((Char_t*)(lnam+3),"BTO1",4); lnum[3]=1; - break; - default: - cerr<<"Wrong sector number : "<=8 && dig[0]<=9) lnum[4]=2; - if (dig[0]>=13 && dig[0]<=18) lnum[4]=2; - strncpy((Char_t*)(lnam+5),"FLTC",4); lnum[5]=0; - break; - case 2: - strncpy((Char_t*)(lnam+4),"FTOB",4); lnum[4]=1; - if (dig[0]==1 || dig[0]==2 ) lnum[4]=2; - if (dig[0]>=8 && dig[0]<=9) lnum[4]=2; - if (dig[0]>=13 && dig[0]<=18) lnum[4]=2; - strncpy((Char_t*)(lnam+5),"FLTB",4); lnum[5]=0; - break; - case 3: - strncpy((Char_t*)(lnam+4),"FTOA",4); lnum[4]=0; - strncpy((Char_t*)(lnam+5),"FLTA",4); lnum[5]=0; - break; - case 4: - strncpy((Char_t*)(lnam+4),"FTOB",4); lnum[4]=1; - strncpy((Char_t*)(lnam+5),"FLTB",4); lnum[5]=0; - break; - case 5: - strncpy((Char_t*)(lnam+4),"FTOC",4); lnum[4]=1; - strncpy((Char_t*)(lnam+5),"FLTC",4); lnum[5]=0; - break; - default: - cerr<<"Wrong module number : "<19) { - cerr<<"Wrong strip number : "<2) { - cerr<<"Wrong z-division number : "<48) { - cerr<<"Wrong x-division number : "<Gcvolu(); gcvolu->nlevel=0; - Int_t err=geant3->Glvolu(11,lnam,lnum); //11-th level - if (err) {cout<Gdtom(l,g,1); - return 0; + return fPmax*ref2/p2beta2; } -Int_t AliTOFpidESD::LoadClusters(const TFile *df) { - //-------------------------------------------------------------------- - //This function loads the TOF clusters - //-------------------------------------------------------------------- - if (!((TFile *)df)->IsOpen()) { - Error("LoadClusters","file with the TOF digits has not been open !\n"); - return 1; - } - - Char_t name[100]; - sprintf(name,"TreeD%d",GetEventNumber()); - TTree *dTree=(TTree*)((TFile *)df)->Get(name); - if (!dTree) { - Error("LoadClusters"," can't get the tree with digits !\n"); - return 1; - } - TBranch *branch=dTree->GetBranch("TOF"); - if (!branch) { - Error("LoadClusters"," can't get the branch with the TOF digits !\n"); - return 1; - } - - TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy; - branch->SetAddress(&digits); - - dTree->GetEvent(0); - Int_t nd=digits->GetEntriesFast(); - Info("LoadClusters","number of digits: %d",nd); - - for (Int_t i=0; iUncheckedAt(i); - Int_t dig[5]; Float_t g[3]; - dig[0]=d->GetSector(); - dig[1]=d->GetPlate(); - dig[2]=d->GetStrip(); - dig[3]=d->GetPadz(); - dig[4]=d->GetPadx(); - - DtoM(dig,g); - - Double_t h[5]; - h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); - h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2]; - h[3]=d->GetTdc(); h[4]=d->GetAdc(); +//_________________________________________________________________________ +Int_t AliTOFpidESD::MakePID(AliESDEvent *event, Double_t timeZero) +{ + // + // This function calculates the "detector response" PID probabilities + // Just for a bare hint... - AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks()); - InsertCluster(cl); - } + AliDebug(1,Form("TOF PID Parameters: Sigma (ps)= %f, Range= %f",fSigma,fRange)); + AliDebug(1,"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n"); - delete dTree; - return 0; -} + Int_t ntrk=event->GetNumberOfTracks(); + AliESDtrack **tracks=new AliESDtrack*[ntrk]; -Int_t AliTOFpidESD::LoadClusters(TTree *dTree) { - //-------------------------------------------------------------------- - //This function loads the TOF clusters - //-------------------------------------------------------------------- - TBranch *branch=dTree->GetBranch("TOF"); - if (!branch) { - Error("LoadClusters"," can't get the branch with the TOF digits !\n"); - return 1; + Int_t i; + for (i=0; iGetTrack(i); + tracks[i]=t; } - TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy; - branch->SetAddress(&digits); - - dTree->GetEvent(0); - Int_t nd=digits->GetEntriesFast(); - Info("LoadClusters","number of digits: %d",nd); + for (i=0; iGetStatus()&AliESDtrack::kTOFout)==0) continue; + if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue; + Double_t tof=t->GetTOFsignal()-timeZero; + Double_t time[10]; t->GetIntegratedTimes(time); + Double_t p[10]; + Double_t mom=t->GetP(); + Bool_t mismatch=kTRUE, heavy=kTRUE; + for (Int_t j=0; j0.5) dpp=0.01*mom; + Double_t sigma=dpp*time[j]/(1.+ mom*mom/(mass*mass)); + sigma=TMath::Sqrt(sigma*sigma + fSigma*fSigma); + if (TMath::Abs(tof-time[j]) > fRange*sigma) { + p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma; + } else + p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma))/sigma; - for (Int_t i=0; iUncheckedAt(i); - Int_t dig[5]; Float_t g[3]; - dig[0]=d->GetSector(); - dig[1]=d->GetPlate(); - dig[2]=d->GetStrip(); - dig[3]=d->GetPadz(); - dig[4]=d->GetPadx(); + // Check the mismatching + Double_t pm=GetMismatchProbability(mom,mass); + if (p[j]>pm) mismatch=kFALSE; - DtoM(dig,g); + // Check for particles heavier than (AliPID::kSPECIES - 1) + if (tof < (time[j] + fRange*sigma)) heavy=kFALSE; - Double_t h[5]; - h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); - h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2]; - h[3]=d->GetTdc(); h[4]=d->GetAdc(); + } - AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks()); - InsertCluster(cl); - } + if (mismatch) + for (Int_t j=0; jSetTOFpid(p); -void AliTOFpidESD::UnloadClusters() { - //-------------------------------------------------------------------- - //This function unloads TOF clusters - //-------------------------------------------------------------------- - for (Int_t i=0; iResetStatus(AliESDtrack::kTOFpid); -Int_t AliTOFpidESD::InsertCluster(AliTOFcluster *c) { - //-------------------------------------------------------------------- - //This function adds a cluster to the array of clusters sorted in Z - //-------------------------------------------------------------------- - if (fN==kMaxCluster) { - Error("InsertCluster","Too many clusters !\n"); - return 1; } - if (fN==0) {fClusters[fN++]=c; return 0;} - Int_t i=FindClusterIndex(c->GetZ()); - memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*)); - fClusters[i]=c; fN++; - + delete[] tracks; + return 0; } -Int_t AliTOFpidESD::FindClusterIndex(Double_t z) const { - //-------------------------------------------------------------------- - // This function returns the index of the nearest cluster - //-------------------------------------------------------------------- - if (fN==0) return 0; - if (z <= fClusters[0]->GetZ()) return 0; - if (z > fClusters[fN-1]->GetZ()) return fN; - Int_t b=0, e=fN-1, m=(b+e)/2; - for (; b fClusters[m]->GetZ()) b=m+1; - else e=m; - } - return m; -} - //_________________________________________________________________________ -Int_t AliTOFpidESD::MakePID(AliESD *event) +Int_t AliTOFpidESD::MakePID(AliESDEvent *event) { // // This function calculates the "detector response" PID probabilities // Just for a bare hint... - static const Double_t masses[]={ - 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613 - }; - Int_t ntrk=event->GetNumberOfTracks(); - Int_t nmatch=0; - for (Int_t i=0; iGetTrack(i); + tracks[i]=t; + } - if ((t->GetStatus()&AliESDtrack::kTRDout)==0) continue; + for (i=0; iGetStatus()&AliESDtrack::kTOFout)==0) continue; if ((t->GetStatus()&AliESDtrack::kTIME)==0) continue; - - Double_t x,par[5]; t->GetExternalParameters(x,par); - Double_t cov[15]; t->GetExternalCovariance(cov); - - Double_t dphi2=3*3*(cov[0] + fDy*fDy/12.)/fR/fR; - Double_t dz=3*TMath::Sqrt(cov[2] + fDz*fDz/12.); - - Double_t phi=TMath::ATan2(par[0],x) + t->GetAlpha(); - if (phi<-TMath::Pi()) phi+=2*TMath::Pi(); - if (phi>=TMath::Pi()) phi-=2*TMath::Pi(); - Double_t z=par[1]; - - Double_t d2max=1000.; - Int_t index=-1; - for (Int_t k=FindClusterIndex(z-dz); kGetZ() > z+dz) break; - if (c->IsUsed()) continue; - - Double_t dphi=TMath::Abs(c->GetPhi()-phi); - if (dphi>TMath::Pi()) dphi-=TMath::Pi(); - if (dphi*dphi > dphi2) continue; - - Double_t d2=dphi*dphi*fR*fR + (c->GetZ()-z)*(c->GetZ()-z); - if (d2 > d2max) continue; - - d2max=d2; - index=k; - } - - if (index<0) { - //Info("MakePID","matching failed ! %d",TMath::Abs(t->GetLabel())); - continue; - } - - nmatch++; - - AliTOFcluster *c=fClusters[index]; - + Double_t tof=t->GetTOFsignal(); Double_t time[10]; t->GetIntegratedTimes(time); - Double_t tof=50*c->GetTDC(); // in ps - Double_t p[10]; Double_t mom=t->GetP(); - for (Int_t j=0; j0.5) dpp=0.01*mom; + Double_t sigma=dpp*time[j]/(1.+ mom*mom/(mass*mass)); sigma=TMath::Sqrt(sigma*sigma + fSigma*fSigma); if (TMath::Abs(tof-time[j]) > fRange*sigma) { - p[j]=TMath::Exp(-0.5*fRange*fRange); - continue; - } - p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma)); + p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma; + } else + p[j]=TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sigma*sigma))/sigma; + + // Check the mismatching + Double_t pm=GetMismatchProbability(mom,mass); + if (p[j]>pm) mismatch=kFALSE; + + // Check for particles heavier than (AliPID::kSPECIES - 1) + if (tof < (time[j] + fRange*sigma)) heavy=kFALSE; + } - //if (c->GetLabel(0)!=TMath::Abs(t->GetLabel())) continue; + if (mismatch) + for (Int_t j=0; jSetTOFsignal(tof); - t->SetTOFcluster(index); t->SetTOFpid(p); - c->Use(); - } + if (heavy) t->ResetStatus(AliESDtrack::kTOFpid); - Info("MakePID","Number of matched ESD track: %d",nmatch); + } + delete[] tracks; + return 0; } +