All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
icarus::trigger::MakeTriggerSimulationTree Class Reference

Make ROOT tree with information about event and trigger input. More...

Inheritance diagram for icarus::trigger::MakeTriggerSimulationTree:

Classes

struct  Config
 

Public Types

using microseconds = util::quantities::intervals::microseconds
 
using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 MakeTriggerSimulationTree (Parameters const &config)
 
 MakeTriggerSimulationTree (MakeTriggerSimulationTree const &)=delete
 
 MakeTriggerSimulationTree (MakeTriggerSimulationTree &&)=delete
 
MakeTriggerSimulationTreeoperator= (MakeTriggerSimulationTree const &)=delete
 
MakeTriggerSimulationTreeoperator= (MakeTriggerSimulationTree &&)=delete
 
virtual void analyze (art::Event const &event) override
 Fills the plots. Also extracts the information to fill them with. More...
 

Private Member Functions

TriggerGatesInfo extractTriggerInfo (art::Event const &event, detinfo::DetectorTimings const &detTimings) const
 Returns a TriggerGatesInfo with trigger information for the tree. More...
 
geo::Point_t gateChannelCentroid (icarus::trigger::OpticalTriggerGateData_t const &gate) const
 

Static Private Member Functions

static
icarus::trigger::details::EventInfoExtractor::EDepTags_t 
makeEdepTag (fhicl::OptionalSequence< art::InputTag > const &EnergyDepositTags, fhicl::OptionalAtom< art::InputTag > const &EnergyDepositSummaryTag)
 Creates a EDepTags_t from two optional parameters. More...
 

Private Attributes

microseconds const fBeamGateDuration
 Duration of the gate during with global optical triggers are accepted. More...
 
microseconds const fBeamGateStart
 Start of the beam gate with respect to BeamGate(). More...
 
microseconds const fPreSpillWindow
 Duration of the pre-spill gate. More...
 
microseconds const fPreSpillStart
 Start of the pre-spill gate. More...
 
art::InputTag const fTriggerGatesTag
 Tag for optical trigger gate data product. More...
 
std::string const fLogCategory
 Name of output stream for message facility. More...
 
geo::GeometryCore const & fGeom
 
details::EventIDTree fIDTree
 Main ROOT tree: event ID. More...
 
std::optional
< details::EventInfoTree
fEventTree
 ROOT tree: event information. More...
 
std::optional< TriggerGateTreefTriggerGateTree
 ROOT tree: trigger gates. More...
 
details::EventInfoExtractorMaker
const 
fEventInfoExtractorMaker
 Helper to fill a EventInfo_t from an art event. More...
 
icarus::ns::util::ThreadSafeChangeMonitor
< icarus::trigger::BeamGateStruct
fBeamGateChangeCheck
 Functor returning whether a gate has changed. More...
 

Detailed Description

Make ROOT tree with information about event and trigger input.

This module produces a ROOT tree with information about the event and about the trigger input.

Trigger simulation logic is applied in a time interval that we call "beam gate", although it would more precisely dubbed as "trigger gate". The reference time of this gate is the ("real") beam gate opening time as reported by detinfo::DetectorClocksData::BeamGateTime(), whose absolute value may vary event by event (see note below). The configuration of this module allows to shift pre-beam and beam gates with respect to that time.

Note: detector data and simulated data have intrinsically different time references. In LArSoft, the TPC waveform time reference is the most static and less flexible. Since the detector pins the TPC timing to the trigger time, TPC waveforms are written referring to that time, and then the whole event is also written in that frame. In simulated data, instead, a trigger is not known until after the (PMT) waveforms are produced, and it is therefore more convenient to refer to a time that is less dependent on data itself: the beam gate opening. In detector data, the value of beam gate opening time will appear to change event by event, as trigger(s) time do in simulated data. For this reason, all the analysis should be performed on relative times (e.g. relative to the trigger, which is the "native" LArSoft reference), i.e. in the trigger timescale or, equivalently, subtracting detinfo::DetectorClocksData::TriggerTime() from the times.

Input

The following data products are required in input:

Output

The output tree is written via TFileService in the ROOT directory assigned to this module.

The tree contains three "sections":

Configuration parameters

Technical description of the module

Definition at line 263 of file MakeTriggerSimulationTree_module.cc.

Member Typedef Documentation

