ATLAS Offline Software
PhysValTool.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 "src/PhysValTool.h"
6 
7 namespace ActsTrk {
8 
9  PhysValTool::PhysValTool(const std::string & type,
10  const std::string& name,
11  const IInterface* parent)
13  {}
14 
16  {
17  ATH_MSG_DEBUG("Initializing " << name() << " ... ");
18 
21 
25 
29 
31 
32  ATH_MSG_DEBUG("Properties:");
39 
40  std::string folder = "SquirrelPlots/Acts";
41  if (m_doPixelClusters) {
43  std::make_unique< ActsTrk::PixelClusterValidationPlots >(nullptr,
44  Form("%s/%s/",
45  folder.c_str(),
46  m_pixelClusterContainerKey.key().c_str()));
47  }
48 
49  if (m_doStripClusters) {
51  std::make_unique< ActsTrk::StripClusterValidationPlots >(nullptr,
52  Form("%s/%s/",
53  folder.c_str(),
54  m_stripClusterContainerKey.key().c_str()));
55  }
56 
59  std::make_unique< ActsTrk::PixelSpacePointValidationPlots >(nullptr,
60  Form("%s/%s/",
61  folder.c_str(),
62  m_pixelSpacePointContainerKey.key().c_str()));
63  }
64 
67  std::make_unique< ActsTrk::StripSpacePointValidationPlots >(nullptr,
68  Form("%s/%s/",
69  folder.c_str(),
70  m_stripSpacePointContainerKey.key().c_str()),
71  "Strip");
72  }
73 
76  std::make_unique< ActsTrk::StripSpacePointValidationPlots >(nullptr,
77  Form("%s/%s/",
78  folder.c_str(),
80  "StripOverlap");
81  }
82 
83  // Schedule HGTD objects
84  if (m_doHgtdClusters) {
86  std::make_unique< ActsTrk::HgtdClusterValidationPlots >(nullptr,
87  Form("%s/%s/",
88  folder.c_str(),
89  m_hgtdClusterContainerKey.key().c_str()));
90  }
91 
93  ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
95  ATH_CHECK(detStore()->retrieve(m_stripID, "SCT_ID"));
96  if (m_doHgtdClusters)
97  ATH_CHECK(detStore()->retrieve(m_hgtdID, "HGTD_ID"));
98 
99  return StatusCode::SUCCESS;
100  }
101 
103  {
104  ATH_MSG_DEBUG("Booking histograms for " << name() << " ... " );
105 
109 
113 
114  return StatusCode::SUCCESS;
115  }
116 
117  StatusCode PhysValTool::fillHgtdClusters(const EventContext& ctx,
118  float beamSpotWeight) {
119  ATH_MSG_DEBUG("Analysing HGTD Clusters");
121  if (not inputHgtdClusterContainer.isValid()) {
122  ATH_MSG_FATAL("xAOD::HGTDClusterContainer with key " << m_hgtdClusterContainerKey.key() << " is not available...");
123  return StatusCode::FAILURE;
124  }
125  const xAOD::HGTDClusterContainer *hgtdClusterContainer = inputHgtdClusterContainer.cptr();
126 
128  const InDetDD::HGTD_DetectorElementCollection* hgtdElements(*hgtdDetEleHandle);
129  if (not hgtdDetEleHandle.isValid() or hgtdElements==nullptr) {
130  ATH_MSG_FATAL(m_HGTDDetEleCollKey.fullKey() << " is not available.");
131  return StatusCode::FAILURE;
132  }
133 
134  // Fill plots
135  for (const xAOD::HGTDCluster* cluster : *hgtdClusterContainer) {
136  m_hgtdClusterValidationPlots->fill(cluster, *hgtdElements, beamSpotWeight, m_hgtdID);
137  }
138 
139  return StatusCode::SUCCESS;
140  }
141 
143  float beamSpotWeight) {
144  ATH_MSG_DEBUG("Analysing Pixel Clusters");
146  if (not inputPixelClusterContainer.isValid()) {
147  ATH_MSG_FATAL("xAOD::PixelClusterContainer with key " << m_pixelClusterContainerKey.key() << " is not available...");
148  return StatusCode::FAILURE;
149  }
150  const xAOD::PixelClusterContainer *pixelClusterContainer = inputPixelClusterContainer.cptr();
151 
152  for (const xAOD::PixelCluster* cluster : *pixelClusterContainer) {
153  m_pixelClusterValidationPlots->fill(cluster, beamSpotWeight, m_pixelID);
154  }
155 
156  return StatusCode::SUCCESS;
157  }
158 
160  float beamSpotWeight) {
161  ATH_MSG_DEBUG("Analysing Strip Clusters");
163  if (not inputStripClusterContainer.isValid()) {
164  ATH_MSG_FATAL("xAOD::StripClusterContainer with key " << m_stripClusterContainerKey.key() << " is not available...");
165  return StatusCode::FAILURE;
166  }
167  const xAOD::StripClusterContainer *stripClusterContainer = inputStripClusterContainer.cptr();
168 
169  for (const xAOD::StripCluster* cluster : *stripClusterContainer) {
170  m_stripClusterValidationPlots->fill(cluster, beamSpotWeight, m_stripID);
171  }
172 
173  return StatusCode::SUCCESS;
174  }
175 
176 
178  float beamSpotWeight) {
179  ATH_MSG_DEBUG("Analysing Pixel Space Points");
181  if (not inputPixelSpacePointContainer.isValid()) {
182  ATH_MSG_FATAL("xAOD::SpacePointContainer with key " << m_pixelSpacePointContainerKey.key() << " is not available...");
183  return StatusCode::FAILURE;
184  }
185  const xAOD::SpacePointContainer *pixelSpacePointContainer = inputPixelSpacePointContainer.cptr();
186 
187  for (const xAOD::SpacePoint* spacePoint : *pixelSpacePointContainer) {
188  m_pixelSpacePointValidationPlots->fill(spacePoint, beamSpotWeight, m_pixelID);
189  }
190 
191  return StatusCode::SUCCESS;
192  }
193 
195  float beamSpotWeight) {
196  ATH_MSG_DEBUG("Analysing Strip Space Points");
198  if (not inputStripSpacePointContainer.isValid()) {
199  ATH_MSG_FATAL("xAOD::SpacePointContainer with key " << m_stripSpacePointContainerKey.key() << " is not available...");
200  return StatusCode::FAILURE;
201  }
202  const xAOD::SpacePointContainer *stripSpacePointContainer = inputStripSpacePointContainer.cptr();
203 
204  for (const xAOD::SpacePoint* spacePoint : *stripSpacePointContainer) {
205  m_stripSpacePointValidationPlots->fill(spacePoint, beamSpotWeight, m_stripID);
206  }
207 
208  return StatusCode::SUCCESS;
209  }
210 
212  float beamSpotWeight) {
213  ATH_MSG_DEBUG("Analysing Strip Overlap Space Points");
215  if (not inputStripOverlapSpacePointContainer.isValid()) {
216  ATH_MSG_FATAL("xAOD::SpacePointContainer with key " << m_stripOverlapSpacePointContainerKey.key() << " is not available...");
217  return StatusCode::FAILURE;
218  }
219  const xAOD::SpacePointContainer *stripOverlapSpacePointContainer = inputStripOverlapSpacePointContainer.cptr();
220 
221  for(const xAOD::SpacePoint* spacePoint : *stripOverlapSpacePointContainer) {
222  m_stripOverlapSpacePointValidationPlots->fill(spacePoint, beamSpotWeight, m_stripID);
223  }
224 
225  return StatusCode::SUCCESS;
226  }
227 
228 
230  {
231  ATH_MSG_DEBUG("Filling histograms for " << name() << " ... ");
232 
233  const EventContext& ctx = Gaudi::Hive::currentContext();
234 
235  // Get Event Info
237  if (not eventInfoHandle.isValid()) {
238  ATH_MSG_FATAL("Could not retrieve EventInfo with key " << m_eventInfo.key());
239  return StatusCode::FAILURE;
240  }
241  const xAOD::EventInfo* eventInfo = eventInfoHandle.cptr();
242  float beamSpotWeight = eventInfo->beamSpotWeight();
243 
244  if (m_doPixelClusters) ATH_CHECK(fillPixelClusters(ctx, beamSpotWeight));
245  if (m_doStripClusters) ATH_CHECK(fillStripClusters(ctx, beamSpotWeight));
246  if (m_doHgtdClusters) ATH_CHECK(fillHgtdClusters(ctx, beamSpotWeight));
247 
248  if (m_doPixelSpacePoints) ATH_CHECK(fillPixelSpacePoints(ctx, beamSpotWeight));
249  if (m_doStripSpacePoints) ATH_CHECK(fillStripSpacePoints(ctx, beamSpotWeight));
251 
252  return StatusCode::SUCCESS;
253  }
254 
256  {
257  ATH_MSG_DEBUG("Finalising hists for " << name() << "...");
264  return StatusCode::SUCCESS;
265  }
266 
267 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ActsTrk::PhysValTool::m_pixelClusterContainerKey
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_pixelClusterContainerKey
Definition: PhysValTool.h:60
ActsTrk::PhysValTool::m_stripOverlapSpacePointContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_stripOverlapSpacePointContainerKey
Definition: PhysValTool.h:71
ActsTrk::PhysValTool::m_HGTDDetEleCollKey
SG::ReadCondHandleKey< InDetDD::HGTD_DetectorElementCollection > m_HGTDDetEleCollKey
Definition: PhysValTool.h:74
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ActsTrk::PhysValTool::m_hgtdClusterContainerKey
SG::ReadHandleKey< xAOD::HGTDClusterContainer > m_hgtdClusterContainerKey
Definition: PhysValTool.h:64
ActsTrk::PhysValTool::m_stripClusterContainerKey
SG::ReadHandleKey< xAOD::StripClusterContainer > m_stripClusterContainerKey
Definition: PhysValTool.h:62
ActsTrk::PhysValTool::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: PhysValTool.h:57
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ActsTrk::PhysValTool::bookHistograms
virtual StatusCode bookHistograms() override
An inheriting class should either override this function or bookHists().
Definition: PhysValTool.cxx:102
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
ActsTrk::PhysValTool::initialize
virtual StatusCode initialize() override
Definition: PhysValTool.cxx:15
PhysValTool.h
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:73
ActsTrk::PhysValTool::m_stripSpacePointContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_stripSpacePointContainerKey
Definition: PhysValTool.h:69
ActsTrk::PhysValTool::fillPixelSpacePoints
StatusCode fillPixelSpacePoints(const EventContext &ctx, float beamSpotWeight)
Definition: PhysValTool.cxx:177
ActsTrk::PhysValTool::m_doStripSpacePoints
Gaudi::Property< bool > m_doStripSpacePoints
Definition: PhysValTool.h:81
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ActsTrk::PhysValTool::fillPixelClusters
StatusCode fillPixelClusters(const EventContext &ctx, float beamSpotWeight)
Definition: PhysValTool.cxx:142
ActsTrk::PhysValTool::fillHgtdClusters
StatusCode fillHgtdClusters(const EventContext &ctx, float beamSpotWeight)
Definition: PhysValTool.cxx:117
ActsTrk::PhysValTool::m_doStripOverlapSpacePoints
Gaudi::Property< bool > m_doStripOverlapSpacePoints
Definition: PhysValTool.h:82
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
ActsTrk::PhysValTool::m_stripSpacePointValidationPlots
std::unique_ptr< ActsTrk::StripSpacePointValidationPlots > m_stripSpacePointValidationPlots
Definition: PhysValTool.h:89
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
xAOD::HGTDCluster_v1
Definition: HGTDCluster_v1.h:23
ActsTrk::PhysValTool::m_stripClusterValidationPlots
std::unique_ptr< ActsTrk::StripClusterValidationPlots > m_stripClusterValidationPlots
Definition: PhysValTool.h:85
ActsTrk::PhysValTool::m_doHgtdClusters
Gaudi::Property< bool > m_doHgtdClusters
Definition: PhysValTool.h:79
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ActsTrk::PhysValTool::fillHistograms
virtual StatusCode fillHistograms() override
An inheriting class should either override this function or fillHists().
Definition: PhysValTool.cxx:229
ActsTrk::PhysValTool::m_doPixelClusters
Gaudi::Property< bool > m_doPixelClusters
Definition: PhysValTool.h:77
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:617
ActsTrk::PhysValTool::procHistograms
virtual StatusCode procHistograms() override
An inheriting class should either override this function or finalHists().
Definition: PhysValTool.cxx:255
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ActsTrk::PhysValTool::m_hgtdID
const HGTD_ID * m_hgtdID
Definition: PhysValTool.h:94
ActsTrk::PhysValTool::m_doPixelSpacePoints
Gaudi::Property< bool > m_doPixelSpacePoints
Definition: PhysValTool.h:80
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::PhysValTool::m_pixelID
const PixelID * m_pixelID
Definition: PhysValTool.h:92
ActsTrk::PhysValTool::bookCollection
StatusCode bookCollection(external_collection_t *)
Definition: PhysValTool.h:98
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::PhysValTool::m_pixelSpacePointValidationPlots
std::unique_ptr< ActsTrk::PixelSpacePointValidationPlots > m_pixelSpacePointValidationPlots
Definition: PhysValTool.h:88
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::PhysValTool::m_pixelClusterValidationPlots
std::unique_ptr< ActsTrk::PixelClusterValidationPlots > m_pixelClusterValidationPlots
Definition: PhysValTool.h:84
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
ActsTrk::PhysValTool::fillStripSpacePoints
StatusCode fillStripSpacePoints(const EventContext &ctx, float beamSpotWeight)
Definition: PhysValTool.cxx:194
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
ActsTrk::PhysValTool::m_stripID
const SCT_ID * m_stripID
Definition: PhysValTool.h:93
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
ActsTrk::PhysValTool::m_pixelSpacePointContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_pixelSpacePointContainerKey
Definition: PhysValTool.h:67
ActsTrk::PhysValTool::PhysValTool
PhysValTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PhysValTool.cxx:9
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:49
ActsTrk::PhysValTool::fillStripClusters
StatusCode fillStripClusters(const EventContext &ctx, float beamSpotWeight)
Definition: PhysValTool.cxx:159
ActsTrk::PhysValTool::m_hgtdClusterValidationPlots
std::unique_ptr< ActsTrk::HgtdClusterValidationPlots > m_hgtdClusterValidationPlots
Definition: PhysValTool.h:86
ActsTrk::PhysValTool::m_stripOverlapSpacePointValidationPlots
std::unique_ptr< ActsTrk::StripSpacePointValidationPlots > m_stripOverlapSpacePointValidationPlots
Definition: PhysValTool.h:90
InDetDD::HGTD_DetectorElementCollection
Definition: HGTD_DetectorElementCollection.h:29
xAOD::EventInfo_v1::beamSpotWeight
float beamSpotWeight() const
Weight for beam spot size reweighting.
Definition: EventInfo_v1.cxx:970
ActsTrk::PhysValTool::fillStripOverlapSpacePoints
StatusCode fillStripOverlapSpacePoints(const EventContext &ctx, float beamSpotWeight)
Definition: PhysValTool.cxx:211
ActsTrk::PhysValTool::m_doStripClusters
Gaudi::Property< bool > m_doStripClusters
Definition: PhysValTool.h:78