11 if( col.empty() )
return false;
12 std::vector<const RpcPrepData*>::const_iterator cit_begin = col.begin();
13 std::vector<const RpcPrepData*>::const_iterator cit_end = col.end();
14 if( cit_begin == cit_end )
return false;
15 std::vector<const RpcPrepData*>::const_iterator cit = cit_begin;
17 if( !prd_first )
return false;
21 std::set<Identifier> subModuleIds;
22 for( ; cit!=cit_end;++cit ) {
29 subModuleIds.insert(detElId);
32 std::cout <<
" RPC performing clustering " << col.size() <<
" sub modules " << subModuleIds.size() << std::endl;
33 std::set<Identifier>::iterator it = subModuleIds.begin();
34 std::set<Identifier>::iterator it_end = subModuleIds.end();
35 for( ;it!=it_end;++it ){
36 std::cout <<
" sub module " <<
m_rpcIdHelper->print_to_string(*it) << std::endl;
39 std::set<Identifier>::iterator it = subModuleIds.begin();
40 std::set<Identifier>::iterator it_end = subModuleIds.end();
41 for( ;it!=it_end;++it ){
42 if( !
cluster(col,*it) )
return false;
70 if( col.empty() )
return false;
71 std::vector<const RpcPrepData*>::const_iterator cit_begin = col.begin();
72 std::vector<const RpcPrepData*>::const_iterator cit_end = col.end();
73 if( cit_begin == cit_end )
return false;
74 if(
debug ) std::cout <<
" RPC performing clustering: " << col.size() <<
" " <<
m_rpcIdHelper->print_to_string(subid) << std::endl;
79 std::vector<const RpcPrepData*>::const_iterator cit = cit_begin;
81 for( ; cit!=cit_end;++cit ) {
91 if( !prd_first )
return false;
102 std::vector<Doublet>* channelsPtr =
nullptr;
104 for( ; cit!=cit_end;++cit ) {
111 if(
debug ) std::cout <<
" adding prd " <<
m_rpcIdHelper->print_to_string(
id) << std::endl;
119 if( channel >= (
int)channelsPtr->size() ){
120 std::cout <<
"index channels out of range: " << channel <<
" max " << channelsPtr->size() << std::endl;
127 Doublet& doublet = (*channelsPtr)[channel];
130 int channelClusterNumber = gasgap==1 ? doublet.
first : doublet.
second;
131 if( channelClusterNumber != -1 ){
133 std::cout <<
" secondary hit " << channel <<
" " << gasgap;
134 if( measuresPhi ) std::cout <<
" phi " << channelClusterNumber << std::endl;
135 else std::cout <<
" eta " << channelClusterNumber << std::endl;
138 if( !
cluster.addSecond(prd,gasgap) ){
142 std::vector<Id> neighbours;
145 neighbours.emplace_back(2,channel );
146 if( channel != 0 ) neighbours.emplace_back(2,channel-1 );
147 if( channel < (
int)channelsPtr->size()-1 ) neighbours.emplace_back(2,channel+1 );
148 }
else if( gasgap == 2 ){
149 neighbours.emplace_back(1,channel );
150 if( channel != 0 ) neighbours.emplace_back(1,channel-1 );
151 if( channel < (
int)channelsPtr->size()-1 ) neighbours.emplace_back(1,channel+1 );
154 if( channel != 0 ) neighbours.emplace_back(gasgap,channel-1 );
155 if( channel < (
int)channelsPtr->size()-1 ) neighbours.emplace_back(gasgap,channel+1 );
158 std::cout <<
" adding new channel " << channel <<
" " << gasgap;
159 if( measuresPhi ) std::cout <<
" phi " <<
" neighbours " << neighbours.size() << std::endl;
160 else std::cout <<
" eta " <<
" neighbours " << neighbours.size() << std::endl;
162 std::vector<Id>::iterator nit = neighbours.begin();
163 std::vector<Id>::iterator nit_end = neighbours.end();
165 int currentClusterId = -1;
166 for( ;nit!=nit_end;++nit ){
168 Doublet& doub = (*channelsPtr)[nit->ch];
170 int clusterNumber = nit->gp==1 ? doub.
first : doub.
second;
171 if( clusterNumber == -1 )
continue;
172 if(
debug ) std::cout <<
" new neighbour " << nit->gp <<
" " << nit->ch <<
" clusterid " << clusterNumber;
177 if( currentCluster ==
nullptr ){
180 if( gasgap==1 ) doublet.
first = clusterNumber;
181 else doublet.
second = clusterNumber;
182 currentClusterId = clusterNumber;
183 if(
debug ) std::cout <<
" adding hit to neighbour cluster with ID " << clusterNumber << std::endl;
184 }
else if( clusterNumber != currentClusterId ){
189 for( ;
h!=h_end;++
h ) {
193 Doublet& doub = (*channelsPtr)[ch];
194 if( gp==1 ) doub.
first = currentClusterId;
195 else doub.
second = currentClusterId;
197 if(
debug ) std::cout <<
" found cluster overlap, merging clusters " << std::endl;
200 if(
debug ) std::cout <<
" cluster overlap, same cluster " << std::endl;
204 if( currentCluster ==
nullptr ){
205 if(
debug ) std::cout <<
" no neighbouring hits, creating new cluster " << clusters.size() << std::endl;
208 Doublet& doub = (*channelsPtr)[channel];
209 if( gasgap==1 ) doub.
first = clusters.size();
210 else doub.
second = clusters.size();
211 clusters.push_back(cl);
219 std::cout <<
" cluster " << cl.ngasgap1 <<
" " << cl.ngasgap2 <<
" hits " << cl.hitList.size() << std::endl;
220 for(
const auto *hit : cl.hitList ){
221 std::cout <<
" " <<
m_rpcIdHelper->print_to_string(hit->identify()) << std::endl;