25 #include "canvas/Persistency/Common/FindOneP.h" 47 class MergeSimSources;
62 fhicl::Comment{
"offset to add to the MC particles from each source" }
67 fhicl::Comment{
"whether to merge also photons from reflections" },
98 {
"merges energy deposit collection; if omitted, follows LArG4Parmeters" }
103 fhicl::Comment{
"labels of sim::SimEnergyDeposit collections to merge" },
104 std::vector<std::string>{
"TPCActive",
"Other" }
110 {
"whether to merge aux det hit collections" },
117 std::vector<std::string>{
"LArG4DetectorServicevolAuxDetSensitiveCRTStripY",
"Other" }
153 template <
typename Optional>
154 std::optional<typename Optional::value_type>
155 getOptionalValue(Optional
const&
parameter) {
157 using Value_t =
typename Optional::value_type;
159 if (!parameter.hasValue())
return std::nullopt;
184 getOptionalValue(
params().FillSimEnergyDeposits).value_or
194 <<
"Unequal input vector sizes: InputSourcesLabels and TrackIDOffsets.\n";
201 consumes<std::vector<simb::MCParticle>>(
tag);
202 consumes<art::Assns<simb::MCParticle, simb::MCTruth, sim::GeneratedParticleInfo>>(
tag);
206 consumes<std::vector<sim::SimChannel>>(
tag);
210 consumes<std::vector<sim::AuxDetSimChannel>>(
tag);
215 else consumes<std::vector<sim::SimPhotonsLite>>(
tag);
219 if (!
fUseLitePhotons) consumes<std::vector<sim::SimPhotons>>(reflected_tag);
220 else consumes<std::vector<sim::SimPhotonsLite>>(reflected_tag);
227 consumes<std::vector<sim::SimEnergyDeposit>>(edep_tag);
234 consumes<std::vector<sim::AuxDetHit>>(auxdethit_tag);
242 produces< std::vector<simb::MCParticle> >();
243 produces< art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo> >();
246 produces< std::vector<sim::SimChannel> >();
249 produces< std::vector<sim::AuxDetSimChannel> >();
254 else produces< std::vector<sim::SimPhotonsLite> >();
258 else produces< std::vector<sim::SimPhotonsLite> >(
ReflectedLabel);
264 produces< std::vector<sim::SimEnergyDeposit> >(edep_inst);
269 produces< std::vector<sim::AuxDetHit> >(auxdethit_inst);
280 auto partCol = std::make_unique<std::vector<simb::MCParticle>>();
281 auto scCol = std::make_unique<std::vector<sim::SimChannel>>();
282 auto PhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
283 auto LitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
284 auto ReflPhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
285 auto ReflLitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
286 auto tpassn = std::make_unique<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
287 auto adCol = std::make_unique<std::vector<sim::AuxDetSimChannel>>();
289 using edeps_t = std::vector<sim::SimEnergyDeposit>;
290 std::vector<edeps_t> edepCols;
294 using aux_det_hits_t = std::vector<sim::AuxDetHit>;
295 std::vector<aux_det_hits_t> auxdethitCols;
306 auto const input_partCol
308 MergeUtility.MergeMCParticles(*partCol,*input_partCol,i_source);
311 const std::vector<size_t>& assocVectorPrimitive
312 = MergeUtility.GetMCParticleListMap().at(i_source);
313 art::FindOneP<simb::MCTruth, sim::GeneratedParticleInfo> mctAssn(input_partCol,e,input_label);
315 tpassn->addSingle(mctAssn.at(i_p), makePartPtr(assocVectorPrimitive[i_p]), mctAssn.data(i_p).ref());
319 auto const& input_scCol
320 = e.
getProduct<std::vector<sim::SimChannel>>(input_label);
321 MergeUtility.MergeSimChannels(*scCol,input_scCol,i_source);
325 auto const& input_adCol
326 = e.
getProduct<std::vector<sim::AuxDetSimChannel>>(input_label);
327 MergeUtility.MergeAuxDetSimChannels(*adCol,input_adCol,i_source);
332 auto const& input_PhotonCol
333 = e.
getProduct<std::vector<sim::SimPhotons>>(input_label);
334 MergeUtility.MergeSimPhotons(*PhotonCol,input_PhotonCol);
337 auto const& input_LitePhotonCol
338 = e.
getProduct<std::vector<sim::SimPhotonsLite>>(input_label);
339 MergeUtility.MergeSimPhotonsLite(*LitePhotonCol,input_LitePhotonCol);
346 auto const& input_PhotonCol
347 = e.
getProduct<std::vector<sim::SimPhotons>>(input_reflected_label);
348 MergeUtility.MergeSimPhotons(*ReflPhotonCol,input_PhotonCol);
351 auto const& input_LitePhotonCol
352 = e.
getProduct<std::vector<sim::SimPhotonsLite>>(input_reflected_label);
353 MergeUtility.MergeSimPhotonsLite(*ReflLitePhotonCol,input_LitePhotonCol);
360 for (
auto const& [ edep_inst, edepCol ]
364 MergeUtility.MergeSimEnergyDeposits(edepCol,
372 for (
auto const& [ auxdethit_inst, auxdethitCol ]
376 MergeUtility.MergeAuxDetHits(auxdethitCol,
404 for (
auto&& [ edep_inst, edepCol ]
407 e.
put(std::make_unique<edeps_t>(
move(edepCol)), edep_inst);
412 for (
auto&& [ auxdethit_inst, auxdethitCol ]
415 e.
put(std::make_unique<aux_det_hits_t>(
move(auxdethitCol)), auxdethit_inst);
425 log <<
"Configuration:" 427 for (
auto const& [ i_source,
tag, offset ]
430 log <<
"\n [" << i_source <<
"] '" <<
tag.encode()
431 <<
"' (ID offset: " << offset <<
")";
440 log <<
"\n - filling Simulated Photons";
441 if (
fUseLitePhotons) log <<
"\n - using photon summary (`SimPhotonsLite`)";
442 else log <<
"\n - using detailed photons (`SimPhotons`)";
447 log <<
"\n - filling simulated energy deposits (" 450 log <<
" '" <<
label <<
"'";
455 log <<
"\n - filling auxiliary detector hits (" 458 log <<
" '" <<
label <<
"'";
bool const fFillSimChannels
bool const fFillMCParticles
Store parameters for running LArG4.
MergeSimSources(Parameters const &config)
fhicl::Sequence< int > TrackIDOffsets
Definition of util::zip().
Definition of util::enumerate().
bool const fFillSimEnergyDeposits
EDProducer(fhicl::ParameterSet const &pset)
fhicl::Atom< bool > FillAuxDetSimChannels
fhicl::OptionalAtom< bool > FillSimEnergyDeposits
static Argument * parameter
fhicl::Atom< bool > FillSimChannels
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
fhicl::Sequence< std::string > EnergyDepositInstanceLabels
std::vector< art::InputTag > const fInputSourcesLabels
bool const fUseLitePhotons
Simulation objects for optical detectors.
std::vector< std::string > const fAuxDetHitsInstanceLabels
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
#define DEFINE_ART_MODULE(klass)
bool const fFillSimPhotons
fhicl::Atom< bool > FillSimPhotons
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< int > const fTrackIDOffsets
Test of util::counter and support utilities.
void dumpConfiguration() const
Code to link reconstructed objects back to the MC truth information.
fhicl::Atom< bool > StoreReflected
void produce(art::Event &e) override
fhicl::Sequence< std::string > AuxDetHitsInstanceLabels
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
static std::string const ReflectedLabel
fhicl::Atom< bool > FillMCParticles
bool const fStoreReflected
Contains data associated to particles from detector simulation.
bool const fFillAuxDetHits
contains information for a single step in the detector simulation
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
fhicl::Atom< bool > FillAuxDetHits
bool const fFillAuxDetSimChannels
PROD const & getProduct(InputTag const &tag) const
fhicl::Sequence< art::InputTag > InputSourcesLabels
std::vector< std::string > const fEnergyDepositionInstances