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

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

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

 IsoGen (fhicl::ParameterSet const &pset)
 
virtual ~IsoGen ()
 
void produce (art::Event &evt)
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void beginRun (art::Run &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 Member Functions

void Sample (simb::MCTruth &truth)
 
void setInSurfID (CLHEP::RandFlat &flat, int const &i)
 
void setDirection (CLHEP::RandFlat &flat, int const &i)
 
bool getOutSurfPosition (int i)
 
bool projectToSurface (int axis, double surfaceLoc)
 

Private Attributes

std::vector< intfPDG
 PDG code of particles to generate. More...
 
std::vector< double > fP0
 Central momentum (GeV/c) to generate. More...
 
std::vector< double > fSigmaP
 Variation in momenta (GeV/c) More...
 
std::vector< double > fPL
 momentum list (GeV/c) to generate More...
 
std::vector< intfPDist
 How to distribute momenta (0=uniform, 1=gaussian) More...
 
std::vector< double > fXhigh
 Up limit of x position (cm) More...
 
std::vector< double > fYhigh
 Up limit of y position (cm) More...
 
std::vector< double > fZhigh
 Up limit of z position (cm) More...
 
std::vector< double > fT0
 Central t position (ns) More...
 
std::vector< double > fXlow
 Low limit of x position (cm) More...
 
std::vector< double > fYlow
 Low Limit of y position (cm) More...
 
std::vector< double > fZlow
 Low Limit of z position (cm) More...
 
std::vector< double > fSigmaT
 Variation in t position (ns) More...
 
TTree * isoGen_Tree
 
int inSurfID
 
int outSurfID
 
double cosx
 
double cosy
 
double cosz
 
double init_x [4]
 
double final_x [3]
 
double localPhi
 
double localTheta
 

Detailed Description

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

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

Definition at line 88 of file IsoGen_module.cc.

References art::EngineCreator::createEngine(), fhicl::ParameterSet::get(), evgb::GetRandomNumberSeed(), reconfigure(), and seed.

89  {
90  this->reconfigure(pset);
91 
92  // get the random number seed, use a random default if not specified
93  // in the configuration file.
94  int seed = pset.get< unsigned int >("Seed", evgb::GetRandomNumberSeed());
95 
96  createEngine( seed );
97 
98  produces< std::vector<simb::MCTruth> >();
99  produces< sumdata::RunData, art::InRun >();
100  }
void reconfigure(const fhicl::ParameterSet &pset)
unsigned int GetRandomNumberSeed()
Definition: evgenbase.h:22
base_engine_t & createEngine(seed_t seed)
unsigned int seed
Definition: runWimpSim.h:102
evgen::IsoGen::~IsoGen ( )
virtual

Definition at line 103 of file IsoGen_module.cc.

103 { }

Member Function Documentation

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

Reimplemented from art::EDProducer.

Definition at line 124 of file IsoGen_module.cc.

References cosx, cosy, cosz, geo::GeometryBase::DetId(), geo::GeometryBase::ExtractGDML(), geo::GeometryBase::FileBaseName(), final_x, init_x, inSurfID, isoGen_Tree, localPhi, localTheta, art::TFileDirectory::make(), outSurfID, and art::Run::put().

125  {
126  // grab the geometry object to see what geometry we are using
128 
129  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetId(),
130  geo->FileBaseName(),
131  geo->ExtractGDML()));
132 
134  isoGen_Tree = tfs->make<TTree>("isoGen_Tree","Information from Generator");
135  isoGen_Tree -> Branch("inSurfID", &inSurfID);
136  isoGen_Tree -> Branch("outSurfID", &outSurfID);
137  isoGen_Tree -> Branch("cosx", &cosx);
138  isoGen_Tree -> Branch("cosy", &cosy);
139  isoGen_Tree -> Branch("cosz", &cosz);
140  isoGen_Tree -> Branch("ix", &init_x[0]);
141  isoGen_Tree -> Branch("iy", &init_x[1]);
142  isoGen_Tree -> Branch("iz", &init_x[2]);
143  isoGen_Tree -> Branch("it", &init_x[3]);
144  isoGen_Tree -> Branch("fx", &final_x[0]);
145  isoGen_Tree -> Branch("fy", &final_x[1]);
146  isoGen_Tree -> Branch("fz", &final_x[2]);
147  isoGen_Tree -> Branch("localPhi", &localPhi);
148  isoGen_Tree -> Branch("localTheta", &localTheta);
149 
150  run.put(std::move(runcol));
151 
152  return;
153  }
double init_x[4]
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
T * make(ARGS...args) const
double final_x[3]
TTree * isoGen_Tree
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
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
bool evgen::IsoGen::getOutSurfPosition ( int  i)
private