Definition at line 267 of file MakeTriggerSimulationTree_module.cc.

Definition at line 333 of file MakeTriggerSimulationTree_module.cc.

Constructor & Destructor Documentation

icarus::trigger::MakeTriggerSimulationTree::MakeTriggerSimulationTree ( Parameters const &  config)
explicit

Definition at line 560 of file MakeTriggerSimulationTree_module.cc.

561  : art::EDAnalyzer(config)
562  // persistent configuration
563  , fBeamGateDuration (config().BeamGateDuration())
564  , fBeamGateStart (config().BeamGateStart())
565  , fPreSpillWindow (config().PreSpillWindow())
567  (fBeamGateStart - config().PreSpillWindowGap() - fPreSpillWindow)
568  , fTriggerGatesTag(config().TriggerGatesTag())
569  , fLogCategory(config().LogCategory())
570  // setup
571  , fGeom(*lar::providerFrom<geo::Geometry>())
572  // other data
573  , fIDTree(*(art::ServiceHandle<art::TFileService>()
574  ->make<TTree>(config().EventTreeName().c_str(), "Event information")
575  ))
576  , fEventTree(fIDTree.tree())
579  config().GeneratorTags(), // truthTags
580  makeEdepTag(config().EnergyDepositTags, config().EnergyDepositSummaryTag),
581  // edepTags
582  fGeom, // geom
583  nullptr, // detProps
584  nullptr, // detTimings
585  fLogCategory, // logCategory
586  consumesCollector() // consumesCollector
587  )
588 {
589 
590  //
591  // declaration of further input (more is by `fEventInfoExtractorMaker`)
592  //
593 
594  // none so far
595 
596 } // icarus::trigger::MakeTriggerSimulationTree::MakeTriggerSimulationTree()
std::optional< details::EventInfoTree > fEventTree
ROOT tree: event information.
art::InputTag const fTriggerGatesTag
Tag for optical trigger gate data product.
std::optional< TriggerGateTree > fTriggerGateTree
ROOT tree: trigger gates.
details::EventInfoExtractorMaker const fEventInfoExtractorMaker
Helper to fill a EventInfo_t from an art event.
microseconds const fPreSpillStart
Start of the pre-spill gate.
static icarus::trigger::details::EventInfoExtractor::EDepTags_t makeEdepTag(fhicl::OptionalSequence< art::InputTag > const &EnergyDepositTags, fhicl::OptionalAtom< art::InputTag > const &EnergyDepositSummaryTag)
Creates a EDepTags_t from two optional parameters.
microseconds const fPreSpillWindow
Duration of the pre-spill gate.
details::EventIDTree fIDTree
Main ROOT tree: event ID.
microseconds const fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
std::string const fLogCategory
Name of output stream for message facility.
microseconds const fBeamGateStart
Start of the beam gate with respect to BeamGate().
fDetProps &fDetProps fDetProps &fDetProps consumesCollector())
icarus::trigger::MakeTriggerSimulationTree::MakeTriggerSimulationTree ( MakeTriggerSimulationTree const &  )
delete
icarus::trigger::MakeTriggerSimulationTree::MakeTriggerSimulationTree ( MakeTriggerSimulationTree &&  )
delete

Member Function Documentation

void icarus::trigger::MakeTriggerSimulationTree::analyze ( art::Event const &  event)
overridevirtual

Fills the plots. Also extracts the information to fill them with.

Definition at line 601 of file MakeTriggerSimulationTree_module.cc.

