Classes | Typedefs | Functions | Variables
sim Namespace Reference

Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event. More...

Classes

class  EmEveIdCalculator
 
class  EveIdCalculator
 
class  FilterFlags
 
class  FLSHit
 A single unit of energy deposition in the liquid scintillator. More...
 
class  FLSHitList
 A vector of FLSHit from single neutrino interaction. More...
 
class  MixSimAndRealEventsDetail
 
class  Particle
 
class  ParticleHistory
 
class  ParticleNavigator
 
class  PhotonSignal
 
class  TrueEnergy
 

Typedefs

typedef art::MixFilter< MixSimAndRealEventsDetailMixSimAndRealEvents
 

Functions

std::ostream & operator<< (std::ostream &o, const FLSHit &a)
 
std::ostream & operator<< (std::ostream &output, const ParticleHistory &list)
 
ParticleNavigator operator+ (const int &value, const ParticleNavigator &list)
 
std::ostream & operator<< (std::ostream &output, const ParticleNavigator &list)
 
std::ostream & operator<< (std::ostream &o, const PhotonSignal &ps)
 
bool CompareByPlaneAndCell (const sim::PhotonSignal &a, const sim::PhotonSignal &b)
 Helper for SortByPlaneAndCell. More...
 
void SortByPlaneAndCell (std::vector< sim::PhotonSignal > &c)
 
bool CompareByNPhoton (const sim::PhotonSignal &a, const sim::PhotonSignal &b)
 Helper for SortByNPhoton. More...
 
void SortByNPhoton (std::vector< sim::PhotonSignal > &c)
 Sort c by number of photons. Lowerst to highest. More...
 
unsigned int GetRandomNumberSeed ()
 
std::ostream & operator<< (std::ostream &o, const TrueEnergy &TE)
 

Variables

static std::unique_ptr< EveIdCalculatoreveIdCalculator
 
static const int kNoiseId = 1234567890
 flag for noise id More...
 
static const int kNoParticleId = -999
 
static const int kPrimaryParticle = 0
 

Detailed Description

Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event.

A class to contain true energy deposited in/escaping the detector Remember that as this data product holds information from all daughters it is possible (and in fact likely) that not all of the numbers add up. Especially as the energies are kinetic energies. Consider for example a very low energy muon KE = 10 KeV which decays. The electron it produces will likely deposit ~50 KeV in the detector. The neutrinos will likely leave the detector with about ~50 KeV energy. Therefore, EntEn = 10 KeV, EnDep = ~60 KeV, TotEscEn = ~50 KeV!!!

A class to contain true energy deposited in/escaping the detector.

Simulation header file.

Useful tools for simulation.

Photon signal class.

Particle list in DetSim contains Monte Carlo particle information.

A "chain" of particles associated with production of a Particle in a ParticleList.

A "chain" of particles associated with production of a Particle in a ParticleNavigator.

Description of a particle passed to Geant4.

Vector container of FLSHit.

A single unit of energy deposition in the liquid scintillator.

FLSHit class.

FilterFlags class.

Interface for calculating the "ultimate mother" of a particle in a simulated event.

