EventSelector_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: EventSelector
3 // Module Type: filter
4 // File: EventSelector_module.cc
5 //
6 // Generated at Tue Dec 1 15:03:41 2015 by Martin Frank using artmod
7 // from cetpkgsupport v1_08_07.
8 ////////////////////////////////////////////////////////////////////////
9 
16 // #include <canvas/Utilities/InputTag.h>
17 #include <art/Utilities/InputTag.h>
18 #include <fhiclcpp/ParameterSet.h>
20 
21 #include "MCCheater/BackTracker.h"
22 #include "Monopole/Constants.h"
23 #include "Monopole/Track3D.h"
24 #include "RecoBase/Cluster.h"
25 #include "Simulation/Particle.h"
26 
27 #include <iostream>
28 #include <memory>
29 
30 namespace mono
31 {
32  class EventSelector;
33 }
34 
36 {
37 public:
38  explicit EventSelector(fhicl::ParameterSet const & p);
39 
40  EventSelector(EventSelector const &) = delete;
41  EventSelector(EventSelector &&) = delete;
42  EventSelector & operator = (EventSelector const &) = delete;
44 
45  bool filter(art::Event & e) override;
46 
47 private:
49 };
50 
51 
52 
54 {
55 }
56 
57 
58 
60 {
61  //
62  // Extract Objects from the Event
63  //
65  e.getByLabel("monoslicer", mono_slices);
66 
68  e.getByLabel("monotrack", reco_tracks);
69 
70 
71  //
72  // Select Desired Events
73  //
74 
75  // Slice Counts
76  // unsigned n_slices = 0;
77  // for (auto const& slice : *mono_slices)
78  // if (!slice.IsNoise())
79  // ++n_slices;
80 
81  // if (n_slices > 1)
82  // {
83  // std::cout << "MF (Event Selector): This event has "
84  // << n_slices << " slices."
85  // << "\nMF (Event Selector): Saving Event." << std::endl;
86  // return true;
87  // }
88 
89  // Beta Reconstruction/Truth Difference
90  if (bt_->HaveTruthInfo())
91  {
93  if (pn.size() == 1)
94  {
95  sim::Particle const* particle = pn.Primary(0);
96  unsigned const trajectory = 0;
97 
99  auto m = particle->Mass();
100  auto p = particle->Momentum(trajectory);
101  auto mc_beta = p.P() / m;
102 
103  if (!reco_tracks->empty())
104  {
105  auto reco_beta = reco_tracks->front().beta();
106  auto beta_diff = (mc_beta - reco_beta) / mc_beta;
107 
108  if (std::fabs(beta_diff) > 0.1)
109  {
110  std::cout << "MF (Event Selector): beta_diff = " << beta_diff
111  << "\nMF (Event Selector): Saving Event." << std::endl;
112  return true;
113  }
114  }
115  }
116  }
117 
118  std::cout << "MF (Event Selector): Skipping Event." << std::endl;
119  return false;
120 }
121 
122 
123 
back track the reconstruction to the simulation
bool filter(art::Event &e) override
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
Definition: Cluster.h:13
const sim::ParticleNavigator & ParticleNavigator() const
Get a reference to the ParticleNavigator.
Definition: BackTracker.h:744
size_type size() const
const char * p
Definition: xmltok.h:285
double Mass() const
Definition: MCParticle.h:238
EventSelector & operator=(EventSelector const &)=delete
const double SPEED_OF_LIGHT
Definition: Constants.h:8
DEFINE_ART_MODULE(TestTMapFile)
art::ServiceHandle< cheat::BackTracker > bt_
EventSelector(fhicl::ParameterSet const &p)
const sim::Particle * Primary(const int) const
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:219
bool HaveTruthInfo() const
Is this a file with truth info in? (Is BackTracker going to be any use to you?)
Definition: BackTracker.h:133
Float_t e
Definition: plot.C:35