Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
hv::HoughVertex Class Reference

Find event vertex using a Hough transform. More...

Inheritance diagram for hv::HoughVertex:
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

 HoughVertex (const fhicl::ParameterSet &pset)
 
virtual ~HoughVertex ()
 
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
 

Protected Attributes

std::string fSliceLabel
 
double fErrorScale
 
double fMaxHitsUsedPerView
 
bool fObeyPreselection
 
HoughVertexAlg fAlg
 
bool fSaveMaps
 

Detailed Description

Find event vertex using a Hough transform.

Definition at line 30 of file HoughVertex_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

hv::HoughVertex::HoughVertex ( const fhicl::ParameterSet pset)
explicit

Definition at line 50 of file HoughVertex_module.cc.

References fSaveMaps.

51  : fSliceLabel(pset.get<std::string>("SliceLabel")),
52  fErrorScale(pset.get<double>("ErrorScale")),
53  fMaxHitsUsedPerView(pset.get<double>("MaxHitsUsedPerView")),
54  fObeyPreselection(pset.get<bool>("ObeyPreselection")),
55  fAlg(pset.get<fhicl::ParameterSet>("VertexAlgPSet")),
56  fSaveMaps(pset.get<bool>("SaveMaps"))
57  {
58  produces<std::vector<rb::Vertex>>();
59  // Vertices are associated with the slice they came from
60  produces<art::Assns<rb::Vertex, rb::Cluster>>();
61 
62  if(fSaveMaps) produces<std::vector<TH2F>>();
63  }
HoughVertexAlg fAlg
std::string fSliceLabel
T get(std::string const &key) const
Definition: ParameterSet.h:231
enum BeamMode string
hv::HoughVertex::~HoughVertex ( )
virtual

Definition at line 66 of file HoughVertex_module.cc.

67  {
68  }

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 hv::HoughVertex::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 71 of file HoughVertex_module.cc.

References rb::CellHit::Cell(), rb::Cluster::Cell(), util::CreateAssn(), DEFINE_ART_MODULE(), dz, fAlg, fErrorScale, hv::HoughVertexAlg::FindVertex(), fMaxHitsUsedPerView, fObeyPreselection, genie::utils::style::Format(), fSaveMaps, fSliceLabel, geom(), art::DataViewImpl::getByLabel(), geo::CellGeo::GetCenter(), geo::CellGeo::HalfD(), geo::CellGeo::HalfW(), rb::IsFiltered(), rb::Cluster::IsNoise(), geo::kX, rb::Cluster::MeanTNS(), rb::Cluster::NCell(), rb::CellHit::Plane(), geo::GeometryBase::Plane(), art::Event::put(), std::sqrt(), and rb::CellHit::View().