602 {
603 
604  // we need to convert the two relevant gates with the proper parameters
607 
608  auto const beamGate = icarus::trigger::makeBeamGateStruct
609  (detTimings, fBeamGateDuration, fBeamGateStart);
610 
611  if (auto oldGate = fBeamGateChangeCheck(beamGate); oldGate) {
612  MF_LOG_DEBUG(fLogCategory)
613  << "Beam gate has changed from " << oldGate->asOptTickRange()
614  << " to " << beamGate.asOptTickRange() << " (optical tick)!";
615  }
616 
617  details::EventInfo_t const eventInfo = fEventInfoExtractorMaker(
618  beamGate.asSimulationRange(),
622  )(event);
623 
624  TriggerGatesInfo const triggerInfo = extractTriggerInfo(event, detTimings);
625 
626  mf::LogDebug(fLogCategory) << event.id() << " trigger info: " << triggerInfo;
627 
628  fIDTree.assignID(event.id());
629  if (fEventTree) fEventTree->assignEvent(eventInfo);
630  if (fTriggerGateTree) fTriggerGateTree->assignTriggerGatesInfo(triggerInfo);
631 
632  fIDTree.tree().Fill();
633 
634 } // icarus::trigger::MakeTriggerSimulationTree::analyze()
std::optional< details::EventInfoTree > fEventTree
ROOT tree: event information.
TriggerGatesInfo extractTriggerInfo(art::Event const &event, detinfo::DetectorTimings const &detTimings) const
Returns a TriggerGatesInfo with trigger information for the tree.
std::optional< TriggerGateTree > fTriggerGateTree
ROOT tree: trigger gates.
details::EventInfoExtractorMaker const fEventInfoExtractorMaker
Helper to fill a EventInfo_t from an art event.
TimeRange< simulation_time > const & asSimulationRange() const
Returns the gate as start/stop pair in simulation time scale.
microseconds const fPreSpillStart
Start of the pre-spill gate.
microseconds const fPreSpillWindow
Duration of the pre-spill gate.
details::EventIDTree fIDTree
Main ROOT tree: event ID.
All information from the trigger gates.
microseconds const fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
void assignID(art::EventID const &id)
Fills the information of the specified event.
Definition: EventIDTree.cxx:29
BeamGateStruct makeBeamGateStruct(detinfo::DetectorTimings const &detTimings, util::quantities::intervals::microseconds duration, util::quantities::intervals::microseconds delay=util::quantities::intervals::microseconds{0.0})
Creates a BeamGateStruct object of specified duration and start.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
icarus::ns::util::ThreadSafeChangeMonitor< icarus::trigger::BeamGateStruct > fBeamGateChangeCheck
Functor returning whether a gate has changed.
fDetProps &fDetProps fDetProps &fDetProps detTimings
std::string const fLogCategory
Name of output stream for message facility.
microseconds const fBeamGateStart
Start of the beam gate with respect to BeamGate().
detinfo::DetectorTimings makeDetTimings(art::Event const *event)
Returns a detinfo::DetectorTimings from DetectorClocksService.
TriggerGatesInfo icarus::trigger::MakeTriggerSimulationTree::extractTriggerInfo ( art::Event const &  event,
detinfo::DetectorTimings const &  detTimings 
) const
private

Returns a TriggerGatesInfo with trigger information for the tree.

Parameters
eventthe art event where to find the trigger gates
detTimingsdetector timings updated for this event
Returns
a TriggerGatesInfo with trigger information for the tree

Information from the trigger gates configured in the module is extracted and stored into a TriggerGatesInfo object, which is returned. The data fields are defined as follows:

  • a TriggerGateInfo element is stored in TriggerGatesInfo::info for each and every trigger gate in the input, in the same order as the input data product;
  • for each gate:
    • TriggerGateInfo::center: for each channel associated to the trigger gate, the geometric center of the optical detector connected to that channel is taken; center is set to the middle point (unweighted 3D centroid) of all those points; the center is in world coordinates and in centimeters;it is assumed that the trigger gate is associated to at least one channel, otherwise behavior is undefined;
    • TriggerGateInfo::nOpenings: the number of times in coincidence with the beam gate, when the gate changes state from closed (opening level 0) to open (opening level 1 or larger);
    • TriggerGateInfo::firstOpenTime: the time the first of the openings (as defined in nOpenings) happens; the time is in simulation time scale; if there was no opening during the beam gate (nOpenings zero), the value is undefined;
    • 'TriggerGateInfo::Amplitude': the amplitude of the PMT

Definition at line 639 of file MakeTriggerSimulationTree_module.cc.

