Skip to content

Commit f3d5228

Browse files
committed
Adds basic lepton plots.
1 parent 798757e commit f3d5228

File tree

4 files changed

+163
-103
lines changed

4 files changed

+163
-103
lines changed

GeneratorPlotsAlt/MyxAODAnalysis.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33

44
#include <EventLoop/Algorithm.h>
55

6-
// GitHubProgramCode added
7-
#include <TH1.h>
6+
#include "MCValidation/lepton_plots.h"
7+
#include "MCValidation/neutrino_plots.h"
8+
#include "MCValidation/two_particle_plots.h"
9+
#include "MCValidation/standard_p_plots.h"
10+
#include "MCValidation/lifetime_plots.h"
11+
#include "MCValidation/truth_helpers.h"
812

913
class MyxAODAnalysis : public EL::Algorithm
1014
{
1115
// put your configuration variables here as public variables.
1216
// that way they can be set directly from CINT and python.
1317
public:
14-
// float cutValue;
15-
// GitHubProgramCode added
16-
int m_eventCounter; //!
17-
18-
19-
2018
// variables that don't get filled at submission time should be
2119
// protected from being send from the submission node to the worker
2220
// node (done by the //!)
23-
public:
24-
// Tree *myTree; //!
25-
// TH1 *myHist; //!
26-
27-
// GitHubProgramCode added
28-
TH1 *h_jetPt; //!
29-
21+
int m_eventCounter; //!
3022

23+
// Histograms for each type of particle.
24+
lifetime_plots* all; //!
25+
standard_p_plots* hs; //!
26+
two_particle_plots* twohs; //!
27+
neutrino_plots* e_neutrino; //!
28+
neutrino_plots* mu_neutrino; //!
29+
lepton_plots* e; //!
30+
lepton_plots* mu; //!
3131

3232
// this is a standard constructor
3333
MyxAODAnalysis ();

MCValidation/lepton_plots.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef __lepton_plots__
2+
#define __lepton_plots__
3+
4+
#include "xAODTruth/TruthParticle.h"
5+
#include "xAODTruth/TruthVertex.h"
6+
#include <EventLoop/Worker.h>
7+
8+
#include "TH1F.h"
9+
10+
#include <string>
11+
12+
class lepton_plots {
13+
public:
14+
lepton_plots(const std::string &name, const std::string &title, EL::Worker *wk)
15+
{
16+
_mass = new TH1F((name + "mass").c_str(), (title + "mass; mass [GeV]").c_str(), 6000, 0.0, 6000.0);
17+
wk->addOutput (_mass);
18+
_pt = new TH1F((name + "pt").c_str(), (title + "p_{T}; p_{T} [GeV]").c_str(), 250, 0.0, 2000.0);
19+
wk->addOutput (_pt);
20+
_eta = new TH1F((name + "eta").c_str(), (title + "\\eta; \\eta").c_str(), 200, -5.0, 5.0);
21+
wk->addOutput (_eta);
22+
_phi = new TH1F((name + "phi").c_str(), (title + "\\phi; \\phi [rad]").c_str(), 200, -3.15, 3.15);
23+
wk->addOutput (_phi);
24+
}
25+
26+
void Process(const xAOD::TruthParticle *p)
27+
{
28+
_mass->Fill(p->m()*0.001);
29+
_pt->Fill(p->pt()*0.001);
30+
_eta->Fill(p->eta());
31+
_phi->Fill(p->phi());
32+
}
33+
34+
private:
35+
TH1F *_mass;
36+
TH1F *_pt;
37+
TH1F *_eta;
38+
TH1F *_phi;
39+
};
40+
41+
#endif

MCValidation/neutrino_plots.h

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef __neutrino_plots__
2+
#define __neutrino_plots__
3+
4+
#include "xAODTruth/TruthParticle.h"
5+
#include "xAODTruth/TruthVertex.h"
6+
#include <EventLoop/Worker.h>
7+
8+
#include "TH1F.h"
9+
10+
#include <string>
11+
12+
class neutrino_plots {
13+
public:
14+
neutrino_plots(const std::string &name, const std::string &title, EL::Worker *wk)
15+
{
16+
_pt = new TH1F((name + "pt").c_str(), (title + "p_{T}; p_{T} [GeV]").c_str(), 250, 0.0, 2000.0);
17+
wk->addOutput (_pt);
18+
_eta = new TH1F((name + "eta").c_str(), (title + "\\eta; \\eta").c_str(), 200, -5.0, 5.0);
19+
wk->addOutput (_eta);
20+
_phi = new TH1F((name + "phi").c_str(), (title + "\\phi; \\phi [rad]").c_str(), 200, -3.15, 3.15);
21+
wk->addOutput (_phi);
22+
}
23+
24+
void Process(const xAOD::TruthParticle *p)
25+
{
26+
_pt->Fill(p->pt()*0.001);
27+
_eta->Fill(p->eta());
28+
_phi->Fill(p->phi());
29+
}
30+
31+
private:
32+
TH1F *_mass;
33+
TH1F *_pt;
34+
TH1F *_eta;
35+
TH1F *_phi;
36+
};
37+
38+
#endif

Root/MyxAODAnalysis.cxx

+69-88
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <EventLoop/Worker.h>
44
#include <GeneratorPlotsAlt/MyxAODAnalysis.h>
55

6-
// GitHubProgramCode added
76
// Infrastructure include(s):
87
#include "xAODRootAccess/Init.h"
98
#include "xAODRootAccess/TEvent.h"
@@ -12,47 +11,27 @@
1211
#include "xAODTruth/TruthEventContainer.h"
1312
#include "GeneratorPlotsAlt/truth_helpers.h"
1413

15-
// GitHubProgramCode added
1614
// ASG status code check
1715
#include <AsgTools/MessageCheck.h>
1816

19-
// GitHubProgramCode added
2017
// EDM includes:
2118
#include "xAODEventInfo/EventInfo.h"
2219

23-
// // GitHubProgramCode added
24-
// #include <iostream>
25-
// #include <string>
26-
27-
// GitHubProgramCode added
2820
// To create a basic loop over a jet container, for the AntiKt4EMTTopoJets jet collection.
2921
#include "xAODJet/JetContainer.h"
3022

31-
// Gordoncode added from validationPlots_HSS.cxx
32-
//#include "MCValidation/template_access.h"
23+
// Validation histograms:
24+
#include "MCValidation/lepton_plots.h"
25+
#include "MCValidation/neutrino_plots.h"
3326
#include "MCValidation/two_particle_plots.h"
3427
#include "MCValidation/standard_p_plots.h"
3528
#include "MCValidation/lifetime_plots.h"
3629
#include "MCValidation/truth_helpers.h"
3730

38-
// Gordoncode added from validationPlots_HSS.cxx
3931
// Config
4032
const char *APP_NAME = "validationPlots";
4133
const char *OutputFile = "validation.root";
4234

43-
// // Book the histos
44-
// // Gordoncode from validationPlots_HSS.cxx
45-
// lifetime_plots all ("all", "all ");
46-
// standard_p_plots hs ("hs", "#h_{s} ");
47-
// standard_p_plots hhiggs ("higgs", "Higgs ");
48-
// two_particle_plots twohs ("twoHS", "Two HSs ");
49-
50-
// Book the histos
51-
// Gordoncode from validationPlots_HSS.cxx
52-
lifetime_plots* all;
53-
standard_p_plots* hs;
54-
two_particle_plots* twohs;
55-
5635
// this is needed to distribute the algorithm to the workers
5736
ClassImp(MyxAODAnalysis)
5837

@@ -101,14 +80,15 @@ EL::StatusCode MyxAODAnalysis :: histInitialize ()
10180

10281
// GitHubProgramCode added
10382
// This method is called before processing any events. Note that the wk()->addOutput call is a mechanism EventLoop uses for delivering the results of an algorithm to the outside world. When running in PROOF, ROOT will merge all of the objects in this list.
104-
105-
h_jetPt = new TH1F("h_jetPt", "h_jetPt", 100, 0, 500); // jet pt [GeV]
106-
wk()->addOutput (h_jetPt);
10783

108-
// Initializing histograms
109-
all = new lifetime_plots ("all", "all ", wk());
110-
hs = new standard_p_plots ("hs", "#h_{s} ", wk());
111-
twohs = new two_particle_plots ("twoHS", "Two HSs ", wk());
84+
// Initializing histograms
85+
all = new lifetime_plots ("all", "all ", wk());
86+
hs = new standard_p_plots ("hs", "#h_{s} ", wk());
87+
twohs = new two_particle_plots ("twoHS", "Two HSs ", wk());
88+
e_neutrino = new neutrino_plots ("e_neutrino_", "\\nu_{e} ", wk());
89+
mu_neutrino = new neutrino_plots ("mu_neutrino_", "\\nu_{\\mu} ", wk());
90+
e = new lepton_plots ("e_", "e ", wk());
91+
mu = new lepton_plots("mu_", "\\mu ", wk());
11292

11393
return EL::StatusCode::SUCCESS;
11494
}
@@ -175,71 +155,72 @@ EL::StatusCode MyxAODAnalysis :: execute ()
175155

