20 #include "art_root_io/TFileService.h" 82 CLHEP::HepRandomEngine&
fEngine;
93 ,
fbuffbox{pset.get<std::vector<double>>(
"BufferBox", {0.0, 0.0, 0.0, 0.0, 0.0, 0.0})}
101 produces<std::vector<simb::MCTruth>>();
102 produces<sumdata::RunData, art::InRun>();
111 tfs->make<TH2F>(
"fPhotonAngles",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
113 tfs->make<TH2F>(
"fPhotonAnglesLo",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
115 tfs->make<TH2F>(
"fPhotonAnglesMi",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
117 tfs->make<TH2F>(
"fPhotonAnglesHi",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
118 fPhotonCosQ = tfs->make<TH1F>(
"fPhotonCosQ",
";cos#theta;tracks", 50, -1.0, 1.0);
119 fPhotonEnergy = tfs->make<TH1F>(
"fPhotonEnergy",
";E (GeV)", 5000, 0.0, 1000.0);
121 tfs->make<TH1F>(
"fPhotonsPerSample",
";Number Photons;Samples", 100, 0, 1000);
123 tfs->make<TH1F>(
"fPhotonsInCryostat",
";Number Photons;Samples", 100, 0, 1000);
124 fPhotonsInTPC = tfs->make<TH1F>(
"fPhotonsInTPC",
";Number Photons;Samples", 100, 0, 1000);
127 tfs->make<TH2F>(
"fElectronAngles",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
129 tfs->make<TH2F>(
"fElectronAnglesLo",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
131 tfs->make<TH2F>(
"fElectronAnglesMi",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
133 tfs->make<TH2F>(
"fElectronAnglesHi",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
134 fElectronCosQ = tfs->make<TH1F>(
"fElectronCosQ",
";cos#theta;tracks", 50, -1.0, 1.0);
135 fElectronEnergy = tfs->make<TH1F>(
"fElectronEnergy",
";E (GeV)", 5000, 0.0, 1000.0);
137 tfs->make<TH1F>(
"fElectronsPerSample",
";Number Electrons;Samples", 100, 0, 1000);
139 tfs->make<TH1F>(
"fElectronsInCryotat",
";Number Electrons;Samples", 100, 0, 1000);
140 fElectronsInTPC = tfs->make<TH1F>(
"fElectronsInTPC",
";Number Electrons;Samples", 100, 0, 1000);
143 tfs->make<TH2F>(
"fMuonAngles",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
145 tfs->make<TH2F>(
"fMuonAnglesLo",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
147 tfs->make<TH2F>(
"fMuonAnglesMi",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
149 tfs->make<TH2F>(
"fMuonAnglesHi",
";#phi;cos#theta", 36, -180.0, 180.0, 50, -1.0, 1.0);
150 fMuonCosQ = tfs->make<TH1F>(
"fMuonCosQ",
";cos#theta;tracks", 50, -1.0, 1.0);
151 fMuonEnergy = tfs->make<TH1F>(
"fMuonEnergy",
";E (GeV)", 5000, 0.0, 1000.0);
152 fMuonsPerSample = tfs->make<TH1F>(
"fMuonsPerSample",
";Number Muons;Samples", 100, 0, 1000);
153 fMuonsInCStat = tfs->make<TH1F>(
"fMuonsInCryostat",
";Number Muons;Samples", 100, 0, 1000);
154 fMuonsInTPC = tfs->make<TH1F>(
"fMuonsInTPC",
";Number Muons;Samples", 100, 0, 1000);
167 std::unique_ptr<std::vector<simb::MCTruth>> truthcol(
new std::vector<simb::MCTruth>);
172 int nCrossCryostat = 0;
176 auto const [surface_y, tpc_length] = std::make_tuple(geom->
SurfaceY(), geom->
TPC().
Length());
177 while (nCrossCryostat < 1) {
184 int numElectrons = 0;
187 int allElectrons = 0;
191 for (
int i = 0; i < pretruth.
NParticles(); ++i) {
193 const TLorentzVector& v4 = particle.
Position();
194 const TLorentzVector& p4 = particle.
Momentum();
195 double x0[3] = {v4.X(), v4.Y(), v4.Z()};
196 double dx[3] = {p4.Px(), p4.Py(), p4.Pz()};
205 TH1F* hCosQ =
nullptr;
206 TH2F* hAngles =
nullptr;
207 TH2F* hAnglesLo =
nullptr;
208 TH2F* hAnglesMi =
nullptr;
209 TH2F* hAnglesHi =
nullptr;
210 TH1F* hEnergy =
nullptr;
240 double bounds[6] = {0.};
241 cryostat.Boundaries(bounds);
247 for (
unsigned int cb = 0; cb < 6; cb++)
248 bounds[cb] = bounds[cb] +
fbuffbox[cb];
251 bool intersects_cryo =
false;
252 for (
int bnd = 0; bnd != 6; ++bnd) {
254 double p2[3] = {bounds[bnd],
255 x0[1] + (dx[1] / dx[0]) * (bounds[bnd] - x0[0]),
256 x0[2] + (dx[2] / dx[0]) * (bounds[bnd] - x0[0])};
257 if (p2[1] >= bounds[2] && p2[1] <= bounds[3] && p2[2] >= bounds[4] &&
258 p2[2] <= bounds[5]) {
259 intersects_cryo =
true;
263 else if (bnd >= 2 && bnd < 4) {
264 double p2[3] = {x0[0] + (dx[0] / dx[1]) * (bounds[bnd] - x0[1]),
266 x0[2] + (dx[2] / dx[1]) * (bounds[bnd] - x0[1])};
267 if (p2[0] >= bounds[0] && p2[0] <= bounds[1] && p2[2] >= bounds[4] &&
268 p2[2] <= bounds[5]) {
269 intersects_cryo =
true;
274 double p2[3] = {x0[0] + (dx[0] / dx[2]) * (bounds[bnd] - x0[2]),
275 x0[1] + (dx[1] / dx[2]) * (bounds[bnd] - x0[2]),
277 if (p2[0] >= bounds[0] && p2[0] <= bounds[1] && p2[1] >= bounds[2] &&
278 p2[1] <= bounds[3]) {
279 intersects_cryo =
true;
285 if (intersects_cryo) {
296 double cosq = -p4.Py() / p4.P();
297 double phi = std::atan2(p4.Pz(), p4.Px());
300 hAngles->Fill(phi, cosq);
302 hAnglesLo->Fill(phi, cosq);
303 else if (p4.E() < 10.0)
304 hAnglesMi->Fill(phi, cosq);
306 hAnglesHi->Fill(phi, cosq);
307 hEnergy->Fill(p4.E());
326 truthcol->push_back(truth);
327 evt.
put(std::move(truthcol));
TH2F * fElectronAnglesHi
Electron rate vs angle, high momenta.
base_engine_t & createEngine(seed_t seed)
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)
TH2F * fElectronAnglesLo
Electron rate vs angle, low momenta.
TH2F * fElectronAngles
Electron rate vs angle.
TH1F * fElectronCosQ
Electron rate vs cos(Q)
void SetOrigin(simb::Origin_t origin)
TH2F * fMuonAngles
Muon rate vs angle.
EDProducer(fhicl::ParameterSet const &pset)
TH2F * fMuonAnglesLo
Muon rate vs angle, low momenta.
TH1F * fPhotonEnergy
Photon energy (GeV)
constexpr auto abs(T v)
Returns the absolute value of the argument.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Geometry information for a single cryostat.
TH2F * fElectronAnglesMi
Electron rate vs angle, middle momenta.
void produce(art::Event &evt) override
TH1F * fMuonCosQ
Muon rate vs cos(Q)
Length_t SurfaceY() const
The position of the detector respect to earth surface.
TH1F * fElectronsPerSample
number of electrons in the sampled time window
double Length() const
Length is associated with z coordinate [cm].
CosmicsGen(fhicl::ParameterSet const &pset)
TH1F * fPhotonsPerSample
number of photons in the sampled time window
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
double Sample(simb::MCTruth &mctruth, double const &surfaceY, double const &detectorLength, double *w, double rantime=0)
#define DEFINE_ART_MODULE(klass)
Interface to the CRY cosmic ray generator.
TH1F * fPhotonCosQ
Photon rate vs cos(Q)
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
void beginRun(art::Run &run) override
evgb::CRYHelper fCRYHelp
CRY generator object.
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.
void Add(simb::MCParticle const &part)
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.
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Event generator information.
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
TH1F * fMuonsPerSample
number of muons in the sampled time window
TH1F * fMuonEnergy
Muon energy (GeV)
Event Generation using GENIE, cosmics or single particles.
art framework interface to geometry description