Author
selig.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..edu
Date
Author
selig.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..edu you haven't done so already, read the comments in front of Simulation/EveIdCalculator.h. The default calculator for the eve ID, EveIdCalculator, goes up the chain of particles in an event to return the track ID of a primary particle from the event generator. But what if you want different defintion of the eve ID? There's a way to substitute your own calculation; this class is an example of how to do it. This particular class attempts to find the "ultimate mother" for electromagnetic showers. It goes up the chain of particles in an event, until it encounters a particle that is either primary or was not produced by a "trivial" e-m process. To create your own eve ID calculation, copy this header file and change the name from "EmEveIdCalculator" to whatever name you prefer. Then copy the implementation file "EmEveIdCalculator.cxx", again changing the name to your class. Then revise the calculation in the DoCalculateEveId method to whatever you want. To use this new calculation within sim::ParticleNavigator, use the following statement: If you've written your own calculator, subtitute it for "sim::EmEveIdCalculator" in the above statement. Just do this once, in the initialization portion of your program. (You can call it for every event, but you'll be wasting time.) It may look like there's a memory leak in the above statement, but there isn't: the "Adopt" in the method name means that ParticleNavigator will take control of the pointer. Don't delete it; ParticleNavigator will do that. If you're familiar with design patterns, this class makes use of the Template Method. No, this has nothing to do with C++ templates; see "Design Patterns" by Gemma et al., or "Effective C++" by Scott Meyers. If you're a good enough programmer to contemplate buffering of results or lazy evaluation, don't bother; ParticleNavigator and EveIdCalculator already take care of this. Monte Carlo Simulation
selig.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..edu is the base class for an algorithm to calculate the "eve ID". This begs two questions: - What is an eve ID? - What does it mean to be a base class? The "eve ID" is the ultimate "mother" of a particle in a shower produced by the detector simulation. Consider the following example chain of particles: TrackID Particle "Mother" 2 pi+ 0 101 nu_mu 2 102 mu+ 2 341 nu_mu_bar 102 342 nu_e 102 343 e+ 102 1022 gamma 343 1123 e+ 1022 1124 e- 1022 The "mother" (or parent) particle of track ID 1123 is 1022; the "mother" of track ID 102 is 2. The mother of ID 2 is 0 because it is a primary particle, created by the event generator instead of the detector simulation. The track IDs were originally assigned by the simulation. Each particle is stored in a sim::Particle object. All of the particles for a given event are stored in a sim::ParticleNavigator object. When you are studying an event, especially one with many primary particles, it can be helpful to go up the decay chain, from "child" to mother to "grand-mother", to eventually the ultimate mother particle of the chain. The track ID of the ultimate mother is the "eve ID". In the above example, if we want the eve ID to refer to primary particles, the eve ID of track ID 1123 is 2. This class is never called directly. Instead, it's invoked indirectly via the sim::ParticleNavigator class. For example: const sim::ParticleNavigator* particleList = // ... from somewhere int trackID = // ... an ID you select according to some criteria int eveID = particleList->EveId( trackID ); The class below defines the eve ID to be a primary particle that comes from the event. But what if you want a different definition of the ultimate mother; for example, perhaps you only want to go up the chain of particles for basic e-m showers, but stop at more significant physics; for example, in the chain above, you might want the eve ID of track 1123 to be 343, since all the particles descended from 343 are part of the same e-m shower. You can override the default calculation of this class (the "base" calculation) with one of your own. For an example of how to do this, see EmEveIdCalculator.h. (If you're familiar with design patterns, this base class implements the Template Method. No, this has nothing to do with C++ templates; see "Design Patterns" by Gemma et al., or "Effective C++" by Scott Meyers.)
???
Date
Author
brebe.nosp@m.l@fn.nosp@m.al.go.nosp@m.v
Date
Author
messi.nosp@m.er@i.nosp@m.ndian.nosp@m.a.ed.nosp@m.u
Date
Author
ishi@.nosp@m.indi.nosp@m.ana.e.nosp@m.du
Date
Author
selig.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..edu container for a chain of particles in an event. It's meant as a convenience for looking at a sequence of particles within a sim::ParticeList. Here's an example to illustrate the purpose and use of a list. Assume a pi+ is a primary particle in an event whose decay is modeled like this: TrackID Particle 2 pi+ 101 nu_mu 102 mu+ 341 nu_mu_bar 342 nu_e 343 e+ I'm playing around with the ParticleNavigator for the event, and I'm interested in what produced track ID 343, which is an e+. I can use the ParticleHistory class to quickly go through the production chain: sim::ParticleNavigator* particleNav = // ... from somewhere int trackID = 343; const sim::ParticleHistory particleHistory( particleNav, trackID ); for ( int i = 0; i != particleHistory.size(); ++i ) { const sim::Particle* particle = particleHistory[i]; // ... } In the above example: particleHistory.size() == 3 particleHistory[0] points to the particle with track ID 2 particleHistory[1] points to the particle with track ID 102 particleHistory[2] points to the particle with track ID 343 So as you go through a ParticleHistory "array," the first element is a primary particle in the event, and the last element is the particle you used to create the history. ParticleHistory looks like a vector< const sim::Particle* >, with the following additions: - a ParticleNavigator() method that returns a ParticleNavigator* to the object that's associated with the history. - an EndParticleID() method that returns the track ID of the last particle in the chain; that is, it's the second argument in the constructor. - Print() and operator<< methods for ROOT display and ease of debugging. TECHNICAL NOTES: ParticleHistory behaves mostly like a vector, but it's actually a deque. This means that you can't assume that &particleHistory[0] is a continugous array of Particle*. If those two sentences mean nothing to you, don't worry about it; this only matters to folks familiar with STL. A given ParticleHistory object is associated with the ParticleNavigator used to create it. If you delete the ParticleNavigator (by reading in a new event, for example) then the contents of the corresponding ParticleHistory object(s) are garbage. If you create a ParticleHistory object like this: const sim::ParticleHistory ph(particleNav,1123); and there is no track 1123 in the particle list, then ph.size()==0. particleHistory[0] is not necessarily a primary particle in the event. It's possible for a production chain to be broken due to simulation cuts. The first element just represents as far back we can go in the production chain given the ParticleNavigator.
selig.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..edu
Date

