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

Public Member Functions

 FinalStateParticleFilter (fhicl::ParameterSet const &)
 
bool filter (art::Event &evt)
 
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 isSubset (std::vector< int > const &a, std::vector< int > const &b) const
 

Private Attributes

std::string fGenieModuleLabel
 
std::vector< int > fPDG
 
std::vector< int > fStatusCode
 
TH1D * fSelectedEvents
 
TH1D * fTotalEvents
 

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 30 of file FinalStateParticleFilter_module.cc.

Constructor & Destructor Documentation

filt::FinalStateParticleFilter::FinalStateParticleFilter ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 57 of file FinalStateParticleFilter_module.cc.

58  : EDFilter{pset}
59  {
60  fGenieModuleLabel = pset.get< std::string >("GenieModuleLabel");
61  fPDG = pset.get< std::vector<int> >("PDG");
62  }
std::string string
Definition: nybbler.cc:12
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:21

Member Function Documentation

void filt::FinalStateParticleFilter::beginJob ( )
virtual

Reimplemented from art::EDFilter.

Definition at line 65 of file FinalStateParticleFilter_module.cc.

66  {
68  fSelectedEvents = tfs->make<TH1D>("fSelectedEvents", "Number of Selected Events", 3, 0, 3); //counts the number of selected events
69  fTotalEvents = tfs->make<TH1D>("fTotalEvents", "Total Events", 3, 0, 3); //counts the initial number of events in the unfiltered root input file
70  }
bool filt::FinalStateParticleFilter::filter ( art::Event evt)
virtual

Implements art::EDFilter.

Definition at line 73 of file FinalStateParticleFilter_module.cc.

74  {
75 
76  //const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
77 
79  evt.getByLabel(fGenieModuleLabel,mclist);
80  art::Ptr<simb::MCTruth> mc(mclist,0);
81 
82  fTotalEvents->Fill(1);
83 
84  std::vector<int> finalstateparticles;
85 
86  //get a vector of final state particles
87  for(int i = 0; i < mc->NParticles(); ++i){
88  simb::MCParticle part(mc->GetParticle(i));
89  if(part.StatusCode()== 1)
90  finalstateparticles.push_back(part.PdgCode());
91  }
92 
93  if(isSubset(fPDG, finalstateparticles)){
94  fSelectedEvents->Fill(1);
95  std::cout << "this is a selected event" << std::endl;
96  }
97 
98  return isSubset(fPDG, finalstateparticles); // returns true if the user-defined fPDG exist(s) in the final state particles
99 
100  } // bool
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
bool isSubset(std::vector< int > const &a, std::vector< int > const &b) const
QTextStream & endl(QTextStream &s)
bool filt::FinalStateParticleFilter::isSubset ( std::vector< int > const &  a,
std::vector< int > const &  b 
) const
private

Definition at line 105 of file FinalStateParticleFilter_module.cc.

106 {
107  for (auto const a_int : a) {
108  bool found = false;
109  for (auto const b_int : b) {
110  if (a_int == b_int){
111  found = true;
112  break;
113  }
114  }
115 
116  if (!found){
117  return false;
118  }
119  }
120  return true;
121 }

Member Data Documentation

std::string filt::FinalStateParticleFilter::fGenieModuleLabel
private

Definition at line 42 of file FinalStateParticleFilter_module.cc.

std::vector<int> filt::FinalStateParticleFilter::fPDG
private

Definition at line 43 of file FinalStateParticleFilter_module.cc.

TH1D* filt::FinalStateParticleFilter::fSelectedEvents
private

Definition at line 45 of file FinalStateParticleFilter_module.cc.

std::vector<int> filt::FinalStateParticleFilter::fStatusCode
private

Definition at line 44 of file FinalStateParticleFilter_module.cc.

TH1D* filt::FinalStateParticleFilter::fTotalEvents
private

Definition at line 46 of file FinalStateParticleFilter_module.cc.


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