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
FilterOnArtPathOutcome Class Reference

Filter module using a response an existing trigger path response. More...

Inheritance diagram for FilterOnArtPathOutcome:

Classes

struct  Config
 
struct  TriggerSpec
 

Public Types

using Parameters = art::SharedFilter::Table< Config >
 

Public Member Functions

 FilterOnArtPathOutcome (Parameters const &params, const art::ProcessingFrame &)
 Constructor. No surprise here. More...
 
virtual bool filter (art::Event &event, const art::ProcessingFrame &) override
 

Private Member Functions

art::TriggerResults const & readTriggerResults (art::Event const &event, art::InputTag const &tag) const
 Reads the needed trigger data product, and throws if not found. More...
 
art::HLTPathStatus const & findPath (art::TriggerResults const &results, std::string const &name) const
 
std::vector< std::string > pathNames (art::TriggerResults const &results) const
 
bool responseFromPath (art::HLTPathStatus const &path) const
 Translates a path status into the response from this filter. More...
 

Static Private Member Functions

static TriggerSpec parseTriggerSpec (std::string const &spec)
 Parses a trigger path specification. More...
 

Private Attributes

TriggerSpec const fTriggerSpec
 Trigger configuration. More...
 
bool const fResponseWhenNotRun
 What to do if path was not run at all. More...
 
bool const fResponseOnError
 What to do if path ended with error. More...
 

Detailed Description

Filter module using a response an existing trigger path response.

This filter emits the same response as for a art path (not just a filter) that was run previously.

Input

Given a configured Path, this module reads from the event the data product named TriggerResults (art::TriggerResults type) from the process specified in that configuration parameter.

Configuration parameters

Definition at line 55 of file FilterOnArtPathOutcome_module.cc.

Member Typedef Documentation

using FilterOnArtPathOutcome::Parameters = art::SharedFilter::Table<Config>

Definition at line 82 of file FilterOnArtPathOutcome_module.cc.

Constructor & Destructor Documentation

FilterOnArtPathOutcome::FilterOnArtPathOutcome ( Parameters const &  params,
const art::ProcessingFrame &   
)

Constructor. No surprise here.

Definition at line 129 of file FilterOnArtPathOutcome_module.cc.

130  : art::SharedFilter{ params }
131  , fTriggerSpec { parseTriggerSpec(params().Path()) }
132  , fResponseWhenNotRun{ params().ResponseWhenNotRun() }
133  , fResponseOnError { params().ResponseOnError() }
134 {
135 
136  async<art::InEvent>();
137 
138 } // FilterOnArtPathOutcome::FilterOnArtPathOutcome()
bool const fResponseOnError
What to do if path ended with error.
TriggerSpec const fTriggerSpec
Trigger configuration.
static TriggerSpec parseTriggerSpec(std::string const &spec)
Parses a trigger path specification.
bool const fResponseWhenNotRun
What to do if path was not run at all.

Member Function Documentation

bool FilterOnArtPathOutcome::filter ( art::Event &  event,
const art::ProcessingFrame &   
)
overridevirtual

Definition at line 143 of file FilterOnArtPathOutcome_module.cc.

144 {
145 
146  art::TriggerResults const& trgResults
148 
149  art::HLTPathStatus const& path = findPath(trgResults, fTriggerSpec.path);
150 
151  return responseFromPath(path);
152 
153 } // FilterOnArtPathOutcome::filter()
std::string const path
Name of the path to be read.
art::HLTPathStatus const & findPath(art::TriggerResults const &results, std::string const &name) const
art::InputTag const tag
Input tag of the trigger result data product.
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
bool responseFromPath(art::HLTPathStatus const &path) const
Translates a path status into the response from this filter.
TriggerSpec const fTriggerSpec
Trigger configuration.
art::TriggerResults const & readTriggerResults(art::Event const &event, art::InputTag const &tag) const
Reads the needed trigger data product, and throws if not found.
art::HLTPathStatus const & FilterOnArtPathOutcome::findPath ( art::TriggerResults const &  results,
std::string const &  name 
) const
private

Returns the status of the path with the required name.

Exceptions
cet::exceptionif not found

Definition at line 198 of file FilterOnArtPathOutcome_module.cc.

199 {
200  std::vector<std::string> const names = pathNames(results);
201 
202  //
203  // find the proper one...
204  //
205 
206  auto iPathName = names.end();
207  do { // quick-exit block
208 
209  // try verbatim first:
210  iPathName = std::find(names.begin(), names.end(), name);
211  if (iPathName != names.end()) break;
212 
213  // art has the custom of prepending an index to the name ("<index>:<name>");
214  // let's try to ignore it
215  iPathName = std::find_if(names.begin(), names.end(),
216  [name](std::string const& s)
217  {
218  std::size_t const iSep = s.find(':');
219  return ((iSep == std::string::npos)? s: s.substr(iSep+1)) == name;
220  }
221  );
222 
223  } while (false);
224 
225  if (iPathName == names.end()) {
226  cet::exception e{ "FilterOnArtPathOutcome" };
227  e << "The trigger path '" << fTriggerSpec.tag.process()
228  << "' does not include '" << name << "'! The " << names.size()
229  << " available paths are:";
230  for (std::string const& pathName: names)
231  e << "\n - '" << pathName << "'";
232  throw e << "\n";
233  }
234 
235  // in principle we could also extract the index from the name; we don't.
236  std::size_t const pathIndex = std::distance(names.begin(), iPathName);
237 
238  return results.at(pathIndex);
239 
240 } // FilterOnArtPathOutcome::findPath()
art::InputTag const tag
Input tag of the trigger result data product.
std::vector< std::string > pathNames(art::TriggerResults const &results) const
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
static const std::vector< std::string > names
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
TriggerSpec const fTriggerSpec
Trigger configuration.
then echo fcl name
auto FilterOnArtPathOutcome::parseTriggerSpec ( std::string const &  spec)
staticprivate

