StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plPubJS.C
1 TCanvas *can=0;
2 
3 //=================================================
4 plPubJS( int page=1,int pl=0, char *core0="R10103042", char *iPath="", char *oPath=""){ //1=gif, 2=ps, 3=both
5  //char *iPath="/star/data05/scratch/stevens4/wAnalysisOut/data/";
6  //char *iPath="/star/u/stevens4/wAnalysis/out/verB4.3/useEtow2allLT20/";
7  //char *iPath="/star/u/stevens4/wAnalysis/out/verB4.3/useEtow1/";
8  char *iPath="/star/u/stevens4/wAnalysis/out/verB4.3/enhanceQCD/";
9  //char *iPath="/star/u/stevens4/wAnalysis/out/";
10  //core0="R10097000";
11  core0="run9setABCD";
12  //core0="mcSetD1_ppWprod";
13  //core0="mcSetD2_ppQCD10_inf_filter";
14  //core0="mcSetD1_ppZprod";
15  if(page==0) {
16  doAll(pl);
17  return;
18  }
19 
20  /*
21 
22  cat run9setABCD*ps | ps2pdf - all.pdf
23  mv all.pdf ~/stevens4/tmp/all-run9setABCD-pub.pdf
24 
25  */
26 
27 
28  char *nameA[]={"JSetowEneZ1","JSetowEneZ2","JSetowEneZ3","JSetowEneZ4"};
29  char *nameB[]={"JSetowHighPostTr","JSetowTotPostTr","JSetowHighPreNear","JSetowTotPreNear"};
30  char *nameC[]={"JSetowHighPreAway","JSetowTotPreAway"};
31  char *nameD[]={"JSawayNTow","JSawayNTr"};
32  //char *nameD[]={"JSawayNTow","JSawayNTr","JSnearNTow","JSnearNTr"};
33  char *nameE[]={"JSawayCond1","JSawayCond2"};
34 
35  gStyle->SetOptFit(1);
36  TString fullInpName=iPath; fullInpName+=core0;
37  fullInpName+=".wana.hist.root";
38  fd=new TFile(fullInpName);
39  if(! fd->IsOpen()) {
40  printf("EROR: input histo file not found, quit\n",fullInpName.Data());
41  return;
42  } else {
43  printf("Opened: %s\n",fullInpName.Data());
44  }
45 
46  TLine *ln; TList *Lx;
47 
48  gStyle->SetPalette(1,0);
49  //gStyle->SetOptStat(0);
50  char padTit[1000];
51  sprintf(padTit,"%s",core0);
52 
53  switch (page) {
54 
55  case 1:{ sprintf(padTit,"ETOW Gain Study I, %s",core0);
56  can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,padTit,page);
57  c->Divide(2,2);gStyle->SetOptStat(1);
58  char **nameX=nameA;
59  for(int i=0;i<4;i++) {
60  char txt[100]; int xInt=0;
61  printf("->%s<\n",nameX[i]);
62  h=(TH1*)fd->Get(nameX[i]); assert(h);
63  TAxis* axX=h->GetXaxis(); int nbX=axX->GetNbins();
64  float entries= h->GetEntries();
65  for(int j=nbX; j>0; j--){
66  xInt += h->GetBinContent(j);
67  //if(i==0) cout<<j<<" "<<xInt<<endl;
68  if(xInt > 0.0005*entries)
69  {float bin=j; break;}
70  }
71  cout<<i+1<<" 0.01% of counts in energy = "<<bin/10<<" bin"<<endl;
72  Lx=h->GetListOfFunctions();
73  ln=new TLine(bin/10,0,bin/10,1.e6); ln->SetLineColor(kRed); Lx->Add(ln);
74 
75  c->cd(i+1); h->Draw();
76  c->GetPad(i+1)->SetLogy();
77  }
78 
79  } break;//--------------------------------------
80 
81  case 2:{ sprintf(padTit,"ETOW Gain Study II, %s",core0);
82  can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,padTit,page);
83  gStyle->SetOptStat(0); int entries=0;
84  leg = new TLegend(0.6,0.7,.9,.9);
85  leg->SetHeader("Z vertex range (cm)");
86  char **nameX=nameA;
87  for(int i=0;i<4;i++) {
88  char txt[100]; string entry;
89  printf("->%s<\n",nameX[i]);
90  h=(TH1*)fd->Get(nameX[i]); assert(h);
91  h->Rebin(10);
92  if(i==0) entry="[-100,-50]"; if(i==1) entry="[-50,0]";
93  if(i==2) {entry="[0,50]"; h->SetLineStyle(2);}
94  if(i==3) {entry="[50,100]"; h->SetLineStyle(2);}
95 
96  if(i==0) {h->Draw(); entries=h->GetEntries(); gPad->SetLogy(); h->SetTitle("Normalized Endcap Tower E");}
97  else { h->SetLineColor(i+1); h->DrawNormalized("same",entries);}
98  leg->AddEntry(h,Form("%s",entry),"l");
99  }
100  leg->Draw();
101  } break;//--------------------------------------
102 
103  case 3:{ sprintf(padTit,"Beam Background I, %s",core0);
104  can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,padTit,page);
105  c->Divide(2,2); gStyle->SetOptStat(10);
106  char **nameX=nameB;
107  for(int i=0;i<4;i++) {
108  char txt[100];
109  printf("->%s<\n",nameX[i]);
110  h=(TH1*)fd->Get(nameX[i]); assert(h);
111  c->cd(i+1); h->Draw("colz");
112  }
113  } break;//--------------------------------------
114 
115  case 4:{ sprintf(padTit,"Beam Background II, %s",core0);
116  can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,padTit,page);
117  c->Divide(2,2); gStyle->SetOptStat(10);
118  char **nameX=nameC;
119  for(int i=0;i<2;i++) {
120  char txt[100];
121  printf("->%s<\n",nameX[i]);
122  h=(TH1*)fd->Get(nameX[i]); assert(h);
123  c->cd(i+1); h->Draw("colz");
124  }
125  } break;//--------------------------------------
126 
127  case 5:{ sprintf(padTit,"Away Side Counters, %s",core0);
128  can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,padTit,page);
129  c->Divide(2,1);//gStyle->SetOptStat(0);
130  char **nameX=nameD;
131  for(int i=0;i<2;i++) {
132  char txt[100];
133  printf("->%s<\n",nameX[i]);
134  h=(TH1*)fd->Get(nameX[i]); assert(h);
135  c->cd(i+1); h->Draw();
136  c->GetPad(i+1)->SetLogy();
137  }
138  } break;//--------------------------------------
139 
140  case 6:{ sprintf(padTit,"Away Side Conditions, %s",core0);
141  can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,padTit,page);
142  c->Divide(2,2);//gStyle->SetOptStat(0);
143  char **nameX=nameE;
144  for(int i=0;i<2;i++) {
145  char txt[100];
146  printf("->%s<\n",nameX[i]);
147  h=(TH1*)fd->Get(nameX[i]); assert(h);
148  c->cd(i+1); h->Draw();
149  }
150  } break;//--------------------------------------
151 
152 
153 
154  default:
155  printf("page=%d NOT defined\n",page);
156  return;
157  }
158 
159  char text[100];
160  sprintf(text,"%s%s_page%03d",oPath,core0,page);
161  TString tit=text;
162  can->SetTitle(tit);
163  can->SetName(tit);
164 
165 
166  if(pl&1) can->Print(tit+".gif");
167  if(pl&2) can->Print(tit+".ps");
168 
169 }
170 
171 //------------------------
172 TPad *makeTitle(TCanvas *c,char *core, int page) {
173 
174  c->Range(0,0,1,1);
175  TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.);
176  pad0->Draw();
177  pad0->cd();
178 
179  TPaveText *pt = new TPaveText(0,0.,1,1,"br");
180  pt->Draw();
181  TDatime dt;
182  TString txt2=core;
183  txt2+=", page=";
184  txt2+=page;
185  txt2+=", ";
186  txt2+=dt.AsString();
187  pt->AddText(txt2);
188  txt2="--";
189  pt->AddText(txt2);
190 
191  c->cd();
192  pad = new TPad("pad1", "apd1",0.0,0.0,1,.95);
193  pad->Draw();
194  return pad;
195 }
196 
197 //============================
198 void doAll(int pl){
199  for(int i=1;i<=4;i++) {
200  //if(i==10) continue;
201  plPubJS(i,pl);
202  }
203 }
204 
205 
206 
207 // $Log: plPubJS.C,v $
208 // Revision 1.1 2009/11/23 23:00:20 balewski
209 // code moved spin-pool
210 //