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

Public Types

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

Public Member Functions

 MEFinder (const Parameters &params)
 
virtual ~MEFinder ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
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 GetPhysNoiseSlcs (art::Handle< std::vector< rb::Cluster > > slcs, std::vector< rb::Cluster > &noiseSlcs, std::vector< rb::Cluster > &physSlcs)
 
me::VecCHits MECandHits (std::vector< rb::Cluster > noiseSlcs, std::vector< rb::Cluster > physSlcs)
 
void FindNoiseHitRange (me::VecCHits hits, double physTNS, int &firstIdx, int &latsIdx)
 
void AddMEHit (me::VecCHits &meHits, me::PtrCHit noiseCell, rb::Cluster physSlc)
 
double MinHitSlcDist (me::PtrCHit hit, rb::Cluster slc)
 
double HitToHitDistance (const PtrCHit &hit1, const PtrCHit &hit2)
 
me::VecVecCHits ClusterMEHits (VecCHits)
 
double MEDistanceMetric (me::PtrCHit hit1, me::PtrCHit hit2)
 
me::SlcME MakeSlcME (me::VecCHits michel, art::Handle< std::vector< rb::Cluster > > slcs, int &parentSlcIdx)
 
me::TrkME MakeTrkME (me::SlcME michel, art::Handle< std::vector< rb::Cluster > > slcs, art::Ptr< rb::Track > parentTrack)
 
void BestSlcMatch (me::SlcME michel, me::MEVars &vars, art::Handle< std::vector< rb::Cluster > > slcs, int &parentSlcIdx)
 
bool PassesMEPresel (me::SlcME michel)
 
double GetMID (double deltaT, double distToSlc, double calE, int nCells)
 
bool IsTrkME (me::SlcME michel, const std::vector< art::Ptr< rb::Track > > trks, art::Ptr< rb::Track > &parentTrk)
 
double TrkMEDist (me::SlcME slcME, TVector3 trkEnd)
 
std::vector< double > MEMeanXYZ (me::VecCHits me, bool &, bool &)
 
CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

art::ServiceHandle< geo::Geometryfgeom
 
MEFinderParams fParams
 
LikeHists fLikeHists
 

Detailed Description

Definition at line 191 of file MEFinder_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

Definition at line 196 of file MEFinder_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

me::MEFinder::MEFinder ( const Parameters params)
explicit

Definition at line 266 of file MEFinder_module.cc.

267  : fParams(params())
268  {
269  produces<std::vector<me::SlcME> >();
270  produces<art::Assns<me::SlcME, rb::Cluster> >();
271  produces<std::vector<me::TrkME> >();
272  produces<art::Assns<me::TrkME, rb::Track> >();
273  produces<art::Assns<me::TrkME, rb::Cluster> >();
274  }
MEFinderParams fParams
me::MEFinder::~MEFinder ( )
virtual

Definition at line 276 of file MEFinder_module.cc.

276 { }

Member Function Documentation

void me::MEFinder::AddMEHit ( me::VecCHits meHits,
me::PtrCHit  noiseCell,
rb::Cluster  physSlc 
)
protected

Definition at line 408 of file MEFinder_module.cc.

References rawdata::RawDigit::ADC(), rb::CellHit::Cell(), fParams, MECModelEnuComparisons::i, makeTrainCVSamples::int, me::MEFinderParams::maxDeltaT, me::MEFinderParams::maxDist, rb::Cluster::MeanTNS(), me::MEFinderParams::minDeltaT, me::MEFinderParams::minDeltaTReTrigger, me::MEFinderParams::minHitADC, MinHitSlcDist(), rb::CellHit::Plane(), and rb::CellHit::TNS().

Referenced by MECandHits().

410  {
411  double minDist = MinHitSlcDist(noiseCell, physSlc);
412  double deltaT = noiseCell->TNS() - physSlc.MeanTNS();
413  if (noiseCell->ADC() < fParams.minHitADC())
414  return;
415  // Treat Retriggers differently because of APD dead-time (DocDB 12295)
416  // Additionally require deltaT > 0 for tagging retrigger hits to
417  // accomodate negative search time for measuring uncorrelated background
418  double curMinDeltaT = ( minDist == 0 && deltaT > 0 ) ?
420  if (deltaT > curMinDeltaT &&
421  deltaT < fParams.maxDeltaT() &&
422  minDist < fParams.maxDist()){
423  bool addHit = true;
424  for (int i = 0; i < (int)meHits.size(); i++){
425  if (noiseCell->Plane() == meHits[i]->Plane() &&
426  noiseCell->Cell() == meHits[i]->Cell() &&
427  noiseCell->ADC() == meHits[i]->ADC())
428  addHit = false;
429  }
430  if (addHit) meHits.push_back(noiseCell);
431  }
432  return;
433  }
float TNS() const
Definition: CellHit.h:46
unsigned short Plane() const
Definition: CellHit.h:39
Atom< double > maxDist
unsigned short Cell() const
Definition: CellHit.h:40
Atom< double > maxDeltaT
MEFinderParams fParams
Atom< double > minDeltaT
Atom< double > minDeltaTReTrigger
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.cxx:554
Atom< double > minHitADC
double MinHitSlcDist(me::PtrCHit hit, rb::Cluster slc)
void me::MEFinder::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 279 of file MEFinder_module.cc.

References me::LikeHists::fHFCalE_NCells, me::LikeHists::fHFDeltaT_Dist, cet::search_path::find_file(), fLikeHists, me::LikeHists::fMECalE_NCells, me::LikeHists::fMEDeltaT_Dist, fParams, me::MEFinderParams::llFileName, and string.

280  {
281  cet::search_path sp("FW_SEARCH_PATH");
282  std::string LikeFileName;
283  sp.find_file(fParams.llFileName(), LikeFileName);
284  TFile* like = TFile::Open(LikeFileName.c_str());
285  like->cd();
286 
287  fLikeHists.fMEDeltaT_Dist = (TH2F*)gDirectory->Get("MEDeltaT_Dist");
288  fLikeHists.fMECalE_NCells = (TH2F*)gDirectory->Get("MECalE_NCells");
289 
290  fLikeHists.fHFDeltaT_Dist = (TH2F*)gDirectory->Get("HFDeltaT_Dist");
291  fLikeHists.fHFCalE_NCells = (TH2F*)gDirectory->Get("HFCalE_NCells");
292  }
LikeHists fLikeHists
MEFinderParams fParams
Atom< std::string > llFileName
enum BeamMode string
void me::MEFinder::BestSlcMatch ( me::SlcME  michel,
me::MEVars vars,
art::Handle< std::vector< rb::Cluster > >  slcs,
int parentSlcIdx 
)
protected

Definition at line 566 of file MEFinder_module.cc.

References rb::Cluster::Cell(), dist, me::MEVars::distToSlc, fLikeHists, me::LikeHists::fMEDeltaT_Dist, fParams, MECModelEnuComparisons::i, rb::Cluster::IsNoise(), calib::j, me::MEFinderParams::matchMEtoSlcByDist, me::MEFinderParams::maxNCells, rb::Cluster::MeanTNS(), MinHitSlcDist(), rb::Cluster::NCell(), me::MEVars::parentSlc, and PandAna.Demos.tute_pid_validation::slc.

Referenced by MakeSlcME().

