FEDRA emulsion software from the OPERA Collaboration
check_cp.C File Reference
#include "TCanvas.h"
#include "TFile.h"
#include "TSystem.h"
#include "TCut.h"
#include "TStyle.h"
#include "TTree.h"
#include "TH1.h"
#include "TF1.h"
#include "Riostream.h"
#include "EdbPVRec.h"
Include dependency graph for check_cp.C:

Macros

#define XSIZE   1200
 
#define YSIZE   800
 

Functions

void check_cp (int output=0, char *fname=0, char *csignal_cut="1")
 
void check_distorsion (TCanvas *cs)
 
void check_shrinkage (TCanvas *diff)
 
void check_sigma (TCanvas *cs)
 
void check_surf (TCanvas *surf)
 
void check_view (TCanvas *cs)
 
void correct_shrinkage (TCanvas *cshr)
 
TCut csignal ("1")
 
TCut cut1 ("pid2>-1&&eCHI2P<1.5")
 
TCut diffarea ("(s1.eAid[0]!=s2.eAid[0])")
 
TCut diffview ("(s1.eAid[1]!=s2.eAid[1])")
 
void init ()
 
int main (int argc, char *argv[])
 
TCut sameview ("(s1.eAid[1]==s2.eAid[1])")
 

Variables

TTree * couples
 

Macro Definition Documentation

◆ XSIZE

#define XSIZE   1200

◆ YSIZE

#define YSIZE   800

Function Documentation

◆ check_cp()

void check_cp ( int  output = 0,
char *  fname = 0,
char *  csignal_cut = "1" 
)
335{
336 csignal = csignal_cut;
337
338 cout << "fname : " << fname << endl;
339
340 printf("Check couples with the general selection as: %s\n",csignal_cut);
341 printf("s1: Red line\n");
342 printf("s2: Blue line\n");
343 printf("functions: check_surf, check_sigma, check_shrinkage, check_distorsion, check_view, correct_shrinkage\n");
344
345 TFile *f=0;
346 if (fname&&output>=2) f = new TFile(fname,"UPDATE");
347 else if (fname&&output<2) f = new TFile(fname);
348
349 couples = (TTree*) gFile->Get("couples") ;
350
351 init();
352 //check_all();
353
354 int do_surf=1, do_sig=1, do_view=1, do_diff=1;
355 int do_shr=1;
356 int do_dist=1 ;
357
358 TCanvas *csurf=0, *csig=0, *cview=0, *cdiff=0, *cshr=0, *cdist=0;
359 if( output!=2 ) {
360 csurf = dynamic_cast<TCanvas*>(gDirectory->Get("csurf"));
361 csig = dynamic_cast<TCanvas*>(gDirectory->Get("csig"));
362 cview = dynamic_cast<TCanvas*>(gDirectory->Get("cview"));
363 cdiff = dynamic_cast<TCanvas*>(gDirectory->Get("cdiff"));
364 cshr = dynamic_cast<TCanvas*>(gDirectory->Get("cshr"));
365 cdist = dynamic_cast<TCanvas*>(gDirectory->Get("cdist"));
366
367 if(csurf ) { csurf ->Draw(); do_surf =0; }
368 if(csig ) { csig ->Draw(); do_sig =0; }
369 if(cview ) { cview ->Draw(); do_view =0; }
370 if(cdiff ) { cdiff ->Draw(); do_diff =0; }
371 if(cshr ) { cshr ->Draw(); do_shr =0; }
372 if(cdist ) { cdist ->Draw(); do_dist =0; }
373 }
374
375 if(do_surf ) {
376 csurf = new TCanvas("csurf" ,"couples_surf" ,XSIZE,YSIZE);
377 csurf->Divide(2,3);
378 check_surf(csurf);
379 }
380 if(do_sig ) {
381 csig = new TCanvas("csig" ,"couples_sigma" ,XSIZE,YSIZE);
382 csig ->Divide(2,3);
383 check_sigma(csig);
384 }
385 if(do_view ) {
386 cview = new TCanvas("cview" ,"couples_view" ,XSIZE,YSIZE);
387 cview->Divide(2,2);
388 check_view(cview);
389 }
390 if(do_diff ) {
391 cdiff = new TCanvas("cdiff" ,"couples_shrinkage" ,XSIZE,YSIZE);
392 cdiff->Divide(2,2);
393 check_shrinkage(cdiff);
394 }
395 if(do_shr ) {
396 cshr = new TCanvas("cshr" ,"couples_shrinkage_corr",XSIZE,YSIZE);
397 cshr ->Divide(2,2);
398 correct_shrinkage(cshr);
399 }
400 if(do_dist ) {
401 cdist = new TCanvas("cdist" ,"couples_distortion" ,XSIZE,YSIZE);
402 cdist->Divide(2,2);
403 check_distorsion(cdist) ;
404 }
405
406 if( (fname&&output==2) || (fname&&output==3) ) {
407 printf("save as canvases into root file\n");
408 if(csurf ) csurf ->Write("cp_surf");
409 if(csig ) csig ->Write("cp_sigma" );
410 if(cview ) cview ->Write("cp_view");
411 if(cdiff ) cdiff ->Write("cp_diff");
412 if(cshr ) cshr ->Write("cp_shr" );
413 if(cdist ) cdist ->Write("cp_dist");
414 }
415 if(output==1 || (fname&&output==3) ) {
416 printf("save as gif pictures\n");
417 gSystem->Sleep(500);
418 if(csurf ) csurf ->SaveAs("cp_surf.gif" );
419 if(csig ) csig ->SaveAs("cp_sigma.gif");
420 if(cview ) cview ->SaveAs("cp_view.gif");
421 if(cdiff ) cdiff ->SaveAs("cp_diff.gif");
422 if(cshr ) cshr ->SaveAs("cp_shr.gif" );
423 if(cdist ) cdist ->SaveAs("cp_dist.gif");
424 }
425 if(f) f->Close();
426}
FILE * f
Definition: RecDispMC.C:150
void init()
Definition: check_cp.C:56
TTree * couples
Definition: check_cp.C:50
void check_view(TCanvas *cs)
Definition: check_cp.C:201
void check_shrinkage(TCanvas *diff)
Definition: check_cp.C:227
void check_distorsion(TCanvas *cs)
Definition: check_cp.C:308
void check_sigma(TCanvas *cs)
Definition: check_cp.C:123
TCut csignal("1")
void correct_shrinkage(TCanvas *cshr)
Definition: check_cp.C:244
void check_surf(TCanvas *surf)
Definition: check_cp.C:93
#define XSIZE
Definition: check_cp.C:52
#define YSIZE
Definition: check_cp.C:53
const char * fname
Definition: mc2raw.cxx:41
new TCanvas()

