Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
mcchk::POTAna Class Reference

A module to check the results from the Monte Carlo generator. More...

Inheritance diagram for mcchk::POTAna:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 POTAna (fhicl::ParameterSet const &pset)
 
virtual ~POTAna ()
 
void analyze (art::Event const &evt)
 
void beginJob ()
 
void beginSubRun (art::SubRun const &sr)
 
void endJob ()
 
void endSubRun (art::SubRun const &sr)
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) 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 ()
 

Protected Member Functions

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

Private Attributes

std::string fPotLabel
 Module that produced the POTSum object. More...
 
bool fIsPOTSumObjectForSubRun = false
 Flag whether the SubRun has a POTSum object. More...
 
int fNeventsInSubrun
 Number of events in the subrun. More...
 
int fNevents
 Total number of events. More...
 
std::vector< double > fPOTSpillSubrun
 POT per spill per subrun. More...
 
std::vector< double > fPOTSubrun
 POT per subrun. More...
 
std::vector< double > fNeventsPOTSubrun
 Events per POT per subrun. More...
 
std::vector< double > fNeventsSubrun
 Total number of events per subrun. More...
 
sumdata::POTSumfPOTSum
 

Detailed Description

A module to check the results from the Monte Carlo generator.

Definition at line 30 of file POTAna_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

mcchk::POTAna::POTAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 62 of file POTAna_module.cc.

63  : EDAnalyzer(pset),
64  fPotLabel(pset.get<std::string>("PotLabel")),
67  fNevents(0)
68  {
69  }
std::string fPotLabel
Module that produced the POTSum object.
int fNeventsInSubrun
Number of events in the subrun.
bool fIsPOTSumObjectForSubRun
Flag whether the SubRun has a POTSum object.
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
int fNevents
Total number of events.
enum BeamMode string
mcchk::POTAna::~POTAna ( )
virtual

Definition at line 72 of file POTAna_module.cc.

73  {
74  }

Member Function Documentation

void mcchk::POTAna::analyze ( art::Event const &  evt)
virtual

Implements art::EDAnalyzer.

Definition at line 83 of file POTAna_module.cc.

References fNevents, and fNeventsInSubrun.

84  {
86  ++fNevents;
87  }
int fNeventsInSubrun
Number of events in the subrun.
int fNevents
Total number of events.
void mcchk::POTAna::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 77 of file POTAna_module.cc.

References fPOTSum.

78  {
79  fPOTSum = new sumdata::POTSum();
80  }
sumdata::POTSum * fPOTSum
void mcchk::POTAna::beginSubRun ( art::SubRun const &  sr)
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 90 of file POTAna_module.cc.

References allTimeWatchdog::endl, fIsPOTSumObjectForSubRun, fNeventsInSubrun, fPotLabel, fPOTSum, art::DataViewImpl::getByLabel(), sumdata::POTSum::goodspills, sumdata::POTSum::totgoodpot, sumdata::POTSum::totpot, and sumdata::POTSum::totspills.

91  {
92  // Reset variables for the next subrun
93  fNeventsInSubrun = 0;
95 
97 
98  // Try to get the POTSum information from the SubRun
99  try {
100  sr.getByLabel(fPotLabel, p);
101 
102  // If successful, set this flag to true
104 
105  // Pull some information about the SubRun, store it locally
106  fPOTSum->totpot = p->totpot;
110 
111  mf::LogInfo("POTAna") << "fPOTSum This sub run has " << fPOTSum->totspills
112  << " total spills with an exposure of " << fPOTSum->totpot << " POT " << std::endl
113  << "with cuts on beam quality, there are " << fPOTSum->goodspills
114  << " good spills with an exposure of " << fPOTSum->totgoodpot << std::endl;
115  }
116  catch(...) {
117  mf::LogWarning("POTAna POTSum") << "Error trying to access POTSum information." << std::endl;
118  fIsPOTSumObjectForSubRun = false; // If there was a problem, make absolutely sure this flag is false!
119  }
120  }
std::string fPotLabel
Module that produced the POTSum object.
int fNeventsInSubrun
Number of events in the subrun.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool fIsPOTSumObjectForSubRun
Flag whether the SubRun has a POTSum object.
const char * p
Definition: xmltok.h:285
caf::StandardRecord * sr
int goodspills
Definition: POTSum.h:31
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
sumdata::POTSum * fPOTSum
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
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
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::EDAnalyzer::currentContext ( ) const
protectedinherited
void mcchk::POTAna::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 141 of file POTAna_module.cc.

