ATLAS Offline Software
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 
23 #include "InDetIdentifier/SCT_ID.h"
26 
28 
29 #include <string>
30 
31 static const int maxclusters = 24000;
32 static const int maxclsize = 10;
33 
34 //=====================================================================
35 // InDetAlignFillSiCluster()
36 //=====================================================================
38  const std::string& name,
39  const IInterface* 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 
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)
109  FillSCTSiNtuple();
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);
156  m_pixel_nclusters = 0;
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 
245  if ( m_sct_nclusters < maxclusters ) {
246  m_sct_clx[m_sct_nclusters] = cluster.globalPosition().x();
247  m_sct_cly[m_sct_nclusters] = cluster.globalPosition().y();
248  m_sct_clz[m_sct_nclusters] = cluster.globalPosition().z();
253  m_sct_groupsize[m_sct_nclusters] = GroupSize;
254 
255  // Cluster Information
256  if (msgLvl(MSG::DEBUG)) {
257  msg(MSG::DEBUG) << "SCT Cluster: ["
258  << m_sct_layer[m_sct_nclusters] << "/"
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  }
280  m_sct_nclusters++;
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 
295  m_pixel_nclusters = 0;
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 
313  if (m_pixel_nclusters < maxclusters ){
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){
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
InDetAlignFillSiCluster::m_sct_phi
NTuple::Array< long > m_sct_phi
SCT Cluster phi.
Definition: InDetAlignFillSiCluster.h:103
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
InDetAlignFillSiCluster::m_Sct_clcontainer
const InDet::SCT_ClusterContainer * m_Sct_clcontainer
Definition: InDetAlignFillSiCluster.h:61
InDetAlignFillSiCluster::m_pixel_cly
NTuple::Array< float > m_pixel_cly
Pixel Cluster Y.
Definition: InDetAlignFillSiCluster.h:84
WriteBchToCool.comments
comments
Definition: WriteBchToCool.py:297
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
InDetAlignFillSiCluster::m_pixelid
const PixelID * m_pixelid
Pixel ID helper
Definition: InDetAlignFillSiCluster.h:54
InDetAlignFillSiCluster::RetrieveSCTSiClusters
StatusCode RetrieveSCTSiClusters()
Definition: InDetAlignFillSiCluster.cxx:185
InDetAlignFillSiCluster::m_Sct_SiClustersName
std::string m_Sct_SiClustersName
Definition: InDetAlignFillSiCluster.h:58
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
InDetAlignFillSiCluster::m_sct_nclusters
NTuple::Item< long > m_sct_nclusters
number of SCT Clusters
Definition: InDetAlignFillSiCluster.h:79
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
InDetAlignFillSiCluster::m_sct_side
NTuple::Array< long > m_sct_side
SCT Cluster side.
Definition: InDetAlignFillSiCluster.h:104
InDetAlignFillSiCluster::m_sct_clz
NTuple::Array< float > m_sct_clz
SCT Cluster Z.
Definition: InDetAlignFillSiCluster.h:99
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
InDetAlignFillSiCluster::m_sct_cly
NTuple::Array< float > m_sct_cly
SCT Cluster Y.
Definition: InDetAlignFillSiCluster.h:98
InDetAlignFillSiCluster::m_pixel_nclusters
NTuple::Item< long > m_pixel_nclusters
number of Pixel Clusters
Definition: InDetAlignFillSiCluster.h:78
ParamDefs.h
InDetAlignFillSiCluster::m_pixel_groupsize
NTuple::Array< long > m_pixel_groupsize
Pixel Cluster Group Size.
Definition: InDetAlignFillSiCluster.h:86
InDetAlignFillSiCluster::m_pixel_clrow
NTuple::Matrix< long > m_pixel_clrow
Definition: InDetAlignFillSiCluster.h:91
InDetAlignFillSiCluster::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: InDetAlignFillSiCluster.h:66
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
InDetAlignFillSiCluster::m_sct_eta
NTuple::Array< long > m_sct_eta
SCT Cluster eta.
Definition: InDetAlignFillSiCluster.h:102
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
InDetAlignFillSiCluster::FillSiCluster
virtual StatusCode FillSiCluster() override
Definition: InDetAlignFillSiCluster.cxx:102
InDetAlignFillSiCluster::FillPixelSiNtuple
void FillPixelSiNtuple()
Definition: InDetAlignFillSiCluster.cxx:291
InDetAlignFillSiCluster::finalize
virtual StatusCode finalize() override
Definition: InDetAlignFillSiCluster.cxx:84
InDetAlignFillSiCluster::initialize
virtual StatusCode initialize() override
Definition: InDetAlignFillSiCluster.cxx:57
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetAlignFillSiCluster::m_ntupleSvc
ServiceHandle< INTupleSvc > m_ntupleSvc
Definition: InDetAlignFillSiCluster.h:52
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
InDetAlignFillSiCluster::m_pixel_LocX
NTuple::Array< float > m_pixel_LocX
Pixel Cluster Local X.
Definition: InDetAlignFillSiCluster.h:89
InDetAlignFillSiCluster::InDetAlignFillSiCluster
InDetAlignFillSiCluster(const std::string &type, const std::string &name, const IInterface *parent)
Definition: InDetAlignFillSiCluster.cxx:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
InDetAlignFillSiCluster::m_sct_clx
NTuple::Array< float > m_sct_clx
SCT Cluster X.
Definition: InDetAlignFillSiCluster.h:97
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDetAlignFillSiCluster::m_sctID
const SCT_ID * m_sctID
SCT ID helper.
Definition: InDetAlignFillSiCluster.h:55
InDetAlignFillSiCluster::m_pixel_LocY
NTuple::Array< float > m_pixel_LocY
Pixel Cluster Local Y.
Definition: InDetAlignFillSiCluster.h:90
InDetAlignFillSiCluster::m_pixel_clz
NTuple::Array< float > m_pixel_clz
Pixel Cluster Z.
Definition: InDetAlignFillSiCluster.h:85
InDet::SCT_Cluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/SCT_Cluster.h:34
InDetAlignFillSiCluster::m_Pixel_clcontainer
const InDet::PixelClusterContainer * m_Pixel_clcontainer
Definition: InDetAlignFillSiCluster.h:60
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
InDetAlignFillSiCluster::RetrievePixelSiClusters
StatusCode RetrievePixelSiClusters()
Definition: InDetAlignFillSiCluster.cxx:205
InDetAlignFillSiCluster::m_Pixel_SiClustersName
std::string m_Pixel_SiClustersName
Definition: InDetAlignFillSiCluster.h:57
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PixelClusterContainer.h
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetAlignFillSiCluster::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: InDetAlignFillSiCluster.h:64
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDetAlignFillSiCluster::m_pixel_clcol
NTuple::Matrix< long > m_pixel_clcol
Definition: InDetAlignFillSiCluster.h:92
InDetAlignFillSiCluster::FillSCTSiNtuple
void FillSCTSiNtuple()
Definition: InDetAlignFillSiCluster.cxx:224
InDetAlignFillSiCluster::m_sct_layer
NTuple::Array< long > m_sct_layer
SCT Cluster layer.
Definition: InDetAlignFillSiCluster.h:101
InDet::PixelCluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::SiCluster::globalPosition
const Amg::Vector3D & globalPosition() const
return global position reference
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDetAlignFillSiCluster::bookNtuple
void bookNtuple()
Definition: InDetAlignFillSiCluster.cxx:125
InDetAlignFillSiCluster::m_pixel_layer
NTuple::Array< long > m_pixel_layer
Pixel Cluster layer.
Definition: InDetAlignFillSiCluster.h:87
DEBUG
#define DEBUG
Definition: page_access.h:11
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SCT_ClusterContainer.h
InDetAlignFillSiCluster::m_pixel_phi
NTuple::Array< long > m_pixel_phi
Pixel Cluster phi.
Definition: InDetAlignFillSiCluster.h:88
InDetAlignFillSiCluster::m_ntupleName
std::string m_ntupleName
ntuple name
Definition: InDetAlignFillSiCluster.h:76
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
InDetAlignFillSiCluster::m_pixel_clx
NTuple::Array< float > m_pixel_clx
Pixel Cluster X.
Definition: InDetAlignFillSiCluster.h:83
AthAlgTool
Definition: AthAlgTool.h:26
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
InDet::SCT_ClusterCollection
Trk::PrepRawDataCollection< SCT_Cluster > SCT_ClusterCollection
Definition: SCT_ClusterCollection.h:26
InDetAlignFillSiCluster::m_sct_groupsize
NTuple::Array< long > m_sct_groupsize
SCT Cluster Group Size.
Definition: InDetAlignFillSiCluster.h:100
InDetAlignFillSiCluster.h
InDet::PixelClusterCollection
Trk::PrepRawDataCollection< PixelCluster > PixelClusterCollection
Definition: PixelClusterCollection.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14