20 #include "art_root_io/TFileService.h"
21 #include "art/Framework/Services/Registry/ServiceHandle.h"
22 #include "art/Framework/Core/EDAnalyzer.h"
23 #include "art/Framework/Core/ModuleMacros.h"
24 #include "art/Framework/Principal/Event.h"
25 #include "canvas/Persistency/Provenance/EventID.h"
26 #include "canvas/Utilities/InputTag.h"
27 #include "messagefacility/MessageLogger/MessageLogger.h"
28 #include "fhiclcpp/types/TableAs.h"
29 #include "fhiclcpp/types/Sequence.h"
30 #include "fhiclcpp/types/Atom.h"
42 namespace sbn {
class TriggerEmulationTree; }
107 fhicl::Atom<std::string>
Name {
109 Comment(
"name of the trigger (e.g. `\"M5O3\"`), used for branch name")
113 Comment(
"tag of the input trigger info data product")
118 = fhicl::TableAs<TriggerInputSpec_t, TriggerSpecConfig>;
121 Name(
"BeamGateProducer"),
122 Comment(
"tag of beam gate information")
127 Name(
"TriggerProducer"),
128 Comment(
"tag of hardware trigger information")
133 Name(
"EmulatedTriggers"),
134 Comment(
"the emulated triggers to include in the tree")
139 Comment(
"name of the output ROOT tree"),
145 Comment(
"label for output messages of this module instance"),
146 "TriggerEmulationTree"
166 =
"beamGateStart/l:beamGateDuration/F:beamGateType/i";
176 =
"beamType/i:triggerTime/l:beamGateTime/l:triggerID/i:gateID/i";
244 : art::EDAnalyzer{ config }
246 , fBeamGateProducer { config().BeamGateProducer() }
247 , fTriggerProducer { config().TriggerProducer() }
251 art::ServiceHandle<art::TFileService>()->make<TTree>
252 (config().TreeName().c_str(),
"Trigger emulation results")
262 consumes<std::vector<sim::BeamGateInfo>>(fBeamGateProducer);
267 fStoreTree->Branch(
"run", &fEventID.run);
268 fStoreTree->Branch(
"subrun", &fEventID.subRun);
269 fStoreTree->Branch(
"event", &fEventID.event);
270 fStoreTree->Branch(
"beamInfo", &fBeamInfo, BeamInfo_t::branchDef);
272 (
"globalTrigger", &fGlobalTriggerInfo, GlobalTriggerInfo_t::branchDef);
280 fEventID = {
event.run(),
event.subRun(),
event.event() };
288 =
event.getProduct<std::vector<sim::BeamGateInfo>>(fBeamGateProducer);
290 mf::LogWarning(
fLogCategory) <<
"No Beam Gate Information!";
291 if(beamgate.size() > 1U)
292 mf::LogWarning(
fLogCategory) <<
"Event has multiple beam gate info labels! (maybe this changes later to be standard)";
293 fBeamInfo.beamGateSimStart = beamgate.front().Start();
294 fBeamInfo.beamGateDuration = beamgate.front().Width();
295 fBeamInfo.beamGateType = beamgate.front().BeamType();
300 auto const& triggerinfo
302 fGlobalTriggerInfo.beamType
303 =
static_cast<unsigned int>(triggerinfo.sourceType);
305 fGlobalTriggerInfo.beamGateTime = triggerinfo.beamGateTimestamp;
306 fGlobalTriggerInfo.triggerID = triggerinfo.triggerID;
307 fGlobalTriggerInfo.gateID = triggerinfo.gateID;
311 = fTriggerResponses.extractorsFor(event);
313 triggerResponseExtractors.
fetch(0);
324 mf::LogInfo(
fLogCategory) <<
"Processed " << fTotalProcessed <<
" events.";
static constexpr char branchDef[]
unsigned int beamGateType
friend TriggerInputSpec_t convert(Config::TriggerSpecConfig const &config)
fhicl::Sequence< TriggerSpecConfigTable > EmulatedTriggers
art::InputTag const fTriggerProducer
GlobalTriggerInfo_t fGlobalTriggerInfo
Data for global trigger in tree.
Manages extraction of trigger results and filling of their branches.
struct sbn::TriggerEmulationTree::@0 fEventID
Helper managing the trigger response part of a TTree.
fhicl::Atom< std::string > TreeName
fhicl::Atom< art::InputTag > TriggerTag
Fills a ROOT tree with trigger emulation results.
fhicl::Atom< std::string > Name
static constexpr char branchDef[]
art::EDAnalyzer::Table< Config > Parameters
fhicl::Atom< std::string > LogCategory
art::InputTag const fBeamGateProducer
std::uint64_t triggerTime
fhicl::Atom< art::InputTag > TriggerProducer
std::uint64_t beamGateSimStart
BEGIN_PROLOG vertical distance to the surface Name
fhicl::TableAs< TriggerInputSpec_t, TriggerSpecConfig > TriggerSpecConfigTable
Information about a single trigger logic (hardware or emulated).
Information on a single trigger source for the tree.
std::string const fLogCategory
fhicl::Atom< art::InputTag > BeamGateProducer
std::uint64_t beamGateTime
sbn::details::TriggerResponseManager fTriggerResponses
< Manages filling of trigger result branches.
void analyze(art::Event const &event) override
TriggerEmulationTree(Parameters const &config)
Data structure for the beam gate data in the tree.
TimeTrackTreeStorage::TriggerInputSpec_t convert(TimeTrackTreeStorage::Config::TriggerSpecConfig const &config)
unsigned int fTotalProcessed
Data structure for the global trigger data in the tree.