List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Attributes | Private Types | Private Member Functions | Private Attributes
ParticleInjectorNEU::ParticleInjector Class Reference

Module to inject particles into a tank. More...

#include <ParticleInjectorNEU/ParticleInjector.h>

Inheritance diagram for ParticleInjectorNEU::ParticleInjector:
Inheritance graph
[legend]

Classes

struct  RandomPart
 

Public Types

enum  ResultFlag { eSuccess, eFailure, eBreakLoop, eContinueLoop }
 Flag returned by module methods to the RunController. More...
 
enum  VersionInfoType {
  eFilename = 1, eRevisionNumber = 2, eDate = 3, eTime = 4,
  eLastEditor = 5
}
 Different types of version info that can be retrieved from GetVersionInfo. More...
 

Public Member Functions

fwk::VModule::ResultFlag Finish ()
 Finish: invoked at end of the run (NOT end of the event) More...
 
utl::StopwatchGetStopwatch ()
 
const utl::StopwatchGetStopwatch () const
 
std::string GetVersionInfo (const VersionInfoType v) const
 Retrieve different sorts of module version info. More...
 
fwk::VModule::ResultFlag Init ()
 Initialize: invoked at beginning of run (NOT beginning of event) More...
 
void InitTiming ()
 
 ParticleInjector ()
 
fwk::VModule::ResultFlag Run (evt::Event &theEvent)
 Run: invoked once per event. More...
 
ResultFlag RunWithTiming (evt::Event &event)
 
virtual ~ParticleInjector ()
 

Static Public Member Functions

static std::string GetResultFlagByName (const ResultFlag flag)
 

Static Public Attributes

static const double fgFarAway2 = utl::Sqr(1000*utl::kilometer)
 

Protected Types

enum  InfoLevel { eInfoNone = 0, eInfoFinal = 1, eInfoIntermediate = 2, eInfoDebug = 3 }
 

Protected Attributes

int fInfoLevel = 0
 

Private Types

enum  PositionFlag {
  eNone, eFixed, eDisk, eSphere,
  ePDF
}
 

Private Member Functions

double GenerateAzimuth ()
 
double GenerateEnergy (const utl::Particle::Type particle, const int i)
 
void GeneratePosition (double &x, double &y, double &z)
 
double GenerateTime ()
 
double GenerateZenith ()
 
void InjectParticles (sevt::Station &station)
 
utl::VRandomSamplerLoadRandomSampler (const utl::Branch &branch)
 
void ParticleInjectorConfiguration ()
 
 REGISTER_MODULE ("ParticleInjectorNEU", ParticleInjector)
 

Private Attributes

utl::VRandomSamplerfAzimuthDistribution = nullptr
 
std::string fContinuousAzimuthString
 
std::string fContinuousTimeString
 
std::string fContinuousZenithString
 
bool fCreateEvent = false
 
utl::VRandomSamplerfDefaultEnergyDistribution = nullptr
 
std::vector< double > fDiscreteAzimuth
 
std::vector< double > fDiscreteParticleTime
 
std::vector< double > fDiscreteZenith
 
utl::VRandomSamplerfElectronEnergyDistribution = nullptr
 
utl::TimeStamp fEventTime
 
std::vector< double > fFixedEnergy
 
utl::VRandomSamplerfGammaEnergyDistribution = nullptr
 
double fHeight = 1.5*utl::meter
 
unsigned int fMinMomentum = 0
 
utl::VRandomSamplerfMuonEnergyDistribution = nullptr
 
unsigned int fNumberOfEntries = 0
 
std::vector< utl::Particle::TypefParticles
 
PositionFlag fPositionFlag = eNone
 
std::string fPropagate = "no"
 
double fRadius = 5*utl::meter
 
utl::RandomEngine::RandomEngineTypefRandomEngine
 
bool fRandomEntries = false
 
RandomPart fRandomParticle
 
TChain * fRandomTree = nullptr
 
unsigned int fSingleTankID = 0
 
