10 ATH_MSG_DEBUG(
"Initializing JfexSimMonitorAlgorithm algorithm with name: "<< name());
58 if(!jFexTowerContainer.isValid()) {
60 return StatusCode::SUCCESS;
63 std::string inputTower = jFexTowerContainer->
empty() ?
"EmulatedTowers" :
"DataTowers";
70 timeSince = ctx.eventID().time_stamp() - larBadChan.
getRange().start().time_stamp();
71 timeUntil = larBadChan.
getRange().stop().time_stamp() - ctx.eventID().time_stamp();
74 if(jFexTowerContainer->
empty()) {
76 if (timeUntil>=0 && timeUntil<=5) {
82 if (!scells.
isValid() || scells->size() != 34048) {
89 static constexpr int jJmaxTobs = 7;
90 static constexpr int jTAUmaxTobs = 6;
91 static constexpr int jEMmaxTobs = 5;
92 bool simReady = !jFexTowerContainer->
empty();
101 return StatusCode::SUCCESS;
104template<
typename T> uint16_t
tobEt(
const T* tob) {
return tob->tobEt(); }
111 const EventContext& ctx,
bool simReadyFlag,
size_t maxTobs)
const {
121 bool mismatches =
false;
134 auto mask = (
label==
"jTE") ? 0x7FFFFFFE : 0xFFFFFFFE;
138 std::map<std::pair<uint8_t,uint8_t>,std::multiset<uint16_t>> tobEts_byFpga;
140 unsigned zeroTobs1 = 0;
141 unsigned zeroTobs2 = 0;
142 for(
const auto tob1 : *tobsDataCont) {
143 bool isMatched =
false;
144 auto word1 = tob1->tobWord();
145 auto jfex1 = tob1->jFexNumber();
146 auto fpga1 = tob1->fpgaNumber();
148 for (
const auto tob2 : *tobsSimCont) {
149 if(word1==0 || ((word1&mask) == (tob2->tobWord()&mask) && jfex1 == tob2->jFexNumber() && fpga1 == tob2->fpgaNumber())) {
160 if(tobEts_byFpga.empty()) {
161 for (
const auto tob: *tobsSimCont) {
164 tobEts_byFpga[std::pair(tob->jFexNumber(), tob->fpgaNumber())].insert(
tobEt(tob));
169 if(
auto itr = tobEts_byFpga.find(std::pair(jfex1,fpga1)); itr != tobEts_byFpga.end()
170 && itr->second.size() == maxTobs
171 && (*itr->second.begin())==
tobEt(tob1)
186 for (
const auto tob2: *tobsSimCont) {
187 if (tob2->tobWord() == 0) {
193 if(tobsSimCont.
isValid() && (tobsDataCont->size() - zeroTobs1) < (tobsSimCont->size() - zeroTobs2) ) {
204 auto itr = m_firstEvents.find(lbn);
205 if(itr==m_firstEvents.end()) {
206 m_firstEvents[lbn] = std::to_string(lbn)+
":"+std::to_string(evtNumber);
207 itr = m_firstEvents.find(lbn);
209 lbnString = itr->second;
211 std::vector<float> detas{};std::vector<float> setas{};
212 std::vector<float> dphis{};std::vector<float> sphis{};
213 std::vector<unsigned int> dword0s{};std::vector<unsigned int> sword0s{};
223 std::cout <<
"LBN: " << std::string(lbnString) <<
" EventNumber: " << ULong64_t(evtNumber) <<
" signature: " <<
label << std::endl;
224 std::cout <<
" data : " << std::hex;
225 for (
const auto w: dword0s) std::cout << w <<
" ";
226 std::cout << std::endl <<
" sim : ";
227 for (
const auto w: sword0s) std::cout << w <<
" ";
228 std::cout << std::endl << std::dec;
232 fill(
"mismatches",simReadyMismatch,tobMismatched,lbn,lbnString,evtNumber,dtobEtas,dtobPhis,dtobWord0s,stobEtas,stobPhis,stobWord0s,Signature,eventType,IsDataTowers,IsEmulatedTowers,simReady,signatureEventType);
235 fill(
"mismatches",lbn,Signature,tobMismatched,simReady,eventType);
243 etas.clear();phis.clear();word0s.clear();
246 etas.reserve(tobs->size());
247 phis.reserve(tobs->size());
248 word0s.reserve(tobs->size());
249 std::vector<SortableTob> sortedTobs;
250 sortedTobs.reserve(tobs->size());
252 sortedTobs.emplace_back(SortableTob{tob->tobWord(),0.,0.});
254 std::sort(sortedTobs.begin(),sortedTobs.end(),[](
const SortableTob& lhs,
const SortableTob& rhs) { return lhs.word0<rhs.word0; });
255 for(
const auto& tob : sortedTobs) {
256 etas.push_back(tob.eta);
257 phis.push_back(tob.phi);
258 word0s.push_back(tob.word0);
263 etas.clear();phis.clear();word0s.clear();
266 etas.reserve(tobs->size());
267 phis.reserve(tobs->size());
268 word0s.reserve(tobs->size());
269 std::vector<SortableTob> sortedTobs;
270 sortedTobs.reserve(tobs->size());
271 for(
const auto tob : *tobs) {
272 sortedTobs.emplace_back(SortableTob{tob->tobWord(),0.,0.});
274 std::sort(sortedTobs.begin(),sortedTobs.end(),[](
const SortableTob& lhs,
const SortableTob& rhs) { return lhs.word0<rhs.word0; });
275 for(
const auto& tob : sortedTobs) {
276 etas.push_back(tob.eta);
277 phis.push_back(tob.phi);
278 word0s.push_back(tob.word0);
#define ATH_CHECK
Evaluate an expression and check for errors.
uint16_t tobEt(const T *tob)
bool msgLvl(const MSG::Level lvl) const
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
bool empty() const noexcept
Returns true if the collection is empty.
This class represents the "type of event" where the type is given by one or more "characteristics".
SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer > m_data_key_jLJ
SG::ReadHandleKey< xAOD::jFexMETRoIContainer > m_simu_key_jXE
SG::ReadHandleKey< xAOD::jFexFwdElRoIContainer > m_simu_key_jEM
SG::ReadHandleKey< xAOD::jFexTowerContainer > m_jFexTowerKey
SG::ReadHandleKey< xAOD::jFexTauRoIContainer > m_data_key_jTau
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_data_key_jJ
SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer > m_simu_key_jLJ
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::jFexSumETRoIContainer > m_data_key_jTE
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
SG::ReadHandleKey< xAOD::jFexFwdElRoIContainer > m_data_key_jEM
void fillVectors(const SG::ReadHandleKey< T > &key, const EventContext &ctx, std::vector< float > &etas, std::vector< float > &phis, std::vector< unsigned int > &word0s) const
SG::ReadHandleKey< xAOD::jFexSumETRoIContainer > m_simu_key_jTE
SG::ReadHandleKey< CaloCellContainer > m_scellKey
bool compareRoI(const std::string &label, const std::string &evenType, const SG::ReadHandleKey< T > &tobs1Key, const SG::ReadHandleKey< T > &tobs2Key, const EventContext &ctx, bool simReadyFlag=false, size_t maxTobs=0) const
JfexSimMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::jFexMETRoIContainer > m_data_key_jXE
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< xAOD::jFexTauRoIContainer > m_simu_key_jTau
std::mutex m_firstEventsMutex
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_simu_key_jJ
Declare a monitored scalar variable.
const EventIDRange & getRange()
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string label(const std::string &format, int i)
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
jFexSumETRoI_v1 jFexSumETRoI
Define the latest version of the jFexSumETJetRoI class.
jFexMETRoI_v1 jFexMETRoI
Define the latest version of the jFexMETRoI class.
void fill(H5::Group &out_file, size_t iterations)