Although there's nothing in the following class that assumes units, the standard for NOvASoft is that distances are in cm, and energies are in GeV.

Author
jpale.nosp@m.y@in.nosp@m.diana.nosp@m..edu
Date
Author
brebe.nosp@m.l@fn.nosp@m.al.go.nosp@m.vDat.nosp@m.a classes required for detector simulation
karlw.nosp@m.arb@.nosp@m.iasta.nosp@m.te.e.nosp@m.du
Date

Typedef Documentation

Definition at line 137 of file MixSimAndRealEvents_module.cc.

Function Documentation

bool sim::CompareByNPhoton ( const sim::PhotonSignal a,
const sim::PhotonSignal b 
)

Helper for SortByNPhoton.

Definition at line 61 of file PhotonSignal.cxx.

References sim::PhotonSignal::NPhoton().

Referenced by cheat::BackTracker::Rebuild(), and SortByNPhoton().

63  {
64  return a.NPhoton() < b.NPhoton();
65  }
int NPhoton() const
Definition: PhotonSignal.h:30
bool sim::CompareByPlaneAndCell ( const sim::PhotonSignal a,
const sim::PhotonSignal b 
)

Helper for SortByPlaneAndCell.

Definition at line 44 of file PhotonSignal.cxx.

References sim::PhotonSignal::fCell, and sim::PhotonSignal::fPlane.

46  {
47  if(a.fPlane < b.fPlane) return true;
48  if(a.fPlane > b.fPlane) return false;
49  return a.fCell < b.fCell;
50  }
int fCell
cell number
Definition: PhotonSignal.h:43
int fPlane
plane number
Definition: PhotonSignal.h:44
unsigned int sim::GetRandomNumberSeed ( )
inline

Definition at line 13 of file Simulation.cxx.

References central_limit::rand.

Referenced by chaninfo::BadChanList::BadChanList(), evgen::CosmicPionGen::CosmicPionGen(), evgen::CosmicsGen::CosmicsGen(), fuzz::FuzzyKVertex::FuzzyKVertex(), g4n::G4Gen::G4Gen(), photrans::ImprovedTransport::ImprovedTransport(), evgen::IsoGen::IsoGen(), rsim::MakeNoiseSpectrumFile::MakeNoiseSpectrumFile(), mix::MixSimEvents::MixSimEvents(), photrans::PhotonSystRewriter::PhotonSystRewriter(), photrans::PhotonTransport::PhotonTransport(), rsim::ReadoutSim::ReadoutSim(), evgen::SingleGen::SingleGen(), and evgen::SupernovaGen::SupernovaGen().

14  {
15  // the maximum allowed seed for the art::RandomNumberGenerator
16  // is 900000000. Use TRandom3 to get the seed value in that range.
17  // Instantiating TRandom3 with a 0 means that its seed is set based
18  // on the TUUID and should always be random, even for jobs running on the
19  // same machine
20  TRandom3 *rand = new TRandom3(0);
21 
22  // set gRandom to be our new TRandom3 for cases where we need to pull
23  // random numbers out of ROOT histograms, etc
24  gRandom = rand;
25  return rand->Integer(900000000);
26  }
ParticleNavigator sim::operator+ ( const int value,
const ParticleNavigator list 
)

