#ifndef MCRESULTCOMPARATOR_H #define MCRESULTCOMPARATOR_H #include "TAxis.h" #include "TBranch.h" #include "TCanvas.h" #include "TChain.h" #include "TF1.h" #include "TFile.h" #include "TFitResult.h" #include "TFitResultPtr.h" #include "TGraphErrors.h" #include "TH1.h" #include "TH2.h" #include "TLegend.h" #include "TMath.h" #include "TObject.h" #include "TRatioPlot.h" #include "TROOT.h" #include "TStyle.h" #include "TTree.h" #include #include #include "fstream" #include "iostream" #include "sstream" #include "map" #include "math.h" #include "string" #include "vector" #include // <---<< mkdir() #include // using namespace std; class MCResultComparator { public: MCResultComparator(string InputRootFile, string SInputRootFile, string DecayMode, string SDecayMode); ~MCResultComparator(); virtual void CompareMCResults(); private: virtual void ClearAllVariables(); virtual void ClearAllSVariables(); TFile* InputRootF; TFile* SInputRootF; TTree* InMCTree; TTree* SInMCTree; std::string DecayMode; std::string SDecayMode; std::string InputRootFile; std::string SInputRootFile; std::string DirectoryName; std::string SDirectoryName; TFile* OutputRootF; // First MC Sample // // Input MC Tree Leaves // std::vector *In_TriggerList; std::vector *In_Truth_JPsi_Pt; std::vector *In_Truth_JPsi_Eta; std::vector *In_Truth_JPsi_Phi; std::vector *In_Truth_JPsi_Mass; std::vector *In_Truth_JPsiLepton1_Pt; std::vector *In_Truth_JPsiLepton2_Pt; std::vector *In_Truth_JPsiLepton1_Eta; std::vector *In_Truth_JPsiLepton2_Eta; std::vector *In_Truth_JPsiLepton1_Phi; std::vector *In_Truth_JPsiLepton2_Phi; std::vector *In_Truth_JPsiLepton1_Charge; std::vector *In_Truth_JPsiLepton2_Charge; std::vector *In_Truth_JPsiLepton1_Status; std::vector *In_Truth_JPsiLepton2_Status; std::vector *In_TruthPDG; std::vector *In_TruthPDG_BuDaughters; std::vector *In_TruthPDG_JPsiDaughters; std::vector *In_MudeltaR; std::vector *In_EldeltaR; std::vector *In_deltaPtOverPt_Mu; std::vector *In_deltaPtOverPt_El; // Input MC Tree Branches // TBranch *In_b_TriggerList; TBranch *In_b_Truth_JPsi_Pt; TBranch *In_b_Truth_JPsi_Eta; TBranch *In_b_Truth_JPsi_Phi; TBranch *In_b_Truth_JPsi_Mass; TBranch *In_b_Truth_JPsiLepton1_Pt; TBranch *In_b_Truth_JPsiLepton2_Pt; TBranch *In_b_Truth_JPsiLepton1_Eta; TBranch *In_b_Truth_JPsiLepton2_Eta; TBranch *In_b_Truth_JPsiLepton1_Phi; TBranch *In_b_Truth_JPsiLepton2_Phi; TBranch *In_b_Truth_JPsiLepton1_Charge; TBranch *In_b_Truth_JPsiLepton2_Charge; TBranch *In_b_Truth_JPsiLepton1_Status; TBranch *In_b_Truth_JPsiLepton2_Status; TBranch *In_b_TruthPDG; TBranch *In_b_TruthPDG_BuDaughters; TBranch *In_b_TruthPDG_JPsiDaughters; TBranch *In_b_MudeltaR; TBranch *In_b_EldeltaR; TBranch *In_b_deltaPtOverPt_Mu; TBranch *In_b_deltaPtOverPt_El; // Second MC Sample // // Input MC Tree Leaves // std::vector *SIn_TriggerList; std::vector *SIn_Truth_JPsi_Pt; std::vector *SIn_Truth_JPsi_Eta; std::vector *SIn_Truth_JPsi_Phi; std::vector *SIn_Truth_JPsi_Mass; std::vector *SIn_Truth_JPsiLepton1_Pt; std::vector *SIn_Truth_JPsiLepton2_Pt; std::vector *SIn_Truth_JPsiLepton1_Eta; std::vector *SIn_Truth_JPsiLepton2_Eta; std::vector *SIn_Truth_JPsiLepton1_Phi; std::vector *SIn_Truth_JPsiLepton2_Phi; std::vector *SIn_Truth_JPsiLepton1_Charge; std::vector *SIn_Truth_JPsiLepton2_Charge; std::vector *SIn_Truth_JPsiLepton1_Status; std::vector *SIn_Truth_JPsiLepton2_Status; std::vector *SIn_TruthPDG; std::vector *SIn_TruthPDG_BuDaughters; std::vector *SIn_TruthPDG_JPsiDaughters; std::vector *SIn_MudeltaR; std::vector *SIn_EldeltaR; std::vector *SIn_deltaPtOverPt_Mu; std::vector *SIn_deltaPtOverPt_El; // Input MC Tree Branches // TBranch *SIn_b_TriggerList; TBranch *SIn_b_Truth_JPsi_Pt; TBranch *SIn_b_Truth_JPsi_Eta; TBranch *SIn_b_Truth_JPsi_Phi; TBranch *SIn_b_Truth_JPsi_Mass; TBranch *SIn_b_Truth_JPsiLepton1_Pt; TBranch *SIn_b_Truth_JPsiLepton2_Pt; TBranch *SIn_b_Truth_JPsiLepton1_Eta; TBranch *SIn_b_Truth_JPsiLepton2_Eta; TBranch *SIn_b_Truth_JPsiLepton1_Phi; TBranch *SIn_b_Truth_JPsiLepton2_Phi; TBranch *SIn_b_Truth_JPsiLepton1_Charge; TBranch *SIn_b_Truth_JPsiLepton2_Charge; TBranch *SIn_b_Truth_JPsiLepton1_Status; TBranch *SIn_b_Truth_JPsiLepton2_Status; TBranch *SIn_b_TruthPDG; TBranch *SIn_b_TruthPDG_BuDaughters; TBranch *SIn_b_TruthPDG_JPsiDaughters; TBranch *SIn_b_MudeltaR; TBranch *SIn_b_EldeltaR; TBranch *SIn_b_deltaPtOverPt_Mu; TBranch *SIn_b_deltaPtOverPt_El; }; MCResultComparator::MCResultComparator(string InputRootFile, string SInputRootFile, string DecayMode, string SDecayMode) { MCResultComparator::DecayMode = DecayMode; MCResultComparator::SDecayMode = SDecayMode; MCResultComparator::InputRootFile = InputRootFile; MCResultComparator::SInputRootFile = SInputRootFile; // First MC Sample // // Input File // TFile* InputRootF = new TFile(InputRootFile.c_str(),"READ"); TDirectory* InputDir = (TDirectory*)InputRootF->Get("JPsiAnalyzer"); // Input MC Tree // InMCTree = new TTree("InMCTree", "InMCTree"); InputDir->GetObject("MCTree",InMCTree); InMCTree->SetBranchAddress("TriggerList", &In_TriggerList, &In_b_TriggerList); InMCTree->SetBranchAddress("Truth_JPsi_Pt", &In_Truth_JPsi_Pt, &In_b_Truth_JPsi_Pt); InMCTree->SetBranchAddress("Truth_JPsi_Eta", &In_Truth_JPsi_Eta, &In_b_Truth_JPsi_Eta); InMCTree->SetBranchAddress("Truth_JPsi_Phi", &In_Truth_JPsi_Phi, &In_b_Truth_JPsi_Phi); InMCTree->SetBranchAddress("Truth_JPsi_Mass", &In_Truth_JPsi_Mass, &In_b_Truth_JPsi_Mass); InMCTree->SetBranchAddress("Truth_JPsiLepton1_Pt", &In_Truth_JPsiLepton1_Pt, &In_b_Truth_JPsiLepton1_Pt); InMCTree->SetBranchAddress("Truth_JPsiLepton1_Eta", &In_Truth_JPsiLepton1_Eta, &In_b_Truth_JPsiLepton1_Eta); InMCTree->SetBranchAddress("Truth_JPsiLepton1_Phi", &In_Truth_JPsiLepton1_Phi, &In_b_Truth_JPsiLepton1_Phi); InMCTree->SetBranchAddress("Truth_JPsiLepton1_Charge", &In_Truth_JPsiLepton1_Charge, &In_b_Truth_JPsiLepton1_Charge); InMCTree->SetBranchAddress("Truth_JPsiLepton1_Status", &In_Truth_JPsiLepton1_Status, &In_b_Truth_JPsiLepton1_Status); InMCTree->SetBranchAddress("Truth_JPsiLepton2_Pt", &In_Truth_JPsiLepton2_Pt, &In_b_Truth_JPsiLepton2_Pt); InMCTree->SetBranchAddress("Truth_JPsiLepton2_Eta", &In_Truth_JPsiLepton2_Eta, &In_b_Truth_JPsiLepton2_Eta); InMCTree->SetBranchAddress("Truth_JPsiLepton2_Phi", &In_Truth_JPsiLepton2_Phi, &In_b_Truth_JPsiLepton2_Phi); InMCTree->SetBranchAddress("Truth_JPsiLepton2_Charge", &In_Truth_JPsiLepton2_Charge, &In_b_Truth_JPsiLepton2_Charge); InMCTree->SetBranchAddress("Truth_JPsiLepton2_Status", &In_Truth_JPsiLepton2_Status, &In_b_Truth_JPsiLepton2_Status); InMCTree->SetBranchAddress("TruthPDG", &In_TruthPDG, &In_b_TruthPDG); InMCTree->SetBranchAddress("TruthPDG_BuDaughters", &In_TruthPDG_BuDaughters, &In_b_TruthPDG_BuDaughters); InMCTree->SetBranchAddress("TruthPDG_JPsiDaughters", &In_TruthPDG_JPsiDaughters, &In_b_TruthPDG_JPsiDaughters); InMCTree->SetBranchAddress("MudeltaR", &In_MudeltaR, &In_b_MudeltaR); InMCTree->SetBranchAddress("EldeltaR", &In_EldeltaR, &In_b_EldeltaR); InMCTree->SetBranchAddress("deltaPtOverPt_Mu", &In_deltaPtOverPt_Mu, &In_b_deltaPtOverPt_Mu); InMCTree->SetBranchAddress("deltaPtOverPt_El", &In_deltaPtOverPt_El, &In_b_deltaPtOverPt_El); // Second MC Sample // // Input File // TFile* SInputRootF = new TFile(SInputRootFile.c_str(),"READ"); TDirectory* SInputDir = (TDirectory*)SInputRootF->Get("JPsiAnalyzer"); // Input MC Tree // SInMCTree = new TTree("SInMCTree", "SInMCTree"); SInputDir->GetObject("MCTree",SInMCTree); SInMCTree->SetBranchAddress("TriggerList", &SIn_TriggerList, &SIn_b_TriggerList); SInMCTree->SetBranchAddress("Truth_JPsi_Pt", &SIn_Truth_JPsi_Pt, &SIn_b_Truth_JPsi_Pt); SInMCTree->SetBranchAddress("Truth_JPsi_Eta", &SIn_Truth_JPsi_Eta, &SIn_b_Truth_JPsi_Eta); SInMCTree->SetBranchAddress("Truth_JPsi_Phi", &SIn_Truth_JPsi_Phi, &SIn_b_Truth_JPsi_Phi); SInMCTree->SetBranchAddress("Truth_JPsi_Mass", &SIn_Truth_JPsi_Mass, &SIn_b_Truth_JPsi_Mass); SInMCTree->SetBranchAddress("Truth_JPsiLepton1_Pt", &SIn_Truth_JPsiLepton1_Pt, &SIn_b_Truth_JPsiLepton1_Pt); SInMCTree->SetBranchAddress("Truth_JPsiLepton1_Eta", &SIn_Truth_JPsiLepton1_Eta, &SIn_b_Truth_JPsiLepton1_Eta); SInMCTree->SetBranchAddress("Truth_JPsiLepton1_Phi", &SIn_Truth_JPsiLepton1_Phi, &SIn_b_Truth_JPsiLepton1_Phi); SInMCTree->SetBranchAddress("Truth_JPsiLepton1_Charge", &SIn_Truth_JPsiLepton1_Charge, &SIn_b_Truth_JPsiLepton1_Charge); SInMCTree->SetBranchAddress("Truth_JPsiLepton1_Status", &SIn_Truth_JPsiLepton1_Status, &SIn_b_Truth_JPsiLepton1_Status); SInMCTree->SetBranchAddress("Truth_JPsiLepton2_Pt", &SIn_Truth_JPsiLepton2_Pt, &SIn_b_Truth_JPsiLepton2_Pt); SInMCTree->SetBranchAddress("Truth_JPsiLepton2_Eta", &SIn_Truth_JPsiLepton2_Eta, &SIn_b_Truth_JPsiLepton2_Eta); SInMCTree->SetBranchAddress("Truth_JPsiLepton2_Phi", &SIn_Truth_JPsiLepton2_Phi, &SIn_b_Truth_JPsiLepton2_Phi); SInMCTree->SetBranchAddress("Truth_JPsiLepton2_Charge", &SIn_Truth_JPsiLepton2_Charge, &SIn_b_Truth_JPsiLepton2_Charge); SInMCTree->SetBranchAddress("Truth_JPsiLepton2_Status", &SIn_Truth_JPsiLepton2_Status, &SIn_b_Truth_JPsiLepton2_Status); SInMCTree->SetBranchAddress("TruthPDG", &SIn_TruthPDG, &SIn_b_TruthPDG); SInMCTree->SetBranchAddress("TruthPDG_BuDaughters", &SIn_TruthPDG_BuDaughters, &SIn_b_TruthPDG_BuDaughters); SInMCTree->SetBranchAddress("TruthPDG_JPsiDaughters", &SIn_TruthPDG_JPsiDaughters, &SIn_b_TruthPDG_JPsiDaughters); SInMCTree->SetBranchAddress("MudeltaR", &SIn_MudeltaR, &SIn_b_MudeltaR); SInMCTree->SetBranchAddress("EldeltaR", &SIn_EldeltaR, &SIn_b_EldeltaR); SInMCTree->SetBranchAddress("deltaPtOverPt_Mu", &SIn_deltaPtOverPt_Mu, &SIn_b_deltaPtOverPt_Mu); SInMCTree->SetBranchAddress("deltaPtOverPt_El", &SIn_deltaPtOverPt_El, &SIn_b_deltaPtOverPt_El); } MCResultComparator::~MCResultComparator() { if (!InMCTree || !SInMCTree) return; } void MCResultComparator::ClearAllVariables() { // First MC Sample // In_TriggerList->clear(); In_Truth_JPsi_Pt->clear(); In_Truth_JPsi_Eta->clear(); In_Truth_JPsi_Phi->clear(); In_Truth_JPsi_Mass->clear(); In_Truth_JPsiLepton1_Pt->clear(); In_Truth_JPsiLepton2_Pt->clear(); In_Truth_JPsiLepton1_Eta->clear(); In_Truth_JPsiLepton2_Eta->clear(); In_Truth_JPsiLepton1_Phi->clear(); In_Truth_JPsiLepton2_Phi->clear(); In_Truth_JPsiLepton1_Charge->clear(); In_Truth_JPsiLepton2_Charge->clear(); In_Truth_JPsiLepton1_Status->clear(); In_Truth_JPsiLepton2_Status->clear(); In_TruthPDG->clear(); In_TruthPDG_BuDaughters->clear(); In_TruthPDG_JPsiDaughters->clear(); In_MudeltaR->clear(); In_EldeltaR->clear(); In_deltaPtOverPt_Mu->clear(); In_deltaPtOverPt_El->clear(); } void MCResultComparator::ClearAllSVariables() { // Second MC Sample // SIn_TriggerList->clear(); SIn_Truth_JPsi_Pt->clear(); SIn_Truth_JPsi_Eta->clear(); SIn_Truth_JPsi_Phi->clear(); SIn_Truth_JPsi_Mass->clear(); SIn_Truth_JPsiLepton1_Pt->clear(); SIn_Truth_JPsiLepton2_Pt->clear(); SIn_Truth_JPsiLepton1_Eta->clear(); SIn_Truth_JPsiLepton2_Eta->clear(); SIn_Truth_JPsiLepton1_Phi->clear(); SIn_Truth_JPsiLepton2_Phi->clear(); SIn_Truth_JPsiLepton1_Charge->clear(); SIn_Truth_JPsiLepton2_Charge->clear(); SIn_Truth_JPsiLepton1_Status->clear(); SIn_Truth_JPsiLepton2_Status->clear(); SIn_TruthPDG->clear(); SIn_TruthPDG_BuDaughters->clear(); SIn_TruthPDG_JPsiDaughters->clear(); SIn_MudeltaR->clear(); SIn_EldeltaR->clear(); SIn_deltaPtOverPt_Mu->clear(); SIn_deltaPtOverPt_El->clear(); } #endif