ATLAS Offline Software
Loading...
Searching...
No Matches
SpacePointAnalysis.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GaudiKernel/EventContext.h"
8
11
12#include "TTree.h"
13#include "TString.h"
14
15#include <algorithm>
16#include <cmath>
17#include <functional>
18#include <iostream>
19
20SpacePointAnalysis::SpacePointAnalysis(const std::string& name, ISvcLocator *pSvcLocator)
21: AthAlgorithm(name, pSvcLocator) {}
22
24 ATH_MSG_DEBUG( "Initializing SpacePointAnalysis" );
25
26 ATH_CHECK( m_inputKey.initialize() );
27
29
30 if (m_usePixel)
31 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
32 else
33 ATH_CHECK(detStore()->retrieve(m_stripID, "SCT_ID"));
34
35 ATH_CHECK(m_thistSvc.retrieve());
36
37 m_tree = new TTree(TString(m_ntupleTreeName.value()), "SpacePointAna");
38 std::string fullNtupleName = m_ntupleFileName.value() + m_ntupleDirName.value() + m_ntupleTreeName.value();
39 ATH_CHECK(m_thistSvc->regTree(fullNtupleName, m_tree));
40
41 if (m_tree) {
42 m_tree->Branch("barrelEndcap", &m_barrelEndcap);
43 m_tree->Branch("layerDisk", &m_layerDisk);
44 m_tree->Branch("phiModule", &m_phiModule);
45 m_tree->Branch("etaModule", &m_etaModule);
46 m_tree->Branch("sideModule", &m_sideModule);
47 m_tree->Branch("isInnermost", &m_isInnermost);
48 m_tree->Branch("isNextToInnermost", &m_isNextToInnermost);
49 m_tree->Branch("isOverlap", &m_isOverlap);
50 m_tree->Branch("eta", &m_eta);
51 m_tree->Branch("globalX", &m_globalX);
52 m_tree->Branch("globalY", &m_globalY);
53 m_tree->Branch("globalZ", &m_globalZ);
54 m_tree->Branch("globalCovXX", &m_globalCovXX);
55 m_tree->Branch("globalCovYY", &m_globalCovYY);
56 m_tree->Branch("globalCovZZ", &m_globalCovZZ);
57 m_tree->Branch("globalCovXY", &m_globalCovXY);
58 m_tree->Branch("globalCovXZ", &m_globalCovXZ);
59 m_tree->Branch("globalCovYX", &m_globalCovYX);
60 m_tree->Branch("globalCovYZ", &m_globalCovYZ);
61 m_tree->Branch("globalCovZX", &m_globalCovZX);
62 m_tree->Branch("globalCovZY", &m_globalCovZY);
63
64 } else {
65 ATH_MSG_ERROR("No tree found!");
66 }
67
68 m_h_globalZR = new TH2F("h_globalZR","h_globalZR; z [mm]; r [mm]",1500,-3000.,3000,1500,0.,1500);
69 ATH_CHECK(m_thistSvc->regHist(m_path.value() + m_h_globalZR->GetName(), m_h_globalZR));
70
71 m_h_etaSpacePoint = new TH1F("m_h_etaSpacePoint","m_h_etaSpacePoint; space point #eta",100, -5, 5);
72 ATH_CHECK(m_thistSvc->regHist(m_path.value() + m_h_etaSpacePoint->GetName(), m_h_etaSpacePoint));
73
75 ATH_MSG_INFO("No overlap collection when enabled for pixel space points! Check your configuration if needed.");
76
77 return StatusCode::SUCCESS;
78}
79
81 ATH_MSG_DEBUG(" In SpacePointAnalysis::execute()" );
82
83 m_barrelEndcap->clear();
84 m_layerDisk->clear();
85 m_phiModule->clear();
86 m_etaModule->clear();
87 m_sideModule->clear();
88 m_isInnermost->clear();
89 m_isNextToInnermost->clear();
90 m_isOverlap->clear();
91 m_eta->clear();
92 m_globalX->clear();
93 m_globalY->clear();
94 m_globalZ->clear();
95 m_globalCovXX->clear();
96 m_globalCovYY->clear();
97 m_globalCovZZ->clear();
98 m_globalCovXY->clear();
99 m_globalCovXZ->clear();
100 m_globalCovYX->clear();
101 m_globalCovYZ->clear();
102 m_globalCovZX->clear();
103 m_globalCovZY->clear();
104
105 const EventContext& ctx = Algorithm::getContext();
106
108 if(spContainer.isValid()) {
109 for( const SpacePointCollection* spCollection : *spContainer) {
110 if (!spCollection) continue;
111 for( const Trk::SpacePoint* spacePoint : *spCollection) {
112 const Identifier idColl(spCollection->identify());
113 const int brlEc(m_usePixel ? m_pixelID->barrel_ec(idColl) : m_stripID->barrel_ec(idColl));
114 const int layerDisk(m_usePixel ? m_pixelID->layer_disk(idColl) : m_stripID->layer_disk(idColl));
115 const int phiMod(m_usePixel ? m_pixelID->phi_module(idColl) : m_stripID->phi_module(idColl));
116 const int etaMod(m_usePixel ? m_pixelID->eta_module(idColl) : m_stripID->eta_module(idColl));
117 const int side(m_usePixel ? 0 : m_stripID->side(idColl));
118
119 bool isInnermost = m_usePixel ? (layerDisk==0) : false;
120 bool isNextToInnermost = m_usePixel ? ((layerDisk==1) or (brlEc!=0 and layerDisk==2)) : false;
121
122 m_barrelEndcap->push_back(brlEc);
123 m_layerDisk->push_back(layerDisk);
124 m_phiModule->push_back(phiMod);
125 m_etaModule->push_back(etaMod);
126 m_sideModule->push_back(side);
127 m_isInnermost->push_back(int(isInnermost));
128 m_isNextToInnermost->push_back(int(isNextToInnermost));
129 m_isOverlap->push_back(0);
130
131 auto globalPos = spacePoint->globalPosition();
132 auto globalCov = spacePoint->globCovariance();
133
134 m_eta->push_back(globalPos.eta());
135 m_globalX->push_back(globalPos.x());
136 m_globalY->push_back(globalPos.y());
137 m_globalZ->push_back(globalPos.z());
138
139 m_globalCovXX->push_back(globalCov(0,0));
140 m_globalCovYY->push_back(globalCov(1,1));
141 m_globalCovZZ->push_back(globalCov(2,2));
142 m_globalCovXY->push_back(globalCov(0,1));
143 m_globalCovXZ->push_back(globalCov(0,2));
144 m_globalCovYX->push_back(globalCov(1,0));
145 m_globalCovYZ->push_back(globalCov(1,2));
146 m_globalCovZX->push_back(globalCov(2,0));
147 m_globalCovZY->push_back(globalCov(2,1));
148
149 m_h_globalZR->Fill(globalPos.z(), globalPos.perp());
150 m_h_etaSpacePoint->Fill(globalPos.eta());
151
152 }
153 }
154 } else {
155 ATH_MSG_FATAL("Unable to get SpacePointContainer: " << m_inputKey.key());
156 }
157
158 if (not m_usePixel and m_useOverlap) {
160 if (spCollection.isValid()) {
161 for( const Trk::SpacePoint* spacePoint : *spCollection) {
162 const IdentifierHash hashId(spacePoint->elementIdList().first);
163 const Identifier idColl = m_stripID->wafer_id(hashId);
164
165 const int brlEc(m_stripID->barrel_ec(idColl));
166 const int layerDisk(m_stripID->layer_disk(idColl));
167 const int phiMod(m_stripID->phi_module(idColl));
168 const int etaMod(m_stripID->eta_module(idColl));
169 const int side(m_stripID->side(idColl));
170
171 const bool isInnermost(false);
172 const bool isNextToInnermost(false);
173
174 m_barrelEndcap->push_back(brlEc);
175 m_layerDisk->push_back(layerDisk);
176 m_phiModule->push_back(phiMod);
177 m_etaModule->push_back(etaMod);
178 m_sideModule->push_back(side);
179 m_isInnermost->push_back(int(isInnermost));
180 m_isNextToInnermost->push_back(int(isNextToInnermost));
181 m_isOverlap->push_back(1);
182
183 auto globalPos = spacePoint->globalPosition();
184 auto globalCov = spacePoint->globCovariance();
185
186 m_eta->push_back(globalPos.eta());
187 m_globalX->push_back(globalPos.x());
188 m_globalY->push_back(globalPos.y());
189 m_globalZ->push_back(globalPos.z());
190
191 m_globalCovXX->push_back(globalCov(0,0));
192 m_globalCovYY->push_back(globalCov(1,1));
193 m_globalCovZZ->push_back(globalCov(2,2));
194 m_globalCovXY->push_back(globalCov(0,1));
195 m_globalCovXZ->push_back(globalCov(0,2));
196 m_globalCovYX->push_back(globalCov(1,0));
197 m_globalCovYZ->push_back(globalCov(1,2));
198 m_globalCovZX->push_back(globalCov(2,0));
199 m_globalCovZY->push_back(globalCov(2,1));
200
201 m_h_globalZR->Fill(globalPos.z(), globalPos.perp());
202 m_h_etaSpacePoint->Fill(globalPos.eta());
203
204 }
205 } else {
206 ATH_MSG_FATAL("Unable to get SpacePointContainer: " << m_inputOverlapKey.key());
207 }
208 }
209
210 if (m_tree) {
211 m_tree->Fill();
212 }
213
214 return StatusCode::SUCCESS;
215}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
Handle class for reading from StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
This is a "hash" representation of an Identifier.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::vector< double > * m_globalY
StringProperty m_ntupleTreeName
std::vector< double > * m_globalZ
SpacePointAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< double > * m_globalCovZY
std::vector< int > * m_layerDisk
std::vector< int > * m_isInnermost
std::vector< double > * m_globalCovXX
BooleanProperty m_useOverlap
const PixelID * m_pixelID
std::vector< double > * m_globalCovZZ
std::vector< double > * m_eta
StringProperty m_ntupleFileName
std::vector< double > * m_globalX
std::vector< int > * m_barrelEndcap
virtual StatusCode initialize() override final
const SCT_ID * m_stripID
std::vector< int > * m_sideModule
std::vector< int > * m_phiModule
std::vector< double > * m_globalCovYZ
std::vector< int > * m_isOverlap
SG::ReadHandleKey< SpacePointOverlapCollection > m_inputOverlapKey
std::vector< double > * m_globalCovXY
SG::ReadHandleKey< SpacePointContainer > m_inputKey
std::vector< double > * m_globalCovYX
BooleanProperty m_usePixel
std::vector< int > * m_etaModule
virtual StatusCode execute() override final
std::vector< double > * m_globalCovZX
std::vector< int > * m_isNextToInnermost
std::vector< double > * m_globalCovYY
std::vector< double > * m_globalCovXZ
StringProperty m_ntupleDirName
ServiceHandle< ITHistSvc > m_thistSvc