ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
InDet::InDetBeamSpotRooFit Class Reference

A concrete implementation of IInDetBeamSpotTool, using primary vertex information to determine the position of the beamspot using a chi2 and/or log-likelihood method. More...

#include <InDetBeamSpotRooFit.h>

Inheritance diagram for InDet::InDetBeamSpotRooFit:
Collaboration diagram for InDet::InDetBeamSpotRooFit:

Public Types

enum  FitStatus { unsolved =0, problems, failed, successful }
 Internally used enum for fit status. More...
 
enum  FitID {
  trackChi2 =1, trackChi2Widths =2, vertexLL =3, vertexChi2 =4,
  RooFitLL = 6, unknown = 99
}
 Beamspot determination type. More...
 

Public Member Functions

 InDetBeamSpotRooFit (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~InDetBeamSpotRooFit ()
 
 InDetBeamSpotRooFit (const InDetBeamSpotRooFit &rhs)
 
virtual StatusCode initialize ()
 Standard initialize. More...
 
virtual StatusCode finalize ()
 Standard finalize. More...
 
virtual std::map< std::string, double > getCovMap () const
 
virtual std::map< std::string, double > getParamMap () const
 
virtual FitID getFitID () const
 A unique ID for the specific fit type. More...
 
virtual FitStatus fit (std::vector< BeamSpot::VrtHolder > &)
 Attempt a to find a solution of the beamspot. More...
 
IInDetBeamSpotToolClone ()
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID. More...
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

TMatrixDSym m_cov
 
double m_ax
 
double m_ay
 
double m_k
 
double m_mx
 
double m_my
 
double m_mz
 
double m_rho
 
double m_sx
 
double m_sy
 
double m_sz
 
int m_nUsed
 
std::vector< BeamSpot::VrtHolderm_vertexData
 
long m_vertexCount
 
FitStatus m_fitStatus
 
std::string m_vtxCutString
 
double m_vtxResCut
 
double m_kStart
 
double m_rmsCutNum
 
bool m_kConst
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

A concrete implementation of IInDetBeamSpotTool, using primary vertex information to determine the position of the beamspot using a chi2 and/or log-likelihood method.

Abstract class for all beamspot determination algorithms. Any class for finding the position of the beamspot needs to derive itself from this class.

Definition at line 33 of file InDetBeamSpotRooFit.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ FitID

Beamspot determination type.

Enumerator
trackChi2 
trackChi2Widths 
vertexLL 
vertexChi2 
RooFitLL 
unknown 

Definition at line 51 of file IInDetBeamSpotTool.h.

◆ FitStatus

Internally used enum for fit status.

Useful for quick checks.

Enumerator
unsolved 
problems 
failed 
successful 

Definition at line 49 of file IInDetBeamSpotTool.h.

Constructor & Destructor Documentation

◆ InDetBeamSpotRooFit() [1/2]

InDetBeamSpotRooFit::InDetBeamSpotRooFit ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 16 of file InDetBeamSpotRooFit.cxx.

18  :
20  m_cov(10), m_ax(0),m_ay(0),m_k(0),
21  m_mx(0),m_my(0),m_mz(0),m_rho(0),
22  m_sx(0),m_sy(0),m_sz(0),m_nUsed(0),
23  m_vertexCount(0),
25 {
26  declareInterface<IInDetBeamSpotTool>(this);
27  declareProperty("vtxResCut", m_vtxResCut = 0.05 );//m_vtxCut="abs(vxx) < .0025 && abs(vyy) < .0025 && abs(z) < 300 && abs(x)<3 && abs(y)<3");
28  declareProperty("InitialKFactor", m_kStart=1.0);
29  declareProperty("RMSCut", m_rmsCutNum = 16);
30  declareProperty("ConstantKFactor", m_kConst=false);
31 }

◆ ~InDetBeamSpotRooFit()

virtual InDet::InDetBeamSpotRooFit::~InDetBeamSpotRooFit ( )
inlinevirtual

Definition at line 41 of file InDetBeamSpotRooFit.h.

41 {}

◆ InDetBeamSpotRooFit() [2/2]

InDetBeamSpotRooFit::InDetBeamSpotRooFit ( const InDetBeamSpotRooFit rhs)

Definition at line 34 of file InDetBeamSpotRooFit.cxx.

34  :
35  IInDetBeamSpotTool(rhs),
36  AthAlgTool(rhs.type(), rhs.name(), rhs.parent()),
37  m_cov(10), m_ax(0),m_ay(0),m_k(0),
38  m_mx(0),m_my(0),m_mz(0),m_rho(0),
39  m_sx(0),m_sy(0),m_sz(0),m_nUsed(0),
40  m_vertexCount(0),
43  m_kStart(rhs.m_kStart),
45  m_kConst(rhs.m_kConst)
46 {}

Member Function Documentation

◆ Clone()

IInDetBeamSpotTool* InDet::InDetBeamSpotRooFit::Clone ( )
inlinevirtual

Implements InDet::IInDetBeamSpotTool.

Definition at line 54 of file InDetBeamSpotRooFit.h.

54 { return new InDetBeamSpotRooFit(*this); }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode InDetBeamSpotRooFit::finalize ( )
virtual

Standard finalize.

Will attempt a solution if not already done

Implements InDet::IInDetBeamSpotTool.

Definition at line 53 of file InDetBeamSpotRooFit.cxx.

53  {
54  ATH_MSG_DEBUG( "In finalize");
55  return StatusCode::SUCCESS;
56 }

◆ fit()

InDetBeamSpotRooFit::FitStatus InDetBeamSpotRooFit::fit ( std::vector< BeamSpot::VrtHolder > &  )
virtual

Attempt a to find a solution of the beamspot.

Implements InDet::IInDetBeamSpotTool.

Definition at line 58 of file InDetBeamSpotRooFit.cxx.

58  {
60 
61  //This is to determine the min and max values of the data for setting up the RooDataSet
62  double xMin = m_vertexData[0].x ;
63  double xMax = xMin;
64  double yMin = m_vertexData[0].y ;
65  double yMax = yMin;
66  double zMin = m_vertexData[0].z;
67  double zMax = zMin;
68  double vxxMin=m_vertexData[0].vxx ;
69  double vxxMax=vxxMin;
70  double vyyMin=m_vertexData[0].vyy;
71  double vyyMax=vyyMin;
72  double vxyMin=m_vertexData[0].vxy;
73  double vxyMax=vxyMin;
74 
75  for(Int_t i = 1;i < (Int_t)m_vertexData.size() ; i++){
76  if (m_vertexData[i].x < xMin) xMin = m_vertexData[i].x;
77  if (m_vertexData[i].x > xMax) xMax = m_vertexData[i].x;
78  if (m_vertexData[i].y < yMin) yMin = m_vertexData[i].y;
79  if (m_vertexData[i].y > yMax) yMax = m_vertexData[i].y;
80  if (m_vertexData[i].z < zMin) zMin = m_vertexData[i].z;
81  if (m_vertexData[i].z > zMax) zMax = m_vertexData[i].z;
82  if (m_vertexData[i].vxx < vxxMin) vxxMin = m_vertexData[i].vxx;
83  if (m_vertexData[i].vxx > vxxMax) vxxMax = m_vertexData[i].vxx;
84  if (m_vertexData[i].vyy < vyyMin) vyyMin = m_vertexData[i].vyy;
85  if (m_vertexData[i].vyy > vyyMax) vyyMax = m_vertexData[i].vyy;
86  if (m_vertexData[i].vxy < vxyMin) vxyMin = m_vertexData[i].vxy;
87  if (m_vertexData[i].vxy > vxyMax) vxyMax = m_vertexData[i].vxy;
88  }
89 
90  //Declare the observables
91  RooRealVar x("x","Primary Vertex x [mm]",xMin,xMax);
92  RooRealVar y("y","Primary Vertex y [mm]",yMin,yMax);
93  RooRealVar z("z","Primary Vertex z [mm]",zMin,zMax);
94  RooRealVar vxx("vxx","vxx [mm^2]",vxxMin,vxxMax);
95  RooRealVar vyy("vyy","vyy [mm^2]",vyyMin,vyyMax);
96  RooRealVar vxy("vxy","vyy [mm^2]",vxyMin,vxyMax);
97 
98 
99  m_vtxCutString = "abs(x) < 3 && abs(y) < 3 && abs(z) < 300";
101  + " && abs(vxy) < 1000.";
102  const char *vtxCut = (const char*)m_vtxCutString.c_str();
103 
104  //Declare the RooDataSet and add data to it
105  RooDataSet rfData("rfData","RooFit data",RooArgSet(x,y,z,vxx,vyy,vxy));
106 
107  m_vertexCount = m_vertexData.size();
108 
109  for( unsigned int j = 0; j < m_vertexCount; j++){
110  x.setVal(m_vertexData[j].x);
111  y.setVal(m_vertexData[j].y);
112  z.setVal(m_vertexData[j].z);
113  vxx.setVal(m_vertexData[j].vxx);
114  vyy.setVal(m_vertexData[j].vyy);
115  vxy.setVal(m_vertexData[j].vxy);
116  rfData.add(RooArgSet(x,y,z,vxx,vyy,vxy));
117  }
118 
119  // ROOT assumes the user takes ownership of the reduced dataset
120  // Therefore, wrap it into a unique pointer so that we don't leak it
121  auto reducedDSvtxCut = std::unique_ptr<RooAbsData>(rfData.reduce(Cut(vtxCut)));
122 
123  Double_t vxxMean = reducedDSvtxCut->mean(vxx);
124  Double_t vyyMean = reducedDSvtxCut->mean(vyy);
125  Double_t axStart = 0, ayStart = 0, kStart = m_kStart;
126  Double_t wxxStart = reducedDSvtxCut->sigma(x);
127  Double_t wyyStart = reducedDSvtxCut->sigma(y);
128  Double_t sxStart = sqrt(std::abs(wxxStart*wxxStart - kStart*kStart*vxxMean));
129  Double_t syStart = sqrt(std::abs(wyyStart*wyyStart - kStart*kStart*vyyMean));
130  Double_t szStart = reducedDSvtxCut->sigma(z);
131  Double_t mxStart = reducedDSvtxCut->mean(x);
132  Double_t myStart = reducedDSvtxCut->mean(y);
133  Double_t mzStart = reducedDSvtxCut->mean(z);
134  Double_t rhoStart = 0;
135 
136  RooRealVar ax("ax","Tilt x",axStart,-1,1);
137  RooRealVar ay("ay","Tilt y",ayStart,-1,1);
138  RooRealVar k("k","k factor",kStart,0,3);
139  if (m_kConst){ k.setConstant(kTRUE); }
140  RooRealVar mx("mx","Mean x",mxStart,xMin,xMax);
141  RooRealVar my("my","Mean y",myStart,yMin,yMax);
142  RooRealVar mz("mz","Mean z",mzStart,zMin,zMax);
143  RooRealVar rho("rho","x-y correlation",rhoStart,-1,1);
144  RooRealVar sx("sx","Width x",sxStart,0,1);
145  RooRealVar sy("sy","Width y",syStart,0,1);
146  RooRealVar sz("sz","Width z",szStart,1,200);
147 
148 
149  //Perform the fit and add results to member variables
150 
151  BeamSpotPdf fitModel("fitModel","BeamSpot PDF",x,y,z,vxx,vyy,vxy,mx,sx,ax,my,sy,ay,mz,sz,k,rho);
152 
153  //Apply the specified cut on position and vertex resolution
154  //RooDataSet *reducedData = (RooDataSet*)rfData.reduce( Cut(vtxCut) );
155  //We now need to combine the vtx resolution cut with the rms cut
156  //std::string combinedCutString = combineCuts(rfData);
157  //const char *combinedCut = (const char*)combinedCutString.c_str();
158 
159  double rmsCutXLow = mxStart - m_rmsCutNum * wxxStart;
160  double rmsCutXHigh = mxStart + m_rmsCutNum * wxxStart;
161  double rmsCutYLow = myStart - m_rmsCutNum * wyyStart;
162  double rmsCutYHigh = myStart + m_rmsCutNum * wyyStart;
163  double rmsCutZLow = mzStart - m_rmsCutNum * szStart;
164  double rmsCutZHigh = mzStart + m_rmsCutNum * szStart;
165 
166  std::ostringstream ss;
167  ss << "x > " << rmsCutXLow << " && "
168  << "x < " << rmsCutXHigh << " && "
169  << "y > " << rmsCutYLow << " && "
170  << "y < " << rmsCutYHigh << " && "
171  << "z > " << rmsCutZLow << " && "
172  << "z < " << rmsCutZHigh;
173  std::string rmsCutString = ss.str();
174 
175  std::string combinedCutString = m_vtxCutString + std::string(" && ") + rmsCutString;
176  const char *combinedCut = (const char*)combinedCutString.c_str();
177 
178  ATH_MSG_INFO( "combinedCut = "<<combinedCut );
179 
180 
181  //Convert these numbers to strings, then concatenate the strings
182  //rmsCutX = x > rmsCutLow && x < rmsCutXHigh;
183  //repeat for y and z
184 
185 
186  // ROOT assumes the user takes ownership of the reduced dataset
187  // Therefore, wrap it into a unique pointer so that we don't leak it
188  auto reducedDScombinedCut = std::unique_ptr<RooAbsData>(rfData.reduce(Cut(combinedCut)));
189 
190  RooFitResult *r = fitModel.fitTo( *(reducedDScombinedCut.get()) ,ConditionalObservables(RooArgSet(vxx,vyy,vxy)),Save(),PrintLevel(-1),PrintEvalErrors(-1));
191 
192  r->Print();
193  m_nUsed = reducedDScombinedCut->numEntries();
194 
195  ATH_MSG_INFO( "A total of " << m_vertexCount << " vertices passed pre-selection. Of which "
196  << reducedDScombinedCut->numEntries()<<" vertices will be used in the ML fit.") ;
197 
198 
199  if ( r->edm() <= 10e-04 && r->covQual() == 3){
201  }
202  else m_fitStatus = failed;
203  m_ax = ax.getVal();
204  m_ay = ay.getVal();
205  m_k = k.getVal();
206  m_mx = mx.getVal();
207  m_my = my.getVal();
208  m_mz = mz.getVal();
209  m_rho = rho.getVal();
210  m_sx = sx.getVal();
211  m_sy = sy.getVal();
212  m_sz = sz.getVal();
213 
214  if( m_kConst ){
215  m_cov.ResizeTo(9,9);
216  }
217  m_cov = r->covarianceMatrix();
218 
219  return ( m_fitStatus );
220 }

◆ getCovMap()

std::map< std::string, double > InDetBeamSpotRooFit::getCovMap ( ) const
virtual

Implements InDet::IInDetBeamSpotTool.

Definition at line 223 of file InDetBeamSpotRooFit.cxx.

223  {
224  int numParams=0;
225  if (m_kConst){
226  numParams = 9;
227  }
228  else{
229  numParams = 10;
230  }
231 
232  const std::string offDiagArr[] = {"TiltX","TiltY","k","X","Y","Z","RhoXY","Sx","Sy","Sz"};
233  const std::string diagArr[] = {"tiltX","tiltY","k","posX","posY","posZ","rhoXY","sigmaX","sigmaY","sigmaZ"};
234 
235  const std::string offDiagArrConstK[] = {"TiltX","TiltY","X","Y","Z","RhoXY","Sx","Sy","Sz"};
236  const std::string diagArrConstK[] = {"tiltX","tiltY","posX","posY","posZ","rhoXY","sigmaX","sigmaY","sigmaZ"};
237 
238  std::map< std::string, double > covMap;
239  std::vector< std::string > offDiagVector;
240  std::vector< std::string > diagVector;
241  std::string covString = "cov";
242  std::string errString = "Err";
243 
244  std::string key;
245 
246  for(int i = 0; i < numParams; i++){
247  if(m_kConst){
248  offDiagVector.push_back(offDiagArrConstK[i]);
249  diagVector.push_back(diagArrConstK[i]);
250  }
251  else{
252  offDiagVector.push_back(offDiagArr[i]);
253  diagVector.push_back(diagArr[i]);
254  }
255  }
256 
257  for( unsigned int i = 0; i < offDiagVector.size(); i++){
258  for( unsigned int j = 0; j <= i; j++){
259  if( i == j ){
260  key = diagVector[i] + errString;
261  covMap[key] = sqrt(m_cov[i][j]);
262  }
263  else {
264  key = covString + offDiagVector[i] + offDiagVector[j];
265  covMap[key] = m_cov[i][j];
266  key = covString + offDiagVector[j] + offDiagVector[i];
267  covMap[key] = m_cov[i][j];
268  }
269 
270  }
271  }
272 
273  if( m_kConst ){
274  covMap["kErr"] = 0;
275  }
276 
277  //We've filled the entire covariance matrix, but we only want to keep the top half, in the order:
278  //x,y,z,ax,ay,sx,sy,sz,rho,k
279  const std::string offDiagRemoveArr[] = {"k","RhoXY","Sz","Sy","Sx","TiltY","TiltX","Z","Y","X"};
280  const std::string offDiagRemoveArrConstK[] = {"RhoXY","Sz","Sy","Sx","TiltY","TiltX","Z","Y","X"};
281  std::vector< std::string > offDiagRemoveVector;
282  for (int i = 0; i < numParams; i++){
283  if( m_kConst ){
284  offDiagRemoveVector.push_back(offDiagRemoveArrConstK[i]);
285  }
286  else{
287  offDiagRemoveVector.push_back(offDiagRemoveArr[i]);
288  }
289  }
290  for( unsigned int i = 0; i < offDiagRemoveVector.size(); i++){
291  for( unsigned int j = i+1; j < offDiagRemoveVector.size(); j++){
292  covMap.erase(covString+offDiagRemoveVector[i]+offDiagRemoveVector[j]);
293  }
294  }
295 
296  return covMap;
297 }

◆ getFitID()

virtual FitID InDet::InDetBeamSpotRooFit::getFitID ( ) const
inlinevirtual

A unique ID for the specific fit type.

Implements InDet::IInDetBeamSpotTool.

Definition at line 52 of file InDetBeamSpotRooFit.h.

52 { return RooFitLL; }

◆ getParamMap()

std::map< std::string, double > InDetBeamSpotRooFit::getParamMap ( ) const
virtual

Implements InDet::IInDetBeamSpotTool.

Definition at line 299 of file InDetBeamSpotRooFit.cxx.

299  {
300 
301  std::map<std::string,double> paramMap;
302  paramMap["tiltX"] = m_ax;
303  paramMap["tiltY"] = m_ay;
304  paramMap["k"] = m_k;
305  paramMap["posX"] = m_mx;
306  paramMap["posY"] = m_my;
307  paramMap["posZ"] = m_mz;
308  paramMap["sigmaX"] = m_sx;
309  paramMap["sigmaY"] = m_sy;
310  paramMap["sigmaZ"] = m_sz;
311  paramMap["rhoXY"] = m_rho;
312  paramMap["nUsed"] = m_nUsed;
313 
314  return paramMap;
315 }

◆ initialize()

StatusCode InDetBeamSpotRooFit::initialize ( )
virtual

Standard initialize.

Implements InDet::IInDetBeamSpotTool.

Definition at line 48 of file InDetBeamSpotRooFit.cxx.

48  {
49  ATH_MSG_DEBUG( "In initialize" );
50  return StatusCode::SUCCESS;
51 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

static const InterfaceID& InDet::IInDetBeamSpotTool::interfaceID ( )
inlinestaticinherited

Retrieve interface ID.

Definition at line 53 of file IInDetBeamSpotTool.h.

53 { return IID_IInDetBeamSpotTool; }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_ax

double InDet::InDetBeamSpotRooFit::m_ax
private

Definition at line 61 of file InDetBeamSpotRooFit.h.

◆ m_ay

double InDet::InDetBeamSpotRooFit::m_ay
private

Definition at line 62 of file InDetBeamSpotRooFit.h.

◆ m_cov

TMatrixDSym InDet::InDetBeamSpotRooFit::m_cov
private

Definition at line 59 of file InDetBeamSpotRooFit.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_fitStatus

FitStatus InDet::InDetBeamSpotRooFit::m_fitStatus
private

Definition at line 74 of file InDetBeamSpotRooFit.h.

◆ m_k

double InDet::InDetBeamSpotRooFit::m_k
private

Definition at line 63 of file InDetBeamSpotRooFit.h.

◆ m_kConst

bool InDet::InDetBeamSpotRooFit::m_kConst
private

Definition at line 79 of file InDetBeamSpotRooFit.h.

◆ m_kStart

double InDet::InDetBeamSpotRooFit::m_kStart
private

Definition at line 77 of file InDetBeamSpotRooFit.h.

◆ m_mx

double InDet::InDetBeamSpotRooFit::m_mx
private

Definition at line 64 of file InDetBeamSpotRooFit.h.

◆ m_my

double InDet::InDetBeamSpotRooFit::m_my
private

Definition at line 65 of file InDetBeamSpotRooFit.h.

◆ m_mz

double InDet::InDetBeamSpotRooFit::m_mz
private

Definition at line 66 of file InDetBeamSpotRooFit.h.

◆ m_nUsed

int InDet::InDetBeamSpotRooFit::m_nUsed
private

Definition at line 71 of file InDetBeamSpotRooFit.h.

◆ m_rho

double InDet::InDetBeamSpotRooFit::m_rho
private

Definition at line 67 of file InDetBeamSpotRooFit.h.

◆ m_rmsCutNum

double InDet::InDetBeamSpotRooFit::m_rmsCutNum
private

Definition at line 78 of file InDetBeamSpotRooFit.h.

◆ m_sx

double InDet::InDetBeamSpotRooFit::m_sx
private

Definition at line 68 of file InDetBeamSpotRooFit.h.

◆ m_sy

double InDet::InDetBeamSpotRooFit::m_sy
private

Definition at line 69 of file InDetBeamSpotRooFit.h.

◆ m_sz

double InDet::InDetBeamSpotRooFit::m_sz
private

Definition at line 70 of file InDetBeamSpotRooFit.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vertexCount

long InDet::InDetBeamSpotRooFit::m_vertexCount
private

Definition at line 73 of file InDetBeamSpotRooFit.h.

◆ m_vertexData

std::vector< BeamSpot::VrtHolder > InDet::InDetBeamSpotRooFit::m_vertexData
private

Definition at line 72 of file InDetBeamSpotRooFit.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_vtxCutString

std::string InDet::InDetBeamSpotRooFit::m_vtxCutString
private

Definition at line 75 of file InDetBeamSpotRooFit.h.

◆ m_vtxResCut

double InDet::InDetBeamSpotRooFit::m_vtxResCut
private

Definition at line 76 of file InDetBeamSpotRooFit.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
InDet::InDetBeamSpotRooFit::m_vertexCount
long m_vertexCount
Definition: InDetBeamSpotRooFit.h:73
fitman.sy
sy
Definition: fitman.py:524
fitman.sz
sz
Definition: fitman.py:527
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
BeamSpotPdf
Definition: InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotPdf.h:21
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
fitman.ax
ax
Definition: fitman.py:522
fitman.my
my
Definition: fitman.py:523
InDet::InDetBeamSpotRooFit::m_vertexData
std::vector< BeamSpot::VrtHolder > m_vertexData
Definition: InDetBeamSpotRooFit.h:72
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
InDet::InDetBeamSpotRooFit::m_kConst
bool m_kConst
Definition: InDetBeamSpotRooFit.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
InDet::InDetBeamSpotRooFit::m_k
double m_k
Definition: InDetBeamSpotRooFit.h:63
python.compressB64.sx
string sx
Definition: compressB64.py:96
InDet::InDetBeamSpotRooFit::m_vtxResCut
double m_vtxResCut
Definition: InDetBeamSpotRooFit.h:76
InDet::InDetBeamSpotRooFit::m_ay
double m_ay
Definition: InDetBeamSpotRooFit.h:62
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
fitman.mx
mx
Definition: fitman.py:520
InDet::InDetBeamSpotRooFit::m_ax
double m_ax
Definition: InDetBeamSpotRooFit.h:61
InDet::IInDetBeamSpotTool::vertexLL
@ vertexLL
Definition: IInDetBeamSpotTool.h:51
InDet::InDetBeamSpotRooFit::m_vtxCutString
std::string m_vtxCutString
Definition: InDetBeamSpotRooFit.h:75
InDet::InDetBeamSpotRooFit::m_nUsed
int m_nUsed
Definition: InDetBeamSpotRooFit.h:71
InDet::IInDetBeamSpotTool::vertexChi2
@ vertexChi2
Definition: IInDetBeamSpotTool.h:51
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
fitman.vxy
vxy
Definition: fitman.py:506
Cut
Definition: SUSYToolsAlg.cxx:62
InDet::IInDetBeamSpotTool::RooFitLL
@ RooFitLL
Definition: IInDetBeamSpotTool.h:51
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
InDet::IInDetBeamSpotTool::successful
@ successful
Definition: IInDetBeamSpotTool.h:49
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::IInDetBeamSpotTool::problems
@ problems
Definition: IInDetBeamSpotTool.h:49
fitman.mz
mz
Definition: fitman.py:526
test_pyathena.parent
parent
Definition: test_pyathena.py:15
InDet::InDetBeamSpotRooFit::m_sz
double m_sz
Definition: InDetBeamSpotRooFit.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
InDet::IInDetBeamSpotTool::unsolved
@ unsolved
Definition: IInDetBeamSpotTool.h:49
InDet::IInDetBeamSpotTool::failed
@ failed
Definition: IInDetBeamSpotTool.h:49
InDet::InDetBeamSpotRooFit::m_rmsCutNum
double m_rmsCutNum
Definition: InDetBeamSpotRooFit.h:78
InDet::IInDetBeamSpotTool::trackChi2
@ trackChi2
Definition: IInDetBeamSpotTool.h:51
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
InDet::IInDetBeamSpotTool::unknown
@ unknown
Definition: IInDetBeamSpotTool.h:51
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
InDet::InDetBeamSpotRooFit::m_sy
double m_sy
Definition: InDetBeamSpotRooFit.h:69
InDet::InDetBeamSpotRooFit::m_mx
double m_mx
Definition: InDetBeamSpotRooFit.h:64
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
InDet::InDetBeamSpotRooFit::m_rho
double m_rho
Definition: InDetBeamSpotRooFit.h:67
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
InDet::InDetBeamSpotRooFit::m_sx
double m_sx
Definition: InDetBeamSpotRooFit.h:68
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDet::InDetBeamSpotRooFit::m_fitStatus
FitStatus m_fitStatus
Definition: InDetBeamSpotRooFit.h:74
InDet::InDetBeamSpotRooFit::InDetBeamSpotRooFit
InDetBeamSpotRooFit(const std::string &type, const std::string &name, const IInterface *parent)
Definition: InDetBeamSpotRooFit.cxx:16
InDet::InDetBeamSpotRooFit::m_kStart
double m_kStart
Definition: InDetBeamSpotRooFit.h:77
InDet::InDetBeamSpotRooFit::m_my
double m_my
Definition: InDetBeamSpotRooFit.h:65
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
fitman.vtxData
vtxData
Definition: fitman.py:512
y
#define y
h
fitman.vxx
vxx
Definition: fitman.py:504
InDet::InDetBeamSpotRooFit::m_cov
TMatrixDSym m_cov
Definition: InDetBeamSpotRooFit.h:59
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
fitman.vyy
vyy
Definition: fitman.py:505
InDet::IInDetBeamSpotTool
Definition: IInDetBeamSpotTool.h:45
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
InDet::InDetBeamSpotRooFit::m_mz
double m_mz
Definition: InDetBeamSpotRooFit.h:66
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
InDet::IInDetBeamSpotTool::trackChi2Widths
@ trackChi2Widths
Definition: IInDetBeamSpotTool.h:51
fitman.rho
rho
Definition: fitman.py:532
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
fitman.ay
ay
Definition: fitman.py:525