ATLAS Offline Software
Loading...
Searching...
No Matches
CscSegmentMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
8
9#include "CscSegmentMaker.h"
11
14#include <cmath>
15
16
17namespace TrigL2MuonSA {
18
19
20CscSegmentMaker::CscSegmentMaker(const std::string& type, const std::string& name, const IInterface* parent)
21 : AthAlgTool(type, name, parent),
22 m_util()
23{
24}
25
26
28 ATH_CHECK(m_cscregdict.retrieve());
29 ATH_CHECK(m_muDetMgrKey.initialize());
30 ATH_CHECK(m_idHelperSvc.retrieve());
31 return StatusCode::SUCCESS;
32}
33
34
36 std::vector<TrigL2MuonSA::TrackPattern> &v_trackPatterns,
37 const TrigL2MuonSA::TgcFitResult &tgcFitResult,
38 const TrigL2MuonSA::MuonRoad &muroad) const
39{
40 ATH_MSG_DEBUG( "FindSuperPointCsc" );
42 const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
43
44 if( !cscHits.empty() ){
45
46 for (TrigL2MuonSA::TrackPattern& track : v_trackPatterns) { // loop for track candidates
47
48 //get module hash to read
49 int hash_clusters[32]={0};
50
51 TrigL2MuonSA::CscHits clusters[32][8];
52 for(unsigned int iclu=0; iclu<cscHits.size(); ++iclu){
53 const TrigL2MuonSA::CscHitData &cscHit = cscHits[iclu];
54
55 //outlier or not
56 double width = (cscHit.MeasuresPhi == 0 ) ? m_max_residual_eta : m_max_residual_phi;
57 if ( width < std::abs(cscHit.Residual) ) continue;
58
59
60 int cathodelayer = 2*(cscHit.WireLayer-1)+ cscHit.MeasuresPhi;//cathodelayer is in [0,7]
61 int module_hash = m_cscregdict->get_hash(cscHit.StationName, cscHit.StationEta, cscHit.StationPhi);
62
63 if(0<=module_hash && 32>module_hash){
64 clusters[module_hash][cathodelayer].push_back( cscHit );
65 hash_clusters[module_hash]=1;//set modules to read
66 }else{
67 continue;
68 }
69 }//for clusters
70
71
72 //decide which module to read
73 int hashSPs[2]={999,999};
74 if( getModuleSP( hashSPs, tgcFitResult, track.phiBin, muroad, hash_clusters)!=ReturnCode::FAILURE ){
75
76 bool found_segment=false;
77 for(int ihash=0; ihash<2; ++ihash){
78 if(found_segment) break;//once a segment is found, then finish searching more
79
80 int hashSP=hashSPs[ihash];
81 if(hashSP>32) continue;
82
83 //making segment
84 CscSegment cscsegment, cscsegment_noip;
85 if (this->make_segment(hashSP, clusters[hashSP] , cscsegment, cscsegment_noip, muDetMgr) != ReturnCode::FAILURE ){
86 found_segment=true;
87 track.hashID_CSC = hashSP;
88
91 TrigL2MuonSA::SuperPoint* superPoint = &(track.superPoints[csc]);
92 const TrigL2MuonSA::SuperPoint* outerSP = &(track.superPoints[outer]);
93 bool &large_dphidz = track.large_dPhidZ;
94 double &outerCorFactor = track.outerCorFactor;
95
96 //tgcfitresult
97 double tgcmid1z = tgcFitResult.tgcMid1[3];
98 double tgcmid2z = tgcFitResult.tgcMid2[3];
99 double phimiddle = tgcFitResult.phi;
100 double dPhidz = tgcFitResult.dPhidZ;
101 if( 0.75e-6<std::abs(dPhidz) ) large_dphidz=true;
102 double tgcmidZ = (tgcmid1z+tgcmid2z)/2.;
103 double outerz = outerSP->Z;
104
105 //calculate SP
106 CscSegment cscsegment_ext = segmentAtFirstLayer(hashSP, &cscsegment);
107 double phiMod = m_cscregdict->phiMod(hashSP);
108 double CSCR=cscsegment_ext.x()*std::cos(phiMod)+cscsegment_ext.y()*std::sin(phiMod);
109 double CSCZ=cscsegment_ext.z();
110 double PhiAtCsc = phimiddle/* - std::abs(CSCZ-tgcmidZ)*dPhidz*/;
111 double CSCSPR = CSCR/std::cos( m_util.calc_dphi(PhiAtCsc,phiMod) );
112
113
114 superPoint->Z = CSCZ;
115 superPoint->R = CSCSPR;
116 superPoint->Alin = cscsegment_ext.slopeRZ();
117 superPoint->Blin = cscsegment_ext.interceptRZ();
118 superPoint->Npoint = cscsegment_ext.nHitEta();
119 superPoint->Chi2 = cscsegment_ext.chiSquare();
120 ATH_MSG_DEBUG("CSC super point:hashID=" << hashSP
121 << ",CSCR=" << CSCSPR << ",CSCZ=" << CSCZ
122 << ",Slope=" << cscsegment_ext.slopeRZ() << ",Intercept=" << cscsegment_ext.interceptRZ()
123 << ",nHitsEta=" << cscsegment_ext.nHitEta() << ",Chi2="<< cscsegment_ext.chiSquare());
124
125 //calculate outerSP's correction (dphidz of tgcFitResult)
126 double phiouter = phimiddle+std::abs(outerz-tgcmidZ)*dPhidz;
127 outerCorFactor = std::cos( m_util.calc_dphi(phiouter,phiMod) )/std::cos( m_util.calc_dphi(phimiddle,phiMod) );
128 ATH_MSG_DEBUG("outerCorFactor=" << outerCorFactor);
129
130 }//if there is a segment.
131 }//ihash loop over modules in which segment will be made
132 }//if there is the module in which segment will be made.
133 }//loop over track pattern candidate
134 }//if there are clusters, then make a segment
135
136
137 return ReturnCode::SUCCESS;
138}
139
140
141
142
143// cppcheck-suppress passedByValue
145 CscSegment &cscsegment,
146 CscSegment &cscsegment_noip, const MuonGM::MuonDetectorManager* muDetMgr) const
147{
148 ATH_MSG_DEBUG("################################## make_segment #####################################");
149
150 std::vector<localCscHit> hits_loc_eta[4], hits_loc_phi[4],emp;
151 emp.clear();
152 for(int i =0;i<4;++i){
153 hits_loc_eta[i]=emp;
154 hits_loc_phi[i]=emp;
155 }
156
157
158
159 Amg::Transform3D gToLocal;
160 if(m_use_geometry){
161 Identifier Id = m_idHelperSvc->cscIdHelper().channelID(m_cscregdict->stationName(mod_hash), m_cscregdict->stationEta(mod_hash),m_cscregdict->stationPhi(mod_hash),2/*chamberLayer*/, 1, 0, 1);
162 const MuonGM::CscReadoutElement *csc = muDetMgr->getCscReadoutElement(Id);
163 if (csc == NULL){
164 ATH_MSG_DEBUG( "Csc Readout Element not found ---- skip");
165 return ReturnCode::FAILURE;
166 }
167 ATH_MSG_DEBUG("CscReadoutElement");
168 gToLocal = csc->GlobalToAmdbLRSTransform();
169 }else{
170 double rotpi = (m_cscregdict->stationEta(mod_hash)>0) ? -M_PI/2. : M_PI/2.;
171 Amg::AngleAxis3D rotZamg( (-1)*(m_cscregdict->phiMod(mod_hash)), Amg::Vector3D(0,0,1));
172 Amg::AngleAxis3D rotYamg( (-1)*(m_cscregdict->actualAtanNormal(mod_hash)), Amg::Vector3D(0,1,0) );
173 Amg::AngleAxis3D rotPIamg( rotpi, Amg::Vector3D(0,0,1));
174 Amg::Translation3D translation( 0.0, 0.0, (-1)*(m_cscregdict->displacement(mod_hash)) );
175 gToLocal=translation*rotPIamg*rotYamg*rotZamg;
176 }
177
178
179 localCscHit ip_loc;
180 Amg::Vector3D ip_vec = gToLocal*Amg::Vector3D(0.0, 0.0, 0.0);
181 ip_loc.loc_x = ip_vec(Amg::x);
182 ip_loc.loc_y = ip_vec(Amg::y);
183 ip_loc.loc_z = ip_vec(Amg::z);
184 ip_loc.measphi = -1;
185 ip_loc.error = m_err_ip;
186 ip_loc.residual = 0.;
187 ip_loc.isIP = true;
188 ip_loc.enabled = false;
189 ip_loc.stationname = 0;
190
191 for (unsigned int clyr=0; clyr<8; ++clyr) {
192 for (unsigned int ihit=0; ihit<clusters[clyr].size(); ++ihit) {
193
194 TrigL2MuonSA::CscHitData &cschit = clusters[clyr][ihit];
195 double r = cschit.r;
196 double phi = cschit.phi;
197 double z = cschit.z;
198
199 //move to local coordinate system
200 Amg::Vector3D vect(r*std::cos(phi),r*std::sin(phi),z);
201 Amg::Vector3D loc_vect = gToLocal*vect;
202
203 //building localCscHit object
204 localCscHit loc_hit;
205 loc_hit.loc_x = loc_vect(Amg::x);
206 loc_hit.loc_y = loc_vect(Amg::y);
207 loc_hit.loc_z = loc_vect(Amg::z);
208 loc_hit.measphi=cschit.MeasuresPhi;
209 loc_hit.error = (loc_hit.measphi==0) ? m_err_eta : m_err_phi;
210 loc_hit.residual = cschit.Residual;
211 loc_hit.enabled=true;
212 loc_hit.isIP=false;
213 loc_hit.stationname=cschit.StationName;
214 ATH_MSG_DEBUG( "measphi=" << cschit.MeasuresPhi << " wirelyr=" << cschit.WireLayer << " x=" << loc_hit.loc_x << " y=" << loc_hit.loc_y << " z=" << loc_hit.loc_z << " err=" << loc_hit.error << " res=" << loc_hit.residual);
215
216
217 if(0==loc_hit.measphi) {
218 if(m_max_residual_eta>std::abs(loc_hit.residual)) hits_loc_eta[cschit.WireLayer-1].push_back( loc_hit );
219 }
220 if(1==loc_hit.measphi) {
221 if(m_max_residual_phi>std::abs(loc_hit.residual)) hits_loc_phi[cschit.WireLayer-1].push_back( loc_hit );
222 }
223 }//ihit
224 }//clyr
225
226 Amg::Vector3D seg_pos_loc, seg_dir_loc,seg_pos_loc_noip, seg_dir_loc_noip;
227 int nhite=0,nhitp=0;
228 local2dSegment seg2d_eta ,seg2d_phi, seg2d_eta_noip, seg2d_phi_noip;
229
230
231 if( this->make_2dsegment( 0/*=measphi*/, ip_loc, hits_loc_eta, seg2d_eta, seg2d_eta_noip, nhite)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
232 if( this->make_2dsegment( 1/*=measphi*/, ip_loc, hits_loc_phi, seg2d_phi,seg2d_phi_noip, nhitp)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
233
234
235 ATH_MSG_DEBUG("==include IP==");
236 if( this->make_4dsegment(seg2d_eta,seg2d_phi,seg_pos_loc,seg_dir_loc)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
237 ATH_MSG_DEBUG("==exclude IP==");
238 if( this->make_4dsegment(seg2d_eta_noip,seg2d_phi_noip,seg_pos_loc_noip,seg_dir_loc_noip)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
239
240
241 Amg::Transform3D lToGlobal = gToLocal.inverse();
242 Amg::Vector3D seg_pos = lToGlobal*seg_pos_loc;
243 Amg::Vector3D seg_dir = lToGlobal.rotation()*seg_dir_loc;
244 Amg::Vector3D seg_pos_noip = lToGlobal*seg_pos_loc_noip;
245 Amg::Vector3D seg_dir_noip = lToGlobal.rotation()*seg_dir_loc_noip;
246
247
248 //building CscSegment objects
249 cscsegment.set(seg_pos,seg_dir, seg2d_eta.chi2, seg2d_phi.chi2);
250 cscsegment.setNHitEta(seg2d_eta.nhit);
251 cscsegment.setNHitPhi(seg2d_phi.nhit);
252 cscsegment_noip.set(seg_pos_noip,seg_dir_noip, seg2d_eta_noip.chi2, seg2d_phi_noip.chi2);
253 cscsegment_noip.setNHitEta(seg2d_eta_noip.nhit);
254 cscsegment_noip.setNHitPhi(seg2d_phi_noip.nhit);
255
256
257 return ReturnCode::SUCCESS;
258}
259
260
261// cppcheck-suppress passedByValue
262 ReturnCode CscSegmentMaker::make_2dsegment(int measphi, const localCscHit &ip_loc, const std::vector<localCscHit> hits_loc[4],
263 local2dSegment &seg2d,
264 local2dSegment &seg2d_ipremoved,
265 int &nhit) const
266{
267
268 int nohit=0;
269 std::vector<int> hit_lyr;
270 hit_lyr.clear();
271
272 //counting layers without clusters
273 for (int i=0; i<4; ++i ){
274 if( 0==hits_loc[i].size() ) ++nohit;
275 }
276
277 std::vector<local2dSegment> seg2d_4hitCollection,seg2d_3hitCollection;
278 seg2d_4hitCollection.clear(); seg2d_3hitCollection.clear();
279 std::vector<localCscHit> hits_loc_copy[4];
280 for (int i=0;i<4;++i) hits_loc_copy[i] = hits_loc[i];
281
282
283 if(0==nohit){
284
285 if( this->make_2dseg4hit(measphi, ip_loc, hits_loc_copy, seg2d_4hitCollection, nhit)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
286 //hits already used are removed in hits_loc_copy
287 ATH_MSG_DEBUG("display hits left");
288 display_hits(hits_loc_copy);
289 if( this->make_2dseg3hit(measphi, ip_loc, hits_loc_copy, seg2d_3hitCollection, nhit)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
290
291 } else if(1==nohit) {
292
293 if( this->make_2dseg3hit(measphi, ip_loc, hits_loc_copy, seg2d_3hitCollection, nhit)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
294
295 } else {
296 return ReturnCode::FAILURE;
297 }
298
299 //select the segment nearest to tgcroad.
300 bool exist=false;
301 seg2d.residual=99999.;
302 for(unsigned int iseg4=0; iseg4< seg2d_4hitCollection.size(); ++iseg4){
303
304 if( std::abs( seg2d_4hitCollection[iseg4].residual ) < std::abs(seg2d.residual) ){
305 seg2d=seg2d_4hitCollection[iseg4];
306 exist=true;
307 ATH_MSG_DEBUG("seg2d.residual=" << seg2d.residual);
308 }
309 }
310 for(unsigned int iseg3=0; iseg3< seg2d_3hitCollection.size(); ++iseg3){
311
312 if( std::abs( seg2d_3hitCollection[iseg3].residual ) < std::abs(seg2d.residual) ){
313 seg2d=seg2d_3hitCollection[iseg3];
314 exist=true;
315 ATH_MSG_DEBUG("seg2d.residual=" << seg2d.residual);
316 }
317 }
318
319 if(false==exist) return ReturnCode::FAILURE;
320
321 if( this->fit_clusters(measphi,seg2d.localHits,seg2d_ipremoved)!=ReturnCode::SUCCESS ) return ReturnCode::FAILURE;
322
323 return ReturnCode::SUCCESS;
324
325}
326
328 std::vector<localCscHit> hits_loc[4], //removing hits used in fit with 4 hits
329 std::vector<local2dSegment> &seg2d_4hitCollection,
330 int &nhit) const
331{
332
333 std::vector<localCscHit> hit_fit;
334
335 for (unsigned int ihit0=0; ihit0<hits_loc[0].size(); ++ihit0) {
336 for (unsigned int ihit1=0; ihit1<hits_loc[1].size(); ++ihit1) {
337 for (unsigned int ihit2=0; ihit2<hits_loc[2].size(); ++ihit2) {
338 for (unsigned int ihit3=0; ihit3<hits_loc[3].size(); ++ihit3) {
339
340 // set clusters
341 hit_fit.clear();
342 hit_fit.push_back(ip_loc);
343 hit_fit.push_back(hits_loc[0][ihit0]);
344 hit_fit.push_back(hits_loc[1][ihit1]);
345 hit_fit.push_back(hits_loc[2][ihit2]);
346 hit_fit.push_back(hits_loc[3][ihit3]);
347
348 //segment fit
349 local2dSegment seg2d_tmp;
350 if( this->fit_clusters(measphi,hit_fit,seg2d_tmp)!=ReturnCode::SUCCESS ) continue;
351
352
353 if(seg2d_tmp.chi2<m_max_chisquare){
354 seg2d_tmp.localHits.push_back(hits_loc[0][ihit0]);
355 seg2d_tmp.localHits.push_back(hits_loc[1][ihit1]);
356 seg2d_tmp.localHits.push_back(hits_loc[2][ihit2]);
357 seg2d_tmp.localHits.push_back(hits_loc[3][ihit3]);
358 //disable hits
359 hits_loc[0][ihit0].enabled=false;
360 hits_loc[1][ihit1].enabled=false;
361 hits_loc[2][ihit2].enabled=false;
362 hits_loc[3][ihit3].enabled=false;
363
364 seg2d_4hitCollection.push_back(seg2d_tmp);
365 ATH_MSG_DEBUG("4hitsegment was made");
366 }
367
368 }
369 }
370 }
371 }//loop over all combination of 4hits
372
373
374 //make vector of hits left unused
375 std::vector<localCscHit> hit_loc_left[4];
376 for (unsigned int ilyr=0;ilyr<4; ++ilyr){
377 for(unsigned int ihit=0; ihit < hits_loc[ilyr].size(); ++ihit){
378
379 if ( true==hits_loc[ilyr][ihit].enabled ){
380 hit_loc_left[ilyr].push_back(hits_loc[ilyr][ihit]);
381 }
382 }//loop over hits in layer
383 }//loop over wire layer
384
385 for(int ilyr=0; ilyr<4; ++ilyr) hits_loc[ilyr]=hit_loc_left[ilyr];//copying "objects" of vector
386
387 nhit=4;
388
389 return ReturnCode::SUCCESS;
390
391}
392
393
395 // cppcheck-suppress passedByValue
396 const std::vector<localCscHit> hits_loc[4],
397 std::vector<local2dSegment> &seg2d_3hitCollection,
398 int &nhit) const
399{
400
401 int empty_lyr=-1;
402 int nohit=0;
403 for (int ilyr=0; ilyr<4; ++ilyr ){
404 if( 0==hits_loc[ilyr].size() ){
405 ++nohit;
406 empty_lyr=ilyr;
407 }
408 }
409
410 if ( 1<nohit ) return ReturnCode::SUCCESS;
411
412 std::vector<localCscHit> hit_fit;
413
414
415 int hit_lyrA[4] = {1, 2, 3, 0};
416 int hit_lyrB[4] = {2, 3, 0, 1};
417 int hit_lyrC[4] = {3, 0, 1, 2};
418
419 for(int lyrcomb=0; lyrcomb<4; ++lyrcomb){
420
421 if(0<=empty_lyr && empty_lyr!=lyrcomb) continue;
422
423 for (unsigned int ihitA=0; ihitA<hits_loc[hit_lyrA[lyrcomb]].size(); ++ihitA) {
424 for (unsigned int ihitB=0; ihitB<hits_loc[hit_lyrB[lyrcomb]].size(); ++ihitB) {
425 for (unsigned int ihitC=0; ihitC<hits_loc[hit_lyrC[lyrcomb]].size(); ++ihitC) {
426
427 hit_fit.clear();
428 hit_fit.push_back(ip_loc);
429 hit_fit.push_back(hits_loc[hit_lyrA[lyrcomb]][ihitA]);
430 hit_fit.push_back(hits_loc[hit_lyrB[lyrcomb]][ihitB]);
431 hit_fit.push_back(hits_loc[hit_lyrC[lyrcomb]][ihitC]);
432
433 //fit clusters
434 local2dSegment seg2d_tmp;
435
436 if( this->fit_clusters(measphi,hit_fit,seg2d_tmp)!=ReturnCode::SUCCESS ) continue;//for eta
437
438 if(seg2d_tmp.chi2<2.0*m_max_chisquare/3.0){
439 seg2d_tmp.localHits.push_back(hits_loc[hit_lyrA[lyrcomb]][ihitA]);
440 seg2d_tmp.localHits.push_back(hits_loc[hit_lyrB[lyrcomb]][ihitB]);
441 seg2d_tmp.localHits.push_back(hits_loc[hit_lyrC[lyrcomb]][ihitC]);
442 seg2d_3hitCollection.push_back(seg2d_tmp);
443 ATH_MSG_DEBUG("3hitsegment was made");
444 }
445 }
446 }
447 }
448 }//loop over layer combination
449 nhit=3;
450
451
452 return ReturnCode::SUCCESS;
453}
454
455
456ReturnCode CscSegmentMaker::fit_clusters(int measphi, const std::vector<localCscHit> &hits_fit, local2dSegment &seg2d) const{
457
458
459 double S=0.;
460 double Sx=0.;
461 double Sy=0.;
462 double aStt=0.;
463 int nhit=0;
464 int nhit_with_ip=0;
465 double Stt=0.;
466 double Syy=0.;
467 double Sxx=0.;
468 double Sxy=0.;
469 double a = 0.;
470 double b = 0.;
471 double rp=0.;
472 double rq=0.;
473 double aver_res=0.;
474
475
476 for (unsigned int ihit=0; ihit< hits_fit.size(); ++ihit) {
477
478
479 double x= hits_fit[ihit].loc_z;
480 double y= (measphi==0) ? hits_fit[ihit].loc_y : hits_fit[ihit].loc_x;
481 double err= hits_fit[ihit].error;
482 double w = 1./(err*err);
483 // ATH_MSG_DEBUG("local pos, z=" << hits_fit[ihit].loc_z << ", x,y=" << y << ", err=" << err << ", w=" << w << ", res=" << hits_fit[ihit].residual << ", measphi="<< hits_fit[ihit].measphi);
484 S += w;
485 Sx += w*x;
486 Sy += w*y;
487 if( !hits_fit[ihit].isIP ){
488 seg2d.stationname=hits_fit[ihit].stationname;
489 aver_res += w*hits_fit[ihit].residual;
490 rq += w;
491 rp += w*x;
492 ++nhit;
493 }
494 ++nhit_with_ip;
495 }//ihit
496 seg2d.zshift=rp/rq;
497
498 seg2d.residual=aver_res/rq;
499
500
501 for (unsigned int ihit=0; ihit< hits_fit.size(); ++ihit) {
502
503 double x= hits_fit[ihit].loc_z;
504 double y= (measphi==0) ? hits_fit[ihit].loc_y : hits_fit[ihit].loc_x;
505 double err = hits_fit[ihit].error;
506 double w = 1./(err*err);// (ihit==0)?0.25:100.;//
507 Stt += w*(x-Sx/S)*(x-Sx/S);
508 aStt += w*y*(x-Sx/S);
509 Sxx += w*x*x;
510 Syy += w*y*y;
511 Sxy += w*x*y;
512
513 }//ihit
514
515
516
517 if(nhit_with_ip>1){
518 a = seg2d.a = aStt/Stt;
519 b = seg2d.b = (Sy-Sx*a)/S;
520 seg2d.nhit = nhit;
521
522 }else{
523 return ReturnCode::FAILURE;
524 }
525 seg2d.chi2 = Syy + a*a*Sxx + 2*b*a*Sx + b*b*S - 2*b*Sy - 2*a*Sxy;
526
527 ATH_MSG_DEBUG( "fit: a=" << a << " b=" << b << " chi2=" << seg2d.chi2 );
528
529 return ReturnCode::SUCCESS;
530}
531
532
533
535 const local2dSegment &seg2d_phi,
536 Amg::Vector3D &seg_pos,
537 Amg::Vector3D &seg_dir) const
538{
539
540 int nhit_e=seg2d_eta.nhit;
541 int nhit_p=seg2d_phi.nhit;
542 double a_eta=seg2d_eta.a;
543 double b_eta=seg2d_eta.b;
544 double a_phi=seg2d_phi.a;
545 double b_phi=seg2d_phi.b;
546 double rzshift=seg2d_eta.zshift;
547 double phizshift=seg2d_phi.zshift;
548
549
550 if (nhit_e<2 || nhit_p<2 ) return ReturnCode::FAILURE;
551
552
553
554 ATH_MSG_DEBUG("rzshift=" << rzshift << " phizshift=" << phizshift << " diff=" << (rzshift-phizshift)
555 << " angle=" << ( 0.5*M_PI - std::atan(a_phi) ) << " b_phi=" << b_phi /*<< " Newb_phi=" << Newb_phi*/ );
556
557
558 double norm = std::sqrt( a_phi*a_phi + a_eta*a_eta + 1 );
559
560
561
562 seg_dir = Amg::Vector3D(a_phi/norm, a_eta/norm, 1./norm);
563 ATH_MSG_DEBUG("segdir_loc (px,py,pz)=" << "(" << seg_dir(Amg::px) << "," << seg_dir(Amg::py) << "," << seg_dir(Amg::pz) << ") a_eta="
564 << a_eta << " a_phi=" << a_phi << " chi2_eta=" << seg2d_eta.chi2 << " chi2_phi=" << seg2d_phi.chi2 );
565
566 double aver_z=0.5*(rzshift+phizshift);
567
568
569 ATH_MSG_DEBUG(" new aver_z=" << aver_z );
570 seg_pos = Amg::Vector3D(seg_dir(Amg::px)*aver_z/seg_dir(Amg::pz) + b_phi, seg_dir(Amg::py)*aver_z/seg_dir(Amg::z) + b_eta, aver_z);
571
572 ATH_MSG_DEBUG( "myseg_loc (x,y,z,px,py,pz)=(" << seg_pos(Amg::x) << "," << seg_pos(Amg::y) << "," << seg_pos(Amg::z)
573 << "," << seg_dir(Amg::px) << "," << seg_dir(Amg::py) << "," << seg_dir(Amg::pz) << ")");
574
575 return ReturnCode::SUCCESS;
576
577}
578
579
580
582 const TrigL2MuonSA::TgcFitResult &tgcFitResult,
583 int phibin,
584 const MuonRoad &muroad,
585 const int hash_clusters[32]) const
586{
587 ATH_MSG_DEBUG("getModuleSP()");
588
589
590 for(unsigned int imod=0; imod<32;++imod){
591
592 if( 0==hash_clusters[imod] ) continue;
593 int stationeta = m_cscregdict->stationEta(imod);
594 int side = (muroad.side) ? 1 : -1;
595 double phiMod = m_cscregdict->phiMod(imod);
596 double dphi = m_util.calc_dphi(phiMod, tgcFitResult.phi);
597 ATH_MSG_DEBUG("getModuleSP()::(phi,side) modlue:(" << phiMod << "," << stationeta << ") tgcroad:(" << tgcFitResult.phi << "," << side << ")");
598 if( std::abs(dphi)>M_PI/8. || side != stationeta) continue;
599
600
601 if(7!=phibin){
602
603 if(imod<16 && phibin>7){//small normal
604 mod_hashes[0]=imod;
605 } else if( imod >=16 && phibin<7){//large normal
606 mod_hashes[0]=imod;
607 } else {//overlap
608 mod_hashes[1]=imod;
609 }
610
611 } else if (7==phibin) {
612
613 if(imod<16 && 1==muroad.LargeSmall ){//small normal
614 mod_hashes[0]=imod;
615 } else if( imod >=16 && 0== muroad.LargeSmall){//large normal
616 mod_hashes[0]=imod;
617 } else {//overlap
618 mod_hashes[1]=imod;
619 }
620
621 }
622 }//for imod
623 ATH_MSG_DEBUG("getModuleSP::Normal sector=" << mod_hashes[0] << " overlap sector=" << mod_hashes[1]);
624
625 return ReturnCode::SUCCESS;
626
627
628}
629
630
632
633
634 double alpha = m_cscregdict->displacement(mod_hash);
635 Amg::Vector3D n = m_cscregdict->nomalVector(mod_hash);
636 double a0=mu_seg->px(), a1=mu_seg->py(), a2=mu_seg->pz();
637 double b0=mu_seg->x(), b1=mu_seg->y(),b2=mu_seg->z();
638 double t = ( alpha-(n(0)*b0+n(1)*b1+n(2)*b2) )/( n(0)*a0+n(1)*a1+n(2)*a2 );
639 double x0=a0*t+b0,x1=a1*t+b1,x2=a2*t+b2;
640 double chisquare=mu_seg->chiSquare();
641 double chisquare_phi=mu_seg->chiSquarePhi();
642
643 CscSegment cscsegment;
644 cscsegment.set(x0,x1,x2,a0,a1,a2,chisquare, chisquare_phi);
645 cscsegment.setNHitEta(mu_seg->nHitEta());
646 cscsegment.setNHitPhi(mu_seg->nHitPhi());
647
648 return cscsegment;
649}
650
651
652
653// cppcheck-suppress passedByValue
654ReturnCode CscSegmentMaker::display_hits(const std::vector<localCscHit> localHits[4]) const
655{
656 for(unsigned int ilyr=0; ilyr<4; ++ilyr){
657 for (unsigned int ihit=0; ihit<localHits[ilyr].size(); ++ihit) {
658 const localCscHit &locHit = localHits[ilyr][ihit];
659 ATH_MSG_DEBUG("measphi=" << locHit.measphi << " wirelyr=" << ilyr+1
660 << " x=" << locHit.loc_x << " y=" << locHit.loc_y << " z=" << locHit.loc_z
661 << " err=" << locHit.error << " res=" << locHit.residual);
662 }
663 }
664
665 return ReturnCode::SUCCESS;
666}
667
668
669
671
672 m_x=0.;
673 m_y=0.;
674 m_z=0.;
675 m_px=0.;
676 m_py=0.;
677 m_pz=0.;
678 m_slopeRZ=0.;
679 m_interceptRZ=0.;
680 m_nhit_eta=0;
681 m_nhit_phi=0;
682 m_chisquare=0.;
684}
685
686ReturnCode CscSegment::set(double x, double y, double z, double px, double py, double pz, double chisquare, double chisquare_phi)
687{
688
689 m_x=x;
690 m_y=y;
691 m_z=z;
692 m_px=px;
693 m_py=py;
694 m_pz=pz;
695 double r = std::sqrt( x*x + y*y );
696 m_slopeRZ = ( px*x+py*y )/( r*pz );
697 m_interceptRZ = r - slopeRZ()*z;
698 m_chisquare = chisquare;
699 m_chisquare_phi = chisquare_phi;
700
701 return ReturnCode::SUCCESS;
702
703}
704
705ReturnCode CscSegment::set( Amg::Vector3D &seg_pos, Amg::Vector3D &seg_dir, double chisquare, double chisquare_phi)
706{
707
708 m_x = seg_pos(Amg::x);
709 m_y = seg_pos(Amg::y);
710 m_z = seg_pos(Amg::z);
711 m_px = seg_dir(Amg::px);
712 m_py = seg_dir(Amg::py);
713 m_pz = seg_dir(Amg::pz);
714 double r = std::sqrt( x()*x() + y()*y() );
715 m_slopeRZ = ( px()*x()+py()*y() )/( r*pz() );
716 m_interceptRZ = r - slopeRZ()*z();
717 m_chisquare = chisquare;
718 m_chisquare_phi = chisquare_phi;
719
720 return ReturnCode::SUCCESS;
721
722}
723
724
725
727
728 bool eta_clean=false;
729 bool phi_clean=false;
730
731 if (m_nhit_eta>1&&m_nhit_eta<5) eta_clean = true;
732 if (m_nhit_phi>1&&m_nhit_phi<5) phi_clean = true;
733
734 return eta_clean && phi_clean;
735
736}
737
738
739}//namespace TrigL2MuonSA
#define M_PI
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
ReadCards * rp
static Double_t a
const double width
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const_pointer_type cptr()
ReturnCode make_2dsegment(int measphi, const localCscHit &ip_loc, const std::vector< localCscHit > hits_loc[4], local2dSegment &seg2d_eta, local2dSegment &local2d_noip, int &nhite) const
ReturnCode make_2dseg3hit(int measphi, const localCscHit &ip_loc, const std::vector< localCscHit > hits_loc[4], std::vector< local2dSegment > &seg2d_4hitCollection, int &nhit) const
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_muDetMgrKey
ReturnCode display_hits(const std::vector< localCscHit > localHits[4]) const
virtual StatusCode initialize() override
ReturnCode fit_clusters(int measphi, const std::vector< localCscHit > &hits_fit, local2dSegment &seg2d) const
ReturnCode FindSuperPointCsc(const TrigL2MuonSA::CscHits &cscHits, std::vector< TrigL2MuonSA::TrackPattern > &v_trackPatterns, const TrigL2MuonSA::TgcFitResult &tgcFitResult, const TrigL2MuonSA::MuonRoad &muroad) const
Gaudi::Property< double > m_max_residual_phi
Gaudi::Property< double > m_max_residual_eta
ToolHandle< CscRegDict > m_cscregdict
CscSegment segmentAtFirstLayer(int mod_hash, TrigL2MuonSA::CscSegment *mu_seg) const
Gaudi::Property< double > m_max_chisquare
CscSegmentMaker(const std::string &type, const std::string &name, const IInterface *parent)
ReturnCode make_2dseg4hit(int measphi, const localCscHit &ip_loc, std::vector< localCscHit > hits_loc[4], std::vector< local2dSegment > &seg2d_4hitCollection, int &nhite) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_use_geometry
Gaudi::Property< double > m_err_ip
ReturnCode make_segment(int mod_hash, TrigL2MuonSA::CscHits clusters[8], CscSegment &cscsegment, CscSegment &cscsegment_noip, const MuonGM::MuonDetectorManager *muDetMgr) const
Gaudi::Property< double > m_err_phi
ReturnCode make_4dsegment(const local2dSegment &seg2d_eta, const local2dSegment &seg2d_phi, Amg::Vector3D &seg_pos, Amg::Vector3D &seg_dir) const
Gaudi::Property< double > m_err_eta
ReturnCode getModuleSP(int mod_hash[2], const TrigL2MuonSA::TgcFitResult &tgcFitResult, int phibin, const TrigL2MuonSA::MuonRoad &muroad, const int exist_clusters[32]) const
ReturnCode set(double x, double y, double z, double px, double py, double pz, double chisquare, double chisquare_phi)
int r
Definition globals.cxx:22
double a0
Definition globals.cxx:27
Eigen::AngleAxisd AngleAxis3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
std::vector< CscHitData > CscHits
Definition CscData.h:40
Chamber
Define chamber types and locations.
@ EndcapOuter
Outer station in the endcap spectrometer.
@ CSC
CSC measurement point.
unsigned int StationName
Definition CscData.h:15