9 #ifndef DisambigCheater_h 10 #define DisambigCheater_h 50 std::map< std::pair<double,double>, std::vector<geo::WireID> >
fHitToWids;
92 for(
unsigned int p = 0; p<np; ++p){
94 double xyz_next[3] = {0.};
96 for(
unsigned int w = 0;
w<nw; ++
w){
107 if(xyz[2]==xyz_next[2]){
114 for(
unsigned int i=0; i<np; i++)
132 std::vector< art::Ptr<recob::Hit> > ChHits;
139 const bool doRawDigitAssns = ChannelHitRawDigits.isValid();
142 const bool doWireAssns = ChannelHitWires.isValid();
155 for(
size_t h=0; h<ChHits.size(); h++){
159 if (doWireAssns) wire = ChannelHitWires.at(h);
161 if (doRawDigitAssns) rawdigits = ChannelHitRawDigits.at(h);
164 if(ChHits[h]->View()==
geo::kZ){
165 this->
MakeDisambigHit(ChHits[h], ChHits[h]->WireID(), wire, rawdigits, hits);
173 std::pair<double,double> ChanTime(ChHits[h]->Channel()*1., ChHits[h]->PeakTime()*1.);
202 mf::LogWarning(
"InvalidWireID") <<
"wid is invalid, hit not being made\n";
217 unsigned int Ucount(0), Vcount(0);
218 for(
size_t h = 0; h < ChHits.size(); 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++;
224 std::pair<double,double> ChanTime( (
double) chit.
Channel(), (double) chit.
PeakTime());
227 std::vector<const sim::IDE* > ides;
234 bool hasIDEs = !ides.empty();
237 catch(...) { hasIDEs =
false; }
243 fHitToWids[ChanTime] = std::vector< geo::WireID >();
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 };
260 <<
", y = " << xyzIde[1]
261 <<
", z = " << xyzIde[2]
262 <<
" does not correspond to a TPC.";
265 unsigned int tpc = tpcID.
TPC, cryo = tpcID.
Cryostat;
277 mf::LogError(
"DisambigCheat") <<
"Detected a point out of its wire plane:\n" 278 << e.what() <<
"\nUsing suggested wire " << IdeWid <<
"\n";
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];
291 mf::LogWarning(
"DisambigCheat") <<
"IDE NearestWire return more than 1 off from channel wids: wire " 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);
338 #endif // DisambigCheater_h MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void InitHitToWids(const std::vector< art::Ptr< recob::Hit > > &ChHits)
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides)
DisambigCheater(fhicl::ParameterSet const &p)
WireGeo const & Wire(unsigned int iwire) const
unsigned int Nplanes() const
Number of planes in this tpc.
Declaration of signal hit object.
std::vector< unsigned int > fMaxWireShift
bool isValid
Whether this ID points to a valid element.
art::ServiceHandle< geo::Geometry > geom
virtual ~DisambigCheater()
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 of basic raw digits.
Planes which measure Z direction.
WireID_t Wire
Index of the wire within its plane.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
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)
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.
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.
unsigned int fBadIDENearestWire
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Class managing the creation of a new recob::Hit object.
Helper functions to create a hit.
View_t View() const
Which coordinate does this plane measure.
A class handling a collection of hits and its associations.
#define DEFINE_ART_MODULE(klass)
void reconfigure(fhicl::ParameterSet const &p)
T get(std::string const &key) const
void produce(art::Event &e)
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
art::ServiceHandle< cheat::BackTrackerService > bt_serv
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.
The data type to uniquely identify a TPC.
Definition of data types for geometry description.
unsigned int fFalseChanHits
float PeakTimeMinusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
void put_into(art::Event &)
Moves the data into an event.
Detector simulation of raw signals on wires.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
float PeakTime() const
Time of the signal peak, in tick units.
Encapsulate the construction of a single detector plane.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
std::string fChanHitLabel
unsigned int Nwires() const
Number of wires in this plane.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
object containing MC truth information necessary for making RawDigits and doing back tracking ...
Exception thrown on invalid wire number.
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.
Declaration of basic channel signal object.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
2D representation of charge deposited in the TDC/wire plane
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
TPCID_t TPC
Index of the TPC within its cryostat.
geo::WireID suggestedWireID() const
Returns a better wire ID.
recob::tracking::Plane Plane
bool hasSuggestedWire() const
Returns whether we known a better wire number.
recob::Hit && move()
Prepares the constructed hit to be moved away.
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
std::map< std::pair< double, double >, std::vector< geo::WireID > > fHitToWids
art framework interface to geometry description
Encapsulate the construction of a single detector plane.