13#ifdef TRKRECO_DEBUG_DETAIL
19#include "CLHEP/String/Strings.h"
38#include "GaudiKernel/MsgStream.h"
39#include "GaudiKernel/AlgFactory.h"
40#include "GaudiKernel/ISvcLocator.h"
41#include "GaudiKernel/IMessageSvc.h"
42#include "GaudiKernel/IDataProviderSvc.h"
43#include "GaudiKernel/SmartDataPtr.h"
44#include "GaudiKernel/PropertyMgr.h"
45#include "GaudiKernel/IJobOptionsSvc.h"
46#include "GaudiKernel/Bootstrap.h"
47#include "GaudiKernel/StatusCode.h"
96 if (! _cdc) _cdc =
new TMDC(
"1.0");
100TMDC::TMDC(
const std::string & version)
103 _cdcVersion(version),
115 _newCdc(version ==
"-2000") {
120 std::cout <<
"TMDC ... MDC version = " << _cdcVersion << std::endl;
133 StatusCode sc = Gaudi::svcLocator()->service(
"MdcGeomSvc", mdcGeomSvc);
134 if (sc == StatusCode::SUCCESS) {
142 for (
unsigned i = 0; i < _nSuperLayers; i++)
147 for (
unsigned i = 0; i < _nLayers; i++) {
154 _layers.append(
layer);
158 for (
unsigned j = 0; j < l->
NCell(); j++) {
186 if ( msg.find(
"name") != std::string::npos
187 || msg.find(
"version") != std::string::npos
188 || msg.find(
"detail") != std::string::npos
192 if (msg.find(
"detail") != std::string::npos || msg.find(
"state") != std::string::npos) {
193 std::cout <<
"Debug Level=" << _debugLevel;
195 std::cout << std::endl;
197 std::string tab(
" ");
199 if (msg ==
"" || msg.find(
"geometry") != std::string::npos) {
202 unsigned nLayer = _layers.length();
203 std::cout <<
" version : " <<
version() << std::endl;
204 std::cout <<
" cdc version: " <<
cdcVersion() << std::endl;
205 std::cout <<
" # of wires : " << _wires.length() << std::endl;
206 std::cout <<
" # of layers: " << nLayer << std::endl;
207 std::cout <<
" super layer information" << std::endl;
208 std::cout <<
" # of super layers = " << _superLayers.length()
211 std::cout <<
" layer information" << std::endl;
212 for (
unsigned i = 0; i < _nLayers; i++)
213 _layers[i]->
dump(
"", tab);
215 std::cout <<
" wire information" << std::endl;
216 for (
unsigned i = 0; i < _nWires; i++)
217 (_wires[i])->dump(
"neighbor", tab);
221 if (msg.find(
"hits") != std::string::npos) {
222 std::cout <<
" hits : " << _hits.length() << std::endl;
223 for (
unsigned i = 0; i < _hits.length(); i++) {
224 _hits[i]->dump(
"state mc", tab);
227 if (msg.find(
"axialHits") != std::string::npos) {
228 std::cout <<
" hits : " << _axialHits.length() << std::endl;
229 for (
unsigned i = 0; i < _axialHits.length(); i++) {
230 _axialHits[i]->dump(
"state mc", tab);
233 if (msg.find(
"stereoHits") != std::string::npos) {
234 std::cout <<
" hits : " << _stereoHits.length() << std::endl;
235 for (
unsigned i = 0; i < _stereoHits.length(); i++) {
236 _stereoHits[i]->dump(
"state mc", tab);
259 std::cout <<
"r,phi = " << r <<
"," << p << std::endl;
266 if (! l)
return NULL;
287 _hitWires.removeAll();
288 _axialHits.removeAll();
289 _stereoHits.removeAll();
290 HepAListDeleteAll(_hits);
291 HepAListDeleteAll(_hitsMC);
292 HepAListDeleteAll(_badHits);
300 while (
TMDCWire * w = _hitWires[i++])
306 _hitWires.removeAll();
307 _axialHits.removeAll();
308 _stereoHits.removeAll();
309 HepAListDeleteAll(_hits);
310 HepAListDeleteAll(_hitsMC);
311 HepAListDeleteAll(_badHits);
328 cout<<
"size of MdcRecWirhit:"<<nReccdc<<endl;
330 for (
unsigned i = 0; i < nReccdc; i++) {
361 if (w->
axial()) _axialHits.append(hit);
362 else _stereoHits.append(hit);
398 unsigned n = _hits.length();
399 unsigned j = (whp->
id <
n) ? whp->
id :
n;
402 if (_hits[j]->reccdc() == whp) {
404 w = _wires[wh->
wire()->
id()];
427 if (hep) hep->_hits.append(hit);
429 std::cout <<
"TMDC::updateMC !!! mission impossible" << std::endl;
430 std::cout <<
" This error will cause TrkReco crush";
431 std::cout << std::endl;
432#ifdef TRKRECO_DEBUG_DETAIL
435 std::cout <<
" TTrackHEP list length = ";
446 unsigned n = _hits.length();
448 for (
unsigned i = 0; i <
n; i++) {
451 unsigned state = h->
state();
455 for (
unsigned j = 0; j < 6; j++) neighbor[j] = w->
neighbor(j);
463 unsigned pattern = 0;
464 for (
unsigned j = 0; j < 6; j++) {
466 if (neighbor[j]->hit())
474 if ((hr1 == 0) && (hl1 == 0)) {
480 if ((hr2 == 0) && (hr1 != 0) && (hl1 == 0) ||
481 (hl2 == 0) && (hl1 != 0) && (hr1 == 0))
487 bool previous =
false;
489 if (neighbor[0] == 0) previous =
true;
491 if ((neighbor[0]->hit()) || neighbor[1]->hit())
494 if (neighbor[5] == 0) next =
true;
496 if ((neighbor[4]->hit()) || neighbor[5]->hit())
503 if ((pattern == 34) || (pattern == 42) ||
504 (pattern == 40) || (pattern == 10) ||
505 (pattern == 35) || (pattern == 50))
507 else if ((pattern == 17) || (pattern == 21) ||
508 (pattern == 20) || (pattern == 5) ||
509 (pattern == 19) || (pattern == 49))
519 if (! mask)
return _axialHits;
521 std::cout <<
"TMDC::axialHits !!! unsupported mask given" << std::endl;
527 if (! mask)
return _stereoHits;
529 std::cout <<
"TMDC::stereoHits !!! unsupported mask given" << std::endl;
535 if (! mask)
return _hits;
537 std::cout <<
"TMDC::hits !!! unsupported mask given" << std::endl;
544 if (_badHits.length())
return _badHits;
549 for (
unsigned i = 0; i < nReccdc; i++) {
568 _badHits.append(
new TMDCWireHit(w, h, _fudgeFactor));
577 return itostring(
layerId(wireId)) +
"=" +
579 return itostring(
layerId(wireId)) +
"-" + itostring(
localId(wireId));
584 if (! w)
return std::string(
"no such a wire");
586 unsigned id = w->
Id();
603 if (
id < 40)
return 0;
604 else if (
id < 84)
return 1;
605 else if (
id < 132)
return 2;
606 else if (
id < 188)
return 3;
608 else if (
id < 252)
return 4;
609 else if (
id < 324)
return 5;
610 else if (
id < 404)
return 6;
611 else if (
id < 484)
return 7;
613 else if (
id < 560)
return 8;
614 else if (
id < 636)
return 9;
615 else if (
id < 724)
return 10;
616 else if (
id < 812)
return 11;
618 else if (
id < 912)
return 12;
619 else if (
id < 1012)
return 13;
620 else if (
id < 1124)
return 14;
621 else if (
id < 1236)
return 15;
623 else if (
id < 1364)
return 16;
624 else if (
id < 1492)
return 17;
625 else if (
id < 1632)
return 18;
626 else if (
id < 1772)
return 19;
628 else if (
id < 1932)
return 20;
629 else if (
id < 2092)
return 21;
630 else if (
id < 2252)
return 22;
631 else if (
id < 2412)
return 23;
633 else if (
id < 2604)
return 24;
634 else if (
id < 2796)
return 25;
635 else if (
id < 2988)
return 26;
636 else if (
id < 3180)
return 27;
638 else if (
id < 3388)
return 28;
639 else if (
id < 3596)
return 29;
640 else if (
id < 3804)
return 30;
641 else if (
id < 4012)
return 31;
643 else if (
id < 4252)
return 32;
644 else if (
id < 4492)
return 33;
645 else if (
id < 4732)
return 34;
646 else if (
id < 4972)
return 35;
648 else if (
id < 5228)
return 36;
649 else if (
id < 5484)
return 37;
650 else if (
id < 5740)
return 38;
651 else if (
id < 5996)
return 39;
653 else if (
id < 6284)
return 40;
654 else if (
id < 6572)
return 41;
655 else if (
id < 6860)
return 42;
662 if (! w)
return 9999;
677 if (
id < 40)
return id;
678 else if (
id < 84)
return id-40;
679 else if (
id < 132)
return id-84;
680 else if (
id < 188)
return id-132;
682 else if (
id < 252)
return id-188;
683 else if (
id < 324)
return id-252;
684 else if (
id < 404)
return id-324;
685 else if (
id < 484)
return id-404;
687 else if (
id < 560)
return id-484;
688 else if (
id < 636)
return id-560;
689 else if (
id < 724)
return id-636;
690 else if (
id < 812)
return id-724;
692 else if (
id < 912)
return id-812;
693 else if (
id < 1012)
return id-912;
694 else if (
id < 1124)
return id-1012;
695 else if (
id < 1236)
return id-1124;
697 else if (
id < 1364)
return id-1236;
698 else if (
id < 1492)
return id-1364;
699 else if (
id < 1632)
return id-1492;
700 else if (
id < 1772)
return id-1632;
702 else if (
id < 1932)
return id-1772;
703 else if (
id < 2092)
return id-1932;
704 else if (
id < 2252)
return id-2092;
705 else if (
id < 2412)
return id-2252;
707 else if (
id < 2604)
return id-2412;
708 else if (
id < 2796)
return id-2604;
709 else if (
id < 2988)
return id-2796;
710 else if (
id < 3180)
return id-2988;
712 else if (
id < 3388)
return id-3180;
713 else if (
id < 3596)
return id-3388;
714 else if (
id < 3804)
return id-3596;
715 else if (
id < 4012)
return id-3804;
717 else if (
id < 4252)
return id-4012;
718 else if (
id < 4492)
return id-4252;
719 else if (
id < 4732)
return id-4492;
720 else if (
id < 4972)
return id-4732;
722 else if (
id < 5228)
return id-4972;
723 else if (
id < 5484)
return id-5228;
724 else if (
id < 5740)
return id-5484;
725 else if (
id < 5996)
return id-5740;
727 else if (
id < 6284)
return id-5996;
728 else if (
id < 6572)
return id-6284;
729 else if (
id < 6860)
return id-6572;
751 if (! w)
return 9999;
766 if (
id < 188)
return 0;
767 else if (
id < 484)
return 1;
768 else if (
id < 812)
return 2;
769 else if (
id < 1236)
return 3;
770 else if (
id < 1772)
return 4;
771 else if (
id < 2412)
return 5;
772 else if (
id < 3180)
return 6;
773 else if (
id < 4012)
return 7;
774 else if (
id < 4972)
return 8;
775 else if (
id < 5996)
return 9;
776 else if (
id < 6860)
return 10;
797 if (! w)
return 9999;
798 unsigned id = w->
Id();
811 if (! l)
return 9999;
812 unsigned id = l->
Id();
814 if(
id < 44)
return id/4;
834 if(
id < 6860)
return layerId(
id)%4;
904 if (! w)
return 9999;
920 if (! l)
return 9999;
921 unsigned id = l->
Id();
922 if (
id < 44)
return id%4;
992 if (! l)
return 9999;
993 unsigned id = l->
Id();
995 if (
id < 8)
return id;
996 else if (
id < 20)
return id-8;
997 else if (
id < 36)
return id-12;
998 else if (
id < 43)
return id-24;
1008 if (
id < 12)
return id + 8;
1009 else if (
id < 19)
return id + 24;
1014 if (
id < 8)
return id;
1015 else if (
id < 24)
return id + 12;
1056 float tl =
t.helix().a()[4];
1057 float f = sqrt(1. + tl * tl);
1058 float s = fabs(
t.helix().curv()) * fabs(l.
dPhi()) * f;
1059 float p = f / fabs(
t.helix().a()[2]);
1064 if (! (flag && 2)) t0Offset = 0.;
1070 float p[3] = {tp.x(), tp.y(), tp.z()};
1072 float x[3] = {onWire.x(), onWire.y(), onWire.z()};
1076 int prop = (flag & 4);
1080 if (side == 0) side = -1;
1107 float tanl =
abs(p[2]) / tp.perp();
1109 if ((tanl >= 0.0) && (tanl < 0.5)) c = -0.48 * tanl + 1.3;
1110 else if ((tanl >= 0.5) && (tanl < 1.0)) c = -0.28 * tanl + 1.2;
1111 else if ((tanl >= 1.0) && (tanl < 1.5)) c = -0.16 * tanl + 1.08;
double abs(const EvtComplex &c)
#define WireHitFindingValid
#define WireHitContinuous
#define WireHitPatternLeft
#define WireHitPatternRight
#define WireHitNeighborHit
virtual const MdcGeoLayer *const Layer(unsigned id)=0
virtual const MdcGeoWire *const Wire(unsigned id)=0
static vector< MdcDat_mcwirhit > * getMdcDatMcwirhitCol(void)
double Radius(void) const
double RCSiz2(void) const
double RCSiz1(void) const
double Offset(void) const
static vector< MdcRec_wirhit > * getMdcRecWirhitCol(void)
A class to represent a wire layer.
unsigned superLayerId(void) const
returns super layer id.
const TMDCWire *const wire(int id) const
returns a pointer to a wire. 'id' can be negative or 'id' can be greater than 'nWires()'.
const MdcGeoLayer * geocdc(void) const
returns a pointer to GEOMDC_WIR.
unsigned nWires(void) const
returns # of wires.
A class to represent a MC wire hit in MDC.
struct MdcRec_wirhit * reccdc(void) const
returns a pointer to RECMDC_WIRHIT.
unsigned state(void) const
returns state.
float dDrift(unsigned) const
returns drift distance error.
float drift(unsigned) const
returns drift distance.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
const TMDCWireHitMC *const mc(void) const
returns a pointer to TMDCWireHitMC.
A class to represent a wire in MDC.
unsigned id(void) const
returns id.
bool axial(void) const
returns true if this wire is in an axial layer.
const TMDCWireHit *const hit(void) const
returns a pointer to a TMDCWireHit.
unsigned superLayerId(void) const
returns super layer id.
const TMDCWire *const neighbor(unsigned) const
returns a pointer to a neighbor wire.
void fastClear(void)
clears TMDC information.
static unsigned localId(unsigned wireId)
static unsigned axialStereoLayerId(const MdcGeoLayer *const)
const TMDCWire *const wire(unsigned wireId) const
returns a pointer to a wire. 0 will be returned if 'wireId' is invalid.
void updateMC(void)
updates TMDC information for MC.
static void driftDistance(TMLink &link, const TTrack &track, unsigned correctionFlag=0, float T0Offset=0.)
calculates corrected drift time. correctionFlag(bit 0:tof, 1:T0 offset, 2:propagation delay,...
std::string cdcVersion(void) const
returns MDC version.
static unsigned superLayerId(unsigned wireId)
std::string name(void) const
returns name.
static unsigned layerId(unsigned wireId)
const AList< TMDCWireHit > & hits(unsigned mask=0) const
returns a list of TMDCWireHit. 'update()' must be called before calling this function.
static TMDC * getTMDC(void)
const AList< TMDCWireHit > & axialHits(unsigned mask=0) const
returns a list of axial hits. 'update()' must be called before calling this function.
unsigned nWires(void) const
const TMDCLayer *const layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
static std::string wireName(unsigned wireId)
std::string version(void) const
returns version.
static float phi(float phi)
const AList< TMDCWireHit > & badHits(void)
returns bad hits(finding invalid hits).
const AList< TMDCWireHit > & stereoHits(unsigned mask=0) const
returns a list of stereo hits. 'update()' must be called before calling this function.
static unsigned localLayerId(unsigned wireId)
void dump(const std::string &message) const
dumps debug information.
const AList< TMDCLayer > *const superLayer(unsigned id) const
returns a pointer to a super-layer. 0 will be returned if 'id' is invalid.
void clear(void)
clears all TMDC information.
void classification(void)
classify hits.
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & positionOnWire(void) const
returns the closest point on wire to a track.
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
float dDrift(void) const
returns/sets drift distance error.
double dPhi(void) const
returns dPhi to the closest point.
float drift(void) const
returns/sets drift distance.
A class to represent a GEN_HEPEVT particle in tracking.
static const AList< TTrackHEP > & list(void)
returns a list of TTrackHEP's.
A class to represent a track in tracking.
virtual void update(void)
updates an object.
virtual bool updated(void) const
returns true if an object is updated.
virtual void clear(void)
clears an object.