Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
supernova::SnovaGen Class Reference
Inheritance diagram for supernova::SnovaGen:
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

 SnovaGen (const fhicl::ParameterSet &p)
 
 ~SnovaGen ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void beginRun (art::Run &run)
 
double RecordTime ()
 
double EventStart ()
 
double EventEnd ()
 
bool FluxEnd ()
 
void EventTimeNext ()
 
simb::MCTruth MakeMCTruth (const genie::EventRecord &record)
 
void PrepareEvent (art::Event &evt)
 
void SaveEvent (art::Event &evt)
 
void GenerateNextRecord ()
 
void SaveRecordToEvent ()
 
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
 

Protected Attributes

std::string MsgLevelFile
 
std::string MsgLevelFileName
 
std::string ModelFile
 
std::string ModelFileName
 
std::string MaxPathLenFile
 
std::string MaxPathLenFileName
 
std::string XsecFile
 
std::string XsecFileName
 
std::string TopVolume
 
std::string EventGenList
 
double DistanceKpc
 
double Emin
 
TVector3 WindowPos
 
double WindowSize
 
double WindowX
 
double WindowY
 
double WindowZ
 
double fTime
 
double fEventDuration
 
genie::GMCJDriver fMCJobDriver
 
std::unique_ptr< genie::geometry::ROOTGeomAnalyzerfGeomDriver = nullptr
 
std::unique_ptr< genie::supernova::GFluxSNovafFluxDriver = nullptr
 
std::unique_ptr< std::vector< simb::MCTruth > > fTruth = nullptr
 
TGeoManager * fGeoManager = nullptr
 
TGeoVolume * fTopVolume = nullptr
 
size_t fRecordsCounter = 0
 
std::shared_ptr< genie::EventRecordfRecord = nullptr
 

Detailed Description

Definition at line 43 of file SnovaGen_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

supernova::SnovaGen::SnovaGen ( const fhicl::ParameterSet p)
explicit

Definition at line 107 of file SnovaGen_module.cc.

References genie::units::centimeter, genie::GMCJDriver::Configure(), om::cout, DistanceKpc, Emin, allTimeWatchdog::endl, EventGenList, fFluxDriver, fGeoManager, fGeomDriver, cet::search_path::find_file(), fMCJobDriver, fTopVolume, genie::GMCJDriver::GlobProbScale(), genie::units::gram_centimeter3, MaxPathLenFile, MaxPathLenFileName, genie::utils::app_init::MesgThresholds(), ModelFile, ModelFileName, MsgLevelFile, MsgLevelFileName, geo::GeometryBase::ROOTGeoManager(), genie::GMCJDriver::SetEventGeneratorList(), TopVolume, genie::GMCJDriver::UseFluxDriver(), genie::GMCJDriver::UseGeomAnalyzer(), genie::GMCJDriver::UseMaxPathLengths(), WindowPos, WindowSize, WindowX, WindowY, WindowZ, XsecFile, XsecFileName, and genie::utils::app_init::XSecTable().

