BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TMDCWire.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: TMDCWire.cxx,v 1.16 2022/01/28 22:04:42 maqm Exp $
3//-----------------------------------------------------------------------------
4// Filename : TMDCWire.cc
5// Section : Tracking MDC
6// Owner : Yoshi Iwasaki
7// Email : yoshihito.iwasaki@kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to represent a wire in MDC.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#define TMDCWire_INLINE_DEFINE_HERE
14// #include "CLHEP/String/Strings.h"
15// #include "belle.h"
16// #include MDC_H
17// #include "MdcRecGeo/MdcRecGeo.h"
18#include "TrkReco/TMDCWire.h"
19#include "MdcGeomSvc/IMdcGeomSvc.h"
20#include "TrkReco/TMDC.h"
21#include "TrkReco/TMDCTsf.h"
22#include "TrkReco/TMDCUtil.h"
23
24TMDC* TMDCWire::_cdc = 0;
25
26/*zsl
27extern "C" void
28calcdc_sag3_(int *, float *, float[3], float *, float *, float *);
29*/
30
32 : _forwardPosition( w->Backward() * 0.1 )
33 , _backwardPosition( w->Forward() * 0.1 )
34 , _tension( w->Tension() )
35 , _direction( w->Backward() - w->Forward() ) {
36 //: _forwardPosition(w->Forward()*0.1),
37 // _backwardPosition(w->Backward()*0.1),
38 // _direction(w->Forward() - w->Backward()) {
39 _state = 0;
40 _geo = w;
41 _id = w->Id();
42 _localId = w->Cell();
43 _layerId = w->Layer();
44 _layer = l;
45 _tsf = 0;
46 _hit = 0;
47 _xyPosition = 0.5 * ( _forwardPosition + _backwardPosition );
48 _xyPosition.setZ( 0. );
49 _direction = _direction.unit();
50}
51
53
54void TMDCWire::dump( const std::string& msg, const std::string& pre ) const {
55 std::cout << pre;
56 std::cout << "w " << _id;
57 std::cout << ",local " << _localId;
58 std::cout << ",layer " << _layerId;
59 std::cout << ",super layer " << superLayerId();
60 std::cout << ",local layer " << localLayerId();
61 std::cout << std::endl;
62 if ( msg.find( "neighbor" ) != std::string::npos ||
63 msg.find( "detail" ) != std::string::npos )
64 {
65 for ( unsigned i = 0; i < 6; i++ )
66 if ( neighbor( i ) ) neighbor( i )->dump( "", pre + std::to_string( i ) + " " );
67 }
68 if ( msg.find( "tsf" ) != std::string::npos || msg.find( "detail" ) != std::string::npos )
69 {
70 if ( _tsf ) _tsf->dump( "", pre + " " );
71 }
72}
73
74const HepPoint3D TMDCWire::xyPosition( double z ) const {
75 double A = 47.35E-6 / _tension;
76 HepPoint3D x0 =
77 ( z - _backwardPosition.z() ) / _direction.z() * _direction + _backwardPosition;
78
79 double zinit = x0.z();
80 HepVector3D wire;
81 wire.setX( _forwardPosition.x() - _backwardPosition.x() );
82 wire.setY( _forwardPosition.y() - _backwardPosition.y() );
83 wire.setZ( _forwardPosition.z() - _backwardPosition.z() );
84 double lxz = sqrt( wire.z() * wire.z() + wire.x() * wire.x() );
85 double Zp = ( zinit - _backwardPosition.z() ) * lxz / wire.z();
86 double x = _direction.x() * ( zinit - _backwardPosition.z() ) / _direction.z() +
87 _backwardPosition.x();
88 double y = ( A * ( Zp - lxz ) + wire.y() / lxz ) * Zp + _backwardPosition.y();
89 x0.setX( x );
90 x0.setY( y );
91 return x0;
92}
93
94const TMDCWire* const TMDCWire::neighbor( unsigned i ) const {
95 if ( _cdc == 0 ) _cdc = TMDC::getTMDC();
96 static const unsigned nLayers = _cdc->nLayers();
97
98 //...Expensive...
99 unsigned l = layerId();
100 int local = (int)localId();
101 float phi0 = _cdc->layer( l )->offset();
102 int nWir = (int)_cdc->layer( l )->nWires();
103 float phi = phi0 + local * 2 * M_PI / nWir;
104 unsigned s = superLayerId();
105 // cout<<"i:"<<i<<" layerId:"<<l<<" local:"<<local<<" nWire:"<<nWir<<"
106 // superLyrId:"<<s<<endl;
107
108 if ( i == WireInnerLeft || i == WireInnerRight )
109 {
110 if ( l == 0 ) return 0;
111 --l;
112 if ( _cdc->layer( l )->superLayerId() != s ) return 0;
113 phi0 = _cdc->layer( l )->offset();
114 nWir = _cdc->layer( l )->nWires();
115 local = (int)( ( phi - phi0 ) / ( 2 * M_PI / nWir ) );
116
117 // cout<<"inner local"<<local<<", "<<local+1<<endl;
118
119 // cout<<(phi-phi0)/(2*pi/nWir)<<" local:"<<local<<endl;
120 // cout<<"InnerLeft phi:"<<phi0 + local*2*pi/nWir
121 // <<" InnerRight phi:"<<phi0 + (local+1)*2*pi/nWir
122 // <<" phi:"<<phi<<endl;
123 // if(local<0 || local+1>nWir-1)
124 // cout<<"TMDCWire::neighbor()---Pay attation the cellNo !!!"<<endl
125 // <<l+1<<"th layer: InnerLeftRight, local:"<<local<<"
126 // local+1:"<<local+1<<endl;
127 // LR changed to bes3
128 if ( i == WireInnerLeft ) return _cdc->wire( l, local );
129 else return _cdc->wire( l, local + 1 );
130 // if (i == WireInnerRight) return _cdc->wire(l, local);
131 // else return _cdc->wire(l, local + 1);
132 }
133 else if ( i == WireLeft || i == WireRight )
134 {
135 // cout<<"Left phi:"<<phi0 + (local-1)*2*pi/nWir
136 // <<" Right phi:"<<phi0 + (local+1)*2*pi/nWir
137 // <<" phi:"<<phi<<endl;
138 // if(local-1<0 || local+1>nWir-1)
139 // cout<<"TMDCWire::neighbor()---Pay attation the Cell No !!!"<<endl
140 // <<l<<"th layer: LeftRight, local-1:"<<local-1<<" local+1:"<<local+1<<endl;
141 if ( i == WireLeft ) return _cdc->wire( l, local - 1 );
142 else return _cdc->wire( l, local + 1 );
143 }
144 else if ( i == WireOuterLeft || i == WireOuterRight )
145 {
146 if ( l == nLayers - 1 ) return 0;
147 ++l;
148 if ( _cdc->layer( l )->superLayerId() != s ) return 0;
149 phi0 = _cdc->layer( l )->offset();
150 nWir = _cdc->layer( l )->nWires();
151 local = (int)( ( phi - phi0 ) / ( 2 * M_PI / nWir ) );
152
153 // cout<<"outer local"<<local<<", "<<local+1<<endl;
154
155 // cout<<(phi-phi0)/(2*pi/nWir)<<" local:"<<local<<endl;
156 // cout<<"OuterLeft phi:"<<phi0 + local*2*pi/nWir
157 // <<" OuterRight phi:"<<phi0 + (local+1)*2*pi/nWir
158 // <<" phi:"<<phi<<endl;
159 // if(local<0 || local+1>nWir-1)
160 // cout<<"TMDCWire::neighbor()---Pay attation the Cell No !!!"<<endl
161 // <<l-1<<"th layer: OuterLeftRight, local:"<<local<<"
162 // local+1:"<<local+1<<endl;
163 if ( i == WireOuterLeft ) return _cdc->wire( l, local );
164 else return _cdc->wire( l, local + 1 );
165 }
166 return 0;
167}
168
169int TMDCWire::localIdForPlus( void ) const {
170 /*
171 if(_layerId >= 0 && _layerId <= 5){
172 if(_localId == 63)
173 return -1;
174 else return _localId;
175 }
176
177 if(_layerId >= 6 && _layerId <= 8){
178 if(_localId == 79)
179 return -1;
180 else return _localId;
181 }
182
183 if(_layerId >= 9 && _layerId <= 14){
184 if(_localId == 95)
185 return -1;
186 else return _localId;
187 }
188
189 if(_layerId >= 15 && _layerId <= 17){
190 if(_localId == 127)
191 return -1;
192 else return _localId;
193 }
194
195 if(_layerId >= 18 && _layerId <= 22){
196 if(_localId == 143)
197 return -1;
198 else return _localId;
199 }
200
201 if(_layerId >= 23 && _layerId <= 26){
202 if(_localId == 159)
203 return -1;
204 else return _localId;
205 }
206
207 if(_layerId >= 27 && _layerId <= 31){
208 if(_localId == 175)
209 return -1;
210 else return _localId;
211 }
212
213 if(_layerId >= 32 && _layerId <= 35){
214 if(_localId == 207)
215 return -1;
216 else return _localId;
217 }
218
219 if(_layerId >= 36 && _layerId <= 40){
220 if(_localId == 239)
221 return -1;
222 else return _localId;
223 }
224
225 if(_layerId >= 41 && _layerId <= 44){
226 if(_localId == 255)
227 return -1;
228 else return _localId;
229 }
230
231 if(_layerId >= 45){
232 if(_localId == 287)
233 return -1;
234 else return _localId;
235 }
236
237 return -1;
238 */
239 // Liuqg 060915
240 if ( _layerId == 0 )
241 {
242 if ( _localId == 39 ) return -1;
243 else return _localId;
244 }
245
246 if ( _layerId == 1 )
247 {
248 if ( _localId == 43 ) return -1;
249 else return _localId;
250 }
251
252 if ( _layerId == 2 )
253 {
254 if ( _localId == 47 ) return -1;
255 else return _localId;
256 }
257
258 if ( _layerId == 3 )
259 {
260 if ( _localId == 55 ) return -1;
261 else return _localId;
262 }
263
264 if ( _layerId == 4 )
265 {
266 if ( _localId == 63 ) return -1;
267 else return _localId;
268 }
269
270 if ( _layerId == 5 )
271 {
272 if ( _localId == 71 ) return -1;
273 else return _localId;
274 }
275
276 if ( _layerId == 6 || _layerId == 7 )
277 {
278 if ( _localId == 79 ) return -1;
279 else return _localId;
280 }
281
282 if ( _layerId == 8 || _layerId == 9 )
283 {
284 if ( _localId == 75 ) return -1;
285 else return _localId;
286 }
287
288 if ( _layerId == 10 || _layerId == 11 )
289 {
290 if ( _localId == 87 ) return -1;
291 else return _localId;
292 }
293
294 if ( _layerId == 12 || _layerId == 13 )
295 {
296 if ( _localId == 99 ) return -1;
297 else return _localId;
298 }
299
300 if ( _layerId == 14 || _layerId == 15 )
301 {
302 if ( _localId == 111 ) return -1;
303 else return _localId;
304 }
305
306 if ( _layerId == 16 || _layerId == 17 )
307 {
308 if ( _localId == 127 ) return -1;
309 else return _localId;
310 }
311
312 if ( _layerId == 18 || _layerId == 19 )
313 {
314 if ( _localId == 139 ) return -1;
315 else return _localId;
316 }
317
318 if ( _layerId >= 20 && _layerId <= 23 )
319 {
320 if ( _localId == 159 ) return -1;
321 else return _localId;
322 }
323
324 if ( _layerId >= 24 && _layerId <= 27 )
325 {
326 if ( _localId == 175 ) return -1;
327 else return _localId;
328 }
329
330 if ( _layerId >= 28 && _layerId <= 31 )
331 {
332 if ( _localId == 207 ) return -1;
333 else return _localId;
334 }
335
336 if ( _layerId >= 32 && _layerId <= 35 )
337 {
338 if ( _localId == 239 ) return -1;
339 else return _localId;
340 }
341
342 if ( _layerId >= 36 && _layerId <= 39 )
343 {
344 if ( _localId == 255 ) return -1;
345 else return _localId;
346 }
347
348 if ( _layerId >= 40 && _layerId <= 42 )
349 {
350 if ( _localId == 287 ) return -1;
351 else return _localId;
352 }
353
354 return -1;
355}
356
357int TMDCWire::localIdForMinus( void ) const {
358 /*
359 if(_layerId >= 0 && _layerId <= 5){
360 if(_localId == 0)
361 return 64;
362 else return _localId;
363 }
364
365 if(_layerId >= 6 && _layerId <= 8){
366 if(_localId == 0)
367 return 80;
368 else return _localId;
369 }
370
371 if(_layerId >= 9 && _layerId <= 14){
372 if(_localId == 0)
373 return 96;
374 else return _localId;
375 }
376
377 if(_layerId >= 15 && _layerId <= 17){
378 if(_localId == 0)
379 return 128;
380 else return _localId;
381 }
382
383 if(_layerId >= 18 && _layerId <= 22){
384 if(_localId == 0)
385 return 144;
386 else return _localId;
387 }
388
389 if(_layerId >= 23 && _layerId <= 26){
390 if(_localId == 0)
391 return 160;
392 else return _localId;
393 }
394
395 if(_layerId >= 27 && _layerId <= 31){
396 if(_localId == 0)
397 return 192;
398 else return _localId;
399 }
400
401 if(_layerId >= 32 && _layerId <= 35){
402 if(_localId == 0)
403 return 208;
404 else return _localId;
405 }
406
407 if(_layerId >= 36 && _layerId <= 40){
408 if(_localId == 0)
409 return 240;
410 else return _localId;
411 }
412
413 if(_layerId >= 41 && _layerId <= 44){
414 if(_localId == 0)
415 return 256;
416 else return _localId;
417 }
418
419 if(_layerId >= 45){
420 if(_localId == 0)
421 return 288;
422 else return _localId;
423 }
424 */
425 // Liuqg 060915
426 if ( _layerId == 0 )
427 {
428 if ( _localId == 0 ) return 40;
429 else return _localId;
430 }
431
432 if ( _layerId == 1 )
433 {
434 if ( _localId == 0 ) return 44;
435 else return _localId;
436 }
437
438 if ( _layerId == 2 )
439 {
440 if ( _localId == 0 ) return 48;
441 else return _localId;
442 }
443
444 if ( _layerId == 3 )
445 {
446 if ( _localId == 0 ) return 56;
447 else return _localId;
448 }
449
450 if ( _layerId == 4 )
451 {
452 if ( _localId == 0 ) return 64;
453 else return _localId;
454 }
455
456 if ( _layerId == 5 )
457 {
458 if ( _localId == 0 ) return 72;
459 else return _localId;
460 }
461
462 if ( _layerId == 6 || _layerId == 7 )
463 {
464 if ( _localId == 0 ) return 80;
465 else return _localId;
466 }
467
468 if ( _layerId == 8 || _layerId == 9 )
469 {
470 if ( _localId == 0 ) return 76;
471 else return _localId;
472 }
473
474 if ( _layerId == 10 || _layerId == 11 )
475 {
476 if ( _localId == 0 ) return 88;
477 else return _localId;
478 }
479
480 if ( _layerId == 12 || _layerId == 13 )
481 {
482 if ( _localId == 0 ) return 100;
483 else return _localId;
484 }
485
486 if ( _layerId == 14 || _layerId == 15 )
487 {
488 if ( _localId == 0 ) return 112;
489 else return _localId;
490 }
491
492 if ( _layerId == 16 || _layerId == 17 )
493 {
494 if ( _localId == 0 ) return 128;
495 else return _localId;
496 }
497
498 if ( _layerId == 18 || _layerId == 19 )
499 {
500 if ( _localId == 0 ) return 140;
501 else return _localId;
502 }
503
504 if ( _layerId >= 20 && _layerId <= 23 )
505 {
506 if ( _localId == 0 ) return 160;
507 else return _localId;
508 }
509
510 if ( _layerId >= 24 && _layerId <= 27 )
511 {
512 if ( _localId == 0 ) return 176;
513 else return _localId;
514 }
515
516 if ( _layerId >= 28 && _layerId <= 31 )
517 {
518 if ( _localId == 0 ) return 208;
519 else return _localId;
520 }
521
522 if ( _layerId >= 32 && _layerId <= 35 )
523 {
524 if ( _localId == 0 ) return 240;
525 else return _localId;
526 }
527
528 if ( _layerId >= 36 && _layerId <= 39 )
529 {
530 if ( _localId == 0 ) return 256;
531 else return _localId;
532 }
533
534 if ( _layerId >= 40 && _layerId <= 42 )
535 {
536 if ( _localId == 0 ) return 288;
537 else return _localId;
538 }
539 return -1;
540}
541
543 HepVector3D& dir ) const {
544 back = _backwardPosition;
545
546 //...Check z position...
547 if ( !( z > _backwardPosition.z() && z < _forwardPosition.z() ) )
548 {
549 xy = _xyPosition;
550 dir = _direction;
551 }
552
553 //...Setup...
554 int wireID = id();
555 float wirePosition[3] = { 0., 0., 0. };
556 float dydz = 0;
557 float ybSag = 0;
558 float yfSag = 0;
559
560 //...Get corrections...
561 // zsl calcdc_sag3_(& wireID, & z, wirePosition, & dydz, & ybSag, & yfSag);
562
563 //...Wire position...
564 xy.setX( (double)wirePosition[0] );
565 xy.setY( (double)wirePosition[1] );
566 xy.setZ( (double)wirePosition[2] );
567 back.setY( (double)ybSag );
568 HepVector3D v_aux( _forwardPosition.x() - _backwardPosition.x(), yfSag - ybSag,
569 _forwardPosition.z() - _backwardPosition.z() );
570 dir = v_aux.unit();
571
572 return;
573}
574
576
577#ifdef TRKRECO_DEBUG_DETAIL
578 if ( superLayerId() != a.superLayerId() )
579 {
580 std::cout << "TMDCWire::localIdDifference !!!";
581 std::cout << "super layer assumption violation" << std::endl;
582 }
583#endif
584
585 int diff = int( a.localId() ) - int( localId() );
586 unsigned nWires = layer()->nWires();
587 if ( diff > 0 )
588 {
589 int difR = nWires - diff;
590 if ( diff < difR ) return diff;
591 else return -difR;
592 }
593 else
594 {
595 int difR = nWires + diff;
596 if ( -diff < difR ) return diff;
597 else return difR;
598 }
599}
double w
XmlRpcServer s
HepGeom::Point3D< double > HepPoint3D
HepGeom::Vector3D< double > HepVector3D
#define M_PI
Definition TConstant.h:4
unsigned nWires(void) const
returns # of wires.
unsigned localLayerId(void) const
returns local layer id in a super layer.
const TMDCLayer *const layer(void) const
returns a pointer to a layer.
virtual ~TMDCWire()
Destructor.
Definition TMDCWire.cxx:52
unsigned localId(void) const
returns local id in a wire layer.
unsigned layerId(void) const
returns layer id.
TMDCWire(const MdcGeoWire *, TMDCLayer *)
Constructor.
Definition TMDCWire.cxx:31
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
unsigned superLayerId(void) const
returns super layer id.
const TMDCWire *const neighbor(unsigned) const
returns a pointer to a neighbor wire.
Definition TMDCWire.cxx:94
int localIdForMinus(void) const
returns localId but if 0, return maxLocalId + 1.
Definition TMDCWire.cxx:357
int localIdDifference(const TMDCWire &) const
returns local id difference.
Definition TMDCWire.cxx:575
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition TMDCWire.cxx:54
int localIdForPlus(void) const
returns localId but if maxLocalId, return -1.
Definition TMDCWire.cxx:169
void wirePosition(float zPosition, HepPoint3D &xyPosition, HepPoint3D &backwardPosition, HepVector3D &direction) const
calculates position and direction vector with sag correction.
Definition TMDCWire.cxx:542
static TMDC * getTMDC(void)
Definition TMDC.cxx:84