3 #include <fwk/CentralConfig.h>
4 #include <fwk/RandomEngineRegistry.h>
6 #include <det/Detector.h>
7 #include <evt/ShowerSimData.h>
9 #include <mevt/Counter.h>
10 #include <mevt/CounterSimData.h>
12 #include <sevt/SEvent.h>
13 #include <sevt/Station.h>
14 #include <sevt/StationTriggerData.h>
15 #include <sevt/StationSimData.h>
16 #include <sdet/SDetector.h>
18 #include <utl/ConfigUtils.h>
19 #include <utl/ErrorLogger.h>
20 #include <utl/Reader.h>
21 #include <utl/Particle.h>
22 #include <utl/ShowerParticleIterator.h>
23 #include <utl/TimeDistribution.h>
24 #include <utl/TimeDistributionAlgorithm.h>
25 #include <utl/AugerUnits.h>
26 #include <utl/GeometryUtilities.h>
27 #include <utl/AxialVector.h>
41 using namespace UnderGrdInjectorAG;
44 const double UnderGrdInjector::kTriggerDelay = 0.*
utl::ns;
47 UnderGrdInjector::UnderGrdInjector() :
56 INFO(
"\n++++\nReading XML parameters");
70 INFO(
"\n++++\nStarting MdUnderGrdInjector run\n++++");
73 ERROR(
"MEvent does not exist.");
77 MEvent& mEvent =
event.GetMEvent();
78 INFO(
"\n++++\nMEvent retrieved\n++++");
80 utl::TimeStamp eventTime =
event.GetMEvent().GetHeader().GetTime();
84 const mdet::MDetector& mDetector = det::Detector::GetInstance().GetMDetector();
87 ERROR(
"SEvent does not exist. Do not use UseT1FromSD");
94 ofstream ofile (
"stats_injected.ascii");
95 ofile <<
"CounterId ModuleId ScintId Particle X(m) Y(m) Z(m) Time(ns) intersected Parent T1(ns) EventGPS(s) EventGPSNano(ns)\n";
103 G4cerr << G4endl <<
"Recovering underground particles from counter " << cIt->GetId() << G4endl;
105 if (!cIt->HasSimData())
108 const int cId = cIt->GetId();
112 G4cerr << numParticles <<
" particles at depth level of Counter Id :" << cId << G4endl;
120 int modId = mmDet->GetId();
121 if (!cIt->HasModule(modId)) {
122 cIt->MakeModule(modId);
123 cIt->GetModule(modId).SetCandidate();
132 cout <<
"SD trigger found for counter " << cId <<
" at T1 " << T1/
utl::ns <<
"ns " <<endl;
133 cout <<
"Trigger is T" << triggerFound <<
"\n";
136 cout <<
"XXX NO SD trigger found for counter " << cId << endl;
151 bool injected =
false;
155 int MoIdx = mmDet->GetId();
157 if (!cIt->HasModule(MoIdx))
158 cIt->MakeModule(MoIdx);
179 mmDet->ScintillatorsBegin()->VisitShape(sbox).GetDimensions(l, w, h);
183 if (fabs(ppos.
GetY(mCS)) > 16.*w || fabs(ppos.
GetX(mCS)) > l + 0.4*
utl::m)
197 for (ScIt smDet = mmDet->ScintillatorsBegin(), esc = mmDet->ScintillatorsEnd(); smDet != esc; ++smDet) {
199 const int ScIdx = smDet->
GetId();
204 bool intersected = fabs(ppos.
GetX(sCS)) < 0.5*w && fabs(ppos.
GetY(sCS)) < 0.5*l;
220 const Point injectedPosition(ppos.
GetX(sCS), ppos.
GetY(sCS), 0.5*h, sCS);
232 << cId <<
" " << MoIdx <<
" " << ScIdx <<
" "
233 << pIt->GetType() <<
" "
234 << injectedPosition.GetX(cCS)/
utl::m <<
" "
235 << injectedPosition.GetY(cCS)/
utl::m <<
" "
236 << injectedPosition.GetZ(cCS)/
utl::m <<
" "
237 << interval.GetInterval()/
utl::ns <<
" "
238 << smDet->IntersectedBy(path) <<
" "
239 << pIt->GetParent().GetType() <<
" "
256 const int cId = cIt->GetId();
258 if (!cIt->HasSimData())
278 const int mId = mIt->GetId();
335 if (!mIt->HasChannel(ch->GetId()))
336 mIt->MakeChannel(ch->GetId());
365 if (!mIt->HasChannel(ch->GetId()))
366 mIt->MakeChannel(ch->GetId());
390 pIt->GetType() == Particle::eNuElectron ||
391 pIt->GetType() == Particle::eAntiNuElectron ||
392 pIt->GetType() == Particle::eNuMuon ||
393 pIt->GetType() == Particle::eAntiNuMuon ||
394 pIt->GetType() == Particle::eNuTau ||
395 pIt->GetType() == Particle::eAntiNuTau;
411 pIt->GetType() == Particle::ePiZero ||
412 pIt->GetType() == Particle::eKaon0L ||
413 pIt->GetType() == Particle::eKaon0S ||
414 pIt->GetType() == Particle::eNeutron ||
415 pIt->GetType() == Particle::eAntiNeutron;
430 ERROR(
"SEvent does not exist.");
438 ostringstream message;
439 message <<
"partner station with id " << partnerId <<
"was not found in SEvent\n";
445 const sdet::Station& detStation = Detector::GetInstance().GetSDetector().GetStation(sStation);
461 cout <<
"IsT1 " << trig.IsT1() <<
" - " <<
"IsT2 " << trig.IsT2() << endl;
463 if (!(trig.IsT2() || trig.IsT1()))
470 if (trigTime < firstT1Sd) {
471 cout <<
"There is a previous trigger\n";
472 firstT1Sd = trigTime;
474 cout <<
"Trigger time: " << trigTime << endl;
482 utl::TimeStamp eventTime =
event.GetMEvent().GetHeader().GetTime();
487 T1 = TstartTrace - eventTime;
489 cout <<
"eventTime " << eventTime << endl;
490 cout <<
"firstT1Sd " << firstT1Sd << endl;
491 cout <<
"TstartTrace " << TstartTrace << endl;
492 cout <<
"shift " << shift << endl;
493 cout <<
"T1 " << T1 << endl;
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Branch GetTopBranch() const
UGrdParticleIterator UGrdParticlesBegin()
Station Level Simulated Data
const Module & GetModule(const int mId) const
Retrieve by id a constant module.
CounterConstIterator CountersBegin() const
const utl::TimeStamp & GetTimeStamp() const
Get the TimeStamp of the absolute shower core-time.
bool HasStation(const int stationId) const
Check whether station exists.
Detector description interface for Station-related data.
Report success to RunController.
void SetPosition(const utl::Point &position)
bool HasScintillator(const int sId) const
ChannelGroup::ConstIterator ChannelConstIterator
Convenience typedef for const iterator over the contained mdet::Channel instances.
void MakeScintillator(const int sId)
UGrdParticleIterator UGrdParticlesEnd()
Interface class to access to the SD part of an event.
Describes a particle for Simulation.
ChannelConstIterator ChannelsEnd() const
End iterator over the contained channels.
unsigned int GetPostT1BufferLength() const
Number of bins of the post-T1 buffer.
bool HasSimShower() const
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Local system based on position and configured rotations.
#define INFO(message)
Macro for logging informational messages.
void AddParticle(const utl::Particle &particle)
Electronic front-end for the modules.
unsigned int GetPreT1BufferLength() const
Number of bins of the (cyclic) pre-T1 buffer.
const std::string & GetAlgorithmName() const
ModuleConstIterator ModulesEnd() const
Begin iterator for the Modules contained in the Counter.
Detector associated to muon detector hierarchy.
unsigned int GetNumberOfUGrdParticles() const
Electronic front-end for the modules.
A TimeStamp holds GPS second and nanosecond for some event.
void IncrementNumberOfInjectedMuons()
Interface class to access Shower Simulated parameters.
bool IsChargedParticle(mevt::ScintillatorSimData::ParticleIterator pIt)
Scintillator & GetScintillator(const int sId)
Scintillator level event data.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
sevt::StationTriggerData & GetTriggerData(const utl::TimeStamp &time)
Get simulated TriggerData.
Class representing a document branch.
class to hold data at Station level
ChannelGroup::ConstIterator ChannelConstIterator
Convenience typedef for const iterator over the contained mdet::Channel instances.
boost::indirect_iterator< InternalParticleIterator, utl::Particle & > ParticleIterator
ChannelConstIterator ChannelsBegin() const
Begin iterator over the contained channels.
bool HasSimData() const
Check whether station simulated data exists.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
double GetMeanSampleRatePeriod() const
Mean electronic sample rate period.
decltype(std::begin(boost::adaptors::keys(TriggerGPSMap()))) typedef TriggerTimeIterator
int GetTriggerTimeFromSD(evt::Event &event, const mdet::Counter &cmDet, double &T1)
int GetAssociatedTankId() const
Retrieve the id of the associated surface tank.
double GetMeanSampleRatePeriod() const
Mean electronic sample rate period.
void SetTraceStartTime(mevt::Counter::ModuleIterator mIt, const FrontEndType &frontEnd, const utl::TimeStamp &eventTime, const double &deltaLatch)
unsigned int GetPreT1BufferLength() const
Number of bins of the (cyclic) pre-T1 buffer.
ScintillatorGroup::ConstIterator ScintillatorConstIterator
Scintillator handling.
#define WARNING(message)
Macro for logging warning messages.
unsigned int GetPostT1BufferLength() const
Number of bins of the post-T1 buffer.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
const FrontEnd & GetFrontEnd() const
InternalModuleCollection::ComponentIterator ModuleIterator
TriggerTimeIterator TriggerTimesBegin() const
Beginning of simulated local trigger times list.
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
Root detector of the muon detector hierarchy.
Counter level simulation data.
boost::indirect_iterator< InternalUGrdParticleIterator, utl::Particle & > UGrdParticleIterator
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Scintillator level simulation data.
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
double GetFADCBinSize() const
unsigned long GetGPSSecond() const
GPS second.
InternalCounterCollection::ComponentIterator CounterIterator
double GetGPSNanoSecond() const
GPS nanosecond.
Station Trigger Data description
const FrontEndSiPM & GetFrontEndSiPM() const
ChannelConstIterator ChannelsBegin() const
Begin iterator over the contained channels.
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
ModuleConstIterator ModulesBegin() const
Begin iterator for the Modules contained in the Counter.
TriggerTimeIterator TriggerTimesEnd() const
End of simulated local trigger times list.
Report failure to RunController, causing RunController to terminate execution.
CounterConstIterator CountersEnd() const
unsigned int GetFADCTraceLength() const
bool IsNeutrino(mevt::ScintillatorSimData::ParticleIterator pIt)
ModuleGroup::ConstIterator ModuleConstIterator
Convenience typedef for const iterator over the contained Module instances.
sevt::StationSimData & GetSimData()
Get simulated data at station level.
const Counter & GetCounter(int id) const
Retrieve Counter by id.
#define ERROR(message)
Macro for logging error messages.
Root of the Muon event hierarchy.
ChannelConstIterator ChannelsEnd() const
End iterator over the contained channels.
ScintillatorSimData & GetSimData()