27 #include "range/v3/view/zip.hpp" 48 class MergeSimSources;
61 fhicl::Comment{
"offset to add to the MC particles from each source"}};
101 fhicl::Comment{
"merges energy deposit collection; if omitted, follows LArG4Parmeters"}};
105 fhicl::Comment{
"labels of sim::SimEnergyDeposit collections to merge"},
106 std::vector<std::string>{
"TPCActive",
"Other"}
118 std::vector<std::string>{
"LArG4DetectorServicevolAuxDetSensitiveCRTStripY",
159 template <
typename Optional>
160 std::optional<typename Optional::value_type> getOptionalValue(Optional
const& parameter)
163 using Value_t =
typename Optional::value_type;
165 if (!parameter.hasValue())
return std::nullopt;
189 getOptionalValue(params().FillSimEnergyDeposits)
199 <<
"Unequal input vector sizes: InputSourcesLabels and TrackIDOffsets.\n";
205 consumes<std::vector<simb::MCParticle>>(tag);
206 consumes<art::Assns<simb::MCParticle, simb::MCTruth, sim::GeneratedParticleInfo>>(tag);
215 consumes<std::vector<sim::SimPhotons>>(tag);
217 consumes<std::vector<sim::SimPhotonsLite>>(tag);
222 consumes<std::vector<sim::SimPhotons>>(reflected_tag);
224 consumes<std::vector<sim::SimPhotonsLite>>(reflected_tag);
231 consumes<std::vector<sim::SimEnergyDeposit>>(edep_tag);
238 consumes<std::vector<sim::AuxDetHit>>(auxdethit_tag);
247 produces<std::vector<simb::MCParticle>>();
248 produces<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
255 produces<std::vector<sim::SimPhotons>>();
257 produces<std::vector<sim::SimPhotonsLite>>();
269 produces<std::vector<sim::SimEnergyDeposit>>(edep_inst);
274 produces<std::vector<sim::AuxDetHit>>(auxdethit_inst);
285 auto partCol = std::make_unique<std::vector<simb::MCParticle>>();
286 auto scCol = std::make_unique<std::vector<sim::SimChannel>>();
287 auto PhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
288 auto LitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
289 auto ReflPhotonCol = std::make_unique<std::vector<sim::SimPhotons>>();
290 auto ReflLitePhotonCol = std::make_unique<std::vector<sim::SimPhotonsLite>>();
292 std::make_unique<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
293 auto adCol = std::make_unique<std::vector<sim::AuxDetSimChannel>>();
294 auto pamCol = std::make_unique<std::vector<sim::ParticleAncestryMap>>();
296 using edeps_t = std::vector<sim::SimEnergyDeposit>;
297 std::vector<edeps_t> edepCols;
300 using aux_det_hits_t = std::vector<sim::AuxDetHit>;
301 std::vector<aux_det_hits_t> auxdethitCols;
310 auto const input_partCol = e.
getValidHandle<std::vector<simb::MCParticle>>(input_label);
311 MergeUtility.MergeMCParticles(*partCol, *input_partCol, i_source);
314 const std::vector<size_t>& assocVectorPrimitive =
315 MergeUtility.GetMCParticleListMap().at(i_source);
317 input_partCol, e, input_label);
320 mctAssn.at(i_p), makePartPtr(assocVectorPrimitive[i_p]), mctAssn.
data(i_p).ref());
324 auto const& input_scCol = e.
getProduct<std::vector<sim::SimChannel>>(input_label);
340 auto const& input_adCol = e.
getProduct<std::vector<sim::AuxDetSimChannel>>(input_label);
341 MergeUtility.MergeAuxDetSimChannels(*adCol, input_adCol, i_source);
346 auto const& input_PhotonCol = e.
getProduct<std::vector<sim::SimPhotons>>(input_label);
347 MergeUtility.MergeSimPhotons(*PhotonCol, input_PhotonCol);
350 auto const& input_LitePhotonCol =
351 e.
getProduct<std::vector<sim::SimPhotonsLite>>(input_label);
352 MergeUtility.MergeSimPhotonsLite(*LitePhotonCol, input_LitePhotonCol);
358 auto const& input_PhotonCol =
359 e.
getProduct<std::vector<sim::SimPhotons>>(input_reflected_label);
360 MergeUtility.MergeSimPhotons(*ReflPhotonCol, input_PhotonCol);
363 auto const& input_LitePhotonCol =
364 e.
getProduct<std::vector<sim::SimPhotonsLite>>(input_reflected_label);
365 MergeUtility.MergeSimPhotonsLite(*ReflLitePhotonCol, input_LitePhotonCol);
371 for (
auto const& [edep_inst, edepCol] :
374 MergeUtility.MergeSimEnergyDeposits(edepCol, e.
getProduct<edeps_t>(edep_tag), i_source);
379 for (
auto const& [auxdethit_inst, auxdethitCol] :
382 MergeUtility.MergeAuxDetHits(
383 auxdethitCol, e.
getProduct<aux_det_hits_t>(auxdethit_tag), i_source);
388 MergeUtility.MergeParticleAncestryMaps(*pamCol, input_pamCol, i_source);
394 e.
put(std::move(partCol));
395 e.
put(std::move(tpassn));
401 e.
put(std::move(PhotonCol));
403 e.
put(std::move(LitePhotonCol));
414 e.
put(std::make_unique<edeps_t>(move(edepCol)), edep_inst);
419 for (
auto&& [auxdethit_inst, auxdethitCol] :
421 e.
put(std::make_unique<aux_det_hits_t>(move(auxdethitCol)), auxdethit_inst);
432 log <<
"Configuration:" 434 for (
auto const& [i_source, tag, offset] :
436 log <<
"\n [" << i_source <<
"] '" << tag.encode() <<
"' (ID offset: " << offset <<
")";
445 log <<
"\n - filling Simulated Photons";
447 log <<
"\n - using photon summary (`SimPhotonsLite`)";
449 log <<
"\n - using detailed photons (`SimPhotons`)";
457 log <<
" '" << label <<
"'";
465 log <<
" '" << label <<
"'";
bool const fSkipTrackIDOffsets
bool const fFillSimChannels
bool const fFillMCParticles
Store parameters for running LArG4.
MergeSimSources(Parameters const &config)
fhicl::Sequence< int > TrackIDOffsets
fhicl::Atom< bool > SkipTrackIDOffsets
Definition of util::enumerate().
bool const fFillSimEnergyDeposits
EDProducer(fhicl::ParameterSet const &pset)
fhicl::Atom< bool > FillAuxDetSimChannels
Contains data associated to particles from detector simulation.
fhicl::OptionalAtom< bool > FillSimEnergyDeposits
fhicl::Atom< bool > FillSimChannels
fhicl::Sequence< std::string > EnergyDepositInstanceLabels
std::vector< art::InputTag > const fInputSourcesLabels
bool const fUseLitePhotons
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
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
bool const fFillParticleAncestryMaps
fhicl::Atom< bool > FillSimPhotons
std::vector< int > const fTrackIDOffsets
Test of util::counter and support utilities.
void dumpConfiguration() const
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
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool const fStoreReflected
bool const fFillAuxDetHits
contains information for a single step in the detector simulation
object containing MC truth information necessary for making RawDigits and doing back tracking ...
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
fhicl::Atom< bool > FillAuxDetHits
cet::maybe_ref< Data const > data(size_type i) const
bool const fFillAuxDetSimChannels
fhicl::Atom< bool > FillParticleAncestryMaps
PROD const & getProduct(InputTag const &tag) const
fhicl::Sequence< art::InputTag > InputSourcesLabels
std::vector< std::string > const fEnergyDepositionInstances