%jsroot on #include #include #include TChain *dataset = new TChain("mini"); //dataset->Add("mc_105986.ZZ.root"); //dataset->Add("mc_147770.Zee.root"); //This input is readed directly from the Internet. If you are ofline, you can use the line above dataset->Add("http://opendata.atlas.cern/release/samples/MC/mc_147770.Zee.root"); const int vs = 5; Int_t lepton_n = -1, lepton_charge[vs], lepton_type[vs]; Float_t lepton_pt[vs], lepton_eta[vs], lepton_phi[vs]; dataset->SetBranchAddress("lep_n", &lepton_n); dataset->SetBranchAddress("lep_charge", &lepton_charge); dataset->SetBranchAddress("lep_type", &lepton_type); dataset->SetBranchAddress("lep_pt", &lepton_pt); dataset->SetBranchAddress("lep_eta", &lepton_eta); dataset->SetBranchAddress("lep_phi", &lepton_phi); TH1F *h_lep_pt_leptons = new TH1F("h_lep_pt_leptons","Lepton pt in GeV",20,0,200); h_lep_pt_leptons->SetFillColor(kRed); int nentries, nbytes, i; nentries = (Int_t)dataset->GetEntries(); // IMPORTANT: fraction events we want to run fraction_events = 1; events_to_run = nentries*fraction_events; std::cout << "Total # events = " << nentries << ". Events to run = " << events_to_run << " corresponding to " << fraction_events*100 << "% of total events!" << std::endl; for (i=0; iGetEntry(i); if(lepton_n>1) // Number of leptons in the events has to be at least 2 { if(lepton_type[0] == lepton_type[1]) //Leptons of the same family, i.e. 2 electrons or 2 muons (those are the two most energetic leptons) { if(lepton_charge[0] != lepton_charge[1]) // The two selected leptons must have opposite charge { //PT float lepton_pt_inGeV = lepton_pt[0]/1000.; // The default value in the root file is in MeV, so, we divide by 1000 to get it in GeV h_lep_pt_leptons->Fill(lepton_pt_inGeV); } } } } TCanvas *cz = new TCanvas("cz","cz",10,10,700,700); h_lep_pt_leptons->Draw(); cz->Draw();