ATLAS Offline Software
Loading...
Searching...
No Matches
CMApatterns.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
8
10#include <cmath>
11
13
15 TRIGdistance(99999.,99999.);
16
18
20 unsigned long int debug) :
21 RPCtrigDataObject(0,"CMA patterns"),
24m_pivot0("pivot0 ",PATTERNidentity(Pivot,0),CMAparameters::pivot_channels),
25m_pivot1("pivot1 ",PATTERNidentity(Pivot,1),CMAparameters::pivot_channels),
26m_lowPt0("lowPt0 ",PATTERNidentity(LowPt,0),CMAparameters::confirm_channels),
27m_lowPt1("lowPt1 ",PATTERNidentity(LowPt,1),CMAparameters::confirm_channels),
28m_highPt0("highPt0",PATTERNidentity(HighPt,0),CMAparameters::confirm_channels),
29m_highPt1("highPt1",PATTERNidentity(HighPt,1),CMAparameters::confirm_channels)
30{}
31
44
47{
48 static_cast<RPCtrigDataObject&>(*this) =
49 static_cast<const RPCtrigDataObject&>(patterns);
50 m_debug = patterns.debug();
51 m_sector = patterns.sector();
52 m_cma_parameters = &patterns.cma_parameters();
53 m_pivot0 = patterns.pivot0();
54 m_pivot1 = patterns.pivot1();
55 m_lowPt0 = patterns.lowPt0();
56 m_lowPt1 = patterns.lowPt1();
57 m_highPt0 = patterns.highPt0();
58 m_highPt1 = patterns.highPt1();
59 return *this;
60}
61
62bool
64{
65 if(m_sector == patterns.sector())
66 {
67 if (m_cma_parameters->id()==patterns.cma_parameters().id()) return true;
68 }
69 return false;
70}
71
72bool
74{
75 return !(*this == patterns);
76}
77
78
79bool
81{
82 if(m_sector < patterns.sector())
83 {
84 if (m_cma_parameters->id() < patterns.cma_parameters().id()) return true;
85 }
86 return false;
87}
88
89void
91{
92 int station = digit->decoding().lvl1_station();
93 int cabling = digit->decoding().cabling_code();
94
95 CMAinput IO = NoInput;
96 int channel = 0;
97 int layer = 0;
98
99 if(m_cma_parameters->give_connection(station,cabling,IO,layer,channel))
100 {
101 if(IO == Pivot)
102 {
103 if(layer) m_pivot1.set(digit,channel);
104 else m_pivot0.set(digit,channel);
105 }
106 else if (IO == LowPt)
107 {
108 if(layer) m_lowPt1.set(digit,channel);
109 else m_lowPt0.set(digit,channel);
110 }
111 else if (IO == HighPt)
112 {
113 if(layer) m_highPt1.set(digit,channel);
114 else m_highPt0.set(digit,channel);
115 }
116 }
117}
118
121{
122
123 bitPATTERN pattern(data);
124
125 for(int i=0;i<pattern.size();++i)
126 {
127 if(pattern.test(i))
128 {
129 int cluster_size = 0;
130 do { ++cluster_size; } while( pattern.test(i+cluster_size) );
131
132 int decl_lower = 1;
133 int decl_upper = cluster_size;
134
135 switch (cluster_size%2)
136 {
137 case 0:
138 for( ;decl_lower+1 < decl_upper && decl_lower<=3; ++decl_lower)
139 {
140 pattern.unset(i - 1 + decl_lower);
141 pattern.unset(i - 1 + decl_upper);
142 --decl_upper;
143 }
144 break;
145 case 1:
146 for( ;decl_lower+1 < decl_upper && decl_lower<=3; ++decl_lower)
147 {
148 pattern.unset(i - 1 + decl_lower);
149 pattern.unset(i - 1 + decl_upper);
150 --decl_upper;
151 }
152 }
153 i += (cluster_size - 1);
154 }
155 }
156 return pattern;
157}
158
159
162{
163
164 int left = 1;
165 int right = 1;
166
167 bitPATTERN result(layer0.name(),layer0.id(),layer0.size());
168 bitPATTERN tmp1(layer1);
169 bitPATTERN tmp2(layer1);
170
171 result |= layer0 & layer1;
172 for(int i=0;i<left;++i) result |= layer0 & (tmp1<<1);
173 for(int i=0;i<right;++i) result |= layer0 & (tmp2>>1);
174
175 for (int i=0;i<result.size();++i)
176 {
177 if(result.test(i))
178 {
179 layer0.unset(i);
180 layer0.unset(i-1);
181 layer0.unset(i+1);
182 layer1.unset(i);
183 layer1.unset(i-1);
184 layer1.unset(i+1);
185 }
186 }
187
188 return result;
189}
190
191void
193{
194 if(std::fabs(NEW.first) < std::fabs(OLD.first)) OLD = NEW;
195}
196
197void
199const
200{
201
202 lowTr = no_distance;
203 highTr = no_distance;
204
211
215
216 update_distance( lowest_distance(pivot2,lowPt2) , lowTr );
217 update_distance( lowest_distance(pivot2,lowPt0) , lowTr );
218 update_distance( lowest_distance(pivot2,lowPt1) , lowTr );
219 update_distance( lowest_distance(pivot0,lowPt2) , lowTr );
220 update_distance( lowest_distance(pivot1,lowPt2) , lowTr );
221
222 update_distance( lowest_distance(pivot2,highPt2) , highTr );
223 update_distance( lowest_distance(pivot2,highPt0) , highTr );
224 update_distance( lowest_distance(pivot2,highPt1) , highTr );
225 update_distance( lowest_distance(pivot0,highPt2) , highTr );
226 update_distance( lowest_distance(pivot1,highPt2) , highTr );
227}
228
231const
232{
233 if ( !pivot.any() || !confirm.any() ) return no_distance;
234
236
237 for(int i=0;i<pivot.size();++i)
238 {
239 if(const RPCdigit* pivot_digit = pivot[i])
240 {
241 for(int j=0;j<confirm.size();++j)
242 {
243 if(const RPCdigit* confirm_digit = confirm[j])
244 {
245 update_distance(distance(pivot_digit,confirm_digit),value);
246 }
247 }
248 }
249 }
250
251 return value;
252}
253
255CMApatterns::distance(const RPCdigit* pivot,const RPCdigit* confirm) const
256{
257
258
260 float pivrad = 0;
261 float conrad = 0;
262 if( pivot->station_radius(pivrad) && confirm->station_radius(conrad) )
263 {
264 if(pivot->decoding().view() == Eta)
265 {
266 if(pivot->station_eta(value.second))
267 {
268 float Zprime = pivot->z()*(conrad/pivrad);
269 value.first = confirm->z() - Zprime;
270 }
271 }
272 else if (pivot->decoding().view() == Phi)
273 {
274 float pivphi = 0;
275 float conphi = 0;
276 float staphi = 0;
277 if( pivot->phi(pivphi) &&
278 confirm->phi(conphi) &&
279 pivot->station_phi(staphi) &&
280 pivot->station_eta(value.second) )
281 {
282 float Sprime = std::tan(pivphi-staphi)*conrad;
283 value.first = std::tan(conphi-staphi)*conrad - Sprime;
284 }
285 }
286 }
287 return value;
288}
289
290const CMAtrigger
292{
293
294
295
297 {
298 return CMAtrigger(type,this);
299 }
300 else
301 {
302 TrigSigns signatures;
303 search_for_lowPt(type,signatures);
304 if(!signatures.empty())
305 {
306 if(signatures.top().trigger().searchForHigh())
307 search_for_highPt(type,signatures);
308 return signatures.top();
309 }
310 else return CMAtrigger(type,this);
311 }
312}
313
314void
316{
317
318
323
325 bitPATTERN lowPt2 = majority(lowPt0,lowPt1);
326
327 search_signatures(type,Low,signatures,pivot2,lowPt2);
328 search_signatures(type,Low,signatures,pivot2,lowPt0);
329 search_signatures(type,Low,signatures,pivot2,lowPt1);
330 search_signatures(type,Low,signatures,pivot0,lowPt2);
331 search_signatures(type,Low,signatures,pivot1,lowPt2);
332}
333
334void
336{
337
338
341
343
344 TrigSigns tmp;
345
346 while(!signatures.empty())
347 {
348 CMAtrigger signature = signatures.top();
349 signatures.pop();
350 if(signature.trigger().searchForHigh())
351 {
352 search_signatures(type,High,signature,highPt2);
355 tmp.push(signature);
356 }
357 }
358
359 signatures = std::move(tmp);
360}
361
362
363void
365 TrigSigns& signatures,
366 const bitPATTERN& pivot,
367 const bitPATTERN& confirm) const
368{
369
370 if ( !pivot.any() || !confirm.any() ) return;
371
372 for(int i=0;i<pivot.size();++i)
373 {
374 if(const RPCdigit* pivot_digit = pivot[i])
375 {
376 // Start searching for trigger signature
377 CMAtrigger trigger_result(algoType,this);
378
379 for(int j=0;j<confirm.size();++j)
380 {
381 if(const RPCdigit* confirm_digit = confirm[j])
382 {
383 TRIGdistance d = distance(pivot_digit,confirm_digit);
384 CMAtrigger signature(algoType,this);
385
386 if(algoType == GeometricAlgo)
387 {
388 signature = trigger_window(d,trigType);
389 }
390 else if (algoType == LogicEmulation)
391 {
392 signature = trigger_threshold(i,j,trigType);
393 }
394
395 if(trigType == Low)
396 {
397 signature.set_pivot(pivot_digit);
398 signature.set_lowPt(confirm_digit);
399 }
400 else if(trigType == High)
401 {
402 signature.set_highPt(confirm_digit);
403 }
404 signature.set_width(d.first);
405 signature.set_Kpatt(i);
406 trigger_result += signature;
407 }
408
409 //if ( trigger_result.trigger().highest(trigType) ) break;
410 }
411 if(trigger_result.trigger().type()!=None)
412 signatures.push(trigger_result);
413 }
414 }
415}
416
417
418void
420 CMAtrigger& trigger_result,
421 const bitPATTERN& confirm) const
422{
423
424 if ( !confirm.any() ) return;
425
426
427 const RPCdigit* pivot_digit = trigger_result.pivot_hit();
428 const int Kpatt = trigger_result.Kpatt();
429
430 // Start searching for trigger signature
431 CMAtrigger signature(algoType,this);
432
433 for(int j=0;j<confirm.size();++j)
434 {
435 if(const RPCdigit* confirm_digit = confirm[j])
436 {
437 TRIGdistance d = distance(pivot_digit,confirm_digit);
438
439 if(algoType == GeometricAlgo)
440 {
441 signature = trigger_window(d,trigType);
442 }
443 else if (algoType == LogicEmulation)
444 {
445 signature = trigger_threshold(Kpatt,j,trigType);
446 }
447
448 if(trigType == Low)
449 {
450 signature.set_pivot(pivot_digit);
451 signature.set_lowPt(confirm_digit);
452 }
453 else if(trigType == High)
454 {
455 signature.set_highPt(confirm_digit);
456 }
457 signature.set_width(d.first);
458 signature.set_Kpatt(Kpatt);
459 trigger_result += signature;
460 }
461
462 //if ( trigger_result.trigger().highest(trigType) ) break;
463 }
464}
465
466
469 const bitPATTERN& highPt) const
470{
471
472
473 CMAtrigger trigger_result(GeometricAlgo,this);
474
475 if ( !pivot.any() || !lowPt.any() ) return trigger_result;
476
477 for(int i=0;i<pivot.size();++i)
478 {
479 if(const RPCdigit* pivot_digit = pivot[i])
480 {
481 // Start searching for Low Pt trigger signature
482 for(int j=0;j<lowPt.size();++j)
483 {
484 if(const RPCdigit* confirm_digit = lowPt[j])
485 {
486 TRIGdistance d = distance(pivot_digit,confirm_digit);
487 CMAtrigger signature = trigger_window(d,Low);
488 signature.set_pivot(pivot_digit);
489 signature.set_lowPt(confirm_digit);
490 trigger_result += signature;
491 }
492
493 // if Low Pt Third threshold has fired
494 if ( trigger_result.trigger().searchForHigh() )
495 {
496 // Start searching for High Pt trigger signature
497 for(int k=0;k<highPt.size();++k)
498 {
499 if(const RPCdigit* confirm_digit = highPt[k])
500 {
501 TRIGdistance d=distance(pivot_digit,confirm_digit);
502 CMAtrigger signature = trigger_window(d,High);
503 signature.set_highPt(confirm_digit);
504 trigger_result += signature;
505 }
506 if( trigger_result.trigger().highest(High) ) break;
507 }
508 }
509 if ( trigger_result.trigger().highest(High) ) break;
510 }
511 }
512 if ( trigger_result.trigger().highest(High) ) break;
513 }
514
515 return trigger_result;
516}
517
518
521 const bitPATTERN& highPt0,const bitPATTERN& highPt1) const
522{
523
524 CMAtrigger trigger_result(GeometricAlgo,this);
525
526 if ( !pivot.any() || !lowPt.any() ) return trigger_result;
527
528 for(int i=0;i<pivot.size();++i)
529 {
530 if(const RPCdigit* pivot_digit = pivot[i])
531 {
532 // Start searching for Low Pt trigger signature
533 for(int j=0;j<lowPt.size();++j)
534 {
535 if(const RPCdigit* confirm_digit = lowPt[j])
536 {
537 TRIGdistance d = distance(pivot_digit,confirm_digit);
538 CMAtrigger signature = trigger_window(d,Low);
539 signature.set_pivot(pivot_digit);
540 signature.set_lowPt(confirm_digit);
541 trigger_result += signature;
542 }
543
544 // if Low Pt Third threshold has fired
545 if ( trigger_result.trigger().searchForHigh() )
546 {
547 // Start searching for High Pt trigger signature in plane 0
548 for(int k=0;k<highPt0.size();++k)
549 {
550 if(const RPCdigit* confirm_digit = highPt0[k])
551 {
552 TRIGdistance d=distance(pivot_digit,confirm_digit);
553 CMAtrigger signature = trigger_window(d,High);
554 signature.set_highPt(confirm_digit);
555 trigger_result += signature;
556 }
557 if( trigger_result.trigger().highest(High) ) break;
558 }
559 }
560
561 // if Low Pt Third threshold has fired
562 if ( trigger_result.trigger().searchForHigh() )
563 {
564 // Start searching for High Pt trigger signature in plane 1
565 for(int k=0;k<highPt1.size();++k)
566 {
567 if(const RPCdigit* confirm_digit = highPt1[k])
568 {
569 TRIGdistance d=distance(pivot_digit,confirm_digit);
570 CMAtrigger signature = trigger_window(d,High);
571 signature.set_highPt(confirm_digit);
572 trigger_result += signature;
573 }
574 if( trigger_result.trigger().highest(High) ) break;
575 }
576 }
577 if ( trigger_result.trigger().highest(High) ) break;
578 }
579 }
580 if ( trigger_result.trigger().highest(High) ) break;
581 }
582
583 return trigger_result;
584}
585
588{
589
590 if (type == None) return CMAtrigger(GeometricAlgo,this);
591
592 if(m_cma_parameters->id().type() == Eta)
593 {
594 //implement the geometric coincidence for the eta projection
595 int upper_threshold = (type == Low)? 2 : 4;
596 int lower_threshold = (type == Low)? 0 : 3;
597
598 for(int i=upper_threshold; i >= lower_threshold;--i)
599 {
600 if (windows(dist.first,dist.second,i,m_sector%32))
601 {
603 if ( (i%3) == 0 ) threshold = FirstTh;
604 else if ( (i%3) == 1 ) threshold = SecondTh;
605 else if ( (i%3) == 2 ) threshold = ThirdTh;
607 }
608 }
609 }
610 else if (m_cma_parameters->id().type() == Phi)
611 {
612 //implement the geometric coincidence for the phi projection
613 if(type == Low)
614 {
615 // set the trigger window width equal to 10 centimeters
616 if(fabsf(dist.first)<10.0)
618 }
619 else if (type == High)
620 {
621 // set the trigger window width equal to 10 centimeters
622 if(fabsf(dist.first)<10.0)
624 }
625 }
626
627 return CMAtrigger(GeometricAlgo,this);
628}
629
631CMApatterns::trigger_threshold(int pivot,int confirm,TrigType type) const
632{
633
634 if (type == None) return CMAtrigger(LogicEmulation,this);
635
636 const int pivch = CMAparameters::pivot_channels;
637 const int conch = CMAparameters::confirm_channels;
638
639 const bool* program = 0;
640
641 if(type == Low)
642 {
643 if(const CMAprogram* prog = cma_parameters().lowPt_program() )
644 {
645 // avoid to use the Phi program for the time being ///////////
646 if(cma_parameters().id().type() == Phi) //
647 return CMAtrigger(LogicEmulation,type,ThirdTh,this); //
649 program = prog->registers();
650 }
651 else return CMAtrigger(LogicEmulation,type,ThirdTh,this);
652 }
653 else
654 {
655 if(const CMAprogram* prog = cma_parameters().highPt_program() )
656 {
657 // avoid to use the Phi program for the time being ///////////
658 if(cma_parameters().id().type() == Phi) //
659 return CMAtrigger(LogicEmulation,type,ThirdTh,this); //
661 program = prog->registers();
662 }
663 else return CMAtrigger(LogicEmulation,type,ThirdTh,this);
664 }
665
666
667 for(int th=2;th>=0;--th)
668 {
669 int pos = th*pivch*conch + pivot*conch + confirm;
670 if(*(program+pos))
671 {
672 Threshold threshold = static_cast<Threshold>(th);
674 }
675 }
676 return CMAtrigger(LogicEmulation,this);
677}
678
681{
682 load_digit(digit);
683 return *this;
684}
685
686void CMApatterns::Print(std::ostream& stream,bool detail) const
687{
688 //unsigned int upper = 19;
689 //unsigned int lower = 17;
690
691 unsigned int upper = 95;
692 unsigned int lower = 45;
693
694 for(int i=0;i<80;++i) stream << (char) upper;
695 stream << std::endl;
696
697 stream << name() << " giving input to: logic sector = " << m_sector
698 << ", sector type = " << cma_parameters().sector_type() << std::endl;
699 stream << cma_parameters() << std::endl;
700
701 //bitPATTERN layer0 = decluster(pivot0());
702 //bitPATTERN layer1 (pivot1());
703
704 pivot1().Print(stream,detail);
705 pivot0().Print(stream,detail);
706
707 //layer0.Print(stream,detail); // test for declustering
708 //stream << majority(layer0,layer1); // test for majority logic
709 //layer1.Print(stream,detail); // test for majority logic
710 //layer0.Print(stream,detail); // test for majority logic
711
712 lowPt1().Print(stream,detail);
713 lowPt0().Print(stream,detail);
714 highPt1().Print(stream,detail);
715 highPt0().Print(stream,detail);
716
717 for(int i=0;i<80;++i) stream << (char) lower;
718 stream << std::endl;
719}
720
721void
723{
724
725 if(type == None) return;
726
727 int run = 0;
728 int event = 0;
729 unsigned int long debug = m_debug;
730 int subsystem = (m_sector<32)? 0 : 1;
731 int proj = cma_parameters().id().type();
732 int sector = m_sector%32;
733 int PADadd = cma_parameters().id().PAD_index();
734 int lohi = (type == Low) ? 0 : 1;
735 int address[2] = { cma_parameters().id().eta_index(),
737 int localAdd = cma_parameters().id().Ixx_index();
738
739
740 // Instanciate the Matrix
741
742 auto matrix = std::make_unique<Matrix>(run,event,debug,subsystem,proj,sector,PADadd,lohi,
743 address,localAdd, NOBXS, BCZERO);
744
746 // ****************** START PROGRAMMING THE MATRIX ****************** //
748
749
750 // Loading pivot data into Matrix
751 // load_data(0,0,m_pivot0,matrix);
752 // load_data(0,1,m_pivot1,matrix);
753
754
755 // Specify the readout threshold to be transmitted into the readout
756 matrix->setKReadOut(0);
757
758 // Specify the AND/OR logic for a matrix input (0=pivot, 1=coincidence)
759 matrix->setLocalDirection(0,7);
760 matrix->setLocalDirection(1,7);
761
762 // Specify the width of the pulse signal in Matrix clock thick (320 Mhz)
763 matrix->setPulseWidth(4);
764
765 if(type == Low)
766 {
767 // Loading pivot data into Matrix
768 load_data(0,0,m_pivot0,matrix.get());
769 load_data(0,1,m_pivot1,matrix.get());
770
771 // Load the theshold registers into Matrix hardware simulation
772 const CMAprogram* program = cma_parameters().lowPt_program();
773 const int pivot_ch = CMAparameters::pivot_channels;
774
775 CMAword ovl1 = 0x0;
776 CMAword ovl2 = 0x0;
777 CMAword maj_th0 = 0x2;
778 CMAword maj_th1 = 0x2;
779 CMAword maj_th2 = 0x2;
780
781
782 if(program)
783 {
784 if(cma_parameters().id().type() == Phi)
785 {
786 const uint32_t* bytes = program->bytes();
787
788 for(int th=0;th<3;++th) // loop over thresholds
789 for (int ch=0; ch<pivot_ch; ++ch) // loop over channels
790 for (int by=0;by<2;++by) // loop over bytes
791 {
792 // G.Bruni, M.Corradi 1/3/2010 set phi roads for new cabling
793 if (cma_parameters().conf_type() != CMAparameters::Atlas){
794 matrix->setRoad(th,ch,by,0xffffffff); // old cabling, keep the phi roads all open
795 } else {
796 int pos = th*pivot_ch*2 + ch*2 + by;
797 matrix->setRoad(th,ch,by,bytes[pos]);
798 }
799 }
800 }
801 else
802 {
803
804 const uint32_t* bytes = program->bytes();
805
806 for(int th=0;th<3;++th) // loop over thresholds
807 for (int ch=0; ch<pivot_ch; ++ch) // loop over channels
808 for (int by=0;by<2;++by) // loop over bytes
809 {
810 int pos = th*pivot_ch*2 + ch*2 + by;
811 matrix->setRoad(th,ch,by,bytes[pos]);
812 }
813 }
814
815 ovl1 = program->overlap1();
816 ovl2 = program->overlap2();
817 maj_th0 = program->trig_thr0_maj_reg();
818 maj_th1 = program->trig_thr1_maj_reg();
819 maj_th2 = program->trig_thr2_maj_reg();
820
821
822 }
823 else if (!program && cma_parameters().id().type() == Phi)
824 {
825 // open only the Phi matrix if no program is found
826
827 for(int th=0;th<3;++th) // loop over thresholds
828 for (int ch=0; ch<pivot_ch; ++ch) // loop over channels
829 for (int by=0;by<2;++by) // loop over bytes
830 {
831 matrix->setRoad(th,ch,by,0xffffffff);
832 }
833 }
834
835 // Load the Majority logic setup
836 matrix->setMajority(0,maj_th0);
837 matrix->setMajority(1,maj_th1);
838 matrix->setMajority(2,maj_th2);
839
840 //matrix->setMask1(0,1);
841
842 // Load the Overlap flag
843 matrix->setMatOverlap(0, ovl1);
844 matrix->setMatOverlap(1, ovl2);
845
846 // Load Low Pt plane data into Matrix
847 load_data(1,0,m_lowPt0,matrix.get());
848 load_data(1,1,m_lowPt1,matrix.get());
849
850 // Execute the matrix simulation
851 matrix->execute();
852 m_low_pt_matrix = std::move(matrix);
853 }
854 else
855 {
856 // Load the theshold registers into Matrix hardware simulation
857 const CMAprogram* program = cma_parameters().highPt_program();
858 const int pivot_ch = CMAparameters::pivot_channels;
859
860 CMAword ovl1 = 0x0;
861 CMAword ovl2 = 0x0;
862 CMAword maj_th0 = 0x1;
863 CMAword maj_th1 = 0x1;
864 CMAword maj_th2 = 0x1;
865
866 if(program)
867 {
868
869 if(cma_parameters().id().type() == Phi)
870 {
871 const uint32_t* bytes = program->bytes();
872
873 for(int th=0;th<3;++th) // loop over thresholds
874 for (int ch=0; ch<pivot_ch; ++ch) // loop over channels
875 for (int by=0;by<2;++by) // loop over bytes
876 {
877 // G.Bruni, M.Corradi 1/3/2010 set phi roads for new cabling
878 if (cma_parameters().conf_type()!= CMAparameters::Atlas){
879 matrix->setRoad(th,ch,by,0xffffffff); // old cabling, keep the phi roads all open
880 } else {
881 int pos = th*pivot_ch*2 + ch*2 + by;
882 matrix->setRoad(th,ch,by,bytes[pos]);
883 }
884 }
885 }
886 else
887 {
888 const uint32_t* bytes = program->bytes();
889 for(int th=0;th<3;++th) // loop over thresholds
890 for (int ch=0; ch<pivot_ch; ++ch) // loop over channels
891 for (int by=0;by<2;++by) // loop over bytes
892 {
893 int pos = th*pivot_ch*2 + ch*2 + by;
894 matrix->setRoad(th,ch,by,bytes[pos]);
895 }
896 }
897
898 ovl1 = program->overlap1();
899 ovl2 = program->overlap2();
900 maj_th0 = program->trig_thr0_maj_reg();
901 maj_th1 = program->trig_thr1_maj_reg();
902 maj_th2 = program->trig_thr2_maj_reg();
903
904 }
905 else if (!program && cma_parameters().id().type() == Phi)
906 {
907
908 // open only the Phi matrix if no program is found
909
910 for(int th=0;th<3;++th) // loop over thresholds
911 for (int ch=0; ch<pivot_ch; ++ch) // loop over channels
912 for (int by=0;by<2;++by) // loop over bytes
913 {
914 matrix->setRoad(th,ch,by,0xffffffff);
915 }
916 }
917 // Load the Majority logic setup
918 matrix->setMajority(0,maj_th0);
919 matrix->setMajority(1,maj_th1);
920 matrix->setMajority(2,maj_th2);
921
922 // Load the Overlap flag
923 matrix->setMatOverlap(0, ovl1);
924 matrix->setMatOverlap(1, ovl2);
925
926 // Load High Pt plane data into Matrix
927 load_data(1,0,m_highPt0,matrix.get());
928 load_data(1,1,m_highPt1,matrix.get());
929
930 if(!m_low_pt_matrix) create_hardware(Low, NOBXS, BCZERO);
931
932 // Put the Low Pt patterns into the High Pt Matrix input
933 matrix->putPatt(m_low_pt_matrix.get());
934
935 // Execute the matrix simulation
936 matrix->execute();
937 m_high_pt_matrix = std::move(matrix);
938 }
939}
940
941void
942CMApatterns::load_data(int side,int layer,const bitPATTERN& pattern,
943 Matrix* mat)
944{
945
946 if(pattern.any())
947 {
948 for (int i=0;i<pattern.size();++i)
949 {
950 if(pattern.test(i)) mat->putData(side,layer,i,pattern[i]->time());
951 }
952 }
953}
954
955Matrix*
957{
958
959 if(!m_low_pt_matrix) create_hardware(Low, NOBXS, BCZERO);
960 return m_low_pt_matrix.get();
961}
962
963
964Matrix*
966{
967
968 if(!m_high_pt_matrix) create_hardware(High, NOBXS, BCZERO);
969 return m_high_pt_matrix.get();
970}
CMAinput
@ LowPt
@ NoInput
@ HighPt
@ Pivot
Lvl1RPCalgo
Definition CMAtrigger.h:20
@ HardwareEmulation
Definition CMAtrigger.h:20
@ LogicEmulation
Definition CMAtrigger.h:20
@ GeometricAlgo
Definition CMAtrigger.h:20
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
int upper(int c)
unsigned int uint
uint32_t CMAword
Definition Lvl1Def.h:17
TrigType
@ High
@ Low
@ None
Threshold
@ SecondTh
@ FirstTh
@ ThirdTh
const std::string & name() const
Definition BaseObject.h:23
ViewType type() const
int Ixx_index() const
int PAD_index() const
int eta_index() const
int phi_index() const
static constexpr int confirm_channels
const CMAidentity & id() const
const CMAprogram * lowPt_program() const
static constexpr int pivot_channels
const CMAprogram * highPt_program() const
bool operator==(const CMApatterns &) const
bitPATTERN m_highPt0
Definition CMApatterns.h:39
void Print(std::ostream &, bool) const
std::unique_ptr< Matrix > m_low_pt_matrix
Definition CMApatterns.h:42
const TRIGdistance lowest_distance(const bitPATTERN &, const bitPATTERN &) const
bitPATTERN m_pivot1
Definition CMApatterns.h:36
const bitPATTERN & pivot1(void) const
Definition CMApatterns.h:90
unsigned long int debug(void) const
Definition CMApatterns.h:84
CMAtrigger find_trigger(const bitPATTERN &, const bitPATTERN &, const bitPATTERN &) const
std::unique_ptr< Matrix > m_high_pt_matrix
Definition CMApatterns.h:43
static const TRIGdistance no_distance
Definition CMApatterns.h:24
bitPATTERN decluster(const bitPATTERN &) const
bitPATTERN m_lowPt1
Definition CMApatterns.h:38
Matrix * give_high_pt_matrix(uint NOBXS, uint BCZERO)
void coincidence_distance(TRIGdistance &, TRIGdistance &) const
void search_for_lowPt(Lvl1RPCalgo, TrigSigns &) const
bool operator<(const CMApatterns &) const
bool operator!=(const CMApatterns &) const
const bitPATTERN & lowPt0(void) const
Definition CMApatterns.h:91
std::priority_queue< CMAtrigger > TrigSigns
Definition CMApatterns.h:27
CMApatterns operator=(const CMApatterns &)
bitPATTERN majority(bitPATTERN &, bitPATTERN &) const
int sector(void) const
Definition CMApatterns.h:86
CMAtrigger trigger_threshold(int, int, TrigType) const
const bitPATTERN & pivot0(void) const
Definition CMApatterns.h:89
bitPATTERN m_highPt1
Definition CMApatterns.h:40
const CMAparameters * m_cma_parameters
Definition CMApatterns.h:33
CMApatterns & operator<<(const RPCdigit *)
const bitPATTERN & highPt0(void) const
Definition CMApatterns.h:93
const CMAparameters & cma_parameters(void) const
Definition CMApatterns.h:87
bitPATTERN m_pivot0
Definition CMApatterns.h:35
const TRIGdistance distance(const RPCdigit *, const RPCdigit *) const
void load_digit(const RPCdigit *)
void search_signatures(Lvl1RPCalgo, TrigType, TrigSigns &, const bitPATTERN &, const bitPATTERN &) const
const CMAtrigger give_trigger(Lvl1RPCalgo) const
CMAtrigger trigger_window(TRIGdistance, TrigType) const
void search_for_highPt(Lvl1RPCalgo, TrigSigns &) const
CMApatterns(int, const CMAparameters *, unsigned long int)
void create_hardware(TrigType, uint NOBXS, uint BCZERO)
void update_distance(const TRIGdistance &, TRIGdistance &) const
Matrix * give_low_pt_matrix(uint NOBXS, uint BCZERO)
unsigned long int m_debug
Definition CMApatterns.h:30
void load_data(int, int, const bitPATTERN &, Matrix *)
const bitPATTERN & highPt1(void) const
Definition CMApatterns.h:94
bitPATTERN m_lowPt0
Definition CMApatterns.h:37
std::pair< float, float > TRIGdistance
Definition CMApatterns.h:23
const bitPATTERN & lowPt1(void) const
Definition CMApatterns.h:92
uint32_t overlap2(void) const
Definition CMAprogram.h:124
uint8_t trig_thr2_maj_reg() const
Definition CMAprogram.h:257
const uint32_t * bytes(void) const
Definition CMAprogram.h:120
uint8_t trig_thr0_maj_reg() const
Definition CMAprogram.h:245
uint8_t trig_thr1_maj_reg() const
Definition CMAprogram.h:251
uint32_t overlap1(void) const
Definition CMAprogram.h:123
int Kpatt(void) const
Definition CMAtrigger.h:63
void set_pivot(const RPCdigit *)
void set_highPt(const RPCdigit *)
void set_Kpatt(int Kpatt)
void set_width(const float width)
void set_lowPt(const RPCdigit *)
const RPCdigit * pivot_hit(void) const
Definition CMAtrigger.h:59
const TRIGGERidentity & trigger(void) const
Definition CMAtrigger.h:57
int sector_type() const
ViewType view(void) const
float z(void) const
Definition RPCdigit.h:55
const RPCdecoder & decoding(void) const
Definition RPCdigit.h:48
bool station_phi(float &) const
Definition RPCdigit.h:93
bool station_eta(float &) const
Definition RPCdigit.cxx:227
bool phi(float &) const
Definition RPCdigit.cxx:217
bool station_radius(float &) const
Definition RPCdigit.h:81
RPCtrigDataObject(int, const std::string &)
bool searchForHigh(void) const
bool highest(TrigType) const
TrigType type(void) const
const PATTERNidentity & id(void) const
Definition bitPATTERN.h:39
void Print(std::ostream &, bool detail) const
void unset(int)
bool any(void) const
int size(void) const
Definition bitPATTERN.h:41
std::vector< std::string > patterns
Definition listroot.cxx:187
Definition run.py:1
int windows(float distance, float eta_pivot, int thr, int sector)
Definition windows.cxx:14