ATLAS Offline Software
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
TrigL2MuonSA::TgcFit Class Reference

#include <TgcFit.h>

Inheritance diagram for TrigL2MuonSA::TgcFit:
Collaboration diagram for TrigL2MuonSA::TgcFit:

Classes

struct  LinStats
 
struct  Point
 
struct  SimpleStats
 A structure to hold simple statisitcs. More...
 

Public Types

enum  Status { FIT_NONE, FIT_POINT, FIT_LINE }
 
typedef std::vector< PointPointArray
 

Public Member Functions

 TgcFit (const std::string &type, const std::string &name, const IInterface *parent)
 
void setFitParameters (double CHI2_TEST, unsigned MIN_WIRE_POINTS, unsigned MIN_STRIP_POINTS)
 
const LinStatsgetStripLinStats () const
 
const LinStatsgetWireLinStats () const
 
void linReg (PointArray &points, LinStats &stats) const
 
void SimpleStatistics (PointArray &points, SimpleStats &stats) const
 
Status runTgcMiddle (PointArray &stripPoints, PointArray &wirePoints, TgcFitResult &fitResult) const
 
Status runTgcInner (PointArray &stripPoints, PointArray &wirePoints, TgcFitResult &fitResult) const
 
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
 

Protected Member Functions

size_t countUniqueStations (const TrigL2MuonSA::TgcFit::PointArray &) const
 
void printDebug (const std::string &str) const
 
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...
 

Protected Attributes

PointArray m_superPoints
 List of wire (eta) super-points. More...
 
double m_CHI2_TEST { 10.0 }
 
unsigned m_MIN_WIRE_POINTS { 4 }
 Test for outliers: w * (value - mean)^2 > CHI2_TEST. More...
 
unsigned m_MIN_STRIP_POINTS { 3 }
 Minimum number of strip points for linear fit. 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

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

Definition at line 21 of file TgcFit.h.

Member Typedef Documentation

◆ PointArray

Definition at line 86 of file TgcFit.h.

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ Status

Enumerator
FIT_NONE 
FIT_POINT 
FIT_LINE 

Definition at line 24 of file TgcFit.h.

25  {
26  FIT_NONE,
27  FIT_POINT,
28  FIT_LINE
29  };

Constructor & Destructor Documentation

◆ TgcFit()

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

Definition at line 20 of file TgcFit.cxx.

22  :
24 {
25 }

Member Function Documentation

◆ countUniqueStations()

size_t TrigL2MuonSA::TgcFit::countUniqueStations ( const TrigL2MuonSA::TgcFit::PointArray array) const
protected

Definition at line 188 of file TgcFit.cxx.

188  {
189  std::vector<int> Stations;
190  Stations.reserve(array.size());
191  for (const TrigL2MuonSA::TgcFit::Point& wirePt : array)
192  {
193  Stations.push_back(wirePt.nStation);
194  }
195  std::sort(Stations.begin(), Stations.end());
196  Stations.erase( std::unique( Stations.begin(), Stations.end() ), Stations.end() );
197  return Stations.size();
198 }

◆ 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

◆ getStripLinStats()

const LinStats& TrigL2MuonSA::TgcFit::getStripLinStats ( ) const

◆ getWireLinStats()

const LinStats& TrigL2MuonSA::TgcFit::getWireLinStats ( ) const

◆ 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.

◆ linReg()

void TrigL2MuonSA::TgcFit::linReg ( PointArray points,
LinStats stats 
) const

Definition at line 114 of file TgcFit.cxx.