Definition at line 376 of file IsoGen_module.cc.

References final_x, fXhigh, fXlow, fYhigh, fYlow, fZhigh, fZlow, inSurfID, outSurfID, and projectToSurface().

Referenced by Sample().

376  {
377  //use http://nusoft.fnal.gov/nova/novasoft/doxygen/html/classevgen_1_1EventGeneratorTest.html#a1a77bf812bda6f7c03012ea11d1c2311
378  if(inSurfID!=2){
379  if(projectToSurface(0,fXhigh[i])){
380  if(fYlow[i] <=final_x[1] && final_x[1]<=fYhigh[i] && fZlow[i]<=final_x[2] && final_x[2]<=fZhigh[i]){
381  outSurfID = 2;
382  return true;
383  }
384  }
385  }
386  if(inSurfID!=4){
387  if( projectToSurface(0,fXlow[i])){
388  if(fYlow[i] <=final_x[1] && final_x[1]<=fYhigh[i] && fZlow[i]<=final_x[2] && final_x[2]<=fZhigh[i]){
389  outSurfID = 4;
390  return true;
391  }
392  }
393  }
394  if(inSurfID!=1){
395  if(projectToSurface(1,fYhigh[i])){
396  if(fXlow[i] <=final_x[0] && final_x[0]<=fXhigh[i] && fZlow[i]<=final_x[2] && final_x[2]<=fZhigh[i]){
397  outSurfID = 1;
398  return true;
399  }
400  }
401  }
402  if(inSurfID!=3){
403  if(projectToSurface(1,fYlow[i])){
404  if(fXlow[i] <=final_x[0] && final_x[0]<=fXhigh[i] && fZlow[i]<=final_x[2] && final_x[2]<=fZhigh[i]){
405  outSurfID = 3;
406  return true;
407  }
408  }
409  }
410  if(inSurfID!=0){
411  if(projectToSurface(2,fZhigh[i])){
412  if(fXlow[i] <=final_x[0] && final_x[0]<=fXhigh[i] && fYlow[i]<=final_x[1] && final_x[1]<=fYhigh[i]){
413  outSurfID = 0;
414  return true;
415  }
416  }
417  }
418  if(inSurfID!=5){
419  if(projectToSurface(2,fZlow[i])){
420  if(fXlow[i] <=final_x[0] && final_x[0]<=fXhigh[i] && fYlow[i]<=final_x[1] && final_x[1]<=fYhigh[i]){
421  outSurfID = 5;
422  return true;
423  }
424  }
425  }
426  return false;
427  }
std::vector< double > fZhigh
Up limit of z position (cm)
std::vector< double > fYlow
Low Limit of y position (cm)
std::vector< double > fYhigh
Up limit of y position (cm)
std::vector< double > fXhigh
Up limit of x position (cm)
double final_x[3]
bool projectToSurface(int axis, double surfaceLoc)
std::vector< double > fXlow
Low limit of x position (cm)
std::vector< double > fZlow
Low Limit of z position (cm)
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::IsoGen::produce ( art::Event evt)
virtual

unique_ptr allows ownership to be transferred to the art::Event after the ut statement

Implements art::EDProducer.

Definition at line 156 of file IsoGen_module.cc.

References simb::kSingleParticle, art::Event::put(), Sample(), and simb::MCTruth::SetOrigin().

157  {
158  ///unique_ptr allows ownership to be transferred to the art::Event after the ut statement
159  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
160 
161  simb::MCTruth truth;
163  Sample(truth);
164 
165  // std::cout << "put mctruth into the vector" << std::endl;
166  truthcol->push_back(truth);
167 
168  // std::cout << "add vector to the event " << truthcol->size() << std::endl;
169  evt.put(std::move(truthcol));
170 
171  return;
172  }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:80
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
single particles thrown at the detector
Definition: MCTruth.h:26
void Sample(simb::MCTruth &truth)
Event generator information.
Definition: MCTruth.h:32
bool evgen::IsoGen::projectToSurface ( int  axis,
double  surfaceLoc 
)
private

Definition at line 428 of file IsoGen_module.cc.