107  :
108  MsgLevelFileName(p.get<std::string> ("MsgLevelFile")),
109  ModelFileName(p.get<std::string> ("ModelFile")),
110  MaxPathLenFileName(p.get<std::string> ("MaxPathLenFile")),
111  XsecFileName(p.get<std::string> ("XsecFile")),
112  TopVolume(p.get<std::string> ("TopVolumeName")),
113  EventGenList(p.get<std::string> ("EventGenList")),
114  DistanceKpc(p.get<double> ("DistanceKpc")),
115  Emin(p.get<double> ("Emin")),
116  WindowSize(p.get<double> ("Window.Size")),
117  WindowX(p.get<double> ("Window.X")),
118  WindowY(p.get<double> ("Window.Y")),
119  WindowZ(p.get<double> ("Window.Z")),
120  fTime(p.get<double> ("TimeStart")),
121  fEventDuration(p.get<double> ("EventDuration"))
122  {
123  cet::search_path sp0("GXMLPATH");
124  sp0.find_file(MsgLevelFileName, MsgLevelFile);
125 
126  cet::search_path sp("GSNOVA_DATA");
127  sp.find_file(ModelFileName, ModelFile);
128  sp.find_file(MaxPathLenFileName, MaxPathLenFile);
129  sp.find_file(XsecFileName, XsecFile);
130 
131  std::cout << "Using files: "
132  << "\n ModelFile: \"" << ModelFile << "\""
133  << "\n MaxPathLenFile: \"" << MaxPathLenFile << "\""
134  << "\n XsecFile: \"" << XsecFile << "\""
135  << "\n MsgLevelFile: \"" << MsgLevelFile << "\""
136  << std::endl;
137 
138  WindowPos.SetX(WindowX);
139  WindowPos.SetY(WindowY);
140  WindowPos.SetZ(WindowZ);
141 
142  // Set messages level
144 
145  // setup geometry driver
147  fGeoManager = geo->ROOTGeoManager();
148  fTopVolume = fGeoManager->FindVolumeFast(TopVolume.c_str());
149  //fGeoManager->SetTopVolume(fTopVolume);
150 
152  fGeomDriver->SetTopVolName(TopVolume);
153  fGeomDriver->SetLengthUnits(genie::units::centimeter);
155  fGeomDriver->SetMixtureWeightsSum(1.);
156 
157  // Make model
158  auto snova_model = genie::supernova::GSNovaModel(ModelFile);
160 
161  snova_model.SetEmin(Emin);
162 
163  // Get flux driver
164  fFluxDriver.reset(new genie::supernova::GFluxSNova(snova_model, flux_window));
165 
166  // Read Xsec table
168 
169  // Create the GENIE monte carlo job driver
175 
176  // Charge the supernova!
178 
179  produces<std::vector<simb::MCTruth>> ();
180  produces<sumdata::RunData, art::InRun> ();
181  }
void XSecTable(string inpfile, bool require_table)
Definition: AppInit.cxx:39
genie::GMCJDriver fMCJobDriver
std::string ModelFileName
std::string MsgLevelFile
void SetEventGeneratorList(string listname)
Definition: GMCJDriver.cxx:157
TGeoVolume * fTopVolume
TGeoManager * ROOTGeoManager() const
std::string MaxPathLenFile
std::string EventGenList
std::string MsgLevelFileName
std::unique_ptr< genie::supernova::GFluxSNova > fFluxDriver
void UseFluxDriver(GFluxI *flux)
Definition: GMCJDriver.cxx:174
double GlobProbScale(void) const
Definition: GMCJDriver.h:72
std::unique_ptr< genie::geometry::ROOTGeomAnalyzer > fGeomDriver
std::string XsecFileName
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool UseMaxPathLengths(string xml_filename)
Definition: GMCJDriver.cxx:190
static const double gram_centimeter3
Definition: Units.h:151
std::string MaxPathLenFileName
void Configure(bool calc_prob_scales=true)
Definition: GMCJDriver.cxx:446
A ROOT/GEANT4 geometry driver.
TGeoManager * fGeoManager
OStream cout
Definition: OStream.cxx:6
static const double centimeter
Definition: Units.h:52
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:100
Helper for AttenCurve.
Definition: Path.h:10
void UseGeomAnalyzer(GeomAnalyzerI *geom)
Definition: GMCJDriver.cxx:179
A squre window, where neutrinos appear towards the origin (0,0,0)
Definition: GFluxWindow.h:12
enum BeamMode string
supernova::SnovaGen::~SnovaGen ( )

Definition at line 185 of file SnovaGen_module.cc.

186  {
187  }

Member Function Documentation

void supernova::SnovaGen::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 191 of file SnovaGen_module.cc.

References om::cout, and allTimeWatchdog::endl.

192  {
193  std::cout << "Begin job!" << std::endl;
194  }
OStream cout
Definition: OStream.cxx:6
void supernova::SnovaGen::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 198 of file SnovaGen_module.cc.

References om::cout, geo::GeometryBase::DetId(), allTimeWatchdog::endl, geo::GeometryBase::ExtractGDML(), geo::GeometryBase::FileBaseName(), and art::Run::put().

199  {
200  std::cout << "--- SupernovaGen::begin run\n";
201 
203  std::cout << "\tDetector ID: " << geo->DetId() << std::endl;
204 
205  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetId(),
206  geo->FileBaseName(),
207  geo->ExtractGDML()));
208  run.put(std::move(runcol));
209  return;
210  }
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
OStream cout
Definition: OStream.cxx:6
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
double supernova::SnovaGen::EventEnd ( )
inline

Definition at line 55 of file SnovaGen_module.cc.

References fEventDuration, and fTime.

Referenced by EventTimeNext(), PrepareEvent(), and produce().

