Public Member Functions | Private Attributes | List of all members
MCReco Class Reference
Inheritance diagram for MCReco:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 MCReco (fhicl::ParameterSet const &p)
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

art::InputTag fMCParticleLabel
 
art::InputTag fSimChannelLabel
 
bool fUseSimEnergyDeposit
 
::sim::MCRecoPart fPart
 
::sim::MCRecoEdep fEdep
 
::sim::MCShowerRecoAlg fMCSAlg
 
::sim::MCTrackRecoAlg fMCTAlg
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 27 of file MCReco_module.cc.

Constructor & Destructor Documentation

MCReco::MCReco ( fhicl::ParameterSet const &  p)
explicit

Definition at line 47 of file MCReco_module.cc.

48  : EDProducer{pset}
49  , fPart (pset.get< fhicl::ParameterSet >("MCRecoPart"))
50  , fEdep (pset.get< fhicl::ParameterSet >("MCRecoEdep"))
51  , fMCSAlg (pset.get< fhicl::ParameterSet >("MCShowerRecoAlg"))
52  , fMCTAlg (pset.get< fhicl::ParameterSet >("MCTrackRecoAlg"))
53 {
54 
55  //for backwards compatibility to using the "G4ModName" label...
56  if(!(pset.get_if_present<art::InputTag>("MCParticleLabel",fMCParticleLabel) &&
57  pset.get_if_present<art::InputTag>("SimChannelLabel",fSimChannelLabel)) ){
58 
59  mf::LogWarning("MCReco_module") << "USING DEPRECATED G4ModName CONFIG IN MCRECO_MODULE"
60  << "\nUse 'MCParticleLabel' and 'SimChannelLabel' instead.";
61 
62  fMCParticleLabel = pset.get<art::InputTag>("G4ModName","largeant");
63  fSimChannelLabel = pset.get<art::InputTag>("G4ModName","largeant");
64  }
65 
66  fUseSimEnergyDeposit = pset.get<bool>("UseSimEnergyDeposit",false);
67 
68  produces< std::vector< sim::MCShower> >();
69  produces< std::vector< sim::MCTrack> >();
70  // Call appropriate produces<>() functions here.
71 
72 //MCReco::~MCReco()
73 //{
74  // Clean up dynamic memory and other resources here.
75 //}
76 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
::sim::MCShowerRecoAlg fMCSAlg
::sim::MCRecoEdep fEdep
art::InputTag fMCParticleLabel
::sim::MCRecoPart fPart
art::InputTag fSimChannelLabel
bool fUseSimEnergyDeposit
::sim::MCTrackRecoAlg fMCTAlg
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning

Member Function Documentation

void MCReco::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 78 of file MCReco_module.cc.

79 {
80 // std::unique_ptr< std::vector<sim::MCTrack> > outTrackArray(new std::vector<sim::MCTrack>);
81 
82  // Retrieve mcparticles
84  evt.getByLabel(fMCParticleLabel,mcpHandle);
85  if(!mcpHandle.isValid()) throw cet::exception(__FUNCTION__) << "Failed to retrieve simb::MCParticle";;
86 
87  // Find associations
88  art::FindOneP<simb::MCTruth> ass(mcpHandle, evt, fMCParticleLabel);
89  std::vector<simb::Origin_t> orig_array;
90  orig_array.reserve(mcpHandle->size());
91  for(size_t i=0; i<mcpHandle->size(); ++i) {
92  const art::Ptr<simb::MCTruth> &mct = ass.at(i);
93  orig_array.push_back(mct->Origin());
94  }
95 
96  const std::vector<simb::MCParticle>& mcp_array(*mcpHandle);
97  fPart.AddParticles(mcp_array,orig_array);
98 
99 
100  // change implemented by David Caratelli to allow for MCRECO to run without SimChannels and using
101  // SimEnergyDeposits instead
102  if (fUseSimEnergyDeposit == true) {
103  // Retrieve SimEnergyDeposit
105  evt.getByLabel(fSimChannelLabel,sedHandle);
106  if(!sedHandle.isValid()) throw cet::exception(__FUNCTION__) << "Failed to retrieve sim::SimEnergyDeposit";
107 
108  const std::vector<sim::SimEnergyDeposit>& sed_array(*sedHandle);
109  fEdep.MakeMCEdep(sed_array);
110  }
111  else {
112  // Retrieve SimChannel
114  evt.getByLabel(fSimChannelLabel,schHandle);
115  if(!schHandle.isValid()) throw cet::exception(__FUNCTION__) << "Failed to retrieve sim::SimChannel";
116 
117  const std::vector<sim::SimChannel>& sch_array(*schHandle);
118  fEdep.MakeMCEdep(sch_array);
119  }
120 
121  //Add MCShowers and MCTracks to the event
124 
125  fEdep.Clear();
126  fPart.clear();
127 }
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
Definition: MCRecoEdep.cxx:60
simb::Origin_t Origin() const
Definition: MCTruth.h:74
std::unique_ptr< std::vector< sim::MCShower > > Reconstruct(MCRecoPart &part_v, MCRecoEdep &edep_v)
::sim::MCShowerRecoAlg fMCSAlg
bool isValid() const noexcept
Definition: Handle.h:191
::sim::MCRecoEdep fEdep
art::InputTag fMCParticleLabel
void AddParticles(const std::vector< simb::MCParticle > &mcp_v, const std::vector< simb::Origin_t > &orig_v)
Definition: MCRecoPart.cxx:128
::sim::MCRecoPart fPart
art::InputTag fSimChannelLabel
bool fUseSimEnergyDeposit
::sim::MCTrackRecoAlg fMCTAlg
std::unique_ptr< std::vector< sim::MCTrack > > Reconstruct(MCRecoPart &part_v, MCRecoEdep &edep_v)
TCEvent evt
Definition: DataStructs.cxx:7
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

::sim::MCRecoEdep MCReco::fEdep
private

Definition at line 42 of file MCReco_module.cc.

art::InputTag MCReco::fMCParticleLabel
private

Definition at line 37 of file MCReco_module.cc.

::sim::MCShowerRecoAlg MCReco::fMCSAlg
private

Definition at line 43 of file MCReco_module.cc.

::sim::MCTrackRecoAlg MCReco::fMCTAlg
private

Definition at line 44 of file MCReco_module.cc.

::sim::MCRecoPart MCReco::fPart
private

Definition at line 41 of file MCReco_module.cc.

art::InputTag MCReco::fSimChannelLabel
private

Definition at line 38 of file MCReco_module.cc.

bool MCReco::fUseSimEnergyDeposit
private

Definition at line 39 of file MCReco_module.cc.


The documentation for this class was generated from the following file: