StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmbeddingQA.cxx
1 /****************************************************************************************************
2  * $Id: StEmbeddingQA.cxx,v 1.26 2021/05/10 21:46:20 perev Exp $
3  * $Log: StEmbeddingQA.cxx,v $
4  * Revision 1.26 2021/05/10 21:46:20 perev
5  * Rollback kCanRebin not in Root6
6  *
7  * Revision 1.25 2021/05/10 21:22:32 perev
8  * Remove kCanRebin not in Root6
9  *
10  * Revision 1.24 2019/07/10 05:44:17 zhux
11  * added option for btof pid for primary real tracks
12  *
13  * Revision 1.23 2016/10/27 15:50:20 zhux
14  * added an option to set the maximum pT cut, by Zachariah Miller
15  *
16  * Revision 1.22 2012/03/05 10:32:19 cpowell
17  * Functions added to cut on refMult
18  *
19  * Revision 1.21 2011/08/31 18:04:48 cpowell
20  * Extended the range of hGeantId
21  *
22  * Revision 1.20 2011/04/01 05:05:49 hmasui
23  * Track selections by StEmbeddingQAUtilities. Added 1/pt(RC)-1/pt(MC) vs pt, and pt dependent Ncommon vs NhitFit histograms
24  *
25  * Revision 1.19 2011/02/11 03:55:46 hmasui
26  * Change geantid type to integer
27  *
28  * Revision 1.18 2011/01/31 21:32:12 hmasui
29  * Modify histogram keys to TString to take into account parent geantid
30  *
31  * Revision 1.17 2011/01/14 23:46:16 hmasui
32  * Add Ncommon hit cut for NHitFit histograms
33  *
34  * Revision 1.16 2011/01/12 21:36:29 hmasui
35  * Add nHitsFit/nHitsPoss cut
36  *
37  * Revision 1.15 2010/11/01 03:10:23 hmasui
38  * Modify geantid check for MC tracks in order to avoid non primary tracks
39  *
40  * Revision 1.14 2010/07/12 21:30:23 hmasui
41  * Use StEmbeddingQAUtilities::getParticleDefinition(). Increase bin size, maximum for geantid histogram in order to cover geantid > 10k
42  *
43  * Revision 1.13 2010/06/28 17:33:47 hmasui
44  * Added geant process = 6 (photon pair production) in contaminated pairs
45  *
46  * Revision 1.12 2010/05/14 19:50:12 hmasui
47  * Add rapidity and trigger cuts.
48  *
49  * Revision 1.11 2010/04/24 20:21:21 hmasui
50  * Add geant process check for contaminated pairs
51  *
52  * Revision 1.10 2010/03/15 21:03:56 hmasui
53  * Modify binning for histograms of vertices
54  *
55  * Revision 1.9 2010/03/12 19:27:02 hmasui
56  * Reduce bin size for event number histograms, and allow automatic bin extention
57  *
58  * Revision 1.8 2010/02/19 18:06:39 hmasui
59  * Change the vertex range to +/-200 cm for vz histograms
60  *
61  * Revision 1.7 2010/02/16 02:13:34 hmasui
62  * Add parent-parent geant id in the histogram name
63  *
64  * Revision 1.6 2010/02/12 16:24:13 hmasui
65  * Extend the range of vz to +/-150cm for vx(vy) vs vz histograms
66  *
67  * Revision 1.5 2010/02/01 21:28:14 hmasui
68  * Fix bugs for the binning of delta vx, vy, vz histograms
69  *
70  * Revision 1.4 2010/01/28 21:50:35 hmasui
71  * Add Vx vs Vz and Vy vs Vz histograms.
72  *
73  * Revision 1.3 2010/01/26 18:07:33 hmasui
74  * Change the binning for delta v_{x,y,z} from +/- 10 to +/- 1 cm
75  *
76  * Revision 1.2 2010/01/26 17:47:33 hmasui
77  * Add histograms for eventid, runnumber and # of particles. Fix binning for delta pt vs pt
78  *
79  * Revision 1.1 2009/12/22 21:41:18 hmasui
80  * Change class name from StEmbeddingQAMaker to StEmbeddingQA
81  *
82  ****************************************************************************************************/
83 
84 #include <algorithm>
85 #include <fstream>
86 #include <string>
87 
88 #include "TClonesArray.h"
89 #include "TError.h"
90 #include "TH1.h"
91 #include "TH2.h"
92 #include "TH3.h"
93 #include "TFile.h"
94 #include "TTree.h"
95 #include "TObjArray.h"
96 
97 #include "StMessMgr.h"
98 #include "StarRoot/TH1Helper.h"
101 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
102 #include "StMuDSTMaker/COMMON/StMuEvent.h"
103 #include "StMuDSTMaker/COMMON/StMuTrack.h"
104 #include "StParticleDefinition.hh"
105 
106 #include "StEmbeddingQA.h"
107 #include "StEmbeddingQATrack.h"
108 
109 using namespace std ;
110 
111 ClassImp(StEmbeddingQA)
112 
113 //__________________________________________________________________________________________
115  : mYear(2007), mProduction("P08ic"), mIsSimulation(kTRUE)
116 {
119 
120  init() ;
121 }
122 
123 //__________________________________________________________________________________________
124 StEmbeddingQA::StEmbeddingQA(const Int_t year, const TString production, const Bool_t isSimulation)
125  : mYear(year), mProduction(production), mIsSimulation(isSimulation)
126 {
128 
129  init() ;
130 }
131 
132 //__________________________________________________________________________________________
134 {
135  clear();
136 }
137 
138 //__________________________________________________________________________________________
139 void StEmbeddingQA::clear()
140 {
142  LOG_DEBUG << "StEmbeddingQA::clear()" << endm;
143 
145  if ( mhRef ) delete mhRef ;
146  if ( mhRefAccepted ) delete mhRefAccepted ;
147  if ( mhVz ) delete mhVz ;
148  if ( mhVzAccepted ) delete mhVzAccepted ;
149  if ( mhVyVx ) delete mhVyVx ;
150  if ( mhVxVz ) delete mhVxVz ;
151  if ( mhVyVz ) delete mhVyVz ;
152  if ( mhdVx ) delete mhdVx ;
153  if ( mhdVy ) delete mhdVy ;
154  if ( mhdVz ) delete mhdVz ;
155  if ( mhEventId ) delete mhEventId ;
156  if ( mhRunNumber ) delete mhRunNumber ;
157 
158  mGeantIdCollection.clear();
159 
161  for(UInt_t ic=0; ic<StEmbeddingQAConst::mNCategory; ic++){
162  if ( mhGeantId[ic] ) delete mhGeantId[ic] ;
163  if ( mhNParticles[ic] ) delete mhNParticles[ic] ;
164 
165  mGeantId[ic].clear();
166  mhNHit[ic].clear();
167  mhNCommonHitVsNHit[ic].clear();
168  mhDca[ic].clear();
169  mhPtVsEta[ic].clear();
170  mhPtVsY[ic].clear();
171  mhPtVsPhi[ic].clear();
172  mhPtVsMom[ic].clear();
173  mhdPtVsPt[ic].clear();
174  mhdInvPtVsPt[ic].clear();
175  mhMomVsEta[ic].clear();
176  mhdEdxVsMomMc[ic].clear();
177  mhdEdxVsMomMcPidCut[ic].clear();
178  mhdEdxVsMomReco[ic].clear();
179  mhdEdxVsMomRecoPidCut[ic].clear();
180  mhRecoPVsMcP[ic].clear();
181  mhNCommonHitVsNHit[ic].clear();
182  mhEtaVsPhi[ic].clear();
183  mhEtaVsVz[ic].clear();
184  mhYVsVz[ic].clear();
185  }
186 }
187 
188 //__________________________________________________________________________________________
190 {
192 
193  LOG_INFO << endm;
194  LOG_INFO << Form(" StEmbeddingQA::init() for year : %10d", mYear) << endm;
195  LOG_INFO << Form(" StEmbeddingQA::init() for production : %10s", mProduction.Data()) << endm;
196  LOG_INFO << endm;
197 
198  mMuDstMaker = 0;
199 
200  mOutput = 0;
201  mVz = -9999. ;
202 
203  mhRef = 0 ;
204  mhRefAccepted = 0 ;
205  mhVz = 0 ;
206  mhVzAccepted = 0 ;
207  mhVyVx = 0 ;
208  mhVxVz = 0 ;
209  mhVyVz = 0 ;
210  mhdVx = 0 ;
211  mhdVy = 0 ;
212  mhdVz = 0 ;
213  mhEventId = 0 ;
214  mhRunNumber = 0 ;
215  mPtMax = 10. ;
216 
217  for(UInt_t ic=0; ic<StEmbeddingQAConst::mNCategory; ic++){
218  mhNParticles[ic] = 0 ;
219  mhGeantId[ic] = 0 ;
220  }
221 
223  clear();
224 }
225 
226 //__________________________________________________________________________________________
227 void StEmbeddingQA::setRefMultMinCut(const Int_t refMultMin)
228 {
229  StEmbeddingQAUtilities::instance()->setRefMultMinCut(refMultMin) ;
230 }
231 
232 //__________________________________________________________________________________________
233 void StEmbeddingQA::setRefMultMaxCut(const Int_t refMultMax)
234 {
235  StEmbeddingQAUtilities::instance()->setRefMultMaxCut(refMultMax) ;
236 }
237 
238 //__________________________________________________________________________________________
239 void StEmbeddingQA::setZVertexCut(const Float_t vz)
240 {
241  StEmbeddingQAUtilities::instance()->setZVertexCut(vz) ;
242 }
243 
244 //__________________________________________________________________________________________
245 void StEmbeddingQA::addTriggerIdCut(const UInt_t id)
246 {
248 
249  StEmbeddingQAUtilities::instance()->addTriggerIdCut(id) ;
250 }
251 
252 //__________________________________________________________________________________________
253 void StEmbeddingQA::setRapidityCut(const Float_t ycut)
254 {
256  StEmbeddingQAUtilities::instance()->setRapidityCut(ycut) ;
257 }
258 
259 //__________________________________________________________________________________________
260 Bool_t StEmbeddingQA::isRefMultOk(const StMiniMcEvent& mcevent) const
261 {
263  return StEmbeddingQAUtilities::instance()->isRefMultOk(mcevent.nUncorrectedPrimaries()) ;
264 }
265 
266 //__________________________________________________________________________________________
267 Bool_t StEmbeddingQA::isZVertexOk(const StMiniMcEvent& mcevent) const
268 {
270  return StEmbeddingQAUtilities::instance()->isZVertexOk(mcevent.vertexZ()) ;
271 }
272 
273 //__________________________________________________________________________________________
274 Bool_t StEmbeddingQA::isTriggerOk(StMuEvent* event) const
275 {
277  const vector<UInt_t> triggerId(StEmbeddingQAUtilities::instance()->getTriggerIdCut());
278  if( triggerId.empty() ) return kTRUE ;
279 
281  for(UInt_t i=0; i<triggerId.size(); i++){
282  if( event->triggerIdCollection().nominal().isTrigger( triggerId[i] ) ){
283  LOG_DEBUG << "StEmbeddingQA::isTriggerOk Trigger found: " << triggerId[i] << endm ;
284  return kTRUE ;
285  }
286  }
287 
288  return kFALSE ;
289 }
290 
291 //__________________________________________________________________________________________
292 Bool_t StEmbeddingQA::book(const TString outputFileName)
293 {
295  LOG_DEBUG << "StEmbeddingQA::book()" << endm;
296 
297  TString fileName(outputFileName);
298 
302  if( fileName.IsWhitespace() ){
303  const TString data = (mIsSimulation) ? "embedding" : "real" ;
304  fileName = Form("qa_%s_%d_%s.root", data.Data(), mYear, mProduction.Data());
305  }
306 
308  mOutput = TFile::Open(fileName, "recreate");
309  mOutput->cd();
310  LOG_INFO << " OPEN " << mOutput->GetName() << endm;
311 
318 
319  // Event-wise informations
320  mhRef = new TH1D("hRef", "refMult", 1000, 0, 1000);
321  mhRefAccepted = new TH1D("hRefAccepted", "refMult", 1000, 0, 1000);
322  mhVz = new TH1D("hVz", "z-vertex", 400, -200, 200);
323  mhVzAccepted = new TH1D("hVzAccepted", "z-vertex with z-vertex cut", 400, -200, 200);
324  mhRef->SetXTitle("refMult");
325  mhRefAccepted->SetXTitle("refMult");
326  mhVz->SetXTitle("v_{z} (cm)");
327  mhVzAccepted->SetXTitle("v_{z} (cm)");
328 
329  utility->setStyle(mhRef);
330  utility->setStyle(mhRefAccepted);
331  utility->setStyle(mhVz);
332  utility->setStyle(mhVzAccepted);
333 
334  // Bins for vertices
335  const Int_t vtxBin = 800 ;
336  const Double_t vtxMin = -2.0 ;
337  const Double_t vtxMax = 2.0 ;
338  const Double_t binSize = (vtxMax-vtxMin)/static_cast<Double_t>(vtxBin);
339 
340  // Shift vertices range by binSize/2 to locate v=0 at the middle of 0-th bin
341  const Double_t vtxMinShift = vtxMin - binSize/2.0 ;
342  const Double_t vtxMaxShift = vtxMax - binSize/2.0 ;
343 
344  mhVyVx = new TH2D("hVyVx", "v_{y} vs v_{x}", vtxBin, vtxMinShift, vtxMaxShift, vtxBin, vtxMinShift, vtxMaxShift);
345  mhVxVz = new TH2D("hVxVz", "v_{x} vs v_{z}", 300, -150, 150, vtxBin, vtxMinShift, vtxMaxShift);
346  mhVyVz = new TH2D("hVyVz", "v_{y} vs v_{z}", 300, -150, 150, vtxBin, vtxMinShift, vtxMaxShift);
347  mhVyVx->SetXTitle("v_{x} (cm)"); mhVyVx->SetYTitle("v_{y} (cm)");
348  mhVxVz->SetXTitle("v_{z} (cm)"); mhVxVz->SetYTitle("v_{x} (cm)");
349  mhVyVz->SetXTitle("v_{z} (cm)"); mhVyVz->SetYTitle("v_{y} (cm)");
350 
351  utility->setStyle(mhVyVx);
352  utility->setStyle(mhVxVz);
353  utility->setStyle(mhVyVz);
354 
355  mhdVx = new TH1D("hdVx", "#Delta x = v_{x} - v_{x}(MC)", vtxBin, vtxMinShift, vtxMaxShift);
356  mhdVy = new TH1D("hdVy", "#Delta y = v_{y} - v_{y}(MC)", vtxBin, vtxMinShift, vtxMaxShift);
357  mhdVz = new TH1D("hdVz", "#Delta z = v_{z} - v_{z}(MC)", vtxBin, vtxMinShift, vtxMaxShift);
358  mhdVx->SetXTitle("#Deltav_{x} = v_{x} - v_{x}(MC) (cm)");
359  mhdVy->SetXTitle("#Deltav_{y} = v_{y} - v_{y}(MC) (cm)");
360  mhdVz->SetXTitle("#Deltav_{z} = v_{z} - v_{z}(MC) (cm)");
361 
362  utility->setStyle(mhdVx);
363  utility->setStyle(mhdVy);
364  utility->setStyle(mhdVz);
365 
366  mhEventId = new TH1D("hEventId", "Event id", 1000, 0, 1000);
367  mhRunNumber = new TH1D("hRunNumber", "Run id - (Year - 1999)#times10^{6}", 400000, 0, 400000);
368  mhEventId->SetXTitle("Event id");
369  mhRunNumber->SetXTitle("Run number");
370 
371  // Set bit to automatic bin extention
372  TH1Helper::SetCanRebin(mhEventId);
373 
374  utility->setStyle( mhEventId ) ;
375  utility->setStyle( mhRunNumber ) ;
376 
377  for(UInt_t ic=0; ic<StEmbeddingQAConst::mNCategory; ic++){
378  mhNParticles[ic] = new TH1D(Form("hNParticles_%d", ic),
379  Form("Number of particles per event, %s", utility->getCategoryTitle(ic).Data()), 1000, 0, 1000);
380  mhNParticles[ic]->SetXTitle("# of particles / event");
381 
382  utility->setStyle(mhNParticles[ic]);
383 
384  // Initialize geantid histogram. Increase the bin and maximum in order to cover id > 10k
385  mhGeantId[ic] = new TH1D(Form("hGeantId_%d", ic), Form("Geantid, %s", utility->getCategoryTitle(ic).Data()), 100000, 0, 100000) ;
386  mhGeantId[ic]->SetXTitle("Geantid");
387 
388  utility->setStyle(mhGeantId[ic]);
389  }
390 
391  mOutput->GetList()->Sort();
392  LOG_INFO << endm << endm << endm;
393 
394  return kStOk ;
395 }
396 
397 //__________________________________________________________________________________________
398 Bool_t StEmbeddingQA::make(const TString inputFileName, const Bool_t isSimulation)
399 {
401 
403  if(!mOutput || !mOutput->IsOpen()){
404  Error("StEmbeddingQA::Make", "Output file is not opened");
405  return kStErr ;
406  }
407 
408  if( isSimulation ){
410  LOG_INFO << "------------------------------------------------------------------------------------" << endm;
411  LOG_INFO << " Fill embedding ..." << endm;
412  LOG_INFO << "------------------------------------------------------------------------------------" << endm;
413  fillEmbedding(inputFileName);
414  }
415  else{
417  LOG_INFO << "------------------------------------------------------------------------------------" << endm;
418  LOG_INFO << " Fill real data ..." << endm;
419  LOG_INFO << "------------------------------------------------------------------------------------" << endm;
420  fillRealData(inputFileName);
421  }
422 
423  return kStOk ;
424 }
425 
426 //__________________________________________________________________________________________
427 Bool_t StEmbeddingQA::fillEmbedding(const TString inputFileName)
428 {
430 
432  TFile* file = TFile::Open(inputFileName);
433  if( !file || !file->IsOpen() ){
434  Error("StEmbeddingQA::fillEmbedding", "can't open %s", inputFileName.Data());
435  return kStErr ;
436  }
437 
439  const TString treeName("StMiniMcTree");
440  TTree* tree = (TTree*) file->Get(treeName);
441  if( !tree ){
442  Error("StEmbeddingQA::fillEmbedding", "can't find %s tree", treeName.Data());
443  return kStErr ;
444  }
445 
447  StMiniMcEvent* mMiniMcEvent = new StMiniMcEvent();
448  TBranch* b_MiniMcEvent = tree->GetBranch("StMiniMcEvent");
449  b_MiniMcEvent->SetAddress(&mMiniMcEvent);
450 
451  // Tracks in minimc tree
452  // mMcTracks = new TClonesArray("StTinyMcTrack",nMcTrack);
453  // mMatchedPairs = new TClonesArray("StMiniMcPair",nMatchedPair);
454  // mMergedPairs = new TClonesArray("StMiniMcPair",nMergedPair);
455  // mSplitPairs = new TClonesArray("StMiniMcPair",nSplitPair);
456  //
457  // mGhostPairs = new TClonesArray("StMiniMcPair",nGhostPair);
458  // mContamPairs = new TClonesArray("StContamPair",nContamPair);
459  // mMatGlobPairs = new TClonesArray("StMiniMcPair",nMatGlobPair);
460  //
461  // Track name definition in StMiniMcEvent.h
462  // enum Category { MC,MATCHED,MERGED,SPLIT,CONTAM,GHOST,MATGLOB};
463 
464  const Long64_t nentries = tree->GetEntries();
465  LOG_INFO << Form(" OPEN %s, # of event = %10d", inputFileName.Data(), nentries) << endm;
466 
468  for (Int_t ievent=0; ievent<nentries;ievent++) {
469  tree->GetEntry(ievent);
470 
471  const Float_t vx = mMiniMcEvent->vertexX() ;
472  const Float_t vy = mMiniMcEvent->vertexY() ;
473  const Float_t vz = mMiniMcEvent->vertexZ() ;
474  const Float_t vxmc = mMiniMcEvent->mcVertexX() ;
475  const Float_t vymc = mMiniMcEvent->mcVertexY() ;
476  const Float_t vzmc = mMiniMcEvent->mcVertexZ() ;
477  const Int_t nprimaries = mMiniMcEvent->nUncorrectedPrimaries();
478 
479  mhRef->Fill(nprimaries);
480  mhVz->Fill(vz);
481 
482  mVz = vz ;
483 
485  if( !isZVertexOk(*mMiniMcEvent) ) continue ;
486 
488  if( !isRefMultOk(*mMiniMcEvent) ) continue ;
489 
491  mhRefAccepted->Fill(nprimaries);
492  mhVzAccepted->Fill(vz);
493  mhVyVx->Fill(vx, vy);
494  mhVxVz->Fill(vz, vx);
495  mhVyVz->Fill(vz, vy);
496  mhdVx->Fill( vx - vxmc );
497  mhdVy->Fill( vy - vymc );
498  mhdVz->Fill( vz - vzmc );
499 
501  mhEventId->Fill( mMiniMcEvent->eventId() );
502  mhRunNumber->Fill( StEmbeddingQAUtilities::instance()->getRunNumber(mMiniMcEvent->runId(), mYear) );
503 
505  for(UInt_t categoryid=0; categoryid<StEmbeddingQAConst::mNEmbedding; categoryid++){
506  const Int_t nTrack = getNtrack(categoryid, *mMiniMcEvent) ;
507  mhNParticles[categoryid]->Fill(nTrack);
508 
509  const Int_t nevents = (Int_t)mhVz->GetEntries();
510  if( nevents % 100 == 0 && nTrack > 0 ){
511  LOG_INFO << Form("#### accept/throw=%10d/%10d, category=%10s, ntrack=%10d",
512  (Int_t)mhVzAccepted->GetEntries(), nevents,
513  StEmbeddingQAUtilities::instance()->getCategoryName(categoryid).Data(), nTrack)
514  << endm;
515  }
516 
518  for(Int_t itrk=0; itrk<nTrack; itrk++){
519  fillEmbeddingTracks(*mMiniMcEvent, categoryid, itrk) ;
520  } // Track loop
521  }// Track category
522 
523  }// event loop
524 
526  delete mMiniMcEvent ;
527 
529  file->Close() ;
530 
531  return kStOk ;
532 }
533 
534 //__________________________________________________________________________________________
535 Bool_t StEmbeddingQA::fillRealData(const TString inputFileName)
536 {
538 
540  Int_t ievent = 0;
541  Int_t ieventAccept = 0;
542  while( !mMuDstMaker->Make() ){ //read event
543  ievent++;
544  StMuEvent* muEvent = mMuDstMaker->muDst()->event() ;
545  if(!muEvent) continue ;
546 
549  const Double_t vx = muEvent->primaryVertexPosition().x() ;
550  const Double_t vy = muEvent->primaryVertexPosition().y() ;
551  const Double_t vz = muEvent->primaryVertexPosition().z() ;
552  const Int_t refMult = muEvent->refMult() ;
553  mhRef->Fill(refMult);
554 // const Bool_t isVertexBad = TMath::Abs(vz) >= mVertexCut
555  const Bool_t isVertexBad = !StEmbeddingQAUtilities::instance()->isZVertexOk(vz)
556  || !StEmbeddingQAUtilities::instance()->isRefMultOk(refMult)
557  || ( TMath::Abs(vx) < 1.0e-5 && TMath::Abs(vy) < 1.0e-5 && TMath::Abs(vz) < 1.0e-5 )
558  || ( TMath::Abs(vx) > 1000 || TMath::Abs(vy) > 1000 || TMath::Abs(vz) > 1000 )
559  ;
560  if( isVertexBad ) continue ;
561 
563  if( !isTriggerOk(muEvent) ) continue ;
564 
565  mhRefAccepted->Fill(refMult);
566  mhVz->Fill(vz);
567  mhVyVx->Fill(vx, vy);
568 
569  mVz = vz ;
570 
572  for(UInt_t ic=0; ic<StEmbeddingQAConst::mNReal; ic++){
573  const Int_t categoryid = ic + StEmbeddingQAConst::mNEmbedding ;
574 
575  if( ieventAccept % 100 == 0 ){
576  LOG_INFO << Form("%85s #### accept/throw=%10d/%10d, category=%10s",
577  mMuDstMaker->GetFileName(), ieventAccept, ievent, StEmbeddingQAUtilities::instance()->getCategoryName(categoryid).Data())
578  << endm;
579  }
580 
581  const TObjArray* tracks = (ic==0)
582  ? mMuDstMaker->muDst()->primaryTracks() // Primary tracks
583  : mMuDstMaker->muDst()->globalTracks() ; // Global tracks
584 
585  TObjArrayIter trackIterator(tracks);
586  StMuTrack* track = 0;
587  Int_t itrk = 0;
588  while ( ( track = (StMuTrack*) trackIterator.Next() ) ){
589  fillRealTracks(*track, categoryid, itrk);
590  itrk++;
591  }
592  }
593 
594  ieventAccept++;
595  }// event loop
596 
597  LOG_INFO << "End of real data" << endm;
598  LOG_INFO << "Total # of events = " << ievent << endm;
599 
600  return kStOk ;
601 }
602 
603 //__________________________________________________________________________________________
604 Bool_t StEmbeddingQA::runRealData(const TString inputFileList)
605 {
607 
609  if( mMuDstMaker ) delete mMuDstMaker ;
610 
611  LOG_INFO << "### Read " << inputFileList << endm;
612  mMuDstMaker = new StMuDstMaker(0, 0, "", inputFileList, "MuDst", 1000);
613 
615  LOG_INFO << "StEmbeddingQA::runRealData()" << endm;
616  LOG_INFO << "Add electrons, pions, kaons and protons for the real data QA" << endm;
617  for(UInt_t ic=0; ic<StEmbeddingQAConst::mNReal; ic++){
618  const Int_t categoryid = ic + StEmbeddingQAConst::mNEmbedding ;
619 
620  const Int_t parentid = 0 ; // real tracks are assumed to be primary
621  const Int_t parentparentid = 0 ; // real tracks are assumed to be primary
622  const Int_t geantprocess = 0 ;
623  expandHistograms(categoryid, 2, parentid, parentparentid, geantprocess);
624  expandHistograms(categoryid, 3, parentid, parentparentid, geantprocess);
625  expandHistograms(categoryid, 8, parentid, parentparentid, geantprocess);
626  expandHistograms(categoryid, 9, parentid, parentparentid, geantprocess);
627  expandHistograms(categoryid, 11, parentid, parentparentid, geantprocess);
628  expandHistograms(categoryid, 12, parentid, parentparentid, geantprocess);
629  expandHistograms(categoryid, 14, parentid, parentparentid, geantprocess);
630  expandHistograms(categoryid, 15, parentid, parentparentid, geantprocess);
631 
632  // Make sure the input particle list
633  for(vector<Int_t>::iterator iter = mGeantId[categoryid].begin(); iter != mGeantId[categoryid].end(); iter++){
634  const Int_t geantid = (*iter) ;
635  LOG_DEBUG << Form(" Input geant id = %10d, name = %10s", geantid,
636  StEmbeddingQAUtilities::instance()->getParticleDefinition(geantid)->name().c_str()) << endm ;
637  }
638  }
639 
640  make(inputFileList, kFALSE);
641 
642  return kStOk ;
643 }
644 
645 //__________________________________________________________________________________________
646 Bool_t StEmbeddingQA::runEmbedding(const TString inputFileList)
647 {
649 
650  ifstream fEmbedding(inputFileList);
651  if(!fEmbedding){
652  Error("StEmbeddingQA::runEmbedding", "can't find %s", inputFileList.Data());
653  return kFALSE ;
654  }
655  LOG_INFO << "### Read " << inputFileList << endm;
656 
658  TString file ;
659  while( fEmbedding >> file ){
660  LOG_INFO << "#### Read file : " << file << endm;
661  make(file, kTRUE);
662  }
663 
664  return kStOk ;
665 }
666 
667 //__________________________________________________________________________________________
668 Bool_t StEmbeddingQA::run(const TString inputFileList)
669 {
671 
672  LOG_INFO << "StEmbeddingQA::run()" << endm ;
673 // LOG_INFO << " z-vertex cut is |vz| < " << mVertexCut << endm;
675 
676  if( mIsSimulation ){
677  // Embedding QA
678  return runEmbedding(inputFileList) ;
679  }
680  else{
681  // Real data QA
682  return runRealData(inputFileList) ;
683  }
684 
685  return kFALSE ;
686 }
687 
688 //__________________________________________________________________________________________
689 Bool_t StEmbeddingQA::end() const
690 {
692 
693  LOG_INFO << " End of StEmbeddingQA" << endm;
694  LOG_INFO << " Write output " << mOutput->GetName() << endm;
695  mOutput->GetList()->Sort();
696 
697  mOutput->Write();
698  mOutput->Close();
699 
700  return kStOk ;
701 }
702 
703 //__________________________________________________________________________________________
704 void StEmbeddingQA::fillEmbeddingTracks(const StMiniMcEvent& mcevent, const Int_t categoryid, const Int_t itrk)
705 {
707 
709  StEmbeddingQATrack* miniTrack = getEmbeddingQATrack(mcevent, categoryid, itrk);
710 
712  if(!miniTrack) return ;
713 
715  fillHistograms(*miniTrack, categoryid);
716 
718  delete miniTrack ;
719 }
720 
721 //____________________________________________________________________________________________________
722 StEmbeddingQATrack* StEmbeddingQA::getEmbeddingQATrack(const StMiniMcEvent& mcevent, const Int_t categoryid, const Int_t itrk)
723 {
726 
727  const TString name(utility->getCategoryName(categoryid));
728  const Category category(utility->getCategory(categoryid));
729 
730  if ( utility->isMc(name) ){
732  const StTinyMcTrack* track = (StTinyMcTrack*) mcevent.tracks(category)->At(itrk) ;
733 
735  if ( track->isPrimary() != 1 ){
736  LOG_DEBUG << Form("StEmbeddingQA::getEmbeddingQATrack", "MC track with GeantID %3d is not a primary track", track->geantId()) << endm ;
737  return 0;
738  }
739 
740  return (new StEmbeddingQATrack(name, *track));
741  }
742  else if ( utility->isMatched(name) || utility->isGhost(name) || utility->isMatchedGlobal(name) ){
744  StMiniMcPair* track = (StMiniMcPair*) mcevent.tracks(category)->At(itrk) ;
745 
747  if ( !utility->isGeantIdOk(track->geantId()) ){
748  LOG_DEBUG << Form("StEmbeddingQA::getEmbeddingQATrack", "No geantid = %3d exists in StParticleTable", track->geantId()) << endm ;
749  return 0;
750  }
751 
752  return (new StEmbeddingQATrack(name, track));
753  }
754  else if ( utility->isContaminated(name) ){
756  StContamPair* track = (StContamPair*) mcevent.tracks(category)->At(itrk) ;
757 
759  if ( !utility->isGeantIdOk(track->geantId()) ){
760  LOG_DEBUG << Form("StEmbeddingQA::getEmbeddingQATrack", "No geantid = %3d exists in StParticleTable", track->geantId()) << endm ;
761  return 0;
762  }
763 
766  const Bool_t isGeantProcessOk = ( track->mGeantProcess == 5 || (track->parentGeantId() == 1 && track->mGeantProcess == 6) );
767 
768  if ( !isGeantProcessOk ){
769  LOG_DEBUG << Form("StEmbeddingQA::getEmbeddingTrack() geantprocess = %3d. Skip the track", track->mGeantProcess) << endm;
770  return 0;
771  }
772 
773  return (new StEmbeddingQATrack(name, track));
774  }
775  else{
776  Warning("StEmbeddingQA::fillEmbeddingTracks", "Unknown category id, id=%3d", categoryid);
777  return 0;
778  }
779 
780  return 0;
781 }
782 
783 //__________________________________________________________________________________________
784 void StEmbeddingQA::fillRealTracks(const StMuTrack& track, const Int_t categoryid, const Int_t itrk)
785 {
788  for(vector<Int_t>::iterator iter = mGeantId[categoryid].begin(); iter != mGeantId[categoryid].end(); iter++){
789  const Int_t geantid = (*iter) ;
790  Bool_t btofflag = kFALSE;
791  if( (categoryid - StEmbeddingQAConst::mNEmbedding) == 0 && utility->getBTofPid() ) btofflag = kTRUE; //use btof nsigma for primary tracks
792  StEmbeddingQATrack miniTrack(StEmbeddingQAUtilities::instance()->getCategoryName(categoryid), track, geantid, btofflag);
793 
794  fillHistograms(miniTrack, categoryid);
795  }
796 }
797 
798 //__________________________________________________________________________________________
799 void StEmbeddingQA::fillHistograms(const StEmbeddingQATrack& track, const Int_t categoryid)
800 {
802 
805 
807  const Int_t geantid = track.getGeantId() ;
808  if ( geantid < 0 ) return ;
809 
811  if( !track.isPtAndEtaOk() ) return ;
812 
815  const Double_t pt = (utility->isReal(track.getName())) ? track.getPtRc() : track.getPtMc() ;
816  const Double_t mom = (utility->isReal(track.getName())) ? track.getPRc() : track.getPMc() ;
817  const Double_t eta = (utility->isReal(track.getName())) ? track.getEtaRc() : track.getEtaMc() ;
818  const Double_t y = (utility->isReal(track.getName())) ? track.getRapidityRc() : track.getRapidityMc() ;
819 
820  // Reconstructed momentum
821  const Double_t momRc = track.getPRc() ;
822 
826  expandHistograms(categoryid, geantid, track.getParentGeantId(), track.getParentParentGeantId(),
827  track.getGeantProcess());
828 
829  // Fill geant id
830  mhGeantId[categoryid]->Fill(track.getGeantId());
831 
832  // Rapidity cut, default rapidity cut is 10 (Use setRapidityCut(const Float_t ycut) to restrict y window)
833 // if(!track.isRapidityOk(mRapidityCut)) return ;
834  if(!utility->isRapidityOk(y)) return ;
835 
836  const TString idcollection(getIdCollection(geantid, track.getParentGeantId(), track.getParentParentGeantId()));
837 
838  // dE/dx (no PID cut)
839  // - Add NHit cut (Nov/13/2009)
840  // - Add NHitFit/NHitPoss cut
841  if( track.isDcaOk() && track.isNHitOk() && track.isNHitToNPossOk() ) {
842  mhdEdxVsMomMc[categoryid][idcollection]->Fill(mom, track.getdEdxkeV());
843  mhdEdxVsMomReco[categoryid][idcollection]->Fill(momRc, track.getdEdxkeV());
844  }
845 
846  // Oct/21/2009
850 
851  if ( !track.isNSigmaOk(geantid) ) return ;
852 
853  if( track.isDcaOk() ){
854  // Fill NHit points
855  // Added common hit cuts
856  if ( track.isCommonHitOk() ) {
857  mhNHit[categoryid][idcollection]->Fill(pt, eta, track.getNHit());
858  }
859 
860  if( track.isNHitOk() ){
861  const Double_t phi = track.getPhi() ;
862 
863  // Fill Ncommon hits vs Nhits
864  mhNCommonHitVsNHit[categoryid][idcollection]->Fill(pt, track.getNHit(), track.getNCommonHit());
865 
866  // NHitFit/NHitPoss cut
867  if( track.isNHitToNPossOk() ) {
868  // dE/dx (with PID cut)
869  mhdEdxVsMomMcPidCut[categoryid][idcollection]->Fill(mom, track.getdEdxkeV());
870  mhdEdxVsMomRecoPidCut[categoryid][idcollection]->Fill(momRc, track.getdEdxkeV());
871 
872  // Correlation between reconstructed and MC momentum
873  mhRecoPVsMcP[categoryid][idcollection]->Fill(mom, momRc);
874 
875  // Pt, eta, phi
876  mhPtVsEta[categoryid][idcollection]->Fill(eta, pt);
877  mhPtVsY[categoryid][idcollection]->Fill(y, pt);
878  mhPtVsPhi[categoryid][idcollection]->Fill(phi, pt);
879  mhPtVsMom[categoryid][idcollection]->Fill(mom, pt);
880  mhdPtVsPt[categoryid][idcollection]->Fill(pt, track.getPtRc()-pt);
881  mhdInvPtVsPt[categoryid][idcollection]->Fill(pt, (1.0/track.getVectorGl().perp()-1.0/pt)*1000.);
882  mhMomVsEta[categoryid][idcollection]->Fill(eta, mom);
883 
884  mhEtaVsPhi[categoryid][idcollection]->Fill(phi, eta);
885  mhEtaVsVz[categoryid][idcollection]->Fill(mVz, eta);
886  mhYVsVz[categoryid][idcollection]->Fill(mVz, y);
887  }
888  }
889  }
890 
891  // Fill Dca
892  if( track.isNHitOk() && track.isNHitToNPossOk() ){
893  mhDca[categoryid][idcollection]->Fill(pt, eta, track.getDcaGl());
894  }
895 
896  LOG_DEBUG << Form(" RC:(nfit, pt, eta, phi) = (%5d, %1.4f, %1.4f, %1.4f) MC:(pt, eta) = (%1.4f, %1.4f)",
897  track.getNHit(), track.getPtRc(), track.getEtaRc(), track.getPhi(), track.getPtMc(), track.getEtaMc()
898  ) << endm;
899 }
900 
901 //__________________________________________________________________________________________
902 Bool_t StEmbeddingQA::pushBackGeantId(const Int_t categoryid, const Int_t geantid, const Int_t parentid,
903  const Int_t parentparentid, const Int_t geantprocess)
904 {
907 
908  const Bool_t isContaminated = utility->isContaminated(utility->getCategoryName(categoryid)) ;
909 
910  Bool_t isOk = kFALSE ;
911  if ( mGeantId[categoryid].empty() ){
913  LOG_INFO << "#----------------------------------------------------------------------------------------------------" << endm ;
914  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() mGeantId[%d] is empty", categoryid) << endm;
915  if( isContaminated ){
916  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() Find a new geant id, (geant, parent, parent-parent, process) = (%4d, %4d, %4d, %4d) (%10s)",
917  geantid, parentid, parentparentid, geantprocess, utility->getCategoryName(categoryid).Data()) << endm;
918  }
919  else{
920  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() Find a new geant id, geantid = %5d (%10s)",
921  geantid, utility->getCategoryName(categoryid).Data()) << endm;
922  }
923  LOG_INFO << "#----------------------------------------------------------------------------------------------------" << endm ;
924  mGeantId[categoryid].push_back(geantid);
925 
926  isOk = kTRUE ;
927  }
928  else{
932  const vector<Int_t>::iterator iter = find(mGeantId[categoryid].begin(), mGeantId[categoryid].end(), geantid) ;
933 
934  if ( iter != mGeantId[categoryid].end() ){
936  isOk = kFALSE;
937  }
938  else{
940  if( isContaminated ){
941  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() Find a new geant id, (geant, parent, parent-parent, process) = (%4d, %4d, %4d, %4d) (%10s)",
942  geantid, parentid, parentparentid, geantprocess, utility->getCategoryName(categoryid).Data()) << endm;
943  }
944  else{
945  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() Find a new geant id, geantid = %5d (%10s)",
946  geantid, utility->getCategoryName(categoryid).Data()) << endm;
947  }
948  mGeantId[categoryid].push_back(geantid);
949 
950  isOk = kTRUE ;
951  }
952  }
953 
955  if( !utility->isContaminated(utility->getCategoryName(categoryid)) ) return isOk ;
956 
960 
962  isOk = kFALSE ;
963  if( parentid == 0 ){
964  isOk = kFALSE ;
965  }
966  else{
967  const TString idcollection(getIdCollection(geantid, parentid, parentparentid));
968 
969  if( mGeantIdCollection.empty() ){
971  LOG_INFO << "#----------------------------------------------------------------------------------------------------" << endm ;
972  LOG_INFO << "StEmbeddingQA::pushBackGeantId() mGeantIdCollection is empty." << endm;
973  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() Push back (geant, parent, parent-parent) = (%4d, %4d, %4d) (process=%4d)",
974  geantid, parentid, parentparentid, geantprocess) << endm;
975  LOG_INFO << "#----------------------------------------------------------------------------------------------------" << endm ;
976 
977  mGeantIdCollection.push_back( idcollection );
978  return kTRUE ;
979  }
980 
982  const vector<TString>::iterator iterIdCollection = find(mGeantIdCollection.begin(), mGeantIdCollection.end(), idcollection) ;
983  if ( iterIdCollection != mGeantIdCollection.end() ){
985  isOk = kFALSE;
986  }
987  else{
989  LOG_INFO << Form("StEmbeddingQA::pushBackGeantId() Push back (geant, parent, parent-parent) = (%4d, %4d, %4d) (process=%4d)",
990  geantid, parentid, parentparentid, geantprocess) << endm;
991  mGeantIdCollection.push_back( idcollection );
992 
993  isOk = kTRUE ;
994  }
995  }// parentid != 0
996 
997  return isOk ;
998 }
999 
1000 
1001 //__________________________________________________________________________________________
1002 void StEmbeddingQA::expandHistograms(const Int_t categoryid, const Int_t geantid, const Int_t parentid,
1003  const Int_t parentparentid, const Int_t geantprocess)
1004 {
1007  if ( !pushBackGeantId(categoryid, geantid, parentid, parentparentid, geantprocess) ) return ;
1008 
1009  // Expand histograms
1010  mOutput->cd();
1011 
1012  const Int_t ptBin = 10 * mPtMax ;
1013  const Float_t ptMin = 0.0 ;
1014  const Float_t ptMax = mPtMax ;
1015  const Int_t etaBin = 100 ;
1016  const Float_t etaMin = -2.5 ;
1017  const Float_t etaMax = 2.5 ;
1018 
1021  const Char_t* categoryTitle(utility->getCategoryTitle(categoryid).Data());
1022 
1024  const TString nameSuffix = (parentid>0) ? Form("_%d_%d_%d_%d", categoryid, parentparentid, parentid, geantid)
1025  : Form("_%d_%d", categoryid, geantid);
1026 
1028  TString CategoryAndGeantId = (parentid>0) ? Form("%s (%s #rightarrow %s)", categoryTitle,
1029  utility->getParticleDefinition(parentid)->name().c_str(), utility->getParticleDefinition(geantid)->name().c_str())
1030  : Form("%s (%s)", categoryTitle, utility->getParticleDefinition(geantid)->name().c_str());
1031 
1032  if ( parentparentid > 0 ){
1033  CategoryAndGeantId = Form("%s (%s #rightarrow %s #rightarrow %s)", categoryTitle,
1034  utility->getParticleDefinition(parentparentid)->name().c_str(),
1035  utility->getParticleDefinition(parentid)->name().c_str(),
1036  utility->getParticleDefinition(geantid)->name().c_str());
1037  }
1038 
1039  const TString categoryName(utility->getCategoryName(categoryid));
1040  const Bool_t isMc = utility->isMc(categoryName);
1041  const Bool_t isEmbedding = utility->isEmbedding(categoryName);
1042 
1043  const TString idcollection(getIdCollection(geantid, parentid, parentparentid));
1044 
1045  // NHit vs eta vs MC pt
1046  TString title(Form("N_{fit} distribution (|dcaGl|<3cm), %s", CategoryAndGeantId.Data()));
1047  if( isMc ) title = Form("N_{fit} distribution, %s", CategoryAndGeantId.Data());
1048  TH3* hNhit = new TH3D(Form("hNHit%s", nameSuffix.Data()), title, 10, 0, 5, 10, -1.0, 1.0, 50, 0, 50) ;
1049  hNhit->SetXTitle("MC p_{T} (GeV/c)");
1050  hNhit->SetYTitle("#eta");
1051  hNhit->SetZTitle("N_{fit}");
1052  utility->setStyle(hNhit);
1053  mhNHit[categoryid].insert( std::make_pair(idcollection, hNhit) );
1054 
1055  // Ncommon hit vs Nfit
1056  title = Form("N_{common} hit vs N_{fit} (|dcaGl|<3cm), %s", CategoryAndGeantId.Data());
1057  if( isMc ) title = Form("N_{common} hit vs N_{fit}, %s", CategoryAndGeantId.Data());
1058  TH3* hNCommonHitVsNHit = new TH3D(Form("hNCommonHitVsNHit%s", nameSuffix.Data()), title, 10, 0, 5, 50, 0, 50, 50, 0, 50) ;
1059  hNCommonHitVsNHit->SetXTitle("p_{T} (GeV/c)");
1060  hNCommonHitVsNHit->SetYTitle("N_{fit}");
1061  hNCommonHitVsNHit->SetZTitle("N_{common}");
1062  utility->setStyle(hNCommonHitVsNHit);
1063  mhNCommonHitVsNHit[categoryid].insert( std::make_pair(idcollection, hNCommonHitVsNHit) );
1064 
1065  // Dca vs eta vs MC pt
1066  title = Form("Dca vs #eta vs MC p_{T} (N_{fit}#geq10), %s", CategoryAndGeantId.Data());
1067  if( isMc ) title = Form("Dca vs #eta vs MC p_{T}, %s", CategoryAndGeantId.Data());
1068  else if ( isEmbedding ) title = Form("Dca vs #eta vs MC p_{T} (N_{fit}#geq10 & N_{common}#geq10), %s", CategoryAndGeantId.Data());
1069 
1070  TH3* hDca = new TH3D(Form("hDca%s", nameSuffix.Data()), title, 10, 0, 5, 10, -1.0, 1.0, 100, 0, 3.0);
1071  hDca->SetXTitle("MC p_{T} (GeV/c)");
1072  hDca->SetYTitle("#eta");
1073  hDca->SetZTitle("Global dca (cm)");
1074  utility->setStyle(hDca);
1075  mhDca[categoryid].insert( std::make_pair(idcollection, hDca) );
1076 
1077  //--------------------------------------------------
1078  // Common cuts for the
1079  // - pt vs eta
1080  // - pt vs y
1081  // - pt vs phi
1082  // - pt vs momentum
1083  // - delta pt vs pt
1084  // - momentum vs eta
1085  // - dE/dx vs momentum
1086  // - reco. momentum vs MC momentum
1087  // - eta vs phi
1088  // - eta vs vz
1089  // - rapidity vs vz
1090  //
1091  // - dE/dx vs momentum (with pid cuts for the real data)
1092  //--------------------------------------------------
1093  TString cut(" (N_{fit}#geq10 & |dcaGl|<3cm)"); // real data
1094  if( isMc ) cut = "";
1095  else if ( isEmbedding ) cut = "(N_{fit}#geq10 & N_{common}#geq10 & |dcaGl|<3cm)";
1096 
1097  const TString titleSuffix(Form("%s, %s", cut.Data(), CategoryAndGeantId.Data()));
1098 
1099  // pt vs eta
1100  TH2* hPtVsEta = new TH2D(Form("hPtVsEta%s", nameSuffix.Data()), Form("MC p_{T} vs #eta%s", titleSuffix.Data()),
1101  etaBin, etaMin, etaMax, ptBin, ptMin, ptMax);
1102  hPtVsEta->SetXTitle("#eta");
1103  hPtVsEta->SetYTitle("MC p_{T} (GeV/c)");
1104  utility->setStyle(hPtVsEta);
1105  mhPtVsEta[categoryid].insert( std::make_pair(idcollection, hPtVsEta) );
1106 
1107  // pt vs y
1108  TH2* hPtVsY = new TH2D(Form("hPtVsY%s", nameSuffix.Data()), Form("MC p_{T} vs y%s", titleSuffix.Data()),
1109  etaBin, etaMin, etaMax, ptBin, ptMin, ptMax);
1110  hPtVsY->SetXTitle("rapidity y");
1111  hPtVsY->SetYTitle("MC p_{T} (GeV/c)");
1112  utility->setStyle(hPtVsY);
1113  mhPtVsY[categoryid].insert( std::make_pair(idcollection, hPtVsY) );
1114 
1115  // pt vs phi
1116  TH2* hPtVsPhi = new TH2D(Form("hPtVsPhi%s", nameSuffix.Data()), Form("MC p_{T} vs #phi%s", titleSuffix.Data()),
1117  100, -TMath::Pi(), TMath::Pi(), ptBin, ptMin, ptMax);
1118  hPtVsPhi->SetXTitle("#phi (rad)");
1119  hPtVsPhi->SetYTitle("MC p_{T} (GeV/c)");
1120  utility->setStyle(hPtVsPhi);
1121  mhPtVsPhi[categoryid].insert( std::make_pair(idcollection, hPtVsPhi) );
1122 
1123  // pt vs momentum
1124  TH2* hPtVsMom = new TH2D(Form("hPtVsMom%s", nameSuffix.Data()), Form("MC p_{T} vs momentum%s", titleSuffix.Data()),
1125  ptBin, ptMin, ptMax, ptBin, ptMin, ptMax);
1126  hPtVsMom->SetXTitle("momentum (GeV/c)");
1127  hPtVsMom->SetYTitle("MC p_{T} (GeV/c)");
1128  utility->setStyle(hPtVsMom);
1129  mhPtVsMom[categoryid].insert( std::make_pair(idcollection, hPtVsMom) );
1130 
1131  // Delta pt vs pt
1132  TH2* hdPtVsPt = new TH2D(Form("hdPtVsPt%s", nameSuffix.Data()), Form("p_{T} - p_{T} (MC) vs p_{T}%s", titleSuffix.Data()),
1133  ptBin, ptMin, ptMax, 100, -5, 5);
1134  hdPtVsPt->SetXTitle("MC p_{T} (GeV/c)");
1135  hdPtVsPt->SetYTitle("reco. p_{T} - MC p_{T} (GeV/c)");
1136  utility->setStyle(hdPtVsPt);
1137  mhdPtVsPt[categoryid].insert( std::make_pair(idcollection, hdPtVsPt) );
1138 
1139  // Delta 1/pt vs pt
1140  TH2* hdInvPtVsPt = new TH2D(Form("hdInvPtVsPt%s", nameSuffix.Data()), Form("1/p_{T} (Gl) - 1/p_{T} (MC) vs p_{T}%s", titleSuffix.Data()),
1141  ptBin, ptMin, ptMax, 200, -50, 50);
1142  hdInvPtVsPt->SetXTitle("MC p_{T} (GeV/c)");
1143  hdInvPtVsPt->SetYTitle("Gl 1/p_{T} - MC 1/p_{T} (c/MeV)");
1144  utility->setStyle(hdInvPtVsPt);
1145  mhdInvPtVsPt[categoryid].insert( std::make_pair(idcollection, hdInvPtVsPt) );
1146 
1147  // momentum vs eta
1148  TH2* hMomVsEta = new TH2D(Form("hMomVsEta%s", nameSuffix.Data()), Form("Momentum vs #eta%s", titleSuffix.Data()),
1149  etaBin, etaMin, etaMax, ptBin, ptMin, ptMax);
1150  hMomVsEta->SetXTitle("#eta");
1151  hMomVsEta->SetYTitle("momentum (GeV/c)");
1152  utility->setStyle(hMomVsEta);
1153  mhMomVsEta[categoryid].insert( std::make_pair(idcollection, hMomVsEta) );
1154 
1155  // dE/dx vs MC momentum
1156  TH2* hdEdxVsMomMc = new TH2D(Form("hdEdxVsMomMc%s", nameSuffix.Data()), Form("dE/dx vs MC p%s", titleSuffix.Data()),
1157  ptBin, ptMin, ptMax, 100, 0, 10.0);
1158  hdEdxVsMomMc->SetXTitle("MC p (GeV/c)");
1159  hdEdxVsMomMc->SetYTitle("dE/dx (keV/cm)");
1160  utility->setStyle(hdEdxVsMomMc);
1161  mhdEdxVsMomMc[categoryid].insert( std::make_pair(idcollection, hdEdxVsMomMc) );
1162 
1163  // dE/dx vs reconstructed momentum
1164  TH2* hdEdxVsMomReco = new TH2D(Form("hdEdxVsMomReco%s", nameSuffix.Data()), Form("dE/dx vs Reconstructed p%s", titleSuffix.Data()),
1165  ptBin, ptMin, ptMax, 100, 0, 10.0);
1166  hdEdxVsMomReco->SetXTitle("Reconstructed p (GeV/c)");
1167  hdEdxVsMomReco->SetYTitle("dE/dx (keV/cm)");
1168  utility->setStyle(hdEdxVsMomReco);
1169  mhdEdxVsMomReco[categoryid].insert( std::make_pair(idcollection, hdEdxVsMomReco) );
1170 
1171  // Reconstructed momentum vs MC momentum
1172  TH2* hRecoPVsMcP = new TH2D(Form("hRecoPVsMcP%s", nameSuffix.Data()), Form("Reconstructed p vs MC p%s", titleSuffix.Data()),
1173  ptBin, ptMin, ptMax, ptBin, ptMin, ptMax);
1174  hRecoPVsMcP->SetXTitle("MC p (GeV/c)");
1175  hRecoPVsMcP->SetYTitle("Reconstructed p (GeV/c)");
1176  utility->setStyle(hRecoPVsMcP);
1177  mhRecoPVsMcP[categoryid].insert( std::make_pair(idcollection, hRecoPVsMcP) );
1178 
1179  // eta vs phi
1180  TH2* hEtaVsPhi = new TH2D(Form("hEtaVsPhi%s", nameSuffix.Data()), Form("#eta vs #phi%s", titleSuffix.Data()),
1181  100, -TMath::Pi(), TMath::Pi(), etaBin, etaMin, etaMax);
1182  hEtaVsPhi->SetXTitle("#phi (rad)");
1183  hEtaVsPhi->SetYTitle("#eta");
1184  utility->setStyle(hEtaVsPhi);
1185  mhRecoPVsMcP[categoryid].insert( std::make_pair(idcollection, hRecoPVsMcP) );
1186  mhEtaVsPhi[categoryid].insert( std::make_pair(idcollection, hEtaVsPhi) );
1187 
1188  // eta vs vz
1189  TH2* hEtaVsVz = new TH2D(Form("hEtaVsVz%s", nameSuffix.Data()), Form("#eta vs v_{z}%s", titleSuffix.Data()),
1190  200, -50, 50, 200, etaMin, etaMax);
1191  hEtaVsVz->SetXTitle("v_{z} (cm)");
1192  hEtaVsVz->SetYTitle("#eta");
1193  utility->setStyle(hEtaVsVz);
1194  mhEtaVsVz[categoryid].insert( std::make_pair(idcollection, hEtaVsVz) );
1195 
1196  // rapidity vs vz
1197  TH2* hYVsVz = new TH2D(Form("hYVsVz%s", nameSuffix.Data()), Form("rapidity y vs v_{z}%s", titleSuffix.Data()),
1198  200, -50, 50, 200, etaMin, etaMax);
1199  hYVsVz->SetXTitle("v_{z} (cm)");
1200  hYVsVz->SetYTitle("rapidity y");
1201  utility->setStyle(hYVsVz);
1202  mhYVsVz[categoryid].insert( std::make_pair(idcollection, hYVsVz) );
1203 
1204  // dE/dx vs MC momentum (with pid cut)
1205  TH2* hdEdxVsMomMcPidCut = new TH2D(Form("hdEdxVsMomMcPidCut%s", nameSuffix.Data()), Form("dE/dx vs MC p (with 2#sigma pid cut)%s", titleSuffix.Data()),
1206  ptBin, ptMin, ptMax, 100, 0, 10.0);
1207  hdEdxVsMomMcPidCut->SetXTitle("MC p (GeV/c)");
1208  hdEdxVsMomMcPidCut->SetYTitle("dE/dx (keV/cm)");
1209  utility->setStyle(hdEdxVsMomMcPidCut);
1210  mhdEdxVsMomMcPidCut[categoryid].insert( std::make_pair(idcollection, hdEdxVsMomMcPidCut) );
1211 
1212  // dE/dx vs Reconstructed momentum (with pid cut)
1213  TH2* hdEdxVsMomRecoPidCut = new TH2D(Form("hdEdxVsMomRecoPidCut%s", nameSuffix.Data()),
1214  Form("dE/dx vs Reconstructed p (with 2#sigma pid cut)%s", titleSuffix.Data()),
1215  ptBin, ptMin, ptMax, 100, 0, 10.0);
1216  hdEdxVsMomRecoPidCut->SetXTitle("Reconstructed p (GeV/c)");
1217  hdEdxVsMomRecoPidCut->SetYTitle("dE/dx (keV/cm)");
1218  utility->setStyle(hdEdxVsMomRecoPidCut);
1219  mhdEdxVsMomRecoPidCut[categoryid].insert( std::make_pair(idcollection, hdEdxVsMomRecoPidCut) );
1220 }
1221 
1222 //__________________________________________________________________________________________
1223 Int_t StEmbeddingQA::getNtrack(const Int_t categoryid, const StMiniMcEvent& mcevent) const
1224 {
1225  switch ( categoryid ) {
1226  case 0: return mcevent.nMcTrack() ;
1227  case 1: return mcevent.nMatchedPair() ;
1228  case 2: return mcevent.nGhostPair() ;
1229  case 3: return mcevent.nContamPair() ;
1230  // NOTE:
1231  // Currently, there is no function to get number of matched global paris in StMiniMcEvent
1232  // Skip it
1233  case 4: return 0 ;
1234  default:
1235  Warning("getNtrack", "Unkown category id, id=%3d", categoryid);
1236  return 0 ;
1237  }
1238 
1239  return 0 ;
1240 }
1241 
1242 //__________________________________________________________________________________________
1243 TString StEmbeddingQA::getIdCollection(const Int_t geantid, const Int_t parentid, const Int_t parentparentid) const
1244 {
1245  return Form("%d_%d_%d", geantid, parentid, parentparentid) ;
1246 }
1247 
1248 void StEmbeddingQA::setPtMax(Float_t ptmax)
1249 {
1250  mPtMax = ptmax;
1251  LOG_INFO << Form("Maximum p_T for histograms set to %f", mPtMax) << endm;
1252 }
Bool_t isMatchedGlobal(const TString name) const
Check whether the track is Contaminated pair or not.
Float_t getPtMc() const
Get MC particle mass.
void PrintCuts() const
Print all track selections.
Short_t getNCommonHit() const
Get reconstructed 4-momentum (global)
static TObjArray * globalTracks()
returns pointer to the global tracks list
Definition: StMuDst.h:303
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in &#39;physical events&#39;. Therefore there is only 1 primary vert...
Definition: StMuEvent.cxx:221
Definition: FJcore.h:367
void setRapidityCut(const Float_t ycut)
Float_t getRapidityRc() const
Get reconstructed pseudorapidity (primary)
virtual int Make()
StMuDst * muDst()
Definition: StMuDstMaker.h:425
Bool_t isGhost(const TString name) const
Check whether the track is Matched pair or not.
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.
StEmbeddingQA()
Default constructor (default argument is 2007, P08ic)
Bool_t isEmbedding(const TString name) const
Check whether the track is global track or not.
Category getCategory(const UInt_t id) const
Int_t getParentParentGeantId() const
Get number of common hits.
Bool_t run(const TString inputFileList)
Either RunRealData or RunEmbedding according to the kIsSimulation flag.
Float_t getPRc() const
Get reconstructed pz (primary)
Int_t getParentGeantId() const
Get parent geant id.
Bool_t isDcaOk() const
Nhits/NhitsPoss cut.
Float_t getPhi() const
Get reconstructed rapidity (primary)
void setPtMax(Float_t ptmax)
Set Maximum Range of pT histograms; binning = 10*ptmax.
Bool_t runRealData(const TString inputFileList)
Analyzer real data.
Top level class for the MiniMcTree, containing event-wise information and the McTrack, and all TrackPair collections.
TString getCategoryName(const UInt_t id) const
Category from category id.
void setStyle() const
Check the input geantid is gamma.
Short_t getNHit() const
Get geant process.
Bool_t isContaminated(const TString name) const
Check whether the track is Ghost pair or not.
StParticleDefinition * getParticleDefinition(const UInt_t geantid) const
runnumber = runid - (year - 2000 + 1) * 10^6
Int_t getGeantId() const
Get parent geant id.
const TString getName() const
Get track node name.
Bool_t book(const TString outputFileName="")
Initialization.
virtual ~StEmbeddingQA()
Destructor.
Bool_t runEmbedding(const TString inputFileList)
Analyzer embedding data.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
Bool_t make(const TString inputFileName, const Bool_t isSimulation=kTRUE)
Either fillEmbedding or fillRealData according to the isSimulation flag.
unsigned short refMult(int vtx_id=-1)
Reference multiplicity of charged particles as defined in StEventUtilities/StuRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)
Definition: StMuEvent.cxx:195
Bool_t isNHitOk() const
Rapidity cut.
Float_t getdEdxkeV() const
Get dE/dx.
Bool_t isGeantIdOk(const UInt_t geantid) const
Check geant id is defined in StParticleTable or not.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Bool_t isNHitToNPossOk() const
Nhits cut.
static StEmbeddingQAUtilities * instance()
Get instance.
Float_t getEtaMc() const
Get MC momentum.
void addTriggerIdCut(const UInt_t id)
Float_t getPMc() const
Get MC pz.
Bool_t isCommonHitOk() const
Dca cut.
Bool_t isNSigmaOk(const Int_t geantid) const
Common hit cut.
Bool_t end() const
Close output file.
StLorentzVectorD getVectorGl() const
Get reconstructed 4-momentum (primary &lt;- return getVectorRc())
Int_t getGeantProcess() const
Get geant id.
Float_t getEtaRc() const
Get reconstructed momentum (primary)
Float_t getDcaGl() const
Get dE/dx in keV unit.
TString getCategoryTitle(const UInt_t id) const
Category name from category id.
Bool_t isPtAndEtaOk() const
Bool_t isMatched(const TString name) const
Check whether the track is MC track or not.
Definition: Stypes.h:44
Float_t getRapidityMc() const
Get MC pseudorapidity.
void setZVertexCut(const Float_t vz)
Bool_t isMc(const TString name) const
Category id from category name.
Definition: Stypes.h:41
Persistent MC track class.