StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmbeddingQADraw.h
1 //----------------------------------------------------------------------------------------------------
2 // Draw QA histograms
3 // - Comparison of the results between embedding and real data
4 // - Print only one PDF file by default.
5 //
6 //----------------------------------------------------------------------------------------------------
7 // NOTE: These functions are not used for the latest QA codes.
8 // file function
9 // png setPNGOn()
10 // gif setGIFOn()
11 // jpg setJPGOn()
12 // eps setEPSOn()
13 // ps setPSOn()
14 //----------------------------------------------------------------------------------------------------
15 //
16 // You can make the QA plots by drawEmbeddingQA.C under StRoot/macros/embedding
17 // Suppose you have output ROOT files: qa_embedding_2007_P08ic.root,
18 // and qa_real_2007_P08ic.root (the output file format is automatically
19 // determined if you leave the output filename blank in StEmbeddingQAMaker)
20 // Suppose you have embedded single pion+ (geantid=8) in the output files.
21 //
22 // > root4star -b -q drawEmbeddingQA.C'("./", "qa_embedding_2007_P08ic.root", "qa_real_2007_P08ic.root", 8)'
23 //
24 // First argument is the directory where the output figures are printed.
25 // The default output directory is the current directory.
26 // The 6th argument is the input geantid
27 //
28 // If you name the output ROOT files by hand, you need to put the year,
29 // production and particle name by yourself since those are used
30 // for the output figure name and to print those informations in
31 // the legend for each QA plot.
32 // Suppose you have output ROOT files: qa_embedding.root and qa_real.root
33 //
34 // > root4star -b -q drawEmbeddingQA.C'("./", "qa_embedding.root", "qa_real.root", 2005, "P08ic", 8)'
35 //
36 //
37 // If you just want ot check the embedding output only, you can do
38 //
39 // > root4star -b -q drawEmbeddingQA.C'("./", "qa_embedding_2007_P08ic.root", "qa_real_2007_P08ic.root", 8, kTRUE)'
40 //
41 // where the last argument is the switch to skip drawing the real data if it's true (default is false)
42 //
43 //----------------------------------------------------------------------------------------------------
44 /****************************************************************************************************
45  * $Id: StEmbeddingQADraw.h,v 1.16 2011/04/12 03:01:07 hmasui Exp $
46  * $Log: StEmbeddingQADraw.h,v $
47  * Revision 1.16 2011/04/12 03:01:07 hmasui
48  * Fix isMatchedPairOk() to properly process particles with decay daughters
49  *
50  * Revision 1.15 2011/02/11 03:44:57 hmasui
51  * Draw error messages in pdf if histogram is missing. Add error check for Ncommon histogram
52  *
53  * Revision 1.14 2011/01/31 21:33:51 hmasui
54  * Add setParentGeantId() function to allow the multiple decays
55  *
56  * Revision 1.13 2010/06/22 16:31:17 hmasui
57  * Separate 2D and 1D QA for MC tracks. Add pol0 fit for MC eta, y and phi distributions.
58  *
59  * Revision 1.12 2010/06/10 14:51:01 hmasui
60  * Added particle name functions
61  *
62  * Revision 1.11 2010/04/07 19:45:11 hmasui
63  * Use box option for dE/dx vs p to reduce the pdf file size
64  *
65  * Revision 1.10 2010/03/15 21:05:23 hmasui
66  * Separate MC vertices QA into 2 pages. Added constraint on z-vertex cut for vx(vy) vs vz histograms.
67  *
68  * Revision 1.9 2010/02/24 18:11:47 hmasui
69  * Added isMC flag in drawProjection2D() to switch real or MC tracks
70  *
71  * Revision 1.8 2010/02/23 16:56:37 hmasui
72  * Add phi distributions QA (MC vs reconstructed)
73  *
74  * Revision 1.7 2010/02/16 02:14:03 hmasui
75  * Print PDF file only for all QA plots
76  *
77  * Revision 1.6 2009/12/22 21:40:11 hmasui
78  * Add comments for functions and members
79  *
80  ****************************************************************************************************/
81 
82 
83 #ifndef __StEmbeddingQADraw_h__
84 #define __StEmbeddingQADraw_h__
85 
86 #include <vector>
87 
88 class TCanvas ;
89 class TH1 ;
90 class TFile ;
91 class TObject ;
92 class TPad ;
93 class TPaveText ;
94 class TPDF ;
95 #include "TString.h"
96 
98  public:
103  StEmbeddingQADraw(const TString embeddingFile, const TString realDataFile, const Int_t geantid,
104  const Bool_t isEmbeddingOnly = kFALSE);
105 
107  StEmbeddingQADraw(const TString embeddingFile, const TString realDataFile,
108  const Int_t year, const TString production, const Int_t geantid, const Bool_t isEmbeddingOnly = kFALSE);
109  virtual ~StEmbeddingQADraw();
110 
112  void init() ;
113 
115  void setParentGeantId(const Int_t parentgeantid) ;
116 
118  void setOutputDirectory(const TString name = "./") ;
119 
120  Bool_t draw() const ;
121 
122  // Event-wise
123  Bool_t drawEvent() const;
124 
125  // Track-wise
126  Bool_t drawMcTrack() const;
127  Bool_t drawTrack() const ;
128 
129  Bool_t drawGeantId() const;
130  Bool_t drawPhi() const ;
131  Bool_t drawRapidity() const;
132  Bool_t drawPt() const;
133  Bool_t drawMomentum() const;
134  Bool_t drawdEdx() const;
135  Bool_t drawDca() const;
136  Bool_t drawNHit() const;
137 
138  Bool_t finish() ;
139 
140  void setPNGOn() ;
141  void setGIFOn() ;
142  void setJPGOn() ;
143  void setEPSOn() ;
144  void setPSOn() ;
145 
146  Int_t getYear() const ;
147  const Char_t* getProduction() const ;
148  Int_t getGeantId() const ;
149 
151  // Default id = -1, returns particle name from mGeantId
152  const Char_t* getParticleName(const Int_t geantid = -1) const ;
153 
154  void setPtMax(const Double_t ptmax) ;
155 
156  private:
158  // return true only if both embedding and real data files are opened properly
159  Bool_t open(const TString embeddingFile, const TString realDataFile) ;
160 
162  void print(const TCanvas& canvas, const TString name) const;
163 
165  // if we don't find geantid in the MC histogram, replace mGeantId to that found in the MC histogram
166  void checkInputGeantId() ;
167 
169  Bool_t isOpen() const ;
170 
172  Bool_t isMatchedPairOk() const ;
173 
175  void setDaughterGeantId() ;
176 
178  Int_t getEntries() const ;
179 
181  Bool_t isDecay() const ;
182 
184  // if input geantid (or daughter geantid) is not e/pi/K/p, use pi+(=8)
185  Int_t getGeantIdReal(const Int_t daughter) const ;
186 
188  // For embedding
189  // stable particles (# of daughters = 0) --> matched pairs
190  // unstable particles (# of daughters > 0) --> contaminated pairs
191  // For real data --> primary tracks
192  Int_t getCategoryId(const Bool_t isEmbedding = kTRUE) const ;
193 
195  TObject* getHistogram(const TString name, const Bool_t isEmbedding = kTRUE) const ;
196 
199  TObject* getHistogram(const TString name, const UInt_t daughter, const Bool_t isEmbedding,
200  const UInt_t parentparentid = 0) const ;
201 
203  const Char_t* getHistogramName(const TString name, const UInt_t daughter, const Bool_t isEmbedding,
204  const UInt_t parentparentid = 0) const ;
205 
206 
208  Double_t getNormalization(const TH1& h) const ;
209 
211  const Char_t* getBaseName() const ;
212 
214  Bool_t drawStatistics(const Double_t x1=0.1, const Double_t y1=0.2, const Double_t x2=0.9, const Double_t y2=0.8,
215  const Double_t textSize = 0.05) const;
216 
218  TPaveText* drawHeader(const TString description,
219  const Double_t x1=0.0, const Double_t y1=0.9, const Double_t x2=1.0, const Double_t y2=0.95,
220  const Double_t textSize = 0.032) const;
221 
223  void drawLegend(const UInt_t id, TH1* hembed, TH1* hreal, const Option_t* option="L",
224  const Bool_t doSplit=kFALSE) const ;
225 
227  void drawErrorMessages(const TString histogramName) const ;
228 
230  Bool_t drawVertices() const;
231  Bool_t drawRunEventId() const;
232  Bool_t drawNumberOfParticles() const;
233 
235  Bool_t drawdEdxVsMomentum(const Bool_t isMcMomentum=kTRUE) const ;
236 
237  // Added isMC flag
238  // isMC = kTRUE --> Compare reconstructed embedding tracks with MC tracks
239  // isMC = kFALSE (default) --> Compare reconstructed embedding tracks with real data
240  Bool_t drawProjection2D(const TString name, const Bool_t isMC = kFALSE) const;
241  Bool_t drawProjection3D(const TString name) const;
242 
244  // Header for current QA, division of (x,y), default is (0,0), no division
245  TPaveText* initCanvas(const TString header, const Int_t nx=0, const Int_t ny=0) const;
246 
248  Double_t getVzAcceptedMinimum() const ;
249  Double_t getVzAcceptedMaximum() const ;
250 
252  const Char_t* getMcParticleName() const ;
253 
255  const Char_t* getEmbeddingParticleName(const UInt_t id, const Bool_t doSplit=kFALSE) const ;
256 
258  const Char_t* getRealParticleName(const UInt_t id, const Bool_t doSplit=kFALSE) const ;
259 
260  // Data members
261  static UInt_t mCanvasId ;
262 
263  TCanvas* mCanvas ;
264  TPad* mMainPad ;
265  TPDF* mPDF ;
266 
267  const Bool_t mIsEmbeddingOnly ;
268 
269  Bool_t mIsOpen ;
270 
271  Bool_t mIsPNGOn ;
272  Bool_t mIsGIFOn ;
273  Bool_t mIsJPGOn ;
274  Bool_t mIsEPSOn ;
275  Bool_t mIsPSOn ;
276 
277  Int_t mYear ;
278  TString mProduction ;
279  Int_t mGeantId ;
280  Double_t mPtMax ;
281 
282  TFile* mInputEmbedding ;
283  TFile* mInputRealData ;
284 
285  TString mOutputFigureDirectory ;
286 
287  std::vector<Int_t> mDaughterGeantId ;
288  std::vector<Int_t> mParentGeantId ;
289  std::vector<Int_t> mParentParentGeantId ;
290  std::vector<Int_t> mMcGeantId ;
291  Int_t mInputParentGeantId ;
292 
293  ClassDef(StEmbeddingQADraw, 1)
294 };
295 
296 inline Int_t StEmbeddingQADraw::getYear() const { return mYear ; }
297 inline const Char_t* StEmbeddingQADraw::getProduction() const { return mProduction.Data() ; }
298 inline Int_t StEmbeddingQADraw::getGeantId() const { return mGeantId ; }
299 
300 #endif
301 
Bool_t drawPhi() const
Geant id.
const Char_t * getParticleName(const Int_t geantid=-1) const
Get geant id.
Bool_t drawPt() const
(pseudo-)rapidity in different eta bins
Bool_t drawDca() const
dE/dx (2D) and projections
Bool_t drawdEdx() const
momentum (|eta|&lt;2, 0.5 eta increment)
Bool_t drawNHit() const
Dca vs (pt, eta)
Bool_t drawGeantId() const
Draw Reconstructed track histograms.
void setJPGOn()
Set true for gif file flag (default is false)
void setPNGOn()
Finish QA.
void setEPSOn()
Set true for jpg file flag (default is false)
Bool_t drawRapidity() const
Azimuthal angle (phi) distributions.
Int_t getYear() const
Set true for ps file flag (default is false)
const Char_t * getProduction() const
Get year.
Bool_t drawTrack() const
Draw MC track histograms.
Bool_t finish()
NHit vs (pt, eta)
void setParentGeantId(const Int_t parentgeantid)
Set parent geant id (default is 0)
void setPSOn()
Set true for eps file flag (default is false)
Bool_t drawMomentum() const
pt (|eta|&lt;2, 0.5 eta increment)
void setGIFOn()
Set true for png file flag (default is false)
Bool_t drawMcTrack() const
Draw all event-wise histograms.
Int_t getGeantId() const
Get production.
Bool_t drawEvent() const
Draw all histograms (event and track histograms).
void init()
Initialization.
void setOutputDirectory(const TString name="./")
Default is current directory.
StEmbeddingQADraw(const TString embeddingFile, const TString realDataFile, const Int_t geantid, const Bool_t isEmbeddingOnly=kFALSE)