00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "L1Trigger/DTBti/interface/DTBtiChip.h"
00023
00024
00025
00026
00027 #include "L1Trigger/DTBti/interface/DTBtiHit.h"
00028 #include "L1Trigger/DTBti/interface/DTBtiTrig.h"
00029
00030 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
00031 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
00032 #include <DataFormats/MuonDetId/interface/DTSuperLayerId.h>
00033 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00034
00035 #include <DataFormats/DTDigi/interface/DTDigiCollection.h>
00036
00037
00038
00039 #include <iostream>
00040 #include <cmath>
00041
00042 using namespace std;
00043
00044
00045
00046
00047
00048 DTBtiChip::DTBtiChip(DTTrigGeom* geom, int supl, int n, DTConfigBti* conf): _geom(geom), _config(conf) {
00049
00050
00051
00052 setSnap();
00053 reSumSet();
00054
00055
00056 if(config()->debug()>2){
00057 cout << "DTBtiChip constructor called for BTI number " << n;
00058 cout << " in superlayer " << supl << endl;
00059 }
00060
00061
00062 int i=0;
00063 for(i=0;i<DTConfig::NSTEPL - DTConfig::NSTEPF;i++) {
00064 _trigs[i].reserve(2);
00065 }
00066
00067 for(i=0;i<9;i++) {
00068 _digis[i].reserve(10);
00069 _hits[i].reserve(10);
00070 }
00071
00072
00073 int DEAD = config()->DEADpar();
00074 for(int cell=1; cell<=9; cell++){
00075 _busyStart_clock[cell-1] = - DEAD -1;
00076 }
00077
00078
00079 DTChamberId sid = _geom->statId();
00080 _id = DTBtiId(sid, supl, n);
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 _MinKAcc = 0;
00105 _MaxKAcc = 63;
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 if(_id.superlayer()==2){
00172
00173 float distp2 = 2*_geom->cellH()*config()->ST()/_geom->cellPitch();
00174 float K0 = config()->ST();
00175
00176
00177 DTBtiId _id1 = DTBtiId(sid,supl,1);
00178 GlobalPoint gp1 = _geom->CMSPosition(_id1);
00179 GlobalPoint gp = CMSPosition();
00180 if(config()->debug()>3){
00181 cout << "Position: R=" << gp.perp() << "cm, Phi=" << gp.phi()*180/3.14159;
00182 cout << " deg, Z=" << gp.z() << " cm" << endl;
00183 }
00184
00185 float theta;
00186 if(gp1.z() < 0.0)
00187 theta = atan( -(gp.z())/gp.perp() );
00188 else
00189 theta = atan( (gp.z())/gp.perp() );
00190
00191
00192 float fktmin = tan(theta)*distp2+K0 ;
00193 int ktmin = static_cast<int>(fktmin)-config()->KAccTheta();
00194 float fktmax = tan(theta)*distp2+K0+1;
00195 int ktmax = static_cast<int>(fktmax)+config()->KAccTheta();
00196 if(ktmin>_MinKAcc)_MinKAcc=ktmin;
00197 if(ktmax<_MaxKAcc)_MaxKAcc=ktmax;
00198 }
00199
00200
00201 if(config()->debug()>2){
00202 cout << "CMS position:" << CMSPosition() << endl;
00203 cout << "K acceptance:" << _MinKAcc << "," << _MaxKAcc << endl;
00204 }
00205
00206
00207
00208
00209
00210 init_done = 0;
00211
00212 }
00213
00214
00215 DTBtiChip::DTBtiChip(const DTBtiChip& bti) :
00216 _geom(bti._geom), _id(bti._id),
00217 _curStep(bti._curStep), _nStepUsedHits(bti._nStepUsedHits){
00218
00219 setSnap();
00220 reSumSet();
00221
00222 int i=0;
00223 for(i=0;i<DTConfig::NSTEPL - DTConfig::NSTEPF;i++) {
00224 _trigs[i].reserve(2);
00225 vector<DTBtiTrig*>::const_iterator p;
00226 for(p=bti._trigs[i].begin();p<bti._trigs[i].end();p++){
00227 _trigs[i].push_back(*p);
00228 }
00229 }
00230 for(i=0;i<9;i++) {
00231 _digis[i].reserve(10);
00232 vector<const DTDigi*>::const_iterator p;
00233 for(p=bti._digis[i].begin();p<bti._digis[i].end();p++){
00234 _digis[i].push_back(*p);
00235 }
00236 _hits[i].reserve(10);
00237 vector<DTBtiHit*>::const_iterator p1;
00238 for(p1=bti._hits[i].begin();p1<bti._hits[i].end();p1++){
00239 _hits[i].push_back(*p1);
00240 }
00241 _thisStepUsedTimes[i] = bti._thisStepUsedTimes[i];
00242 _thisStepUsedHit[i] = _thisStepUsedHit[i];
00243 }
00244 for(i=0;i<25;i++){
00245 _sums[i] = bti._sums[i];
00246 _difs[i] = bti._difs[i];
00247 }
00248 for(i=0;i<26;i++){
00249 int j = 0;
00250 for(j=0;j<6;j++){
00251 _Keq[i][j] = bti._Keq[i][j];
00252 }
00253 for(j=0;j<3;j++){
00254 _JTR[i][j] = bti._JTR[i][j];
00255 }
00256 for(j=0;j<2;j++){
00257 _Xeq[i][j] = bti._Xeq[i][j];
00258 _KTR[i][j] = bti._KTR[i][j];
00259 }
00260 }
00261 _MinKAcc = bti._MinKAcc;
00262 _MaxKAcc = bti._MaxKAcc;
00263
00264
00265
00266 }
00267
00268
00269
00270 DTBtiChip::~DTBtiChip(){
00271 clear();
00272 }
00273
00274
00275
00276
00277 DTBtiChip&
00278 DTBtiChip::operator=(const DTBtiChip& bti) {
00279 if(this != &bti){
00280 _geom = bti._geom;
00281 _id = bti._id;
00282 _curStep = bti._curStep;
00283 _nStepUsedHits = bti._nStepUsedHits;
00284 int i=0;
00285 for(i=0;i<DTConfig::NSTEPL - DTConfig::NSTEPF;i++) {
00286 _trigs[i].reserve(2);
00287 vector<DTBtiTrig*>::const_iterator p;
00288 for(p=bti._trigs[i].begin();p<bti._trigs[i].end();p++){
00289 _trigs[i].push_back(*p);
00290 }
00291 }
00292 for(i=0;i<9;i++) {
00293 _digis[i].reserve(10);
00294 vector<const DTDigi*>::const_iterator p;
00295 for(p=bti._digis[i].begin();p<bti._digis[i].end();p++){
00296 _digis[i].push_back(*p);
00297 }
00298 _hits[i].reserve(10);
00299 vector<DTBtiHit*>::const_iterator p1;
00300 for(p1=bti._hits[i].begin();p1<bti._hits[i].end();p1++){
00301 _hits[i].push_back(*p1);
00302 }
00303 _thisStepUsedTimes[i] = bti._thisStepUsedTimes[i];
00304 _thisStepUsedHit[i] = _thisStepUsedHit[i];
00305 }
00306 for(i=0;i<25;i++){
00307 _sums[i] = bti._sums[i];
00308 _difs[i] = bti._difs[i];
00309 }
00310 for(i=0;i<26;i++){
00311 int j = 0;
00312 for(j=0;j<6;j++){
00313 _Keq[i][j] = bti._Keq[i][j];
00314 }
00315 for(j=0;j<3;j++){
00316 _JTR[i][j] = bti._JTR[i][j];
00317 }
00318 for(j=0;j<2;j++){
00319 _Xeq[i][j] = bti._Xeq[i][j];
00320 _KTR[i][j] = bti._KTR[i][j];
00321 }
00322 }
00323 _MinKAcc = bti._MinKAcc;
00324 _MaxKAcc = bti._MaxKAcc;
00325 }
00326 return *this;
00327 }
00328
00329 void
00330 DTBtiChip::add_digi(int cell, const DTDigi* digi) {
00331
00332 if(_id.bti()<1 || _id.bti() >_geom->nCell(superlayer()))return;
00333 if(cell<1 || cell>9){
00334 cout << "DTBtiChip::add_digi : wrong cell number: " << cell;
00335 cout << ". Digi not added!" << endl;
00336 return;
00337 }
00338
00339 int DEAD = config()->DEADpar();
00340 float stepTimeTdc = DTBtiHit::_stepTimeTdc;
00341
00342
00343 if( int(digi->countsTDC()/stepTimeTdc) - _busyStart_clock[cell-1] > DEAD ){
00344 _busyStart_clock[cell-1] = int(digi->countsTDC()/stepTimeTdc);
00345 _digis[cell-1].push_back(digi);
00346
00347
00348 if(config()->debug()>1){
00349 cout << "DTBtiChip::add_digi: DTBtiChip # " <<_id.bti() <<
00350 " cell " << cell << " --> drift time (tdc units)= " << digi->countsTDC()<< endl;
00351 digi->print();
00352 }
00353 }
00354 else {
00355
00356 if(config()->debug()>1)
00357 cout << "DTBtiChip::add_digi: DTBtiChip # " <<_id.bti() <<
00358 " cell " << cell << " in dead time -> digi not added! " << endl;
00359 }
00360
00361 }
00362
00363
00364 void
00365 DTBtiChip::add_digi_clock(int cell, int digi) {
00366
00367 if(cell<1 || cell>9){
00368 cout << "DTBtiChip::add_digi_clock : wrong cell number: " << cell;
00369 cout << ". Digi not added!" << endl;
00370 return;
00371 }
00372
00373 int DEAD = config()->DEADpar();
00374
00375 if( digi - _busyStart_clock[cell-1] > DEAD ){
00376 _busyStart_clock[cell-1] = digi;
00377 _digis_clock[cell-1].push_back(digi);
00378
00379 if(config()->debug()>1)
00380 cout << "DTBtiChip::add_digi_clock: DTBtiChip # " <<number() <<
00381 " cell " << cell << " --> clock time = " << digi << endl;
00382 }
00383 else{
00384
00385 if(config()->debug()>1)
00386 cout << "DTBtiChip::add_digi_clock: DTBtiChip # " << number() <<
00387 " cell " << cell << " in dead time -> digi not added! " << endl;
00388 }
00389 }
00390
00391
00392 int
00393 DTBtiChip::nCellHit() const {
00394 int n=0;
00395 int i=0;
00396 for(i=0;i<9;i++) {
00397 if( _digis[i].size() >0 ) n++;
00398 }
00399 if(config()->debug()>2) {
00400 cout << n << " cells with hits found:" << endl;
00401 }
00402 if(config()->debug()>2) {
00403 for(i=0;i<9;i++) {
00404 vector<const DTDigi*>::const_iterator p;
00405 for(p=_digis[i].begin();p<_digis[i].end();p++) {
00406 cout << "DTBtiChip # " <<
00407 _id.bti() <<
00408 " cell " << i+1;
00409 cout << " --> drift time (tdc units): " << (*p)->countsTDC() << endl;
00410 (*p)->print();
00411 }
00412 }
00413 }
00414 return n;
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441 }
00442
00443 void
00444 DTBtiChip::addTrig(int step, DTBtiTrig* btitrig) {
00445 if(step>=DTConfig::NSTEPF&&step<=DTConfig::NSTEPL){
00446 if(config()->debug()>3)
00447 cout << "DTBtiChip: adding trigger..." <<endl;
00448 _trigs[step-DTConfig::NSTEPF].push_back(btitrig);
00449 } else {
00450 if(config()->debug()>3){
00451 cout << "DTBtiChip::addTrig: step " << step ;
00452 cout << " outside range. Trigger not added" << endl;
00453 }
00454 }
00455 }
00456
00457 int
00458 DTBtiChip::nTrig(int step) const {
00459 if(step<DTConfig::NSTEPF||step>DTConfig::NSTEPL){
00460 cout << "DTBtiChip::nTrig: step out of range: " << step ;
00461 cout << " 0 returned" << endl;
00462 return 0;
00463 }
00464 return _trigs[step-DTConfig::NSTEPF].size();
00465 }
00466
00467 vector<DTBtiTrig*>
00468 DTBtiChip::trigList(int step) const {
00469 if(step<DTConfig::NSTEPF||step>DTConfig::NSTEPL){
00470 cout << "DTBtiChip::trigList: step out of range: " << step ;
00471 cout << " empty pointer returned" << endl;
00472
00473 }
00474 return _trigs[step-DTConfig::NSTEPF];
00475 }
00476
00477 DTBtiTrig*
00478 DTBtiChip::trigger(int step, unsigned n) const {
00479 if(step<DTConfig::NSTEPF||step>DTConfig::NSTEPL){
00480 cout << "DTBtiChip::trigger: step out of range: " << step ;
00481 cout << " empty pointer returned" << endl;
00482 return 0;
00483 }
00484 if(n<1 || n>_trigs[step-DTConfig::NSTEPF].size()) {
00485 cout << "DTBtiChip::trigger: requested trigger does not exist: " << n;
00486 cout << " empty pointer returned!" << endl;
00487 return 0;
00488 }
00489 vector<DTBtiTrig*>::const_iterator p = _trigs[step-DTConfig::NSTEPF].begin();
00490 return (*(p+n-1));
00491 }
00492
00493 DTBtiTrigData
00494 DTBtiChip::triggerData(int step, unsigned n) const {
00495 if(step<DTConfig::NSTEPF||step>DTConfig::NSTEPL){
00496 cout << "DTBtiChip::triggerData: step out of range: " << step ;
00497 cout << " dummy trigger returned" << endl;
00498 return DTBtiTrigData();
00499 }
00500 if(n<1 || n>_trigs[step-DTConfig::NSTEPF].size()) {
00501 cout << "DTBtiChip::triggerData: requested trig. doesn't exist: " << n;
00502 cout << " dummy trigger returned!" << endl;
00503 return DTBtiTrigData();
00504 }
00505 vector<DTBtiTrig*>::const_iterator p = _trigs[step-DTConfig::NSTEPF].begin();
00506 return (*(p+n-1))->data();
00507 }
00508
00509 void
00510 DTBtiChip::eraseTrigger(int step, unsigned n) {
00511 if(step<DTConfig::NSTEPF||step>DTConfig::NSTEPL){
00512 cout << "DTBtiChip::eraseTrigger: step out of range: " << step ;
00513 cout << " trigger not deleted!" << endl;
00514 }
00515 if(n<1 || n>_trigs[step-DTConfig::NSTEPF].size()) {
00516 cout << "DTBtiChip::trigger: requested trigger does not exist: " << n;
00517 cout << " trigger not deleted!" << endl;
00518 }
00519 vector<DTBtiTrig*>::iterator p = _trigs[step-DTConfig::NSTEPF].begin()+n-1;
00520 if(&(*p))delete (*p);
00521 _trigs[step-DTConfig::NSTEPF].erase(p);
00522 }
00523
00524 void
00525 DTBtiChip::clear() {
00526
00527 if(config()->debug()>3)
00528 cout << "DTBtiChip::clear()" << endl;
00529
00530 for(int c=0;c<9;c++) {
00531
00532 _digis[c].clear();
00533 _digis_clock[c].clear();
00534
00535 vector<DTBtiHit*>::iterator p;
00536 for(p=_hits[c].begin();p<_hits[c].end();p++){
00537 delete (*p);
00538 }
00539 _hits[c].clear();
00540 }
00541
00542 vector<DTBtiTrig*>::iterator p1;
00543 for(int is=0;is<DTConfig::NSTEPL-DTConfig::NSTEPF+1;is++){
00544 for(p1=_trigs[is].begin();p1<_trigs[is].end();p1++){
00545 delete (*p1);
00546 }
00547 _trigs[is].clear();
00548 }
00549 }
00550
00551 void
00552 DTBtiChip::init() {
00553
00554 if(config()->debug()>3)
00555 cout << "DTBtiChip::init() -> initializing bti chip" << endl;
00556
00557 _curStep=0;
00558 for(int i=0;i<25;i++) {
00559 _sums[i] = 1000;
00560 _difs[i] = 1000;
00561 }
00562
00563 for(int cell=0;cell<9;cell++) {
00564 int WEN = config()->WENflag(cell+1);
00565 if( WEN==1 ){
00566 _thisStepUsedHit[cell]=0;
00567 vector<const DTDigi*>::const_iterator p;
00568 for(p=_digis[cell].begin();p<_digis[cell].end();p++){
00569 DTBtiHit* hit = new DTBtiHit(*p,config());
00570
00571
00572 _hits[cell].push_back(hit);
00573 }
00574
00575
00576 if(config()->debug()>2){
00577 vector<DTBtiHit*>::const_iterator p1;
00578 for(p1=_hits[cell].begin();p1<_hits[cell].end();p1++){
00579 cout << " Filling hit in cell " << cell+1;
00580 if((*p1)->curTime()!=4000)
00581 cout << " raw time in trigger: " << (*p1)->curTime() << endl;
00582 cout << " time (clock units): " << (*p1)->clockTime() << endl;
00583 }
00584 }
00585
00586 }
00587 }
00588 }
00589
00590
00591 void
00592 DTBtiChip::init_clock() {
00593
00594 if(config()->debug()>3)
00595 cout << "DTBtiChip::init_clock() -> initializing bti chip" << endl;
00596
00597 init_done = 1;
00598 _curStep=0;
00599
00600 for(int i=0;i<25;i++) {
00601 _sums[i] = 1000;
00602 _difs[i] = 1000;
00603 }
00604
00605 for(int cell=0;cell<9;cell++) {
00606 int WEN = config()->WENflag(cell+1);
00607 if( WEN==1 ){
00608 _thisStepUsedHit[cell]=0;
00609 for(int i=0; i<_digis_clock[cell].size(); i++){
00610 const int clockTime = (_digis_clock[cell])[i];
00611 DTBtiHit* hit = new DTBtiHit(clockTime,config());
00612 _hits[cell].push_back(hit);
00613 }
00614
00615
00616 if(config()->debug()>2){
00617 vector<DTBtiHit*>::const_iterator p1;
00618 for(p1=_hits[cell].begin();p1<_hits[cell].end();p1++){
00619 cout << " Filling hit in cell " << cell+1;
00620 if((*p1)->curTime()!=4000)
00621 cout << " time: " << (*p1)->curTime() << endl;
00622 else
00623 cout << " time (clock units): " << (*p1)->clockTime() << endl;
00624 }
00625 }
00626
00627 }
00628 }
00629 }
00630
00631
00632 void
00633 DTBtiChip::run() {
00634
00635
00636 if(config()->debug()>2){
00637 cout << "DTBtiChip::run: Processing BTI " << _id.bti() << endl;
00638 cout << " in SL " << _id.superlayer() << endl;
00639 }
00640
00641
00642 if(_id.bti()<1 || _id.bti() >_geom->nCell(superlayer())) {
00643 if(config()->debug()>1)
00644 cout << "DTBtiChip::run : wrong BTI number: " << _id.bti() << endl;
00645 return;
00646 }
00647
00648
00649 if(!init_done)
00650 init();
00651 if( nCellHit()<3 ) return;
00652
00653 for(int ints=0; ints<2*DTConfig::NSTEPL; ints++) {
00654 tick();
00655
00656
00657
00658
00659 if((currentIntStep()/2)*2!=currentIntStep())continue;
00660
00661
00662
00663 if(config()->debug()>2){
00664 cout << "DTBtiChip::run : internal step " << currentIntStep();
00665 cout << " number of JTRIG hits is " << _nStepUsedHits << endl;
00666 }
00667 if(currentStep()>=DTConfig::NSTEPF && _nStepUsedHits>2) {
00668
00669 computeSums();
00670 computeEqs();
00671 findTrig();
00672 }
00673 }
00674 if( config()->LTS()>0 ) doLTS();
00675 }
00676
00677 void
00678 DTBtiChip::tick() {
00679
00680
00681
00682
00683
00684 _curStep++;
00685
00686
00687 if(config()->debug()>2){
00688 cout << "DTBtiChip::tick: internal step is now " << currentIntStep()<< endl;
00689 }
00690
00691
00692
00693 _nStepUsedHits=0;
00694 for(int cell=0;cell<9;cell++) {
00695
00696
00697 vector<DTBtiHit*>::const_iterator p;
00698 for(p=_hits[cell].begin();p<_hits[cell].end();p++){
00699 (*p)->stepDownTime();
00700 }
00701
00702
00703 _thisStepUsedHit[cell]=0;
00704 for(p=_hits[cell].begin();p<_hits[cell].end();p++){
00705 if ( (*p)->isDrifting() ) {
00706 break;
00707 } else if( (*p)->isInsideReg() ) {
00708 _thisStepUsedHit[cell]=(*p);
00709 _nStepUsedHits++;
00710
00711 if(config()->debug()>2){
00712 if((*p)->curTime() != 4000)
00713 cout << "DTBtiChip::tick: hit in register: time=" << (*p)->curTime();
00714 else
00715 cout << "DTBtiChip::tick: hit in register! " << endl;
00716 cout << " jtrig=" << (*p)->jtrig() << endl;
00717
00718 }
00719
00720 break;
00721 }
00722
00723
00724 }
00725
00726
00727 if(config()->debug()>2){
00728 if(_thisStepUsedHit[cell]!=0){
00729 cout << "int. step=" << currentIntStep() << " cell=" << cell+1;
00730 cout << " jtrig=" << _thisStepUsedHit[cell]->jtrig();
00731 if( _thisStepUsedHit[cell]->curTime() != 4000 )
00732 cout << " (time=" << _thisStepUsedHit[cell]->curTime() << ")" << endl;
00733 else
00734 cout << endl;
00735 }
00736 }
00737
00738
00739 }
00740
00741 }
00742
00743 void
00744 DTBtiChip::doLTS() {
00745
00746 if(config()->debug()>2)
00747 cout<<"Do LTS"<<endl;
00748 int lts = config()->LTS();
00749 int nbxlts = config()->SET();
00750
00751
00752
00753
00754
00755 if (lts==0) return;
00756
00757
00758 for(int is=DTConfig::NSTEPF; is<=DTConfig::NSTEPL; is++) {
00759 if(nTrig(is)>0) {
00760 if( trigger(is,1)->code()==8 ) {
00761
00762 for(int js=is+1;(js<=is+nbxlts&&js<=DTConfig::NSTEPL);js++){
00763 if(nTrig(js)>0) {
00764 DTBtiTrig* tr = trigger(js,1);
00765 if( tr->code()<8 && (lts==1 || lts==3)) {
00766 if(config()->debug()>3)
00767 cout<<"LTS: erasing trigger!"<<endl;
00768 eraseTrigger(js,1);
00769 }
00770 }
00771 }
00772
00773 if(is>DTConfig::NSTEPF && nTrig(is-1)>0) {
00774 DTBtiTrig* tr = trigger(is-1,1);
00775 if( tr->code()<8 && (lts==2 || lts==3) ) {
00776 if(config()->debug()>3)
00777 cout<<"LTS: erasing trigger!"<<endl;
00778 eraseTrigger(is-1,1);
00779 }
00780 }
00781
00782 }
00783 }
00784 }
00785 }
00786
00787 int
00788 DTBtiChip::store(const int eq, const int code, const int K, const int X,
00789 float KeqAB, float KeqBC, float KeqCD,
00790 float KeqAC, float KeqBD, float KeqAD) {
00791
00792
00793 if(X<0)return 0;
00794
00795
00796
00797 if(K>=_MinKAcc && K<=_MaxKAcc)
00798 {
00799 int trig_step = currentStep();
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815 int strobe=-1;
00816
00817
00818 float Keq[6] = {KeqAB,KeqBC,KeqCD,KeqAC,KeqBD,KeqAD};
00819
00820 DTBtiTrig* trg = new DTBtiTrig(this,code,K,X,trig_step,eq,strobe,Keq);
00821
00822
00823 for(int c=0; c<9; c++) {
00824 if(_thisStepUsedHit[c]) {
00825 const DTDigi* digi = _thisStepUsedHit[c]->hitDigi();
00826 if(digi)
00827 trg->addDigi(digi);
00828 }
00829 }
00830
00831
00832 addTrig(trig_step,trg);
00833
00834
00835 if(config()->debug()>1)
00836 trg->print();
00837
00838
00839 return 1;
00840 }
00841 else{
00842
00843 if(config()->debug()>2){
00844 cout << "DTBtiChip::store, at step "<< currentStep();
00845 cout << " allowed K range is: [";
00846 cout << _MinKAcc << ","<< _MaxKAcc << "]";
00847 cout << "K value is " << K << endl;
00848 }
00849 return 0;
00850 }
00851 }
00852
00853
00854 void
00855 DTBtiChip::setSnap(){
00856
00857
00858 ST43 = config()->ST43();
00859 RE43 = config()->RE43();
00860 ST23 = int(double(ST43)/2.);
00861 RE23 = (RE43==1) ? 2 : int(double(RE43)/2.);
00862
00863
00864 ST = int( double(ST43) * 3./4. + double(RE43) * 1./4. );
00865 ST2 = int( (double(ST43) * 3./4. + double(RE43) * 1./4.)*2. );
00866 ST3 = int( (double(ST43) * 3./4. + double(RE43) * 1./4.)*3. );
00867 ST4 = int( (double(ST43) * 3./4. + double(RE43) * 1./4.)*4. );
00868 ST5 = int( (double(ST43) * 3./4. + double(RE43) * 1./4.)*5. );
00869 ST7 = int( (double(ST43) * 3./4. + double(RE43) * 1./4.)*7. );
00870
00871 if(config()->debug()>3){
00872 cout << "Snap register dump: " << endl;
00873 cout << "ST43 = " << ST43 << endl;
00874 cout << "RE43 = " << RE43 << endl;
00875 cout << "ST23 = " << ST23 << endl;
00876 cout << "RE23 = " << RE23 << endl;
00877 cout << "ST = " << ST << endl;
00878 cout << "ST2 = " << ST2 << endl;
00879 cout << "ST3 = " << ST3 << endl;
00880 cout << "ST4 = " << ST4 << endl;
00881 cout << "ST5 = " << ST5 << endl;
00882 cout << "ST7 = " << ST7 << endl;
00883 }
00884 }
00885