All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
MCReco Class Reference
Inheritance diagram for MCReco:

Public Member Functions

 MCReco (fhicl::ParameterSet const &p)
 
void produce (art::Event &e) override
 
template<typename T >
void MakeMCEdep (art::Event &evt)
 

Private Attributes

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

Detailed Description

Definition at line 28 of file MCReco_module.cc.

Constructor & Destructor Documentation

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

Definition at line 52 of file MCReco_module.cc.

53  : EDProducer{pset}
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"))
58 {
59 
60  //for backwards compatibility to using the "G4ModName" label...
61  if(!(pset.get_if_present<art::InputTag>("MCParticleLabel",fMCParticleLabel) &&
62  pset.get_if_present<art::InputTag>("SimChannelLabel",fSimChannelLabel)) ){
63 
64  mf::LogWarning("MCReco_module") << "USING DEPRECATED G4ModName CONFIG IN MCRECO_MODULE"
65  << "\nUse 'MCParticleLabel' and 'SimChannelLabel' instead.";
66 
67  fMCParticleLabel = pset.get<art::InputTag>("G4ModName","largeant");
68  fMCParticleLiteLabel = pset.get<art::InputTag>("G4ModName","largeant");
69  fSimChannelLabel = pset.get<art::InputTag>("G4ModName","largeant");
70  }
71  else {
72  fMCParticleLiteLabel = pset.get<art::InputTag>("MCParticleLiteLabel", "largeant");
73  }
74 
75  fUseSimEnergyDeposit = pset.get<bool>("UseSimEnergyDeposit",false);
76  fUseSimEnergyDepositLite = pset.get<bool>("UseSimEnergyDepositLite",false);
77  fIncludeDroppedParticles = pset.get<bool>("IncludeDroppedParticles",false);
78 
79  if (fUseSimEnergyDepositLite && fUseSimEnergyDeposit) {
80  mf::LogWarning("MCReco_module") << "Asked to use both SimEnergyDeposit and SimEnergyDepositLite - will use SimEnergyDeposit.";
81  }
82 
83  produces< std::vector< sim::MCShower> >();
84  produces< std::vector< sim::MCTrack> >();
85  // Call appropriate produces<>() functions here.
86 
87 //MCReco::~MCReco()
88 //{
89  // Clean up dynamic memory and other resources here.
90 //}
91 }
::sim::MCShowerRecoAlg fMCSAlg
bool fIncludeDroppedParticles
::sim::MCRecoEdep fEdep
art::InputTag fMCParticleLabel
bool fUseSimEnergyDepositLite
::sim::MCRecoPart fPart
art::InputTag fMCParticleLiteLabel
art::InputTag fSimChannelLabel
bool fUseSimEnergyDeposit
::sim::MCTrackRecoAlg fMCTAlg

Member Function Documentation

template<typename T >
void MCReco::MakeMCEdep ( art::Event &  evt)

Definition at line 142 of file MCReco_module.cc.

142  {
143  // Retrieve T
144  auto const& sed_array = *evt.getValidHandle<std::vector<T>>(fSimChannelLabel);
145  fEdep.MakeMCEdep(sed_array);
146 }
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
Definition: MCRecoEdep.cxx:64
::sim::MCRecoEdep fEdep
art::InputTag fSimChannelLabel
TCEvent evt
Definition: DataStructs.cxx:8
void MCReco::produce ( art::Event &  e)
override

Definition at line 93 of file MCReco_module.cc.

94 {
95 // std::unique_ptr< std::vector<sim::MCTrack> > outTrackArray(new std::vector<sim::MCTrack>);
96 
97  // Retrieve mcparticles
98  art::Handle<std::vector<simb::MCParticle> > mcpHandle;
99  evt.getByLabel(fMCParticleLabel,mcpHandle);
100  if(!mcpHandle.isValid()) throw cet::exception(__FUNCTION__) << "Failed to retrieve simb::MCParticle";;
101 
102  // Find associations
103  art::FindOneP<simb::MCTruth> ass(mcpHandle, evt, fMCParticleLabel);
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());
109  }
110 
111  const std::vector<simb::MCParticle>& mcp_array(*mcpHandle);
112 
114  auto const& mcmp_array = *evt.getValidHandle<std::vector<sim::MCParticleLite>>(fMCParticleLiteLabel);
115  fPart.AddParticles(mcp_array, orig_array, mcmp_array);
116  } // end if fIncludeDroppedParticles
117  else {
118  fPart.AddParticles(mcp_array,orig_array);
119  }
120 
121  // change implemented by David Caratelli to allow for MCRECO to run without SimChannels and using
122  // SimEnergyDeposits instead
123  if (fUseSimEnergyDeposit == true) {
124  MakeMCEdep<sim::SimEnergyDeposit>(evt);
125  }
126  // change implemented by Laura Domine to allow for MCRECO to run with SimEnergyDepositLite
127  else if (fUseSimEnergyDepositLite == true) {
128  MakeMCEdep<sim::SimEnergyDepositLite>(evt);
129  }
130  else {
131  MakeMCEdep<sim::SimChannel>(evt);
132  }
133 
134  //Add MCShowers and MCTracks to the event
137 
138  fEdep.Clear();
139  fPart.clear();
140 }
void AddParticles(const std::vector< simb::MCParticle > &mcp_v, const std::vector< simb::Origin_t > &orig_v, const std::vector< sim::MCParticleLite > &mcmp_v={})
Definition: MCRecoPart.cxx:128
std::unique_ptr< std::vector< sim::MCShower > > Reconstruct(MCRecoPart &part_v, MCRecoEdep &edep_v)
::sim::MCShowerRecoAlg fMCSAlg
bool fIncludeDroppedParticles
::sim::MCRecoEdep fEdep
art::InputTag fMCParticleLabel
bool fUseSimEnergyDepositLite
::sim::MCRecoPart fPart
art::InputTag fMCParticleLiteLabel
bool fUseSimEnergyDeposit
::sim::MCTrackRecoAlg fMCTAlg
std::unique_ptr< std::vector< sim::MCTrack > > Reconstruct(MCRecoPart &part_v, MCRecoEdep &edep_v)
TCEvent evt
Definition: DataStructs.cxx:8

Member Data Documentation

::sim::MCRecoEdep MCReco::fEdep
private

Definition at line 47 of file MCReco_module.cc.

bool MCReco::fIncludeDroppedParticles
private

Definition at line 44 of file MCReco_module.cc.

art::InputTag MCReco::fMCParticleLabel
private

Definition at line 39 of file MCReco_module.cc.

art::InputTag MCReco::fMCParticleLiteLabel
private

Definition at line 40 of file MCReco_module.cc.

::sim::MCShowerRecoAlg MCReco::fMCSAlg
private

Definition at line 48 of file MCReco_module.cc.

::sim::MCTrackRecoAlg MCReco::fMCTAlg
private

Definition at line 49 of file MCReco_module.cc.

::sim::MCRecoPart MCReco::fPart
private

Definition at line 46 of file MCReco_module.cc.

art::InputTag MCReco::fSimChannelLabel
private

Definition at line 41 of file MCReco_module.cc.

bool MCReco::fUseSimEnergyDeposit
private

Definition at line 42 of file MCReco_module.cc.

bool MCReco::fUseSimEnergyDepositLite
private

Definition at line 43 of file MCReco_module.cc.


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