72  {
73  std::unique_ptr<std::vector<rb::Vertex>> vtxcol(new std::vector<rb::Vertex>);
74  std::unique_ptr<std::vector<TH2F>> histcol(new std::vector<TH2F>);
75  // Associate vertices with the slice they came from
76  std::unique_ptr<art::Assns<rb::Vertex, rb::Cluster>> assns(new art::Assns<rb::Vertex, rb::Cluster>);
77 
79 
81  evt.getByLabel(fSliceLabel, slices);
82 
83  for(unsigned int sliceIdx = 0; sliceIdx < slices->size(); ++sliceIdx){
84  if(fObeyPreselection && rb::IsFiltered(evt, slices, sliceIdx)) continue;
85 
86  const rb::Cluster& slice = (*slices)[sliceIdx];
87  if(slice.IsNoise()) continue;
88 
89  std::vector<Vector2D> xhits, yhits;
90 
91  for(unsigned int hitIdx = 0; hitIdx < slice.NCell(); ++hitIdx){
92  const rb::CellHit& chit = *slice.Cell(hitIdx);
93 
94  TVector3 xyz;
95  const geo::CellGeo* geocell = geom->Plane(chit.Plane())->Cell(chit.Cell());
96  geocell->GetCenter(xyz);
97  const float dz = (2*geocell->HalfD())/sqrt(12) * fErrorScale;
98  const float dv = (2*geocell->HalfW())/sqrt(12) * fErrorScale;
99 
100  if(chit.View() == geo::kX){
101  xhits.push_back(Vector2D(xyz.Z(), xyz.X(), dz, dv));
102  }
103  else{
104  yhits.push_back(Vector2D(xyz.Z(), xyz.Y(), dz, dv));
105  }
106  } // end for hitIdx
107 
108  // Vertexing time goes quadratically as the number of hits. Only use the
109  // N most-upstream hits in each view.
110  std::sort(xhits.begin(), xhits.end());
111  std::sort(yhits.begin(), yhits.end());
112  while(xhits.size() > fMaxHitsUsedPerView) xhits.pop_back();
113  while(yhits.size() > fMaxHitsUsedPerView) yhits.pop_back();
114 
115  // Do all the actual work
116  TVector3 vtx;
117  if(fSaveMaps){
118  TH2F *xmap, *ymap;
119 
120  vtx = fAlg.FindVertex(xhits, yhits, &xmap, &ymap);
121 
122  xmap->SetName(TString::Format("xmap_slice%d", sliceIdx));
123  ymap->SetName(TString::Format("ymap_slice%d", sliceIdx));
124 
125  xmap->SetTitle(TString::Format("X view Hough map, slice %d", sliceIdx));
126  ymap->SetTitle(TString::Format("Y view Hough map, slice %d", sliceIdx));
127 
128  histcol->push_back(*xmap);
129  histcol->push_back(*ymap);
130 
131  delete xmap;
132  delete ymap;
133  }
134  else{
135  vtx = fAlg.FindVertex(xhits, yhits);
136  }
137 
138  vtxcol->push_back(rb::Vertex(vtx, slice.MeanTNS()));
139  // Associate most recently added vertex with the slice
140  util::CreateAssn(*this, evt, *vtxcol,
141  art::Ptr<rb::Cluster>(slices, sliceIdx), *assns);
142  } // end for sliceIdx
143 
144  evt.put(std::move(vtxcol));
145  if(fSaveMaps) evt.put(std::move(histcol));
146  evt.put(std::move(assns));
147  }
A 3D position and time representing an interaction vertex.
Definition: Vertex.h:15
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.
double HalfD() const
Definition: CellGeo.cxx:205
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
void GetCenter(double *xyz, double localz=0.0) const
Definition: CellGeo.cxx:159
HoughVertexAlg fAlg
unsigned short Plane() const
Definition: CellHit.h:39
std::string fSliceLabel
geo::View_t View() const
Definition: CellHit.h:41
T sqrt(T number)
Definition: d0nt_math.hpp:156
Vertical planes which measure X.
Definition: PlaneGeo.h:28
double HalfW() const
Definition: CellGeo.cxx:191
A collection of associated CellHits.
Definition: Cluster.h:47
const PlaneGeo * Plane(unsigned int i) const
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
unsigned short Cell() const
Definition: CellHit.h:40
double dz[NP][NC]
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.cxx:554
void geom(int which=0)
Definition: geom.C:163
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
TVector3 FindVertex(const std::vector< Vector2D > &xhits, const std::vector< Vector2D > &yhits, TH2F **xmap=0, TH2F **ymap=0) const
Encapsulate the cell geometry.
Definition: CellGeo.h:25
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

HoughVertexAlg hv::HoughVertex::fAlg
protected

Definition at line 44 of file HoughVertex_module.cc.

Referenced by produce().

double hv::HoughVertex::fErrorScale
protected

Definition at line 40 of file HoughVertex_module.cc.

Referenced by produce().

double hv::HoughVertex::fMaxHitsUsedPerView
protected

Definition at line 41 of file HoughVertex_module.cc.

Referenced by produce().

bool hv::HoughVertex::fObeyPreselection
protected

Definition at line 42 of file HoughVertex_module.cc.

Referenced by produce().

bool hv::HoughVertex::fSaveMaps
protected

Definition at line 46 of file HoughVertex_module.cc.

Referenced by HoughVertex(), and produce().

std::string hv::HoughVertex::fSliceLabel
protected

Definition at line 39 of file HoughVertex_module.cc.

Referenced by produce().


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