115 {
116  double *x = new double[points.size()];
117  double *y = new double[points.size()];
118  double *w = new double[points.size()];
119  for (;;)
120  {
121  stats.clear();
122  for (const TrigL2MuonSA::TgcFit::Point& Pt : points)
123  {
124  if (!Pt.bOutlier)
125  {
126  x[stats.n] = Pt.fX;
127  y[stats.n] = Pt.fY;
128  w[stats.n] = Pt.fW;
129  stats.n++;
130  }
131  }
132  if (stats.n < 2)
133  break;
134 
135  // suppress thread-checker warning about unchecked code (gsl is thread-safe)
136  int status [[maybe_unused]] ATLAS_THREAD_SAFE = gsl_fit_wlinear(x, 1,
137  w, 1,
138  y, 1,
139  stats.n,
140  &stats.fIntercept, &stats.fSlope,
141  &stats.fCov00, &stats.fCov01, &stats.fCov11,
142  &stats.fChi2);
143  ATH_MSG_DEBUG("Y=" << stats.fIntercept << "+X*" << stats.fSlope
144  << ", N=" << stats.n << ", Chi2=" << stats.fChi2);
145 
146  double fMaxChi2 = 0.0;
147  int iPtMax = -1;
148  for (unsigned iPt = 0; iPt < points.size(); iPt++)
149  {
150  if (!points[iPt].bOutlier)
151  {
152  double fDiff = points[iPt].fY - stats.eval(points[iPt].fX);
153  points[iPt].fChi2 = points[iPt].fW * fDiff * fDiff;
154  if (fMaxChi2 < points[iPt].fChi2)
155  {
156  fMaxChi2 = points[iPt].fChi2;
157  iPtMax = iPt;
158  }
159  }
160  }
161  if (iPtMax == -1 || fMaxChi2 < m_CHI2_TEST || stats.n <= 2)
162  break;
163  points[iPtMax].bOutlier = true;
164  }
165 
166  delete [] x;
167  delete [] y;
168  delete [] w;
169 
170  // Print results
171  for (const TrigL2MuonSA::TgcFit::Point& Pt : points)
172  {
173  if (!Pt.bOutlier)
174  {
175  ATH_MSG_DEBUG("Idx=" << Pt.nIdx
176  << ", x=" << Pt.fX
177  << ", y=" << Pt.fY
178  << ", w=" << Pt.fW
179  << ", Y=" << stats.eval(Pt.fX)
180  << ", chi2=" << Pt.fChi2);
181  }
182  }
183 }

◆ 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.

◆ printDebug()

void TrigL2MuonSA::TgcFit::printDebug ( const std::string &  str) const
inlineprotected

Definition at line 199 of file TgcFit.h.

199 { ATH_MSG_DEBUG(str); };

◆ 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  }

◆ runTgcInner()

TrigL2MuonSA::TgcFit::Status TrigL2MuonSA::TgcFit::runTgcInner ( PointArray stripPoints,
PointArray wirePoints,
TrigL2MuonSA::TgcFitResult tgcFitResult 
) const

Definition at line 318 of file TgcFit.cxx.

321 {
323  SimpleStats stripStats;
324  SimpleStats wireStats;
325 
326  tgcFitResult.tgcInnRhoNin = wirePoints.size();
327  tgcFitResult.tgcInnPhiNin = stripPoints.size();
328 
329  ATH_MSG_DEBUG("runTgcInner: stripPoints.size()=" << stripPoints.size()
330  << ", wirePoints.size()=" << wirePoints.size());
331 
332  if (stripPoints.size() > 1 && wirePoints.size() > 1)
333  {
334  status = FIT_POINT;
335  printDebug("runTgcInner: Wires fit point");
336  SimpleStatistics(wirePoints, wireStats);
337 
338  printDebug("runTgcInner: Strips fit point");
339  SimpleStatistics(stripPoints, stripStats);
340 
341  Amg::Vector3D p(wireStats.fMean, 0.0, wirePoints[0].fX);
342  double phi = stripStats.fMean;
343  if( phi > M_PI ) phi -= M_PI*2;
344  if( phi < -M_PI ) phi += M_PI*2;
345  Amg::setPhi(p, phi);
346 
347  ATH_MSG_DEBUG("runTgcInner: Point eta=" << p.eta()
348  << ",phi=" << p.phi() << ",perp=" << p.perp() << ",z=" << p.z());
349 
350  tgcFitResult.tgcInn[0] = p.eta();
351  tgcFitResult.tgcInn[1] = p.phi();
352  tgcFitResult.tgcInn[2] = p.perp();
353  tgcFitResult.tgcInn[3] = p.z();
354  tgcFitResult.tgcInnRhoStd = wireStats.fStd;
355  tgcFitResult.tgcInnRhoN = wireStats.n;
356  tgcFitResult.tgcInnPhiStd = stripStats.fStd;
357  tgcFitResult.tgcInnPhiN = stripStats.n;
358  }
359  return status;
360 }

◆ runTgcMiddle()

TrigL2MuonSA::TgcFit::Status TrigL2MuonSA::TgcFit::runTgcMiddle ( PointArray stripPoints,
PointArray wirePoints,
TrigL2MuonSA::TgcFitResult tgcFitResult 
) const

Definition at line 200 of file TgcFit.cxx.

