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

Module to find best LEM matches. More...

Inheritance diagram for lem::LEM:
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

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

void AddHists (std::vector< TH2F > *th2col, const Match &bestMatch, const EventSummary &trial, const EventSummary *head, bool headFlipEven, bool headFlipOdd) const
 
rb::Vertex MatchToVertex (const Match &match, int vtxPlane, int vtxCell, int vtxCellOther) const
 
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 fInputLabel
 
std::string fInputInstance
 
bool fUseLibraryService
 
std::string fLibPath
 Directory to find the library files in. More...
 
bool fUseDownsample
 Whether to use downsampling optimization. More...
 
int fDownsampleFactor
 How many levels to take the downsampling optimization. More...
 
bool fMMappedLoading
 
bool fOnDemand
 
bool fPreloadLib
 
bool fPreloadHeads
 
LibraryfLib
 
HeadsfHeads
 
int fSplitLibFactor
 
int fSplitLibIndex
 
bool fSaveEventImages
 
bool fSaveEventPotentials
 

Detailed Description

Module to find best LEM matches.

Definition at line 48 of file LEM_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::LEM::LEM ( const fhicl::ParameterSet pset)
explicit

Definition at line 90 of file LEM_module.cc.

References fSaveEventImages, fSaveEventPotentials, and reconfigure().

92  fMMappedLoading(false), fPreloadLib(false), fPreloadHeads(false),
93  fLib(0), fHeads(0),
95  {
96  reconfigure(pset);
97 
98  produces<std::vector<lem::MatchList> >();
99  // MatchLists are associated with the slice they are against
100  produces<art::Assns<lem::MatchList, rb::Cluster> >();
101 
102  // produces<std::vector<lem::MatchIndices> >();
103  // MatchLists are associated with the slice they are against
104  // produces<art::Assns<lem::MatchIndices, rb::Cluster> >();
105 
106  // True vertex of best match. Associate to slice
107  produces<std::vector<rb::Vertex> >();
108  produces<art::Assns<rb::Vertex, rb::Cluster> >();
109 
110  // Really should be file level, not run level, but don't know how to do
111  // that
112  produces<lem::LibrarySummary, art::InRun>();
113 
114  // Just to mark where the vertex is so you can check it's right
115  produces<std::vector<geo::OfflineChan> >();
116 
117  // Images of best match
119  produces<std::vector<TH2F> >();
120  }
bool fPreloadLib
Definition: LEM_module.cc:78
bool fUseDownsample
Whether to use downsampling optimization.
Definition: LEM_module.cc:74
bool fPreloadHeads
Definition: LEM_module.cc:78
int fDownsampleFactor
How many levels to take the downsampling optimization.
Definition: LEM_module.cc:75
bool fSaveEventPotentials
Definition: LEM_module.cc:86
int fSplitLibFactor
Definition: LEM_module.cc:83
int fSplitLibIndex
Definition: LEM_module.cc:84
bool fSaveEventImages
Definition: LEM_module.cc:86
virtual void reconfigure(const fhicl::ParameterSet &pset)
Definition: LEM_module.cc:132
Heads * fHeads
Definition: LEM_module.cc:81
bool fMMappedLoading
Definition: LEM_module.cc:77
Library * fLib
Definition: LEM_module.cc:80
lem::LEM::~LEM ( )

Definition at line 123 of file LEM_module.cc.

References fHeads, fLib, and fUseLibraryService.

124  {
125  if(!fUseLibraryService){
126  delete fLib;
127  delete fHeads;
128  }
129  }
bool fUseLibraryService
Definition: LEM_module.cc:71
Heads * fHeads
Definition: LEM_module.cc:81
Library * fLib
Definition: LEM_module.cc:80

Member Function Documentation

void lem::LEM::AddHists ( std::vector< TH2F > *  th2col,
const Match bestMatch,
const EventSummary trial,
const EventSummary head,
bool  headFlipEven,
bool  headFlipOdd 
) const
protected

Definition at line 406 of file LEM_module.cc.

References getBrightness::cell, lem::EventSummary::Description(), lem::Match::evt, fHeads, lem::EventSummary::FillHists(), lem::FillPotential(), lem::Match::flipEven, lem::Match::flipOdd, fSaveEventImages, fSaveEventPotentials, NDAPDHVSetting::plane, string, and lem::Potential::V.

