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

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

Inheritance diagram for evgen::GENIEGen:
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

 GENIEGen (fhicl::ParameterSet const &pset)
 
virtual ~GENIEGen ()
 
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...
 
int fPassEmptySpills
 whether or not to allow for events with no interactions to be put into the event More...
 
TStopwatch fStopwatch
 keep track of how long it takes to run the job More...
 
int fSpillCounter
 how many spills so far? More...
 
double fPOTPerSpill
 how many POT to simulate per spill More...
 
double fEventsPerSpill
 how many events to simulate per spill More...
 
double fTotalExposure
 total exposure in POT More...
 
double fTotalPOTLimit
 total POT limit More...
 
int fCycle
 cycle number in the MC generation More...
 

Detailed Description

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

Definition at line 51 of file GENIEGen_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::GENIEGen::GENIEGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 80 of file GENIEGen_module.cc.

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

81  : fGENIEHelp (0)
82  , fPassEmptySpills (pset.get< bool >("PassEmptySpills"))
83  , fSpillCounter (0)
84  , fPOTPerSpill (pset.get< double >("POTPerSpill", 5.0e13))
85  , fEventsPerSpill (pset.get< double >("EventsPerSpill", 0))
86  , fTotalExposure (0)
87  , fTotalPOTLimit (pset.get< double >("TotalPOTLimit"))
88  , fCycle (pset.get< int >("Cycle", 0))
89  {
90  fStopwatch.Start();
91 
92  produces< std::vector<simb::MCTruth> >();
93  produces< std::vector<simb::MCFlux> >();
94  produces< std::vector<simb::GTruth> >();
95  produces< sumdata::SpillData >();
96  produces< sumdata::POTSum, art::InSubRun >();
97  produces< sumdata::SubRunData, art::InSubRun >();
98  produces< sumdata::RunData, art::InRun >();
99  // Associate every truth with the flux it came from
100  produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
101  produces< art::Assns<simb::MCTruth, simb::GTruth> >();
102  // Dk2Nu additions
103  produces< std::vector<bsim::Dk2Nu> >();
104  produces< std::vector<bsim::NuChoice> >();
105 #ifdef PUT_DK2NU_ASSN
106  produces< art::Assns<simb::MCTruth, bsim::Dk2Nu> >();
107  produces< art::Assns<simb::MCTruth, bsim::NuChoice> >();
108 #endif
109 
111  fGENIEHelp = new evgb::GENIEHelper(pset,
112  geo->ROOTGeoManager(),
113  geo->ROOTFile(),
114  geo->TotalMass(pset.get< std::string>("TopVolume").c_str()));
115  }
double fEventsPerSpill
how many events to simulate per spill
int fSpillCounter
how many spills so far?
double fTotalExposure
total exposure in POT
int fPassEmptySpills
whether or not to allow for events with no interactions to be put into the event
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
int fCycle
cycle number in the MC generation
double fPOTPerSpill
how many POT to simulate per spill
double fTotalPOTLimit
total POT limit
TStopwatch fStopwatch
keep track of how long it takes to run the job
Helper for AttenCurve.
Definition: Path.h:10
enum BeamMode string
evgen::GENIEGen::~GENIEGen ( )
virtual

Definition at line 118 of file GENIEGen_module.cc.

References fGENIEHelp, and fStopwatch.

