#include #include #include #include #include #include #include #include #include void correlation() { // Create a file TFile outf("new_output_new.root","RECREATE"); std::cout << "creating output ..." <SetOptStat(0); gStyle->SetOptTitle(0); // Create new histograms TH2D* h_top_pt = new TH2D("top_pt",";Reconstructed p_{T}(top);Truth p_{T}(top) ",4,0.,600.,4, 0., 600.); TH2D* h_top_eta = new TH2D("top_eta",";Reconstructed #eta(top);Truth #eta(top) ",4,0.,5.,4, 0., 5.); //Get the old files and trees TFile *reco_file= new TFile("/RootFiles/test_files/input_selection/reco.root","READ"); TFile *truth_file= new TFile("/RootFiles/test_files/input_selection/truth.root","READ"); TTree *reco= (TTree*)reco_file->Get("Loop_reco"); TTree *truth= (TTree*)truth_file->Get("Loop_truth"); // Declaring the type of vaiables of the branches float reco_eventnumber, reco_runnumber, reco_t_pt, reco_t_eta; float truth_eventnumber, truth_runnumber, truth_t_pt, truth_t_eta; Long64_t nentries, nentries1, nentries2; // List ofthe branches in the reco tree reco->SetBranchAddress("reco_eventnumber",&reco_eventnumber); reco->SetBranchAddress("reco_runnumber",&reco_runnumber); reco->SetBranchAddress("reco_t_pt",&reco_t_pt); reco->SetBranchAddress("reco_t_eta",&reco_t_eta); // List ofthe branches in the truth tree truth->SetBranchAddress("truth_eventnumber",&truth_runnumber); truth->SetBranchAddress("truth_runnumber",&truth_runnumber); truth->SetBranchAddress("truth_t_pt",&truth_t_pt); truth->SetBranchAddress("truth_t_eta",&truth_t_eta); nentries1= reco->GetEntries(); nentries2= truth->GetEntries(); nentries= nentries1; // Running over the entries of the branches for (int i=0; iGetEntry(i); reco->GetEntry(i); h_top_pt->Fill(reco_t_pt,reco_t_pt); h_top_eta->Fill(reco_t_eta, truth_t_eta); } // correlation float cor = h_top_pt->GetCorrelationFactor(); std::cout<<"The correlation is: "<