ATLAS Offline Software
Loading...
Searching...
No Matches
InDetAlignFillSiCluster.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// ================================================
7// InDetAlignFillSiCluster
8// ================================================
9//
10// InDetAlignFillSiCluster.cxx
11// Source file for InDetAlignFillSiCluster
12//
13// Carlos Escobar, started 08/03/2008
14//
15// AthAlgTool to fill silicon cluster information in a ntuple
16
17#include "GaudiKernel/NTuple.h"
18#include "GaudiKernel/SmartDataPtr.h"
19
21
26
28
29#include <string>
30
31static const int maxclusters = 24000;
32static const int maxclsize = 10;
33
34//=====================================================================
35// InDetAlignFillSiCluster()
36//=====================================================================
38 const std::string& name,
39 const IInterface* parent)
40 : AthAlgTool(type,name,parent),
41 m_pixelid(nullptr),
42 m_sctID(nullptr),
43 m_Pixel_clcontainer(nullptr),
44 m_Sct_clcontainer(nullptr)
45{
46 declareInterface<IInDetAlignFillSiCluster>(this);
47 declareProperty("Pixel_SiClusterContainerName", m_Pixel_SiClustersName="PixelClusters");
48 declareProperty("SCT_SiClusterContainerName", m_Sct_SiClustersName="SCT_Clusters");
49
50 // Ntuple
51 declareProperty("NtupleName", m_ntupleName="/NTUPLES/GLOBFILE");
52}
53
54//=====================================================================
55// initialize()
56//=====================================================================
58
59 ATH_MSG_DEBUG("In Initialize() of FillSiCluster()");
60
61 // ID Helper
62 ATH_CHECK(detStore()->retrieve(m_sctID, "SCT_ID"));
63 ATH_MSG_DEBUG("SCT ID is : "<< m_sctID);
64
65 ATH_CHECK(detStore()->retrieve(m_pixelid, "PixelID"));
66 ATH_MSG_DEBUG("Pixel ID is : " << m_pixelid);
67
68 // retrieve the NTuple Service
69 ATH_CHECK(m_ntupleSvc.retrieve());
70
71 bookNtuple();
72
73 ATH_CHECK(m_pixelDetEleCollKey.initialize());
74 ATH_CHECK(m_SCTDetEleCollKey.initialize());
75
76 ATH_MSG_DEBUG("Initialize() of FillSiCluster successful");
77 return StatusCode::SUCCESS;
78}
79
80
81//=====================================================================
82// finalize()
83//=====================================================================
85
86 if (msgLvl(MSG::DEBUG)) {
87 msg(MSG::DEBUG) << "Finalize() of FillSiCluster" << endmsg;
88 msg(MSG::DEBUG) << "________________________________________________________" << endmsg;
89 msg(MSG::DEBUG) << endmsg;
90 msg(MSG::DEBUG) << " InDetAlignFillSiCluster Summary: " << endmsg;
91 msg(MSG::DEBUG) << "________________________________________________________" << endmsg;
92 msg(MSG::DEBUG) << endmsg;
93 }
94
95 return StatusCode::SUCCESS;
96}
97
98
99//=====================================================================
100// FillSiCluster()
101//=====================================================================
103
104 ATH_MSG_DEBUG("In FillSiCluster()");
105
106 StatusCode sc;
107
108 if(RetrieveSCTSiClusters() != StatusCode::FAILURE)
110
111 if(RetrievePixelSiClusters() != StatusCode::FAILURE)
113
114 std::string nt0id = m_ntupleName + "/SiCluster";
115 sc = m_ntupleSvc->writeRecord(nt0id);
116 if (sc.isFailure()) ATH_MSG_DEBUG("Could not write " << nt0id << "!");
117
118 return StatusCode::SUCCESS;
119}
120
121
122//=====================================================================
123// bookNtuple()
124//=====================================================================
126
127 ATH_MSG_DEBUG ("Booking Trk::Track Info...");
128
129 NTupleFilePtr file1(m_ntupleSvc.get(), m_ntupleName);
130 std::string nt0id = m_ntupleName + "/SiCluster";
131 std::string comments = "Silicon Cluster Information";
132
133 StatusCode sc;
134
135 NTuplePtr nt0(m_ntupleSvc.get(), nt0id);
136 if (nt0) ATH_MSG_DEBUG ("Ntuple is already booked");
137 else {
138 ATH_MSG_DEBUG ("Attempting to book general ntuple");
139 nt0 = m_ntupleSvc->book(nt0id,CLID_ColumnWiseTuple,comments);
140
141 if (nt0) {
142
143 // ---------------------------------------------------------------------
144 // Pixel Clusters
145 sc = nt0->addItem("pixel_clus_nclusters", m_pixel_nclusters, 0, maxclusters);
146 sc = nt0->addItem("pixel_clus_clx", m_pixel_nclusters, m_pixel_clx);
147 sc = nt0->addItem("pixel_clus_cly", m_pixel_nclusters, m_pixel_cly);
148 sc = nt0->addItem("pixel_clus_clz", m_pixel_nclusters, m_pixel_clz);
149 sc = nt0->addItem("pixel_clus_LocX", m_pixel_nclusters, m_pixel_LocX);
150 sc = nt0->addItem("pixel_clus_LocY", m_pixel_nclusters, m_pixel_LocY);
151 sc = nt0->addItem("pixel_clus_groupsize", m_pixel_nclusters, m_pixel_groupsize);
152 sc = nt0->addItem("pixel_clus_layer", m_pixel_nclusters, m_pixel_layer);
153 sc = nt0->addItem("pixel_clus_phi", m_pixel_nclusters, m_pixel_phi);
154 sc = nt0->addItem("pixel/pixel_clus_row",m_pixel_nclusters, m_pixel_clrow, maxclsize);
155 sc = nt0->addItem("pixel/pixel_clus_col",m_pixel_nclusters, m_pixel_clcol, maxclsize);
157 // ---------------------------------------------------------------------
158
159 // ----------------------------------------------------------------------
160 // SCT Clusters
161 sc = nt0->addItem("sct_clus_nclusters", m_sct_nclusters, 0, maxclusters);
162 sc = nt0->addItem("sct_clus_x", m_sct_nclusters, m_sct_clx);
163 sc = nt0->addItem("sct_clus_y", m_sct_nclusters, m_sct_cly);
164 sc = nt0->addItem("sct_clus_z", m_sct_nclusters, m_sct_clz);
165 sc = nt0->addItem("sct_clus_groupsize", m_sct_nclusters, m_sct_groupsize);
166 sc = nt0->addItem("sct_clus_layer", m_sct_nclusters, m_sct_layer);
167 sc = nt0->addItem("sct_clus_eta", m_sct_nclusters, m_sct_eta);
168 sc = nt0->addItem("sct_clus_phi", m_sct_nclusters, m_sct_phi);
169 sc = nt0->addItem("sct_clus_side", m_sct_nclusters, m_sct_side);
170 m_sct_nclusters = 0;
171 // ----------------------------------------------------------------------
172
173 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Ntuple " << nt0id << " has been booked successfully! " << endmsg;
174 }
175 else
176 ATH_MSG_ERROR ("Error booking ntuple");
177 }
178
179}
180
181
182//=====================================================================
183// RetrieveSCTSiClusters()
184//=====================================================================
186
187 ATH_MSG_DEBUG ("In RetrieveSCTSiClusters()");
188 StatusCode sc;
189
190 // get clusters from TDS
192 if (sc.isFailure() || !m_Sct_clcontainer){
193 ATH_MSG_DEBUG ("SCT Cluster container for SCT not found");
194 return StatusCode::FAILURE;
195 }
196 else ATH_MSG_DEBUG ("SCT Cluster container for SCT found");
197
198 return sc;
199}
200
201
202//=====================================================================
203// RetrievePixelSiClusters()
204//=====================================================================
206
207 ATH_MSG_DEBUG ("In RetrievePixelSiClusters()");
208 StatusCode sc;
209
210 // get pixel clusters from TDS
212 if (sc.isFailure() || !m_Pixel_clcontainer){
213 ATH_MSG_DEBUG ("Pixel Cluster container for Pixels not found");
214 return StatusCode::FAILURE;
215 }
216 else ATH_MSG_DEBUG ("Pixel Cluster container for Pixels found");
217
218 return sc;
219}
220
221//=====================================================================
222// FillSCTSiNtuple()
223//=====================================================================
225
226 ATH_MSG_DEBUG ("In FillSCTSiNtuple()");
227
228 m_sct_nclusters = 0;
229
230 // loop over SCT clusters collections
231 for(SCT_ClusterContainer::const_iterator it=m_Sct_clcontainer->begin();
232 it!=m_Sct_clcontainer->end(); ++it) {
233
234 const InDet::SCT_ClusterCollection *colNext=&(**it);
235 if (!colNext) continue;
236
237 // loop over Clusters
239 for(p_clus=colNext->begin(); p_clus!=colNext->end(); ++p_clus) {
240
241 Identifier clId = (*p_clus)->identify();
242 const InDet::SCT_Cluster& cluster = **p_clus;
243 int GroupSize = cluster.rdoList().size();
244
249 m_sct_layer[m_sct_nclusters] = m_sctID->layer_disk(clId);
250 m_sct_eta[m_sct_nclusters] = m_sctID->eta_module(clId);
251 m_sct_phi[m_sct_nclusters] = m_sctID->phi_module(clId);
252 m_sct_side[m_sct_nclusters] = m_sctID->side(clId);
253 m_sct_groupsize[m_sct_nclusters] = GroupSize;
254
255 // Cluster Information
256 if (msgLvl(MSG::DEBUG)) {
257 msg(MSG::DEBUG) << "SCT Cluster: ["
259 << m_sct_eta[m_sct_nclusters] << "/"
260 << m_sct_phi[m_sct_nclusters] << "/"
261 << m_sct_side[m_sct_nclusters] << "] - ("
262 << m_sct_clx[m_sct_nclusters] << ","
263 << m_sct_cly[m_sct_nclusters] << ","
264 << m_sct_clz[m_sct_nclusters] << ")";
265 }
266
267 if (GroupSize>1) {
268 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " strips: (" << m_sctID->strip(clId) - GroupSize
269 << "," << m_sctID->strip(clId)
270 << ") - GroupSize: " << GroupSize
271 << endmsg;
272 }
273 else {
274 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " strip: (" << m_sctID->strip(clId)
275 << ") - GroupSize: " << GroupSize
276 << endmsg;
277 }
278
279 }
281 }
282 // if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "number of clusters: " << m_sct_nclusters << endmsg;
283 }
284 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "SCT Clusters: " << m_sct_nclusters << endmsg;
285 return;
286}
287
288//=====================================================================
289// FillPixelSiNtuple()
290//=====================================================================
292
293 ATH_MSG_DEBUG ("In FillPixelSiNtuple()");
294
296
297 // loop over Pixel clusters collections
298 for(PixelClusterContainer::const_iterator it=m_Pixel_clcontainer->begin();
299 it!=m_Pixel_clcontainer->end(); ++it) {
300
301 const InDet::PixelClusterCollection *colNext=&(**it);
302 if (!colNext) continue;
303
304 // loop over Clusters
306 for(p_clus=colNext->begin(); p_clus!=colNext->end(); ++p_clus) {
307 Identifier clId = (*p_clus)->identify();
308
309 const InDet::PixelCluster& cluster = **p_clus;
310
311 int GroupSize = cluster.rdoList().size();
312
316 m_pixel_layer[m_pixel_nclusters] = m_pixelid->layer_disk(clId);
317 m_pixel_phi[m_pixel_nclusters] = m_pixelid->phi_module(clId);
322 const std::vector<Identifier>& rdoList =cluster.rdoList();
323 std::vector<Identifier>::const_iterator nextRDO;
324 int i(0);
325 for(nextRDO=rdoList.begin(); nextRDO !=rdoList.end(); ++nextRDO){
326 Identifier rdoId = (*nextRDO);
327 if(i<maxclsize){
328 m_pixel_clrow[m_pixel_nclusters][i] = m_pixelid->phi_index(rdoId);
329 m_pixel_clcol[m_pixel_nclusters][i] = m_pixelid->eta_index(rdoId);
330 }
331 ++i;
332 }
333
334 // Cluster Information
335 if (msgLvl(MSG::DEBUG)) {
336 msg(MSG::DEBUG) << "Pixel Cluster (Local Pos): ["
338 << m_pixel_phi[m_pixel_nclusters] << "] - ("
341 << " Groupsize: " << GroupSize << endmsg;
342 }
343
344 }
346 }
347 }
348 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Pixel Clusters: " << m_pixel_nclusters << endmsg;
349
350 return;
351}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static const int maxclusters
static const int maxclsize
static Double_t sc
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
NTuple::Item< long > m_sct_nclusters
number of SCT Clusters
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
NTuple::Array< float > m_sct_clx
SCT Cluster X.
virtual StatusCode FillSiCluster() override
virtual StatusCode finalize() override
NTuple::Array< float > m_pixel_clx
Pixel Cluster X.
NTuple::Matrix< long > m_pixel_clrow
NTuple::Array< float > m_sct_clz
SCT Cluster Z.
NTuple::Array< long > m_pixel_layer
Pixel Cluster layer.
ServiceHandle< INTupleSvc > m_ntupleSvc
NTuple::Array< long > m_sct_side
SCT Cluster side.
NTuple::Array< long > m_pixel_groupsize
Pixel Cluster Group Size.
const InDet::PixelClusterContainer * m_Pixel_clcontainer
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
NTuple::Array< long > m_sct_layer
SCT Cluster layer.
virtual StatusCode initialize() override
const InDet::SCT_ClusterContainer * m_Sct_clcontainer
std::string m_ntupleName
ntuple name
NTuple::Array< float > m_pixel_clz
Pixel Cluster Z.
NTuple::Item< long > m_pixel_nclusters
number of Pixel Clusters
NTuple::Array< float > m_pixel_cly
Pixel Cluster Y.
NTuple::Array< float > m_sct_cly
SCT Cluster Y.
NTuple::Array< float > m_pixel_LocY
Pixel Cluster Local Y.
NTuple::Array< long > m_sct_groupsize
SCT Cluster Group Size.
NTuple::Array< long > m_sct_phi
SCT Cluster phi.
NTuple::Matrix< long > m_pixel_clcol
const PixelID * m_pixelid
Pixel ID helper.
NTuple::Array< long > m_pixel_phi
Pixel Cluster phi.
NTuple::Array< long > m_sct_eta
SCT Cluster eta.
const SCT_ID * m_sctID
SCT ID helper.
NTuple::Array< float > m_pixel_LocX
Pixel Cluster Local X.
InDetAlignFillSiCluster(const std::string &type, const std::string &name, const IInterface *parent)
const Amg::Vector3D & globalPosition() const
return global position reference
const Amg::Vector2D & localPosition() const
return the local position reference
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)