ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_PixelHistoFiller.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7//local object includes
13
14//STL
15#include <memory> //for unique_ptr
16
17//ROOT
18#include "TFile.h"
19#include "TH1I.h"
20
21AFP_PixelHistoFiller::AFP_PixelHistoFiller(const std::string& name, ISvcLocator* pSvcLocator) :
22 AthAlgorithm(name, pSvcLocator)
23{
24}
25
26
28{
29 ATH_CHECK( m_eventInfoKey.initialize() );
30 ATH_CHECK( m_afpHitContainerKey.initialize() );
31 ATH_CHECK( m_afpTrackContainerKey.initialize() );
32
35
36 for(int st=0;st<m_nStations;++st)
37 {
38 for(int la=0;la<m_nLayers;++la)
39 {
40 m_pixelHits[st][la].clear();
41 m_pixelCluster[st][la].clear();
42
43
44 TProfile lb_dx(Form("lb_dx_station_%d_layer_%d", st,la), Form("lb_dx, station %d, layer %d", st,la), 100, 0, 1000);
45 m_lb_xDistSiTrackCluster[st][la] = lb_dx;
46
47 TProfile lb_dy(Form("lb_dy_station_%d_layer_%d", st,la), Form("lb_dy, station %d, layer %d", st,la), 100, 0, 1000);
48 m_lb_yDistSiTrackCluster[st][la] = lb_dy;
49
50 TProfile2D lb_yc_dy(Form("lb_yCluster_dy_station_%d_layer_%d", st,la), Form("lb_yCluster_dy, station %d, layer %d", st,la), 100, 0, 1000, 40, -20., 20.);
51 m_lb_yCluster_yDistSiTrackCluster[st][la] = lb_yc_dy;
52
53 TProfile2D lb_xc_dx(Form("lb_xCluster_dx_station_%d_layer_%d", st,la), Form("lb_xCluster_dx, station %d, layer %d", st,la), 100, 0, 1000, 40, -20., 20.);
54 m_lb_xCluster_xDistSiTrackCluster[st][la] = lb_xc_dx;
55
56 TProfile2D lb_xC_dy(Form("lb_xCluster_dy_station_%d_layer_%d", st, la), Form("lb_xCluster_dy, station %d, layer %d", st, la), 100, 0, 1000, 40, -20, 20);
57 m_lb_xCluster_yDistSiTrackCluster[st][la] = lb_xC_dy;
58
59 TProfile2D lb_yC_dx(Form("lb_yCluster_dx_station_%d_layer_%d", st, la), Form("lb_yCluster_dx, station %d, layer %d", st, la), 100, 0, 1000, 40, -20, 20);
60 m_lb_yCluster_xDistSiTrackCluster[st][la] = lb_yC_dx;
61
62 TProfile2D lb_zC_dx(Form("lb_zCluster_dx_station_%d_layer_%d", st, la), Form("lb_zCluster_dx, station %d, layer %d", st, la), 100, 0, 1000, 100, 9*la - 3, 9*(la+1));
63 m_lb_zCluster_xDistSiTrackCluster[st][la] = lb_zC_dx;
64
65 TProfile2D lb_zC_dy(Form("lb_zCluster_dy_station_%d_layer_%d", st, la), Form("lb_zCluster_dy, station %d, layer %d", st, la), 100, 0, 1000, 100, 9*la - 3, 9*(la+1));
66 m_lb_zCluster_yDistSiTrackCluster[st][la] = lb_zC_dy;
67
68 TProfile2D lb_sx_dx(Form("lb_xSlopeTrack_dx_station_%d_layer_%d",st,la), Form("xSlopeTrack_dx, station %d, layer %d", st,la), 100, 0, 1000, 100, -1., 1.);
69 m_lb_sxTrack_xDistSiTrackCluster[st][la] = lb_sx_dx;
70
71 TProfile2D lb_sy_dy(Form("lb_ySlopeTrack_dy_station_%d_layer_%d", st,la), Form("lb_ySlopeTrack_dy, station %d, layer %d", st,la), 100, 0, 1000, 100, -1., 1.);
72 m_lb_syTrack_yDistSiTrackCluster[st][la] = lb_sy_dy;
73
74 TProfile2D lb_sy_dx(Form("lb_ySlopeTrack_dx_station_%d_layer_%d", st,la), Form("lb_ySlopeTrack_dx, station %d, layer %d", st,la), 100, 0, 1000, 100, -1., 1.);
75 m_lb_syTrack_xDistSiTrackCluster[st][la] = lb_sy_dx;
76
77 TProfile2D lb_sx_dy(Form("lb_xSlopeTrack_dy_station_%d_layer_%d", st,la), Form("lb_xSlopeTrack_dy, station %d, layer %d", st,la), 100, 0, 1000, 100, -1., 1.);
78 m_lb_sxTrack_yDistSiTrackCluster[st][la] = lb_sx_dy;
79
80 }
81 }
82
83 return StatusCode::SUCCESS;
84}
85
86
88{
89 const EventContext& ctx = Gaudi::Hive::currentContext();
90
91 // get event info
93 if (!eventInfo.isValid())
94 {
95 ATH_MSG_WARNING("cannot get eventInfo");
96 return StatusCode::SUCCESS;
97 }
98 else ATH_MSG_DEBUG("successfully got eventInfo");
99
100 // make sure all the histograms are defined
101 int current_lb=eventInfo->lumiBlock();
102
103 if(static_cast<int>(m_pixelHits[0][0].size())-1<current_lb/m_LBRangeLength)
104 {
105 for(int st=0;st<m_nStations;++st)
106 {
107 for(int la=0;la<m_nLayers;++la)
108 {
109 for(int add=static_cast<int>(m_pixelHits[st][la].size());add<=current_lb/m_LBRangeLength;++add)
110 {
111 TH2F p_hist(Form("pixel_hits_lb_%d_%d_station_%d_layer_%d", add*m_LBRangeLength,(add+1)*m_LBRangeLength-1,st,la),
112 Form("pixel hits, lb %d-%d, station %d, layer %d", add*m_LBRangeLength,(add+1)*m_LBRangeLength-1,st,la),
114
115 m_pixelHits[st][la].push_back(p_hist);
116
117 TH2F c_hist(Form("pixel_clusters_lb_%d_%d_station_%d_layer_%d", add*m_LBRangeLength,(add+1)*m_LBRangeLength-1,st,la),
118 Form("pixel_clusters, lb %d-%d, station %d, layer %d", add*m_LBRangeLength,(add+1)*m_LBRangeLength-1,st,la),
119 400,-20, 20, 400, -20, 20);
120
121 m_pixelCluster[st][la].push_back(c_hist);
122
123
124 }
125
126 }
127 }
128 }
129
130 int lb_index=current_lb/m_LBRangeLength;
131
132 // Get containers:
133
135 if (!afpHitContainer.isValid())
136 {
137 ATH_MSG_WARNING("cannot get AFPSiHitContainer");
138 return StatusCode::SUCCESS;
139 }
140 else ATH_MSG_DEBUG("successfully got AFPSiHitContainer");
141
143 if(!afpTrackContainer.isValid()){
144 ATH_MSG_WARNING("cannot get AFPTrackContainer");
145 return StatusCode::SUCCESS;
146 }else{
147 ATH_MSG_DEBUG("successfully got AFPTrackContainer");
148 }
149
150
151// Fill histograms:
152// Pixel hit histograms:
153
154 for (const xAOD::AFPSiHit* hit : *afpHitContainer)
155 {
156 int st=hit->stationID();
157 int la=hit->pixelLayerID();
158
159 if(st<0 || m_nStations<=st)
160 {
161 ATH_MSG_INFO("stationID = " <<st<<", but expected values are from 0 to "<<m_nStations-1 );
162 continue;
163 }
164 if(la<0 || m_nLayers<=la)
165 {
166 ATH_MSG_INFO("pixelLayerID = " <<la<<", but expected values are from 0 to "<<m_nLayers-1 );
167 continue;
168 }
169
170 m_pixelHits[st][la].at(lb_index).Fill(hit->pixelRowIDChip(),hit->pixelColIDChip());
171 }
172
173// Histograms for local alignment:
174
175 // determining numbers for good track selection
176
177 int nTrks[m_nStations]={0};
178 int nClusterHits[m_nStations]={0};
179 int nClusterHistPerPlane[m_nStations][m_nLayers]={{0}};
180
181 for(const xAOD::AFPTrack* track: *afpTrackContainer){
182 nTrks[track->stationID()]++;
183 for(const auto& cluster : track->clusters()){
184 nClusterHits[(*cluster)->stationID()]++;
185 nClusterHistPerPlane[(*cluster)->stationID()][(*cluster)->pixelLayerID()]++;
186 }
187 }
188
189 // looping over tracks
190
191 for(const xAOD::AFPTrack* track: *afpTrackContainer){
192
193 if(nTrks[track->stationID()] != 1) continue; //exactly 1 track per station
194
195 for (const auto& cluster : track->clusters())
196 {
197 int st=(*cluster)->stationID();
198 int la=(*cluster)->pixelLayerID();
199
200
201
202 if(st<0 || m_nStations<=st)
203 {
204 ATH_MSG_INFO("stationID = " <<st<<", but expected values are from 0 to "<<m_nStations-1 );
205 continue;
206 }
207
208 if(la<0 || m_nLayers<=la)
209 {
210 ATH_MSG_INFO("pixelLayerID = " <<la<<", but expected values are from 0 to "<<m_nLayers-1 );
211 continue;
212 }
213
214 if(nClusterHits[st]<3 || nClusterHits[st]>4) continue; // 3 or 4 cluster hits per track
215 if(nClusterHistPerPlane[st][la]>1) continue; // 1 cluster hit per plane
216
217 m_pixelCluster[st][la].at(lb_index).Fill((*cluster)->xLocal(),(*cluster)->yLocal());
218
219 double dx = 1e3*(track->xLocal() + (*cluster)->zLocal()*track->xSlope() - (*cluster)->xLocal());
220 double dy = 1e3*(track->yLocal() + (*cluster)->zLocal()*track->ySlope() - (*cluster)->yLocal());
221
222 m_lb_yCluster_yDistSiTrackCluster[st][la].Fill(current_lb, (*cluster)->yLocal(), dy);
223 m_lb_xCluster_xDistSiTrackCluster[st][la].Fill(current_lb, (*cluster)->xLocal(), dx);
224 m_lb_sxTrack_xDistSiTrackCluster[st][la].Fill(current_lb, track->xSlope(), dx);
225 m_lb_syTrack_yDistSiTrackCluster[st][la].Fill(current_lb, track->ySlope(), dy);
226 m_lb_syTrack_xDistSiTrackCluster[st][la].Fill(current_lb, track->ySlope(), dx);
227 m_lb_sxTrack_yDistSiTrackCluster[st][la].Fill(current_lb, track->xSlope(), dy);
228
229 m_lb_xDistSiTrackCluster[st][la].Fill(current_lb, dx);
230 m_lb_yDistSiTrackCluster[st][la].Fill(current_lb, dy);
231
232 m_lb_xCluster_yDistSiTrackCluster[st][la].Fill(current_lb, (*cluster)->xLocal(), dy);
233 m_lb_yCluster_xDistSiTrackCluster[st][la].Fill(current_lb, (*cluster)->yLocal(), dx);
234 m_lb_zCluster_xDistSiTrackCluster[st][la].Fill(current_lb, (*cluster)->zLocal(), dx);
235 m_lb_zCluster_yDistSiTrackCluster[st][la].Fill(current_lb, (*cluster)->zLocal(), dy);
236
237 }
238
239 }
240
241 return StatusCode::SUCCESS;
242}
243
244
246{
247 std::unique_ptr<TFile> output_file(new TFile("AFP_PixelHistoFiller.root","recreate"));
248
249 TH1I lb("LBRangeLength","LBRangeLength",2,0,2);
250 lb.Fill(0.5);
251 lb.Fill(1.5,m_LBRangeLength);
252 lb.Write();
253
254 for(int st=0;st<m_nStations;++st)
255 {
256 for(int la=0;la<m_nLayers;++la)
257 {
258 m_lb_xDistSiTrackCluster[st][la].Write();
259 m_lb_yDistSiTrackCluster[st][la].Write();
260 m_lb_xCluster_yDistSiTrackCluster[st][la].Write();
261 m_lb_yCluster_xDistSiTrackCluster[st][la].Write();
262 m_lb_zCluster_xDistSiTrackCluster[st][la].Write();
263 m_lb_zCluster_yDistSiTrackCluster[st][la].Write();
264 m_lb_yCluster_yDistSiTrackCluster[st][la].Write();
265 m_lb_xCluster_xDistSiTrackCluster[st][la].Write();
266 m_lb_sxTrack_xDistSiTrackCluster[st][la].Write();
267 m_lb_syTrack_yDistSiTrackCluster[st][la].Write();
268 m_lb_syTrack_xDistSiTrackCluster[st][la].Write();
269 m_lb_sxTrack_yDistSiTrackCluster[st][la].Write();
270
271 for(TH2F& p_hist: m_pixelHits[st][la])
272 {
273 p_hist.Write();
274 }
275 for(TH2F& c_hist: m_pixelCluster[st][la]){
276 c_hist.Write();
277 }
278
279 }
280 }
281
282 output_file->Close();
283
284 return StatusCode::SUCCESS;
285}
286
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< int > m_LBRangeLength
TProfile2D m_lb_zCluster_xDistSiTrackCluster[m_nStations][m_nLayers]
virtual StatusCode initialize() override
virtual StatusCode finalize() override
TProfile2D m_lb_sxTrack_xDistSiTrackCluster[m_nStations][m_nLayers]
SG::ReadHandleKey< xAOD::AFPTrackContainer > m_afpTrackContainerKey
std::vector< TH2F > m_pixelCluster[m_nStations][m_nLayers]
TProfile2D m_lb_yCluster_yDistSiTrackCluster[m_nStations][m_nLayers]
TProfile2D m_lb_xCluster_xDistSiTrackCluster[m_nStations][m_nLayers]
virtual StatusCode execute() override
static const int m_nStations
TProfile2D m_lb_yCluster_xDistSiTrackCluster[m_nStations][m_nLayers]
SG::ReadHandleKey< xAOD::AFPSiHitContainer > m_afpHitContainerKey
TProfile m_lb_xDistSiTrackCluster[m_nStations][m_nLayers]
TProfile2D m_lb_xCluster_yDistSiTrackCluster[m_nStations][m_nLayers]
TProfile2D m_lb_sxTrack_yDistSiTrackCluster[m_nStations][m_nLayers]
TProfile2D m_lb_syTrack_xDistSiTrackCluster[m_nStations][m_nLayers]
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
AFP_PixelHistoFiller(const std::string &name, ISvcLocator *pSvcLocator)
TProfile2D m_lb_zCluster_yDistSiTrackCluster[m_nStations][m_nLayers]
TProfile2D m_lb_syTrack_yDistSiTrackCluster[m_nStations][m_nLayers]
TProfile m_lb_yDistSiTrackCluster[m_nStations][m_nLayers]
std::vector< TH2F > m_pixelHits[m_nStations][m_nLayers]
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
int lb
Definition globals.cxx:23
AFPSiHit_v2 AFPSiHit
Definition AFPSiHit.h:12
AFPTrack_v2 AFPTrack
Definition AFPTrack.h:12
static constexpr double SiT_Pixel_amount_y
static constexpr double SiT_Pixel_amount_x