176156
// GitHubProgramCode added
177157
// print every 100 events, so we know where we are:
178-
if( (m_eventCounter % 100) ==0 ) Info("execute()", "Event number = %i", m_eventCounter );
179-
m_eventCounter++;
180-
181-
//----------------------------
182-
// Event information
183-
//---------------------------
184-
const xAOD::EventInfo* eventInfo = 0;
185-
ANA_CHECK(event->retrieve( eventInfo, "EventInfo"));
186-
187-
// check if the event is data or MC
188-
// (many tools are applied either to data or MC)
189-
// Warning: set but not used below commented out
190-
// bool isMC = false;
191-
// check if the event is MC
192-
// if(eventInfo->eventType( xAOD::EventInfo::IS_SIMULATION ) ){
193-
// isMC = true; // can do something with this later
194-
// }
195-
196-
// GitHubProgramCode added + Gordoncode
197-
// get jet container of interest
198-
const xAOD::TruthEventContainer* truths = 0;
199-
ANA_CHECK(event->retrieve( truths, "TruthEvents" ));
200-
Info("execute()", " number of truths = %lu", truths->size());
201-
202-
// loop over the jets in the container
203-
xAOD::TruthEventContainer::const_iterator truth_itr = truths->begin();
204-
xAOD::TruthEventContainer::const_iterator truth_end = truths->end();
205-
// for( ; jet_itr != jet_end; ++jet_itr ) {
206-
// Info("execute()", " jet pt = %.2f GeV", ((*jet_itr)->pt() * 0.001)); // just to print out something
207-
// } // end for loop over jets
208-
209-
// GitHubProgramCode added + Gordoncode
210-
// Get the truth info
211-
const xAOD::TruthEventContainer *truth = nullptr;
212-
// RETURN_CHECK (APP_NAME, event->retrieve(truth, "TruthEvents"));
213-
ANA_CHECK(event->retrieve( truth, "TruthEvents" ));
214-
// Warning: set but not used below commented out
215-
// bool isHiggs62 = false;
216-
// Loop over all the truth particles in there
217-
for (auto evt : *truth)
158+
if( (m_eventCounter % 100) ==0 ) Info("execute()", "Event number = %i", m_eventCounter );
159+
m_eventCounter++;
160+
161+
//----------------------------
162+
// Event information
163+
//---------------------------
164+
const xAOD::EventInfo* eventInfo = 0;
165+
ANA_CHECK(event->retrieve( eventInfo, "EventInfo"));
166+
167+
// check if the event is data or MC
168+
// (many tools are applied either to data or MC)
169+
// Warning: set but not used below commented out
170+
// bool isMC = false;
171+
// check if the event is MC
172+
// if(eventInfo->eventType( xAOD::EventInfo::IS_SIMULATION ) ){
173+
// isMC = true; // can do something with this later
174+
// }
175+
176+
// GitHubProgramCode added + Gordoncode
177+
// get jet container of interest
178+
const xAOD::TruthEventContainer* truths = 0;
179+
ANA_CHECK(event->retrieve( truths, "TruthEvents" ));
180+
Info("execute()", " number of truths = %lu", truths->size());
181+
182+
// loop over the jets in the container
183+
xAOD::TruthEventContainer::const_iterator truth_itr = truths->begin();
184+
xAOD::TruthEventContainer::const_iterator truth_end = truths->end();
185+
186+
// Get the truth info
187+
const xAOD::TruthEventContainer *truth = nullptr;
188+
// RETURN_CHECK (APP_NAME, event->retrieve(truth, "TruthEvents"));
189+
ANA_CHECK(event->retrieve( truth, "TruthEvents" ));
190+
// Warning: set but not used below commented out
191+
// bool isHiggs62 = false;
192+
// Loop over all the truth particles in there
193+
for (auto evt : *truth)
194+
{
195+
for (auto p : truth_as_range(evt))
196+
{
197+
if (p != nullptr)
218198
{
219-
for (auto p : truth_as_range(evt))
199+
all->Process(p);
200+
if (p->pdgId() == 35) // 35 is the higgs' pdgId.
220201
{
221-
if (p != nullptr)
202+
hs->Process(p);
203+
twohs->addParticle(p);
204+
}
205+
else if (p->pdgId() == 11) // 11 is the electron.
222206
{
223-
all->Process(p);
224-
if (p->pdgId() == 35) {
225-
hs->Process(p);
226-
twohs->addParticle(p);
227-
// Changed i --> 0
228-
if(p->nParents() > 1) std::cout << "event " << 0 << ": this scalar has " << p->nParents() << " parents! " << std::endl;
229-
// Changed i --> 0
230-
if(0 < 5){
231-
std::cout << "h_s, particle status: " << p->status() << std::endl;
232-
std::cout << "h_s has " << p->nChildren() << std::endl;
233-
234-
for(unsigned int k=0; k < p->nChildren(); k++){
235-
std::cout <<" h_s child status, id: " << p->child(k)->status() << ", " << p->child(k)->pdgId() << std::endl;
236-
}
207+
e->Process(p);
237208
}
209+
else if (p->pdgId() == 12) // 12 is the electron neutrino.
210+
{
211+
e_neutrino->Process(p);
212+
}
213+
else if (p->pdgId() == 13) // 13 is the muon.
214+
{
215+
mu->Process(p);
216+
}
217+
else if (p->pdgId() == 14) // 14 is the muon neutrino.
218+
{
219+
mu_neutrino->Process(p);
238220
}
239221
}
240222
}
241223
}
242-
243224

244225
return EL::StatusCode::SUCCESS;
245226
}

0 commit comments

Comments
 (0)