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 (char *csignal_cut="1")
 
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() [1/2]

void check_cp ( char *  csignal_cut = "1")
420{
421 check_cp( 0, 0, csignal_cut ) ;
422}
void check_cp(int output=0, char *fname=0, char *csignal_cut="1")
Definition: check_cp.C:334

◆ check_cp() [2/2]

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

◆ check_distorsion()

void check_distorsion ( TCanvas cs)
299{
300 printf("check_distortion with the cut: %s \n", csignal.GetTitle() );
301
302 cs->cd(1);
303 couples->Draw("s1.eTX-s.eTX:s.eX", csignal );
304 cs->cd(2);
305 couples->Draw("s1.eTY-s.eTY:s.eY", csignal );
306 cs->cd(3);
307 couples->Draw("s2.eTX-s.eTX:s.eX", csignal );
308 cs->cd(4);
309 couples->Draw("s2.eTY-s.eTY:s.eY", csignal );
310 gStyle->SetOptStat("nemr");
311}

◆ check_shrinkage()

void check_shrinkage ( TCanvas diff)
218{
219 printf("check_shrinkage with the cut: %s \n", csignal.GetTitle() );
220
221 diff->cd(1);
222 couples->Draw("s1.eTX-tx:tx", csignal );
223 diff->cd(2);
224 couples->Draw("s2.eTX-tx:tx", csignal );
225 diff->cd(3);
226 couples->Draw("s1.eTY-ty:ty", csignal );
227 diff->cd(4);
228 couples->Draw("s2.eTY-ty:ty", csignal );
229 gStyle->SetOptStat("nemr");
230
231}

◆ check_sigma()

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

◆ check_surf()

void check_surf ( TCanvas surf)
84{
85 printf("check_surf with the cut: %s \n", csignal.GetTitle() );
86
87 surf->cd(1); couples->Draw("s.eY:s.eX",csignal);
88 surf->cd(2); couples->Draw("s.eTY:s.eTX",csignal);
89 surf->cd(5); {
90 couples->Draw("eCHI2P", csignal );
91 couples->SetLineColor(kGreen);
92 couples->Draw("eCHI2P", csignal && sameview ,"same");
93 couples->SetLineColor(kRed);
94 couples->Draw("eCHI2P", csignal && diffview,"same");
95 couples->SetLineColor(6);
96 couples->Draw("eCHI2P", csignal && diffarea,"same");
97 }
98 couples->SetLineColor(1);
99 surf->cd(3); {
100 couples->SetLineColor(kBlue);
101 couples->Draw("s1.eW>>hw1(15,5,20)", csignal );
102 couples->SetLineColor(kRed);
103 couples->Draw("s2.eW", csignal,"same");
104 }
105 couples->SetLineColor(1);
106
107 surf->cd(4); couples->Draw("s.eW>>hw(25,10,35)", csignal );
108 surf->cd(6); couples->Draw("eCHI2P:s.eW>>hchiw(25,10,35,30,0,3.)", csignal,"colZ");
109
110}
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)
192{
193 // check the accuracy deterioration in case when the segments are in
194 // the different views
195
196 printf("check_view with the cut: %s \n", csignal.GetTitle() );
197
198 cs->cd(1);
199 couples->Draw("eCHI2P", csignal&&sameview);
200 couples->Draw("eCHI2P", csignal&&diffview,"same");
201 couples->Draw("eCHI2P", csignal&&diffarea,"same");
202 cs->cd(2);
203 couples->SetMarkerStyle(20);
204 couples->SetAlias("same_view","(s1.eAid[1]==s2.eAid[1])");
205 couples->Draw("s.eTY:same_view",csignal,"prof");
206 cs->cd(3);
207 couples->Draw("s.eTX:same_view",csignal,"prof");
208 cs->cd(4);
209 couples->Draw("s.eTX>>htxv(100)",csignal&&sameview);
210 couples->Draw("s.eTX",csignal&&diffview,"same");
211 couples->SetMarkerStyle(1);
212 gStyle->SetOptStat("nemr");
213
214}

◆ correct_shrinkage()

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

◆ 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 ( )
47{
48 gStyle->SetOptFit(0001);
49 couples->SetAlias("tx","(s2.eX-s1.eX)/(s2.eZ-s1.eZ)"); // baseline angle tx
50 couples->SetAlias("ty","(s2.eY-s1.eY)/(s2.eZ-s1.eZ)"); // baseline angle ty
51 couples->SetAlias("t","sqrt(tx*tx+ty*ty)"); // baseline theta
52 couples->SetAlias("ts","sqrt(s.eTX*s.eTX + s.eTY*s.eTY)"); // basetrack theta
53
54 couples->SetAlias("t1","sqrt(s1.eTX*s1.eTX + s1.eTY*s1.eTY)"); // theta of the s1
55 couples->SetAlias("t2","sqrt(s2.eTX*s2.eTX + s2.eTY*s2.eTY)"); // theta of the s2
56
57 couples->SetAlias("phi","atan(s.eTY/s.eTX)"); // phi of the s
58 couples->SetAlias("phi1","atan(s1.eTY/s1.eTX)"); // phi of the s1
59 couples->SetAlias("phi2","atan(s2.eTY/s2.eTX)"); // phi of the s2
60
61 couples->SetAlias("dsx1","s1.eTX-s.eTX");
62 couples->SetAlias("dsy1","s1.eTY-s.eTY");
63 couples->SetAlias("ds1","sqrt(dsx1*dsx1+dsy1*dsy1)"); // absoulte angular diff s1-s
64 couples->SetAlias("dsx2","s2.eTX-s.eTX");
65 couples->SetAlias("dsy2","s2.eTY-s.eTY");
66 couples->SetAlias("ds2","sqrt(dsx2*dsx2+dsy2*dsy2)"); // absoulte angular diff s2-s
67
68 couples->SetAlias("dst1","(s1.eTX*s.eTY-s1.eTY*s.eTX)/ts"); // transverse slope diff s1-s
69 couples->SetAlias("dsl1","sqrt(ds1*ds1-dst1*dst1)"); // longitudinal slope diff s1-s
70 couples->SetAlias("dst2","(s2.eTX*s.eTY-s2.eTY*s.eTX)/ts"); // transverse slope diff s2-s
71 couples->SetAlias("dsl2","sqrt(ds2*ds2-dst2*dst2)"); // longitudinal slope diff s2-s
72
73
74 couples->SetAlias("dz","s2.eZ-s1.eZ");
75 couples->SetAlias("dx12","s2.eX-(s1.eX+dz*s1.eTX)"); // project s1 to s2 and calc dx
76 couples->SetAlias("dy12","s2.eY-(s1.eY+dz*s1.eTY)"); // project s1 to s2 and calc dy
77 couples->SetAlias("dx21","(s2.eX-dz*s2.eTX)-s1.eX"); // project s1 to s2 and calc dx
78 couples->SetAlias("dy21","(s2.eY-dz*s2.eTY)-s1.eY"); // project s1 to s2 and calc dx
79
80}

◆ main()

int main ( int  argc,
char *  argv[] 
)
427{
428 int output=3;
429 char* fname=argv[1];
430 char* csignal_cut="1";
431
432 gStyle->SetPalette(1);
433 check_cp( output, fname, csignal_cut ) ;
434
435 return 1 ;
436}

◆ sameview()

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

Variable Documentation

◆ couples

TTree* couples