21 #include "TDatabasePDG.h" 23 #include "CLHEP/Random/RandFlat.h" 30 #include "art_root_io/TFileService.h" 33 #include "nurandom/RandomUtils/NuRandomService.h" 45 #include "TStopwatch.h" 118 produces< std::vector<simb::MCTruth> >();
119 produces< sumdata::RunData, art::InRun >();
123 <<
"Could not open file: " <<
fNdkFile <<
'\n';
140 fGenerated[0] = tfs->make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
141 fGenerated[1] = tfs->make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
142 fGenerated[2] = tfs->make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
143 fGenerated[3] = tfs->make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
144 fGenerated[4] = tfs->make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
145 fGenerated[5] = tfs->make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
147 fDCosX = tfs->make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
148 fDCosY = tfs->make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
149 fDCosZ = tfs->make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
151 fMuMomentum = tfs->make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
152 fMuDCosX = tfs->make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
153 fMuDCosY = tfs->make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
154 fMuDCosZ = tfs->make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
156 fEMomentum = tfs->make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
157 fEDCosX = tfs->make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
158 fEDCosY = tfs->make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
159 fEDCosZ = tfs->make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
161 fCCMode = tfs->make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 5, 0., 5.);
162 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
163 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
164 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
165 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
166 fCCMode->GetXaxis()->SetBinLabel(5,
"kInverseMuDecay");
167 fCCMode->GetXaxis()->CenterLabels();
169 fNCMode = tfs->make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 5, 0., 5.);
170 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
171 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
172 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
173 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
174 fNCMode->GetXaxis()->SetBinLabel(5,
"kNuElectronElastic");
175 fNCMode->GetXaxis()->CenterLabels();
177 fECons = tfs->make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
183 int xdiv = TMath::Nint(2*x/5.);
184 int ydiv = TMath::Nint(2*y/5.);
185 int zdiv = TMath::Nint(2*z/5.);
187 fVertexX = tfs->make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -
x,
x);
188 fVertexY = tfs->make<TH1F>(
"fVertexY",
";y (cm)", ydiv, -
y,
y);
189 fVertexZ = tfs->make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.2*
z,
z);
191 fVertexXY = tfs->make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -
x,
x, ydiv, -
y,
y);
192 fVertexXZ = tfs->make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -
x,
x);
193 fVertexYZ = tfs->make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
214 std::cout<<
"------------------------------------------------------------------------------"<<
std::endl;
243 int Idx, Ist,
PDG, Mother1, Mother2, Daughter1 ,Daughter2;
244 double Px, Py, Pz,
E,
m ;
245 std::string p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14;
250 int FirstMother = -1;
262 TLorentzVector Neutrino;
263 TLorentzVector Lepton;
264 TLorentzVector Target;
266 TLorentzVector Hadron4mom;
279 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
285 double const fvCut{5.0};
294 for (
size_t i = 0; i<geo->
NTPC(); ++i)
296 double local[3] = {0.,0.,0.};
297 double world[3] = {0.,0.,0.};
315 double X0 = 0.0 + flat.fire( minx+fvCut , maxx-fvCut );
316 double Y0 = 0.0 + flat.fire( miny+fvCut , maxy-fvCut );
317 double Z0 = 0.0 + flat.fire( minz+fvCut , maxz-fvCut );
319 std::cout <<
"NDKGen_module: X, Y, Z of vtx: " << X0 <<
", "<< Y0 <<
", "<< Z0 <<
std::endl;
324 std::cout <<
"NdkFile: Problem reading Ndk file" << std::endl;
328 if (k.find(
"** Event:")!= std::string::npos) {
329 std::istringstream in;
333 in>> dummy>> dummy>> dummy >> dummy>> dummy>> dummy>> dummy >> dummy>> dummy>> dummy >> GenieEvt;
334 std::cout<<
"Genie Evt "<< GenieEvt <<
" art evt "<<evt.
id().
event()<<
"\n";
337 if (GenieEvt+1 != static_cast<int>(evt.
id().
event()))
341 if (!k.compare(0,25,
"GENIE Interaction Summary"))
343 if (k.compare(0,1,
"|") || k.compare(1,2,
" "))
continue;
344 if (k.find(
"Fin-Init") != std::string::npos)
continue;
345 if (k.find(
"Ar") != std::string::npos)
continue;
346 if (k.find(
"Cl") != std::string::npos)
continue;
347 if (k.find(
"HadrBlob") != std::string::npos)
continue;
348 if (k.find(
"NucBindE") != std::string::npos)
continue;
349 if (k.find(
"FLAGS") != std::string::npos)
break;
350 if (k.find(
"Vertex") != std::string::npos)
break;
353 if (!k.compare(26,1,
"1"))
356 std::istringstream in;
360 in>>p1>> Idx >>p2>> Name >>p3>> Ist >>p4>> PDG >>p5>>Mother1 >> p6 >> Mother2 >>p7>> Daughter1 >>p8>> Daughter2 >>p9>>Px>>p10>>Py>>p11>>Pz>>p12>>E>>p13>> m>>p14;
362 if (Ist!=1)
continue;
364 std::cout <<
"PDG = " << PDG <<
std::endl;
366 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
367 const TParticlePDG* definition = databasePDG->GetParticle(PDG);
368 Mass = definition->Mass();
369 if (E-Mass < 0.001)
continue;
382 P = std::sqrt(
pow(E,2.) -
pow(Mass,2.));
383 std::cout <<
"Momentum = " << P <<
std::endl;
385 TLorentzVector
pos(X0, Y0, Z0, 0);
389 TLorentzVector mom(Px,Py,Pz, E);
405 std::cout <<
"NDKGen.cxx: Putting " << truth.
NParticles() <<
" tracks on stack." <<
std::endl;
406 truthcol->push_back(truth);
416 int code = StatusCode;
422 ParticleStatusName =
"kIStInitialState";
425 ParticleStatusName =
"kIStFinalState";
428 ParticleStatusName =
"kIStNucleonTarget";
431 ParticleStatusName =
"Status Unknown";
443 ReactionChannelName =
"kCC";
445 ReactionChannelName =
"kNC";
446 else std::cout<<
"Current mode unknown!! "<<
std::endl;
449 ReactionChannelName +=
"_kQE";
451 ReactionChannelName +=
"_kRes";
453 ReactionChannelName +=
"_kDIS";
455 ReactionChannelName +=
"_kCoh";
457 ReactionChannelName +=
"_kNuElectronElastic";
459 ReactionChannelName +=
"_kInverseMuDecay";
460 else std::cout<<
"interaction mode unknown!! "<<
std::endl;
462 return ReactionChannelName;
559 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
565 if (part.PdgCode() == 18040)
567 else if (part.PdgCode() != -99999 )
569 name = databasePDG->GetParticle(part.PdgCode())->GetName();
572 int code = part.StatusCode();
574 double mass = part.Mass();
576 double Ek = (energy-mass);
591 if(
abs(part.PdgCode()) == 11){
593 fEDCosX->Fill(part.Px()/part.P());
594 fEDCosY->Fill(part.Py()/part.P());
595 fEDCosZ->Fill(part.Pz()/part.P());
596 fECons->Fill(nu.
E() - part.E());
599 else if(
abs(part.PdgCode()) == 13){
604 fECons->Fill(nu.
E() - part.E());
double E(const int i=0) const
NDKGen(fhicl::ParameterSet const &pset)
TH1F * fMuMomentum
momentum of outgoing muons
TH2F * fVertexXY
vertex location in xy
const simb::MCNeutrino & GetNeutrino() const
TH1F * fGenerated[6]
Spectra as generated.
double Py(const int i=0) const
TH1F * fMuDCosY
direction cosine of outgoing mu in y
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
TH1F * fECons
histogram to determine if energy is conserved in the event
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void SetOrigin(simb::Origin_t origin)
TH1F * fEDCosZ
direction cosine of outgoing e in z
const simb::MCParticle & Nu() const
TH1F * fEMomentum
momentum of outgoing electrons
EDProducer(fhicl::ParameterSet const &pset)
TH2F * fVertexXZ
vertex location in xz
Geometry information for a single TPC.
double Px(const int i=0) const
ChannelGroupService::Name Name
TH1F * fVertexY
vertex location of generated events in y
double Mass(Resonance_t res)
resonance mass (GeV)
std::pair< float, std::string > P
TH1F * fCCMode
CC interaction mode.
TH1F * fEDCosY
direction cosine of outgoing e in y
void produce(art::Event &evt) override
art framework interface to geometry description
CLHEP::HepRandomEngine & fEngine
art-managed random-number engine
A module to check the results from the Monte Carlo generator.
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
#define DEFINE_ART_MODULE(klass)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
double P(const int i=0) const
TH1F * fMuDCosX
direction cosine of outgoing mu in x
TH2F * fVertexYZ
vertex location in yz
TH1F * fVertexZ
vertex location of generated events in z
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
TH1F * fDCosZ
direction cosine in z
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
CodeOutputInterface * code
std::string ReactionChannel(int ccnc, int mode)
std::string fNDKModuleLabel
keep track of how long it takes to run the job
Q_EXPORT QTSManip setw(int w)
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
const simb::MCParticle & GetParticle(int i) const
TH1F * fEDCosX
direction cosine of outgoing e in x
double Vx(const int i=0) const
void Add(simb::MCParticle const &part)
void FillHistograms(simb::MCTruth const &mc)
double Pz(const int i=0) const
double Vz(const int i=0) const
cet::LibraryManager dummy("noplugin")
EventNumber_t event() const
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::string ParticleStatus(int StatusCode)
void beginRun(art::Run &run) override
Event generator information.
TH1F * fNCMode
CC interaction mode.
TH1F * fDCosY
direction cosine in y
Event generator information.
LArSoft geometry interface.
Event Generation using GENIE, cosmics or single particles.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
TH1F * fVertexX
vertex location of generated events in x
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
TH1F * fDCosX
direction cosine in x
double Vy(const int i=0) const
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)