LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_cluster3d::SpacePointHit3DBuilder Class Reference

SpacePointHit3DBuilder class definiton. More...

Inheritance diagram for lar_cluster3d::SpacePointHit3DBuilder:
lar_cluster3d::IHit3DBuilder

Public Types

enum  TimeValues { COLLECTARTHITS = 0, BUILDTHREEDHITS = 1, NUMTIMEVALUES }
 enumerate the possible values for time checking if monitoring timing More...
 
using RecobHitToPtrMap = std::map< const recob::Hit *, art::Ptr< recob::Hit >>
 Defines a structure mapping art representation to internal. More...
 

Public Member Functions

 SpacePointHit3DBuilder (fhicl::ParameterSet const &pset)
 Constructor. More...
 
 ~SpacePointHit3DBuilder ()
 Destructor. More...
 
void configure (const fhicl::ParameterSet &) override
 Interface for configuring the particular algorithm tool. More...
 
void Hit3DBuilder (const art::Event &evt, reco::HitPairList &hitPairList, RecobHitToPtrMap &) const override
 Given a set of recob hits, run DBscan to form 3D clusters. More...
 
float getTimeToExecute (IHit3DBuilder::TimeValues index) const override
 If monitoring, recover the time to execute a particular function. More...
 

Private Types

using Hit2DVector = std::vector< reco::ClusterHit2D >
 

Private Attributes

art::InputTag m_spacePointTag
 Data members to follow. More...
 
bool m_enableMonitoring
 
std::vector< float > m_timeVector
 
Hit2DVector m_clusterHit2DMasterVec
 
const detinfo::DetectorPropertiesm_detector
 

Detailed Description

SpacePointHit3DBuilder class definiton.

Definition at line 39 of file SpacePointHit3DBuilder_tool.cc.

Member Typedef Documentation

Defines a structure mapping art representation to internal.

Definition at line 44 of file IHit3DBuilder.h.

Member Enumeration Documentation

enumerate the possible values for time checking if monitoring timing

Enumerator
COLLECTARTHITS 
BUILDTHREEDHITS 
NUMTIMEVALUES 

Definition at line 57 of file IHit3DBuilder.h.

Constructor & Destructor Documentation

lar_cluster3d::SpacePointHit3DBuilder::SpacePointHit3DBuilder ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Parameters
pset

Definition at line 87 of file SpacePointHit3DBuilder_tool.cc.

References configure().

88 {
89  this->configure(pset);
90 }
void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool.
lar_cluster3d::SpacePointHit3DBuilder::~SpacePointHit3DBuilder ( )

Destructor.

Definition at line 94 of file SpacePointHit3DBuilder_tool.cc.

95 {
96 }

Member Function Documentation

void lar_cluster3d::SpacePointHit3DBuilder::configure ( const fhicl::ParameterSet )
overridevirtual

Interface for configuring the particular algorithm tool.

Parameters
ParameterSetThe input set of parameters for configuration

Implements lar_cluster3d::IHit3DBuilder.

Definition at line 100 of file SpacePointHit3DBuilder_tool.cc.

References fhicl::ParameterSet::get(), m_detector, m_enableMonitoring, and m_spacePointTag.

Referenced by SpacePointHit3DBuilder().

101 {
102  m_spacePointTag = pset.get<art::InputTag>("SpacePointTag");
103  m_enableMonitoring = pset.get<bool> ("EnableMonitoring", true);
104 
105  m_detector = lar::providerFrom<detinfo::DetectorPropertiesService>();
106 }
const detinfo::DetectorProperties * m_detector
art::InputTag m_spacePointTag
Data members to follow.
float lar_cluster3d::SpacePointHit3DBuilder::getTimeToExecute ( IHit3DBuilder::TimeValues  index) const
inlineoverridevirtual

If monitoring, recover the time to execute a particular function.

Implements lar_cluster3d::IHit3DBuilder.

Definition at line 67 of file SpacePointHit3DBuilder_tool.cc.

References m_timeVector.

