10 #include "cetlib/search_path.h" 11 #include "cetlib/cpu_timer.h" 22 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 23 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 109 m_detector = lar::providerFrom<detinfo::DetectorPropertiesService>();
117 cet::cpu_timer theClockMakeHits;
129 if (!hitSpacePointAssnsHandle.
isValid())
return;
133 using SpacePointHitVecMap = std::map<const recob::SpacePoint*, std::vector<const recob::Hit*>>;
134 using RecobHitSet = std::set<const recob::Hit*>;
136 SpacePointHitVecMap spacePointHitVecMap;
137 RecobHitSet recobHitSet;
139 for(
auto& assnPair : *hitSpacePointAssnsHandle)
144 spacePointHitVecMap[spacePoint.
get()].push_back(recobHit.
get());
145 recobHitSet.insert(recobHit.
get());
146 recobHitToArtPtrMap[recobHit.
get()] = recobHit;
151 std::map<geo::PlaneID, double> planeOffsetMap;
166 std::cout <<
"***> plane 0 offset: " << planeOffsetMap[
geo::PlaneID(cryoIdx,tpcIdx,0)] <<
", plane 1: " << planeOffsetMap[
geo::PlaneID(cryoIdx,tpcIdx,1)] <<
", plane 2: " << planeOffsetMap[
geo::PlaneID(cryoIdx,tpcIdx,2)] << std::endl;
172 using RecobHitTo2DHitMap = std::map<const recob::Hit*,const reco::ClusterHit2D*>;
174 RecobHitTo2DHitMap recobHitTo2DHitMap;
181 for(
auto& recobHit : recobHitSet)
185 double hitPeakTime(recobHit->PeakTime() - planeOffsetMap[hitWireID.planeID()]);
194 for(
auto& pointPair : spacePointHitVecMap)
197 const std::vector<const recob::Hit*>& recobHitVec = pointPair.second;
199 if (recobHitVec.size() != 3)
201 std::cout <<
"************>>>>>> do not have 3 hits associated to space point! " << recobHitVec.size() <<
" ***************" << std::endl;
205 std::vector<const reco::ClusterHit2D*> hit2DVec(recobHitVec.size());
207 for(
const auto& recobHit : recobHitVec)
215 float avePeakTime(0.);
218 for(
const auto& hit2D : hit2DVec)
220 float hitSigma = hit2D->getHit().RMS();
221 float weight = 1. / (hitSigma * hitSigma);
223 avePeakTime += weight * hit2D->getTimeTicks();
227 avePeakTime /= weightSum;
230 float hitChiSquare(0.);
231 float sigmaPeakTime(std::sqrt(1./weightSum));
233 for(
const auto& hit2D : hit2DVec)
235 float hitRMS = hit2D->getHit().RMS();
236 float combRMS = std::sqrt(hitRMS*hitRMS - sigmaPeakTime*sigmaPeakTime);
237 float peakTime = hit2D->getTimeTicks();
238 float deltaTime = peakTime - avePeakTime;
239 float hitSig = deltaTime / combRMS;
241 hitChiSquare += hitSig * hitSig;
245 float position[] = { float(spacePoint->
XYZ()[0]),
float(spacePoint->
XYZ()[1]),
float(spacePoint->
XYZ()[2])};
246 float totalCharge = hit2DVec[0]->getHit().Integral() + hit2DVec[1]->getHit().Integral() + hit2DVec[2]->getHit().Integral();
250 hitVector.resize(3,NULL);
253 hitVector.at(hit2DVec[0]->getHit().WireID().
Plane) = hit2DVec[0];
254 hitVector.at(hit2DVec[1]->getHit().WireID().
Plane) = hit2DVec[1];
255 hitVector.at(hit2DVec[2]->getHit().WireID().
Plane) = hit2DVec[2];
258 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)};
260 for(
const auto&
hit : hitVector)
262 wireIDVec[
hit->getHit().WireID().Plane] =
hit->getHit().WireID();
269 unsigned int statusBits(0x7);
272 std::vector<float> hitDelTSigVec = {0.,0.,0.};
274 hitDelTSigVec[0] = std::fabs(hitVector[0]->getTimeTicks() - 0.5 * (hitVector[1]->getTimeTicks() + hitVector[2]->getTimeTicks()));
275 hitDelTSigVec[1] = std::fabs(hitVector[1]->getTimeTicks() - 0.5 * (hitVector[2]->getTimeTicks() + hitVector[0]->getTimeTicks()));
276 hitDelTSigVec[2] = std::fabs(hitVector[2]->getTimeTicks() - 0.5 * (hitVector[0]->getTimeTicks() + hitVector[1]->getTimeTicks()));
278 float deltaPeakTime = *std::min_element(hitDelTSigVec.begin(),hitDelTSigVec.end());
298 theClockMakeHits.stop();
303 mf::LogDebug(
"Cluster3D") <<
">>>>> 3D hit building done, found " << hitPairList.size() <<
" 3D Hits" << std::endl;
const detinfo::DetectorProperties * m_detector
virtual int TriggerOffset() const =0
art::InputTag m_spacePointTag
Data members to follow.
std::vector< float > m_timeVector
geo::WireID WireID() const
Initial tdc tick for hit.
float getTimeToExecute(IHit3DBuilder::TimeValues index) const override
If monitoring, recover the time to execute a particular function.
Declaration of signal hit object.
The data type to uniquely identify a Plane.
std::vector< reco::ClusterHit2D > Hit2DVector
~SpacePointHit3DBuilder()
Destructor.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
geo::Geometry * m_geometry
std::list< std::unique_ptr< reco::ClusterHit3D >> HitPairList
Hit2DVector m_clusterHit2DMasterVec
T get(std::string const &key) const
const recob::Hit & getHit() const
SpacePointHit3DBuilder class definiton.
const Double32_t * XYZ() const
TimeValues
enumerate the possible values for time checking if monitoring timing
The geometry of one entire detector, as served by art.
std::map< const recob::Hit *, art::Ptr< recob::Hit >> RecobHitToPtrMap
Defines a structure mapping art representation to internal.
PlaneID_t Plane
Index of the plane within its TPC.
IHit3DBuilder interface class definiton.
Detector simulation of raw signals on wires.
This provides an art tool interface definition for tools which construct 3D hits used in 3D clusterin...
std::vector< const reco::ClusterHit2D * > ClusterHit2DVec
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
SpacePointHit3DBuilder(fhicl::ParameterSet const &pset)
Constructor.
void Hit3DBuilder(const art::Event &evt, reco::HitPairList &hitPairList, RecobHitToPtrMap &) const override
Given a set of recob hits, run DBscan to form 3D clusters.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Planes which measure W (third view for Bo, MicroBooNE, etc).
recob::tracking::Plane Plane
art framework interface to geometry description
void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool.
virtual double GetXTicksOffset(int p, int t, int c) const =0