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