References allInOneTrainingPlots::axis, cosx, cosy, cosz, DEFINE_ART_MODULE(), final_x, and init_x.

Referenced by getOutSurfPosition().

428  {
429  double momDir = 0, posDir = 0;
430  if(axis == 0){
431  momDir = cosx;
432  }
433  else if(axis == 1){
434  momDir = cosy;
435  }
436  else if(axis == 2){
437  momDir = cosz;
438  }
439 
440  posDir = init_x[axis];
441  double length1Dim = (surfaceLoc - posDir);
442  if(TMath::Abs(momDir)>0.){
443  length1Dim/=momDir;
444  final_x[0] = init_x[0] + length1Dim*cosx;
445  final_x[1] = init_x[1] + length1Dim*cosy;
446  final_x[2] = init_x[2] + length1Dim*cosz;
447  return true;
448  }
449  else{
450  return false;
451  }
452  }
double init_x[4]
double final_x[3]
void evgen::IsoGen::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 106 of file IsoGen_module.cc.

References fP0, fPDG, fPDist, fPL, fSigmaP, fSigmaT, fT0, fXhigh, fXlow, fYhigh, fYlow, fZhigh, fZlow, and fhicl::ParameterSet::get().

Referenced by IsoGen().

107  {
108  fXlow = pset.get< std::vector<double> >("Xlow");
109  fYlow = pset.get< std::vector<double> >("Ylow");
110  fZlow = pset.get< std::vector<double> >("Zlow");
111  fXhigh = pset.get< std::vector<double> >("Xhigh");
112  fYhigh = pset.get< std::vector<double> >("Yhigh");
113  fZhigh = pset.get< std::vector<double> >("Zhigh");
114  fPDG = pset.get< std::vector<int> >("PDG");
115  fP0 = pset.get< std::vector<double> >("P0");
116  fSigmaP = pset.get< std::vector<double> >("SigmaP");
117  fPL = pset.get< std::vector<double> >("PL");
118  fPDist = pset.get< std::vector<int> >("PDist");
119  fT0 = pset.get< std::vector<double> >("T0");
120  fSigmaT = pset.get< std::vector<double> >("SigmaT");
121  }
std::vector< double > fZhigh
Up limit of z position (cm)
std::vector< double > fYlow
Low Limit of y position (cm)
std::vector< double > fSigmaT
Variation in t position (ns)
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< double > fP0
Central momentum (GeV/c) to generate.
std::vector< double > fYhigh
Up limit of y position (cm)
std::vector< double > fXhigh
Up limit of x position (cm)
std::vector< double > fSigmaP
Variation in momenta (GeV/c)
std::vector< double > fPL
momentum list (GeV/c) to generate
std::vector< int > fPDist
How to distribute momenta (0=uniform, 1=gaussian)
std::vector< double > fXlow
Low limit of x position (cm)
std::vector< double > fT0
Central t position (ns)
std::vector< int > fPDG
PDG code of particles to generate.
std::vector< double > fZlow
Low Limit of z position (cm)
void evgen::IsoGen::Sample ( simb::MCTruth truth)
private

Definition at line 175 of file IsoGen_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), cosx, cosy, cosz, Fill(), CLHEP::RandGaussQ::fire(), CLHEP::RandFlat::fire(), CLHEP::RandFlat::fireInt(), fP0, fPDG, fPDist, fPL, fSigmaP, fSigmaT, fT0, Munits::gauss, art::RandomNumberGenerator::getEngine(), getOutSurfPosition(), MECModelEnuComparisons::i, init_x, makeTrainCVSamples::int, isoGen_Tree, m, part, elec2geo::pos, art::EngineCreator::rng(), setDirection(), setInSurfID(), std::sqrt(), and string.

Referenced by produce().

