ATLAS Offline Software
Loading...
Searching...
No Matches
BackgroundWordFiller.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5/* Algorihtm to fill the background word that is stored in the EventInfo
6
7background word contains:
8=========================
9MBTSTimeDiffHalo, MBTSTimeDiffCol, // these bits are set in
10MBTSTimeDiffEventInfoAlg due to ordering reasons.... MBTSBeamVeto
11LArECTimeDiffHalo, LArECTimeDiffCol
12PixMultiplicityHuge, PixSPNonEmpty,
13SCTMultiplicityHuge, SCTSPNonEmpty
14CSCTimeDiffHalo, CSCTimeDiffCol
15BCMTimeDiffHalo, BCMTimeDiffCol, BCMBeamVeto
16MuonTimingCol, MuonTimingCosmic,
17LUCIDBeamVeto
18
19Jamie Boyd 7/2/2010
20
21added for 2012 in addition to above:
22====================================
23HaloMuonSegment, HaloClusterShape,
24HaloMuonOneSided, HaloMuonTwoSided,
25HaloTileClusterPattern,
26BeamGasPixel,
27CosmicStandAlone, CosmicStandAloneTight,
28CosmicCombined, CosmicCombinedTight,
29BkgdResvBit1, BkgdResvBit2,
30BkgdResvBit3, BkgdResvBit4,
31BkgdResvBit5,
32
33Mark Tibbetts 6/3/2012
34
35*/
36
38
40
41//----------------------------------------------------------------
42
43using xAOD::EventInfo;
44
46 ISvcLocator* pSvcLocator)
47 : AthAlgorithm(name, pSvcLocator),
64 m_MBTSmask(TileCell::MASK_BADCH | TileCell::MASK_OVER |
65 TileCell::MASK_TIME),
66 m_MBTSpattern(TileCell::MASK_TIME),
71 m_totalcnt(0),
72 m_bitnamevec{{"MBTSTimeDiffHalo", "MBTSTimeDiffCol",
73 "LArECTimeDiffHalo", "LArECTimeDiffCol",
74 "PixMultiplicityHuge", "PixSPNonEmpty",
75 "SCTMultiplicityHuge", "SCTSPNonEmpty",
76 "CSCTimeDiffHalo", "CSCTimeDiffCol",
77 "BCMTimeDiffHalo", "BCMTimeDiffCol",
78 "MuonTimingCol", "MuonTimingCosmic",
79 "MBTSBeamVeto", "BCMBeamVeto",
80 "LUCIDBeamVeto", "HaloMuonSegment",
81 "HaloClusterShape", "HaloMuonOneSided",
82 "HaloMuonTwoSided", "HaloTileClusterPattern",
83 "BeamGasPixel", "CosmicStandAlone",
84 "CosmicStandAloneTight", "CosmicCombined",
85 "CosmicCombinedTight", "BkgdResvBit1",
86 "BkgdResvBit2", "BkgdResvBit3",
87 "BkgdResvBit4", "BkgdResvBit5"}}
88
89{
90 // ID
91 declareProperty("HaloNumSegment_Cut", m_HaloNumSegment_Cut = 0);
92 declareProperty("HaloNumClusterShape_Cut", m_HaloNumClusterShape_Cut = 0);
93 declareProperty("HaloNumOneSidedLoose_Cut", m_HaloNumOneSidedLoose_Cut = 0);
94 declareProperty("HaloNumTwoSided_Cut", m_HaloNumTwoSided_Cut = 0);
95 declareProperty("PixMultiplicityHuge_Cut",
96 m_PixMultiplicityHuge_Cut = 100000);
97 declareProperty("PixSPNonEmpty_Cut", m_PixSPNonEmpty_Cut = 10);
98 declareProperty("SCTMultiplicityHuge_Cut",
99 m_SCTMultiplicityHuge_Cut = 100000);
100 declareProperty("SCTSPNonEmpty_Cut", m_SCTSPNonEmpty_Cut = 10);
101
102 // LUCID
103 declareProperty("LUCIDBeamVeto_Cut", m_LUCIDBeamVeto_Cut = 0); // >0
104
105 declareProperty("BCMTimeDiffCol_Cut", m_BCMTimeDiffCol_Cut = 6.);
106 declareProperty("BCMTimeDiffHalo_CutLo", m_BCMTimeDiffHalo_CutLo = 6.);
107 declareProperty("BCMLowGainCut", m_BCMLowGainCut = 1);
108 declareProperty("BCMHiGainCut", m_BCMHiGainCut = 1);
109
110 declareProperty("MBTSBeamVeto_MultiplicityCut",
111 m_MBTSBeamVeto_MultiplicityCut = 0); // >0
112 declareProperty("MBTSBeamVeto_TimeCut", m_MBTSBeamVeto_TimeCut = 15.);
113 declareProperty("MBTSBeamVeto_ThresholdCut",
114 m_MBTSBeamVeto_ThresholdCut = 40.0 / 222.0);
115 // LAr
116 declareProperty("LArEC_SideCut", m_LArEC_SideCut = 1);
117 declareProperty("LArECTimeDiffCol_Cut", m_LArECTimeDiffCol_Cut = 10.);
118 declareProperty("LArECTimeDiffHalo_CutLo", m_LArECTimeDiffHalo_CutLo = 10.);
119 declareProperty("LArECTimeDiffHalo_CutHi", m_LArECTimeDiffHalo_CutHi = 30.);
120
121 // Reset counter-array
122 m_bitcntvec.fill(0);
123}
124
125//----------------------------------------------------------------
126
128
129//----------------------------------------------------------------
130
132
133 // initialise the read handle keys
134 ATH_CHECK(m_eventInfoKey.initialize());
137 ATH_CHECK(m_bcmCollisionTimeKey.initialize());
138 ATH_CHECK(m_sctSpacePointKey.initialize(!m_isMC));
139 ATH_CHECK(m_pixSpacePointKey.initialize(!m_isMC));
140 ATH_CHECK(m_tileCellContainerKey.initialize());
142 ATH_CHECK(m_eventInfoDecorKey.initialize());
143
144 return StatusCode::SUCCESS;
145}
146
147//----------------------------------------------------------------
148
150
152 // get the EventInfo
154
156
157 m_totalcnt++;
158
160 // NOW SET THE BITS!!
162
164 // Halo Identification
166 if (!m_isMC) { // do not request in MC
167 SG::ReadHandle<BeamBackgroundData> beamBackgroundDataReadHandle(
169
170 if (!beamBackgroundDataReadHandle.isValid())
171 ATH_MSG_WARNING("Invalid ReadHandle to BeamBackgoundData with name: "
172 << m_beamBackgroundDataKey.key());
173 else {
174 if (beamBackgroundDataReadHandle->GetNumSegment() >
176 if (eventInfoReadHandle->updateEventFlagBit(
178 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
180 else
182 }
183 if (beamBackgroundDataReadHandle->GetNumClusterShape() >
185 if (eventInfoReadHandle->updateEventFlagBit(
187 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
189 else
191 }
192 if (beamBackgroundDataReadHandle->GetNumNoTimeLoose() >
194 if (eventInfoReadHandle->updateEventFlagBit(
196 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
198 else
200 }
201 if (beamBackgroundDataReadHandle->GetNumTwoSidedNoTime() >
203 if (eventInfoReadHandle->updateEventFlagBit(
205 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
207 else
209 }
210 }
211 }
212
214 // LUCID: LUCIDBeamVeto
216
217 if (!m_isMC) { // do not request in MC
218 SG::ReadHandle<LUCID_RawDataContainer> LUCID_rawDataContainerReadHandle(
220
221 if (!LUCID_rawDataContainerReadHandle.isValid())
222 ATH_MSG_WARNING("Invalid ReadHandle to LUCID_RawDataContainer with name: "
224 else {
225 int LUCIDcounter(0);
226 for (auto LUCID_rawData : *LUCID_rawDataContainerReadHandle) {
227 LUCIDcounter += LUCID_rawData->getNhitsPMTsideA();
228 LUCIDcounter += LUCID_rawData->getNhitsPMTsideC();
229 }
230 if (LUCIDcounter > m_LUCIDBeamVeto_Cut) {
231 if (eventInfoReadHandle->updateEventFlagBit(
233 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
235 else
237 }
238 }
239 }
240
242 // BCM: BCMTimeDiffHalo, BCMTimeDiffCol, BCMBeamVeto
244
245 SG::ReadHandle<BcmCollisionTime> bcmCollisionTimeReadHandle(
247
248 if (!bcmCollisionTimeReadHandle.isValid())
249 ATH_MSG_WARNING("Invalid ReadHandle to BcmCollisionTime with name: "
250 << m_bcmCollisionTimeKey.key());
251 else {
252 std::vector<float> bcmTDs = bcmCollisionTimeReadHandle->getDeltaT();
253 ATH_MSG_DEBUG(" got BCMCollisionTime object getMultiLG "
254 << bcmCollisionTimeReadHandle->getMultiLG() << " getMultiHG "
255 << bcmCollisionTimeReadHandle->getMultiHG() << " TDs size "
256 << bcmTDs.size());
257 float minTD = 999;
258 float maxTD = 0;
259
260 for (unsigned int i = 0; i < bcmTDs.size(); i++) {
261 float td = bcmTDs.at(i);
262 ATH_MSG_DEBUG(" BCMCollisionTime td " << i << " " << td);
263 if (fabs(td) > fabs(maxTD))
264 maxTD = td;
265 if (fabs(td) < fabs(minTD))
266 minTD = td;
267 }
268
269 ATH_MSG_DEBUG(" BCMCollisionTime minDT " << minTD << " maxDT " << maxTD);
270
271 if (fabs(minTD) < m_BCMTimeDiffCol_Cut) {
272 if (eventInfoReadHandle->updateEventFlagBit(
274 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
276 else
278 }
279 if (fabs(maxTD) > m_BCMTimeDiffHalo_CutLo) {
280 if (eventInfoReadHandle->updateEventFlagBit(
282 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
284 else
286 }
287 if (bcmCollisionTimeReadHandle->getMultiLG() > m_BCMLowGainCut ||
288 bcmCollisionTimeReadHandle->getMultiHG() > m_BCMHiGainCut) {
289 if (eventInfoReadHandle->updateEventFlagBit(
291 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
293 else
295 }
296 }
297
299 // ID SP multiplicities from Raw for filling: IDMultiplicityHuge,
300 // IDSPNonEmpty
302 if (!m_isMC) { // do not request in MC
305
306 if (!sctSP.isValid() or !pixSP.isValid()) {
307 ATH_MSG_WARNING("Invalid ReadHandle to SCT/Pix spacepoints");
308 } else {
309 int NSCTsps = 0;
310 int NPIXsps = 0;
311 std::for_each(sctSP->begin(), sctSP->end(), [&NSCTsps](const auto coll) {
312 if (coll)
313 NSCTsps += coll->size();
314 });
315 std::for_each(pixSP->begin(), pixSP->end(), [&NPIXsps](const auto coll) {
316 if (coll)
317 NPIXsps += coll->size();
318 });
319
320 // set IDMultiplicityHuge
321 if ((NPIXsps) > m_PixMultiplicityHuge_Cut) {
322 if (eventInfoReadHandle->updateEventFlagBit(
324 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
326 else
328 }
329
330 // set PixSPNonEmpty
331 if ((NPIXsps) > m_PixSPNonEmpty_Cut) {
332 if (eventInfoReadHandle->updateEventFlagBit(
334 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
336 else
338 }
339
340 if ((NSCTsps) > m_SCTMultiplicityHuge_Cut) {
341 if (eventInfoReadHandle->updateEventFlagBit(
343 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
345 else
347 }
348
349 // set SCTSPNonEmpty
350 if ((NSCTsps) > m_SCTSPNonEmpty_Cut) {
351 if (eventInfoReadHandle->updateEventFlagBit(
353 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
355 else
357 }
358 }
359 }
360
362 // MBTSBeamVeto
364
365 SG::ReadHandle<TileCellContainer> tileCellContainerReadHandle(
367
368 if (!tileCellContainerReadHandle.isValid())
369 ATH_MSG_WARNING("Invalid ReadHandle to TileCellContainer: "
370 << m_tileCellContainerKey.key());
371 else {
372 int MBTScount(0);
373
374 for (auto tileCellContainer : *tileCellContainerReadHandle) {
375 if (tileCellContainer->energy() < m_MBTSBeamVeto_ThresholdCut)
376 continue;
377 const uint8_t qbit1 = tileCellContainer->qbit1();
378
379 if ((qbit1 & m_MBTSmask) != m_MBTSpattern) {
380 ATH_MSG_DEBUG("Rejected based on quality bits");
381 continue;
382 }
383 if (fabs(tileCellContainer->time()) < m_MBTSBeamVeto_TimeCut)
384 MBTScount++;
385 } // loop on MBTS containers
386
387 if (MBTScount > m_MBTSBeamVeto_MultiplicityCut) {
388 if (eventInfoReadHandle->updateEventFlagBit(
390 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
392 else
394 }
395 }
396
398 // LAr EC collision timing stuff (from Guillaume...) - for filling:
399 // LArECTimeDiffHalo, LArECTimeDiffCol
401
402 if (!m_isMC) { // do not request in MC
403 SG::ReadHandle<LArCollisionTime> lArCollisionTimeReadHandle(
405
406 if (!lArCollisionTimeReadHandle.isValid())
407 ATH_MSG_WARNING("Invalid ReadHandle to LArCollisionTime: "
408 << m_lArCollisionTimeKey.key());
409 else {
410 if (lArCollisionTimeReadHandle->ncellA() > m_LArEC_SideCut &&
411 lArCollisionTimeReadHandle->ncellC() > m_LArEC_SideCut) {
412 float LArECtimeDiff = lArCollisionTimeReadHandle->timeA() -
413 lArCollisionTimeReadHandle->timeC();
414 if (fabs(LArECtimeDiff) < m_LArECTimeDiffCol_Cut) {
415 if (eventInfoReadHandle->updateEventFlagBit(
417 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
419 else
421 }
422 if (fabs(LArECtimeDiff) > m_LArECTimeDiffHalo_CutLo &&
423 fabs(LArECtimeDiff) < m_LArECTimeDiffHalo_CutHi) {
424 if (eventInfoReadHandle->updateEventFlagBit(
426 ATH_MSG_WARNING("Failed to set EventInfo Background word bit "
428 else
430 } // halo timing
431 } // enough hits per side
432 }
433 }
434
436 // printout the final background word
438 ATH_MSG_DEBUG("Summary of background word contents:");
439 ATH_MSG_DEBUG("MBTSTimeDiffHalo: " << eventInfoReadHandle->isEventFlagBitSet(
441 ATH_MSG_DEBUG("MBTSTimeDiffCol: " << eventInfoReadHandle->isEventFlagBitSet(
443 ATH_MSG_DEBUG("MBTSBeamVeto: " << eventInfoReadHandle->isEventFlagBitSet(
445 ATH_MSG_DEBUG("LArECTimeDiffHalo: " << eventInfoReadHandle->isEventFlagBitSet(
447 ATH_MSG_DEBUG("LArECTimeDiffCol: " << eventInfoReadHandle->isEventFlagBitSet(
450 "PixMultiplicityHuge: " << eventInfoReadHandle->isEventFlagBitSet(
452 ATH_MSG_DEBUG("PixSPNonEmpty: " << eventInfoReadHandle->isEventFlagBitSet(
455 "SCTMultiplicityHuge: " << eventInfoReadHandle->isEventFlagBitSet(
457 ATH_MSG_DEBUG("SCTSPNonEmpty: " << eventInfoReadHandle->isEventFlagBitSet(
459 ATH_MSG_DEBUG("CSCTimeDiffHalo: " << eventInfoReadHandle->isEventFlagBitSet(
461 ATH_MSG_DEBUG("CSCTimeDiffCol: " << eventInfoReadHandle->isEventFlagBitSet(
463 ATH_MSG_DEBUG("BCMTimeDiffHalo: " << eventInfoReadHandle->isEventFlagBitSet(
465 ATH_MSG_DEBUG("BCMTimeDiffCol: " << eventInfoReadHandle->isEventFlagBitSet(
467 ATH_MSG_DEBUG("BCMBeamVeto: " << eventInfoReadHandle->isEventFlagBitSet(
469 ATH_MSG_DEBUG("MuonTimingCol: " << eventInfoReadHandle->isEventFlagBitSet(
471 ATH_MSG_DEBUG("MuonTimingCosmic: " << eventInfoReadHandle->isEventFlagBitSet(
473 ATH_MSG_DEBUG("LUCIDBeamVeto: " << eventInfoReadHandle->isEventFlagBitSet(
475
476 return StatusCode::SUCCESS;
477}
478
479//----------------------------------------------------------------
480
482
483 ATH_MSG_INFO("In finalize()");
484
486 "Job Summary for Background Word (NB. MBTS time bits not counted by this "
487 "alg)");
488 for (int ibit = 0; ibit < EventInfo::NBackgroundWords; ++ibit)
489 ATH_MSG_INFO(" " << m_bitnamevec[ibit] << ": " << m_bitcntvec[ibit] << "/"
490 << m_totalcnt << " events");
491
492 return StatusCode::SUCCESS;
493}
494
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
ReadHandleKey for EventInfo object.
SG::ReadHandleKey< BcmCollisionTime > m_bcmCollisionTimeKey
ReadHandleKey for BcmCollisionTime.
SG::ReadHandleKey< TileCellContainer > m_tileCellContainerKey
ReadHandleKey for TileCellContainer.
SG::ReadHandleKey< SpacePointContainer > m_pixSpacePointKey
std::array< const char *, xAOD::EventInfo::NBackgroundWords > m_bitnamevec
SG::ReadHandleKey< SpacePointContainer > m_sctSpacePointKey
ReadHandleKey for SpacePointContainers.
SG::ReadHandleKey< BeamBackgroundData > m_beamBackgroundDataKey
ReadHandleKey for BeamBackgroundData.
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
WriteDecorHandleKey: needed for scheduling downstream clients.
SG::ReadHandleKey< LUCID_RawDataContainer > m_LUCID_rawDataContainerKey
ReadHandleKey for LUCID_RawDataContainer.
Gaudi::Property< bool > m_isMC
std::array< unsigned int, xAOD::EventInfo::NBackgroundWords > m_bitcntvec
SG::ReadHandleKey< LArCollisionTime > m_lArCollisionTimeKey
ReadHandleKey for LArCollisionTime.
BackgroundWordFiller(const std::string &name, ISvcLocator *pSvcLocator)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ Background
The beam background detectors.
EventInfo_v1 EventInfo
Definition of the latest event info version.