13#define FTWireHitInvalid 2
14#define FTWireHitAppended 4
15#define FTWireHitAppendedOrInvalid 6
16#define FTWireNeighbor0 8
17#define FTWireNeighbor1 16
18#define FTWireNeighbor2 32
19#define FTWireNeighbor3 64
20#define FTWireNeighbor4 128
21#define FTWireNeighbor5 256
22#define FTWireHitSegment 16384
23#define FTWireHitLinked 131072
24#define FTWireHitRight 32768
25#define FTWireHitLeft 65536
27#define FTWireFittingInvalid 0x10000000
28#define FTWireInvalid 0x20000000
29#define FTWireStateMask 0xf0000000
32#define M_PI 3.14159265358979323846
40#include "CLHEP/Matrix/Vector.h"
46 FTWire(
const float x,
const float y,
const float dx,
const float dy,
59 const float x(
void)
const;
62 const float y(
void)
const;
65 float phi(
void)
const;
89 unsigned state(
void)
const;
92 unsigned stateAND(
const unsigned mask)
const;
95 int z(
const Lpav & la,
double &
z)
const;
98 float time(
void)
const;
114 float t0(
const float t0);
123 void stateOR(
const unsigned mask);
151 const FTWire * left(
void)
const;
154 const FTWire * right(
void)
const;
157 void getInnerNeighbor(
FTWire *
const vtWire);
160 void getOuterNeighbor(
FTWire *
const vtWire);
163 void getMidNeighbor(
void);
189#ifdef FTWire_NO_INLINE
193#define FTWire_INLINE_DEFINE_HERE
196#ifdef FTWire_INLINE_DEFINE_HERE
200 const float dx,
const float dy,
const FTLayer & layer,
201 const int localID,
FTWire *
const vt)
209 _phi((const float)2*
M_PI*_localId/(float)_layer.NWire()+_layer.offset()),
257 getInnerNeighbor(_wire);
258 getOuterNeighbor(_wire);
270FTWire::getInnerNeighbor(
FTWire *
const vtWire)
273 _neighbor[0] = _neighbor[1] = vtWire;
276 float thisPhi =
phi();
277 const FTLayer * pLayer = &_layer;
278 int n = (*(pLayer-1)).NWire();
279 int low=0, high=
n-1, mid = 0;
280 int innerPosition = 1;
284 if ((*(lastInnerPointer-mid)).phi() <= thisPhi)
291 if((*(lastInnerPointer-innerPosition)).phi() <= thisPhi) {
292 _neighbor[0] = lastInnerPointer-innerPosition;
293 if(innerPosition == 0) _neighbor[1] = lastInnerPointer-
n+1;
294 else _neighbor[1] = lastInnerPointer-innerPosition+1;
296 if((innerPosition+1) ==
n) _neighbor[0] = lastInnerPointer;
297 else _neighbor[0] = lastInnerPointer-innerPosition-1;
298 _neighbor[1] = lastInnerPointer-innerPosition;
305FTWire::getOuterNeighbor(
FTWire *
const vtWire)
308 _neighbor[4] = _neighbor[5] = vtWire;
311 float thisPhi =
phi();
312 const FTLayer * pLayer = &_layer;
313 int n = (*(pLayer+1)).NWire();
314 int low=0, high=
n-1, mid = 0;
319 if ((*(firstPointer+mid)).phi() > thisPhi)
326 if((*(firstPointer+position)).phi() <= thisPhi) {
327 _neighbor[4] = firstPointer+position;
328 if((position+1) ==
n) _neighbor[5] = firstPointer;
329 else _neighbor[5] = firstPointer+position+1;
331 if((position-1) == -1) _neighbor[4] = firstPointer +
n - 1;
332 else _neighbor[4] = firstPointer+position-1;
333 _neighbor[5] = firstPointer+position;
339FTWire::getMidNeighbor(
void)
341 _neighbor[2] = (
FTWire *) left();
342 _neighbor[3] = (
FTWire *) right();
410 return _distance * std::fabs(_layer.
tanSlant());
445 return _pedestal = ped;
472FTWire::hep(
void)
const
517 _state=(_state|mask)^mask;
523 HepVector center = la.
center();
525 double dx2 = center(1) - _x;
526 double dy2 = center(2) - _y;
527 double par1 = _dx*_dx + _dy*_dy;
528 double par2 = (_dx*dx2 + _dy*dy2)/par1;
529 double par3 = _dx*dy2 - _dy*dx2;
530 double par4 = rho*rho*par1 - par3*par3;
531 if (par4<0.)
return 0;
532 par4 = std::sqrt(par4)/par1;
533 double delta = par2 + par4;
535 if (delta>=0. && delta<1.){
537 z = _layer.
zf()+delta*(_layer.
zb()-_layer.
zf());
541 if (delta>=0. && delta<1.){
543 z = _layer.
zf()+delta*(_layer.
zb()-_layer.
zf());
553 if (((**(_neighbor+2))._state&
FTWireHit) &&
563FTWire::left(
void)
const{
564 const FTWire * tmp =
this;
565 if (!_localId) tmp += _layer.
NWire();
571FTWire::right(
void)
const{
572 const FTWire * tmp =
this;
573 if (_localId == (_layer.
NWire()-1)) {
574 tmp -= _layer.
NWire();
NTuple::Array< double > m_adc
const int localLayerId(void) const
returns local-layer ID
const int NWire(void) const
returns the number of wire
const float zf(void) const
returns z of forward end-plate
const float tanSlant(void) const
returns tangent of slant angle
const float zb(void) const
returns z of backward end-plate
const FTSuperLayer & superLayer(void) const
returns super-layer
const int layerMaxId(void) const
returns layer max ID
float phi(void) const
returns phi
const float y(void) const
returns position y
int z(const Lpav &la, double &z) const
returns z for track la
float distance(void) const
returns drift distance
float getChi2(void) const
unsigned stateAND(const unsigned mask) const
returns state bit
FTWire ** neighborPtr(void)
returns pointer of neighbor array
unsigned state(void) const
returns state
void initNeighbor(void)
initNeighbor
const FTLayer & layer(void) const
returns layer
void stateORXOR(const unsigned mask)
reset state bit
float distance_z(void) const
returns z_distance from the center of wire by drift distance
void chk_left_and_right(void)
check neighbors of phi-side and raise invalid flag if both hits
void setAdc(float adc)
wangdy add:set Adc value
const int localId(void) const
returns local ID
int getWireId(void)
get wireId
const float x(void) const
returns position x
float pedestal(void) const
returns pedestal read at begin run
void wireId(int wireID)
set wireId
void stateXOR(const unsigned mask)
invert state bit
void stateOR(const unsigned mask)
set state bit
float time(void) const
rerurns TDC time(after t0 subtraction)
void setChi2(float chi2)
set residual fit chi2
float t0(void) const
returns t0 read at begin run