double supernova::SnovaGen::EventStart ( )
inline

Definition at line 54 of file SnovaGen_module.cc.

References fTime.

Referenced by MakeMCTruth(), PrepareEvent(), and produce().

54 { return fTime; }
void supernova::SnovaGen::EventTimeNext ( )
inline
bool supernova::SnovaGen::FluxEnd ( )
inline

Definition at line 56 of file SnovaGen_module.cc.

References fFluxDriver.

Referenced by GenerateNextRecord(), and produce().

56 { return fFluxDriver->End(); }
std::unique_ptr< genie::supernova::GFluxSNova > fFluxDriver
void supernova::SnovaGen::GenerateNextRecord ( )

Definition at line 213 of file SnovaGen_module.cc.

References FluxEnd(), fMCJobDriver, fRecord, fRecordsCounter, and genie::GMCJDriver::GenerateEvent().

Referenced by EventTimeNext(), and produce().

214  {
215  if(FluxEnd())return;
216  fRecord=std::unique_ptr<genie::EventRecord>(fMCJobDriver.GenerateEvent());
217  ++fRecordsCounter;
218  }
std::shared_ptr< genie::EventRecord > fRecord
genie::GMCJDriver fMCJobDriver
EventRecord * GenerateEvent(void)
Definition: GMCJDriver.cxx:838
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  }
simb::MCTruth supernova::SnovaGen::MakeMCTruth ( const genie::EventRecord record)

This function was copied from GENIEHelper with minor modifications

Definition at line 246 of file SnovaGen_module.cc.

References simb::MCTruth::Add(), om::cout, genie::GHepParticle::E(), allTimeWatchdog::endl, EventStart(), genie::GHepRecord::FinalStatePrimaryLepton(), genie::GHepParticle::FirstMother(), genie::GHepParticle::GetPolarization(), genie::GHepRecord::HitNucleon(), genie::Target::HitNucPdg(), genie::Target::HitQrkPdg(), genie::Interaction::InitState(), genie::ProcessInfo::IsAMNuGamma(), genie::ProcessInfo::IsCoherent(), genie::ProcessInfo::IsCoherentElas(), genie::ProcessInfo::IsDeepInelastic(), genie::ProcessInfo::IsDiffractive(), genie::ProcessInfo::IsElectronScattering(), genie::ProcessInfo::IsEM(), genie::ProcessInfo::IsGlashowResonance(), genie::ProcessInfo::IsIMDAnnihilation(), genie::ProcessInfo::IsInverseBetaDecay(), genie::ProcessInfo::IsInverseMuDecay(), genie::ProcessInfo::IsMEC(), genie::ProcessInfo::IsNuElectronElastic(), genie::ProcessInfo::IsQuasiElastic(), genie::ProcessInfo::IsResonant(), genie::ProcessInfo::IsWeakMix(), genie::ProcessInfo::IsWeakNC(), simb::kAMNuGamma, simb::kCC, simb::kCoh, simb::kCohElastic, simb::kDiffractive, simb::kDIS, simb::kElectronScattering, simb::kEM, simb::kGlashowResonance, simb::kIMDAnnihilation, simb::kInverseBetaDecay, simb::kInverseMuDecay, simb::kMEC, simb::kNC, simb::kNuanceOffset, genie::constants::kNucleonMass, simb::kNuElectronElastic, simb::kQE, simb::kRes, genie::kRfLab, simb::kSuperNovaNeutrino, simb::kUnknownInteraction, simb::kWeakMix, genie::GHepParticle::Mass(), submit_nova_art::mode, genie::utils::ghep::NuanceReactionCode(), part, genie::GHepParticle::Pdg(), genie::Target::Pdg(), genie::GHepParticle::PolzIsSet(), elec2geo::pos, genie::GHepRecord::Probe(), genie::InitialState::ProbeE(), genie::Interaction::ProcInfo(), genie::GHepParticle::Px(), genie::GHepParticle::Py(), genie::GHepParticle::Pz(), genie::utils::kinematics::Q2(), genie::GHepParticle::RescatterCode(), simb::MCTruth::SetNeutrino(), simb::MCTruth::SetOrigin(), std::sqrt(), genie::GHepParticle::Status(), string, genie::GHepRecord::Summary(), genie::InitialState::Tgt(), registry_explorer::v, genie::GHepRecord::Vertex(), genie::GHepParticle::Vt(), genie::GHepParticle::Vx(), genie::GHepParticle::Vy(), genie::GHepParticle::Vz(), W, submit_syst::x, and submit_syst::y.

