32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
34 #pragma GCC diagnostic ignored "-Wshadow"
35 #include <boost/graph/adjacency_list.hpp>
36 #include <boost/graph/connected_components.hpp>
37 #pragma GCC diagnostic pop
132 std::cout <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
138 auto trkrclusters = findNode::getClass<TrkrClusterContainer>(dstNode,
"TRKR_CLUSTER");
147 dstNode->addNode(DetNode);
153 DetNode->
addNode(TrkrClusterContainerNode);
156 auto clusterhitassoc = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
157 if (!clusterhitassoc)
165 dstNode->addNode(DetNode);
181 dstNode->addNode(DetNode);
201 std::cout <<
"====================== InttClusterizer::InitRun() =====================" << std::endl;
202 std::cout <<
" Fraction of expected thickness MIP energy = " <<
_fraction_of_mip << std::endl;
205 std::cout <<
" Cluster Threshold in Layer #" << iter_tmp.first <<
" = " << 1.0e6 * iter_tmp.second <<
" keV" << std::endl;
209 std::cout <<
" Z-dimension Clustering in Layer #" << iter_tmp.first <<
" = " << std::boolalpha << iter_tmp.second << std::noboolalpha << std::endl;
213 std::cout <<
" Energy weighting clusters in Layer #" << _make_e_weight.first <<
" = " << std::boolalpha << _make_e_weight.second << std::noboolalpha << std::endl;
215 std::cout <<
"===========================================================================" << std::endl;
221 mClusHitsVerbose = findNode::getClass<ClusHitsVerbosev1>(topNode,
"Trkr_SvtxClusHitsVerbose");
229 dstNode->addNode(DetNode);
233 DetNode->addNode(newNode);
245 m_hits = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
248 std::cout <<
PHWHERE <<
"ERROR: Can't find node TRKR_HITSET" << std::endl;
255 m_rawhits = findNode::getClass<RawHitSetContainer>(topNode,
"TRKR_RAWHITSET");
258 std::cout <<
PHWHERE <<
"ERROR: Can't find node TRKR_HITSET" << std::endl;
264 m_clusterlist = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
267 std::cout <<
PHWHERE <<
" ERROR: Can't find TRKR_CLUSTER." << std::endl;
272 m_clusterhitassoc = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
275 std::cout <<
PHWHERE <<
" ERROR: Can't find TRKR_CLUSTERHITASSOC" << std::endl;
280 m_clustercrossingassoc = findNode::getClass<TrkrClusterCrossingAssoc>(topNode,
"TRKR_CLUSTERCROSSINGASSOC");
283 std::cout <<
PHWHERE <<
" ERROR: Can't find TRKR_CLUSTERCROSINGASSOC" << std::endl;
315 layeriter != layerrange.second;
319 int layer = layeriter->second->get_layer();
322 float thickness = (layeriter->second)->get_thickness();
345 std::cout <<
"Entering InttClusterizer::ClusterLadderCells " << std::endl;
367 hitsetitr != hitsetrange.second;
375 std::cout <<
"InttClusterizer found hitsetkey " << hitsetitr->first << std::endl;
392 std::vector<std::pair<TrkrDefs::hitkey, TrkrHit*>> hitvec;
395 hitr != hitrangei.second;
398 hitvec.emplace_back(hitr->first, hitr->second);
402 std::cout <<
"hitvec.size(): " << hitvec.size() << std::endl;
405 using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>;
409 for (
unsigned int i = 0;
i < hitvec.size();
i++)
411 for (
unsigned int j =
i + 1;
j < hitvec.size();
j++)
424 std::vector<int> component(num_vertices(G));
427 connected_components(G, &component[0]);
431 std::set<int> cluster_ids;
433 std::multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*>>
clusters;
434 for (
unsigned int i = 0;
i < component.size();
i++)
436 cluster_ids.insert(component[
i]);
437 clusters.insert(std::make_pair(component[i], hitvec[i]));
441 for (
int clusid : cluster_ids)
445 std::pair<std::multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*>>::iterator,
446 std::multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*>>::iterator>
447 clusrange = clusters.equal_range(clusid);
454 std::cout <<
"Filling cluster with key " << ckey << std::endl;
465 double xlocalsum = 0.0;
466 double ylocalsum = 0.0;
467 double zlocalsum = 0.0;
468 unsigned int clus_adc = 0.0;
469 unsigned int clus_maxadc = 0.0;
472 for (std::multimap<
int, std::pair<TrkrDefs::hitkey, TrkrHit*>>::iterator mapiter = clusrange.first; mapiter != clusrange.second; ++mapiter)
482 unsigned int hit_adc = (mapiter->second).second->getAdc();
488 double local_hit_location[3] = {0., 0., 0.};
495 xlocalsum += local_hit_location[0] * (
double) hit_adc;
496 ylocalsum += local_hit_location[1] * (
double) hit_adc;
497 zlocalsum += local_hit_location[2] * (
double) hit_adc;
501 xlocalsum += local_hit_location[0];
502 ylocalsum += local_hit_location[1];
503 zlocalsum += local_hit_location[2];
505 if (hit_adc > clus_maxadc)
507 clus_maxadc = hit_adc;
517 std::cout <<
" nhits = " << nhits << std::endl;
521 std::cout <<
" From geometry object: hit x " << local_hit_location[0] <<
" hit y " << local_hit_location[1] <<
" hit z " << local_hit_location[2] << std::endl;
522 std::cout <<
" nhits " << nhits <<
" clusx = " << xlocalsum / nhits <<
" clusy " << ylocalsum / nhits <<
" clusz " << zlocalsum / nhits <<
" hit_adc " << hit_adc << std::endl;
526 static const float invsqrt12 = 1. / sqrt(12);
535 float phierror = pitch * invsqrt12;
537 static constexpr std::array<double, 3> scalefactors_phi = {{0.85, 0.4, 0.33}};
538 if (phibins.size() == 1 && layer < 5)
540 phierror *= scalefactors_phi[0];
542 else if (phibins.size() == 2 && layer < 5)
544 phierror *= scalefactors_phi[1];
546 else if (phibins.size() == 2 && layer > 4)
548 phierror *= scalefactors_phi[2];
551 const float zerror = zbins.size() * length * invsqrt12;
553 double cluslocaly = NAN;
554 double cluslocalz = NAN;
558 cluslocaly = ylocalsum / (
double) clus_adc;
559 cluslocalz = zlocalsum / (
double) clus_adc;
563 cluslocaly = ylocalsum / nhits;
564 cluslocalz = zlocalsum / nhits;
567 auto clus = std::make_unique<TrkrClusterv5>();
568 clus->setAdc(clus_adc);
569 clus->setMaxAdc(clus_maxadc);
570 clus->setLocalX(cluslocaly);
571 clus->setLocalY(cluslocalz);
572 clus->setPhiError(phierror);
573 clus->setZError(zerror);
574 clus->setPhiSize(phibins.size());
575 clus->setZSize(zbins.size());
578 clus->setSubSurfKey(0);
593 std::cout <<
"After InttClusterizer, cluster-hit associations are:" << std::endl;
599 std::cout <<
" Cluster-crossing associations are:" << std::endl;
609 std::cout <<
"Entering InttClusterizer::ClusterLadderCells " << std::endl;
631 hitsetitr != hitsetrange.second;
639 std::cout <<
"InttClusterizer found hitsetkey " << hitsetitr->first << std::endl;
656 std::vector<RawHit*> hitvec;
662 hitr != hitrangei.second;
668 hitvec.push_back((*hitr));
672 std::cout <<
"hitvec.size(): " << hitvec.size() << std::endl;
675 using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>;
679 for (
unsigned int i = 0;
i < hitvec.size();
i++)
681 for (
unsigned int j =
i + 1;
j < hitvec.size();
j++)
694 std::vector<int> component(num_vertices(G));
697 connected_components(G, &component[0]);
701 std::set<int> cluster_ids;
703 std::multimap<int, RawHit*>
clusters;
704 for (
unsigned int i = 0;
i < component.size();
i++)
706 cluster_ids.insert(component[
i]);
707 clusters.insert(std::make_pair(component[i], hitvec[i]));
711 for (
int clusid : cluster_ids)
715 auto clusrange = clusters.equal_range(clusid);
722 std::cout <<
"Filling cluster with key " << ckey << std::endl;
733 double xlocalsum = 0.0;
734 double ylocalsum = 0.0;
735 double zlocalsum = 0.0;
736 unsigned int clus_adc = 0.0;
741 std::map<int, unsigned int> m_phi, m_z;
742 for (
auto mapiter = clusrange.first; mapiter != clusrange.second; ++mapiter)
746 const auto energy = (mapiter->second)->getAdc();
747 int col = (mapiter->second)->getPhiBin();
748 int row = (mapiter->second)->
getTBin();
755 auto pnew = m_phi.try_emplace(row,
energy);
758 pnew.first->second +=
energy;
761 pnew = m_z.try_emplace(col,
energy);
764 pnew.first->second +=
energy;
769 unsigned int hit_adc = (mapiter->second)->getAdc();
775 double local_hit_location[3] = {0., 0., 0.};
782 xlocalsum += local_hit_location[0] * (
double) hit_adc;
783 ylocalsum += local_hit_location[1] * (
double) hit_adc;
784 zlocalsum += local_hit_location[2] * (
double) hit_adc;
788 xlocalsum += local_hit_location[0];
789 ylocalsum += local_hit_location[1];
790 zlocalsum += local_hit_location[2];
801 std::cout <<
" nhits = " << nhits << std::endl;
805 std::cout <<
" From geometry object: hit x " << local_hit_location[0] <<
" hit y " << local_hit_location[1] <<
" hit z " << local_hit_location[2] << std::endl;
806 std::cout <<
" nhits " << nhits <<
" clusx = " << xlocalsum / nhits <<
" clusy " << ylocalsum / nhits <<
" clusz " << zlocalsum / nhits <<
" hit_adc " << hit_adc << std::endl;
814 for (
auto const& hit : m_phi)
816 std::cout <<
" m_phi(" << hit.first <<
" : " << hit.second <<
") " << std::endl;
819 for (
auto& hit : m_phi)
823 for (
auto& hit : m_z)
830 static const float invsqrt12 = 1. / sqrt(12);
839 float phierror = pitch * invsqrt12;
841 static constexpr std::array<double, 3> scalefactors_phi = {{0.85, 0.4, 0.33}};
842 if (phibins.size() == 1 && layer < 5)
844 phierror *= scalefactors_phi[0];
846 else if (phibins.size() == 2 && layer < 5)
848 phierror *= scalefactors_phi[1];
850 else if (phibins.size() == 2 && layer > 4)
852 phierror *= scalefactors_phi[2];
855 const float zerror = zbins.size() * length * invsqrt12;
857 double cluslocaly = NAN;
858 double cluslocalz = NAN;
862 cluslocaly = ylocalsum / (
double) clus_adc;
863 cluslocalz = zlocalsum / (
double) clus_adc;
867 cluslocaly = ylocalsum / nhits;
868 cluslocalz = zlocalsum / nhits;
871 auto clus = std::make_unique<TrkrClusterv5>();
872 clus->setAdc(clus_adc);
873 clus->setLocalX(cluslocaly);
874 clus->setLocalY(cluslocalz);
875 clus->setPhiError(phierror);
876 clus->setZError(zerror);
877 clus->setPhiSize(phibins.size());
878 clus->setZSize(zbins.size());
881 clus->setSubSurfKey(0);
896 std::cout <<
"After InttClusterizer, cluster-hit associations are:" << std::endl;
902 std::cout <<
" Cluster-crossing associations are:" << std::endl;
913 TrkrClusterContainer* clusterlist = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
919 std::cout <<
"================= After InttClusterizer::process_event() ====================" << std::endl;
921 std::cout <<
" There are " << clusterlist->
size() <<
" clusters recorded: " << std::endl;
925 std::cout <<
"===========================================================================" << std::endl;