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

Extracts from event the relevant information on the physics event. More...

#include <EventInfoUtils.h>

Classes

struct  CategorizedInputTag
 Utility tag to identify a parameter as a specific type of tag. More...
 

Public Types

enum  InputType { InputType::EnergyDeposits, InputType::EnergyDepositSummary, InputType::SimChannels, InputType::Unknown }
 Enumerator of possible inputs. More...
 
using simulation_time = detinfo::timescales::simulation_time
 
using TimeSpan_t = std::pair< simulation_time, simulation_time >
 
using SimEnergyDepositSummaryInputTag = CategorizedInputTag< InputType::EnergyDepositSummary >
 Utility tag to identify a parameter as for SimEnergyDepositSummary tag. More...
 
using SimChannelsInputTag = CategorizedInputTag< InputType::SimChannels >
 Utility tag to identify a parameter as for sim::SimChannel tag. More...
 
using EDepTags_t = std::variant< std::vector< art::InputTag >, SimEnergyDepositSummaryInputTag, SimChannelsInputTag >
 Type to specify the source of energy deposition information, if any. More...
 

Public Member Functions

bool hasGenerated () const
 Returns whether we are extracting any generator information. More...
 
bool hasEDep () const
 Returns whether we are extracting any energy deposition information. More...
 
template<typename Event >
auto extractInfo (Event const &event) const -> EventInfo_t
 
Constructors

Constructors are available to take advantage of specific art features, and for the generic art/_gallery_ compatible interfaces.

 EventInfoExtractor (std::vector< art::InputTag > truthTags, EDepTags_t edepTags, TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const &geom, detinfo::DetectorPropertiesData const *detProps, detinfo::DetectorTimings const *detTimings, std::string logCategory="EventInfoExtractor")
 Constructor: configures the object. More...
 
template<typename ConsumesColl >
 EventInfoExtractor (std::vector< art::InputTag > truthTags, std::vector< art::InputTag > edepTags, TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const &geom, detinfo::DetectorPropertiesData const *detProps, detinfo::DetectorTimings const *detTimings, std::string logCategory, ConsumesColl &consumesCollector)
 Constructor: configures, and declares consuming data product. More...
 
template<typename Event >
EventInfo_t extractInfo (Event const &event) const
 Returns an EventInfo_t object with information from event. More...
 
template<typename Event >
EventInfo_t operator() (Event const &event) const
 

Static Public Member Functions

static bool isEDepSummaryTag (EDepTags_t const &edepTag)
 Returns whether edepTags contains a energy deposition summary tag. More...
 
static bool isEDepListTag (EDepTags_t const &edepTag)
 Returns whether edepTags contains energy deposition list tags. More...
 
static bool isEDepSpecified (EDepTags_t const &edepTag)
 Returns whether edepTags contains any energy deposition tag. More...
 

Static Public Attributes

static EDepTags_t const NoEDepTags {}
 Represents the absence of any energy deposition information. More...
 

Private Member Functions

bool useEnergyDepositSummary () const
 Returns whether we use energy summary instead of full energy deposits. More...
 
void fillGeneratorInfo (EventInfo_t &info, simb::MCTruth const &truth) const
 Fills info record with generation information from truth. More...
 
void fillGeneratorNeutrinoInfo (EventInfo_t &info, simb::MCTruth const &truth) const
 Fills info record with generated neutrino information from truth. More...
 
void setMainGeneratorNeutrinoInfo (EventInfo_t &info, simb::MCTruth const &truth) const
 
void addGeneratorNeutrinoInfo (EventInfo_t &info, simb::MCTruth const &truth) const
 
void addEnergyDepositionInfo (EventInfo_t &info, std::vector< sim::SimEnergyDeposit > const &energyDeposits) const
 Adds the energy depositions from energyDeposits into info record. More...
 
void addEnergyDepositionInfo (EventInfo_t &info, std::vector< sim::SimChannel > const &channels) const
 Adds the energy depositions from channels into info record. More...
 
geo::TPCGeo const * pointInTPC (geo::Point_t const &point) const
 Returns in which TPC volume point falls in (nullptr if none). More...
 
geo::TPCGeo const * pointInActiveTPC (geo::Point_t const &point) const
 Returns in which active TPC volume point falls in (nullptr if none). More...
 
simulation_time getInteractionTime (simb::MCTruth const &truth) const
 

Static Private Member Functions

template<typename ConsumesColl >
static void declareConsumables (ConsumesColl &consumesCollector, std::vector< art::InputTag > const &truthTags, EDepTags_t const &edepTags)
 Declares all the consumables to the collector. More...
 

Private Attributes

friend EventInfoExtractorMaker
 
std::vector< art::InputTag > const fGeneratorTags
 List of truth data product tags (std::vector<simb::MCTruth>). More...
 
EDepTags_t const fEnergyDepositTags
 
std::string const fLogCategory
 Stream name for message facility. More...
 
