31 declareInterface<IMuonSegmentCleaner>(
this);
46 return StatusCode::SUCCESS;
62 const std::vector<const Trk::MeasurementBase*>& meas =
segment->containedMeasurements();
63 std::vector<const Trk::MeasurementBase*>::const_iterator mit = meas.begin();
64 std::vector<const Trk::MeasurementBase*>::const_iterator mit_end = meas.end();
74 std::vector<const Trk::RIO_OnTrack*> rots;
75 std::vector<const Trk::CompetingRIOsOnTrack*> crots;
76 rots.reserve(2*meas.size());
77 crots.reserve(2*meas.size());
79 for( ; mit!=mit_end;++mit ){
86 crots.push_back(
nullptr);
98 crots.push_back(crio);
104 unsigned int nMeas = rots.size();
105 unsigned int nphi = 0;
108 std::vector <const Trk::RIO_OnTrack*> rots_phi(nMeas);
109 std::vector <const Trk::CompetingRIOsOnTrack*> crots_phi(nMeas);
110 std::vector <const Trk::MeasurementBase*> meas_phi(nMeas);
111 std::vector <double> dis_phi(nMeas);
112 std::vector <int> chambercode_phi(nMeas);
113 std::vector <int> stripcode_phi(nMeas);
114 std::vector <int> ok_phi(nMeas);
115 std::vector <int> det_phi(nMeas);
116 std::vector <Identifier> id_phi(nMeas);
118 if (
m_debug) std::cout <<
" MuonSegmentAmbiCleanerTool nMeas " << nMeas <<
" competing rios: " << crots.size() << std::endl;
120 for (
unsigned int i=0;
i<rots.size();
i++){
126 meas_keep.push_back(rot->
clone());
131 meas_keep.push_back(rot->
clone());
137 meas_keep.push_back(rot->
clone());
142 meas_keep.push_back(rot->
clone());
153 rots_phi[nphi] = rot;
154 crots_phi[nphi] = crots[
i];
155 chambercode_phi[nphi] = 0;
156 stripcode_phi[nphi] = 0;
159 dis_phi[nphi] = 10000000;
164 chambercode_phi[nphi] =
code;
165 stripcode_phi[nphi] =
m_idHelperSvc->rpcIdHelper().strip(
id);
178 double disRPC = lSegmentPos.z() - lHitPos.z() + lSegmentDir.z()*(lHitPos.y()-lSegmentPos.y())/lSegmentDir.y();
180 std::cout <<
" ghit pos x " << gHitPos.x() <<
" y " << gHitPos.y() <<
" z " << gHitPos.z() << std::endl;
181 std::cout <<
" dis RPC " << disRPC << std::endl;
183 dis_phi[nphi] = disRPC;
188 chambercode_phi[nphi] =
code;
189 stripcode_phi[nphi] =
m_idHelperSvc->tgcIdHelper().channel(
id);
202 double disTGC = lSegmentPos.y() - lHitPos.y() + lSegmentDir.y()*(lHitPos.z()-lSegmentPos.z())/lSegmentDir.z();
204 std::cout <<
" ghit pos x " << gHitPos.x() <<
" y " << gHitPos.y() <<
" z " << gHitPos.z() << std::endl;
205 std::cout <<
" dis TGC " << disTGC << std::endl;
207 dis_phi[nphi] = disTGC;
211 if (
m_debug) std::cout <<
" Distance to segment " << dis_phi[nphi] << std::endl;
212 if (ok_phi[nphi] == 1 ) nphi++;
216 bool changeSegment =
false;
220 for(
unsigned int i = 0;
i < nphi-1 ; ++
i ) {
221 if (ok_phi[
i] == 0)
continue;
222 for(
unsigned int j =
i+1 ; j < nphi ; ++j ) {
223 if (ok_phi[j] == 0)
continue;
225 if ( stripcode_phi[
i] == stripcode_phi[j] && chambercode_phi[
i] == chambercode_phi[j] ) ambi =
true;
229 if (det_phi[
i] == 1 && det_phi[j] == 1 &&
m_debug) {
233 if (det_phi[
i] == 2 && det_phi[j] == 2 &&
m_debug) {
238 if (
m_debug) {
ATH_MSG_DEBUG(
" Ambiguous " <<
" Distance1 " << dis_phi[
i] <<
" Distance1 " << dis_phi[j]); }
239 if (dis_phi[
i]!= 0.&& dis_phi[j]!=0) {
240 if ( fabs(dis_phi[
i]) < fabs(dis_phi[j]) ) {
249 ATH_MSG_DEBUG(
" index " <<
i <<
" strip " << stripcode_phi [
i] <<
" chambercode " << chambercode_phi[
i] <<
" selected " << ok_phi[
i] <<
" segment distance " << dis_phi[
i]);
250 ATH_MSG_DEBUG(
" index " << j <<
" strip " << stripcode_phi [j] <<
" chambercode " << chambercode_phi[j] <<
" selected " << ok_phi[j] <<
" segment distance " << dis_phi[j]);
258 for(
unsigned int i = 0;
i < nphi ;
i++ ) {
261 for(
unsigned int j = 0; j < nphi ; j++ ) {
262 if (crots_phi[j] == crots_phi[
i] && j!=
i)
264 crots_phi[j]=
nullptr;
267 crots_phi[
i]=
nullptr;
274 std::set <const Trk::CompetingRIOsOnTrack*> selected_crots;
276 for (
unsigned int i=0;
i<nphi;++
i){
277 if (ok_phi[
i] == 1) {
280 if (det_phi[
i] == 1) nphirpcn++;
281 if (det_phi[
i] == 2) nphitgcn++;
282 meas_keep.push_back(rots_phi[
i]->
clone());
284 else if (selected_crots.count(crots_phi[
i]) == 0)
286 meas_keep.push_back(crots_phi[
i]->
clone());
287 selected_crots.insert(crots_phi[
i]);
288 if (det_phi[
i] == 1) nphirpcn++;
289 if (det_phi[
i] == 2) nphitgcn++;
291 }
if (ok_phi[
i] == 0 && (det_phi[
i] == 1||det_phi[
i] == 2)) {
292 changeSegment =
true;
298 std::cout <<
" Summary MuonSegmentAmbiCleaner (not accurate with competing rios!)" << std::endl;
299 std::cout <<
" Input Segment with " << netamdt <<
" MDT hits " << netacsc <<
" eta CSC hits " << netatgc <<
" eta TGC Hits " << netarpc <<
" eta RPC hits " << std::endl;
300 std::cout <<
" and " << nphicsc <<
" phi CSC hits " << nphitgc <<
" phi TGC Hits " << nphirpc <<
" phi RPC hits " << std::endl;
301 std::cout <<
" Output after Ambiguity removal " << nphitgcn <<
" phi TGC Hits " << nphirpcn <<
" phi RPC hits " << std::endl;
314 Amg::Vector2D locSegmentPos(lSegmentPos.x(),lSegmentPos.y());
320 std::move(meas_keep),