Referenced by produce().

411  {
412  // Best
413  const EventSummary* bestEvt = bestMatch.evt;
414 
415  const std::string bestTitle = bestEvt->Description()+";Plane;Cell";
416 
417  if(fSaveEventImages){
418  TH2F evenBest("bestEven", bestTitle.c_str(), 64, 0, 128, 128, 64, 192);
419  TH2F oddBest ("bestOdd", bestTitle.c_str(), 64, 0, 128, 128, 64, 192);
420 
421  bestEvt->FillHists(&evenBest, &oddBest, bestMatch.flipEven, bestMatch.flipOdd);
422 
423  th2col->push_back(evenBest);
424  th2col->push_back(oddBest);
425  }
426 
428  TH2F hVsBest[2] = {TH2F("bestVEven", bestTitle.c_str(), 64, 0, 128, 128, 64, 192),
429  TH2F("bestVOdd", bestTitle.c_str(), 64, 0, 128, 128, 64, 192)};
430  Potential VBest;
431  FillPotential(*bestEvt, VBest, bestMatch.flipEven, bestMatch.flipOdd);
432  for(int plane = 0; plane < 256; ++plane){
433  for(int cell = 0; cell < 256; ++cell){
434  const double p = VBest.V[256*plane+cell];
435  hVsBest[plane%2].Fill(plane, cell, p);
436  }
437  }
438  th2col->push_back(hVsBest[0]);
439  th2col->push_back(hVsBest[1]);
440  }
441 
442 
443  // Head
444  if(fHeads && head){
445  const char* headTitle = (head->Description()+";Plane;Cell").c_str();
446 
447  if(fSaveEventImages){
448  TH2F evenHead("headEven", headTitle, 64, 0, 128, 128, 64, 192);
449  TH2F oddHead ("headOdd", headTitle, 64, 0, 128, 128, 64, 192);
450 
451  head->FillHists(&evenHead, &oddHead, headFlipEven, headFlipOdd);
452 
453  th2col->push_back(evenHead);
454  th2col->push_back(oddHead);
455  }
456 
458  TH2F hVsHead[2] = {TH2F("headVEven", bestTitle.c_str(), 64, 0, 128, 128, 64, 192),
459  TH2F("headVOdd", bestTitle.c_str(), 64, 0, 128, 128, 64, 192)};
460  Potential VHead;
461  FillPotential(*head, VHead, headFlipEven, headFlipOdd);
462  for(int plane = 0; plane < 256; ++plane){
463  for(int cell = 0; cell < 256; ++cell){
464  const double p = VHead.V[256*plane+cell];
465  hVsHead[plane%2].Fill(plane, cell, p);
466  }
467  }
468  th2col->push_back(hVsHead[0]);
469  th2col->push_back(hVsHead[1]);
470  }
471  }
472 
473 
474  // Trial
475  const char* trialTitle = "Trial event;Plane;Cell";
476 
477  if(fSaveEventImages){
478  TH2F evenTrial("trialEven", trialTitle, 64, 0, 128, 128, 64, 192);
479  TH2F oddTrial ("trialOdd", trialTitle, 64, 0, 128, 128, 64, 192);
480 
481  trial.FillHists(&evenTrial, &oddTrial);
482 
483  th2col->push_back(evenTrial);
484  th2col->push_back(oddTrial);
485  }
486 
488  TH2F hVsTrial[2] = {TH2F("trialVEven", trialTitle, 64, 0, 128, 128, 64, 192),
489  TH2F("trialVOdd", trialTitle, 64, 0, 128, 128, 64, 192)};
490  Potential VTrial;
491  FillPotential(trial, VTrial, false, false);
492  for(int plane = 0; plane < 256; ++plane){
493  for(int cell = 0; cell < 256; ++cell){
494  const double p = VTrial.V[256*plane+cell];
495  hVsTrial[plane%2].Fill(plane, cell, p);
496  }
497  }
498  th2col->push_back(hVsTrial[0]);
499  th2col->push_back(hVsTrial[1]);
500  }
501  }
const char * p
Definition: xmltok.h:285
bool fSaveEventPotentials
Definition: LEM_module.cc:86
Eigen::Matrix< T, Eigen::Dynamic, 1 > head(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, size_t n)
Definition: head.hpp:24
bool fSaveEventImages
Definition: LEM_module.cc:86
Heads * fHeads
Definition: LEM_module.cc:81
void FillPotential(const EventSummary &trial, Potential &V, bool flipEven, bool flipOdd)
Definition: FindMatches.cxx:76
enum BeamMode string
void lem::LEM::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 169 of file LEM_module.cc.