Referenced by EventTimeNext(), and SaveRecordToEvent().

247  {
248  ///This function was copied from GENIEHelper with minor modifications
249  simb::MCTruth truth;
250  TLorentzVector *vertex = record.Vertex();
251 
252  std::cout << "vtx=";
253  vertex->Print();
254  std::cout << std::endl;
255 
256  // Get the Interaction object from the record - this is the object
257  // that talks to the event information objects and is in m
258  genie::Interaction *inter = record.Summary();
259 
260  // Get the different components making up the interaction
261  const genie::InitialState &initState = inter->InitState();
262  const genie::ProcessInfo &procInfo = inter->ProcInfo();
263 
264  std::cout << "Neutrino E=" << initState.ProbeE(genie::kRfLab) << std::endl;
265 
266  // Add the particles from the interaction
267  TIter partitr(&record);
269 
270  // GHepParticles return units of GeV/c for p. The V_i are all in fermis
271  // and are relative to the center of the struck nucleus.
272  // Add the vertex X/Y/Z to the V_i for status codes 0 and 1
273  int trackid = 0;
274  std::string primary("primary");
275  while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){
276 
277  simb::MCParticle tpart(trackid,
278  part->Pdg(),
279  primary,
280  part->FirstMother(),
281  part->Mass(),
282  part->Status());
283 
284  double vtx[4] = {part->Vx(), part->Vy(), part->Vz(), part->Vt()};
285  tpart.SetGvtx(vtx);
286  tpart.SetRescatter(part->RescatterCode());
287 
288  // Set the vertex location for the neutrino, nucleus and everything
289  // that is to be tracked. Vertex returns values in meters.
290  if(part->Status() == 0 || part->Status() == 1){
291  vtx[0] = 100*(part->Vx() * 1.e-15 + vertex->X());
292  vtx[1] = 100*(part->Vy() * 1.e-15 + vertex->Y());
293  vtx[2] = 100*(part->Vz() * 1.e-15 + vertex->Z());
294  //convert time to nanoseconds since event start
295  vtx[3] = part->Vt()+(vertex->T()-EventStart())*1e9;
296  }
297 
298  TLorentzVector pos(vtx[0], vtx[1], vtx[2], vtx[3]);
299  TLorentzVector mom(part->Px(), part->Py(), part->Pz(), part->E());
300 
301  tpart.AddTrajectoryPoint(pos, mom);
302 
303  if(part->PolzIsSet()) {
304  TVector3 polz;
305  part->GetPolarization(polz);
306  tpart.SetPolarization(polz);
307  }
308 
309  truth.Add(tpart);
310 
311  ++trackid;
312  } // End loop to convert GHepParticles to MCParticles
313 
314  // Get interaction category, mode, and type
315  int CCNC = procInfo.IsWeakNC() ? simb::kNC : simb::kCC;
317  int itype = simb::kUnknownInteraction;
318 
319  if (procInfo.IsNuElectronElastic() ) itype = simb::kNuElectronElastic;
320  else if (procInfo.IsInverseMuDecay() ) itype = simb::kInverseMuDecay;
321  else if (procInfo.IsQuasiElastic() ) itype = simb::kQE;
322  else if (procInfo.IsResonant() ) itype = simb::kRes;
323  else if (procInfo.IsDeepInelastic() ) itype = simb::kDIS;
324  else if (procInfo.IsCoherent() ) itype = simb::kCoh;
325  else if (procInfo.IsCoherentElas() ) itype = simb::kCohElastic;
326  else if (procInfo.IsElectronScattering() ) itype = simb::kElectronScattering;
327  else if (procInfo.IsIMDAnnihilation() ) itype = simb::kIMDAnnihilation;
328  else if (procInfo.IsInverseBetaDecay() ) itype = simb::kInverseBetaDecay;
329  else if (procInfo.IsGlashowResonance() ) itype = simb::kGlashowResonance;
330  else if (procInfo.IsAMNuGamma() ) itype = simb::kAMNuGamma;
331  else if (procInfo.IsMEC() ) itype = simb::kMEC;
332  else if (procInfo.IsDiffractive() ) itype = simb::kDiffractive;
333  else if (procInfo.IsEM() ) itype = simb::kEM;
334  else if (procInfo.IsWeakMix() ) itype = simb::kWeakMix;
335 
336  else itype = simb::kNuanceOffset + mode;
337 
338  // Set the neutrino information in MCTruth
340 
341  // The GENIE event kinematics are subtle different from the event
342  // kinematics that a experimentalist would calculate
343  // Instead of retriving the GENIE values for these kinematic variables
344  // calcuate them from the the final state particles
345  // while ingnoring the fermi momentum and the off-shellness of the bound nucleon.
346  genie::GHepParticle * hitnucl = record.HitNucleon();
347  TLorentzVector pdummy(0, 0, 0, 0);
348 
349  const TLorentzVector & k1 = *((record.Probe())->P4());
350  const TLorentzVector & k2 = *((record.FinalStatePrimaryLepton())->P4());
351  //const TLorentzVector & p1 = (hitnucl) ? *(hitnucl->P4()) : pdummy;
352 
354  TLorentzVector q = k1 - k2; // q = k1-k2, 4-p transfer
355 
356  double Q2 = -1 * q.M2(); // momemtum transfer
357  double v = (hitnucl) ? q.Energy() : -1; // v (E transfer to the nucleus)
358  double x = (hitnucl) ? 0.5 * Q2 / (M * v) : -1; // Bjorken x
359  double y = (hitnucl) ? v / k1.Energy() : -1; // Inelasticity, y = q * P1 / k1 * P1
360  double W2 = (hitnucl) ? M * M + 2 * M * v - Q2 : -1; // Hadronic invariant mass ^ 2
361  double W = (hitnucl) ? std::sqrt(W2) : -1; // Hardronic invariant mass
362 
363  truth.SetNeutrino(CCNC,
364  mode,
365  itype,
366  initState.Tgt().Pdg(),
367  initState.Tgt().HitNucPdg(),
368  initState.Tgt().HitQrkPdg(),
369  W,
370  x,
371  y,
372  Q2);
373 
374  return truth;
375  }
bool IsResonant(void) const
Definition: ProcessInfo.cxx:92
int RescatterCode(void) const
Definition: GHepParticle.h:66
bool IsWeakMix(void) const
Definition: event.h:34
double E(void) const
Get energy.
Definition: GHepParticle.h:92
static const double kNucleonMass
Definition: Constants.h:78
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:991
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:80
neutrino electron elastic scatter
Definition: MCNeutrino.h:140
virtual Interaction * Summary(void) const
Definition: GHepRecord.cxx:135
int HitNucPdg(void) const
Definition: Target.cxx:321
int HitQrkPdg(void) const
Definition: Target.cxx:259
bool IsInverseMuDecay(void) const
bool IsQuasiElastic(void) const
Definition: ProcessInfo.cxx:67
int NuanceReactionCode(const GHepRecord *evrec)
Definition: GHepUtils.cxx:281
T sqrt(T number)
Definition: d0nt_math.hpp:156
bool IsElectronScattering(void) const
int Pdg(void) const
Definition: Target.h:72
bool IsInverseBetaDecay(void) const
offset to account for adding in Nuance codes to this enum
Definition: MCNeutrino.h:95
bool IsDiffractive(void) const
double Mass(void) const
Mass that corresponds to the PDG code.
bool IsIMDAnnihilation(void) const
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
Definition: MCTruth.cxx:30
void Add(simb::MCParticle &part)
Definition: MCTruth.h:79
double Pz(void) const
Get Pz.
Definition: GHepParticle.h:91
GHepStatus_t Status(void) const
Definition: GHepParticle.h:65
virtual TLorentzVector * Vertex(void) const
Definition: GHepRecord.h:141
double Px(void) const
Get Px.
Definition: GHepParticle.h:89
virtual GHepParticle * Probe(void) const
Definition: GHepRecord.cxx:321
double Vt(void) const
Get production time.
Definition: GHepParticle.h:98
int Pdg(void) const
Definition: GHepParticle.h:64
int FirstMother(void) const
Definition: GHepParticle.h:67
Summary information for an interaction.
Definition: Interaction.h:56
TString part[npart]
Definition: Style.C:32
bool IsWeakNC(void) const
bool IsNuElectronElastic(void) const
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition: ProcessInfo.h:44
bool IsAMNuGamma(void) const
virtual GHepParticle * FinalStatePrimaryLepton(void) const
Definition: GHepRecord.cxx:370
bool PolzIsSet(void) const
OStream cout
Definition: OStream.cxx:6
bool IsMEC(void) const
bool IsEM(void) const
void GetPolarization(TVector3 &polz)
bool IsDeepInelastic(void) const
Definition: ProcessInfo.cxx:82
n.b.: this group is similar but not quite, entirely unlike GENIE ScatteringType convention ...
Definition: MCNeutrino.h:80
double Vz(void) const
Get production z.
Definition: GHepParticle.h:97
inverse muon decay
Definition: MCNeutrino.h:141
virtual GHepParticle * HitNucleon(void) const
Definition: GHepRecord.cxx:350
Supernova neutrinos.
Definition: MCTruth.h:25
const InitialState & InitState(void) const
Definition: Interaction.h:69
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:70
double Vy(void) const
Get production y.
Definition: GHepParticle.h:96
const Target & Tgt(void) const
Definition: InitialState.h:67
Event generator information.
Definition: MCTruth.h:32
bool IsCoherentElas(void) const
bool IsGlashowResonance(void) const
#define W(x)
double ProbeE(RefFrame_t rf) const
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:40
double Vx(void) const
Get production x.
Definition: GHepParticle.h:95
Initial State information.
Definition: InitialState.h:49
bool IsCoherent(void) const
Definition: ProcessInfo.cxx:97
double Py(void) const
Get Py.
Definition: GHepParticle.h:90
enum BeamMode string
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 supernova::SnovaGen::PrepareEvent ( art::Event evt)