geo::GeometryCore const & fGeom
 Geometry service provider. More...
 
detinfo::DetectorPropertiesData
const * 
fDetProps = nullptr
 Detector timing conversion utility. More...
 
detinfo::DetectorTimings const * fDetTimings = nullptr
 
TimeSpan_t const fInSpillTimes
 Start and stop time for "in spill" label. More...
 
TimeSpan_t const fInPreSpillTimes
 Start and stop time for "pre-spill" label. More...
 

Detailed Description

Extracts from event the relevant information on the physics event.

This returns a EventInfo_t object filled as completely as possible.

The EventInfo_t is managed so that it contains all the information about the "main" neutrino interaction. All other neutrino interactions are acknowledged but their information is not stored, with minor exceptions. Currently:

This class can read any data product in the event, and is completely configured at construction time via constructor arguments. If information is needed from a data product that is not read yet, the following actions are needed:

  1. decide the input tag of the data product(s) to be read; this is usually delegated to the user via a configuration parameter;
  2. the required input tags need to be stored into data members;
  3. art needs to be informed of the intention of reading the data products via consumes() or equivalent calls; this class can take care of that, if a art::ConsumesCollector object is provided;
  4. the data product can be read with the usual means.

Energy deposition

The energy deposition information is event-wide and does not select depositions from any specific interaction.

The energy depositions are grouped according to whether they are within the time interval of the beam spill window, a pre-spill window, or at any time; and whether they are in the active volume or anywhere. The depositions can be collected from a sim::SimEnergyDeposit list of data products or (not recommended) from a single sim::SimChannel data product. In the latter case, the depositions are extracted from the channels on the first interaction plane (always plane 0 according to LArSoft definitions), which is usually the largest of the planes.

Definition at line 99 of file EventInfoUtils.h.

Member Typedef Documentation

Type to specify the source of energy deposition information, if any.

Definition at line 149 of file EventInfoUtils.h.

Utility tag to identify a parameter as for sim::SimChannel tag.

Definition at line 141 of file EventInfoUtils.h.

Utility tag to identify a parameter as for SimEnergyDepositSummary tag.

Definition at line 138 of file EventInfoUtils.h.

Definition at line 103 of file EventInfoUtils.h.

Definition at line 104 of file EventInfoUtils.h.

Member Enumeration Documentation

Enumerator of possible inputs.

Enumerator
EnergyDeposits 
EnergyDepositSummary 
SimChannels 
Unknown 

Definition at line 107 of file EventInfoUtils.h.

107  {
108  EnergyDeposits,
109  EnergyDepositSummary,
110  SimChannels,
111  Unknown
112  }; // InputType
Type of beam unknown.

Constructor & Destructor Documentation

icarus::trigger::details::EventInfoExtractor::EventInfoExtractor ( std::vector< art::InputTag >  truthTags,
EDepTags_t  edepTags,
TimeSpan_t  inSpillTimes,
TimeSpan_t  inPreSpillTimes,
geo::GeometryCore const &  geom,
detinfo::DetectorPropertiesData const *  detProps,
detinfo::DetectorTimings const *  detTimings,
std::string  logCategory = "EventInfoExtractor" 
)

Constructor: configures the object.

Parameters
truthTagslist of truth information data products to be read
edepTagslist of energy deposition data products to be read
inSpillTimesstart and end of spill, in simulation time
inPreSpillTimesstart and end of pre-spill, in simulation time
geomLArSoft geometry service provider
detTimingsPtrpointer to LArSoft detector timings utility
logCategoryname of message facility stream to sent messages to
See Also
EventInfoExtractor(std::vector<art::InputTag> const&, ConsumesColl&)

In art framework context, prefer the EventInfoExtractor(std::vector<art::InputTag> const&, ConsumesColl&) constructor.

Two formats of energy depositions are supported:

  • standard LArSoft (std::vector<sim::SimEnergyDeposit>): specify a vector of input tags in edepTags argument;
  • ICARUS deposited energy summary: specify an input tag converted into a SimEnergyDepositSummaryInputTag parameter in edepTags argument.

Definition at line 97 of file EventInfoUtils.cxx.

