LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
CheckGenParticle_module.cc
Go to the documentation of this file.
1
//
2
// __ __ __ __ __
3
// ____ ______/ /_____ _/ // / / /_/ /__
4
// / __ `/ ___/ __/ __ `/ // /_/ __/ //_/
5
// / /_/ / / / /_/ /_/ /__ __/ /_/ ,<
6
// \__,_/_/ \__/\__, / /_/ \__/_/|_|
7
// /____/
8
//
9
// artg4tk: art based Geant 4 Toolkit
10
//
11
//=============================================================================
12
// CheckGenParticle_module.cc: Analysis module to analyze the GenParticles
13
// in the Event
14
// Author: Hans Wenzel (Fermilab)
15
//=============================================================================
16
17
// C++ includes.
18
#include <iostream>
19
#include <string>
20
21
// Framework includes.
22
#include "
art/Framework/Core/EDAnalyzer.h
"
23
#include "
art/Framework/Core/ModuleMacros.h
"
24
#include "
art/Framework/Principal/Event.h
"
25
#include "
art/Framework/Principal/Handle.h
"
26
#include "
art/Framework/Principal/Run.h
"
27
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
28
#include "art_root_io/TFileService.h"
29
30
// artg4tk includes:
31
#include "
artg4tk/DataProducts/EventGenerators/GenParticle.hh
"
32
#include "
artg4tk/DataProducts/EventGenerators/GenParticleCollection.hh
"
33
34
// Root includes.
35
#include "TDirectory.h"
36
#include "TH1F.h"
37
38
using namespace
std
;
39
namespace
artg4tk
{
40
class
CheckGenParticle;
41
}
42
43
class
artg4tk::CheckGenParticle
:
public
art::EDAnalyzer
{
44
public
:
45
explicit
CheckGenParticle
(
fhicl::ParameterSet
const
& p);
46
void
beginJob
()
override
;
47
void
beginRun(
const
art::Run
& Run)
override
;
48
void
endJob()
override
;
49
void
analyze(
const
art::Event
&
event
)
override
;
50
51
private
:
52
std::string
_myName
;
53
TH1F*
_hnParts
;
54
TDirectory
const
*
_directory
;
55
TFile*
_file
;
56
};
57
58
artg4tk::CheckGenParticle::CheckGenParticle
(
fhicl::ParameterSet
const
& p)
59
:
art
::EDAnalyzer(p)
60
, _myName(p.
get
<
std
::string>(
"name"
,
"CheckGenParticle"
))
61
, _hnParts(0)
62
, _directory(0)
63
, _file(0)
64
{}
65
66
void
67
artg4tk::CheckGenParticle::beginRun
(
const
art::Run
& thisRun)
68
{
69
std::cout <<
"******************************Run: "
<< thisRun.
id
() <<
": looking at Run Header"
70
<< std::endl;
71
}
72
73
void
74
artg4tk::CheckGenParticle::beginJob
()
75
{
76
77
art::ServiceHandle<art::TFileService>
tfs;
78
_directory
= gDirectory;
79
std::cout <<
"******************************We are in the directory named: "
80
<< gDirectory->GetName() << std::endl;
81
_file
= gDirectory->GetFile();
82
_hnParts
= tfs->make<TH1F>(
"hnParts"
,
"Number of generated Particles"
, 100, 0., 2000.);
83
}
// end beginJob
84
85
void
86
artg4tk::CheckGenParticle::analyze
(
const
art::Event
&
event
)
87
{
88
std::cout <<
"******************************event "
<<
event
.id().event()
89
<<
": looking at GenParticles"
<< std::endl;
90
typedef
std::vector<art::Handle<GenParticleCollection>> HandleVector;
91
// HandleVector allGens;
92
// event.getManyByType(allGens);
93
auto
allGens =
event
.getMany<
GenParticleCollection
>();
94
95
cout <<
"GenParticles*********************Size: "
<< allGens.size() << endl;
96
for
(
HandleVector::const_iterator
i = allGens.begin(); i != allGens.end(); ++i) {
97
const
GenParticleCollection
& gens(**i);
98
cout <<
" ********************************CheckGenParticle: collection size: "
<< gens.size()
99
<< endl;
100
_hnParts
->Fill(gens.size());
101
for
(
GenParticleCollection::const_iterator
j = gens.begin(); j != gens.end(); ++j) {
102
const
GenParticle
& genpart = *j;
103
cout <<
"Part id: "
<< genpart.
pdgId
() << endl;
104
CLHEP::HepLorentzVector
const
& mom = genpart.
momentum
();
105
cout <<
"Part Energy: "
<< mom.e() << endl;
106
cout <<
"invariant mass: "
<< mom.invariantMass() << endl;
107
cout <<
"momentum: "
<< mom.pz() << endl;
108
cout << genpart << endl;
109
}
110
}
111
112
}
// end analyze
113
114
void
115
artg4tk::CheckGenParticle::endJob
()
116
{
117
cout <<
" ********************************CheckGenParticle: I am done "
<< endl;
118
}
119
120
DEFINE_ART_MODULE
(
artg4tk::CheckGenParticle
)
art::ServiceHandle< art::TFileService >
art::Run::id
RunID id() const
Definition:
Run.cc:21
std
STL namespace.
GenParticle.hh
artg4tk::CheckGenParticle
Definition:
CheckGenParticle_module.cc:43
const_iterator
intermediate_table::const_iterator const_iterator
Definition:
intermediate_table.cc:28
artg4tk::CheckGenParticle::analyze
void analyze(const art::Event &event) override
Definition:
CheckGenParticle_module.cc:86
artg4tk::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
Definition:
GenParticleCollection.hh:14
Handle.h
artg4tk::CheckGenParticle::beginRun
void beginRun(const art::Run &Run) override
Definition:
CheckGenParticle_module.cc:67
GenParticleCollection.hh
art::Run
Definition:
Run.h:37
artg4tk::CheckGenParticle::CheckGenParticle
CheckGenParticle(fhicl::ParameterSet const &p)
Definition:
CheckGenParticle_module.cc:58
ServiceHandle.h
artg4tk::CheckGenParticle::beginJob
void beginJob() override
Definition:
CheckGenParticle_module.cc:74
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:65
breakpoints::beginJob
void beginJob()
Definition:
Breakpoints.cc:14
artg4tk::GenParticle::pdgId
PDGCode::type pdgId() const
Definition:
GenParticle.hh:35
Event.h
EDAnalyzer.h
artg4tk
Definition:
ActionBase.hh:12
ModuleMacros.h
artg4tk::GenParticle::momentum
CLHEP::HepLorentzVector const & momentum() const
Definition:
GenParticle.hh:60
art::Event
Definition:
Event.h:26
util::get
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition:
StdUtils.h:120
artg4tk::GenParticle
Definition:
GenParticle.hh:20
artg4tk::CheckGenParticle::_directory
TDirectory const * _directory
Definition:
CheckGenParticle_module.cc:54
art::EDAnalyzer
Definition:
EDAnalyzer.h:20
artg4tk::CheckGenParticle::_hnParts
TH1F * _hnParts
Definition:
CheckGenParticle_module.cc:53
artg4tk::CheckGenParticle::_myName
std::string _myName
Definition:
CheckGenParticle_module.cc:52
art
Definition:
MVAAlg.h:12
artg4tk::CheckGenParticle::_file
TFile * _file
Definition:
CheckGenParticle_module.cc:55
Run.h
event
Event finding and building.
Definition:
EventCheater_module.cc:32
fhicl::ParameterSet
Definition:
ParameterSet.h:36
artg4tk::CheckGenParticle::endJob
void endJob() override
Definition:
CheckGenParticle_module.cc:115
artg4tk
v12_00_03
source
artg4tk
Analysis
CheckGenParticle_module.cc
Generated on Thu May 2 2024 20:59:30 for LArSoft by
1.8.11