#include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TH1F.h" #include using namespace std; void readEvents(){ //TASK 1************************************************************* //Load the file //Get the tree(called POOLCollectionTree) from the file //Get entries of the file //Here, YOU print the number of entries the file found //TASK 2************************************************************** // create local variables for the tree's branches // We need Float_t type for LooseMuonsPhi1, LooseMuonsPt1, LooseMuonsEta2, LooseMuonsPhi2,LooseMuonsPt2 UInt_t NLooseMuons; Float_t LooseMuonsEta1; Float_t LooseMuonsPhi1; Float_t LooseMuonsPt1; //Here YOU define a Float_t for LooseMuon objects //Task 3************************************************************** // set the tree's braches to the local variables tree->SetBranchAddress("NLooseMuon", &NLooseMuons); tree->SetBranchAddress("LooseMuonEta1", &LooseMuonsEta1); tree->SetBranchAddress("LooseMuonPhi1", &LooseMuonsPhi1); tree->SetBranchAddress("LooseMuonPt1", &LooseMuonsPt1); //Here YOU set a tree's branch to LooseMuonPt, Eta, Phi //Task 4************************************************************** //declare some histograms //declare a histogram called muPt, with 50 bins, and range from 0 to 200 TH1F *muPt = new TH1F("muPt", ";p_{T} [GeV/c];Events", 50, 0, 200); //declare a histogram called muEta, with 50 bins and range -3 to 3 TH1F *muEta = new TH1F("muEta", ";#eta;Events", 50, -3, 3); //declare a histogram called muPhi with 50 bins and range from -4 to 4 TH1F *muPhi = new TH1F("muPhi", ";#phi;Events", 50, -4, 4); //declare a histogram called muE with 50 bins and range from 0 to 200 TH1F *muE = new TH1F("muE", ";Energy;Events", 50, 0, 200); // Here, YOUdeclare a histogram called Zmass with 50 bins and range from 0 to 200 // Here, YOU declare a histogram called ZmassBkg with 50 bins and range from 0 to 200 // loop over each entry (event) in the tree for( int entry=0; entry<10000; entry++ ){ //Task A************************************************************** // check that the event is read properly //Task B************************************************************** // only look at events containing at least 2 leptons // require the leptons to be greater than 20 GeV //here YOU require LooseMuonsPt2 > 20 GeV // make a LorentzVector from the muon //here YOU define a LorentzVector for Muons2 // print out the details of an electron every so often //Task C*********************************************************** // fill our histograms //Here, YOU define the Z boson vector as a sum of the 2 muon vectors //Fill the Zmass and ZmassBkg histograms }//THIS IS THE END OF OUR ENTRIES LOOP //Task 5 // Here, YOU draw the Zmass distribution // make a ROOT output file to store your histograms TFile *outFile = new TFile("histograms.root", "recreate"); muPt->Write(); muEta->Write(); muPhi->Write(); muE->Write(); //Here, YOU write the Zmass and ZmassBkg histogram }// END OF readEventsLoop