00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifdef TRKRECO_DEBUG_DETAIL
00014 #ifndef TRKRECO_DEBUG
00015 #define TRKRECO_DEBUG
00016 #endif
00017 #endif
00018 #include <iostream>
00019 #include "CLHEP/String/Strings.h"
00020
00021 #include "TrkReco/TMDC.h"
00022 #include "TrkReco/TMDCUtil.h"
00023 #include "TrkReco/TMDCWire.h"
00024 #include "TrkReco/TMDCLayer.h"
00025 #include "TrkReco/TMDCWireHit.h"
00026 #include "TrkReco/TMDCWireHitMC.h"
00027 #include "TrkReco/TMLink.h"
00028 #include "TrkReco/TTrack.h"
00029 #include "TrkReco/TTrackHEP.h"
00030
00031
00032
00033 #include "MdcGeomSvc/MdcGeomSvc.h"
00034 #include "MdcTables/MdcTables.h"
00035
00036
00037
00038 #include "GaudiKernel/MsgStream.h"
00039 #include "GaudiKernel/AlgFactory.h"
00040 #include "GaudiKernel/ISvcLocator.h"
00041 #include "GaudiKernel/IMessageSvc.h"
00042 #include "GaudiKernel/IDataProviderSvc.h"
00043 #include "GaudiKernel/SmartDataPtr.h"
00044 #include "GaudiKernel/PropertyMgr.h"
00045 #include "GaudiKernel/IJobOptionsSvc.h"
00046 #include "GaudiKernel/Bootstrap.h"
00047 #include "GaudiKernel/StatusCode.h"
00048 #include "EventModel/Event.h"
00049
00050
00051
00052
00053
00054 #include <vector>
00055 #include <iostream>
00056
00057 using namespace std;
00058 using namespace Event;
00059
00060 TMDC * GMDC = 0;
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 std::string
00076 TMDC::name(void) const {
00077 return "TMDC";
00078 }
00079
00080 std::string
00081 TMDC::version(void) const {
00082 return "2.18";
00083 }
00084
00085 TMDC *
00086 TMDC::_cdc = 0;
00087
00088 TMDC *
00089 TMDC::getTMDC(const std::string & version) {
00090 if (! _cdc) _cdc = new TMDC(version);
00091 return _cdc;
00092 }
00093
00094 TMDC *
00095 TMDC::getTMDC(void) {
00096 if (! _cdc) _cdc = new TMDC("1.0");
00097 return _cdc;
00098 }
00099
00100 TMDC::TMDC(const std::string & version)
00101 : _debugLevel(0),
00102 _fudgeFactor(1.),
00103 _cdcVersion(version),
00104
00105
00106
00107
00108
00109
00110
00111
00112 _nWires(6796),
00113 _nSuperLayers(11),
00114 _nLayers(43),
00115 _newCdc(version == "-2000") {
00116
00117 GMDC = this;
00118
00119
00120 std::cout << "TMDC ... MDC version = " << _cdcVersion << std::endl;
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 IMdcGeomSvc* mdcGeomSvc;
00133 StatusCode sc = Gaudi::svcLocator()->service("MdcGeomSvc", mdcGeomSvc);
00134 if (sc == StatusCode::SUCCESS) {
00135
00136
00137
00138
00139
00140
00141
00142 for (unsigned i = 0; i < _nSuperLayers; i++)
00143 _superLayers.append(new AList<TMDCLayer>);
00144
00145
00146 unsigned nWires = 0;
00147 for (unsigned i = 0; i < _nLayers; i++) {
00148
00149
00150
00151
00152 const MdcGeoLayer * l = mdcGeomSvc->Layer(i);
00153 TMDCLayer * layer = new TMDCLayer(l);
00154 _layers.append(layer);
00155 _superLayers[layer->superLayerId()]->append(layer);
00156
00157
00158 for (unsigned j = 0; j < l->NCell(); j++) {
00159
00160
00161
00162
00163 const MdcGeoWire * w = mdcGeomSvc->Wire(l->Wirst()+j);
00164 TMDCWire * tw = new TMDCWire(w, layer);
00165 _wires.append(tw);
00166 layer->append(tw);
00167
00168 ++nWires;
00169 }
00170 }
00171
00172 } else {
00173
00174 return;
00175 }
00176
00177
00178 }
00179
00180 void
00181 TMDC::dump(const std::string & msg) const {
00182
00183
00184
00185
00186 if ( msg.find("name") != std::string::npos
00187 || msg.find("version") != std::string::npos
00188 || msg.find("detail") != std::string::npos
00189 || msg == "") {
00190 std::cout << name() << "(" << version() << ") ";
00191 }
00192 if (msg.find("detail") != std::string::npos || msg.find("state") != std::string::npos) {
00193 std::cout << "Debug Level=" << _debugLevel;
00194 }
00195 std::cout << std::endl;
00196
00197 std::string tab(" ");
00198
00199 if (msg == "" || msg.find("geometry") != std::string::npos) {
00200
00201
00202 unsigned nLayer = _layers.length();
00203 std::cout << " version : " << version() << std::endl;
00204 std::cout << " cdc version: " << cdcVersion() << std::endl;
00205 std::cout << " # of wires : " << _wires.length() << std::endl;
00206 std::cout << " # of layers: " << nLayer << std::endl;
00207 std::cout << " super layer information" << std::endl;
00208 std::cout << " # of super layers = " << _superLayers.length()
00209 << std::endl;
00210
00211 std::cout << " layer information" << std::endl;
00212 for (unsigned i = 0; i < _nLayers; i++)
00213 _layers[i]->dump("", tab);
00214
00215 std::cout << " wire information" << std::endl;
00216 for (unsigned i = 0; i < _nWires; i++)
00217 (_wires[i])->dump("neighbor", tab);
00218
00219 return;
00220 }
00221 if (msg.find("hits") != std::string::npos) {
00222 std::cout << " hits : " << _hits.length() << std::endl;
00223 for (unsigned i = 0; i < _hits.length(); i++) {
00224 _hits[i]->dump("state mc", tab);
00225 }
00226 }
00227 if (msg.find("axialHits") != std::string::npos) {
00228 std::cout << " hits : " << _axialHits.length() << std::endl;
00229 for (unsigned i = 0; i < _axialHits.length(); i++) {
00230 _axialHits[i]->dump("state mc", tab);
00231 }
00232 }
00233 if (msg.find("stereoHits") != std::string::npos) {
00234 std::cout << " hits : " << _stereoHits.length() << std::endl;
00235 for (unsigned i = 0; i < _stereoHits.length(); i++) {
00236 _stereoHits[i]->dump("state mc", tab);
00237 }
00238 }
00239 }
00240
00241 const TMDCWire * const
00242 TMDC::wire(unsigned layerId, int localId) const {
00243 if (layerId < _nLayers)
00244 return _layers[layerId]->wire(localId);
00245
00246 return NULL;
00247 }
00248
00249 const TMDCWire * const
00250 TMDC::wire(const HepPoint3D & p) const {
00251 float r = p.mag();
00252 float phi = p.phi();
00253 return wire(r, phi);
00254 }
00255
00256 const TMDCWire * const
00257 TMDC::wire(float r, float p) const {
00258
00259 std::cout << "r,phi = " << r << "," << p << std::endl;
00260
00261 unsigned id = 25;
00262 bool ok = false;
00263 const TMDCLayer * l;
00264 while (! ok) {
00265 l = layer(id);
00266 if (! l) return NULL;
00267
00268 const MdcGeoLayer * geo = l->geocdc();
00269 if (geo->Radius()/10 + geo->RCSiz2()/10 < r) ++id;
00270 else if (geo->Radius()/10 - geo->RCSiz1()/10 > r) --id;
00271 else ok = true;
00272 }
00273
00274
00275 float dPhi = 2. * M_PI / float(l->nWires());
00276 p -= l->geocdc()->Offset()/dPhi;
00277 unsigned localId = unsigned(phi(p) / dPhi);
00278 return l->wire(localId);
00279 }
00280
00281 void
00282 TMDC::clear(void) {
00283 unsigned i = 0;
00284 while (TMDCWire * w = _wires[i++])
00285 w->clear();
00286
00287 _hitWires.removeAll();
00288 _axialHits.removeAll();
00289 _stereoHits.removeAll();
00290 HepAListDeleteAll(_hits);
00291 HepAListDeleteAll(_hitsMC);
00292 HepAListDeleteAll(_badHits);
00293
00294 TUpdater::clear();
00295 }
00296
00297 void
00298 TMDC::fastClear(void) {
00299 unsigned i = 0;
00300 while (TMDCWire * w = _hitWires[i++])
00301 w->clear();
00302 i = 0;
00303 while (TMDCWireHit * h = _badHits[i++])
00304 ((TMDCWire *) h->wire())->clear();
00305
00306 _hitWires.removeAll();
00307 _axialHits.removeAll();
00308 _stereoHits.removeAll();
00309 HepAListDeleteAll(_hits);
00310 HepAListDeleteAll(_hitsMC);
00311 HepAListDeleteAll(_badHits);
00312
00313 TUpdater::clear();
00314 }
00315
00316 void
00317 TMDC::update(bool mcAnalysis) {
00318
00319
00320
00321
00322 fastClear();
00323
00324
00325
00326 unsigned nReccdc = MdcRecWirhitCol::getMdcRecWirhitCol()->size();
00327 #ifdef TRKRECO_DEBUG
00328 cout<<"size of MdcRecWirhit:"<<nReccdc<<endl;
00329 #endif
00330 for (unsigned i = 0; i < nReccdc; i++) {
00331
00332
00333
00334 MdcRec_wirhit* h = &(*MdcRecWirhitCol::getMdcRecWirhitCol())[i];
00335
00336
00337
00338
00339
00340
00341
00342 const MdcGeoWire* g = h->geo;
00343
00344
00345
00346
00347
00348
00349 TMDCWire * w = _wires[g->Id()];
00350 _hitWires.append(w);
00351
00352
00353 TMDCWireHit * hit = new TMDCWireHit(w, h, _fudgeFactor);
00354 _hits.append(hit);
00355
00356
00357 w->hit(hit);
00358
00359
00360
00361 if (w->axial()) _axialHits.append(hit);
00362 else _stereoHits.append(hit);
00363 }
00364
00365
00366 classification();
00367
00368
00369 if (mcAnalysis) updateMC();
00370
00371
00372 TUpdater::update();
00373 }
00374
00375 void
00376 TMDC::updateMC(void) {
00377
00378
00379 TTrackHEP::update();
00380
00381
00382 unsigned n = 0;
00383
00384 for (unsigned i = 0; i < MdcDatMcwirhitCol::getMdcDatMcwirhitCol()->size(); i++) {
00385
00386
00387
00388 MdcDat_mcwirhit* h = &(*MdcDatMcwirhitCol::getMdcDatMcwirhitCol())[i];
00389
00390
00391
00392 MdcRec_wirhit* whp = h->dat->rec;
00393
00394 TMDCWireHit * wh = 0;
00395 TMDCWire * w = 0;
00396 if (whp) {
00397 if (whp->stat & WireHitFindingValid) {
00398 unsigned n = _hits.length();
00399 unsigned j = (whp->id < n) ? whp->id : n;
00400 while (j) {
00401 --j;
00402 if (_hits[j]->reccdc() == whp) {
00403 wh = _hits[j];
00404 w = _wires[wh->wire()->id()];
00405 break;
00406 }
00407 }
00408 }
00409 }
00410 if (! w) {
00411
00412
00413
00414 const MdcGeoWire* g = h->geo;
00415 }
00416
00417
00418 TMDCWireHitMC * hit = new TMDCWireHitMC(w, wh, h);
00419 _hitsMC.append(hit);
00420 w->hit(hit);
00421 if (wh) wh->mc(hit);
00422
00423
00424
00425 TTrackHEP * hep = TTrackHEP::list()[h->hep->id];
00426 hit->_hep = hep;
00427 if (hep) hep->_hits.append(hit);
00428 else {
00429 std::cout << "TMDC::updateMC !!! mission impossible" << std::endl;
00430 std::cout << " This error will cause TrkReco crush";
00431 std::cout << std::endl;
00432 #ifdef TRKRECO_DEBUG_DETAIL
00433
00434
00435 std::cout << " TTrackHEP list length = ";
00436 std::cout << TTrackHEP::list().length() << std::endl;
00437
00438
00439 #endif
00440 }
00441 }
00442 }
00443
00444 void
00445 TMDC::classification(void) {
00446 unsigned n = _hits.length();
00447
00448 for (unsigned i = 0; i < n; i++) {
00449 TMDCWireHit * h = _hits[i];
00450 const TMDCWire * w = h->wire();
00451 unsigned state = h->state();
00452
00453
00454 const TMDCWire * neighbor[6];
00455 for (unsigned j = 0; j < 6; j++) neighbor[j] = w->neighbor(j);
00456
00457
00458
00459
00460
00461
00462
00463 unsigned pattern = 0;
00464 for (unsigned j = 0; j < 6; j++) {
00465 if (neighbor[j])
00466 if (neighbor[j]->hit())
00467 pattern += (1 << j);
00468 }
00469 state |= (pattern << WireHitNeighborHit);
00470
00471
00472 const TMDCWireHit * hr1 = neighbor[2]->hit();
00473 const TMDCWireHit * hl1 = neighbor[3]->hit();
00474 if ((hr1 == 0) && (hl1 == 0)) {
00475 state |= WireHitIsolated;
00476 }
00477 else {
00478 const TMDCWireHit * hr2 = neighbor[2]->neighbor(2)->hit();
00479 const TMDCWireHit * hl2 = neighbor[3]->neighbor(3)->hit();
00480 if ((hr2 == 0) && (hr1 != 0) && (hl1 == 0) ||
00481 (hl2 == 0) && (hl1 != 0) && (hr1 == 0))
00482 state |= WireHitIsolated;
00483 }
00484
00485
00486 unsigned superLayer = w->superLayerId();
00487 bool previous = false;
00488 bool next = false;
00489 if (neighbor[0] == 0) previous = true;
00490 else {
00491 if ((neighbor[0]->hit()) || neighbor[1]->hit())
00492 previous = true;
00493 }
00494 if (neighbor[5] == 0) next = true;
00495 else {
00496 if ((neighbor[4]->hit()) || neighbor[5]->hit())
00497 next = true;
00498 }
00499
00500 if (previous || next) state |= WireHitContinuous;
00501
00502
00503 if ((pattern == 34) || (pattern == 42) ||
00504 (pattern == 40) || (pattern == 10) ||
00505 (pattern == 35) || (pattern == 50))
00506 state |= WireHitPatternRight;
00507 else if ((pattern == 17) || (pattern == 21) ||
00508 (pattern == 20) || (pattern == 5) ||
00509 (pattern == 19) || (pattern == 49))
00510 state |= WireHitPatternLeft;
00511
00512
00513 h->state(state);
00514 }
00515 }
00516
00517 const AList<TMDCWireHit> &
00518 TMDC::axialHits(unsigned mask) const {
00519 if (! mask) return _axialHits;
00520 else if (mask == WireHitFindingValid) return _axialHits;
00521 std::cout << "TMDC::axialHits !!! unsupported mask given" << std::endl;
00522 return _axialHits;
00523 }
00524
00525 const AList<TMDCWireHit> &
00526 TMDC::stereoHits(unsigned mask) const {
00527 if (! mask) return _stereoHits;
00528 else if (mask == WireHitFindingValid) return _stereoHits;
00529 std::cout << "TMDC::stereoHits !!! unsupported mask given" << std::endl;
00530 return _stereoHits;
00531 }
00532
00533 const AList<TMDCWireHit> &
00534 TMDC::hits(unsigned mask) const {
00535 if (! mask) return _hits;
00536 else if (mask == WireHitFindingValid) return _hits;
00537 std::cout << "TMDC::hits !!! unsupported mask given" << std::endl;
00538 return _hits;
00539 }
00540
00541 const AList<TMDCWireHit> &
00542 TMDC::badHits(void) {
00543 if (! updated()) update();
00544 if (_badHits.length()) return _badHits;
00545
00546
00547
00548 unsigned nReccdc = MdcRecWirhitCol::getMdcRecWirhitCol()->size();
00549 for (unsigned i = 0; i < nReccdc; i++) {
00550
00551
00552
00553 MdcRec_wirhit* h = &(*MdcRecWirhitCol::getMdcRecWirhitCol())[i];
00554
00555
00556 if (h->stat & WireHitFindingValid) continue;
00557
00558
00559
00560
00561 const MdcGeoWire* g = h->geo;
00562
00563
00564
00565 TMDCWire * w = _wires[g->Id()];
00566
00567
00568 _badHits.append(new TMDCWireHit(w, h, _fudgeFactor));
00569 }
00570
00571 return _badHits;
00572 }
00573
00574 std::string
00575 TMDC::wireName(unsigned wireId) {
00576 if (superLayerId(wireId) % 2)
00577 return itostring(layerId(wireId)) + "=" +
00578 itostring(localId(wireId));
00579 return itostring(layerId(wireId)) + "-" + itostring(localId(wireId));
00580 }
00581
00582 std::string
00583 TMDC::wireName(const MdcGeoWire * const w) {
00584 if (! w) return std::string("no such a wire");
00585
00586 unsigned id = w->Id();
00587 return wireName(id);
00588 }
00589
00590
00591
00592
00593
00594
00595
00596
00597 unsigned
00598 TMDC::layerId(unsigned id) {
00599
00600
00601
00602
00603 if (id < 40) return 0;
00604 else if (id < 84) return 1;
00605 else if (id < 132) return 2;
00606 else if (id < 188) return 3;
00607
00608 else if (id < 252) return 4;
00609 else if (id < 324) return 5;
00610 else if (id < 404) return 6;
00611 else if (id < 484) return 7;
00612
00613 else if (id < 560) return 8;
00614 else if (id < 636) return 9;
00615 else if (id < 724) return 10;
00616 else if (id < 812) return 11;
00617
00618 else if (id < 912) return 12;
00619 else if (id < 1012) return 13;
00620 else if (id < 1124) return 14;
00621 else if (id < 1236) return 15;
00622
00623 else if (id < 1364) return 16;
00624 else if (id < 1492) return 17;
00625 else if (id < 1632) return 18;
00626 else if (id < 1772) return 19;
00627
00628 else if (id < 1932) return 20;
00629 else if (id < 2092) return 21;
00630 else if (id < 2252) return 22;
00631 else if (id < 2412) return 23;
00632
00633 else if (id < 2604) return 24;
00634 else if (id < 2796) return 25;
00635 else if (id < 2988) return 26;
00636 else if (id < 3180) return 27;
00637
00638 else if (id < 3388) return 28;
00639 else if (id < 3596) return 29;
00640 else if (id < 3804) return 30;
00641 else if (id < 4012) return 31;
00642
00643 else if (id < 4252) return 32;
00644 else if (id < 4492) return 33;
00645 else if (id < 4732) return 34;
00646 else if (id < 4972) return 35;
00647
00648 else if (id < 5228) return 36;
00649 else if (id < 5484) return 37;
00650 else if (id < 5740) return 38;
00651 else if (id < 5996) return 39;
00652
00653 else if (id < 6284) return 40;
00654 else if (id < 6572) return 41;
00655 else if (id < 6860) return 42;
00656
00657 return 9999;
00658 }
00659
00660 unsigned
00661 TMDC::layerId(const MdcGeoWire * const w) {
00662 if (! w) return 9999;
00663
00664
00665 return w->Layer();
00666 }
00667
00668
00669
00670
00671
00672
00673
00674
00675 unsigned
00676 TMDC::localId(unsigned id) {
00677 if (id < 40) return id;
00678 else if (id < 84) return id-40;
00679 else if (id < 132) return id-84;
00680 else if (id < 188) return id-132;
00681
00682 else if (id < 252) return id-188;
00683 else if (id < 324) return id-252;
00684 else if (id < 404) return id-324;
00685 else if (id < 484) return id-404;
00686
00687 else if (id < 560) return id-484;
00688 else if (id < 636) return id-560;
00689 else if (id < 724) return id-636;
00690 else if (id < 812) return id-724;
00691
00692 else if (id < 912) return id-812;
00693 else if (id < 1012) return id-912;
00694 else if (id < 1124) return id-1012;
00695 else if (id < 1236) return id-1124;
00696
00697 else if (id < 1364) return id-1236;
00698 else if (id < 1492) return id-1364;
00699 else if (id < 1632) return id-1492;
00700 else if (id < 1772) return id-1632;
00701
00702 else if (id < 1932) return id-1772;
00703 else if (id < 2092) return id-1932;
00704 else if (id < 2252) return id-2092;
00705 else if (id < 2412) return id-2252;
00706
00707 else if (id < 2604) return id-2412;
00708 else if (id < 2796) return id-2604;
00709 else if (id < 2988) return id-2796;
00710 else if (id < 3180) return id-2988;
00711
00712 else if (id < 3388) return id-3180;
00713 else if (id < 3596) return id-3388;
00714 else if (id < 3804) return id-3596;
00715 else if (id < 4012) return id-3804;
00716
00717 else if (id < 4252) return id-4012;
00718 else if (id < 4492) return id-4252;
00719 else if (id < 4732) return id-4492;
00720 else if (id < 4972) return id-4732;
00721
00722 else if (id < 5228) return id-4972;
00723 else if (id < 5484) return id-5228;
00724 else if (id < 5740) return id-5484;
00725 else if (id < 5996) return id-5740;
00726
00727 else if (id < 6284) return id-5996;
00728 else if (id < 6572) return id-6284;
00729 else if (id < 6860) return id-6572;
00730
00731 return 9999;
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747 }
00748
00749 unsigned
00750 TMDC::localId(const MdcGeoWire * const w) {
00751 if (! w) return 9999;
00752
00753
00754 return w->Cell();
00755 }
00756
00757
00758
00759
00760
00761
00762
00763
00764 unsigned
00765 TMDC::superLayerId(unsigned id) {
00766 if (id < 188) return 0;
00767 else if (id < 484) return 1;
00768 else if (id < 812) return 2;
00769 else if (id < 1236) return 3;
00770 else if (id < 1772) return 4;
00771 else if (id < 2412) return 5;
00772 else if (id < 3180) return 6;
00773 else if (id < 4012) return 7;
00774 else if (id < 4972) return 8;
00775 else if (id < 5996) return 9;
00776 else if (id < 6860) return 10;
00777
00778 return 9999;
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793 }
00794
00795 unsigned
00796 TMDC::superLayerId(const MdcGeoWire * const w) {
00797 if (! w) return 9999;
00798 unsigned id = w->Id();
00799 return superLayerId(id);
00800 }
00801
00802
00803
00804
00805
00806
00807
00808
00809 unsigned
00810 TMDC::superLayerId(const MdcGeoLayer * const l) {
00811 if (! l) return 9999;
00812 unsigned id = l->Id();
00813
00814 if(id < 44) return id/4;
00815 return 9999;
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830 }
00831
00832 unsigned
00833 TMDC::localLayerId(unsigned id) {
00834 if(id < 6860) return layerId(id)%4;
00835 return 9999;
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900 }
00901
00902 unsigned
00903 TMDC::localLayerId(const MdcGeoWire * const w) {
00904 if (! w) return 9999;
00905 return w->Layer()%4;
00906
00907
00908
00909 }
00910
00911
00912
00913
00914
00915
00916
00917
00918 unsigned
00919 TMDC::localLayerId(const MdcGeoLayer * const l) {
00920 if (! l) return 9999;
00921 unsigned id = l->Id();
00922 if (id < 44) return id%4;
00923 return 9999;
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988 }
00989
00990 unsigned
00991 TMDC::axialStereoLayerId(const MdcGeoLayer * const l) {
00992 if (! l) return 9999;
00993 unsigned id = l->Id();
00994
00995 if (id < 8) return id;
00996 else if (id < 20) return id-8;
00997 else if (id < 36) return id-12;
00998 else if (id < 43) return id-24;
00999
01000 return 9999;
01001 }
01002
01003 unsigned
01004 TMDC::layerId(unsigned as, unsigned id) {
01005
01006
01007 if (as == 0) {
01008 if (id < 12) return id + 8;
01009 else if (id < 19) return id + 24;
01010 return 9999;
01011 }
01012
01013
01014 if (id < 8) return id;
01015 else if (id < 24) return id + 12;
01016 return 9999;
01017 }
01018
01019 std::string
01020 TMDC::wireName(const MdcRec_wirhit & h) {
01021
01022
01023
01024 const MdcGeoWire* g = h.geo;
01025 return wireName(g);
01026 }
01027
01028 void
01029 TMDC::driftDistance(TMLink & l,
01030 const TTrack & t,
01031 unsigned flag,
01032 float t0Offset) {
01033
01034
01035 if (flag == 0) {
01036 if (l.hit()) {
01037 l.drift(0, l.hit()->drift(0));
01038 l.drift(1, l.hit()->drift(1));
01039 l.dDrift(0, l.hit()->dDrift(0));
01040 l.dDrift(1, l.hit()->dDrift(1));
01041 }
01042 else {
01043 l.drift(0, 0.);
01044 l.drift(1, 0.);
01045 l.dDrift(0, 0.);
01046 l.dDrift(1, 0.);
01047 }
01048
01049 return;
01050 }
01051
01052
01053 float tof = 0.;
01054 if (flag && 1) {
01055 int imass = 3;
01056 float tl = t.helix().a()[4];
01057 float f = sqrt(1. + tl * tl);
01058 float s = fabs(t.helix().curv()) * fabs(l.dPhi()) * f;
01059 float p = f / fabs(t.helix().a()[2]);
01060
01061 }
01062
01063
01064 if (! (flag && 2)) t0Offset = 0.;
01065
01066
01067 const TMDCWireHit & h = * l.hit();
01068 int wire = h.wire()->id();
01069 HepVector3D tp = t.helix().momentum(l.dPhi());
01070 float p[3] = {tp.x(), tp.y(), tp.z()};
01071 const HepPoint3D & onWire = l.positionOnWire();
01072 float x[3] = {onWire.x(), onWire.y(), onWire.z()};
01073 float time = h.reccdc()->tdc + t0Offset - tof;
01074 float dist;
01075 float edist;
01076 int prop = (flag & 4);
01077
01078
01079 int side = -1;
01080 if (side == 0) side = -1;
01081
01082
01083
01084
01085
01086
01087
01088
01089 l.drift(0, dist);
01090 l.dDrift(0, edist);
01091
01092
01093 side = 1;
01094
01095
01096
01097
01098
01099
01100
01101
01102 l.drift(1, dist);
01103 l.dDrift(1, edist);
01104
01105
01106 if (flag && 8) {
01107 float tanl = abs(p[2]) / tp.perp();
01108 float c;
01109 if ((tanl >= 0.0) && (tanl < 0.5)) c = -0.48 * tanl + 1.3;
01110 else if ((tanl >= 0.5) && (tanl < 1.0)) c = -0.28 * tanl + 1.2;
01111 else if ((tanl >= 1.0) && (tanl < 1.5)) c = -0.16 * tanl + 1.08;
01112 else c = 0.84;
01113
01114 l.dDrift(0, l.dDrift(0) * c);
01115 l.dDrift(1, l.dDrift(1) * c);
01116 }
01117 }