bool fUseSingleTank = false
 
double fX = 0
 
utl::VRandomSamplerfXDistribution = nullptr
 
double fY = 0
 
utl::VRandomSamplerfYDistribution = nullptr
 
double fZ = 0
 
utl::VRandomSamplerfZDistribution = nullptr
 
utl::VRandomSamplerfZenithDistribution = nullptr
 

Detailed Description

Module to inject particles into a tank.

Author
Javier Gonzalez
Darko Veberic
Tom Paul
Date
Sept 2004

This module implements a particle injector. The configuration tries to be simple enough by providing a default behaviour while keeping flexibility.

The configuration is done via an xml file that needs to conform to a particular schema, defined inside ParticleInjectorNEU.xsd. Since you might not want to look at the schema, here are a couple of examples for different use cases and an explanation of how to specify things:

The simplest example

The simplest case, a single particle, fixed position and direction of a given type. This requires that another module creates the event before this one is called, if there is no event, nothing is injected!

<NumberOfParticles>
   <Type> 1 </Type>
   <Number> 13 </Number>
</NumberOfParticles>

<Position>
   <Fixed unit='m'> 0 0 0.6 </Fixed>
</Position>

<Direction>
   <Fixed> 0 0 -1 </Fixed>
</Direction>

<!-- In this example the energy PDF is just a delta function at 1 GeV -->
<Energy>  
   <Discrete>
     <x unit="GeV"> 1 </x>
     <y> 1 </y>  <!-- weight -->
   <Discrete unit='GeV'> 1 </Discrete> 
</Energy>

Of all the branches, stationId is optional. It defaults to inject in all stations in the event. Also, if instead of providing a position you provide an injection radius, the particles will be injected randomly over a sphere.

So, for example, the following would inject one muon in all stations in the event.

<NumberOfParticles>
   <Type> 1 </Type>
   <Number> 13 </Number>
</NumberOfParticles>

<Position>
   <InjectionRadius unit='m'> 3 </InjectionRadius>
</Position>

<Direction>
   <fixed> 0 0 -1 </fixed>
</Direction>

<Energy>  
   <Discrete>
     <x unit="GeV"> 1 </x>
     <y> 1 </y>  <!-- weight -->
   <Discrete unit='GeV'> 1 </Discrete> 
</Energy>

Distribution functions

Many things are specified as probability distribution functions. There are three ways of specifying a quantity as a distribution function, let's see the energy, for example:

Specifying energy

Energy is a distribution function (see previous section)

If one ever wants to use different spectra for different kind of particles, that can be done as well. So far there are three kinds: muons, electrons and gammas. So, something like the following would use one spectrum for muons and another for all the rest:

<Energy> 
   <PDF> 1/x </PDF>
   <min unit='MeV'> 100 </min>
   <max unit='GeV'> 1 </max>
<muons>
   <x unit='MeV'> 150 500 1000 </x>
   <y> 1 1 0.5 </y>
   <scaleY> 1 </scaleY> 
<muons>
</Energy>

Specifying fluxes for different species does not take care of the relative number of particles for each species. Although in theory that's possible, it hasn't been implemented and one has to specify the number of particles explicitly.

Direction

There are two ways to give direction. A fixed direction like in the first example, given by a vector. One could easily add a line to accept coordinate in different coordinate systems, so far it is only cartesian.

The other way is to specify the azimuth and zenith angles. Each of them is a distribution function. So, it would be something like:

<Direction>
   <Zenith>
     <Discrete>
       <x unit='degree'> 0 </x>
       <y> 1 </y>
     </Discrete>
   </Zenith>

   <Azimuth>
     <Discrete>
       <x unit='degree'> 0 </x>
       <y> 0 </y>
   </Azimuth>

</Direction>

Injection time

The injection time is measured respect to the event time. At this point, the time is specified this way:

<Time>
   <Discrete> 
     <x unit='ns'> 10 </x>
     <y> 1 </y>
   <Discrete/>
</Time>

