Public Member Functions | Private Member Functions | Private Attributes | List of all members
simfilter::FilterSimPhotonTime Class Reference
Inheritance diagram for simfilter::FilterSimPhotonTime:
art::SharedFilter art::detail::Filter art::detail::SharedModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 FilterSimPhotonTime (fhicl::ParameterSet const &p, art::ProcessingFrame const &)
 
 FilterSimPhotonTime (FilterSimPhotonTime const &)=delete
 
 FilterSimPhotonTime (FilterSimPhotonTime &&)=delete
 
FilterSimPhotonTimeoperator= (FilterSimPhotonTime const &)=delete
 
FilterSimPhotonTimeoperator= (FilterSimPhotonTime &&)=delete
 
- Public Member Functions inherited from art::SharedFilter
 SharedFilter (fhicl::ParameterSet const &pset)
 
template<typename Config >
 SharedFilter (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)
 
- Public Member Functions inherited from art::detail::SharedModule
 SharedModule ()
 
 SharedModule (std::string const &moduleLabel)
 
hep::concurrency::SerialTaskQueueChain * serialTaskQueueChain () const
 
std::set< std::string > const & sharedResources () const
 
void createQueues (SharedResources const &resources)
 
template<BranchType , typename... T>
void serialize (T const &...resources)
 
template<BranchType , typename... T>
void serializeExternal (T const &...resources)
 

Private Member Functions

bool filter (art::Event &e, art::ProcessingFrame const &) override
 
void CheckTimeWindows () const
 

Private Attributes

std::string const fSimPhotonsCollectionLabel
 
std::vector< std::pair< float, float > > const fTimeWindows
 
float const fMinTotalEnergy
 
float const fMinPhotonEnergy
 
bool const fDebug
 
std::size_t const fN
 
bool const fUseReflectedPhotons
 
std::string const fReflectedLabel
 

Additional Inherited Members

- Public Types inherited from art::SharedFilter
using ModuleType = SharedFilter
 
using WorkerType = WorkerT< SharedFilter >
 
- 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 ()
 
- Protected Member Functions inherited from art::detail::SharedModule
template<BranchType BT = InEvent, typename... T>
void serialize (T const &...)
 
template<BranchType BT = InEvent, typename... T>
void serializeExternal (T const &...)
 
template<BranchType BT = InEvent>
void async ()
 

Detailed Description

Definition at line 28 of file FilterSimPhotonTime_module.cc.

Constructor & Destructor Documentation

simfilter::FilterSimPhotonTime::FilterSimPhotonTime ( fhicl::ParameterSet const &  p,
art::ProcessingFrame const &   
)
explicit

Definition at line 53 of file FilterSimPhotonTime_module.cc.

55  : SharedFilter{p}
56  , fSimPhotonsCollectionLabel(p.get<std::string>("SimPhotonsCollectionLabel"))
57  , fTimeWindows(p.get<std::vector<std::pair<float, float>>>("TimeWindows"))
58  , fMinTotalEnergy(p.get<float>("MinTotalEnergy", 0.0))
59  , fMinPhotonEnergy(p.get<float>("MinPhotonEnergy", -1))
60  , fDebug(p.get<bool>("Debug", false))
61  , fN(fTimeWindows.size())
62  , fUseReflectedPhotons(p.get<bool>("UseReflectedPhotons", false))
63  , fReflectedLabel(p.get<std::string>("ReflectedLabel", "Reflected"))
64 {
66 
67  // For printing out debug messages, we want to serialize the
68  // event-level calls so that the messages are not garbled.
69  // Otherwise, this module works well for asynchronous event-level
70  // calls.
71  if (fDebug) { serialize(); }
72  else {
73  async<art::InEvent>();
74  }
75 }
std::string string
Definition: nybbler.cc:12
std::vector< std::pair< float, float > > const fTimeWindows
struct vector vector
SharedFilter(fhicl::ParameterSet const &pset)
Definition: SharedFilter.h:22
p
Definition: test.py:223
void serialize(T const &...)
simfilter::FilterSimPhotonTime::FilterSimPhotonTime ( FilterSimPhotonTime const &  )
delete
simfilter::FilterSimPhotonTime::FilterSimPhotonTime ( FilterSimPhotonTime &&  )
delete

Member Function Documentation

void simfilter::FilterSimPhotonTime::CheckTimeWindows ( ) const
private

Definition at line 78 of file FilterSimPhotonTime_module.cc.

79 {
80 
81  if (fDebug)
82  std::cout << "\tFilterSimPhotonTime: TimeWindows size is " << fTimeWindows.size() << std::endl;
83 
84  for (auto const& tw : fTimeWindows) {
85  if (fDebug)
86  std::cout << "\t\tTimeWindow "
87  << "[" << tw.first << "," << tw.second << "]" << std::endl;
88 
89  if (tw.first > tw.second)
90  throw cet::exception("FilterSimPhotonTime::CheckTimeWindows")
91  << "Bad time window initialization: tw.first>tw.second. Reverse the order!" << std::endl;
92  }
93 }
std::vector< std::pair< float, float > > const fTimeWindows
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
bool simfilter::FilterSimPhotonTime::filter ( art::Event e,
art::ProcessingFrame const &   
)
overrideprivatevirtual

