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

Public Member Functions

 FilterSimPhotonLiteTime (fhicl::ParameterSet const &p, art::ProcessingFrame const &)
 
 FilterSimPhotonLiteTime (FilterSimPhotonLiteTime const &)=delete
 
 FilterSimPhotonLiteTime (FilterSimPhotonLiteTime &&)=delete
 
FilterSimPhotonLiteTimeoperator= (FilterSimPhotonLiteTime const &)=delete
 
FilterSimPhotonLiteTimeoperator= (FilterSimPhotonLiteTime &&)=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 fSimPhotonsLiteCollectionLabel
 Label for the sim::SimPhotonsLite data product. More...
 
std::vector< std::pair< int, int > > const fTimeWindows
 Time windows used for filtering. Units are the same as in the sim::SimPhotonsLite. More...
 
int const fMinTotalPhotons
 Minimum number of photons inside a window to pass the filter. More...
 
bool const fDebug
 Set to true to print (a lot of) debug information. More...
 
std::size_t const fN
 Number of time winows. More...
 
bool const fUseReflectedPhotons
 Whether to include reflected photons in the filter. More...
 
std::string const fReflectedLabel
 Label for the reflected photons – "Reflected" by default. More...
 

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 32 of file FilterSimPhotonLiteTime_module.cc.

Constructor & Destructor Documentation

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

Definition at line 58 of file FilterSimPhotonLiteTime_module.cc.

60  : SharedFilter{p}
61  , fSimPhotonsLiteCollectionLabel(p.get<std::string>("SimPhotonsLiteCollectionLabel"))
62  , fTimeWindows(p.get<std::vector<std::pair<int, int>>>("TimeWindows"))
63  , fMinTotalPhotons(p.get<int>("MinTotalPhotons"))
64  , fDebug(p.get<bool>("Debug", false))
65  , fN(fTimeWindows.size())
66  , fUseReflectedPhotons(p.get<bool>("UseReflectedPhotons", false))
67  , fReflectedLabel(p.get<std::string>("ReflectedLabel", "Reflected"))
68 {
70 
71  // For printing out debug messages, we want to serialize the
72  // event-level calls so that the messages are not garbled.
73  // Otherwise, this module works well for asynchronous event-level
74  // calls.
75  if (fDebug) { serialize(); }
76  else {
77  async<art::InEvent>();
78  }
79 }
std::string string
Definition: nybbler.cc:12
struct vector vector
int const fMinTotalPhotons
Minimum number of photons inside a window to pass the filter.
SharedFilter(fhicl::ParameterSet const &pset)
Definition: SharedFilter.h:22
bool const fUseReflectedPhotons
Whether to include reflected photons in the filter.
bool const fDebug
Set to true to print (a lot of) debug information.
std::string const fReflectedLabel
Label for the reflected photons – "Reflected" by default.
p
Definition: test.py:223
std::size_t const fN
Number of time winows.
void serialize(T const &...)
std::string const fSimPhotonsLiteCollectionLabel
Label for the sim::SimPhotonsLite data product.
std::vector< std::pair< int, int > > const fTimeWindows
Time windows used for filtering. Units are the same as in the sim::SimPhotonsLite.
simfilter::FilterSimPhotonLiteTime::FilterSimPhotonLiteTime ( FilterSimPhotonLiteTime const &  )
delete
simfilter::FilterSimPhotonLiteTime::FilterSimPhotonLiteTime ( FilterSimPhotonLiteTime &&  )
delete

Member Function Documentation

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

Definition at line 82 of file FilterSimPhotonLiteTime_module.cc.

83 {
84 
85  if (fDebug)
86  std::cout << "\tFilterSimPhotonLiteTime: TimeWindows size is " << fTimeWindows.size()
87  << std::endl;
88 
89  for (auto const& tw : fTimeWindows) {
90  if (fDebug)
91  std::cout << "\t\tTimeWindow "
92  << "[" << tw.first << "," << tw.second << "]" << std::endl;
93 
94  if (tw.first > tw.second)
95  throw cet::exception("FilterSimPhotonLiteTime::CheckTimeWindows")
96  << "Bad time window initialization: tw.first>tw.second. Reverse the order!" << std::endl;
97  }
98 }
bool const fDebug
Set to true to print (a lot of) debug information.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::vector< std::pair< int, int > > const fTimeWindows
Time windows used for filtering. Units are the same as in the sim::SimPhotonsLite.
bool simfilter::FilterSimPhotonLiteTime::filter ( art::Event e,
art::ProcessingFrame const &   
)
overrideprivatevirtual

Implements art::SharedFilter.

Definition at line 101 of file FilterSimPhotonLiteTime_module.cc.

