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

Public Types

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

Public Member Functions

 SliceMergeViews (const Parameters &params)
 
virtual ~SliceMergeViews ()
 
void beginRun (art::Run &run)
 
void produce (art::Event &evt)
 
void endJob ()
 
void TrimNoise (rb::Cluster *cNoise, std::vector< rb::Cluster > *c2D)
 
double GetZTDist (SliceZT cX, SliceZT cY)
 
std::vector< SliceZTGetSliceZT (std::vector< rb::Cluster > s)
 
std::vector< rb::ClusterDoMerge (rb::Cluster *cNoise, std::vector< rb::Cluster > *cX, std::vector< rb::Cluster > *cY)
 
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

SliceMergeViewsParams fParams
 
SliceMergeViewsDetectorParams fDetectorParams
 

Detailed Description

Definition at line 104 of file SliceMergeViews_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 106 of file SliceMergeViews_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

slicemergeviews::SliceMergeViews::SliceMergeViews ( const Parameters params)
explicit

Definition at line 139 of file SliceMergeViews_module.cc.

140  : fParams(params())
141  {
142  produces< std::vector<rb::Cluster> >();
143  }
slicemergeviews::SliceMergeViews::~SliceMergeViews ( )
virtual

Definition at line 146 of file SliceMergeViews_module.cc.

147  { }

Member Function Documentation

void slicemergeviews::SliceMergeViews::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 150 of file SliceMergeViews_module.cc.

References ana::assert(), geo::GeometryBase::DetId(), fDetectorParams, slicemergeviews::SliceMergeViewsParams::fdParams, fParams, geom(), novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, novadaq::cnv::kTESTBEAM, slicemergeviews::SliceMergeViewsParams::ndParams, and slicemergeviews::SliceMergeViewsParams::tbParams.

151  {
153  switch (geom->DetId()) {
156  break;
159  break;
162  break;
163  default:
164  assert(0 && "Unknown detector");
165  }
166  }
Table< SliceMergeViewsDetectorParams > fdParams
Table< SliceMergeViewsDetectorParams > ndParams
Table< SliceMergeViewsDetectorParams > tbParams
Far Detector at Ash River, MN.
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
Near Detector in the NuMI cavern.
SliceMergeViewsDetectorParams fDetectorParams
void geom(int which=0)
Definition: geom.C:163
assert(nhit_max >=nhit_nbins)
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
std::vector< rb::Cluster > slicemergeviews::SliceMergeViews::DoMerge ( rb::Cluster cNoise,
std::vector< rb::Cluster > *  cX,
std::vector< rb::Cluster > *  cY 
)

Definition at line 212 of file SliceMergeViews_module.cc.

References rb::Cluster::Add(), fDetectorParams, GetSliceZT(), GetZTDist(), MECModelEnuComparisons::i, makeTrainCVSamples::int, calib::j, minY, slicemergeviews::SliceMergeViewsDetectorParams::tolerance, and TrimNoise().

Referenced by produce().

215  {
216  TrimNoise(cNoise, cX);
217  TrimNoise(cNoise, cY);
218 
219  std::vector<rb::Cluster> clusts;
220  std::vector<SliceZT> cXInfo = GetSliceZT(*cX);
221  std::vector<SliceZT> cYInfo = GetSliceZT(*cY);
222 
223  while (cX->size() > 0 && cY->size() > 0){
224  double dzt[cX->size()][cY->size()];
225  int minX = 0, minY = 0;
226  for (int i = 0; i < (int)cX->size(); i++){
227  for (int j = 0; j < (int)cY->size(); j++){
228  dzt[i][j] = GetZTDist(cXInfo[i], cYInfo[j]);
229  if (dzt[i][j] < dzt[minX][minY]){
230  minX = i; minY = j;
231  }
232  }
233  }
234  if (dzt[minX][minY] < fDetectorParams.tolerance()){
235  for (int j = 0; j < (int)cY->at(minY).NCell(); j++){
236  cX->at(minX).Add(cY->at(minY).Cell(j));
237  }
238  clusts.push_back(cX->at(minX));
239  cX->erase(cX->begin()+minX);
240  cY->erase(cY->begin()+minY);
241  cXInfo.erase(cXInfo.begin()+minX);
242  cYInfo.erase(cYInfo.begin()+minY);
243  continue;
244  }
245  else break;
246  // if (cX->size() == 0 || cY->size() == 0) break;
247  }
248  while (cX->size() > 0){
249  for (int i = 0; i < (int)cX->at(0).NCell(); i++){
250  //clusts.push_back(cX->at(0));
251  cNoise->Add(cX->at(0).Cell(i));
252  }
253  cX->erase(cX->begin());
254  cXInfo.erase(cXInfo.begin());
255  }
256  while (cY->size() > 0){
257  for (int i = 0; i < (int)cY->at(0).NCell(); i++){
258  //clusts.push_back(cY->at(0));
259  cNoise->Add(cY->at(0).Cell(i));
260  }
261  cY->erase(cY->begin());
262  cYInfo.erase(cYInfo.begin());
263  }
264  return clusts;
265  }
double minY
Definition: plot_hist.C:9
double GetZTDist(SliceZT cX, SliceZT cY)
void TrimNoise(rb::Cluster *cNoise, std::vector< rb::Cluster > *c2D)
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
std::vector< SliceZT > GetSliceZT(std::vector< rb::Cluster > s)
const double j
Definition: BetheBloch.cxx:29
SliceMergeViewsDetectorParams fDetectorParams
void slicemergeviews::SliceMergeViews::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 169 of file SliceMergeViews_module.cc.