203 {
204  ATH_MSG_DEBUG("TrigL2MuonSA::TgcFit::runTgcMiddle stripPoints=" << stripPoints.size()
205  << " wirePoints=" << wirePoints.size());
206 
207  tgcFitResult.tgcMidRhoNin = wirePoints.size();
208  tgcFitResult.tgcMidPhiNin = stripPoints.size();
209 
210  if (stripPoints.empty() || wirePoints.empty())
211  return FIT_NONE;
212 
214  LinStats stripStats;
215  LinStats wireStats;
216  const int wireStationsCount = countUniqueStations(wirePoints);
217  const int stripStationsCount = countUniqueStations(stripPoints);
218 
219 
220  if (wireStationsCount == 1 || wirePoints.size() < m_MIN_WIRE_POINTS)
221  {
222  status = FIT_POINT;
223  printDebug("runTgcMiddle: Wires fit point");
224  SimpleStats stats;
225  SimpleStatistics(wirePoints, stats);
226  wireStats.fIntercept = stats.fMean;
227  wireStats.n = stats.n;
228  wireStats.fChi2 = stats.fChi2;
229 
230  printDebug("runTgcMiddle: Strips fit point");
231  SimpleStatistics(stripPoints, stats);
232  stripStats.fIntercept = stats.fMean;
233  stripStats.n = stats.n;
234  stripStats.fChi2 = stats.fChi2;
235  }
236  else
237  {
238  status = FIT_LINE;
239  printDebug("runTgcMiddle: Wires fit line");
240  linReg(wirePoints, wireStats);
241  if (stripStationsCount == 1 || stripPoints.size() < m_MIN_STRIP_POINTS)
242  {
243  printDebug("runTgcMiddle: Strips fit point");
244  SimpleStats stats;
245  SimpleStatistics(stripPoints, stats);
246  stripStats.fIntercept = stats.fMean;
247  stripStats.n = stats.n;
248  stripStats.fChi2 = stats.fChi2;
249  }
250  else
251  {
252  printDebug("runTgcMiddle: Strips fit line");
253  linReg(stripPoints, stripStats);
254  }
255  }
256 
257  tgcFitResult.intercept = wireStats.fIntercept;
258  tgcFitResult.slope = wireStats.fSlope;
259 
260  // Create low and high points
261  double lowZ = 30000.0, highZ = 0.0;
262  int iLow = -1, iHigh = -1;
263  for (unsigned iPt = 0; iPt < wirePoints.size(); iPt++)
264  {
265  if (!wirePoints[iPt].bOutlier)
266  {
267  if (lowZ > std::abs(wirePoints[iPt].fX))
268  {
269  lowZ = std::abs(wirePoints[iPt].fX);
270  iLow = iPt;
271  }
272  if (highZ < std::abs(wirePoints[iPt].fX))
273  {
274  highZ = std::abs(wirePoints[iPt].fX);
275  iHigh = iPt;
276  }
277  }
278  }
279  if (iLow > -1 && iLow < (int)wirePoints.size()) lowZ = wirePoints[iLow].fX;
280  if (iHigh > -1 && iHigh < (int)wirePoints.size()) highZ = wirePoints[iHigh].fX;
281  Amg::Vector3D p1(wireStats.eval(lowZ), 0.0, lowZ);
282  double phi = stripStats.eval(lowZ);
283  if( phi > M_PI ) phi -= M_PI*2;
284  if( phi < -M_PI ) phi += M_PI*2;
285  Amg::setPhi(p1, phi);
286  Amg::Vector3D p2(wireStats.eval(highZ), 0.0, highZ);
287  phi = stripStats.eval(highZ);
288  if( phi > M_PI ) phi -= M_PI*2;
289  if( phi < -M_PI ) phi += M_PI*2;
290  Amg::setPhi(p2, phi);
291  {
292  ATH_MSG_DEBUG("runTgcMiddle: Point1 eta=" << p1.eta()
293  << ",phi=" << p1.phi() << ",perp=" << p1.perp() << ",z=" << p1.z());
294  }
295  {
296  ATH_MSG_DEBUG("runTgcMiddle: Point2 eta=" << p2.eta()
297  << ",phi=" << p2.phi() << ",perp=" << p2.perp() << ",z=" << p2.z());
298  }
299  tgcFitResult.tgcMid1[0] = p1.eta();
300  tgcFitResult.tgcMid1[1] = p1.phi();
301  tgcFitResult.tgcMid1[2] = p1.perp();
302  tgcFitResult.tgcMid1[3] = p1.z();
303  tgcFitResult.tgcMid2[0] = p2.eta();
304  tgcFitResult.tgcMid2[1] = p2.phi();
305  tgcFitResult.tgcMid2[2] = p2.perp();
306  tgcFitResult.tgcMid2[3] = p2.z();
307  tgcFitResult.tgcMidRhoChi2 = wireStats.fChi2;
308  tgcFitResult.tgcMidRhoN = wireStats.n;
309  tgcFitResult.tgcMidPhiChi2 = stripStats.fChi2;
310  tgcFitResult.tgcMidPhiN = stripStats.n;
311 
312  return status;
313 }