As you can see, the time is also specified by a probability distribution! but I haven't implemented the code for reading the other two possibilities. It doesn't take long, but is one of many things...

Position

As mentioned before, the position will either be fixed, specified by a vector. Positions are measured from the center of the bottom face of the tank.

<Position>
   <fixed unit='m'> 0 0 0.6 </fixed>
</Position>

by a disk,

<Position>
   <DiskHeight unit='m'> 1.5 </disk_height>
   <DiskRadius unit='m'> 5 </disk_radius>
</Position>

or randomly over a sphere of given radius:

<Position>
   <InjectionRadius unit='m'> 3 </InjectionRadius>
</Position>

Number of particles

The only way right now is to give a tabulated function giving the number of particles of each type. Something like

<NumberOfParticles>
   <Type> 1 </Type>
   <Number> 13 </Number>
</NumberOfParticles>

The type of particle is specified using the PDG numbering scheme . The injector does not recognize all the types, but they can be easily added to the corresponding enumeration.

Inject on one station

Simple enough, add the following to the xml file:

<stationId> 119 </stationId>

If no station is specified, the same configuration will by applied for all stations in the event. If there are no stations in the event, nothing is injected. This means that if you use the ParticleInjectorOG and then this module, there will be no particles injected.

Create the event in this module

If you want to create the Event, then you need to specifically ask for it and provide the time for the event, before the station id (if you don't provide the station id, the event will have no stations and nothing will be injected): The time is specified like this:

<EventTime> 2004-01-21T4:33:12.012345678 </EventTime>

For more details on this format, click here and search for xs:dateTime type.

Dumping the configuration to the screen

Finally, at the end, you can add the tag

<DumpConfiguration/>

If you want the injector to show how it is configured in the screen.

Author
Javier Gonzalez
Darko Veberic
Date
25 Nov 2007

Definition at line 40 of file ParticleInjectorNEU/ParticleInjector.h.

Member Enumeration Documentation

enum fwk::VModule::InfoLevel
protectedinherited
Enumerator
eInfoNone 
eInfoFinal 
eInfoIntermediate 
eInfoDebug 

Definition at line 125 of file VModule.h.

Enumerator
eNone 
eFixed 
eDisk 
eSphere 
ePDF 

Definition at line 53 of file ParticleInjectorNEU/ParticleInjector.h.

enum fwk::VModule::ResultFlag
inherited

Flag returned by module methods to the RunController.

Enumerator
eSuccess 

Report success to RunController.

eFailure 

Report failure to RunController, causing RunController to terminate execution.

eBreakLoop 

Break current loop. It works for nested loops too!

eContinueLoop 

Skip remaining modules in the current loop and continue with next iteration of the loop.

Definition at line 60 of file VModule.h.

Different types of version info that can be retrieved from GetVersionInfo.

Enumerator
eFilename 
eRevisionNumber 
eDate 
eTime 
eLastEditor 

Definition at line 110 of file VModule.h.

Constructor & Destructor Documentation

ParticleInjectorNEU::ParticleInjector::ParticleInjector ( )

Definition at line 68 of file ParticleInjectorNEU/ParticleInjector.cc.

virtual ParticleInjectorNEU::ParticleInjector::~ParticleInjector ( )
inlinevirtual

Definition at line 44 of file ParticleInjectorNEU/ParticleInjector.h.

Member Function Documentation

VModule::ResultFlag ParticleInjectorNEU::ParticleInjector::Finish ( )
virtual

Finish: invoked at end of the run (NOT end of the event)

This method is for things that should be done at the end of the run (for example, closing files or writing out histograms) {You must override this method in your concrete module}

Implements fwk::VModule.

Definition at line 291 of file ParticleInjectorNEU/ParticleInjector.cc.

References fwk::VModule::eSuccess, fAzimuthDistribution, fDefaultEnergyDistribution, fElectronEnergyDistribution, fGammaEnergyDistribution, fMuonEnergyDistribution, fRandomTree, fXDistribution, fYDistribution, fZDistribution, and fZenithDistribution.

double ParticleInjectorNEU::ParticleInjector::GenerateAzimuth ( )
private
double ParticleInjectorNEU::ParticleInjector::GenerateEnergy ( const utl::Particle::Type  particle,
const int  i 
)
private
void ParticleInjectorNEU::ParticleInjector::GeneratePosition ( double &  x,
double &  y,
double &  z 
)
private
double ParticleInjectorNEU::ParticleInjector::GenerateTime ( )
private

Definition at line 466 of file ParticleInjectorNEU/ParticleInjector.cc.

References fDiscreteParticleTime, and fRandomEngine.

Referenced by InjectParticles().

double ParticleInjectorNEU::ParticleInjector::GenerateZenith ( )
private
std::string fwk::VModule::GetResultFlagByName ( const ResultFlag  flag)
staticinherited
utl::Stopwatch& fwk::VModule::GetStopwatch ( )
inlineinherited

Definition at line 106 of file VModule.h.

References fwk::VModule::fStopwatch.

const utl::Stopwatch& fwk::VModule::GetStopwatch ( ) const
inlineinherited

Definition at line 107 of file VModule.h.

References fwk::VModule::fStopwatch.

std::string fwk::VModule::GetVersionInfo ( const VersionInfoType  v) const
inherited
VModule::ResultFlag ParticleInjectorNEU::ParticleInjector::Init ( )
virtual
void fwk::VModule::InitTiming ( )
inlineinherited

Definition at line 95 of file VModule.h.

References fwk::VModule::fStopwatch, and utl::Stopwatch::Reset().

void ParticleInjectorNEU::ParticleInjector::InjectParticles ( sevt::Station station)
private
VRandomSampler * ParticleInjectorNEU::ParticleInjector::LoadRandomSampler ( const utl::Branch branch)
private

Definition at line 512 of file ParticleInjectorNEU/ParticleInjector.cc.

References ERROR, utl::Branch::Get(), utl::Branch::GetChild(), and max.

Referenced by Init().

void ParticleInjectorNEU::ParticleInjector::ParticleInjectorConfiguration ( )
private
ParticleInjectorNEU::ParticleInjector::REGISTER_MODULE ( "ParticleInjectorNEU"  ,
ParticleInjector   
)
private
VModule::ResultFlag ParticleInjectorNEU::ParticleInjector::Run ( evt::Event event)
virtual

Run: invoked once per event.

This method is for things that should be done once per event {You must override this method in your concrete module}

Implements fwk::VModule.

Definition at line 249 of file ParticleInjectorNEU/ParticleInjector.cc.

References fwk::VModule::eSuccess, fCreateEvent, fEventTime, fSingleTankID, fUseSingleTank, evt::Event::HasMEvent(), evt::Event::HasSEvent(), and InjectParticles().

ResultFlag fwk::VModule::RunWithTiming ( evt::Event event)
inlineinherited

Member Data Documentation

utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fAzimuthDistribution = nullptr
private

Definition at line 106 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GenerateAzimuth(), and Init().

std::string ParticleInjectorNEU::ParticleInjector::fContinuousAzimuthString
private

Definition at line 98 of file ParticleInjectorNEU/ParticleInjector.h.

std::string ParticleInjectorNEU::ParticleInjector::fContinuousTimeString
private

Definition at line 99 of file ParticleInjectorNEU/ParticleInjector.h.

std::string ParticleInjectorNEU::ParticleInjector::fContinuousZenithString
private

Definition at line 97 of file ParticleInjectorNEU/ParticleInjector.h.

bool ParticleInjectorNEU::ParticleInjector::fCreateEvent = false
private

Definition at line 84 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), ParticleInjectorConfiguration(), and Run().

utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fDefaultEnergyDistribution = nullptr
private

Definition at line 116 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GenerateEnergy(), and Init().

std::vector<double> ParticleInjectorNEU::ParticleInjector::fDiscreteAzimuth
private

Definition at line 91 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by GenerateAzimuth(), and Init().

std::vector<double> ParticleInjectorNEU::ParticleInjector::fDiscreteParticleTime
private

Definition at line 93 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by GenerateTime(), and Init().

std::vector<double> ParticleInjectorNEU::ParticleInjector::fDiscreteZenith
private

Definition at line 92 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by GenerateZenith(), and Init().

utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fElectronEnergyDistribution = nullptr
private

Definition at line 118 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GenerateEnergy(), and Init().

utl::TimeStamp ParticleInjectorNEU::ParticleInjector::fEventTime
private
std::vector<double> ParticleInjectorNEU::ParticleInjector::fFixedEnergy
private

Definition at line 95 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by GenerateEnergy(), and Init().

utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fGammaEnergyDistribution = nullptr
private

Definition at line 119 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GenerateEnergy(), and Init().

const double ParticleInjectorNEU::ParticleInjector::fgFarAway2 = utl::Sqr(1000*utl::kilometer)
static

Definition at line 50 of file ParticleInjectorNEU/ParticleInjector.h.

