Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lem::MergeMatches Class Reference

Merge LEM match lists from split running. More...

Inheritance diagram for lem::MergeMatches:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

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

Public Member Functions

 MergeMatches (const fhicl::ParameterSet &pset)
 
 ~MergeMatches ()
 
virtual void beginRun (art::Run &run)
 
virtual void produce (art::Event &evt)
 
virtual void reconfigure (const fhicl::ParameterSet &pset)
 
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
 

Protected Attributes

std::string fSplitLabel
 

Detailed Description

Merge LEM match lists from split running.

Definition at line 31 of file MergeMatches_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

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

lem::MergeMatches::MergeMatches ( const fhicl::ParameterSet pset)
explicit

Definition at line 47 of file MergeMatches_module.cc.

References reconfigure().

48  {
49  reconfigure(pset);
50 
51  produces<std::vector<lem::MatchList>>();
52  // MatchLists are associated with the slice they are against
53  produces<art::Assns<lem::MatchList, rb::Cluster>>();
54 
55  // Really should be file level, not run level, but don't know how to do
56  // that
57  produces<lem::LibrarySummary, art::InRun>();
58 
59  // Copies from one of the split parts
60  produces<std::vector<geo::OfflineChan> >();
61 
62  produces<std::vector<TH2F>>(); // copies from best match part
63  }
virtual void reconfigure(const fhicl::ParameterSet &pset)
lem::MergeMatches::~MergeMatches ( )

Definition at line 66 of file MergeMatches_module.cc.

67  {
68  }

Member Function Documentation

void lem::MergeMatches::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 77 of file MergeMatches_module.cc.

References art::DataViewImpl::getManyByType(), getGoodRuns4SAM::n, and art::Run::put().

78  {
79  std::vector<art::Handle<lem::LibrarySummary> > libsums;
80  run.getManyByType(libsums);
81 
82  std::unique_ptr<lem::LibrarySummary> libout(new lem::LibrarySummary);
83 
84  for(unsigned int n = 0; n < libsums.size(); ++n){
85  *libout += *libsums[n];
86  }
87 
88  run.put(std::move(libout));
89  }
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:149
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: DataViewImpl.h:446
Details of the library LEM matches were made against.
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 lem::MergeMatches::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 92 of file MergeMatches_module.cc.

References ana::assert(), om::cout, util::CreateAssn(), DEFINE_ART_MODULE(), allTimeWatchdog::endl, PandAna.Demos.pi0_spectra::fmt, fSplitLabel, art::DataViewImpl::getManyByType(), lem::kMaxNumMatches, lem::MatchList::matches, overlay_prestage_def::matches, Munits::ms, art::Event::put(), and gen_flatrecord::size.

93  {
94  std::unique_ptr<std::vector<lem::MatchList>> outcol(new std::vector<lem::MatchList>);
95  std::unique_ptr<std::vector<TH2F>> th2outcol(new std::vector<TH2F>);
96 
97  // Associate matches with the slice they came from
98  std::unique_ptr<art::Assns<lem::MatchList, rb::Cluster>> assns(new art::Assns<lem::MatchList, rb::Cluster>);
99 
100  std::unique_ptr<std::vector<geo::OfflineChan>> chanoutcol(new std::vector<geo::OfflineChan>);
101 
102 
103  std::vector<art::Handle<std::vector<lem::MatchList>>> matchcol;
104  std::vector<art::Handle<std::vector<TH2F>>> th2col;
105  std::vector<art::Handle<std::vector<geo::OfflineChan>>> chancol;
106 
107  evt.getManyByType(matchcol);
108  // TODO: this is bad if anyone else puts TH2s or chans in the event
109  evt.getManyByType(th2col);
110  evt.getManyByType(chancol);
111  assert(!matchcol.empty());
112  assert(th2col.size() == matchcol.size());
113 
114  // Just copy them from the first split job
115  chanoutcol->insert(chanoutcol->end(),
116  chancol[0]->begin(), chancol[0]->end());
117 
118  const unsigned int partMax = matchcol.size();
119  const unsigned int sliceMax = matchcol[0]->size();
120 
121  std::cout << "Merging from " << partMax << " jobs over "
122  << sliceMax << " slices" << std::endl;
123 
124  // Note: these are indexes into the list of slices that got PID'd: not all
125  // slices.
126  for(unsigned int sliceIdx = 0; sliceIdx < sliceMax; ++sliceIdx){
127 
128  std::vector<MatchSummary> matches;
129  std::vector<MatchSummary> enrichedMatches;
130 
131  for(unsigned int partIdx = 0; partIdx < partMax; ++partIdx){
132  assert(matchcol[partIdx]->size() == sliceMax);
133 
134  const MatchList& ms = (*matchcol[partIdx])[sliceIdx];
135 
136  matches.insert(matches.end(), ms.matches.begin(), ms.matches.end());
137  }
138 
139 
140  std::sort(matches.begin(), matches.end());
141  matches.resize(kMaxNumMatches);
142 
143  int bestMatchPart = -1;
144  const double bestPotential = matches[0].potential;
145  for(unsigned int partIdx = 0; partIdx < partMax; ++partIdx){
146  if((*matchcol[partIdx])[sliceIdx].matches.empty()) continue;
147  if((*matchcol[partIdx])[sliceIdx].matches[0].potential == bestPotential){
148  bestMatchPart = partIdx;
149  }
150  } // end for partIdx
151 
152  if(bestMatchPart >= 0){
153  th2outcol->insert(th2outcol->end(),
154  th2col[bestMatchPart]->begin(),
155  th2col[bestMatchPart]->end());
156  }
157  else{
158  mf::LogWarning("MergeMatches") << "Couldn't figure out which part had the best match to copy its histograms";
159  }
160 
161  art::FindManyP<rb::Cluster> fmt(matchcol[0], evt, fSplitLabel);
162  // Get all the slices associated with this match list
163  std::vector<art::Ptr<rb::Cluster> > slice = fmt.at(sliceIdx);
164  assert(slice.size() == 1);
165 
166  // Duplicate the same association in our output
167  util::CreateAssn(*this, evt, *outcol, slice[0], *assns);
168  }
169 
170  evt.put(std::move(outcol));
171  evt.put(std::move(assns));
172  evt.put(std::move(th2outcol));
173  evt.put(std::move(chanoutcol));
174  }
static constexpr Double_t ms
Definition: Munits.h:192
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.
const unsigned int kMaxNumMatches
Definition: FindMatches.h:29
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: DataViewImpl.h:446
OStream cout
Definition: OStream.cxx:6
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
assert(nhit_max >=nhit_nbins)
void lem::MergeMatches::reconfigure ( const fhicl::ParameterSet pset)
virtual

Definition at line 71 of file MergeMatches_module.cc.

References fSplitLabel, fhicl::ParameterSet::get(), and string.

Referenced by MergeMatches().

72  {
73  fSplitLabel = pset.get<std::string>("SplitLabel");
74  }
T get(std::string const &key) const
Definition: ParameterSet.h:231
enum BeamMode string
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

std::string lem::MergeMatches::fSplitLabel
protected

Definition at line 43 of file MergeMatches_module.cc.

Referenced by produce(), and reconfigure().


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