Definition at line 227 of file SnovaGen_module.cc.

References om::cout, allTimeWatchdog::endl, EventEnd(), EventStart(), fGeoManager, fTopVolume, and fTruth.

Referenced by EventTimeNext(), and produce().

228  {
229  fGeoManager->SetTopVolume(fTopVolume);
230  std::cout<<"Event Time=["<<EventStart()<<" - "<<EventEnd()<<"]"<<std::endl;
231  std::cout<<"~ starting gen ~"<<std::endl;
232  fTruth=std::make_unique<std::vector<simb::MCTruth>>();
233  }
TGeoVolume * fTopVolume
TGeoManager * fGeoManager
OStream cout
Definition: OStream.cxx:6
std::unique_ptr< std::vector< simb::MCTruth > > fTruth
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void supernova::SnovaGen::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 379 of file SnovaGen_module.cc.

References om::cout, DEFINE_ART_MODULE(), allTimeWatchdog::endl, EventEnd(), EventStart(), FluxEnd(), fRecord, fRecordsCounter, GenerateNextRecord(), PrepareEvent(), RecordTime(), SaveEvent(), and SaveRecordToEvent().

380  {
381  PrepareEvent(evt);
382  if(fRecord==nullptr)GenerateNextRecord();
383 
384  while(!FluxEnd() && RecordTime() < EventEnd()){
387  if(!FluxEnd())
388  std::cout<<"\rgenerated event #" << fRecordsCounter << " at time " << RecordTime() << std::endl;
389  }
390  SaveEvent(evt);
391  }
std::shared_ptr< genie::EventRecord > fRecord
void PrepareEvent(art::Event &evt)
void SaveEvent(art::Event &evt)
OStream cout
Definition: OStream.cxx:6
double supernova::SnovaGen::RecordTime ( )
inline