640 {
641  /*
642  * 1. get the data product from the event
643  * 2. fill one "channel" of `TriggerGateInfo` per entry in the data product
644  * 1. get centroid of associated detectors
645  * 2. find and convert to `simulation_time` the first opening
646  * 3. find the number of openings
647  * 4. find the amplitude
648  * 4. fill the information
649  *
650  */
651 
654 
655  //
656  // 0. construct the beam gate for this event
657  //
658  auto const beamGate = icarus::trigger::BeamGateMaker{ detTimings }
660 
661  //
662  // 1. get the data product from the event
663  //
664  auto const& gates
665  = event.getProduct<std::vector<OpticalTriggerGateData_t>>(fTriggerGatesTag);
666 
667  //
668  // 2. fill one "channel" of `TriggerGateInfo` per entry in the data product
669  //
671 
672  unsigned int nOpenChannels = 0U; // count for debugging message
673  for (OpticalTriggerGateData_t const& gate: gates) {
674 
675  // the gate, in coincidence with the beam gate:
676  auto const beamAndGate = OpticalTriggerGateData_t::Mul(gate, beamGate);
677 
678  //
679  // 2.2. find and convert to `simulation_time` the first opening
680  //
681  OpticalTriggerGateData_t::ClockTick_t const firstOpenTick
682  = beamAndGate.findOpen();
683 
684  //
685  // 2.3. find the number of openings
686  //
687  unsigned int nOpenings = 0U;
688  OpticalTriggerGateData_t::ClockTick_t openTick = firstOpenTick;
689  while (openTick != OpticalTriggerGateData_t::MaxTick) {
690  ++nOpenings;
691  // move out of this open region, then find the next one
692  openTick = beamAndGate.findClose(1U, openTick);
693  openTick = beamAndGate.findOpen(1U, openTick);
694  } // while
695  if (nOpenings > 0) ++nOpenChannels;
696 
697  //
698  // 2.4. fill the information
699  //
700  info.TriggerGates.push_back({
701  gateChannelCentroid(gate), // 2.1. get centroid of associated detectors
702  nOpenings,
703  // users should ignore this if `nOpenings == 0`:
704  (nOpenings == 0U)
705  ? std::numeric_limits<simulation_time>::max() //std::numeric_limits<T>::max Returns the maximum finite value representable by the
706  //numeric type T. Meaningful for all bounded types.
707  : detTimings.toSimulationTime
708  (detinfo::timescales::optical_tick{ firstOpenTick })
709  //,amplitude
710  });
711 
712  } // for all gates
713 
714  mf::LogTrace(fLogCategory)
715  << "Information from '" << fTriggerGatesTag.encode() << "' ("
716  << gates.size() << " trigger gates, " << nOpenChannels
717  << " channels) written to tree."
718  ;
719 
720  return info;
721 } // icarus::trigger::MakeTriggerSimulationTree::extractTriggerInfo()
ReadoutTriggerGate & Mul(ReadoutTriggerGate const &other)
Combines with a gate, keeping the product of openings of the two.
art::InputTag const fTriggerGatesTag
Tag for optical trigger gate data product.
static constexpr ClockTick_t MaxTick
An unbearably large tick number.
geo::Point_t gateChannelCentroid(icarus::trigger::OpticalTriggerGateData_t const &gate) const
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
All information from the trigger gates.
microseconds const fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
Simple utility to generate gates around beam time.
Definition: BeamGateMaker.h:49
fDetProps &fDetProps fDetProps &fDetProps detTimings
std::string const fLogCategory
Name of output stream for message facility.
microseconds const fBeamGateStart
Start of the beam gate with respect to BeamGate().
geo::Point_t icarus::trigger::MakeTriggerSimulationTree::gateChannelCentroid ( icarus::trigger::OpticalTriggerGateData_t const &  gate) const
private

Returns the centroid (middle point) of all the centers of optical detectors contributing to the specified gate, in world coordinates [cm]

Definition at line 726 of file MakeTriggerSimulationTree_module.cc.

727 {
728 
730 
731  for (auto const channel: gate.channels()) {
732 
733  try {
734  centroid.add(fGeom.OpDetGeoFromOpChannel(channel).GetCenter());
735  }
736  catch (cet::exception const& e) {
737  throw cet::exception("MakeTriggerSimulationTree", "", e)
738  << "Error while accessing position of optical detector with channel "
739  << channel << "\n";
740  }
741 
742  } // for
743 
744  return centroid.middlePoint();
745 
746 } // icarus::trigger::MakeTriggerSimulationTree::gateChannelCentroid()
Helper class to compute the middle point in a point set.
void GetCenter(double *xyz, double localz=0.0) const
Definition: OpDetGeo.cxx:40
void add(Point const &p)
Accumulates a point.
do i e
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
icarus::trigger::details::EventInfoExtractor::EDepTags_t icarus::trigger::MakeTriggerSimulationTree::makeEdepTag ( fhicl::OptionalSequence< art::InputTag > const &  EnergyDepositTags,
fhicl::OptionalAtom< art::InputTag > const &  EnergyDepositSummaryTag 
)
staticprivate

