// Analysis.C // Skeleton code in C++ provided for you // In place of this comment you should write [your name] -- [the date] and update it as you go! // Make sure to make backups and comment as you go along :) // Header guard to ensure file is imported properly #ifndef Analysis #define Analysis // Include the file that lets the program know about the data #include "backend/CLoop.h" #include #include #include #include void CLoop::Book() { // This function is where you "book" your histograms // It is called once per data set // You will need to do this for each histogram you want to plot // The syntax is: histogram = new TH1F("histogram_name", "Title", number_of_bins, x_min, x_max); // For example, booking a histogram to plot number of leptons per event: h_lep_n = new TH1F("lep_n","Number of leptons",10,-0.5,9.5); int binnumber = 30; // A couple of other basic histograms h_lep_mll = new TH1F("lep_mll","Invariant Mass of Dilepton System",binnumber*2, 0, 200000); h_lep_Z_pseud = new TH1F("lep_Z_pseud","Z Boson Pseudorapidity",binnumber*2,-7,7); h_lep_cos_decang = new TH1F("lep_cos_decang", " Cosine of Decay Angle Distribution", binnumber*2, -1, 1); h_lep_cos_decang_pos = new TH1F("lep_cos_decang_pos", " Cosine of Decay Angle Distribution positive", binnumber, 0, 1); h_lep_cos_decang_neg = new TH1F("lep_cos_decang_neg", " Cosine of Decay Angle Distribution negative", binnumber, 0, 1); top = new TH1F("top", "top",binnumber,0,1); bottom = new TH1F("bottom", "bottom",binnumber,0,1); h_lep_cos_w = new TH1F("lep_cos_w", "Forward-Backward Asymmetry in Angular Distribution", binnumber, 0, 1); flip = new TH1F("flip", "flip", binnumber, 0, 1); empty = new TH1F("empty", "empty", binnumber, 0, 1); } void CLoop::Fill(double weight) { // This function is where you select events and fill your histograms // It is called once PER EVENT. // To fill a histogram you should write: // histogram->Fill(quantity,weight) // For example, filling a histogram with the number of leptons in each event float mll; float Z_pseud; vector pt; vector eta; vector phi; vector ltype; vector etcone20; vector ptcone30; float pzll; float ptll2; float cos_decang; // loop over leptons in the event for (size_t ilep=0; ilepsize(); ilep++) { // This is where you will want to fill histograms with properties of individual leptons // You will need to use quantity->at(ilep) to refer to properties of the lepton // For example, filling a histogram with the type of each lepton // electrons have type = 11, muons have type = 13 pt.push_back(lep_pt->at(ilep)); eta.push_back(lep_eta->at(ilep)); phi.push_back(lep_phi->at(ilep)); ltype.push_back(lep_type->at(ilep)*lep_charge->at(ilep)); etcone20.push_back(lep_etcone20->at(ilep)); ptcone30.push_back(lep_ptcone30->at(ilep)); } // End of loop over leptons float etamin; float etaplus; if (ltype[0] < 0) { etamin = eta[0]; etaplus = eta[1]; } else if(ltype[0] > 0) { etamin = eta[1]; etaplus = eta[0]; } Z_pseud = (etamin+etaplus)/2; pzll = pt[0]*sinh(eta[0]) + pt[1]*sinh(eta[1]); ptll2 = pow(pt[0]*sin(phi[0]) + pt[1]*sin(phi[1]), 2) + pow(pt[0]*cos(phi[0]) + pt[1]*cos(phi[1]), 2); mll = sqrt(2.0*pt[0]*pt[1]*(cosh(eta[0]-eta[1])-cos(phi[0]-phi[1]))); cos_decang = (pzll / (mll * abs(pzll))) * ((2 * pt[0] * pt[1] * sinh(etamin - etaplus)) / (sqrt(pow(mll, 2) + ptll2))); //change below to be ltype[0] == 11 for electron or 13 for muon. selection cuts for etcone in the third and fourth statement. if(ltype[0]==-ltype[1]){ if (abs(ltype[0])==13&&0) { if (abs(etcone20[0])<0.065*pt[0]&&abs(etcone20[1])<0.065*pt[1]&&(pt[0]>17.5e3||pt[1]>17.5e3)&&(ptcone30[0]<2000)&&(ptcone30[1]<2000)&&(abs(Z_pseud)<1.5)&&(abs(Z_pseud)>1)&&(mll>140e3)&&(mll<200e3)) { h_lep_mll -> Fill(mll,weight); h_lep_cos_decang -> Fill(cos_decang, weight); if(cos_decang > 0){ h_lep_cos_decang_pos -> Fill(abs(cos_decang), weight); } if(cos_decang < 0){ h_lep_cos_decang_neg -> Fill(abs(cos_decang), weight); } } } else if(abs(ltype[0])==11&&1) { if((abs(etcone20[0])<0.13*pt[0]&&abs(etcone20[1])<0.13*pt[1])&&(pt[0]>22.5e3&&pt[1]>22.5e3)&&(ptcone30[0]<4000)&&(ptcone30[1]<4000)&&(Z_pseud<1.5)&&(Z_pseud>1)&&(mll>100e3)&&(mll<120e3)) { h_lep_mll -> Fill(mll,weight); h_lep_cos_decang -> Fill(cos_decang, weight); h_lep_Z_pseud -> Fill(Z_pseud, weight); if(cos_decang > 0){ h_lep_cos_decang_pos -> Fill(abs(cos_decang),weight); } if(cos_decang < 0){ h_lep_cos_decang_neg -> Fill(abs(cos_decang),weight); } } } } } void CLoop::Style() { // This function is where you can control the style elements of your histograms and write them to a file // It is called once per data set // DIVIDE HISTOGRAMS bottom->Add(h_lep_cos_decang_pos,h_lep_cos_decang_neg); flip->Add(h_lep_cos_decang_neg,-1); top->Add(h_lep_cos_decang_pos,flip); TH1F *clone = (TH1F*)top->Clone("clone"); top->Divide(bottom); h_lep_cos_w->Add(top); //TH1 * h3 = h_lep_cos_decang_pos->GetAsymmetry(h_lep_cos_decang_neg); //h_lep_cos_w->Add(h3); // For example, set some properties of the lep_n histogram h_lep_mll->GetXaxis()->SetTitle("Mass (MeV)"); h_lep_Z_pseud->GetXaxis()->SetTitle("Pseudorapidity"); h_lep_cos_decang->GetXaxis()->SetTitle("Cos(theta*)"); h_lep_cos_decang_pos->GetXaxis()->SetTitle("Cos(theta*) pos"); h_lep_cos_decang_neg->GetXaxis()->SetTitle("Cos(theta*) neg"); h_lep_cos_w->GetXaxis()->SetTitle("Absolute Cos(theta*)"); bottom->GetXaxis()->SetTitle("bottom"); top->GetXaxis()->SetTitle("top"); clone->GetXaxis()->SetTitle("clone"); // For more information see https://root.cern.ch/root/htmldoc/guides/users-guide/Histograms.html // Write histograms to a file h_lep_mll->Write(); h_lep_Z_pseud->Write(); h_lep_cos_decang->Write(); h_lep_cos_decang_neg->Write(); h_lep_cos_decang_pos->Write(); h_lep_cos_w->Write(); bottom->Write(); top->Write(); clone->Write(); delete h_lep_mll; delete h_lep_Z_pseud; delete h_lep_cos_decang; delete h_lep_cos_decang_neg; delete h_lep_cos_decang_pos; delete h_lep_cos_w; delete bottom; delete top; delete flip; delete empty; delete clone; } #endif // End header guard