Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
skim::RandomEventFilter Class Reference
Inheritance diagram for skim::RandomEventFilter:
art::EDFilter art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDFilter
 
using WorkerType = WorkerT< EDFilter >
 
template<typename UserConfig >
using Table = ProducerBase::Table< UserConfig >
 

Public Member Functions

 RandomEventFilter (fhicl::ParameterSet const &p)
 
virtual ~RandomEventFilter ()
 
 RandomEventFilter (RandomEventFilter const &)=delete
 
 RandomEventFilter (RandomEventFilter &&)=delete
 
RandomEventFilteroperator= (RandomEventFilter const &)=delete
 
RandomEventFilteroperator= (RandomEventFilter &&)=delete
 
bool filter (art::Event &e) override
 
bool beginSubRun (art::SubRun &sr) override
 
bool endRun (art::Run &r) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Static Public Attributes

static constexpr bool Pass {true}
 
static constexpr bool Fail {false}
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

float fThreshold
 threshold for random number to be filtered More...
 
TRandom3 fRandom
 random number generator to decide if we should keep an event More...
 
sumdata::POTSum fPOTSum
 POT summary for the subrun. More...
 
std::string fPOTLabel
 label for POTs in subrun object More...
 

Detailed Description

Definition at line 29 of file RandomEventFilter_module.cc.

Member Typedef Documentation

using art::EDFilter::ModuleType = EDFilter
inherited

Definition at line 37 of file EDFilter.h.

template<typename UserConfig >
using art::EDFilter::Table = ProducerBase::Table<UserConfig>
inherited

Definition at line 46 of file EDFilter.h.

using art::EDFilter::WorkerType = WorkerT<EDFilter>
inherited

Definition at line 38 of file EDFilter.h.

Constructor & Destructor Documentation

skim::RandomEventFilter::RandomEventFilter ( fhicl::ParameterSet const &  p)
explicit

Definition at line 58 of file RandomEventFilter_module.cc.

References fPOTSum, fRandom, sumdata::POTSum::goodspills, reconfigure(), sumdata::POTSum::totgoodpot, sumdata::POTSum::totpot, and sumdata::POTSum::totspills.

59 {
60  this->reconfigure(p);
61 
62  // this call apparently sets a unique seed for this process
63  fRandom.SetSeed();
64 
65  // for every subrun, create a POTSum object
66  produces<sumdata::POTSum, art::InRun>();
67 
68  // initialize the pot summary to 0
69  fPOTSum.totpot = 0.;
70  fPOTSum.totgoodpot = 0.;
71  fPOTSum.totspills = 0;
72  fPOTSum.goodspills = 0;
73 
74  return;
75 }
void reconfigure(fhicl::ParameterSet const &p)
const char * p
Definition: xmltok.h:285
TRandom3 fRandom
random number generator to decide if we should keep an event
sumdata::POTSum fPOTSum
POT summary for the subrun.
int goodspills
Definition: POTSum.h:31
int totspills
Definition: POTSum.h:30
double totgoodpot
normalized by 10^12 POT
Definition: POTSum.h:28
double totpot
normalized by 10^12 POT
Definition: POTSum.h:27
skim::RandomEventFilter::~RandomEventFilter ( )
virtual

Definition at line 78 of file RandomEventFilter_module.cc.

79 {
80 }
skim::RandomEventFilter::RandomEventFilter ( RandomEventFilter const &  )
delete
skim::RandomEventFilter::RandomEventFilter ( RandomEventFilter &&  )
delete

Member Function Documentation

bool skim::RandomEventFilter::beginSubRun ( art::SubRun sr)
overridevirtual

Reimplemented from art::EDFilter.

Definition at line 83 of file RandomEventFilter_module.cc.

References fPOTLabel, fPOTSum, art::DataViewImpl::getByLabel(), LOG_VERBATIM, and pot.

84 {
86  sr.getByLabel(fPOTLabel, pot);
87 
88  LOG_VERBATIM("RandomEventFilter")
89  << "adding "
90  << (*pot).totgoodpot
91  << " POT to sum";
92  fPOTSum += *pot;
93 
94  return true;
95 }
#define pot
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
sumdata::POTSum fPOTSum
POT summary for the subrun.
std::string fPOTLabel
label for POTs in subrun object
#define LOG_VERBATIM(category)
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDFilter::currentContext ( ) const
protectedinherited
bool skim::RandomEventFilter::endRun ( art::Run r)
overridevirtual