119  {
120  fStopwatch.Stop();
121  mf::LogInfo("GENIEGen") << "real time to produce file: "
122  << fStopwatch.RealTime();
123  delete fGENIEHelp; // clean up, and let dtor do its thing
124  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
TStopwatch fStopwatch
keep track of how long it takes to run the job

Member Function Documentation

void evgen::GENIEGen::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 127 of file GENIEGen_module.cc.

128  {
129  }
void evgen::GENIEGen::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 132 of file GENIEGen_module.cc.

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

133  {
134  // grab the geometry object to see what geometry we are using
136 
137  std::unique_ptr<sumdata::RunData>
138  runcol(new sumdata::RunData(geo->DetId(),
139  geo->FileBaseName(),
140  geo->ExtractGDML()));
141 
142  run.put(std::move(runcol));
143 
144  // initialize the GENIEHelper here rather than in beginJob to
145  // avoid problems with the Geometry reloading at a run boundary.
146  // If we ever make more than one run in a single job we will have
147  // to re-evaluate
148  fGENIEHelp->Initialize();
149  fTotalExposure = 0.0;
150 
151  return;
152  }
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:149
double fTotalExposure
total exposure in POT
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
std::string ExtractGDML() const
Extract contents from fGDMLFile and return as a string.
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::GENIEGen::endSubRun ( art::SubRun sr)
virtual

Reimplemented from art::EDProducer.

Definition at line 155 of file GENIEGen_module.cc.

References om::cout, fCycle, fSpillCounter, fTotalExposure, art::SubRun::put(), and sd().

156  {
157  std::unique_ptr< sumdata::POTSum > p(new sumdata::POTSum);
158 
159  // p->totpot = fGENIEHelp->TotalExposure();
160  // p->totgoodpot = fGENIEHelp->TotalExposure();
161  p->totpot = fTotalExposure;
162  p->totgoodpot = fTotalExposure;
163  p->totspills = fSpillCounter;
164  p->goodspills = fSpillCounter;
165  p->Print(std::cout);
166 
167  sr.put(std::move(p));
168 
169  // store the cycle information
171  std::unique_ptr< sumdata::SubRunData > sd(new sumdata::SubRunData(fCycle));
172  sr.put(std::move(sd));
173  }
int fSpillCounter
how many spills so far?
const char * p
Definition: xmltok.h:285
double sd(Eigen::VectorXd x)
double fTotalExposure
total exposure in POT
OStream cout
Definition: OStream.cxx:6
int fCycle
cycle number in the MC generation
ProductID put(std::unique_ptr< PROD > &&)
Helper for AttenCurve.
Definition: Path.h:10
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::GENIEGen::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 176 of file GENIEGen_module.cc.

References bsim::DkMeta::beam0x, bsim::DkMeta::beam0y, bsim::DkMeta::beamhwidth, bsim::DkMeta::beamvwidth, om::cout, util::CreateAssn(), DEFINE_ART_MODULE(), dkmeta, allTimeWatchdog::endl, fEventsPerSpill, fGENIEHelp, flux, fPassEmptySpills, fPOTPerSpill, fSpillCounter, fTotalExposure, fTotalPOTLimit, genie::flux::GDk2NuFlux::GetDk2Nu(), genie::flux::GDk2NuFlux::GetDkMeta(), genie::flux::GDk2NuFlux::GetNuChoice(), bsim::DkMeta::horncfg, LOG_DEBUG, art::Event::put(), submit_cafana::regex, sd(), art::DataViewImpl::size(), and string.

177  {
178  // A temporary value is needed to store the spill exposure that GENIEHelper uses. GENIEGen
179  // needs to remember the number after GENIEHelper has reset it to zero for the purposes of
180  // updating fTotalExposure.
181  double SpillExpTemp = 0.0;
182 
183  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
184  std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (new std::vector<simb::MCFlux >);
185  std::unique_ptr< std::vector<simb::GTruth> > gtruthcol (new std::vector<simb::GTruth >);
186  std::unique_ptr< art::Assns<simb::MCTruth, simb::GTruth> > tgtassn(new art::Assns<simb::MCTruth, simb::GTruth>);
187  std::unique_ptr< art::Assns<simb::MCTruth, simb::MCFlux> > assns(new art::Assns<simb::MCTruth, simb::MCFlux>);
188 
189  std::unique_ptr< std::vector<bsim::Dk2Nu> >
190  dk2nucol(new std::vector<bsim::Dk2Nu>);
191  std::unique_ptr< std::vector<bsim::NuChoice> >
192  nuchoicecol(new std::vector<bsim::NuChoice>);
193 
194  std::unique_ptr< art::Assns<simb::MCTruth, bsim::Dk2Nu> >
196  std::unique_ptr< art::Assns<simb::MCTruth, bsim::NuChoice> >
198 
199  bool passedPOTLimit = false;
200 
201  // keep throwing spills until we get one with something in it
202  while ( truthcol->size() < 1 ) {
203 
204  // POT limit. Maybe we passed the limit in a previous event, so now we
205  // have to keep skipping until the end of the file. Or maybe we're in the
206  // process of breaking out of the inner loop, and need to break again.
207  if(fTotalPOTLimit > 0 &&
208  fTotalExposure + fGENIEHelp->SpillExposure() >= fTotalPOTLimit){
209  passedPOTLimit = true;
210  break;
211  }
212 
213  while ( ! fGENIEHelp->Stop() ) {
214 
215  simb::MCTruth truth;
217  simb::GTruth gTruth;
218 
219  // GENIEHelper returns a false in the sample method if
220  // either no neutrino was generated, or the interaction
221  // occurred beyond the detector's z extent - ie something we
222  // would never see anyway.
223  if ( fGENIEHelp->Sample(truth, flux, gTruth ) ) {
224 
225  // POT limit
226  if(fTotalPOTLimit > 0 &&
227  fTotalExposure + fGENIEHelp->SpillExposure() > fTotalPOTLimit){
228  // Top the total exposure up to the right value
229  SpillExpTemp = fTotalPOTLimit - fTotalExposure;
230  break;
231  }
232 
233  // When running in "POT per Spill" mode, this will prevent the last neutrino (that was produced after
234  // the POT limit had been passed) from being put into the event.
235  //
236  // This is only a temporary fix to correct the problem of GENIEHelper always making one more neutrino
237  // than it should.
238  if((fGENIEHelp->SpillExposure() <= fPOTPerSpill && fEventsPerSpill == 0) || fEventsPerSpill > 0) {
239  truthcol ->push_back(truth);
240  gtruthcol->push_back(gTruth);
241  fluxcol ->push_back(flux);
242 
243  util::CreateAssn(*this, evt, *truthcol, *fluxcol, *assns,
244  fluxcol->size()-1, fluxcol->size());
245 
246  util::CreateAssn(*this, evt, *truthcol, *gtruthcol, *tgtassn,
247  gtruthcol->size()-1, gtruthcol->size());
248 
249  genie::GFluxI* fdriver = fGENIEHelp->GetFluxDriver(true);
250  genie::flux::GDk2NuFlux* dk2nuDriver =
251  dynamic_cast<genie::flux::GDk2NuFlux*>(fdriver);
252  if ( dk2nuDriver ) {
253  const bsim::Dk2Nu& dk2nuObj = dk2nuDriver->GetDk2Nu();
254  dk2nucol ->push_back(dk2nuObj);
255  const bsim::NuChoice& nuchoiceObj = dk2nuDriver->GetNuChoice();
256  nuchoicecol->push_back(nuchoiceObj);
257 
258 #ifdef PUT_DK2NU_ASSN
259  evgb::util::CreateAssn(*this, evt, *truthcol, *dk2nucol, *dk2nuassn,
260  dk2nucol->size()-1, dk2nucol->size());
261  evgb::util::CreateAssn(*this, evt, *truthcol, *nuchoicecol, *nuchoiceassn,
262  nuchoicecol->size()-1, nuchoicecol->size());
263 #endif
264  }
265 
266  // update exposure
267  SpillExpTemp = fGENIEHelp->SpillExposure();
268  }
269 
270  } // end if genie was able to make an event
271 
272  } // end event generation loop
273 
274  // check to see if we are to pass empty spills
275  if ( truthcol->size() < 1 && fPassEmptySpills ) {
276  LOG_DEBUG("GENIEGen")
277  << "no events made for this spill "
278  << " continue on until we get a spill with events";
279  break;
280  }
281 
282  } // end loop while no interactions are made
283 
284  // put the collections in the event
285  evt.put(std::move(truthcol));
286  evt.put(std::move(fluxcol));
287  evt.put(std::move(gtruthcol));
288  evt.put(std::move(assns));
289  evt.put(std::move(tgtassn));
290 
291  // in the constructor we said these were produced ...
292  // ... so we have to put them in the record, even if just empty
293  evt.put(std::move(dk2nucol));
294  evt.put(std::move(nuchoicecol));
295 #ifdef PUT_DK2NU_ASSN
296  evt.put(std::move(dk2nuassn));
297  evt.put(std::move(nuchoiceassn));
298 #endif
299 
300  ++fSpillCounter;
301 
302  // If fEventsPerSpill > 0, then we should update by what we actually used.
303  // Otherwise, we are in "POT per Spill" mode so we should update by the cutoff
304  // value, fPOTPerSpill.
305 
306  double ThisSpillPoT = fPOTPerSpill;
307  if(fEventsPerSpill > 0 || passedPOTLimit) ThisSpillPoT=SpillExpTemp;
308  fTotalExposure += ThisSpillPoT;
309 
310  std::unique_ptr<sumdata::SpillData> sd(new sumdata::SpillData);
311  sd->spillpot = ThisSpillPoT;
312  sd->goodbeam = 1;
313 
314  // Fill in some typical values to hopefully keep good beam cuts happy
315  // without having to special-case for MC.
316  sd->deltaspilltimensec = 0;
317  sd->hornI = -199.5;
318  sd->posx = 0.9;
319  sd->posy = 1.3;
320  sd->widthx = 1.2;
321  sd->widthy = 1.2;
322 
323  genie::GFluxI* fdriver = fGENIEHelp->GetFluxDriver(true);
324  genie::flux::GDk2NuFlux* dk2nuDriver = dynamic_cast<genie::flux::GDk2NuFlux*>(fdriver);
325  // if we're using dk2nu flux, set SpillData from the flux metadata
326  if ( dk2nuDriver ) {
327  // get metadata for last generated dk2nu ray
328  // all rays used for a single simulation run have the same horn current and beam position
329  const bsim::DkMeta &dkmeta = dk2nuDriver->GetDkMeta();
330  //strip out alphabetic characters and convert to a float
331  //only works if the format is something like 200i or -200i
332  std::string stripped_horncfg = std::regex_replace(dkmeta.horncfg, std::regex(R"([A-Za-z])"), "");
333 
334  sd->hornI = std::stof(stripped_horncfg);
335 
336  std::cout<<"sd->hornI: "<<sd->hornI<<std::endl;
337 
338  if (sd->hornI < 0){
339  sd->isRHC = true;
340  }else if (sd->hornI == 0){
341  sd->is0HC = true;
342  }else {
343  sd->isRHC = false;
344  sd->is0HC = false;
345  }
346 
347  std::cout<<"sd->isRHC : "<<sd->isRHC<<std::endl;
348  std::cout<<"sd->is0HC : "<<sd->is0HC<<std::endl;
349 
350  sd->posx = dkmeta.beam0x;
351  sd->posy = dkmeta.beam0y;
352  sd->widthx = dkmeta.beamhwidth*10; //convert to mm
353  sd->widthy = dkmeta.beamvwidth*10;
354  }
355 
356  //based on data
357 /*
358  sd->bposx[0]=-0.8;
359  sd->bposx[1]=-0.2;
360  sd->bposx[2]=-0.04;
361  sd->bposx[3]=0.05;
362  sd->bposx[4]=-0.008;
363  sd->bposx[5]=-0.007;
364 
365  for(int i=0;i<6;i++){
366  sd->bposy[i]=0.5;
367  //assuming no slip-stacking
368  sd->intx[i]=ThisSpillPoT/6;
369  sd->inty[i]=ThisSpillPoT/6;
370  }
371  */
372  evt.put(std::move(sd));
373  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
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.
double fEventsPerSpill
how many events to simulate per spill
int fSpillCounter
how many spills so far?
Double_t beamvwidth
vertical width of beam
Definition: dkmeta.h:110
Double_t beamhwidth
horizontal width of beam
Definition: dkmeta.h:109
const bsim::NuChoice & GetNuChoice(void)
Definition: GDk2NuFlux.h:103
Loaders::FluxType flux
Double_t beam0y
y of beam center at start
Definition: dkmeta.h:107
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
double sd(Eigen::VectorXd x)
double fTotalExposure
total exposure in POT
int fPassEmptySpills
whether or not to allow for events with no interactions to be put into the event
evgb::GENIEHelper * fGENIEHelp
GENIEHelper object.
OStream cout
Definition: OStream.cxx:6
std::string horncfg
horn config e.g. "FHC/185A/LE/h1xoff=1mm"
Definition: dkmeta.h:99
const bsim::DkMeta & GetDkMeta(void)
Definition: GDk2NuFlux.h:105
bsim::DkMeta * dkmeta
Double_t beam0x
x of beam center at start
Definition: dkmeta.h:106
double fPOTPerSpill
how many POT to simulate per spill
double fTotalPOTLimit
total POT limit
An implementation of the GENIE GFluxI interface ("flux driver") encapsulating reading/processing the ...
Definition: GDk2NuFlux.h:69
Event generator information.
Definition: MCTruth.h:32
const bsim::Dk2Nu & GetDk2Nu(void)
Definition: GDk2NuFlux.h:104
size_t size() const
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:37
enum BeamMode string
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

int evgen::GENIEGen::fCycle
private

cycle number in the MC generation

Definition at line 73 of file GENIEGen_module.cc.

Referenced by endSubRun().

double evgen::GENIEGen::fEventsPerSpill
private

how many events to simulate per spill

Definition at line 70 of file GENIEGen_module.cc.

Referenced by produce().

evgb::GENIEHelper* evgen::GENIEGen::fGENIEHelp
private

GENIEHelper object.

Definition at line 65 of file GENIEGen_module.cc.

Referenced by beginRun(), GENIEGen(), produce(), and ~GENIEGen().

int evgen::GENIEGen::fPassEmptySpills
private

whether or not to allow for events with no interactions to be put into the event

Definition at line 66 of file GENIEGen_module.cc.

Referenced by produce().

double evgen::GENIEGen::fPOTPerSpill
private

how many POT to simulate per spill

Definition at line 69 of file GENIEGen_module.cc.

Referenced by produce().

int evgen::GENIEGen::fSpillCounter
private

how many spills so far?

Definition at line 68 of file GENIEGen_module.cc.

Referenced by endSubRun(), and produce().

TStopwatch evgen::GENIEGen::fStopwatch
private

keep track of how long it takes to run the job

Definition at line 67 of file GENIEGen_module.cc.

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

double evgen::GENIEGen::fTotalExposure
private

total exposure in POT

Definition at line 71 of file GENIEGen_module.cc.

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

double evgen::GENIEGen::fTotalPOTLimit
private

total POT limit

Definition at line 72 of file GENIEGen_module.cc.

Referenced by produce().


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