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

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

Inheritance diagram for evgen::GENIERockGen:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 GENIERockGen (fhicl::ParameterSet const &pset)
 
virtual ~GENIERockGen ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void beginRun (art::Run &run)
 
void endSubRun (art::SubRun &sr)
 
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 ()
 

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

evgb::GENIEHelper * fGENIEHelp
 GENIEHelper object. More...
 
TStopwatch fStopwatch
 
int fSpillCounter
 keep track of how long it takes to run the job More...
 

Detailed Description

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

Definition at line 46 of file GENIERockGen_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

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

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

evgen::GENIERockGen::GENIERockGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 67 of file GENIERockGen_module.cc.

References fGENIEHelp, fStopwatch, fhicl::ParameterSet::get(), and string.

68  : fSpillCounter(0)
69  {
70  fStopwatch.Start();
71 
72  produces< std::vector<simb::MCTruth> >();
73  produces< std::vector<simb::MCFlux> >();
74  produces< std::vector<simb::GTruth> >();
75  produces< sumdata::POTSum, art::InSubRun >();
76  produces< sumdata::RunData, art::InRun >();
77  // Associate every truth with the flux it came from
78  produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
79  produces< art::Assns<simb::MCTruth, simb::GTruth> >();
80 
82  fGENIEHelp = new evgb::GENIEHelper(pset,
83  geo->ROOTGeoManager(),
84  geo->ROOTFile(),
85  geo->TotalMass(pset.get< std::string>("TopVolume").c_str()));
86  }
int fSpillCounter
keep track of how long it takes to run the job
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
Helper for AttenCurve.
Definition: Path.h:10
enum BeamMode string
evgen::GENIERockGen::~GENIERockGen ( )
virtual

Definition at line 89 of file GENIERockGen_module.cc.

References fStopwatch.

90  {
91  fStopwatch.Stop();
92  mf::LogInfo("GENIERockGen") << "Real time to produce file: " << fStopwatch.RealTime();
93  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo

Member Function Documentation

void evgen::GENIERockGen::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 96 of file GENIERockGen_module.cc.

97  {
98  }
void evgen::GENIERockGen::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 101 of file GENIERockGen_module.cc.

References geo::GeometryBase::DetId(), fGENIEHelp, geo::GeometryBase::FileBaseName(), and art::Run::put().

102  {
103 
104  // grab the geometry object to see what geometry we are using
106 
107  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetId(),
108  geo->FileBaseName()));
109 
110  run.put(std::move(runcol));
111 
112  // initialize the GENIEHelper here rather than in beginJob to avoid problems with
113  // the Geometry reloading at a run boundary. If we ever make more than one run
114  // in a single job we will have to re-evaluate
115  fGENIEHelp->Initialize();
116 
117  return;
118  }
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:149
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
Helper for AttenCurve.
Definition: Path.h:10
std::string FileBaseName() const
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::EDProducer::currentContext ( ) const
protectedinherited
void evgen::GENIERockGen::endSubRun ( art::SubRun sr)
virtual

Reimplemented from art::EDProducer.

Definition at line 122 of file GENIERockGen_module.cc.

References om::cout, fGENIEHelp, fSpillCounter, and art::SubRun::put().

