21 <<
"Wrong number of arguments! Please specify:" << std::endl
22 <<
" * filepath" << std::endl
23 <<
" * process name" << std::endl;
29 gSystem->Load(
"libFWCoreFWLite");
36 TH1I* noMuons =
new TH1I(
"noMuons",
"N(Muon)", 10, 0, 10);
37 TH1I* noLepts =
new TH1I(
"noLepts",
"N(Lepton)", 10, 0, 10);
38 TH1F*
ptMuons =
new TH1F(
"ptMuons",
"pt_{Muons}", 100, 0., 300.);
39 TH1F* enMuons =
new TH1F(
"enMuons",
"energy_{Muons}", 100, 0., 300.);
40 TH1F*
etaMuons =
new TH1F(
"etaMuons",
"eta_{Muons}", 100, -3., 3.);
41 TH1F* phiMuons =
new TH1F(
"phiMuons",
"phi_{Muons}", 100, -5., 5.);
44 std::cout <<
"open file: " << argv[1] << std::endl;
46 TFile* inFile = TFile::Open(argv[1]);
47 TTree* events_ =
nullptr;
49 inFile->GetObject(
"Events", events_);
50 if (events_ ==
nullptr) {
53 <<
"Unable to retrieve TTree Events!" << std::endl
54 <<
" Eighter wrong file name or the the tree doesn't exists" << std::endl;
61 sprintf(muonName,
"patMuons_selectedPatMuons__%s.obj", argv[2]);
62 TBranch* muons_ = events_->GetBranch(muonName);
63 assert(muons_ !=
nullptr);
65 sprintf(elecName,
"patElectrons_selectedPatElectrons__%s.obj", argv[2]);
66 TBranch* elecs_ = events_->GetBranch(elecName);
67 assert(elecs_ !=
nullptr);
70 std::vector<pat::Muon>
muons;
71 std::vector<pat::Electron>
elecs;
72 int nevt = events_->GetEntries();
75 std::cout <<
"start looping " << nevt <<
" events..." << std::endl;
77 for (
int evt = 0; evt <
nevt; ++evt) {
79 muons_->SetAddress(&muons);
80 elecs_->SetAddress(&elecs);
82 muons_->GetEntry(evt);
83 elecs_->GetEntry(evt);
84 events_->GetEntry(evt, 0);
87 if (evt > 0 && !(evt % 10))
88 std::cout <<
" processing event: " << evt << std::endl;
92 noMuons->Fill(muons.size());
93 noLepts->Fill(muons.size() + elecs.size());
94 for (
unsigned idx = 0;
idx < muons.size(); ++
idx) {
96 ptMuons->Fill(muons[
idx].
pt());
98 etaMuons->Fill(muons[
idx].
eta());
99 phiMuons->Fill(muons[
idx].
phi());
108 TFile
outFile(
"analyzeMuons.root",
"recreate");
109 outFile.mkdir(
"analyzeMuon");
110 outFile.cd(
"analyzeMuon");
int main(int argc, char *argv[])
static void enable()
enable automatic library loading