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

Public Types

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

Public Member Functions

 FindParent (const Parameters &params)
 
virtual ~FindParent ()
 
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 Member Functions

int MatchToOrigSlice (art::Ptr< rb::Cluster > mrSlice, art::Handle< std::vector< rb::Cluster > > origSlices, std::vector< art::Ptr< rb::CellHit > > mrHits, float &maxPur, float &maxEff)
 

Private Attributes

FindParentParams fParams
 

Detailed Description

Definition at line 78 of file FindParent_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 82 of file FindParent_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::FindParent::FindParent ( const Parameters params)
explicit

Definition at line 102 of file FindParent_module.cc.

103  : fParams(params())
104  {
105 
106  produces<std::vector<murem::MRCCParent> >();
107  produces< art::Assns<murem::MRCCParent, rb::Cluster> >();
108  }
FindParentParams fParams
murem::FindParent::~FindParent ( )
virtual

Definition at line 114 of file FindParent_module.cc.

115  {
116  }

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  }
int murem::FindParent::MatchToOrigSlice ( art::Ptr< rb::Cluster mrSlice,
art::Handle< std::vector< rb::Cluster > >  origSlices,
std::vector< art::Ptr< rb::CellHit > >  mrHits,
float &  maxPur,
float &  maxEff 
)
private

Definition at line 208 of file FindParent_module.cc.

References rb::Cluster::AllCells(), getBrightness::cell, rb::CellHit::Cell(), rb::Cluster::Cell(), DEFINE_ART_MODULE(), check_time_usage::float, make_syst_table_plots::h, rb::Cluster::IsNoise(), makeBrightnessMap::maxPlane, rb::Cluster::MaxPlane(), rb::Cluster::MinPlane(), rb::Cluster::NCell(), rb::CellHit::Plane(), NDAPDHVSetting::plane, PandAna.Demos.pi0_spectra::pur, rb::Cluster::RemoveHit(), rb::SortByPlane(), febshutoff_auto::start, and rawdata::RawDigit::TDC().

Referenced by produce().