107  : fGeneratorTags(std::move(truthTags))
108  , fEnergyDepositTags(std::move(edepTags))
109  , fLogCategory(std::move(logCategory))
110  , fGeom(geom)
113  , fInSpillTimes(std::move(inSpillTimes))
114  , fInPreSpillTimes(std::move(inPreSpillTimes))
115 {
116 } // icarus::trigger::details::EventInfoExtractor::EventInfoExtractor()
fDetProps &fDetProps detProps
TimeSpan_t const fInPreSpillTimes
Start and stop time for &quot;pre-spill&quot; label.
TimeSpan_t const fInSpillTimes
Start and stop time for &quot;in spill&quot; label.
detinfo::DetectorPropertiesData const * fDetProps
Detector timing conversion utility.
geo::GeometryCore const & fGeom
Geometry service provider.
detinfo::DetectorTimings const * fDetTimings
std::vector< art::InputTag > const fGeneratorTags
List of truth data product tags (std::vector&lt;simb::MCTruth&gt;).
fDetProps &fDetProps fDetProps &fDetProps detTimings
std::string const fLogCategory
Stream name for message facility.
template<typename ConsumesColl >
icarus::trigger::details::EventInfoExtractor::EventInfoExtractor ( std::vector< art::InputTag >  truthTags,
std::vector< art::InputTag >  edepTags,
TimeSpan_t  inSpillTimes,
TimeSpan_t  inPreSpillTimes,
geo::GeometryCore const &  geom,
detinfo::DetectorPropertiesData const *  detProps,
detinfo::DetectorTimings const *  detTimings,
std::string  logCategory,
ConsumesColl &  consumesCollector 
)

Constructor: configures, and declares consuming data product.

Template Parameters
ConsumesColltype with art::ConsumesCollector interface
Parameters
truthTagslist of truth information data products to be read
edepTagslist of energy deposition data products to be read
inSpillTimesstart and end of spill, in simulation time
inPreSpillTimesstart and end of pre-spill, in simulation time
geomLArSoft geometry service provider
detTimingsLArSoft detector timings utility
logCategoryname of message facility stream to sent messages to
consumesCollectorobject to declare the consumed products to

Typical usage is within a art module constructor:

{ art:InputTag{ "generator" } },
};

Definition at line 458 of file EventInfoUtils.h.

470  std::move(truthTags), std::move(edepTags),
471  inSpillTimes, inPreSpillTimes,
472  geom, detProps, detTimings, std::move(logCategory)
473  }
474 {
476 } // icarus::trigger::details::EventInfoExtractor::EventInfoExtractor(coll)
fDetProps &fDetProps detProps
static void declareConsumables(ConsumesColl &consumesCollector, std::vector< art::InputTag > const &truthTags, EDepTags_t const &edepTags)
Declares all the consumables to the collector.
EventInfoExtractor(std::vector< art::InputTag > truthTags, EDepTags_t edepTags, TimeSpan_t inSpillTimes, TimeSpan_t inPreSpillTimes, geo::GeometryCore const &geom, detinfo::DetectorPropertiesData const *detProps, detinfo::DetectorTimings const *detTimings, std::string logCategory="EventInfoExtractor")
Constructor: configures the object.
std::vector< art::InputTag > const fGeneratorTags
List of truth data product tags (std::vector&lt;simb::MCTruth&gt;).
fDetProps &fDetProps fDetProps &fDetProps detTimings
fDetProps &fDetProps fDetProps &fDetProps consumesCollector())

Member Function Documentation

void icarus::trigger::details::EventInfoExtractor::addEnergyDepositionInfo ( EventInfo_t info,
std::vector< sim::SimEnergyDeposit > const &  energyDeposits 
) const
private

Adds the energy depositions from energyDeposits into info record.

Definition at line 229 of file EventInfoUtils.cxx.

231 {
233 
234  auto Eacc = EnergyAccumulator(fInSpillTimes, fInPreSpillTimes, fGeom);
235 
236  for (sim::SimEnergyDeposit const& edep: energyDeposits) {
237 
238  Eacc.add(
239  MeV{ edep.Energy() } // assuming it's stored in MeV
240  , detinfo::timescales::simulation_time{ edep.Time() }
241  , edep.MidPoint()
242  );
243 
244  } // for all energy deposits in the data product
245 
246  info.SetDepositedEnergy
247  (info.DepositedEnergy() + Eacc.totalEnergy);
249  (info.DepositedEnergyInSpill() + Eacc.inSpillEnergy);
250  info.SetDepositedEnergyInPreSpill
251  (info.DepositedEnergyInPreSpill() + Eacc.inPreSpillEnergy);
253  (info.DepositedEnergyInActiveVolume() + Eacc.activeEnergy);
254  info.SetDepositedEnergyInSpillInActiveVolume
255  (info.DepositedEnergyInSpillInActiveVolume() + Eacc.inSpillActiveEnergy);
256  info.SetDepositedEnergyInPreSpillInActiveVolume(
257  info.DepositedEnergyInPreSpillInActiveVolume() + Eacc.inPreSpillActiveEnergy
258  );
259 
260 } // icarus::trigger::details::EventInfoExtractor::addEnergyDepositionInfo()
GeV DepositedEnergyInSpill() const
Returns the total energy deposited in the detector during beam [GeV].
GeV DepositedEnergyInSpillInActiveVolume() const
Returns the energy deposited in the active volume during the beam [GeV].
TimeSpan_t const fInPreSpillTimes
Start and stop time for &quot;pre-spill&quot; label.
TimeSpan_t const fInSpillTimes
Start and stop time for &quot;in spill&quot; label.
GeV DepositedEnergyInActiveVolume() const
Returns the energy deposited in the active volume during the event [GeV].
timescale_traits< SimulationTimeCategory >::time_point_t simulation_time
A point in time on the simulation time scale.
A value measured in the specified unit.
Definition: quantities.h:566
megaelectronvolt_as<> megaelectronvolt
Type of energy stored in megaelectronvolt, in double precision.
Definition: energy.h:119
geo::GeometryCore const & fGeom
Geometry service provider.
Energy deposition in the active material.
void SetDepositedEnergy(GeV e)
Sets the total deposited energy of the event [GeV].
void SetDepositedEnergyInActiveVolume(GeV e)
Sets the total deposited energy of the event in active volume [GeV].
GeV DepositedEnergy() const
Returns the total energy deposited in the detector during the event [GeV].
void SetDepositedEnergyInSpill(GeV e)
Sets the energy of the event deposited during beam gate [GeV].
void icarus::trigger::details::EventInfoExtractor::addEnergyDepositionInfo ( EventInfo_t info,
std::vector< sim::SimChannel > const &  channels 
) const
private

Adds the energy depositions from channels into info record.

Definition at line 265 of file EventInfoUtils.cxx.

266 {
267  assert(fDetProps);
268  assert(fDetTimings);
269 
271 
272  auto Eacc = EnergyAccumulator(fInSpillTimes, fInPreSpillTimes, fGeom);
273 
274  double const driftVel = fDetProps->DriftVelocity(); // cm/us
275 
276  for (sim::SimChannel const& channel: channels) {
277 
278  // only channels on any of the first induction planes
279  std::vector<geo::WireID> const& wires
280  = fGeom.ChannelToWire(channel.Channel());
281  if (empty(wires)) continue; // ghost channel or something; move on
282  if (wires.front().Plane != 0) continue; // not the first induction plane
283 
284  geo::PlaneGeo const& plane = fGeom.Plane(wires.front());
285 
286  for (auto const& [ tdc, IDEs ]: channel.TDCIDEMap()) {
287 
288  // collection tick: includes also drift time, diffusion and what-not
292 
293  for (sim::IDE const& IDE: IDEs) {
294  MeV const energy { IDE.energy }; // assuming it's stored in MeV
295  geo::Point_t const location { IDE.x, IDE.y, IDE.z };
296 
297  // tentative estimation of drift length:
298  double const d = plane.DistanceFromPlane(location); // cm
300  { d / driftVel };
301 
302  Eacc.add(energy, time - driftTime, location);
303  } // all deposits at this time tick
304 
305  } // all time ticks in this channel
306 
307  } // for all channels
308 
309  info.SetDepositedEnergy
310  (info.DepositedEnergy() + Eacc.totalEnergy);
312  (info.DepositedEnergyInSpill() + Eacc.inSpillEnergy);
313  info.SetDepositedEnergyInPreSpill
314  (info.DepositedEnergyInPreSpill() + Eacc.inPreSpillEnergy);
316  (info.DepositedEnergyInActiveVolume() + Eacc.activeEnergy);
317  info.SetDepositedEnergyInSpillInActiveVolume
318  (info.DepositedEnergyInSpillInActiveVolume() + Eacc.inSpillActiveEnergy);
319  info.SetDepositedEnergyInPreSpillInActiveVolume(
320  info.DepositedEnergyInPreSpillInActiveVolume() + Eacc.inPreSpillActiveEnergy
321  );
322 
323 } // icarus::trigger::details::EventInfoExtractor::addEnergyDepositionInfo()
GeV DepositedEnergyInSpill() const
Returns the total energy deposited in the detector during beam [GeV].
GeV DepositedEnergyInSpillInActiveVolume() const
Returns the energy deposited in the active volume during the beam [GeV].
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
timescale_traits< ElectronicsTimeCategory >::tick_t electronics_tick
A point on the electronics time scale expressed in its ticks.
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:145
TimeSpan_t const fInPreSpillTimes
Start and stop time for &quot;pre-spill&quot; label.
TimeSpan_t const fInSpillTimes
Start and stop time for &quot;in spill&quot; label.
GeV DepositedEnergyInActiveVolume() const
Returns the energy deposited in the active volume during the event [GeV].
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
detinfo::DetectorPropertiesData const * fDetProps
Detector timing conversion utility.
timescale_traits< SimulationTimeCategory >::time_point_t simulation_time
A point in time on the simulation time scale.
Ionization at a point of the TPC sensitive volume.
Definition: SimChannel.h:86
A value measured in the specified unit.
Definition: quantities.h:566
megaelectronvolt_as<> megaelectronvolt
Type of energy stored in megaelectronvolt, in double precision.
Definition: energy.h:119
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
simulation_time toSimulationTime(FromTime time) const
Converts a time point into simulation time scale.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:114
geo::GeometryCore const & fGeom
Geometry service provider.
detinfo::DetectorTimings const * fDetTimings
double DistanceFromPlane(geo::Point_t const &point) const
Returns the distance of the specified point from the wire plane.
Definition: PlaneGeo.h:621
void SetDepositedEnergy(GeV e)
Sets the total deposited energy of the event [GeV].
void SetDepositedEnergyInActiveVolume(GeV e)
Sets the total deposited energy of the event in active volume [GeV].
GeV DepositedEnergy() const
Returns the total energy deposited in the detector during the event [GeV].
void SetDepositedEnergyInSpill(GeV e)
Sets the energy of the event deposited during beam gate [GeV].
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
void icarus::trigger::details::EventInfoExtractor::addGeneratorNeutrinoInfo ( EventInfo_t info,
simb::MCTruth const &  truth 
) const
private

