CMS 3D CMS Logo

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