//Program to read CERN data from trees and make hists. (So far) # include # include # include # include # include # include # include //# include # include # include //# include //For Sleep() # include "TROOT.h" # include "TFile.h" # include "TTree.h" # include "TBrowser.h" # include "TH1.h" # include "TH2.h" # include "TH3.h" # include "TRandom.h" # include using namespace std; int main(){ /////Controls///// //int NEntries = 469384; //469384 for data.root. Click on tree and read hist to find these. char rootFilePrefix[50] = ""; //Prefix to root file, this is the path to it - all the way up until its name. char rootFileName[50] = "mhance.root"; //The root file name itself - this is where the tree is. char TreeName[50] = "OutputTree;34"; double xMin = -400; double xMax = 400; // double yMin = 0; // double yMax = 10000; // double zMin = 0; // double zMax = 10000; const int NChannels = 100; //Number of channels for root hist bool OutputToFile = false; /////////////////////////////////////// /////Varibles (Pre-stated)///// char rootFilePath[100]; int flavLep[3]; int nLeps35; float pTLep[3], etaLep[3], phiLep[3]; ofstream outFile1; TH1F *histpTLep = new TH1F("histpTLep", "pTLep hist", NChannels, xMin, xMax); TH1F *histetaLep = new TH1F("histetaLep", "etaLep hist", NChannels, xMin, xMax); TH1F *histphiLep = new TH1F("histphiLep", "phiLep hist", NChannels, xMin, xMax); TH1F *histpTLepPos = new TH1F("histpTLepPos", "pTLepPos hist", NChannels, xMin, xMax); TH1F *histetaLepPos = new TH1F("histetaLepPos", "etaLepPos hist", NChannels, xMin, xMax); TH1F *histphiLepPos = new TH1F("histphiLepPos", "phiLepPos hist", NChannels, xMin, xMax); TH1F *histpTLepNeg = new TH1F("histpTLepNeg", "pTLepNeg hist", NChannels, xMin, xMax); TH1F *histetaLepNeg = new TH1F("histetaLepNeg", "etaLepNeg hist", NChannels, xMin, xMax); TH1F *histphiLepNeg = new TH1F("histphiLepNeg", "phiLepNeg hist", NChannels, xMin, xMax); TH1F *histnLep = new TH1F("histnLep", "nLep hist", 10, -5, 5); TLorentzVector pos_muon; TLorentzVector neg_muon; TLorentzVector tot_muon; ////////////////////////////////////// //Creating path to root file and getting tree// strcpy(rootFilePath, rootFilePrefix); strcat(rootFilePath, rootFileName); cout<<"Root file path: "<Get(TreeName); t1->SetBranchAddress("pTLep",&pTLep[0]); t1->SetBranchAddress("etaLep",&etaLep[0]); t1->SetBranchAddress("phiLep",&phiLep[0]); t1->SetBranchAddress("flavLep",&flavLep[0]); t1->SetBranchAddress("nLeps35",nLeps35); int NEntries = t1->GetEntries(); cout<<"NEntries: "<GetEntry(i); cout<<"i: "<GetEvent(j); if(flavLep[i] == 2){ pos_muon.SetPtEtaPhiM(pTLep[i],etaLep[i],phiLep[i],0.105); histpTLep->Fill(pTLep); histetaLep->Fill(etaLep); histphiLep->Fill(phiLep); histpTLepPos->Fill(pTLep); histetaLepPos->Fill(etaLep); histphiLepPos->Fill(phiLep); } if(flavLep[i] == -2){ neg_muon.SetPtEtaPhiM(pTLep[i],etaLep[i],phiLep[i],0.105); histpTLep->Fill(pTLep); histetaLep->Fill(etaLep); histphiLep->Fill(phiLep); histpTLepNeg->Fill(pTLep); histetaLepNeg->Fill(etaLep); histphiLepNeg->Fill(phiLep); } //cout<<"i: "<Fill(nLeps35); } } //////Graphics////// cout<<"Making histrograms..."<SetFillColor(10); c1->SetGrid(); c1->GetFrame()->SetFillColor(10); c1->GetFrame()->SetBorderSize(12); c1->Range(0,0,1,1); gStyle->SetOptStat(1); c1->cd(); histpTLep->SetXTitle("pTLep"); histpTLep->SetYTitle("Counts"); histpTLep->SetStats(1); histpTLep->Draw(); TCanvas *c2 = new TCanvas("c2","etaLep Histrogram" ,200,10,900,700); c2->SetFillColor(10); c2->SetGrid(); c2->GetFrame()->SetFillColor(10); c2->GetFrame()->SetBorderSize(12); c2->Range(0,0,1,1); gStyle->SetOptStat(1); c2->cd(); histetaLep->SetXTitle("etaLep"); histetaLep->SetYTitle("Counts"); histetaLep->SetStats(1); histetaLep->Draw(); TCanvas *c3 = new TCanvas("c3","phiLep Histrogram" ,200,10,900,700); c3->SetFillColor(10); c3->SetGrid(); c3->GetFrame()->SetFillColor(10); c3->GetFrame()->SetBorderSize(12); c3->Range(0,0,1,1); gStyle->SetOptStat(1); c3->cd(); histphiLep->SetXTitle("phiLep"); histphiLep->SetYTitle("Counts"); histphiLep->SetStats(1); histphiLep->Draw(); // TCanvas *c4 = new TCanvas("c1","pTLep Histrogram" ,200,10,900,700); // c4->SetFillColor(10); // c4->SetGrid(); // c4->GetFrame()->SetFillColor(10); // c4->GetFrame()->SetBorderSize(12); // c4->Range(0,0,1,1); // gStyle->SetOptStat(1); // c1->cd(); // histpTLep->SetXTitle("pTLep"); // histpTLep->SetYTitle("Counts"); // histpTLep->SetStats(1); // histpTLep->Draw(); // TCanvas *c2 = new TCanvas("c2","etaLep Histrogram" ,200,10,900,700); // c2->SetFillColor(10); // c2->SetGrid(); // c2->GetFrame()->SetFillColor(10); // c2->GetFrame()->SetBorderSize(12); // c2->Range(0,0,1,1); // gStyle->SetOptStat(1); // c2->cd(); // histetaLep->SetXTitle("etaLep"); // histetaLep->SetYTitle("Counts"); // histetaLep->SetStats(1); // histetaLep->Draw(); // TCanvas *c3 = new TCanvas("c3","phiLep Histrogram" ,200,10,900,700); // c3->SetFillColor(10); // c3->SetGrid(); // c3->GetFrame()->SetFillColor(10); // c3->GetFrame()->SetBorderSize(12); // c3->Range(0,0,1,1); // gStyle->SetOptStat(1); // c3->cd(); // histphiLep->SetXTitle("phiLep"); // histphiLep->SetYTitle("Counts"); // histphiLep->SetStats(1); // histphiLep->Draw(); // TCanvas *c7 = new TCanvas("c7","nLep Histrogram" ,100,5,400,300); // c7->SetFillColor(10); // c7->SetGrid(); // c7->GetFrame()->SetFillColor(10); // c7->GetFrame()->SetBorderSize(12); // c7->Range(0,0,1,1); // gStyle->SetOptStat(1); // c7->cd(); // histnLep->SetXTitle("nLep"); // histnLep->SetYTitle("Counts"); // histnLep->SetStats(1); // histnLep->Draw(); return 0; }