StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
create_ftpc_QA_refhists.C
1 // $Id: create_ftpc_QA_refhists.C,v 1.2 2006/04/11 09:32:49 jcs Exp $
2 // $Log: create_ftpc_QA_refhists.C,v $
3 // Revision 1.2 2006/04/11 09:32:49 jcs
4 // improve comments
5 //
6 // Revision 1.1 2006/04/11 09:30:17 jcs
7 // sample macro to create one *.gif file for each FTPC Offline QA reference histogram
8 //
9 //
10 //------------------------------------------------------------------------
11 //
12 // This macro produces one *.gif file for each Y2006 FTPC QA Reference Histogram
13 // The *.gif files are used in the "STAR Offline FTPC QA Reference Histograms - Run 6" description:
14 // /afs/rhic.bnl.gov/star/doc_public/www/ftpc/DataQualityControl/FTPC_QA_histograms_Y2006.html
15 //
16 // For Year 2006, the EventQA histograms are divided into a set of general
17 // histograms and one or more multiplicity/trigger class histograms.
18 //
19 // Checking FTPC QA histograms with less than 400 pp events does not make much
20 // sense because of inconclusive statistics. For Y2006, the "high tower histogram"
21 // set is used because it contains more events than the minbias set
22 //
23 // ATTENTION!!!!!!!: The *.gif files ONLY contain the correct line attributes
24 // when this macro is run interactively
25 //
26 //------------------------------------------------------------------------
27 
28 int sizeOfCharPtr = sizeof(Char_t*);
29 
30 class StChain;
31 StChain *chain;
32 
33 class StIOMaker;
34 StIOMaker *IOMk=0;
35 
36 //------------------------------------------------------------------------
37 
38 void create_ftpc_QA_refhists(
39  const Char_t *MainFile=
40  "/star/xtp/jcs/st_physics_7075188_raw_1030004.hist.root"
41 )
42 {
43 
44  cout << "create_ftpc_refhists.C, input hist file = "
45  << MainFile << endl;
46 
47 //
48  gSystem->Load("St_base");
49  gSystem->Load("StChain");
50  gSystem->Load("StIOMaker");
51  gSystem->Load("StarClassLibrary");
52  gSystem->Load("libglobal_Tables");
53  gSystem->Load("StUtilities");
54  gSystem->Load("StAnalysisUtilities");
55 
56 // Setup top part of chain
57  chain = new StChain("bfc");
58  chain->SetDebug();
59 
60 // setup chain with IOMaker - can read in .dst.root, .dst.xdf files
61  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
62  IOMk->SetDebug();
63  IOMk->SetIOMode("r");
64  IOMk->SetBranch("*",0,"0"); //deactivate all branches
65  IOMk->SetBranch("histBranch",0,"r"); //activate hist Branch
66 
67 // Set the default canvas style to plain (so it won't print out grey!)
68  gROOT->SetStyle("Plain");
69  TCanvas *canvas = new TCanvas("CanvasName"," STAR Maker Histogram Canvas",1);
70  gStyle->SetOptStat(111111);
71  gStyle->SetStatStyle(0);
72  gStyle->SetOptDate(0);
73  canvas->SetGridx(0);
74  canvas->SetGridy(0);
75 
76 // --- now execute chain member functions
77  chain->Init();
78 
79  TDataSet *ds=0;
80  TDataSet *obj=0;
81  int i=0;
82  int istat=0;
83  int countev=0;
84  int countevhds=0;
85 
86  chain->Clear();
87  istat = chain->Make(i);
88 
89 // Ftpc Reference Histogram list for Y2006
90  cout<<"sizeOfCharPtr = "<<sizeOfCharPtr<<endl;
91  Char_t* sdefList[] = {
92  "StEQaEvsumTotChgF",
93  "fcl_chargestepW",
94  "fcl_chargestepE",
95  "StEHTQaPointFtpc",
96  "StEHTQaPointXYFtpcE",
97  "StEHTQaPointXYFtpcW",
98  "StEHTQaPointPadTimeFtpcW",
99  "StEHTQaPointPadTimeFtpcE",
100  "StEHTQaPointPlaneF",
101  "StEHTQaGtrkXfYfFE",
102  "StEHTQaGtrkXfYfFW",
103  "StEHTQaGtrkPsiF",
104  "StEHTQaGtrkPtF",
105  "StEHTQaGtrkEtaF",
106  "StEHTQaGtrkPF",
107  "StEHTQaGtrkNPntF",
108  "StEHTQaGtrkGoodF",
109  "StEHTQaGtrkImpactrF",
110  "StEHTQaPtrkMeanPtF",
111  "StEHTQaPtrkMeanEtaF",
112  "StEHTQaPtrkEtaF",
113  "StEHTQaPtrkPtF",
114  "StEHTQaVtxFtpcETpcXY",
115  "StEHTQaVtxFtpcETpcZ",
116  "StEHTQaVtxFtpcWTpcZ",
117  "StEHTQaVtxFtpcWTpcXY"
118  };
119  Int_t lengofList = sizeof(sdefList)/sizeOfCharPtr;
120 cout<<"sdefList[0] = "<<sdefList[0]<<endl;
121  cout<<"sizeof(sdefList) = "<<sizeof(sdefList)<<" sizeOfCharPtr = "<<sizeOfCharPtr<<" lengofList = "<<lengofList<<endl;
122 
123 // Now look at the data in the event:
124  int countObj=0;
125  int countHist=0;
126 
127  if (!istat) {
128 
129  countev++;
130 
131  cout << " start event # " << countev << endl;
132 
133  ds=chain->GetDataSet("hist");
134  TDataSetIter tabiter(ds);
135  if (ds) {
136 
137  countevhds++;
138 
139  TDataSetIter nextHistList(ds);
140  St_ObjectSet *histContainer = 0;
141  TList *dirList = 0;
142 
143 // loop over directories:
144  while (histContainer = (St_ObjectSet *)nextHistList()) {
145  dirList = (TList *) histContainer->GetObject();
146 
147  cout << " QAInfo: found directory: " <<
148  histContainer->GetName() << endl;
149 
150  countObj++;
151 
152  if (strcmp((Char_t *)histContainer->GetName(),"EventQAHist") == 0) {
153  cout << "QAInfo: Process histograms in directory EventQAHist" <<endl;
154 
155 // Notes for future reference (if we want to generalize this...)
156 // dirList is returned 0 for non-histogram file
157 // in that case, use GetList instead of GetObject
158 
159  TIter nextHist(dirList);
160  TObject *o = 0;
161  TH1* hobjradialW = NULL;
162  TH1* hobjradialE = NULL;
163 // loop over histograms in the directory:
164  while (o= nextHist()) {
165 //cout<<" o->GetName()) "<<o->GetName()<<endl;
166 
167  canvas->SetLogy(0);
168  Int_t ilg = 0;
169  Char_t filename[50];
170  for (ilg=0;ilg<lengofList;ilg++) {
171  if (strcmp(sdefList[ilg],o->GetName()) == 0) {
172  countHist++;
173  cout << " QAInfo: Hist name: " << o->GetName() <<
174  " ==> Title: " << o->GetTitle() << endl;
175  if ( (strcmp("fcl_chargestepW",o->GetName()) == 0)
176  || (strcmp("fcl_chargestepE",o->GetName()) == 0)
177  || (strcmp("StEHTQaGtrkEtaF",o->GetName()) == 0)
178  || (strcmp("StEHTQaGtrkPtF",o->GetName()) == 0)
179  ||(strcmp("StEHTQaGtrkPF",o->GetName()) == 0)
180  ) canvas->SetLogy(1);
181  // Now draw the actual histogram to canvas and to gif file
182  if ( (strcmp("StEHTQaPointXYFtpcE",o->GetName()) == 0)
183  || (strcmp("StEHTQaPointXYFtpcW",o->GetName()) == 0)
184  || (strcmp("StEHTQaPointPadTimeFtpcE",o->GetName()) == 0)
185  || (strcmp("StEHTQaPointPadTimeFtpcW",o->GetName()) == 0)
186  || (strcmp("StEHTQaGtrkGoodF",o->GetName()) == 0)
187  || (strcmp("StEHTQaGtrkXfYfFW",o->GetName()) == 0)
188  || (strcmp("StEHTQaGtrkXfYfFE",o->GetName()) == 0)
189  || (strcmp("StEHTQaVtxFtpcETpcXY",o->GetName()) == 0)
190  || (strcmp("StEHTQaVtxFtpcWTpcXY",o->GetName()) == 0)) {
191  o->Draw("Box");
192  if (strcmp("StEHTQaGtrkGoodF",o->GetName()) == 0
193  && o->InheritsFrom("TH1")) {
194  TH1* hobj = (TH1*) o;
195  // Limit both x & y ranges together
196  Float_t mean1 = hobj->GetMean(1);
197  Float_t mean2 = hobj->GetMean(2);
198  Float_t window1 = hobj->GetRMS(1);
199  Float_t window2 = hobj->GetRMS(2);
200  Float_t bwid = hobj->GetBinWidth(1);
201  if (window1 < bwid) window1 = bwid;
202  if (window2 < bwid) window2 = bwid;
203  Float_t lo = TMath::Min(mean1-5*window1,mean2-5*window2);
204  Float_t hi = TMath::Max(mean1+5*window1,mean2+5*window2);
205  hobj->SetAxisRange(lo,hi,"X");
206  hobj->SetAxisRange(lo,hi,"Y");
207  TLine ruler;ruler.SetLineColor(46);
208  ruler.DrawLineNDC(0.1,0.1,0.9,0.9);
209  }
210  }
211  else {
212  if (strcmp("StEHTQaPointFtpc",o->GetName()) == 0
213  && o->InheritsFrom("TH1")) {
214  TH1* hobj = (TH1*) o;
215  Float_t mean = hobj->GetMean(1);
216  Float_t window = hobj->GetRMS(1);
217  Float_t bwid = hobj->GetBinWidth(1);
218  if (window < bwid) window = bwid;
219  hobj->SetAxisRange(mean-5*window,mean+5*window,"X");
220  } // StEHTQaPointFtpc
221  o->Draw();
222  }
223  sprintf(filename,"%s.gif",o->GetName());
224  canvas->Print(filename);
225  }
226  } // sdefList
227  if ((strcmp("fcl_radialW",o->GetName()) == 0)) hobjradialW = (TH1*) o;
228  if ((strcmp("fcl_radialE",o->GetName()) == 0)) hobjradialE = (TH1*) o;
229 //cout<<"hobjradialW = "<<hobjradialW<<" hobjradialE = "<<hobjradialE<<endl;
230  if (hobjradialW && hobjradialE) {
231  hobjradialW->SetStats(kFALSE);
232  hobjradialW->GetXaxis()->SetRangeUser(7.0,9.0);
233  hobjradialE->SetStats(kFALSE);
234  hobjradialE->GetXaxis()->SetRangeUser(7.0,9.0);
235  if ( hobjradialW->GetMaximum() >= hobjradialE->GetMaximum()) {
236  //hobjradialW->SetTitle((TString)"FTPCW+E cluster radial position");
237  hobjradialW->SetTitle("FTPCW+E cluster radial position");
238  hobjradialE->SetTitle(hobjradialW->GetTitle());
239  hobjradialW->Draw();
240  hobjradialE->Draw("Same");
241  canvas->Modified();
242  TLine ruler; ruler.SetLineColor(kBlack);
243  ruler.SetLineWidth(2);
244  ruler.DrawLine(7.8,0.,7.8,hobjradialW->GetMaximum());
245  sprintf(filename,"%s.gif",hobjradialW->GetName());
246  } else {
247  hobjradialE->SetTitle((TString)"FTPCE+W cluster radial position");
248  hobjradialW->SetTitle(hobjradialE->GetTitle());
249  hobjradialE->Draw();
250  canvas->Modified();
251  hobjradialW->Draw("Same");
252  TLine ruler; ruler.SetLineColor(kBlack);
253  ruler.SetLineWidth(2);
254  ruler.DrawLine(7.8,0.,7.8,hobjradialE->GetMaximum());
255  sprintf(filename,"%s.gif",hobjradialE->GetName());
256  }
257 
258  // make a legend
259  TLegend *legend = new TLegend(0.75,0.85,0.98,0.95);
260  legend->SetFillColor(0);
261  legend->SetHeader("Legend");
262  legend->SetMargin(0.25);
263  legend->AddEntry(hobjradialE,"FtpcEast","l");
264  legend->AddEntry(hobjradialW,"FtpcWest","l");
265  legend->Draw();
266  canvas->Print(filename);
267  hobjradialW = NULL;
268  hobjradialE = NULL;
269  } // hobjradialW && hobjradialE
270  } // nextHist
271  } // histContainer == "EventQA"
272  } // histContainer
273  } // ds
274 
275  cout << " QAInfo: event # " << countev
276  << ", # directories found = " << countObj
277  << ", # hist found = " << countHist
278  << endl << endl;
279 
280  } // istat
281 
282  else // if (istat)
283  {
284  cout << "Last event processed. Status = " << istat << endl;
285  }
286 
287  cout <<" create_ftpc_refhists.C, end of macro" << endl;
288 
289 }
290 
291 
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Make()
Definition: StChain.cxx:110
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56