62 #include "art/Framework/Core/EDProducer.h"
63 #include "art/Framework/Core/ModuleMacros.h"
64 #include "art/Framework/Principal/Event.h"
65 #include "art/Framework/Principal/Handle.h"
66 #include "fhiclcpp/ParameterSet.h"
67 #include "messagefacility/MessageLogger/MessageLogger.h"
68 #include "nurandom/RandomUtils/NuRandomService.h"
69 #include "canvas/Persistency/Common/Ptr.h"
70 #include "canvas/Persistency/Common/PtrVector.h"
71 #include "canvas/Persistency/Common/Assns.h"
72 #include "art/Persistency/Common/PtrMaker.h"
112 explicit CRTDetSim(fhicl::ParameterSet
const &
p);
120 void produce(art::Event &
e)
override;
137 fRandEngine(art::ServiceHandle<rndm::NuRandomService>()->createEngine(*
this,
"HepJamesRandom",
"crt",
p,
"Seed")),
138 detAlg(
p.get<fhicl::ParameterSet>(
"DetSimAlg"),fRandEngine)
142 produces< vector<CRTData> >();
143 produces< vector<sim::AuxDetIDE> >();
144 produces< art::Assns<CRTData, sim::AuxDetIDE> >();
151 std::unique_ptr< vector<CRTData> > triggeredCRTHits (
152 new vector<CRTData>);
154 std::unique_ptr< vector<sim::AuxDetIDE> > ides (
155 new vector<sim::AuxDetIDE>);
157 std::unique_ptr< art::Assns<CRTData,sim::AuxDetIDE> > dataAssn (
158 new art::Assns<CRTData,sim::AuxDetIDE> );
159 art::PtrMaker<CRTData> makeDataPtr(event);
160 art::PtrMaker<sim::AuxDetIDE> makeIDEPtr(event);
163 detAlg.ClearTaggers();
166 art::Handle< vector<sim::AuxDetSimChannel> > adChanHandle;;
167 vector< art::Ptr<sim::AuxDetSimChannel> > adChanList;
168 if (event.getByLabel(fG4ModuleLabel, adChanHandle) )
169 art::fill_ptr_vector(adChanList, adChanHandle);
171 mf::LogInfo(
"CRTDetSimProducer")
172 <<
"Number of AuxDetChannels = " << adChanList.size();
175 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(event);
176 for(
auto const& adsc : adChanList) {
178 auto const& auxDetIDEs = adsc->AuxDetIDEs();
179 if(auxDetIDEs.size()>0) {
181 detAlg.FillTaggers(clockData, adsc->AuxDetID(), adsc->AuxDetSensitiveID(), auxDetIDEs);
189 vector<std::pair<CRTData,vector<sim::AuxDetIDE>>> data = detAlg.CreateData();
191 std::sort(data.begin(),data.end(),
192 [](
const std::pair<CRTData,vector<sim::AuxDetIDE>>& d1,
193 const std::pair<CRTData,vector<sim::AuxDetIDE>>& d2) {
194 return d1.first.fTs0 < d2.first.fTs0;
197 for(
auto const& dataPair : data){
199 triggeredCRTHits->push_back(dataPair.first);
200 art::Ptr<CRTData> dataPtr = makeDataPtr(triggeredCRTHits->size()-1);
203 for(
auto const& ide : dataPair.second){
204 ides->push_back(ide);
205 art::Ptr<sim::AuxDetIDE> idePtr = makeIDEPtr(ides->size()-1);
206 dataAssn->addSingle(dataPtr, idePtr);
213 mf::LogWarning(
"CRTDetSimProducer")
214 <<
"0 CRTData produced (expected for most neutrino events, never for cosmics)";
217 event.put(std::move(triggeredCRTHits));
218 event.put(std::move(ides));
219 event.put(std::move(dataAssn));
221 mf::LogInfo(
"CRTDetSimProducer")
222 <<
"Number of CRT data produced = "<< nData <<
'\n'
223 <<
" from " << nide <<
" AuxDetIDEs";
Functions to help with numbers.
CLHEP::HepRandomEngine & fRandEngine
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
void produce(art::Event &e) override
art framework interface to geometry description for auxiliary detectors
Encapsulate the geometry of an auxiliary detector.
CRTDetSim(fhicl::ParameterSet const &p)
void reconfigure(fhicl::ParameterSet const &p)
CRTDetSim & operator=(CRTDetSim const &)=delete
Class def header for a class ElecClock.
art framework interface to geometry description