Parses a trigger path specification.

Definition at line 294 of file FilterOnArtPathOutcome_module.cc.

296 {
297  std::string processName, pathName;
298  auto const iSep = spec.find(':');
299  if (iSep == std::string::npos) {
300  pathName = spec;
301  }
302  else {
303  processName = spec.substr(0, iSep);
304  pathName = spec.substr(iSep + 1);
305  }
306 
307  return { art::InputTag{ "TriggerResults", "", processName }, pathName };
308 
309 } // FilterOnArtPathOutcome::parseTriggerSpec()
std::vector< std::string > FilterOnArtPathOutcome::pathNames ( art::TriggerResults const &  results) const
private

Returns the list of path names stored in results.

Exceptions
art::Exception(code: art::errors::Unknown) on logic errors

Definition at line 245 of file FilterOnArtPathOutcome_module.cc.

246 {
247  //
248  // list of paths for this event;
249  // copied from art/Framework/Core/EventSelector.cc of art 3.9.3, `dataFor()`:
250  //
251  fhicl::ParameterSet pset;
252  if (!fhicl::ParameterSetRegistry::get(results.parameterSetID(), pset)) {
253  // "This should never happen";
254  // just in case, I leave the message and blame to art
255  throw art::Exception(art::errors::Unknown)
256  << "FilterOnArtPathOutcome::findPath cannot find the trigger names for\n"
257  << "a process for which the configuration has requested that the\n"
258  << "OutputModule use TriggerResults to select events from. This should\n"
259  << "be impossible, please send information to reproduce this problem to\n"
260  << "the art developers at artists@fnal.gov.\n";
261  }
262  auto const names = pset.get<std::vector<std::string>>("trigger_paths", {});
263  if (names.size() != results.size()) {
264  throw art::Exception(art::errors::Unknown)
265  << "FilterOnArtPathOutcome::findPath: path names vector and\n"
266  << "TriggerResults are different sizes (" << names.size()
267  << " vs. " << results.size() << "). This should be impossible,\n"
268  << "please send information to reproduce this problem to\n"
269  << "the art developers.\n";
270  }
271 
272  return names;
273 
274 } // FilterOnArtPathOutcome::pathNames()
static const std::vector< std::string > names
art::TriggerResults const & FilterOnArtPathOutcome::readTriggerResults ( art::Event const &  event,
art::InputTag const &  tag 
) const
private

Reads the needed trigger data product, and throws if not found.

Definition at line 158 of file FilterOnArtPathOutcome_module.cc.

159 {
160 
161  try {
162  return event.getProduct<art::TriggerResults>(tag);
163  }
164  catch (art::Exception const& e) {
165  if (e.categoryCode() != art::errors::ProductNotFound) throw;
166 
167  std::optional<std::vector<art::InputTag>> available;
168  try {
169  std::vector<art::Handle<art::TriggerResults>> const& triggerHandles
170  = event.getMany<art::TriggerResults>();
171  available.emplace();
172  for (art::Handle<art::TriggerResults> const& handle: triggerHandles) {
173  if (handle.isValid() && handle.provenance())
174  available->push_back(handle.provenance()->inputTag());
175  } // for
176  }
177  catch (...) {} // we tried to be nice, and failed.
178 
179  art::Exception msg { e.categoryCode(), "", e };
180  msg << "Trigger data product '" << tag.encode() << "' not found.";
181  if (available) {
182  msg << "\n" << available->size() << " trigger products available";
183  if (available->empty()) msg << ".";
184  else {
185  msg << ":";
186  for (art::InputTag const& tag: *available)
187  msg << "\n - '" << tag.encode() << "'";
188  } // if ... else
189  } // if available
190  throw msg << "\n";
191  }
192 
193 } // FilterOnArtPathOutcome::readTriggerResults()
do i e
bool FilterOnArtPathOutcome::responseFromPath ( art::HLTPathStatus const &  path) const
private

Translates a path status into the response from this filter.

Definition at line 279 of file FilterOnArtPathOutcome_module.cc.

280 {
281 
282  if (!path.wasrun()) { // path was not run at all
283  return fResponseWhenNotRun;
284  }
285  else if (path.error()) { // path terminated with an exception
286  return fResponseOnError;
287  }
288  else return path.accept();
289 
290 } // FilterOnArtPathOutcome::responseFromPath()
bool const fResponseOnError
What to do if path ended with error.
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
bool const fResponseWhenNotRun
What to do if path was not run at all.

Member Data Documentation

bool const FilterOnArtPathOutcome::fResponseOnError
private

What to do if path ended with error.

Definition at line 102 of file FilterOnArtPathOutcome_module.cc.

bool const FilterOnArtPathOutcome::fResponseWhenNotRun
private

What to do if path was not run at all.

Definition at line 101 of file FilterOnArtPathOutcome_module.cc.

TriggerSpec const FilterOnArtPathOutcome::fTriggerSpec
private

Trigger configuration.

Definition at line 100 of file FilterOnArtPathOutcome_module.cc.


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