[1] | 1 | /* |
---|
| 2 | root |
---|
| 3 | gSystem->Load("libDelphes"); |
---|
| 4 | .X examples/Example1.C("delphes_output.root"); |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | //------------------------------------------------------------------------------ |
---|
| 8 | |
---|
| 9 | void Example1(const char *inputFile) |
---|
| 10 | { |
---|
| 11 | // Create chain of root trees |
---|
| 12 | TChain chain("Delphes"); |
---|
| 13 | chain.Add(inputFile); |
---|
| 14 | |
---|
| 15 | // Create object of class ExRootTreeReader |
---|
| 16 | ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); |
---|
| 17 | Long64_t numberOfEntries = treeReader->GetEntries(); |
---|
| 18 | |
---|
| 19 | // Get pointers to branches used in this analysis |
---|
| 20 | TClonesArray *branchJet = treeReader->UseBranch("Jet"); |
---|
| 21 | TClonesArray *branchElectron = treeReader->UseBranch("Electron"); |
---|
| 22 | |
---|
| 23 | // Book histograms |
---|
| 24 | TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0); |
---|
| 25 | TH1 *histMass = new TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0); |
---|
| 26 | |
---|
| 27 | // Loop over all events |
---|
| 28 | for(Int_t entry = 0; entry < numberOfEntries; ++entry) |
---|
| 29 | { |
---|
| 30 | |
---|
| 31 | // Load selected branches with data from specified event |
---|
| 32 | treeReader->ReadEntry(entry); |
---|
| 33 | |
---|
| 34 | // If event contains at least 1 jet |
---|
| 35 | if(branchJet->GetEntries() > 0) |
---|
| 36 | { |
---|
| 37 | |
---|
| 38 | // Take first jet |
---|
| 39 | Jet *jet = (Jet*) branchJet->At(0); |
---|
| 40 | |
---|
| 41 | // Plot jet transverse momentum |
---|
| 42 | histJetPT->Fill(jet->PT); |
---|
| 43 | |
---|
| 44 | // Print jet transverse momentum |
---|
| 45 | cout << jet->PT << endl; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | Electron *elec1, *elec2; |
---|
| 49 | TLorentzVector vec1, vec2; |
---|
| 50 | |
---|
| 51 | // If event contains at least 2 electrons |
---|
| 52 | if(branchElectron->GetEntries() > 1) |
---|
| 53 | { |
---|
| 54 | |
---|
| 55 | // Take first two electrons |
---|
| 56 | elec1 = (Electron *) branchElectron->At(0); |
---|
| 57 | elec2 = (Electron *) branchElectron->At(1); |
---|
| 58 | |
---|
| 59 | // Create two 4-vectors for the electrons |
---|
| 60 | vec1.SetPtEtaPhiM(elec1->PT, elec1->Eta, elec1->Phi, 0.0); |
---|
| 61 | vec2.SetPtEtaPhiM(elec2->PT, elec2->Eta, elec2->Phi, 0.0); |
---|
| 62 | |
---|
| 63 | // Plot their invariant mass |
---|
| 64 | histMass->Fill((vec1 + vec2).M()); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | // Show resulting histograms |
---|
| 69 | histJetPT->Draw(); |
---|
| 70 | histMass->Draw(); |
---|
| 71 | } |
---|