#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="/panda/pandaroot/macro/lmd/tmpOutputAlignTMPSamples/", double tr_sc=0, double rt_sc=0, const int nSamples=2) { const int nS=8; double TrksSim[nS]={10000, 100000, 200000, 300000, 400000, 500000, 700000, 1000000}; // double TrksSim[nS]={10, 100, 200, 300, 400, 500, 700, 1000}; double Trks[nSamples][nS]; //How to save data TString resname= pathG+"/ResultsSamplesSummary_"; resname+=tr_sc; resname+="um_"; resname+=rt_sc; resname+="mrad"; TString resname_pdf = resname+".pdf"; TString resname_pdf_o = resname_pdf+"("; TString resname_pdf_c = resname_pdf+")"; double mis_b[nSamples][6][nS]; double mis_a[nSamples][6][nS]; double theta_mean_b[nSamples][nS], theta_mean_a[nSamples][nS], theta_mean_r[nSamples][nS]; double theta_rms_b[nSamples][nS], theta_rms_a[nSamples][nS], theta_rms_r[nSamples][nS]; double theta_mean_b_sec[nSamples][10][nS], theta_mean_a_sec[nSamples][10][nS], theta_mean_r_sec[nSamples][10][nS]; double theta_rms_b_sec[nSamples][10][nS], theta_rms_a_sec[nSamples][10][nS], theta_rms_r_sec[nSamples][10][nS]; TH1D *hthetabefore = new TH1D("hthetabefore","#theta_{MC}-#theta_{rec};#delta#theta,rad",1e2,-1e-3,1e-3); TH1D *hthetaafter = new TH1D("hthetaafter","#theta_{MC}-#theta_{rec};#delta#theta,rad",1e2,-1e-3,1e-3); TH1D *hthetaref = new TH1D("hthetaref","#theta_{MC}-#theta_{rec};#delta#theta,rad",1e2,-1e-3,1e-3); for(int ipart=0;ipartIsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <IsZombie()) { std::cout << "!!! Error opening file " <Get("nhits"); trksCur+= 0.25*(hntuple0->GetEntries()); TNtuple* hntuple1 = (TNtuple*)fresb1->Get("nhits"); trksCur+= 0.25*(hntuple1->GetEntries()); TNtuple* hntuple2 = (TNtuple*)fresb2->Get("nhits"); trksCur+= 0.25*(hntuple2->GetEntries()); TNtuple* hntuple3 = (TNtuple*)fresb3->Get("nhits"); trksCur+= 0.25*(hntuple3->GetEntries()); TNtuple* hntuple4 = (TNtuple*)fresb4->Get("nhits"); trksCur+= 0.25*(hntuple4->GetEntries()); TNtuple* hntuple5 = (TNtuple*)fresb5->Get("nhits"); trksCur+= 0.25*(hntuple5->GetEntries()); TNtuple* hntuple6 = (TNtuple*)fresb6->Get("nhits"); trksCur+= 0.25*(hntuple6->GetEntries()); TNtuple* hntuple7 = (TNtuple*)fresb7->Get("nhits"); trksCur+= 0.25*(hntuple7->GetEntries()); TNtuple* hntuple8 = (TNtuple*)fresb8->Get("nhits"); trksCur+= 0.25*(hntuple8->GetEntries()); TNtuple* hntuple9 = (TNtuple*)fresb9->Get("nhits"); trksCur+= 0.25*(hntuple9->GetEntries()); Trks[ipart][i] = int(trksCur*0.1); // ///Misalignment constants ----------------------------------------------------------------- // TString namemisc = path + "/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) ----------------------------------------------------------- /// Theta resolution-------------------------------------------------------------------------------------- TString name1 = path + "/Lumi_out_MC_and_REC_trks_matches_with_IDs0_dr_"; name1+=tr_sc; name1+="_da_"; name1+=rt_sc; name1+="_before.root"; TString name2 = path + "/Lumi_out_MC_and_REC_trks_matches_with_IDs0_dr_"; name2+=tr_sc; name2+="_da_"; name2+=rt_sc; name2+="_after.root"; TString name3 = pathG+"/Sample"; name3+= ipart; name3+="/results_0mkm_0mrad_"; name3+=nTrks; name3+="events/Lumi_out_MC_and_REC_trks_matches_with_IDs0_dr_0_da_0_before.root"; // TH1F *hbeforetmp; TH1F *haftertmp; TH1F *hbefore; TH1F *hafter; TH1F *hrefer; TFile *f1 = new TFile(name1,"READ"); if (f1->IsZombie()) { std::cout << "!!! Error opening file " <Get("hResTheta"); hbefore->SetName("hResThetaBefore"); hbefore->SetTitle("#theta resolution"); // hbefore->Print(); TF1 *funrth_b = new TF1("fitrth_b","gaus",-0.01,0.01); funrth_b->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")); TFile *f2 = new TFile(name2,"READ"); if (f2->IsZombie()) { std::cout << "!!! Error opening file " <Get("hResTheta"); hafter->SetName("hResThetaAfter"); hafter->SetTitle("#theta resolution"); 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")); TFile *f3 = new TFile(name3,"READ"); if (f3->IsZombie()) { std::cout << "!!! Error opening file " <Get("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")); for(int isector=0;isector<10;isector++){ TNtuple *nsectors_b = (TNtuple*)f1->Get("nsectors"); TNtuple *nsectors_a = (TNtuple*)f2->Get("nsectors"); TNtuple *nsectors_r = (TNtuple*)f3->Get("nsectors"); // TTree *nsectors_b = (TNtuple*)f1->Get("nsectors"); // TTree *nsectors_a = (TNtuple*)f2->Get("nsectors"); // TTree *nsectors_r = (TNtuple*)f3->Get("nsectors"); 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(); } } // 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 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_Trks[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_Trks[nS]; for(int i=0;iGetXaxis()->SetTitle("Average number of rec. trks per sector"); 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,av_Trks,av_theta_rms_b,avEr_Trks,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,av_Trks,av_theta_rms_a,avEr_Trks,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,av_Trks,av_theta_rms_r,avEr_Trks,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,av_Trks, av_theta_mean_b_sec[isector],avEr_Trks, 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,av_Trks, av_theta_mean_a_sec[isector],avEr_Trks, 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,av_Trks, av_theta_mean_r_sec[isector],avEr_Trks, 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 per sector"); 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,av_Trks,av_theta_rms_b_sec[isector],avEr_Trks,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,av_Trks,av_theta_rms_a_sec[isector],avEr_Trks,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,av_Trks,av_theta_rms_r_sec[isector],avEr_Trks,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 per sector"); 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(); } TGraphErrors *grstat = new TGraphErrors(nS,TrksSim,av_Trks,0,avEr_Trks); grstat->SetMarkerStyle(22); grstat->SetMarkerSize(2.5); grstat->Draw("APL"); // grstat->GetYaxis()->SetTitle("Average number of rec. trks per sector"); grstat->GetXaxis()->SetTitle("Number of sim. trks"); grstat->SetTitle("Average number of rec. trks per sector (used in Knossos)"); c1.Print(resname_pdf_c); //write canvas and close ps file 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(); f->Write(); f->Close(); }