23 #include "GaudiKernel/MsgStream.h"
24 #include "GaudiKernel/ITHistSvc.h"
32 ISvcLocator* pSvcLocator )
35 for (
size_t ix = 0; ix <
NDETS; ++ix) {
36 for (
size_t iy = ix+1; iy <
NDETS; ++iy) {
69 std::multiset<uint32_t> sctbcidset;
70 std::multiset<uint32_t> trtbcidset;
71 std::multiset<uint32_t> larbcidset;
72 std::multiset<uint32_t> tilebcidset;
73 std::multiset<uint32_t> rpcbcidset;
74 std::multiset<uint32_t> pixelbcidset;
76 std::multiset<uint32_t> sctl1idset;
77 std::multiset<uint32_t> trtl1idset;
78 std::multiset<uint32_t> larl1idset;
79 std::multiset<uint32_t> tilel1idset;
80 std::multiset<uint32_t> rpcl1idset;
81 std::multiset<uint32_t> pixell1idset;
84 Monitored::Scalar<uint16_t> sctbcid(
"sctbcid", 0), trtbcid(
"trtbcid", 0), larbcid(
"larbcid", 0), tilebcid(
"tilebcid", 0), rpcbcid(
"rpcbcid", 0), pixelbcid(
"pixelbcid", 0);
85 Monitored::Scalar<uint32_t> sctl1id(
"sctl1id", 0), trtl1id(
"trtl1id", 0), larl1id(
"larl1id", 0), rpcl1id(
"rpcl1id", 0), pixell1id(
"pixell1id", 0);
88 Monitored::Scalar<float> sctfrac(
"sctfrac", 0.0), trtfrac(
"trtfrac", 0.0), larfrac(
"larfrac", 0.0), tilefrac(
"tilefrac", 0.0), rpcfrac(
"rpcfrac", 0.0), pixelfrac(
"pixelfrac", 0.0);
97 if(! thisEventInfo.isValid())
103 ctpbcid = thisEventInfo->bcid();
104 lumi = thisEventInfo->lumiBlock() ;
105 evtNum = thisEventInfo->eventNumber();
106 ctpl1id = thisEventInfo->extendedLevel1ID();
110 auto inDetTimeCollections = m_InDetTimeCollectionKeys.makeHandles(ctx);
112 if (inDetTimeCollections[0].
isValid()) {
113 auto& TRT_BCIDColl(inDetTimeCollections[0]);
114 for ( InDetTimeCollection::const_iterator itrt_bcid
115 = TRT_BCIDColl->begin();
116 itrt_bcid != TRT_BCIDColl->end(); ++itrt_bcid ) {
118 trtbcidset.insert((
uint16_t)(*itrt_bcid).second);
126 if (inDetTimeCollections[1].
isValid()) {
127 auto& SCT_BCIDColl(inDetTimeCollections[1]);
128 for ( InDetTimeCollection::const_iterator isct_bcid
129 = SCT_BCIDColl->begin();
130 isct_bcid != SCT_BCIDColl->end(); ++isct_bcid ) {
132 sctbcidset.insert((
uint16_t)(*isct_bcid).second);
140 if (inDetTimeCollections[2].
isValid()) {
141 auto& Pixel_BCIDColl(inDetTimeCollections[2]);
142 for ( InDetTimeCollection::const_iterator ipixel_bcid
143 = Pixel_BCIDColl->begin();
144 ipixel_bcid != Pixel_BCIDColl->end(); ++ipixel_bcid ) {
146 pixelbcidset.insert((
uint16_t)(*ipixel_bcid).second);
154 if (inDetTimeCollections[3].
isValid()) {
155 auto& TRT_LVL1IDColl(inDetTimeCollections[3]);
156 for ( InDetTimeCollection::const_iterator itrt_lvl1id
157 = TRT_LVL1IDColl->begin();
158 itrt_lvl1id != TRT_LVL1IDColl->end(); ++itrt_lvl1id ) {
160 trtl1idset.insert((
uint16_t)(*itrt_lvl1id).second);
168 if (inDetTimeCollections[4].
isValid()) {
169 auto& SCT_LVL1IDColl(inDetTimeCollections[4]);
170 for ( InDetTimeCollection::const_iterator isct_lvl1id
171 = SCT_LVL1IDColl->begin();
172 isct_lvl1id != SCT_LVL1IDColl->end(); ++isct_lvl1id ) {
174 sctl1idset.insert((
uint16_t)(*isct_lvl1id).second);
182 if (inDetTimeCollections[5].
isValid()) {
183 auto& Pixel_LVL1IDColl(inDetTimeCollections[5]);
184 for ( InDetTimeCollection::const_iterator ipixel_lvl1id
185 = Pixel_LVL1IDColl->begin();
186 ipixel_lvl1id != Pixel_LVL1IDColl->end(); ++ipixel_lvl1id ) {
188 pixell1idset.insert((
uint16_t)(*ipixel_lvl1id).second);
196 sctbcid=findid(sctbcidset);
197 sctfrac=findfrac(sctbcidset,ctpbcid);
198 trtbcid=findid(trtbcidset);
199 trtfrac=findfrac(trtbcidset,ctpbcid);
200 sctl1id=findid(sctl1idset);
201 trtl1id=findid(trtl1idset);
202 pixell1id=findid(pixell1idset);
203 pixelbcid=findid(pixelbcidset);
204 pixelfrac=findfrac(pixelbcidset,ctpbcid);
214 for ( ;
it!=itend;++
it) {
216 unsigned int febid=((*it)->FEBId()).get_identifier32().get_compact();
217 if (febid >= 0x38000000 && febid <= 0x3bc60000) {
218 larbcidset.insert((
uint16_t) (*it)->BCId() );
219 larl1idset.insert((
uint32_t) (*it)->ELVL1Id() );
223 larbcid=findid(larbcidset);
224 larfrac=findfrac(larbcidset,larbcid);
225 larl1id=findid(larl1idset);
234 for (;collItr!=lastColl;++collItr){
235 tilebcidset.insert( (*collItr)->getRODBCID() );
236 tilel1idset.insert( (*collItr)->getLvl1Id() );
239 tilebcid=findid(tilebcidset);
240 tilefrac=findfrac(tilebcidset,tilebcid);
241 tilel1id=findid(tilel1idset);
250 for (; pad != endpad ; ++pad ) {
252 if ( (*pad)->size() > 0 ) {
253 rpcbcidset.insert( (*pad)->bcId() );
254 rpcl1idset.insert( (*pad)->lvl1Id() );
262 rpcbcid=findid(rpcbcidset);
263 rpcfrac=findfrac(rpcbcidset,rpcbcid);
264 rpcl1id=findid(rpcl1idset);
267 uint32_t ctp_l1id9 = ctpl1id & 0x1FF;
269 uint32_t tile_l1id9 = tilel1id & 0x1FF;
270 uint32_t sct_l1id9 = sctl1id & 0x1FF;
271 uint32_t trt_l1id9 = trtl1id & 0x1FF;
272 uint32_t lar_l1id9 = larl1id & 0x1FF;
273 uint32_t pixel_l1id9 = pixell1id & 0x1FF;
275 std::vector<float> bcidrates_base { sctfrac, trtfrac, larfrac,
276 tilefrac, rpcfrac, pixelfrac };
280 std::vector<int> bcidrates_idx_base = { 1, 2, 3, 4, 5, 6 };
283 bcidrates_idx_base );
286 std::vector<Int_t> bcidvals { ctpbcid, sctbcid, trtbcid, larbcid,
287 tilebcid, rpcbcid, pixelbcid };
288 std::vector<int> diffx_base, diffy_base;
290 assert( bcidvals.size() == NDETS );
292 std::vector<Monitored::Scalar<Int_t>> diffvec;
293 for (
size_t ix = 0; ix < NDETS; ++ix) {
294 for (
size_t iy = ix+1; iy < NDETS; ++iy) {
295 if (m_run2Compat && iy == 6) {
303 for (
size_t ix = 0,
ivec = 0; ix < NDETS; ++ix) {
304 for (
size_t iy = ix+1; iy < NDETS; ++iy) {
305 Int_t comparison = bcidvals[ix] - bcidvals[iy];
306 if (comparison > 0) {
307 diffx_base.push_back(ix); diffy_base.push_back(iy);
308 }
else if (comparison < 0) {
309 diffx_base.push_back(iy); diffy_base.push_back(ix);
311 diffx_base.push_back(ix); diffy_base.push_back(ix);
312 diffx_base.push_back(iy); diffy_base.push_back(iy);
314 if (m_run2Compat && iy == 6) {
315 diffvec[
ivec] = -comparison;
317 diffvec[
ivec] = comparison;
322 for (
auto&&
var: diffvec) {
327 fill(
"bcid", diffjunk,
lb);
332 fill(
"bcid", ctpbcid, sctbcid, trtbcid, larbcid, tilebcid, rpcbcid,
333 pixelbcid, bcidrates, bcidrates_idx, diffx, diffy);
337 std::vector<UInt_t> l1idvals { ctp_l1id16, sctl1id, trtl1id, larl1id,
338 tile_l1id16, rpcl1id, pixell1id };
340 std::vector<UInt_t> l1idvals_d9 { ctp_l1id9, sct_l1id9, trt_l1id9,
341 lar_l1id9, tile_l1id9, rpcl1id, pixel_l1id9 };
343 assert( l1idvals.size() == NDETS && l1idvals_d9.size() == NDETS );
345 diffx_base.clear(); diffy_base.clear();
347 for (
size_t ix = 0,
ivec = 0; ix < NDETS; ++ix) {
348 for (
size_t iy = ix+1; iy < NDETS; ++iy) {
352 yl1id = rpcl1id; xl1id = l1idvals_d9[ix];
353 }
else if (ix == 5) {
354 xl1id = rpcl1id; yl1id = l1idvals_d9[iy];
356 xl1id = l1idvals[ix]; yl1id = l1idvals[iy];
358 Int_t comparison = xl1id - yl1id;
359 if (comparison > 0) {
360 diffx_base.push_back(ix); diffy_base.push_back(iy);
361 }
else if (comparison < 0) {
362 diffx_base.push_back(iy); diffy_base.push_back(ix);
364 diffx_base.push_back(ix); diffy_base.push_back(ix);
365 diffx_base.push_back(iy); diffy_base.push_back(iy);
367 if (m_run2Compat && iy == 6) {
368 diffvec[
ivec] = -comparison;
370 diffvec[
ivec] = comparison;
375 for (
auto&&
var: diffvec) {
380 fill(
"l1id", diffjunk,
lb);
382 fill(
"l1id", ctp_l1id16, sctl1id, trtl1id, larl1id,
383 tile_l1id16, rpcl1id, pixell1id, diffx, diffy);
387 Amg::Vector3D gP1(m_solenoidPositionX, m_solenoidPositionY, m_solenoidPositionZ);
391 if (fieldCondObj ==
nullptr) {
392 ATH_MSG_ERROR(
"DQTDetSynchMonAlg: Failed to retrieve AtlasFieldCacheCondObj with key " << m_fieldCacheCondObjInputKey.key());
393 return StatusCode::FAILURE;
395 fieldCondObj->getInitializedCache (fieldCache);
396 fieldCache.
getField(gP1.data(),
f.data());
401 Amg::Vector3D gP2(m_toroidPositionX, m_toroidPositionY, m_toroidPositionZ);
402 fieldCache.
getField(gP2.data(),
f.data());
406 fill(
"bfield", solenoid_bz, toroid_bx,
lb);
410 ATH_MSG_VERBOSE(
"evt L1ID : " << ctpl1id <<
"\tevt BCID : " << ctpbcid );
411 ATH_MSG_VERBOSE(
"CTP L1ID : " << ctpl1id <<
"\tCTP BCID : " << ctpbcid );
412 ATH_MSG_VERBOSE(
"LAR L1ID : " << larl1id <<
"\tLAR BCID : " << larbcid );
413 ATH_MSG_VERBOSE(
"TILE L1ID: " << tilel1id <<
"\tTILE BCID : " << tilebcid );
414 ATH_MSG_VERBOSE(
"RPC L1ID : " << rpcl1id <<
"\tRPC BCID : " << rpcbcid );
415 ATH_MSG_VERBOSE(
"Pixel L1ID : " << pixell1id <<
"\tPixel BCID : " << pixelbcid );
416 ATH_MSG_VERBOSE(
"CTP-RPC L1ID : " << ctp_l1id9-rpcl1id <<
"\tCTP-LAR L1ID : " << ctp_l1id16-larl1id );
417 return StatusCode::SUCCESS;
426 int refcount(0),
count(0);
430 if (
it!=itend && !mset.empty()){
431 for (;
it!=itend;++
it) {
436 if ( ( (*
it) !=refid )&&(
count>refcount) ){
439 ATH_MSG_VERBOSE(
"new REFERENCE id: " << refid <<
" with REFERENCE counts: " << refcount );
444 ATH_MSG_VERBOSE(
"Returning REFERENCE id: " << refid <<
" with REFERENCE counts: " << refcount );
457 int nonctpIdCounter=0;
460 if (
it!=itend && !mset.empty()){
461 for (;
it!=itend;++
it) {
463 if ( (*
it) != ctpid ) nonctpIdCounter++;