Reimplemented from art::EDFilter.

Definition at line 98 of file RandomEventFilter_module.cc.

References fPOTSum, fThreshold, sumdata::POTSum::goodspills, sumdata::POTSum::totgoodpot, sumdata::POTSum::totpot, and sumdata::POTSum::totspills.

99 {
100  // scale the total POT and spills by the fraction to keep
101  float keepFrac = 1. - fThreshold;
102  fPOTSum.totpot *= keepFrac;
103  fPOTSum.totgoodpot *= keepFrac;
104  fPOTSum.totspills *= keepFrac;
105  fPOTSum.goodspills *= keepFrac;
106 //
107 // std::unique_ptr< sumdata::POTSum > potsum(new sumdata::POTSum(fPOTSum));
108 //
109 // LOG_VERBATIM("RandomEventFilter")
110 // << "There are "
111 // << potsum->totgoodpot
112 // << " POT in run "
113 // << r.run();
114 //
115 // r.put(std::move(potsum));
116 //
117  // reset the summary to 0
118  fPOTSum.totpot = 0.;
119  fPOTSum.totgoodpot = 0.;
120  fPOTSum.totspills = 0;
121  fPOTSum.goodspills = 0;
122 
123  return true;
124 }
float fThreshold
threshold for random number to be filtered
sumdata::POTSum fPOTSum
POT summary for the subrun.
int goodspills
Definition: POTSum.h:31
int totspills
Definition: POTSum.h:30
double totgoodpot
normalized by 10^12 POT
Definition: POTSum.h:28
double totpot
normalized by 10^12 POT
Definition: POTSum.h:27
bool skim::RandomEventFilter::filter ( art::Event e)
overridevirtual

Implements art::EDFilter.

Definition at line 127 of file RandomEventFilter_module.cc.

References fRandom, fThreshold, and central_limit::rand.

128 {
129  float rand = fRandom.Rndm();
130 
131  if(rand > fThreshold) return true;
132 
133  return false;
134 }
TRandom3 fRandom
random number generator to decide if we should keep an event
float fThreshold
threshold for random number to be filtered
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDFilter::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 131 of file EDFilter.h.

References art::EDFilter::moduleDescription_.

Referenced by novaddt::HoughTrackMaker::create_associations().

132  {
133  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
134  instanceName);
135  }
ModuleDescription moduleDescription_
Definition: EDFilter.h:124
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
RandomEventFilter& skim::RandomEventFilter::operator= ( RandomEventFilter const &  )
delete
RandomEventFilter& skim::RandomEventFilter::operator= ( RandomEventFilter &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void skim::RandomEventFilter::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 137 of file RandomEventFilter_module.cc.

References DEFINE_ART_MODULE(), fPOTLabel, fThreshold, fhicl::ParameterSet::get(), and sanity_check_grl::keep.

Referenced by RandomEventFilter().

138 {
139 
140  auto keep = p.get<float>("FractionToKeep", 1.);
141 
142  fThreshold = 1. - keep;
143 
144  fPOTLabel = p.get<std::string>("POTLabel", "cellskimmer");
145 
146  return;
147 }
const char * p
Definition: xmltok.h:285
float fThreshold
threshold for random number to be filtered
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string fPOTLabel
label for POTs in subrun object
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

constexpr bool art::EDFilter::Fail {false}
staticinherited

Definition at line 33 of file EDFilter.h.

Referenced by evgen::GENIEFilter::filter().

std::string skim::RandomEventFilter::fPOTLabel
private

label for POTs in subrun object

Definition at line 53 of file RandomEventFilter_module.cc.

Referenced by beginSubRun(), and reconfigure().

sumdata::POTSum skim::RandomEventFilter::fPOTSum
private

POT summary for the subrun.

Definition at line 52 of file RandomEventFilter_module.cc.

Referenced by beginSubRun(), endRun(), and RandomEventFilter().

TRandom3 skim::RandomEventFilter::fRandom
private

random number generator to decide if we should keep an event

Definition at line 51 of file RandomEventFilter_module.cc.

Referenced by filter(), and RandomEventFilter().

float skim::RandomEventFilter::fThreshold
private

threshold for random number to be filtered

Definition at line 50 of file RandomEventFilter_module.cc.

Referenced by endRun(), filter(), and reconfigure().

constexpr bool art::EDFilter::Pass {true}
staticinherited

Definition at line 32 of file EDFilter.h.

Referenced by evgen::GENIEFilter::filter().


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