◆ setFitParameters()

void TrigL2MuonSA::TgcFit::setFitParameters ( double  CHI2_TEST,
unsigned  MIN_WIRE_POINTS,
unsigned  MIN_STRIP_POINTS 
)

Definition at line 30 of file TgcFit.cxx.

33 {
34  m_CHI2_TEST = CHI2_TEST;
35  m_MIN_WIRE_POINTS = MIN_WIRE_POINTS;
36  m_MIN_STRIP_POINTS = MIN_STRIP_POINTS;
37 }

◆ SimpleStatistics()

void TrigL2MuonSA::TgcFit::SimpleStatistics ( PointArray points,
SimpleStats stats 
) const

Definition at line 54 of file TgcFit.cxx.

55 {
56  double *y = new double[points.size()];
57  double *w = new double[points.size()];
58  for (;;)
59  {
60  stats.clear();
61  for (const TrigL2MuonSA::TgcFit::Point& Pt : points)
62  {
63  // Exclude outliers.
64  if (!Pt.bOutlier)
65  {
66  y[stats.n] = Pt.fY;
67  w[stats.n] = Pt.fW;
68  stats.n++;
69  }
70  }
71  if (stats.n == 0)
72  break;
73 
74  // Calculate mean and standard deviation.
75  // suppress thread-checker warning about unchecked code (gsl is thread-safe)
76  const double mean ATLAS_THREAD_SAFE = gsl_stats_wmean(w, 1, y, 1, stats.n);
77  stats.fMean = mean;
78  if (stats.n == 1)
79  break;
80  const double stddev ATLAS_THREAD_SAFE = gsl_stats_wsd (w, 1, y, 1, stats.n);
81  stats.fStd = stddev;
82  double fMaxChi2 = 0.0;
83  int iPtMax = -1;
84  for (unsigned iPt = 0; iPt < points.size(); iPt++)
85  {
86  if (!points[iPt].bOutlier)
87  {
88  double fDiff = points[iPt].fY - stats.fMean;
89  points[iPt].fChi2 = points[iPt].fW * fDiff * fDiff;
90  stats.fChi2 += points[iPt].fChi2;
91  if (fMaxChi2 < points[iPt].fChi2)
92  {
93  fMaxChi2 = points[iPt].fChi2;
94  iPtMax = iPt;
95  }
96  }
97  }
98  // Print results.
99  ATH_MSG_DEBUG( "SimpleStatistics:"
100  << " n=" << stats.n << " Mean=" << stats.fMean
101  << " Std=" << stats.fStd << " Chi2=" << stats.fChi2);
102 
103  if (iPtMax == -1 || fMaxChi2 < m_CHI2_TEST)
104  break;
105  points[iPtMax].bOutlier = true;
106  }
107  delete [] y;
108  delete [] w;
109 }

◆ 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_CHI2_TEST

double TrigL2MuonSA::TgcFit::m_CHI2_TEST { 10.0 }
protected

Definition at line 195 of file TgcFit.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_MIN_STRIP_POINTS

unsigned TrigL2MuonSA::TgcFit::m_MIN_STRIP_POINTS { 3 }
protected

Minimum number of strip points for linear fit.

Definition at line 197 of file TgcFit.h.

◆ m_MIN_WIRE_POINTS

unsigned TrigL2MuonSA::TgcFit::m_MIN_WIRE_POINTS { 4 }
protected

Test for outliers: w * (value - mean)^2 > CHI2_TEST.

Minimum number of wire points for linear fit.

Definition at line 196 of file TgcFit.h.

◆ m_superPoints

PointArray TrigL2MuonSA::TgcFit::m_superPoints
protected

List of wire (eta) super-points.

