LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
filt::LArG4ParticleFilter Class Reference
Inheritance diagram for filt::LArG4ParticleFilter:
art::EDFilter art::detail::Filter art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDFilter
 
template<typename UserConfig >
using Table = Modifier::Table< UserConfig >
 

Public Member Functions

 LArG4ParticleFilter (fhicl::ParameterSet const &pset)
 
virtual bool filter (art::Event &e)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Static Public Attributes

static constexpr bool Pass {true}
 
static constexpr bool Fail {false}
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

bool IsInterestingParticle (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool PDGCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool IsPrimaryCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool MinMomentumCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool MaxMomentumCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool StartInTPCCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool StopInTPCCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
bool TPCTrajLengthCheck (const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
 
double CalculateLength (const std::vector< TVector3 > &position_segment) const
 
void VerifyDataMembers () const
 
void VerifyElementRequest (const unsigned int index) const
 

Private Attributes

art::ServiceHandle< geo::Geometry const > fGeom
 
const std::string fLArG4ModuleLabel
 
const std::vector< int > fInterestingPDGs
 
const std::vector< int > fIsPrimary
 
const std::vector< double > fParticleMinMomentum
 
const std::vector< double > fParticleMaxMomentum
 
const std::vector< int > fStartInTPC
 
const std::vector< int > fStopInTPC
 
const std::vector< double > fParticleMinTPCLength
 
const bool fRequireAllInterestingParticles
 
std::vector< bool > fFoundInterestingParticles
 

Detailed Description

Definition at line 24 of file LArG4ParticleFilter_module.cc.

Member Typedef Documentation

Definition at line 18 of file EDFilter.h.

template<typename UserConfig >
using art::detail::Filter::Table = Modifier::Table<UserConfig>
inherited

Definition at line 32 of file Filter.h.

Constructor & Destructor Documentation

filt::LArG4ParticleFilter::LArG4ParticleFilter ( fhicl::ParameterSet const &  pset)
explicit

Member Function Documentation

double filt::LArG4ParticleFilter::CalculateLength ( const std::vector< TVector3 > &  position_segment) const
private

Definition at line 270 of file LArG4ParticleFilter_module.cc.

Referenced by TPCTrajLengthCheck().

271  {
272  double length = 0;
273  //Check how many points we have in the segment. If it is one or less, there is nothing to calculate so return 0
274  if (position_segment.size() <= 1) return length;
275 
276  //Now we need to compare every adjacent pair of positions to work out the length of this segment
277  for (unsigned int i = 1; i < position_segment.size(); i++) {
278  length += (position_segment[i] - position_segment[i - 1]).Mag();
279  }
280 
281  return length;
282  }
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Filter::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 29 of file Filter.cc.

30  {
31  setupQueues(resources);
32  ProcessingFrame const frame{ScheduleID{}};
33  beginJobWithFrame(frame);
34  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Filter::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 72 of file Filter.cc.

References art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

73  {
74  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
75  ProcessingFrame const frame{mc.scheduleID()};
76  bool const rc = beginRunWithFrame(r, frame);
77  r.commitProducts();
78  return rc;
79  }
TRandom r
Definition: spectrum.C:23
virtual bool beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Filter::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Filter.cc.

References art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

93  {
94  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
95  ProcessingFrame const frame{mc.scheduleID()};
96  bool const rc = beginSubRunWithFrame(sr, frame);
97  sr.commitProducts();
98  return rc;
99  }
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
virtual bool beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
void art::detail::Filter::doEndJob ( )
inherited

Definition at line 37 of file Filter.cc.

38  {
39  ProcessingFrame const frame{ScheduleID{}};
40  endJobWithFrame(frame);
41  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Filter::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 82 of file Filter.cc.

References art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

83  {
84  auto r = rp.makeRun(mc, rp.seenRanges());
85  ProcessingFrame const frame{mc.scheduleID()};
86  bool const rc = endRunWithFrame(r, frame);
87  r.commitProducts();
88  return rc;
89  }
TRandom r
Definition: spectrum.C:23
virtual bool endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Filter::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 102 of file Filter.cc.

References art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

103  {
104  auto sr = srp.makeSubRun(mc, srp.seenRanges());
105  ProcessingFrame const frame{mc.scheduleID()};
106  bool const rc = endSubRunWithFrame(sr, frame);
107  sr.commitProducts();
108  return rc;
109  }
virtual bool endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Filter::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 112 of file Filter.cc.

References e, art::EventPrincipal::makeEvent(), and art::ModuleContext::scheduleID().

117  {
118  auto e = ep.makeEvent(mc);
119  ++counts_run;
120  ProcessingFrame const frame{mc.scheduleID()};
121  bool const rc = filterWithFrame(e, frame);
122  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
123  if (rc) {
124  ++counts_passed;
125  } else {
126  ++counts_failed;
127  }
128  return rc;
129  }
virtual bool filterWithFrame(Event &, ProcessingFrame const &)=0
bool const checkPutProducts_
Definition: Filter.h:75
Float_t e
Definition: plot.C:35
void art::detail::Filter::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 51 of file Filter.cc.

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Filter::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 65 of file Filter.cc.

66  {
67  ProcessingFrame const frame{ScheduleID{}};
69  }
TFile fb("Li6.root")
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Filter::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Filter.cc.

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Filter::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Filter.cc.

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
TFile fb("Li6.root")
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
bool filt::LArG4ParticleFilter::filter ( art::Event e)
virtual

Implements art::EDFilter.

Definition at line 80 of file LArG4ParticleFilter_module.cc.

References fFoundInterestingParticles, fInterestingPDGs, fLArG4ModuleLabel, fRequireAllInterestingParticles, art::ProductRetriever::getByLabel(), and IsInterestingParticle().

81  {
82  //Reset the found vector
83  for (unsigned int i = 0; i < fFoundInterestingParticles.size(); i++) {
84  fFoundInterestingParticles[i] = false;
85  }
86 
87  //Get the vector of particles
89  e.getByLabel(fLArG4ModuleLabel, particles);
90  //Loop through the particles
91  for (unsigned int part_i = 0; part_i < particles->size(); part_i++) {
92  //Get the particle
93  const art::Ptr<simb::MCParticle> particle(particles, part_i);
94  //Loop over the list of particles we want and compare it with the particle we are looking it
95  for (unsigned int interest_i = 0; interest_i < fInterestingPDGs.size(); interest_i++) {
96  if (IsInterestingParticle(particle, interest_i)) {
98  return true; //If we only require at least one of the particles be found then we have already done our job
99  fFoundInterestingParticles[interest_i] = true;
100  bool foundThemAll = true;
101  for (unsigned int found_i = 0; found_i < fFoundInterestingParticles.size(); found_i++) {
102  if (fFoundInterestingParticles[found_i] == false) {
103  foundThemAll = false;
104  break;
105  }
106  }
107  if (foundThemAll) { return true; }
108  }
109  }
110  }
111  //Assume that the event is not worth saving
112  return false;
113  }
std::vector< bool > fFoundInterestingParticles
bool IsInterestingParticle(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
const std::vector< int > fInterestingPDGs
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: fwd.h:26
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
bool filt::LArG4ParticleFilter::IsInterestingParticle ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 115 of file LArG4ParticleFilter_module.cc.

References IsPrimaryCheck(), MaxMomentumCheck(), MinMomentumCheck(), PDGCheck(), StartInTPCCheck(), StopInTPCCheck(), TPCTrajLengthCheck(), and VerifyElementRequest().

Referenced by filter().

117  {
118  VerifyElementRequest(index);
119  //Run the checks
120  if (!PDGCheck(particle, index)) return false;
121  if (!IsPrimaryCheck(particle, index)) return false;
122  if (!MinMomentumCheck(particle, index)) return false;
123  if (!MaxMomentumCheck(particle, index)) return false;
124  if (!StartInTPCCheck(particle, index)) return false;
125  if (!StopInTPCCheck(particle, index)) return false;
126  if (!TPCTrajLengthCheck(particle, index)) return false;
127 
128  return true;
129  }
bool IsPrimaryCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
bool MaxMomentumCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
void VerifyElementRequest(const unsigned int index) const
bool StartInTPCCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
bool MinMomentumCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
bool TPCTrajLengthCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
bool PDGCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
bool StopInTPCCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
bool filt::LArG4ParticleFilter::IsPrimaryCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 140 of file LArG4ParticleFilter_module.cc.

References fIsPrimary, and simb::MCParticle::Mother().

Referenced by IsInterestingParticle().

142  {
143  const int isPrimaryCondition(fIsPrimary[index]);
144  if (isPrimaryCondition == -1) return true;
145  bool particlePrimaryStatus(particle->Mother() > 0 ? false : true);
146  if (particlePrimaryStatus != isPrimaryCondition) return false;
147  return true;
148  }
int Mother() const
Definition: MCParticle.h:214
const std::vector< int > fIsPrimary
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
bool filt::LArG4ParticleFilter::MaxMomentumCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 159 of file LArG4ParticleFilter_module.cc.

References fParticleMaxMomentum, and simb::MCParticle::Momentum().

Referenced by IsInterestingParticle().

161  {
162  if (fParticleMaxMomentum[index] > 0 &&
163  particle->Momentum(0).Vect().Mag() > fParticleMaxMomentum[index])
164  return false;
165  return true;
166  }
const std::vector< double > fParticleMaxMomentum
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
bool filt::LArG4ParticleFilter::MinMomentumCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 150 of file LArG4ParticleFilter_module.cc.

References fParticleMinMomentum, and simb::MCParticle::Momentum().

Referenced by IsInterestingParticle().

152  {
153  if (fParticleMinMomentum[index] > 0 &&
154  particle->Momentum(0).Vect().Mag() < fParticleMinMomentum[index])
155  return false;
156  return true;
157  }
const std::vector< double > fParticleMinMomentum
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
bool filt::LArG4ParticleFilter::PDGCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 131 of file LArG4ParticleFilter_module.cc.

References fInterestingPDGs, and simb::MCParticle::PdgCode().

Referenced by IsInterestingParticle().

133  {
134  int pdg = fInterestingPDGs[index];
135  if (pdg == 0) return true; //User does not care what the PDG is
136  if (particle->PdgCode() != pdg) return false;
137  return true;
138  }
int PdgCode() const
Definition: MCParticle.h:213
const std::vector< int > fInterestingPDGs
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
bool filt::LArG4ParticleFilter::StartInTPCCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 168 of file LArG4ParticleFilter_module.cc.

References fGeom, geo::GeometryCore::FindTPCAtPosition(), fStartInTPC, geo::CryostatID::isValid, simb::MCParticle::Position(), and geo::vect::toPoint().

Referenced by IsInterestingParticle().

170  {
171  //Firstly check if we even care if the particle starts in the TPC or not
172  int demand = fStartInTPC[index];
173  if (demand == 0)
174  return true; //We don't care if the particle starts in the TPC or not so pass the check
175  //Get TPC corresponding to starting position of particle
176  geo::TPCID tpcid = fGeom->FindTPCAtPosition(geo::vect::toPoint(particle->Position(0).Vect()));
177  //Now we need to compare if we have a TPC that we started in with whether we wanted to start in a TPC at all
178  if (tpcid.isValid) {
179  //The particle DID start in a TPC. Now, did we WANT this to happen
180  return demand == 1;
181  }
182  else {
183  //The particle did NOT start in a TPC. Did we WANT this to happen?
184  return demand == 2;
185  }
186 
187  //Assume true by default
188  return true;
189  }
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
art::ServiceHandle< geo::Geometry const > fGeom
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:210
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
const std::vector< int > fStartInTPC
bool filt::LArG4ParticleFilter::StopInTPCCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 191 of file LArG4ParticleFilter_module.cc.

References fGeom, geo::GeometryCore::FindTPCAtPosition(), fStopInTPC, geo::CryostatID::isValid, simb::MCParticle::NumberTrajectoryPoints(), simb::MCParticle::Position(), and geo::vect::toPoint().

Referenced by IsInterestingParticle().

193  {
194  //Firstly check if we even care if the particle stops in the TPC or not
195  int demand = fStopInTPC[index];
196  if (demand == 0)
197  return true; //We don't care if the particle stops in the TPC or not so pass the check
198  //Get final position of particle
199  auto const final_position = particle->Position(particle->NumberTrajectoryPoints() - 1).Vect();
200 
201  geo::TPCID tpcid = fGeom->FindTPCAtPosition(geo::vect::toPoint(final_position));
202  //Now we need to compare if we have a TPC that we stopped in with whether we wanted to stop in a TPC at all
203  if (tpcid.isValid) {
204  //The particle DID stop in a TPC. Now, did we WANT this to happen
205  return demand == 1;
206  }
207  else {
208  //The particle did NOT stop in a TPC. Did we WANT this to happen?
209  return demand == 2;
210  }
211 
212  //Assume true by default
213  return true;
214  }
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:219
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
art::ServiceHandle< geo::Geometry const > fGeom
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:210
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
const std::vector< int > fStopInTPC
bool filt::LArG4ParticleFilter::TPCTrajLengthCheck ( const art::Ptr< simb::MCParticle > &  particle,
const unsigned int  index 
) const
private

Definition at line 216 of file LArG4ParticleFilter_module.cc.

References CalculateLength(), fGeom, geo::GeometryCore::FindTPCAtPosition(), fParticleMinTPCLength, geo::CryostatID::isValid, simb::MCParticle::NumberTrajectoryPoints(), simb::MCParticle::Position(), and geo::vect::toPoint().

Referenced by IsInterestingParticle().

218  {
219  double min_traj_length = fParticleMinTPCLength[index];
220 
221  //Firstly, if we don't care about the TPC trajectory length then pass the check
222  if (min_traj_length < 0) return true;
223 
224  //Now the hard bit
225  //To do this, we need to collect the sequential particle positions which are contained in the TPC into segments. The reason for doing this is that the particle may enter a TPC, leave it and enter it again and if this isn't taken into account, the length might be grossly overestimated
226  //It is easiest to store the positions in a vector of vectors
227  bool OK = false;
228  std::vector<std::vector<TVector3>> position_segments;
229  //We are also going to need an empty vector to store in the above vector
230  std::vector<TVector3> position_segment;
231  //Loop through the trajectory points
232  for (unsigned int i = 0; i < particle->NumberTrajectoryPoints(); i++) {
233  //Extract the current position of the particle
234  geo::TPCID curr_tpcid =
235  fGeom->FindTPCAtPosition(geo::vect::toPoint(particle->Position(i).Vect()));
236  //There are a couple of things to check here. If the particle is currently in the TPC, then we need to store that particular position. If it is NOT in the TPC, then its either exited the TPC or has not yet entered. If it has just exited, then the position_segment should have some positions stored in it, it which case we now need to store this segment. If it has not yet entered the TPC, then we don't need to do anything
237  //If it is currently in the TPC
238  if (curr_tpcid.isValid) position_segment.push_back(particle->Position(i).Vect());
239  //It has just exited the TPC
240  else if (position_segment.size() > 0) {
241  //Store the segment
242  position_segments.push_back(position_segment);
243  //Now reset the segment
244  position_segment.clear();
245  }
246  //There is nothing to do because the particle has remained outside of the TPC
247  }
248  //We need to check once more if the position_segment vector has been filled
249  if (position_segment.size() > 0) {
250  position_segments.push_back(position_segment);
251  position_segment.clear();
252  }
253  //Now lets check the length of each segment
254  //Firstly, if we didn't store a segment then the particle fails the check
255  if (position_segments.size() == 0) return false;
256  //Now loop through the segments and check if they are above threshold
257  for (unsigned int i = 0; i < position_segments.size(); i++) {
258  double segment_length = CalculateLength(position_segments[i]);
259  if (segment_length > min_traj_length) {
260  //We found a track segment in the TPC which passes the length threshold so don't flag as bad
261  OK = true;
262  break;
263  }
264  }
265  if (!OK) return false;
266 
267  return true;
268  }
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:219
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
art::ServiceHandle< geo::Geometry const > fGeom
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:210
double CalculateLength(const std::vector< TVector3 > &position_segment) const
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
const std::vector< double > fParticleMinTPCLength
void filt::LArG4ParticleFilter::VerifyDataMembers ( ) const
private

Definition at line 284 of file LArG4ParticleFilter_module.cc.

References art::errors::Configuration, fInterestingPDGs, fIsPrimary, fParticleMaxMomentum, fParticleMinMomentum, fParticleMinTPCLength, fStartInTPC, and fStopInTPC.

285  {
286  if (fInterestingPDGs.size() != fIsPrimary.size())
288  << "Config error: InterestingPDGs and IsPrimary FCL vectors are different sizes\n";
289  if (fInterestingPDGs.size() != fParticleMinMomentum.size())
291  << "Config error: InterestingPDGs and ParticleMinMomentum FCL vectors are different "
292  "sizes\n";
293  if (fInterestingPDGs.size() != fParticleMaxMomentum.size())
295  << "Config error: InterestingPDGs and ParticleMaxMomentum FCL vectors are different "
296  "sizes\n";
297  if (fInterestingPDGs.size() != fStartInTPC.size())
299  << "Config error: InterestingPDGs and StartInTPC FCL vectors are different sizes\n";
300  if (fInterestingPDGs.size() != fStopInTPC.size())
302  << "Config error: InterestingPDGs and StopInTPC FCL vectors are different sizes\n";
303  if (fInterestingPDGs.size() != fParticleMinTPCLength.size())
305  << "Config error: InterestingPDGs and ParticleMinTPCLength FCL vectors are different "
306  "sizes\n";
307 
308  for (unsigned int iIsPrimary = 0; iIsPrimary < fIsPrimary.size(); iIsPrimary++)
309  if (!(-1 == fIsPrimary[iIsPrimary] || 0 == fIsPrimary[iIsPrimary] ||
310  1 == fIsPrimary[iIsPrimary]))
312  << "Config error: Element " << iIsPrimary << " of the IsPrimary vector equals "
313  << fIsPrimary[iIsPrimary]
314  << ". Valid options are -1 (not set), 0 (not primary) or 1 (is primary)" << std::endl;
315 
316  for (unsigned int iStartInTPC = 0; iStartInTPC < fStartInTPC.size(); iStartInTPC++)
317  if (!(0 == fStartInTPC[iStartInTPC] || 1 == fStartInTPC[iStartInTPC] ||
318  2 == fStartInTPC[iStartInTPC]))
320  << "Config error: Element " << iStartInTPC << " of the StartInTPC vector equals "
321  << fStartInTPC[iStartInTPC]
322  << ". Valid options are 0 (not set), 1 (start in TPC) or 2 (do not start in TPC)"
323  << std::endl;
324 
325  for (unsigned int iStopInTPC = 0; iStopInTPC < fStopInTPC.size(); iStopInTPC++)
326  if (!(0 == fStopInTPC[iStopInTPC] || 1 == fStopInTPC[iStopInTPC] ||
327  2 == fStopInTPC[iStopInTPC]))
329  << "Config error: Element " << iStopInTPC << " of the StopInTPC vector equals "
330  << fStopInTPC[iStopInTPC]
331  << ". Valid options are 0 (not set), 1 (stop in TPC) or 2 (do not stop in TPC)"
332  << std::endl;
333 
334  return;
335  }
const std::vector< int > fInterestingPDGs
const std::vector< double > fParticleMaxMomentum
const std::vector< int > fStopInTPC
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
const std::vector< double > fParticleMinMomentum
const std::vector< int > fIsPrimary
const std::vector< double > fParticleMinTPCLength
const std::vector< int > fStartInTPC
void filt::LArG4ParticleFilter::VerifyElementRequest ( const unsigned int  index) const
private

Definition at line 337 of file LArG4ParticleFilter_module.cc.

References DEFINE_ART_MODULE, fInterestingPDGs, fIsPrimary, fParticleMaxMomentum, fParticleMinMomentum, fParticleMinTPCLength, fStartInTPC, fStopInTPC, and art::errors::InvalidNumber.

Referenced by IsInterestingParticle().

338  {
339  if (index > fInterestingPDGs.size())
341  << "Bounds error: Requested element " << index
342  << " from InterestingPDGs vector which is size " << fInterestingPDGs.size() << "\n";
343  if (index > fIsPrimary.size())
345  << "Bounds error: Requested element " << index << " from IsPrimary vector which is size "
346  << fIsPrimary.size() << "\n";
347  if (index > fParticleMinMomentum.size())
349  << "Bounds error: Requested element " << index
350  << " from ParticleMinMomentum vector which is size " << fParticleMinMomentum.size() << "\n";
351  if (index > fParticleMaxMomentum.size())
353  << "Bounds error: Requested element " << index
354  << " from ParticleMaxMomentum vector which is size " << fParticleMaxMomentum.size() << "\n";
355  if (index > fStartInTPC.size())
357  << "Bounds error: Requested element " << index << " from StartInTPC vector which is size "
358  << fStartInTPC.size() << "\n";
359  if (index > fStopInTPC.size())
361  << "Bounds error: Requested element " << index << " from StopInTPC vector which is size "
362  << fStopInTPC.size() << "\n";
363  if (index > fParticleMinTPCLength.size())
365  << "Bounds error: Requested element " << index
366  << " from ParticleMinTPCLength vector which is size " << fParticleMinTPCLength.size()
367  << "\n";
368  return;
369  }
const std::vector< int > fInterestingPDGs
const std::vector< double > fParticleMaxMomentum
const std::vector< int > fStopInTPC
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
const std::vector< double > fParticleMinMomentum
const std::vector< int > fIsPrimary
const std::vector< double > fParticleMinTPCLength
const std::vector< int > fStartInTPC

Member Data Documentation

constexpr bool art::detail::Filter::Fail {false}
staticinherited

Definition at line 29 of file Filter.h.

std::vector<bool> filt::LArG4ParticleFilter::fFoundInterestingParticles
private

Definition at line 61 of file LArG4ParticleFilter_module.cc.

Referenced by filter().

art::ServiceHandle<geo::Geometry const> filt::LArG4ParticleFilter::fGeom
private
const std::vector<int> filt::LArG4ParticleFilter::fInterestingPDGs
private
const std::vector<int> filt::LArG4ParticleFilter::fIsPrimary
private
const std::string filt::LArG4ParticleFilter::fLArG4ModuleLabel
private

Definition at line 51 of file LArG4ParticleFilter_module.cc.

Referenced by filter().

const std::vector<double> filt::LArG4ParticleFilter::fParticleMaxMomentum
private
const std::vector<double> filt::LArG4ParticleFilter::fParticleMinMomentum
private
const std::vector<double> filt::LArG4ParticleFilter::fParticleMinTPCLength
private
const bool filt::LArG4ParticleFilter::fRequireAllInterestingParticles
private

Definition at line 59 of file LArG4ParticleFilter_module.cc.

Referenced by filter().

const std::vector<int> filt::LArG4ParticleFilter::fStartInTPC
private
const std::vector<int> filt::LArG4ParticleFilter::fStopInTPC
private
constexpr bool art::detail::Filter::Pass {true}
staticinherited

Definition at line 28 of file Filter.h.


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