3 #include "mvtx/MvtxDefUtil.h"
4 #include "mvtx/MvtxHitSetv1.h"
21 #include <g4detectors/PHG4CylinderGeom_MAPS.h>
22 #include <g4detectors/PHG4CylinderGeom_Siladders.h>
26 #include <boost/tuple/tuple.hpp>
27 #include <boost/format.hpp>
32 #define BOOST_NO_HASH // Our version of boost.graph is incompatible with GCC-4.3 w/o this flag
33 #include <boost/bind.hpp>
34 #include <boost/graph/adjacency_list.hpp>
35 #include <boost/graph/connected_components.hpp>
36 using namespace boost;
44 static const float twopi = 2.0 * M_PI;
50 if ( GetZClustering() )
53 if ( fabs(lhs.first - rhs.first) <= 1 )
55 if ( fabs(lhs.second - rhs.second) <= 1 )
63 if ( fabs(lhs.first - rhs.first) == 0 )
65 if ( fabs(lhs.second - rhs.second) <= 1 )
80 make_z_clustering_(
true),
97 =
dynamic_cast<PHCompositeNode*
>(iter.findFirst(
"PHCompositeNode",
"DST"));
99 cout <<
PHWHERE <<
"DST Node missing, doing nothing." << endl;
106 =
dynamic_cast<PHCompositeNode*
>(iter_dst.findFirst(
"PHCompositeNode",
"TRKR"));
114 = findNode::getClass<TrkrClusterContainer>(dstNode,
"TrkrClusterContainer");
119 svxNode->
addNode(TrkrClusterContainerNode);
128 cout <<
"====================== MvtxClusterizer::InitRun() =====================" << endl;
129 cout <<
" Z-dimension Clustering = " << boolalpha <<
make_z_clustering_ << noboolalpha << endl;
130 cout <<
"===========================================================================" << endl;
141 hits_ = findNode::getClass<TrkrHitSetContainer>(topNode,
"TrkrHitSetContainer");
144 cout <<
PHWHERE <<
"ERROR: Can't find node TrkrHitSetContainer" << endl;
149 clusterlist_ = findNode::getClass<TrkrClusterContainer>(topNode,
"TrkrClusterContainer");
152 cout <<
PHWHERE <<
" ERROR: Can't find TrkrClusterContainer." << endl;
169 cout <<
"Entering MvtxClusterizer::ClusterMvtx " << endl;
184 hitsetitr != hitsetrange.second;
188 MvtxHitSetv1* hitset =
static_cast<MvtxHitSetv1*
>(hitsetitr->second);
192 TrkrDefUtil trkrutil;
193 MvtxDefUtil mvtxutil;
198 std::vector<pixel> hitvec;
199 MvtxHitSetv1::ConstRange hitrangei = hitset->GetHits();
200 for ( MvtxHitSetv1::ConstIterator hitr = hitrangei.first;
201 hitr != hitrangei.second;
204 hitvec.push_back(make_pair(hitr->first, hitr->second));
207 cout <<
"hitvec.size(): " << hitvec.size() << endl;
210 typedef adjacency_list <vecS, vecS, undirectedS> Graph;
214 for (
unsigned int i = 0;
i < hitvec.size();
i++)
216 for (
unsigned int j = 0;
j < hitvec.size();
j++)
226 vector<int> component(num_vertices(G));
229 connected_components(G, &component[0]);
233 set<int> cluster_ids;
235 for (
unsigned int i = 0;
i < component.size();
i++)
237 cluster_ids.insert( component[
i] );
238 clusters.insert( make_pair(component[i], hitvec[i]) );
242 for (set<int>::iterator clusiter = cluster_ids.begin();
243 clusiter != cluster_ids.end();
247 int clusid = *clusiter;
248 pair< multimap<int, pixel>::iterator,
249 multimap<int, pixel>::iterator> clusrange = clusters.equal_range(clusid);
251 multimap<int, pixel>::iterator mapiter = clusrange.first;
254 cout <<
"Filling cluster id " << clusid << endl;
271 for (mapiter = clusrange.first; mapiter != clusrange.second; mapiter++ )
275 zbins.insert((mapiter->second).first);
276 phibins.insert((mapiter->second).second);
279 xsum += (mapiter->second).second;
280 zsum += (mapiter->second).first + 0.5;
286 float phisize = phibins.size();
287 float zsize = zbins.size();
293 clusx = xsum / nhits;
294 clusy = ysum / nhits;
295 clusz = zsum / nhits;
297 clus->SetPosition(0, clusx);
298 clus->SetPosition(1, clusy);
299 clus->SetPosition(2, clusz);
304 float invsqrt12 = 1.0 / sqrt(12.0);
307 DIM[0][0] = pow(0.5 * phisize, 2);
312 DIM[1][1] = pow(0.5 * thickness, 2);
316 DIM[2][2] = pow(0.5 * zsize, 2);
319 ERR[0][0] = pow(0.5 * phisize * invsqrt12, 2);
323 ERR[1][1] = pow(0.5 * thickness * invsqrt12, 2);
327 ERR[2][2] = pow(0.5 * zsize * invsqrt12, 2);
330 clus->SetSize( 0 , 0 , DIM[0][0] );
331 clus->SetSize( 0 , 1 , DIM[0][1] );
332 clus->SetSize( 0 , 2 , DIM[0][2] );
333 clus->SetSize( 1 , 0 , DIM[1][0] );
334 clus->SetSize( 1 , 1 , DIM[1][1] );
335 clus->SetSize( 1 , 2 , DIM[1][2] );
336 clus->SetSize( 2 , 0 , DIM[2][0] );
337 clus->SetSize( 2 , 1 , DIM[2][1] );
338 clus->SetSize( 2 , 2 , DIM[2][2] );
340 clus->SetError( 0 , 0 ,
ERR[0][0] );
341 clus->SetError( 0 , 1 ,
ERR[0][1] );
342 clus->SetError( 0 , 2 ,
ERR[0][2] );
343 clus->SetError( 1 , 0 ,
ERR[1][0] );
344 clus->SetError( 1 , 1 ,
ERR[1][1] );
345 clus->SetError( 1 , 2 ,
ERR[1][2] );
346 clus->SetError( 2 , 0 ,
ERR[2][0] );
347 clus->SetError( 2 , 1 ,
ERR[2][1] );
348 clus->SetError( 2 , 2 ,
ERR[2][2] );
366 TrkrClusterContainer *clusterlist = findNode::getClass<TrkrClusterContainer>(topNode,
"TrkrClusterContainer");
367 if (!clusterlist)
return;
369 cout <<
"================= MvtxClusterizer::process_event() ====================" << endl;
371 cout <<
" Found and recorded the following " << clusterlist->
size() <<
" clusters: " << endl;
375 cout <<
"===========================================================================" << endl;