176  {
177  // get the random number generator service and make some CLHEP generators
179 
180  CLHEP::HepRandomEngine &engine = rng->getEngine();
181  CLHEP::RandFlat flat(engine);
182  CLHEP::RandGaussQ gauss(engine);
183 
184  //std::ofstream ofs;
185  //ofs.open ("iso.txt", std::ofstream::out | std::ofstream::app);
186 
187  // every event will have one of each particle species in the fPDG array
188  for (unsigned int i=0; i<fPDG.size(); ++i) {
189  // Choose momentum
190  double p = 0.0;
191  double m = 0.0;
192 
193  if (fPL.size()==0){
194  if (fPDist[i]) {
195  p = gauss.fire(fP0[i], fSigmaP[i]);
196  }
197  else {
198  p = flat.fire(fP0[i]-fSigmaP[i], fP0[i]+fSigmaP[i]);
199  }
200  }
201  else {
202  int randomIndex = int(flat.fireInt(fPL.size()));
203  p = fPL[randomIndex];
204  }
205 
206  // ofs << "get the mass" << std::endl;
207  static TDatabasePDG* pdgt = TDatabasePDG::Instance();
208  TParticlePDG* pdgp = pdgt->GetParticle(fPDG[i]);
209  if (pdgp) m = pdgp->Mass();
210 
211  setInSurfID(flat, i);
212  // Choose position and time
213  init_x[3] = flat.fire(fT0[i]-fSigmaT[i], fT0[i]+fSigmaT[i]);
214  // Choose angles
215  setDirection(flat, i);
217 
218  isoGen_Tree -> Fill();
219 
220  TLorentzVector pvec(cosx*p,
221  cosy*p,
222  cosz*p,
223  sqrt(p*p+m*m));
224 
225  // ofs<<cosx<<" "<<cosy<<" "<<cosz<<std::endl;
226  TLorentzVector pos(init_x[0],
227  init_x[1],
228  init_x[2],
229  init_x[3]);
230 
231  // set track id to -i as these are all primary particles and have
232  // id <= 0
233  //
234  int trackid = -1*(i+1);
235 
236  std::string primary("primary");
237  simb::MCParticle part(trackid, fPDG[i], primary);
238  part.AddTrajectoryPoint(pos, pvec);
239 
240  mct.Add(part);
241  } //end loop over particles
242 
243  // ofs.close();
244  }
double init_x[4]
const char * p
Definition: xmltok.h:285
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
T sqrt(T number)
Definition: d0nt_math.hpp:156
void setInSurfID(CLHEP::RandFlat &flat, int const &i)
std::vector< double > fSigmaT
Variation in t position (ns)
base_engine_t & getEngine() const
TString part[npart]
Definition: Style.C:32
correl_yv Fill(-(dy[iP-1][iC-1]), hyv->GetBinContent(iP, iC))
std::vector< double > fP0
Central momentum (GeV/c) to generate.
bool getOutSurfPosition(int i)
void setDirection(CLHEP::RandFlat &flat, int const &i)
static constexpr Double_t gauss
Definition: Munits.h:360
std::vector< double > fSigmaP
Variation in momenta (GeV/c)
std::vector< double > fPL
momentum list (GeV/c) to generate
TTree * isoGen_Tree
std::vector< int > fPDist
How to distribute momenta (0=uniform, 1=gaussian)
std::vector< double > fT0
Central t position (ns)
std::vector< int > fPDG
PDG code of particles to generate.
enum BeamMode string
void evgen::IsoGen::setDirection ( CLHEP::RandFlat flat,
int const &  i 
)
private

Definition at line 298 of file IsoGen_module.cc.

References cosx, cosy, cosz, CLHEP::RandFlat::fire(), fXhigh, fXlow, fYhigh, fYlow, fZhigh, fZlow, MECModelEnuComparisons::i, init_x, inSurfID, localPhi, localTheta, and std::sqrt().

Referenced by Sample().

