Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DAQTriggerSim
AnalyzeTriggers
TemplateTriggerAna_module.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
// Class: TemplateTriggerAna
3
// Module Type: analyzer
4
// File: TemplateTriggerAna_module.cc
5
//
6
// Generated at Fri Feb 19 08:55:48 2016 by Michael Baird using artmod
7
// from cetpkgsupport v1_10_01.
8
////////////////////////////////////////////////////////////////////////
9
10
// C++ includes
11
12
// ROOT includes
13
#include "TH1F.h"
14
#include "TTree.h"
15
16
// Framework includes
17
#include "
art/Framework/Core/EDAnalyzer.h
"
18
#include "
art/Framework/Core/ModuleMacros.h
"
19
#include "
art/Framework/Principal/Event.h
"
20
#include "
art/Framework/Principal/Handle.h
"
21
#include "
art/Framework/Principal/Run.h
"
22
#include "
art/Framework/Principal/SubRun.h
"
23
#include "art_root_io/TFileDirectory.h"
24
#include "art_root_io/TFileService.h"
25
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
26
#include "
canvas/Utilities/InputTag.h
"
27
#include "
fhiclcpp/ParameterSet.h
"
28
#include "
messagefacility/MessageLogger/MessageLogger.h
"
29
30
// DUNETPC specific includes
31
#include "
dunecore/DAQTriggerSim/TriggerDataProducts/TriggerTypes.h
"
32
#include "
dunecore/DAQTriggerSim/TriggerDataProducts/BasicTrigger.h
"
33
34
namespace
triggersim
{
35
36
class
TemplateTriggerAna
:
public
art::EDAnalyzer
{
37
38
public
:
39
40
explicit
TemplateTriggerAna
(
fhicl::ParameterSet
const
&
p
);
41
42
// Plugins should not be copied or assigned.
43
TemplateTriggerAna
(
TemplateTriggerAna
const
&) =
delete
;
44
TemplateTriggerAna
(
TemplateTriggerAna
&&) =
delete
;
45
TemplateTriggerAna
&
operator =
(
TemplateTriggerAna
const
&) =
delete
;
46
TemplateTriggerAna
&
operator =
(
TemplateTriggerAna
&&) =
delete
;
47
48
// The main guts...
49
void
analyze
(
art::Event
const
&
evt
)
override
;
50
51
void
reconfigure
(
fhicl::ParameterSet
const
& p);
52
53
void
beginJob
()
override
;
54
55
void
ResetVars
();
56
57
private
:
58
59
// label for module that made trigger objects
60
std::string
fTriggerLabel
;
61
62
// a simple histo to be filled
63
TH1F *
fTrigTypes
;
64
65
// The name of our TTree, and the variables which we want to put in it.
66
TTree *
TrigAnaTree
;
67
int
Run
;
///< The run which the trigger was taken from
68
int
SubRun
;
///< The SubRun which the trigger was taken from
69
int
Event
;
///< The event which the trigger was taken from
70
bool
TrigDecision
;
///< The decision of the trigger
71
int
TrigType
;
///< The type of trigger decision which was made
72
int
TrigSubType
;
///< The subtype of trigger decision which was made
73
};
74
75
//......................................................
76
void
TemplateTriggerAna::ResetVars
() {
77
Run
= -1;
78
SubRun
= -1;
79
Event
= -1;
80
TrigDecision
=
false
;
81
TrigType
= -1;
82
TrigSubType
= -1;
83
}
84
85
//......................................................
86
TemplateTriggerAna::TemplateTriggerAna
(
fhicl::ParameterSet
const
&
p
)
87
:
88
EDAnalyzer
(p)
89
{
90
this->
reconfigure
(p);
91
}
92
93
//......................................................
94
void
TemplateTriggerAna::reconfigure
(
fhicl::ParameterSet
const
&
p
)
95
{
96
fTriggerLabel
= p.
get
<
std::string
> (
"TriggerLabel"
);
97
}
98
99
//......................................................
100
void
TemplateTriggerAna::beginJob
()
101
{
102
// --- Make a handle to the TFileService - the thing that handles all the histogram and TTree outputs...
103
art::ServiceHandle<art::TFileService>
tfs;
104
// --- Now we can declare the histrogram which we want to make.
105
fTrigTypes
= tfs->make<TH1F>(
"fTrigTypes"
,
"Trigger Types;trig type;count"
,
106
101,-0.5,100.5);
107
108
// --- Now we want to declare our TTree, and set the names of the variables in it...
109
TrigAnaTree
= tfs->make<TTree>(
"TrigAnaTree"
,
"Analysis tree from triggers"
);
110
TrigAnaTree
-> Branch(
"Run"
, &
Run
);
111
TrigAnaTree
-> Branch(
"SubRun"
, &
SubRun
);
112
TrigAnaTree
-> Branch(
"Event"
, &
Event
);
113
TrigAnaTree
-> Branch(
"TrigDecision"
, &
TrigDecision
);
114
TrigAnaTree
-> Branch(
"TrigType"
, &
TrigType
);
115
TrigAnaTree
-> Branch(
"TrigSubType"
, &
TrigSubType
);
116
}
117
118
119
120
//......................................................
121
void
TemplateTriggerAna::analyze
(
art::Event
const
&
evt
) {
122
123
// --- Reset all of our variables...
124
ResetVars
();
125
126
// --- Get trigger data products out of the event...
127
auto
triggers = evt.
getValidHandle
<std::vector<triggersim::BasicTrigger> >(
fTriggerLabel
);
128
129
// --- Loop over trigger objects...
130
for
(
unsigned
int
i = 0; i < triggers->size(); ++i) {
131
132
// --- Set our variables for the TTree...
133
Run
= evt.
run
();
134
SubRun
= evt.
subRun
();
135
Event
= evt.
event
();
136
137
TrigDecision
= (*triggers)[i].TrigDecision();
138
TrigType
= (*triggers)[i].TrigType();
139
TrigSubType
= (*triggers)[i].TrigSubType();
140
// --- Print some info, and confirm to ourselves that our variables are correctly set...
141
std::cout <<
"\n----------Info for trigger "
<< i <<
":"
142
<<
"\nTrigger Decision = "
<< (*triggers)[i].TrigDecision() <<
" "
<<
TrigDecision
143
<<
"\nTrigger Type = "
<< (*triggers)[i].TrigType() <<
" "
<<
TrigType
144
<<
"\nTrigger Sub-Type = "
<< (*triggers)[i].TrigSubType() <<
" "
<<
TrigSubType
145
<<
"\nTrigger HardwareID = "
<< (*triggers)[i].TrigHardwareID()
146
<<
std::endl
;
147
148
149
std::cout <<
"\nAnother way of printing out a trigger"
<<
std::endl
;
150
std::cout << (*triggers)[i] <<
std::endl
;
151
152
// --- Fill a histogram...
153
fTrigTypes
->Fill((*triggers)[i].
TrigType
());
154
155
// --- Fill a TTree...
156
TrigAnaTree
-> Fill();
157
}
158
159
}
160
161
DEFINE_ART_MODULE
(
TemplateTriggerAna
)
162
163
}
art::ServiceHandle< art::TFileService >
triggersim::TemplateTriggerAna::ResetVars
void ResetVars()
Definition:
TemplateTriggerAna_module.cc:76
art::DataViewImpl::event
EventNumber_t event() const
Definition:
DataViewImpl.cc:85
Handle.h
string
std::string string
Definition:
nybbler.cc:12
triggersim::TemplateTriggerAna::reconfigure
void reconfigure(fhicl::ParameterSet const &p)
Definition:
TemplateTriggerAna_module.cc:94
BasicTrigger.h
triggersim::TemplateTriggerAna::TemplateTriggerAna
TemplateTriggerAna(fhicl::ParameterSet const &p)
Definition:
TemplateTriggerAna_module.cc:86
triggersim
Definition:
TemplateTriggerAna_module.cc:34
triggersim::TemplateTriggerAna::Event
int Event
The event which the trigger was taken from.
Definition:
TemplateTriggerAna_module.cc:69
art::EDAnalyzer::EDAnalyzer
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition:
EDAnalyzer.h:25
triggersim::TemplateTriggerAna::TrigType
int TrigType
The type of trigger decision which was made.
Definition:
TemplateTriggerAna_module.cc:71
MessageLogger.h
ParameterSet.h
triggersim::TemplateTriggerAna::fTriggerLabel
std::string fTriggerLabel
Definition:
TemplateTriggerAna_module.cc:60
ServiceHandle.h
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
triggersim::TemplateTriggerAna::fTrigTypes
TH1F * fTrigTypes
Definition:
TemplateTriggerAna_module.cc:63
triggersim::TemplateTriggerAna::operator=
TemplateTriggerAna & operator=(TemplateTriggerAna const &)=delete
TriggerTypes.h
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
triggersim::TemplateTriggerAna
Definition:
TemplateTriggerAna_module.cc:36
art::DataViewImpl::getValidHandle
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition:
DataViewImpl.h:441
test.p
p
Definition:
test.py:223
SubRun.h
art::DataViewImpl::subRun
SubRunNumber_t subRun() const
Definition:
DataViewImpl.cc:78
triggersim::TemplateTriggerAna::SubRun
int SubRun
The SubRun which the trigger was taken from.
Definition:
TemplateTriggerAna_module.cc:68
art::DataViewImpl::run
RunNumber_t run() const
Definition:
DataViewImpl.cc:71
EDAnalyzer.h
ModuleMacros.h
triggersim::TemplateTriggerAna::Run
int Run
The run which the trigger was taken from.
Definition:
TemplateTriggerAna_module.cc:67
triggersim::TemplateTriggerAna::TrigDecision
bool TrigDecision
The decision of the trigger.
Definition:
TemplateTriggerAna_module.cc:70
art::Event
Definition:
Event.h:22
art::EDAnalyzer
Definition:
EDAnalyzer.h:20
triggersim::TemplateTriggerAna::analyze
void analyze(art::Event const &evt) override
Definition:
TemplateTriggerAna_module.cc:121
triggersim::TemplateTriggerAna::TrigAnaTree
TTree * TrigAnaTree
Definition:
TemplateTriggerAna_module.cc:66
InputTag.h
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
Event.h
triggersim::TemplateTriggerAna::TrigSubType
int TrigSubType
The subtype of trigger decision which was made.
Definition:
TemplateTriggerAna_module.cc:72
triggersim::TemplateTriggerAna::beginJob
void beginJob() override
Definition:
TemplateTriggerAna_module.cc:100
Run.h
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11