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