1 #include <iostream> // Standardstream-Funktionaliät einbinden
\r#include <fstream> // ofstream und ifstream einbinden
\r#include <vector>
\rusing namespace std;
\r\rextern TRandom *gRandom;
\rextern TBenchmark *gBenchmark;
\rextern TSystem *gSystem;
\r\r\rvoid Plot_IntegratedPi0Yield(const char *input = "RB-data-AnalysisResults", const char *path = "./", const char *suffix = "gif"){
\r \r gROOT->Reset();
\r gROOT->SetStyle("Plain");
\r gStyle->SetOptStat(0);
\r \r // Which file you want to analyse
\r //Char_t filename_input1[100] = (Form("%s%s",path,input1));
\r\r cout<<"Path is :"<<path<<endl;
\r\r TString fileName = Form("%s%s.dat",path,input);
\r\r vector<TString> inputVector;
\r vector<TString> cutVector;
\r vector<Double_t> nGoodEvents;
\r vector<Double_t> Reco;
\r vector<Double_t> Reco_error;
\r vector<Double_t> Background;
\r vector<Double_t> Background_error;
\r vector<Double_t> Mass;
\r vector<Double_t> Mass_error;
\r vector<Double_t> FWHM;
\r vector<Double_t> FWHM_error;
\r vector<Double_t> nPi0_MC;
\r vector<Double_t> nPi0_MC_error;
\r \r ifstream in;
\r in.open(fileName.Data(),ios_base::in);
\r cout<<"Open the file: "<<fileName.Data()<<endl;
\r \r while(!in.eof()){
\r string tmpStr;
\r Double_t tmpDouble;
\r\r in >> tmpStr;
\r inputVector.push_back(tmpStr);
\r in >> tmpStr;
\r cutVector.push_back(tmpStr);
\r in >> tmpDouble;
\r nGoodEvents.push_back(tmpDouble);
\r in >> tmpDouble;
\r Reco.push_back(tmpDouble);
\r in >> tmpDouble;
\r Reco_error.push_back(tmpDouble);
\r in >> tmpDouble;
\r Background.push_back(tmpDouble);
\r in >> tmpDouble;
\r Background_error.push_back(tmpDouble);
\r in >> tmpDouble;
\r Mass.push_back(tmpDouble);
\r in >> tmpDouble;
\r Mass_error.push_back(tmpDouble);
\r in >> tmpDouble;
\r FWHM.push_back(tmpDouble);
\r in >> tmpDouble;
\r FWHM_error.push_back(tmpDouble);
\r in >> tmpDouble;
\r nPi0_MC.push_back(tmpDouble);
\r in >> tmpDouble;
\r nPi0_MC_error.push_back(tmpDouble);
\r }
\r in.close();
\r \r cout<<"The values are read"<<endl;
\r\r TH1F *histYield = new TH1F("Yield","",10,0.,10.);
\r TH1F *histSignificance = new TH1F("Significance","",10,0.,10.);
\r TH1F *histMass = new TH1F("Mass","",10,0.,10.);
\r TH1F *histFWHM = new TH1F("FWHM","",10,0.,10.);
\r\r if(nPi0_MC != 0){
\r TH1F *histEff = new TH1F("histEff","",10,0.,10.);
\r }
\r \r \r for(Int_t i = 1; i < inputVector.size(); i++){
\r \r if(nGoodEvents[i-1] == 0){
\r cout<<"Warning: nGoodEvents["<<i-1<<"]=0"<<endl;
\r }
\r else{
\r Double_t Yield = (Reco[i-1]-Background[i-1])/nGoodEvents[i-1];
\r Double_t Yield_error = sqrt(Reco_error[i-1]*Reco_error[i-1] + Background_error[i-1]*Background_error[i-1])/nGoodEvents[i-1];
\r histYield->SetBinContent(i,Yield);
\r histYield->SetBinError(i,Yield_error);
\r histYield->GetXaxis()->SetBinLabel(i,cutVector[i-1].Data());
\r \r histMass->SetBinContent(i,Mass[i-1]);
\r histMass->SetBinError(i,Mass_error[i-1]);
\r histMass->GetXaxis()->SetBinLabel(i,cutVector[i-1].Data());
\r \r histFWHM->SetBinContent(i,FWHM[i-1]/2.36);
\r histFWHM->SetBinError(i,FWHM_error[i-1]/2.36);
\r histFWHM->GetXaxis()->SetBinLabel(i,cutVector[i-1].Data());
\r }
\r\r if(Background[i-1]==0){
\r cout<<"Warning: Background["<<i-1<<"]=0"<<endl;
\r }
\r else{
\r cout<<"BG good"<<endl;
\r Double_t Sign = Reco[i-1]/sqrt(Background[i-1]);
\r Double_t Sign_error = sqrt( pow(Reco_error[i-1]/sqrt(Background[i-1]),2) + pow( -0.5 * Reco[i-1]/pow(Background[i-1],1.5) * Background_error[i-1],2) );
\r histSignificance->SetBinContent(i,Sign);
\r histSignificance->SetBinError(i,Sign_error);
\r histSignificance->GetXaxis()->SetBinLabel(i,cutVector[i-1].Data());
\r }
\r if(nPi0_MC[i-1] == 0){
\r cout<<"Warning: nPi0_MC["<<i-1<<"]=0"<<endl;
\r }
\r else{
\r Double_t Eff = Reco[i-1]/nPi0_MC[i-1];
\r Double_t Eff_error = sqrt( pow(Reco_error[i-1]/nPi0_MC[i-1],2) + pow(Reco[i-1]/nPi0_MC[i-1]/nPi0_MC[i-1]*nPi0_MC_error[i-1],2) );
\r histEff->SetBinContent(i,Eff);
\r histEff->SetBinError(i,Eff_error);
\r histEff->GetXaxis()->SetBinLabel(i,cutVector[i-1].Data());
\r }
\r }
\r \r cout<<"Loop finished"<<endl;
\r\r //Create summary histograms and write them to file
\r\r // Yield
\r c_Yield = new TCanvas("c_Yield","",1000,600); // gives the page size
\r c_Yield->SetTickx();
\r c_Yield->SetTicky();
\r c_Yield->SetGridx();
\r c_Yield->SetGridy();
\r c_Yield->SetFillColor(0);
\r c_Yield->SetBottomMargin(0.2);
\r histYield->SetTitle(Form("%s",input));
\r histYield->SetYTitle("Int. Yield");
\r histYield->GetYaxis()->SetRangeUser(1e-7,1e-3);
\r histYield->SetMarkerStyle(20);
\r histYield->SetMarkerColor(4);
\r histYield->GetYaxis()->SetTitleOffset(1.3);
\r histYield->GetXaxis()->LabelsOption("v");
\r histYield->GetXaxis()->SetLabelSize(0.05);
\r histYield->DrawCopy("E,p");
\r c_Yield->Print(Form("%sPi0Yield_%s.%s",path,input,suffix));
\r c_Yield->Update();
\r \r // Sign
\r c_Sign = new TCanvas("c_Sign","",1000,600); // gives the page size
\r c_Sign->SetTickx();
\r c_Sign->SetTicky();
\r c_Sign->SetGridx();
\r c_Sign->SetGridy();
\r c_Sign->SetFillColor(0);
\r c_Sign->SetBottomMargin(0.2);
\r histSignificance->SetTitle(Form("%s",input));
\r histSignificance->SetYTitle("Significance");
\r //histSignificance->GetYaxis()->SetDecimals();
\r histSignificance->SetMarkerStyle(20);
\r histSignificance->SetMarkerColor(4);
\r histSignificance->GetYaxis()->SetTitleOffset(1.3);
\r histSignificance->GetXaxis()->LabelsOption("v");
\r histSignificance->GetXaxis()->SetLabelSize(0.05);
\r histSignificance->DrawCopy("E,p");
\r c_Sign->Print(Form("%sPi0Significance_%s.%s",path,input,suffix));
\r c_Sign->Update();
\r \r \r // Mass
\r c_Mass = new TCanvas("c_Mass","",1000,600); // gives the page size
\r c_Mass->SetTickx();
\r c_Mass->SetTicky();
\r c_Mass->SetGridx();
\r c_Mass->SetGridy();
\r c_Mass->SetFillColor(0);
\r c_Mass->SetBottomMargin(0.2);
\r histMass->SetTitle(Form("%s",input));
\r histMass->SetYTitle("Mass");
\r histMass->GetYaxis()->SetRangeUser(0.133,0.136);
\r histMass->SetMarkerStyle(20);
\r histMass->SetMarkerColor(4);
\r histMass->GetYaxis()->SetTitleOffset(1.3);
\r histMass->GetXaxis()->LabelsOption("v");
\r histMass->GetXaxis()->SetLabelSize(0.05);
\r histMass->DrawCopy("E,p");
\r c_Mass->Print(Form("%sPi0Mass_%s.%s",path,input,suffix));
\r c_Mass->Update();
\r \r \r // FWHM
\r c_FWHM = new TCanvas("c_FWHM","",1000,600); // gives the page size
\r c_FWHM->SetTickx();
\r c_FWHM->SetTicky();
\r c_FWHM->SetGridx();
\r c_FWHM->SetGridy();
\r c_FWHM->SetFillColor(0);
\r c_FWHM->SetBottomMargin(0.2);
\r histFWHM->SetTitle(Form("%s",input));
\r histFWHM->SetYTitle("FWHM");
\r histFWHM->GetYaxis()->SetRangeUser(0.,0.01);
\r histFWHM->SetMarkerStyle(20);
\r histFWHM->SetMarkerColor(4);
\r histFWHM->GetYaxis()->SetTitleOffset(1.3);
\r histFWHM->GetXaxis()->LabelsOption("v");
\r histFWHM->GetXaxis()->SetLabelSize(0.05);
\r histFWHM->DrawCopy("E,p");
\r c_FWHM->Print(Form("%sPi0FWHM_%s.%s",path,input,suffix));
\r c_FWHM->Update();
\r \r \r // Eff
\r if(nPi0_MC != 0){
\r c_Eff = new TCanvas("c_Eff","",1000,600); // gives the page size
\r c_Eff->SetTickx();
\r c_Eff->SetTicky();
\r c_Eff->SetGridx();
\r c_Eff->SetGridy();
\r c_Eff->SetFillColor(0);
\r c_Eff->SetBottomMargin(0.2);
\r histEff->SetTitle(Form("%s",input));
\r histEff->SetYTitle("Reconstr. Eff.");
\r //histEff->GetYaxis()->SetDecimals();
\r histEff->SetMarkerStyle(20);
\r histEff->SetMarkerColor(4);
\r histEff->GetYaxis()->SetTitleOffset(1.3);
\r histEff->GetXaxis()->LabelsOption("v");
\r histEff->GetXaxis()->SetLabelSize(0.05);
\r histEff->DrawCopy("E,p");
\r c_Eff->Print(Form("%sPi0Eff_%s.%s",path,input,suffix));
\r c_Eff->Update();
\r }
\r}
\r