102 {
103  auto const& simPhotonsLiteCollection =
104  *e.getValidHandle<std::vector<sim::SimPhotonsLite>>(fSimPhotonsLiteCollectionLabel);
105 
106  std::vector<int> sumNPhotonArray(fN, 0);
107 
108  const std::vector<sim::SimPhotonsLite>& simPhotonsLiteCollectionReflected =
109  fUseReflectedPhotons ? *e.getValidHandle<std::vector<sim::SimPhotonsLite>>(
111  std::vector<sim::SimPhotonsLite>();
112 
113  size_t n_sim_photons = simPhotonsLiteCollection.size() + simPhotonsLiteCollectionReflected.size();
114 
115  if (fDebug) {
116  std::cout << "New event to filter with total # sim photons: " << n_sim_photons << std::endl;
117  }
118 
119  for (size_t i_pc = 0; i_pc < n_sim_photons; i_pc++) {
120  const sim::SimPhotonsLite& simphotonslite =
121  (i_pc < simPhotonsLiteCollection.size()) ?
122  simPhotonsLiteCollection[i_pc] :
123  simPhotonsLiteCollectionReflected[i_pc - simPhotonsLiteCollection.size()];
124 
125  if (fDebug)
126  std::cout << "\tFilterSimPhotonLiteTime: Processing simphotonslite channel "
127  << simphotonslite.OpChannel << std::endl;
128 
129  for (auto const& photon_pair : simphotonslite.DetectedPhotons) {
130  for (size_t i_tw = 0; i_tw < fN; i_tw++) {
131  auto const& tw(fTimeWindows[i_tw]);
132  if (photon_pair.first >= tw.first && photon_pair.first <= tw.second) {
133 
134  if (fDebug) {
135  std::string photon_string =
136  (i_pc < simPhotonsLiteCollection.size()) ? "Photon" : "Reflected Photon";
137  std::cout << "\t\t" << photon_string << " with number " << photon_pair.second
138  << " at time " << photon_pair.first << " detected." << std::endl;
139  }
140 
141  sumNPhotonArray[i_tw] += photon_pair.second;
142 
143  if (fDebug)
144  std::cout << "\t\tTotal number of photons in this window (" << i_tw << ") is now "
145  << sumNPhotonArray[i_tw] << std::endl;
146 
147  if (sumNPhotonArray[i_tw] >= fMinTotalPhotons) return true;
148  }
149  }
150  }
151  }
152 
153  if (fDebug) {
154  std::cout << "\tFilterSimPhotonLiteTime: Final total numbers are below min of "
155  << fMinTotalPhotons << ":" << std::endl;
156  for (size_t i_tw = 0; i_tw < fN; ++i_tw) {
157  std::cout << "\t\tTimeWindow "
158  << "[" << fTimeWindows[i_tw].first << "," << fTimeWindows[i_tw].second
159  << "]: " << sumNPhotonArray[i_tw] << std::endl;
160  }
161  }
162 
163  return false;
164 }
std::string string
Definition: nybbler.cc:12
int const fMinTotalPhotons
Minimum number of photons inside a window to pass the filter.
bool const fUseReflectedPhotons
Whether to include reflected photons in the filter.
std::map< int, int > DetectedPhotons
Number of photons detected at each given time: time tick -> photons.
Definition: SimPhotons.h:117
bool const fDebug
Set to true to print (a lot of) debug information.
std::string const fReflectedLabel
Label for the reflected photons – "Reflected" by default.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
int OpChannel
Optical detector channel associated to this data.
Definition: SimPhotons.h:114
Compact representation of photons on a channel.
Definition: SimPhotons.h:103
std::size_t const fN
Number of time winows.
std::string const fSimPhotonsLiteCollectionLabel
Label for the sim::SimPhotonsLite data product.
QTextStream & endl(QTextStream &s)
std::vector< std::pair< int, int > > const fTimeWindows
Time windows used for filtering. Units are the same as in the sim::SimPhotonsLite.
FilterSimPhotonLiteTime& simfilter::FilterSimPhotonLiteTime::operator= ( FilterSimPhotonLiteTime const &  )
delete
FilterSimPhotonLiteTime& simfilter::FilterSimPhotonLiteTime::operator= ( FilterSimPhotonLiteTime &&  )
delete

Member Data Documentation

bool const simfilter::FilterSimPhotonLiteTime::fDebug
private

Set to true to print (a lot of) debug information.

Definition at line 50 of file FilterSimPhotonLiteTime_module.cc.

int const simfilter::FilterSimPhotonLiteTime::fMinTotalPhotons
private

Minimum number of photons inside a window to pass the filter.

Definition at line 49 of file FilterSimPhotonLiteTime_module.cc.

std::size_t const simfilter::FilterSimPhotonLiteTime::fN
private

Number of time winows.

Definition at line 51 of file FilterSimPhotonLiteTime_module.cc.

std::string const simfilter::FilterSimPhotonLiteTime::fReflectedLabel
private

Label for the reflected photons – "Reflected" by default.

Definition at line 53 of file FilterSimPhotonLiteTime_module.cc.

std::string const simfilter::FilterSimPhotonLiteTime::fSimPhotonsLiteCollectionLabel
private

Label for the sim::SimPhotonsLite data product.

Definition at line 46 of file FilterSimPhotonLiteTime_module.cc.

std::vector<std::pair<int, int> > const simfilter::FilterSimPhotonLiteTime::fTimeWindows
private

Time windows used for filtering. Units are the same as in the sim::SimPhotonsLite.

Definition at line 48 of file FilterSimPhotonLiteTime_module.cc.

bool const simfilter::FilterSimPhotonLiteTime::fUseReflectedPhotons
private

Whether to include reflected photons in the filter.

Definition at line 52 of file FilterSimPhotonLiteTime_module.cc.


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