OccupiedSpillFilter_module.cc
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////
2 /// \brief Simple Filter module to reject Events with no truth
3 /// information in them (i.e. all the cosmics missed the
4 /// detector big box or didn't make it through the rock),
5 /// no FLSHits or RawDigit info - empty event filter essentially.
6 /// \author Chris Backhouse - bckhouse@caltech.edu
7 /// \date July 2011
8 //////////////////////////////////////////////////////////////////////////
9 
10 // Framework includes
15 #include "fhiclcpp/ParameterSet.h"
17 
18 // NOvA includes
19 #include "RawData/RawDigit.h"
21 #include "Simulation/FLSHitList.h"
22 
23 namespace evgen
24 {
26  {
27  public:
28  explicit OccupiedSpillFilter(const fhicl::ParameterSet& pset);
30 
31  bool filter(art::Event& evt);
32 
33  void reconfigure(const fhicl::ParameterSet& pset);
34 
35  private:
37  std::string fG4GenLabel; ///< Default "geantgen"
38  std::string fDAQLabel; ///< Default "daq"
39 
40  // Switches to configure checking of different objects
42  bool fCheckDAQ;
43 
44  };
45 }
46 
47 
48 ////////////////////////////////////////////////////////////////////////
49 
50 namespace evgen
51 {
52  //......................................................................
54  fGenToken(consumes<std::vector<simb::MCTruth>>(pset.get<std::string>("GenLabel"))),
55  fCheckG4Gen(0),
56  fCheckDAQ (0)
57  {
58  reconfigure(pset);
59  }
60 
61  //......................................................................
63  {
64  }
65 
66  //......................................................................
68  {
69  fG4GenLabel = pset.get< std::string >("G4GenLabel");
70  fDAQLabel = pset.get< std::string >("DAQLabel" );
71 
72  fCheckG4Gen = pset.get< bool >("CheckG4Gen");
73  fCheckDAQ = pset.get< bool >("CheckDAQ" );
74  }
75  //......................................................................
77  {
78 
79  // get the MCTruth list
81  evt.getByToken(fGenToken, mcTruths);
82 
83  // Filter if no truth info
84  if(mcTruths.failedToGet()) {
85  mf::LogError("OccupiedSpillFilter") << "No MCTruth object. \n";
86  return false;
87  }
88  // Filter if truth info is empty
89  if(mcTruths->empty()) {
90  mf::LogError("OccupiedSpillFilter") << "Empty MCTruth object. \n";
91  return false;
92  }
93 
94  const simb::MCTruth mcTruth = (*mcTruths)[0];
95 
96 
97  if(fCheckG4Gen){
98  // get the FLSHit list
100  evt.getByLabel(fG4GenLabel, FLScol);
101  // Filter if no FLShit info
102  if (FLScol.failedToGet()) {
103  mf::LogError("OccupiedSpillFilter") << "No FLSHit object. \n";
104  return false;
105  }
106  // Filter if FLShit info is empty
107  if(FLScol->empty()) {
108  mf::LogError("OccupiedSpillFilter") << "Empty FLSHit object. \n";
109  return false;
110  }
111  }
112 
113  if(fCheckDAQ){
114  // get the RawDigit list
116  evt.getByLabel(fDAQLabel, digitcol);
117  // Filter if no rawdata info
118  if(digitcol.failedToGet()) {
119  mf::LogError("OccupiedSpillFilter") << "No RawDigit object. \n";
120  return false;
121  }
122  // Filter if rawdata info is empty
123  if(digitcol->empty()) {
124  mf::LogError("OccupiedSpillFilter") << "Empty RawDigit object. \n";
125  return false;
126  }
127  }
128 
129  // Pass if there are Truth particles of course
130  // after all subsequent checks
131  return (mcTruth.NParticles() != 0);
132  }
133 } // namespace
134 
135 ////////////////////////////////////////////////////////////////////////
136 namespace evgen
137 {
139 }
void reconfigure(const fhicl::ParameterSet &pset)
int NParticles() const
Definition: MCTruth.h:74
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
OccupiedSpillFilter(const fhicl::ParameterSet &pset)
DEFINE_ART_MODULE(TestTMapFile)
const art::ProductToken< std::vector< simb::MCTruth > > fGenToken
std::string fDAQLabel
Default "daq".
T get(std::string const &key) const
Definition: ParameterSet.h:231
int evt
This class describes a particle created in the detector Monte Carlo simulation.
std::string fG4GenLabel
Default "geantgen".
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Event generator information.
Definition: MCTruth.h:32
bool getByToken(ProductToken< PROD > const &token, Handle< PROD > &result) const
Definition: DataViewImpl.h:387
Module to generate only pions from cosmic rays.
ProductToken< T > consumes(InputTag const &)
bool failedToGet() const
Definition: Handle.h:196
enum BeamMode string