References fDownsampleFactor, fHeads, fLib, fLibPath, fMMappedLoading, fOnDemand, fPreloadHeads, fPreloadLib, lem::Heads::FromMMap(), lem::Library::FromMMap(), lem::Heads::FromMMapOnDemand(), lem::Library::FromMMapOnDemand(), lem::Library::FromTrees(), fSplitLibFactor, fSplitLibIndex, and fUseLibraryService.

170  {
171  if(fUseLibraryService) return;
172 
173  if(fMMappedLoading){
174  if(fOnDemand){
177  }
178  else{
181  }
182  }
183  else{
187  fHeads = 0;
188  }
189  }
bool fPreloadLib
Definition: LEM_module.cc:78
std::string fLibPath
Directory to find the library files in.
Definition: LEM_module.cc:73
static Heads * FromMMapOnDemand(const std::string &libPath)
Definition: Heads.cxx:49
bool fUseLibraryService
Definition: LEM_module.cc:71
bool fPreloadHeads
Definition: LEM_module.cc:78
int fDownsampleFactor
How many levels to take the downsampling optimization.
Definition: LEM_module.cc:75
bool fOnDemand
Definition: LEM_module.cc:77
int fSplitLibFactor
Definition: LEM_module.cc:83
int fSplitLibIndex
Definition: LEM_module.cc:84
Heads * fHeads
Definition: LEM_module.cc:81
static Library * FromMMapOnDemand(const std::string &libPath)
Definition: Library.cxx:82
bool fMMappedLoading
Definition: LEM_module.cc:77
static Library * FromTrees(const std::string &libPath, int splitLibFactor, int splitLibIndex, int downsampleFactor)
Definition: Library.cxx:100
static Heads * FromMMap(const std::string &libPath, bool touchAll)
Definition: Heads.cxx:23
Library * fLib
Definition: LEM_module.cc:80
static Library * FromMMap(const std::string &libPath, bool touchAll)
Definition: Library.cxx:62
void lem::LEM::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 197 of file LEM_module.cc.

References fLib, fUseLibraryService, lem::LEMLibrary::GetLib(), g4zmq::ls(), art::Run::put(), and lem::Library::Summary().

198  {
199  std::unique_ptr<lem::LibrarySummary> ls(new lem::LibrarySummary);
200  if(fUseLibraryService){
202  *ls = libserv->GetLib()->Summary();
203  }
204  else{
205  *ls = fLib->Summary();
206  }
207  run.put(std::move(ls));
208  }
bool fUseLibraryService
Definition: LEM_module.cc:71
const LibrarySummary & Summary() const
Definition: Library.h:30
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:149
Details of the library LEM matches were made against.
const Library * GetLib() const
def ls(target="")
Definition: g4zmq.py:69
Library * fLib
Definition: LEM_module.cc:80
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
void lem::LEM::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 192 of file LEM_module.cc.

193  {
194  }
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  }
rb::Vertex lem::LEM::MatchToVertex ( const Match match,
int  vtxPlane,
int  vtxCell,
int  vtxCellOther 
) const
protected

Definition at line 504 of file LEM_module.cc.

References abs(), getBrightness::cell, geo::PlaneGeo::Cell(), DEFINE_ART_MODULE(), lem::Match::evt, geom(), geo::CellGeo::GetCenter(), geo::kPLANE_NOT_FOUND, lem::kVertexCell, lem::kVertexPlane, geo::kX, geo::kY, geo::PlaneGeo::Ncells(), geo::GeometryBase::NextPlaneOtherView(), geo::GeometryBase::NPlanes(), geo::GeometryBase::Plane(), NDAPDHVSetting::plane, lem::EventSummary::trueVtxCell, lem::EventSummary::trueVtxCellOther, lem::EventSummary::trueVtxPlane, registry_explorer::v, and geo::PlaneGeo::View().

