#include #include #include #include #include #include using namespace std; //void TOTALSummaryAlign(TString pathG="/panda/pandaroot/macro/lmd/tmpOutputAlignTMP/", double tr_sc=200, double rt_sc=9) void SamplesSummaryAlign(TString pathG="/home/karavdin/datastorage/AlignmentLMDpixel/LargeSamplesStudyMay/BOX/mom_15/", double tr_sc=300, double rt_sc=3) { const int ntrksSample = 2e4; const double i_TrksSimi = 100./ntrksSample; //relative to simulated in % const int nParDt=8; double v_Dt[nParDt]={0,50,100,200,300,400,500,600}; const int nParDa=5; double v_Da[nParDa]={0,1,3,6,9}; // const int nParDt=1; // double v_Dt[nParDt]={600}; // const int nParDa=1; // double v_Da[nParDa]={0}; for(int iDt=0;iDtIsZombie()) { std::cout << "!!! Error opening file " <Get("NearIP/hResTheta"); //hbefore->Print(); hbefore->SetName("hResThetaBefore"); hbefore->SetTitle("#theta resolution"); // hbefore->Print(); TrksBef[ipart][i] = hbefore->GetEntries(); TrksBef[ipart][i] *=i_TrksSimi; // // if(i>0) TrksBef[ipart][i] += TrksBef[ipart][i-1]; // // cout<<" Trks["<SetParameters(100,0,3e-3); // funrth_b->SetParNames("Constant","Mean","Sigma"); // hbefore->Fit(funrth_b); // theta_mean_b[ipart][i] = 1e6*(funrth_b->GetParameter("Mean")); // theta_rms_b[ipart][i] = 1e6*(funrth_b->GetParameter("Sigma")); theta_mean_b[ipart][i] = 1e6*(hbefore->GetMean()); theta_rms_b[ipart][i] = 1e6*(hbefore->GetRMS()); // nsectors_b = (TNtuple*)f1->Get("nsectors"); TFile *f2 = new TFile(name2,"READ"); if (f2->IsZombie()) { std::cout << "!!! Error opening file " <Get("NearIP/hResTheta"); hafter->SetName("hResThetaAfter"); hafter->SetTitle("#theta resolution"); // Trks[ipart][i] = hafter->GetEntries(); // if(i>0) Trks[ipart][i] += Trks[ipart][i-1]; TrksAft[ipart][i] = hafter->GetEntries(); TrksAft[ipart][i] *=i_TrksSimi; // if(i>0) TrksAft[ipart][i] += TrksAft[ipart][i-1]; TrksDiff[ipart][i] = (TrksAft[ipart][i] - TrksBef[ipart][i]); // TF1 *funrth_a = new TF1("fitrth_a","gaus",-0.01,0.01); // funrth_a->SetParameters(100,0,3e-3); // funrth_a->SetParNames("Constant","Mean","Sigma"); // hafter->Fit(funrth_a); // theta_mean_a[ipart][i] = 1e6*(funrth_a->GetParameter("Mean")); // theta_rms_a[ipart][i] = 1e6*(funrth_a->GetParameter("Sigma")); // // nsectors_a = (TNtuple*)f2->Get("nsectors"); theta_mean_a[ipart][i] = 1e6*(hafter->GetMean()); theta_rms_a[ipart][i] = 1e6*(hafter->GetRMS()); TFile *f3 = new TFile(name3,"READ"); if (f3->IsZombie()) { std::cout << "!!! Error opening file " <Get("NearIP/hResTheta"); hrefer->SetName("hResThetaRef"); hrefer->SetTitle("#theta resolution"); // TF1 *funrth_r = new TF1("fitrth_r","gaus",-0.01,0.01); // funrth_r->SetParameters(100,0,3e-3); // funrth_r->SetParNames("Constant","Mean","Sigma"); // hrefer->Fit(funrth_r); // theta_mean_r[ipart][i] = 1e6*(funrth_r->GetParameter("Mean")); // theta_rms_r[ipart][i] = 1e6*(funrth_r->GetParameter("Sigma")); // nsectors_r = (TNtuple*)f3->Get("nsectors"); theta_mean_r[ipart][i] = 1e6*(hrefer->GetMean()); theta_rms_r[ipart][i] = 1e6*(hrefer->GetRMS()); // for(int isector=0;isector<10;isector++){ // TString cond = "sector=="; // cond +=isector; // nsectors_b->Project("hthetabefore","thetares",cond.Data()); // nsectors_a->Project("hthetaafter","thetares",cond.Data()); // nsectors_r->Project("hthetaref","thetares",cond.Data()); // hthetabefore->Fit(funrth_b); // hthetaafter->Fit(funrth_a); // hthetaref->Fit(funrth_r); // theta_mean_b_sec[ipart][isector][i] = 1e6*(funrth_b->GetParameter("Mean")); // theta_rms_b_sec[ipart][isector][i] = 1e6*(funrth_b->GetParameter("Sigma")); // theta_mean_a_sec[ipart][isector][i] = 1e6*(funrth_a->GetParameter("Mean")); // theta_rms_a_sec[ipart][isector][i] = 1e6*(funrth_a->GetParameter("Sigma")); // theta_mean_r_sec[ipart][isector][i] = 1e6*(funrth_r->GetParameter("Mean")); // theta_rms_r_sec[ipart][isector][i] = 1e6*(funrth_r->GetParameter("Sigma")); // } /// END (Theta resolution) --------------------------------------------------------------- f1->Close(); f2->Close(); f3->Close(); ///Misalignment constants ----------------------------------------------------------------- TString namemisc = pathG+"/"; namemisc+=tr_sc; namemisc+="mkm_"; namemisc+=rt_sc; namemisc+="mrad/Sum"; namemisc +=i; namemisc+="Samples/KnossosResults.root"; TFile *fmisc = new TFile(namemisc,"READ"); if (fmisc->IsZombie()) { std::cout << "!!! Error opening file " <Get("mis_before_0"); mis_b[ipart][0][i] = 1e4*(hmis_b_0->ProjectionY()->GetRMS()); TH2F *hmis_b_1 = (TH2F*)fmisc->Get("mis_before_1"); mis_b[ipart][1][i] = 1e4*(hmis_b_1->ProjectionY()->GetRMS()); TH2F *hmis_b_2 = (TH2F*)fmisc->Get("mis_before_2"); mis_b[ipart][2][i] = 1e4*(hmis_b_2->ProjectionY()->GetRMS()); TH2F *hmis_b_3 = (TH2F*)fmisc->Get("mis_before_3"); mis_b[ipart][3][i] = 1e3*(hmis_b_3->ProjectionY()->GetRMS()); TH2F *hmis_b_4 = (TH2F*)fmisc->Get("mis_before_4"); mis_b[ipart][4][i] = 1e3*(hmis_b_4->ProjectionY()->GetRMS()); TH2F *hmis_b_5 = (TH2F*)fmisc->Get("mis_before_5"); mis_b[ipart][5][i] = 1e3*(hmis_b_5->ProjectionY()->GetRMS()); TH2F *hmis_a_0 = (TH2F*)fmisc->Get("mis_diff_0"); mis_a[ipart][0][i] = 1e4*(hmis_a_0->ProjectionY()->GetRMS()); TH2F *hmis_a_1 = (TH2F*)fmisc->Get("mis_diff_1"); mis_a[ipart][1][i] = 1e4*(hmis_a_1->ProjectionY()->GetRMS()); TH2F *hmis_a_2 = (TH2F*)fmisc->Get("mis_diff_2"); mis_a[ipart][2][i] = 1e4*(hmis_a_2->ProjectionY()->GetRMS()); TH2F *hmis_a_3 = (TH2F*)fmisc->Get("mis_diff_3"); mis_a[ipart][3][i] = 1e3*(hmis_a_3->ProjectionY()->GetRMS()); TH2F *hmis_a_4 = (TH2F*)fmisc->Get("mis_diff_4"); mis_a[ipart][4][i] = 1e3*(hmis_a_4->ProjectionY()->GetRMS()); TH2F *hmis_a_5 = (TH2F*)fmisc->Get("mis_diff_5"); mis_a[ipart][5][i] = 1e3*(hmis_a_5->ProjectionY()->GetRMS()); /// END (Misalignment constants) ----------------------------------------------------------- fmisc->Close(); } } //return; double av_theta_mean_b[nS],av_theta_rms_b[nS]; double av_theta_mean_a[nS],av_theta_rms_a[nS]; double av_theta_mean_r[nS],av_theta_rms_r[nS]; double av_TrksBef[nS];double av_TrksAft[nS];double av_TrksDiff[nS]; double avEr_theta_mean_b[nS],avEr_theta_rms_b[nS]; double avEr_theta_mean_a[nS],avEr_theta_rms_a[nS]; double avEr_theta_mean_r[nS],avEr_theta_rms_r[nS]; double avEr_TrksBef[nS]; double avEr_TrksAft[nS];double avEr_TrksDiff[nS]; // double av_theta_mean_b_sec[10][nS],av_theta_rms_b_sec[10][nS]; // double av_theta_mean_a_sec[10][nS],av_theta_rms_a_sec[10][nS]; // double av_theta_mean_r_sec[10][nS],av_theta_rms_r_sec[10][nS]; // double avEr_theta_mean_b_sec[10][nS],avEr_theta_rms_b_sec[10][nS]; // double avEr_theta_mean_a_sec[10][nS],avEr_theta_rms_a_sec[10][nS]; // double avEr_theta_mean_r_sec[10][nS],avEr_theta_rms_r_sec[10][nS]; double av_mis_a_mean[6][nS]; double av_mis_b_mean[6][nS]; double avEr_mis_a_mean[6][nS]; double avEr_mis_b_mean[6][nS]; for(int i=0;iGetXaxis()->SetTitle("Average number of rec. trks"); mgr_theta->GetYaxis()->SetTitle("#theta_{mean}, #murad"); c1.Print(resname_pdf_o); //write canvas and keep the ps file open c1.Clear(); TGraphErrors *gr_theta_rms_b = new TGraphErrors(nS,TrksSim,av_theta_rms_b,0,avEr_theta_rms_b); gr_theta_rms_b->SetMarkerStyle(20); gr_theta_rms_b->SetMarkerColor(kGreen-3); gr_theta_rms_b->SetMarkerSize(2.5); TGraphErrors *gr_theta_rms_a = new TGraphErrors(nS,TrksSim,av_theta_rms_a,0,avEr_theta_rms_a); gr_theta_rms_a->SetMarkerStyle(29); gr_theta_rms_a->SetMarkerColor(kOrange+7); gr_theta_rms_a->SetMarkerSize(2.5); TGraphErrors *gr_theta_rms_r = new TGraphErrors(nS,TrksSim,av_theta_rms_r,0,avEr_theta_rms_a); gr_theta_rms_r->SetMarkerStyle(21); gr_theta_rms_r->SetMarkerColor(15); gr_theta_rms_r->SetMarkerSize(2.5); TMultiGraph *mgr_theta_rms = new TMultiGraph(); // mgr_theta_rms->Add(gr_theta_rms_b); mgr_theta_rms->Add(gr_theta_rms_r); mgr_theta_rms->Add(gr_theta_rms_a); mgr_theta_rms->Draw("AP"); mgr_theta_rms->GetXaxis()->SetTitle("Average number of rec. trks per sector"); mgr_theta_rms->GetYaxis()->SetTitle("#theta_{#sigma}, #murad"); c1.Print(resname_pdf_o); //write canvas and keep the ps file open c1.Clear(); // for(int isector=0;isector<10;isector++){ // //put together theta resolution results // TGraphErrors *gr_theta_b_sec = new TGraphErrors(nS,TrksSim, av_theta_mean_b_sec[isector],0, avEr_theta_mean_b_sec[isector]); // gr_theta_b_sec->SetMarkerStyle(20); // gr_theta_b_sec->SetMarkerColor(kGreen-3); // gr_theta_b_sec->SetMarkerSize(2.5); // TGraphErrors *gr_theta_a_sec = new TGraphErrors(nS,TrksSim, av_theta_mean_a_sec[isector],0, avEr_theta_mean_a_sec[isector]); // gr_theta_a_sec->SetMarkerStyle(29); // gr_theta_a_sec->SetMarkerColor(kOrange+7); // gr_theta_a_sec->SetMarkerSize(2.5); // TGraphErrors *gr_theta_r_sec = new TGraphErrors(nS,TrksSim, av_theta_mean_r_sec[isector],0, avEr_theta_mean_r_sec[isector]); // gr_theta_r_sec->SetMarkerStyle(21); // gr_theta_r_sec->SetMarkerColor(15); // gr_theta_r_sec->SetMarkerSize(2.5); // TMultiGraph *mgr_theta_sec = new TMultiGraph(); // // mgr_theta_sec->Add(gr_theta_b_sec); // mgr_theta_sec->Add(gr_theta_r_sec); // mgr_theta_sec->Add(gr_theta_a_sec); // TString titlemean = "#theta_{mean}, #murad [sector No."; // titlemean+=isector; // titlemean +="]"; // mgr_theta_sec->Draw("AP"); // mgr_theta_sec->GetXaxis()->SetTitle("Average number of rec. trks "); // mgr_theta_sec->GetYaxis()->SetTitle(titlemean.Data()); // c1.Print(resname_pdf_o); //write canvas and keep the ps file open // c1.Clear(); // TGraphErrors *gr_theta_rms_b_sec = new TGraphErrors(nS,TrksSim,av_theta_rms_b_sec[isector],0,avEr_theta_rms_b_sec[isector]); // gr_theta_rms_b_sec->SetMarkerStyle(20); // gr_theta_rms_b_sec->SetMarkerColor(kGreen-3); // gr_theta_rms_b_sec->SetMarkerSize(2.5); // TGraphErrors *gr_theta_rms_a_sec = new TGraphErrors(nS,TrksSim,av_theta_rms_a_sec[isector],0,avEr_theta_rms_a_sec[isector]); // gr_theta_rms_a_sec->SetMarkerStyle(29); // gr_theta_rms_a_sec->SetMarkerColor(kOrange+7); // gr_theta_rms_a_sec->SetMarkerSize(2.5); // TGraphErrors *gr_theta_rms_r_sec = new TGraphErrors(nS,TrksSim,av_theta_rms_r_sec[isector],0,avEr_theta_rms_a_sec[isector]); // gr_theta_rms_r_sec->SetMarkerStyle(21); // gr_theta_rms_r_sec->SetMarkerColor(15); // gr_theta_rms_r_sec->SetMarkerSize(2.5); // TMultiGraph *mgr_theta_rms_sec = new TMultiGraph(); // // mgr_theta_rms_sec->Add(gr_theta_rms_b_sec); // mgr_theta_rms_sec->Add(gr_theta_rms_r_sec); // mgr_theta_rms_sec->Add(gr_theta_rms_a_sec); // mgr_theta_rms_sec->Draw("AP"); // mgr_theta_rms_sec->GetXaxis()->SetTitle("Average number of rec. trks "); // TString titlerms = "#theta_{#sigma}, #murad [sector No."; // titlerms+=isector; // titlerms +="]"; // mgr_theta_rms_sec->GetYaxis()->SetTitle(titlerms.Data()); // c1.Print(resname_pdf_o); //write canvas and keep the ps file open // c1.Clear(); // } //put together missalignment consts results TGraphErrors *gr_mis_b[6]; TGraphErrors *gr_mis_a[6]; TMultiGraph *mgr_mis[6]; for(int ialc=0;ialc<6;ialc++){ gr_mis_b[ialc] = new TGraphErrors(nS,TrksSim,av_mis_b_mean[ialc],0,avEr_mis_b_mean[ialc]); gr_mis_b[ialc]->SetMarkerStyle(20); gr_mis_b[ialc]->SetMarkerColor(kGreen-3); gr_mis_b[ialc]->SetMarkerSize(2.5); gr_mis_a[ialc] = new TGraphErrors(nS,TrksSim,av_mis_a_mean[ialc],0,avEr_mis_a_mean[ialc]); gr_mis_a[ialc]->SetMarkerStyle(29); gr_mis_a[ialc]->SetMarkerColor(kOrange+7); gr_mis_a[ialc]->SetMarkerSize(2.5); mgr_mis[ialc] = new TMultiGraph(); mgr_mis[ialc]->Add(gr_mis_b[ialc]); mgr_mis[ialc]->Add(gr_mis_a[ialc]); mgr_mis[ialc]->Draw("AP"); mgr_mis[ialc]->GetXaxis()->SetTitle("Average number of rec. trks "); if(ialc==0) mgr_mis[ialc]->GetYaxis()->SetTitle("#Delta_{x}, #mum"); if(ialc==1) mgr_mis[ialc]->GetYaxis()->SetTitle("#Delta_{y}, #mum"); if(ialc==2) mgr_mis[ialc]->GetYaxis()->SetTitle("#Delta_{z}, #mum"); if(ialc==3) mgr_mis[ialc]->GetYaxis()->SetTitle("#Delta_{#alpha}, mrad"); if(ialc==4) mgr_mis[ialc]->GetYaxis()->SetTitle("#Delta_{#beta}, mrad"); if(ialc==5) mgr_mis[ialc]->GetYaxis()->SetTitle("#Delta_{#gamma}, mrad"); if(ialc<2 || ialc==5) c1.Print(resname_pdf_o); //write canvas and keep the file open c1.Clear(); } TMultiGraph *mgr_stat = new TMultiGraph(); TGraphErrors *grstatBef = new TGraphErrors(nS,TrksSim,av_TrksBef,0,avEr_TrksBef); grstatBef->SetMarkerStyle(24); grstatBef->SetMarkerSize(2.5); TGraphErrors *grstatAft = new TGraphErrors(nS,TrksSim,av_TrksAft,0,avEr_TrksAft); grstatAft->SetMarkerStyle(22); grstatAft->SetMarkerSize(2.5); grstatAft->SetTitle("Average number of rec. trks (empty = before Knossos; filled = after Knossos)"); mgr_stat->Add(grstatBef); mgr_stat->Add(grstatAft); mgr_stat->Draw("AP"); mgr_stat->GetXaxis()->SetTitle("Number of sim. trks"); mgr_stat->GetYaxis()->SetTitle("N_{REC}/N_{SIM}, % [empty = N^{ before}_{REC}; filled = N^{ after}_{REC}]"); //mgr_stat->SetTitle("Average number of rec. trks (empty = before Knossos; filled = after Knossos)"); c1.Print(resname_pdf_o); //write canvas and keep the file open c1.Clear(); TGraphErrors *grstatDiff = new TGraphErrors(nS,TrksSim,av_TrksDiff,0,avEr_TrksDiff); grstatDiff->SetMarkerStyle(22); grstatDiff->SetMarkerSize(2.5); grstatDiff->Draw("ALP"); grstatDiff->GetXaxis()->SetTitle("Number of sim. trks"); grstatDiff->GetYaxis()->SetTitle("(N^{ after}_{REC} - N^{ before}_{REC})/N_{SIM}, %"); // grstatDiff->SetTitle("Diff number of rec. trks (after - before), %"); c1.Print(resname_pdf_c); //write canvas and close ps file c1.Close(); TString out = resname+".root"; TFile *f = new TFile(out,"RECREATE"); // for (int g=0;g<6;g++){ // gr_mis_b[g]->Write(); // gr_mis_a[g]->Write(); // mgr_mis[g]->Write(); // } gr_theta_b->Write(); gr_theta_r->Write(); gr_theta_a->Write(); mgr_theta->Write(); gr_theta_rms_b->Write(); gr_theta_rms_r->Write(); gr_theta_rms_a->Write(); mgr_theta_rms->Write(); for(int ialc=0;ialc<6;ialc++){ gr_mis_b[ialc]->Write(); gr_mis_a[ialc]->Write(); mgr_mis[ialc]->Write(); } mgr_stat->Write(); grstatDiff->Write(); f->Write(); f->Close(); } } }