10 #ifndef EVGEN_SINGLEGEN 11 #define EVGEN_SINGLEGEN 29 #include "art_root_io/TFileService.h" 30 #include "art_root_io/TFileDirectory.h" 34 #include "cetlib_except/exception.h" 41 #include "nugen/EventGeneratorBase/evgenbase.h" 42 #include "nurandom/RandomUtils/NuRandomService.h" 47 #include "CoreUtils/ServiceUtil.h" 50 #include "TDatabasePDG.h" 53 #include "CLHEP/Random/RandFlat.h" 54 #include "CLHEP/Random/RandGaussQ.h" 56 namespace simb {
class MCTruth; }
75 void SampleOne(
unsigned int i,
78 void printVecs(std::vector<std::string>
const& list);
79 bool PadVector(std::vector<double> &vec);
81 static const int kUNIF = 0;
82 static const int kGAUS = 1;
92 std::vector<double>
fP0;
95 std::vector<double>
fX0;
96 std::vector<double>
fY0;
97 std::vector<double>
fZ0;
98 std::vector<double>
fT0;
117 art::EDProducer{pset},
123 produces< std::vector<simb::MCTruth> >();
124 produces< sumdata::RunData, ::art::InRun >();
138 fMode = p.
get<
int >(
"ParticleSelectionMode");
139 fPDG = p.
get< std::vector<int> >(
"PDG");
140 fP0 = p.
get< std::vector<double> >(
"P0");
141 fSigmaP = p.
get< std::vector<double> >(
"SigmaP");
144 fX0 = p.
get< std::vector<double> >(
"X0");
145 fY0 = p.
get< std::vector<double> >(
"Y0");
146 fZ0 = p.
get< std::vector<double> >(
"Z0");
147 fT0 = p.
get< std::vector<double> >(
"T0");
148 fSigmaX = p.
get< std::vector<double> >(
"SigmaX");
149 fSigmaY = p.
get< std::vector<double> >(
"SigmaY");
150 fSigmaZ = p.
get< std::vector<double> >(
"SigmaZ");
151 fSigmaT = p.
get< std::vector<double> >(
"SigmaT");
159 std::vector<std::string> vlist(15);
169 vlist[9] =
"Theta0XZ";
170 vlist[10] =
"Theta0YZ";
171 vlist[11] =
"SigmaThetaXZ";
172 vlist[12] =
"SigmaThetaYZ";
174 vlist[14] =
"SigmaT";
179 if( !this->
PadVector(fP0 ) ) list.append(vlist[1] .append(
", \n"));
180 if( !this->
PadVector(fSigmaP ) ) list.append(vlist[2] .append(
", \n"));
181 if( !this->
PadVector(fX0 ) ) list.append(vlist[3] .append(
", \n"));
182 if( !this->
PadVector(fY0 ) ) list.append(vlist[4] .append(
", \n"));
183 if( !this->
PadVector(fZ0 ) ) list.append(vlist[5] .append(
", \n"));
184 if( !this->
PadVector(fSigmaX ) ) list.append(vlist[6] .append(
", \n"));
185 if( !this->
PadVector(fSigmaY ) ) list.append(vlist[7] .append(
", \n"));
186 if( !this->
PadVector(fSigmaZ ) ) list.append(vlist[8] .append(
", \n"));
187 if( !this->
PadVector(fTheta0XZ ) ) list.append(vlist[9] .append(
", \n"));
188 if( !this->
PadVector(fTheta0YZ ) ) list.append(vlist[10].append(
", \n"));
189 if( !this->
PadVector(fSigmaThetaXZ) ) list.append(vlist[11].append(
", \n"));
190 if( !this->
PadVector(fSigmaThetaYZ) ) list.append(vlist[12].append(
" \n"));
191 if( !this->
PadVector(fT0 ) ) list.append(vlist[13].append(
", \n"));
192 if( !this->
PadVector(fSigmaT ) ) list.append(vlist[14].append(
", \n"));
196 <<
"\n vector(s) defined in the fhicl files has/have " 197 <<
"a different size than the PDG vector " 198 <<
"\n and it has (they have) more than one value, " 199 <<
"\n disallowing sensible padding " 200 <<
" and/or you have set fPadOutVectors to false. \n";
211 if( vec.size() !=
fPDG.size() ){
223 if(vec.size() != 1)
return false;
226 vec.resize(
fPDG.size(), vec[0]);
239 auto geo = gar::providerFrom<geo::GeometryGAr>();
253 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
261 truthcol->push_back(truth);
285 p =
fP0[i] +
fSigmaP[i]*(2.0*flat.fire()-1.0);
288 static TDatabasePDG pdgt;
289 TParticlePDG* pdgp = pdgt.GetParticle(
fPDG[i]);
290 if (pdgp) m = pdgp->Mass();
300 x[0] =
fX0[i] +
fSigmaX[i]*(2.0*flat.fire()-1.0);
301 x[1] =
fY0[i] +
fSigmaY[i]*(2.0*flat.fire()-1.0);
302 x[2] =
fZ0[i] +
fSigmaZ[i]*(2.0*flat.fire()-1.0);
310 t =
fT0[i] +
fSigmaT[i]*(2.0*flat.fire()-1.0);
313 TLorentzVector
pos(x[0], x[1], x[2], t);
320 double thyzradsplussigma = 0;
321 double thyzradsminussigma = 0;
339 double sinthyzmin = std::sin(thyzradsminussigma);
340 double sinthyzmax = std::sin(thyzradsplussigma);
341 double sinthyz = sinthyzmin + flat.fire() * (sinthyzmax - sinthyzmin);
342 thyz = (180. /
M_PI) * std::asin(sinthyz);
345 double thxzrad = thxz*
M_PI/180.0;
346 double thyzrad = thyz*
M_PI/180.0;
348 TLorentzVector pvec(p*std::cos(thyzrad)*std::sin(thxzrad),
350 p*std::cos(thxzrad)*std::cos(thyzrad),
354 int trackid = -1 * (i + 1);
370 for (
unsigned int i=0; i<
fPDG.size(); ++i) {
379 unsigned int i=flat.fireInt(
fPDG.size());
385 <<
"SingleGen does not recognize ParticleSelectionMode " 398 <<
" You are using vector values for SingleGen configuration.\n " 399 <<
" Some of the configuration vectors may have been padded out ," 400 <<
" because they (weren't) as long as the pdg vector" 401 <<
" in your configuration. \n" 402 <<
" The new input particle configuration is:\n" ;
405 for(
size_t i = 0; i < list.size(); ++i){
407 values.append(list[i]);
408 values.append(
": [ ");
410 for(
size_t e = 0;
e <
fPDG.size(); ++
e){
411 std::stringstream buf;
413 if(i == 0 ) buf <<
fPDG[
e] <<
", ";
415 if(i == 1 ) buf <<
fP0[
e] <<
", ";
416 if(i == 2 ) buf <<
fSigmaP[
e] <<
", ";
417 if(i == 3 ) buf <<
fX0[
e] <<
", ";
418 if(i == 4 ) buf <<
fY0[
e] <<
", ";
419 if(i == 5 ) buf <<
fZ0[
e] <<
", ";
420 if(i == 6 ) buf <<
fSigmaX[
e] <<
", ";
421 if(i == 7 ) buf <<
fSigmaY[
e] <<
", ";
422 if(i == 8 ) buf <<
fSigmaZ[
e] <<
", ";
427 if(i == 13) buf <<
fT0[
e] <<
", ";
428 if(i == 14) buf <<
fSigmaT[
e] <<
", ";
429 values.append(buf.str());
432 values.erase(values.find_last_of(
","));
433 values.append(
" ] \n");
base_engine_t & createEngine(seed_t seed)
module to produce single or multiple specified particles in the detector
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void SetOrigin(simb::Origin_t origin)
void Sample(simb::MCTruth &mct)
std::vector< double > fZ0
Central z position (cm) in world coordinates.
std::vector< double > fTheta0YZ
Angle in YZ plane (degrees)
int fTDist
How to distribute t (gaus, or uniform)
void beginRun(::art::Run &run)
int fAngleDist
How to distribute angles (gaus, uniform)
std::vector< double > fY0
Central y position (cm) in world coordinates.
#define DEFINE_ART_MODULE(klass)
std::vector< int > fPDG
PDG code of particles to generate.
virtual void reconfigure(fhicl::ParameterSet const &pset)
CLHEP::HepRandomEngine & fEngine
single particles thrown at the detector
T get(std::string const &key) const
std::vector< double > fT0
Central t position (s) in world coordinates.
int fPDist
How to distribute momenta (gaus or uniform)
std::vector< double > fSigmaZ
Variation in z position (cm)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< double > fSigmaThetaYZ
Variation in angle in YZ plane.
#define MF_LOG_INFO(category)
Base utilities and modules for event generation and detector simulation.
void SampleOne(unsigned int i, simb::MCTruth &mct)
void reconfigure(fhicl::ParameterSet const &p)
std::vector< double > fSigmaP
Variation in momenta (GeV/c)
int fPosDist
How to distribute xyz (gaus, or uniform)
std::vector< double > fTheta0XZ
Angle in XZ plane (degrees)
General GArSoft Utilities.
std::vector< double > fSigmaThetaXZ
Variation in angle in XZ plane.
void Add(simb::MCParticle const &part)
std::vector< double > fSigmaT
Variation in t position (s)
std::vector< double > fSigmaX
Variation in x position (cm)
void printVecs(std::vector< std::string > const &list)
Event generator information.
#define MF_LOG_WARNING(category)
LArSoft geometry interface.
art framework interface to geometry description
Event Generation using GENIE, cosmics or single particles.
bool PadVector(std::vector< double > &vec)
std::vector< double > fSigmaY
Variation in y position (cm)
cet::coded_exception< error, detail::translate > exception
std::vector< double > fP0
Central momentum (GeV/c) to generate.
std::vector< double > fX0
Central x position (cm) in world coordinates.
void produce(::art::Event &evt)