117 std::unique_ptr<std::vector<recob::EndPoint2D> > mvertexcol(
new std::vector<recob::EndPoint2D>);
122 std::vector< art::Ptr<recob::Hit> > vHits;
125 std::vector<double> weakvertexstrength;
126 std::vector<double> strongvertexstrength;
128 std::vector< art::Ptr<recob::Hit> > hHits;
133 std::vector< std::pair<art::Ptr<recob::Hit>,
double> > matchedvertex;
136 std::vector< std::pair<art::Ptr<recob::Hit>,
double> > strongestvertex;
140 for(
size_t ii = 0; ii < vertexListHandle->size(); ++ii){
148 for(
size_t ii = 0; ii < houghListHandle->size(); ++ii){
155 uint32_t channel = 0;
159 double slope,intercept,distance;
160 double starttime, endtime;
161 int startwire, endwire;
168 for(
size_t v = 0; v < vertIn.
size(); ++v){
175 if(vHits.size() > 0){
177 while (vertexhitIter != vHits.end()){
179 weakvertexstrength.push_back((*vertexIter)->Strength());
187 if(vHits.size() == 0)
192 houghIter = houghIn.
begin();
194 while(houghIter!= houghIn.
end()){
200 hHits = fmhh.at(ctr);
202 if(hHits.size() > 0){
205 while (hitIter!=hHits.end()){
211 wire = houghhit[0]->WireID().Wire;
212 wireID = houghhit[0]->WireID();
216 slope = std::atan((*houghIter)->StartAngle());
217 intercept=(*houghIter)->StartTick() - slope*(*houghIter)->StartWire();
218 for(
unsigned int i=0;i < vertexhit.
size(); i++){
221 wire = vertexhit[i]->WireID().Wire;
222 wireID = vertexhit[i]->WireID();
224 starttime=(*houghIter)->StartTick();
225 endtime=(*houghIter)->EndTick();
226 startwire=(*houghIter)->StartWire();
227 endwire=(*houghIter)->EndWire();
231 if(((std::abs((
int)(wire-startwire))<
fMaxDistance*.0743)
234 &&((std::abs(vertexhit[i]->PeakTime()-starttime)<
fMaxDistance)
235 ||(std::abs(vertexhit[i]->PeakTime()-endtime)<
fMaxDistance)
237 distance=(std::abs(vertexhit[i]->PeakTime()-slope*(
double)wire-intercept)/(std::sqrt(pow(.0743*slope,2)+1)));
239 if(distance<(
fMaxDistance+vertexhit[i]->RMS())&&distance>-1)
240 matchedvertex.emplace_back(vertexhit[i],
241 weakvertexstrength[i]*std::sqrt(std::pow(std::abs(endwire-startwire)*.0743,2)
242 +std::pow(std::abs(endtime-starttime),2)));
247 if(vertexhit.
size() == 0 || houghhit.
size() == 0){
253 if(vertexIter!=vertIn.
end()) vertexIter++;
254 if(houghIter!=houghIn.
end()){
261 std::sort(matchedvertex.rbegin(), matchedvertex.rend(),
sort_pred);
267 for(
unsigned int i=0;i < matchedvertex.size(); i++){
268 strength=matchedvertex[i].second;
270 for(
unsigned int n=1;
n < matchedvertex.size() && i>=
n;
n++)
271 if(matchedvertex[i].first==matchedvertex[i-
n].first)
272 strength+=matchedvertex[i-
n].second;
274 strongvertexstrength.push_back(strength);
277 if(strength>matchedvertex[i].second)
278 strongestvertex.emplace_back(matchedvertex[i].first,strength);
283 std::sort(strongestvertex.rbegin(), strongestvertex.rend(),
sort_pred2);
284 for(
unsigned int i=0;i < matchedvertex.size(); i++){
287 channel=(matchedvertex[i].first)->Channel();
290 strongvertex.
push_back(matchedvertex[i].first);
296 if(matchedvertex[i].first==matchedvertex[i-1].first){
297 if(strongvertex[0]==(strongestvertex[0].first)&&strongestvertex.size()>0)
311 for(
size_t h = 0; h < strongvertex.
size(); ++h) totalQ += strongvertex[h]->Integral();
315 strongvertexstrength[i],
320 mvertexcol->push_back(
vertex);
322 util::CreateAssn(*
this, evt, *(mvertexcol.get()), strongvertex, *(assn.get()));
324 strongvertex.
clear();
328 strongestvertex.clear();
329 matchedvertex.clear();
333 evt.
put(std::move(mvertexcol));
334 evt.
put(std::move(assn));
PlaneID const & planeID() const
The data type to uniquely identify a Plane.
Cluster finding and building.
bool sort_pred2(const std::pair< art::Ptr< recob::Hit >, double > &left, const std::pair< art::Ptr< recob::Hit >, double > &right)
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
ProductID put(std::unique_ptr< PROD > &&product)
std::string fHoughModuleLabel
void push_back(Ptr< U > const &p)
std::string fVertexModuleLabel
bool sort_pred(const std::pair< art::Ptr< recob::Hit >, double > &left, const std::pair< art::Ptr< recob::Hit >, double > &right)
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
data_t::const_iterator const_iterator
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const