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