ATLAS Offline Software
Loading...
Searching...
No Matches
SiZvertexMaker_xk.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Source file for interface SiZvertexMaker_xk
8// (c) ATLAS Detector software
10// Version 1.0 30/10/2004 I.Gavrilenko
12
14
17#include "VxVertex/Vertex.h"
18
19#include <iomanip>
20#include <map>
21#include <ostream>
22
24// Constructor
26
28(const std::string& t,const std::string& n,const IInterface* p)
29 : base_class(t, n, p)
30{
31}
32
34// Initialisation
36
38{
39 // Get tool for seed generator
40 //
41 ATH_CHECK(m_seedsgenerator.retrieve());
42
43 dump(msg(MSG::DEBUG));
44
45 return StatusCode::SUCCESS;
46}
47
49// Finalize
51
53{
54 return AlgTool::finalize();
55}
56
58// Initialize tool for new event
60
61std::list<Trk::Vertex> InDet::SiZvertexMaker_xk::newEvent(const EventContext& ctx, SiSpacePointsSeedMakerEventData& data) const
62{
63 m_seedsgenerator->newEvent(ctx, data);
64 return production(ctx, data);
65}
66
68// Initialize tool for new region
70
72(const EventContext& ctx, SiSpacePointsSeedMakerEventData& data,
73 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT) const
74{
75 m_seedsgenerator->newRegion(ctx, data, vPixel, vSCT);
76 return production(ctx, data);
77}
78
80// Initialize tool for new region with ROI parameters (PhRt)
82
84(const EventContext& ctx, SiSpacePointsSeedMakerEventData& data,
85 const std::vector<IdentifierHash>& vPixel, const std::vector<IdentifierHash>& vSCT,
86 const IRoiDescriptor& PhEt) const
87{
88 m_seedsgenerator->newRegion(ctx, data, vPixel, vSCT, PhEt);
89 return production(ctx, data);
90}
91
93// Get list vertices Z-coordinates
95
96std::list<Trk::Vertex> InDet::SiZvertexMaker_xk::production(const EventContext& ctx,
98{
99 std::list<Trk::Vertex> vertices;
100
101 std::vector<int> histogram(m_histsize+1, 0);
102 std::vector<double> z_histogram(m_histsize+1, 0.);
103
104 double sZ = static_cast<double>(m_histsize)/(m_zmax-m_zmin);
105
106 std::list<int> NMAX;
107 std::list<double> ZMAX;
108 const Trk::SpacePoint* p0 = nullptr;
109
110 std::list<Trk::Vertex> lv;
111
112 if (m_nspoint==2) m_seedsgenerator->find2Sp(data, lv);
113 else if (m_nspoint==3) m_seedsgenerator->find3Sp(ctx, data, lv);
114 else m_seedsgenerator->findVSp(ctx, data, lv);
115
116 const InDet::SiSpacePointsSeed* seed = nullptr;
117 std::multimap<int,double> ver;
118
119 int nmax = 0 ;
120 int Hmax = 0 ;
121 double zmax = 0.;
122
123 while ((seed = m_seedsgenerator->next(ctx, data))) {
124
125 std::vector<const Trk::SpacePoint*>::const_iterator
126 s = seed->spacePoints().begin();
127 ++s;
128 if ((*s)!=p0) {
129 if (Hmax!=0) {
130 NMAX.push_back(nmax);
131 ZMAX.push_back(zmax);
132 }
133 Hmax = nmax = 0;
134 p0=(*s);
135 }
136 int n = static_cast<int>((seed->zVertex()-m_zmin)*sZ);
137 if (n>=0 && n<=m_histsize) {
138 if (++histogram[n]>Hmax) {
139 Hmax = histogram[n];
140 nmax = n;
141 zmax = seed->zVertex();
142 }
143 }
144 }
145
146 // Clear histogram
147 //
148 for (int i=0; i<=m_histsize; ++i) histogram[i] = 0;
149
150 // Fill histogram again using NMAX information
151 //
152 std::list<int> ::iterator m, me = NMAX.end();
153 std::list<double>::iterator z = ZMAX.begin();
154 for (m=NMAX.begin(); m!=me; ++m) {
155 ++histogram[(*m)];
156 z_histogram[(*m)] += (*z++);
157 }
158
159 // Max. content seach and output bank Z coordinates of vertices production
160 //
161 int HiZm = 0;
162 int im = 0;
163 int i = 1;
164 while (true) {
165
166 if (histogram[i]>=histogram[i-1] && histogram[i]>=histogram[i+1]) {
167 int H3 = histogram[i-1]+histogram[i]+histogram[i+1];
168 if (H3>HiZm) {
169 HiZm=H3;
170 im=i;
171 }
172 if (++i==m_histsize) break;
173 }
174 if (++i==m_histsize) break;
175 }
176
177 if (im==0 || HiZm < m_mincontent) {
178
179 return vertices;
180 }
181 double zv = (z_histogram[im]+z_histogram[im-1]+z_histogram[im+1])/static_cast<double>(HiZm);
182 ver.insert(std::make_pair(-HiZm, zv));
183
184 // Z-vertex coordinates
185 //
186 HiZm = static_cast<int>(m_ratio*static_cast<double>(HiZm));
187 if (HiZm<m_mincontent) HiZm = m_mincontent;
188 i = 1;
189 while (true) {
190 if (histogram[i]>=histogram[i-1] && histogram[i]>=histogram[i+1] && i!=im) {
191 int H3 = histogram[i-1]+histogram[i]+histogram[i+1];
192 if (H3>=HiZm) {
193 zv = (z_histogram[i]+z_histogram[i-1]+z_histogram[i+1])/static_cast<double>(H3);
194 ver.insert(std::make_pair(-H3, zv));
195 }
196 if (++i==m_histsize) break;
197 }
198 if (++i==m_histsize) break;
199 }
200
201 if (!ver.empty()) {
202 std::multimap<int, double>::iterator v = ver.begin(), ve = ver.end();
203 for (; v!=ve; ++v) {
204 Amg::Vector3D Vp(0., 0., (*v).second);
205 Trk::Vertex Ver(Vp);
206 vertices.push_back(Ver);
207 }
208 }
209
210 dump(msg(MSG::DEBUG));
211
212 return vertices;
213}
214
215
217// Dumps relevant information into the MsgStream
219
220MsgStream& InDet::SiZvertexMaker_xk::dump(MsgStream& out) const
221{
222 out << std::endl;
223 return dumpConditions(out);
224}
225
227// Dumps conditions information into the MsgStream
229
230MsgStream& InDet::SiZvertexMaker_xk::dumpConditions(MsgStream& out) const
231{
232 int n = 62-m_seedsgenerator.type().size();
233 std::string s1;
234 for (int i=0; i<n; ++i) s1.append(" ");
235 s1.append("|");
236
237 out<<"|----------------------------------------------------------------------"
238 <<"-------------------|"
239 <<std::endl;
240 out<<"| SP seeds maker tool | "
241 <<m_seedsgenerator.type()<<s1<<std::endl;
242 out<<"| Histogram size | "
243 <<std::setw(12)<<m_histsize
244 <<" |"<<std::endl;
245 out<<"| SP seed length (2 or 3) | "
246 <<std::setw(12)<<m_nspoint
247 <<" |"<<std::endl;
248 out<<"| min content of hist.bin | "
249 <<std::setw(12)<<m_mincontent
250 <<" |"<<std::endl;
251 out<<"| min vertex Z-coordinate | "
252 <<std::setw(12)<<std::setprecision(4)<<m_zmin
253 <<" |"<<std::endl;
254 out<<"| max vertex Z-coordinate | "
255 <<std::setw(12)<<std::setprecision(4)<<m_zmax
256 <<" |"<<std::endl;
257 out<<"| min. ratio to max bin | "
258 <<std::setw(12)<<std::setprecision(4)<<m_ratio
259 <<" |"<<std::endl;
260 out<<"|----------------------------------------------------------------------"
261 <<"-------------------|"
262 <<std::endl;
263
264 return out;
265}
#define ATH_CHECK
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const int NMAX
const int nmax(200)
#define z
std::string histogram
Definition chains.cxx:52
Describes the API of the Region of Ineterest geometry.
InDet::SiSpacePointsSeedMakerEventData holds event dependent data used by ISiSpacePointsSeedMaker.
virtual std::list< Trk::Vertex > newEvent(const EventContext &ctx, SiSpacePointsSeedMakerEventData &data) const override
MsgStream & dumpConditions(MsgStream &out) const
virtual StatusCode finalize() override
virtual StatusCode initialize() override
std::list< Trk::Vertex > production(const EventContext &ctx, SiSpacePointsSeedMakerEventData &data) const
virtual std::list< Trk::Vertex > newRegion(const EventContext &ctx, SiSpacePointsSeedMakerEventData &data, const std::vector< IdentifierHash > &, const std::vector< IdentifierHash > &) const override
ToolHandle< InDet::ISiSpacePointsSeedMaker > m_seedsgenerator
SiZvertexMaker_xk(const std::string &, const std::string &, const IInterface *)
virtual MsgStream & dump(MsgStream &out) const override
This class is a simplest representation of a vertex candidate.
Eigen::Matrix< double, 3, 1 > Vector3D
-event-from-file
MsgStream & msg
Definition testRead.cxx:32