67 {return m_timeVector.at(index);}
void lar_cluster3d::SpacePointHit3DBuilder::Hit3DBuilder ( const art::Event evt,
reco::HitPairList hitPairList,
RecobHitToPtrMap recobHitToArtPtrMap 
) const
overridevirtual

Given a set of recob hits, run DBscan to form 3D clusters.

Parameters
hitPairListThe input list of 3D hits to run clustering on
clusterParametersListA list of cluster objects (parameters from associated hits)

Recover the 2D hits from art and fill out the local data structures for the 3D clustering

Implements lar_cluster3d::IHit3DBuilder.

Definition at line 108 of file SpacePointHit3DBuilder_tool.cc.

References lar_cluster3d::IHit3DBuilder::BUILDTHREEDHITS, detinfo::DetectorProperties::ConvertTicksToX(), DEFINE_ART_CLASS_TOOL, art::Ptr< T >::get(), art::DataViewImpl::getByLabel(), reco::ClusterHit2D::getHit(), detinfo::DetectorProperties::GetXTicksOffset(), art::Handle< T >::isValid(), geo::kU, geo::kV, geo::kW, m_clusterHit2DMasterVec, m_detector, m_enableMonitoring, m_spacePointTag, m_timeVector, lar_cluster3d::IHit3DBuilder::NUMTIMEVALUES, geo::PlaneID::Plane, reco::ClusterHit2D::SHAREDINTRIPLET, reco::ClusterHit2D::USEDINTRIPLET, weight, recob::Hit::WireID(), and recob::SpacePoint::XYZ().

