Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
filt::LArG4ExtCounterFilter Class Reference
Inheritance diagram for filt::LArG4ExtCounterFilter:
art::EDFilter art::detail::Filter art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  CounterSetPair
 

Public Member Functions

 LArG4ExtCounterFilter (fhicl::ParameterSet const &pset)
 
virtual ~LArG4ExtCounterFilter ()
 
virtual bool filter (art::Event &e)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void beginJob ()
 
- Public Member Functions inherited from art::EDFilter
 EDFilter (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDFilter (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Filter
virtual ~Filter () noexcept
 
 Filter (fhicl::ParameterSet const &)
 
 Filter (Filter const &)=delete
 
 Filter (Filter &&)=delete
 
Filteroperator= (Filter const &)=delete
 
Filteroperator= (Filter &&)=delete
 
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)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

bool IsInterestingParticle (const art::Ptr< simb::MCParticle > particle)
 
bool UsesCounterSetPair (const CounterSetPair &CSP, const std::set< unsigned int > &usedCounterIDs)
 
bool UsesCounterSet (const std::vector< unsigned int > &counterIDs, const std::set< unsigned int > &usedCounterIDs)
 

Private Attributes

std::vector< CounterSetPairfCounterSetPairs
 
bool fUseEWCounterPair
 
bool fUseNupSdownCounterPair
 
bool fUseNdownSupCounterPair
 
std::vector< int > fInterestingPDGs
 
double fParticleMinEnergy
 
double fParticleMaxEnergy
 

Additional Inherited Members

- Public Types inherited from art::EDFilter
using ModuleType = EDFilter
 
using WorkerType = WorkerT< EDFilter >
 
- Public Types inherited from art::detail::Filter
template<typename UserConfig >
using Table = Modifier::Table< UserConfig >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Attributes inherited from art::detail::Filter
static constexpr bool Pass {true}
 
static constexpr bool Fail {false}
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

Definition at line 18 of file LArG4ExtCounterFilter_module.cc.

Constructor & Destructor Documentation

filt::LArG4ExtCounterFilter::LArG4ExtCounterFilter ( fhicl::ParameterSet const &  pset)
explicit
virtual filt::LArG4ExtCounterFilter::~LArG4ExtCounterFilter ( )
inlinevirtual

Definition at line 21 of file LArG4ExtCounterFilter_module.cc.

21 {};

Member Function Documentation

void filt::LArG4ExtCounterFilter::beginJob ( )
virtual

Reimplemented from art::EDFilter.

Definition at line 126 of file LArG4ExtCounterFilter_module.cc.

126  {
127 
128  //Need to get the counter information. By doing this at the start of the job, rather than per event, the code assumes the geomtry is not going to change between events
130  //Create the pairwise counter sets
131  CounterSetPair EWCounterSetPair;
132  CounterSetPair NupSdownCounterSetPair;
133  CounterSetPair NdownSupCounterSetPair;
134  //A stupid way of storing the IDs of the counters, this REALLY needs changing
135  //The code loops through all of the counters in the geomtry, and if the number matches a particular counter number e.g. one of the east counters, store it in the correct, pairwise set
136  for (unsigned int i = 0; i < geom->NAuxDets(); i++){
137  //The WE counter pairs
138  if (i >=6 && i <= 15) EWCounterSetPair.setA.push_back(i);
139  else if (i >= 28 && i <=37) EWCounterSetPair.setB.push_back(i);
140  //The N (up) S (down) counter pairs
141  else if (i >= 22 && i <= 27) NupSdownCounterSetPair.setA.push_back(i);
142  else if (i <= 5) NupSdownCounterSetPair.setB.push_back(i);
143  //The N (down) S (up) counter pairs
144  else if (i >= 16 && i <= 21) NdownSupCounterSetPair.setA.push_back(i);
145  else if (i >= 38 && i <= 43) NdownSupCounterSetPair.setB.push_back(i);
146  }
147 
148  //Enable/disable the counter set pairs
149  EWCounterSetPair.IsRequested = fUseEWCounterPair;
150  NupSdownCounterSetPair.IsRequested = fUseNupSdownCounterPair;
151  NdownSupCounterSetPair.IsRequested = fUseNdownSupCounterPair;
152 
153  //Store them onto the vector of counter set pairs
154  fCounterSetPairs.push_back(EWCounterSetPair);
155  fCounterSetPairs.push_back(NupSdownCounterSetPair);
156  fCounterSetPairs.push_back(NdownSupCounterSetPair);
157 
158 
159  for (unsigned int i = 0; i < fCounterSetPairs.size(); i++){
160  std::cout<<"Counter set pair: "<<i<<std::endl;
161  std::cout<<"--setA size: " << fCounterSetPairs[i].setA.size() << std::endl;
162  std::cout<<"--setB size: " << fCounterSetPairs[i].setB.size() << std::endl;
163 
164  }
165  }
std::vector< CounterSetPair > fCounterSetPairs
QTextStream & endl(QTextStream &s)
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
bool filt::LArG4ExtCounterFilter::filter ( art::Event e)
virtual

Implements art::EDFilter.

Definition at line 73 of file LArG4ExtCounterFilter_module.cc.

73  {
74 
76 
77 
78  //Get the vector of particles
79  auto particles = e.getHandle<std::vector<simb::MCParticle> >("largeant");
80  //Loop through the particles
81  for (unsigned int part_i = 0; part_i < particles->size(); part_i++){
82  //Get the particle
83  const art::Ptr<simb::MCParticle> particle(particles,part_i);
84  //Check if the particle is initially worth considering
85  if (IsInterestingParticle(particle)){
86  //OK so the particle matches the criteria we need. Now we need to get the IDs of all external counters it passes through
87  //To do this, get the trajectory points and find which counter (if any) said points are contained in
88  //Use a set to store the counter IDs the particle passes through
89  std::set<unsigned int> usedExtCounterIDs;
90  //Now get the trajcectory points
91  unsigned int npts = particle->NumberTrajectoryPoints();
92  //Loop over those points
93  for (unsigned int pt = 0; pt < npts; pt++){
94  //Get the position at the point
95  TLorentzVector pos4 = particle->Position(pt);
96  //The function which checks whether a position is contained in a counter requires a double[3]. So convert the position to that format
97  double pos[3];
98  pos[0] = pos4.X();
99  pos[1] = pos4.Y();
100  pos[2] = pos4.Z();
101  //If the position is not contained in a counter, the function throws an exception. We don't want to end the process when this happens
102  try{
103  //std::cout<<"AuxDetID: " << geom->FindAuxDetAtPosition(pos) << " pdg: " << particle->PdgCode() << std::endl;
104  unsigned int counterID = geom->FindAuxDetAtPosition(pos);
105  usedExtCounterIDs.insert(counterID);
106  }
107  catch(...){};
108  }
109  std::cout<<"NCounters (any) passed through: " << usedExtCounterIDs.size() << std::endl;
110  //We now have a list (set) of the counter IDs which the particles passed through. Now compare this list with the information stored in the CounterSetPairs
111  for (unsigned int csp_i = 0; csp_i < fCounterSetPairs.size(); csp_i++){
112  //Only bother comparing the information if a particlar counter set pair has been requested
113  if (!fCounterSetPairs[csp_i].IsRequested) continue;
114  if (UsesCounterSetPair(fCounterSetPairs[csp_i],usedExtCounterIDs)){
115  std::cout<<"SELECTED EVENT"<<std::endl;
116  return true;
117  }
118  }
119  }
120  }
121 
122  //Assume that the event is not worth saving
123  return false;
124  }
unsigned int FindAuxDetAtPosition(double const worldLoc[3], double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
bool IsInterestingParticle(const art::Ptr< simb::MCParticle > particle)
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::vector< CounterSetPair > fCounterSetPairs
bool UsesCounterSetPair(const CounterSetPair &CSP, const std::set< unsigned int > &usedCounterIDs)
QTextStream & endl(QTextStream &s)
bool filt::LArG4ExtCounterFilter::IsInterestingParticle ( const art::Ptr< simb::MCParticle particle)
private

Definition at line 167 of file LArG4ExtCounterFilter_module.cc.

167  {
168  //Loop over the list of requested PDGs. See if that matches the particle under consideration
169  for (unsigned int i = 0; i < fInterestingPDGs.size(); i++){
170  //Check if the particle under consideration has a requested PDG
171  if (particle->PdgCode() == fInterestingPDGs[i]){
172  //Got a requested PDG, now check that the energy matches the requested range
173  TLorentzVector mom4 = particle->Momentum();
174  if (mom4.T() > fParticleMinEnergy && mom4.T() < fParticleMaxEnergy){
175  //std::cout<<"FOUND INTERESTING PARTICLE"<<std::endl;
176  return true;
177  }
178  }
179  }
180  return false;
181  }
int PdgCode() const
Definition: MCParticle.h:212
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:220
void filt::LArG4ExtCounterFilter::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 55 of file LArG4ExtCounterFilter_module.cc.

55  {
56  fUseEWCounterPair = pset.get<bool>("UseEWCounterPair",1);
57  std::cout<<"Use EW counter pair: " << fUseEWCounterPair<<std::endl;
58  fUseNupSdownCounterPair = pset.get<bool>("UseNupSdownCounterPair",1);
59  std::cout<<"Use N (up) S (down) counter pair: " << fUseNupSdownCounterPair << std::endl;
60  fUseNdownSupCounterPair = pset.get<bool>("UseNdownSupCounterPair",1);
61  std::cout<<"Use N (down) S (up) counter pair: " << fUseNdownSupCounterPair << std::endl;
62  fInterestingPDGs = pset.get<std::vector<int> >("InterestingPDGs");
63  std::cout<<"NInteresting PDGs: " << fInterestingPDGs.size() << std::endl;
64  for (unsigned int i = 0; i < fInterestingPDGs.size(); i++){
65  std::cout<<"-- PDG: " << fInterestingPDGs[i] << std::endl;
66  }
67  fParticleMinEnergy = pset.get<double>("ParticleMinEnergy",0);
68  std::cout<<"Particle min energy: " << fParticleMinEnergy << std::endl;
69  fParticleMaxEnergy = pset.get<double>("ParticleMaxEnergy",999999999);
70  std::cout<<"Particle max energy: " << fParticleMaxEnergy << std::endl;
71  }
QTextStream & endl(QTextStream &s)
bool filt::LArG4ExtCounterFilter::UsesCounterSet ( const std::vector< unsigned int > &  counterIDs,
const std::set< unsigned int > &  usedCounterIDs 
)
private

Definition at line 195 of file LArG4ExtCounterFilter_module.cc.

195  {
196  //Iterate over the used counter IDs and compare them with every counter ID in the vector. If a match is found, this means the particle of interest passed through one of the counters in the vector
197  for (std::set<unsigned int>::iterator setIt = userCounterIDs.begin(); setIt != userCounterIDs.end(); setIt++){
198  unsigned int usedCounterID = (*setIt);
199  //Now loop through the IDs in the vector
200  for (unsigned int i = 0; i < counterIDs.size(); i++){
201  //Compare the elements. If there is a match, return true
202  if (usedCounterID == counterIDs[i]){
203  std::cout<<"Counter ID match"<<std::endl;
204  return true;
205  }
206  }
207  }
208 
209  //None of the used counters matched the counters in the set
210  return false;
211  }
intermediate_table::iterator iterator
QTextStream & endl(QTextStream &s)
bool filt::LArG4ExtCounterFilter::UsesCounterSetPair ( const CounterSetPair CSP,
const std::set< unsigned int > &  usedCounterIDs 
)
private

Definition at line 183 of file LArG4ExtCounterFilter_module.cc.

183  {
184 
185  bool usesSetA = UsesCounterSet(CSP.setA,usedCounterIDs);
186  bool usesSetB = UsesCounterSet(CSP.setB,usedCounterIDs);
187  if (usesSetA && usesSetB){
188  std::cout<<"USES BOTH SETS OF COUNTERS"<<std::endl;
189  return true;
190  }
191 
192  return false;
193  }
bool UsesCounterSet(const std::vector< unsigned int > &counterIDs, const std::set< unsigned int > &usedCounterIDs)
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::vector<CounterSetPair> filt::LArG4ExtCounterFilter::fCounterSetPairs
private

Definition at line 34 of file LArG4ExtCounterFilter_module.cc.

std::vector<int> filt::LArG4ExtCounterFilter::fInterestingPDGs
private

Definition at line 40 of file LArG4ExtCounterFilter_module.cc.

double filt::LArG4ExtCounterFilter::fParticleMaxEnergy
private

Definition at line 42 of file LArG4ExtCounterFilter_module.cc.

double filt::LArG4ExtCounterFilter::fParticleMinEnergy
private

Definition at line 41 of file LArG4ExtCounterFilter_module.cc.

bool filt::LArG4ExtCounterFilter::fUseEWCounterPair
private

Definition at line 37 of file LArG4ExtCounterFilter_module.cc.

bool filt::LArG4ExtCounterFilter::fUseNdownSupCounterPair
private

Definition at line 39 of file LArG4ExtCounterFilter_module.cc.

bool filt::LArG4ExtCounterFilter::fUseNupSdownCounterPair
private

Definition at line 38 of file LArG4ExtCounterFilter_module.cc.


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