569  {
570  // Grab the MID building histogram
571  TH2F* hAssn = fLikeHists.fMEDeltaT_Dist;
572  // The assnScore is larger for slices that are appropriately near the ME
573  double assnScore = -1;
574  parentSlcIdx = 0;
575  double allSlcMinDist = 1.0e6;
576  for (unsigned int i = 0; i < slcs->size(); i++){
577  rb::Cluster slc = slcs->at(i);
578  if (slc.IsNoise() || slc.NCell() <= fParams.maxNCells())
579  continue;
580  art::Ptr<rb::Cluster> slcPtr(slcs, i);
581 
582  double deltaT = slcME.MeanTNS() - slc.MeanTNS();
583  double minDist = 10000;
584 
585  for (unsigned int j = 0; j < slcME.NCell(); j++){
586  double dist = MinHitSlcDist(slcME.Cell(j), slcs->at(i));
587  if (dist < minDist)
588  minDist = dist;
589  } // Loop over ME hits
590 
591  // Match by distance only
592  if ( fParams.matchMEtoSlcByDist() )
593  {
594  if ( minDist < allSlcMinDist )
595  {
596  parentSlcIdx = i;
597  allSlcMinDist = minDist;
598  vars.parentSlc = slcPtr;
599  vars.distToSlc = minDist;
600  }
601  }
602 
603  // Match by distance and time (standard method)
604  else
605  {
606  double curScore = hAssn->GetBinContent(hAssn->FindBin(deltaT, minDist));
607  if (curScore > assnScore){
608  parentSlcIdx = i;
609  assnScore = curScore;
610  vars.parentSlc = slcPtr;
611  vars.distToSlc = minDist;
612  }
613  }
614 
615  } // Loop over slices
616  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
LikeHists fLikeHists
A collection of associated CellHits.
Definition: Cluster.h:47
double dist
Definition: runWimpSim.h:113
Atom< unsigned int > maxNCells
MEFinderParams fParams
const double j
Definition: BetheBloch.cxx:29
double distToSlc
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.cxx:554
Atom< bool > matchMEtoSlcByDist
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
art::Ptr< rb::Cluster > parentSlc
double MinHitSlcDist(me::PtrCHit hit, rb::Cluster slc)
me::VecVecCHits me::MEFinder::ClusterMEHits ( me::VecCHits  meHits)
protected

Definition at line 436 of file MEFinder_module.cc.

References me::MEFinderParams::eps, fParams, MECModelEnuComparisons::i, calib::j, and MEDistanceMetric().

Referenced by produce().

436  {
437  me::VecVecCHits meClusters;
438  if (meHits.size() == 0)
439  return meClusters;
440 
441  // This will keep track of wheter hit is already clustered
442  std::vector<bool> isUsed(meHits.size(), false);
443 
444  for (unsigned int i = 0; i < meHits.size(); i++){
445  if (isUsed[i]) continue;
446  me::VecCHits curCluster;
447  curCluster.push_back(meHits[i]);
448  isUsed[i] = true;
449  for (unsigned int j = i; j < meHits.size(); j++){
450  if (isUsed[j]) continue;
451  if (MEDistanceMetric(meHits[i], meHits[j]) < fParams.eps()){
452  isUsed[j] = true;
453  curCluster.push_back(meHits[j]);
454  // Check if any of the hits we just passed over are close to jth idx
455  for (unsigned int k = i; k < j; k++){
456  if (isUsed[k]) continue;
457  if (MEDistanceMetric(meHits[j], meHits[k]) < fParams.eps()){
458  isUsed[k] = true;
459  curCluster.push_back(meHits[k]);
460  }
461  }
462  }
463  }
464  meClusters.push_back(curCluster);
465  }
466  return meClusters;
467  }
std::vector< PtrCHit > VecCHits
double MEDistanceMetric(me::PtrCHit hit1, me::PtrCHit hit2)
Atom< double > eps
MEFinderParams fParams
const double j
Definition: BetheBloch.cxx:29
std::vector< me::VecCHits > VecVecCHits
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 me::MEFinder::FindNoiseHitRange ( me::VecCHits  hits,
double  physTNS,
int firstIdx,
int latsIdx 
)
protected

Definition at line 391 of file MEFinder_module.cc.

References fParams, MECModelEnuComparisons::i, stan::math::log2(), me::MEFinderParams::maxDeltaT, me::MEFinderParams::minDeltaT, and cet::pow().

Referenced by MECandHits().

393  {
394  fIdx = 0; lIdx = 0;
395  double fMETime = physTNS+fParams.minDeltaT();
396  double lMETime = physTNS+fParams.maxDeltaT();
397  int nIter = log2(nHits.size())+1;
398  for (int i = 1; i <= nIter; i++){
399  int fmidpoint = fIdx + (nHits.size()-1)/pow(2,i);
400  fIdx = (nHits[fmidpoint]->TNS() > fMETime) ? fIdx : fmidpoint;
401  int lmidpoint = lIdx + nHits.size()/pow(2,i);
402  lIdx = (nHits[lmidpoint]->TNS() > lMETime) ? lIdx : lmidpoint;
403  }
404  fIdx++;
405  }
constexpr T pow(T x)
Definition: pow.h:75
Atom< double > maxDeltaT
MEFinderParams fParams
Atom< double > minDeltaT
fvar< T > log2(const fvar< T > &x)
Definition: log2.hpp:19
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
double me::MEFinder::GetMID ( double  deltaT,
double  distToSlc,
double  calE,
int  nCells 
)
protected

Definition at line 639 of file MEFinder_module.cc.

References e, me::LikeHists::fHFCalE_NCells, me::LikeHists::fHFDeltaT_Dist, fLikeHists, me::LikeHists::fMECalE_NCells, and me::LikeHists::fMEDeltaT_Dist.

Referenced by MakeSlcME(), and MakeTrkME().

639  {
640  TH2* meDeltaT_Dist = fLikeHists.fMEDeltaT_Dist;
641  TH2* meCalE_NCells = fLikeHists.fMECalE_NCells;
642 
643  int meDeltaT_Dist_Bin = meDeltaT_Dist->FindBin(DeltaT, Dist);
644  int meCalE_NCells_Bin = meCalE_NCells->FindBin(CalE, NCells);
645  double meLike = meDeltaT_Dist->GetBinContent(meDeltaT_Dist_Bin) *
646  meCalE_NCells->GetBinContent(meCalE_NCells_Bin);
647 
648  TH2* hfDeltaT_Dist = fLikeHists.fHFDeltaT_Dist;
649  TH2* hfCalE_NCells = fLikeHists.fHFCalE_NCells;
650 
651  int hfDeltaT_Dist_Bin = hfDeltaT_Dist->FindBin(DeltaT, Dist);
652  int hfCalE_NCells_Bin = hfCalE_NCells->FindBin(CalE, NCells);
653  double hfLike = hfDeltaT_Dist->GetBinContent(hfDeltaT_Dist_Bin) *
654  hfCalE_NCells->GetBinContent(hfCalE_NCells_Bin);
655 
656  if (meLike == 0 && hfLike == 0) return -10;
657  if (meLike == 0)
658  meLike = 1e-10;
659  if (hfLike == 0)
660  hfLike = 1e-10;
661 
662  return TMath::Log(meLike) - TMath::Log(hfLike);
663 
664  }
LikeHists fLikeHists
Float_t e
Definition: plot.C:35
void me::MEFinder::GetPhysNoiseSlcs ( art::Handle< std::vector< rb::Cluster > >  slcs,
std::vector< rb::Cluster > &  noiseSlcs,
std::vector< rb::Cluster > &  physSlcs 
)
protected

Definition at line 348 of file MEFinder_module.cc.

References fParams, MECModelEnuComparisons::i, rb::Cluster::IsNoise(), me::MEFinderParams::maxNCells, and rb::Cluster::NCell().

Referenced by produce().

351  {
352  // Label each slice either noise or physics. A noise slice can be a slice
353  // flagged as noise, or slices with only a few hits ( <= 12 )
354  for (unsigned int i = 0; i < slcs->size(); i++){
355  rb::Cluster slice = slcs->at(i);
356  if (slice.IsNoise())
357  noiseSlcs.push_back(slice);
358  else if (slice.NCell() <= fParams.maxNCells())
359  noiseSlcs.push_back(slice);
360  else
361  physSlcs.push_back(slice);
362  }
363  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
A collection of associated CellHits.
Definition: Cluster.h:47
Atom< unsigned int > maxNCells
MEFinderParams fParams
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
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  }
double me::MEFinder::HitToHitDistance ( const PtrCHit hit1,
const PtrCHit hit2 
)
protected

Definition at line 493 of file MEFinder_module.cc.

References rb::CellHit::Cell(), geo::PlaneGeo::Cell(), fgeom, geo::CellGeo::GetCenter(), rb::CellHit::Plane(), geo::GeometryBase::Plane(), util::pythag(), and rb::CellHit::View().

Referenced by MinHitSlcDist().

493  {
494  // Only calculate if both hits are in the same view
495  if (hit1->View() != hit2->View()) return 100000.;
496  else{
497  double xyz1[3], xyz2[3];
498 
499  unsigned short plane1_idx = hit1->Plane();
500  unsigned short cell1_idx = hit1->Cell();
501  const geo::PlaneGeo* plane1 = fgeom->Plane(plane1_idx);
502  const geo::CellGeo* cell1 = plane1->Cell(cell1_idx);
503  cell1->GetCenter(xyz1);
504 
505  unsigned short plane2_idx = hit2->Plane();
506  unsigned short cell2_idx = hit2->Cell();
507  const geo::PlaneGeo* plane2 = fgeom->Plane(plane2_idx);
508  const geo::CellGeo* cell2 = plane2->Cell(cell2_idx);
509  cell2->GetCenter(xyz2);
510 
511  // Agnostic to whether hits are in X or Y views
512  return util::pythag(xyz1[0]-xyz2[0], xyz1[1]-xyz2[1], xyz1[2]-xyz2[2]);
513  }
514  }
void GetCenter(double *xyz, double localz=0.0) const
Definition: CellGeo.cxx:159
art::ServiceHandle< geo::Geometry > fgeom
const CellGeo * Cell(int icell) const
Definition: PlaneGeo.h:48
const PlaneGeo * Plane(unsigned int i) const
Geometry information for a single readout plane.
Definition: PlaneGeo.h:36
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
Encapsulate the cell geometry.
Definition: CellGeo.h:25
bool me::MEFinder::IsTrkME ( me::SlcME  michel,
const std::vector< art::Ptr< rb::Track > >  trks,
art::Ptr< rb::Track > &  parentTrk 
)
protected

Definition at line 666 of file MEFinder_module.cc.

References dist, fParams, MECModelEnuComparisons::i, me::MEFinderParams::trkClosestApproach, and TrkMEDist().

Referenced by produce().

668  {
669  for (unsigned int i = 0; i < trks.size(); i++){
670  if (trks[i]->NXCell() == 0 || trks[i]->NYCell() == 0)
671  continue;
672  double dist = TrkMEDist(slcME, trks[i]->Stop());
673  if (dist < fParams.trkClosestApproach()){
674  parentTrk = trks[i];
675  return true;
676  }
677  }
678  return false;
679  }
double TrkMEDist(me::SlcME slcME, TVector3 trkEnd)
double dist
Definition: runWimpSim.h:113
MEFinderParams fParams
Atom< double > trkClosestApproach
me::SlcME me::MEFinder::MakeSlcME ( me::VecCHits  michel,
art::Handle< std::vector< rb::Cluster > >  slcs,
int parentSlcIdx 
)
protected

Definition at line 517 of file MEFinder_module.cc.

References rb::Cluster::Add(), BestSlcMatch(), me::MEFinderParams::calibAvailable, rb::Cluster::CalorimetricEnergy(), me::SlcME::DeltaT(), me::SlcME::DistToSlc(), me::MEVars::distToSlc, fParams, GetMID(), MECModelEnuComparisons::i, rb::Cluster::MeanTNS(), rb::Cluster::NCell(), me::MEVars::parentSlc, me::SlcME::SetDeltaT(), me::SlcME::SetDistToSlc(), me::SlcME::SetMID(), me::SlcME::SetParentSlc(), and vars.

Referenced by produce().

519  {
520  me::SlcME slcME;
522 
523  for (unsigned int i = 0; i < michel.size(); i++)
524  slcME.Add(michel[i]);
525  BestSlcMatch(slcME, vars, slcs, parentSlcIdx);
526  slcME.SetDistToSlc (vars.distToSlc);
527  slcME.SetParentSlc (vars.parentSlc);
528  slcME.SetDeltaT (slcME.MeanTNS() - vars.parentSlc->MeanTNS());
529  double mid = -10;
530  if (fParams.calibAvailable()){
531  mid = GetMID(slcME.DeltaT(),
532  slcME.DistToSlc(),
533  slcME.CalorimetricEnergy(),
534  slcME.NCell());
535  }
536  slcME.SetMID(mid);
537  return slcME;
538  }
void SetParentSlc(art::Ptr< rb::Cluster >)
Definition: MEClusters.cxx:26
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
double DistToSlc() const
Definition: MEClusters.cxx:12
void SetDistToSlc(double)
Definition: MEClusters.cxx:22
double GetMID(double deltaT, double distToSlc, double calE, int nCells)
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
void SetDeltaT(double)
Definition: MEClusters.cxx:20
Atom< bool > calibAvailable
double DeltaT() const
Definition: MEClusters.cxx:10
double CalorimetricEnergy(EEnergyCalcScheme escheme=kRecomputeEnergy) const
Simple estimate of neutrino energy.
Definition: Cluster.cxx:439
void BestSlcMatch(me::SlcME michel, me::MEVars &vars, art::Handle< std::vector< rb::Cluster > > slcs, int &parentSlcIdx)
MEFinderParams fParams
const std::map< std::pair< std::string, std::string >, Variable > vars
void SetMID(double)
Definition: MEClusters.cxx:18
double distToSlc
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.cxx:554
art::Ptr< rb::Cluster > parentSlc
me::TrkME me::MEFinder::MakeTrkME ( me::SlcME  michel,
art::Handle< std::vector< rb::Cluster > >  slcs,
art::Ptr< rb::Track parentTrack 
)
protected

Definition at line 540 of file MEFinder_module.cc.

References rb::Cluster::Add(), me::MEFinderParams::calibAvailable, rb::Cluster::CalorimetricEnergy(), rb::Cluster::Cell(), me::SlcME::DeltaT(), me::SlcME::DistToSlc(), fParams, GetMID(), MECModelEnuComparisons::i, rb::Cluster::MeanTNS(), rb::Cluster::NCell(), me::SlcME::SetDeltaT(), me::SlcME::SetDistToSlc(), me::SlcME::SetMID(), me::SlcME::SetParentSlc(), me::TrkME::SetParentTrk(), and vars.

Referenced by produce().

542  {
543  me::TrkME trkME;
545 
546  for (unsigned int i = 0; i < slcME.NCell(); i++)
547  trkME.Add(slcME.Cell(i));
548 
549  trkME.SetDistToSlc (slcME.DistToSlc());
550  trkME.SetParentSlc (parentTrk);
551  trkME.SetDeltaT (slcME.MeanTNS() - parentTrk->MeanTNS());
552  double mid = -10;
553  if (fParams.calibAvailable()){
554  mid = GetMID(slcME.DeltaT(),
555  slcME.DistToSlc(),
556  slcME.CalorimetricEnergy(),
557  slcME.NCell());
558  }
559  trkME.SetMID(mid);
560  trkME.SetParentTrk(parentTrk);
561  return trkME;
562  }
void SetParentSlc(art::Ptr< rb::Cluster >)
Definition: MEClusters.cxx:26
void SetDistToSlc(double)
Definition: MEClusters.cxx:22
double GetMID(double deltaT, double distToSlc, double calE, int nCells)
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
void SetDeltaT(double)
Definition: MEClusters.cxx:20
Atom< bool > calibAvailable
MEFinderParams fParams
const std::map< std::pair< std::string, std::string >, Variable > vars
void SetMID(double)
Definition: MEClusters.cxx:18
void SetParentTrk(art::Ptr< rb::Track >)
Definition: MEClusters.cxx:44
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
me::VecCHits me::MEFinder::MECandHits ( std::vector< rb::Cluster noiseSlcs,
std::vector< rb::Cluster physSlcs 
)
protected

Definition at line 365 of file MEFinder_module.cc.

References AddMEHit(), FindNoiseHitRange(), fParams, me::MEFinderParams::minHitADC, and rb::SortByTime().

Referenced by produce().

366  {
367  // Loop over all noise hits, then ask each physics slice if the noise
368  // hit is close in time / space, then add the hit to the list of candidate
369  // hits appropriately.
370  me::VecCHits meHits;
371 
372  for (unsigned int nIdx = 0; nIdx < noiseSlcs.size(); nIdx++){
373  me::VecCHits noiseHits;
374  for (unsigned int cIdx = 0; cIdx < noiseSlcs[nIdx].NCell(); cIdx++)
375  if (noiseSlcs[nIdx].Cell(cIdx)->ADC() > fParams.minHitADC())
376  noiseHits.push_back(noiseSlcs[nIdx].Cell(cIdx));
377  rb::SortByTime(noiseHits);
378  for (unsigned int pIdx = 0; pIdx < physSlcs.size(); pIdx++){
379  int fIdx = 0; int lIdx = 0;
380  FindNoiseHitRange(noiseHits, physSlcs[pIdx].MeanTNS(), fIdx, lIdx);
381  for (int cIdx = fIdx; cIdx <= lIdx; cIdx++){
382  AddMEHit(meHits, noiseHits[cIdx], physSlcs[pIdx]);
383  }
384  }
385  }
386  return meHits;
387  }
void AddMEHit(me::VecCHits &meHits, me::PtrCHit noiseCell, rb::Cluster physSlc)
std::vector< PtrCHit > VecCHits
void SortByTime(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in time order (earliest to latest).
Definition: CellHit.cxx:134
MEFinderParams fParams
Atom< double > minHitADC
void FindNoiseHitRange(me::VecCHits hits, double physTNS, int &firstIdx, int &latsIdx)
double me::MEFinder::MEDistanceMetric ( me::PtrCHit  hit1,
me::PtrCHit  hit2 
)
protected

Definition at line 469 of file MEFinder_module.cc.

References rb::CellHit::Cell(), me::MEFinderParams::cellScale, fParams, rb::CellHit::Plane(), me::MEFinderParams::planeScale, std::sqrt(), me::MEFinderParams::timeScale, rb::CellHit::TNS(), and rb::CellHit::View().

Referenced by ClusterMEHits().

470  {
471  double deltaC = (hit1->View() == hit2->View()) ?
472  double(hit1->Cell() - hit2->Cell()) / fParams.cellScale() : 0;
473  double deltaP = double(hit1->Plane() - hit2->Plane());
474  deltaP /= fParams.planeScale();
475  double deltaT = double(hit1->TNS() - hit2->TNS());
476  deltaT /= fParams.timeScale();
477  return sqrt(deltaC*deltaC + deltaP*deltaP + deltaT*deltaT);
478  }
float TNS() const
Definition: CellHit.h:46
Atom< double > cellScale
unsigned short Plane() const
Definition: CellHit.h:39
geo::View_t View() const
Definition: CellHit.h:41
T sqrt(T number)
Definition: d0nt_math.hpp:156
Atom< double > timeScale
Atom< double > planeScale
unsigned short Cell() const
Definition: CellHit.h:40
MEFinderParams fParams
std::vector<double> me::MEFinder::MEMeanXYZ ( me::VecCHits  me,
bool &  ,
bool &   
)
protected
double me::MEFinder::MinHitSlcDist ( me::PtrCHit  hit,
rb::Cluster  slc 
)
protected

Definition at line 481 of file MEFinder_module.cc.

References rb::Cluster::Cell(), HitToHitDistance(), MECModelEnuComparisons::i, and rb::Cluster::NCell().

Referenced by AddMEHit(), and BestSlcMatch().

481  {
482  double minDist = 10000;
483  for (unsigned int i = 0; i < slc.NCell(); i++){
484  double curDist = HitToHitDistance(hit, slc.Cell(i));
485  if (curDist < minDist){
486  minDist = curDist;
487  }
488  }
489  return minDist;
490  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
double HitToHitDistance(const PtrCHit &hit1, const PtrCHit &hit2)
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
bool me::MEFinder::PassesMEPresel ( me::SlcME  michel)
protected

Definition at line 618 of file MEFinder_module.cc.

References me::MEFinderParams::calibAvailable, rb::Cluster::CalorimetricEnergy(), me::SlcME::DeltaT(), me::SlcME::DistToSlc(), fParams, me::MEFinderParams::maxCalE, me::MEFinderParams::maxClosestApproach, me::MEFinderParams::maxDeltaT, me::MEFinderParams::maxNCells, me::MEFinderParams::minCalE, me::MEFinderParams::minDeltaT, me::MEFinderParams::minNCells, and rb::Cluster::NCell().

Referenced by produce().

618  {
619  if (slcME.DistToSlc() > fParams.maxClosestApproach())
620  return false;
621  if (slcME.NCell() > fParams.maxNCells())
622  return false;
623  if (slcME.NCell() < fParams.minNCells())
624  return false;
625  if (slcME.DeltaT() > fParams.maxDeltaT())
626  return false;
627  if (slcME.DeltaT() < fParams.minDeltaT())
628  return false;
629  // Only apply calE presel if a calibration is available
630  if (fParams.calibAvailable()){
631  if (slcME.CalorimetricEnergy() > fParams.maxCalE())
632  return false;
633  if (slcME.CalorimetricEnergy() < fParams.minCalE())
634  return false;
635  }
636  return true;
637  }
Atom< double > maxCalE
Atom< bool > calibAvailable
Atom< double > maxDeltaT
Atom< double > minCalE
Atom< unsigned int > maxNCells
Atom< unsigned int > minNCells
MEFinderParams fParams
Atom< double > minDeltaT
Atom< double > maxClosestApproach
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void me::MEFinder::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 295 of file MEFinder_module.cc.

References ClusterMEHits(), util::CreateAssn(), fParams, art::DataViewImpl::getByLabel(), GetPhysNoiseSlcs(), MECModelEnuComparisons::i, IsTrkME(), MakeSlcME(), MakeTrkME(), MECandHits(), me::SlcME::ParentSlc(), me::TrkME::ParentTrk(), PassesMEPresel(), art::Event::put(), me::MEFinderParams::slicerInput, and me::MEFinderParams::trackInput.

296  {
297  // Grab ahold of slc and trk info from the art event, set up Assns
299  evt.getByLabel(fParams.slicerInput(), slcs);
300  art::FindManyP<rb::Track> trkInfo(slcs, evt, fParams.trackInput());
301 
302  std::unique_ptr< std::vector<me::SlcME> >
303  slcMEs(new std::vector<me::SlcME>);
304  std::unique_ptr< art::Assns<me::SlcME, rb::Cluster> >
306 
307  std::unique_ptr< std::vector<me::TrkME> >
308  trkMEs(new std::vector<me::TrkME>);
309  std::unique_ptr< art::Assns<me::TrkME, rb::Track> >
311  std::unique_ptr< art::Assns<me::TrkME, rb::Cluster> >
312  trkMEToSlcAssn(new art::Assns<me::TrkME, rb::Cluster>);
313 
314  // Vector of all CellHits close to any parent slice in time and space
315  std::vector<rb::Cluster> noiseSlcs, physSlcs;
316  GetPhysNoiseSlcs(slcs, noiseSlcs, physSlcs);
317  me::VecCHits meHits = MECandHits(noiseSlcs, physSlcs);
318 
319  // Then sort this vec of CellHits into ME clusters
320  me::VecVecCHits meClusters = ClusterMEHits(meHits);
321 
322  for (unsigned int i = 0; i < meClusters.size(); i++){
323  art::Ptr<rb::Track> parentTrk;
324  int parentSlcIdx;
325  me::SlcME slcME = MakeSlcME(meClusters[i], slcs, parentSlcIdx);
326  if (!PassesMEPresel(slcME)) continue;
327  const std::vector< art::Ptr<rb::Track> > trks = trkInfo.at(parentSlcIdx);
328  if (IsTrkME(slcME, trks, parentTrk)){
329  me::TrkME trkME = MakeTrkME(slcME, slcs, parentTrk);
330  trkMEs->push_back(trkME);
331  util::CreateAssn(*this,evt,*trkMEs,trkME.ParentTrk(),*(trkAssn.get()));
332  util::CreateAssn(*this,evt,*trkMEs,trkME.ParentSlc(),
333  *(trkMEToSlcAssn.get()));
334  }
335  else {
336  slcMEs->push_back(slcME);
337  util::CreateAssn(*this,evt,*slcMEs,slcME.ParentSlc(),*(slcAssn.get()));
338  }
339  }
340  evt.put(std::move(slcMEs));
341  evt.put(std::move(slcAssn));
342  evt.put(std::move(trkMEs));
343  evt.put(std::move(trkAssn));
344  evt.put(std::move(trkMEToSlcAssn));
345  }
me::VecCHits MECandHits(std::vector< rb::Cluster > noiseSlcs, std::vector< rb::Cluster > physSlcs)
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.
art::Ptr< rb::Cluster > ParentSlc() const
Definition: MEClusters.cxx:15
std::vector< PtrCHit > VecCHits
art::Ptr< rb::Track > ParentTrk() const
Definition: MEClusters.cxx:32
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Atom< std::string > trackInput
bool IsTrkME(me::SlcME michel, const std::vector< art::Ptr< rb::Track > > trks, art::Ptr< rb::Track > &parentTrk)
MEFinderParams fParams
bool PassesMEPresel(me::SlcME michel)
std::vector< me::VecCHits > VecVecCHits
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
me::SlcME MakeSlcME(me::VecCHits michel, art::Handle< std::vector< rb::Cluster > > slcs, int &parentSlcIdx)
me::TrkME MakeTrkME(me::SlcME michel, art::Handle< std::vector< rb::Cluster > > slcs, art::Ptr< rb::Track > parentTrack)
Atom< std::string > slicerInput
void GetPhysNoiseSlcs(art::Handle< std::vector< rb::Cluster > > slcs, std::vector< rb::Cluster > &noiseSlcs, std::vector< rb::Cluster > &physSlcs)
me::VecVecCHits ClusterMEHits(VecCHits)
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

double me::MEFinder::TrkMEDist ( me::SlcME  slcME,
TVector3  trkEnd 
)
protected

Definition at line 681 of file MEFinder_module.cc.

References DEFINE_ART_MODULE(), rb::Cluster::MeanX(), rb::Cluster::MeanY(), rb::Cluster::MeanZ(), rb::Cluster::NXCell(), rb::Cluster::NYCell(), and util::pythag().

Referenced by IsTrkME().

681  {
682  double deltaX = ( (me.NXCell() == 0) ? 0 : me.MeanX() - trkEnd.X() );
683  double deltaY = ( (me.NYCell() == 0) ? 0 : me.MeanY() - trkEnd.Y() );
684  double deltaZ = me.MeanZ() - trkEnd.Z();
685  return util::pythag( deltaX, deltaY, deltaZ );
686  }
Definition: NueSkimmer.h:24
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

art::ServiceHandle<geo::Geometry> me::MEFinder::fgeom
protected

Definition at line 256 of file MEFinder_module.cc.

Referenced by HitToHitDistance().

LikeHists me::MEFinder::fLikeHists
protected

Definition at line 260 of file MEFinder_module.cc.

Referenced by beginJob(), BestSlcMatch(), and GetMID().

MEFinderParams me::MEFinder::fParams
protected

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