506  {
508 
509  int plane = vtxPlane+match.evt->trueVtxPlane-kVertexPlane;
510 
511  if(plane < 0) plane = 0;
512  if(plane > int(geom->NPlanes())) plane = geom->NPlanes()-1;
513 
514  int cell, cellOther;
515  if(abs(match.evt->trueVtxPlane-kVertexPlane)%2 == 0){
516  cell = vtxCell+match.evt->trueVtxCell-kVertexCell;
517  cellOther = vtxCellOther+match.evt->trueVtxCellOther-kVertexCell;
518  }
519  else{
520  cell = vtxCellOther+match.evt->trueVtxCell-kVertexCell;
521  cellOther = vtxCell+match.evt->trueVtxCellOther-kVertexCell;
522  }
523 
524  int planeOther = 0;
525  if(geom->Plane(plane)){
526  geom->NextPlaneOtherView(plane, +1);
527  if(planeOther == geo::kPLANE_NOT_FOUND) planeOther = geom->NextPlaneOtherView(plane, -1);
528  }
529 
530  if(cell < 0) cell = 0;
531  if(cellOther < 0) cellOther = 0;
532  if(cell >= int(geom->Plane(plane)->Ncells())) cell = geom->Plane(plane)->Ncells()-1;
533  if(cellOther >= int(geom->Plane(planeOther)->Ncells())) cellOther = geom->Plane(planeOther)->Ncells()-1;
534 
535  double xyz[3];
536  geom->Plane(plane)->Cell(cell)->GetCenter(xyz);
537 
538  double xyz2[3];
539  geom->Plane(planeOther)->Cell(cellOther)->GetCenter(xyz2);
540 
541  const geo::View_t v = geom->Plane(plane)->View();
542 
543  return rb::Vertex((v == geo::kX) ? xyz[0] : xyz2[0],
544  (v == geo::kY) ? xyz[1] : xyz2[1],
545  xyz[2],
546  -1); // Don't bother to fill the time
547  }
A 3D position and time representing an interaction vertex.
Definition: Vertex.h:15
void GetCenter(double *xyz, double localz=0.0) const
Definition: CellGeo.cxx:159
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const CellGeo * Cell(int icell) const
Definition: PlaneGeo.h:48
Vertical planes which measure X.
Definition: PlaneGeo.h:28
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const int kVertexPlane
Definition: EventSummary.h:22
void abs(TH1 *hist)
const PlaneGeo * Plane(unsigned int i) const
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:53
const int kVertexCell
Definition: EventSummary.h:23
void geom(int which=0)
Definition: geom.C:163
unsigned int NPlanes() const
const unsigned int NextPlaneOtherView(unsigned int p, int d=+1) const
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::LEM::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 211 of file LEM_module.cc.

References AddHists(), ana::assert(), lem::CalcEnergy(), lem::EventSummary::ccnc, util::CreateAssn(), lem::Library::DownsampledEvents(), E, lem::Library::Event(), lem::EventSummary::event, art::Event::event(), lem::Library::Events(), art::Handle< T >::failedToGet(), fDownsampleFactor, fHeads, lem::FillPotential(), lem::FindMatches(), fInputInstance, fInputLabel, fLib, PandAna.Demos.pi0_spectra::fmt, fSaveEventImages, fSaveEventPotentials, fUseDownsample, fUseLibraryService, art::DataViewImpl::getByLabel(), lem::LEMLibrary::GetHeads(), lem::LEMLibrary::GetLib(), art::DataViewImpl::getManyByType(), lem::MatchIndices::headIdx, lem::MatchList::headIdx, lem::Heads::HeadIdx(), lem::LEMInput::hits, MECModelEnuComparisons::i, dumpEventsToText::inputs, calib::j, lem::kMaxNumMatches, lem::MatchIndices::matches, lem::MatchList::matches, overlay_prestage_def::matches, lem::MatchIndices::matchesEnrich, lem::Library::NEvents(), lem::Heads::NHeads(), lem::EventSummary::origPdg, lem::EventSummary::pdg, art::Event::put(), lem::EventSummary::run, art::Event::run(), lem::MatchableEvent::selfEnergy, gen_flatrecord::size, lem::EventSummary::subrun, art::Event::subRun(), sum, lem::MatchList::trial, lem::EventSummary::trueEVis, lem::FlippedPotentials::V, and lem::EventSummary::y.

