All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
filt::FinalStateParticleFilter Class Reference
Inheritance diagram for filt::FinalStateParticleFilter:

Public Member Functions

 FinalStateParticleFilter (fhicl::ParameterSet const &)
 
bool filter (art::Event &evt)
 
void beginJob ()
 

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
 

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  }

Member Function Documentation

void filt::FinalStateParticleFilter::beginJob ( )

Definition at line 65 of file FinalStateParticleFilter_module.cc.

66  {
67  art::ServiceHandle<art::TFileService const> tfs;
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  }
art::ServiceHandle< art::TFileService > tfs
bool filt::FinalStateParticleFilter::filter ( art::Event &  evt)

Definition at line 73 of file FinalStateParticleFilter_module.cc.

74  {
75 
76  //const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
77 
78  art::Handle< std::vector<simb::MCTruth> > mclist;
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 isSubset(std::vector< int > const &a, std::vector< int > const &b) const
TCEvent evt
Definition: DataStructs.cxx:8
BEGIN_PROLOG could also be cout
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: