25 #include "TDatabasePDG.h" 27 #include "TStopwatch.h" 36 #include "art_root_io/TFileService.h" 37 #include "art_root_io/TFileDirectory.h" 122 produces< std::vector<simb::MCTruth> >();
123 produces< sumdata::RunData, art::InRun >();
126 fEventFile = std::make_unique<std::ifstream>(fNuanceFile.c_str());
129 <<
"Failed to open input file '" << fNuanceFile <<
"'.\n";
145 fGenerated[0] = tfs->make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
146 fGenerated[1] = tfs->make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
147 fGenerated[2] = tfs->make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
148 fGenerated[3] = tfs->make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
149 fGenerated[4] = tfs->make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
150 fGenerated[5] = tfs->make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
152 fDCosX = tfs->make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
153 fDCosY = tfs->make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
154 fDCosZ = tfs->make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
156 fMuMomentum = tfs->make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
157 fMuDCosX = tfs->make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
158 fMuDCosY = tfs->make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
159 fMuDCosZ = tfs->make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
161 fEMomentum = tfs->make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
162 fEDCosX = tfs->make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
163 fEDCosY = tfs->make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
164 fEDCosZ = tfs->make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
166 fCCMode = tfs->make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 5, 0., 5.);
167 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
168 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
169 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
170 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
171 fCCMode->GetXaxis()->SetBinLabel(5,
"kInverseMuDecay");
172 fCCMode->GetXaxis()->CenterLabels();
174 fNCMode = tfs->make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 5, 0., 5.);
175 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
176 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
177 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
178 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
179 fNCMode->GetXaxis()->SetBinLabel(5,
"kNuElectronElastic");
180 fNCMode->GetXaxis()->CenterLabels();
183 fECons = tfs->make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
189 int xdiv = TMath::Nint(2*x/5.);
190 int ydiv = TMath::Nint(2*y/5.);
191 int zdiv = TMath::Nint(2*z/5.);
193 fVertexX = tfs->make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -
x,
x);
194 fVertexY = tfs->make<TH1F>(
"fVertexY",
";y (cm)", ydiv, -
y,
y);
195 fVertexZ = tfs->make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.2*
z,
z);
197 fVertexXY = tfs->make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -
x,
x, ydiv, -
y,
y);
198 fVertexXZ = tfs->make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -
x,
x);
199 fVertexYZ = tfs->make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
220 std::cout<<
"------------------------------------------------------------------------------"<<
std::endl;
229 double PDGCODE = -9999.;
230 double CHANNEL = -9999.;
241 int FirstMother = -1;
248 int targetnucleusPdg = -9999;
249 int hitquarkPdg = -9999;
252 TLorentzVector Neutrino;
253 TLorentzVector Lepton;
254 TLorentzVector Target;
256 TLorentzVector Hadron4mom;
258 double InvariantMass = -9999;
266 double Tcosx = 0., Tcosy = 0., Tcosz = 0., Tenergy = 0.;
276 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
280 std::cout <<
"NuanceFile: Problem reading nuance file" << std::endl;
283 std::istringstream in;
287 in>>dollar>>name>>PDGCODE>>energy>>cosx>>cosy>>cosz>>partnumber;
291 if(name ==
"nuance"){
293 channel =
int (CHANNEL);
338 if(name ==
"vertex"){
345 double PI = 3.14159265;
352 if(name ==
"track" && (PDGCODE == 2212 || PDGCODE == 2112 || PDGCODE == 18040 || PDGCODE == 11) && partnumber == -1){
353 Tpdg =
int (PDGCODE);
355 if ( PDGCODE == 18040 ){
360 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
361 const TParticlePDG* definition = databasePDG->GetParticle(Tpdg);
362 Tmass = definition->Mass();
372 if(name ==
"track" && (
374 (partnumber == -1 && (PDGCODE != 2212 && PDGCODE != 2112 && PDGCODE != 18040 && PDGCODE != 11))
378 int pdgcode =
int (PDGCODE);
381 if ( PDGCODE == 18040 )
385 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
386 const TParticlePDG* definition = databasePDG->GetParticle(pdgcode);
387 Mass = definition->Mass();
404 P = std::sqrt(
pow(energy/1000,2.) -
pow(Mass,2.));
413 TLorentzVector
pos(X0, Y0, Z0, 0);
416 TLorentzVector mom(CosX*P, CosY*P, CosZ*P, energy/1000);
422 if(name ==
"track" && (
abs(pdgcode) == 14 ||
abs(pdgcode) == 12) && partnumber == -1)
423 Neutrino.SetPxPyPzE(CosX*P, CosY*P, CosZ*P, energy/1000);
425 if(name ==
"track" && (
abs(pdgcode) == 13 ||
abs(pdgcode) == 11 ||
abs(pdgcode) == 14 ||
abs(pdgcode) == 12) && partnumber == 0)
426 Lepton.SetPxPyPzE(CosX*P, CosY*P, CosZ*P, energy/1000);
449 Tmom.SetPxPyPzE(Tcosx, Tcosy, Tcosz, Tenergy/1000);
473 q = Neutrino - Lepton;
479 double W2 = M*M + 2*M*v -
Q2;
480 InvariantMass = TMath::Sqrt(TMath::Max(0.,W2));
494 InvariantMass, x, y, Q2
499 truthcol->push_back(truth);
501 evt.
put(std::move(truthcol));
509 int code = StatusCode;
515 ParticleStatusName =
"kIStInitialState";
518 ParticleStatusName =
"kIStFinalState";
521 ParticleStatusName =
"kIStNucleonTarget";
524 ParticleStatusName =
"Status Unknown";
536 ReactionChannelName =
"kCC";
538 ReactionChannelName =
"kNC";
539 else std::cout<<
"Current mode unknown!! "<<
std::endl;
542 ReactionChannelName +=
"_kQE";
544 ReactionChannelName +=
"_kRes";
546 ReactionChannelName +=
"_kDIS";
548 ReactionChannelName +=
"_kCoh";
550 ReactionChannelName +=
"_kNuElectronElastic";
552 ReactionChannelName +=
"_kInverseMuDecay";
553 else std::cout<<
"interaction mode unknown!! "<<
std::endl;
555 return ReactionChannelName;
652 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
658 if (part.PdgCode() == 18040)
660 else if (part.PdgCode() != -99999 )
662 name = databasePDG->GetParticle(part.PdgCode())->GetName();
665 int code = part.StatusCode();
667 double mass = part.Mass();
669 double Ek = (energy-mass);
685 if(
abs(part.PdgCode()) == 11){
687 fEDCosX->Fill(part.Px()/part.P());
688 fEDCosY->Fill(part.Py()/part.P());
689 fEDCosZ->Fill(part.Pz()/part.P());
690 fECons->Fill(nu.
E() - part.E());
693 else if(
abs(part.PdgCode()) == 13){
698 fECons->Fill(nu.
E() - part.E());
double E(const int i=0) const
TH1F * fVertexX
vertex location of generated events in x
neutral current quasi-elastic
TH2F * fVertexYZ
vertex location in yz
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
const simb::MCNeutrino & GetNeutrino() const
double Py(const int i=0) const
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
charged current deep inelastic scatter
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
NUANCEGen(fhicl::ParameterSet const &pset)
resonant charged current, nubar p -> l+ p pi-
double Q2(const Interaction *const i)
void SetOrigin(simb::Origin_t origin)
neutrino electron elastic scatter
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
TH2F * fVertexXY
vertex location in xy
TH1F * fDCosY
direction cosine in y
const simb::MCParticle & Nu() const
EDProducer(fhicl::ParameterSet const &pset)
TH1F * fEMomentum
momentum of outgoing electrons
double Px(const int i=0) const
TH1F * fECons
histogram to determine if energy is conserved in the event
double Mass(Resonance_t res)
resonance mass (GeV)
offset to account for adding in Nuance codes to this enum
TH1F * fGenerated[6]
Spectra as generated.
TH1F * fNCMode
CC interaction mode.
TH2F * fVertexXZ
vertex location in xz
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
charged current quasi-elastic
std::string ParticleStatus(int StatusCode)
void reconfigure(fhicl::ParameterSet const &p)
TH1F * fDCosZ
direction cosine in z
TH1F * fCCMode
CC interaction mode.
TH1F * fDCosX
direction cosine in x
TH1F * fEDCosX
direction cosine of outgoing e in x
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)
resonant charged current, nu n -> l- n pi+
void FillHistograms(simb::MCTruth mc)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
TH1F * fMuDCosY
direction cosine of outgoing mu in y
std::string ReactionChannel(int ccnc, int mode)
double P(const int i=0) const
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
CodeOutputInterface * code
std::unique_ptr< std::ifstream > fEventFile
TH1F * fEDCosZ
direction cosine of outgoing e in z
void produce(art::Event &evt)
TH1F * fMuMomentum
momentum of outgoing muons
charged current deep inelastic scatter
resonant charged current, nu p -> l- p pi+
Q_EXPORT QTSManip setw(int w)
const simb::MCParticle & GetParticle(int i) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
double Vx(const int i=0) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
double fBeamVerticalAngle
void Add(simb::MCParticle const &part)
charged current coherent pion
A module to check the results from the Monte Carlo generator.
double Pz(const int i=0) const
resonant charged current, nubar n -> l+ n pi-
TH1F * fMuDCosX
direction cosine of outgoing mu in x
double Vz(const int i=0) const
EventNumber_t event() const
TH1F * fEDCosY
direction cosine of outgoing e in y
Event generator information.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Event generator information.
Namespace collecting geometry-related classes utilities.
Event Generation using GENIE, cosmics or single particles.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
void beginRun(art::Run &run)
TH1F * fVertexY
vertex location of generated events in y
double Vy(const int i=0) const
std::string fNUANCEModuleLabel
keep track of how long it takes to run the job
QTextStream & endl(QTextStream &s)
TH1F * fVertexZ
vertex location of generated events in z