◆ check_distorsion()

void check_distorsion ( TCanvas cs)
309{
310 printf("check_distortion with the cut: %s \n", csignal.GetTitle() );
311
312 cs->cd(1);
313 couples->Draw("s1.eTX-s.eTX:s.eX", csignal );
314 cs->cd(2);
315 couples->Draw("s1.eTY-s.eTY:s.eY", csignal );
316 cs->cd(3);
317 couples->Draw("s2.eTX-s.eTX:s.eX", csignal );
318 cs->cd(4);
319 couples->Draw("s2.eTY-s.eTY:s.eY", csignal );
320 gStyle->SetOptStat("nemr");
321}

◆ check_shrinkage()

void check_shrinkage ( TCanvas diff)
228{
229 printf("check_shrinkage with the cut: %s \n", csignal.GetTitle() );
230
231 diff->cd(1);
232 couples->Draw("s1.eTX-tx:tx", csignal );
233 diff->cd(2);
234 couples->Draw("s2.eTX-tx:tx", csignal );
235 diff->cd(3);
236 couples->Draw("s1.eTY-ty:ty", csignal );
237 diff->cd(4);
238 couples->Draw("s2.eTY-ty:ty", csignal );
239 gStyle->SetOptStat("nemr");
240
241}

◆ check_sigma()

