Fork me on GitHub

Ticket #312: testDelphes.C

File testDelphes.C, 2.3 KB (added by Maximilian Heindl, 10 years ago)

analysis script

Line 
1#include <iostream.h>
2#include <TStopwatch.h>
3#include <TDatime.h>
4#include <TSystem.h>
5
6
7
8
9void testDelphes(const char *inputFile="/home/heindl/Delphes-3.1.2/LQ700NoIso2.root")
10{
11 TStopwatch watch;
12 watch.Start();
13 gSystem->Load("/home/heindl/Delphes-3.1.2/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 *branchMuon = treeReader->UseBranch("Muon");
26
27 //Histogramme erstellen
28 TH1D* HMuonN = new TH1D("HMuonN","Muon Number; Muons; Entries",10, 0, 10);
29 TH1D* HJetN = new TH1D("HJetN","Jet Number; Jets; Entries",20, 0, 20);
30 TH1D* HMuonEta = new TH1D("HMuonEta","MuonEta; Eta; Entries",50, -5, 5);
31
32
33 double muonN;
34 double muonAll=0;
35 double jetN;
36 double jetAll=0;
37
38 // Loop over all events
39 for(Int_t entry = 0; entry < numberOfEntries; ++entry)
40 {
41 // Load selected branches with data from specified event
42 treeReader->ReadEntry(entry);
43
44 muonN=0;
45 jetN=0;
46
47 if (branchMuon->GetEntries()<=1) {std::cout << "Event: " << entry << std::endl;}
48
49
50 for (int i=0;i<branchMuon->GetEntries();i++) {
51
52 Muon *muon = (Muon*) branchMuon->At(i);
53 if (branchMuon->GetEntries()<=1) {std::cout << i+1 << " MuonPT: " << muon->PT << std::endl;}
54 if (muon->PT<=50) continue;
55 HMuonEta->Fill(muon->Eta);
56 if (muon->Eta>2.5) continue;
57
58 muonN++;
59 muonAll++;
60
61 }
62
63
64
65 for (int n=0;n<branchJet->GetEntries();n++) {
66
67 Jet *jet = (Jet*) branchJet->At(n);
68 if (jet->PT<=50) continue;
69 if (jet->Eta>2.5) continue;
70 jetN++;
71 jetAll++;
72
73 }
74
75 HMuonN->Fill(muonN);
76 HJetN->Fill(jetN);
77
78 }
79
80
81 TFile* outF = new TFile("testDelphes.root", "RECREATE"); //File erzeugen
82
83 HJetN->Write();
84 HMuonN->Write();
85 HMuonEta->Write();
86
87 outF->Write();
88 outF->Close();
89
90 std::cout << "Muons: " << muonAll << std::endl;
91 std::cout << "Jets: " << jetAll << std::endl;
92
93 int min=watch.RealTime()/60;
94
95 double sec=watch.RealTime()-60*min;
96
97 std::cout << "The running time was: " << min << " min " << sec << " sec" << std::endl;
98
99}
100
101