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

Public Member Functions

 PrimaryPionSelection (fhicl::ParameterSet const &p)
 
 PrimaryPionSelection (PrimaryPionSelection const &)=delete
 
 PrimaryPionSelection (PrimaryPionSelection &&)=delete
 
PrimaryPionSelectionoperator= (PrimaryPionSelection const &)=delete
 
PrimaryPionSelectionoperator= (PrimaryPionSelection &&)=delete
 
bool filter (art::Event &e) override
 
- 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 InRange (double, double, double)
 

Private Attributes

fhicl::ParameterSet beamlineUtil
 
protoana::ProtoDUNEBeamCuts beam_cuts
 
std::string fNominalMomentum
 
std::string fPFParticleTag
 
std::string fTrackerTag
 
std::string fShowerTag
 
std::string fCalorimetryTag
 
fhicl::ParameterSet fCalorimetryParameters
 
std::string fGeneratorTag
 
double fTrackEndZCut
 
bool fStrictNTracks
 
bool fUseMVA
 
double fDaughterCNNCut
 
double fChi2PIDCut
 
std::string dEdX_template_name
 
TFile dEdX_template_file
 
TProfile * profile
 

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 42 of file PrimaryPionSelection_module.cc.

Constructor & Destructor Documentation

PrimaryPionSelection::PrimaryPionSelection ( fhicl::ParameterSet const &  p)
explicit

Definition at line 89 of file PrimaryPionSelection_module.cc.

90  : EDFilter{p} ,
91 
92  beamlineUtil( p.get< fhicl::ParameterSet >("BeamlineUtils")),
93  beam_cuts( p.get< fhicl::ParameterSet >("BeamCuts") ),
94  fNominalMomentum( p.get< std::string >("NominalMomentum") ),
95  fPFParticleTag( p.get< std::string >("PFParticleTag")),
96  fTrackerTag( p.get< std::string >("TrackerTag")),
97  fShowerTag( p.get< std::string >("ShowerTag")),
98  fCalorimetryTag( p.get< std::string >("CalorimetryTag")),
99  fCalorimetryParameters( p.get< fhicl::ParameterSet >("CalorimetryParameters")),
100  fGeneratorTag( p.get< std::string >("GeneratorTag") ),
101 
102  //fTrackStartXCut( p.get< std::pair< double, double> >("TrackStartXCut") ),
103  //fTrackStartYCut( p.get< std::pair< double, double> >("TrackStartYCut") ),
104  //fTrackStartZCut( p.get< std::pair< double, double> >("TrackStartZCut") ),
105  fTrackEndZCut( p.get< double >("TrackEndZCut") ),
106  // fTrackDirCut( p.get< double>("TrackDirCut") ),
107  fStrictNTracks( p.get< bool >("StrictNTracks") ),
108  fUseMVA( p.get< bool >("UseMVA") ),
109  fDaughterCNNCut( p.get< double >("DaughterCNNCut") ),
110  fChi2PIDCut( p.get< double >("Chi2PIDCut") ),
111 
112  dEdX_template_name(p.get<std::string>("dEdX_template_name")),
113  dEdX_template_file( dEdX_template_name.c_str(), "OPEN" )
114 
115 {
116  profile = (TProfile*)dEdX_template_file.Get( "dedx_range_pro" );
117 }
protoana::ProtoDUNEBeamCuts beam_cuts
std::string string
Definition: nybbler.cc:12
p
Definition: test.py:223
fhicl::ParameterSet fCalorimetryParameters
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:21
PrimaryPionSelection::PrimaryPionSelection ( PrimaryPionSelection const &  )
delete
PrimaryPionSelection::PrimaryPionSelection ( PrimaryPionSelection &&  )
delete

Member Function Documentation

bool PrimaryPionSelection::filter ( art::Event e)
overridevirtual

Implements art::EDFilter.

Definition at line 119 of file PrimaryPionSelection_module.cc.

