StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plSmdCal.C
1 /* varouis utility plots for SMD callibration
2 
3 */
4 
5 TFile *f;
6 TCanvas *cc;
7 TString inPath;
8 
9 //=========================
10 plSmdCal(TString hFile="R7089008"){
11  inPath="/star/u/wissink/cal2006/iter4-pp/";
12  // inPath="/star/data05/scratch/balewski/2005-eemcCal/day171-hist/iter5-pp/";
13  f=new TFile(inPath+hFile+".hist.root");
14 
15  gStyle->SetPalette(1,0);
16  return;
17 }
18 
19 
20 //====================
21 plOne(int sec=1, float zMax=10., int sepSect=1) {
22  if(sepSect) {// read each sector from different input file
23  TString fname="sect01/sum-sect"; fname+=sec;
24  f=new TFile(inPath+fname+".hist.root");
25  }
26 
27  printf("\n MIP yield for sector=%d --------------------\n",sec);
28  char name[100], title[500];
29  sprintf(name,"mip%02d",sec);
30  cc=new TCanvas(name,name,1000,700);
31  cc->Range(0,0,1,1);
32  cc->cd();
33  TPad *c1 = new TPad("pad0", "apd0",0.0,0.,.35,1.);
34  c1->Draw();
35  c1->Divide(1,2);
36 
37  //sector: 1 2 3 4 5 6 7 8 9 10 11 12
38  float x1[]={ -20, 40, 60, 40, -20, -80, -170, -220, -240, -220,-160, -80};
39  float y1[]={ 40, -20, -80, -160,-220,-250, -220, -160, -80, 0, 40, 60};
40  int is=sec-1;
41 
42  int i;
43  for(i=0;i<2;i++) {
44  sprintf(name,"xy%02d",sec);
45  if(i==0) sprintf(name,"xy%02dm",sec);
46 
47  TH2F* h=(TH2F *)f->Get(name); assert(h);
48  c1->cd(1+i);
49  h->Draw("colz");
50  if(i==0) h->SetMaximum(zMax);
51  h->SetAxisRange(x1[is],x1[is]+180,"X");
52  h->SetAxisRange(y1[is],y1[is]+180,"Y");
53  }
54 
55  cc->cd();
56  c1 = new TPad("pad0", "apd0",0.35,0.,1.,1.);
57  c1->Draw();
58  c1->cd();
59  c1->Divide(1,2);
60 
61 
62  //------------ Do Integrals -----------
63  int binL=5,binH=50; int ped=20; char cT='T';//towers
64  // int binL=5,binH=150; int ped=50; char cT='R';//pre/post
65 
66  sprintf(name,"y%02d",sec);
67  sprintf(title,"MIP yield per tower, sector=%d; tower ID=sub+eta*5, 1=A12,2=B12,3=C12,...6=A11,..,11=A10, 21=A8, 31=A6, 41=A4, 51=A2",sec);
68  TH1F * hy=new TH1F(name,title,60,.5,60.5);
69  sprintf(name,"m%02d",sec);
70  TH1F * hm=new TH1F(name,"MIP yiled / UxV yield ; tower ID=sub+eta*5, ....(as above)",60,.5,60.5); hm->SetMarkerStyle(20);
71  hm->SetMarkerColor(kRed);
72  hm->SetMinimum(-0.001);
73  // hm->SetMaximum(0.03);
74  int sub,eta=5;
75 
76  sprintf(name,"ca%02d",sec);
77  // f2=new TFile("smdCal-Xk6.hist.root");
78  TH1F * huxv=(TH1F *)f->Get(name); assert(huxv);
79 
80  int ix=0;
81  for(eta=12;eta>=1;eta--)
82  for(sub='A';sub<='E';sub++) {
83  ix++;
84  sprintf(name,"e%02d%c%c%02d",sec,cT,sub,eta);
85  TH1F *h1=(TH1F *)f->Get(name); assert(h1);
86  //h1->Draw();
87  float nMip=h1->Integral(binL+ped,binH+ped);
88 
89  // get normalization
90  int iPhi=(sec-1)*5+sub-'A';
91  int iSpir=iPhi+(eta-1)*60;
92  float nUxV=huxv->GetBinContent(iSpir+1);
93  float rat=-1.;
94  if(nUxV>0) rat=nMip/nUxV;
95 
96  printf("x=%2d %s iSpir=%3d nUxV=%d nMip=%d -->R=%.3f\n",ix,name,iSpir,nUxV,nMip,rat);
97 
98  if(nMip==0) nMip=0.2;
99  hy->Fill(ix,nMip);
100 
101  hm->SetBinContent(ix,rat);
102  hm->SetBinError(ix,sqrt(nMip)/nUxV);
103  //break;
104  }
105  c1->cd(1);
106  hy->Draw("e");
107  gPad->SetGrid();
108  // gPad->SetLogy();
109  hy->SetMinimum(-0.9);
110  hy->SetMarkerStyle(23);
111  hy->SetStats(0);
112  c1->cd(2);
113  // huxv->Draw();
114  hm->Draw();
115  hm->SetStats(0);
116 
117  sprintf(name,"mip%02d.ps",sec); cc->Print(name);
118 }
119 
120 //=============================================
121 pl2Dall(float zMax=10., int bestMip=0, int sepSect=1) {
122 
123  char *tit="12secUxV";
124  if(bestMip) tit="12secMIP";
125  cc=new TCanvas(tit,tit,600,630);
126  for(int sec=1;sec<=12;sec++) {
127  char txt[100];
128  if(sepSect) {//
129  if(sec<10) {TString fname=inPath+"sect0"; fname+=sec; fname+="/sum-sect"; fname+=sec; fname+=".hist.root";}
130  if(sec>9) {TString fname=inPath+"sect"; fname+=sec; fname+="/sum-sect"; fname+=sec; fname+=".hist.root";}
131  printf("read each sector from different input file=%s\n",fname.Data());
132  f=new TFile(fname);
133  }
134  TString opt="colz";
135  // if(sec%2==0) opt="box";
136  if(sec>1) opt+=" same";
137 
138 
139  sprintf(txt,"xy%02d",sec);
140  if(bestMip) sprintf(txt,"xy%02dm",sec);
141  printf("=%s=%s\n",txt,opt.Data());
142  TH2F *h=(TH2F *)f->Get(txt);
143  if(sec==1) {
144  h->SetStats(0);
145  if(bestMip)
146  h->SetTitle("MIP position, UxV & Tw & pre/post");
147  else
148  h->SetTitle("MIP position, only UxV");
149  }
150  assert(h);
151  h->Draw(opt.Data());
152  h->SetMaximum(zMax);
153  float phi=(75-30*(sec-1))/180.*3.1416;
154  float y=50*sin(phi);
155  float x=50*cos(phi);
156  ln=new TLine(x,y,5*x,5*y);
157  ln->Draw();
158  continue;
159  sprintf(txt,"%02d",sec);
160  tx=new TText(5*x,5*y,txt);
161  tx->Draw(); tx->SetTextSize(0.03);
162  // break;
163  }
164  gPad->SetGrid();
165 }
166 
167 
168 //-------------
169 void do12(){
170  int i;
171  for(i=1;i<=12;i++) plOne(i,30);
172 }