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

Public Member Functions

 MCParticleShowerMatching (fhicl::ParameterSet const &p)
 
 MCParticleShowerMatching (MCParticleShowerMatching const &)=delete
 
 MCParticleShowerMatching (MCParticleShowerMatching &&)=delete
 
MCParticleShowerMatchingoperator= (MCParticleShowerMatching const &)=delete
 
MCParticleShowerMatchingoperator= (MCParticleShowerMatching &&)=delete
 
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 fShowerModuleLabel
 
art::InputTag fShowerHitAssnLabel
 
art::InputTag fHitModuleLabel
 
art::InputTag fHitParticleAssnLabel
 

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 43 of file MCParticleShowerMatching_module.cc.

Constructor & Destructor Documentation

t0::MCParticleShowerMatching::MCParticleShowerMatching ( fhicl::ParameterSet const &  p)
explicit

Definition at line 68 of file MCParticleShowerMatching_module.cc.

69  : EDProducer{p}
70 {
71  fShowerModuleLabel = p.get<art::InputTag>("ShowerModuleLabel");
72  fShowerHitAssnLabel = p.get<art::InputTag>("ShowerHitAssnLabel",fShowerModuleLabel);
73  fHitModuleLabel = p.get<art::InputTag>("HitModuleLabel");
74  fHitParticleAssnLabel = p.get<art::InputTag>("HitParticleAssnLabel");
75 
76  produces< art::Assns<recob::Shower , simb::MCParticle, anab::BackTrackerMatchingData > > ();
77 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
t0::MCParticleShowerMatching::MCParticleShowerMatching ( MCParticleShowerMatching const &  )
delete
t0::MCParticleShowerMatching::MCParticleShowerMatching ( MCParticleShowerMatching &&  )
delete

Member Function Documentation

MCParticleShowerMatching& t0::MCParticleShowerMatching::operator= ( MCParticleShowerMatching const &  )
delete
MCParticleShowerMatching& t0::MCParticleShowerMatching::operator= ( MCParticleShowerMatching &&  )
delete
void t0::MCParticleShowerMatching::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 79 of file MCParticleShowerMatching_module.cc.

80 {
81  if (evt.isRealData()) return;
82 
83  //auto mcpartHandle = evt.getValidHandle< std::vector<simb::MCParticle> >("largeant");
84  std::unique_ptr< art::Assns<recob::Shower, simb::MCParticle, anab::BackTrackerMatchingData > > MCPartShowerassn( new art::Assns<recob::Shower, simb::MCParticle, anab::BackTrackerMatchingData >);
85 
86 
87  double maxe = -1;
88  double tote = 0;
89  // int trkid = -1;
90  //int maxtrkid = -1;
91  //double maxn = -1;
92  //double totn = 0;
93  //int maxntrkid = -1;
94 
96  std::unordered_map<int,double> trkide;
97 
98  art::Handle< std::vector<recob::Shower> > showerListHandle;
99  evt.getByLabel(fShowerModuleLabel,showerListHandle);
100 
101  art::Handle< std::vector<recob::Hit> > hitListHandle;
102  evt.getByLabel(fHitModuleLabel,hitListHandle);
103 
104  if(!showerListHandle.isValid()){
105  std::cerr << "Shower handle is not valid!" << std::endl;
106  return;
107  }
108 
109  if(!hitListHandle.isValid()){
110  std::cerr << "Hit handle is not valid!" << std::endl;
111  return;
112  }
113 
114  auto const& showerList(*showerListHandle);
115  art::FindManyP<recob::Hit> fmtht(showerListHandle, evt, fShowerHitAssnLabel);
116  //auto const& mcpartList(*mcpartHandle);
117 
118  for(size_t i_t=0; i_t<showerList.size(); ++i_t){
119  art::Ptr<recob::Shower> shwPtr(showerListHandle,i_t);
120  trkide.clear();
121  tote = 0; maxe=-1; art::Ptr<simb::MCParticle> maxp;
122 
123  std::vector< art::Ptr<recob::Hit> > allHits = fmtht.at(i_t);
124 
125  std::vector<anab::BackTrackerHitMatchingData const*> bthmd_vec;
126  std::vector< art::Ptr<simb::MCParticle> > matchedParticlePtrs;
127 
128  art::FindManyP<simb::MCParticle,anab::BackTrackerHitMatchingData>
129  particles_per_hit(hitListHandle, evt, fHitParticleAssnLabel);
130 
131  for(size_t i_h=0; i_h<allHits.size(); ++i_h){
132  bthmd_vec.clear(); matchedParticlePtrs.clear();
133  particles_per_hit.get(allHits[i_h].key(),matchedParticlePtrs,bthmd_vec);
134 
135  for(size_t i_p=0; i_p<matchedParticlePtrs.size(); ++i_p){
136  trkide[ matchedParticlePtrs[i_p]->TrackId() ] += bthmd_vec[i_p]->energy;
137  tote += bthmd_vec[i_p]->energy;
138  if( trkide[ matchedParticlePtrs[i_p]->TrackId() ] > maxe ){
139  maxe = trkide[ matchedParticlePtrs[i_p]->TrackId() ];
140  maxp = matchedParticlePtrs[i_p];
141  }
142  }//end loop over particles per hit
143 
144  }//end loop over hits
145 
146  btdata.cleanliness = maxe/tote;
147  if(maxe>0)
148  MCPartShowerassn->addSingle(shwPtr, maxp, btdata);
149 
150  }//end loop over showers
151 
152  evt.put(std::move(MCPartShowerassn));
153 } // Produce
int maxp
Definition: tracks.py:196
bool isValid() const noexcept
Definition: Handle.h:191
def key(type, name=None)
Definition: graph.py:13
def move(depos, offset)
Definition: depos.py:107
TCEvent evt
Definition: DataStructs.cxx:7
QTextStream & endl(QTextStream &s)

Member Data Documentation

art::InputTag t0::MCParticleShowerMatching::fHitModuleLabel
private

Definition at line 62 of file MCParticleShowerMatching_module.cc.

art::InputTag t0::MCParticleShowerMatching::fHitParticleAssnLabel
private

Definition at line 63 of file MCParticleShowerMatching_module.cc.

art::InputTag t0::MCParticleShowerMatching::fShowerHitAssnLabel
private

Definition at line 61 of file MCParticleShowerMatching_module.cc.

art::InputTag t0::MCParticleShowerMatching::fShowerModuleLabel
private

Definition at line 60 of file MCParticleShowerMatching_module.cc.


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