25 #include "art_root_io/TFileService.h" 27 #include "cetlib_except/exception.h" 40 #include "TLorentzVector.h" 44 #include "CLHEP/Random/RandFlat.h" 45 #include "CLHEP/Random/RandGaussQ.h" 104 ,
fScan{pset.get<
bool>(
"Scan")}
105 ,
fPosDist{pset.get<
int>(
"PosDist")}
106 ,
fTDist{pset.get<
int>(
"TDist")}
107 ,
fPDist{pset.get<
int>(
"PDist")}
108 ,
fT{pset.get<
double>(
"T0")}
109 ,
fSigmaT{pset.get<
double>(
"SigmaT")}
110 ,
fP{pset.get<
double>(
"P")}
111 ,
fSigmaP{pset.get<
double>(
"SigmaP")}
112 ,
fN{pset.get<
int>(
"N")}
117 produces<sumdata::RunData, art::InRun>();
118 produces<std::vector<simb::MCTruth>>();
122 fPhotonGen = tfs->make<TTree>(
"PhGen",
"PhGen");
135 fPx = pset.get<
double>(
"X");
136 fPy = pset.get<
double>(
"Y");
137 fPz = pset.get<
double>(
"Z");
138 std::cout <<
"Will generate photons from 3 points." << std::endl;
146 std::cout <<
"Number of optical detector: " << int(geo->
Cryostat().
NOpDet()) << std::endl;
149 fXmin = CryoBounds.MinX();
150 fXmax = CryoBounds.MaxX();
151 fYmin = CryoBounds.MinY();
152 fYmax = CryoBounds.MaxY();
153 fZmin = CryoBounds.MinZ();
154 fZmax = CryoBounds.MaxZ();
155 std::cout <<
"Cryo Boundaries:" << std::endl;
156 std::cout <<
"Xmin: " <<
fXmin <<
" Xmax: " <<
fXmax <<
" Ymin: " <<
fYmin <<
" Ymax: " <<
fYmax 157 <<
" Zmin: " <<
fZmin <<
" Zmax: " <<
fZmax << std::endl;
165 rng.seed(std::random_device()());
166 std::uniform_real_distribution<double> distX(
fXmin,
fXmax);
167 std::uniform_real_distribution<double> distY(
fYmin,
fYmax);
168 std::uniform_real_distribution<double> distZ(
fZmin,
fZmax);
169 std::uniform_real_distribution<double> width(-2.0, 2.0);
171 std::unique_ptr<std::vector<simb::MCTruth>> truthcol(
new std::vector<simb::MCTruth>);
177 fY =
fPy + width(rng);
178 fZ =
fPz + width(rng);
189 truthcol->push_back(truth);
190 evt.
put(std::move(truthcol));
195 std::cout <<
"Photons Shooting at the Position: " <<
fX <<
" " <<
fY <<
" " <<
fZ << std::endl;
198 CLHEP::RandGaussQ gauss(
fEngine);
200 for (
int j = 0; j !=
fN; ++j) {
209 time =
fT +
fSigmaT * (2.0 * flat.fire() - 1.0);
211 fShotPos = TLorentzVector(pos[0], pos[1], pos[2], time);
217 p =
fP +
fSigmaP * (2.0 * flat.fire() - 1.0);
222 double costh = 2 * flat.fire() - 1;
223 double sinth = std::sqrt(1 - costh * costh);
224 double phi = 2 * M_PI * flat.fire();
227 fShotMom = TLorentzVector(p * sinth * cos(phi), p * sinth * sin(phi), p * costh, p);
base_engine_t & createEngine(seed_t seed)
PhotonGen(fhicl::ParameterSet const &pset)
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void SetOrigin(simb::Origin_t origin)
void beginRun(art::Run &run)
EDProducer(fhicl::ParameterSet const &pset)
void Sample(simb::MCTruth &truth)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
CryostatGeo const & Cryostat(CryostatID const &cryoid=cryostat_zero) const
Returns the specified cryostat.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
#define DEFINE_ART_MODULE(klass)
single particles thrown at the detector
CLHEP::HepRandomEngine & fEngine
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
void Add(simb::MCParticle const &part)
unsigned int NOpDet() const
Number of optical detectors in this TPC.
geo::BoxBoundedGeo const & Boundaries() const
Returns boundaries of the cryostat (in centimetres).
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Event generator information.
Namespace collecting geometry-related classes utilities.
void produce(art::Event &evt)
Event Generation using GENIE, cosmics or single particles.
static ServiceHandle< RandomNumberGenerator > & rng()
art framework interface to geometry description