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