void check_sigma ( TCanvas cs)
124{
125 printf("check_sigma with the cut: %s \n", csignal.GetTitle() );
126
127 couples->Project("htx1(20,-1.,1.,40,0.,0.1)", "abs(s1.eTX-tx):tx",csignal,"prof");
128 couples->Project("htx2(20,-1.,1.,40,0.,0.1)", "abs(s2.eTX-tx):tx",csignal,"prof");
129 couples->Project("hty1(20,-1.,1.,40,0.,0.1)", "abs(s1.eTY-ty):ty",csignal,"prof");
130 couples->Project("hty2(20,-1.,1.,40,0.,0.1)", "abs(s2.eTY-ty):ty",csignal,"prof");
131 TH1* htx1 = (TH1*) gDirectory->Get("htx1");
132 TH1* htx2 = (TH1*) gDirectory->Get("htx2");
133 TH1* hty1 = (TH1*) gDirectory->Get("hty1");
134 TH1* hty2 = (TH1*) gDirectory->Get("hty2");
135
136 cs->cd(1);{
137 cs->GetPad(1)->SetGrid(1,1);
138 htx1->SetLineColor(kRed);
139 htx1->Draw();
140 htx2->SetLineColor(kBlue);
141 htx2->Draw("same");
142 }
143 cs->cd(2);{
144 cs->GetPad(2)->SetGrid(1,1);
145 hty1->SetLineColor(kRed);
146 hty1->Draw();
147 hty2->SetLineColor(kBlue);
148 hty2->Draw("same");
149 }
150 couples->Project("htt1(10,0.,1.,40,0.,0.1)", "abs(dst1):ts",csignal,"prof");
151 couples->Project("htt2(10,0.,1.,40,0.,0.1)", "abs(dst2):ts",csignal,"prof");
152 couples->Project("htl1(10,0.,1.,40,0.,0.1)", "dsl1:ts",csignal,"prof");
153 couples->Project("htl2(10,0.,1.,40,0.,0.1)", "dsl2:ts",csignal,"prof");
154 TH1* htt1 = (TH1*) gDirectory->Get("htt1");
155 TH1* htt2 = (TH1*) gDirectory->Get("htt2");
156 TH1* htl1 = (TH1*) gDirectory->Get("htl1");
157 TH1* htl2 = (TH1*) gDirectory->Get("htl2");
158
159 cs->cd(3); {
160 cs->GetPad(3)->SetGrid(1,1);
161 htt1->SetLineColor(kRed);
162 htt1->Draw();
163 htt2->SetLineColor(kBlue);
164 htt2->Draw("same");
165 }
166 cs->cd(4);{
167 cs->GetPad(4)->SetGrid(1,1);
168 htl1->SetLineColor(kRed);
169 htl1->Draw();
170 htl2->SetLineColor(kBlue);
171 htl2->Draw("same");
172 gStyle->SetOptStat("ne");
173 }
174
175 cs->cd(5); {
176 cs->GetPad(4)->SetGrid(1,1);
177 couples->Project("hs" ,"s.eW:ts" , csignal, "prof");
178 couples->Project("hs1","s1.eW:ts", csignal, "prof");
179 couples->Project("hs2","s2.eW:ts", csignal, "prof");
180 TH1* hs = (TH1*) gDirectory->Get("hs");
181 TH1* hs1 = (TH1*) gDirectory->Get("hs1");
182 TH1* hs2 = (TH1*) gDirectory->Get("hs2");
183 hs->Draw();
184 hs1->SetLineColor(kRed);
185 hs1->Draw("same");
186 hs2->SetLineColor(kBlue);
187 hs2->Draw("same");
188 gStyle->SetOptStat("nemr");
189 }
190 cs->cd(6); {
191 couples->SetLineColor(kBlue);
192 couples->Draw("eN1tot:ts", csignal, "prof");
193 couples->SetLineColor(kRed);
194 couples->Draw("eN2tot:ts", csignal, "prof same");
195 }
196 couples->SetLineColor(1);
197
198}

◆ check_surf()

void check_surf ( TCanvas surf)
94{
95 printf("check_surf with the cut: %s \n", csignal.GetTitle() );
96
97 surf->cd(1); couples->Draw("s.eY:s.eX",csignal);
98 surf->cd(2); couples->Draw("s.eTY:s.eTX",csignal);
99 surf->cd(5); {
100 couples->Draw("eCHI2P", csignal );
101 couples->SetLineColor(kGreen);
102 couples->Draw("eCHI2P", csignal && sameview ,"same");
103 couples->SetLineColor(kRed);
104 couples->Draw("eCHI2P", csignal && diffview,"same");
105 couples->SetLineColor(6);
106 couples->Draw("eCHI2P", csignal && diffarea,"same");
107 }
108 couples->SetLineColor(1);
109 surf->cd(3); {
110 couples->SetLineColor(kBlue);
111 couples->Draw("s1.eW>>hw1(15,5,20)", csignal );
112 couples->SetLineColor(kRed);
113 couples->Draw("s2.eW", csignal,"same");
114 }
115 couples->SetLineColor(1);
116
117 surf->cd(4); couples->Draw("s.eW>>hw(25,10,35)", csignal );
118 surf->cd(6); couples->Draw("eCHI2P:s.eW>>hchiw(25,10,35,30,0,3.)", csignal,"colZ");
119
120}
TCut sameview("(s1.eAid[1]==s2.eAid[1])")
TCut diffview("(s1.eAid[1]!=s2.eAid[1])")
TCut diffarea("(s1.eAid[0]!=s2.eAid[0])")