212  {
213  std::unique_ptr<std::vector<lem::MatchList> > matchcol(new std::vector<lem::MatchList>);
214  std::unique_ptr<std::vector<lem::MatchIndices>> matchidxs(new std::vector<lem::MatchIndices>);
215 
216  // Associate matches with the slice they came from
217  std::unique_ptr<art::Assns<lem::MatchList, rb::Cluster> > assns(new art::Assns<lem::MatchList, rb::Cluster>);
218  std::unique_ptr<art::Assns<lem::MatchIndices, rb::Cluster> > idxassns(new art::Assns<lem::MatchIndices, rb::Cluster>);
219 
220  std::unique_ptr<std::vector<rb::Vertex> > vtxcol(new std::vector<rb::Vertex>);
221  std::unique_ptr<art::Assns<rb::Vertex, rb::Cluster> > vtxassns(new art::Assns<rb::Vertex, rb::Cluster>);
222 
223  std::unique_ptr<std::vector<geo::OfflineChan> > chancol(new std::vector<geo::OfflineChan>);
224 
225  std::unique_ptr<std::vector<TH2F>> th2col(new std::vector<TH2F>);
226 
227 
230  if(!fInputInstance.empty() && inputs.failedToGet()){
231  evt.put(std::move(matchcol));
232  evt.put(std::move(assns));
233 
234  evt.put(std::move(vtxcol));
235  evt.put(std::move(vtxassns));
236 
237  evt.put(std::move(chancol));
238  if(fSaveEventImages || fSaveEventPotentials) evt.put(std::move(th2col));
239  return;
240  }
241 
243 
244  const Library* lib = fLib;
245  const Heads* heads = fHeads;
246  if(fUseLibraryService){
248  lib = libserv->GetLib();
249  heads = libserv->GetHeads();
250  }
251 
252  const int inputMax = inputs->size();
253  for(int inputIdx = 0; inputIdx < inputMax; ++inputIdx){
254  const LEMInput& input = (*inputs)[inputIdx];
255 
256  EventSummary sum(input.hits, -1, std::vector<int>());
257 
258  sum.run = evt.run();
259  sum.subrun = evt.subRun();
260  sum.event = evt.event();
261 
262  sum.origPdg = 0;
263 
264  sum.pdg = 0;
265  sum.ccnc = 0;
266  sum.y = 0;
267  sum.trueEVis = 0;
268 
269 
270  // chancol->push_back(geo::OfflineChan(vtxPlane, vtxCell));
271  // Should really be nextPlane, but that's lost inside of Util.cxx. This
272  // is almost always right, and only for display purposes anyway.
273  // chancol->push_back(geo::OfflineChan(vtxPlane+1, vtxCellOther));
274 
275  // PID calculation starts around here
276 
277  MatchableEvent trial(sum);
278 
279  std::vector<art::Handle<std::vector<lem::MatchList>>> prevmatchcol;
280 
281  evt.getManyByType(prevmatchcol);
282 
283  std::multiset<float> already;
284  for(unsigned int i = 0; i < prevmatchcol.size(); ++i){
285  // This isn't the same as sliceIdx, because we could have skipped
286  // slices for failing preselection.
287  const unsigned int colIdx = matchcol->size();
288  assert(colIdx < (*prevmatchcol[i]).size());
289 
290  for(unsigned int j = 0; j < (*prevmatchcol[i])[colIdx].matches.size(); ++j){
291  already.insert((*prevmatchcol[i])[colIdx].matches[j].potential);
292  }
293  }
294 
295 
296  int bestHead = -1;
297  bool headFlipEven = false;
298  bool headFlipOdd = false;
299  if(heads){
300  // TODO: consolidate potential-filling with FindMatches
301  FlippedPotentials Vs;
302  FillPotential(trial, Vs);
303  float bestE = FLT_MAX;
304  const int nHeads = heads->NHeads();
305  for(int iHead = 0; iHead < nHeads; ++iHead){
306  const MatchableEvent& headEvt = lib->Event(heads->HeadIdx(iHead));
307 
308  for(int flipEven = 0; flipEven < 2; ++flipEven){
309  for(int flipOdd = 0; flipOdd < 2; ++flipOdd){
310  const float E = CalcEnergy(Vs.V[flipEven][flipOdd], trial, headEvt);
311  if(E < bestE){
312  bestE = E;
313  bestHead = iHead;
314  headFlipEven = flipEven;
315  headFlipOdd = flipOdd;
316  }
317  }
318  }
319  }
320  assert(bestHead >= 0);
321  // Don't bother to PID slices with extremely poor matching to any
322  // head. Flag it here.
323 
324  if(bestE > 2*trial.selfEnergy) bestHead = -1;
325  }
326 
327  std::vector<Match> matches, matchesEnrich;
328 
329  if(!heads || bestHead >= 0){
330  matches =
331  FindMatches(trial,
332  lib->NEvents(), lib->Events(), lib->DownsampledEvents(),
333  fDownsampleFactor, already, kMaxNumMatches, false,
334  heads, heads ? bestHead : -1, headFlipEven, headFlipOdd,
336 
337  matchesEnrich =
338  FindMatches(trial,
339  lib->NEvents(), lib->Events(), lib->DownsampledEvents(),
340  fDownsampleFactor, already, kMaxNumMatches, true,
341  heads, heads ? bestHead : -1, headFlipEven, headFlipOdd,
343  }
344 
345 /*
346  if(!matches.empty()){
347  vtxcol->push_back(MatchToVertex(matches[0], vtxPlane, vtxCell, vtxCellOther));
348  vtxcol->back().SetT(slice.MinTNS());
349  util::CreateAssn(*this, evt, *vtxcol,
350  art::Ptr<rb::Cluster>(slices, sliceIdx), *vtxassns);
351  }
352 */
353 
354  if(!matches.empty()){
355  AddHists(th2col.get(), matches[0], sum,
356  (bestHead >= 0) ? &lib->Event(heads->HeadIdx(bestHead)) : 0,
357  headFlipEven, headFlipOdd);
358  }
359 
360  matchcol->push_back(MatchList());
361  MatchList& ml = matchcol->back();
362 
363  matchidxs->push_back(MatchIndices());
364  MatchIndices& mi = matchidxs->back();
365  mi.headIdx = (bestHead >= 0) ? heads->HeadIdx(bestHead) : -1;
366 
367  for(unsigned int i = 0; i < matches.size(); ++i){
368  ml.matches.push_back(MatchSummary(matches[i]));
369  mi.matches.push_back(matches[i].evt-&lib->Event(0));
370  } // end for i
371 
372  for(unsigned int i = 0; i < matchesEnrich.size(); ++i){
373  ml.matches.push_back(MatchSummary(matchesEnrich[i]));
374  mi.matchesEnrich.push_back(matchesEnrich[i].evt-&lib->Event(0));
375  } // end for i
376 
377  ml.trial = MatchSummary(Match(0, &trial, false, false));
378 
379  ml.headIdx = (bestHead >= 0) ? heads->HeadIdx(bestHead) : -1;
380 
381  // If the original input hits were associated to a cluster, then so
382  // should our matches be.
383  try{
384  std::vector<art::Ptr<rb::Cluster>> slices = fmt.at(inputIdx);
385  if(slices.size() == 1){
386  util::CreateAssn(*this, evt, *matchcol, slices[0], *assns);
387  // util::CreateAssn(*this, evt, *matchidxs, slices[0], *idxassns);
388  }
389  }
390  catch(...){
391  // ugh
392  }
393  } // end for sliceIdx
394 
395  evt.put(std::move(matchcol));
396  evt.put(std::move(assns));
397 
398  evt.put(std::move(vtxcol));
399  evt.put(std::move(vtxassns));
400 
401  evt.put(std::move(chancol));
402  if(fSaveEventImages || fSaveEventPotentials) evt.put(std::move(th2col));
403  }
SubRunNumber_t subRun() const
Definition: Event.h:72
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.
bool fUseDownsample
Whether to use downsampling optimization.
Definition: LEM_module.cc:74
float CalcEnergy(const Potential &Va, const MatchableEvent &a, const MatchableEvent &b)
Definition: FindMatches.cxx:21
const unsigned int kMaxNumMatches
Definition: FindMatches.h:29
bool fUseLibraryService
Definition: LEM_module.cc:71
int fDownsampleFactor
How many levels to take the downsampling optimization.
Definition: LEM_module.cc:75
void AddHists(std::vector< TH2F > *th2col, const Match &bestMatch, const EventSummary &trial, const EventSummary *head, bool headFlipEven, bool headFlipOdd) const
Definition: LEM_module.cc:406
bool fSaveEventPotentials
Definition: LEM_module.cc:86
Definition: __init__.py:1
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
std::vector< Match > FindMatches(const MatchableEvent &trial, unsigned int libSize, const MatchableEvent *lib, const MatchableEvent *libDownsample, int factor, const std::multiset< float > &alreadyInput, unsigned int numMatches, int enrich, const Heads *heads, int headIdx, bool flipHeadEven, bool flipHeadOdd, bool useDownsample)
Float_t E
Definition: plot.C:20
bool fSaveEventImages
Definition: LEM_module.cc:86
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: DataViewImpl.h:446
const double j
Definition: BetheBloch.cxx:29
EventNumber_t event() const
Definition: Event.h:67
Heads * fHeads
Definition: LEM_module.cc:81
void FillPotential(const EventSummary &trial, Potential &V, bool flipEven, bool flipOdd)
Definition: FindMatches.cxx:76
const Heads * GetHeads() const
const Library * GetLib() const
std::string fInputInstance
Definition: LEM_module.cc:69
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
assert(nhit_max >=nhit_nbins)
Library * fLib
Definition: LEM_module.cc:80
Double_t sum
Definition: plot.C:31
RunNumber_t run() const
Definition: Event.h:77
Event(EventPrincipal const &ep, ModuleDescription const &md, cet::exempt_ptr< Consumer > consumer, RangeSet const &rs)
bool failedToGet() const
Definition: Handle.h:196
std::string fInputLabel
Definition: LEM_module.cc:68
void lem::LEM::reconfigure ( const fhicl::ParameterSet pset)
virtual

Definition at line 132 of file LEM_module.cc.

References util::EnvExpansion(), fDownsampleFactor, lem::EventSummary::fgChargePower, lem::EventSummary::fgDecayRate, fInputInstance, fInputLabel, fLibPath, fMMappedLoading, fOnDemand, fPreloadHeads, fPreloadLib, fSaveEventImages, fSaveEventPotentials, fSplitLibFactor, fSplitLibIndex, fUseDownsample, fUseLibraryService, fhicl::ParameterSet::get(), lem::DistanceMap::SetCellScale(), lem::DistanceMap::SetDecayPower(), lem::DistanceMap::SetExpMode(), lem::SetOnDemandMemoryLimit(), lem::DistanceMap::SetPlaneScale(), and string.

Referenced by LEM().

133  {
134  fUseLibraryService = pset.get<bool>("UseLibraryService", false);
135 
136  std::string libpath = pset.get<std::string>("LibraryPath");
137  fLibPath = util::EnvExpansion(libpath);
138 
139  fUseDownsample = pset.get<bool>("UseDownsample");
140  fDownsampleFactor = pset.get<int>("DownsampleFactor");
141 
142  fInputLabel = pset.get<std::string>("InputLabel");
143  fInputInstance = pset.get<std::string>("InputInstance");
144 
145  // This needs to be before anyone asks the DistanceMap anything, should be
146  // safe enough here.
147  DistanceMap::SetPlaneScale(pset.get<double>("DistPlaneScale"));
148  DistanceMap::SetCellScale(pset.get<double>("DistCellScale"));
149  DistanceMap::SetDecayPower(pset.get<double>("DistDecayPower"));
150  DistanceMap::SetExpMode(pset.get<bool>("DistExpMode"));
151 
152  EventSummary::fgDecayRate = pset.get<double>("HitDecayRate");
153  EventSummary::fgChargePower = pset.get<double>("HitChargePower");
154 
155  fSplitLibFactor = pset.get<int>("SplitLibFactor");
156  fSplitLibIndex = pset.get<int>("SplitLibIndex");
157 
158  fMMappedLoading = pset.get<bool>("MMappedLoading");
159  SetOnDemandMemoryLimit(pset.get<int>("LibraryMemoryLimit"));
160  fOnDemand = (pset.get<int>("LibraryMemoryLimit") > 0);
161  fPreloadLib = pset.get<bool>("PreloadLib");
162  fPreloadHeads = pset.get<bool>("PreloadHeads");
163 
164  fSaveEventImages = pset.get<bool>("SaveEventImages", true);
165  fSaveEventPotentials = pset.get<bool>("SaveEventPotentials", false);
166  }
bool fPreloadLib
Definition: LEM_module.cc:78
bool fUseDownsample
Whether to use downsampling optimization.
Definition: LEM_module.cc:74
static double fgChargePower
Definition: EventSummary.h:76
std::string fLibPath
Directory to find the library files in.
Definition: LEM_module.cc:73
bool fUseLibraryService
Definition: LEM_module.cc:71
bool fPreloadHeads
Definition: LEM_module.cc:78
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
int fDownsampleFactor
How many levels to take the downsampling optimization.
Definition: LEM_module.cc:75
bool fSaveEventPotentials
Definition: LEM_module.cc:86
bool fOnDemand
Definition: LEM_module.cc:77
int fSplitLibFactor
Definition: LEM_module.cc:83
static void SetPlaneScale(double ps)
Must call before first call to Instance()
Definition: DistanceMap.h:32
int fSplitLibIndex
Definition: LEM_module.cc:84
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool fSaveEventImages
Definition: LEM_module.cc:86
static void SetDecayPower(double dp)
Definition: DistanceMap.h:34
void SetOnDemandMemoryLimit(long limit_mb)
Definition: OnDemand.cxx:117
std::string fInputInstance
Definition: LEM_module.cc:69
static void SetExpMode(bool em=true)
Definition: DistanceMap.h:35
bool fMMappedLoading
Definition: LEM_module.cc:77
static double fgDecayRate
Definition: EventSummary.h:75
static void SetCellScale(double cs)
Definition: DistanceMap.h:33
std::string fInputLabel
Definition: LEM_module.cc:68
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

int lem::LEM::fDownsampleFactor
protected

How many levels to take the downsampling optimization.

Definition at line 75 of file LEM_module.cc.

Referenced by beginJob(), produce(), and reconfigure().

Heads* lem::LEM::fHeads
protected

Definition at line 81 of file LEM_module.cc.

Referenced by AddHists(), beginJob(), produce(), and ~LEM().

std::string lem::LEM::fInputInstance
protected

Definition at line 69 of file LEM_module.cc.

Referenced by produce(), and reconfigure().

std::string lem::LEM::fInputLabel
protected

Definition at line 68 of file LEM_module.cc.

Referenced by produce(), and reconfigure().

Library* lem::LEM::fLib
protected

Definition at line 80 of file LEM_module.cc.

Referenced by beginJob(), beginRun(), produce(), and ~LEM().

std::string lem::LEM::fLibPath
protected

Directory to find the library files in.

Definition at line 73 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

bool lem::LEM::fMMappedLoading
protected

Definition at line 77 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

bool lem::LEM::fOnDemand
protected

Definition at line 77 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

bool lem::LEM::fPreloadHeads
protected

Definition at line 78 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

bool lem::LEM::fPreloadLib
protected

Definition at line 78 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

bool lem::LEM::fSaveEventImages
protected

Definition at line 86 of file LEM_module.cc.

Referenced by AddHists(), LEM(), produce(), and reconfigure().

bool lem::LEM::fSaveEventPotentials
protected

Definition at line 86 of file LEM_module.cc.

Referenced by AddHists(), LEM(), produce(), and reconfigure().

int lem::LEM::fSplitLibFactor
protected

Definition at line 83 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

int lem::LEM::fSplitLibIndex
protected

Definition at line 84 of file LEM_module.cc.

Referenced by beginJob(), and reconfigure().

bool lem::LEM::fUseDownsample
protected

Whether to use downsampling optimization.

Definition at line 74 of file LEM_module.cc.

Referenced by produce(), and reconfigure().

bool lem::LEM::fUseLibraryService
protected

Definition at line 71 of file LEM_module.cc.

Referenced by beginJob(), beginRun(), produce(), reconfigure(), and ~LEM().


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