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

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

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

 CosmicPionGen (fhicl::ParameterSet const &pset)
 
virtual ~CosmicPionGen ()
 
void produce (art::Event &evt)
 
void beginRun (art::Run &run)
 
void beginSubRun (art::SubRun &run)
 
void endSubRun (art::SubRun &run)
 
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::CRYHelperfCRYHelp
 CRY generator object. More...
 
std::string fGeoVersion
 gdml file containing detector geometry More...
 
double fSpillLength
 Time in seconds to add to fExposure every spill. More...
 
double fExposure
 Livetime this subrun, in seconds. More...
 
int fCycle
 MC production cycle. More...
 

Detailed Description

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

Definition at line 44 of file CosmicPionGen_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::CosmicPionGen::CosmicPionGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 68 of file CosmicPionGen_module.cc.

References art::EngineCreator::createEngine(), fCRYHelp, fhicl::ParameterSet::get(), art::RandomNumberGenerator::getEngine(), evgb::GetRandomNumberSeed(), art::EngineCreator::rng(), and seed.

69  : fSpillLength(pset.get< double >("SpillLength"))
70  , fExposure (0)
71  , fCycle (pset.get< int >("Cycle", 0))
72  {
73 
74  // Create a Art Random Number engine
75  int seed = pset.get< int >("Seed", evgb::GetRandomNumberSeed());
76  createEngine(seed);
77 
78  // get the random number generator service and make some CLHEP generators
80  CLHEP::HepRandomEngine& engine = rng->getEngine();
81 
82  // Create a new CRYHelper
83  fCRYHelp = new evgb::CRYHelper(pset, engine);
84 
85  // Producers
86  produces< std::vector<simb::MCTruth> >();
87  produces< sumdata::RunData, art::InRun >();
88  produces< sumdata::CosmicExposure, art::InSubRun >();
89  produces< sumdata::SubRunData, art::InSubRun >();
90  }
Interface to the CRY cosmic-ray generator.
Definition: CRYHelper.h:26
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
unsigned int GetRandomNumberSeed()
Definition: evgenbase.h:22
base_engine_t & createEngine(seed_t seed)
base_engine_t & getEngine() const
unsigned int seed
Definition: runWimpSim.h:102
double fSpillLength
Time in seconds to add to fExposure every spill.
double fExposure
Livetime this subrun, in seconds.
evgb::CRYHelper * fCRYHelp
CRY generator object.
int fCycle
MC production cycle.
evgen::CosmicPionGen::~CosmicPionGen ( )
virtual

Definition at line 93 of file CosmicPionGen_module.cc.

References fCRYHelp.

94  {
95  if(fCRYHelp) delete fCRYHelp;
96  }
evgb::CRYHelper * fCRYHelp
CRY generator object.

Member Function Documentation

void evgen::CosmicPionGen::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 99 of file CosmicPionGen_module.cc.

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

100  {
101 
102  // grab the geometry object to see what geometry we are using
104 
105  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetId(),
106  geo->FileBaseName(),
107  geo->ExtractGDML()));
108 
109  run.put(std::move(runcol));
110 
111  return;
112  }
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
std::string ExtractGDML() const
Extract contents from fGDMLFile and return as a string.
Helper for AttenCurve.
Definition: Path.h:10
std::string FileBaseName() const
void evgen::CosmicPionGen::beginSubRun ( art::SubRun run)
virtual

Reimplemented from art::EDProducer.

Definition at line 115 of file CosmicPionGen_module.cc.

References fExposure.

116  {
117  fExposure = 0;
118  }
double fExposure
Livetime this subrun, in seconds.
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::CosmicPionGen::endSubRun ( art::SubRun run)
virtual

Reimplemented from art::EDProducer.

Definition at line 121 of file CosmicPionGen_module.cc.

References fCycle, fExposure, art::SubRun::put(), and sd().

122  {
123  std::unique_ptr<sumdata::CosmicExposure> ce(new sumdata::CosmicExposure);
124  ce->totlivetime = fExposure;
125  subrun.put(std::move(ce));
126 
127  // store the cycle information
129  std::unique_ptr< sumdata::SubRunData > sd(new sumdata::SubRunData(fCycle));
130  subrun.put(std::move(sd));
131 
132  }
double sd(Eigen::VectorXd x)
double fExposure
Livetime this subrun, in seconds.
Helper for AttenCurve.
Definition: Path.h:10
int fCycle
MC production cycle.
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::CosmicPionGen::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 135 of file CosmicPionGen_module.cc.

References abs(), simb::MCTruth::Add(), DEFINE_ART_MODULE(), geo::GeometryBase::DetLength(), fCRYHelp, fExposure, fSpillLength, simb::MCTruth::GetParticle(), MECModelEnuComparisons::i, simb::kCosmicRay, simb::MCTruth::NParticles(), part, art::Event::put(), evgb::CRYHelper::Sample(), simb::MCTruth::SetOrigin(), and geo::GeometryBase::SurfaceY().

136  {
137  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
138 
140 
141  simb::MCTruth pitruth;
142  pitruth.SetOrigin(simb::kCosmicRay);
143 
144  while( pitruth.NParticles() < 1 ){
145  simb::MCTruth truth;
147  fCRYHelp->Sample(truth, geo->SurfaceY(), geo->DetLength(), 0);
148 
149  // look to see if there are any charged pions in this spill
150  // drop everything else and only write the pions to the event
151  for(int i = 0; i < truth.NParticles(); ++i){
153  if( abs(part.PdgCode()) == 211 || part.PdgCode() == 111 ) pitruth.Add(part);
154  }
155 
156  // add the spill length to the exposure even if
157  // we didn't have a pion so that we have the correct
158  // exposure in order to understand how long we would
159  // have to run to have a reasonable sample
161  }
162 
163  truthcol->push_back(pitruth);
164  evt.put(std::move(truthcol));
165 
166  return;
167  }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:80
double DetLength() const
void abs(TH1 *hist)
int NParticles() const
Definition: MCTruth.h:74
void Add(simb::MCParticle &part)
Definition: MCTruth.h:79
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
TString part[npart]
Definition: Style.C:32
double Sample(simb::MCTruth &mctruth, double const &surfaceY, double const &detectorLength, double *w, double rantime=0)
Definition: CRYHelper.cxx:97
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:75
double fSpillLength
Time in seconds to add to fExposure every spill.
double fExposure
Livetime this subrun, in seconds.
double SurfaceY() const
Event generator information.
Definition: MCTruth.h:32
Helper for AttenCurve.
Definition: Path.h:10
Cosmic rays.
Definition: MCTruth.h:24
evgb::CRYHelper * fCRYHelp
CRY generator object.
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::CRYHelper* evgen::CosmicPionGen::fCRYHelp
private

CRY generator object.

Definition at line 56 of file CosmicPionGen_module.cc.

Referenced by CosmicPionGen(), produce(), and ~CosmicPionGen().

int evgen::CosmicPionGen::fCycle
private

MC production cycle.

Definition at line 60 of file CosmicPionGen_module.cc.

Referenced by endSubRun().

double evgen::CosmicPionGen::fExposure
private

Livetime this subrun, in seconds.

Definition at line 59 of file CosmicPionGen_module.cc.

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

std::string evgen::CosmicPionGen::fGeoVersion
private

gdml file containing detector geometry

Definition at line 57 of file CosmicPionGen_module.cc.

double evgen::CosmicPionGen::fSpillLength
private

Time in seconds to add to fExposure every spill.

Definition at line 58 of file CosmicPionGen_module.cc.

Referenced by produce().


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