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" 205 produces< sumdata::RunData, art::InRun >();
206 produces< std::vector<simb::MCTruth> >();
217 fT = pset.
get<
double>(
"T0");
219 fN = pset.
get<
int >(
"N");
224 fP = pset.
get<
double>(
"P");
247 if(!fUseCustomRegion)
278 mf::LogVerbatim(
"LightSource") <<
"Light Source : Determining voxel params : " 286 throw cet::exception(
"LightSource") <<
"EVGEN Light Source : Unrecognised light source mode\n";
317 run.
put(std::move(runcol));
335 mf::LogWarning(
"LightSource") <<
"EVGEN Light Source : Warning, reached end of file," 336 <<
" looping back to beginning";
342 throw cet::exception(
"LightSource") <<
"EVGEN Light Source : File error in " 375 fX = VoxelCenter.X();
376 fY = VoxelCenter.Y();
377 fZ = VoxelCenter.Z();
386 throw cet::exception(
"LightSource") <<
"EVGEN : Light Source, unrecognised source mode\n";
397 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
404 truthcol->push_back(truth);
407 evt.
put(std::move(truthcol));
421 mf::LogVerbatim(
"LightSource") <<
"Light source : Stowing voxel params ";
431 mf::LogVerbatim(
"LightSource") <<
"EVGEN Light Source fully scanned detector. Starting over.";
447 CLHEP::HepRandomEngine &engine = rng->
getEngine();
448 CLHEP::RandFlat flat(engine);
449 CLHEP::RandGaussQ gauss(engine);
451 for(
int j=0; j!=
fN; ++j){
467 x[2] = gauss.fire(fZ,
fSigmaZ);
470 x[0] =
fX +
fSigmaX*(2.0*flat.fire()-1.0);
471 x[1] =
fY +
fSigmaY*(2.0*flat.fire()-1.0);
472 x[2] = fZ +
fSigmaZ*(2.0*flat.fire()-1.0);
481 t =
fT +
fSigmaT * (2.0 * flat.fire()-1.0);
488 fShotPos = TLorentzVector(x[0], x[1], x[2], t);
492 double costh = 2 * flat.fire() - 1;
493 double sinth = pow(1-pow(costh,2),0.5);
494 double phi = 2 * M_PI * flat.fire();
498 fShotMom = TLorentzVector( p*sinth*cos(phi),
503 int trackid = -1*(j+1);
504 std::string primary(
"primary");
529 #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