Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:57

0001 //-------------------------------------------------

0002 //

0003 //   Class: DTBtiChip

0004 //

0005 //   Description: Implementation of DTBtiChip

0006 //                trigger algorithm

0007 //

0008 //

0009 //   Author List:

0010 //   C. Grandi

0011 //   Modifications:

0012 //   S. Vanini

0013 //   30/IX/03 SV : wire dead time = ST added

0014 //   22/VI/04 SV : last trigger code update

0015 //   15/I/07  SV : new DTConfig setup

0016 //   17/III/07 SV : distp2 truncation bug fixed

0017 //--------------------------------------------------

0018 
0019 //-----------------------

0020 // This Class's Header --

0021 //-----------------------

0022 #include "L1Trigger/DTBti/interface/DTBtiChip.h"
0023 
0024 //-------------------------------

0025 // Collaborating Class Headers --

0026 //-------------------------------

0027 #include "L1Trigger/DTBti/interface/DTBtiHit.h"
0028 #include "L1Trigger/DTBti/interface/DTBtiTrig.h"
0029 
0030 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
0031 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
0032 #include <DataFormats/MuonDetId/interface/DTSuperLayerId.h>
0033 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0034 
0035 #include <DataFormats/DTDigi/interface/DTDigiCollection.h>
0036 //---------------

0037 // C++ Headers --

0038 //---------------

0039 #include <iostream>
0040 #include <cmath>
0041 
0042 using namespace std;
0043 
0044 //----------------

0045 // Constructors --

0046 //----------------