Definition at line 53 of file SnovaGen_module.cc.

References fRecord.

Referenced by produce().

53 { return fRecord->Vertex()->T(); }
std::shared_ptr< genie::EventRecord > fRecord
void supernova::SnovaGen::SaveEvent ( art::Event evt)

Definition at line 236 of file SnovaGen_module.cc.

References om::cout, allTimeWatchdog::endl, EventTimeNext(), fGeoManager, fTruth, art::Event::id(), and art::Event::put().

Referenced by EventTimeNext(), and produce().

237  {
238  std::cout<<"Event #"<<evt.id()<<" has "<<fTruth->size()<<" interactions"<<std::endl;
239  evt.put(std::move(fTruth));
240  fGeoManager->SetTopVolume(fGeoManager->GetMasterVolume());
241  EventTimeNext();
242  }
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
TGeoManager * fGeoManager
OStream cout
Definition: OStream.cxx:6
std::unique_ptr< std::vector< simb::MCTruth > > fTruth
EventID id() const
Definition: Event.h:56
void supernova::SnovaGen::SaveRecordToEvent ( )

Definition at line 221 of file SnovaGen_module.cc.

References fRecord, fTruth, and MakeMCTruth().

Referenced by EventTimeNext(), and produce().

222  {
223  fTruth->push_back(MakeMCTruth(*fRecord));
224  }
std::shared_ptr< genie::EventRecord > fRecord
std::unique_ptr< std::vector< simb::MCTruth > > fTruth
simb::MCTruth MakeMCTruth(const genie::EventRecord &record)
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

