StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_hist_to_ps.C
1 // $Id: bfcread_hist_to_ps.C,v 1.31 2011/02/07 20:29:57 genevb Exp $
2 // $Log: bfcread_hist_to_ps.C,v $
3 // Revision 1.31 2011/02/07 20:29:57 genevb
4 // Allow detectors specification
5 //
6 // Revision 1.30 2006/08/15 21:42:42 jeromel
7 // Fix rhic -> rhic.bnl.gov
8 //
9 // Revision 1.29 2006/05/18 16:38:04 genevb
10 // Introduce StHistUtil::GetRunYear()
11 //
12 // Revision 1.28 2006/03/28 02:04:42 genevb
13 // Allow non-PostScript output
14 //
15 // Revision 1.27 2002/01/29 20:03:08 genevb
16 // Switched default dir from QA to EventQA
17 //
18 // Revision 1.26 2000/09/05 19:52:20 lansdell
19 // fixed a minor syntax error
20 //
21 // Revision 1.25 2000/06/21 21:15:22 kathy
22 // now allow the zone settings for horizontal & vertical axes to be set during input to macro
23 //
24 // Revision 1.24 2000/06/12 19:58:54 lansdell
25 // loaded global shared library
26 //
27 // Revision 1.23 2000/04/12 15:06:53 kathy
28 // changed all macros that read DSTs to load Tables from libraries: gen,sim,global,dst instead of ALL Tables (previously loaded St_Tables); currently, if you are using DEV to read a DST in NEW,PRO, you must comment out the loading of libtpc_Tables because of a mismatch with tpt_track table
29 //
30 // Revision 1.22 2000/03/20 17:32:55 kathy
31 // setbranches in all macros so that they will work with softlinks - for StIOMaker
32 //
33 // Revision 1.21 2000/02/29 18:25:14 kathy
34 // fix typo
35 //
36 // Revision 1.20 2000/02/14 20:30:41 kathy
37 // removing unneeded macros; updating documentation in bfcread macros
38 //
39 // Revision 1.19 2000/01/26 19:28:15 kathy
40 // put in call to method SetDefaultLogXList
41 //
42 // Revision 1.18 2000/01/19 16:29:51 kathy
43 // update macros to use default input files in /afs/rhic.bnl.gov/star/data/samples
44 //
45 // Revision 1.17 2000/01/18 16:38:05 kathy
46 // add loading of StUtilities and StAnalysisUtilities so that StHistUtil class can now be picked up from StAnalysisUtilities library
47 //
48 // Revision 1.16 2000/01/13 17:18:04 kathy
49 // updated bfcread_hist* macros so that they can now use the new *PrintList methods from StHistUtil to only print a subset (given a list of names) of histograms from the given Maker Directory; also updated documentation
50 //
51 // Revision 1.15 2000/01/10 21:59:17 kathy
52 // must now load St_global when running St_QA_Maker
53 //
54 // Revision 1.14 2000/01/10 21:24:03 kathy
55 // St_QA_Maker now requires that St_global be loaded because it uses the prop_one_track function from pams/global/egr
56 //
57 // Revision 1.13 2000/01/05 22:12:03 kathy
58 // changed input file to current one
59 //
60 // Revision 1.12 1999/12/01 21:30:11 kathy
61 // added input TopDirTree to bfcread_hist* macros in order to tell which top level directory hist file has since sometimes its not bfcTree; cleaned up print statements in bfcread_dst*hist.C macros; two new macros bfcread_dst_*QA_outhistfile.C added which read dst file and book and fill histograms and write out a new *.hist.root file, instead of just sending hist to postscript - this new *.hist.root file can then be read into bfcread_hist*.C to look at it --- note that topdirtree is different!
62 //
63 // Revision 1.11 1999/11/30 19:23:06 kathy
64 // changed bfcread_dst*.C so that MakerHist is hardwired in instead of being input; wrote better documentation in bfcread_hist*.C so that it explains where top level directory is set
65 //
66 // Revision 1.10 1999/11/23 20:42:16 genevb
67 // Re-arranged load order
68 //
69 // Revision 1.9 1999/11/19 20:13:22 kathy
70 // cleaned up macros to remove uneccessary lines; also added info about new tables to QA* macros
71 //
72 // Revision 1.8 1999/11/05 22:50:40 kathy
73 // now input global title for all output pages in the macro for printing & drawing histograms
74 //
75 // Revision 1.7 1999/11/05 16:30:16 kathy
76 // minor changes to documentation in macro
77 //
78 // Revision 1.6 1999/11/03 21:35:35 kathy
79 // small fixes for use of StIOMaker - had it wrong before
80 //
81 // Revision 1.5 1999/11/03 19:02:55 kathy
82 // changes to default input files and output file names - needed by perl script for testing
83 //
84 // Revision 1.4 1999/11/03 17:13:02 kathy
85 // fixed macros so they use StIOMaker instead of StTreeMaker
86 //
87 // Revision 1.3 1999/09/21 15:07:03 kathy
88 // change to have notes on input values at top of each macro, also clean up notes on usage and remove the usage of method St_QA_Maker::SetPntrToHistUtil which is not going to be used now that I made St_QA_Maker totally independent of the histogram printing
89 //
90 // Revision 1.2 1999/09/20 20:28:12 kathy
91 // fix to give macro correct name
92 //
93 // Revision 1.1 1999/09/20 20:09:02 kathy
94 // bfcread_hist_list_all now lists all histograms in hist.root file; bfcread_hist_list now only lists those that are in the Maker that is input; bfcread_hist_to_ps prints and draws the hist that are in the input Maker, bfcread_dst_QAhist.C reads .dst.root file - runs QA_Maker and prints and draws the QA histograms
95 //
96 //
97 //======================================================================
98 // owner: Kathy Turner
99 // what it does: see below
100 //=======================================================================
101 // bfcread_hist_to_ps.C
102 //
103 // what it does: reads the *.hist.root file produced from a chain
104 // (such as bfc) and
105 // then draws & sends to ps file the
106 // histograms from given input Maker
107 //
108 // inputs: MainFile - *.hist.root file from bfc output
109 // MakerHistDir - directory name of Maker that you want histograms
110 // from (this will be first input when you did constructor)
111 // -- see standard Maker names note below!
112 // TopDirTree - top level directory tree in your input hist file
113 // (this is 3rd argument of constructor for StTreeMaker that
114 // you probably used to write the *.hist.root file)
115 // NOTE: if you ran bfc, then the TopDirTree = bfcTree !!
116 // psFile - output postscript file name
117 // PageTitle - title at top of each page - if it's "", then it's
118 // set to MainFile by default
119 // PrintList - name of subset histogram list that you want printed
120 // - these are defined in StHistUtil, method SetDefaultPrintList
121 // - default = "", prints all histograms in directory MakerHistDir
122 // DetList - names of detectors to include (e.g. "tpc ftpc bemc")
123 //
124 //
125 // standard Maker names in bfc
126 // (but if you run your own Maker here, then use whatever name you give it)
127 // are listed at
128 // http://www.star.bnl.gov/STAR/html/comp_l/train/tut/bfc_maker_names.html
129 //
130 //
131 // Documentation on StHistUtil class is at:
132 // http://duvall.star.bnl.gov/STARAFS/comp/pkg/dev/StRoot/StAnalysisUtilities/doc/
133 //
134 //======================================================================
135 
136 class StChain;
137 StChain *chain;
138 
139 class StIOMaker;
140 StIOMaker *IOMk=0;
141 
142 //------------------------------------------------------------------------
143 
144 void bfcread_hist_to_ps(
145  const Char_t *MainFile=
146  "/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
147  const Char_t *MakerHistDir="EventQA",
148  const Char_t *TopDirTree="bfcTree",
149  const Char_t *psFile="QA_hist.ps",
150  const Char_t *PageTitle="",
151  const Char_t *PrintList="",
152  const Int_t ZoneH=2,
153  const Int_t ZoneV=3,
154  const Char_t *DetList=0
155 )
156 {
157 
158  cout << "bfcread_hist_to_ps.C, input hist file = "
159  << MainFile << endl;
160  cout << "bfcread_hist_to_ps.C, directory name for hist = "
161  << MakerHistDir << endl;
162  cout << "bfcread_hist_to_ps.C, top level directory in hist file = "
163  << TopDirTree << endl;
164  cout << "bfcread_hist_to_ps.C, output ps file = "
165  << psFile << endl;
166  cout << "bfcread_hist_to_ps.C, page title for histograms = "
167  << PageTitle << endl;
168  cout << "bfcread_hist_to_ps.C, subset list name of which histograms to draw,print = "
169  << PrintList << endl;
170  cout << "bfcread_hist_to_ps.C, # histograms on page horizontally = "
171  << ZoneH << endl;
172  cout << "bfcread_hist_to_ps.C, # histograms on page vertically = "
173  << ZoneV << endl;
174 
175 //
176  gSystem->Load("St_base");
177  gSystem->Load("StChain");
178  gSystem->Load("StIOMaker");
179  gSystem->Load("StarClassLibrary");
180  gSystem->Load("libglobal_Tables");
181  gSystem->Load("StUtilities");
182  gSystem->Load("StAnalysisUtilities");
183 
184 
185 // setup chain with IOMaker - can read in .dst.root, .dst.xdf files
186  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
187  IOMk->SetDebug();
188  IOMk->SetIOMode("r");
189  IOMk->SetBranch("*",0,"0"); //deactivate all branches
190  IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch
191 
192 
193 // constructor for other maker (not used in chain)
194  StHistUtil *HU = new StHistUtil;
195 
196 // now must set pointer to StMaker so HistUtil can find histograms
197 // with StHistUtil methods
198 // -- input any maker pointer but must cast as type StMaker
199  HU->SetPntrToMaker((StMaker *)IOMk);
200 
201 // ONLY use StIOMaker in chain
202 // --- now execute chain member functions - 1 event (histograms) only
203  IOMk->Init();
204  IOMk->Clear();
205  IOMk->Make();
206 
207 // method to print out list of histograms
208 // - can do this anytime after they're booked
209 // - default is to print out QA hist branch
210  Int_t NoHist=0;
211  NoHist = HU->ListHists(MakerHistDir);
212  cout << " in bfcread_hist_list: Num of Hist = " << NoHist << endl;
213 
214 // Set the default canvas style to plain (so it won't print out grey!)
215  gROOT->SetStyle("Plain");
216 // gStyle->SetOptStat(111111);
217 
218  HU->SetDetectors(DetList);
219  HU->SetHistsNamesDraw("*","*");
220  HU->GetRunYear(MainFile);
221  HU->SetOutFile(psFile);
222  HU->SetZones(ZoneH,ZoneV);
223  HU->SetPaperSize();
224  HU->SetDefaultLogXList(MakerHistDir);
225  HU->SetDefaultLogYList(MakerHistDir);
226  if (PageTitle=="") PageTitle=MainFile;
227  HU->SetGlobalTitle(PageTitle);
228 
229  HU->SetDefaultPrintList(MakerHistDir,PrintList);
230 
231  Int_t numLog = 0;
232  numLog = HU->ExamineLogYList();
233  cout <<" bfcread_hist_to_ps.C, Number hist to plot with log scale = " << numLog << endl;
234 
235  Int_t numPrint = 0;
236  numPrint = HU->ExaminePrintList();
237  cout << " bfcread_hist_to_ps.C, Number hist to print = " << numPrint << endl;
238 
239 // Now draw the actual histograms to canvas and to ps file
240  HU->DrawHists(MakerHistDir);
241 
242  cout <<" bfcread_hist_to_ps.C, end of macro" << endl;
243 
244 }
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
255 
256 
virtual void Clear(Option_t *opt)
User defined functions.
Definition: StIOMaker.cxx:252
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual Int_t Make()
Definition: StIOMaker.cxx:183