123  {
124 
125  std::unique_ptr< sumdata::POTSum > p(new sumdata::POTSum);
126 
127  p->totpot = fGENIEHelp->TotalExposure();
128  p->totgoodpot = fGENIEHelp->TotalExposure();
129  p->totspills = fSpillCounter;
130  p->goodspills = fSpillCounter;
131  p->Print(std::cout);
132 
133  sr.put(std::move(p));
134 
135 
136  }
int fSpillCounter
keep track of how long it takes to run the job
const char * p
Definition: xmltok.h:285
OStream cout
Definition: OStream.cxx:6
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
ProductID put(std::unique_ptr< PROD > &&)
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::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
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(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void evgen::GENIERockGen::produce ( art::Event evt)
virtual

check if we are going to make events for this spill - could be that we are using flux histograms and the poisson number for how many interactions to make is 0

GENIEHelper returns a false in the sample method if either no neutrino was generated, or the interaction occurred beyond the detector's z extent - ie something we would never see anyway.

end if genie was able to make an event

end event generation loop

Implements art::EDProducer.

Definition at line 139 of file GENIERockGen_module.cc.

References util::CreateAssn(), DEFINE_ART_MODULE(), geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), geo::GeometryBase::DetLength(), stan::math::fabs(), fGENIEHelp, flux, simb::MCTruth::GetNeutrino(), simb::MCNeutrino::Nu(), art::Event::put(), art::DataViewImpl::size(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

140  {
141 
142  ///check if we are going to make events for this spill - could be
143  ///that we are using flux histograms and the poisson number for
144  ///how many interactions to make is 0
145  if(fGENIEHelp->Stop()){
146  throw cet::exception("NoNuInteraction")
147  << "no neutrino interaction made for this spill\n"
148  << __FILE__ << ":" << __LINE__ << "\n";
149  return;
150  }
151 
152  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
153  std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (new std::vector<simb::MCFlux >);
154  std::unique_ptr< std::vector<simb::GTruth> > gtruthcol (new std::vector<simb::GTruth >);
155  std::unique_ptr< art::Assns<simb::MCTruth, simb::GTruth> > tgtassn(new art::Assns<simb::MCTruth, simb::GTruth>);
156  std::unique_ptr< art::Assns<simb::MCTruth, simb::MCFlux> > assns(new art::Assns<simb::MCTruth, simb::MCFlux>);
157 
159 
160  while(!fGENIEHelp->Stop()){
161 
162  simb::MCTruth truth;
164  simb::GTruth gTruth;
165 
166  ///GENIEHelper returns a false in the sample method if
167  ///either no neutrino was generated, or the interaction
168  ///occurred beyond the detector's z extent - ie something we
169  ///would never see anyway.
170  if(fGENIEHelp->Sample(truth, flux, gTruth)){
171 
172 
173  const simb::MCParticle nu = truth.GetNeutrino().Nu();
174 
175  if(fabs(nu.Vx())>geo->DetHalfWidth()
176  || fabs(nu.Vy())>geo->DetHalfHeight()
177  || nu.Vz()> geo->DetLength()
178  || nu.Vz()<0 ){
179 
180 
181  truthcol->push_back(truth);
182  gtruthcol->push_back(gTruth);
183  fluxcol->push_back(flux);
184 
185  util::CreateAssn(*this, evt, *truthcol, *fluxcol, *assns,
186  fluxcol->size()-1, fluxcol->size());
187 
188  util::CreateAssn(*this, evt, *truthcol, *gtruthcol, *tgtassn,
189  gtruthcol->size()-1, gtruthcol->size());
190  }
191 
192  }///end if genie was able to make an event
193 
194 
195  }///end event generation loop
196 
197  // put the collections in the event
198  evt.put(std::move(truthcol));
199  evt.put(std::move(fluxcol));
200  evt.put(std::move(gtruthcol));
201  evt.put(std::move(assns));
202  evt.put(std::move(tgtassn));
203 
204  return;
205  }
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:76
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
double DetLength() const
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Loaders::FluxType flux
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
double DetHalfHeight() const
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
double Vx(const int i=0) const
Definition: MCParticle.h:220
double DetHalfWidth() const
double Vz(const int i=0) const
Definition: MCParticle.h:222
Event generator information.
Definition: MCTruth.h:32
Helper for AttenCurve.
Definition: Path.h:10
size_t size() const
double Vy(const int i=0) const
Definition: MCParticle.h:221
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

evgb::GENIEHelper* evgen::GENIERockGen::fGENIEHelp
private

GENIEHelper object.

Definition at line 58 of file GENIERockGen_module.cc.

Referenced by beginRun(), endSubRun(), GENIERockGen(), and produce().

int evgen::GENIERockGen::fSpillCounter
private

keep track of how long it takes to run the job

Definition at line 60 of file GENIERockGen_module.cc.

Referenced by endSubRun().

TStopwatch evgen::GENIERockGen::fStopwatch
private

Definition at line 59 of file GENIERockGen_module.cc.

Referenced by GENIERockGen(), and ~GENIERockGen().


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