Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
murem::FindMREParent Class Reference
Inheritance diagram for murem::FindMREParent:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using Parameters = art::EDProducer::Table< FindMREParentParams >
 
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 FindMREParent (const Parameters &params)
 
virtual ~FindMREParent ()
 
void produce (art::Event &evt)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

FindMREParentParams fParams
 

Detailed Description

Definition at line 67 of file FindMREParent_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 71 of file FindMREParent_module.cc.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

murem::FindMREParent::FindMREParent ( const Parameters params)
explicit

Definition at line 86 of file FindMREParent_module.cc.

87  : fParams(params())
88  {
89 
90  produces<std::vector<murem::MRCCParent> >();
91  produces< art::Assns<murem::MRCCParent, rb::Cluster> >();
92  }
FindMREParentParams fParams
murem::FindMREParent::~FindMREParent ( )
virtual

Definition at line 99 of file FindMREParent_module.cc.

100  {
101  }

Member Function Documentation

template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void murem::FindMREParent::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 106 of file FindMREParent_module.cc.

References util::CreateAssn(), DEFINE_ART_MODULE(), efficiency(), evt, art::fill_ptr_vector(), fParams, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, it, art::PtrVector< T >::push_back(), art::Event::put(), murem::MRCCParent::SetParentEff(), murem::MRCCParent::SetParentIndex(), murem::MRCCParent::SetParentPur(), art::PtrVector< T >::size(), and cheat::BackTracker::SlicesToMCTruthsTable().

107  {
108  // the mreparent object to be put in event
109  std::unique_ptr< std::vector< murem::MRCCParent > >
110  mrccParents(new std::vector< murem::MRCCParent >);
111 
112  // the mreparent object to slice association
113  std::unique_ptr< art::Assns< murem::MRCCParent,rb::Cluster > >
115 
116  std::vector< murem::MRCCParent> mrccParentsVec;
117 
118  // mre slices
119  art::Handle< std::vector<rb::Cluster> > mreslicehandle;
120  evt.getByLabel(fParams.mreClusterLabel(), mreslicehandle);
121  art::PtrVector<rb::Cluster> mreslices;
122  for(unsigned i=0; i < mreslicehandle->size(); i++){
123  art::Ptr<rb::Cluster> ptr(mreslicehandle, i);
124  mreslices.push_back(ptr);
125  }
126 
127  // mre electron mc truth
129  evt.getByLabel(fParams.mreLabel(), elechandle);
130  std::vector<art::Ptr<simb::MCTruth> > elecs;
131  art::fill_ptr_vector(elecs, elechandle);
132 
133  // removed muon particles
135  evt.getByLabel(fParams.mrccLabel(), muonhandle);
136  std::vector<art::Ptr<simb::MCParticle> > muons;
137  art::fill_ptr_vector(muons, muonhandle);
138 
139  // parent slices
141  evt.getByLabel(fParams.clusterLabel(), slicehandle);
142  std::vector<art::Ptr<rb::Cluster> > slices;
143  art::fill_ptr_vector(slices, slicehandle);
144 
146  std::vector<std::vector<cheat::NeutrinoEffPur> > truthtable =
147  bt->SlicesToMCTruthsTable( mreslices);
148 
149  if(!truthtable.empty()){
150 
151  // Map the mre slice to an electron mctruth
152  // electron mctruths are associated with
153  // an mcparticle that corresponds to the
154  // removed muon, which is asociated with
155  // the parent event slice.
156 
157  for(unsigned int isli = 0; isli < mreslices.size(); isli++){
158 
159  if(mreslices[isli]->IsNoise())
160  continue;
161 
162  if(truthtable[isli].empty())
163  continue;
164 
165  // Find the best match for this slice
166  int bestidx = -1;
167  float besteff = 0;
168  for(size_t it = 0; it < truthtable[isli].size(); ++it){
169  if( truthtable[isli][it].efficiency > besteff){
170  bestidx = it;
171  besteff = truthtable[isli][it].efficiency;
172  }
173  }
174 
175  if( bestidx < 0 ||
176  truthtable[isli].at(bestidx).efficiency <= 0 )
177  continue;
178 
179  art::Ptr< simb::MCTruth > electruth =
180  truthtable[isli].at(bestidx).neutrinoInt;
181 
183  fop({electruth}, evt, fParams.mreLabel());
184 
185  if(!fop.isValid() )
186  continue;
187 
188 
189  // the electron truth is associated with
190  // the removed muon mc particle. Grab that
191  art::Ptr<simb::MCParticle> muon = fop.at(0);
192 
194  fos({muon}, evt, fParams.mrccLabel());
195 
196  if(!fos.isValid() && fos.at(0))
197  continue;
198 
199  art::Ptr<rb::Cluster> parentslice = fos.at(0);
200  int sliceIdx = -5;
201  for(unsigned int i = 0; i < slices.size(); i++){
202  if(slices[i] == parentslice)
203  sliceIdx = i;
204  }
205 
206  if(sliceIdx == -5 )
207  continue;
208 
209  // now find the efficiency and purity numbers
210  MRCCParent mrccParent;
211  mrccParent.SetParentPur( 1 );
212  mrccParent.SetParentEff( 1 );
213  mrccParent.SetParentIndex( sliceIdx );
214 
215  mrccParents->push_back( mrccParent );
216  util::CreateAssn( *this, evt, *mrccParents,
217  mreslices[isli] ,*assns);
218 
219  }// end loop over mre slices
220  }// mre truth table is not empty
221 
222  evt.put( std::move(mrccParents) );
223  evt.put( std::move(assns) );
224  }// End of produce method
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
set< int >::iterator it
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable(const std::vector< const rb::Cluster * > &sliceList) const
Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures...
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
int evt
size_type size() const
Definition: PtrVector.h:308
FindMREParentParams fParams
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
void efficiency()
Definition: efficiency.C:58
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

FindMREParentParams murem::FindMREParent::fParams
private

Definition at line 79 of file FindMREParent_module.cc.

Referenced by produce().


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