Theta resolution--------------------------------------------------------------------——————
END (Misalignment constants) --------------------------------------------------———
Let's draw now! ---------------------------------------------------------------—— 
   28   double v_tr_sc[nDt]={0,50,100,200,300,400,500,600};
 
   31   double v_rt_sc[nDa]={daGL};
 
   33   const int nSdstep = 10; 
 
   34   const int nuSd = nSdGL/nSdstep;
 
   38     for(
int iDa=0;iDa<nDa;iDa++){
 
   39       double  rt_sc1 = v_rt_sc[iDa];
 
   40       double av_theta_mean_b[nuSd+1][nDt],av_theta_rms_b[nuSd+1][nDt];
 
   41       double av_theta_mean_a[nuSd+1][nDt],av_theta_rms_a[nuSd+1][nDt];
 
   42       double av_theta_mean_r[nuSd+1][nDt],av_theta_rms_r[nuSd+1][nDt];
 
   43       double avEr_theta_mean_b[nuSd+1][nDt],avEr_theta_rms_b[nuSd+1][nDt];
 
   44       double avEr_theta_mean_a[nuSd+1][nDt],avEr_theta_rms_a[nuSd+1][nDt];
 
   45       double avEr_theta_mean_r[nuSd+1][nDt],avEr_theta_rms_r[nuSd+1][nDt];
 
   46       double av_events[nuSd+1][nDt], avEr_events[nuSd+1][nDt];
 
   47       double av_mis_a_mean[6][nuSd+1][nDt];
 
   48       double av_mis_b_mean[6][nuSd+1][nDt];
 
   49       double avEr_mis_a_mean[6][nuSd+1][nDt];
 
   50       double avEr_mis_b_mean[6][nuSd+1][nDt];
 
   53     TMultiGraph *mgr_mis[6];
 
   54     TMultiGraph *mgr_theta = 
new TMultiGraph(
"mgr_theta_mean",
"");
 
   55     TMultiGraph *mgr_theta_rms = 
new TMultiGraph(
"mgr_theta_rms",
"");
 
   56     TMultiGraph *mgr_theta_b = 
new TMultiGraph(
"mgr_theta_mean_b",
"");
 
   57     TMultiGraph *mgr_theta_rms_b = 
new TMultiGraph(
"mgr_theta_rms_b",
"");
 
   58     TMultiGraph *mgr_events = 
new TMultiGraph(
"mgr_events",
"");
 
   62   TString resname= pathG+
"/AlignmentLimits_";
 
   63   resname+=v_rt_sc[iDa];
 
   66   resname+=
"constsSample";
 
   67   TString resname_pdf = resname+
".pdf";
 
   68   TString resname_pdf_o = resname_pdf+
"(";
 
   69   TString resname_pdf_c = resname_pdf+
")"; 
 
   70   for(
int ijsum=1;ijsum<nuSd+1;ijsum++){ 
 
   71     int isum = 1+nSdstep*(ijsum-1);
 
   72     for(
int idt=0;idt<nDt;idt++){
 
   74         double tr_sc = v_tr_sc[idt];
 
   75         double rt_sc = v_rt_sc[iDa];
 
   86         path+=
"Samples/resultsSUM/";
 
   95         name3+=
"Samples/resultsSUM/Lumi_QA_before.root";
 
  100         TFile *
f1 = 
new TFile(name1,
"READ");
 
  101         if (f1->IsZombie()) {
 
  102           std::cout << 
"!!! Error opening file " <<name1<< std::endl;
 
  107         hbefore = (TH1*)f1->Get(
"NearIP/hResTheta");
 
  108         hbefore->SetName(
"hResThetaBefore");
 
  109         hbefore->SetTitle(
"#theta resolution");
 
  110         av_theta_mean_b[isum][idt]  = 1e6*(hbefore->GetMean());
 
  111         av_theta_rms_b[isum][idt]  = 1e6*(hbefore->GetRMS());
 
  112         avEr_theta_mean_b[isum][idt]  = 1e6*(hbefore->GetMeanError());
 
  113         avEr_theta_rms_b[isum][idt]  = 1e6*(hbefore->GetRMSError());
 
  116         TFile *
f2 = 
new TFile(name2,
"READ");
 
  117         if (f2->IsZombie()) {
 
  118           std::cout << 
"!!! Error opening file " <<name2<< std::endl;
 
  121         hafter = (TH1F*)f2->Get(
"NearIP/hResTheta");
 
  122         hafter->SetName(
"hResThetaAfter");
 
  123         hafter->SetTitle(
"#theta resolution");
 
  124         av_theta_mean_a[isum][idt]  = 1e6*(hafter->GetMean());
 
  125         av_theta_rms_a[isum][idt]  = 1e6*(hafter->GetRMS());
 
  126         avEr_theta_mean_a[isum][idt]  = 1e6*(hafter->GetMeanError());
 
  127         avEr_theta_rms_a[isum][idt]  = 1e6*(hafter->GetRMSError());
 
  128         TFile *
f3 = 
new TFile(name3,
"READ");
 
  129         if (f3->IsZombie()) {
 
  130           std::cout << 
"!!! Error opening file " <<name2<< std::endl;
 
  133         hrefer = (TH1F*)f3->Get(
"NearIP/hResTheta");
 
  134         hrefer->SetName(
"hResThetaRef");
 
  135         hrefer->SetTitle(
"#theta resolution");
 
  136         av_theta_mean_r[isum][idt]  = 1e6*(hrefer->GetMean());
 
  137         av_theta_rms_r[isum][idt]  = 1e6*(hrefer->GetRMS());
 
  138         avEr_theta_mean_r[isum][idt]  = 1e6*(hrefer->GetMeanError());
 
  139         avEr_theta_rms_r[isum][idt]  = 1e6*(hrefer->GetRMSError());
 
  155         namemisc+=
"Samples/KnossosResults.root";
 
  156         TFile *fmisc = 
new TFile(namemisc,
"READ");
 
  157         if (fmisc->IsZombie()) {
 
  158           std::cout << 
"!!! Error opening file " <<namemisc<< std::endl;
 
  163         for(
int imdf=0;imdf<6;imdf++){
 
  166           hmis_b[imdf] = (TH2F*)fmisc->Get(nb);
 
  167           av_mis_b_mean[imdf][isum][idt] = 1e4*(hmis_b[imdf]->ProjectionY()->GetRMS());
 
  168           avEr_mis_b_mean[imdf][isum][idt] = 1e4*(hmis_b[imdf]->ProjectionY()->GetRMSError());
 
  172           hmis_a[imdf] = (TH2F*)fmisc->Get(na);
 
  173           av_mis_a_mean[imdf][isum][idt] = 1e4*(hmis_a[imdf]->ProjectionY()->GetRMS());
 
  174           avEr_mis_a_mean[imdf][isum][idt] = 1e4*(hmis_a[imdf]->ProjectionY()->GetRMSError());
 
  184  TGraphErrors *gr_theta_b[nuSd+1];
 
  185  TGraphErrors *gr_theta_a[nuSd+1];
 
  186  TGraphErrors *gr_theta_r[nuSd+1];
 
  187  TGraphErrors *gr_events[nuSd+1];
 
  188  TLegend *legThMb = 
new TLegend(0.1,0.2,0.38,0.58);
 
  189  TLegend *legThMa = 
new TLegend(0.1,0.2,0.38,0.58);
 
  190   for(
int isum=1;isum<nuSd+1;isum++){
 
  195     gr_events[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_events[isum],0, avEr_events[isum]);
 
  196     TString name_ev = 
"number_ev_sum";
 
  198     gr_events[isum]->SetName(name_ev);
 
  199     gr_events[isum]->SetMarkerStyle(20+isum); 
 
  200     gr_events[isum]->SetMarkerColor(kGreen-3); 
 
  201     gr_events[isum]->SetMarkerSize(1.5); 
 
  202     mgr_events->Add(gr_events[isum]);
 
  204     gr_theta_b[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_theta_mean_b[isum],0, avEr_theta_mean_b[isum]);
 
  205     TString name_thm_b = 
"th_mean_b_sum";
 
  207     gr_theta_b[isum]->SetName(name_thm_b);
 
  208     gr_theta_b[isum]->SetMarkerStyle(20+isum); 
 
  209     gr_theta_b[isum]->SetMarkerColor(kGreen-3); 
 
  210     gr_theta_b[isum]->SetMarkerSize(1.5); 
 
  211     legThMb->AddEntry(gr_theta_b[isum],sname,
"P");
 
  213    gr_theta_a[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_theta_mean_a[isum],0, avEr_theta_mean_a[isum]);
 
  215    TString name_thm_a = 
"th_mean_a_sum";
 
  217    gr_theta_a[isum]->SetName(name_thm_a);
 
  218    gr_theta_a[isum]->SetMarkerStyle(20+isum); 
 
  219    gr_theta_a[isum]->SetMarkerColor(kOrange+7); 
 
  220    gr_theta_a[isum]->SetMarkerSize(1.5); 
 
  222    legThMa->AddEntry(gr_theta_a[isum],sname,
"P");
 
  223    gr_theta_r[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_theta_mean_r[isum],0, avEr_theta_mean_r[isum]);
 
  225   TString name_thm_r = 
"th_mean_r_sum";
 
  227    gr_theta_r[isum]->SetName(name_thm_r);
 
  228    gr_theta_r[isum]->SetMarkerStyle(20+isum); 
 
  229    gr_theta_r[isum]->SetMarkerColor(15);
 
  230    gr_theta_r[isum]->SetMarkerSize(1.5); 
 
  231    mgr_theta_b->Add(gr_theta_b[isum]);
 
  232    mgr_theta->Add(gr_theta_a[isum]);
 
  233    mgr_theta->Add(gr_theta_r[isum]);
 
  236  mgr_theta->Draw(
"AP");
 
  237  mgr_theta->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
 
  238  mgr_theta->GetYaxis()->SetTitle(
"#theta_{mean}, #murad");
 
  240  legThMa->SetFillColor(0);
 
  241  legThMb->SetFillColor(0);
 
  243  cRes.Print(resname_pdf_o); 
 
  245  mgr_theta_b->Draw(
"AP");
 
  246  mgr_theta_b->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
 
  247  mgr_theta_b->GetYaxis()->SetTitle(
"#theta_{mean}, #murad");
 
  249  cRes.Print(resname_pdf_o); 
 
  251  TGraphErrors *gr_theta_rms_b[nuSd+1];
 
  252  TGraphErrors *gr_theta_rms_a[nuSd+1];
 
  253  TGraphErrors *gr_theta_rms_r[nuSd+1];
 
  254   for(
int isum=1;isum<nuSd+1;isum++){
 
  255    gr_theta_rms_b[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_theta_rms_b[isum],0, avEr_theta_rms_b[isum]);
 
  256    gr_theta_rms_b[isum]->SetMarkerStyle(20+isum); 
 
  257    gr_theta_rms_b[isum]->SetMarkerColor(kGreen-3); 
 
  258    gr_theta_rms_b[isum]->SetMarkerSize(1.5); 
 
  259    TString name_thm_b = 
"th_rms_b_sum";
 
  261    gr_theta_rms_b[isum]->SetName(name_thm_b);
 
  263    gr_theta_rms_a[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_theta_rms_a[isum],0, avEr_theta_rms_a[isum]);
 
  265    gr_theta_rms_a[isum]->SetMarkerStyle(20+isum); 
 
  266    gr_theta_rms_a[isum]->SetMarkerColor(kOrange+7); 
 
  267    gr_theta_rms_a[isum]->SetMarkerSize(1.5); 
 
  268    TString name_thm_a = 
"th_rms_a_sum";
 
  270    gr_theta_rms_a[isum]->SetName(name_thm_a);
 
  271    gr_theta_rms_r[isum] = 
new TGraphErrors(nDt,v_tr_sc, av_theta_rms_r[isum],0, avEr_theta_rms_r[isum]);
 
  273    gr_theta_rms_r[isum]->SetMarkerStyle(20+isum); 
 
  274    gr_theta_rms_r[isum]->SetMarkerColor(15);
 
  275    gr_theta_rms_r[isum]->SetMarkerSize(1.5); 
 
  276    TString name_thm_r = 
"th_rms_r_sum";
 
  278    gr_theta_rms_r[isum]->SetName(name_thm_r);
 
  279    mgr_theta_rms_b->Add(gr_theta_rms_b[isum]);
 
  280    mgr_theta_rms->Add(gr_theta_rms_a[isum]);
 
  281    mgr_theta_rms->Add(gr_theta_rms_r[isum]);
 
  284  mgr_theta_rms->Draw(
"AP");
 
  285  mgr_theta_rms->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
 
  286  mgr_theta_rms->GetYaxis()->SetTitle(
"#theta_{#sigma}, #murad");
 
  287  cRes.Print(resname_pdf_o); 
 
  289  mgr_theta_rms_b->Draw(
"AP");
 
  290  mgr_theta_rms_b->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
 
  291  mgr_theta_rms_b->GetYaxis()->SetTitle(
"#theta_{#sigma}, #murad");
 
  292  cRes.Print(resname_pdf_o); 
 
  294  mgr_events->Draw(
"APL");
 
  295  mgr_events->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
 
  296  mgr_events->GetYaxis()->SetTitle(
"events, 10^{3}");
 
  297  cRes.Print(resname_pdf_o); 
 
  300  TGraphErrors *gr_mis_b[6][nuSd+1];
 
  301  TGraphErrors *gr_mis_a[6][nuSd+1];
 
  303  for(
int ialc=0;ialc<6;ialc++){
 
  304   for(
int isum=1;isum<nuSd+1;isum++){
 
  305      gr_mis_b[ialc][isum] = 
new TGraphErrors(nDt,v_tr_sc,av_mis_b_mean[ialc][isum],0,avEr_mis_b_mean[ialc][isum]);
 
  306      gr_mis_b[ialc][isum]->SetMarkerStyle(20+isum);
 
  307      gr_mis_b[ialc][isum]->SetMarkerColor(kGreen-3);
 
  308      gr_mis_b[ialc][isum]->SetMarkerSize(1.5);
 
  309      gr_mis_a[ialc][isum] = 
new TGraphErrors(nDt,v_tr_sc,av_mis_a_mean[ialc][isum],0,avEr_mis_a_mean[ialc][isum]);
 
  310      gr_mis_a[ialc][isum]->SetMarkerStyle(20+isum);
 
  311      gr_mis_a[ialc][isum]->SetMarkerColor(kOrange+7);
 
  312      gr_mis_a[ialc][isum]->SetMarkerSize(1.5);
 
  313      TString name_miss_a = 
"mis_a_";
 
  315      name_miss_a +=
"_sum";
 
  317      TString name_miss_b = 
"mis_b_";
 
  319      name_miss_b +=
"_sum";
 
  321      gr_mis_b[ialc][isum]->SetName(name_miss_b);
 
  322      gr_mis_a[ialc][isum]->SetName(name_miss_a);
 
  323      mgr_mis[ialc]->Add(gr_mis_b[ialc][isum]);
 
  324      mgr_mis[ialc]->Add(gr_mis_a[ialc][isum]);
 
  326    mgr_mis[ialc]->Draw(
"AP");
 
  327    mgr_mis[ialc]->GetXaxis()->SetTitle(
"#delta_{t}, #mum");
 
  328    if(ialc==0) mgr_mis[ialc]->GetYaxis()->SetTitle(
"#Delta_{x}, #mum");
 
  329    if(ialc==1) mgr_mis[ialc]->GetYaxis()->SetTitle(
"#Delta_{y}, #mum");
 
  330    if(ialc==2) mgr_mis[ialc]->GetYaxis()->SetTitle(
"#Delta_{z}, #mum");
 
  331    if(ialc==3) mgr_mis[ialc]->GetYaxis()->SetTitle(
"#Delta_{#alpha}, mrad");
 
  332    if(ialc==4) mgr_mis[ialc]->GetYaxis()->SetTitle(
"#Delta_{#beta}, mrad");
 
  333    if(ialc==5) mgr_mis[ialc]->GetYaxis()->SetTitle(
"#Delta_{#gamma}, mrad");
 
  335      if(ialc==0 || ialc==1)
 
  336        cRes.Print(resname_pdf_o); 
 
  338    else cRes.Print(resname_pdf_c); 
 
  346  TFile *
f = 
new TFile(out,
"RECREATE");
 
  348  mgr_theta_rms->Write();
 
  349  mgr_theta_b->Write();
 
  350  mgr_theta_rms_b->Write();
 
  351  for(
int ialc=0;ialc<6;ialc++){
 
  352    mgr_mis[ialc]->Write();
 
  355   for(
int isum=1;isum<nuSd+1;isum++){
 
  356     gr_events[isum]->Write();
 
  357     gr_theta_b[isum]->Write();
 
  358     gr_theta_a[isum]->Write();
 
  359     gr_theta_r[isum]->Write();
 
  360     gr_theta_rms_b[isum]->Write();
 
  361     gr_theta_rms_a[isum]->Write();
 
  362     gr_theta_rms_r[isum]->Write();
 
  363     for(
int ialc=0;ialc<6;ialc++){
 
  364       gr_mis_b[ialc][isum]->Write();
 
  365       gr_mis_a[ialc][isum]->Write();