CMS 3D CMS Logo

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