Public Member Functions | Private Attributes | List of all members
evgen::TestGENIEHelper Class Reference

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

Inheritance diagram for evgen::TestGENIEHelper:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 TestGENIEHelper (fhicl::ParameterSet const &pset)
 
virtual ~TestGENIEHelper ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void beginRun (art::Run &run)
 
void endSubRun (art::SubRun &sr)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob ()
 
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 &mc)
 
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)
 

Private Attributes

evgb::GENIEHelperfGENIEHelp
 GENIEHelper object. More...
 
TStopwatch fStopwatch
 
int fEventsPerSpill
 negative for Poisson() More...
 
unsigned int fDebugFlags
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- 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 ()
 

Detailed Description

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

Definition at line 63 of file TestGENIEHelper_module.cc.

Constructor & Destructor Documentation

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

Definition at line 88 of file TestGENIEHelper_module.cc.

89  : EDProducer{pset}
90  , fGENIEHelp (0)
91  //, fPassEmptySpills (pset.get< bool >("PassEmptySpills"))
92  //, fSpillCounter (0)
93  //, fPOTPerSpill (pset.get< double >("POTPerSpill", 5.0e13))
94  , fEventsPerSpill (pset.get< double >("EventsPerSpill", 1))
95  //, fTotalExposure (0)
96  //, fTotalPOTLimit (pset.get< double >("TotalPOTLimit"))
97  , fDebugFlags (pset.get< unsigned int >("DebugFlags", 0))
98  {
99  fStopwatch.Start();
100 
101  produces< std::vector<simb::MCTruth> >();
102  produces< std::vector<simb::MCFlux> >();
103  produces< std::vector<simb::GTruth> >();
104  //produces< sumdata::SpillData >();
105  //produces< sumdata::POTSum, art::InSubRun >();
106  //produces< sumdata::RunData, art::InRun >();
107  // Associate every truth with the flux it came from
108  produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
109  produces< art::Assns<simb::MCTruth, simb::GTruth> >();
110 
111  //--- Dk2Nu additions
112  //--- BEGIN
113  produces< std::vector<bsim::Dk2Nu> >();
114  produces< std::vector<bsim::NuChoice> >();
115 #ifdef PUT_DK2NU_ASSN
116  produces< art::Assns<simb::MCTruth, bsim::Dk2Nu> >();
117  produces< art::Assns<simb::MCTruth, bsim::NuChoice> >();
118 #endif
119  //--- END
120 
121  //art::ServiceHandle<geo::Geometry> geo;
122  std::string geomFileName =
123  pset.get<std::string>("GeomFileName");
124  mf::LogInfo("TestGENIEHelper") << "using GeomFileName '"
125  << geomFileName << "'";
126  TGeoManager::Import(geomFileName.c_str());
127  double detectorMass = 1; // no generally used (except for histogram)
128 
129  fGENIEHelp = new evgb::GENIEHelper(pset,
130  gGeoManager,
131  geomFileName,
132  detectorMass);
133  /*
134  geo->ROOTGeoManager(),
135  geo->ROOTFile(),
136  geo->TotalMass(pset.get< std::string>("TopVolume").c_str()));
137  */
138  }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
#define Import
int fEventsPerSpill
negative for Poisson()
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
evgen::TestGENIEHelper::~TestGENIEHelper ( )
virtual

Definition at line 141 of file TestGENIEHelper_module.cc.