Adds selected information from the interaction in truth to info record.

Definition at line 206 of file EventInfoUtils.cxx.

207 {
208  /*
209  * The only update to the record so far is the addition of the vertex of the
210  * interaction at the end of the current list.
211  * No information is overwritten.
212  *
213  */
214 
215  simb::MCParticle const& nu = truth.GetNeutrino().Nu();
216 
217  // we do not trust the vertex (`GvX()`) of the neutrino particle,
218  // since GenieHelper does not translate the vertex
219  // of some of the particles from GENIE to detector frame;
220  // trajectory is always translated:
221  geo::Point_t const vertex { nu.EndX(), nu.EndY(), nu.EndZ() };
222  info.AddVertex(vertex);
223 
224 } // icarus::trigger::details::EventInfoExtractor::addGeneratorNeutrinoInfo()
process_name vertex
Definition: cheaterreco.fcl:51
void AddVertex(geo::Point_t const &vertex)
Adds a point to the list of interaction vertices in the event.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
BEGIN_PROLOG SN nu
template<typename ConsumesColl >
void icarus::trigger::details::EventInfoExtractor::declareConsumables ( ConsumesColl &  consumesCollector,
std::vector< art::InputTag > const &  truthTags,
EDepTags_t const &  edepTags 
)
staticprivate

Declares all the consumables to the collector.

Definition at line 571 of file EventInfoUtils.h.

575  {
576 
577  for (art::InputTag const& inputTag: truthTags)
578  consumesCollector.template consumes<std::vector<simb::MCTruth>>(inputTag);
579 
580  if (
581  auto* summaryTag = std::get_if<SimEnergyDepositSummaryInputTag>(&edepTags);
582  summaryTag
583  ) {
584 
585  consumesCollector.template consumes<icarus::SimEnergyDepositSummary>
586  (static_cast<art::InputTag const&>(*summaryTag));
587 
588  }
589  else if (
590  auto* edepListTag = std::get_if<std::vector<art::InputTag>>(&edepTags);
591  edepListTag
592  ) {
593  // may be empty
594  for (art::InputTag const& inputTag: *edepListTag) {
595  consumesCollector.template consumes<std::vector<sim::SimEnergyDeposit>>
596  (inputTag);
597  }
598  }
599 
600 } // icarus::trigger::details::EventInfoExtractor::declareConsumables()
fDetProps &fDetProps fDetProps &fDetProps consumesCollector())
template<typename Event >
EventInfo_t icarus::trigger::details::EventInfoExtractor::extractInfo ( Event const &  event) const

Returns an EventInfo_t object with information from event.

Template Parameters
Eventtype of event to read data from (art or gallery event)
Parameters
eventevent record to read the information from
Returns
a EventInfo_t with information extracted from event
template<typename Event >
auto icarus::trigger::details::EventInfoExtractor::extractInfo ( Event const &  event) const -> EventInfo_t

Definition at line 482 of file EventInfoUtils.h.

