ATLAS Offline Software
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 
44 
45  return StatusCode::SUCCESS;
46 }
47 
49 // Finalize
51 
53 {
54  return AlgTool::finalize();
55 }
56 
58 // Initialize tool for new event
60 
61 std::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 
96 std::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 
220 MsgStream& 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 
230 MsgStream& 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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SiZvertexMaker_xk.h
SiSpacePointsSeedMakerEventData.h
Trk::SpacePoint
Definition: Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePoint.h:35
InDet::SiZvertexMaker_xk::m_zmax
DoubleProperty m_zmax
Definition: SiZvertexMaker_xk.h:108
Trk::Vertex
Definition: Tracking/TrkEvent/VxVertex/VxVertex/Vertex.h:26
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
InDet::SiZvertexMaker_xk::dump
virtual MsgStream & dump(MsgStream &out) const override
Definition: SiZvertexMaker_xk.cxx:220
InDet::SiSpacePointsSeedMakerEventData
Definition: SiSpacePointsSeedMakerEventData.h:49
SiSpacePointsSeed.h
NMAX
const int NMAX
Definition: LArPhysWaveHECTool.cxx:22
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
python.atlas_oh.im
im
Definition: atlas_oh.py:167
InDet::SiZvertexMaker_xk::production
std::list< Trk::Vertex > production(const EventContext &ctx, SiSpacePointsSeedMakerEventData &data) const
Definition: SiZvertexMaker_xk.cxx:96
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Pythia8_A14_NNPDF23LO_Var1Down_Common.ver
ver
Definition: Pythia8_A14_NNPDF23LO_Var1Down_Common.py:26
InDet::SiZvertexMaker_xk::dumpConditions
MsgStream & dumpConditions(MsgStream &out) const
Definition: SiZvertexMaker_xk.cxx:230
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
InDet::SiSpacePointsSeed
Definition: SiSpacePointsSeed.h:30
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:169
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::SiZvertexMaker_xk::m_ratio
DoubleProperty m_ratio
Definition: SiZvertexMaker_xk.h:109
InDet::SiZvertexMaker_xk::newEvent
virtual std::list< Trk::Vertex > newEvent(const EventContext &ctx, SiSpacePointsSeedMakerEventData &data) const override
Definition: SiZvertexMaker_xk.cxx:61
InDet::SiZvertexMaker_xk::m_seedsgenerator
ToolHandle< InDet::ISiSpacePointsSeedMaker > m_seedsgenerator
Definition: SiZvertexMaker_xk.h:99
InDet::SiZvertexMaker_xk::initialize
virtual StatusCode initialize() override
Definition: SiZvertexMaker_xk.cxx:37
Vertex.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.PyAthena.v
v
Definition: PyAthena.py:154
InDet::SiZvertexMaker_xk::m_zmin
DoubleProperty m_zmin
Definition: SiZvertexMaker_xk.h:107
DEBUG
#define DEBUG
Definition: page_access.h:11
InDet::SiZvertexMaker_xk::m_nspoint
IntegerProperty m_nspoint
Definition: SiZvertexMaker_xk.h:104
InDet::SiZvertexMaker_xk::finalize
virtual StatusCode finalize() override
Definition: SiZvertexMaker_xk.cxx:52
InDet::SiZvertexMaker_xk::m_mincontent
IntegerProperty m_mincontent
Definition: SiZvertexMaker_xk.h:106
InDet::SiZvertexMaker_xk::newRegion
virtual std::list< Trk::Vertex > newRegion(const EventContext &ctx, SiSpacePointsSeedMakerEventData &data, const std::vector< IdentifierHash > &, const std::vector< IdentifierHash > &) const override
Definition: SiZvertexMaker_xk.cxx:72
InDet::SiZvertexMaker_xk::m_histsize
IntegerProperty m_histsize
Definition: SiZvertexMaker_xk.h:105
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
nmax
const int nmax(200)
InDet::SiZvertexMaker_xk::SiZvertexMaker_xk
SiZvertexMaker_xk(const std::string &, const std::string &, const IInterface *)
Definition: SiZvertexMaker_xk.cxx:28
histogram
std::string histogram
Definition: chains.cxx:52
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129