LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evgen::GaisserParam Class Reference

module to produce single or multiple specified particles in the detector More...

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

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 GaisserParam (fhicl::ParameterSet const &pset)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Types

typedef std::map< double, TH1 * > dhist_Map
 
typedef std::map< double, TH1 * >::iterator dhist_Map_it
 

Private Member Functions

void produce (art::Event &evt) override
 
void beginJob () override
 
void beginRun (art::Run &run) override
 
void SampleOne (unsigned int i, simb::MCTruth &mct, CLHEP::HepRandomEngine &engine)
 
void Sample (simb::MCTruth &mct, CLHEP::HepRandomEngine &engine)
 
std::pair< double, double > GetThetaAndEnergy (double rand1, double rand2)
 
void MakePDF ()
 
void ResetMap ()
 
double GaisserMuonFlux_Integrand (Double_t *x, Double_t *par)
 
double GaisserFlux (double e, double theta)
 
std::vector< double > GetBinning (const TAxis *axis, bool finalEdge=true)
 

Private Attributes

TFile * m_File
 
dhist_Mapm_PDFmap
 
TH1 * m_thetaHist
 
CLHEP::HepRandomEngine & fEngine
 art-managed random-number engine More...
 
int fMode
 
bool fPadOutVectors
 
std::vector< int > fPDG
 PDG code of particles to generate. More...
 
int fCharge
 Charge. More...
 
std::string fInputDir
 Input Directory. More...
 
double fEmin
 Minimum Kinetic Energy (GeV) More...
 
double fEmax
 Maximum Kinetic Energy (GeV) More...
 
double fEmid
 Energy to go from low to high (GeV) More...
 
int fEBinsLow
 Number of low energy Bins. More...
 
int fEBinsHigh
 Number of high energy Bins. More...
 
double fThetamin
 Minimum theta. More...
 
double fThetamax
 Maximum theta. More...
 
int fThetaBins
 Number of theta Bins. More...
 
double fXHalfRange
 Max X position. More...
 
double fYInput
 Max Y position. More...
 
double fZHalfRange
 Max Z position. More...
 
double fT0
 Central t position (ns) in world coordinates. More...
 
double fSigmaT
 Variation in t position (ns) More...
 
int fTDist
 How to distribute t (gaus, or uniform) More...
 
bool fSetParam
 Which version of Gaissers Param. More...
 
bool fSetRead
 Whether to Read. More...
 
bool fSetWrite
 Whether to Write. More...
 
bool fSetReWrite
 Whether to ReWrite pdfs. More...
 
double fEpsilon
 Minimum integration sum.... More...
 
double fCryoBoundaries [6]
 
double xNeg = 0
 
double xPos = 0
 
double zNeg = 0
 
double zPos = 0
 
double fCenterX = 0
 
double fCenterZ = 0
 
TTree * fTree
 
double Time
 
double Momentum
 
double KinEnergy
 
double Gamma
 
double Energy
 
double Theta
 
double Phi
 
double pnorm
 
double XPosition
 
double YPosition
 
double ZPosition
 
double DirCosineX
 
double DirCosineY
 
double DirCosineZ
 

Static Private Attributes

static constexpr int kGAUS = 1
 

Detailed Description

module to produce single or multiple specified particles in the detector

Definition at line 61 of file GaisserParam_module.cc.

Member Typedef Documentation

typedef std::map<double, TH1*> evgen::GaisserParam::dhist_Map
private

Definition at line 73 of file GaisserParam_module.cc.

typedef std::map<double, TH1*>::iterator evgen::GaisserParam::dhist_Map_it
private

Definition at line 74 of file GaisserParam_module.cc.

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

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

Definition at line 147 of file GaisserParam_module.cc.

References art::detail::EngineCreator::createEngine(), fCharge, fEBinsHigh, fEBinsLow, fEmax, fEmid, fEmin, fEngine, fEpsilon, fInputDir, fMode, fPadOutVectors, fPDG, fSetParam, fSetRead, fSetReWrite, fSetWrite, fSigmaT, fT0, fTDist, fThetaBins, fThetamax, fThetamin, fXHalfRange, fYInput, and fZHalfRange.

