Module to inject particles into a tank. More...
#include <ParticleInjectorNEU/ParticleInjector.h>
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::Stopwatch & | GetStopwatch () |
const utl::Stopwatch & | GetStopwatch () 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::VRandomSampler * | LoadRandomSampler (const utl::Branch &branch) |
void | ParticleInjectorConfiguration () |
REGISTER_MODULE ("ParticleInjectorNEU", ParticleInjector) | |
Module to inject particles into a tank.
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 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>
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:
<Energy> <Discrete> <x unit="GeV"> 1 2 </x> <y> 2 1 </y> </Discrete> </Energy>
<Energy> <x unit='MeV'> 150 500 1000 </x> <y> 1 1 0.5 </y> <scaleY> 1 </scaleY> </Energy>
<Energy> <PDF> 1/x </PDF> <min unit='MeV'> 100 </min> <max unit='GeV'> 1 </max> </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.
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>
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...
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>
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.
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.
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.
Finally, at the end, you can add the tag
<DumpConfiguration/>
If you want the injector to show how it is configured in the screen.
Definition at line 40 of file ParticleInjectorNEU/ParticleInjector.h.
|
protectedinherited |
|
private |
Enumerator | |
---|---|
eNone | |
eFixed | |
eDisk | |
eSphere | |
ePDF |
Definition at line 53 of file ParticleInjectorNEU/ParticleInjector.h.
|
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. |
|
inherited |
ParticleInjectorNEU::ParticleInjector::ParticleInjector | ( | ) |
Definition at line 68 of file ParticleInjectorNEU/ParticleInjector.cc.
|
inlinevirtual |
Definition at line 44 of file ParticleInjectorNEU/ParticleInjector.h.
|
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.
|
private |
Definition at line 408 of file ParticleInjectorNEU/ParticleInjector.cc.
References fAzimuthDistribution, fDiscreteAzimuth, fRandomEngine, and utl::VRandomSampler::shoot().
Referenced by InjectParticles().
|
private |
Definition at line 434 of file ParticleInjectorNEU/ParticleInjector.cc.
References utl::Particle::eAntiMuon, utl::Particle::eElectron, utl::Particle::eMuon, utl::Particle::ePhoton, utl::Particle::ePositron, fDefaultEnergyDistribution, fElectronEnergyDistribution, fFixedEnergy, fGammaEnergyDistribution, fMuonEnergyDistribution, fRandomEngine, INFO, and utl::VRandomSampler::shoot().
Referenced by InjectParticles().
|
private |
Definition at line 475 of file ParticleInjectorNEU/ParticleInjector.cc.
References eDisk, eFixed, eSphere, fHeight, fPositionFlag, fRadius, fRandomEngine, fX, fXDistribution, fY, fYDistribution, fZ, fZDistribution, utl::kTwoPi, utl::VRandomSampler::shoot(), utl::Sqr(), and sqrt().
Referenced by InjectParticles().
|
private |
Definition at line 466 of file ParticleInjectorNEU/ParticleInjector.cc.
References fDiscreteParticleTime, and fRandomEngine.
Referenced by InjectParticles().
|
private |
Definition at line 421 of file ParticleInjectorNEU/ParticleInjector.cc.
References fDiscreteZenith, fRandomEngine, fZenithDistribution, and utl::VRandomSampler::shoot().
Referenced by InjectParticles().
|
staticinherited |
Definition at line 8 of file VModule.cc.
References fwk::VModule::eBreakLoop, fwk::VModule::eContinueLoop, fwk::VModule::eFailure, and fwk::VModule::eSuccess.
Referenced by fwk::RunController::DoNextInSequence(), fwk::RunController::FinishBranch(), and fwk::RunController::InitBranch().
|
inlineinherited |
Definition at line 106 of file VModule.h.
References fwk::VModule::fStopwatch.
|
inlineinherited |
Definition at line 107 of file VModule.h.
References fwk::VModule::fStopwatch.
|
inherited |
Retrieve different sorts of module version info.
Definition at line 26 of file VModule.cc.
Referenced by fwk::CentralConfig::GetConfig(), ThresholdCalculatorKG::ThresholdCalculator::Init(), fdDoubleBumpFinder::FdDoubleBumpFinder::Init(), LaserGeneratorNA::LaserGenerator::Init(), LaserLightSimulatorNA::LaserLightSimulator::Init(), FdElectronicsSimulatorOG::FdElectronicsSimulator::Init(), TelescopeSimulatorKG::TelescopeSimulator::Init(), TelescopeSimulatorKG2::TelescopeSimulator::Init(), SdSimpleSimKG::SdSimpleSim::Init(), ShowerPhotonGeneratorOG::ShowerPhotonGenerator::Init(), and testRunController::testModuleVersionInfo().
|
virtual |
Initialize: invoked at beginning of run (NOT beginning of event)
This method is for things that should be done once at the beginning of a run (for example, booking histograms, performing calculations that need to be done only once, initializing parameters) {You must override this method in your concrete module}
Implements fwk::VModule.
Definition at line 104 of file ParticleInjectorNEU/ParticleInjector.cc.
References eDisk, fwk::VModule::eFailure, eFixed, ePDF, ERROR, eSphere, fwk::VModule::eSuccess, fAzimuthDistribution, fCreateEvent, fDefaultEnergyDistribution, fDiscreteAzimuth, fDiscreteParticleTime, fDiscreteZenith, fElectronEnergyDistribution, fEventTime, fFixedEnergy, fGammaEnergyDistribution, fHeight, filename, fMinMomentum, fMuonEnergyDistribution, fNumberOfEntries, fParticles, fPositionFlag, fPropagate, ParticleInjectorNEU::ParticleInjector::RandomPart::fPx, ParticleInjectorNEU::ParticleInjector::RandomPart::fPy, ParticleInjectorNEU::ParticleInjector::RandomPart::fPz, fRadius, fRandomEntries, fRandomParticle, fRandomTree, ParticleInjectorNEU::ParticleInjector::RandomPart::fSecondaryId, fSingleTankID, fUseSingleTank, fX, fXDistribution, fY, fYDistribution, fZ, fZDistribution, fZenithDistribution, INFO, LoadRandomSampler(), ParticleInjectorConfiguration(), utl::Sqr(), sqrt(), and utl::StringEquivalent().
|
inlineinherited |
Definition at line 95 of file VModule.h.
References fwk::VModule::fStopwatch, and utl::Stopwatch::Reset().
|
private |
Definition at line 319 of file ParticleInjectorNEU/ParticleInjector.cc.
References sevt::Station::AddParticle(), io::Corsika::CorsikaToPDG(), utl::Particle::eBackground, utl::Particle::eUndefined, fMinMomentum, fNumberOfEntries, fParticles, fPropagate, ParticleInjectorNEU::ParticleInjector::RandomPart::fPx, ParticleInjectorNEU::ParticleInjector::RandomPart::fPy, ParticleInjectorNEU::ParticleInjector::RandomPart::fPz, fRandomEngine, fRandomEntries, fRandomParticle, fRandomTree, ParticleInjectorNEU::ParticleInjector::RandomPart::fSecondaryId, GenerateAzimuth(), GenerateEnergy(), GeneratePosition(), GenerateTime(), GenerateZenith(), utl::Particle::GetDirection(), utl::Vector::GetMag(), utl::Particle::GetPosition(), utl::GeV, sevt::Station::HasSimData(), INFO, utl::NucleusProperties::IsNucleus(), sevt::Station::MakeSimData(), particle, utl::String::Plural(), utl::Particle::SetPosition(), and utl::StringEquivalent().
Referenced by Run().
|
private |
Definition at line 512 of file ParticleInjectorNEU/ParticleInjector.cc.
References ERROR, utl::Branch::Get(), utl::Branch::GetChild(), and max.
Referenced by Init().
|
private |
Definition at line 74 of file ParticleInjectorNEU/ParticleInjector.cc.
References eDisk, eFixed, ePDF, eSphere, fCreateEvent, fEventTime, fParticles, fPositionFlag, fSingleTankID, fUseSingleTank, fX, fY, fZ, and INFO.
Referenced by Init().
|
private |
|
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().
|
inlineinherited |
Definition at line 98 of file VModule.h.
References fwk::VModule::fStopwatch, fwk::VModule::Run(), utl::Stopwatch::Start(), and utl::Stopwatch::Stop().
Referenced by fwk::RunController::DoNextInSequence().
|
private |
Definition at line 106 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GenerateAzimuth(), and Init().
|
private |
Definition at line 98 of file ParticleInjectorNEU/ParticleInjector.h.
|
private |
Definition at line 99 of file ParticleInjectorNEU/ParticleInjector.h.
|
private |
Definition at line 97 of file ParticleInjectorNEU/ParticleInjector.h.
|
private |
Definition at line 84 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), ParticleInjectorConfiguration(), and Run().
|
private |
Definition at line 116 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GenerateEnergy(), and Init().
|
private |
Definition at line 91 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GenerateAzimuth(), and Init().
|
private |
Definition at line 93 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GenerateTime(), and Init().
|
private |
Definition at line 92 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GenerateZenith(), and Init().
|
private |
Definition at line 118 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GenerateEnergy(), and Init().
|
private |
Definition at line 110 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), ParticleInjectorConfiguration(), and Run().
|
private |
Definition at line 95 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GenerateEnergy(), and Init().
|
private |
Definition at line 119 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GenerateEnergy(), and Init().
|
static |
Definition at line 50 of file ParticleInjectorNEU/ParticleInjector.h.
|
private |
Definition at line 115 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GeneratePosition(), and Init().
|
protectedinherited |
Definition at line 123 of file VModule.h.
Referenced by RdChannelASCIINoiseImporterRD::RdChannelASCIINoiseImporterRD::Init(), Rd2dLDFFitter::Rd2dLDFFitter::Init(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::Init(), and Rd2dLDFFitter::Rd2dLDFFitter::Run().
|
private |
Definition at line 130 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), and InjectParticles().
|
private |
Definition at line 117 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GenerateEnergy(), and Init().
|
private |
Definition at line 129 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), and InjectParticles().
|
private |
Definition at line 108 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), InjectParticles(), and ParticleInjectorConfiguration().
|
private |
Definition at line 81 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GeneratePosition(), Init(), and ParticleInjectorConfiguration().
|
private |
Definition at line 121 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), and InjectParticles().
|
private |
Definition at line 114 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GeneratePosition(), and Init().
|
private |
Definition at line 112 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GenerateAzimuth(), GenerateEnergy(), GeneratePosition(), GenerateTime(), GenerateZenith(), and InjectParticles().
|
private |
Definition at line 128 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), and InjectParticles().
|
private |
Definition at line 127 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), and InjectParticles().
|
private |
Definition at line 126 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), Init(), and InjectParticles().
|
private |
Definition at line 85 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), ParticleInjectorConfiguration(), and Run().
|
private |
Definition at line 82 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Init(), ParticleInjectorConfiguration(), and Run().
|
private |
Definition at line 87 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GeneratePosition(), Init(), and ParticleInjectorConfiguration().
|
private |
Definition at line 101 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GeneratePosition(), and Init().
|
private |
Definition at line 88 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GeneratePosition(), Init(), and ParticleInjectorConfiguration().
|
private |
Definition at line 102 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GeneratePosition(), and Init().
|
private |
Definition at line 89 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by GeneratePosition(), Init(), and ParticleInjectorConfiguration().
|
private |
Definition at line 103 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GeneratePosition(), and Init().
|
private |
Definition at line 105 of file ParticleInjectorNEU/ParticleInjector.h.
Referenced by Finish(), GenerateZenith(), and Init().