9 #include <mvtx/MvtxDefs.h>
10 #include <mvtx/MvtxHit.h>
24 #include <boost/format.hpp>
25 #include <boost/tuple/tuple.hpp>
30 #define BOOST_NO_HASH // Our version of boost.graph is incompatible with GCC-4.3 w/o this flag
31 #include <boost/bind.hpp>
32 #include <boost/graph/adjacency_list.hpp>
33 #include <boost/graph/connected_components.hpp>
34 using namespace boost;
42 static const float twopi = 2.0 * M_PI;
74 , m_clusterlist(nullptr)
75 , m_clusterhitassoc(nullptr)
76 , m_makeZClustering(
true)
92 cout <<
PHWHERE <<
"DST Node missing, doing nothing." << endl;
106 TrkrClusterContainer *trkrclusters = findNode::getClass<TrkrClusterContainer>(dstNode,
"TRKR_CLUSTER");
115 dstNode->addNode(DetNode);
121 DetNode->
addNode(TrkrClusterContainerNode);
124 TrkrClusterHitAssoc *clusterhitassoc = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
133 dstNode->addNode(DetNode);
147 cout <<
"====================== MvtxPrototype2Clusterizer::InitRun() =====================" << endl;
148 cout <<
" Z-dimension Clustering = " << boolalpha <<
m_makeZClustering << noboolalpha << endl;
149 cout <<
"===========================================================================" << endl;
158 m_hits = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
161 cout <<
PHWHERE <<
"ERROR: Can't find node TRKR_HITSET" << endl;
166 m_clusterlist = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
169 cout <<
PHWHERE <<
" ERROR: Can't find TRKR_CLUSTER." << endl;
174 m_clusterhitassoc = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
177 cout <<
PHWHERE <<
" ERROR: Can't find TRKR_CLUSTERHITASSOC" << endl;
193 cout <<
"Entering MvtxPrototype2Clusterizer::ClusterMvtx " << endl;
203 hitsetitr != hitsetrange.second;
209 if(
Verbosity() > 10) cout <<
"MvtxPrototype2Clusterizer found hitsetkey " << hitsetitr->first << endl;
215 std::vector <std::pair< TrkrDefs::hitkey, TrkrHit*> > hitvec;
219 hitr != hitrangei.second;
222 hitvec.push_back(make_pair(hitr->first, hitr->second));
225 cout <<
"hitvec.size(): " << hitvec.size() << endl;
228 typedef adjacency_list<vecS, vecS, undirectedS> Graph;
232 for (
unsigned int i = 0;
i < hitvec.size();
i++)
234 for (
unsigned int j = 0;
j < hitvec.size();
j++)
243 vector<int> component(num_vertices(G));
246 connected_components(G, &component[0]);
250 set<int> cluster_ids;
252 multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*> >
clusters;
253 for (
unsigned int i = 0;
i < component.size();
i++)
255 cluster_ids.insert(component[
i]);
256 clusters.insert(make_pair(component[i], hitvec[i]));
260 for (set<int>::iterator clusiter = cluster_ids.begin(); clusiter != cluster_ids.end(); ++clusiter)
262 int clusid = *clusiter;
263 pair<multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*>>::iterator,
264 multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*>>::iterator> clusrange = clusters.equal_range(clusid);
265 multimap<int, std::pair<TrkrDefs::hitkey, TrkrHit*>>::iterator mapiter = clusrange.first;
268 cout <<
"Filling cluster id " << clusid << endl;
294 for (mapiter = clusrange.first; mapiter != clusrange.second; ++mapiter)
319 float phisize = phibins.size();
320 float zsize = zbins.size();
336 clus->setPosition(0, clusx);
337 clus->setPosition(1, clusy);
338 clus->setPosition(2, clusz);
342 float invsqrt12 = 1.0 / sqrt(12.0);
347 DIM[0][0] = pow(0.5 * phisize, 2);
351 DIM[1][1] = pow(0.5 * thickness, 2);
355 DIM[2][2] = pow(0.5 * zsize, 2);
358 ERR[0][0] = pow(0.5 * phisize * invsqrt12, 2);
362 ERR[1][1] = pow(0.5 * thickness * invsqrt12, 2);
366 ERR[2][2] = pow(0.5 * zsize * invsqrt12, 2);
368 clus->setSize( 0 , 0 , DIM[0][0] );
369 clus->setSize( 0 , 1 , DIM[0][1] );
370 clus->setSize( 0 , 2 , DIM[0][2] );
371 clus->setSize( 1 , 0 , DIM[1][0] );
372 clus->setSize( 1 , 1 , DIM[1][1] );
373 clus->setSize( 1 , 2 , DIM[1][2] );
374 clus->setSize( 2 , 0 , DIM[2][0] );
375 clus->setSize( 2 , 1 , DIM[2][1] );
376 clus->setSize( 2 , 2 , DIM[2][2] );
378 clus->setError( 0 , 0 , ERR[0][0] );
379 clus->setError( 0 , 1 , ERR[0][1] );
380 clus->setError( 0 , 2 , ERR[0][2] );
381 clus->setError( 1 , 0 , ERR[1][0] );
382 clus->setError( 1 , 1 , ERR[1][1] );
383 clus->setError( 1 , 2 , ERR[1][2] );
384 clus->setError( 2 , 0 , ERR[2][0] );
385 clus->setError( 2 , 1 , ERR[2][1] );
386 clus->setError( 2 , 2 , ERR[2][2] );
407 TrkrClusterContainer *clusterlist = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
408 if (!clusterlist)
return;
410 cout <<
"================= Aftyer MvtxPrototype2Clusterizer::process_event() ====================" << endl;
412 cout <<
" There are " << clusterlist->
size() <<
" clusters recorded: " << endl;
416 cout <<
"===========================================================================" << endl;