Implements art::SharedFilter.

Definition at line 96 of file FilterSimPhotonTime_module.cc.

97 {
98  auto const& simPhotonsCollection =
99  *e.getValidHandle<std::vector<sim::SimPhotons>>(fSimPhotonsCollectionLabel);
100 
101  std::vector<double> sumEnergyArray(fN, 0.0);
102 
103  const std::vector<sim::SimPhotons>& simPhotonsCollectionReflected =
104  fUseReflectedPhotons ? *e.getValidHandle<std::vector<sim::SimPhotons>>(
106  std::vector<sim::SimPhotons>();
107 
108  size_t n_sim_photons = simPhotonsCollection.size() + simPhotonsCollectionReflected.size();
109 
110  for (size_t i_pc = 0; i_pc < n_sim_photons; i_pc++) {
111  const sim::SimPhotons& simphotons =
112  (i_pc < simPhotonsCollection.size()) ?
113  simPhotonsCollection[i_pc] :
114  simPhotonsCollectionReflected[i_pc - simPhotonsCollection.size()];
115 
116  if (fDebug)
117  std::cout << "\tFilterSimPhotonTime: Processing simphotons channel " << simphotons.OpChannel()
118  << std::endl;
119 
120  for (auto const& photon : simphotons)
121  for (size_t i_tw = 0; i_tw < fN; i_tw++) {
122  auto const& tw(fTimeWindows[i_tw]);
123  if (photon.Time >= tw.first && photon.Time <= tw.second &&
124  photon.Energy > fMinPhotonEnergy) {
125 
126  if (fDebug) {
127  std::string photon_string =
128  (i_pc < simPhotonsCollection.size()) ? "Photon" : "Reflected Photon";
129  std::cout << "\t\t" << photon_string << " with time " << photon.Time << " detected. "
130  << "Energy is " << photon.Energy << "." << std::endl;
131  }
132 
133  sumEnergyArray[i_tw] += photon.Energy;
134 
135  if (fDebug)
136  std::cout << "\t\tTotal energy in this window (" << i_tw << ") is now "
137  << sumEnergyArray[i_tw] << std::endl;
138 
139  if (sumEnergyArray[i_tw] > fMinTotalEnergy) return true;
140  }
141  }
142  }
143 
144  if (fDebug) {
145  std::cout << "\tFilterSimPhotonTime: Final total energies are below min of " << fMinTotalEnergy
146  << ":" << std::endl;
147  for (size_t i_tw = 0; i_tw < fN; ++i_tw) {
148  std::cout << "\t\tTimeWindow "
149  << "[" << fTimeWindows[i_tw].first << "," << fTimeWindows[i_tw].second
150  << "]: " << sumEnergyArray[i_tw] << std::endl;
151  }
152  }
153 
154  return false;
155 }
int OpChannel() const
Returns the optical channel number this object is associated to.
Definition: SimPhotons.h:254
std::string string
Definition: nybbler.cc:12
std::vector< std::pair< float, float > > const fTimeWindows
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
Collection of photons which recorded on one channel.
Definition: SimPhotons.h:136
QTextStream & endl(QTextStream &s)
FilterSimPhotonTime& simfilter::FilterSimPhotonTime::operator= ( FilterSimPhotonTime const &  )
delete
FilterSimPhotonTime& simfilter::FilterSimPhotonTime::operator= ( FilterSimPhotonTime &&  )
delete

Member Data Documentation

bool const simfilter::FilterSimPhotonTime::fDebug
private

Definition at line 45 of file FilterSimPhotonTime_module.cc.

float const simfilter::FilterSimPhotonTime::fMinPhotonEnergy
private

Definition at line 44 of file FilterSimPhotonTime_module.cc.

float const simfilter::FilterSimPhotonTime::fMinTotalEnergy
private

Definition at line 43 of file FilterSimPhotonTime_module.cc.

std::size_t const simfilter::FilterSimPhotonTime::fN
private

Definition at line 46 of file FilterSimPhotonTime_module.cc.

std::string const simfilter::FilterSimPhotonTime::fReflectedLabel
private

Definition at line 48 of file FilterSimPhotonTime_module.cc.

std::string const simfilter::FilterSimPhotonTime::fSimPhotonsCollectionLabel
private

Definition at line 41 of file FilterSimPhotonTime_module.cc.

std::vector<std::pair<float, float> > const simfilter::FilterSimPhotonTime::fTimeWindows
private

Definition at line 42 of file FilterSimPhotonTime_module.cc.

bool const simfilter::FilterSimPhotonTime::fUseReflectedPhotons
private

Definition at line 47 of file FilterSimPhotonTime_module.cc.


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