213  {
214 
215  SortByPlane(mrHits);
216 
217  auto minPlane = [](art::Ptr<rb::CellHit> hit, int plane ){ return (hit->Plane() < plane); };
218  auto maxPlane = [](int plane, art::Ptr<rb::CellHit> hit ){ return (hit->Plane() >= plane); };
219 
220  int nSlices = origSlices->size();
221  int nMrCells = mrccSlice->NCell();
222  int mrMin = mrccSlice->MinPlane();
223  int mrMax = mrccSlice->MaxPlane();
224  int matchedSliceIndex = -5;
225  maxPur = -1;
226 
227  for( int sli = 0; sli < nSlices; sli++ ){
228 
229  art::Ptr<rb::Cluster> thisSlice( origSlices, sli);
230 
231  // Don't match mrcc slices to original noise slice, even
232  // if it legitimate. Noise slice info is not saved in
233  // cafs and therefore, causes trouble at the time of analysis
234  if( thisSlice->IsNoise() )
235  continue;
236 
237  int origMin = thisSlice->MinPlane();
238  int origMax = thisSlice->MaxPlane();
239 
240 
241  if( !( ( mrMin >= origMin && mrMin <= origMax ) ||
242  ( mrMax >= origMin && mrMax <= origMax ) ) )
243  continue;
244 
245 
246  int nCells = thisSlice->NCell();
247 
248  int cellCount = 0;
249  for(int h = 0; h < nMrCells; h++){
250  art::Ptr<rb::CellHit> mhit = mrccSlice->Cell(h);
251  int plane = mhit->Plane();
252  int cell = mhit->Cell();
253  int tdc = mhit->TDC();
254 
255  for(int oh = 0; oh < nCells; oh++){
256  art::Ptr<rb::CellHit> hit = thisSlice->Cell(oh);
257  if( plane == hit->Plane() &&
258  cell == hit->Cell() &&
259  tdc == hit->TDC())
260  cellCount++;
261  }// end loop over orig slice hits
262 
263  }// end loop over hits in mrccSlice
264 
265 
266  float pur = ((float)cellCount)/nMrCells;
267 
268  if( pur > maxPur ){
269  matchedSliceIndex = sli;
270  maxPur = pur;
271  }
272 
273  }// end loop over the orig slices
274 
275  // Once the original slice for which the mrcc slice has the max
276  // purity is found, determine the efficiency of mrcc slice wrt
277  // hits in the original matched slice minus the muon hits.
278 
279  if(matchedSliceIndex == -5)
280  return matchedSliceIndex;
281 
282 
283  art::Ptr<rb::Cluster> origSlice( origSlices, matchedSliceIndex );
284  rb::Cluster nonMuonClust = *(origSlice);
285  int nCells = origSlice->NCell();
286  int minP = origSlice->MinPlane();
287  int maxP = origSlice->MaxPlane();
288 
289 
290  art::PtrVector<rb::CellHit>::iterator mrhitIter, mrhitBegin, mrhitEnd;
291  mrhitEnd = std::upper_bound( mrHits.begin(), mrHits.end(),
292  maxP, maxPlane );
293  mrhitBegin = std::lower_bound( mrHits.begin(), mrHits.end(),
294  minP, minPlane );
295 
296 
297  for(int oh = 0; oh < nCells; oh++){
298  const art::Ptr<rb::CellHit> hit = origSlice->Cell(oh);
299  int plane = hit->Plane();
300  int cell = hit->Cell();
301  int tdc = hit->TDC();
302  bool matchedHit = false;
303 
304  for( mrhitIter = mrhitBegin; mrhitIter != mrhitEnd; ++mrhitIter){
305  const art::Ptr<rb::CellHit> mrHit = *mrhitIter;
306  if( mrHit->Plane() == plane &&
307  mrHit->Cell() == cell &&
308  mrHit->TDC() == tdc )
309  matchedHit = true;
310 
311  }// end loop over mrcc hits
312 
313  if( !matchedHit )
314  nonMuonClust.RemoveHit( hit );
315 
316  }// end loop over origSlice hits
317 
318  // Now we have the muon removed original cells ,
319  // Lets calculate the efficiency we're after.
320  int nNonMuonHits = nonMuonClust.NCell();
321  int hitCount = 0;
322 
323  art::PtrVector<rb::CellHit> nonMuonHits = nonMuonClust.AllCells();
324  art::PtrVector<rb::CellHit> mrccSliceHits = mrccSlice->AllCells();
325  rb::SortByPlane(nonMuonHits);
326  rb::SortByPlane(mrccSliceHits);
327 
328  int start = 0;
329  for(int oh = 0; oh < nNonMuonHits; oh++){
330  const art::Ptr<rb::CellHit> hit = nonMuonHits[oh];
331  int plane = hit->Plane();
332  int cell = hit->Cell();
333  int tdc = hit->TDC();
334 
335  for(int h = start; h < nMrCells; h++){
336  const art::Ptr<rb::CellHit> mrHit = mrccSliceHits[h];
337  if( mrHit->Plane() > plane ){
338  start = h;
339  break;
340  }
341  if( mrHit->Plane() == plane &&
342  mrHit->Cell() == cell &&
343  mrHit->TDC() == tdc ){
344  hitCount++;
345  break;
346  }
347  }// end loop over mrcc hits
348  }// end loop over non-muon hits
349 
350  maxEff = (float)hitCount/nNonMuonHits;
351 
352  return matchedSliceIndex;
353 
354  }// End of MatchToOrigSlice
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
unsigned short Plane() const
Definition: CellHit.h:39
A collection of associated CellHits.
Definition: Cluster.h:47
void RemoveHit(const art::Ptr< rb::CellHit > hit)
Remove hit from current cluster.
Definition: Cluster.cxx:290
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
unsigned short Cell() const
Definition: CellHit.h:40
data_t::iterator iterator
Definition: PtrVector.h:60
Definition: structs.h:12
void SortByPlane(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in plane order (low to high).
Definition: CellHit.cxx:124
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::FindParent::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 121 of file FindParent_module.cc.

References util::CreateAssn(), fParams, art::DataViewImpl::getByLabel(), make_syst_table_plots::h, MECModelEnuComparisons::i, makeTrainCVSamples::int, rb::Cluster::IsNoise(), MatchToOrigSlice(), art::PtrVector< T >::push_back(), art::Event::put(), murem::MRCCParent::SetParentEff(), murem::MRCCParent::SetParentIndex(), and murem::MRCCParent::SetParentPur().

122  {
123 
124  std::unique_ptr< std::vector< murem::MRCCParent > >
125  mrccParents(new std::vector< murem::MRCCParent >);
126 
127  std::unique_ptr< art::Assns< murem::MRCCParent, rb::Cluster > >
129 
130  std::vector< murem::MRCCParent> mrccParentsVec;
131 
133  evt.getByLabel(fParams.clusterLabel(), slicelist);
134  if (slicelist->empty()) {
135  mf::LogWarning("FindParent") << "Error retrieving slice list" ;
136  return;
137  }
138 
139 
141  evt.getByLabel(fParams.mrClusterLabel(), mrslicelist);
142  if (mrslicelist->empty()) {
143  mf::LogWarning("FindParent") << "Error retrieving mrcc slice list" ;
144  return;
145  }
146 
148  evt.getByLabel(fParams.mrccLabel(), removedMuonCol);
149 
151  for(int i = 0; i < (int)removedMuonCol->size(); i++){
152  art::Ptr<simb::MCParticle> mu( removedMuonCol, i );
153  removedMuons.push_back( mu );
154  }
155 
156 
157  // Grab all the MRCC cellhits. Need this for parent slice efficiency calculation
158 
160  evt.getByLabel(fParams.mrHitLabel(), mrHitlist);
161 
162  std::vector< art::Ptr<rb::CellHit> > mrAllhits;
163  for(size_t h = 0; h < mrHitlist->size(); ++h){
164  art::Ptr<rb::CellHit> hit(mrHitlist, h);
165  mrAllhits.push_back(hit);
166  }
167 
168  int nSlicesMrcc = mrslicelist->size();
169 
170  for(int mrSli = 0; mrSli < nSlicesMrcc; mrSli++ ){
171 
172  art::Ptr<rb::Cluster> thisMrSlice(mrslicelist, mrSli);
173  if( thisMrSlice->IsNoise() )
174  continue;
175 
176  float slicePur = -5;
177  float sliceEff = -5;
178 
179 
180  int parentSliceIndex = MatchToOrigSlice( thisMrSlice, slicelist, mrAllhits,
181  slicePur, sliceEff);
182  if (parentSliceIndex == -5 )
183  continue;
184 
185  MRCCParent mrccParent;
186  mrccParent.SetParentPur( slicePur );
187  mrccParent.SetParentEff( sliceEff );
188  mrccParent.SetParentIndex( parentSliceIndex );
189 
190  mrccParents->push_back( mrccParent );
191  util::CreateAssn( *this, evt, *mrccParents, thisMrSlice ,*sliceAssassin);
192 
193 
194  }// end loop over mrcc slices
195 
196 
197  evt.put( std::move(mrccParents) );
198  evt.put( std::move(sliceAssassin) );
199  }// 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.
FindParentParams fParams
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Definition: fwd.h:28
int MatchToOrigSlice(art::Ptr< rb::Cluster > mrSlice, art::Handle< std::vector< rb::Cluster > > origSlices, std::vector< art::Ptr< rb::CellHit > > mrHits, float &maxPur, float &maxEff)
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

FindParentParams murem::FindParent::fParams
private

Definition at line 96 of file FindParent_module.cc.

Referenced by produce().


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