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 double eta = (myTower.tower)->eta();
92 const double phi = (myTower.tower)->phi();
93 const int datCp = (myTower.tower)->cpET();
94 const int datJep = (myTower.tower)->lut_jep().empty() ? 0 : (myTower.tower)->jepET();
95 bool pedCorrOverflow =
false;
96 const std::size_t nPedCorr = (myTower.tower)->
correction().size();
101 std::vector<uint8_t> datBcidVec = ( (myTower.tower)->bcidVec());
102 if ( datBcidVec.size() > 0) {
103 datBcid = datBcidVec[ (myTower.tower)->peak()];
109 std::vector<uint16_t> digits40;
111 if(readoutConfigID==5 or readoutConfigID==6){
113 int nSlices = (myTower.tower)->
adc().size();
116 for (
int i=0 ;
i < (nSlices-1)/2 ;
i++ ){
117 digits40.push_back((myTower.tower)->adc().at(2*
i+1));
120 else if((nSlices%4)==1){
121 for (
int i=0 ;
i <= (nSlices-1)/2 ;
i++ ){
122 digits40.push_back((myTower.tower)->adc().at(2*
i));
127 digits40 = (myTower.tower)->
adc();
130 const std::vector<uint_least16_t>&
ADC = digits40;
131 const int Slices =
ADC.size();
132 const int Peak = Slices/2.;
135 for(std::size_t
i = 0;
i < nPedCorr; ++
i) {
136 if((myTower.tower)->correction()[
i]>=511 or (myTower.tower)->correction()[
i]<=-512){
137 pedCorrOverflow =
true;
147 m_ttTool->simulateChannel(*(myTower.tower), LutCp, LutJep, BcidR, BcidD);
148 simBcid = BcidR[Peak];
149 if (Slices < 7 || nPedCorr < 3) {
150 simJep = LutJep[Peak];
160 std::string
groupName =
"group_Mismatch_peakf_";
163 std::bitset<3> simBcidBits(simBcid);
164 std::bitset<3> datBcidBits(datBcid);
165 if ((Slices >= 7) && (nPedCorr >= 3)) {
166 if (simBcidBits[2] && datBcidBits[2]) {
169 else if (!simBcidBits[2] && !datBcidBits[2]) {
172 else if (simBcidBits[2] != datBcidBits[2]) {
174 if (!simBcidBits[2]) {
177 else if (!datBcidBits[2]) {
180 ATH_MSG_DEBUG(
" PeakfinderBCID sim/data Mismatch eta/phi/sim/dat: " << eta <<
"/" << phi <<
"/" << simBcidBits[2] <<
"/" << datBcidBits[2]);
188 if (
ADC[0] < 1020 &&
ADC[1] < 1020) {
189 if (simBcidBits[1] && datBcidBits[1]) {
192 else if (!simBcidBits[1] && !datBcidBits[1]) {
195 else if (simBcidBits[1] != datBcidBits[1]) {
197 if (!simBcidBits[1]) {
201 else if (!datBcidBits[1]) {
204 ATH_MSG_DEBUG(
" SaturatedBCID sim/data Mismatch eta/phi/sim/dat: "
205 << eta <<
"/" << phi <<
"/" << simBcidBits[1] <<
"/" << datBcidBits[1]);
213 if (!simCp && !datCp && !simJep && !datJep)
continue;
217 if ( (myTower.tower)->layer() == 0) {
219 if (simCp && simCp == datCp) {
222 else if (simCp != datCp && !pedCorrOverflow) {
224 if (simCp && datCp) {
228 if ((Slices >= 7) && (nPedCorr >= 3)) {
237 << eta <<
"/" << phi <<
"/" << simCp <<
"/" << datCp);
243 if (simJep && simJep == datJep) {
246 else if (simJep != datJep && !pedCorrOverflow) {
248 if (simJep && datJep) {
252 if ((Slices >= 7) && (nPedCorr >= 3)) {
262 << eta <<
"/" << phi <<
"/" << simJep <<
"/" << datJep);
270 if ((myTower.tower)->layer() == 1) {
272 if (simCp && simCp == datCp) {
275 else if (simCp != datCp && !pedCorrOverflow ) {
277 if (simCp && datCp) {
281 if ((Slices >= 7) && (nPedCorr >= 3)) {
290 << eta <<
"/" << phi <<
"/" << simCp <<
"/" << datCp);
296 if (simJep && simJep == datJep) {
299 else if (simJep != datJep && !pedCorrOverflow ) {
301 if (simJep && datJep) {
305 if ((Slices >= 7) && (nPedCorr >= 3)) {
315 << eta <<
"/" << phi <<
"/" << simJep <<
"/" << datJep);
330 std::lock_guard<std::mutex> lock(
m_mutex);
332 const int crate = coolId.
crate();
334 crateError[crate] = 1;
336 m_errorLB_tt_counter[
lb]+=1;
339 if (!((moduleError[crate] >>
module) & 0
x1)) {
340 const int y =
module + 16 * (crate % 2);
342 if (m_errorLB_tt_counter[
lb]<=maxErrorsPerLB) {
344 if (crate == 0 || crate == 1)
fill(
groupName + crate_map.at(0), eventMonitor, y_2D );
345 else if (crate == 2 || crate == 3)
fill(
groupName + crate_map.at(1), eventMonitor, y_2D );
346 else if (crate == 4 || crate == 5)
fill(
groupName + crate_map.at(2), eventMonitor, y_2D );
347 else if (crate == 6 || crate == 7)
fill(
groupName + crate_map.at(3), eventMonitor, y_2D );
348 moduleError[crate] |= (1 <<
module);
360 auto save = std::make_unique<ErrorVector>(crateError);
363 ATH_MSG_ERROR(
"Error recording PPMSimBS mismatch vector in TES");
364 return StatusCode::FAILURE;
369 return StatusCode::SUCCESS;
374 std::vector<MonitorTT> &vecMonTT)
const
377 const double phi =
tt->phi();
382 const std::vector<uint_least8_t> jepETvec =
tt->lut_jep();
383 if (jepETvec.size() > 0) jepET =
tt->jepET();
393 vecMonTT.push_back(monTT);
395 return StatusCode::SUCCESS;
401 const std::string& weightName,
411 const std::vector<double> offset32 = {1.5, 0.5, -0.5, -1.5};
412 const std::vector<double> offset25 = {0.5, -0.5};
413 std::vector<double>
offset = {};
417 phiMod = std::floor(phiMod/4)*4. + 2.;
422 phiMod = std::floor(phiMod/2)*2. + 1.;
432 for (
auto phiOffset :
offset) {
450 return StatusCode::SUCCESS;