148  : art::EDProducer{pset}
149  // create a default random engine; obtain the random seed from NuRandomService,
150  // unless overridden in configuration with key "Seed"
151  , fEngine(art::ServiceHandle<rndm::NuRandomService>()->registerAndSeedEngine(createEngine(0),
152  pset,
153  "Seed"))
154  , fMode{pset.get<int>("ParticleSelectionMode")}
155  , fPadOutVectors{pset.get<bool>("PadOutVectors")}
156  , fPDG{pset.get<std::vector<int>>("PDG")}
157  , fCharge{pset.get<int>("Charge")}
158  , fInputDir{pset.get<std::string>("InputDir")}
159  , fEmin{pset.get<double>("Emin")}
160  , fEmax{pset.get<double>("Emax")}
161  , fEmid{pset.get<double>("Emid")}
162  , fEBinsLow{pset.get<int>("EBinsLow")}
163  , fEBinsHigh{pset.get<int>("EBinsHigh")}
164  , fThetamin{pset.get<double>("Thetamin")}
165  , fThetamax{pset.get<double>("Thetamax")}
166  , fThetaBins{pset.get<int>("ThetaBins")}
167  , fXHalfRange{pset.get<double>("XHalfRange")}
168  , fYInput{pset.get<double>("YInput")}
169  , fZHalfRange{pset.get<double>("ZHalfRange")}
170  , fT0{pset.get<double>("T0")}
171  , fSigmaT{pset.get<double>("SigmaT")}
172  , fTDist{pset.get<int>("TDist")}
173  , fSetParam{pset.get<bool>("SetParam")}
174  , fSetRead{pset.get<bool>("SetRead")}
175  , fSetWrite{pset.get<bool>("SetWrite")}
176  , fSetReWrite{pset.get<bool>("SetReWrite")}
177  , fEpsilon{pset.get<double>("Epsilon")}
178  {
179  produces<std::vector<simb::MCTruth>>();
180  produces<sumdata::RunData, art::InRun>();
181  }
base_engine_t & createEngine(seed_t seed)
double fEpsilon
Minimum integration sum....
double fThetamax
Maximum theta.
double fYInput
Max Y position.
int fThetaBins
Number of theta Bins.
double fEmid
Energy to go from low to high (GeV)
bool fSetReWrite
Whether to ReWrite pdfs.
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
std::string fInputDir
Input Directory.
int fEBinsLow
Number of low energy Bins.
double fEmin
Minimum Kinetic Energy (GeV)
double fSigmaT
Variation in t position (ns)
bool fSetParam
Which version of Gaissers Param.
double fEmax
Maximum Kinetic Energy (GeV)
double fXHalfRange
Max X position.
int fEBinsHigh
Number of high energy Bins.
std::vector< int > fPDG
PDG code of particles to generate.
bool fSetRead
Whether to Read.
double fThetamin
Minimum theta.
int fTDist
How to distribute t (gaus, or uniform)
double fT0
Central t position (ns) in world coordinates.
bool fSetWrite
Whether to Write.
double fZHalfRange
Max Z position.

Member Function Documentation

void evgen::GaisserParam::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 184 of file GaisserParam_module.cc.

References DirCosineX, DirCosineY, DirCosineZ, Energy, fCenterX, fCenterZ, fCryoBoundaries, fTree, geo::GeometryCore::Iterate(), KinEnergy, Momentum, Phi, Theta, Time, xNeg, xPos, XPosition, YPosition, zNeg, zPos, and ZPosition.

185  {
186  //Work out center of cryostat(s)
188  for (auto const& cryostat : geom->Iterate<geo::CryostatGeo>()) {
189  cryostat.Boundaries(fCryoBoundaries);
190  if (xNeg > fCryoBoundaries[0]) xNeg = fCryoBoundaries[0];
191  if (xPos < fCryoBoundaries[1]) xPos = fCryoBoundaries[1];
192  if (zNeg > fCryoBoundaries[4]) zNeg = fCryoBoundaries[4];
193  if (zPos < fCryoBoundaries[5]) zPos = fCryoBoundaries[5];
194  }
195  fCenterX = xNeg + (xPos - xNeg) / 2;
196  fCenterZ = zNeg + (zPos - zNeg) / 2;
197 
198  // Make the Histograms....
200  fTree = tfs->make<TTree>("Generator", "analysis tree");
201  fTree->Branch("XPosition", &XPosition, "XPosition/D");
202  fTree->Branch("YPosition", &YPosition, "YPosition/D");
203  fTree->Branch("ZPosition", &ZPosition, "ZPosition/D");
204  fTree->Branch("Time", &Time, "Time/D");
205  fTree->Branch("Momentum", &Momentum, "Momentum/D");
206  fTree->Branch("KinEnergy", &KinEnergy, "KinEnergy/D");
207  fTree->Branch("Energy", &Energy, "Energy/D");
208  fTree->Branch("DirCosineX", &DirCosineX, "DirCosineX/D");
209  fTree->Branch("DirCosineY", &DirCosineY, "DirCosineY/D");
210  fTree->Branch("DirCosineZ", &DirCosineZ, "DirCosineZ/D");
211  fTree->Branch("Theta", &Theta, "Theta/D");
212  fTree->Branch("Phi", &Phi, "Phi/D");
213  }
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
void evgen::GaisserParam::beginRun ( art::Run run)
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 216 of file GaisserParam_module.cc.

References geo::GeometryCore::DetectorName(), fThetamax, fThetamin, art::fullRun(), MakePDF(), and art::Run::put().

217  {
218  // Check fcl parameters were set correctly
219  if (fThetamax > M_PI / 2 + 0.01)
220  throw cet::exception("GaisserParam")
221  << "\nThetamax has to be less than " << M_PI / 2 << ", but was entered as " << fThetamax
222  << ", this cause an error so leaving program now...\n\n";
223  if (fThetamin < 0)
224  throw cet::exception("GaisserParam")
225  << "\nThetamin has to be more than 0, but was entered as " << fThetamin
226  << ", this cause an error so leaving program now...\n\n"
227  << std::endl;
228  if (fThetamax < fThetamin)
229  throw cet::exception("GaisserParam")
230  << "\nMinimum angle is bigger than maximum angle....causes an error so leaving program "
231  "now....\n\n"
232  << std::endl;
233 
234  // grab the geometry object to see what geometry we are using
236  run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()), art::fullRun());
237  MakePDF();
238  }
constexpr auto fullRun()
double fThetamax
Maximum theta.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Run.h:121
double fThetamin
Minimum theta.
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Definition: GeometryCore.h:203
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
double evgen::GaisserParam::GaisserFlux ( double  e,
double  theta 
)
private