0047 
0048 DTBtiChip::DTBtiChip(DTBtiCard* card, DTTrigGeom* geom, int supl, int n, DTConfigBti* conf)
0049     : _card(card), _geom(geom), _config(conf) {
0050   // original constructor

0051   setSnap();
0052   reSumSet();
0053 
0054   // Debugging...

0055   if (config()->debug() > 2) {
0056     cout << "DTBtiChip constructor called for BTI number " << n;
0057     cout << " in superlayer " << supl << endl;
0058   }
0059 
0060   // reserve the appropriate amount of space for vectors

0061   for (auto& t : _trigs) {
0062     t.reserve(2);
0063   }
0064 
0065   for (auto& d : _digis) {
0066     d.reserve(10);
0067   }
0068   for (auto& h : _hits) {
0069     h.reserve(10);
0070   }
0071 
0072   //SV wire dead time init

0073   int DEAD = config()->DEADpar();
0074   for (auto& c : _busyStart_clock) {
0075     c = -DEAD - 1;
0076   }
0077 
0078   // Identifier

0079   DTChamberId sid = _geom->statId();
0080   _id = DTBtiId(sid, supl, n);
0081 
0082   //if(config()->trigSetupGeom() == 0){

0083   // set K acceptance in theta view for this BTI: 6 bit resolution....

0084   _MinKAcc = 0;
0085   _MaxKAcc = 63;
0086 
0087   /*       DTBtiId _id1 = DTBtiId(sid,supl,1);

0088 

0089        cout <<"superlayer" << _id.superlayer()<< "BTI1   " <<  _id1.bti()  << " BTICur " << _id.bti()<< endl;

0090        cout <<endl;

0091        GlobalPoint gp1 = _geom->CMSPosition(_id1);

0092        cout << "pos of BTI "<<  _id1.bti()  << gp1 <<endl;

0093        // K of tracks from vertex

0094        GlobalPoint gp = CMSPosition();

0095        cout << "pos of BTI" << _id.bti()  << gp <<endl;    

0096        cout << endl ; */
0097 
0098   //     // theta bti acceptance cut is in bti chip (no traco in theta!)

0099   //     // acceptance from orca geom: bti theta angle in CMS frame +-2 in K units

0100   //     if(_id.superlayer()==2){

0101   //       float distp2 = (int)(2*_geom->cellH()*config()->ST()/_geom->cellPitch());

0102   //       float K0 = config()->ST();

0103 
0104   // /*      DTBtiId _id1 = DTBtiId(sid,supl,1);

0105 
0106   //       cout << "BTI1   " <<  _id1.bti() << endl;

0107   //       cout << "BTICur " << _id.bti() <<endl;

0108   //       GlobalPoint gp1 = _geom->CMSPosition(_id1);

0109   //       cout << "pos of BTI 1 " << gp1 <<endl;*/

0110 
0111   //       // K of tracks from vertex

0112   //       GlobalPoint gp = CMSPosition();

0113   //       if(config()->debug()>3){

0114   //         cout << "Position: R=" << gp.perp() << "cm, Phi=" << gp.phi()*180/3.14159;

0115   //         cout << " deg, Z=" << gp.z() << " cm" << endl;

0116   //       }

0117   //       // CB TEST WITH NEW GEOMETRY

0118   //       // new geometry: modified wrt old due to specularity of theta SLs (still to understand on wheel zero) 19/06/06

0119   //       float theta;

0120   //       if (_id.wheel()==0){

0121   //    if(_id.sector()%4>1) theta = atan( gp.z()/gp.perp() );

0122   //    else theta = atan( -gp.z()/gp.perp() );

0123   //       }

0124   //       else theta = atan( fabs(gp.z())/gp.perp() );

0125   //       // .11 =TAN(6.3 deg) ==> k=2 (e' ancora vero? forse questa parte va aggiornata sena ripassare per gli angoli) 19/6/06

0126   //       float thetamin = theta-config()->KAccTheta()*0.055;

0127   //       float thetamax = theta+config()->KAccTheta()*0.055;

0128 
0129   //       float fktmin = tan(thetamin)*distp2 + K0;

0130   //       int ktmin = (fktmin>0) ? (int)(fktmin+0.5) : (int)(fktmin-0.5);

0131   //       float fktmax = tan(thetamax)*distp2 + K0;

0132   //       int ktmax = (fktmax>0) ? (int)(fktmax+0.5) : (int)(fktmax-0.5);

0133   // //      float fkbti = -gp.z()/gp.perp()*distp2;

0134   // //      int kbti = (fkbti>0) ? (int)(fkbti+0.5) : (int)(fkbti-0.5);

0135   // //      // K acceptance to point to vertex

0136   // //      int ktmin = kbti-config()->KAccTheta();  // minimum

0137   // //      int ktmax = kbti+config()->KAccTheta();  // maximum

0138   //       if(ktmin>_MinKAcc)_MinKAcc=ktmin;

0139   //       if(ktmax<_MaxKAcc)_MaxKAcc=ktmax;

0140   //     }

0141 
0142   //     // debugging

0143   //     if(config()->debug()>2){

0144   //       cout << "CMS position:" << CMSPosition() << endl;

0145   //       cout << "K acceptance:" << _MinKAcc << "," << _MaxKAcc << endl;

0146   //     }

0147   //     // end debugging

0148   // theta bti acceptance cut is in bti chip (no traco in theta!)

0149   // acceptance is determined about BTI angle wrt vertex with programmable value

0150   if (_id.superlayer() == 2) {
0151     // 091105 SV theta bti trigger angular acceptance in CMSSW is computed from geometry

0152     // (theta of the bti) +- a given tolerance config()->KAccTheta(): tolerance NOT in

0153     // hardware configuration. The hw tolerance is given in the system and the

0154     // overall acceptance is computed "before" data (CH,CL) is given to the MC

0155     // or written in the DB. No way to "extract" the tolerance from DB yet.

0156 
0157     if (_card->useAcceptParamFlag() == 0) {
0158       //float distp2 = (int)(2*_geom->cellH()*config()->ST()/_geom->cellPitch());   SV fix 17/III/07

0159       float distp2 = 2 * _geom->cellH() * config()->ST() / _geom->cellPitch();
0160       float K0 = config()->ST();
0161 
0162       // position of BTI 1 and of current one

0163       DTBtiId _id1 = DTBtiId(sid, supl, 1);
0164       GlobalPoint gp1 = _geom->CMSPosition(_id1);
0165       GlobalPoint gp = CMSPosition();
0166       if (config()->debug() > 3) {
0167         cout << "Position: R=" << gp.perp() << "cm, Phi=" << gp.phi() * 180 / 3.14159;
0168         cout << " deg, Z=" << gp.z() << " cm" << endl;
0169       }
0170       // new geometry: modified wrt old due to specularity of theta SLs --> fixed 6/9/06

0171       float theta;
0172       if (gp1.z() < 0.0)
0173         theta = atan(-(gp.z()) / gp.perp());
0174       else
0175         theta = atan((gp.z()) / gp.perp());
0176 
0177       // set BTI acceptance window : fixed wrt ORCA on 6/9/06

0178       float fktmin = tan(theta) * distp2 + K0;
0179       int ktmin = static_cast<int>(fktmin) - config()->KAccTheta();
0180       float fktmax = tan(theta) * distp2 + K0 + 1;
0181       int ktmax = static_cast<int>(fktmax) + config()->KAccTheta();
0182       if (ktmin > _MinKAcc)
0183         _MinKAcc = ktmin;
0184       if (ktmax < _MaxKAcc)
0185         _MaxKAcc = ktmax;
0186     }
0187     // 091105 SV acceptance is taken simply from CH, CL parameters

0188     else {
0189       _MinKAcc = config()->CL();
0190       _MaxKAcc = config()->CH();
0191     }
0192 
0193     // debugging

0194     if (config()->debug() > 2) {
0195       cout << "CMS position:" << CMSPosition() << endl;
0196       cout << "K acceptance (theta view):" << _MinKAcc << "," << _MaxKAcc << endl;
0197     }  // end debugging

0198 
0199   }  //end theta acceptance computation

0200 
0201   //}// end if trigSetupGeom=0

0202 
0203   //SV flag for initialization....

0204   init_done = 0;
0205 }
0206 
0207 //--------------

0208 // Destructor --

0209 //--------------

0210 DTBtiChip::~DTBtiChip() { clear(); }
0211 
0212 void DTBtiChip::add_digi(int cell, const DTDigi* digi) {
0213   if (_id.bti() < 1 || _id.bti() > _geom->nCell(superlayer()))
0214     return;
0215   if (cell < 1 || cell > 9) {
0216     cout << "DTBtiChip::add_digi : wrong cell number: " << cell;
0217     cout << ". Digi not added!" << endl;
0218     return;
0219   }
0220 
0221   int DEAD = config()->DEADpar();
0222   float stepTimeTdc = DTBtiHit::_stepTimeTdc;
0223 
0224   if (int(digi->countsTDC() / stepTimeTdc) - _busyStart_clock[cell - 1] > DEAD) {
0225     _busyStart_clock[cell - 1] = int(digi->countsTDC() / stepTimeTdc);
0226     _digis[cell - 1].push_back(digi);
0227 
0228     // debugging

0229     if (config()->debug() > 1) {
0230       cout << "DTBtiChip::add_digi: DTBtiChip # " << _id.bti() << " cell " << cell
0231            << " --> drift time (tdc units)= " << digi->countsTDC() << endl;
0232       digi->print();
0233     }
0234   } else {
0235     // debugging

0236     if (config()->debug() > 1)
0237       cout << "DTBtiChip::add_digi: DTBtiChip # " << _id.bti() << " cell " << cell
0238            << " in dead time -> digi not added! " << endl;
0239   }
0240 }
0241 
0242 void DTBtiChip::add_digi_clock(int cell, int digi) {
0243   if (cell < 1 || cell > 9) {
0244     cout << "DTBtiChip::add_digi_clock : wrong cell number: " << cell;
0245     cout << ". Digi not added!" << endl;
0246     return;
0247   }
0248 
0249   int DEAD = config()->DEADpar();
0250 
0251   if (digi - _busyStart_clock[cell - 1] > DEAD) {
0252     _busyStart_clock[cell - 1] = digi;
0253     _digis_clock[cell - 1].push_back(digi);
0254     // debugging

0255     if (config()->debug() > 1)
0256       cout << "DTBtiChip::add_digi_clock: DTBtiChip # " << number() << " cell " << cell << " --> clock time = " << digi
0257            << endl;
0258   } else {
0259     // debugging

0260     if (config()->debug() > 1)
0261       cout << "DTBtiChip::add_digi_clock: DTBtiChip # " << number() << " cell " << cell
0262            << " in dead time -> digi not added! " << endl;
0263   }
0264 }
0265 
0266 int DTBtiChip::nCellHit() const {
0267   int n = 0;
0268   int i = 0;
0269   for (auto const& d : _digis) {
0270     if (!d.empty())
0271       n++;
0272   }
0273   if (config()->debug() > 2) {
0274     cout << n << " cells with hits found:" << endl;
0275   }
0276   if (config()->debug() > 2) {
0277     for (i = 0; i < 9; i++) {
0278       for (auto const& d : _digis[i]) {
0279         cout << "DTBtiChip # " << _id.bti() << " cell " << i + 1;
0280         cout << " --> drift time (tdc units): " << d->countsTDC() << endl;
0281         d->print();
0282       }
0283     }
0284   }
0285   return n;
0286   /*

0287  //SV 2/IV/03 counting hits from _hits

0288   int n=0;

0289   int i=0;

0290   for(i=0;i<9;i++) {

0291     if( _hits[i].size() >0 ) n++;

0292   }

0293   if(config()->debug()>2) {

0294     cout << n << " cells with hits found:" << endl;

0295   }

0296   if(config()->debug()>2) {

0297     for(i=0;i<9;i++) {

0298       vector<const DTBtiHit*>::const_iterator p;

0299       for(p=_hits[i].begin();p<_hits[i].end();p++) {

0300         cout << "DTBtiChip # " << 

0301         number() << 

0302         " cell " << i+1;

0303         if((*p)->curTime()!=4000)

0304           cout << " --> drift time: " << (*p)->curTime() << endl;

0305         else

0306           cout << " --> clock time: " << (*p)->clockTime() << endl;

0307       }

0308     }

0309   }

0310   return n;

0311 */
0312 }
0313 
0314 void DTBtiChip::addTrig(int step, std::unique_ptr<DTBtiTrig> btitrig) {
0315   if (step >= DTConfig::NSTEPF && step <= DTConfig::NSTEPL) {
0316     if (config()->debug() > 3)
0317       cout << "DTBtiChip: adding trigger..." << endl;
0318     _trigs[step - DTConfig::NSTEPF].emplace_back(std::move(btitrig));
0319   } else {
0320     if (config()->debug() > 3) {
0321       cout << "DTBtiChip::addTrig: step " << step;
0322       cout << " outside range. Trigger not added" << endl;
0323     }
0324   }
0325 }
0326 
0327 int DTBtiChip::nTrig(int step) const {
0328   if (step < DTConfig::NSTEPF || step > DTConfig::NSTEPL) {
0329     cout << "DTBtiChip::nTrig: step out of range: " << step;
0330     cout << " 0 returned" << endl;
0331     return 0;
0332   }
0333   return _trigs[step - DTConfig::NSTEPF].size();
0334 }
0335 
0336 vector<std::unique_ptr<DTBtiTrig>> const& DTBtiChip::trigList(int step) const {
0337   if (step < DTConfig::NSTEPF || step > DTConfig::NSTEPL) {
0338     cout << "DTBtiChip::trigList: step out of range: " << step;
0339     cout << " empty pointer returned" << endl;
0340     //return 0;

0341   }
0342   return _trigs[step - DTConfig::NSTEPF];
0343 }
0344 
0345 DTBtiTrig const* DTBtiChip::trigger(int step, unsigned n) const {
0346   if (step < DTConfig::NSTEPF || step > DTConfig::NSTEPL) {
0347     cout << "DTBtiChip::trigger: step out of range: " << step;
0348     cout << " empty pointer returned" << endl;
0349     return nullptr;
0350   }
0351   if (n < 1 || n > _trigs[step - DTConfig::NSTEPF].size()) {
0352     cout << "DTBtiChip::trigger: requested trigger does not exist: " << n;
0353     cout << " empty pointer returned!" << endl;
0354     return nullptr;
0355   }
0356   auto p = _trigs[step - DTConfig::NSTEPF].begin();
0357   return (*(p + n - 1)).get();
0358 }
0359 
0360 DTBtiTrigData DTBtiChip::triggerData(int step, unsigned n) const {
0361   if (step < DTConfig::NSTEPF || step > DTConfig::NSTEPL) {
0362     cout << "DTBtiChip::triggerData: step out of range: " << step;
0363     cout << " dummy trigger returned" << endl;
0364     return DTBtiTrigData();
0365   }
0366   if (n < 1 || n > _trigs[step - DTConfig::NSTEPF].size()) {
0367     cout << "DTBtiChip::triggerData: requested trig. doesn't exist: " << n;
0368     cout << " dummy trigger returned!" << endl;
0369     return DTBtiTrigData();
0370   }
0371   auto p = _trigs[step - DTConfig::NSTEPF].begin();
0372   return (*(p + n - 1))->data();
0373 }
0374 
0375 void DTBtiChip::eraseTrigger(int step, unsigned n) {
0376   if (step < DTConfig::NSTEPF || step > DTConfig::NSTEPL) {
0377     cout << "DTBtiChip::eraseTrigger: step out of range: " << step;
0378     cout << " trigger not deleted!" << endl;
0379   }
0380   if (n < 1 || n > _trigs[step - DTConfig::NSTEPF].size()) {
0381     cout << "DTBtiChip::trigger: requested trigger does not exist: " << n;
0382     cout << " trigger not deleted!" << endl;
0383   }
0384   auto p = _trigs[step - DTConfig::NSTEPF].begin() + n - 1;
0385   _trigs[step - DTConfig::NSTEPF].erase(p);
0386 }
0387 
0388 void DTBtiChip::clear() {
0389   if (config()->debug() > 3)
0390     cout << "DTBtiChip::clear()" << endl;
0391 
0392   for (auto& d : _digis) {
0393     d.clear();
0394   }
0395   for (auto& c : _digis_clock) {
0396     c.clear();
0397   }
0398   for (auto& h : _hits) {
0399     h.clear();
0400   }
0401 
0402   for (auto& t : _trigs) {
0403     t.clear();
0404   }
0405 }
0406 
0407 void DTBtiChip::init() {
0408   if (config()->debug() > 3)
0409     cout << "DTBtiChip::init() -> initializing bti chip" << endl;
0410 
0411   _curStep = 0;
0412   for (int i = 0; i < 25; i++) {
0413     _sums[i] = 1000;
0414     _difs[i] = 1000;
0415   }
0416 
0417   for (int cell = 0; cell < 9; cell++) {
0418     int WEN = config()->WENflag(cell + 1);
0419     if (WEN == 1) {
0420       _thisStepUsedHit[cell] = nullptr;
0421       vector<const DTDigi*>::const_iterator p;
0422       for (p = _digis[cell].begin(); p < _digis[cell].end(); p++) {
0423         DTBtiHit* hit = new DTBtiHit(*p, config());
0424         //int clockTime = (int)(fabs(((*p)->time()+config()->SetupTime())/12.5));

0425         //DTBtiHit* hit = new DTBtiHit(clockTime,config());

0426         _hits[cell].push_back(hit);
0427       }
0428 
0429       //debugging

0430       if (config()->debug() > 2) {
0431         vector<DTBtiHit*>::const_iterator p1;
0432         for (p1 = _hits[cell].begin(); p1 < _hits[cell].end(); p1++) {
0433           cout << " Filling hit in cell " << cell + 1;
0434           if ((*p1)->curTime() != 4000)
0435             cout << " raw time in trigger: " << (*p1)->curTime() << endl;
0436           cout << " time (clock units): " << (*p1)->clockTime() << endl;
0437         }
0438       }
0439       // end debugging

0440     }
0441   }
0442 }
0443 
0444 void DTBtiChip::init_clock() {
0445   if (config()->debug() > 3)
0446     cout << "DTBtiChip::init_clock() -> initializing bti chip" << endl;
0447 
0448   init_done = 1;
0449   _curStep = 0;
0450 
0451   for (int i = 0; i < 25; i++) {
0452     _sums[i] = 1000;
0453     _difs[i] = 1000;
0454   }
0455 
0456   for (int cell = 0; cell < 9; cell++) {
0457     int WEN = config()->WENflag(cell + 1);
0458     if (WEN == 1) {
0459       _thisStepUsedHit[cell] = nullptr;
0460       for (unsigned int i = 0; i < _digis_clock[cell].size(); i++) {
0461         const int clockTime = (_digis_clock[cell])[i];
0462         DTBtiHit* hit = new DTBtiHit(clockTime, config());
0463         _hits[cell].push_back(hit);
0464       }
0465 
0466       //debugging

0467       if (config()->debug() > 2) {
0468         vector<DTBtiHit*>::const_iterator p1;
0469         for (p1 = _hits[cell].begin(); p1 < _hits[cell].end(); p1++) {
0470           cout << " Filling hit in cell " << cell + 1;
0471           if ((*p1)->curTime() != 4000)
0472             cout << " time: " << (*p1)->curTime() << endl;
0473           else
0474             cout << " time (clock units): " << (*p1)->clockTime() << endl;
0475         }
0476       }
0477       // end debugging

0478     }
0479   }
0480 }
0481 
0482 void DTBtiChip::run() {
0483   // Debugging...

0484   if (config()->debug() > 2) {
0485     cout << "DTBtiChip::run: Processing BTI " << _id.bti() << endl;
0486     cout << " in SL " << _id.superlayer() << endl;
0487   }
0488   // End debugging

0489 
0490   if (_id.bti() < 1 || _id.bti() > _geom->nCell(superlayer())) {
0491     if (config()->debug() > 1)
0492       cout << "DTBtiChip::run : wrong BTI number: " << _id.bti() << endl;
0493     return;
0494   }
0495 
0496   // run algorithm

0497   if (!init_done)
0498     init();
0499   if (nCellHit() < 3)
0500     return;  // check that at least 3 cell have hits

0501 
0502   for (int ints = 0; ints < 2 * DTConfig::NSTEPL; ints++) {  // 80 MHz

0503     tick();                                                  // Do a 12.5 ns step

0504 
0505     // In electronics equations are computed every 12.5 ns

0506     // but since triggers are searched for only every 25 ns, skip

0507     // also equation's computing at odd values of internal step

0508     if ((currentIntStep() / 2) * 2 != currentIntStep())
0509       continue;
0510     //if((currentIntStep()/2)*2==currentIntStep())continue;

0511 
0512     if (config()->debug() > 2) {
0513       cout << "DTBtiChip::run : internal step " << currentIntStep();
0514       cout << " number of JTRIG hits is " << _nStepUsedHits << endl;
0515     }
0516     if (currentStep() >= DTConfig::NSTEPF && _nStepUsedHits > 2) {
0517       // at least 3 good hits in this step -> run algorithm

0518       computeSums();
0519       computeEqs();
0520       findTrig();
0521     }
0522   }
0523   if (config()->LTS() > 0)
0524     doLTS();  // low trigger suppression

0525 }
0526 
0527 void DTBtiChip::tick() {
0528   //

0529   // fills the DTBtiChip registers ( _thisStepUsedHit[cell] )

0530   // for a given clock (Syncronizer and Shaper functionalities)

0531   //

0532 
0533   _curStep++;  // increase internal step (12.5 ns --> 80 MHz)

0534 
0535   // debugging

0536   if (config()->debug() > 2) {
0537     cout << "DTBtiChip::tick: internal step is now " << currentIntStep() << endl;
0538   }
0539   // end debugging

0540 
0541   // Loop on cells

0542   _nStepUsedHits = 0;
0543   for (int cell = 0; cell < 9; cell++) {
0544     // decrease drift time by 12.5 ns for each hit

0545     for (auto& h : _hits[cell]) {
0546       h->stepDownTime();
0547     }
0548 
0549     // loop on hits

0550     _thisStepUsedHit[cell] = nullptr;
0551     for (auto& h : _hits[cell]) {
0552       if (h->isDrifting()) {          // hit is drifting

0553         break;                        //   --> don't consider others

0554       } else if (h->isInsideReg()) {  // hit is already in registers

0555         _thisStepUsedHit[cell] = h;
0556         _nStepUsedHits++;
0557         // debugging

0558         if (config()->debug() > 2) {
0559           if (h->curTime() != 4000)
0560             cout << "DTBtiChip::tick: hit in register: time=" << h->curTime();
0561           else
0562             cout << "DTBtiChip::tick: hit in register! " << endl;
0563           cout << " jtrig=" << h->jtrig() << endl;
0564         }
0565         // end debugging

0566         break;  //   --> don't consider other triggers

0567       }
0568       // hit is not drifting and not in registers: it is gone out of register, but

0569       // jtrig value is still=ST ; save in array and consider next one if exists

0570     }  // end loop on cell hits

0571 
0572     // debugging...

0573     if (config()->debug() > 2) {
0574       if (_thisStepUsedHit[cell] != nullptr) {
0575         cout << "int. step=" << currentIntStep() << " cell=" << cell + 1;
0576         cout << " jtrig=" << _thisStepUsedHit[cell]->jtrig();
0577         if (_thisStepUsedHit[cell]->curTime() != 4000)
0578           cout << " (time=" << _thisStepUsedHit[cell]->curTime() << ")" << endl;
0579         else
0580           cout << endl;
0581       }
0582     }
0583     // end debugging

0584 
0585   }  // end loop on cells

0586 }
0587 
0588 void DTBtiChip::doLTS() {
0589   if (config()->debug() > 2)
0590     cout << "Do LTS" << endl;
0591   int lts = config()->LTS();
0592   int nbxlts = config()->SET();
0593 
0594   // Do LTS only on the requested SL

0595   //if (superlayer()==2 && lts==1) return;

0596   //if (superlayer()!=2 && lts==2) return;

0597   //new DTConfig: do LTS only is LTS!=0  --> somewhat redundant !

0598   if (lts == 0)
0599     return;
0600 
0601   // loop on steps

0602   for (int is = DTConfig::NSTEPF; is <= DTConfig::NSTEPL; is++) {
0603     if (nTrig(is) > 0) {                  // non empty step

0604       if (trigger(is, 1)->code() == 8) {  // HTRIG at this step

0605         // do LTS on nbxLTS[superlayer] following steps

0606         for (int js = is + 1; (js <= is + nbxlts && js <= DTConfig::NSTEPL); js++) {
0607           if (nTrig(js) > 0) {  // non empty step

0608             DTBtiTrig const* tr = trigger(js, 1);
0609             if (tr->code() < 8 && (lts == 1 || lts == 3)) {
0610               if (config()->debug() > 3)
0611                 cout << "LTS: erasing trigger!" << endl;
0612               eraseTrigger(js, 1);  // delete trigger

0613             }
0614           }
0615         }
0616         // do LTS on previous step

0617         if (is > DTConfig::NSTEPF && nTrig(is - 1) > 0) {  // non empty step

0618           DTBtiTrig const* tr = trigger(is - 1, 1);
0619           if (tr->code() < 8 && (lts == 2 || lts == 3)) {
0620             if (config()->debug() > 3)
0621               cout << "LTS: erasing trigger!" << endl;
0622             eraseTrigger(is - 1, 1);  // delete trigger

0623           }
0624         }
0625       }
0626     }
0627   }
0628 }
0629 
0630 int DTBtiChip::store(const int eq,
0631                      const int code,
0632                      const int K,
0633                      const int X,
0634                      float KeqAB,
0635                      float KeqBC,
0636                      float KeqCD,
0637                      float KeqAC,
0638                      float KeqBD,
0639                      float KeqAD) {
0640   // remove negative position triggers

0641   if (X < 0)
0642     return 0;
0643 
0644   // accept in range triggers (acceptances defined in constructor)

0645   if (K >= _MinKAcc && K <= _MaxKAcc) {
0646     int trig_step = currentStep();
0647 
0648     /*

0649     //SV test 27/I/2003 1-clock delay for critical patterns in default ACx configuration 

0650     int AC1 = config()->AccPattAC1(); //default 0

0651     int AC2 = config()->AccPattAC2(); //default 3

0652     int ACH = config()->AccPattACH(); //default 1

0653     int ACL = config()->AccPattACL(); //default 2     

0654 

0655     if(AC1==0 && AC2==3 && ACH==1 && ACL==2){

0656       if(eq==1 || eq==4 || eq==7 || eq==8 || eq==9 || eq==12 || eq==15

0657     || eq==19 || eq==22 || eq==23 || eq==24 || eq==25 || eq==27 )

0658        trig_step = currentStep()+1;

0659     }

0660 */
0661     //store strobe: SV no strobe defined for this setup SV 15/I/2007

0662     int strobe = -1;
0663 
0664     // create a new trigger

0665     float Keq[6] = {KeqAB, KeqBC, KeqCD, KeqAC, KeqBD, KeqAD};
0666     //DTBtiTrig* trg = new DTBtiTrig(this,code,K,X,currentStep(),eq);

0667     auto trg = std::make_unique<DTBtiTrig>(this, code, K, X, trig_step, eq, strobe, Keq);
0668 
0669     // store also the digis

0670     for (auto& h : _thisStepUsedHit) {
0671       if (h) {
0672         const DTDigi* digi = h->hitDigi();
0673         if (digi)
0674           trg->addDigi(digi);
0675       }
0676     }
0677 
0678     // Debugging...

0679     if (config()->debug() > 1)
0680       trg->print();
0681     // end debugging

0682 
0683     //addTrig(currentStep(),trg);

0684     addTrig(trig_step, std::move(trg));
0685 
0686     return 1;
0687   } else {
0688     // remove out of range triggers (acceptances defined in constructor)

0689     if (config()->debug() > 2) {
0690       cout << "DTBtiChip::store, REJECTED TRIGGER at step " << currentStep();
0691       cout << " allowed K range in theta view is: [";
0692       cout << _MinKAcc << "," << _MaxKAcc << "]";
0693       cout << "K value is " << K << endl;
0694     }
0695     return 0;
0696   }  //end else

0697 }  //end store

0698 
0699 void DTBtiChip::setSnap() {
0700   //set the internally calculated drift velocity parameters

0701   ST43 = config()->ST43();
0702   RE43 = config()->RE43();
0703   ST23 = int(double(ST43) / 2.);
0704   RE23 = (RE43 == 1) ? 2 : int(double(RE43) / 2.);
0705 
0706   ST = int(double(ST43) * 3. / 4. + double(RE43) * 1. / 4.);
0707   ST2 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 2.);
0708   ST3 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 3.);
0709   ST4 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 4.);
0710   ST5 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 5.);
0711   ST7 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 7.);
0712 
0713   if (config()->debug() > 3) {
0714     cout << "Snap register dump: " << endl;
0715     cout << "ST43 = " << ST43 << endl;
0716     cout << "RE43 = " << RE43 << endl;
0717     cout << "ST23 = " << ST23 << endl;
0718     cout << "RE23 = " << RE23 << endl;
0719     cout << "ST = " << ST << endl;
0720     cout << "ST2 = " << ST2 << endl;
0721     cout << "ST3 = " << ST3 << endl;
0722     cout << "ST4 = " << ST4 << endl;
0723     cout << "ST5 = " << ST5 << endl;
0724     cout << "ST7 = " << ST7 << endl;
0725   }
0726 }