483 {
484 
486 
487  //
488  // generator information
489  //
490  for (art::InputTag const& inputTag: fGeneratorTags) {
491 
492  auto const& truthRecords
493  = event.template getProduct<std::vector<simb::MCTruth>>(inputTag);
494 
495  for (simb::MCTruth const& truth: truthRecords) {
496 
497  fillGeneratorInfo(info, truth);
498 
499  } // for truth records
500 
501  } // for generators
502 
503  //
504  // propagation in the detector
505  //
506  if (auto* summaryTag
507  = std::get_if<SimEnergyDepositSummaryInputTag>(&fEnergyDepositTags)
508  ) {
509 
511 
512  auto const& energyDeposits = event
513  .template getProduct<icarus::SimEnergyDepositSummary>(summaryTag->tag());
514 
515  info.SetDepositedEnergy (GeV(energyDeposits.Total));
516  info.SetDepositedEnergyInSpill (GeV(energyDeposits.Spill));
517  info.SetDepositedEnergyInPreSpill (GeV(energyDeposits.PreSpill));
518  info.SetDepositedEnergyInActiveVolume (GeV(energyDeposits.Active));
519  info.SetDepositedEnergyInSpillInActiveVolume (GeV(energyDeposits.SpillActive));
520  info.SetDepositedEnergyInPreSpillInActiveVolume(GeV(energyDeposits.PreSpillActive));
521 
522  }
523  else if
524  (auto* channelsTag = std::get_if<SimChannelsInputTag>(&fEnergyDepositTags))
525  {
526 
527  auto const& channels
528  = event.template getProduct<std::vector<sim::SimChannel>>
529  (channelsTag->tag())
530  ;
531  mf::LogTrace(fLogCategory)
532  << "Event " << event.id() << " has " << channels.size()
533  << " energy deposits recorded in '" << channelsTag->tag().encode() << "'";
534 
535  addEnergyDepositionInfo(info, channels);
536 
537  }
538  else if (
539  auto* edepListTag
540  = std::get_if<std::vector<art::InputTag>>(&fEnergyDepositTags)
541  ) {
542 
543  for (art::InputTag const& edepTag: *edepListTag) {
544 
545  auto const& energyDeposits
546  = event.template getProduct<std::vector<sim::SimEnergyDeposit>>(edepTag);
547  mf::LogTrace(fLogCategory)
548  << "Event " << event.id() << " has " << energyDeposits.size()
549  << " energy deposits recorded in '" << edepTag.encode() << "'";
550 
551  addEnergyDepositionInfo(info, energyDeposits);
552 
553  } // for all energy deposit tags
554 
555  }
556  else {
557  throw std::logic_error(
558  "icarus::trigger::details::EventInfoExtractor::EventInfoExtractor(): "
559  "unexpected type from EDepTags_t"
560  );
561  }
562 
563  mf::LogTrace(fLogCategory) << "Event " << event.id() << ": " << info;
564 
565  return info;
566 } // icarus::trigger::details::EventInfoExtractor::extractInfo()
util::quantities::gigaelectronvolt GeV
void fillGeneratorInfo(EventInfo_t &info, simb::MCTruth const &truth) const
Fills info record with generation information from truth.
Information about the event.
A value measured in the specified unit.
Definition: quantities.h:566
gigaelectronvolt_as<> gigaelectronvolt
Type of energy stored in gigaelectronvolt, in double precision.
Definition: energy.h:129
void addEnergyDepositionInfo(EventInfo_t &info, std::vector< sim::SimEnergyDeposit > const &energyDeposits) const
Adds the energy depositions from energyDeposits into info record.
std::vector< art::InputTag > const fGeneratorTags
List of truth data product tags (std::vector&lt;simb::MCTruth&gt;).
void SetDepositedEnergy(GeV e)
Sets the total deposited energy of the event [GeV].
void SetDepositedEnergyInActiveVolume(GeV e)
Sets the total deposited energy of the event in active volume [GeV].
void SetDepositedEnergyInSpill(GeV e)
Sets the energy of the event deposited during beam gate [GeV].
std::string const fLogCategory
Stream name for message facility.
void icarus::trigger::details::EventInfoExtractor::fillGeneratorInfo ( EventInfo_t info,
simb::MCTruth const &  truth 
) const
private

Fills info record with generation information from truth.

Definition at line 121 of file EventInfoUtils.cxx.

122 {
123 
124  if (truth.NeutrinoSet()) fillGeneratorNeutrinoInfo(info, truth);
125 
126 } // icarus::trigger::details::EventInfoExtractor::fillGeneratorInfo()
void fillGeneratorNeutrinoInfo(EventInfo_t &info, simb::MCTruth const &truth) const
Fills info record with generated neutrino information from truth.
void icarus::trigger::details::EventInfoExtractor::fillGeneratorNeutrinoInfo ( EventInfo_t info,
simb::MCTruth const &  truth 
) const
private

Fills info record with generated neutrino information from truth.

If info record already contains an interaction (the "main" interaction), the interaction in truth becomes the new main interaction of info only if it is earlier than the old main interaction. Otherwise the record is updated to take note that there was yet another interaction in the event, with little-to-no information about it stored.

Definition at line 131 of file EventInfoUtils.cxx.

132 {
133  if (!truth.NeutrinoSet()) return;
134 
135  simulation_time const interactionTime = getInteractionTime(truth);
136 
137  if ((info.nVertices() == 0) || (interactionTime < info.InteractionTime()))
138  setMainGeneratorNeutrinoInfo(info, truth);
139  else
140  addGeneratorNeutrinoInfo(info, truth);
141 
142 } // icarus::trigger::details::EventInfoExtractor::fillGeneratorNeutrinoInfo()
simulation_time getInteractionTime(simb::MCTruth const &truth) const
detinfo::timescales::simulation_time simulation_time
void setMainGeneratorNeutrinoInfo(EventInfo_t &info, simb::MCTruth const &truth) const
void addGeneratorNeutrinoInfo(EventInfo_t &info, simb::MCTruth const &truth) const
auto icarus::trigger::details::EventInfoExtractor::getInteractionTime ( simb::MCTruth const &  truth) const
private

Returns the time of the neutrino interaction in truth.

