StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_hist_anal.C
1 // $Id: bfcread_hist_anal.C,v 3.5 2011/02/07 20:29:57 genevb Exp $
2 // $Log: bfcread_hist_anal.C,v $
3 // Revision 3.5 2011/02/07 20:29:57 genevb
4 // Allow detectors specification
5 //
6 // Revision 3.4 2011/01/24 18:13:48 genevb
7 // Reference hist file has no TopDirTree
8 //
9 // Revision 3.3 2011/01/19 02:41:54 genevb
10 // Flexible input arrangement for 1 file
11 //
12 // Revision 3.2 2011/01/19 02:05:22 genevb
13 // Allow plain ROOT files with hists, and individual plot generation from 1 file
14 //
15 // Revision 3.1 2009/04/03 02:35:30 genevb
16 // Introduction of reference histogram analysis macro
17 //
18 //
19 //======================================================================
20 // bfcread_hist_anal.C
21 // author: G. Van Buren (BNL)
22 //
23 // purpose: reads the *.hist.root file produced from a chain
24 // (such as bfc) or plain root file with hists,
25 // and then draws & sends to ps file the
26 // histograms from given input Maker
27 // also performing an analysis if a reference
28 // histogram file is supplied
29 //
30 // inputs: MainFile - *.hist.root file can be from bfc output
31 // or just a plain file with histograms
32 // MakerHistDir - directory name of Maker that you want histograms
33 // from (this will be first input when you did constructor)
34 // -- see standard Maker names note below!
35 // TopDirTree - top level directory tree in your input hist file
36 // (this is 3rd argument of constructor for StTreeMaker that
37 // you probably used to write the *.hist.root file)
38 // NOTE: if you ran bfc, then the TopDirTree = bfcTree !!
39 // and if you are using a plain file, leave this as "" !!
40 // psFile - output postscript file name
41 // PageTitle - title at top of each page - if it's "", then it's
42 // set to MainFile by default
43 // PrintList - name of subset histogram list that you want printed
44 // - these are defined in StHistUtil, method SetDefaultPrintList
45 // - default = "", prints all histograms in directory MakerHistDir
46 // refOutFile - name of file where histograms will be saved
47 // refResultsFile - name of file where results of analysis will be saved
48 // refCutsFile - name of file from where analysis cuts will be read
49 // refInFile - name of file from where reference histograms will be read
50 // - without this file, no analysis will be done
51 // DetList - names of detectors to include (e.g. "tpc ftpc bemc")
52 //
53 //
54 //======================================================================
55 
56 class StIOMaker;
57 StIOMaker *IOMk=0;
58 
59 //------------------------------------------------------------------------
60 
61 void bfcread_hist_anal(
62  const Char_t *MainFile=
63  "/afs/rhic.bnl.gov/star/data/samples/gstar.hist.root",
64  const Char_t *MakerHistDir="EventQA",
65  const Char_t *TopDirTree="bfcTree",
66  const Char_t *psFile="QA_hist.ps",
67  const Char_t *PageTitle="",
68  const Char_t *PrintList="",
69  const Int_t ZoneH=2,
70  const Int_t ZoneV=3,
71  const Char_t *refOutFile="resultHists.root",
72  const Char_t *refResultsFile="results.txt",
73  const Char_t *refCutsFile=0,
74  const Char_t *refInFile=0,
75  const Char_t *DetList=0
76 )
77 {
78 
79  // If no MainFile, try swapping for the input reference file...
80  if (strlen(MainFile)<1) {
81  cout << "bfcread_hist_anal.C, no input...trying reference as main input..." << endl;
82  const Char_t* temp = refInFile;
83  refInFile = MainFile;
84  MainFile = temp;
85  strcpy(TopDirTree,"");
86  }
87 
88  cout << "bfcread_hist_anal.C, input hist file = "
89  << MainFile << endl;
90  cout << "bfcread_hist_anal.C, directory name for hist = "
91  << MakerHistDir << endl;
92  cout << "bfcread_hist_anal.C, top level directory in hist file = "
93  << TopDirTree << endl;
94  cout << "bfcread_hist_anal.C, output ps file = "
95  << psFile << endl;
96  cout << "bfcread_hist_anal.C, page title for histograms = "
97  << PageTitle << endl;
98  cout << "bfcread_hist_anal.C, subset list name of which histograms to draw,print = "
99  << PrintList << endl;
100  cout << "bfcread_hist_anal.C, # histograms on page horizontally = "
101  << ZoneH << endl;
102  cout << "bfcread_hist_anal.C, # histograms on page vertically = "
103  << ZoneV << endl;
104 
105  gSystem->Load("St_base");
106  gSystem->Load("StChain");
107  gSystem->Load("StIOMaker");
108  gSystem->Load("StarClassLibrary");
109  gSystem->Load("libglobal_Tables");
110  gSystem->Load("StUtilities");
111  gSystem->Load("StAnalysisUtilities");
112 
113  // constructor for analysis class
114  StHistUtil *HU = new StHistUtil;
115 
116  if (strlen(TopDirTree)) {
117  // set up IOMaker - flexibility for STAR input files
118  IOMk = new StIOMaker("IO","r",MainFile,TopDirTree);
119  IOMk->SetDebug();
120  IOMk->SetIOMode("r");
121  IOMk->SetBranch("*",0,"0"); //deactivate all branches
122  IOMk->SetBranch("histBranch",0,"r"); //activate dst Branch
123 
124  // look into the file...
125  IOMk->Init();
126  IOMk->Clear();
127  IOMk->Make();
128 
129  // now must set pointer to StMaker so HistUtil can find histograms
130  // with StHistUtil methods
131  // -- input any maker pointer but must cast as type StMaker
132  HU->SetPntrToMaker((StMaker *)IOMk);
133  } else {
134  // now must set pointer to the plain file so HistUtil can find histograms
135  // with StHistUtil methods
136  HU->SetPntrToPlainFile(TFile::Open(MainFile));
137  }
138 
139  // Set the default canvas style to plain (so it won't print out grey!)
140  gROOT->SetStyle("Plain");
141 
142  HU->SetDetectors(DetList);
143  HU->SetHistsNamesDraw("*","*");
144  HU->GetRunYear(MainFile);
145  HU->SetOutFile(psFile);
146  HU->SetZones(ZoneH,ZoneV);
147  HU->SetPaperSize();
148  HU->SetDefaultLogXList(MakerHistDir);
149  HU->SetDefaultLogYList(MakerHistDir);
150  if (PageTitle=="") PageTitle=MainFile;
151  HU->SetGlobalTitle(PageTitle);
152 
153  HU->SetDefaultPrintList(MakerHistDir,PrintList);
154 
155  Int_t numLog = 0;
156  numLog = HU->ExamineLogYList();
157  cout <<" bfcread_hist_anal.C, Number hist to plot with log scale = " << numLog << endl;
158 
159  Int_t numPrint = 0;
160  numPrint = HU->ExaminePrintList();
161  cout << " bfcread_hist_anal.C, Number hist to print = " << numPrint << endl;
162 
163  HU->SetRefAnalysis(refOutFile,refResultsFile,refCutsFile,refInFile);
164 
165  // Now draw the actual histograms to canvas and to ps file
166  HU->DrawHists(MakerHistDir);
167 
168  cout <<" bfcread_hist_anal.C, end of macro" << endl;
169 
170 }
171 
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