/[PAMELA software]/quicklook/tracker/flight/macros/readpedsig-limits.cpp
ViewVC logotype

Annotation of /quicklook/tracker/flight/macros/readpedsig-limits.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Mar 14 16:09:30 2006 UTC (18 years, 8 months ago) by pam-fi
Branch: trk-QLook
CVS Tags: R1v00, R1v01
Changes since 1.1: +0 -0 lines
First CVS release of tracker flight quick-look 

1 pam-fi 1.1 //#include <utils/yodaUtility.h>
2     //#include "TrkFunctions.cpp"
3     #include <TPaveText.h>
4     #include <TLatex.h>
5     #include <TCanvas.h>
6     #include <TGraph.h>
7     #include <TStyle.h>
8     #include <TObjString.h>
9     #include <fstream>
10     #include <iostream>
11     #include <PscuHeader.h>
12     #include <EventHeader.h>
13     #include <CalibTrk1Event.h>
14     #include <CalibTrk2Event.h>
15    
16     /**
17     * readpedsig-limits --> is a function to read the calculated mean value for
18     * sigma, variance of sigma, pedestal and variance of pedestal
19     * from the pedsig.root file and draw the distribution of these values
20     * to calculate the limits to put in the TrkCalibQLook_BASIC script
21     *
22     * autor: D.Fedele
23     * version 1.0
24     * Parameters:
25     * file - the path to the root file to analyse
26     * outdir - total path of output file
27     *
28     */
29    
30     void readpedsiglimits(TString file,TString outdir)
31     {
32     //
33     // obtain information about the data file and select the output dir
34     const string filepath=file.Data();
35     Int_t dwpos = filepath.find("pedsig");
36     TString fpath=(filepath.c_str());
37     TString base;
38     stringcopy(base,fpath,0,dwpos);
39    
40     TString out;
41     if(outdir.Length()==0){
42     out = base;
43     }else{
44     out = outdir;
45     };
46    
47     stringstream fromfile,rep,tit;
48     fromfile<<"readpedsig from File: "<<file;
49    
50     //
51     // Set some ROOT variables and create the canvases
52     gStyle->SetFillColor(10);
53     gStyle->SetTitleFillColor(10);
54     gStyle->SetTitleFontSize(0.06);
55     gStyle->SetOptStat(1110);
56     gStyle->SetLabelSize(0.05,"x");
57     gStyle->SetLabelSize(0.06,"y");
58     gStyle->SetLabelOffset(0.01,"x");
59     gStyle->SetLabelOffset(0.005,"y");
60     gStyle->SetTitleOffset(0.7,"y");
61     gStyle->SetTitleOffset(0.85,"x");
62     gStyle->SetTitleSize(0.06,"y");
63     gStyle->SetTitleSize(0.05,"x");
64    
65     TLatex *tzz=new TLatex();
66     tzz->SetTextFont(32);
67     tzz->SetTextColor(1);
68     tzz->SetTextAlign(12);
69     tzz->SetTextSize(0.02);
70    
71     Int_t canvasx=900;
72     Int_t canvasy=1200;
73     TCanvas *c[12][3];
74     for(Int_t i=0;i<12;i++){
75     for(Int_t ii=0;ii<3;ii++){
76     rep.str("");
77     tit.str("");
78     tit<<"readpedsig "<<i<<"-"<<ii;
79     rep<<"c["<<i<<"]["<<ii<<"]";
80     c[i][ii] = new TCanvas(rep.str().c_str(),tit.str().c_str(),canvasx,canvasy);
81     c[i][ii]->Range(0,0,100,100);
82     tzz->DrawLatex(1,98.5,fromfile.str().c_str());
83     rep.str("");
84     rep<<"<SIG> e <PED>"<<"----> DSP "<<i+1<<" ladder "<<ii+1;
85     tzz->DrawLatex(60,98.5,rep.str().c_str());
86     }
87     }
88    
89     //
90     // inizialise the variables and open the file
91     Float_t pedav[12][12],sigav[12][12];
92    
93     for(Int_t i=0;i<12;i++){
94     for(Int_t ii=0;ii<12;ii++){
95     pedav[i][ii]=0;
96     sigav[i][ii]=0;
97     }
98     }
99    
100     TFile *pedsig = new TFile("/home/fedele/compiledScripts/pedsig.root");
101    
102     TTree *pstree = (TTree*)pedsig->Get("pstree");
103     pstree->SetBranchAddress("pedav",pedav);
104     pstree->SetBranchAddress("sigav",sigav);
105    
106     Int_t totev=pstree->GetEntries();
107     const Int_t nev=totev;
108    
109    
110    
111     //
112     // Create Pads and Histos
113     TPad *pad1[12][3][8];
114     TH1F *histosigav[12][3][4];
115     TH1F *histopedav[12][3][4];
116    
117     Float_t posy = 0.95; // up y-coord - top pads
118     Float_t hpad = 0; // pad height
119     Float_t posx1=0; // left x-coord - pad column
120     Float_t posx0=0; // x-coord - column division
121     Float_t wrel = 0; // relative x size of first sub-column
122     Float_t marg = 0.004; // margin among pads
123     stringstream oss1,oss2,oss3,oss4;
124    
125     hpad = (posy-marg*7)/4;
126     wrel = (1-marg*4)/2;
127    
128     for(Int_t n = 0; n<8; n++){
129     if ( (n+1)%2==1 ) {
130     if(n>1)posy = posy-(marg*2+hpad);
131     posx1 = marg;
132     posx0 = posx1 +wrel;
133     } else {
134     posx1 = posx0 + 2*marg;
135     posx0 = posx1 + wrel;
136     };
137     for(Int_t i=0;i<12;i++){
138     for(Int_t ii=0;ii<3;ii++){
139     oss1<<"DSP "<<n+1<<i<<ii;
140     oss2<<"DSPh "<<n+1<<i<<ii;
141     pad1[i][ii][n] = new TPad("pad1"," ",posx1,posy-hpad,posx0,posy,18,0,0);
142     if(n<4){
143     tit.str("");
144     tit<<"<SIG> --> VA1 #"<<n+1;
145     histosigav[i][ii][n]=new TH1F(oss1.str().c_str(),tit.str().c_str(),100,0.5,0.);
146     tit.str("");
147     tit<<"<PED> --> VA1 #"<<n+1;
148     histopedav[i][ii][n]=new TH1F(oss2.str().c_str(),tit.str().c_str(),100,0.5,0.);
149     }
150     oss1.str("");
151     oss2.str("");
152     }
153     }
154     }
155    
156     //**********************************************************************
157     //
158     // LOOP OVER EVENTS
159     //
160     //**********************************************************************
161     for(Int_t i=0;i<12;i++){
162     for(Int_t ii=0;ii<3;ii++){
163     for(Int_t iv=0;iv<4;iv++){
164     for(Int_t ev = 0; ev < nev; ev++){
165     pstree->GetEntry(ev);
166     if(sigav[i][(ii*4)+iv]!=0)
167     histosigav[i][ii][iv]->Fill(sigav[i][(ii*4)+iv]);
168     if(pedav[i][(ii*4)+iv]!=0)
169     histopedav[i][ii][iv]->Fill(pedav[i][(ii*4)+iv]);
170     }
171    
172     //
173     // fill the histos whit the right values
174     c[i][ii]->cd();
175     pad1[i][ii][iv*2]->SetFillColor(10);
176     pad1[i][ii][iv*2]->SetFrameFillColor(10);
177     pad1[i][ii][iv*2]->Draw();
178     pad1[i][ii][iv*2]->cd();
179     histosigav[i][ii][iv]->GetXaxis()->SetTitle("<SIG>");
180     histosigav[i][ii][iv]->GetXaxis()->CenterTitle();
181     histosigav[i][ii][iv]->Draw();
182    
183     c[i][ii]->Update();
184     c[i][ii]->cd();
185     pad1[i][ii][iv*2+1]->SetFillColor(10);
186     pad1[i][ii][iv*2+1]->SetFrameFillColor(10);
187     pad1[i][ii][iv*2+1]->Draw();
188     pad1[i][ii][iv*2+1]->cd();
189     histopedav[i][ii][iv]->GetXaxis()->SetTitle("<PED>");
190     histopedav[i][ii][iv]->GetXaxis()->CenterTitle();
191     histopedav[i][ii][iv]->Draw("");
192     c[i][ii]->Update();
193    
194     }
195     }
196     }
197    
198     //
199     // Close the input file and update the canvases
200     pedsig->Close();
201     for(Int_t i=0;i<12;i++){
202     for(Int_t ii=0;ii<3;ii++)
203     c[i][ii]->Update();//draw pads in canvas
204     }
205    
206     //
207     // Create the output files
208     stringstream nom1,nom2,nom3;
209    
210     nom1<<"readpedsig-limits.ps(";
211     nom2<<"readpedsig-limits.ps";
212     nom3<<"readpedsig-limits.ps)";
213     c[0][0]->Print(out+nom1.str().c_str());
214     for(Int_t i=0;i<12;i++){
215     for(Int_t ii=0;ii<3;ii++){
216     if(i==11 && ii==2)
217     continue;
218     if( i==0 && ii==0)
219     continue;
220     c[i][ii]->Print(out+nom2.str().c_str());
221     }
222     }
223    
224     c[11][2]->Print(out+nom3.str().c_str());
225     nom1.str("");
226     nom2.str("");
227     nom3.str("");
228    
229     for(Int_t i=0;i<12;i++){
230     for(Int_t ii=0;ii<3;ii++)
231     delete c[i][ii];
232     }
233    
234     nom1<<"ps2pdf13 "<<out<<"readpedsig-limits.ps "<<out<<"readpedsig-limits.pdf";
235     system(nom1.str().c_str());
236     nom2<<"rm -f "<<out<<"readpedsig-limits.ps";
237     system(nom2.str().c_str());
238    
239     return;
240     }

  ViewVC Help
Powered by ViewVC 1.1.23