1 #include "StTruthTestMaker.h"
5 #include "StMuDSTMaker/COMMON/StMuDst.h"
6 #include "StMuDSTMaker/COMMON/StMuTrack.h"
7 #include "StMuDSTMaker/COMMON/StMuDebug.h"
9 #include "TDataSetIter.h"
10 #include "tables/St_g2t_track_Table.h"
14 #include "StarGenerator/EVENT/StarGenEvent.h"
15 #include "StarGenerator/EVENT/StarGenParticle.h"
28 const Float_t invCut = 0.12000 * 3.0;
29 const Float_t etaCut = 0.01200 * 3.0;
30 const Float_t phiCut = 0.01900 * 3.0;
31 const Float_t absEtaCut = 1.0;
33 #define Res(x) TMath::Abs( x##R - x##T )
35 #define MUDST_CUT qaTruth < 95 || track -> nHits() < 10
38 Int_t StTruthTestMaker::Init()
40 hMatchedEta =
new TH2F(
"hMatchedEta",
";#eta thrown;#eta reco",201,-1.005,1.005,201,-1.005,1.005);
41 hMatchedPhi =
new TH2F(
"hMatchedPhi",
";#phi thrown;#phi reco",201,-1.005*TMath::Pi(),1.005*TMath::Pi(),201,-1.005*TMath::Pi(),1.005*TMath::Pi());
42 hMatchedPt =
new TH2F(
"hMatchedPt",
";p_{T} thrown;p_{T} reco",200,0.,10.,200,0.,10.);
43 hMatchedInv =
new TH2F(
"hMatchedInv",
";1/p_{T} thrown;1/p_{T} reco",200,0.,10.,200,0.,10.);
44 hMatchedPID =
new TH1F(
"hMatchedPID",
"PID of matched particles",2112*2+1.0,-2112.5,+2112.5);
45 TH1Helper::SetCanRebin(hMatchedPID);
46 hMatchedQA =
new TH1F(
"hMatchedQA",
"QA truth of matched tracks",101,-0.5,100.5);
48 hMatchedEtaRes =
new TH1F(
"hMatchedEtaRes",
";#eta resolution",201,-0.2*1.005,0.2*1.005);
49 hMatchedPhiRes =
new TH1F(
"hMatchedPhiRes",
";#phi resolution",201,-0.2*1.005,0.2*1.005);
50 hMatchedPtRes =
new TH1F(
"hMatchedPtRes",
";p_{T} resolution",201,-1.005,1.005);
51 hMatchedInvRes =
new TH1F(
"hMatchedInvRes",
";1/p_{T} resolution",201,-1.005,1.005);
53 hNumMismatched =
new TH1F(
"hNumMismatched",
"Number of mismatched tracks / event;N mismatched",11,-0.5,10.5);
54 hPerMismatched =
new TH1F(
"hPerMismatched",
"Percentage of mismatched globals / event;N mismatched/total",21,-0.025,1.025);
55 hPidMismatched =
new TH1F(
"hPidMismatched",
"PID of mismatched globals",2112*2+1.0,-2112.5,+2112.5);
56 TH1Helper::SetCanRebin(hPidMismatched);
58 TH1 *hList[]={hMatchedEta, hMatchedPhi, hMatchedPt, hMatchedPID,hMatchedEtaRes, hMatchedPhiRes, hMatchedPtRes, hNumMismatched,hPerMismatched, hPidMismatched, hMatchedInv, hMatchedInvRes, hMatchedQA};
62 for ( UInt_t i=0;i<
sizeof(hList)/
sizeof(TH1*);i++ ) {
71 TString name=GetName();
72 if ( name==
"testGeant" ) mDoGeant =
true;
73 else mDoGeant =
false;
82 if ( mDoGeant ) MakeGeant();
88 Int_t StTruthTestMaker::MakeGeant()
91 static Bool_t first =
true;
101 map< Int_t, StMuTrack * > muTrackMap;
104 StMuEvent *muEvent = muDst -> event(); assert(muEvent);
106 { Int_t ntracks = muDst -> globalTracks() -> GetEntries();
107 for ( Int_t itrack = 0; itrack < ntracks; itrack++ )
112 Int_t idTruth = track->idTruth();
113 Int_t qaTruth = track->qaTruth();
116 if ( MUDST_CUT )
continue;
118 if ( idTruth ) muTrackMap[idTruth] = track;
133 TDataSet *geant = GetDataSet(
"geant"); assert(geant);
135 St_g2t_track *g2t_trackTable = (St_g2t_track *)geantIter(
"g2t_track");
136 g2t_track_st *trackTable = (g2t_track_st *)g2t_trackTable->GetTable();
139 g2t_trackTable->Print();
143 cout <<
"-- G2T Table Event Record ----------------------------------------" << endl;
149 { Int_t ntracks = g2t_trackTable->GetNRows();
150 for ( Int_t itrack = 0; itrack<ntracks; itrack++ )
153 Int_t key = trackTable[itrack].id;
154 Int_t pid = trackTable[itrack].eg_pid;
155 Int_t lab = trackTable[itrack].eg_label;
158 if ( !lab )
continue;
162 if ( !muTrack )
continue;
168 Int_t qaTruth = muTrack->qaTruth();
169 Int_t idTruth = muTrack->idTruth(); assert(idTruth==key);
173 Float_t etaR = muTrack->
eta();
174 Float_t phiR = muTrack->
phi();
175 Float_t ptR = muTrack->
pt();
176 Float_t invR = (ptR>0)? 1.0/ptR : 999;
179 Float_t etaT = trackTable[itrack].eta;
180 Float_t ptT = trackTable[itrack].pt;
181 Float_t px = trackTable[itrack].p[0];
182 Float_t py = trackTable[itrack].p[1];
183 Float_t pz = trackTable[itrack].p[2];
184 Float_t invT = (ptT>0)? 1.0/ptT : 999;
186 Float_t phiT = TVector2::Phi_mpi_pi( pT.Phi() );
188 cout << Form(
"g2tTrack idtruth=%03i pid=%i px=%6.3f py=%6.3f pz=%7.3f",key,pid,px,py,pz) << endl;
190 hMatchedEta -> Fill( etaT, etaR );
191 hMatchedPhi -> Fill( phiT, phiR );
192 hMatchedPt -> Fill( ptT, ptR );
193 hMatchedInv -> Fill( invT, invR );
194 hMatchedQA -> Fill( qaTruth );
196 Float_t etaD = (etaR - etaT);
197 Float_t phiD = TVector2::Phi_mpi_pi(phiR - phiT);
198 Float_t ptD = ptR - ptT;
199 Float_t invD = invR - invT;
201 hMatchedEtaRes -> Fill( etaD );
202 hMatchedPhiRes -> Fill( phiD );
203 hMatchedPtRes -> Fill( ptD );
204 hMatchedInvRes -> Fill( invD );
206 if ( TMath::Abs( etaD ) > etaCut &&
207 TMath::Abs( phiD ) > phiCut &&
208 TMath::Abs( invD ) > invCut )
goto MISMATCH;
224 hNumMismatched -> Fill( missed );
226 hPerMismatched -> Fill(
float(missed / count) );
232 Int_t StTruthTestMaker::MakeRecord()
235 static Bool_t first =
true;
245 map< Int_t, StMuTrack * > muTrackMap;
248 StMuEvent *muEvent = muDst -> event(); assert(muEvent);
250 { Int_t ntracks = muDst -> globalTracks() -> GetEntries();
251 for ( Int_t itrack = 0; itrack < ntracks; itrack++ )
254 StMuTrack *track = muDst -> globalTracks(itrack);
256 Int_t idTruth = track->idTruth();
257 Int_t qaTruth = track->qaTruth();
260 if ( MUDST_CUT )
continue;
262 if ( idTruth ) muTrackMap[idTruth] = track;
290 TIter Next( event -> IterAll() );
293 cout <<
"-- Event Generator Record ----------------------------------------" << endl;
296 Int_t idtruth = particle->
GetStack();
298 if ( particle->GetPrimaryKey() != 0 ) particle->
Print();
301 StMuTrack *muTrack = muTrackMap[idtruth];
302 if ( !muTrack )
continue;
310 Int_t qaTruth = muTrack->qaTruth();
314 Float_t etaR = muTrack->
eta();
315 Float_t phiR = muTrack->
phi();
316 Float_t ptR = muTrack->
pt();
317 Float_t invR = (ptR>0)? 1.0/ptR : 999;
320 Float_t etaT = particle->
momentum().Eta();
321 Float_t ptT = particle->
pt();
322 Float_t px = particle->
GetPx();
323 Float_t py = particle->
GetPy();
324 Float_t pz = particle->
GetPz();
325 Float_t invT = (ptT>0)? 1.0/ptT : 999;
327 Float_t phiT = TVector2::Phi_mpi_pi( pT.Phi() );
328 Int_t pid = particle->
GetId();
330 cout << Form(
"evtTrack idtruth=%03i pid=%i px=%6.3f py=%6.3f pz=%7.3f",idtruth ,pid,px,py,pz) << endl;
332 hMatchedEta -> Fill( etaT, etaR );
333 hMatchedPhi -> Fill( phiT, phiR );
334 hMatchedPt -> Fill( ptT, ptR );
335 hMatchedInv -> Fill( invT, invR );
336 hMatchedQA -> Fill( qaTruth );
338 Float_t etaD = (etaR - etaT);
339 Float_t phiD = TVector2::Phi_mpi_pi(phiR - phiT);
340 Float_t ptD = ptR - ptT;
341 Float_t invD = invR - invT;
343 hMatchedEtaRes -> Fill( etaD );
344 hMatchedPhiRes -> Fill( phiD );
345 hMatchedPtRes -> Fill( ptD );
346 hMatchedInvRes -> Fill( invD );
348 if ( TMath::Abs( etaD ) > etaCut &&
349 TMath::Abs( phiD ) > phiCut &&
350 TMath::Abs( invD ) > invCut )
goto MISMATCH;
364 hNumMismatched -> Fill( missed );
366 hPerMismatched -> Fill(
float(missed / count) );
Double_t pt() const
Returns pT at point of dca to primary vertex.
Float_t pt()
Returns the transverse momentum of the particle.
Yet another particle class.
Float_t GetPz()
Get the z-component of the momentum.
Int_t GetId()
Get the id code of the particle according to the PDG standard.
Int_t GetStack()
Get the line number in the particle stack.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
Float_t GetPx()
Get the x-component of the momentum.
TLorentzVector momentum()
Return the 4-momentum of the particle.
Float_t GetPy()
Get the y-component of the momentum.
Base class for event records.
Double_t phi() const
Returns phi at point of dca to primary vertex.
void Print(const Option_t *opts="") const
Print the particle.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)