109 {
110  m_timeVector.resize(NUMTIMEVALUES, 0.);
111 
112  cet::cpu_timer theClockMakeHits;
113 
114  if (m_enableMonitoring) theClockMakeHits.start();
115 
120  // Start by recovering the associations between space points and hits
122  evt.getByLabel(m_spacePointTag, hitSpacePointAssnsHandle);
123 
124  if (!hitSpacePointAssnsHandle.isValid()) return;
125 
126  // First step is to loop through and get a mapping between space points and associated hits
127  // and, importantly, a list of unique hits (and mapping between art ptr and hit)
128  using SpacePointHitVecMap = std::map<const recob::SpacePoint*, std::vector<const recob::Hit*>>;
129  using RecobHitSet = std::set<const recob::Hit*>;
130 
131  SpacePointHitVecMap spacePointHitVecMap;
132  RecobHitSet recobHitSet;
133 
134  for(auto& assnPair : *hitSpacePointAssnsHandle)
135  {
136  const art::Ptr<recob::SpacePoint> spacePoint = assnPair.second;
137  const art::Ptr<recob::Hit>& recobHit = assnPair.first;
138 
139  spacePointHitVecMap[spacePoint.get()].push_back(recobHit.get());
140  recobHitSet.insert(recobHit.get());
141  recobHitToArtPtrMap[recobHit.get()] = recobHit;
142  }
143 
144  // We'll want to correct the hit times for the plane offsets
145  // (note this is already taken care of when converting to position)
146  std::map<size_t, double> planeOffsetMap;
147 
148  planeOffsetMap[0] = 0.;
149  planeOffsetMap[1] = m_detector->GetXTicksOffset(1, 0, 0)-m_detector->GetXTicksOffset(0, 0, 0);
150  planeOffsetMap[2] = m_detector->GetXTicksOffset(2, 0, 0)-m_detector->GetXTicksOffset(0, 0, 0);
151 
152  // We need temporary mapping from recob::Hit's to our 2D hits
153  using RecobHitTo2DHitMap = std::map<const recob::Hit*,const reco::ClusterHit2D*>;
154 
155  RecobHitTo2DHitMap recobHitTo2DHitMap;
156 
157  // Set the size of the container for our hits
158  m_clusterHit2DMasterVec.clear();
159  m_clusterHit2DMasterVec.reserve(recobHitSet.size());
160 
161  // Now go throught the list of unique hits and create the 2D hits we'll use
162  for(auto& recobHit : recobHitSet)
163  {
164  const geo::WireID& hitWireID(recobHit->WireID());
165 
166  double hitPeakTime(recobHit->PeakTime() - planeOffsetMap[hitWireID.Plane]);
167  double xPosition(m_detector->ConvertTicksToX(recobHit->PeakTime(), hitWireID.Plane, hitWireID.TPC, hitWireID.Cryostat));
168 
169  m_clusterHit2DMasterVec.emplace_back(0, 0., 0., xPosition, hitPeakTime, *recobHit);
170 
171  recobHitTo2DHitMap[recobHit] = &m_clusterHit2DMasterVec.back();
172  }
173 
174  // Now we can go through the space points and build our 3D hits
175  for(auto& pointPair : spacePointHitVecMap)
176  {
177  const recob::SpacePoint* spacePoint = pointPair.first;
178  const std::vector<const recob::Hit*>& recobHitVec = pointPair.second;
179 
180  if (recobHitVec.size() != 3)
181  {
182  std::cout << "************>>>>>> do not have 3 hits associated to space point! " << recobHitVec.size() << " ***************" << std::endl;
183  continue;
184  }
185 
186  std::vector<const reco::ClusterHit2D*> hit2DVec(recobHitVec.size());
187 
188  for(const auto& recobHit : recobHitVec)
189  {
190  const reco::ClusterHit2D* hit2D = recobHitTo2DHitMap.at(recobHit);
191 
192  hit2DVec[hit2D->getHit().WireID().Plane] = hit2D;
193  }
194 
195  // Weighted average, delta, sigmas, chisquare, kitchen sink, refrigerator for beer, etc.
196  float avePeakTime(0.);
197  float weightSum(0.);
198  float sigmaPeakTime(0.);
199 
200  for(const auto& hit2D : hit2DVec)
201  {
202  float hitSigma = hit2D->getHit().RMS();
203  float weight = 1. / (hitSigma * hitSigma);
204 
205  avePeakTime += weight * hit2D->getTimeTicks();
206  weightSum += weight;
207  sigmaPeakTime += hitSigma * hitSigma;
208  }
209 
210  avePeakTime /= weightSum;
211  sigmaPeakTime = std::sqrt(sigmaPeakTime);
212 
213  // Now form the hit chi square
214  float hitChiSquare(0.);
215 
216  for(const auto& hit2D : hit2DVec)
217  {
218  float hitSigma = hit2D->getHit().RMS();
219 
220  hitChiSquare += (hit2D->getTimeTicks() - avePeakTime) / (hitSigma * hitSigma);
221  }
222 
223  // The x position is a weighted sum but the y-z position is simply the average
224  float position[] = { float(spacePoint->XYZ()[0]), float(spacePoint->XYZ()[1]), float(spacePoint->XYZ()[2])};
225  float totalCharge = hit2DVec[0]->getHit().Integral() + hit2DVec[1]->getHit().Integral() + hit2DVec[2]->getHit().Integral();
226 
227  reco::ClusterHit2DVec hitVector;
228 
229  hitVector.resize(3,NULL);
230 
231  // Make sure we have the hits
232  hitVector.at(hit2DVec[0]->getHit().WireID().Plane) = hit2DVec[0];
233  hitVector.at(hit2DVec[1]->getHit().WireID().Plane) = hit2DVec[1];
234  hitVector.at(hit2DVec[2]->getHit().WireID().Plane) = hit2DVec[2];
235 
236  // And get the wire IDs
237  std::vector<geo::WireID> wireIDVec = {geo::WireID(0,0,geo::kU,0), geo::WireID(0,0,geo::kV,0), geo::WireID(0,0,geo::kW,0)};
238 
239  for(const auto& hit : hitVector)
240  {
241  wireIDVec[hit->getHit().WireID().Plane] = hit->getHit().WireID();
242 
243  if (hit->getStatusBits() & reco::ClusterHit2D::USEDINTRIPLET) hit->setStatusBit(reco::ClusterHit2D::SHAREDINTRIPLET);
244 
245  hit->setStatusBit(reco::ClusterHit2D::USEDINTRIPLET);
246  }
247 
248  unsigned int statusBits(0x7);
249 
250  // For compiling at the moment
251  std::vector<float> hitDelTSigVec = {0.,0.,0.};
252 
253  hitDelTSigVec[0] = std::fabs(hitVector[0]->getTimeTicks() - 0.5 * (hitVector[1]->getTimeTicks() + hitVector[2]->getTimeTicks()));
254  hitDelTSigVec[1] = std::fabs(hitVector[1]->getTimeTicks() - 0.5 * (hitVector[2]->getTimeTicks() + hitVector[0]->getTimeTicks()));
255  hitDelTSigVec[2] = std::fabs(hitVector[2]->getTimeTicks() - 0.5 * (hitVector[0]->getTimeTicks() + hitVector[1]->getTimeTicks()));
256 
257  float deltaPeakTime = *std::min_element(hitDelTSigVec.begin(),hitDelTSigVec.end());
258 
259  // Create the 3D cluster hit
260  hitPairList.emplace_back(new reco::ClusterHit3D(0,
261  statusBits,
262  position,
263  totalCharge,
264  avePeakTime,
265  deltaPeakTime,
266  sigmaPeakTime,
267  hitChiSquare,
268  0.,
269  0.,
270  hitVector,
271  hitDelTSigVec,
272  wireIDVec));
273  }
274 
275  if (m_enableMonitoring)
276  {
277  theClockMakeHits.stop();
278 
279  m_timeVector[BUILDTHREEDHITS] = theClockMakeHits.accumulated_real_time();
280  }
281 
282  mf::LogDebug("Cluster3D") << ">>>>> 3D hit building done, found " << hitPairList.size() << " 3D Hits" << std::endl;
283 
284  return;
285 }
const detinfo::DetectorProperties * m_detector
float getTimeTicks() const
Definition: Cluster3D.h:72
art::InputTag m_spacePointTag
Data members to follow.
Planes which measure V.
Definition: geo_types.h:77
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:221
bool isValid() const
Definition: Handle.h:190
Planes which measure U.
Definition: geo_types.h:76
const recob::Hit & getHit() const
Definition: Cluster3D.h:73
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Detector simulation of raw signals on wires.
std::vector< const reco::ClusterHit2D * > ClusterHit2DVec
Definition: Cluster3D.h:85
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
double weight
Definition: plottest35.C:25
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
const double * XYZ() const
Definition: SpacePoint.h:64
T const * get() const
Definition: Ptr.h:321
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:78
recob::tracking::Plane Plane
Definition: TrackState.h:17
virtual double GetXTicksOffset(int p, int t, int c) const =0

Member Data Documentation

Hit2DVector lar_cluster3d::SpacePointHit3DBuilder::m_clusterHit2DMasterVec
mutableprivate

Definition at line 82 of file SpacePointHit3DBuilder_tool.cc.

Referenced by Hit3DBuilder().

const detinfo::DetectorProperties* lar_cluster3d::SpacePointHit3DBuilder::m_detector
private

Definition at line 84 of file SpacePointHit3DBuilder_tool.cc.

Referenced by configure(), and Hit3DBuilder().

bool lar_cluster3d::SpacePointHit3DBuilder::m_enableMonitoring
private

Definition at line 78 of file SpacePointHit3DBuilder_tool.cc.

Referenced by configure(), and Hit3DBuilder().

art::InputTag lar_cluster3d::SpacePointHit3DBuilder::m_spacePointTag
private

Data members to follow.

Definition at line 76 of file SpacePointHit3DBuilder_tool.cc.

Referenced by configure(), and Hit3DBuilder().

std::vector<float> lar_cluster3d::SpacePointHit3DBuilder::m_timeVector
mutableprivate

Definition at line 79 of file SpacePointHit3DBuilder_tool.cc.

Referenced by getTimeToExecute(), and Hit3DBuilder().


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