1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //Utils for identified fragmentation function (IDFF) analysis
17 //Author: Xianguo Lu (xianguo.lu@cern.ch)
19 #include "AliIDFFUtils.h"
20 #include "AliAODEvent.h"
21 #include "AliAODMCParticle.h"
22 #include "AliESDtrack.h"
24 #include "TClonesArray.h"
26 ClassImp(AliIDFFUtils);
28 AliPIDResponse * AliIDFFUtils::fPid=0x0;
30 Int_t AliIDFFUtils::PDG2Type(const Int_t pdg)
33 //conversion from pdg code to local definition of particle type
36 Int_t itype = kNOTSELECTED;
57 THnSparseD *AliIDFFUtils::GetTHn(const TString name)
63 const Int_t nvar = 11;
64 // 0 1 2 3 4 5 6 7 8 9 10
65 const TString atitle[nvar]={"TrackEta","JetPt", "TrackTPCsig", "Log10TrackP", "Log10TrackPt", "z", "xi", "pdg", "comb", "tof", "tpc"};
66 const Int_t nbins[nvar] ={ 4, 15, 1200, Nx(), 50, 30, 60, 7, 7, 7, 7};
67 const Double_t xmins[nvar]={ 0, 5, 0, Xmin(), Xmin(), 0, 0, -3.5, -3.5, -3.5, -3.5};
68 const Double_t xmaxs[nvar]={ 0.9, 20, 200, Xmax(), Xmax(), 1.2, 6, 3.5, 3.5, 3.5, 3.5};
70 THnSparseD * hh = new THnSparseD(name,"", nvar, nbins, xmins, xmaxs);
71 for(Int_t ia=0; ia<nvar; ia++){
72 hh->GetAxis(ia)->SetTitle(atitle[ia]);
81 const Double_t etas[]={0, 0.2, 0.4, 0.6, 0.9};
88 Bool_t AliIDFFUtils::HMPIDAcceptance(const AliAODTrack *track)
91 //check HMPID acceptance
95 Double_t tEta = TMath::Abs(track->Eta());
96 Double_t tPhi = track->Phi();
97 if(tPhi < 0.) tPhi += TMath::TwoPi();
98 if(tPhi > TMath::TwoPi()) tPhi -= TMath::TwoPi();
104 if(tPhi < 0.08 || tPhi > 1.12){
111 Bool_t AliIDFFUtils::HMPIDQA(const AliAODTrack *track)
114 //check HMPID PID quality
118 if(track->GetHMPIDsignal() <= 0.){
122 //check track-quality cuts
125 Float_t tX, tY, tTh, tPh;
129 track->GetHMPIDtrk(tX, tY, tTh, tPh);
130 track->GetHMPIDmip(mpX, mpY, mpQ, mpNph);
131 const Double_t dist = TMath::Sqrt((tX-mpX)*(tX-mpX)+(tY-mpY)*(tY-mpY));
133 //taking the pass 2 case for the moment
135 //Printf("Track did not pass the distance cut");
140 //have to check if this also varies with pass
141 //taking the pass 2 case for the moment
143 //Printf("Track did not pass the MipQ cut");
150 Int_t AliIDFFUtils::HMPIDType(const AliAODTrack * track)
153 //return the (locally defined) particle type judged by HMPID
157 if(!HMPIDAcceptance(track))
163 Double_t nsigma[]={-999,-999,-999};
164 nsigma[kPION] = fPid->NumberOfSigmasHMPID( track, AliPID::kPion);
165 nsigma[kKAON] = fPid->NumberOfSigmasHMPID( track, AliPID::kKaon);
166 nsigma[kPROTON] = fPid->NumberOfSigmasHMPID( track, AliPID::kProton);
168 const Double_t inclusion=2;
169 const Double_t exclusion=3;
171 if(TMath::Abs(nsigma[kPION])<inclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])>exclusion) return kPION;
172 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])<inclusion && TMath::Abs(nsigma[kPROTON])>exclusion) return kKAON;
173 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])<inclusion) return kPROTON;
180 Int_t AliIDFFUtils::TPCType(const AliAODTrack * trackptr)
183 //return the (locally defined) particle type judged by TPC
184 //use tofmode for TPC mode
187 const AliPIDResponse::EDetPidStatus tpcstatus = fPid->CheckPIDStatus(AliPIDResponse::kTPC, trackptr);
188 if(tpcstatus != AliPIDResponse::kDetPidOk)
191 Double_t nsigma[]={-999,-999,-999, -999};
192 nsigma[kPION] = fPid->NumberOfSigmasTPC( trackptr, AliPID::kPion);
193 nsigma[kKAON] = fPid->NumberOfSigmasTPC( trackptr, AliPID::kKaon);
194 nsigma[kPROTON] = fPid->NumberOfSigmasTPC( trackptr, AliPID::kProton);
195 nsigma[kELECTRON] = fPid->NumberOfSigmasTPC( trackptr, AliPID::kElectron);
197 //so that the effective region is really low momentum
198 const Double_t inclusion=5;
199 const Double_t exclusion=5;
201 //don't destroy TPC signal shape below 120
202 const Double_t maxsig = 150;
203 if(trackptr->GetTPCsignal()> maxsig){
204 if(TMath::Abs(nsigma[kPION])<inclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])>exclusion && TMath::Abs(nsigma[kELECTRON])>exclusion) return kPION;
205 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])<inclusion && TMath::Abs(nsigma[kPROTON])>exclusion && TMath::Abs(nsigma[kELECTRON])>exclusion) return kKAON;
206 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])<inclusion && TMath::Abs(nsigma[kELECTRON])>exclusion) return kPROTON;
207 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])>exclusion && TMath::Abs(nsigma[kELECTRON])<inclusion) return kELECTRON;
213 Int_t AliIDFFUtils::TOFType(const AliAODTrack * trackptr, const Int_t tofmode)
216 //return the (locally defined) particle type judged by TOF
219 //check kTOFout, kTIME, mismatch
220 const AliPIDResponse::EDetPidStatus tofstatus = fPid->CheckPIDStatus(AliPIDResponse::kTOF, trackptr);
221 if(tofstatus != AliPIDResponse::kDetPidOk)
224 Double_t nsigma[]={-999,-999,-999, -999};
225 nsigma[kPION] = fPid->NumberOfSigmasTOF( trackptr, AliPID::kPion);
226 nsigma[kKAON] = fPid->NumberOfSigmasTOF( trackptr, AliPID::kKaon);
227 nsigma[kPROTON] = fPid->NumberOfSigmasTOF( trackptr, AliPID::kProton);
228 nsigma[kELECTRON] = fPid->NumberOfSigmasTOF( trackptr, AliPID::kElectron);
230 Double_t inclusion=-999;
231 Double_t exclusion=-999;
236 else if(tofmode == 2){
240 else if(tofmode == 3){
244 else if(tofmode == 4){
249 printf("AliIDFFUtils::TOFType bad tofmode ! %d\n", tofmode); exit(1);
252 const Bool_t kpassEle = kTRUE;
254 const Double_t cutEle = 1.5;
255 //tofmode = 1x then require electron exclusion cut
257 if(TMath::Abs(nsigma[kELECTRON])> cutEle ){
266 //cut on electron for pion because the precision of pion is good and the contamination of electron can not be ignored
267 //+1 exclusion sigma in electron/pion to enforce better purity, otherwise not only pion, but also kaon is bias for jet pt 5-10 GeV/c
268 if(TMath::Abs(nsigma[kPION])<inclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])>exclusion && kpassEle) return kPION;
269 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])<inclusion && TMath::Abs(nsigma[kPROTON])>exclusion && kpassEle) return kKAON;
270 if(TMath::Abs(nsigma[kPION])>exclusion && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])<inclusion && kpassEle) return kPROTON;
271 if(TMath::Abs(nsigma[kPION])>exclusion+0.5 && TMath::Abs(nsigma[kKAON])>exclusion && TMath::Abs(nsigma[kPROTON])>exclusion && TMath::Abs(nsigma[kELECTRON])<inclusion) return kELECTRON;
276 Int_t AliIDFFUtils::CombineTPCTOF(const Int_t ktpc, const Int_t ktof)
278 //tpc and tof, if <0 only noinfo or notselected
281 else if(ktpc < 0 && ktof >= 0 )
283 else if(ktof < 0 && ktpc >= 0)
289 void AliIDFFUtils::FillTHn(THnSparseD * hh, Double_t jetpt, const AliAODTrack * track, AliAODEvent *aodevent, const Int_t tofmode) //AliMCEvent * mcevent)
295 Int_t mcpdg = kNOINFO;
297 TClonesArray *tca = dynamic_cast<TClonesArray*>(aodevent->FindListObject(AliAODMCParticle::StdBranchName()));
299 const Int_t mclabel = TMath::Abs(track->GetLabel());
301 AliAODMCParticle* gentrack = dynamic_cast<AliAODMCParticle*> (tca->At(mclabel));
303 //printf("null gentrack in AliIDFFUtils::FillTHn mclabel %d\n", mclabel);
304 mcpdg = PDG2Type(TMath::Abs(gentrack->GetPdgCode()));
308 //===========================================================================================================
310 //use tofmode for tpcmode
311 const Int_t ktpc = TPCType(track);
312 const Int_t ktof = TOFType(track, tofmode);
314 //fake kcomb by pretpc+pretof
315 const Int_t kcomb = CombineTPCTOF(ktpc, ktof);
317 //const Int_t khmpid = HMPIDType(track);
319 //===========================================================================================================
321 const Double_t eps = 1e-6;
322 const Double_t tracketa = TMath::Abs(track->Eta());
323 Double_t tracktpc = track->GetTPCsignal();
325 tracktpc = 200 - eps;
326 const Double_t tracklogmom = TMath::Log10(track->P());
327 const Double_t tracklogpt = TMath::Log10(track->Pt());
332 jetpt = zz = xi = eps;
335 else if(track->Pt()>(1-eps)*jetpt && track->Pt()<(1+eps)*jetpt){ // case z=1 : move entry to last histo bin <1
340 zz = track->Pt()/jetpt;
341 xi = TMath::Log(1/zz);
344 //===========================================================================================================
346 const Double_t vars[]={tracketa, jetpt, tracktpc, tracklogmom, tracklogpt, zz, xi, (Double_t)mcpdg, (Double_t)kcomb, (Double_t)ktof, (Double_t)ktpc};
351 //_________________________________________________________________________________
352 Bool_t AliIDFFUtils::TPCCutPIDN(const AliAODTrack * track)
358 //assuming this cut is particle type independent, then it is fine
359 //need further investigation
360 if(track->GetTPCsignalN()<60){
367 //_________________________________________________________________________________
368 Bool_t AliIDFFUtils::TPCCutMIGeo(const AliAODTrack * track, const AliVEvent* evt, TTreeStream * streamer)
374 Short_t sign = track->Charge();
380 track->GetPxPyPz(pxpypz);
382 AliExternalTrackParam * par = new AliExternalTrackParam(xyz, pxpypz, cv, sign);
385 Double_t varGeom = dummy.GetLengthInActiveZone(par,3,236, evt->GetMagneticField(), 0,0);
386 Double_t varNcr = track->GetTPCClusterInfo(3,1);
387 Double_t varNcls = track->GetTPCsignalN();
389 Bool_t cutGeom = varGeom > 1.*(130-5*TMath::Abs(1./track->Pt()));
390 Bool_t cutNcr = varNcr > 0.85*(130-5*TMath::Abs(1./track->Pt()));
391 Bool_t cutNcls = varNcls > 0.7*(130-5*TMath::Abs(1./track->Pt()));
393 Bool_t kout = cutGeom && cutNcr && cutNcls;
396 Double_t dedx = track->GetTPCsignal();
398 (*streamer)<<"tree"<<
401 "varGeom="<<varGeom<<
403 "varNcls="<<varNcls<<
405 "cutGeom="<<cutGeom<<
407 "cutNcls="<<cutNcls<<