10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "canvas/Persistency/Common/FindOneP.h"
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Principal/Handle.h"
15 #include "messagefacility/MessageLogger/MessageLogger.h"
17 #include "canvas/Utilities/InputTag.h"
18 #include "fhiclcpp/ParameterSet.h"
28 class MCReco :
public art::EDProducer {
30 explicit MCReco(fhicl::ParameterSet
const &
p);
33 void produce(art::Event &
e)
override;
54 , fPart (pset.get< fhicl::ParameterSet >(
"MCRecoPart"))
55 , fEdep (pset.get< fhicl::ParameterSet >(
"MCRecoEdep"))
56 , fMCSAlg (pset.get< fhicl::ParameterSet >(
"MCShowerRecoAlg"))
57 , fMCTAlg (pset.get< fhicl::ParameterSet >(
"MCTrackRecoAlg"))
61 if(!(pset.get_if_present<art::InputTag>(
"MCParticleLabel",fMCParticleLabel) &&
62 pset.get_if_present<art::InputTag>(
"SimChannelLabel",fSimChannelLabel)) ){
64 mf::LogWarning(
"MCReco_module") <<
"USING DEPRECATED G4ModName CONFIG IN MCRECO_MODULE"
65 <<
"\nUse 'MCParticleLabel' and 'SimChannelLabel' instead.";
67 fMCParticleLabel = pset.get<art::InputTag>(
"G4ModName",
"largeant");
68 fMCParticleLiteLabel = pset.get<art::InputTag>(
"G4ModName",
"largeant");
69 fSimChannelLabel = pset.get<art::InputTag>(
"G4ModName",
"largeant");
72 fMCParticleLiteLabel = pset.get<art::InputTag>(
"MCParticleLiteLabel",
"largeant");
75 fUseSimEnergyDeposit = pset.get<
bool>(
"UseSimEnergyDeposit",
false);
76 fUseSimEnergyDepositLite = pset.get<
bool>(
"UseSimEnergyDepositLite",
false);
77 fIncludeDroppedParticles = pset.get<
bool>(
"IncludeDroppedParticles",
false);
79 if (fUseSimEnergyDepositLite && fUseSimEnergyDeposit) {
80 mf::LogWarning(
"MCReco_module") <<
"Asked to use both SimEnergyDeposit and SimEnergyDepositLite - will use SimEnergyDeposit.";
83 produces< std::vector< sim::MCShower> >();
84 produces< std::vector< sim::MCTrack> >();
98 art::Handle<std::vector<simb::MCParticle> > mcpHandle;
100 if(!mcpHandle.isValid())
throw cet::exception(__FUNCTION__) <<
"Failed to retrieve simb::MCParticle";;
104 std::vector<simb::Origin_t> orig_array;
105 orig_array.reserve(mcpHandle->size());
106 for(
size_t i=0; i<mcpHandle->size(); ++i) {
107 const art::Ptr<simb::MCTruth> &mct = ass.at(i);
108 orig_array.push_back(mct->Origin());
111 const std::vector<simb::MCParticle>& mcp_array(*mcpHandle);
113 if (fIncludeDroppedParticles) {
114 auto const& mcmp_array = *evt.getValidHandle<std::vector<sim::MCParticleLite>>(
fMCParticleLiteLabel);
124 MakeMCEdep<sim::SimEnergyDeposit>(
evt);
127 else if (fUseSimEnergyDepositLite ==
true) {
128 MakeMCEdep<sim::SimEnergyDepositLite>(
evt);
131 MakeMCEdep<sim::SimChannel>(
evt);
144 auto const& sed_array = *evt.getValidHandle<std::vector<T>>(
fSimChannelLabel);
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
void AddParticles(const std::vector< simb::MCParticle > &mcp_v, const std::vector< simb::Origin_t > &orig_v, const std::vector< sim::MCParticleLite > &mcmp_v={})
std::unique_ptr< std::vector< sim::MCShower > > Reconstruct(MCRecoPart &part_v, MCRecoEdep &edep_v)
::sim::MCShowerRecoAlg fMCSAlg
bool fIncludeDroppedParticles
art::InputTag fMCParticleLabel
void MakeMCEdep(art::Event &evt)
bool fUseSimEnergyDepositLite
art::InputTag fMCParticleLiteLabel
art::InputTag fSimChannelLabel
Class def header for mctrack data container.
MCReco(fhicl::ParameterSet const &p)
bool fUseSimEnergyDeposit
::sim::MCTrackRecoAlg fMCTAlg
void produce(art::Event &e) override
std::unique_ptr< std::vector< sim::MCTrack > > Reconstruct(MCRecoPart &part_v, MCRecoEdep &edep_v)