LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
hit::DisambigCheater Class Reference
Inheritance diagram for hit::DisambigCheater:
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

 DisambigCheater (fhicl::ParameterSet const &p)
 
virtual ~DisambigCheater ()
 
void produce (art::Event &e)
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
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< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (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< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (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< T > mayConsumeView (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
 

Private Member Functions

void InitHitToWids (const std::vector< art::Ptr< recob::Hit > > &ChHits)
 
void MakeDisambigHit (art::Ptr< recob::Hit > const &hit, geo::WireID const &wid, art::Ptr< recob::Wire > const &wire, art::Ptr< raw::RawDigit > const &rawdigits, recob::HitCollectionCreator &hcol)
 

Private Attributes

art::ServiceHandle< geo::Geometrygeom
 
art::ServiceHandle< cheat::BackTrackerServicebt_serv
 
std::string fChanHitLabel
 
std::string fWidHitLabel
 
std::map< std::pair< double, double >, std::vector< geo::WireID > > fHitToWids
 
unsigned int fFalseChanHits = 0
 
unsigned int fBadIDENearestWire = 0
 
std::vector< unsigned int > fMaxWireShift
 

Detailed Description

Definition at line 32 of file DisambigCheater_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

hit::DisambigCheater::DisambigCheater ( fhicl::ParameterSet const &  p)
explicit

Definition at line 69 of file DisambigCheater_module.cc.

References geo::GeometryCore::Cryostat(), recob::HitAndAssociationsWriterBase::declare_products(), fMaxWireShift, geom, geo::WireGeo::GetCenter(), geo::kZ, geo::GeometryCore::Ncryostats(), geo::TPCGeo::Nplanes(), geo::GeometryCore::NTPC(), geo::PlaneGeo::Nwires(), geo::TPCGeo::Plane(), reconfigure(), geo::CryostatGeo::TPC(), geo::PlaneGeo::View(), w, and geo::PlaneGeo::Wire().

70  {
71  this->reconfigure(p);
72 
73  // let HitCollectionCreator declare that we are going to produce
74  // hits and associations with wires and raw digits
75  // (with no particular product label)
77 
78 
79  // Space charge can shift true IDE postiion to far-off channels.
80  // Calculate maximum number of wires to shift hit in order to be on correct channel.
81  // Shift no more than half of the number of channels, as beyond there will
82  // have been a closer wire segment.
83  if( geom->Ncryostats()!=1 || geom->NTPC()<1 ){
84  fMaxWireShift.resize(3);
85  fMaxWireShift[0]=1;
86  fMaxWireShift[1]=1;
87  fMaxWireShift[2]=1;
88  } else {
89  // assume TPC 0 is typical of all in terms of number of channels
90  unsigned int np = geom->Cryostat(0).TPC(0).Nplanes();
91  fMaxWireShift.resize(np);
92  for(unsigned int p = 0; p<np; ++p){
93  double xyz[3] = {0.};
94  double xyz_next[3] = {0.};
95  unsigned int nw = geom->Cryostat(0).TPC(0).Plane(p).Nwires();
96  for(unsigned int w = 0; w<nw; ++w){
97 
98  // for vertical planes
99  if(geom->Cryostat(0).TPC(0).Plane(p).View()==geo::kZ) {
100  fMaxWireShift[2] = geom->Cryostat(0).TPC(0).Plane(p).Nwires();
101  break;
102  }
103 
104  geom->Cryostat(0).TPC(0).Plane(p).Wire(w).GetCenter(xyz);
105  geom->Cryostat(0).TPC(0).Plane(p).Wire(w+1).GetCenter(xyz_next);
106 
107  if(xyz[2]==xyz_next[2]){
108  fMaxWireShift[p] = w;
109  break;
110  }
111  }// end wire loop
112  }// end plane loop
113 
114  for(unsigned int i=0; i<np; i++)
115  fMaxWireShift[i] = std::floor(fMaxWireShift[i]/2);
116  }
117 
118  }
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:506
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:145
std::vector< unsigned int > fMaxWireShift
art::ServiceHandle< geo::Geometry > geom
Planes which measure Z direction.
Definition: geo_types.h:79
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.h:1117
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:171
void reconfigure(fhicl::ParameterSet const &p)
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:250
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:298
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:68
Float_t w
Definition: plot.C:23
hit::DisambigCheater::~DisambigCheater ( )
virtual

Definition at line 121 of file DisambigCheater_module.cc.

122  {
123  }

Member Function Documentation

void hit::DisambigCheater::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 314 of file DisambigCheater_module.cc.

315  {
316  return;
317  }
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 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
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 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void hit::DisambigCheater::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 321 of file DisambigCheater_module.cc.

References fFalseChanHits.

322  {
323 
324  if(fFalseChanHits > 0)
325  mf::LogWarning("DisambigCheater") << fFalseChanHits << " hits had no associated IDE or WireIDs";
326 
327  return;
328  }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
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_.

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 B, and 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  }
Int_t B
Definition: plot.C:25
void hit::DisambigCheater::InitHitToWids ( const std::vector< art::Ptr< recob::Hit > > &  ChHits)
private
Todo:
: Why would an IDE xyz position be outside of a TPC?
Todo:
: Why would an IDE ossociated with a hit return a nearest wire not on the hit's channel? Usually only one off.

Definition at line 214 of file DisambigCheater_module.cc.

References bt_serv, recob::Hit::Channel(), geo::GeometryCore::ChannelToWire(), geo::CryostatID::Cryostat, e, fBadIDENearestWire, fHitToWids, geo::GeometryCore::FindTPCAtPosition(), fMaxWireShift, geom, geo::InvalidWireError::hasSuggestedWire(), cheat::BackTrackerService::HitToSimIDEs_Ps(), geo::CryostatID::isValid, geo::kU, geo::kV, geo::kZ, geo::GeometryCore::NearestWireID(), recob::Hit::PeakTime(), recob::Hit::PeakTimeMinusRMS(), recob::Hit::PeakTimePlusRMS(), cheat::BackTrackerService::SimIDEsToXYZ(), geo::InvalidWireError::suggestedWireID(), geo::TPCID::TPC, w, and geo::WireID::Wire.

Referenced by produce().

215  {
216 
217  unsigned int Ucount(0), Vcount(0);
218  for( size_t h = 0; h < ChHits.size(); h++ ){
219  recob::Hit const& chit = *(ChHits[h]);
220  if( ChHits[h]->View() == geo::kZ ) continue;
221  if( ChHits[h]->View() == geo::kU ) Ucount++;
222  else if( ChHits[h]->View() == geo::kV ) Vcount++;
223  std::vector<geo::WireID> cwids = geom->ChannelToWire(chit.Channel());
224  std::pair<double,double> ChanTime( (double) chit.Channel(), (double) chit.PeakTime()); // hit key value
225 
226  // get hit IDEs
227  std::vector<const sim::IDE* > ides;
228  try{
229  ides=bt_serv->HitToSimIDEs_Ps( chit);
230  }
231  catch(...){};
232 
233  // catch the hits that have no IDEs
234  bool hasIDEs = !ides.empty();
235  if (hasIDEs) {
236  try { bt_serv->SimIDEsToXYZ(ides); } //What is this supposed to be doing? It get a vector, but never assigns it anywhere. There has to be a better way to do this check
237  catch(...) { hasIDEs = false; }
238  } // if
239  if (!hasIDEs) {
240  mf::LogVerbatim("DisambigCheat") << "Hit on channel " << chit.Channel()
241  << " between " << chit.PeakTimeMinusRMS()
242  << " and " << chit.PeakTimePlusRMS() << " matches no IDEs.";
243  fHitToWids[ChanTime] = std::vector< geo::WireID >();
244  continue;
245  } // if no IDEs
246 
247  // see what wire ID(s) the hit-IDEs are on
248  // if none: hit maps to empty vector
249  // if one: we have a unique hit, vector of size 1
250  // if more than one: make a vector of all wids
251  std::vector<geo::WireID> widsWithIdes;
252  for( size_t i=0; i<ides.size(); i++ ){
253  const double xyzIde[] = { ides[i]->x, ides[i]->y, ides[i]->z };
254 
255  // Occasionally, ide position is not in TPC
257  geo::TPCID tpcID = geom->FindTPCAtPosition(xyzIde);
258  if (!tpcID.isValid) {
259  mf::LogWarning("DisambigCheat") << "IDE at x = " << xyzIde[0]
260  << ", y = " << xyzIde[1]
261  << ", z = " << xyzIde[2]
262  << " does not correspond to a TPC.";
263  continue;
264  }
265  unsigned int tpc = tpcID.TPC, cryo = tpcID.Cryostat;
266 
267  // NearestWire seems to be missing some correction that is applied in LArG4, and is
268  // sometimes off by one or two wires. Use it and then correct it given channel
270  geo::WireID IdeWid;
271  try {
272  IdeWid = geom->NearestWireID(xyzIde, cwids[0].Plane, tpc, cryo);
273  }
274  catch (geo::InvalidWireError const& e) { // adopt suggestion if possible
275  if (!e.hasSuggestedWire()) throw;
276  IdeWid = e.suggestedWireID();
277  mf::LogError("DisambigCheat") << "Detected a point out of its wire plane:\n"
278  << e.what() << "\nUsing suggested wire " << IdeWid << "\n";
279  }
280  geo::WireID storethis = IdeWid; // default...
281  bool foundmatch(false);
282  for( size_t w=0; w<cwids.size(); w++ ){
283  if (cwids[w].TPC!=tpc || cwids[w].Cryostat!=cryo) continue;
284  if( (unsigned int)std::abs((int)(IdeWid.Wire) - (int)(cwids[w].Wire)) <= fMaxWireShift[cwids[0].Plane] ){
285  storethis = cwids[w]; // ...apply correction
286  foundmatch = true;
287  break;
288  }
289  }
290  if( !foundmatch ){
291  mf::LogWarning("DisambigCheat") << "IDE NearestWire return more than 1 off from channel wids: wire "
292  << IdeWid.Wire;
294  }
295 
296  bool alreadyStored(false);
297  for( size_t wid=0; wid<widsWithIdes.size(); wid++ ) if( storethis == widsWithIdes[wid] ) alreadyStored = true;
298  if( !alreadyStored ) widsWithIdes.push_back(storethis);
299  } // end loop through ides from HitToSimIdes
300 
301  fHitToWids[ChanTime] = widsWithIdes;
302 
303  } // end U/V channel hit loop
304 
305  if(fHitToWids.size() != Ucount + Vcount){
306  //throw cet::exception("DisambigCheat");
307  mf::LogWarning("DisambigCheat")<<"Nhits mismatch: "<<fHitToWids.size()<<" "<<Ucount+Vcount;
308  }
309  return;
310  }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides)
Planes which measure V.
Definition: geo_types.h:77
std::vector< unsigned int > fMaxWireShift
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:129
art::ServiceHandle< geo::Geometry > geom
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
Planes which measure Z direction.
Definition: geo_types.h:79
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit)
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
Planes which measure U.
Definition: geo_types.h:76
art::ServiceHandle< cheat::BackTrackerService > bt_serv
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
float PeakTimeMinusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:240
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Exception thrown on invalid wire number.
Definition: Exceptions.h:42
geo::WireID NearestWireID(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:237
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
Float_t e
Definition: plot.C:34
geo::WireID suggestedWireID() const
Returns a better wire ID.
Definition: Exceptions.h:120
recob::tracking::Plane Plane
Definition: TrackState.h:17
bool hasSuggestedWire() const
Returns whether we known a better wire number.
Definition: Exceptions.h:114
Float_t w
Definition: plot.C:23
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
std::map< std::pair< double, double >, std::vector< geo::WireID > > fHitToWids
void hit::DisambigCheater::MakeDisambigHit ( art::Ptr< recob::Hit > const &  hit,
geo::WireID const &  wid,
art::Ptr< recob::Wire > const &  wire,
art::Ptr< raw::RawDigit > const &  rawdigits,
recob::HitCollectionCreator hcol 
)
private

Definition at line 194 of file DisambigCheater_module.cc.

References recob::HitCollectionCreator::emplace_back(), geo::CryostatID::isValid, and recob::HitCreator::move().

Referenced by produce().

199  {
200 
201  if( !wid.isValid ){
202  mf::LogWarning("InvalidWireID") << "wid is invalid, hit not being made\n";
203  return;
204  }
205 
206  // create a hit copy of the original one, but with a different wire ID
207  recob::HitCreator hit(*original_hit, wid);
208  hcol.emplace_back(hit.move(), wire, rawdigits);
209 
210  }
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:84
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:245
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
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 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
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 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void hit::DisambigCheater::produce ( art::Event e)
virtual
Todo:
: Decide how to handle the hits with multiple-wid activity. For now, randomly choose.

Implements art::EDProducer.

Definition at line 126 of file DisambigCheater_module.cc.

References fChanHitLabel, fFalseChanHits, fHitToWids, art::fill_ptr_vector(), art::DataViewImpl::getByLabel(), hits(), InitHitToWids(), geo::kZ, MakeDisambigHit(), and recob::HitCollectionCreator::put_into().

127  {
128 
129  // get hits on channels
131  evt.getByLabel(fChanHitLabel, ChanHits);
132  std::vector< art::Ptr<recob::Hit> > ChHits;
133  art::fill_ptr_vector(ChHits, ChanHits);
134 
135  // also get the associated wires and raw digits;
136  // we assume they have been created by the same module as the hits
137  art::FindOneP<raw::RawDigit> ChannelHitRawDigits
138  (ChanHits, evt, fChanHitLabel);
139  const bool doRawDigitAssns = ChannelHitRawDigits.isValid();
140 
141  art::FindOneP<recob::Wire> ChannelHitWires(ChanHits, evt, fChanHitLabel);
142  const bool doWireAssns = ChannelHitWires.isValid();
143 
144  // this object contains the hit collection
145  // and its associations to wires and raw digits
146  // (if the original objects have them):
147  recob::HitCollectionCreator hits(*this, evt, doWireAssns, doRawDigitAssns);
148 
149 
150  // find the wireIDs each hit is on
151  this->InitHitToWids( ChHits );
152 
153 
154  // make all of the hits
155  for(size_t h=0; h<ChHits.size(); h++){
156 
157  // get the objects associated with this hit
159  if (doWireAssns) wire = ChannelHitWires.at(h);
160  art::Ptr<raw::RawDigit> rawdigits;
161  if (doRawDigitAssns) rawdigits = ChannelHitRawDigits.at(h);
162 
163  // the trivial Z hits
164  if(ChHits[h]->View()==geo::kZ){
165  this->MakeDisambigHit(ChHits[h], ChHits[h]->WireID(), wire, rawdigits, hits);
166  continue;
167  }
168 
169 
170  // make U/V hits if any wire IDs are associated
171  // count hits without a wireID
173  std::pair<double,double> ChanTime(ChHits[h]->Channel()*1., ChHits[h]->PeakTime()*1.);
174  if( fHitToWids[ChanTime].size() == 1 )
175  this->MakeDisambigHit(ChHits[h], fHitToWids[ChanTime][0], wire, rawdigits, hits);
176  else if( fHitToWids[ChanTime].size() == 0 )
177  fFalseChanHits++;
178  else if( fHitToWids[ChanTime].size() > 1 )
179  this->MakeDisambigHit(ChHits[h], fHitToWids[ChanTime][0], wire, rawdigits, hits); // same thing for now
180 
181  } // for
182 
183 
184  // put the hit collection and associations into the event
185  hits.put_into(evt);
186 
187  fHitToWids.clear();
188  return;
189 
190  }
void InitHitToWids(const std::vector< art::Ptr< recob::Hit > > &ChHits)
Planes which measure Z direction.
Definition: geo_types.h:79
void MakeDisambigHit(art::Ptr< recob::Hit > const &hit, geo::WireID const &wid, art::Ptr< recob::Wire > const &wire, art::Ptr< raw::RawDigit > const &rawdigits, recob::HitCollectionCreator &hcol)
void hits()
Definition: readHits.C:15
A class handling a collection of hits and its associations.
Definition: HitCreator.h:513
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Definition: fwd.h:25
std::map< std::pair< double, double >, std::vector< geo::WireID > > fHitToWids
void hit::DisambigCheater::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 332 of file DisambigCheater_module.cc.

References DEFINE_ART_MODULE, fChanHitLabel, and fhicl::ParameterSet::get().

Referenced by DisambigCheater().

333  {
334  fChanHitLabel = p.get< std::string >("ChanHitLabel");
335  return;
336  }
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

art::ServiceHandle<cheat::BackTrackerService> hit::DisambigCheater::bt_serv
private

Definition at line 45 of file DisambigCheater_module.cc.

Referenced by InitHitToWids().

unsigned int hit::DisambigCheater::fBadIDENearestWire = 0
private

Definition at line 62 of file DisambigCheater_module.cc.

Referenced by InitHitToWids().

std::string hit::DisambigCheater::fChanHitLabel
private

Definition at line 47 of file DisambigCheater_module.cc.

Referenced by produce(), and reconfigure().

unsigned int hit::DisambigCheater::fFalseChanHits = 0
private

Definition at line 61 of file DisambigCheater_module.cc.

Referenced by endJob(), and produce().

std::map< std::pair<double,double>, std::vector<geo::WireID> > hit::DisambigCheater::fHitToWids
private

Definition at line 50 of file DisambigCheater_module.cc.

Referenced by InitHitToWids(), and produce().

std::vector<unsigned int> hit::DisambigCheater::fMaxWireShift
private

Definition at line 64 of file DisambigCheater_module.cc.

Referenced by DisambigCheater(), and InitHitToWids().

std::string hit::DisambigCheater::fWidHitLabel
private

Definition at line 48 of file DisambigCheater_module.cc.

art::ServiceHandle<geo::Geometry> hit::DisambigCheater::geom
private

Definition at line 44 of file DisambigCheater_module.cc.

Referenced by DisambigCheater(), and InitHitToWids().


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