◆ check_view()

void check_view ( TCanvas cs)
202{
203 // check the accuracy deterioration in case when the segments are in
204 // the different views
205
206 printf("check_view with the cut: %s \n", csignal.GetTitle() );
207
208 cs->cd(1);
209 couples->Draw("eCHI2P", csignal&&sameview);
210 couples->Draw("eCHI2P", csignal&&diffview,"same");
211 couples->Draw("eCHI2P", csignal&&diffarea,"same");
212 cs->cd(2);
213 couples->SetMarkerStyle(20);
214 couples->SetAlias("same_view","(s1.eAid[1]==s2.eAid[1])");
215 couples->Draw("s.eTY:same_view",csignal,"prof");
216 cs->cd(3);
217 couples->Draw("s.eTX:same_view",csignal,"prof");
218 cs->cd(4);
219 couples->Draw("s.eTX>>htxv(100)",csignal&&sameview);
220 couples->Draw("s.eTX",csignal&&diffview,"same");
221 couples->SetMarkerStyle(1);
222 gStyle->SetOptStat("nemr");
223
224}

◆ correct_shrinkage()

void correct_shrinkage ( TCanvas cshr)
245{
246 // this function check shrinkage and/or distance between linked planes
247 // Note: do not use s.* (linked segment parameters), because them could
248 // be different from the "base angle" calculated here directly
249
250 printf("correct_shrinkage with the cut: %s \n", csignal.GetTitle() );
251
252 // TCut cut1("pid2>-1&&eCHI2P<1.5");
253
254 cshr->cd(1);
255 TH1* hsh1 ;
256
257 couples->Draw("s1.eTX-tx:tx>>hsh1", csignal,"prof");
258 hsh1 = (TH1*) gDirectory->Get("hsh1");
259 hsh1->Fit("pol1","wQ","",-.4,.4);
260
261 float p0 = hsh1->GetFunction("pol1")->GetParameter(0);
262 float p1 = hsh1->GetFunction("pol1")->GetParameter(1);
263 printf("side1 : p0 = %f \t p1 = %f \n",p0,p1);
264
265
266 cshr->cd(3);
267 TH1* hsh3 ;
268
269 char str[160]="";
270 sprintf(str,"s1.eTX*(1-(%f))-(%f)-(s2.eX-s1.eX)/(s2.eZ-s1.eZ):(s2.eX-s1.eX)/(s2.eZ-s1.eZ)>>hsh3",p1,p0);
271 couples->Draw(str,csignal,"prof");
272 hsh3 = (TH1*) gDirectory->Get("hsh3");
273 hsh3->Fit("pol1","wQ","",-.4,.4);
274
275 p0 = hsh3->GetFunction("pol1")->GetParameter(0);
276 p1 = hsh3->GetFunction("pol1")->GetParameter(1);
277 printf("side1 corr: p0 = %f \t p1 = %f \n",p0,p1);
278
279
280 cshr->cd(2);
281 TH1* hsh2;
282
283 couples->Draw("s2.eTX-tx:tx>>hsh2", csignal,"prof");
284 hsh2 = (TH1*) gDirectory->Get("hsh2");
285 hsh2->Fit("pol1","wQ","",-.4,.4);
286
287 p0 = hsh2->GetFunction("pol1")->GetParameter(0);
288 p1 = hsh2->GetFunction("pol1")->GetParameter(1);
289 printf("side2 : p0 = %f \t p1 = %f \n",p0,p1);
290
291 cshr->cd(4);
292 TH1* hsh4 ;
293
294 sprintf(str,"s2.eTX*(1-(%f))-(%f)-(s2.eX-s1.eX)/(s2.eZ-s1.eZ):(s2.eX-s1.eX)/(s2.eZ-s1.eZ)>>hsh4",p1,p0);
295 couples->Draw(str, csignal ,"prof");
296 hsh4 = (TH1*) gDirectory->Get("hsh4");
297 hsh4->Fit("pol1","wQ","",-.4,.4);
298
299 p0 = hsh4->GetFunction("pol1")->GetParameter(0);
300 p1 = hsh4->GetFunction("pol1")->GetParameter(1);
301 printf("side2 corr: p0 = %f \t p1 = %f \n",p0,p1);
302
303
304 gStyle->SetOptStat("nemr");
305}

