ATLAS Offline Software
Loading...
Searching...
No Matches
ThresholdMap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "./ThresholdMap.h"
6
7#include <cstdlib>
8
9
11{
12 //unsigned int start = 0;
13 for ( auto & thr : l1menu->thresholds() ) {
14 CTPTriggerThreshold * ctpThr = new CTPTriggerThreshold(thr->name());
15 /*
16 defining the start and stop bit is much more complex now, as
17 the CTP has many more inputs and the precise mapping of the
18 inputs to the TIP vector has to be worked out
19 */
20 m_mapByName[ctpThr->name()] = ctpThr;
21 }
22}
23
24
25LVL1CTP::ThresholdMap::ThresholdMap( const std::vector< TrigConf::TriggerThreshold* >& threshold_vector)
26{
27 unsigned int start = 0;
28 for ( TrigConf::TriggerThreshold* thr : threshold_vector ) {
29 CTPTriggerThreshold * ctpThr = new CTPTriggerThreshold(thr->name());
30 unsigned int end = start + abs( thr->cableStart() - thr->cableEnd() );
31 ctpThr->setStartBit( start );
32 ctpThr->setEndBit( end );
33 start = end + 1;
34 m_mapByName[thr->name()] = ctpThr;
35 }
36}
37
38LVL1CTP::ThresholdMap::ThresholdMap( const std::vector< TrigConf::TriggerThreshold* >& threshold_vector,
39 const std::vector< TrigConf::PIT* >& pit_vector)
40{
41 for ( TrigConf::TriggerThreshold* thr : threshold_vector ) {
42 CTPTriggerThreshold * ctpThr = new CTPTriggerThreshold(thr->name());
43 //default pit values: used if threshold doesn't have a corresponding pit bit
44 int pit_start=999;
45 int pit_end=-999;
46 for( TrigConf::PIT* pit : pit_vector ) {
47 if( pit->thresholdName() != thr->name() )
48 continue;
49 if( pit->pitNumber() < pit_start )
50 pit_start = pit->pitNumber();
51 if( pit->pitNumber() > pit_end )
52 pit_end = pit->pitNumber();
53 }
54 ctpThr->setStartBit( pit_start );
55 ctpThr->setEndBit( pit_end );
56 m_mapByName[thr->name()] = ctpThr;
57 }
58}
59
60
61LVL1CTP::ThresholdMap::ThresholdMap( const std::vector< TrigConf::TriggerThreshold* >& threshold_vector,
62 const std::vector< TrigConf::TIP* >& tip_vector)
63{
64 for ( TrigConf::TriggerThreshold* thr : threshold_vector ) {
65 CTPTriggerThreshold * ctpThr = new CTPTriggerThreshold(thr->name());
66 //default pit values: used if threshold doesn't have a corresponding pit bit
67 int tip_start=999;
68 int tip_end=-999;
69 for( TrigConf::TIP* tip : tip_vector){
70 if( tip->thresholdName() != thr->name() )
71 continue;
72 if( tip->tipNumber() < tip_start)
73 tip_start = tip->tipNumber();
74 if( tip->tipNumber() > tip_end )
75 tip_end = tip->tipNumber();
76 }
77 ctpThr->setStartBit( tip_start );
78 ctpThr->setEndBit( tip_end );
79 m_mapByName[thr->name()] = ctpThr;
80 }
81}
82
84 for ( auto & entry : m_mapByName ) {
85 delete entry.second;
86 }
87}
88
89std::vector<std::string>
91 std::vector<std::string> thrNames;
92 thrNames.reserve(m_mapByName.size());
93 for( auto & entry : m_mapByName ) {
94 thrNames.emplace_back(entry.first);
95 }
96 return thrNames;
97}
98
100LVL1CTP::ThresholdMap::getCTPThreshold( const std::string & thrName ) const {
101 try {
102 return * m_mapByName.at( thrName );
103 }
104 catch(std::exception&) {
105 throw std::runtime_error("Threshold " + thrName + " not present in CTPSimulation's internal threshold map");
106 }
107}
108
Helper class holding trigger threshold multiplicity.
const std::string & name() const
void setStartBit(unsigned int start)
Set the start position of the threshold.
void setEndBit(unsigned int end)
Set the end position of the threshold.
const CTPTriggerThreshold & getCTPThreshold(const std::string &thrName) const
std::map< std::string, const CTPTriggerThreshold * > m_mapByName
map storing the accosiation between threshold name and CTPTriggerThreshold
std::vector< std::string > getThresholdNames() const
~ThresholdMap()
default destructor
L1 menu configuration.
Definition L1Menu.h:28