ATLAS Offline Software
TrigCountSpacePoints.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 #include "TrigCountSpacePoints.h"
6 
8 
9 TrigCountSpacePoints::TrigCountSpacePoints(const std::string &name, ISvcLocator *pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
10 
16  ATH_CHECK(m_spacePointsKey.initialize());
17  ATH_CHECK(m_spacePointsAuxKey.initialize());
18  if (!m_monTool.empty()) {
19  ATH_CHECK(m_monTool.retrieve());
20  }
21  return StatusCode::SUCCESS;
22 }
23 
24 StatusCode TrigCountSpacePoints::execute(const EventContext &context) const {
25 
26  // For Pixel info decoding
27  SG::ReadHandle<PixelID> pixelHelper(m_pixelHelperKey, context);
28 
29  // Here monitor
30  int pixCLBeforeCuts{};
31  int pixCL{};
32  int pixCLnoToT{};
33  int pixCL_1{};
34  int pixCL_2{};
35  int pixCLmin3{};
36  int pixCLBarrel{};
37  int pixCLEndcapA{};
38  int pixCLEndcapC{};
39  int pixModulesOverThreshold{};
40 
42  ATH_MSG_DEBUG("Successfully retrieved pixel SP container of size " << pixelSP->size());
43 
44  for (const auto pixSPointColl : *pixelSP) {
45  if (pixSPointColl == nullptr) {
46  continue;
47  }
48 
49  const Identifier pixid = (pixSPointColl)->identify();
50  if (m_doOnlyBLayer == true && pixelHelper->layer_disk(pixid) != 0) {
51  continue;
52  }
53  const int bec = pixelHelper->barrel_ec(pixid);
54 
55  int nPixSP{}, nPixCL_1{}, nPixCL_2{}, nPixCLmin3{}, nPixCLnoToT{};
56  for (const auto pSP : *pixSPointColl) {
57  pixCLBeforeCuts++;
58  const InDet::PixelCluster *pixClust = static_cast<const InDet::PixelCluster *>(pSP->clusterList().first);
59 
60  const int pixClSize = (pixClust->rdoList()).size();
61  const int pixclToT = pixClust->totalToT();
62 
63  ++nPixCLnoToT;
64  if (pixclToT > m_pixelClusToTCut) {
65  ++nPixSP;
66  if (pixClSize == 1) {
67  ++nPixCL_1;
68  }
69  if (pixClSize == 2) {
70  ++nPixCL_2;
71  }
72  if (pixClSize >= 3) {
73  ++nPixCLmin3;
74  }
75  }
76  }
77 
78  // total
79  if (nPixSP > m_pixModuleThreshold) {
80  ATH_MSG_DEBUG(" This pixel module : " << pixid << " produced " << nPixSP << " pix spacepoints. Ignoring these spacepoints as the maximum allowed spacepoints per module is " << m_pixModuleThreshold);
81  pixModulesOverThreshold++;
82  } else {
83  pixCL += nPixSP;
84  pixCLnoToT += nPixCLnoToT;
85  pixCL_1 += nPixCL_1;
86  pixCL_2 += nPixCL_2;
87  pixCLmin3 += nPixCLmin3;
88  if (bec == 0) {
89  pixCLBarrel += nPixSP;
90  ATH_MSG_VERBOSE(" Formed " << nPixSP << " PIX spacepoints in PIX Barrel after ToT cut.");
91  } else if (bec == 2) {
92  pixCLEndcapA += nPixSP;
93  ATH_MSG_VERBOSE(" Formed " << nPixSP << " PIX spacepoints in PIX ECA after ToT cut.");
94  } else if (bec == -2) {
95  pixCLEndcapC += nPixSP;
96  ATH_MSG_VERBOSE(" Formed " << nPixSP << " PIX spacepoints in PIX ECC after ToT cut.");
97  }
98  }
99  }
100 
101  ATH_MSG_DEBUG("REGTEST : Formed " << pixCLBeforeCuts << " pixel spacepoints in total before cuts.");
102  ATH_MSG_DEBUG("REGTEST : " << pixCL_1 << " have cl size == 1 in total.");
103  ATH_MSG_DEBUG("REGTEST : " << pixCL_2 << " have cl size == 2 in total.");
104  ATH_MSG_DEBUG("REGTEST : " << pixCLmin3 << " have cl size >= 3 in total.");
105  ATH_MSG_DEBUG("REGTEST : Formed " << pixCLnoToT << " pixel spacepoints without ToT cut in total.");
106  ATH_MSG_DEBUG("REGTEST : Formed " << pixCL << " pixel spacepoints after ToT cut in total.");
107  ATH_MSG_DEBUG("REGTEST : Formed " << pixCLBarrel << " SP in pixel barrel in total.");
108  ATH_MSG_DEBUG("REGTEST : Formed " << pixCLEndcapA << " SP in pixel ECA in total.");
109  ATH_MSG_DEBUG("REGTEST : Formed " << pixCLEndcapC << " SP in pixel ECC in total.");
110 
112 
114  SG::ReadHandle<SCT_ID> SctHelper(m_sctHelperKey, context);
115  ATH_MSG_DEBUG("Successfully retrieved SCT SP container of size " << SctSP->size());
116 
117  // Here monitor define
118  int nSctSP{};
119  int sctSPBarrel{};
120  int sctSPEndcapA{};
121  int sctSPEndcapC{};
122  int sctSP{};
123  int sctModulesOverThreshold{};
124 
125  for (const auto SctSPointColl : *SctSP) {
126  if (SctSPointColl == nullptr) {
127  continue;
128  }
129 
130  nSctSP = (SctSPointColl)->size();
131  const Identifier Sctid = (SctSPointColl)->identify();
132  const int bec = (int)SctHelper->barrel_ec(Sctid);
133 
134  ATH_MSG_VERBOSE(" Formed " << nSctSP << " sct spacepoints"
135  << " with sctid module " << Sctid);
136  // barrel
137  // total
138  if (nSctSP < m_sctModuleLowerThreshold && nSctSP > m_sctModuleHigherThreshold) {
139  // this is noise
140  ATH_MSG_DEBUG(" This SCT module : " << Sctid << " produced " << nSctSP << " SCT spacepoints. Ignoring these spacepoints as the number of allowed spacepoints per module is between"
142  sctModulesOverThreshold++;
143  } else { // Accept the spacepoints
144  if (bec == 0) {
145  sctSPBarrel += nSctSP;
146  ATH_MSG_VERBOSE(" Formed " << nSctSP << " SCT barrel spacepoints .");
147  } else if (bec == 2) { // endcap, side A
148  sctSPEndcapA += nSctSP;
149  ATH_MSG_VERBOSE(" Formed " << nSctSP << " SCT ECA spacepoints.");
150  } else if (bec == -2) { // endcap, side C
151  sctSPEndcapC += nSctSP;
152  ATH_MSG_VERBOSE(" Formed " << nSctSP << " SCT ECC spacepoints.");
153  }
154  }
155  }
156 
157  sctSP = sctSPEndcapC + sctSPBarrel + sctSPEndcapA;
158 
159  ATH_MSG_DEBUG("REGTEST : Formed " << sctSP << " sct spacepoints in total.");
160  ATH_MSG_DEBUG("REGTEST : Formed " << sctSPEndcapC << " sct ECC spacepoints in total.");
161  ATH_MSG_DEBUG("REGTEST : Formed " << sctSPBarrel << " sct Barr spacepoints in total.");
162  ATH_MSG_DEBUG("REGTEST : Formed " << sctSPEndcapA << " sct ECA spacepoints in total.");
163 
164  // Recording Data
166 
167  auto spacePoints = std::make_unique<xAOD::TrigCompositeContainer>();
168  auto spacePointsAux = std::make_unique<xAOD::TrigCompositeAuxContainer>();
169  spacePoints->setStore(spacePointsAux.get());
170 
171  xAOD::TrigComposite *spCounts = new xAOD::TrigComposite();
172  spacePoints->push_back(spCounts);
173 
174  std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> monitoredVariables;
175 
176 #define SAVE_AND_MONITOR(__VARNAME) \
177  spCounts->setDetail(#__VARNAME, __VARNAME); \
178  auto mon_##__VARNAME = Monitored::Scalar(#__VARNAME, __VARNAME); \
179  monitoredVariables.emplace_back(mon_##__VARNAME);
180 
181  SAVE_AND_MONITOR(pixCL);
182  SAVE_AND_MONITOR(pixCLnoToT);
183  SAVE_AND_MONITOR(pixCL_1);
184  SAVE_AND_MONITOR(pixCL_2);
185  SAVE_AND_MONITOR(pixCLmin3);
186  SAVE_AND_MONITOR(pixCLBarrel);
187  SAVE_AND_MONITOR(pixCLEndcapA);
188  SAVE_AND_MONITOR(pixCLEndcapC);
189  SAVE_AND_MONITOR(sctSP);
190  SAVE_AND_MONITOR(sctSPBarrel);
191  SAVE_AND_MONITOR(sctSPEndcapA);
192  SAVE_AND_MONITOR(sctSPEndcapC);
193 #undef SAVE_AND_MONITOR
194 
195  auto mon_pixCLBeforeCuts = Monitored::Scalar<int>("pixCLBeforeCuts", pixCLBeforeCuts);
196  monitoredVariables.emplace_back(mon_pixCLBeforeCuts);
197  auto mon_pixModulesOverThreshold = Monitored::Scalar<int>("pixModulesOverThreshold", pixModulesOverThreshold);
198  monitoredVariables.emplace_back(mon_pixModulesOverThreshold);
199  auto mon_sctModulesOverThreshold = Monitored::Scalar<int>("sctModulesOverThreshold", sctModulesOverThreshold);
200  monitoredVariables.emplace_back(mon_sctModulesOverThreshold);
201  Monitored::Group(m_monTool, monitoredVariables);
202 
203  ATH_CHECK(spacePointHandle.record(std::move(spacePoints), std::move(spacePointsAux)));
204 
205  return StatusCode::SUCCESS;
206 }
TrigCountSpacePoints.h
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigCountSpacePoints::m_pixelHelperKey
SG::ReadHandleKey< PixelID > m_pixelHelperKey
Definition: TrigCountSpacePoints.h:44
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:16
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
PixelCluster.h
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
TrigCountSpacePoints::m_spacePointsKey
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_spacePointsKey
Definition: TrigCountSpacePoints.h:46
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
TrigCountSpacePoints::m_pixelSpKey
SG::ReadHandleKey< SpacePointContainer > m_pixelSpKey
Definition: TrigCountSpacePoints.h:42
TrigCountSpacePoints::m_doOnlyBLayer
Gaudi::Property< bool > m_doOnlyBLayer
Definition: TrigCountSpacePoints.h:26
TrigCountSpacePoints::m_pixelClusToTCut
Gaudi::Property< int > m_pixelClusToTCut
Definition: TrigCountSpacePoints.h:40
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrigCountSpacePoints::m_sctModuleHigherThreshold
Gaudi::Property< int > m_sctModuleHigherThreshold
Definition: TrigCountSpacePoints.h:28
TrigCountSpacePoints::m_sctSpKey
SG::ReadHandleKey< SpacePointContainer > m_sctSpKey
Definition: TrigCountSpacePoints.h:43
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TrigCountSpacePoints::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigCountSpacePoints.h:49
SAVE_AND_MONITOR
#define SAVE_AND_MONITOR(__VARNAME)
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::PixelCluster::totalToT
int totalToT() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:205
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigCountSpacePoints::initialize
virtual StatusCode initialize() override
Definition: TrigCountSpacePoints.cxx:11
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
TrigCountSpacePoints::m_sctHelperKey
SG::ReadHandleKey< SCT_ID > m_sctHelperKey
Definition: TrigCountSpacePoints.h:45
TrigCountSpacePoints::m_pixModuleThreshold
Gaudi::Property< int > m_pixModuleThreshold
Definition: TrigCountSpacePoints.h:27
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
InDet::PixelCluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TrigCountSpacePoints::TrigCountSpacePoints
TrigCountSpacePoints(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigCountSpacePoints.cxx:9
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigCountSpacePoints::m_spacePointsAuxKey
SG::WriteHandleKey< xAOD::TrigCompositeAuxContainer > m_spacePointsAuxKey
Definition: TrigCountSpacePoints.h:47
TrigCountSpacePoints::m_sctModuleLowerThreshold
Gaudi::Property< int > m_sctModuleLowerThreshold
Definition: TrigCountSpacePoints.h:29
TrigCountSpacePoints::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigCountSpacePoints.cxx:24