◆ csignal()

TCut csignal ( "1"  )

◆ cut1()

TCut cut1 ( pid2)

◆ diffarea()

TCut diffarea ( "(s1.eAid[0]!=s2.eAid[0])"  )

◆ diffview()

TCut diffview ( "(s1.eAid[1]!=s2.eAid[1])"  )

◆ init()

void init ( )
57{
58 gStyle->SetOptFit(0001);
59 couples->SetAlias("tx","(s2.eX-s1.eX)/(s2.eZ-s1.eZ)"); // baseline angle tx
60 couples->SetAlias("ty","(s2.eY-s1.eY)/(s2.eZ-s1.eZ)"); // baseline angle ty
61 couples->SetAlias("t","sqrt(tx*tx+ty*ty)"); // baseline theta
62 couples->SetAlias("ts","sqrt(s.eTX*s.eTX + s.eTY*s.eTY)"); // basetrack theta
63
64 couples->SetAlias("t1","sqrt(s1.eTX*s1.eTX + s1.eTY*s1.eTY)"); // theta of the s1
65 couples->SetAlias("t2","sqrt(s2.eTX*s2.eTX + s2.eTY*s2.eTY)"); // theta of the s2
66
67 couples->SetAlias("phi","atan(s.eTY/s.eTX)"); // phi of the s
68 couples->SetAlias("phi1","atan(s1.eTY/s1.eTX)"); // phi of the s1
69 couples->SetAlias("phi2","atan(s2.eTY/s2.eTX)"); // phi of the s2
70
71 couples->SetAlias("dsx1","s1.eTX-s.eTX");
72 couples->SetAlias("dsy1","s1.eTY-s.eTY");
73 couples->SetAlias("ds1","sqrt(dsx1*dsx1+dsy1*dsy1)"); // absoulte angular diff s1-s
74 couples->SetAlias("dsx2","s2.eTX-s.eTX");
75 couples->SetAlias("dsy2","s2.eTY-s.eTY");
76 couples->SetAlias("ds2","sqrt(dsx2*dsx2+dsy2*dsy2)"); // absoulte angular diff s2-s
77
78 couples->SetAlias("dst1","(s1.eTX*s.eTY-s1.eTY*s.eTX)/ts"); // transverse slope diff s1-s
79 couples->SetAlias("dsl1","sqrt(ds1*ds1-dst1*dst1)"); // longitudinal slope diff s1-s
80 couples->SetAlias("dst2","(s2.eTX*s.eTY-s2.eTY*s.eTX)/ts"); // transverse slope diff s2-s
81 couples->SetAlias("dsl2","sqrt(ds2*ds2-dst2*dst2)"); // longitudinal slope diff s2-s
82
83
84 couples->SetAlias("dz","s2.eZ-s1.eZ");
85 couples->SetAlias("dx12","s2.eX-(s1.eX+dz*s1.eTX)"); // project s1 to s2 and calc dx
86 couples->SetAlias("dy12","s2.eY-(s1.eY+dz*s1.eTY)"); // project s1 to s2 and calc dy
87 couples->SetAlias("dx21","(s2.eX-dz*s2.eTX)-s1.eX"); // project s1 to s2 and calc dx
88 couples->SetAlias("dy21","(s2.eY-dz*s2.eTY)-s1.eY"); // project s1 to s2 and calc dx
89
90}

◆ main()

int main ( int  argc,
char *  argv[] 
)
437{
438 int output=3;
439 char* fname=argv[1];
440 char* csignal_cut="1";
441
442 gStyle->SetPalette(1);
443 check_cp( output, fname, csignal_cut ) ;
444
445 return 1 ;
446}
void check_cp(int output=0, char *fname=0, char *csignal_cut="1")
Definition: check_cp.C:334

◆ sameview()

TCut sameview ( "(s1.eAid[1]==s2.eAid[1])"  )

Variable Documentation

◆ couples

TTree* couples