15 m_thresholdNumber{{0,1,2,3,4,5,6,7}, {8,9,10,11,12,13,14,15}},
16 m_thresholdNumber12{{0,1,2,3,4,5,6,7}, {8,1000,9,1000,10,1000,11,1000}}
24 m_thresholds_a.clear();
25 m_thresholds_c.clear();
26 m_thresholds_short_a.clear();
27 m_thresholds_short_c.clear();
28 m_thresholds_a.resize(16,0);
30 m_thresholds_c.resize(16,0);
32 m_thresholds_short_a.resize(12,0);
34 m_thresholds_short_c.resize(12,0);
36 m_cablestarts_a.clear();
37 m_cablestarts_c.clear();
38 m_cablestarts_a.resize(16,0);
39 m_cablestarts_c.resize(16,0);
49 for (std::shared_ptr<TrigConf::L1Threshold>
thr :
l1menu->thresholds(
"MBTS")) {
50 if(
thr->name() !=
"MBTS_A" &&
thr->name() !=
"MBTS_C") {
53 std::string connName =
l1menu->connectorNameFromThreshold(
thr->name());
54 unsigned int startbit =
l1menu->connector(connName).triggerLine(
thr->name()).startbit();
55 m_ThrVecSize12 =
true;
56 std::vector<float> hwThrValues(12, 0.0);
57 if(
thr->name() ==
"MBTS_A") {
58 m_cablestart_a = startbit;
60 m_thresholds_short_a = std::move(hwThrValues);
62 m_thresholds_a = std::move(hwThrValues);
65 m_cablestart_c = startbit;
67 m_thresholds_short_c = std::move(hwThrValues);
69 m_thresholds_c = std::move(hwThrValues);
75 for (std::shared_ptr<TrigConf::L1Threshold>
thr :
l1menu->thresholds(
"MBTSSI")) {
77 std::string thrname =
thr->name();
79 size_t module = std::stoi(thrname.substr(6));
81 std::string connName =
l1menu->connectorNameFromThreshold(
thr->name());
82 unsigned int startbit =
l1menu->connector(connName).triggerLine(
thr->name()).startbit();
83 ATH_MSG_INFO(
"Read " << thrname <<
" with voltage " << hwValue <<
"mV at bit " << startbit <<
" on " << connName);
85 bool isCSide = thrname.find(
"MBTS_C")==0;
87 if(
module >= m_thresholds_c.size()) {
90 m_thresholds_c[
module] = hwValue;
91 m_cablestarts_c[
module] = startbit;
93 }
else if(thrname.starts_with(
"MBTS_A") && thrname.size()>6) {
96 if(
module >= m_thresholds_a.size()) {
99 m_thresholds_a[
module] = hwValue;
100 m_cablestarts_a[
module] = startbit;
108 if(m_thresholds_a.size() != 16) {
109 ATH_MSG_INFO(
"MBTS_A Lvl 1 single input thresholds not set. Triggers will be disabled.");
110 m_thresholds_a.clear();
111 for(
size_t i=0;
i<16;
i++) {
112 m_thresholds_a.push_back(10000000);
115 if(m_thresholds_c.size() != 16) {
116 ATH_MSG_INFO(
"MBTS_C Lvl 1 single input thresholds not set. Triggers will be disabled.");
117 m_thresholds_c.clear();
118 for(
size_t i=0;
i<16;
i++) {
119 m_thresholds_c.push_back(10000000);
130 msg(
MSG::INFO) <<
"C side thresholds for single inputs = {";
131 for(
size_t i=0;
i<12;
i++) {
136 msg(
MSG::INFO) <<
"A side thresholds for single inputs = {";
137 for(
size_t i=0;
i<12;
i++) {
144 for(
size_t j=0;j<2;j++) {
145 for(
size_t i=0;
i<8;
i++) {
153 msg(
MSG::INFO) <<
"C side thresholds for single inputs = {";
154 for(
size_t i=0;
i<16;
i++) {
159 msg(
MSG::INFO) <<
"A side thresholds for single inputs = {";
160 for(
size_t i=0;
i<16;
i++) {
168 for(
size_t j=0;j<2;j++) {
169 for(
size_t i=0;
i<8;
i++) {
177 return StatusCode::SUCCESS;
185 StatusCode sc = evtStore()->retrieve(tileTTL1MBTSContainer, m_tileTTL1ContainerName);
186 if(
sc.isFailure() || !tileTTL1MBTSContainer ) {
187 ATH_MSG_WARNING(m_tileTTL1ContainerName <<
" not found. This event will be skipped.");
188 return StatusCode::SUCCESS;
194 if(tileTTL1MBTSContainer->size() > 32) {
195 if(!m_badDataFound) {
196 ATH_MSG_WARNING(
"BAD DATA!!! tileTTL1MBTSContainer->size() = " << tileTTL1MBTSContainer->size());
197 ATH_MSG_WARNING(
"There should be no more than 24 TileTTL1MBTS elements in one event.");
198 ATH_MSG_WARNING(
"This event will be skipped. Any further bad data will be skipped.");
199 m_badDataFound =
true;
201 return StatusCode::SUCCESS;
204 unsigned int triggersEBA = 0;
205 unsigned int triggersEBC = 0;
206 unsigned int single_triggers_A = 0;
207 unsigned int single_triggers_C = 0;
210 for(
const TileTTL1 * ttl1_mbts : *tileTTL1MBTSContainer) {
214 if (!m_tileTBID->is_tiletb(
id)) {
216 return StatusCode::FAILURE;
219 int phi = m_tileTBID->phi(
id);
220 if(phi < 0 || phi > 7) {
222 return StatusCode::FAILURE;
225 int channel = m_tileTBID->channel(
id);
226 if(channel < 0 || channel > 1) {
228 return StatusCode::FAILURE;
231 int detSide = m_tileTBID->type(
id);
232 if(detSide != -1 && detSide != 1) {
233 ATH_MSG_ERROR(
"Side value " << detSide <<
" is out of range!");
234 return StatusCode::FAILURE;
238 const std::vector<double> & samples = ttl1_mbts->samples();
239 unsigned int numSamples = samples.size();
240 if(m_tZeroBin >= numSamples) {
241 ATH_MSG_ERROR(
"t0 bin index " << m_tZeroBin <<
" is greater than the number of bins " << numSamples);
242 return StatusCode::FAILURE;
245 ATH_MSG_DEBUG(
"Sample [" << m_tZeroBin <<
"]=" << samples[m_tZeroBin]);
254 unsigned int thresholdIndex = m_thresholdNumber[
channel][
phi];
255 unsigned int thresholdIndex12 = m_thresholdNumber12[
channel][
phi];
256 if(thresholdIndex > (
unsigned int)m_thresholds_c.size() || thresholdIndex > (
unsigned int)m_thresholds_a.size()) {
257 ATH_MSG_ERROR(
"Threshold index \"" << thresholdIndex <<
"\" for single triggers is out of range.");
258 return StatusCode::FAILURE;
261 if(thresholdIndex12 == 1000){
262 ATH_MSG_DEBUG(
"this is a needless counter for run2, the sample will be skipped!");
267 float ThrValue_a = 0;
268 float ThrValue_c = 0;
270 ThrValue_a = m_thresholds_short_a[thresholdIndex12];
271 ThrValue_c = m_thresholds_short_c[thresholdIndex12];
273 ThrValue_a = m_thresholds_a[thresholdIndex];
274 ThrValue_c = m_thresholds_c[thresholdIndex];
277 if((samples[m_tZeroBin]*m_CFD_fraction > ThrValue_c && detSide == -1) ||
278 (samples[m_tZeroBin]*m_CFD_fraction > ThrValue_a && detSide == 1))
283 single_triggers_C += (1<<m_cablestarts_c[thresholdIndex]);
286 else if (detSide == 1)
288 single_triggers_A += (1<<m_cablestarts_a[thresholdIndex]);
292 ATH_MSG_DEBUG(
"Single input triggered on sample " << m_tZeroBin <<
" of " << numSamples <<
" bins.");
297 if (triggersEBA>7) triggersEBA=7;
298 if (triggersEBC>7) triggersEBC=7;
300 ATH_MSG_DEBUG(
"Multis: "<< triggersEBA <<
" and "<< triggersEBC );
302 unsigned int cableWordA = single_triggers_A + (triggersEBA<<m_cablestart_a);
303 unsigned int cableWordC = single_triggers_C + (triggersEBC<<m_cablestart_c);
310 ATH_MSG_DEBUG(
" (in CTPSimulation) mbtsA cable word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << mbtsACTP->cableWord0() );
311 ATH_MSG_DEBUG(
" (in CTPSimulation) Mult of mbtsA is: "<<
static_cast<int>( (mbtsACTP->cableWord0() >> m_cablestart_a) &
static_cast<unsigned int>(
pow( 2, 3 ) - 1 ) ) );
313 ATH_MSG_DEBUG(
" (in CTPSimulation) mbtsC cable word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << mbtsCCTP->
cableWord0() );
314 ATH_MSG_DEBUG(
" (in CTPSimulation) Mult of mbtsC is: "<<
static_cast<int>( (mbtsCCTP->
cableWord0() >> m_cablestart_c) &
static_cast<unsigned int>(
pow( 2, 3 ) - 1 ) ) );
316 ATH_CHECK(evtStore()->record(mbtsACTP, DEFAULT_MbtsACTPLocation,
false));
317 ATH_CHECK(evtStore()->record(mbtsCCTP, DEFAULT_MbtsCCTPLocation,
false));
319 return StatusCode::SUCCESS;