7 #include "art/Framework/Core/EDProducer.h"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Framework/Principal/Event.h"
10 #include "art/Framework/Principal/Handle.h"
11 #include "fhiclcpp/ParameterSet.h"
12 #include "messagefacility/MessageLogger/MessageLogger.h"
13 #include "nurandom/RandomUtils/NuRandomService.h"
14 #include "canvas/Persistency/Common/Ptr.h"
15 #include "canvas/Persistency/Common/Assns.h"
16 #include "art/Persistency/Common/PtrMaker.h"
27 #include "CLHEP/Random/RandomEngine.h"
28 #include "CLHEP/Random/RandFlat.h"
29 #include "CLHEP/Random/RandGauss.h"
30 #include "CLHEP/Random/RandPoisson.h"
34 #include "TGeoManager.h"
55 ,
fEngine(art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*
this,
"HepJamesRandom",
"crt",
p,
"Seed"))
56 ,
fG4RefTime(art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob().G4ToElecTime(0) * 1e3)
61 produces<std::vector<sbnd::crt::FEBData> >();
62 produces<std::vector<sim::AuxDetIDE> >();
63 produces<art::Assns<sbnd::crt::FEBData , sim::AuxDetIDE , sbnd::crt::FEBTruthInfo>>();
65 consumes<std::vector<sim::AuxDetSimChannel>>(fG4ModuleLabel);
72 std::unique_ptr<std::vector<sbnd::crt::FEBData> > FEBDataOut(
new std::vector<sbnd::crt::FEBData>);
73 art::PtrMaker<sbnd::crt::FEBData> makeDataPtr(e);
75 std::unique_ptr<std::vector<sim::AuxDetIDE> > auxDetIdes(
new std::vector<sim::AuxDetIDE>);
76 art::PtrMaker<sim::AuxDetIDE> makeIdePtr(e);
78 std::unique_ptr<art::Assns<sbnd::crt::FEBData, sim::AuxDetIDE, sbnd::crt::FEBTruthInfo>> Dataassn
79 (
new art::Assns<sbnd::crt::FEBData, sim::AuxDetIDE, sbnd::crt::FEBTruthInfo>);
82 art::Handle<std::vector<sim::AuxDetSimChannel> > channels;
85 if (!channels.isValid()) {
86 mf::LogWarning(
"CRTDetSim") <<
"No AuxDetSimChannel..." << std::endl;
95 for(
auto const& adsc : *channels) {
97 if(adsc.AuxDetID() == UINT_MAX || adsc.AuxDetSensitiveID() == UINT_MAX) {
98 mf::LogWarning(
"CRTDetSim") <<
"AuxDetSimChannel with ID: UINT_MAX\n"
99 <<
"skipping channel...";
103 if(adsc.AuxDetIDEs().size() > 0) {
104 mf::LogDebug(
"CRTDetSim") <<
"Adding AuxDetSimChannel with AuxDetID " << adsc.AuxDetID()
105 <<
", AuxDetSensitiveID " << adsc.AuxDetSensitiveID() << std::endl;
117 std::vector<std::pair<sbnd::crt::FEBData, std::vector<sim::AuxDetIDE>>> data =
fDetAlg.
GetData();
125 for (
size_t i = 0; i < data.size(); i++) {
127 auto & dataPair = data[i];
128 auto & feb = dataPair.first;
129 auto & ides = dataPair.second;
130 auto & idxs = auxdata.at(i);
132 FEBDataOut->push_back(feb);
133 art::Ptr<FEBData> dataPtr = makeDataPtr(FEBDataOut->size()-1);
135 for(
size_t j = 0; j < ides.size(); j++){
136 auto const& ide = ides[j];
137 auxDetIdes->push_back(ide);
139 mf::LogDebug(
"CRTDetSim") <<
"Adding " << idxs[j] <<
" to FEBTruthInfo." << std::endl;
140 art::Ptr<sim::AuxDetIDE> idePtr = makeIdePtr(auxDetIdes->size()-1);
141 Dataassn->addSingle(dataPtr, idePtr, feb_truth_info);
145 mf::LogInfo(
"CRTDetSim") <<
"Number of FEBData objects produced: " << FEBDataOut->size() <<
"\n";
147 e.put(std::move(FEBDataOut));
148 e.put(std::move(auxDetIdes));
149 e.put(std::move(Dataassn));
Functions to help with numbers.
Encapsulate the construction of a single cyostat.
std::vector< std::pair< sbnd::crt::FEBData, std::vector< AuxDetIDE > > > GetData()
void FillTaggers(const uint32_t adid, const uint32_t adsid, std::vector< AuxDetIDE > ides)
createEngine fDetAlg(p.get< fhicl::ParameterSet >("DetSimParams"), fEngine, fG4RefTime)
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::string fG4ModuleLabel
std::vector< std::vector< int > > GetAuxData()
art framework interface to geometry description for auxiliary detectors
fEngine(art::ServiceHandle< rndm::NuRandomService >() ->createEngine(*this, pset,"Seed"))
void produce(art::Event &e) override
Encapsulate the geometry of an auxiliary detector.
CRTDetSim(fhicl::ParameterSet const &p)
void reconfigure(fhicl::ParameterSet const &p)
createEngine fG4RefTime(art::ServiceHandle< detinfo::DetectorClocksService const >() ->DataForJob().G4ToElecTime(0)*1e3)
Class def header for a class ElecClock.
stream1 can override from command line with o or output services user sbnd
CRTDetSimAlg fDetAlg
Instance of the CRT detector simulation algorithm.
art framework interface to geometry description