170  {
171  }
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  }
std::vector< SliceZT > slicemergeviews::SliceMergeViews::GetSliceZT ( std::vector< rb::Cluster s)

Definition at line 193 of file SliceMergeViews_module.cc.

References MECModelEnuComparisons::i.

Referenced by DoMerge().

194  {
195  std::vector<SliceZT> info(s.size());
196  for (unsigned int i=0; i<s.size(); ++i){
197  info[i].minZ = s[i].MinZ();
198  info[i].maxZ = s[i].MaxZ();
199  info[i].T = s[i].MeanTNS();
200  }
201  return info;
202  }
const XML_Char XML_Encoding * info
Definition: expat.h:530
const XML_Char * s
Definition: expat.h:262
double slicemergeviews::SliceMergeViews::GetZTDist ( SliceZT  cX,
SliceZT  cY 
)

Definition at line 204 of file SliceMergeViews_module.cc.

References fDetectorParams, slicemergeviews::SliceZT::maxZ, slicemergeviews::SliceZT::minZ, std::sqrt(), slicemergeviews::SliceZT::T, slicemergeviews::SliceMergeViewsDetectorParams::tScale, and slicemergeviews::SliceMergeViewsDetectorParams::zScale.

Referenced by DoMerge().

205  {
206  double dz1= (cX.maxZ - cY.maxZ)/fDetectorParams.zScale();
207  double dz2= (cX.minZ - cY.minZ)/fDetectorParams.zScale();
208  double dt = (cX.T - cY.T)/fDetectorParams.tScale();
209  return sqrt(dz1*dz1 + dz2*dz2 + dt*dt);
210  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
Definition: Cand.cxx:23
SliceMergeViewsDetectorParams fDetectorParams
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().

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

Implements art::EDProducer.

Definition at line 268 of file SliceMergeViews_module.cc.

References DEFINE_ART_MODULE(), DoMerge(), fParams, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, makeTrainCVSamples::int, calib::j, art::Event::put(), and slicemergeviews::SliceMergeViewsParams::slice2DInput.

269  {
271  evt.getByLabel(fParams.slice2DInput(), slice2Dcol);
272 
273  std::vector<rb::Cluster> clustsX;
274  std::vector<rb::Cluster> clustsY;
275 
276  std::vector<rb::Cluster> clusters;
277  clusters.push_back(slice2Dcol->at(0));
278 
279  for (int i = 1; i < int(slice2Dcol->size()); i++){
280  slice2Dcol->at(i).NXCell() > 0 ?
281  clustsX.push_back(slice2Dcol->at(i)) :
282  clustsY.push_back(slice2Dcol->at(i));
283  }
284 
285 
286  std::unique_ptr< std::vector<rb::Cluster> >
287  clustercol(new std::vector<rb::Cluster>);
288 
289  std::vector<rb::Cluster> curclusts =
290  DoMerge(&clusters[0], &clustsX, &clustsY);
291  for (int j = 0; j < (int)curclusts.size(); j++){
292  clusters.push_back(curclusts[j]);
293  }
294 
295  // Tag the noise cluster as such.
296  clusters[0].SetNoise(true);
297 
298  // Always put in the noise cluster even if it is empty.
299  for (int i = 0; i < (int)clusters.size(); i++){
300  // if (clusters[i].NXCell() < 3) continue;
301  // if (clusters[i].NYCell() < 3) continue;
302  clustercol->push_back(clusters[i]);
303  }
304 
305  //
306  // Before saving the clusters, put the hits inside them into a
307  // standard order
308  //
309  for (unsigned int i=0; i<clustercol->size(); ++i) {
310  (*clustercol)[i].StandardSort();
311  }
312 
313  // put the slices into the event
314  evt.put(std::move(clustercol));
315 
316  } // end Produce function
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
const double j
Definition: BetheBloch.cxx:29
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< rb::Cluster > DoMerge(rb::Cluster *cNoise, std::vector< rb::Cluster > *cX, std::vector< rb::Cluster > *cY)
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void slicemergeviews::SliceMergeViews::TrimNoise ( rb::Cluster cNoise,
std::vector< rb::Cluster > *  c2D 
)

Definition at line 177 of file SliceMergeViews_module.cc.

References rb::Cluster::Add(), hadd_many_files::counter, fDetectorParams, MECModelEnuComparisons::i, makeTrainCVSamples::int, calib::j, and slicemergeviews::SliceMergeViewsDetectorParams::minCell.

Referenced by DoMerge().

179  {
180  double counter = 0;
181  for (int i = c2D->size()-1; i >= 0; i--){
182  if (c2D->at(i).NXCell() < fDetectorParams.minCell() &&
183  c2D->at(i).NYCell() < fDetectorParams.minCell()){
184  for (int j = 0; j < (int)c2D->at(i).NCell(); j++){
185  cNoise->Add(c2D->at(i).Cell(j));
186  }
187  c2D->erase(c2D->begin()+i);
188  }
189  counter++;
190  }
191  }
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
const double j
Definition: BetheBloch.cxx:29
SliceMergeViewsDetectorParams fDetectorParams
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

SliceMergeViewsDetectorParams slicemergeviews::SliceMergeViews::fDetectorParams
protected

Definition at line 126 of file SliceMergeViews_module.cc.

Referenced by beginRun(), DoMerge(), GetZTDist(), and TrimNoise().

SliceMergeViewsParams slicemergeviews::SliceMergeViews::fParams
protected

Definition at line 125 of file SliceMergeViews_module.cc.

Referenced by beginRun(), and produce().


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