Undefined behaviour if the truth information does not describe a neutrino interaction.

Definition at line 345 of file EventInfoUtils.cxx.

346 {
347  assert(truth.NeutrinoSet());
348  simb::MCParticle const& nu = truth.GetNeutrino().Nu();
349  return simulation_time{ nu.EndT() };
350 } // icarus::trigger::details::EventInfoExtractor::getInteractionTime()
detinfo::timescales::simulation_time simulation_time
BEGIN_PROLOG SN nu
bool icarus::trigger::details::EventInfoExtractor::hasEDep ( ) const
inline

Returns whether we are extracting any energy deposition information.

Definition at line 249 of file EventInfoUtils.h.

static bool isEDepSpecified(EDepTags_t const &edepTag)
Returns whether edepTags contains any energy deposition tag.
bool icarus::trigger::details::EventInfoExtractor::hasGenerated ( ) const
inline

Returns whether we are extracting any generator information.

Definition at line 246 of file EventInfoUtils.h.

246 { return !fGeneratorTags.empty(); }
std::vector< art::InputTag > const fGeneratorTags
List of truth data product tags (std::vector&lt;simb::MCTruth&gt;).
bool icarus::trigger::details::EventInfoExtractor::isEDepListTag ( EDepTags_t const &  edepTag)
static

Returns whether edepTags contains energy deposition list tags.

Definition at line 440 of file EventInfoUtils.h.

441 {
442  auto const* edeplist = std::get_if<std::vector<art::InputTag>>(&edepTag);
443  return edeplist && !edeplist->empty();
444 } // icarus::trigger::details::EventInfoExtractor::isEDepListTag()
static bool icarus::trigger::details::EventInfoExtractor::isEDepSpecified ( EDepTags_t const &  edepTag)
inlinestatic

Returns whether edepTags contains any energy deposition tag.

Definition at line 263 of file EventInfoUtils.h.

264  { return edepTag != NoEDepTags; }
static EDepTags_t const NoEDepTags
Represents the absence of any energy deposition information.
bool icarus::trigger::details::EventInfoExtractor::isEDepSummaryTag ( EDepTags_t const &  edepTag)
static

Returns whether edepTags contains a energy deposition summary tag.

Definition at line 434 of file EventInfoUtils.h.

435  { return std::holds_alternative<SimEnergyDepositSummaryInputTag>(edepTag); }
template<typename Event >
EventInfo_t icarus::trigger::details::EventInfoExtractor::operator() ( Event const &  event) const
inline

Definition at line 240 of file EventInfoUtils.h.

241  { return extractInfo(event); }
EventInfo_t extractInfo(Event const &event) const
Returns an EventInfo_t object with information from event.
geo::TPCGeo const * icarus::trigger::details::EventInfoExtractor::pointInActiveTPC ( geo::Point_t const &  point) const
private

Returns in which active TPC volume point falls in (nullptr if none).

Definition at line 337 of file EventInfoUtils.cxx.

338 {
339  return ::pointInActiveTPC(fGeom, point);
340 } // icarus::trigger::TriggerEfficiencyPlotsBase::pointInActiveTPC()
geo::GeometryCore const & fGeom
Geometry service provider.
geo::TPCGeo const * icarus::trigger::details::EventInfoExtractor::pointInTPC ( geo::Point_t const &  point) const
private

Returns in which TPC volume point falls in (nullptr if none).

Definition at line 328 of file EventInfoUtils.cxx.

329 {
330  return fGeom.PositionToTPCptr(point);
331 } // icarus::trigger::TriggerEfficiencyPlotsBase::pointInTPC()
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point) const
Returns the TPC at specified location.
geo::GeometryCore const & fGeom
Geometry service provider.
void icarus::trigger::details::EventInfoExtractor::setMainGeneratorNeutrinoInfo ( EventInfo_t info,
simb::MCTruth const &  truth 
) const
private

Extracts information from truth and sets it as the "main" interaction information. Previous information is typically overwritten.

Definition at line 147 of file EventInfoUtils.cxx.