References DEFINE_ART_MODULE(), fNevents, fNeventsPOTSubrun, fNeventsSubrun, fPOTSpillSubrun, fPOTSubrun, MECModelEnuComparisons::i, and art::TFileDirectory::make().

142  {
144 
145  // Helpful for spacing/readability
146  // Also helpful in case histograms are made in loops
147  char HistoName[200];
148  char HistoTitle[200];
149 
150  TH1F* hPOTSpillSubrun;
151  TH1F* hPOTSubrun;
152  TH1F* hNEventsPOTSubrun;
153  TH1F* hNEventsSubrun;
154  TH1F* hNEvents;
155 
156  unsigned int size_POTSpillSubrun = fPOTSpillSubrun.size();
157  unsigned int size_POTSubrun = fPOTSubrun.size();
158  unsigned int size_NEventsPOTSubrun = fNeventsPOTSubrun.size();
159  unsigned int size_NEventsSubrun = fNeventsSubrun.size();
160 
161  sprintf(HistoName, "POTSpillSubrun");
162  sprintf(HistoTitle, "POT per Spill per SubRun;Subrun number;POT per Spill");
163  hPOTSpillSubrun = tfs->make<TH1F>(HistoName, HistoTitle,
164  size_POTSpillSubrun + 1, -0.5, size_POTSpillSubrun + 0.5);
165 
166  sprintf(HistoName, "POTSubrun");
167  sprintf(HistoTitle, "POT per SubRun;Subrun number;POT");
168  hPOTSubrun = tfs->make<TH1F>(HistoName, HistoTitle,
169  size_POTSubrun + 1, -0.5, size_POTSubrun + 0.5);
170 
171  sprintf(HistoName, "NEventsPOTSubrun");
172  sprintf(HistoTitle, "Events per POT per Subrun;Subrun number;Events per POT");
173  hNEventsPOTSubrun = tfs->make<TH1F>(HistoName, HistoTitle,
174  size_NEventsPOTSubrun + 1, -0.5, size_NEventsPOTSubrun + 0.5);
175 
176  sprintf(HistoName, "NEventsSubrun");
177  sprintf(HistoTitle, "Events per Subrun;Subrun number;Events");
178  hNEventsSubrun = tfs->make<TH1F>(HistoName, HistoTitle,
179  size_NEventsSubrun + 1, -0.5, size_NEventsSubrun + 0.5);
180 
181  sprintf(HistoName, "NEvents");
182  sprintf(HistoTitle, "Total Number of Events;;Events");
183  hNEvents = tfs->make<TH1F>(HistoName, HistoTitle, 1, -0.5, 0.5);
184  hNEvents->SetBinContent(1, fNevents);
185 
186  for(unsigned int i = 0; i < size_POTSpillSubrun; ++i) {
187  hPOTSpillSubrun->Fill(i, fPOTSpillSubrun[i]);
188  }
189  for(unsigned int i = 0; i < size_POTSubrun; ++i) {
190  hPOTSubrun->Fill(i, fPOTSubrun[i]);
191  }
192  for(unsigned int i = 0; i < size_NEventsPOTSubrun; ++i) {
193  hNEventsPOTSubrun->Fill(i, fNeventsPOTSubrun[i]);
194  }
195  for(unsigned int i = 0; i < size_NEventsSubrun; ++i) {
196  hNEventsSubrun->Fill(i, fNeventsSubrun[i]);
197  }
198  }
std::vector< double > fNeventsPOTSubrun
Events per POT per subrun.
std::vector< double > fPOTSpillSubrun
POT per spill per subrun.
std::vector< double > fPOTSubrun
POT per subrun.
std::vector< double > fNeventsSubrun
Total number of events per subrun.
int fNevents
Total number of events.
T * make(ARGS...args) const
void mcchk::POTAna::endSubRun ( art::SubRun const &  sr)
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 123 of file POTAna_module.cc.

