1 #ifndef EVGEN_COSMICSGEN_H 10 #define EVGEN_COSMICSGEN_H 114 fbuffbox = pset.
get< std::vector<double> >(
"BufferBox",{0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
118 produces< std::vector<simb::MCTruth> >();
119 produces< sumdata::RunData, art::InRun >();
138 CLHEP::HepRandomEngine& engine = rng->
getEngine();
152 fPhotonAngles = tfs->
make<TH2F>(
"fPhotonAngles",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
153 fPhotonAnglesLo = tfs->
make<TH2F>(
"fPhotonAnglesLo",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
154 fPhotonAnglesMi = tfs->
make<TH2F>(
"fPhotonAnglesMi",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
155 fPhotonAnglesHi = tfs->
make<TH2F>(
"fPhotonAnglesHi",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
156 fPhotonCosQ = tfs->
make<TH1F>(
"fPhotonCosQ",
";cos#theta;tracks", 50,-1.0,1.0);
159 fPhotonsInCStat = tfs->
make<TH1F>(
"fPhotonsInCryostat",
";Number Photons;Samples", 100, 0, 1000);
160 fPhotonsInTPC = tfs->
make<TH1F>(
"fPhotonsInTPC",
";Number Photons;Samples", 100, 0, 1000);
162 fElectronAngles = tfs->
make<TH2F>(
"fElectronAngles",
";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
163 fElectronAnglesLo = tfs->
make<TH2F>(
"fElectronAnglesLo",
";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
164 fElectronAnglesMi = tfs->
make<TH2F>(
"fElectronAnglesMi",
";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
165 fElectronAnglesHi = tfs->
make<TH2F>(
"fElectronAnglesHi",
";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
166 fElectronCosQ = tfs->
make<TH1F>(
"fElectronCosQ",
";cos#theta;tracks",50,-1.0,1.0);
169 fElectronsInCStat = tfs->
make<TH1F>(
"fElectronsInCryotat",
";Number Electrons;Samples", 100, 0, 1000);
170 fElectronsInTPC = tfs->
make<TH1F>(
"fElectronsInTPC",
";Number Electrons;Samples", 100, 0, 1000);
172 fMuonAngles = tfs->
make<TH2F>(
"fMuonAngles",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
173 fMuonAnglesLo = tfs->
make<TH2F>(
"fMuonAnglesLo",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
174 fMuonAnglesMi = tfs->
make<TH2F>(
"fMuonAnglesMi",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
175 fMuonAnglesHi = tfs->
make<TH2F>(
"fMuonAnglesHi",
";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
176 fMuonCosQ = tfs->
make<TH1F>(
"fMuonCosQ",
";cos#theta;tracks",50,-1.0,1.0);
177 fMuonEnergy = tfs->
make<TH1F>(
"fMuonEnergy",
";E (GeV)", 5000,0.0,1000.0);
178 fMuonsPerSample = tfs->
make<TH1F>(
"fMuonsPerSample",
";Number Muons;Samples", 100, 0, 1000);
179 fMuonsInCStat = tfs->
make<TH1F>(
"fMuonsInCryostat",
";Number Muons;Samples", 100, 0, 1000);
180 fMuonsInTPC = tfs->
make<TH1F>(
"fMuonsInTPC",
";Number Muons;Samples", 100, 0, 1000);
193 run.
put(std::move(runcol));
201 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
206 int nCrossCryostat = 0;
210 while(nCrossCryostat < 1){
220 int numElectrons = 0;
223 int allElectrons = 0;
231 for(
int i = 0; i < pretruth.
NParticles(); ++i){
233 const TLorentzVector& v4 = particle.
Position();
234 const TLorentzVector& p4 = particle.
Momentum();
235 double x0[3] = {v4.X(), v4.Y(), v4.Z() };
236 double dx[3] = {p4.Px(), p4.Py(), p4.Pz()};
238 if (std::abs(particle.
PdgCode())==13) ++allMuons;
239 else if (std::abs(particle.
PdgCode())==22) ++allPhotons;
240 else if (std::abs(particle.
PdgCode())==11) ++allElectrons;
248 if (std::abs(particle.
PdgCode())==13) {
256 else if (std::abs(particle.
PdgCode())==22) {
264 else if (std::abs(particle.
PdgCode())==11) {
275 for(
unsigned int c = 0; c < geom->
Ncryostats(); ++c){
284 for (
unsigned int cb=0; cb<6; cb++)
285 bounds[cb] = bounds[cb]+
fbuffbox[cb];
288 bool intersects_cryo =
false;
289 for (
int bnd=0; bnd!=6; ++bnd) {
291 double p2[3] = {bounds[bnd], x0[1] + (dx[1]/dx[0])*(bounds[bnd] - x0[0]), x0[2] + (dx[2]/dx[0])*(bounds[bnd] - x0[0])};
292 if ( p2[1] >= bounds[2] && p2[1] <= bounds[3] &&
293 p2[2] >= bounds[4] && p2[2] <= bounds[5] ) {
294 intersects_cryo =
true;
298 else if (bnd>=2 && bnd<4) {
299 double p2[3] = {x0[0] + (dx[0]/dx[1])*(bounds[bnd] - x0[1]), bounds[bnd], x0[2] + (dx[2]/dx[1])*(bounds[bnd] - x0[1])};
300 if ( p2[0] >= bounds[0] && p2[0] <= bounds[1] &&
301 p2[2] >= bounds[4] && p2[2] <= bounds[5] ) {
302 intersects_cryo =
true;
307 double p2[3] = {x0[0] + (dx[0]/dx[2])*(bounds[bnd] - x0[2]), x0[1] + (dx[1]/dx[2])*(bounds[bnd] - x0[2]), bounds[bnd]};
308 if ( p2[0] >= bounds[0] && p2[0] <= bounds[1] &&
309 p2[1] >= bounds[2] && p2[1] <= bounds[3] ) {
310 intersects_cryo =
true;
317 if (intersects_cryo) {
320 if (std::abs(particle.
PdgCode())==13) ++numMuons;
321 else if (std::abs(particle.
PdgCode())==22) ++numPhotons;
322 else if (std::abs(particle.
PdgCode())==11) ++numElectrons;
340 double cosq = -p4.Py()/p4.P();
341 double phi = std::atan2(p4.Pz(),p4.Px());
344 hAngles->Fill(phi,cosq);
345 if (p4.E()<1.0) hAnglesLo->Fill(phi,cosq);
346 else if (p4.E()<10.0) hAnglesMi->Fill(phi,cosq);
347 else hAnglesHi->Fill(phi,cosq);
348 hEnergy->Fill(p4.E());
371 truthcol->push_back(truth);
372 evt.
put(std::move(truthcol));
386 #endif // EVGEN_COSMICSGEN_H 387 TH2F * fElectronAnglesHi
Electron rate vs angle, high momenta.
Interface to the CRY cosmic-ray generator.
const TLorentzVector & Position(const int i=0) const
TH2F * fPhotonAngles
Photon rate vs angle.
TH2F * fMuonAnglesHi
Muon rate vs angle, high momenta.
TH1F * fElectronEnergy
Electron energy (GeV)
Encapsulate the construction of a single cyostat.
TH2F * fElectronAnglesLo
Electron rate vs angle, low momenta.
TH2F * fElectronAngles
Electron rate vs angle.
Collect all the geometry header files together.
TH1F * fElectronCosQ
Electron rate vs cos(Q)
void SetOrigin(simb::Origin_t origin)
TH2F * fMuonAngles
Muon rate vs angle.
void reconfigure(fhicl::ParameterSet const &p)
TH2F * fMuonAnglesLo
Muon rate vs angle, low momenta.
TH1F * fPhotonEnergy
Photon energy (GeV)
const std::string GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
art::ProductID put(std::unique_ptr< PROD > &&)
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
TH2F * fElectronAnglesMi
Electron rate vs angle, middle momenta.
void Add(simb::MCParticle &part)
TH1F * fMuonCosQ
Muon rate vs cos(Q)
TH1F * fElectronsPerSample
number of electrons in the sampled time window
void CryostatBoundaries(double *boundaries, geo::CryostatID const &cid) const
Returns the boundaries of the specified cryostat.
CosmicsGen(fhicl::ParameterSet const &pset)
TH1F * fPhotonsPerSample
number of photons in the sampled time window
ProductID put(std::unique_ptr< PROD > &&product)
evgb::CRYHelper * fCRYHelp
CRY generator object.
base_engine_t & getEngine() const
double Sample(simb::MCTruth &mctruth, double const &surfaceY, double const &detectorLength, double *w, double rantime=0)
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.
Interface to the CRY cosmic ray generator.
T get(std::string const &key) const
TH1F * fPhotonCosQ
Photon rate vs cos(Q)
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
geo::Length_t SurfaceY() const
The position of the detector respect to earth surface.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
TH2F * fMuonAnglesMi
Muon rate vs angle, middle momenta.
std::vector< double > fbuffbox
const simb::MCParticle & GetParticle(int i) const
TH2F * fPhotonAnglesMi
Photon rate vs angle, middle momenta.
TH2F * fPhotonAnglesLo
Photon rate vs angle, low momenta.
T * make(ARGS...args) const
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
void produce(art::Event &evt)
const TLorentzVector & Momentum(const int i=0) const
TH2F * fPhotonAnglesHi
Photon rate vs angle, high momenta.
A module to check the results from the Monte Carlo generator.
void beginRun(art::Run &run)
Event generator information.
TH1F * fMuonsPerSample
number of muons in the sampled time window
Namespace collecting geometry-related classes utilities.
TH1F * fMuonEnergy
Muon energy (GeV)
Event Generation using GENIE, cosmics or single particles.
BoundingBox bounds(int x, int y, int w, int h)
art framework interface to geometry description