double supernova::SnovaGen::DistanceKpc
protected

Definition at line 76 of file SnovaGen_module.cc.

Referenced by SnovaGen().

double supernova::SnovaGen::Emin
protected

Definition at line 77 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::EventGenList
protected

Definition at line 74 of file SnovaGen_module.cc.

Referenced by SnovaGen().

double supernova::SnovaGen::fEventDuration
protected

Definition at line 86 of file SnovaGen_module.cc.

Referenced by EventEnd().

std::unique_ptr<genie::supernova::GFluxSNova> supernova::SnovaGen::fFluxDriver = nullptr
protected

Definition at line 90 of file SnovaGen_module.cc.

Referenced by FluxEnd(), and SnovaGen().

TGeoManager* supernova::SnovaGen::fGeoManager = nullptr
protected

Definition at line 93 of file SnovaGen_module.cc.

Referenced by PrepareEvent(), SaveEvent(), and SnovaGen().

std::unique_ptr<genie::geometry::ROOTGeomAnalyzer> supernova::SnovaGen::fGeomDriver = nullptr
protected

Definition at line 89 of file SnovaGen_module.cc.

Referenced by SnovaGen().

genie::GMCJDriver supernova::SnovaGen::fMCJobDriver
protected

Definition at line 88 of file SnovaGen_module.cc.

Referenced by GenerateNextRecord(), and SnovaGen().

std::shared_ptr< genie::EventRecord > supernova::SnovaGen::fRecord = nullptr
protected

Definition at line 98 of file SnovaGen_module.cc.

Referenced by GenerateNextRecord(), produce(), RecordTime(), and SaveRecordToEvent().

size_t supernova::SnovaGen::fRecordsCounter = 0
protected

Definition at line 96 of file SnovaGen_module.cc.

Referenced by GenerateNextRecord(), and produce().

double supernova::SnovaGen::fTime
protected

Definition at line 85 of file SnovaGen_module.cc.

Referenced by EventEnd(), EventStart(), and EventTimeNext().

TGeoVolume* supernova::SnovaGen::fTopVolume = nullptr
protected

Definition at line 94 of file SnovaGen_module.cc.

Referenced by PrepareEvent(), and SnovaGen().

std::unique_ptr<std::vector<simb::MCTruth> > supernova::SnovaGen::fTruth = nullptr
protected

Definition at line 91 of file SnovaGen_module.cc.

Referenced by PrepareEvent(), SaveEvent(), and SaveRecordToEvent().

std::string supernova::SnovaGen::MaxPathLenFile
protected

Definition at line 70 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::MaxPathLenFileName
protected

Definition at line 70 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::ModelFile
protected

Definition at line 69 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::ModelFileName
protected

Definition at line 69 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::MsgLevelFile
protected

Definition at line 68 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::MsgLevelFileName
protected

Definition at line 68 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::TopVolume
protected

Definition at line 73 of file SnovaGen_module.cc.

Referenced by SnovaGen().

TVector3 supernova::SnovaGen::WindowPos
protected

Definition at line 79 of file SnovaGen_module.cc.

Referenced by SnovaGen().

double supernova::SnovaGen::WindowSize
protected

Definition at line 80 of file SnovaGen_module.cc.

Referenced by SnovaGen().

double supernova::SnovaGen::WindowX
protected

Definition at line 81 of file SnovaGen_module.cc.

Referenced by SnovaGen().

double supernova::SnovaGen::WindowY
protected

Definition at line 82 of file SnovaGen_module.cc.

Referenced by SnovaGen().

double supernova::SnovaGen::WindowZ
protected

Definition at line 83 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::XsecFile
protected

Definition at line 71 of file SnovaGen_module.cc.

Referenced by SnovaGen().

std::string supernova::SnovaGen::XsecFileName
protected

Definition at line 71 of file SnovaGen_module.cc.

Referenced by SnovaGen().


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