Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larg4
larg4
Analysis
CheckMCParticle_module.cc
Go to the documentation of this file.
1
// C++ includes.
2
#include <iostream>
3
#include <string>
4
#include <set>
5
#include <cmath>
6
#include <algorithm>
7
8
// Framework includes.
9
#include "
art/Framework/Core/EDAnalyzer.h
"
10
#include "
art/Framework/Principal/Event.h
"
11
#include "
art/Framework/Principal/Handle.h
"
12
#include "
art/Framework/Core/ModuleMacros.h
"
13
#include "
art/Framework/Principal/Run.h
"
14
#include "art_root_io/TFileDirectory.h"
15
#include "art_root_io/TFileService.h"
16
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
17
#include "
art/Framework/Principal/Provenance.h
"
18
#include "
nusimdata/SimulationBase/MCParticle.h
"
19
20
// Root includes.
21
#include "TFile.h"
22
#include "TH1F.h"
23
#include "TH2F.h"
24
#include "TDirectory.h"
25
26
// Other includes.
27
#include "CLHEP/Units/SystemOfUnits.h"
28
//#define _verbose_ 1
29
using namespace
std
;
30
namespace
larg4
{
31
class
CheckMCParticle;
32
}
33
34
class
larg4::CheckMCParticle
:
public
art::EDAnalyzer
{
35
public
:
36
explicit
CheckMCParticle
(
fhicl::ParameterSet
const
&
p
);
37
38
private
:
39
void
beginJob
()
override
;
40
void
analyze
(
const
art::Event
&
event
)
override
;
41
42
std::string
const
_myName
;
43
TH1F* _hnParts{
nullptr
};
44
};
45
46
larg4::CheckMCParticle::CheckMCParticle
(
fhicl::ParameterSet
const
&
p
) :
47
art
::EDAnalyzer(p),
48
_myName(p.
get
<
std
::
string
>(
"name"
,
"CheckMCParticle"
))
49
{}
50
51
void
larg4::CheckMCParticle::beginJob
()
52
{
53
art::ServiceHandle<art::TFileService const>
tfs;
54
_hnParts
= tfs->make<TH1F>(
"hnParts"
,
"Number of generated Particles"
, 100, 0., 2000.);
55
}
// end beginJob
56
57
void
larg4::CheckMCParticle::analyze
(
const
art::Event
&
event
)
58
{
59
auto
allGens =
event
.getMany<std::vector<simb::MCParticle>>();
60
for
(
auto
const
& gens : allGens) {
61
_hnParts
->Fill(gens->size());
62
#if defined _verbose_
63
for
(
auto
const
& genpart : *gens) {
64
cout <<
"Part id: "
<< genpart.TrackId() <<
endl
;
65
cout <<
"PDG id: "
<< genpart.PdgCode() <<
endl
;
66
cout <<
"Status Code: "
<< genpart.StatusCode() <<
endl
;
67
cout <<
"Mother: "
<< genpart.Mother() <<
endl
;
68
if
(genpart.Mother()==0) {
69
cout <<
"momentum: "
<< genpart.P() <<
endl
;
70
cout <<
"position: "
<< genpart.Vx()<<
" "
<< genpart.Vy()<<
" "
<< genpart.Vz() <<
endl
;
71
}
72
}
73
#endif
74
}
75
}
// end analyze
76
77
DEFINE_ART_MODULE
(
larg4::CheckMCParticle
)
rootstat.analyze
def analyze(root, level, gtrees, gbranches, doprint)
Definition:
rootstat.py:69
art::ServiceHandle< art::TFileService const >
Handle.h
larg4::CheckMCParticle::CheckMCParticle
CheckMCParticle(fhicl::ParameterSet const &p)
Definition:
CheckMCParticle_module.cc:46
string
std::string string
Definition:
nybbler.cc:12
Provenance.h
larg4
Geant4 interface.
Definition:
CheckAuxDetHit_module.cc:25
std
STL namespace.
MCParticle.h
Particle class.
larg4::CheckMCParticle::analyze
void analyze(const art::Event &event) override
Definition:
CheckMCParticle_module.cc:57
ServiceHandle.h
larg4::CheckMCParticle::_hnParts
TH1F * _hnParts
Definition:
CheckMCParticle_module.cc:43
larg4::CheckMCParticle
Definition:
CheckMCParticle_module.cc:34
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
larg4::CheckMCParticle::beginJob
void beginJob() override
Definition:
CheckMCParticle_module.cc:51
breakpoints::beginJob
void beginJob()
Definition:
Breakpoints.cc:14
test.p
p
Definition:
test.py:223
EDAnalyzer.h
ModuleMacros.h
art::Event
Definition:
Event.h:22
art::EDAnalyzer
Definition:
EDAnalyzer.h:20
art
Definition:
BasicOptionsHandler.h:9
larg4::CheckMCParticle::_myName
std::string const _myName
Definition:
CheckMCParticle_module.cc:42
Event.h
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
Run.h
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
event
Event finding and building.
Definition:
EventCheater_module.cc:32
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11