LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
MCTruth.cxx
Go to the documentation of this file.
11 
13 
14 #include "TDatabasePDG.h"
15 
16 #include <iostream>
17 
18 namespace simb{
19 
20  //......................................................................
22  : fPartList()
23  , fMCNeutrino()
24  , fOrigin(simb::kUnknown)
25  , fNeutrinoSet(false)
26  {
27  }
28 
29  //......................................................................
30  void MCTruth::SetNeutrino(int CCNC,
31  int mode,
32  int interactionType,
33  int target,
34  int nucleon,
35  int quark,
36  double w,
37  double x,
38  double y,
39  double qsqr)
40  {
41  if( !fNeutrinoSet ){
42  fNeutrinoSet = true;
43  // loop over the MCParticle list and get the outgoing lepton
44  // assume this is a neutral current interaction to begin with
45  // which means the outgoing lepton is the incoming neutrino
46  MCParticle nu = fPartList[0];
47  MCParticle lep = fPartList[0];
48 
49  // start at i = 1 because i = 0 is the incoming neutrino
50  for(unsigned int i = 1; i < fPartList.size(); ++i){
51  if(fPartList[i].Mother() == nu.TrackId() &&
52  (fPartList[i].PdgCode() == nu.PdgCode() ||
53  abs(fPartList[i].PdgCode()) == abs(nu.PdgCode())-1) ){
54  lep = fPartList[i];
55  break;
56  }
57  }//done looping over particles
58 
59  fMCNeutrino = simb::MCNeutrino(nu, lep,
60  CCNC, mode, interactionType,
61  target, nucleon, quark,
62  w, x, y, qsqr);
63  } // end if MCNeutrino is not already set
64  else
65  throw art::Exception(art::errors::LogicError) << "MCTruth - attempt to set neutrino when already set";
66  return;
67  }
68 
69  //......................................................................
70  std::ostream& operator<< (std::ostream& o, simb::MCTruth const& a)
71  {
72  if(a.Origin() == kCosmicRay)
73  o << "This is a cosmic ray event" << std::endl;
74  else if(a.Origin() == kBeamNeutrino){
75  o << "This is a beam neutrino event" << std::endl;
76  o << a.GetNeutrino();
77  }
78  else if(a.Origin() == kSuperNovaNeutrino){
79  o << "This is a supernova neutrino event" << std::endl;
80  o << a.GetNeutrino();
81  }
82 
83  for (int i = 0; i < a.NParticles(); ++i)
84  o << i << " " << a.GetParticle(i) << std::endl;
85 
86  return o;
87  }
88 }
Float_t x
Definition: compare.C:6
std::vector< simb::MCParticle > fPartList
list of particles in this event
Definition: MCTruth.h:36
int PdgCode() const
Definition: MCParticle.h:216
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:74
cout<< "-> Edep in the target
Definition: analysis.C:54
Float_t y
Definition: compare.C:6
simb::Origin_t Origin() const
Definition: MCTruth.h:71
int NParticles() const
Definition: MCTruth.h:72
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
Definition: MCTruth.cxx:30
simb::MCNeutrino fMCNeutrino
reference to neutrino info - null if not a neutrino
Definition: MCTruth.h:37
Particle class.
int TrackId() const
Definition: MCParticle.h:214
Framework includes.
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:73
friend std::ostream & operator<<(std::ostream &o, simb::MCTruth const &a)
Definition: MCTruth.cxx:70
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Supernova neutrinos.
Definition: MCTruth.h:23
Event generator information.
Definition: MCTruth.h:30
bool fNeutrinoSet
flag for whether the neutrino information has been set
Definition: MCTruth.h:39
Event generator information.
Definition: MCNeutrino.h:18
Float_t w
Definition: plot.C:23
Cosmic rays.
Definition: MCTruth.h:22
Beam neutrinos.
Definition: MCTruth.h:21