Definition at line 193 of file TgcFit.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
TrigL2MuonSA::TgcFitResult::tgcMidPhiN
int tgcMidPhiN
Definition: TgcFitResult.h:52
TrigL2MuonSA::TgcFitResult::tgcMidRhoNin
int tgcMidRhoNin
Definition: TgcFitResult.h:48
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
TrigL2MuonSA::TgcFitResult::tgcMidPhiNin
int tgcMidPhiNin
Definition: TgcFitResult.h:51
TrigL2MuonSA::TgcFit::countUniqueStations
size_t countUniqueStations(const TrigL2MuonSA::TgcFit::PointArray &) const
Definition: TgcFit.cxx:188
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TrigL2MuonSA::TgcFit::Status
Status
Definition: TgcFit.h:25
TrigL2MuonSA::TgcFit::FIT_POINT
@ FIT_POINT
Definition: TgcFit.h:27
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
M_PI
#define M_PI
Definition: ActiveFraction.h:11
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
TrigL2MuonSA::TgcFitResult::tgcMidRhoN
int tgcMidRhoN
Definition: TgcFitResult.h:49
TrigL2MuonSA::TgcFitResult::tgcInnRhoN
int tgcInnRhoN
Definition: TgcFitResult.h:58
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
trigbs_dumpHLTContentInBS.stats
stats
Definition: trigbs_dumpHLTContentInBS.py:91
x
#define x
Amg::setPhi
Amg::RotationMatrix3D setPhi(Amg::RotationMatrix3D mat, double angle, int convention=0)
Definition: EulerAnglesHelpers.h:102
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigL2MuonSA::TgcFit::Point
Definition: TgcFit.h:35
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigL2MuonSA::TgcFitResult::tgcMid2
float tgcMid2[4]
Definition: TgcFitResult.h:46
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigL2MuonSA::TgcFitResult::intercept
float intercept
Definition: TgcFitResult.h:66
TrigL2MuonSA::TgcFit::FIT_NONE
@ FIT_NONE
Definition: TgcFit.h:26
TrigL2MuonSA::TgcFitResult::tgcInnRhoNin
int tgcInnRhoNin
Definition: TgcFitResult.h:57
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigL2MuonSA::TgcFitResult::tgcMid1
float tgcMid1[4]
Definition: TgcFitResult.h:45
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
TrigL2MuonSA::TgcFitResult::tgcInnPhiN
int tgcInnPhiN
Definition: TgcFitResult.h:61
TrigL2MuonSA::TgcFit::m_MIN_WIRE_POINTS
unsigned m_MIN_WIRE_POINTS
Test for outliers: w * (value - mean)^2 > CHI2_TEST.
Definition: TgcFit.h:196
TrigL2MuonSA::TgcFitResult::tgcInnRhoStd
float tgcInnRhoStd
Definition: TgcFitResult.h:56
TrigL2MuonSA::TgcFitResult::slope
float slope
Definition: TgcFitResult.h:65
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
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
lumiFormat.array
array
Definition: lumiFormat.py:91
TrigL2MuonSA::TgcFitResult::tgcMidRhoChi2
float tgcMidRhoChi2
Definition: TgcFitResult.h:47
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigL2MuonSA::TgcFit::linReg
void linReg(PointArray &points, LinStats &stats) const
Definition: TgcFit.cxx:114
TrigL2MuonSA::TgcFit::FIT_LINE
@ FIT_LINE
Definition: TgcFit.h:28
TrigL2MuonSA::TgcFitResult::tgcInn
float tgcInn[4]
Definition: TgcFitResult.h:55
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TrigL2MuonSA::TgcFit::printDebug
void printDebug(const std::string &str) const
Definition: TgcFit.h:199
TrigL2MuonSA::TgcFit::SimpleStatistics
void SimpleStatistics(PointArray &points, SimpleStats &stats) const
Definition: TgcFit.cxx:54
Prompt::Def::Pt
@ Pt
Definition: VarHolder.h:76
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
merge.status
status
Definition: merge.py:17
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TrigL2MuonSA::TgcFitResult::tgcInnPhiNin
int tgcInnPhiNin
Definition: TgcFitResult.h:60
TrigL2MuonSA::TgcFitResult::tgcMidPhiChi2
float tgcMidPhiChi2
Definition: TgcFitResult.h:50
TrigL2MuonSA::TgcFit::m_CHI2_TEST
double m_CHI2_TEST
Definition: TgcFit.h:195
TrigL2MuonSA::TgcFit::m_MIN_STRIP_POINTS
unsigned m_MIN_STRIP_POINTS
Minimum number of strip points for linear fit.
Definition: TgcFit.h:197
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
TrigL2MuonSA::TgcFitResult::tgcInnPhiStd
float tgcInnPhiStd
Definition: TgcFitResult.h:59
jobOptions.points
points
Definition: jobOptions.GenevaPy8_Zmumu.py:97
fitman.k
k
Definition: fitman.py:528