GENIEFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: GENIEFilter
3 // Module Type: filter
4 // File: GENIEFilter_module.cc
5 //
6 // Generated at Tue Nov 17 11:20:20 2015 by Kanika Sachdev using artmod
7 // from cetpkgsupport v1_08_07.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
20 #include <memory>
21 
22 #include "GENIE/Framework/GHEP/GHepStatus.h"
23 
25 
26 namespace evgen {
27 
28  /// A filter module to throw away spills where genie output
29  /// has undesired characteristics. Currently only throws away
30  /// events with undecayed 2-nucleon final states
31  class GENIEFilter;
32 }
33 
35 public:
36  explicit GENIEFilter(fhicl::ParameterSet const & p);
37 
38  GENIEFilter(GENIEFilter const &) = delete;
39  GENIEFilter(GENIEFilter &&) = delete;
40  GENIEFilter & operator = (GENIEFilter const &) = delete;
41  GENIEFilter & operator = (GENIEFilter &&) = delete;
42 
43 
44  bool filter(art::Event & e) override;
45  void reconfigure(const fhicl::ParameterSet& pset);
46 
47 private:
49 
50 };
51 
52 //-------------------------------------------------------------
53 
55  : fGENIEToken(consumes<std::vector<simb::MCTruth>>(p.get<std::string>("GENIELabel")))
56 {
57  reconfigure(p);
58 }
59 
60 //-------------------------------------------------------------
61 
63 {
64 }
65 
66 //-------------------------------------------------------------
67 
69 {
71  e.getByToken(fGENIEToken, truthcol);
72 
73  unsigned int ntruths = truthcol->size();
74 
75  for(unsigned int itruth = 0; itruth < ntruths; ++itruth){
76 
77  unsigned int nparts = truthcol->at(itruth).NParticles();
78 
79  for(unsigned int ipart = 0; ipart < nparts; ++ipart){
80  const simb::MCParticle& particle= truthcol->at(itruth).GetParticle(ipart);
81 
82  // Criteria to throw away dinucleon states
83  // that GENIE wasn't able to decay into appropriate
84  // final states. From Robert H., doc 14388, dated Nov 16, 2015.
85  // Needed for genie 2_8_6. Might not be needed for future
86  // revisions.
87  if( (particle.PdgCode() == 2000000200 || // n+n final state
88  particle.PdgCode() == 2000000201 || // n+p final state
89  particle.PdgCode() == 2000000202) && // p+p final state
91  particle.StatusCode() == genie::kIStDecayedState )){
92 
93  // loop over all the other particles and see if anyone
94  // claims to have this dinucleon as its mother
95  // We can directly probe the daughter info directly because
96  // GENIE doesn't seem to be filling it in properly
97  bool foundDaughter = false;
98 
99  for(unsigned int jpart = 0; jpart < nparts; ++jpart){
100  const simb::MCParticle& jparticle= truthcol->at(itruth).GetParticle(jpart);
101  if( jparticle.Mother() == particle.TrackId() ){
102  foundDaughter = true;
103  break;
104  }
105  }// end loop over j particles
106 
107  if(!foundDaughter)
108  return Fail;
109 
110  }// end if found a dinucleon
111  }// end loop over MCParticles
112  }// end loop over MCTruths
113 
114  return Pass;
115 }
116 
117 //-------------------------------------------------------------
118 
int PdgCode() const
Definition: MCParticle.h:211
Int_t ipart
Definition: Style.C:10
bool filter(art::Event &e) override
void reconfigure(const fhicl::ParameterSet &pset)
int Mother() const
Definition: MCParticle.h:212
const char * p
Definition: xmltok.h:285
static constexpr bool Pass
Definition: EDFilter.h:32
int StatusCode() const
Definition: MCParticle.h:210
GENIEFilter & operator=(GENIEFilter const &)=delete
DEFINE_ART_MODULE(TestTMapFile)
int TrackId() const
Definition: MCParticle.h:209
GENIEFilter(fhicl::ParameterSet const &p)
static constexpr bool Fail
Definition: EDFilter.h:33
This class describes a particle created in the detector Monte Carlo simulation.
bool getByToken(ProductToken< PROD > const &token, Handle< PROD > &result) const
Definition: DataViewImpl.h:387
Float_t e
Definition: plot.C:35
Module to generate only pions from cosmic rays.
ProductToken< T > consumes(InputTag const &)
const art::ProductToken< std::vector< simb::MCTruth > > fGENIEToken
enum BeamMode string