18 #include "TLorentzVector.h" 39 double CalculateLength(
const std::vector<TVector3> &position_segment)
const;
60 LArG4ParticleFilter::LArG4ParticleFilter::LArG4ParticleFilter(
fhicl::ParameterSet const & pset) :
64 fIsPrimary(pset.get<std::vector<int> >(
"IsPrimary")),
67 fStartInTPC(pset.get<std::vector<int> >(
"StartInTPC")),
68 fStopInTPC(pset.get<std::vector<int> >(
"StopInTPC")),
87 for (
unsigned int part_i = 0; part_i < particles->size(); part_i++){
91 for (
unsigned int interest_i = 0; interest_i <
fInterestingPDGs.size(); interest_i++){
95 bool foundThemAll =
true;
116 if (!
PDGCheck(particle,index))
return false;
130 if (pdg == 0)
return true;
137 const int isPrimaryCondition(
fIsPrimary[index]);
138 if (isPrimaryCondition==-1)
return true;
139 bool particlePrimaryStatus(particle->
Mother() > 0 ?
false:
true);
140 if (particlePrimaryStatus != isPrimaryCondition)
return false;
160 if (demand == 0)
return true;
162 TLorentzVector starting_position_4vect = particle->
Position(0);
163 double starting_position[3];
164 starting_position[0] = starting_position_4vect.X();
165 starting_position[1] = starting_position_4vect.Y();
166 starting_position[2] = starting_position_4vect.Z();
173 if (demand == 1)
return true;
178 if (demand == 2)
return true;
191 if (demand == 0)
return true;
194 double final_position[3];
195 final_position[0] = final_position_4vect.X();
196 final_position[1] = final_position_4vect.Y();
197 final_position[2] = final_position_4vect.Z();
204 if (demand == 1)
return true;
209 if (demand == 2)
return true;
222 if (min_traj_length < 0)
return true;
228 std::vector< std::vector<TVector3> > position_segments;
230 std::vector<TVector3> position_segment;
235 curr_pos[0] = particle->
Position(i).X();
236 curr_pos[1] = particle->
Position(i).Y();
237 curr_pos[2] = particle->
Position(i).Z();
241 if (curr_tpcid.
isValid) position_segment.push_back(particle->
Position(i).Vect());
243 else if (position_segment.size() > 0){
245 position_segments.push_back(position_segment);
247 position_segment.clear();
252 if (position_segment.size() > 0){
253 position_segments.push_back(position_segment);
254 position_segment.clear();
258 if (position_segments.size() == 0)
return false;
260 for (
unsigned int i = 0; i < position_segments.size(); i++){
262 if (segment_length > min_traj_length){
268 if (!OK)
return false;
277 if (position_segment.size() <= 1)
return length;
280 for (
unsigned int i = 1; i < position_segment.size(); i++){
281 length += (position_segment[i] - position_segment[i-1]).Mag();
302 for (
unsigned int iIsPrimary = 0; iIsPrimary <
fIsPrimary.size(); iIsPrimary++)
305 <<
fIsPrimary[iIsPrimary] <<
". Valid options are -1 (not set), 0 (not primary) or 1 (is primary)" <<
std::endl;
307 for (
unsigned int iStartInTPC = 0; iStartInTPC <
fStartInTPC.size(); iStartInTPC++)
310 <<
fStartInTPC[iStartInTPC] <<
". Valid options are 0 (not set), 1 (start in TPC) or 2 (do not start in TPC)" <<
std::endl;
312 for (
unsigned int iStopInTPC = 0; iStopInTPC <
fStopInTPC.size(); iStopInTPC++)
315 <<
fStopInTPC[iStopInTPC] <<
". Valid options are 0 (not set), 1 (stop in TPC) or 2 (do not stop in TPC)" <<
std::endl;
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
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
art framework interface to geometry description
bool StartInTPCCheck(const art::Ptr< simb::MCParticle > &particle, const unsigned int index) const
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#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
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
QTextStream & endl(QTextStream &s)
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)