Definition at line 231 of file ParticleNavigator.cxx.

232  {
233  return list + value;
234  }
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::ostream& sim::operator<< ( std::ostream &  o,
const PhotonSignal ps 
)

Definition at line 30 of file PhotonSignal.cxx.

References sim::PhotonSignal::Cell(), sim::PhotonSignal::NPhoton(), msf_helper::o, sim::PhotonSignal::Plane(), art::right(), sim::PhotonSignal::TimeMean(), and sim::PhotonSignal::TrackId().

31  {
32  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
33  o << "TrackId = " << std::setw(5) << std::right << ps.TrackId()
34  << " TimeMean = " << std::setw(5) << std::right << ps.TimeMean()
35  << " Cell# = " << std::setw(5) << std::right << ps.Cell()
36  << " Plane# = " << std::setw(5) << std::right << ps.Plane()
37  << " NPhoton = " << std::setw(5) << std::right << ps.NPhoton();
38 
39  return o;
40  }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
std::ostream& sim::operator<< ( std::ostream &  o,
const TrueEnergy TE 
)

Definition at line 30 of file TrueEnergy.cxx.

References sim::TrueEnergy::EnteringEnergy(), sim::TrueEnergy::EscapingEnergy(), msf_helper::o, sim::TrueEnergy::TotalDepEnergy(), sim::TrueEnergy::TotalEscEnergy(), and sim::TrueEnergy::TrackId().

31  {
32  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
33  o << " Looking at particle with TrackId " << TE.TrackId() << " it had;"
34  << " Entering Energy = " << TE.EnteringEnergy()
35  << " Escaping Energy = " << TE.EscapingEnergy()
36  << " Total En Depos. = " << TE.TotalDepEnergy()
37  << " Total En Escap. = " << TE.TotalEscEnergy();
38  return o;
39  }
std::ostream& sim::operator<< ( std::ostream &  output,
const ParticleHistory list 
)

Definition at line 53 of file ParticleHistory.cxx.

References allTimeWatchdog::endl, makeTrainCVSamples::int, std::log10(), and runNovaSAM::output.

54  {
55  // Determine a field width for the particle number.
56  ParticleHistory::size_type numberOfParticles = list.size();
57  int numberOfDigits = (int) std::log10( (double) numberOfParticles ) + 1;
58 
59  // A simple header.
60  output.width( numberOfDigits );
61  output << "#" << ": < ID, particle >" << std::endl;
62 
63  // Write each particle on a separate line.
64  ParticleHistory::size_type nParticle = 0;
65  for ( ParticleHistory::const_iterator particle = list.begin(); particle != list.end(); ++particle, ++nParticle ){
66  output.width( numberOfDigits );
67  output << nParticle << ": "
68  << *(*particle)
69  << std::endl;
70  }
71 
72  return output;
73  }
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Definition: typedefs.hpp:11
T log10(T number)
Definition: d0nt_math.hpp:120
std::ostream & sim::operator<< ( std::ostream &  o,
const FLSHit a 
)

Definition at line 203 of file FLSHit.cxx.

References sim::FLSHit::GetCellID(), sim::FLSHit::GetCellUniqueId(), sim::FLSHit::GetEdep(), sim::FLSHit::GetEdepBirks(), sim::FLSHit::GetEntryEnergy(), sim::FLSHit::GetEntryT(), sim::FLSHit::GetEntryX(), sim::FLSHit::GetEntryY(), sim::FLSHit::GetEntryZ(), sim::FLSHit::GetExitEnergy(), sim::FLSHit::GetExitT(), sim::FLSHit::GetExitX(), sim::FLSHit::GetExitY(), sim::FLSHit::GetExitZ(), sim::FLSHit::GetNCerenkov(), sim::FLSHit::GetPlaneID(), sim::FLSHit::GetTrackID(), msf_helper::o, and art::right().

