13 m_thresholdNumber{{0,1,2,3,4,5,6,7}, {8,9,10,11,12,13,14,15}},
14 m_thresholdNumber12{{0,1,2,3,4,5,6,7}, {8,1000,9,1000,10,1000,11,1000}}
22 m_thresholds_a.clear();
23 m_thresholds_c.clear();
24 m_thresholds_short_a.clear();
25 m_thresholds_short_c.clear();
26 m_thresholds_a.resize(16,0);
28 m_thresholds_c.resize(16,0);
30 m_thresholds_short_a.resize(12,0);
32 m_thresholds_short_c.resize(12,0);
34 m_cablestarts_a.clear();
35 m_cablestarts_c.clear();
36 m_cablestarts_a.resize(16,0);
37 m_cablestarts_c.resize(16,0);
47 for (std::shared_ptr<TrigConf::L1Threshold> thr :
l1menu->thresholds(
"MBTS")) {
48 if(thr->name() !=
"MBTS_A" && thr->name() !=
"MBTS_C") {
51 std::string connName =
l1menu->connectorNameFromThreshold(thr->name());
52 unsigned int startbit =
l1menu->connector(connName).triggerLine(thr->name()).startbit();
53 m_ThrVecSize12 =
true;
54 std::vector<float> hwThrValues;
55 if(thr->name() ==
"MBTS_A") {
56 m_cablestart_a = startbit;
58 m_thresholds_short_a = hwThrValues;
60 m_thresholds_a = hwThrValues;
63 m_cablestart_c = startbit;
65 m_thresholds_short_c = hwThrValues;
67 m_thresholds_c = hwThrValues;
73 for (std::shared_ptr<TrigConf::L1Threshold> thr :
l1menu->thresholds(
"MBTSSI")) {
75 std::string thrname = thr->name();
77 size_t module = std::stoi(thrname.substr(6));
79 std::string connName =
l1menu->connectorNameFromThreshold(thr->name());
80 unsigned int startbit =
l1menu->connector(connName).triggerLine(thr->name()).startbit();
81 ATH_MSG_INFO(
"Read " << thrname <<
" with voltage " << hwValue <<
"mV at bit " << startbit <<
" on " << connName);
83 bool isCSide = thrname.find(
"MBTS_C")==0;
85 if(
module >= m_thresholds_c.size()) {
88 m_thresholds_c[
module] = hwValue;
89 m_cablestarts_c[
module] = startbit;
91 }
else if(thrname.starts_with(
"MBTS_A") && thrname.size()>6) {
94 if(
module >= m_thresholds_a.size()) {
97 m_thresholds_a[
module] = hwValue;
98 m_cablestarts_a[
module] = startbit;
106 if(m_thresholds_a.size() != 16) {
107 ATH_MSG_INFO(
"MBTS_A Lvl 1 single input thresholds not set. Triggers will be disabled.");
108 m_thresholds_a.clear();
109 for(
size_t i=0;
i<16;
i++) {
110 m_thresholds_a.push_back(10000000);
113 if(m_thresholds_c.size() != 16) {
114 ATH_MSG_INFO(
"MBTS_C Lvl 1 single input thresholds not set. Triggers will be disabled.");
115 m_thresholds_c.clear();
116 for(
size_t i=0;
i<16;
i++) {
117 m_thresholds_c.push_back(10000000);
122 if(msgLvl(MSG::INFO)) {
123 msg(MSG::INFO) <<
"=================== Settings ==================" <<
endmsg;
124 msg(MSG::INFO) <<
"TileTTL1ContainerName = " << m_tileTTL1ContainerName <<
endmsg;
125 msg(MSG::INFO) <<
"Sample t0 bin index = " << m_tZeroBin <<
endmsg;
126 msg(MSG::INFO) <<
"CFD fraction constant = " << m_CFD_fraction <<
endmsg;
128 msg(MSG::INFO) <<
"C side thresholds for single inputs = {";
129 for(
size_t i=0;
i<12;
i++) {
130 msg(MSG::INFO) << m_thresholds_short_c[
i];
131 if(
i<11)
msg(MSG::INFO) <<
",";
134 msg(MSG::INFO) <<
"A side thresholds for single inputs = {";
135 for(
size_t i=0;
i<12;
i++) {
136 msg(MSG::INFO) << m_thresholds_short_a[
i];
137 if(
i<11)
msg(MSG::INFO) <<
",";
140 if(msgLvl(MSG::INFO)) {
142 for(
size_t j=0;j<2;j++) {
143 for(
size_t i=0;
i<8;
i++) {
151 msg(MSG::INFO) <<
"C side thresholds for single inputs = {";
152 for(
size_t i=0;
i<16;
i++) {
153 msg(MSG::INFO) << m_thresholds_c[
i];
154 if(
i<15)
msg(MSG::INFO) <<
",";
157 msg(MSG::INFO) <<
"A side thresholds for single inputs = {";
158 for(
size_t i=0;
i<16;
i++) {
159 msg(MSG::INFO) << m_thresholds_a[
i];
160 if(
i<15)
msg(MSG::INFO) <<
",";
166 for(
size_t j=0;j<2;j++) {
167 for(
size_t i=0;
i<8;
i++) {
173 msg(MSG::INFO) <<
"===============================================" <<
endmsg;
175 return StatusCode::SUCCESS;
183 StatusCode sc = evtStore()->retrieve(tileTTL1MBTSContainer, m_tileTTL1ContainerName);
184 if(
sc.isFailure() || !tileTTL1MBTSContainer ) {
185 ATH_MSG_WARNING(m_tileTTL1ContainerName <<
" not found. This event will be skipped.");
186 return StatusCode::SUCCESS;
192 if(tileTTL1MBTSContainer->size() > 32) {
193 if(!m_badDataFound) {
194 ATH_MSG_WARNING(
"BAD DATA!!! tileTTL1MBTSContainer->size() = " << tileTTL1MBTSContainer->size());
195 ATH_MSG_WARNING(
"There should be no more than 24 TileTTL1MBTS elements in one event.");
196 ATH_MSG_WARNING(
"This event will be skipped. Any further bad data will be skipped.");
197 m_badDataFound =
true;
199 return StatusCode::SUCCESS;
202 unsigned int triggersEBA = 0;
203 unsigned int triggersEBC = 0;
204 unsigned int single_triggers_A = 0;
205 unsigned int single_triggers_C = 0;
208 for(
const TileTTL1 * ttl1_mbts : *tileTTL1MBTSContainer) {
212 if (!m_tileTBID->is_tiletb(
id)) {
214 return StatusCode::FAILURE;
217 int phi = m_tileTBID->phi(
id);
218 if(phi < 0 || phi > 7) {
220 return StatusCode::FAILURE;
223 int channel = m_tileTBID->channel(
id);
224 if(channel < 0 || channel > 1) {
226 return StatusCode::FAILURE;
229 int detSide = m_tileTBID->type(
id);
230 if(detSide != -1 && detSide != 1) {
231 ATH_MSG_ERROR(
"Side value " << detSide <<
" is out of range!");
232 return StatusCode::FAILURE;
236 const std::vector<double> & samples = ttl1_mbts->samples();
237 unsigned int numSamples = samples.size();
238 if(m_tZeroBin >= numSamples) {
239 ATH_MSG_ERROR(
"t0 bin index " << m_tZeroBin <<
" is greater than the number of bins " << numSamples);
240 return StatusCode::FAILURE;
243 ATH_MSG_DEBUG(
"Sample [" << m_tZeroBin <<
"]=" << samples[m_tZeroBin]);
252 unsigned int thresholdIndex = m_thresholdNumber[
channel][phi];
253 unsigned int thresholdIndex12 = m_thresholdNumber12[
channel][phi];
254 if(thresholdIndex > (
unsigned int)m_thresholds_c.size() || thresholdIndex > (
unsigned int)m_thresholds_a.size()) {
255 ATH_MSG_ERROR(
"Threshold index \"" << thresholdIndex <<
"\" for single triggers is out of range.");
256 return StatusCode::FAILURE;
259 if(thresholdIndex12 == 1000){
260 ATH_MSG_DEBUG(
"this is a needless counter for run2, the sample will be skipped!");
265 float ThrValue_a = 0;
266 float ThrValue_c = 0;
268 ThrValue_a = m_thresholds_short_a[thresholdIndex12];
269 ThrValue_c = m_thresholds_short_c[thresholdIndex12];
271 ThrValue_a = m_thresholds_a[thresholdIndex];
272 ThrValue_c = m_thresholds_c[thresholdIndex];
275 if((samples[m_tZeroBin]*m_CFD_fraction > ThrValue_c && detSide == -1) ||
276 (samples[m_tZeroBin]*m_CFD_fraction > ThrValue_a && detSide == 1))
281 single_triggers_C += (1<<m_cablestarts_c[thresholdIndex]);
284 else if (detSide == 1)
286 single_triggers_A += (1<<m_cablestarts_a[thresholdIndex]);
290 ATH_MSG_DEBUG(
"Single input triggered on sample " << m_tZeroBin <<
" of " << numSamples <<
" bins.");
295 if (triggersEBA>7) triggersEBA=7;
296 if (triggersEBC>7) triggersEBC=7;
298 ATH_MSG_DEBUG(
"Multis: "<< triggersEBA <<
" and "<< triggersEBC );
300 unsigned int cableWordA = single_triggers_A + (triggersEBA<<m_cablestart_a);
301 unsigned int cableWordC = single_triggers_C + (triggersEBC<<m_cablestart_c);
308 ATH_MSG_DEBUG(
" (in CTPSimulation) mbtsA cable word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << mbtsACTP->cableWord0() );
309 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 ) ) );
311 ATH_MSG_DEBUG(
" (in CTPSimulation) mbtsC cable word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << mbtsCCTP->
cableWord0() );
312 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 ) ) );
314 ATH_CHECK(evtStore()->record(mbtsACTP, DEFAULT_MbtsACTPLocation,
false));
315 ATH_CHECK(evtStore()->record(mbtsCCTP, DEFAULT_MbtsCCTPLocation,
false));
317 return StatusCode::SUCCESS;