References allTimeWatchdog::endl, fIsPOTSumObjectForSubRun, fNeventsInSubrun, fNeventsPOTSubrun, fNeventsSubrun, fPOTSpillSubrun, fPOTSubrun, fPOTSum, art::SubRun::subRun(), sumdata::POTSum::totpot, and sumdata::POTSum::totspills.

124  {
125  mf::LogInfo("POTAna") << "Event Number " << fNeventsInSubrun << std::endl;
126 
128  mf::LogInfo("POTAna") << "Subrun Number " << sr.subRun() << std::endl;
129  mf::LogInfo("POTAna") << "Event per POT " << fNeventsInSubrun/fPOTSum->totpot << std::endl;
130 
132  fPOTSubrun .push_back(fPOTSum->totpot);
134  }
135 
136  // This plot does not depend on the existence of a POTSum object
137  fNeventsSubrun.push_back(fNeventsInSubrun);
138  }
std::vector< double > fNeventsPOTSubrun
Events per POT per subrun.
std::vector< double > fPOTSpillSubrun
POT per spill per subrun.
int fNeventsInSubrun
Number of events in the subrun.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool fIsPOTSumObjectForSubRun
Flag whether the SubRun has a POTSum object.
std::vector< double > fPOTSubrun
POT per subrun.
std::vector< double > fNeventsSubrun
Total number of events per subrun.
caf::StandardRecord * sr
sumdata::POTSum * fPOTSum
int totspills
Definition: POTSum.h:30
double totpot
normalized by 10^12 POT
Definition: POTSum.h:27
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:35
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::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited

Definition at line 46 of file EventObserverBase.h.

References art::EventObserverBase::wantAllEvents_.

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

47  {
48  return wantAllEvents_;
49  }
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited

Definition at line 51 of file EventObserverBase.h.

References art::EventObserverBase::selectors_, and art::detail::CachedProducts::wantEvent().

52  {
53  return selectors_.wantEvent(e);
54  }
detail::CachedProducts selectors_
Float_t e
Definition: plot.C:35
bool wantEvent(Event const &)
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

bool mcchk::POTAna::fIsPOTSumObjectForSubRun = false
private

Flag whether the SubRun has a POTSum object.

Definition at line 45 of file POTAna_module.cc.

Referenced by beginSubRun(), and endSubRun().

int mcchk::POTAna::fNevents
private

Total number of events.

Definition at line 48 of file POTAna_module.cc.

Referenced by analyze(), and endJob().

int mcchk::POTAna::fNeventsInSubrun
private

Number of events in the subrun.

Definition at line 47 of file POTAna_module.cc.

Referenced by analyze(), beginSubRun(), and endSubRun().

std::vector<double> mcchk::POTAna::fNeventsPOTSubrun
private

Events per POT per subrun.

Definition at line 52 of file POTAna_module.cc.

Referenced by endJob(), and endSubRun().

std::vector<double> mcchk::POTAna::fNeventsSubrun
private

Total number of events per subrun.

Definition at line 53 of file POTAna_module.cc.

Referenced by endJob(), and endSubRun().

std::string mcchk::POTAna::fPotLabel
private

Module that produced the POTSum object.

Definition at line 43 of file POTAna_module.cc.

Referenced by beginSubRun().

std::vector<double> mcchk::POTAna::fPOTSpillSubrun
private

POT per spill per subrun.

Definition at line 50 of file POTAna_module.cc.

Referenced by endJob(), and endSubRun().

std::vector<double> mcchk::POTAna::fPOTSubrun
private

POT per subrun.

Definition at line 51 of file POTAna_module.cc.

Referenced by endJob(), and endSubRun().

sumdata::POTSum* mcchk::POTAna::fPOTSum
private

Definition at line 55 of file POTAna_module.cc.

Referenced by beginJob(), beginSubRun(), and endSubRun().


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