StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmbeddingQATrack.cxx
1 /****************************************************************************************************
2  * $Id: StEmbeddingQATrack.cxx,v 1.19 2019/07/10 05:45:56 zhux Exp $
3  * $Log: StEmbeddingQATrack.cxx,v $
4  * Revision 1.19 2019/07/10 05:45:56 zhux
5  * added option for btof pid for primary real tracks
6  *
7  * Revision 1.18 2011/04/01 05:00:20 hmasui
8  * Move track cuts into StEmbeddingQAUtilities, added global momentum for embedding
9  *
10  * Revision 1.17 2011/02/11 23:22:12 hmasui
11  * Added missing charge check in isNSigmaOk(), and error check for geantid
12  *
13  * Revision 1.16 2011/02/11 03:55:50 hmasui
14  * Change geantid type to integer
15  *
16  * Revision 1.15 2011/02/09 20:56:07 hmasui
17  * Fix initialization of particle id's for real data
18  *
19  * Revision 1.14 2011/01/12 21:36:15 hmasui
20  * Add nHitsFit/nHitsPoss cut
21  *
22  * Revision 1.13 2010/08/13 21:55:36 hmasui
23  * Separate charge for pi/K/p in isNSigmaOk() function
24  *
25  * Revision 1.12 2010/08/04 21:16:50 hmasui
26  * Use MC phi angle for reconstructed embedding tracks
27  *
28  * Revision 1.11 2010/07/12 21:28:55 hmasui
29  * Use StEmbeddingQAUtilities::getParticleDefinition() instead of StParticleTable
30  *
31  * Revision 1.10 2010/05/14 19:49:09 hmasui
32  * Add rapidity cut
33  *
34  * Revision 1.9 2010/04/24 20:20:15 hmasui
35  * Add geant process, and modift the type of parent, parent-parent geantid to match the data members in minimc tree
36  *
37  * Revision 1.8 2010/02/16 02:11:49 hmasui
38  * Add parent-parent geantid
39  *
40  * Revision 1.7 2010/02/12 16:24:54 hmasui
41  * Fix the primary vertex subtraction for nhit
42  *
43  * Revision 1.6 2009/12/22 21:39:30 hmasui
44  * Add comments for functions and members
45  *
46  ****************************************************************************************************/
47 
48 #include <assert.h>
49 #include <iostream>
50 
51 #include "TMath.h"
52 
53 #include "StMessMgr.h"
57 #include "StMuDSTMaker/COMMON/StMuTrack.h"
58 #include "StParticleDefinition.hh"
59 
60 #include "StEmbeddingQATrack.h"
61 #include "StEmbeddingQAUtilities.h"
62 
63 using namespace std ;
64 
65 ClassImp(StEmbeddingQATrack)
66 
67 //____________________________________________________________________________________________________
69  : mNCommonHit(-10), mParentParentGeantId(-10), mParentGeantId(-10), mGeantId(-10), mGeantProcess(-10),
70  mNHit(-10), mNHitPoss(-10), mCharge(-10),
71  mVectorMc(-9999., -9999., -9999., -9999.),
72  mVectorRc(-9999., -9999., -9999., -9999.),
73  mPhi(-9999.), mdEdx(-9999.), mDcaGl(-9999.),
74  mNSigmaElectron(-9999.), mNSigmaPion(-9999.), mNSigmaKaon(-9999.), mNSigmaProton(-9999.),
75  mName("MC")
76 {
78 }
79 
80 //____________________________________________________________________________________________________
82  : mNCommonHit(-10),
83  mParentParentGeantId(-10), mParentGeantId(track.parentGeantId()), mGeantId(track.geantId()), mGeantProcess(-10),
84  mNHit(track.nHitMc()), mNHitPoss(-10), mCharge(track.chargeMc()),
85  mVectorMc(track.pxMc(), track.pyMc(), track.pzMc(),
86  TMath::Sqrt(track.pMc()*track.pMc() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track.geantId())->mass(),2.0))),
87  mVectorRc(-9999., -9999., -9999., -9999.), // No reconstructed momentum for MC tracks
88  mPhi(track.phiMc()), mdEdx(-9999.), mDcaGl(-9999.),
89  mNSigmaElectron(-9999.), mNSigmaPion(-9999.), mNSigmaKaon(-9999.), mNSigmaProton(-9999.),
90  mName(name)
91 {
94 }
95 
96 //____________________________________________________________________________________________________
98  : mNCommonHit(track->commonHits()),
99  mParentParentGeantId(-10), mParentGeantId(track->parentGeantId()), mGeantId(track->geantId()), mGeantProcess(-10),
100  mNHit(track->fitPts()), mNHitPoss(track->nPossiblePts()), mCharge(track->charge()),
101  mVectorMc(track->pxMc(), track->pyMc(), track->pzMc(),
102  TMath::Sqrt(track->pMc()*track->pMc() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track->geantId())->mass(),2.0))),
103  mVectorRc(track->pxPr(), track->pyPr(), track->pzPr(),
104  TMath::Sqrt(track->pPr()*track->pPr() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track->geantId())->mass(),2.0))),
105  mVectorGl(track->pxGl(), track->pyGl(), track->pzGl(),
106  TMath::Sqrt(track->pGl()*track->pGl() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track->geantId())->mass(),2.0))),
107  mPhi(track->phiMc()), mdEdx(track->dedx()), mDcaGl(track->dcaGl()),
108  mNSigmaElectron(-9999.), mNSigmaPion(-9999.), mNSigmaKaon(-9999.), mNSigmaProton(-9999.),
109  mName(name)
110 {
113 }
114 
115 //____________________________________________________________________________________________________
117  : mNCommonHit(track->commonHits()),
118  mParentParentGeantId(track->mParentParentGeantId), mParentGeantId(track->parentGeantId()), mGeantId(track->geantId()),
119  mGeantProcess(track->mGeantProcess),
120  mNHit(track->fitPts()), mNHitPoss(track->nPossiblePts()), mCharge(track->charge()),
121  mVectorMc(track->pxMc(), track->pyMc(), track->pzMc(),
122  TMath::Sqrt(track->pMc()*track->pMc() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track->geantId())->mass(),2.0))),
123  mVectorRc(track->pxPr(), track->pyPr(), track->pzPr(),
124  TMath::Sqrt(track->pPr()*track->pPr() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track->geantId())->mass(),2.0))),
125  mVectorGl(track->pxGl(), track->pyGl(), track->pzGl(),
126  TMath::Sqrt(track->pGl()*track->pGl() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(track->geantId())->mass(),2.0))),
127  mPhi(track->phiMc()), mdEdx(track->dedx()), mDcaGl(track->dcaGl()),
128  mNSigmaElectron(-9999.), mNSigmaPion(-9999.), mNSigmaKaon(-9999.), mNSigmaProton(-9999.),
129  mName(name)
130 {
134 }
135 
136 //____________________________________________________________________________________________________
137 StEmbeddingQATrack::StEmbeddingQATrack(const TString name, const StMuTrack& track, const Int_t geantid, const Bool_t btof)
138  : mNCommonHit(0), mParentParentGeantId(0), mParentGeantId(0), mGeantId(geantid), mGeantProcess(0),
139  mNHit(track.nHitsFit(kTpcId)), mNHitPoss(track.nHitsPoss(kTpcId)), mCharge(track.charge()),
140  mVectorMc(-9999., -9999., -9999., -9999.), // No MC momentum for real tracks
141  mVectorRc(track.p().x(), track.p().y(), track.p().z(),
142  TMath::Sqrt(track.p().mag2() + TMath::Power(StEmbeddingQAUtilities::instance()->getParticleDefinition(geantid)->mass(),2.0))),
143  mVectorGl(-9999., -9999., -9999., -9999.), // Global momentum will be filled in the mVectorRc for global tracks
144  mPhi(track.phi()), mdEdx(track.dEdx()), mDcaGl(track.dcaGlobal().mag()),
145  mNSigmaElectron(btof?track.btofPidTraits().sigmaElectron():track.nSigmaElectron()), mNSigmaPion(btof?track.btofPidTraits().sigmaPion():track.nSigmaPion()), mNSigmaKaon(btof?track.btofPidTraits().sigmaKaon():track.nSigmaKaon()), mNSigmaProton(btof?track.btofPidTraits().sigmaProton():track.nSigmaProton()),
146  mName(name)
147 {
151 
152  // Sep/21/2009
153  // - Get NHit only from TPC in order to avoid the SVT/SSD hit, and remove primary vertex from the NHit
154  // - Get nSigma(pi/K/p) for real data
155 }
156 
157 //____________________________________________________________________________________________________
159 {
161 }
162 
163 //__________________________________________________________________________________________
165 {
169  const Float_t pt = (utility->isReal(mName)) ? getPtRc() : getPtMc() ;
170  const Float_t eta = (utility->isReal(mName)) ? getEtaRc() : getEtaMc() ;
171 
172  const Bool_t isPtOk = utility->isPtOk(pt) ;
173  const Bool_t isEtaOk = utility->isEtaOk(eta) ;
174 
175  return (StEmbeddingQAUtilities::instance()->isMc(mName)) ? isPtOk : (isPtOk && isEtaOk) ;
176 }
177 
178 //__________________________________________________________________________________________
179 Bool_t StEmbeddingQATrack::isRapidityOk(const Double_t ycut) const
180 {
183  const Float_t y = (StEmbeddingQAUtilities::instance()->isReal(mName)) ? getRapidityRc() : getRapidityMc() ;
184 
185  return (StEmbeddingQAUtilities::instance()->isMc(mName)) ? kTRUE : (TMath::Abs(y)<ycut) ;
186 }
187 
188 //__________________________________________________________________________________________
190 {
193  const Bool_t isNHitOk = (StEmbeddingQAUtilities::instance()->isMc(mName)) ? kTRUE
194  : StEmbeddingQAUtilities::instance()->isNHitsFitOk(mNHit)
195  ;
196 
197  return isCommonHitOk() && isNHitOk ;
198 }
199 
200 //__________________________________________________________________________________________
202 {
204  const Float_t ratio = (mNHitPoss>0) ? (Float_t)mNHit/(Float_t)mNHitPoss : -1.0 ;
205 
206  return (StEmbeddingQAUtilities::instance()->isMc(mName)) ? kTRUE
207  : StEmbeddingQAUtilities::instance()->isNHitToNPossOk(ratio) ;
208 }
209 
210 //__________________________________________________________________________________________
212 {
215 
216  return (StEmbeddingQAUtilities::instance()->isMc(mName)) ? kTRUE
217  : StEmbeddingQAUtilities::instance()->isDcaOk(mDcaGl) ;
218 }
219 
220 //__________________________________________________________________________________________
222 {
224  // Use the 'isNHitsFitOk()' function for common hits
225 
226  return (StEmbeddingQAUtilities::instance()->isEmbedding(mName)) ? StEmbeddingQAUtilities::instance()->isNHitsFitOk(mNCommonHit)
227  : kTRUE ;
228 }
229 
230 //__________________________________________________________________________________________
231 Bool_t StEmbeddingQATrack::isNSigmaOk(const Int_t geantid) const
232 {
234 
236 
238  if ( !utility->isReal(mName) ) return kTRUE ;
239 
241  if ( !utility->isEPiKP(geantid) ) return kTRUE ;
242 
244  const Bool_t isChargeOk = utility->getParticleDefinition(geantid)->charge() == mCharge ;
245  if(!isChargeOk) return kFALSE ;
246 
249  if( mCharge < 0 ){
250  // Negative charged particles
251  if ( utility->isElectron(geantid) ) return utility->isNSigmaOk(mNSigmaElectron) ;
252  else if ( utility->isPiMinus(geantid) ) return utility->isNSigmaOk(mNSigmaPion) ;
253  else if ( utility->isKMinus(geantid) ) return utility->isNSigmaOk(mNSigmaKaon) ;
254  else if ( utility->isPBar(geantid) ) return utility->isNSigmaOk(mNSigmaProton) ;
255  else{
257  LOG_ERROR << "StEmbeddingQATrack::isNSigmaOk Geant id is not e, pi, K or p, geantid= " << geantid << endm;
258  LOG_ERROR << "StEmbeddingQATrack::isNSigmaOk Please check geantid, real data QA should only contain e, pi, K and p" << endm;
259  assert(0);
260  }
261  }
262  else if ( mCharge > 0 ) {
263  // Positive charged particles
264  if ( utility->isPositron(geantid) ) return utility->isNSigmaOk(mNSigmaElectron) ;
265  else if ( utility->isPiPlus(geantid) ) return utility->isNSigmaOk(mNSigmaPion) ;
266  else if ( utility->isKPlus(geantid) ) return utility->isNSigmaOk(mNSigmaKaon) ;
267  else if ( utility->isProton(geantid) ) return utility->isNSigmaOk(mNSigmaProton) ;
268  else{
270  LOG_ERROR << "StEmbeddingQATrack::isNSigmaOk Geant id is not e, pi, K or p, geantid= " << geantid << endm;
271  LOG_ERROR << "StEmbeddingQATrack::isNSigmaOk Please check geantid, real data QA should only contain e, pi, K and p" << endm;
272  assert(0);
273  }
274  }
275  else{
277  LOG_ERROR << "StEmbeddingQATrack::isNSigmaOk Charge == 0, charge=" << mCharge << ", geantid= " << geantid << endm;
278  LOG_ERROR << "StEmbeddingQATrack::isNSigmaOk Please check geantid, real data QA should only contain e, pi, K and p" << endm;
279  assert(0);
280  }
281 }
282 
283 //____________________________________________________________________________________________________
285 {
287 
288  return mVectorMc ;
289 }
290 
291 //____________________________________________________________________________________________________
293 {
295 
296  return mVectorRc ;
297 }
298 
299 //____________________________________________________________________________________________________
301 {
303 
304  return getVectorRc() ;
305 }
306 
307 //____________________________________________________________________________________________________
309 {
311 
312  return mVectorGl ;
313 }
314 
315 //____________________________________________________________________________________________________
317 {
319 
320  LOG_INFO << "#----------------------------------------------------------------------------------------------------" << endm;
321  LOG_INFO << Form("StEmbeddingQATrack::print() : Track informations (%s)", mName.Data()) << endm;
322  LOG_INFO << " getNCommonHit() " << getNCommonHit() << endm;
323  LOG_INFO << " getParentParentGeantId() " << getParentParentGeantId() << endm;
324  LOG_INFO << " getParentGeantId() " << getParentGeantId() << endm;
325  LOG_INFO << " getGeantId() " << getGeantId() << endm;
326  LOG_INFO << " getGeantProcess() " << getGeantProcess() << endm;
327  LOG_INFO << " getNHit() " << getNHit() << endm;
328  LOG_INFO << " getMass() (MC, RC) (" << getMassMc() << ", " << getMassRc() << ")" << endm;
329  LOG_INFO << " getPt() (MC, RC) (" << getPtMc() << ", " << getPtRc() << ")" << endm;
330  LOG_INFO << " getPx() (MC, RC) (" << getPxMc() << ", " << getPxRc() << ")" << endm;
331  LOG_INFO << " getPy() (MC, RC) (" << getPyMc() << ", " << getPyRc() << ")" << endm;
332  LOG_INFO << " getPz() (MC, RC) (" << getPzMc() << ", " << getPzRc() << ")" << endm;
333  LOG_INFO << " getP() (MC, RC) (" << getPMc() << ", " << getPRc() << ")" << endm;
334  LOG_INFO << " getEta() (MC, RC) (" << getEtaMc() << ", " << getEtaRc() << ")" << endm;
335  LOG_INFO << " getPhi() " << getPhi() << endm;
336  LOG_INFO << " getdEdx() " << getdEdx() << endm;
337  LOG_INFO << " getDcaGl() " << getDcaGl() << endm;
338  LOG_INFO << "#----------------------------------------------------------------------------------------------------" << endm;
339 }
340 
341 
void print() const
Get nsigma for protons/anti-protons.
Float_t getPtMc() const
Get MC particle mass.
Float_t getPxRc() const
Get reconstructed transverse momentum (primary)
Bool_t isKPlus(const Int_t geantid) const
Check the input geantid is pi-.
Short_t getNCommonHit() const
Get reconstructed 4-momentum (global)
Float_t getRapidityRc() const
Get reconstructed pseudorapidity (primary)
Bool_t isEPiKP(const Int_t geantid) const
Check the input geantid is protons.
Float_t getPtRc() const
Get reconstructed particle mass (primary)
Bool_t isReal(const TString name) const
Check whether the track is embedding pair or not.
Int_t getParentParentGeantId() const
Get number of common hits.
Float_t getPRc() const
Get reconstructed pz (primary)
Bool_t isElectron(const Int_t geantid) const
Check whether the track is real track or not.
Int_t getParentGeantId() const
Get parent geant id.
Float_t getPyMc() const
Get MC px.
Float_t getPzRc() const
Get reconstructed py (primary)
Bool_t isDcaOk() const
Nhits/NhitsPoss cut.
Bool_t isPBar(const Int_t geantid) const
Check the input geantid is p.
Float_t getPhi() const
Get reconstructed rapidity (primary)
Float_t getPxMc() const
Get MC transverse momentum.
Short_t getNHit() const
Get geant process.
StParticleDefinition * getParticleDefinition(const UInt_t geantid) const
runnumber = runid - (year - 2000 + 1) * 10^6
Bool_t isPiMinus(const Int_t geantid) const
Check the input geantid is pi+.
Bool_t isProton(const Int_t geantid) const
Check the input geantid is K-.
Float_t getdEdx() const
Get azimuthal angle.
Int_t getGeantId() const
Get parent geant id.
Double_t getMassRc() const
Get MC rapidity.
StEmbeddingQATrack()
Default constructor.
StLorentzVectorD getVectorMc() const
Float_t getPyRc() const
Get reconstructed px (primary)
Bool_t isPositron(const Int_t geantid) const
Check the input geantid is e-.
StLorentzVectorD getVectorRc() const
Get MC 4-momentum.
Bool_t isNHitOk() const
Rapidity cut.
Bool_t isNHitToNPossOk() const
Nhits cut.
static StEmbeddingQAUtilities * instance()
Get instance.
virtual ~StEmbeddingQATrack()
Destructor.
Float_t getEtaMc() const
Get MC momentum.
Float_t getPMc() const
Get MC pz.
Bool_t isCommonHitOk() const
Dca cut.
Bool_t isKMinus(const Int_t geantid) const
Check the input geantid is K+.
Bool_t isNSigmaOk(const Int_t geantid) const
Common hit cut.
StLorentzVectorD getVectorGl() const
Get reconstructed 4-momentum (primary &lt;- return getVectorRc())
Int_t getGeantProcess() const
Get geant id.
Bool_t isRapidityOk(const Double_t ycut) const
Pt and eta cuts.
for simplicity, this contains both the rc and mc track information.
Float_t getEtaRc() const
Get reconstructed momentum (primary)
Definition of Pair for Contamination tracks (secondary tracks, weak decay tracks) ...
Float_t getDcaGl() const
Get dE/dx in keV unit.
Bool_t isPtAndEtaOk() const
Float_t getRapidityMc() const
Get MC pseudorapidity.
StLorentzVectorD getVectorPr() const
Get reconstructed 4-momentum (primary)
Bool_t isPtOk(const Float_t pt) const
Track and event cuts.
Bool_t isMc(const TString name) const
Category id from category name.
Float_t getPzMc() const
Get MC py.
Bool_t isPiPlus(const Int_t geantid) const
Check the input geantid is e+.
Persistent MC track class.
Double_t getMassMc() const
Get charge.