ATLAS Offline Software
Loading...
Searching...
No Matches
InDetBeamSpotVertex.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef INDET_INDETBEAMSPOTVERTEX_H
6#define INDET_INDETBEAMSPOTVERTEX_H
7
9// Author jwalder@cern.ch
10// Concrete implementation of the IInDetBeamSpotTool class
11// for Vertex methods of Beamspot determination.
13
17#include "CLHEP/Matrix/Vector.h"
18#include "CLHEP/Matrix/SymMatrix.h"
19#include "TMinuit.h"
20#include "TMath.h"
21#include "TTree.h"
22#include <atomic>
23#include <string>
24#include <vector>
25#include <map>
26
27namespace InDet {
33 virtual public IInDetBeamSpotTool {
34 public:
35 // Constructor
36 InDetBeamSpotVertex( const std::string& type,
37 const std::string& name,
38 const IInterface* parent);
39 // Standard Destructor
41
42 //Copy Constructor
44
45
46 virtual StatusCode initialize();
47 virtual StatusCode finalize();
48 virtual FitStatus fit(std::vector< BeamSpot::VrtHolder >&);
49 virtual FitID getFitID() const { return (m_getLLres ? vertexLL : vertexChi2 );}
51
52 double getX( double z) const {
53 return (m_getLLres ? m_pLL(1) + m_pLL(3)*z : m_p(1) + m_p(2)*z);}
54 double getY(double z) const {
55 return (m_getLLres ? m_pLL(2) + m_pLL(4)*z : m_p(3) + m_p(4)*z);}
56
57 double getZ() const { return (m_getLLres ? m_pLL(9):m_zSolved);}
58 double getErrX( double z) const {
59 return (m_getLLres ? sqrt(m_VLL(1,1) + 2*z*m_VLL(3,1) + z*z*m_VLL(3,3)):
60 sqrt(m_V(1,1) + 2*z*m_V(2,1) + z*z*m_V(2,2)));
61 }
62 double getErrY( double z) const{
63 return (m_getLLres ? sqrt(m_VLL(2,2) + 2*z*m_VLL(4,2) + z*z*m_VLL(4,4)):
64 sqrt(m_V(3,3) + 2*z*m_V(4,3) + z*z*m_V(4,4)) );
65 }
66 double getErrZ() const {
67 return (m_getLLres ? (m_fixInputK ? sqrt(m_VLL(8,8)) : sqrt(m_VLL(9,9))):m_zErrSolved);} // defined as centroid of beam
68
69 double getSigmaX(double) const {
70 return (m_getLLres ? m_pLL(5) : m_def_sx);}
71 double getSigmaY(double) const {
72 return (m_getLLres ? m_pLL(6) : m_def_sy);}
73 double getSigmaZ() const {
74 return (m_getLLres ? m_pLL(10) : m_def_sz);}
75 double getErrSigmaX(double) const {
76 return (m_getLLres ? sqrt(m_VLL(5,5)) :0.);}
77 double getErrSigmaY(double) const {
78 return (m_getLLres ? sqrt(m_VLL(6,6)) :0.);}
79 double getErrSigmaZ() const {
80 return (m_getLLres ? (m_fixInputK ? sqrt(m_VLL(9,9)) : sqrt(m_VLL(10,10))) :0.);}
81
82 double getTiltX() const {
83 return (m_getLLres ? m_pLL(3) :m_p(2));}
84 double getTiltY() const {
85 return (m_getLLres ? m_pLL(4) :m_p(4));}
86 double getErrTiltX() const {
87 return (m_getLLres ? sqrt(m_VLL(3,3)):sqrt( m_V(2,2)));}
88 double getErrTiltY() const {
89 return (m_getLLres ? sqrt(m_VLL(4,4)):sqrt( m_V(4,4)));}
90
91 //specific for Vertex
92 double getRhoXY() const { return (m_getLLres ? m_pLL(7) : 0.);}
93 double getK() const { return (m_getLLres ? m_pLL(8) : 0.);}
94 double getErrRhoXY() const { return (m_getLLres ? sqrt(m_VLL(7,7)) : 0.);}
95 double getErrK() const { return (m_getLLres ? (m_fixInputK ? 0. : sqrt(m_VLL(8,8)) ) : 0.);}
96
97 double getSigmaXY(double z) const {return getRhoXY()*getSigmaX(z)*getSigmaY(z);}
98
99 double getErrSigmaXY(double z) const {
100 // Error proporagtion multiplied thorughout by sigmaXY to remove denominator -> safer against zeros
101
102 double rhoXY = getRhoXY();
103 double sigmaX = getSigmaX(z);
104 double sigmaY = getSigmaY(z);
105
106 double errRhoXY = getErrRhoXY();
107 double errSigmaX = getErrSigmaX(z);
108 double errSigmaY = getErrSigmaY(z);
109
110 double errSigmaXY = sqrt((errRhoXY*errRhoXY) * (sigmaX*sigmaX) * (sigmaY*sigmaY) +
111 (rhoXY*rhoXY) * (errSigmaX*errSigmaX) * (sigmaY*sigmaY) +
112 (rhoXY*rhoXY) * (sigmaX*sigmaX) * (errSigmaY*errSigmaY));
113 return errSigmaXY;
114 }
115 CLHEP::HepSymMatrix getCov(double z) const; //x(z),y(z),tiltx,tilty
116
117 const CLHEP::HepVector & getLLpos() const { return m_pLL;}
118 const CLHEP::HepSymMatrix & getLLcov() const { return m_VLL;}
119 virtual std::map<std::string,double> getCovMap() const;
120 virtual std::map<std::string,double> getParamMap() const;
121 void clear();
122 private:
123
124 //updated per vertex
125 CLHEP::HepVector m_x;
126 CLHEP::HepSymMatrix m_cov;
127 double m_z, m_zErr;
128
129 //solved matrices
130 CLHEP::HepVector m_p;
131 CLHEP::HepSymMatrix m_V;
133
134 //for LL output
135 const int m_NPARS;
136 CLHEP::HepVector m_pLL;
137 CLHEP::HepSymMatrix m_VLL;
138
140
141 // std::string m_containerName;
142
143 bool m_useLL; // true if using the full log-likelihood method
144 bool m_getLLres; //use LL results, or fallback on Chi2
145 std::vector< BeamSpot::VrtHolder > m_vertexData;
146
147
149 // Initial fit values: set in Job options.
150 // Note, it using Chi2, these may be overriding by the
151 // results of the Chi2 fit.
152
155
158
161
162 int m_minuit_maxIter; // max iterations for Minuit to perform
163
164 double m_def_x0,m_def_y0,m_def_z,m_def_ax,m_def_ay,m_def_sx,m_def_sy,m_def_sz; //default values: controled by jobOptions
165
166 // selections based on chi2-estimated position of beamspot
167 double m_sigTr; // number of sigmas from total beam-spread width
168 double m_maxVtxErTr; // max uncertainty in vertex error in transverse direction
169 double m_widthFail; // sigma value to 'not trust LL fit'.
170 double m_rhoFail; // rho value to 'not trust LL fit'.
171 int m_singleIterationMax; // max allowed vertices to reject in a single iteration (-1 => all)
175
177 bool solveChi2();
178 bool solveLL(bool printOut = false);
179 bool applyOutlierRemoval();
181 int m_maxOutlierLoops; // maximum number of resursive loops in outlier removal to perform
182 //LL setup
183 int setInitialPars( TMinuit * minuit);
184 int setParsFromChi2( TMinuit * minuit);
185
186 bool setOutput( TMinuit * minuit);
187
188 bool successfulFit( TMinuit * ,
189 std::pair<int, std::string> & );
190 void doFit2(TMinuit * , bool printOut = false);
191
192 bool m_doFitSanityCheck; //<! determine that fit is really converged
193 bool m_doChi2OutlierRemoval; //<! for chi2 only fit, run outlier removal as well.
194 double m_kMaxFail, m_kMinFail; // max and min sanity values for k
195 double m_minVtxProb; // probability cut on chi2/ndf
196
197 bool m_fixInputK; // fix in LL fit the K factor to it's initial value
198 bool m_useLLNorm; // use the normalisation mode of the pdf...
200
202
203 mutable std::atomic<int> m_rCount{0}; // counter used for recussive mode
204 };
205}
206#endif
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Abstract class for all beamspot determination algorithms.
FitStatus
Internally used enum for fit status.
FitID
Beamspot determination type.
A concrete implementation of IInDetBeamSpotTool, using primary vertex information to determine the po...
double getErrX(double z) const
double getSigmaY(double) const
double getErrY(double z) const
double getSigmaX(double) const
void doFit2(TMinuit *, bool printOut=false)
virtual StatusCode finalize()
Standard finalize.
double getX(double z) const
bool solveLL(bool printOut=false)
double getSigmaXY(double z) const
int setInitialPars(TMinuit *minuit)
virtual StatusCode initialize()
Standard initialize.
IInDetBeamSpotTool * Clone()
virtual FitStatus fit(std::vector< BeamSpot::VrtHolder > &)
Attempt a to find a solution of the beamspot.
virtual std::map< std::string, double > getParamMap() const
bool successfulFit(TMinuit *, std::pair< int, std::string > &)
double getErrSigmaY(double) const
double getErrSigmaXY(double z) const
virtual FitID getFitID() const
A unique ID for the specific fit type.
const CLHEP::HepSymMatrix & getLLcov() const
double getErrSigmaX(double) const
double getY(double z) const
std::vector< BeamSpot::VrtHolder > m_vertexData
virtual std::map< std::string, double > getCovMap() const
int setParsFromChi2(TMinuit *minuit)
CLHEP::HepSymMatrix getCov(double z) const
InDetBeamSpotVertex(const std::string &type, const std::string &name, const IInterface *parent)
const CLHEP::HepVector & getLLpos() const
Primary Vertex Finder.