Definition at line 652 of file GaisserParam_module.cc.

References c1, and fSetParam.

Referenced by GaisserMuonFlux_Integrand().

653  {
654 
655  double ct = cos(theta);
656  double di;
657  if (fSetParam) {
658  double gamma = 2.7;
659  double A = 0.14;
660  double rc = 1.e-4; // fraction of prompt muons
661  double c1 = sqrt(1. - (1. - pow(ct, 2.0)) / pow((1. + 32. / 6370.), 2.0)); // Earth curvature
662  double deltae = 2.06e-3 * (1030. / c1 - 120.); // muon energy loss in atmosphere
663  double em = e + deltae / 2.;
664  double e1 = e + deltae;
665  double pdec = pow((120. / (1030. / c1)), (1.04 / c1 / em)); // muon decay
666  di = A * pow(e1, -gamma) *
667  (1. / (1. + 1.1 * e1 * c1 / 115.) + 0.054 / (1. + 1.1 * e1 * c1 / 850.) + rc) * pdec;
668  }
669  else {
670  double gamma = 2.7; // spectral index
671  double A = 0.14; // normalisation
672  double C = 3.64;
673  double gamma2 = 1.29;
674  double ct_star = sqrt((pow(ct, 2) + 0.102573 * 0.102573 - 0.068287 * pow(ct, 0.958633) +
675  0.0407253 * pow(ct, 0.817285)) /
676  (1.0 + 0.102573 * 0.102573 - 0.068287 + 0.0407253));
677  double eMod = e * (1.0 + C / (e * pow(ct_star, gamma2)));
678  di = A * pow(eMod, -gamma) *
679  (1. / (1. + 1.1 * e * ct_star / 115.) + 0.054 / (1. + 1.1 * e * ct_star / 850.));
680  }
681 
682  return di;
683  } // GaisserFlux
TCanvas * c1
Definition: plotHisto.C:7
bool fSetParam
Which version of Gaissers Param.
Float_t e
Definition: plot.C:35
double evgen::GaisserParam::GaisserMuonFlux_Integrand ( Double_t *  x,
Double_t *  par 
)
private

Definition at line 686 of file GaisserParam_module.cc.

References GaisserFlux().

Referenced by MakePDF().

687  {
688 
689  //---- calculate the flux
690  double flux = 2.0 * M_PI * sin(x[1]) * GaisserFlux(x[0], x[1]);
691 
692  return flux;
693  } // MuonFluxIntegrand
Float_t x
Definition: compare.C:6
double GaisserFlux(double e, double theta)
std::vector< double > evgen::GaisserParam::GetBinning ( const TAxis *  axis,
bool  finalEdge = true 
)
private

Definition at line 696 of file GaisserParam_module.cc.

Referenced by MakePDF().

697  {
698  std::vector<double> vbins;
699  for (int ibin = 1; ibin <= axis->GetNbins() + 1; ibin++) {
700  if (ibin <= axis->GetNbins())
701  vbins.push_back(axis->GetBinLowEdge(ibin));
702  else if (finalEdge)
703  vbins.push_back(axis->GetBinLowEdge(ibin) + axis->GetBinWidth(ibin));
704  }
705  return vbins;
706  } // Get Binning
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::pair< double, double > evgen::GaisserParam::GetThetaAndEnergy ( double  rand1,
double  rand2 
)
private

Definition at line 384 of file GaisserParam_module.cc.

References energy, m_PDFmap, and m_thetaHist.

Referenced by SampleOne().

385  {
386  if (rand1 < 0 || rand1 > 1)
387  std::cerr << "GetThetaAndEnergy:\tInvalid random number " << rand1 << std::endl;
388  if (rand2 < 0 || rand2 > 1)
389  std::cerr << "GetThetaAndEnergy:\tInvalid random number " << rand2 << std::endl;
390 
391  int thetaBin = 0;
392  m_thetaHist->GetBinWithContent(double(rand1), thetaBin, 1, m_thetaHist->GetNbinsX(), 1.0);
393  if (m_thetaHist->GetBinContent(thetaBin) < rand1) thetaBin += 1;
394  double drand1 =
395  (m_thetaHist->GetBinContent(thetaBin) - rand1) /
396  (m_thetaHist->GetBinContent(thetaBin) - m_thetaHist->GetBinContent(thetaBin - 1));
397  double thetaLow = m_thetaHist->GetXaxis()->GetBinLowEdge(thetaBin);
398  double thetaUp = m_thetaHist->GetXaxis()->GetBinUpEdge(thetaBin);
399  double theta = drand1 * (thetaUp - thetaLow) + thetaLow;
400 
401  int energyBin = 0;
402  TH1* energyHist = 0;
403  bool notFound = true;
404  for (dhist_Map_it mapit = m_PDFmap->begin(); mapit != m_PDFmap->end(); mapit++) {
405  if (fabs(mapit->first + thetaLow) < 0.000001) {
406  energyHist = mapit->second;
407  notFound = false;
408  break;
409  }
410  }
411  if (notFound) std::cout << "GetThetaAndEnergy: ERROR:\tInvalid theta!" << std::endl;
412  // MSG("string = " << To_TString(thetaLow) << ", double = " << thetaLow );
413 
414  energyHist->GetBinWithContent(double(rand2), energyBin, 1, energyHist->GetNbinsX(), 1.0);
415  if (energyHist->GetBinContent(energyBin) < rand2) energyBin += 1;
416  double drand2 =
417  (energyHist->GetBinContent(energyBin) - rand2) /
418  (energyHist->GetBinContent(energyBin) - energyHist->GetBinContent(energyBin - 1));
419  double energyLow = energyHist->GetXaxis()->GetBinLowEdge(energyBin);
420  double energyUp = energyHist->GetXaxis()->GetBinUpEdge(energyBin);
421  double energy = drand2 * (energyUp - energyLow) + energyLow;
422  // MSG("MuFlux::GetThetaEnergy()\te = " << energy*1000. );
423 
424  return std::make_pair(theta, energy);
425  }
double energy
Definition: plottest35.C:25
std::map< double, TH1 * >::iterator dhist_Map_it
void evgen::GaisserParam::MakePDF ( )
private

Definition at line 428 of file GaisserParam_module.cc.

References fEBinsHigh, fEBinsLow, fEmax, fEmid, fEmin, fEpsilon, fInputDir, fSetRead, fSetReWrite, fSetWrite, fThetaBins, fThetamax, fThetamin, GaisserMuonFlux_Integrand(), GetBinning(), m_File, m_PDFmap, m_thetaHist, and ResetMap().

Referenced by beginRun().

429  {
430  std::cout << "In my function MakePDF" << std::endl;
431  m_File = 0;
432  m_PDFmap = 0;
433  m_thetaHist = 0;
434  double TotalMuonFlux = 0;
435 
436  if (m_PDFmap) {
437  std::cout << "PDFMAP" << std::endl;
438  if (m_PDFmap->size() > 0 && !fSetReWrite) {
439  std::cout << "MakePDF: Map has already been initialised. " << std::endl;
440  std::cout << "Do fSetReWrite - true if you really want to override this map." << std::endl;
441  return;
442  }
443  std::cout << fSetReWrite << std::endl;
444  if (fSetReWrite) ResetMap();
445  }
446  else {
447  m_PDFmap = new dhist_Map;
448  std::cout << "Making new dhist_Map called m_PDFmap....." << std::endl;
449  }
450 
451  TF2* muonSpec = new TF2("muonSpec",
452  this,
454  fEmin,
455  fEmax,
456  fThetamin,
457  fThetamax,
458  0,
459  "GaisserParam",
460  "GaisserMuonFlux_Integrand");
461  //--------------------------------------------
462  //------------ Compute the pdfs
463 
464  //---- compute pdf for the theta
465  TotalMuonFlux = muonSpec->Integral(
466  fEmin, fEmax, fThetamin, fThetamax, fEpsilon); // Work out the muon flux at the surface
467  std::cout << "Surface flux of muons = " << TotalMuonFlux << " cm-2 s-1" << std::endl;
468 
469  //---- work out if we're reading a file, writing to file, or neither
470  std::ostringstream pdfFile;
471  pdfFile << "GaisserPDF_" << fEmin << "-" << fEmid << "-" << fEmax << "-" << fEBinsLow << "-"
472  << fEBinsHigh << "-" << fThetamin << "-" << fThetamax << "-" << fThetaBins << ".root";
473  std::string tmpfileName = pdfFile.str();
474  std::replace(tmpfileName.begin(), tmpfileName.end(), '+', '0');
475  if (tmpfileName == "GaisserPDF_0-100-100100-1000-10000-0-1.5708-100.root")
476  tmpfileName = "GaisserPDF_DefaultBins.root";
477  else if (tmpfileName == "GaisserPDF_0-100-4000-1000-1000-0-1.5708-100.root")
478  tmpfileName = "GaisserPDF_LowEnergy.root";
479  else if (tmpfileName == "GaisserPDF_4000-10000-100000-1000-10000-0-1.5708-100.root")
480  tmpfileName = "GaisserPDF_MidEnergy.root";
481  else if (tmpfileName == "GaisserPDF_100000-500000-1e007-10000-100000-0-1.5708-100.root")
482  tmpfileName = "GaisserPDF_HighEnergy.root";
483 
484  std::ostringstream pdfFilePath;
485  pdfFilePath << fInputDir << tmpfileName;
486  std::string fileName = pdfFilePath.str();
487 
488  cet::search_path sp("FW_SEARCH_PATH");
489  std::string fROOTfile; //return /lbne/data/0-100-1.57.root
490  if (sp.find_file(tmpfileName, fROOTfile)) fileName = fROOTfile;
491 
492  std::cout << "File path; " << fileName << std::endl;
493 
494  if (fSetRead) {
495  struct stat buffer;
496  fSetRead = stat(fileName.c_str(), &buffer) == 0; // Check if file exists already
497  if (!fSetRead)
498  std::cout << "WARNING- " + fileName + " does not exist." << std::endl;
499  else {
500  std::cout << "Reading PDF from file " + fileName << std::endl;
501  m_File = new TFile(fileName.c_str()); // Open file
502  if (m_File->IsZombie() ||
503  m_File->TestBit(TFile::kRecovered)) { // Check that file is not corrupted
504  std::cout << "WARNING- " + fileName + " is corrupted or cannot be read." << std::endl;
505  fSetRead = false;
506  }
507  }
508  }
509 
510  if (fSetRead) { // If the file exists then read it....
511  std::cout << "Now going to read file...." << std::endl;
512  fSetWrite = false; // Don't want to write as already exists
513  double thetalow = fThetamin;
514  m_thetaHist = (TH1D*)m_File->Get("pdf_theta");
515  for (int i = 1; i <= fThetaBins; i++) {
516  std::ostringstream pdfEnergyHist;
517  pdfEnergyHist << "pdf_energy_" << i;
518  std::string pdfEnergyHiststr = pdfEnergyHist.str();
519 
520  TH1* pdf_hist = (TH1D*)m_File->Get(pdfEnergyHiststr.c_str()); // Get the bin
521  m_PDFmap->insert(std::make_pair(-thetalow, pdf_hist)); //---- -ve theta for quicker sorting
522  thetalow = double(i) * (fThetamax) / double(fThetaBins); //---- increment the value of theta
523  }
524  } // ------------------------------------------
525  else { // File doesn't exist so want to make it.....
526  // ------------------------------------------
527  std::cout << "Generating a new muon flux PDF" << std::endl;
528  if (fSetWrite) {
529  std::cout << "Writing to PDF to file " + fileName << std::endl;
530  m_File = new TFile(fileName.c_str(), "RECREATE");
531  }
532 
533  double dnbins_theta = double(fThetaBins);
534  m_thetaHist = new TH1D("pdf_theta", "pdf_theta", fThetaBins, fThetamin, fThetamax);
535  for (int i = 1; i <= fThetaBins; i++) {
536  double di = i == 0 ? 0.1 : double(i);
537  double theta = di * (fThetamax) / dnbins_theta;
538  double int_i = muonSpec->Integral(fEmin, fEmax, fThetamin, theta, fEpsilon);
539  m_thetaHist->SetBinContent(i, int_i / TotalMuonFlux);
540  }
541  if (fSetWrite) m_thetaHist->Write();
542  std::cout
543  << "theta PDF complete... now making the energy PDFs (this will take a little longer)... "
544  << std::endl;
545 
546  //---- now compute the energy pdf
547  double thetalow = fThetamin;
548  for (int i = 1; i <= fThetaBins; i++) {
549 
550  double di = double(i);
551  double theta = di * (fThetamax) / fThetaBins;
552 
553  //---- compute the total integral
554  double int_tot = muonSpec->Integral(fEmin, fEmax, thetalow, theta, fEpsilon);
555 
556  //---- compute pdf for the low energy
557  int nbins = fEBinsLow;
558  TH1* pdf_lowenergy = new TH1D("pdf_lowenergy", "pdf_lowenergy", nbins, fEmin, fEmid);
559  double dnbins = double(nbins);
560  for (int j = 1; j <= nbins; j++) {
561  double dj = double(j);
562  double int_j = muonSpec->Integral(
563  fEmin, fEmin + dj * (fEmid - fEmin) / dnbins, thetalow, theta, fEpsilon);
564  pdf_lowenergy->SetBinContent(j, int_j / int_tot);
565  }
566 
567  //---- compute pdf for the high energy
568  nbins = fEBinsHigh;
569  dnbins = double(nbins);
570  TH1* pdf_highenergy = new TH1D("pdf_highenergy", "pdf_highenergy", nbins, fEmid, fEmax);
571  for (int j = 1; j <= nbins; j++) {
572  double dj = double(j);
573  double int_j = muonSpec->Integral(
574  fEmin, fEmid + dj * (fEmax - fEmid) / dnbins, thetalow, theta, fEpsilon);
575  pdf_highenergy->SetBinContent(j, int_j / int_tot);
576  }
577 
578  //---- now combine the two energy hists
579  std::vector<double> vxbins = GetBinning(pdf_lowenergy->GetXaxis(), false);
580  std::vector<double> vxbins2 = GetBinning(pdf_highenergy->GetXaxis());
581  vxbins.insert(vxbins.end(), vxbins2.begin(), vxbins2.end());
582 
583  int ibin = 0;
584  double* xbins = new double[vxbins.size()];
585  for (std::vector<double>::const_iterator binit = vxbins.begin(); binit != vxbins.end();
586  binit++, ibin++)
587  xbins[ibin] = (*binit);
588  TH1* pdf_energy = new TH1D("pdf_energy", "pdf_energy", vxbins.size() - 1, xbins);
589  int ibin2 = 1;
590  for (ibin = 1; ibin <= pdf_lowenergy->GetNbinsX(); ibin++, ibin2++) {
591  double content = pdf_lowenergy->GetBinContent(ibin);
592  if (ibin == 1) content = content - 0.00001;
593  pdf_energy->Fill(pdf_energy->GetBinCenter(ibin2), content);
594  }
595  for (ibin = 1; ibin <= pdf_highenergy->GetNbinsX(); ibin++, ibin2++) {
596  pdf_energy->Fill(pdf_energy->GetBinCenter(ibin2), pdf_highenergy->GetBinContent(ibin));
597  }
598 
599  //---- and remove any negative bins
600  std::ostringstream Clonestr;
601  Clonestr << "pdf_energy_" << i;
602  TH1* pdf_energy_noneg = (TH1D*)pdf_energy->Clone(Clonestr.str().c_str());
603  pdf_energy_noneg->Reset();
604 
605  double PDF = 0.0;
606  double lastPD = 0.0;
607  int nSkip = 0;
608  for (ibin = 1; ibin <= pdf_energy->GetNbinsX(); ibin++) {
609  double newPD = pdf_energy->GetBinContent(ibin);
610  double probDiff = newPD - lastPD;
611  if (probDiff < 0) {
612  if (ibin != pdf_energy->GetNbinsX()) {
613  nSkip++;
614  continue;
615  }
616  else
617  probDiff = 0;
618  }
619  else
620  PDF += probDiff;
621  if (PDF > 1) PDF = 1;
622  for (int iskip = 0; iskip <= nSkip; iskip++)
623  pdf_energy_noneg->Fill(pdf_energy_noneg->GetBinCenter(ibin - iskip), PDF);
624  nSkip = 0;
625  lastPD = newPD;
626  }
627 
628  //---- add this hist, increment thetalow and delete unwanted TH1s
629  if (fSetWrite) pdf_energy_noneg->Write();
630  m_PDFmap->insert(
631  std::make_pair(-thetalow, pdf_energy_noneg)); //---- -ve theta for quicker sorting
632 
633  //---- increment the value of theta
634  thetalow = theta;
635 
636  //---- free up memory from unwanted hists
637  delete pdf_lowenergy;
638  delete pdf_highenergy;
639  delete pdf_energy;
640 
641  std::cout << "\r===> " << 100.0 * double(i) / double(fThetaBins) << "% complete... "
642  << std::endl;
643  } // ThetaBins
644  std::cout << "finished the energy pdfs." << std::endl;
645  } //---- if(!m_doRead)
646 
647  delete muonSpec;
648  return;
649  } // Make PDF
double fEpsilon
Minimum integration sum....
double fThetamax
Maximum theta.
int fThetaBins
Number of theta Bins.
double fEmid
Energy to go from low to high (GeV)
bool fSetReWrite
Whether to ReWrite pdfs.
intermediate_table::const_iterator const_iterator
std::string fInputDir
Input Directory.
int fEBinsLow
Number of low energy Bins.
std::map< double, TH1 * > dhist_Map
double fEmin
Minimum Kinetic Energy (GeV)
std::vector< double > GetBinning(const TAxis *axis, bool finalEdge=true)
double fEmax
Maximum Kinetic Energy (GeV)
int fEBinsHigh
Number of high energy Bins.
bool fSetRead
Whether to Read.
double fThetamin
Minimum theta.
double GaisserMuonFlux_Integrand(Double_t *x, Double_t *par)
bool fSetWrite
Whether to Write.
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void evgen::GaisserParam::produce ( art::Event evt)
overrideprivatevirtual

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

Implements art::EDProducer.

Definition at line 241 of file GaisserParam_module.cc.

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

242  {
244  std::unique_ptr<std::vector<simb::MCTruth>> truthcol(new std::vector<simb::MCTruth>);
245 
246  simb::MCTruth truth;
248 
249  Sample(truth, fEngine);
250 
251  MF_LOG_DEBUG("GaisserParam") << truth;
252 
253  truthcol->push_back(truth);
254 
255  evt.put(std::move(truthcol));
256  }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
single particles thrown at the detector
Definition: MCTruth.h:26
void Sample(simb::MCTruth &mct, CLHEP::HepRandomEngine &engine)
#define MF_LOG_DEBUG(id)
Event generator information.
Definition: MCTruth.h:32
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void evgen::GaisserParam::ResetMap ( )
private

Definition at line 709 of file GaisserParam_module.cc.

References DEFINE_ART_MODULE, m_PDFmap, and m_thetaHist.

Referenced by MakePDF().

710  {
711  if (m_thetaHist) delete m_thetaHist;
712  if (m_PDFmap) {
713  for (dhist_Map_it mapit = m_PDFmap->begin(); mapit != m_PDFmap->end(); mapit++) {
714  if (mapit->second) delete mapit->second;
715  }
716  m_PDFmap->clear();
717  delete m_PDFmap;
718  std::cout << "Reset PDFmap and thetaHist..." << std::endl;
719  }
720  } // ResetMap
std::map< double, TH1 * >::iterator dhist_Map_it
void evgen::GaisserParam::Sample ( simb::MCTruth mct,
CLHEP::HepRandomEngine &  engine 
)
private

Definition at line 357 of file GaisserParam_module.cc.

References fMode, fPDG, and SampleOne().

Referenced by produce().

358  {
359  switch (fMode) {
360  case 0: // List generation mode: every event will have one of each
361  // particle species in the fPDG array
362  for (unsigned int i = 0; i < fPDG.size(); ++i) {
363  SampleOne(i, mct, engine);
364  } //end loop over particles
365  break;
366  case 1: // Random selection mode: every event will exactly one particle
367  // selected randomly from the fPDG array
368  {
369  CLHEP::RandFlat flat(engine);
370 
371  unsigned int i = flat.fireInt(fPDG.size());
372  SampleOne(i, mct, engine);
373  } break;
374  default:
375  mf::LogWarning("UnrecognizeOption")
376  << "GaisserParam does not recognize ParticleSelectionMode " << fMode;
377  break;
378  } // switch on fMode
379 
380  return;
381  }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< int > fPDG
PDG code of particles to generate.
void SampleOne(unsigned int i, simb::MCTruth &mct, CLHEP::HepRandomEngine &engine)
void evgen::GaisserParam::SampleOne ( unsigned int  i,
simb::MCTruth mct,
CLHEP::HepRandomEngine &  engine 
)
private

Definition at line 261 of file GaisserParam_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), DirCosineX, DirCosineY, DirCosineZ, Energy, fCenterX, fCenterZ, fCharge, fPDG, fSigmaT, fT0, fTDist, fTree, fXHalfRange, fYInput, fZHalfRange, Gamma, GetThetaAndEnergy(), kGAUS, KinEnergy, m_PDFmap, Momentum, part, Phi, pnorm, Theta, Time, x, XPosition, YPosition, and ZPosition.

Referenced by Sample().

262  {
263 
264  CLHEP::RandFlat flat(engine);
265  CLHEP::RandGaussQ gauss(engine);
266 
267  Time = Momentum = KinEnergy = Gamma = Energy = Theta = Phi = pnorm = 0.0;
269 
270  TVector3 x;
271  TVector3 pmom;
272 
273  // set track id to -i as these are all primary particles and have id <= 0
274  int trackid = -1 * (i + 1);
275  std::string primary("primary");
276 
277  // Work out whether particle/antiparticle, and mass...
278  double m = 0.0;
279  fPDG[i] = 13;
280  if (fCharge == 0) {
281  if (1.0 - 2.0 * flat.fire() > 0) fPDG[i] = -fPDG[i];
282  }
283  else if (fCharge == 1)
284  fPDG[i] = 13;
285  else if (fCharge == 2)
286  fPDG[i] = -13;
287  static TDatabasePDG pdgt;
288  TParticlePDG* pdgp = pdgt.GetParticle(fPDG[i]);
289  if (pdgp) m = pdgp->Mass();
290 
291  // Work out T0...
292  if (fTDist == kGAUS) { Time = gauss.fire(fT0, fSigmaT); }
293  else {
294  Time = fT0 + fSigmaT * (2.0 * flat.fire() - 1.0);
295  }
296 
297  // Work out Positioning.....
298  x[0] = (1.0 - 2.0 * flat.fire()) * fXHalfRange + fCenterX;
299  x[1] = fYInput;
300  x[2] = (1.0 - 2.0 * flat.fire()) * fZHalfRange + fCenterZ;
301 
302  // Make Lorentz vector for x and t....
303  TLorentzVector pos(x[0], x[1], x[2], Time);
304 
305  // Access the pdf map which has been loaded.....
306  if (m_PDFmap) {
307 
308  //---- get the muon theta and energy from histograms using 2 random numbers
309  std::pair<double, double> theta_energy; //---- muon theta and energy
310  theta_energy = GetThetaAndEnergy(flat.fire(), flat.fire());
311 
312  //---- Set theta, phi
313  Theta = theta_energy.first; // Angle returned by GetThetaAndEnergy between 0 and pi/2
314  Phi = M_PI * (1.0 - 2.0 * flat.fire()); // Randomly generated angle between -pi and pi
315 
316  //---- Set KE, E, p
317  KinEnergy = theta_energy.second; // Energy returned by GetThetaAndEnergy
318  Gamma = 1 + (KinEnergy / m);
319  Energy = Gamma * m;
320  Momentum = std::sqrt(Energy * Energy - m * m); // Get momentum
321 
322  pmom[0] = Momentum * std::sin(Theta) * std::cos(Phi);
323  pmom[1] = -Momentum * std::cos(Theta);
324  pmom[2] = Momentum * std::sin(Theta) * std::sin(Phi);
325 
326  pnorm = std::sqrt(pmom[0] * pmom[0] + pmom[1] * pmom[1] + pmom[2] * pmom[2]);
327  DirCosineX = pmom[0] / pnorm;
328  DirCosineY = pmom[1] / pnorm;
329  DirCosineZ = pmom[2] / pnorm;
330  }
331  else {
332  std::cout << "MuFlux map hasn't been initialised, aborting...." << std::endl;
333  return;
334  }
335 
336  TLorentzVector pvec(pmom[0], pmom[1], pmom[2], Energy);
337 
338  simb::MCParticle part(trackid, fPDG[i], primary);
339  part.AddTrajectoryPoint(pos, pvec);
340  XPosition = x[0];
341  YPosition = x[1];
342  ZPosition = x[2];
343 
344  std::cout << "Theta: " << Theta << " Phi: " << Phi << " KineticEnergy: " << KinEnergy
345  << " Energy: " << Energy << " Momentum: " << Momentum << std::endl;
346  std::cout << "x: " << pos.X() << " y: " << pos.Y() << " z: " << pos.Z() << " time: " << pos.T()
347  << std::endl;
348  std::cout << "Px: " << pvec.Px() << " Py: " << pvec.Py() << " Pz: " << pvec.Pz() << std::endl;
349  std::cout << "Normalised..." << DirCosineX << " " << DirCosineY << " " << DirCosineZ
350  << std::endl;
351 
352  fTree->Fill();
353  mct.Add(part);
354  }
Float_t x
Definition: compare.C:6
static constexpr int kGAUS
double fYInput
Max Y position.
TString part[npart]
Definition: Style.C:32
double fSigmaT
Variation in t position (ns)
double fXHalfRange
Max X position.
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
std::vector< int > fPDG
PDG code of particles to generate.
int fTDist
How to distribute t (gaus, or uniform)
double fT0
Central t position (ns) in world coordinates.
std::pair< double, double > GetThetaAndEnergy(double rand1, double rand2)
double fZHalfRange
Max Z position.
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

double evgen::GaisserParam::DirCosineX
private

Definition at line 140 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::DirCosineY
private

Definition at line 140 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::DirCosineZ
private

Definition at line 140 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::Energy
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::fCenterX = 0
private

Definition at line 134 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::fCenterZ = 0
private

Definition at line 135 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

int evgen::GaisserParam::fCharge
private

Charge.

Definition at line 101 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

double evgen::GaisserParam::fCryoBoundaries[6]
private

Definition at line 129 of file GaisserParam_module.cc.

Referenced by beginJob().

int evgen::GaisserParam::fEBinsHigh
private

Number of high energy Bins.

Definition at line 108 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

int evgen::GaisserParam::fEBinsLow
private

Number of low energy Bins.

Definition at line 107 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

double evgen::GaisserParam::fEmax
private

Maximum Kinetic Energy (GeV)

Definition at line 105 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

double evgen::GaisserParam::fEmid
private

Energy to go from low to high (GeV)

Definition at line 106 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

double evgen::GaisserParam::fEmin
private

Minimum Kinetic Energy (GeV)

Definition at line 104 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

CLHEP::HepRandomEngine& evgen::GaisserParam::fEngine
private

art-managed random-number engine

Definition at line 89 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and produce().

double evgen::GaisserParam::fEpsilon
private

Minimum integration sum....

Definition at line 126 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

std::string evgen::GaisserParam::fInputDir
private

Input Directory.

Definition at line 102 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

int evgen::GaisserParam::fMode
private

Particle Selection Mode 0–generate a list of all particles, 1–generate a single particle selected randomly from the list

Definition at line 93 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and Sample().

bool evgen::GaisserParam::fPadOutVectors
private

Select to pad out configuration vectors if they are not of of the same length as PDG false: don't pad out - all values need to specified true: pad out - default values assumed and printed out

Definition at line 96 of file GaisserParam_module.cc.

Referenced by GaisserParam().

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

PDG code of particles to generate.

Definition at line 100 of file GaisserParam_module.cc.

Referenced by GaisserParam(), Sample(), and SampleOne().

bool evgen::GaisserParam::fSetParam
private

Which version of Gaissers Param.

Definition at line 122 of file GaisserParam_module.cc.

Referenced by GaisserFlux(), and GaisserParam().

bool evgen::GaisserParam::fSetRead
private

Whether to Read.

Definition at line 123 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

bool evgen::GaisserParam::fSetReWrite
private

Whether to ReWrite pdfs.

Definition at line 125 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

bool evgen::GaisserParam::fSetWrite
private

Whether to Write.

Definition at line 124 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

double evgen::GaisserParam::fSigmaT
private

Variation in t position (ns)

Definition at line 119 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

double evgen::GaisserParam::fT0
private

Central t position (ns) in world coordinates.

Definition at line 118 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

int evgen::GaisserParam::fTDist
private

How to distribute t (gaus, or uniform)

Definition at line 120 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

int evgen::GaisserParam::fThetaBins
private

Number of theta Bins.

Definition at line 112 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and MakePDF().

double evgen::GaisserParam::fThetamax
private

Maximum theta.

Definition at line 111 of file GaisserParam_module.cc.

Referenced by beginRun(), GaisserParam(), and MakePDF().

double evgen::GaisserParam::fThetamin
private

Minimum theta.

Definition at line 110 of file GaisserParam_module.cc.

Referenced by beginRun(), GaisserParam(), and MakePDF().

TTree* evgen::GaisserParam::fTree
private

Definition at line 138 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::fXHalfRange
private

Max X position.

Definition at line 114 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

double evgen::GaisserParam::fYInput
private

Max Y position.

Definition at line 115 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

double evgen::GaisserParam::fZHalfRange
private

Max Z position.

Definition at line 116 of file GaisserParam_module.cc.

Referenced by GaisserParam(), and SampleOne().

double evgen::GaisserParam::Gamma
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by SampleOne().

constexpr int evgen::GaisserParam::kGAUS = 1
staticprivate

Definition at line 91 of file GaisserParam_module.cc.

Referenced by SampleOne().

double evgen::GaisserParam::KinEnergy
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

TFile* evgen::GaisserParam::m_File
private

Definition at line 75 of file GaisserParam_module.cc.

Referenced by MakePDF().

dhist_Map* evgen::GaisserParam::m_PDFmap
private

Definition at line 76 of file GaisserParam_module.cc.

Referenced by GetThetaAndEnergy(), MakePDF(), ResetMap(), and SampleOne().

TH1* evgen::GaisserParam::m_thetaHist
private

Definition at line 77 of file GaisserParam_module.cc.

Referenced by GetThetaAndEnergy(), MakePDF(), and ResetMap().

double evgen::GaisserParam::Momentum
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::Phi
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::pnorm
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by SampleOne().

double evgen::GaisserParam::Theta
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::Time
private

Definition at line 139 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::xNeg = 0
private

Definition at line 130 of file GaisserParam_module.cc.

Referenced by beginJob().

double evgen::GaisserParam::xPos = 0
private

Definition at line 131 of file GaisserParam_module.cc.

Referenced by beginJob().

double evgen::GaisserParam::XPosition
private

Definition at line 140 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::YPosition
private

Definition at line 140 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().

double evgen::GaisserParam::zNeg = 0
private

Definition at line 132 of file GaisserParam_module.cc.

Referenced by beginJob().

double evgen::GaisserParam::zPos = 0
private

Definition at line 133 of file GaisserParam_module.cc.

Referenced by beginJob().

double evgen::GaisserParam::ZPosition
private

Definition at line 140 of file GaisserParam_module.cc.

Referenced by beginJob(), and SampleOne().


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