58 #ifndef EVGEN_LIGHTSOURCE_H 59 #define EVGEN_LIGHTSOURCE_H 79 #include "cetlib_except/exception.h" 97 #include "TLorentzVector.h" 100 #include "CLHEP/Random/RandFlat.h" 101 #include "CLHEP/Random/RandGaussQ.h" 206 produces< sumdata::RunData, art::InRun >();
207 produces< std::vector<simb::MCTruth> >();
218 fT = pset.
get<
double>(
"T0");
220 fN = pset.
get<
int >(
"N");
225 fP = pset.
get<
double>(
"P");
249 if(!fUseCustomRegion)
280 mf::LogVerbatim(
"LightSource") <<
"Light Source : Determining voxel params : " 288 throw cet::exception(
"LightSource") <<
"EVGEN Light Source : Unrecognised light source mode\n";
319 run.
put(std::move(runcol));
337 mf::LogWarning(
"LightSource") <<
"EVGEN Light Source : Warning, reached end of file," 338 <<
" looping back to beginning";
344 throw cet::exception(
"LightSource") <<
"EVGEN Light Source : File error in " 377 fX = VoxelCenter.X();
378 fY = VoxelCenter.Y();
379 fZ = VoxelCenter.Z();
388 throw cet::exception(
"LightSource") <<
"EVGEN : Light Source, unrecognised source mode\n";
399 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
406 truthcol->push_back(truth);
409 evt.
put(std::move(truthcol));
423 mf::LogVerbatim(
"LightSource") <<
"Light source : Stowing voxel params ";
433 mf::LogVerbatim(
"LightSource") <<
"EVGEN Light Source fully scanned detector. Starting over.";
449 CLHEP::HepRandomEngine &engine = rng->
getEngine();
450 CLHEP::RandFlat flat(engine);
451 CLHEP::RandGaussQ gauss(engine);
453 for(
int j=0; j!=
fN; ++j){
475 x[2] = gauss.fire(fZ,
fSigmaZ);
478 x[0] =
fX +
fSigmaX*(2.0*flat.fire()-1.0);
479 x[1] =
fY +
fSigmaY*(2.0*flat.fire()-1.0);
480 x[2] = fZ +
fSigmaZ*(2.0*flat.fire()-1.0);
491 t =
fT +
fSigmaT * (2.0 * flat.fire()-1.0);
498 fShotPos = TLorentzVector(x[0], x[1], x[2], t);
502 double costh = 2 * flat.fire() - 1;
503 double sinth = pow(1-pow(costh,2),0.5);
504 double phi = 2 * M_PI * flat.fire();
508 fShotMom = TLorentzVector( p*sinth*cos(phi),
513 int trackid = -1*(j+1);
514 std::string primary(
"primary");
539 #endif // EVGEN_LIGHTSOURCE_H
std::vector< double > fRegionMin
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
LightSource(fhicl::ParameterSet const &pset)
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void SetOrigin(simb::Origin_t origin)
std::vector< double > fRegionMax
art::ProductID put(std::unique_ptr< PROD > &&)
TVector3 GetCenter() const
void Add(simb::MCParticle &part)
void produce(art::Event &evt)
TTree * fPhotonsGenerated
ProductID put(std::unique_ptr< PROD > &&product)
void StoreLightProd(int VoxID, double N)
base_engine_t & getEngine() const
base_engine_t & createEngine(seed_t seed)
#define DEFINE_ART_MODULE(klass)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
single particles thrown at the detector
T get(std::string const &key) const
TVector3 GetVoxelSize() const
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
void beginRun(art::Run &run)
sim::PhotonVoxelDef fThePhotonVoxelDef
void Sample(simb::MCTruth &truth)
const sim::PhotonVoxelDef & GetVoxelDef() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
T * make(ARGS...args) const
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
A module for optical MC testing and library building.
Event generator information.
Namespace collecting geometry-related classes utilities.
Event Generation using GENIE, cosmics or single particles.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
PhotonVoxel GetPhotonVoxel(int ID) const