148 {
149  /*
150  * Sets the full information of the event, overwriting everything.
151  *
152  * Except that the vertex is just inserted into the vertex list, as the
153  * first entry.
154  */
155 
157 
158  //
159  // interaction flavor (nu_mu, nu_e)
160  // interaction type (CC, NC)
161  //
162 
163  simb::MCParticle const& nu = truth.GetNeutrino().Nu();
164  info.SetNeutrinoPDG(nu.PdgCode());
165  info.SetInteractionType(truth.GetNeutrino().InteractionType());
166  info.SetInteractionTime(getInteractionTime(truth));
167 
168  info.SetNeutrinoEnergy(GeV{ nu.E() });
169  info.SetLeptonEnergy(GeV{ truth.GetNeutrino().Lepton().E() });
170  //info.SetNucleonEnergy(truth.GetNeutrino().HitNuc().E());
171 
172  switch (nu.PdgCode()) {
173  case 14:
174  case -14:
175  info.SetNu_mu(true);
176  break;
177  case 12:
178  case -12:
179  info.SetNu_e(true);
180  break;
181  }
182 
183  switch (truth.GetNeutrino().CCNC()) {
184  case simb::kCC: info.AddWeakChargedCurrentInteractions(); break;
185  case simb::kNC: info.AddWeakNeutralCurrentInteractions(); break;
186  default:
187  mf::LogWarning(fLogCategory)
188  << "Unexpected NC/CC flag (" << truth.GetNeutrino().CCNC() << ")";
189  } // switch
190 
191  // we do not trust the vertex (`GvX()`) of the neutrino particle,
192  // since GenieHelper does not translate the vertex
193  // of some of the particles from GENIE to detector frame;
194  // trajectory is always translated:
195  geo::Point_t const vertex { nu.EndX(), nu.EndY(), nu.EndZ() };
196  info.InsertVertex(vertex, 0U);
197 
198  geo::TPCGeo const* tpc = pointInActiveTPC(vertex);
199  if (tpc) info.SetInActiveVolume();
200 
201 } // icarus::trigger::details::EventInfoExtractor::setMainGeneratorNeutrinoInfo()
process_name vertex
Definition: cheaterreco.fcl:51
void SetInteractionType(int type)
void AddWeakNeutralCurrentInteractions(unsigned int n=1U)
Marks this event as including n more weak neutral current interactions.
geo::TPCGeo const * pointInActiveTPC(geo::Point_t const &point) const
Returns in which active TPC volume point falls in (nullptr if none).
void SetNu_mu(bool numu)
Marks the neutrino flavor.
simulation_time getInteractionTime(simb::MCTruth const &truth) const
Geometry information for a single TPC.
Definition: TPCGeo.h:38
void SetNeutrinoPDG(int NU)
Marks this event&#39;s neutrino type.
Charged-current interactions.
Definition: IPrediction.h:38
A value measured in the specified unit.
Definition: quantities.h:566
void SetInActiveVolume(bool active=true)
Set whether the event has relevant activity in the active volume.
gigaelectronvolt_as<> gigaelectronvolt
Type of energy stored in gigaelectronvolt, in double precision.
Definition: energy.h:129
void AddWeakChargedCurrentInteractions(unsigned int n=1U)
Marks this event as including n more weak charged current interactions.
Neutral-current interactions.
Definition: IPrediction.h:39
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
BEGIN_PROLOG SN nu
std::string const fLogCategory
Stream name for message facility.
bool icarus::trigger::details::EventInfoExtractor::useEnergyDepositSummary ( ) const
inlineprivate

Returns whether we use energy summary instead of full energy deposits.

Definition at line 303 of file EventInfoUtils.h.

static bool isEDepSummaryTag(EDepTags_t const &edepTag)
Returns whether edepTags contains a energy deposition summary tag.

Member Data Documentation

friend icarus::trigger::details::EventInfoExtractor::EventInfoExtractorMaker
private

Definition at line 269 of file EventInfoUtils.h.

detinfo::DetectorPropertiesData const* icarus::trigger::details::EventInfoExtractor::fDetProps = nullptr
private

Detector timing conversion utility.

Definition at line 290 of file EventInfoUtils.h.

detinfo::DetectorTimings const* icarus::trigger::details::EventInfoExtractor::fDetTimings = nullptr
private

Definition at line 293 of file EventInfoUtils.h.

EDepTags_t const icarus::trigger::details::EventInfoExtractor::fEnergyDepositTags
private

List of energy deposition product tags (std::vector<sim::SimEnergyDeposit>) or their summary.

Definition at line 278 of file EventInfoUtils.h.

std::vector<art::InputTag> const icarus::trigger::details::EventInfoExtractor::fGeneratorTags
private

List of truth data product tags (std::vector<simb::MCTruth>).

Definition at line 274 of file EventInfoUtils.h.

geo::GeometryCore const& icarus::trigger::details::EventInfoExtractor::fGeom
private

Geometry service provider.

Detector properties information.

Definition at line 287 of file EventInfoUtils.h.

TimeSpan_t const icarus::trigger::details::EventInfoExtractor::fInPreSpillTimes
private

Start and stop time for "pre-spill" label.

Definition at line 298 of file EventInfoUtils.h.

TimeSpan_t const icarus::trigger::details::EventInfoExtractor::fInSpillTimes
private

Start and stop time for "in spill" label.

Definition at line 295 of file EventInfoUtils.h.

std::string const icarus::trigger::details::EventInfoExtractor::fLogCategory
private

Stream name for message facility.

Definition at line 280 of file EventInfoUtils.h.

icarus::trigger::details::EventInfoExtractor::EDepTags_t const icarus::trigger::details::EventInfoExtractor::NoEDepTags {}
inlinestatic

Represents the absence of any energy deposition information.

Definition at line 254 of file EventInfoUtils.h.


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