Creates a EDepTags_t from two optional parameters.

Definition at line 751 of file MakeTriggerSimulationTree_module.cc.

754  {
755 
756  if (EnergyDepositSummaryTag.hasValue()) {
757  if (EnergyDepositTags.hasValue()) {
758  throw art::Exception(art::errors::Configuration)
759  << "MakeTriggerSimulationTree: "
760  << "both EnergyDepositTags and EnergyDepositSummaryTag "
761  << "have been specified, but they are exclusive: @erase one.\n";
762  }
763 
764  art::InputTag tag;
765  EnergyDepositSummaryTag(tag);
766  return {
768  { tag }
769  };
770  }
771  else {
772 
773  std::vector<art::InputTag> tags;
774  if (!EnergyDepositTags(tags)) tags.push_back("largeant:TPCActive");
775  return { std::move(tags) };
776 
777  }
778 
779 } // icarus::trigger::MakeTriggerSimulationTree::makeEdepTag()
Utility tag to identify a parameter as a specific type of tag.
MakeTriggerSimulationTree& icarus::trigger::MakeTriggerSimulationTree::operator= ( MakeTriggerSimulationTree const &  )
delete
MakeTriggerSimulationTree& icarus::trigger::MakeTriggerSimulationTree::operator= ( MakeTriggerSimulationTree &&  )
delete

Member Data Documentation

icarus::ns::util::ThreadSafeChangeMonitor<icarus::trigger::BeamGateStruct> icarus::trigger::MakeTriggerSimulationTree::fBeamGateChangeCheck
private

Functor returning whether a gate has changed.

Definition at line 406 of file MakeTriggerSimulationTree_module.cc.

microseconds const icarus::trigger::MakeTriggerSimulationTree::fBeamGateDuration
private

Duration of the gate during with global optical triggers are accepted.

Definition at line 362 of file MakeTriggerSimulationTree_module.cc.

microseconds const icarus::trigger::MakeTriggerSimulationTree::fBeamGateStart
private

Start of the beam gate with respect to BeamGate().

Definition at line 365 of file MakeTriggerSimulationTree_module.cc.

details::EventInfoExtractorMaker const icarus::trigger::MakeTriggerSimulationTree::fEventInfoExtractorMaker
private

Helper to fill a EventInfo_t from an art event.

Definition at line 402 of file MakeTriggerSimulationTree_module.cc.

std::optional<details::EventInfoTree> icarus::trigger::MakeTriggerSimulationTree::fEventTree
private

ROOT tree: event information.

Definition at line 396 of file MakeTriggerSimulationTree_module.cc.

geo::GeometryCore const& icarus::trigger::MakeTriggerSimulationTree::fGeom
private

Definition at line 382 of file MakeTriggerSimulationTree_module.cc.

details::EventIDTree icarus::trigger::MakeTriggerSimulationTree::fIDTree
private

Main ROOT tree: event ID.

Definition at line 390 of file MakeTriggerSimulationTree_module.cc.

std::string const icarus::trigger::MakeTriggerSimulationTree::fLogCategory
private

Name of output stream for message facility.

Definition at line 375 of file MakeTriggerSimulationTree_module.cc.

microseconds const icarus::trigger::MakeTriggerSimulationTree::fPreSpillStart
private

Start of the pre-spill gate.

Definition at line 369 of file MakeTriggerSimulationTree_module.cc.

microseconds const icarus::trigger::MakeTriggerSimulationTree::fPreSpillWindow
private

Duration of the pre-spill gate.

Definition at line 367 of file MakeTriggerSimulationTree_module.cc.

art::InputTag const icarus::trigger::MakeTriggerSimulationTree::fTriggerGatesTag
private

Tag for optical trigger gate data product.

Definition at line 372 of file MakeTriggerSimulationTree_module.cc.

std::optional<TriggerGateTree> icarus::trigger::MakeTriggerSimulationTree::fTriggerGateTree
private

ROOT tree: trigger gates.

Definition at line 399 of file MakeTriggerSimulationTree_module.cc.


The documentation for this class was generated from the following file: