CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTBtiChip.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: DTBtiChip
4 //
5 // Description: Implementation of DTBtiChip
6 // trigger algorithm
7 //
8 //
9 // Author List:
10 // C. Grandi
11 // Modifications:
12 // S. Vanini
13 // 30/IX/03 SV : wire dead time = ST added
14 // 22/VI/04 SV : last trigger code update
15 // 15/I/07 SV : new DTConfig setup
16 // 17/III/07 SV : distp2 truncation bug fixed
17 //--------------------------------------------------
18 
19 //-----------------------
20 // This Class's Header --
21 //-----------------------
23 
24 //-------------------------------
25 // Collaborating Class Headers --
26 //-------------------------------
29 
34 
36 //---------------
37 // C++ Headers --
38 //---------------
39 #include <iostream>
40 #include <cmath>
41 
42 using namespace std;
43 
44 //----------------
45 // Constructors --
46 //----------------
47 
49  : _card(card), _geom(geom), _config(conf) {
50  // original constructor
51  setSnap();
52  reSumSet();
53 
54  // Debugging...
55  if (config()->debug() > 2) {
56  cout << "DTBtiChip constructor called for BTI number " << n;
57  cout << " in superlayer " << supl << endl;
58  }
59 
60  // reserve the appropriate amount of space for vectors
61  for (auto& t : _trigs) {
62  t.reserve(2);
63  }
64 
65  for (auto& d : _digis) {
66  d.reserve(10);
67  }
68  for (auto& h : _hits) {
69  h.reserve(10);
70  }
71 
72  //SV wire dead time init
73  int DEAD = config()->DEADpar();
74  for (auto& c : _busyStart_clock) {
75  c = -DEAD - 1;
76  }
77 
78  // Identifier
79  DTChamberId sid = _geom->statId();
80  _id = DTBtiId(sid, supl, n);
81 
82  //if(config()->trigSetupGeom() == 0){
83  // set K acceptance in theta view for this BTI: 6 bit resolution....
84  _MinKAcc = 0;
85  _MaxKAcc = 63;
86 
87  /* DTBtiId _id1 = DTBtiId(sid,supl,1);
88 
89  cout <<"superlayer" << _id.superlayer()<< "BTI1 " << _id1.bti() << " BTICur " << _id.bti()<< endl;
90  cout <<endl;
91  GlobalPoint gp1 = _geom->CMSPosition(_id1);
92  cout << "pos of BTI "<< _id1.bti() << gp1 <<endl;
93  // K of tracks from vertex
94  GlobalPoint gp = CMSPosition();
95  cout << "pos of BTI" << _id.bti() << gp <<endl;
96  cout << endl ; */
97 
98  // // theta bti acceptance cut is in bti chip (no traco in theta!)
99  // // acceptance from orca geom: bti theta angle in CMS frame +-2 in K units
100  // if(_id.superlayer()==2){
101  // float distp2 = (int)(2*_geom->cellH()*config()->ST()/_geom->cellPitch());
102  // float K0 = config()->ST();
103 
104  // /* DTBtiId _id1 = DTBtiId(sid,supl,1);
105 
106  // cout << "BTI1 " << _id1.bti() << endl;
107  // cout << "BTICur " << _id.bti() <<endl;
108  // GlobalPoint gp1 = _geom->CMSPosition(_id1);
109  // cout << "pos of BTI 1 " << gp1 <<endl;*/
110 
111  // // K of tracks from vertex
112  // GlobalPoint gp = CMSPosition();
113  // if(config()->debug()>3){
114  // cout << "Position: R=" << gp.perp() << "cm, Phi=" << gp.phi()*180/3.14159;
115  // cout << " deg, Z=" << gp.z() << " cm" << endl;
116  // }
117  // // CB TEST WITH NEW GEOMETRY
118  // // new geometry: modified wrt old due to specularity of theta SLs (still to understand on wheel zero) 19/06/06
119  // float theta;
120  // if (_id.wheel()==0){
121  // if(_id.sector()%4>1) theta = atan( gp.z()/gp.perp() );
122  // else theta = atan( -gp.z()/gp.perp() );
123  // }
124  // else theta = atan( fabs(gp.z())/gp.perp() );
125  // // .11 =TAN(6.3 deg) ==> k=2 (e' ancora vero? forse questa parte va aggiornata sena ripassare per gli angoli) 19/6/06
126  // float thetamin = theta-config()->KAccTheta()*0.055;
127  // float thetamax = theta+config()->KAccTheta()*0.055;
128 
129  // float fktmin = tan(thetamin)*distp2 + K0;
130  // int ktmin = (fktmin>0) ? (int)(fktmin+0.5) : (int)(fktmin-0.5);
131  // float fktmax = tan(thetamax)*distp2 + K0;
132  // int ktmax = (fktmax>0) ? (int)(fktmax+0.5) : (int)(fktmax-0.5);
133  // // float fkbti = -gp.z()/gp.perp()*distp2;
134  // // int kbti = (fkbti>0) ? (int)(fkbti+0.5) : (int)(fkbti-0.5);
135  // // // K acceptance to point to vertex
136  // // int ktmin = kbti-config()->KAccTheta(); // minimum
137  // // int ktmax = kbti+config()->KAccTheta(); // maximum
138  // if(ktmin>_MinKAcc)_MinKAcc=ktmin;
139  // if(ktmax<_MaxKAcc)_MaxKAcc=ktmax;
140  // }
141 
142  // // debugging
143  // if(config()->debug()>2){
144  // cout << "CMS position:" << CMSPosition() << endl;
145  // cout << "K acceptance:" << _MinKAcc << "," << _MaxKAcc << endl;
146  // }
147  // // end debugging
148  // theta bti acceptance cut is in bti chip (no traco in theta!)
149  // acceptance is determined about BTI angle wrt vertex with programmable value
150  if (_id.superlayer() == 2) {
151  // 091105 SV theta bti trigger angular acceptance in CMSSW is computed from geometry
152  // (theta of the bti) +- a given tolerance config()->KAccTheta(): tolerance NOT in
153  // hardware configuration. The hw tolerance is given in the system and the
154  // overall acceptance is computed "before" data (CH,CL) is given to the MC
155  // or written in the DB. No way to "extract" the tolerance from DB yet.
156 
157  if (_card->useAcceptParamFlag() == 0) {
158  //float distp2 = (int)(2*_geom->cellH()*config()->ST()/_geom->cellPitch()); SV fix 17/III/07
159  float distp2 = 2 * _geom->cellH() * config()->ST() / _geom->cellPitch();
160  float K0 = config()->ST();
161 
162  // position of BTI 1 and of current one
163  DTBtiId _id1 = DTBtiId(sid, supl, 1);
164  GlobalPoint gp1 = _geom->CMSPosition(_id1);
166  if (config()->debug() > 3) {
167  cout << "Position: R=" << gp.perp() << "cm, Phi=" << gp.phi() * 180 / 3.14159;
168  cout << " deg, Z=" << gp.z() << " cm" << endl;
169  }
170  // new geometry: modified wrt old due to specularity of theta SLs --> fixed 6/9/06
171  float theta;
172  if (gp1.z() < 0.0)
173  theta = atan(-(gp.z()) / gp.perp());
174  else
175  theta = atan((gp.z()) / gp.perp());
176 
177  // set BTI acceptance window : fixed wrt ORCA on 6/9/06
178  float fktmin = tan(theta) * distp2 + K0;
179  int ktmin = static_cast<int>(fktmin) - config()->KAccTheta();
180  float fktmax = tan(theta) * distp2 + K0 + 1;
181  int ktmax = static_cast<int>(fktmax) + config()->KAccTheta();
182  if (ktmin > _MinKAcc)
183  _MinKAcc = ktmin;
184  if (ktmax < _MaxKAcc)
185  _MaxKAcc = ktmax;
186  }
187  // 091105 SV acceptance is taken simply from CH, CL parameters
188  else {
189  _MinKAcc = config()->CL();
190  _MaxKAcc = config()->CH();
191  }
192 
193  // debugging
194  if (config()->debug() > 2) {
195  cout << "CMS position:" << CMSPosition() << endl;
196  cout << "K acceptance (theta view):" << _MinKAcc << "," << _MaxKAcc << endl;
197  } // end debugging
198 
199  } //end theta acceptance computation
200 
201  //}// end if trigSetupGeom=0
202 
203  //SV flag for initialization....
204  init_done = 0;
205 }
206 
207 //--------------
208 // Destructor --
209 //--------------
211 
212 void DTBtiChip::add_digi(int cell, const DTDigi* digi) {
213  if (_id.bti() < 1 || _id.bti() > _geom->nCell(superlayer()))
214  return;
215  if (cell < 1 || cell > 9) {
216  cout << "DTBtiChip::add_digi : wrong cell number: " << cell;
217  cout << ". Digi not added!" << endl;
218  return;
219  }
220 
221  int DEAD = config()->DEADpar();
222  float stepTimeTdc = DTBtiHit::_stepTimeTdc;
223 
224  if (int(digi->countsTDC() / stepTimeTdc) - _busyStart_clock[cell - 1] > DEAD) {
225  _busyStart_clock[cell - 1] = int(digi->countsTDC() / stepTimeTdc);
226  _digis[cell - 1].push_back(digi);
227 
228  // debugging
229  if (config()->debug() > 1) {
230  cout << "DTBtiChip::add_digi: DTBtiChip # " << _id.bti() << " cell " << cell
231  << " --> drift time (tdc units)= " << digi->countsTDC() << endl;
232  digi->print();
233  }
234  } else {
235  // debugging
236  if (config()->debug() > 1)
237  cout << "DTBtiChip::add_digi: DTBtiChip # " << _id.bti() << " cell " << cell
238  << " in dead time -> digi not added! " << endl;
239  }
240 }
241 
242 void DTBtiChip::add_digi_clock(int cell, int digi) {
243  if (cell < 1 || cell > 9) {
244  cout << "DTBtiChip::add_digi_clock : wrong cell number: " << cell;
245  cout << ". Digi not added!" << endl;
246  return;
247  }
248 
249  int DEAD = config()->DEADpar();
250 
251  if (digi - _busyStart_clock[cell - 1] > DEAD) {
252  _busyStart_clock[cell - 1] = digi;
253  _digis_clock[cell - 1].push_back(digi);
254  // debugging
255  if (config()->debug() > 1)
256  cout << "DTBtiChip::add_digi_clock: DTBtiChip # " << number() << " cell " << cell << " --> clock time = " << digi
257  << endl;
258  } else {
259  // debugging
260  if (config()->debug() > 1)
261  cout << "DTBtiChip::add_digi_clock: DTBtiChip # " << number() << " cell " << cell
262  << " in dead time -> digi not added! " << endl;
263  }
264 }
265 
266 int DTBtiChip::nCellHit() const {
267  int n = 0;
268  int i = 0;
269  for (auto const& d : _digis) {
270  if (!d.empty())
271  n++;
272  }
273  if (config()->debug() > 2) {
274  cout << n << " cells with hits found:" << endl;
275  }
276  if (config()->debug() > 2) {
277  for (i = 0; i < 9; i++) {
278  for (auto const& d : _digis[i]) {
279  cout << "DTBtiChip # " << _id.bti() << " cell " << i + 1;
280  cout << " --> drift time (tdc units): " << d->countsTDC() << endl;
281  d->print();
282  }
283  }
284  }
285  return n;
286  /*
287  //SV 2/IV/03 counting hits from _hits
288  int n=0;
289  int i=0;
290  for(i=0;i<9;i++) {
291  if( _hits[i].size() >0 ) n++;
292  }
293  if(config()->debug()>2) {
294  cout << n << " cells with hits found:" << endl;
295  }
296  if(config()->debug()>2) {
297  for(i=0;i<9;i++) {
298  vector<const DTBtiHit*>::const_iterator p;
299  for(p=_hits[i].begin();p<_hits[i].end();p++) {
300  cout << "DTBtiChip # " <<
301  number() <<
302  " cell " << i+1;
303  if((*p)->curTime()!=4000)
304  cout << " --> drift time: " << (*p)->curTime() << endl;
305  else
306  cout << " --> clock time: " << (*p)->clockTime() << endl;
307  }
308  }
309  }
310  return n;
311 */
312 }
313 
314 void DTBtiChip::addTrig(int step, std::unique_ptr<DTBtiTrig> btitrig) {
315  if (step >= DTConfig::NSTEPF && step <= DTConfig::NSTEPL) {
316  if (config()->debug() > 3)
317  cout << "DTBtiChip: adding trigger..." << endl;
318  _trigs[step - DTConfig::NSTEPF].emplace_back(std::move(btitrig));
319  } else {
320  if (config()->debug() > 3) {
321  cout << "DTBtiChip::addTrig: step " << step;
322  cout << " outside range. Trigger not added" << endl;
323  }
324  }
325 }
326 
327 int DTBtiChip::nTrig(int step) const {
329  cout << "DTBtiChip::nTrig: step out of range: " << step;
330  cout << " 0 returned" << endl;
331  return 0;
332  }
333  return _trigs[step - DTConfig::NSTEPF].size();
334 }
335 
336 vector<std::unique_ptr<DTBtiTrig>> const& DTBtiChip::trigList(int step) const {
338  cout << "DTBtiChip::trigList: step out of range: " << step;
339  cout << " empty pointer returned" << endl;
340  //return 0;
341  }
342  return _trigs[step - DTConfig::NSTEPF];
343 }
344 
345 DTBtiTrig const* DTBtiChip::trigger(int step, unsigned n) const {
347  cout << "DTBtiChip::trigger: step out of range: " << step;
348  cout << " empty pointer returned" << endl;
349  return nullptr;
350  }
351  if (n < 1 || n > _trigs[step - DTConfig::NSTEPF].size()) {
352  cout << "DTBtiChip::trigger: requested trigger does not exist: " << n;
353  cout << " empty pointer returned!" << endl;
354  return nullptr;
355  }
356  auto p = _trigs[step - DTConfig::NSTEPF].begin();
357  return (*(p + n - 1)).get();
358 }
359 
362  cout << "DTBtiChip::triggerData: step out of range: " << step;
363  cout << " dummy trigger returned" << endl;
364  return DTBtiTrigData();
365  }
366  if (n < 1 || n > _trigs[step - DTConfig::NSTEPF].size()) {
367  cout << "DTBtiChip::triggerData: requested trig. doesn't exist: " << n;
368  cout << " dummy trigger returned!" << endl;
369  return DTBtiTrigData();
370  }
371  auto p = _trigs[step - DTConfig::NSTEPF].begin();
372  return (*(p + n - 1))->data();
373 }
374 
375 void DTBtiChip::eraseTrigger(int step, unsigned n) {
377  cout << "DTBtiChip::eraseTrigger: step out of range: " << step;
378  cout << " trigger not deleted!" << endl;
379  }
380  if (n < 1 || n > _trigs[step - DTConfig::NSTEPF].size()) {
381  cout << "DTBtiChip::trigger: requested trigger does not exist: " << n;
382  cout << " trigger not deleted!" << endl;
383  }
384  auto p = _trigs[step - DTConfig::NSTEPF].begin() + n - 1;
385  _trigs[step - DTConfig::NSTEPF].erase(p);
386 }
387 
389  if (config()->debug() > 3)
390  cout << "DTBtiChip::clear()" << endl;
391 
392  for (auto& d : _digis) {
393  d.clear();
394  }
395  for (auto& c : _digis_clock) {
396  c.clear();
397  }
398  for (auto& h : _hits) {
399  h.clear();
400  }
401 
402  for (auto& t : _trigs) {
403  t.clear();
404  }
405 }
406 
408  if (config()->debug() > 3)
409  cout << "DTBtiChip::init() -> initializing bti chip" << endl;
410 
411  _curStep = 0;
412  for (int i = 0; i < 25; i++) {
413  _sums[i] = 1000;
414  _difs[i] = 1000;
415  }
416 
417  for (int cell = 0; cell < 9; cell++) {
418  int WEN = config()->WENflag(cell + 1);
419  if (WEN == 1) {
420  _thisStepUsedHit[cell] = nullptr;
421  vector<const DTDigi*>::const_iterator p;
422  for (p = _digis[cell].begin(); p < _digis[cell].end(); p++) {
423  DTBtiHit* hit = new DTBtiHit(*p, config());
424  //int clockTime = (int)(fabs(((*p)->time()+config()->SetupTime())/12.5));
425  //DTBtiHit* hit = new DTBtiHit(clockTime,config());
426  _hits[cell].push_back(hit);
427  }
428 
429  //debugging
430  if (config()->debug() > 2) {
431  vector<DTBtiHit*>::const_iterator p1;
432  for (p1 = _hits[cell].begin(); p1 < _hits[cell].end(); p1++) {
433  cout << " Filling hit in cell " << cell + 1;
434  if ((*p1)->curTime() != 4000)
435  cout << " raw time in trigger: " << (*p1)->curTime() << endl;
436  cout << " time (clock units): " << (*p1)->clockTime() << endl;
437  }
438  }
439  // end debugging
440  }
441  }
442 }
443 
445  if (config()->debug() > 3)
446  cout << "DTBtiChip::init_clock() -> initializing bti chip" << endl;
447 
448  init_done = 1;
449  _curStep = 0;
450 
451  for (int i = 0; i < 25; i++) {
452  _sums[i] = 1000;
453  _difs[i] = 1000;
454  }
455 
456  for (int cell = 0; cell < 9; cell++) {
457  int WEN = config()->WENflag(cell + 1);
458  if (WEN == 1) {
459  _thisStepUsedHit[cell] = nullptr;
460  for (unsigned int i = 0; i < _digis_clock[cell].size(); i++) {
461  const int clockTime = (_digis_clock[cell])[i];
462  DTBtiHit* hit = new DTBtiHit(clockTime, config());
463  _hits[cell].push_back(hit);
464  }
465 
466  //debugging
467  if (config()->debug() > 2) {
468  vector<DTBtiHit*>::const_iterator p1;
469  for (p1 = _hits[cell].begin(); p1 < _hits[cell].end(); p1++) {
470  cout << " Filling hit in cell " << cell + 1;
471  if ((*p1)->curTime() != 4000)
472  cout << " time: " << (*p1)->curTime() << endl;
473  else
474  cout << " time (clock units): " << (*p1)->clockTime() << endl;
475  }
476  }
477  // end debugging
478  }
479  }
480 }
481 
483  // Debugging...
484  if (config()->debug() > 2) {
485  cout << "DTBtiChip::run: Processing BTI " << _id.bti() << endl;
486  cout << " in SL " << _id.superlayer() << endl;
487  }
488  // End debugging
489 
490  if (_id.bti() < 1 || _id.bti() > _geom->nCell(superlayer())) {
491  if (config()->debug() > 1)
492  cout << "DTBtiChip::run : wrong BTI number: " << _id.bti() << endl;
493  return;
494  }
495 
496  // run algorithm
497  if (!init_done)
498  init();
499  if (nCellHit() < 3)
500  return; // check that at least 3 cell have hits
501 
502  for (int ints = 0; ints < 2 * DTConfig::NSTEPL; ints++) { // 80 MHz
503  tick(); // Do a 12.5 ns step
504 
505  // In electronics equations are computed every 12.5 ns
506  // but since triggers are searched for only every 25 ns, skip
507  // also equation's computing at odd values of internal step
508  if ((currentIntStep() / 2) * 2 != currentIntStep())
509  continue;
510  //if((currentIntStep()/2)*2==currentIntStep())continue;
511 
512  if (config()->debug() > 2) {
513  cout << "DTBtiChip::run : internal step " << currentIntStep();
514  cout << " number of JTRIG hits is " << _nStepUsedHits << endl;
515  }
516  if (currentStep() >= DTConfig::NSTEPF && _nStepUsedHits > 2) {
517  // at least 3 good hits in this step -> run algorithm
518  computeSums();
519  computeEqs();
520  findTrig();
521  }
522  }
523  if (config()->LTS() > 0)
524  doLTS(); // low trigger suppression
525 }
526 
528  //
529  // fills the DTBtiChip registers ( _thisStepUsedHit[cell] )
530  // for a given clock (Syncronizer and Shaper functionalities)
531  //
532 
533  _curStep++; // increase internal step (12.5 ns --> 80 MHz)
534 
535  // debugging
536  if (config()->debug() > 2) {
537  cout << "DTBtiChip::tick: internal step is now " << currentIntStep() << endl;
538  }
539  // end debugging
540 
541  // Loop on cells
542  _nStepUsedHits = 0;
543  for (int cell = 0; cell < 9; cell++) {
544  // decrease drift time by 12.5 ns for each hit
545  for (auto& h : _hits[cell]) {
546  h->stepDownTime();
547  }
548 
549  // loop on hits
550  _thisStepUsedHit[cell] = nullptr;
551  for (auto& h : _hits[cell]) {
552  if (h->isDrifting()) { // hit is drifting
553  break; // --> don't consider others
554  } else if (h->isInsideReg()) { // hit is already in registers
555  _thisStepUsedHit[cell] = h;
556  _nStepUsedHits++;
557  // debugging
558  if (config()->debug() > 2) {
559  if (h->curTime() != 4000)
560  cout << "DTBtiChip::tick: hit in register: time=" << h->curTime();
561  else
562  cout << "DTBtiChip::tick: hit in register! " << endl;
563  cout << " jtrig=" << h->jtrig() << endl;
564  }
565  // end debugging
566  break; // --> don't consider other triggers
567  }
568  // hit is not drifting and not in registers: it is gone out of register, but
569  // jtrig value is still=ST ; save in array and consider next one if exists
570  } // end loop on cell hits
571 
572  // debugging...
573  if (config()->debug() > 2) {
574  if (_thisStepUsedHit[cell] != nullptr) {
575  cout << "int. step=" << currentIntStep() << " cell=" << cell + 1;
576  cout << " jtrig=" << _thisStepUsedHit[cell]->jtrig();
577  if (_thisStepUsedHit[cell]->curTime() != 4000)
578  cout << " (time=" << _thisStepUsedHit[cell]->curTime() << ")" << endl;
579  else
580  cout << endl;
581  }
582  }
583  // end debugging
584 
585  } // end loop on cells
586 }
587 
589  if (config()->debug() > 2)
590  cout << "Do LTS" << endl;
591  int lts = config()->LTS();
592  int nbxlts = config()->SET();
593 
594  // Do LTS only on the requested SL
595  //if (superlayer()==2 && lts==1) return;
596  //if (superlayer()!=2 && lts==2) return;
597  //new DTConfig: do LTS only is LTS!=0 --> somewhat redundant !
598  if (lts == 0)
599  return;
600 
601  // loop on steps
602  for (int is = DTConfig::NSTEPF; is <= DTConfig::NSTEPL; is++) {
603  if (nTrig(is) > 0) { // non empty step
604  if (trigger(is, 1)->code() == 8) { // HTRIG at this step
605  // do LTS on nbxLTS[superlayer] following steps
606  for (int js = is + 1; (js <= is + nbxlts && js <= DTConfig::NSTEPL); js++) {
607  if (nTrig(js) > 0) { // non empty step
608  DTBtiTrig const* tr = trigger(js, 1);
609  if (tr->code() < 8 && (lts == 1 || lts == 3)) {
610  if (config()->debug() > 3)
611  cout << "LTS: erasing trigger!" << endl;
612  eraseTrigger(js, 1); // delete trigger
613  }
614  }
615  }
616  // do LTS on previous step
617  if (is > DTConfig::NSTEPF && nTrig(is - 1) > 0) { // non empty step
618  DTBtiTrig const* tr = trigger(is - 1, 1);
619  if (tr->code() < 8 && (lts == 2 || lts == 3)) {
620  if (config()->debug() > 3)
621  cout << "LTS: erasing trigger!" << endl;
622  eraseTrigger(is - 1, 1); // delete trigger
623  }
624  }
625  }
626  }
627  }
628 }
629 
630 int DTBtiChip::store(const int eq,
631  const int code,
632  const int K,
633  const int X,
634  float KeqAB,
635  float KeqBC,
636  float KeqCD,
637  float KeqAC,
638  float KeqBD,
639  float KeqAD) {
640  // remove negative position triggers
641  if (X < 0)
642  return 0;
643 
644  // accept in range triggers (acceptances defined in constructor)
645  if (K >= _MinKAcc && K <= _MaxKAcc) {
646  int trig_step = currentStep();
647 
648  /*
649  //SV test 27/I/2003 1-clock delay for critical patterns in default ACx configuration
650  int AC1 = config()->AccPattAC1(); //default 0
651  int AC2 = config()->AccPattAC2(); //default 3
652  int ACH = config()->AccPattACH(); //default 1
653  int ACL = config()->AccPattACL(); //default 2
654 
655  if(AC1==0 && AC2==3 && ACH==1 && ACL==2){
656  if(eq==1 || eq==4 || eq==7 || eq==8 || eq==9 || eq==12 || eq==15
657  || eq==19 || eq==22 || eq==23 || eq==24 || eq==25 || eq==27 )
658  trig_step = currentStep()+1;
659  }
660 */
661  //store strobe: SV no strobe defined for this setup SV 15/I/2007
662  int strobe = -1;
663 
664  // create a new trigger
665  float Keq[6] = {KeqAB, KeqBC, KeqCD, KeqAC, KeqBD, KeqAD};
666  //DTBtiTrig* trg = new DTBtiTrig(this,code,K,X,currentStep(),eq);
667  auto trg = std::make_unique<DTBtiTrig>(this, code, K, X, trig_step, eq, strobe, Keq);
668 
669  // store also the digis
670  for (auto& h : _thisStepUsedHit) {
671  if (h) {
672  const DTDigi* digi = h->hitDigi();
673  if (digi)
674  trg->addDigi(digi);
675  }
676  }
677 
678  // Debugging...
679  if (config()->debug() > 1)
680  trg->print();
681  // end debugging
682 
683  //addTrig(currentStep(),trg);
684  addTrig(trig_step, std::move(trg));
685 
686  return 1;
687  } else {
688  // remove out of range triggers (acceptances defined in constructor)
689  if (config()->debug() > 2) {
690  cout << "DTBtiChip::store, REJECTED TRIGGER at step " << currentStep();
691  cout << " allowed K range in theta view is: [";
692  cout << _MinKAcc << "," << _MaxKAcc << "]";
693  cout << "K value is " << K << endl;
694  }
695  return 0;
696  } //end else
697 } //end store
698 
700  //set the internally calculated drift velocity parameters
701  ST43 = config()->ST43();
702  RE43 = config()->RE43();
703  ST23 = int(double(ST43) / 2.);
704  RE23 = (RE43 == 1) ? 2 : int(double(RE43) / 2.);
705 
706  ST = int(double(ST43) * 3. / 4. + double(RE43) * 1. / 4.);
707  ST2 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 2.);
708  ST3 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 3.);
709  ST4 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 4.);
710  ST5 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 5.);
711  ST7 = int((double(ST43) * 3. / 4. + double(RE43) * 1. / 4.) * 7.);
712 
713  if (config()->debug() > 3) {
714  cout << "Snap register dump: " << endl;
715  cout << "ST43 = " << ST43 << endl;
716  cout << "RE43 = " << RE43 << endl;
717  cout << "ST23 = " << ST23 << endl;
718  cout << "RE23 = " << RE23 << endl;
719  cout << "ST = " << ST << endl;
720  cout << "ST2 = " << ST2 << endl;
721  cout << "ST3 = " << ST3 << endl;
722  cout << "ST4 = " << ST4 << endl;
723  cout << "ST5 = " << ST5 << endl;
724  cout << "ST7 = " << ST7 << endl;
725  }
726 }
DTBtiId _id
Definition: DTBtiChip.h:176
DTBtiChip(DTBtiCard *card, DTTrigGeom *geom, int supl, int n, DTConfigBti *_config)
original constructor
Definition: DTBtiChip.cc:48
int debug() const
Debug flag.
Definition: DTConfigBti.h:58
int _MinKAcc
Definition: DTBtiChip.h:195
const edm::EventSetup & c
T perp() const
Definition: PV3DBase.h:69
float cellPitch() const
Width of a cell (cm) i.e. distance between ywo wires.
Definition: DTTrigGeom.h:76
int superlayer() const
Return superlayer.
Definition: DTBtiChip.h:92
std::array< std::vector< std::unique_ptr< DTBtiTrig > >, DTConfig::NSTEPL-DTConfig::NSTEPF+1 > _trigs
Definition: DTBtiChip.h:184
int DEADpar() const
Wire DEAD time parameter.
Definition: DTConfigBti.h:122
std::array< std::vector< const DTDigi * >, 9 > _digis
Definition: DTBtiChip.h:179
void print() const
Print content of digi.
Definition: DTDigi.cc:49
int ST43() const
ST and RE parameters for drift velocity.
Definition: DTConfigBti.h:118
void eraseTrigger(int step, unsigned n)
Definition: DTBtiChip.cc:375
int store(const int eq, const int code, const int K, const int X, float KeqAB=0., float KeqBC=0., float KeqCD=0., float KeqAC=0., float KeqBD=0., float KeqAD=0.)
Definition: DTBtiChip.cc:630
int CH() const
K right limit for center traco.
Definition: DTConfigBti.h:109
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
float ST() const
Max drift time in 12.5 ns steps.
Definition: DTConfigBti.h:61
void tick()
Definition: DTBtiChip.cc:527
static const int NSTEPF
Definition: DTConfig.h:35
Geom::Theta< T > theta() const
#define X(str)
Definition: MuonsGrabber.cc:38
int init_done
Definition: DTBtiChip.h:209
void clear()
delete hits and triggers
Definition: DTBtiChip.cc:388
std::array< float, 25 > _difs
Definition: DTBtiChip.h:192
std::array< DTBtiHit *, 9 > _thisStepUsedHit
Definition: DTBtiChip.h:190
static const float _stepTimeTdc
Definition: DTBtiHit.h:110
DTBtiCard * _card
Definition: DTBtiChip.h:171
void doLTS()
Definition: DTBtiChip.cc:588
DTBtiTrig const * trigger(int step, unsigned n) const
Return the requested trigger.
Definition: DTBtiChip.cc:345
tuple d
Definition: ztail.py:151
int _MaxKAcc
Definition: DTBtiChip.h:196
void run()
Run DTBtiChip algorithm.
Definition: DTBtiChip.cc:482
int currentIntStep() const
Definition: DTBtiChip.h:143
int superlayer() const
Returns the superlayer.
Definition: DTBtiId.h:61
DTBtiTrigData triggerData(int step, unsigned n) const
Return the data part of the requested trigger.
Definition: DTBtiChip.cc:360
float cellH() const
Height of a cell (cm)
Definition: DTTrigGeom.h:73
DTTrigGeom * _geom
Definition: DTBtiChip.h:173
int RE43() const
Definition: DTConfigBti.h:119
T z() const
Definition: PV3DBase.h:61
def move
Definition: eostools.py:511
int code() const
Return trigger code.
Definition: DTBtiTrig.h:111
const TString p1
Definition: fwPaths.cc:12
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
void init_clock()
Definition: DTBtiChip.cc:444
int nTrig(int step) const
Number of triggers found.
Definition: DTBtiChip.cc:327
~DTBtiChip()
Destructor.
Definition: DTBtiChip.cc:210
static const int NSTEPL
Constants: first and last step to start trigger finding.
Definition: DTConfig.h:35
Definition: DTDigi.h:17
int RE43
Definition: DTBtiChip.h:213
std::array< int, 9 > _busyStart_clock
Definition: DTBtiChip.h:210
GlobalPoint CMSPosition() const
Position in CMS frame.
Definition: DTBtiChip.h:98
int KAccTheta() const
BTI angular acceptance in theta view.
Definition: DTConfigBti.h:67
int _curStep
Definition: DTBtiChip.h:187
int ST23
Definition: DTBtiChip.h:213
std::array< std::vector< int >, 9 > _digis_clock
Definition: DTBtiChip.h:181
int number() const
Return DTBtiChip number.
Definition: DTBtiChip.h:89
int bti() const
Returns the bti.
Definition: DTBtiId.h:63
int SET() const
SET.
Definition: DTConfigBti.h:76
std::array< std::vector< DTBtiHit * >, 9 > _hits
Definition: DTBtiChip.h:188
#define debug
Definition: HDRShower.cc:19
DTChamberId statId() const
Identifier of the associated chamber.
Definition: DTTrigGeom.h:53
int currentStep() const
Definition: DTBtiChip.h:142
bool useAcceptParamFlag()
Return acceptance flag.
Definition: DTBtiCard.h:111
int RE23
Definition: DTBtiChip.h:213
int _nStepUsedHits
Definition: DTBtiChip.h:191
std::array< float, 25 > _sums
Definition: DTBtiChip.h:192
void init()
Definition: DTBtiChip.cc:407
int nCellHit() const
Number of cells with hits.
Definition: DTBtiChip.cc:266
tuple cout
Definition: gather_cfg.py:144
step
Definition: StallMonitor.cc:94
int CL() const
K left limit for center traco.
Definition: DTConfigBti.h:106
int ST43
Definition: DTBtiChip.h:213
void add_digi(int cell, const DTDigi *digi)
Add a digi to the DTBtiChip.
Definition: DTBtiChip.cc:212
void addTrig(int step, std::unique_ptr< DTBtiTrig > btitrig)
Definition: DTBtiChip.cc:314
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
DTConfigBti * config() const
Configuration set.
Definition: DTBtiChip.h:119
std::vector< std::unique_ptr< DTBtiTrig > > const & trigList(int step) const
Definition: DTBtiChip.cc:336
int WENflag(int wire) const
Wire mask flag.
Definition: DTConfigBti.h:97
int32_t countsTDC() const
Get raw TDC count.
Definition: DTDigi.cc:39
GlobalPoint CMSPosition(const DTBtiId obj) const
CMS position of a BTI.
Definition: DTTrigGeom.h:177
int nCell(int sl) const
Number of BTIs in a required superlayer (i.e. nCells in lay 1)
Definition: DTTrigGeom.h:88
void add_digi_clock(int cell, int clock_digi)
Add a clock digi to the DTBtiChip.
Definition: DTBtiChip.cc:242
tuple size
Write out results.
int LTS() const
LTS.
Definition: DTConfigBti.h:73
void setSnap()
Definition: DTBtiChip.cc:699