142  {
143  fStopwatch.Stop();
144  mf::LogInfo("TestGENIEHelper") << "real time to produce file: "
145  << fStopwatch.RealTime();
146  delete fGENIEHelp; // clean up, and let dtor do its thing
147  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.

Member Function Documentation

void evgen::TestGENIEHelper::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 150 of file TestGENIEHelper_module.cc.

151  {
152  }
void evgen::TestGENIEHelper::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 155 of file TestGENIEHelper_module.cc.

156  {
157  // grab the geometry object to see what geometry we are using
158  // art::ServiceHandle<geo::Geometry> geo;
159 
160  /*
161  std::unique_ptr<sumdata::RunData>
162  runcol(new sumdata::RunData(geo->DetId(),
163  geo->FileBaseName(),
164  geo->ExtractGDML()));
165 
166  run.put(std::move(runcol));
167  */
168 
169  std::cerr << " *** TestGENIEHelper::beginRun() begin "
170  << std::endl << std::flush;
171 
172 
173  // initialize the GENIEHelper here rather than in beginJob to
174  // avoid problems with the Geometry reloading at a run boundary.
175  // If we ever make more than one run in a single job we will have
176  // to re-evaluate
178  //fTotalExposure = 0.0;
179 
180  std::cerr << " *** TestGENIEHelper::beginRun() done "
181  << std::endl << std::flush;
182 
183  return;
184  }
QTextStream & flush(QTextStream &s)
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
QTextStream & endl(QTextStream &s)
void evgen::TestGENIEHelper::endSubRun ( art::SubRun sr)
virtual

Reimplemented from art::EDProducer.

Definition at line 187 of file TestGENIEHelper_module.cc.

188  {
189  /*
190  std::unique_ptr< sumdata::POTSum > p(new sumdata::POTSum);
191 
192  // p->totpot = fGENIEHelp->TotalExposure();
193  // p->totgoodpot = fGENIEHelp->TotalExposure();
194  p->totpot = fTotalExposure;
195  p->totgoodpot = fTotalExposure;
196  p->totspills = fSpillCounter;
197  p->goodspills = fSpillCounter;
198  p->Print(std::cout);
199 
200  sr.put(std::move(p));
201  */
202 
203  mf::LogInfo("TestGENIEHelper") << "Total Exposure was "
205 
206  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
double TotalExposure() const
Definition: GENIEHelper.h:74
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
void evgen::TestGENIEHelper::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 209 of file TestGENIEHelper_module.cc.

210  {
211  // A temporary value is needed to store the spill exposure that GENIEHelper uses. TestGENIEHelper
212  // needs to remember the number after GENIEHelper has reset it to zero for the purposes of
213  // updating fTotalExposure.
214  //double SpillExpTemp = 0.0;
215 
216  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
217  std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (new std::vector<simb::MCFlux >);
218  std::unique_ptr< std::vector<simb::GTruth> > gtruthcol (new std::vector<simb::GTruth >);
219  std::unique_ptr< art::Assns<simb::MCTruth, simb::GTruth> > tgtassn(new art::Assns<simb::MCTruth, simb::GTruth>);
220  std::unique_ptr< art::Assns<simb::MCTruth, simb::MCFlux> > assns(new art::Assns<simb::MCTruth, simb::MCFlux>);
221 
222  std::cerr << " ******************************* TestGENIEHelper::produce() " << std::endl << std::flush;
223  std::cout << " stopwatch at produce() ";
224  fStopwatch.Print("um"); fStopwatch.Continue();
225  std::cout << std::flush;
226 
227  //--- Dk2Nu additions
228  //--- BEGIN
229  std::unique_ptr< std::vector<bsim::Dk2Nu> >
230  dk2nucol(new std::vector<bsim::Dk2Nu>);
231  std::unique_ptr< std::vector<bsim::NuChoice> >
232  nuchoicecol(new std::vector<bsim::NuChoice>);
233 
234  std::unique_ptr< art::Assns<simb::MCTruth, bsim::Dk2Nu> >
236  std::unique_ptr< art::Assns<simb::MCTruth, bsim::NuChoice> >
238  //--- END
239 
240  while ( ! fGENIEHelp->Stop() ) {
241 
242  simb::MCTruth truth;
243  simb::MCFlux flux;
244  simb::GTruth gTruth;
245 
246  std::cerr << " *** TestGENIEHelper::produce() about to sample "
247  << truthcol->size()
248  << std::endl << std::flush;
249  std::cout << " stopwatch before Sample() ";
250  fStopwatch.Print("um"); fStopwatch.Continue();
251  std::cout << std::flush;
252 
253 
254  // GENIEHelper returns a false in the sample method if
255  // either no neutrino was generated, or the interaction
256  // occurred beyond the detector's z extent - ie something we
257  // would never see anyway.
258  if ( fGENIEHelp->Sample(truth, flux, gTruth ) ) {
259 
260  std::cout << " stopwatch after Sample() ";
261  fStopwatch.Print("um"); fStopwatch.Continue();
262  std::cout << std::flush;
263 
264  truthcol ->push_back(truth);
265  gtruthcol->push_back(gTruth);
266  fluxcol ->push_back(flux);
267 
268  evgb::util::CreateAssn(*this, evt, *truthcol, *fluxcol, *assns,
269  fluxcol->size()-1, fluxcol->size());
270 
271  evgb::util::CreateAssn(*this, evt, *truthcol, *gtruthcol, *tgtassn,
272  gtruthcol->size()-1, gtruthcol->size());
273 
274  //--- Dk2Nu additions
275  //--- BEGIN
276  genie::GFluxI* fdriver = fGENIEHelp->GetFluxDriver(true);
277  genie::flux::GDk2NuFlux* dk2nuDriver =
278  dynamic_cast<genie::flux::GDk2NuFlux*>(fdriver);
279  if ( dk2nuDriver ) {
280  const bsim::Dk2Nu& dk2nuObj = dk2nuDriver->GetDk2Nu();
281  dk2nucol ->push_back(dk2nuObj);
282  const bsim::NuChoice& nuchoiceObj = dk2nuDriver->GetNuChoice();
283  nuchoicecol->push_back(nuchoiceObj);
284 
285  if ( (fDebugFlags & 0x10 ) != 0 ) {
286  std::cout << "---------==== creation dump" << std::endl;
288  if ( gevtrec ) std::cout << *gevtrec << std::endl;
289  std::cout << dk2nuObj << std::endl;
290  const bsim::Decay& decay = dk2nuObj.decay;
291  std::cout << " necm " << decay.necm
292  << " muparp4 " << decay.muparpx << " "
293  << decay.muparpy << " " << decay.muparpz << " "
294  << decay.mupare << std::endl;
295  std::cout << nuchoiceObj << std::endl;
296  }
297 
298 #ifdef PUT_DK2NU_ASSN
299  evgb::util::CreateAssn(*this, evt, *truthcol, *dk2nucol, *dk2nuassn,
300  dk2nucol->size()-1, dk2nucol->size());
301  evgb::util::CreateAssn(*this, evt, *truthcol, *nuchoicecol, *nuchoiceassn,
302  nuchoicecol->size()-1, nuchoicecol->size());
303 #endif
304  }
305  //--- END
306 
307  std::cerr << " *** TestGENIEHelper::produce() sample success size "
308  << truthcol->size()
309  << std::endl << std::flush;
310  //RWH//if ( dk2nuDriver ) { std::cout << dk2nuDriver->GetDk2Nu() << std::endl; }
311  std::cout << " stopwatch after push_back + CreateAssn ";
312  fStopwatch.Print("um"); fStopwatch.Continue();
313  std::cout << std::flush;
314 
315 
316  } // end if genie was able to make an event
317 
318  } // end event generation loop
319 
320  // put the collections in the event
321  evt.put(std::move(truthcol));
322  evt.put(std::move(fluxcol));
323  evt.put(std::move(gtruthcol));
324  evt.put(std::move(assns));
325  evt.put(std::move(tgtassn));
326 
327  std::cerr << " *** TestGENIEHelper::produce() done "
328  << " event " << evt.event()
329  << std::endl << std::flush;
330 
331  //--- Dk2Nu additions
332  //--- BEGIN
333  // in the constructor we said these were produced ...
334  // ... so we have to put them in the record, even if just empty
335  evt.put(std::move(dk2nucol));
336  evt.put(std::move(nuchoicecol));
337 
338 #ifdef PUT_DK2NU_ASSN
339  std::cerr << " *** TestGENIEHelper::produce()"
340  << " put dk2nuAssn + nuchoiceAssn ** "
341  << " event " << evt.event()
342  << std::endl << std::flush;
343 
344  evt.put(std::move(dk2nuassn));
345  evt.put(std::move(nuchoiceassn));
346 
347  std::cerr << " *** TestGENIEHelper::produce() finished put "
348  << " event " << evt.event()
349  << std::endl << std::flush;
350 
351 #endif
352  //--- END
353 
354  } // end of produce method
genie::GFluxI * GetFluxDriver(bool base=true)
Definition: GENIEHelper.h:94
EventNumber_t event() const
Definition: DataViewImpl.cc:96
genie::EventRecord * GetGenieEventRecord()
Definition: GENIEHelper.h:87
bool Sample(simb::MCTruth &truth, simb::MCFlux &flux, simb::GTruth &gtruth)
void Decay(const Decayer *decayer, int pdgc, double E, int ndecays)
Definition: gtestDecay.cxx:179
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
def move(depos, offset)
Definition: depos.py:107
QTextStream & flush(QTextStream &s)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:38
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
Event generator information.
Definition: MCTruth.h:32
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
QTextStream & endl(QTextStream &s)
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:37

Member Data Documentation

unsigned int evgen::TestGENIEHelper::fDebugFlags
private

Definition at line 80 of file TestGENIEHelper_module.cc.

int evgen::TestGENIEHelper::fEventsPerSpill
private

negative for Poisson()

Definition at line 79 of file TestGENIEHelper_module.cc.

evgb::GENIEHelper* evgen::TestGENIEHelper::fGENIEHelp
private

GENIEHelper object.

Definition at line 77 of file TestGENIEHelper_module.cc.

TStopwatch evgen::TestGENIEHelper::fStopwatch
private

Definition at line 78 of file TestGENIEHelper_module.cc.


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