120 {
124 
125  if( e.isRealData() ){
126  if( !fBeamlineUtils.IsGoodBeamlineTrigger( e ) ){
127  MF_LOG_INFO("PrimaryPionSelection") << "Failed Beamline Trigger Check" << "\n";
128  return false;
129  }
130  }
131 
132 
133  std::vector<const recob::PFParticle*> beamParticles = pfpUtil.GetPFParticlesFromBeamSlice(e,fPFParticleTag);
134  if(beamParticles.size() == 0){
135  MF_LOG_INFO("PrimaryPionSelection") << "We found no beam particles for this event... moving on" << "\n";
136  return false;
137  }
138 
139  // Get the reconstructed PFParticle tagged as beam by Pandora
140  const recob::PFParticle* particle = beamParticles.at(0);
141 
142  // Determine if the beam particle is track-like or shower-like
143  const recob::Track* thisTrack = pfpUtil.GetPFParticleTrack(*particle,e,fPFParticleTag,fTrackerTag);
144  const recob::Shower* thisShower = pfpUtil.GetPFParticleShower(*particle,e,fPFParticleTag,fShowerTag);
145 
146  if( !thisTrack && thisShower ){
147  MF_LOG_INFO("PrimaryPionSelection") << "Beam Particle Reconstructed as shower" << "\n";
148  return false;
149  }
150  else if( !thisShower && !thisTrack ){
151  MF_LOG_INFO("PrimaryPionSelection") << "Beam Particle Not Reconstructed" << "\n";
152  return false;
153  }
154  else{
155  MF_LOG_INFO("PrimaryPionSelection") << "Beam Particle Reconstructed as track" << "\n";
156  }
157  ////////////////////////////////////////////////////////////////////
158  //The beam Particle has beam Type 13 like in PionAnalyzer module ////
159 
160 
161  if( !beam_cuts.IsBeamlike( *thisTrack, e, fNominalMomentum ) ){
162  MF_LOG_INFO("PrimaryPionSelection") << "Beam Particle failed Beam Cuts" << "\n";
163  return false;
164  }
165 
166 
167  //Here add in the cuts for the position of the beam and the incident angle
168  //First: need to switch reversed tracks
169  double endZ = thisTrack->Trajectory().End().Z();
170  double startZ = thisTrack->Trajectory().Start().Z();
171  if( startZ > endZ ){
172  double tempZ = endZ;
173  endZ = startZ;
174  startZ = tempZ;
175  }
176  //Cut for track length to cut out muons/keep the track within the APA3?
177  if( endZ > fTrackEndZCut ){
178  MF_LOG_INFO("PrimaryPionSelection") << "Failed End Z cut" << "\n";
179  return false;
180  }
181 
182 
183  //**********IGNORE DAUGHTERS FOR NOW*******
184  //Get some objects to use for CNN output checking later
185  //anab::MVAReader< recob::Hit, 4 > * hitResults = 0x0;
186  ////if( fUseMVA ) hitResults = new anab::MVAReader<recob::Hit,4>(e, "emtrkmichelid:emtrkmichel" );
187  //auto recoTracks = e.getValidHandle<std::vector<recob::Track> >(fTrackerTag);
188  //art::FindManyP<recob::Hit> findHits(recoTracks,e,fTrackerTag);
189  ////////////////////////////
190 
191 
192  //Look at the daughters and check for track-like daughters that look like showers
193  //to try to pick out misreco'd pi0 gammas
194  /*
195 
196  const std::vector< const recob::Track* > trackDaughters = pfpUtil.GetPFParticleDaughterTracks( *particle, e, fPFParticleTag, fTrackerTag );
197 
198  for( size_t i = 0; i < trackDaughters.size(); ++i ){
199  auto daughterTrack = trackDaughters.at(i);
200 
201 
202  auto daughterHits = findHits.at( daughterTrack->ID() );
203 
204  if( fUseMVA ){
205  double track_total = 0.;
206  for( size_t h = 0; h < daughterHits.size(); ++h ){
207  std::array<float,4> cnn_out = hitResults->getOutput( daughterHits[h] );
208  track_total += cnn_out[ hitResults->getIndex("track") ];
209  }
210 
211  if( track_total < fDaughterCNNCut ){
212  MF_LOG_INFO("PrimaryPionSelection") << "Found daughter track that looks like shower" << "\n";
213  continue;
214  }
215  }
216 
217  //Now: If it's not a potential gamma, pass the calorimetry through the
218  // Chi2 PID and see if any MIP-like daughters are associated
219 
220  auto daughter_calo = trackUtil.GetRecoTrackCalorimetry( *daughterTrack, e, fTrackerTag, fCalorimetryTag );
221  std::vector<float> calo_range = daughter_calo[0].ResidualRange();
222  std::vector<float> calo_dEdX;
223  if( e.isRealData() ) calo_dEdX = trackUtil.CalibrateCalorimetry( *daughterTrack, e, fTrackerTag, fCalorimetryTag, fCalorimetryParameters );
224  else calo_dEdX = daughter_calo[0].dEdx();
225 
226  std::vector<double> daughter_range, daughter_dEdX;
227  for( size_t j = 0; j < calo_range.size(); ++j ){
228  daughter_range.push_back( calo_range[i] );
229  daughter_dEdX.push_back( calo_dEdX[i] );
230  }
231 
232  std::pair< double,int > chi2_pid_results = trackUtil.Chi2PID( daughter_dEdX, daughter_range, profile );
233 
234  if( chi2_pid_results.first > fChi2PIDCut ){
235  MF_LOG_INFO("PrimaryPionSelection") << "Found daughter with MIP-like Chi2 PID" << "\n";
236  return false;
237  }
238  }
239 
240  */
241 
242 
243 
244  return true;
245 }
protoana::ProtoDUNEBeamCuts beam_cuts
const recob::Shower * GetPFParticleShower(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the shower associated to this particle. Returns a null pointer if not found.
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:98
bool IsBeamlike(const recob::Track &, const art::Event &, std::string)
bool isRealData() const
const recob::Track * GetPFParticleTrack(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the track associated to this particle. Returns a null pointer if not found.
const std::vector< const recob::PFParticle * > GetPFParticlesFromBeamSlice(art::Event const &evt, const std::string particleLabel) const
Return the pointers for the PFParticles in the beam slice. Returns an empty vector is no beam slice w...
#define MF_LOG_INFO(category)
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
bool PrimaryPionSelection::InRange ( double  input,
double  low,
double  high 
)
private

Definition at line 247 of file PrimaryPionSelection_module.cc.

247  {
248  return ( (input >= low) && (input <= high) );
249 }
static int input(void)
Definition: code.cpp:15695
PrimaryPionSelection& PrimaryPionSelection::operator= ( PrimaryPionSelection const &  )
delete
PrimaryPionSelection& PrimaryPionSelection::operator= ( PrimaryPionSelection &&  )
delete

Member Data Documentation

protoana::ProtoDUNEBeamCuts PrimaryPionSelection::beam_cuts
private

Definition at line 61 of file PrimaryPionSelection_module.cc.

fhicl::ParameterSet PrimaryPionSelection::beamlineUtil
private

Definition at line 59 of file PrimaryPionSelection_module.cc.

TFile PrimaryPionSelection::dEdX_template_file
private

Definition at line 82 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::dEdX_template_name
private

Definition at line 81 of file PrimaryPionSelection_module.cc.

fhicl::ParameterSet PrimaryPionSelection::fCalorimetryParameters
private

Definition at line 68 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::fCalorimetryTag
private

Definition at line 66 of file PrimaryPionSelection_module.cc.

double PrimaryPionSelection::fChi2PIDCut
private

Definition at line 79 of file PrimaryPionSelection_module.cc.

double PrimaryPionSelection::fDaughterCNNCut
private

Definition at line 78 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::fGeneratorTag
private

Definition at line 69 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::fNominalMomentum
private

Definition at line 62 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::fPFParticleTag
private

Definition at line 63 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::fShowerTag
private

Definition at line 65 of file PrimaryPionSelection_module.cc.

bool PrimaryPionSelection::fStrictNTracks
private

Definition at line 76 of file PrimaryPionSelection_module.cc.

double PrimaryPionSelection::fTrackEndZCut
private

Definition at line 74 of file PrimaryPionSelection_module.cc.

std::string PrimaryPionSelection::fTrackerTag
private

Definition at line 64 of file PrimaryPionSelection_module.cc.

bool PrimaryPionSelection::fUseMVA
private

Definition at line 77 of file PrimaryPionSelection_module.cc.

TProfile* PrimaryPionSelection::profile
private

Definition at line 83 of file PrimaryPionSelection_module.cc.


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