298  {
299  //double localPhi;
300  localPhi = flat.fire(0,2.*TMath::Pi());
301  //double pass = flat.fire(0,1);
302  //incident from front(0):
303  if (inSurfID == 0) {
304  init_x[0] = flat.fire(fXlow[i],fXhigh[i]);
305  init_x[1] = flat.fire(fYlow[i],fYhigh[i]);
306  init_x[2] = fZhigh[i];
307 
308  cosz = -sqrt(flat.fire(0,1));
309  cosx = sqrt(1-cosz*cosz)*TMath::Cos(localPhi);
310  cosy = sqrt(1-cosz*cosz)*TMath::Sin(localPhi);
311  localTheta = TMath::ACos(-cosz);
312  return;
313  }
314 
315  //incident from end(5):
316  else if (inSurfID == 5) {
317  init_x[0] = flat.fire(fXlow[i],fXhigh[i]);
318  init_x[1] = flat.fire(fYlow[i],fYhigh[i]);
319  init_x[2] = fZlow[i];
320  cosz = sqrt(flat.fire(0,1));
321  cosx = sqrt(1-cosz*cosz)*TMath::Cos(localPhi);
322  cosy = sqrt(1-cosz*cosz)*TMath::Sin(localPhi);
323  localTheta = TMath::ACos(cosz);
324  return;
325  }
326 
327  //incident from top(1):
328  else if (inSurfID == 1) {
329  init_x[0] = flat.fire(fXlow[i],fXhigh[i]);
330  init_x[1] = fYhigh[i];
331  init_x[2] = flat.fire(fZlow[i],fZhigh[i]);
332  cosy = -sqrt(flat.fire(0,1));
333  cosz = sqrt(1-cosy*cosy)*TMath::Cos(localPhi);
334  cosx = sqrt(1-cosy*cosy)*TMath::Sin(localPhi);
335  localTheta = TMath::ACos(-cosy);
336  return;
337  }
338 
339  //incident from bottom(3):
340  else if (inSurfID == 3) {
341  init_x[0] = flat.fire(fXlow[i],fXhigh[i]);
342  init_x[1] = fYlow[i];
343  init_x[2] = flat.fire(fZlow[i],fZhigh[i]);
344  cosy = sqrt(flat.fire(0,1));
345  cosz = sqrt(1-cosy*cosy)*TMath::Cos(localPhi);
346  cosx = sqrt(1-cosy*cosy)*TMath::Sin(localPhi);
347  localTheta = TMath::ACos(cosy);
348  return;
349  }
350 
351  //incident from left(4):
352  else if (inSurfID == 4) {
353  init_x[0] = fXlow[i];
354  init_x[1] = flat.fire(fYlow[i],fYhigh[i]);
355  init_x[2] = flat.fire(fZlow[i],fZhigh[i]);
356  cosx = sqrt(flat.fire(0,1));
357  cosy = sqrt(1-cosx*cosx)*TMath::Cos(localPhi);
358  cosz = sqrt(1-cosx*cosx)*TMath::Sin(localPhi);
359  localTheta = TMath::ACos(cosx);
360  return;
361  }
362 
363  //incident from right(2):
364  else if (inSurfID == 2) {
365  init_x[0] = fXhigh[i];
366  init_x[1] = flat.fire(fYlow[i],fYhigh[i]);
367  init_x[2] = flat.fire(fZlow[i],fZhigh[i]);
368  cosx = -sqrt(flat.fire(0,1));
369  cosy = sqrt(1-cosx*cosx)*TMath::Cos(localPhi);
370  cosz = sqrt(1-cosx*cosx)*TMath::Sin(localPhi);
371  localTheta = TMath::ACos(-cosx);
372  return;
373  }
374  }
std::vector< double > fZhigh
Up limit of z position (cm)
double init_x[4]
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::vector< double > fYlow
Low Limit of y position (cm)
std::vector< double > fYhigh
Up limit of y position (cm)
std::vector< double > fXhigh
Up limit of x position (cm)
std::vector< double > fXlow
Low limit of x position (cm)
std::vector< double > fZlow
Low Limit of z position (cm)
void evgen::IsoGen::setInSurfID ( CLHEP::RandFlat flat,
int const &  i 
)
private

Definition at line 246 of file IsoGen_module.cc.

References CLHEP::RandFlat::fire(), fXhigh, fXlow, fYhigh, fYlow, fZhigh, fZlow, MECModelEnuComparisons::i, inSurfID, and calib::j.

Referenced by Sample().

246  {
247  //int inSurfID = 0;
248  //Choose an incident surface:
249  double lx,ly,lz;
250  lx = fXhigh[i]-fXlow[i];
251  ly = fYhigh[i]-fYlow[i];
252  lz = fZhigh[i]-fZlow[i];
253 
254  double Surf[6];
255  Surf[0] = lx*ly;
256  Surf[1] = lx*lz;
257  Surf[2] = ly*lz;
258  Surf[3] = lx*lz;
259  Surf[4] = ly*lz;
260  Surf[5] = lx*ly;
261 
262  double sumA =0;
263  for (int j=0; j!=6;++j) sumA += Surf[j];
264 
265  double dice = flat.fire(0,sumA);
266  if (dice<Surf[0]) {
267  inSurfID=0;
268  return;
269  }
270  //incident from end(5):
271  else if (dice<Surf[0]+Surf[5]) {
272  inSurfID=5;
273  return;
274  }
275  //incident from top(1):
276  else if (dice<Surf[0]+Surf[5]+Surf[1]) {
277  inSurfID=1;
278  return;
279  }
280  //incident from bottom(3):
281  else if (dice<sumA-Surf[4]-Surf[2]) {
282  inSurfID=3;
283  return;
284  }
285  //incident from left(4):
286  else if (dice<sumA-Surf[2]) {
287  inSurfID=4;
288  return;
289  }
290  //incident from right(2):
291  else {
292  inSurfID=2;
293  return;
294  }
295  //return inSurfID;
296  }
std::vector< double > fZhigh
Up limit of z position (cm)
std::vector< double > fYlow
Low Limit of y position (cm)
const double j
Definition: BetheBloch.cxx:29
std::vector< double > fYhigh
Up limit of y position (cm)
std::vector< double > fXhigh
Up limit of x position (cm)
std::vector< double > fXlow
Low limit of x position (cm)
std::vector< double > fZlow
Low Limit of z position (cm)
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 evgen::IsoGen::cosx
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), projectToSurface(), Sample(), and setDirection().

