Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
protoduneana
protoduneana
PhysicsWeek
MichelHitCounter_module.cc
Go to the documentation of this file.
1
// Example module showing how to access and count
2
// michel elctron hits in reconstruction
3
4
#include "
lardataobj/Simulation/SimChannel.h
"
5
#include "
larsim/Simulation/LArG4Parameters.h
"
6
#include "
larsim/Simulation/LArVoxelData.h
"
7
#include "
larsim/Simulation/LArVoxelList.h
"
8
#include "
larsim/Simulation/SimListUtils.h
"
9
#include "
larsim/MCCheater/BackTracker.h
"
10
#include "
larcore/Geometry/Geometry.h
"
11
#include "
lardataobj/RecoBase/Hit.h
"
12
#include "
lardataobj/RecoBase/Track.h
"
13
#include "
lardataobj/RecoBase/Cluster.h
"
14
#include "
larreco/Calorimetry/CalorimetryAlg.h
"
15
#include "
larreco/RecoAlg/PMAlg/Utilities.h
"
16
#include "
nusimdata/SimulationBase/MCParticle.h
"
17
#include "
nusimdata/SimulationBase/MCTruth.h
"
18
#include "
larcoreobj/SimpleTypesAndConstants/PhysicalConstants.h
"
19
#include "
lardata/Utilities/DatabaseUtil.h
"
20
21
#include "
art/Framework/Core/EDAnalyzer.h
"
22
#include "
art/Framework/Core/ModuleMacros.h
"
23
#include "canvas/Persistency/Common/FindManyP.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/Principal/SubRun.h
"
28
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
29
#include "art_root_io/TFileService.h"
30
#include "
canvas/Utilities/InputTag.h
"
31
#include "
fhiclcpp/ParameterSet.h
"
32
#include "
messagefacility/MessageLogger/MessageLogger.h
"
33
34
#include "
lardata/ArtDataHelper/MVAReader.h
"
35
36
#include "TTree.h"
37
38
#include <fstream>
39
40
namespace
MichelReco
{
41
42
class
MichelReco
;
43
44
class
MichelReco
:
public
art::EDAnalyzer
{
45
public
:
46
explicit
MichelReco
(
fhicl::ParameterSet
const
&
p
);
47
// The destructor generated by the compiler is fine for classes
48
// without bare pointers or other resource use.
49
50
// Plugins should not be copied or assigned.
51
MichelReco
(
MichelReco
const
&) =
delete
;
52
MichelReco
(
MichelReco
&&) =
delete
;
53
MichelReco
&
operator =
(
MichelReco
const
&) =
delete
;
54
MichelReco
&
operator =
(
MichelReco
&&) =
delete
;
55
56
// Required functions.
57
void
analyze
(
art::Event
const
&
e
)
override
;
58
59
// Selected optional functions
60
void
beginJob
()
override
;
61
void
endJob
()
override
;
62
void
beginRun
(
const
art::Run
&
run
)
override
;
63
void
reconfigure
(
fhicl::ParameterSet
const
&
p
) ;
64
65
private
:
66
// My parameters
67
size_t
fEvNumber;
// Event number for each event
68
int
fNMichelHits
;
// Total number of Michel hits in events
69
70
// Input parameters
71
art::InputTag
fNNetModuleLabel;
// label of the module used for CNN tagging
72
};
73
74
75
MichelReco::MichelReco
(
fhicl::ParameterSet
const
&
p
)
76
:
77
EDAnalyzer(p)
78
{
79
reconfigure
(p);
80
}
81
82
void
MichelReco::beginJob
()
83
{
84
art::ServiceHandle<art::TFileService>
tfs;
85
}
86
87
void
MichelReco::endJob()
88
{
89
mf::LogVerbatim
(
"MichelReco"
) <<
"MichelHitCounter finished job"
;
90
mf::LogVerbatim
(
"MichelReco"
) << fNMichelHits <<
" michel hits found"
;
91
}
92
93
void
MichelReco::beginRun(
const
art::Run
&)
94
{
95
art::ServiceHandle<sim::LArG4Parameters>
larParameters;
96
}
97
98
void
MichelReco::analyze
(
art::Event
const
&
evt
)
99
{
100
// keep track of progress
101
fEvNumber = evt.
id
().
event
();
102
mf::LogVerbatim
(
"MichelReco"
) <<
"MichelReco module on event "
<< fEvNumber;
103
104
// Helper to get hits and the 4 associated CNN outputs
105
// CNN Outputs: EM, Track, Michel, Empty
106
anab::MVAReader<recob::Hit,4>
hitResults(evt, fNNetModuleLabel);
107
108
// loop over hits
109
for
(
size_t
h
= 0;
h
< hitResults.
size
(); ++
h
) {
110
111
// Get cnn output for hit h
112
std::array<float,4> cnn_out = hitResults.
getOutput
(
h
);
113
114
// Compare michel cnn output to treshold to decide if Michel hit
115
// Example using 0.5, needs to be optimised with clustering
116
// e.g. 0.9 used for event selection
117
if
(cnn_out[hitResults.
getIndex
(
"michel"
)] > 0.5) {
118
fNMichelHits += 1;
119
}
120
121
}
// End of loop over hits
122
123
}
124
125
void
MichelReco::reconfigure
(
fhicl::ParameterSet
const
&
p
)
126
{
127
128
fNMichelHits = 0;
129
fNNetModuleLabel = p.
get
<
std::string
>(
"NNetModuleLabel"
);
130
return
;
131
}
132
133
}
// MichelReco namespace
134
135
DEFINE_ART_MODULE
(
MichelReco::MichelReco
)
rootstat.analyze
def analyze(root, level, gtrees, gbranches, doprint)
Definition:
rootstat.py:69
LArG4Parameters.h
Store parameters for running LArG4.
mf::LogVerbatim
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Definition:
MessageLogger.h:216
art::ServiceHandle< art::TFileService >
MichelReco
Definition:
MichelEventSelection_module.cc:59
art::EDAnalyzer::beginRun
virtual void beginRun(Run const &)
Definition:
EDAnalyzer.cc:115
Handle.h
LArVoxelList.h
Container of LAr voxel information.
string
std::string string
Definition:
nybbler.cc:12
art::EDAnalyzer::analyze
virtual void analyze(Event const &)=0
SimListUtils.h
anab::MVAReader
Definition:
MVAReader.h:104
anab::FVectorReader::getIndex
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
Definition:
MVAReader.h:82
BackTracker.h
MCParticle.h
Particle class.
art::EDAnalyzer::endJob
virtual void endJob()
Definition:
EDAnalyzer.cc:95
filelisting.run
int run
Definition:
filelisting.py:13
Geometry.h
art framework interface to geometry description
art::Run
Definition:
Run.h:17
MVAReader.h
MessageLogger.h
ParameterSet.h
ServiceHandle.h
DatabaseUtil.h
reco_momentum_tuples.h
h
Definition:
reco_momentum_tuples.py:66
art::EDAnalyzer::beginJob
virtual void beginJob()
Definition:
EDAnalyzer.cc:91
e
const double e
Definition:
gUpMuFluxGen.cxx:165
LArVoxelData.h
Encapsulates the information we want store for a voxel.
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
breakpoints::beginJob
void beginJob()
Definition:
Breakpoints.cc:14
RunHistoryService::reconfigure
virtual void reconfigure(fhicl::ParameterSet const &pset)
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
CalorimetryAlg.h
Cluster.h
art::InputTag
Definition:
InputTag.h:12
test.p
p
Definition:
test.py:223
SubRun.h
anab::FVectorReader::size
size_t size() const
Get the number of contained items (no. of data product objects equal to no. of feature vectors)...
Definition:
MVAReader.h:67
EDAnalyzer.h
ModuleMacros.h
MichelReco::MichelReco
Definition:
MichelEventSelection_module.cc:63
art::Observer::operator=
Observer & operator=(Observer const &)=delete
Utilities.h
Implementation of the Projection Matching Algorithm.
Hit.h
Declaration of signal hit object.
art::Event
Definition:
Event.h:22
MichelReco::MichelReco::fNMichelHits
int fNMichelHits
Definition:
MichelHitCounter_module.cc:68
SimChannel.h
art::EDAnalyzer
Definition:
EDAnalyzer.h:20
Track.h
Provides recob::Track data product.
InputTag.h
art::EventID::event
EventNumber_t event() const
Definition:
EventID.h:116
MCTruth.h
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
Event.h
PhysicalConstants.h
Collection of Physical constants used in LArSoft.
anab::MVAReader::getOutput
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
Definition:
MVAReader.h:129
Run.h
art::Event::id
EventID id() const
Definition:
Event.cc:34
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11