double ParticleInjectorNEU::ParticleInjector::fHeight = 1.5*utl::meter
private

Definition at line 115 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by GeneratePosition(), and Init().

int fwk::VModule::fInfoLevel = 0
protectedinherited
unsigned int ParticleInjectorNEU::ParticleInjector::fMinMomentum = 0
private

Definition at line 130 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), and InjectParticles().

utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fMuonEnergyDistribution = nullptr
private

Definition at line 117 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GenerateEnergy(), and Init().

unsigned int ParticleInjectorNEU::ParticleInjector::fNumberOfEntries = 0
private

Definition at line 129 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), and InjectParticles().

std::vector<utl::Particle::Type> ParticleInjectorNEU::ParticleInjector::fParticles
private
PositionFlag ParticleInjectorNEU::ParticleInjector::fPositionFlag = eNone
private
std::string ParticleInjectorNEU::ParticleInjector::fPropagate = "no"
private

Definition at line 121 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), and InjectParticles().

double ParticleInjectorNEU::ParticleInjector::fRadius = 5*utl::meter
private

Definition at line 114 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by GeneratePosition(), and Init().

utl::RandomEngine::RandomEngineType& ParticleInjectorNEU::ParticleInjector::fRandomEngine
private
bool ParticleInjectorNEU::ParticleInjector::fRandomEntries = false
private

Definition at line 128 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), and InjectParticles().

RandomPart ParticleInjectorNEU::ParticleInjector::fRandomParticle
private

Definition at line 127 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), and InjectParticles().

TChain* ParticleInjectorNEU::ParticleInjector::fRandomTree = nullptr
private

Definition at line 126 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), Init(), and InjectParticles().

unsigned int ParticleInjectorNEU::ParticleInjector::fSingleTankID = 0
private

Definition at line 85 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), ParticleInjectorConfiguration(), and Run().

bool ParticleInjectorNEU::ParticleInjector::fUseSingleTank = false
private

Definition at line 82 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Init(), ParticleInjectorConfiguration(), and Run().

double ParticleInjectorNEU::ParticleInjector::fX = 0
private
utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fXDistribution = nullptr
private

Definition at line 101 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GeneratePosition(), and Init().

double ParticleInjectorNEU::ParticleInjector::fY = 0
private
utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fYDistribution = nullptr
private

Definition at line 102 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GeneratePosition(), and Init().

double ParticleInjectorNEU::ParticleInjector::fZ = 0
private
utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fZDistribution = nullptr
private

Definition at line 103 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GeneratePosition(), and Init().

utl::VRandomSampler* ParticleInjectorNEU::ParticleInjector::fZenithDistribution = nullptr
private

Definition at line 105 of file ParticleInjectorNEU/ParticleInjector.h.

Referenced by Finish(), GenerateZenith(), and Init().


The documentation for this class was generated from the following files:

, generated on Tue Sep 26 2023.