9 #include <TGraphErrors.h>
10 #include <TMultiGraph.h>
13 #include <TStopwatch.h>
16 int ModulesStatFast(
TString pathG=
"/home/karavdin/datastorage/AlignmentLMDpixel/100data_10consts_SamplesStudyOct2013/BOX/mom_15/",
double daGL=0,
int MisConstSamp=0)
20 int iSc = MisConstSamp;
22 double v_tr_sc[nDt]={0,50,100,200,300,400,500,600};
25 double v_rt_sc[nDa]={daGL};
28 const int nSdstep = 10;
29 const int nuSd = nSdGL/nSdstep;
36 for(
int iDa=0;iDa<nDa;iDa++){
38 double av_evMod_b[nMod][nuSd+1][nDt];
39 double av_evMod_a[nMod][nuSd+1][nDt];
40 double err_av_evMod_b[nMod][nuSd+1][nDt];
41 double err_av_evMod_a[nMod][nuSd+1][nDt];
42 double av_resxMod_b[nMod][nuSd+1][nDt];
43 double av_resxMod_a[nMod][nuSd+1][nDt];
44 double err_av_resxMod_b[nMod][nuSd+1][nDt];
45 double err_av_resxMod_a[nMod][nuSd+1][nDt];
46 double av_resyMod_b[nMod][nuSd+1][nDt];
47 double av_resyMod_a[nMod][nuSd+1][nDt];
48 double err_av_resyMod_b[nMod][nuSd+1][nDt];
49 double err_av_resyMod_a[nMod][nuSd+1][nDt];
51 TString resname= pathG+
"/AlignmentLimits_EvModStat_";
52 resname+=v_rt_sc[iDa];
55 resname+=
"constsSample";
56 TString resname_pdf = resname+
".pdf";
57 TString resname_pdf_o = resname_pdf+
"(";
58 TString resname_pdf_c = resname_pdf+
")";
60 for(
int idt=0;idt<nDt;idt++){
61 for(
int imod=0;imod<nMod;imod++){
62 for(
int ijsum=1;ijsum<nuSd+1;ijsum++){
63 int isum = 1+nSdstep*(ijsum-1);
64 double tr_sc = v_tr_sc[idt];
65 double rt_sc = v_rt_sc[iDa];
75 path+=
"Samples/resultsSUM/";
78 TString name1 = path +
"/hitsRes_before_alignment_sector";
81 TString name2 = path +
"/hitsRes_after_alignment_sector";
84 TFile *
f1 =
new TFile(name1,
"READ");
85 TNtuple *nb = (TNtuple*)f1->Get(
"nhits");
87 TH1I *ntrksb = (TH1I*)f1->Get(
"trks");
90 av_resxMod_b[imod][ijsum][idt]=0;
91 av_resxMod_a[imod][ijsum][idt]=0;
92 err_av_resxMod_b[imod][ijsum][idt]=0;
93 err_av_resxMod_a[imod][ijsum][idt]=0;
94 av_resyMod_b[imod][ijsum][idt]=0;
95 av_resyMod_a[imod][ijsum][idt]=0;
96 err_av_resyMod_b[imod][ijsum][idt]=0;
97 err_av_resyMod_a[imod][ijsum][idt]=0;
99 av_evMod_b[imod][ijsum][idt]= 1e-3*double(ntrksb->GetEntries())/nDS2;
100 err_av_evMod_b[imod][ijsum][idt]= 0;
101 TH1D *hresx_b =
new TH1D(
"hresx_b",
"",1e3,-1.,1.);
102 nb->Project(
"hresx_b",
"xrec-xmc");
103 av_resxMod_b[imod][ijsum][idt]=1e4*(hresx_b->GetMean());
104 err_av_resxMod_b[imod][ijsum][idt]=1e4*(hresx_b->GetRMS());
105 TH1D *hresy_b =
new TH1D(
"hresy_b",
"",1e3,-1.,1.);
106 nb->Project(
"hresy_b",
"yrec-ymc");
107 av_resyMod_b[imod][ijsum][idt]=1e4*(hresy_b->GetMean());
108 err_av_resyMod_b[imod][ijsum][idt]=1e4*(hresy_b->GetRMS());
109 TFile *
f2 =
new TFile(name2,
"READ");
110 TNtuple *na = (TNtuple*)f2->Get(
"nhits");
112 TH1I *ntrksa = (TH1I*)f2->Get(
"trks");
113 av_evMod_a[imod][ijsum][idt]= 1e-3*double(ntrksa->GetEntries())/nDS2;
114 err_av_evMod_a[imod][ijsum][idt]= 0;
115 TH1D *hresx_a =
new TH1D(
"hresx_a",
"",1e3,-1.,1.);
116 na->Project(
"hresx_a",
"xrec-xmc");
117 av_resxMod_a[imod][ijsum][idt]=1e4*(hresx_a->GetMean());
118 err_av_resxMod_a[imod][ijsum][idt]=1e4*(hresx_a->GetRMS());
119 TH1D *hresy_a =
new TH1D(
"hresy_a",
"",1e3,-1.,1.);
120 na->Project(
"hresy_a",
"yrec-ymc");
122 av_resyMod_a[imod][ijsum][idt]=1e4*(hresy_a->GetMean());
123 err_av_resyMod_a[imod][ijsum][idt]=1e4*(hresy_a->GetRMS());
127 cout<<
"iS_AC:"<<iSc<<
" ida:"<<iDa<<
" dt:"<<idt<<
" imod:"<<imod<<
" isum:"<<isum<<endl;
138 TFile *
f =
new TFile(out,
"RECREATE");
142 for(
int imod=0;imod<nMod;imod++){
143 TGraphErrors *gr_av_b[nuSd+1];
144 TGraphErrors *gr_av_a[nuSd+1];
145 TMultiGraph *mgr_av_b =
new TMultiGraph();
146 TMultiGraph *mgr_av_a =
new TMultiGraph();
147 TGraphErrors *gr_avResx_b[nuSd+1];
148 TGraphErrors *gr_avResx_a[nuSd+1];
149 TMultiGraph *mgr_avResx_b =
new TMultiGraph();
150 TMultiGraph *mgr_avResx_a =
new TMultiGraph();
151 TGraphErrors *gr_avResy_b[nuSd+1];
152 TGraphErrors *gr_avResy_a[nuSd+1];
153 TMultiGraph *mgr_avResy_b =
new TMultiGraph();
154 TMultiGraph *mgr_avResy_a =
new TMultiGraph();
155 TLegend *leg_b =
new TLegend(0.91,0.65,0.99,0.98);
156 leg_b->SetHeader(
"BEFORE");
157 TLegend *leg_a =
new TLegend(0.91,0.65,0.99,0.98);
158 leg_a->SetHeader(
"AFTER");
161 for(
int ijsum=nuSd;ijsum>0;ijsum--){
163 int isum = 1+nSdstep*(ijsum-1);
167 gr_av_b[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_evMod_b[imod][ijsum],0,err_av_evMod_b[imod][ijsum]);
168 gr_av_a[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_evMod_a[imod][ijsum],0,err_av_evMod_a[imod][ijsum]);
169 gr_avResx_b[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resxMod_b[imod][ijsum],0,err_av_resxMod_b[imod][ijsum]);
170 gr_avResx_a[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resxMod_a[imod][ijsum],0,err_av_resxMod_a[imod][ijsum]);
171 gr_avResx_b[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resxMod_b[imod][ijsum],0,err_av_resxMod_b[imod][ijsum]);
172 gr_avResx_a[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resxMod_a[imod][ijsum],0,err_av_resxMod_a[imod][ijsum]);
173 gr_avResy_b[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resyMod_b[imod][ijsum],0,err_av_resyMod_b[imod][ijsum]);
174 gr_avResy_a[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resyMod_a[imod][ijsum],0,err_av_resyMod_a[imod][ijsum]);
175 gr_avResy_b[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resyMod_b[imod][ijsum],0,err_av_resyMod_b[imod][ijsum]);
176 gr_avResy_a[ijsum] =
new TGraphErrors(nDt,v_tr_sc, av_resyMod_a[imod][ijsum],0,err_av_resyMod_a[imod][ijsum]);
181 gr_av_b[ijsum]->SetName(name_ev+
"_b");
182 gr_av_b[ijsum]->SetMarkerStyle(20+ijsum);
183 gr_av_b[ijsum]->SetMarkerColor(kGreen-3);
184 gr_av_b[ijsum]->SetMarkerSize(1.5);
185 gr_av_a[ijsum]->SetName(name_ev+
"_a");
186 gr_av_a[ijsum]->SetMarkerStyle(20+ijsum);
187 gr_av_a[ijsum]->SetMarkerColor(kOrange+7);
188 gr_av_a[ijsum]->SetMarkerSize(1.5);
189 mgr_av_b->Add(gr_av_b[ijsum]);
190 mgr_av_a->Add(gr_av_a[ijsum]);
191 gr_av_b[ijsum]->Write();
192 gr_av_a[ijsum]->Write();
193 leg_b->AddEntry(gr_av_b[ijsum],sname,
"P");
194 leg_a->AddEntry(gr_av_a[ijsum],sname,
"P");
196 gr_avResx_b[ijsum]->SetName(name_ev+
"_b");
197 gr_avResx_b[ijsum]->SetMarkerStyle(20+ijsum);
198 gr_avResx_b[ijsum]->SetMarkerColor(kGreen-3);
199 gr_avResx_b[ijsum]->SetMarkerSize(1.5);
200 gr_avResx_a[ijsum]->SetName(name_ev+
"_a");
201 gr_avResx_a[ijsum]->SetMarkerStyle(20+ijsum);
202 gr_avResx_a[ijsum]->SetMarkerColor(kOrange+7);
203 gr_avResx_a[ijsum]->SetMarkerSize(1.5);
204 mgr_avResx_b->Add(gr_avResx_b[ijsum]);
205 mgr_avResx_a->Add(gr_avResx_a[ijsum]);
206 gr_avResx_b[ijsum]->Write();
207 gr_avResx_a[ijsum]->Write();
208 gr_avResy_b[ijsum]->SetName(name_ev+
"_b");
209 gr_avResy_b[ijsum]->SetMarkerStyle(20+ijsum);
210 gr_avResy_b[ijsum]->SetMarkerColor(kGreen-3);
211 gr_avResy_b[ijsum]->SetMarkerSize(1.5);
212 gr_avResy_a[ijsum]->SetName(name_ev+
"_a");
213 gr_avResy_a[ijsum]->SetMarkerStyle(20+ijsum);
214 gr_avResy_a[ijsum]->SetMarkerColor(kOrange+7);
215 gr_avResy_a[ijsum]->SetMarkerSize(1.5);
216 mgr_avResy_b->Add(gr_avResy_b[ijsum]);
217 mgr_avResy_a->Add(gr_avResy_a[ijsum]);
218 gr_avResy_b[ijsum]->Write();
219 gr_avResy_a[ijsum]->Write();
225 mgr_av_b->SetTitle(smname+
"_b");
226 mgr_av_a->SetTitle(smname+
"_a");
227 leg_a->SetFillColor(0);
228 leg_b->SetFillColor(0);
229 mgr_av_b->SetName(smname+
"_b");
230 mgr_av_a->SetName(smname+
"_a");
236 mgr_avResx_b->SetName(smnamex+
"_b");
237 mgr_avResx_a->SetName(smnamex+
"_a");
238 mgr_avResy_b->SetName(smnamey+
"_b");
239 mgr_avResy_a->SetName(smnamey+
"_a");
240 mgr_av_b->Draw(
"AP");
241 mgr_av_b->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
242 mgr_av_b->GetYaxis()->SetTitle(
"events, 10^{3}");
244 cRes.Print(resname_pdf_o);
246 mgr_av_a->Draw(
"AP");
247 mgr_av_a->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
248 mgr_av_a->GetYaxis()->SetTitle(
"events, 10^{3}");
250 cRes.Print(resname_pdf_o);
255 leg_b->SetName(
"LegBefore");
256 leg_a->SetName(
"LegAfter");
261 mgr_avResx_b->Draw(
"AP");
262 mgr_avResx_b->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
263 mgr_avResx_b->GetYaxis()->SetTitle(
"res_{X}, mean [#mum]");
265 cRes.Print(resname_pdf_o);
267 mgr_avResx_a->Draw(
"AP");
268 mgr_avResx_a->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
269 mgr_avResx_a->GetYaxis()->SetTitle(
"res_{X}, mean [#mum]");
271 cRes.Print(resname_pdf_o);
273 mgr_avResx_a->Write();
274 mgr_avResx_b->Write();
276 mgr_avResy_b->Draw(
"AP");
277 mgr_avResy_b->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
278 mgr_avResy_b->GetYaxis()->SetTitle(
"res_{Y}, mean [#mum]");
280 cRes.Print(resname_pdf_o);
282 mgr_avResy_a->Draw(
"AP");
283 mgr_avResy_a->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
284 mgr_avResy_a->GetYaxis()->SetTitle(
"res_{Y}, mean [#mum]");
286 cRes.Print(resname_pdf_o);
288 mgr_avResy_a->Write();
289 mgr_avResy_b->Write();
292 cRes.Print(resname_pdf_c);
300 printf(
"On HIMSTER it took: RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
304 int main(
int __argc,
char *__argv[]) {
305 TString storePath=
"/home/karavdin/datastorage/AlignmentLMDpixel/100data_10consts_SamplesStudyOct2013/BOX/mom_15/";
308 std::string pathStr=
"",daStr=
"",iScStr=
"";
310 if( __argc>1 && ( strcmp( __argv[1],
"-help" ) == 0
311 || strcmp( __argv[1],
"--help" ) == 0 ) ){
312 std::cout <<
"This is script for alignment data analysis \n"
313 <<
"with parameters\n"
314 <<
"-path path to the file(s) \n"
315 <<
"-da scale for rotation misalignment \n"
316 <<
"-iSc number of misalignment consts sample \n"
321 while ((optind < (__argc-1) ) && (__argv[optind][0]==
'-')) {
323 std::string sw = __argv[optind];
326 pathStr = __argv[optind];
331 daStr = __argv[optind];
337 iScStr = __argv[optind];
341 std::cout<<
"Unknown switch: "
342 << __argv[optind] <<std::endl;
345 while ( (optind < __argc ) && __argv[optind][0]!=
'-' ) optind++;
348 std::stringstream pathSStr(pathStr), daSStr(daStr),iScSStr(iScStr);
int main(int argc, char **argv)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
int ModulesStatFast(TString pathG="/home/karavdin/datastorage/AlignmentLMDpixel/100data_10consts_SamplesStudyOct2013/BOX/mom_15/", double daGL=0, int MisConstSamp=0)