204  {
205  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
206  o << " CellUniqueId " << std::setw(10) << std::right << a.GetCellUniqueId()
207  << " Entry (x,y,z): (" << a.GetEntryX() << "," << a.GetEntryY() << "," << a.GetEntryZ() << ")"
208  << " Entry E: " << std::setw(5) << std::right << a.GetEntryEnergy()
209  << " Exit (x,y,z): (" << a.GetExitX() << "," << a.GetExitY() << "," << a.GetExitZ() << ")"
210  << " Exit E: " << std::setw(5) << std::right << a.GetExitEnergy()
211  << " Entry Time: " << std::setw(5) << std::right << a.GetEntryT()
212  << " Exit Time: " << std::setw(5) << std::right << a.GetExitT()
213  << " E deposited: " << std::setw(5) << std::right << a.GetEdep()
214  << " E Birks Weight: " << std::setw(5) << std::right << a.GetEdepBirks()
215  << " N Cerenkov Photons " << std::setw(5) << std::right << a.GetNCerenkov()
216  << " Plane,Cell: " << a.GetPlaneID() << "," << a.GetCellID()
217  << " Track ID: " << std::setw(5) << std::right << a.GetTrackID();
218 
219  return o;
220  }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
const double a
std::ostream& sim::operator<< ( std::ostream &  output,
const ParticleNavigator list 
)

Definition at line 294 of file ParticleNavigator.cxx.

References sim::ParticleNavigator::begin(), sim::ParticleNavigator::end(), allTimeWatchdog::endl, makeTrainCVSamples::int, std::log10(), runNovaSAM::output, and sim::ParticleNavigator::size().

295  {
296  // Determine a field width for the particle number.
297  ParticleNavigator::size_type numberOfParticles = list.size();
298  int numberOfDigits = (int) std::log10( (double) numberOfParticles ) + 1;
299 
300  // A simple header.
301  output.width( numberOfDigits );
302  output << "#" << ": < ID, particle >" << std::endl;
303 
304  // Write each particle on a separate line.
305  ParticleNavigator::size_type nParticle = 0;
306  for ( ParticleNavigator::const_iterator particle = list.begin();
307  particle != list.end(); ++particle, ++nParticle ){
308  output.width( numberOfDigits );
309  output << nParticle << ": "
310  << "<" << (*particle).first
311  << "," << *((*particle).second)
312  << ">" << std::endl;
313  }
314 
315  return output;
316  }
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Definition: typedefs.hpp:11
T log10(T number)
Definition: d0nt_math.hpp:120
void sim::SortByNPhoton ( std::vector< sim::PhotonSignal > &  c)

Sort c by number of photons. Lowerst to highest.

Definition at line 69 of file PhotonSignal.cxx.

References CompareByNPhoton().

70  {
71  std::sort(c.begin(), c.end(), CompareByNPhoton);
72  }
bool CompareByNPhoton(const sim::PhotonSignal &a, const sim::PhotonSignal &b)
Helper for SortByNPhoton.
void sim::SortByPlaneAndCell ( std::vector< sim::PhotonSignal > &  c)

Sort c by plane and cell. ie guarantees hits on the same channel are adjacent.

Definition at line 54 of file PhotonSignal.cxx.

References sim::PhotonSignal::CompareByPlaneAndCell.

Referenced by rsim::ReadoutSim::produce().

55  {
56  std::sort(c.begin(), c.end(), CompareByPlaneAndCell);
57  }
bool CompareByPlaneAndCell(const sim::PhotonSignal &a, const sim::PhotonSignal &b)
Helper for SortByPlaneAndCell.

Variable Documentation

std::unique_ptr<EveIdCalculator> sim::eveIdCalculator
static

Definition at line 33 of file ParticleNavigator.cxx.

const int sim::kNoiseId = 1234567890
static

flag for noise id

Definition at line 13 of file Simulation.h.

Referenced by trk::KalmanTrackAna::FindVisibleProngs(), and cheat::RecoCheckAna::FindVisibleProngs().

const int sim::kNoParticleId = -999
static

if any track id method returns sim::kNoParticleId, it means the associated particle was too low-energy to be written by the detector Monte Carlo.

Definition at line 14 of file Simulation.h.

Referenced by g4n::ParticleListAction::BeginOfEventAction(), g4n::ParticleListAction::GetParentage(), and g4n::ParticleListAction::PreTrackingAction().

const int sim::kPrimaryParticle = 0
static

enumeration to indicate the mother of a particle is a primary particle

Definition at line 18 of file Simulation.h.