30 return StatusCode::SUCCESS;
41 ATH_MSG_DEBUG(
"RunParameters:: readoutConfigID " << readoutConfigID);
47 return StatusCode::FAILURE;
51 std::vector<MonitorTT> vecMonTT;
53 const int nCrates = 8;
60 std::vector<int> LutCp;
61 std::vector<int> LutJep;
62 std::vector<int> BcidR;
63 std::vector<int> BcidD;
72 std::vector<std::string> mismatch_map= {
"NonZeroMatches",
"ZeroMatches",
"DataNoSim",
"SimNoData"};
73 std::vector<std::string> lut_map= {
"SimEqData",
"SimNeData",
"SimNoData",
"DataNoSim"};
74 std::vector<std::string> crate_map= {
"cr0cr1",
"cr2cr3",
"cr4cr5",
"cr6cr7"};
77 const int maxErrorsPerLB=10;
81 const long long eventNumber = ctx.eventID().event_number();
88 for (
auto& myTower : vecMonTT) {
91 const int datCp = (myTower.tower)->cpET();
92 const int datJep = (myTower.tower)->lut_jep().empty() ? 0 : (myTower.tower)->jepET();
93 bool pedCorrOverflow =
false;
94 const std::size_t nPedCorr = (myTower.tower)->
correction().size();
99 std::vector<uint8_t> datBcidVec = ( (myTower.tower)->bcidVec());
100 if ( datBcidVec.size() > 0) {
101 datBcid = datBcidVec[ (myTower.tower)->peak()];
107 std::vector<uint16_t> digits40;
109 if(readoutConfigID==5 or readoutConfigID==6){
111 int nSlices = (myTower.tower)->
adc().size();
114 for (
int i=0 ;
i < (nSlices-1)/2 ;
i++ ){
115 digits40.push_back((myTower.tower)->adc().at(2*
i+1));
118 else if((nSlices%4)==1){
119 for (
int i=0 ;
i <= (nSlices-1)/2 ;
i++ ){
120 digits40.push_back((myTower.tower)->adc().at(2*
i));
125 digits40 = (myTower.tower)->
adc();
128 const std::vector<uint_least16_t>&
ADC = digits40;
129 const int Slices =
ADC.size();
130 const int Peak = Slices/2.;
133 for(std::size_t
i = 0;
i < nPedCorr; ++
i) {
134 if((myTower.tower)->correction()[
i]>=511 or (myTower.tower)->correction()[
i]<=-512){
135 pedCorrOverflow =
true;
145 m_ttTool->simulateChannel(*(myTower.tower), LutCp, LutJep, BcidR, BcidD);
146 simBcid = BcidR[Peak];
147 if (Slices < 7 || nPedCorr < 3) {
148 simJep = LutJep[Peak];
158 std::string
groupName =
"group_Mismatch_peakf_";
161 std::bitset<3> simBcidBits(simBcid);
162 std::bitset<3> datBcidBits(datBcid);
163 if ((Slices >= 7) && (nPedCorr >= 3)) {
164 if (simBcidBits[2] && datBcidBits[2]) {
167 else if (!simBcidBits[2] && !datBcidBits[2]) {
170 else if (simBcidBits[2] != datBcidBits[2]) {
172 if (!simBcidBits[2]) {
175 else if (!datBcidBits[2]) {
179 ATH_MSG_DEBUG(
"PeakfinderBCID sim/data Mismatch coolId/sim/dat: "
180 << std::hex <<coolId.
id() << std::dec <<
"/" << simBcidBits[2] <<
"/" << datBcidBits[2]);
189 if (
ADC[0] < 1020 &&
ADC[1] < 1020) {
190 if (simBcidBits[1] && datBcidBits[1]) {
193 else if (!simBcidBits[1] && !datBcidBits[1]) {
196 else if (simBcidBits[1] != datBcidBits[1]) {
198 if (!simBcidBits[1]) {
202 else if (!datBcidBits[1]) {
206 ATH_MSG_DEBUG(
"SaturatedBCID sim/data Mismatch coolId/sim/dat: "
207 << std::hex <<coolId.
id() << std::dec <<
"/" << simBcidBits[1] <<
"/" << datBcidBits[1]);
216 if (!simCp && !datCp && !simJep && !datJep)
continue;
220 if ( (myTower.tower)->layer() == 0) {
222 if (simCp && simCp == datCp) {
225 else if (simCp != datCp && !pedCorrOverflow) {
227 if (simCp && datCp) {
231 if ((Slices >= 7) && (nPedCorr >= 3)) {
241 << std::hex <<coolId.
id() << std::dec <<
"/" << simCp <<
"/" << datCp);
248 if (simJep && simJep == datJep) {
251 else if (simJep != datJep && !pedCorrOverflow) {
253 if (simJep && datJep) {
257 if ((Slices >= 7) && (nPedCorr >= 3)) {
268 << std::hex <<coolId.
id() << std::dec <<
"/" << simJep <<
"/" << datJep);
277 if ((myTower.tower)->layer() == 1) {
279 if (simCp && simCp == datCp) {
282 else if (simCp != datCp && !pedCorrOverflow ) {
284 if (simCp && datCp) {
288 if ((Slices >= 7) && (nPedCorr >= 3)) {
298 << std::hex <<coolId.
id() << std::dec <<
"/" << simCp <<
"/" << datCp);
305 if (simJep && simJep == datJep) {
308 else if (simJep != datJep && !pedCorrOverflow ) {
310 if (simJep && datJep) {
314 if ((Slices >= 7) && (nPedCorr >= 3)) {
325 << std::hex <<coolId.
id() << std::dec <<
"/" << simJep <<
"/" << datJep);
342 std::lock_guard<std::mutex> lock(
m_mutex);
343 const int crate = coolId.
crate();
345 crateError[crate] = 1;
347 m_errorLB_tt_counter[
lb]+=1;
350 if (!((moduleError[crate] >>
module) & 0
x1)) {
351 const int y =
module + 16 * (crate % 2);
353 if (m_errorLB_tt_counter[
lb]<=maxErrorsPerLB) {
355 if (crate == 0 || crate == 1)
fill(
groupName + crate_map.at(0), eventMonitor, y_2D );
356 else if (crate == 2 || crate == 3)
fill(
groupName + crate_map.at(1), eventMonitor, y_2D );
357 else if (crate == 4 || crate == 5)
fill(
groupName + crate_map.at(2), eventMonitor, y_2D );
358 else if (crate == 6 || crate == 7)
fill(
groupName + crate_map.at(3), eventMonitor, y_2D );
359 moduleError[crate] |= (1 <<
module);
371 auto save = std::make_unique<ErrorVector>(crateError);
374 ATH_MSG_ERROR(
"Error recording PPMSimBS mismatch vector in TES");
375 return StatusCode::FAILURE;
380 return StatusCode::SUCCESS;
385 std::vector<MonitorTT> &vecMonTT)
const
388 const double phi =
tt->phi();
393 const std::vector<uint_least8_t> jepETvec =
tt->lut_jep();
394 if (jepETvec.size() > 0) jepET =
tt->jepET();
404 vecMonTT.push_back(monTT);
406 return StatusCode::SUCCESS;
412 const std::string& weightName,
422 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
423 const std::vector<double> offset25 = {0.5, -0.5};
424 std::vector<double>
offset = {};
428 phiMod = std::floor(phiMod/4)*4. + 2.;
433 phiMod = std::floor(phiMod/2)*2. + 1.;
441 for (
auto phiOffset :
offset) {
452 return StatusCode::SUCCESS;