StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_hist_prefixes_add_to_ps.C
1 // $Id: bfcread_hist_prefixes_add_to_ps.C,v 3.6 2017/02/27 21:41:36 genevb Exp $
2 // $Log: bfcread_hist_prefixes_add_to_ps.C,v $
3 // Revision 3.6 2017/02/27 21:41:36 genevb
4 // StEvent.so now depends on StBichsel.so
5 //
6 // Revision 3.5 2014/07/22 20:37:52 genevb
7 // Remove unnecessary library loads
8 //
9 // Revision 3.4 2013/03/14 17:28:31 genevb
10 // StTpcDb.so now depends on StEvent.so
11 //
12 // Revision 3.3 2011/06/03 00:09:21 genevb
13 // Calling CopyHist twice was dangerous, AddHist handles copying if not found after first CopyHist
14 //
15 // Revision 3.2 2010/03/16 16:23:09 fisyak
16 // StTpcDb requires StDetectorDbMaker
17 //
18 // Revision 3.1 2008/05/28 05:16:08 genevb
19 // Allow summing over (ignoring) histogram prefixes
20 //
21 //
22 //======================================================================
23 // author: G. Van Buren (BNL)
24 // what it does: see below
25 //=======================================================================
26 // bfcread_hist_prefixes_add_to_ps.C
27 //
28 // what it does: reads the *.hist.root file produced from a chain
29 // (such as bfc) and
30 // adds histograms with the same name, but different prefix,
31 // then draws & sends to ps file the
32 // histograms from given input Maker
33 //
34 // (based on a combination of bfcread_hist_to_ps.C and
35 // bfcread_hist_prefixes_add.C)
36 //
37 // inputs: MainFile - *.hist.root file from bfc output
38 // MakerHistDir - directory name of Maker that you want histograms
39 // from (this will be first input when you did constructor)
40 // -- see standard Maker names note below!
41 // TopDirTree - top level directory tree in your input hist file
42 // (this is 3rd argument of constructor for StTreeMaker that
43 // you probably used to write the *.hist.root file)
44 // NOTE: if you ran bfc, then the TopDirTree = bfcTree !!
45 // psFile - output postscript file name
46 // PageTitle - title at top of each page - if it's "", then it's
47 // set to MainFile by default
48 // PrintList - name of subset histogram list that you want printed
49 // - these are defined in StHistUtil, method SetDefaultPrintList
50 // - default = "", prints all histograms in directory MakerHistDir
51 //
52 //
53 //
54 //======================================================================
55 
56 class StChain;
57 StChain *chain;
58 
59 class StIOMaker;
60 StIOMaker *IOMk=0;
61 
62 //------------------------------------------------------------------------
63 
64 void bfcread_hist_prefixes_add_to_ps(
65  const Char_t *MainFile=
66  "/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
67  const Char_t *MakerHistDir="EventQA",
68  const Char_t *TopDirTree="bfcTree",
69  const Char_t *psFile="QA_hist.ps",
70  const Char_t *PageTitle="",
71  const Char_t *PrintList="",
72  const Int_t ZoneH=2,
73  const Int_t ZoneV=3
74 )
75 {
76 
77  cout << "bfcread_hist_prefixes_add_to_ps.C, input hist file = "
78  << MainFile << endl;
79  cout << "bfcread_hist_prefixes_add_to_ps.C, directory name for hist = "
80  << MakerHistDir << endl;
81  cout << "bfcread_hist_prefixes_add_to_ps.C, top level directory in hist file = "
82  << TopDirTree << endl;
83  cout << "bfcread_hist_prefixes_add_to_ps.C, output ps file = "
84  << psFile << endl;
85  cout << "bfcread_hist_prefixes_add_to_ps.C, page title for histograms = "
86  << PageTitle << endl;
87  cout << "bfcread_hist_prefixes_add_to_ps.C, subset list name of which histograms to draw,print = "
88  << PrintList << endl;
89  cout << "bfcread_hist_prefixes_add_to_ps.C, # histograms on page horizontally = "
90  << ZoneH << endl;
91  cout << "bfcread_hist_prefixes_add_to_ps.C, # histograms on page vertically = "
92  << ZoneV << endl;
93 
94 //
95  gSystem->Load("St_base");
96  gSystem->Load("StChain");
97  gSystem->Load("StIOMaker");
98  gSystem->Load("libglobal_Tables");
99  gSystem->Load("StUtilities");
100  gSystem->Load("StAnalysisUtilities");
101  gSystem->Load("StBichsel");
102  gSystem->Load("StEvent");
103  gSystem->Load("StTpcDb");
104  gSystem->Load("StPmdUtil");
105  gSystem->Load("St_QA_Maker");
106 
107 // setup chain with IOMaker - can read in .dst.root, .dst.xdf files
108  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
109  IOMk->SetDebug();
110  IOMk->SetIOMode("r");
111  IOMk->SetBranch("*",0,"0"); //deactivate all branches
112  IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch
113 
114  TString HMname = MakerHistDir;
115  HMname.Prepend("Summed");
116  const char* MakerHistDirS = HMname.Data();
117 
118 // temporary storage of summed histograms
119  StHistMaker *HM = new StHistMaker(MakerHistDirS);
120 
121 
122 // constructor for other maker (not used in chain)
123  StHistUtil *HO = new StHistUtil;
124  StHistUtil *HU = new StHistUtil;
125 
126 // now must set pointer to StMaker so HistUtil can find histograms
127 // with StHistUtil methods
128  HO->SetPntrToMaker(IOMk);
129  HU->SetPntrToMaker(IOMk);
130  HO->IgnorePrefixes();
131  HU->IgnorePrefixes();
132 
133 // ONLY use StIOMaker in chain
134 // --- now execute chain member functions - 1 event (histograms) only
135  IOMk->Init();
136  IOMk->Clear();
137  IOMk->Make();
138  HM->Init();
139 
140 
141  HO->SetDefaultPrintList(MakerHistDir,PrintList);
142  TList* dirList = HO->FindHists(MakerHistDir,HO->GetPrefix(0));
143  Int_t hCCount = 0;
144 
145  int prefixNum;
146  int nPrefixes = HO->GetNumOfPosPrefixes();
147  Bool_t firstSet = kTRUE;
148  for (prefixNum=0; prefixNum < nPrefixes; prefixNum++) {
149 
150 // get the TList pointer to the histograms for this branch:
151  dirList = HO->FindHists(MakerHistDir,HO->GetPrefix(prefixNum));
152  if (dirList->GetSize()) {
153 
154  if (firstSet) {
155  firstSet = kFALSE;
156 
157 // now make a copy of all histograms into the new histograms!
158  hCCount = HO->CopyHists(dirList);
159  cout << "bfcread_hist_prefixes_add_to_ps.C, # histograms copied with prefix " <<
160  HO->GetPrefix(prefixNum) << " = " << hCCount << endl;
161 
162  HM->SetHArraySize(HO->getNewHistSize());
163  HM->SetHArray(HO->getNewHist());
164  HM->Make();
165  } else { // first set or not
166  hCCount = HO->AddHists(dirList);
167  cout << "bfcread_hist_prefixes_add_to_ps.C, # histograms added with prefix " <<
168  HO->GetPrefix(prefixNum) << " = " << hCCount << endl;
169  } // first set or not
170  } // found hists
171  HO->Clear();
172 
173  } // loop over prefixes
174 
175 
176 
177 // method to print out list of histograms
178 // - can do this anytime after they're booked
179 // - default is to print out QA hist branch
180  Int_t NoHist=0;
181  NoHist = HU->ListHists(MakerHistDirS);
182  cout << " in bfcread_hist_list: Num of Hist = " << NoHist << endl;
183 
184 // Set the default canvas style to plain (so it won't print out grey!)
185  gROOT->SetStyle("Plain");
186 // gStyle->SetOptStat(111111);
187 
188  HU->SetHistsNamesDraw("*","*");
189  HU->GetRunYear(MainFile);
190  HU->SetOutFile(psFile);
191  HU->SetZones(ZoneH,ZoneV);
192  HU->SetPaperSize();
193  HU->SetDefaultLogXList(MakerHistDirS);
194  HU->SetDefaultLogYList(MakerHistDirS);
195  if (PageTitle=="") PageTitle=MainFile;
196  HU->SetGlobalTitle(PageTitle);
197 
198  HU->SetDefaultPrintList(MakerHistDirS,PrintList);
199 
200  Int_t numLog = 0;
201  numLog = HU->ExamineLogYList();
202  cout <<" bfcread_hist_prefixes_add_to_ps.C, Number hist to plot with log scale = " << numLog << endl;
203 
204  Int_t numPrint = 0;
205  numPrint = HU->ExaminePrintList();
206  cout << " bfcread_hist_prefixes_add_to_ps.C, Number hist to print = " << numPrint << endl;
207 
208 // Now draw the actual histograms to canvas and to ps file
209  HU->DrawHists(MakerHistDirS);
210 
211  cout <<" bfcread_hist_prefixes_add_to_ps.C, end of macro" << endl;
212 
213 }
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
virtual Int_t Make()
Definition: StHistMaker.cxx:34
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