double evgen::IsoGen::cosy
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), projectToSurface(), Sample(), and setDirection().

double evgen::IsoGen::cosz
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), projectToSurface(), Sample(), and setDirection().

double evgen::IsoGen::final_x[3]
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), getOutSurfPosition(), and projectToSurface().

std::vector<double> evgen::IsoGen::fP0
private

Central momentum (GeV/c) to generate.

Definition at line 59 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<int> evgen::IsoGen::fPDG
private

PDG code of particles to generate.

Definition at line 57 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<int> evgen::IsoGen::fPDist
private

How to distribute momenta (0=uniform, 1=gaussian)

Definition at line 62 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<double> evgen::IsoGen::fPL
private

momentum list (GeV/c) to generate

Definition at line 61 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<double> evgen::IsoGen::fSigmaP
private

Variation in momenta (GeV/c)

Definition at line 60 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<double> evgen::IsoGen::fSigmaT
private

Variation in t position (ns)

Definition at line 71 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<double> evgen::IsoGen::fT0
private

Central t position (ns)

Definition at line 67 of file IsoGen_module.cc.

Referenced by reconfigure(), and Sample().

std::vector<double> evgen::IsoGen::fXhigh
private

Up limit of x position (cm)

Definition at line 64 of file IsoGen_module.cc.

Referenced by getOutSurfPosition(), reconfigure(), setDirection(), and setInSurfID().

std::vector<double> evgen::IsoGen::fXlow
private

Low limit of x position (cm)

Definition at line 68 of file IsoGen_module.cc.

Referenced by getOutSurfPosition(), reconfigure(), setDirection(), and setInSurfID().

std::vector<double> evgen::IsoGen::fYhigh
private

Up limit of y position (cm)

Definition at line 65 of file IsoGen_module.cc.

Referenced by getOutSurfPosition(), reconfigure(), setDirection(), and setInSurfID().

std::vector<double> evgen::IsoGen::fYlow
private

Low Limit of y position (cm)

Definition at line 69 of file IsoGen_module.cc.

Referenced by getOutSurfPosition(), reconfigure(), setDirection(), and setInSurfID().

std::vector<double> evgen::IsoGen::fZhigh
private

Up limit of z position (cm)

Definition at line 66 of file IsoGen_module.cc.

Referenced by getOutSurfPosition(), reconfigure(), setDirection(), and setInSurfID().

std::vector<double> evgen::IsoGen::fZlow
private

Low Limit of z position (cm)

Definition at line 70 of file IsoGen_module.cc.

Referenced by getOutSurfPosition(), reconfigure(), setDirection(), and setInSurfID().

double evgen::IsoGen::init_x[4]
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), projectToSurface(), Sample(), and setDirection().

int evgen::IsoGen::inSurfID
private

Definition at line 74 of file IsoGen_module.cc.

Referenced by beginRun(), getOutSurfPosition(), setDirection(), and setInSurfID().

TTree* evgen::IsoGen::isoGen_Tree
private

Definition at line 73 of file IsoGen_module.cc.

Referenced by beginRun(), and Sample().

double evgen::IsoGen::localPhi
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), and setDirection().

double evgen::IsoGen::localTheta
private

Definition at line 75 of file IsoGen_module.cc.

Referenced by beginRun(), and setDirection().

int evgen::IsoGen::outSurfID
private

Definition at line 74 of file IsoGen_module.cc.

Referenced by beginRun(), and getOutSurfPosition().


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