27 #include "StCtbTriggerDetector.h"
28 #include "StMuDSTMaker/COMMON/StMuEvent.h"
44 Int_t StPeCL0::dsm1Sum ( ) {
48 for(i=0; i<nL0Phi; i++){
for(j=0; j<nL0Eta; j++){array2[i][j] = 0;}}
49 for(i=0; i<15; i++){
for(j=0; j<nL0Slats; j++){array2[0][2+j]+=weighted1[i][j];}}
50 for(i=15; i<30; i++){
for(j=0; j<nL0Slats; j++){array2[3][2+j]+=weighted1[i][j];}}
51 for(i=30; i<45; i++){
for(j=0; j<nL0Slats; j++){array2[2][2+j]+=weighted1[i][j];}}
52 for(i=45; i<60; i++){
for(j=0; j<nL0Slats; j++){array2[1][2+j]+=weighted1[i][j];}}
53 for(i=60; i<75; i++){
for(j=0; j<nL0Slats; j++){array2[1][1-j]+=weighted1[i][j];}}
54 for(i=75; i<90; i++){
for(j=0; j<nL0Slats; j++){array2[2][1-j]+=weighted1[i][j];}}
55 for(i=90; i<105; i++){
for(j=0; j<nL0Slats; j++){array2[3][1-j]+=weighted1[i][j];}}
56 for(i=105; i<120; i++){
for(j=0; j<nL0Slats; j++){array2[0][1-j]+=weighted1[i][j];}}
61 for ( i = 0 ; i < nL0Phi ; i++ ) {
62 for ( j = 0 ; j < nL0Eta ; j++ ) {
64 if ( sum > 255 ) weighted2[i][j] = 255 ;
65 else if ( sum < 0 ) weighted2[i][j] = 0 ;
66 else weighted2[i][j] = lut2[i][j][sum] ;
72 Int_t StPeCL0::dsm2Sum ( ){
73 array3[0]=0; array3[1]=0;
74 {
for(
int i=0; i<nL0Phi; i++){
for(
int j=0; j<2; j++){array3[0]+=weighted2[i][j];}}}
75 {
for(
int i=0; i<nL0Phi; i++){
for(
int j=2; j<4; j++){array3[1]+=weighted2[i][j];}}}
80 {
for (
int i = 0 ; i < 2 ; i++ ) {
82 if ( sum > 255 ) weighted3[i] = 255 ;
83 else if ( sum < 0 ) weighted3[i] = 0 ;
84 else weighted3[i] = lut3[i][sum] ;
90 void StPeCL0::printWeightedSlats ( ){
93 char parray[nL0Trays][nL0Slats] ;
94 for ( i = 0 ; i < nL0Trays ; i++ ) {
95 for ( j = 0 ; j < nL0Slats ; j++ ) {
96 parray[i][j] = weighted1[i][j] ;
97 if ( parray[i][j] > 14 ) parray[i][j] = 14 ;
101 cout <<
" ++++++++++ Weighted Slat Information ++++++++++ " <<endl ;
102 cout <<
" : south -> top -> north -> bottom" << endl;
103 cout <<
" : 13-1 60-59 | 58-44 | 43-29 | 28-14" << endl;
105 cout <<
"west / eta= " << j <<
" : ";
106 for(i=12; i>-1; i--) printf (
"%x", parray[i][j] );
107 for(i=59; i>57; i--) printf (
"%x", parray[i][j] );
109 for(i=57; i>42; i--) printf (
"%x", parray[i][j] );
111 for(i=42; i>27; i--) printf (
"%x", parray[i][j] );
113 for(i=27; i>12; i--) printf (
"%x", parray[i][j] );
117 cout <<
"east / eta= " << j <<
" : ";
118 for(i=102; i<117; i++) printf (
"%x", parray[i][j] );
120 for(i=117; i<120; i++) printf (
"%x", parray[i][j] );
121 for(i=60; i< 72; i++) printf (
"%x", parray[i][j] );
123 for(i=72; i< 87; i++) printf (
"%x", parray[i][j] );
125 for(i=87; i<102; i++) printf (
"%x", parray[i][j] );
128 cout <<
" : 103-117 | 118-120 61-72 | 73-87 | 88-102" << endl;
131 void StPeCL0::printSlats ( ){
134 char parray[nL0Trays][nL0Slats] ;
135 for ( i = 0 ; i < nL0Trays ; i++ ) {
136 for ( j = 0 ; j < nL0Slats ; j++ ) {
137 parray[i][j] = array1[i][j] ;
138 if ( parray[i][j] > 14 ) parray[i][j] = 14 ;
141 cout <<
" ++++++++++ Slat Information ++++++++++ " <<endl ;
142 cout <<
" : south -> top -> north -> bottom" << endl;
143 cout <<
" : 13-1 60-59 | 58-44 | 43-29 | 28-14" << endl;
145 cout <<
"west / eta= " << j <<
" : ";
146 for(i=12; i>-1; i--) printf (
"%x", parray[i][j] );
147 for(i=59; i>57; i--) printf (
"%x", parray[i][j] );
149 for(i=57; i>42; i--) printf (
"%x", parray[i][j] );
151 for(i=42; i>27; i--) printf (
"%x", parray[i][j] );
153 for(i=27; i>12; i--) printf (
"%x", parray[i][j] );
157 cout <<
"east / eta= " << j <<
" : ";
158 for(i=102; i<117; i++) printf (
"%x", parray[i][j] );
160 for(i=117; i<120; i++) printf (
"%x", parray[i][j] );
161 for(i=60; i< 72; i++) printf (
"%x", parray[i][j] );
163 for(i=72; i< 87; i++) printf (
"%x", parray[i][j] );
165 for(i=87; i<102; i++) printf (
"%x", parray[i][j] );
168 cout <<
" : 103-117 | 118-120 61-72 | 73-87 | 88-102" << endl;
171 void StPeCL0::printPatches ( ) {
172 cout <<
" ------- Patches --------- " << endl;
173 cout <<
" : south top/north bottom/south bottom" << endl;
174 for(
int j=0; j<nL0Eta; j++){
175 cout <<
"eta= " << j <<
" : ";
176 for(
int i=0; i<nL0Phi; i++){
177 cout <<
" " << (int)array2[i][j]<<
" "<<i<<j<<
" "<<(
int)(lut2[i][j][array2[i][j]]);
183 void StPeCL0::printWeightedPatches ( ) {
184 cout <<
" ------- Weighted Patches --------- " << endl;
185 cout <<
" : south top/north bottom/south bottom" << endl;
186 for(
int j=0; j<nL0Eta; j++){
187 cout <<
"eta= " << j <<
" : ";
188 for(
int i=0; i<nL0Phi; i++){
189 cout <<
" " << (int)weighted2[i][j];
197 Int_t StPeCL0::process (
StEvent* event ) {
203 printf (
"StPeCL0::process: Didn't find CTB" ) ;
208 for ( i=0 ; i<nL0Trays; i++ ){
210 if ( slot < 0 || slot >= nL0Trays ) {
211 printf (
"StPeCL0:process: wrong cabling tray %d slot %d \n", i, slot ) ;
214 for ( j = 0 ; j < nL0Slats ; j++ ){
215 int adc = (int)ctb.mips(i,j,0) ;
221 printf (
"StPeCL0:process: adc %d out of range \n", adc ) ;
225 weighted1[slot][j] = lut1[slot][j][adc] ;
227 if ( infoLevel && adc > 0 )
228 printf (
" Event %d tray %d slot %d slat %d adc %d matched %d \n",
229 event->id(), i+1, slot, j+1, adc, weighted1[slot][j] ) ;
236 printWeightedSlats();
243 printWeightedPatches();
248 int output = weighted3[0] + weighted3[1] ;
250 printf (
"StPeCL0::process: trigger output %d \n", output ) ;
255 Int_t StPeCL0::process(
StMuDst* mudst)
258 event = mudst->
event();
264 printf(
"StPeCL0::process: Didn't find CTB");
271 for (i=0 ; i<nL0Trays; i++)
274 if (slot < 0 || slot >= nL0Trays)
276 printf (
"StPeCL0:process: wrong cabling tray %d slot %d \n", i, slot ) ;
280 for (j = 0; j < nL0Slats; j++)
282 int adc = (int)ctb.mips(i, j, 0);
288 printf (
"StPeCL0:process: adc %d out of range \n", adc);
293 weighted1[slot][j] = lut1[slot][j][adc];
294 if (infoLevel && adc > 0)
295 printf (
" Event %d tray %d slot %d slat %d adc %d matched %d \n", mudst->
event()->eventInfo().id(), i+1, slot, j+1, adc, weighted1[slot][j]);
303 printWeightedSlats();
311 printWeightedPatches();
316 int output = weighted3[0] + weighted3[1];
318 printf (
"StPeCL0::process: trigger output %d \n", output);
325 void StPeCL0::setLinearLuts() {
328 for ( i = 0 ; i < nL0Trays ; i++ ) {
329 for ( j = 0 ; j < nL0Range ; j++ ) {
334 for ( i = 0 ; i < nL0Phi ; i++ ) {
335 for ( j = 0 ; j < nL0Eta ; j++ ) {
336 for ( k = 0 ; k < nL0Range ; k++ ) {
343 for ( k = 0 ; k < nL0Range ; k++ ) {
349 void StPeCL0::setP4Luts() {
363 for ( i = 0 ; i < 8 ; i++ ) {
364 for ( j = 0 ; j < nL0Slats ; j++ ) {
365 for ( k = 0 ; k < nL0Range ; k++ ) {
366 if ( k < minAdc ) lut1[i][j][k] = 0 ;
367 else lut1[i][j][k] = maxAdc ;
372 for ( i = 49 ; i < 60 ; i++ ) {
373 for ( j = 0 ; j < nL0Slats ; j++ ) {
374 for ( k = 0 ; k < nL0Range ; k++ ) {
375 if ( k < minAdc ) lut1[i][j][k] = 0 ;
376 else lut1[i][j][k] = maxAdc ;
383 for ( i = 19 ; i < 34 ; i++ ) {
384 for ( j = 0 ; j < nL0Slats ; j++ ) {
385 for ( k = 0 ; k < nL0Range ; k++ ) {
386 if ( k < minAdc ) lut1[i][j][k] = 0 ;
387 else lut1[i][j][k] = maxAdc ;
394 for ( i = 109 ; i < 120 ; i++ ) {
395 for ( j = 0 ; j < nL0Slats ; j++ ) {
396 for ( k = 0 ; k < nL0Range ; k++ ) {
397 if ( k < minAdc ) lut1[i][j][k] = 0 ;
398 else lut1[i][j][k] = maxAdc ;
403 for ( i = 60 ; i < 68 ; i++ ) {
404 for ( j = 0 ; j < nL0Slats ; j++ ) {
405 for ( k = 0 ; k < nL0Range ; k++ ) {
406 if ( k < minAdc ) lut1[i][j][k] = 0 ;
407 else lut1[i][j][k] = maxAdc ;
414 for ( i = 79 ; i < 94 ; i++ ) {
415 for ( j = 0 ; j < nL0Slats ; j++ ) {
416 for ( k = 0 ; k < nL0Range ; k++ ) {
417 if ( k < minAdc ) lut1[i][j][k] = 0 ;
418 else lut1[i][j][k] = maxAdc ;
428 for ( i = 34 ; i < 50 ; i++ ) {
429 for ( j = 0 ; j < nL0Slats ; j++ ) {
430 for ( k = 0 ; k < nL0Range ; k++ ) {
431 if ( k < minAdc ) lut1[i][j][k] = 0 ;
432 else if ( k < maxAdc ) lut1[i][j][k] = 1 ;
433 else lut1[i][j][k] = 17 ;
440 for ( i = 8 ; i < 19 ; i++ ) {
441 for ( j = 0 ; j < nL0Slats ; j++ ) {
442 for ( k = 0 ; k < nL0Range ; k++ ) {
443 if ( k < minAdc ) lut1[i][j][k] = 0 ;
444 else if ( k < maxAdc ) lut1[i][j][k] = 4 ;
445 else lut1[i][j][k] = 17 ;
452 for ( i = 68 ; i < 79 ; i++ ) {
453 for ( j = 0 ; j < nL0Slats ; j++ ) {
454 for ( k = 0 ; k < nL0Range ; k++ ) {
455 if ( k < minAdc ) lut1[i][j][k] = 0 ;
456 else if ( k < maxAdc ) lut1[i][j][k] = 1 ;
457 else lut1[i][j][k] = 17 ;
464 for ( i = 94 ; i < 109 ; i++ ) {
465 for ( j = 0 ; j < nL0Slats ; j++ ) {
466 for ( k = 0 ; k < nL0Range ; k++ ) {
467 if ( k < minAdc ) lut1[i][j][k] = 0 ;
468 else if ( k < maxAdc ) lut1[i][j][k] = 4 ;
469 else lut1[i][j][k] = 17 ;
476 for ( i = 0 ; i < nL0Phi ; i++ ) {
477 for ( j = 0 ; j < nL0Eta ; j++ ) {
478 for ( k = 0 ; k < nL0Range ; k++ ) {
479 if ( k == 1 ) lut2[i][j][k] = 1 ;
480 else if ( k == 4 ) lut2[i][j][k] = 4 ;
481 else if ( k == 5 ) lut2[i][j][k] = 5 ;
482 else if ( k == 8 ) lut2[i][j][k] = 8 ;
483 else lut2[i][j][k] = 0 ;
490 for ( i = 0 ; i < 2 ; i++ ) {
491 for ( k = 0 ; k < nL0Range ; k++ ) {
496 void StPeCL0::setCountingLuts() {
499 for ( i = 0 ; i < nL0Trays ; i++ ) {
500 for ( j = 0 ; j < nL0Range ; j++ ) {
511 for ( i = 0 ; i < nL0Phi ; i++ ) {
512 for ( j = 0 ; j < nL0Eta ; j++ ) {
513 for ( k = 0 ; k < nL0Range ; k++ ) {
514 if ( i == 0 || i == 2 ) {
515 if ( k > 0 ) lut2[i][j][k] = 20 ;
518 if ( k < 10 ) lut2[i][j][k] = 10 * k ;
519 else lut2[i][j][k] = 255 ;
521 else lut2[i][j][k] = k ;
526 for ( k = 0 ; k < nL0Range ; k++ ) {
532 void StPeCL0::setP4PLuts() {
546 for ( i = 0 ; i < 3 ; i++ ) {
547 for ( j = 0 ; j < nL0Slats ; j++ ) {
548 for ( k = 0 ; k < nL0Range ; k++ ) {
549 if ( k < minAdc ) lut1[i][j][k] = 0 ;
550 else lut1[i][j][k] = maxAdc ;
555 for ( i = 52 ; i < 60 ; i++ ) {
556 for ( j = 0 ; j < nL0Slats ; j++ ) {
557 for ( k = 0 ; k < nL0Range ; k++ ) {
558 if ( k < minAdc ) lut1[i][j][k] = 0 ;
559 else lut1[i][j][k] = maxAdc ;
566 for ( i = 22 ; i < 33 ; i++ ) {
567 for ( j = 0 ; j < nL0Slats ; j++ ) {
568 for ( k = 0 ; k < nL0Range ; k++ ) {
569 if ( k < minAdc ) lut1[i][j][k] = 0 ;
570 else lut1[i][j][k] = maxAdc ;
577 for ( i = 112 ; i < 120 ; i++ ) {
578 for ( j = 0 ; j < nL0Slats ; j++ ) {
579 for ( k = 0 ; k < nL0Range ; k++ ) {
580 if ( k < minAdc ) lut1[i][j][k] = 0 ;
581 else lut1[i][j][k] = maxAdc ;
586 for ( i = 60 ; i < 63 ; i++ ) {
587 for ( j = 0 ; j < nL0Slats ; j++ ) {
588 for ( k = 0 ; k < nL0Range ; k++ ) {
589 if ( k < minAdc ) lut1[i][j][k] = 0 ;
590 else lut1[i][j][k] = maxAdc ;
597 for ( i = 82 ; i < 93 ; i++ ) {
598 for ( j = 0 ; j < nL0Slats ; j++ ) {
599 for ( k = 0 ; k < nL0Range ; k++ ) {
600 if ( k < minAdc ) lut1[i][j][k] = 0 ;
601 else lut1[i][j][k] = maxAdc ;
611 for ( i = 33 ; i < 52 ; i++ ) {
612 for ( j = 0 ; j < nL0Slats ; j++ ) {
613 for ( k = 0 ; k < nL0Range ; k++ ) {
614 if ( k < minAdc ) lut1[i][j][k] = 0 ;
615 else if ( k < maxAdc ) lut1[i][j][k] = 4 ;
616 else lut1[i][j][k] = 17 ;
623 for ( i = 3 ; i < 22 ; i++ ) {
624 for ( j = 0 ; j < nL0Slats ; j++ ) {
625 for ( k = 0 ; k < nL0Range ; k++ ) {
626 if ( k < minAdc ) lut1[i][j][k] = 0 ;
627 else if ( k < maxAdc ) lut1[i][j][k] = 1 ;
628 else lut1[i][j][k] = 17 ;
635 for ( i = 63 ; i < 82 ; i++ ) {
636 for ( j = 0 ; j < nL0Slats ; j++ ) {
637 for ( k = 0 ; k < nL0Range ; k++ ) {
638 if ( k < minAdc ) lut1[i][j][k] = 0 ;
639 else if ( k < maxAdc ) lut1[i][j][k] = 1 ;
640 else lut1[i][j][k] = 17 ;
647 for ( i = 93 ; i < 112 ; i++ ) {
648 for ( j = 0 ; j < nL0Slats ; j++ ) {
649 for ( k = 0 ; k < nL0Range ; k++ ) {
650 if ( k < minAdc ) lut1[i][j][k] = 0 ;
651 else if ( k < maxAdc ) lut1[i][j][k] = 4 ;
652 else lut1[i][j][k] = 17 ;
659 for ( i = 0 ; i < nL0Phi ; i++ ) {
660 for ( j = 0 ; j < nL0Eta ; j++ ) {
661 for ( k = 0 ; k < nL0Range ; k++ ) {
662 if ( k == 1 ) lut2[i][j][k] = 1 ;
663 else if ( k == 4 ) lut2[i][j][k] = 4 ;
664 else if ( k == 5 ) lut2[i][j][k] = 5 ;
665 else if ( k == 8 ) lut2[i][j][k] = 8 ;
666 else lut2[i][j][k] = 0 ;
673 for ( i = 0 ; i < 2 ; i++ ) {
674 for ( k = 0 ; k < nL0Range ; k++ ) {
683 void StPeCL0::setP4SLuts() {
697 for ( i = 0 ; i < 3 ; i++ ) {
698 for ( j = 0 ; j < nL0Slats ; j++ ) {
699 for ( k = 0 ; k < nL0Range ; k++ ) {
700 if ( k < minAdc ) lut1[i][j][k] = 0 ;
701 else lut1[i][j][k] = maxAdc ;
706 for ( i = 52 ; i < 60 ; i++ ) {
707 for ( j = 0 ; j < nL0Slats ; j++ ) {
708 for ( k = 0 ; k < nL0Range ; k++ ) {
709 if ( k < minAdc ) lut1[i][j][k] = 0 ;
710 else lut1[i][j][k] = maxAdc ;
717 for ( i = 22 ; i < 33 ; i++ ) {
718 for ( j = 0 ; j < nL0Slats ; j++ ) {
719 for ( k = 0 ; k < nL0Range ; k++ ) {
720 if ( k < minAdc ) lut1[i][j][k] = 0 ;
721 else lut1[i][j][k] = maxAdc ;
728 for ( i = 112 ; i < 120 ; i++ ) {
729 for ( j = 0 ; j < nL0Slats ; j++ ) {
730 for ( k = 0 ; k < nL0Range ; k++ ) {
731 if ( k < minAdc ) lut1[i][j][k] = 0 ;
732 else lut1[i][j][k] = maxAdc ;
737 for ( i = 60 ; i < 63 ; i++ ) {
738 for ( j = 0 ; j < nL0Slats ; j++ ) {
739 for ( k = 0 ; k < nL0Range ; k++ ) {
740 if ( k < minAdc ) lut1[i][j][k] = 0 ;
741 else lut1[i][j][k] = maxAdc ;
748 for ( i = 82 ; i < 93 ; i++ ) {
749 for ( j = 0 ; j < nL0Slats ; j++ ) {
750 for ( k = 0 ; k < nL0Range ; k++ ) {
751 if ( k < minAdc ) lut1[i][j][k] = 0 ;
752 else lut1[i][j][k] = maxAdc ;
762 for ( i = 33 ; i < 52 ; i++ ) {
763 for ( j = 0 ; j < nL0Slats ; j++ ) {
764 for ( k = 0 ; k < nL0Range ; k++ ) {
772 for ( i = 3 ; i < 22 ; i++ ) {
773 for ( j = 0 ; j < nL0Slats ; j++ ) {
774 for ( k = 0 ; k < nL0Range ; k++ ) {
782 for ( i = 63 ; i < 82 ; i++ ) {
783 for ( j = 0 ; j < nL0Slats ; j++ ) {
784 for ( k = 0 ; k < nL0Range ; k++ ) {
792 for ( i = 93 ; i < 112 ; i++ ) {
793 for ( j = 0 ; j < nL0Slats ; j++ ) {
794 for ( k = 0 ; k < nL0Range ; k++ ) {
802 int ns[4][4] = {{4,4,1,1},{1,1,4,4},{1,1,4,4},{4,4,1,1}};
803 int adc_sum_min=2, adc_sum_max=9;
805 for ( i = 0 ; i < nL0Phi ; i++ ) {
806 for ( j = 0 ; j < nL0Eta ; j++ ) {
807 for ( k = 0 ; k < nL0Range ; k++ ) {
808 if ( k <= adc_sum_min ) lut2[i][j][k] = 0 ;
809 else if ( k <= adc_sum_max ) lut2[i][j][k] = ns[i][j] ;
810 else if ( k <= 16 ) lut2[i][j][k] = 0 ;
811 else lut2[i][j][k] = k ;
818 for ( i = 0 ; i < 2 ; i++ ) {
819 for ( k = 0 ; k < nL0Range ; k++ ) {
820 if ( k == 1 || k == 4 || k == 5 ) lut3[i][k] = k ;
821 else lut3[i][k] = 0 ;
826 void StPeCL0::setYear1Input() {
827 for (
int i = 0 ; i < nL0Trays ; i++ ) {
832 void StPeCL0::setYear2Input() {
836 {
for (
int i = 0 ; i < 50 ; i++ ) {
837 cabling[i] = i + 10 ;
839 {
for (
int i = 50 ; i < 60 ; i++ ) {
840 cabling[i] = i - 50 ;
845 {
for (
int i = 65 ; i < 120 ; i++ ) {
848 {
for (
int i = 60 ; i < 65 ; i++ ) {
849 cabling[i] = 55 + i ;
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)