19 #include "TLorentzVector.h" 31 const unsigned int index)
const;
35 const unsigned int index)
const;
37 const unsigned int index)
const;
39 const unsigned int index)
const;
42 const unsigned int index)
const;
44 double CalculateLength(
const std::vector<TVector3>& position_segment)
const;
64 LArG4ParticleFilter::LArG4ParticleFilter::LArG4ParticleFilter(
fhicl::ParameterSet const& pset)
68 ,
fIsPrimary(pset.get<std::vector<int>>(
"IsPrimary"))
71 ,
fStartInTPC(pset.get<std::vector<int>>(
"StartInTPC"))
72 ,
fStopInTPC(pset.get<std::vector<int>>(
"StopInTPC"))
91 for (
unsigned int part_i = 0; part_i < particles->size(); part_i++) {
95 for (
unsigned int interest_i = 0; interest_i <
fInterestingPDGs.size(); interest_i++) {
100 bool foundThemAll =
true;
103 foundThemAll =
false;
107 if (foundThemAll) {
return true; }
116 const unsigned int index)
const 120 if (!
PDGCheck(particle, index))
return false;
132 const unsigned int index)
const 135 if (pdg == 0)
return true;
136 if (particle->
PdgCode() != pdg)
return false;
141 const unsigned int index)
const 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;
151 const unsigned int index)
const 160 const unsigned int index)
const 169 const unsigned int index)
const 192 const unsigned int index)
const 217 const unsigned int index)
const 222 if (min_traj_length < 0)
return true;
228 std::vector<std::vector<TVector3>> position_segments;
230 std::vector<TVector3> position_segment;
238 if (curr_tpcid.
isValid) position_segment.push_back(particle->
Position(i).Vect());
240 else if (position_segment.size() > 0) {
242 position_segments.push_back(position_segment);
244 position_segment.clear();
249 if (position_segment.size() > 0) {
250 position_segments.push_back(position_segment);
251 position_segment.clear();
255 if (position_segments.size() == 0)
return false;
257 for (
unsigned int i = 0; i < position_segments.size(); i++) {
259 if (segment_length > min_traj_length) {
265 if (!OK)
return false;
274 if (position_segment.size() <= 1)
return length;
277 for (
unsigned int i = 1; i < position_segment.size(); i++) {
278 length += (position_segment[i] - position_segment[i - 1]).Mag();
288 <<
"Config error: InterestingPDGs and IsPrimary FCL vectors are different sizes\n";
291 <<
"Config error: InterestingPDGs and ParticleMinMomentum FCL vectors are different " 295 <<
"Config error: InterestingPDGs and ParticleMaxMomentum FCL vectors are different " 299 <<
"Config error: InterestingPDGs and StartInTPC FCL vectors are different sizes\n";
302 <<
"Config error: InterestingPDGs and StopInTPC FCL vectors are different sizes\n";
305 <<
"Config error: InterestingPDGs and ParticleMinTPCLength FCL vectors are different " 308 for (
unsigned int iIsPrimary = 0; iIsPrimary <
fIsPrimary.size(); iIsPrimary++)
312 <<
"Config error: Element " << iIsPrimary <<
" of the IsPrimary vector equals " 314 <<
". Valid options are -1 (not set), 0 (not primary) or 1 (is primary)" << std::endl;
316 for (
unsigned int iStartInTPC = 0; iStartInTPC <
fStartInTPC.size(); iStartInTPC++)
320 <<
"Config error: Element " << iStartInTPC <<
" of the StartInTPC vector equals " 322 <<
". Valid options are 0 (not set), 1 (start in TPC) or 2 (do not start in TPC)" 325 for (
unsigned int iStopInTPC = 0; iStopInTPC <
fStopInTPC.size(); iStopInTPC++)
329 <<
"Config error: Element " << iStopInTPC <<
" of the StopInTPC vector equals " 331 <<
". Valid options are 0 (not set), 1 (stop in TPC) or 2 (do not stop in TPC)" 341 <<
"Bounds error: Requested element " << index
342 <<
" from InterestingPDGs vector which is size " <<
fInterestingPDGs.size() <<
"\n";
345 <<
"Bounds error: Requested element " << index <<
" from IsPrimary vector which is size " 349 <<
"Bounds error: Requested element " << index
353 <<
"Bounds error: Requested element " << index
357 <<
"Bounds error: Requested element " << index <<
" from StartInTPC vector which is size " 361 <<
"Bounds error: Requested element " << index <<
" from StopInTPC vector which is size " 365 <<
"Bounds error: Requested element " << index
unsigned int NumberTrajectoryPoints() const
const TLorentzVector & Position(const int i=0) const
std::vector< bool > fFoundInterestingParticles
bool IsInterestingParticle(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
art::ServiceHandle< geo::Geometry const > fGeom
void VerifyDataMembers() const
bool isValid
Whether this ID points to a valid element.
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.
const std::vector< int > fInterestingPDGs
bool IsPrimaryCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
const std::vector< double > fParticleMaxMomentum
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
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
#define DEFINE_ART_MODULE(klass)
bool MinMomentumCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
const std::string fLArG4ModuleLabel
bool TPCTrajLengthCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
The data type to uniquely identify a TPC.
const std::vector< int > fStopInTPC
Definition of data types for geometry description.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
const std::vector< double > fParticleMinMomentum
const std::vector< int > fIsPrimary
const TLorentzVector & Momentum(const int i=0) const
const bool fRequireAllInterestingParticles
const std::vector< double > fParticleMinTPCLength
EDFilter(fhicl::ParameterSet const &pset)
virtual bool filter(art::Event &e)
const std::vector< int > fStartInTPC
art framework interface to geometry description
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
LArG4ParticleFilter(fhicl::ParameterSet const &pset)