ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
LArSamples::ResidualCompare Class Reference

#include <Residual.h>

Collaboration diagram for LArSamples::ResidualCompare:

Public Member Functions

 ResidualCompare (int sampling)
 
bool operator() (const Residual &r1, const Residual &r2) const
 

Private Attributes

int m_sampling
 

Detailed Description

Definition at line 60 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

Constructor & Destructor Documentation

◆ ResidualCompare()

LArSamples::ResidualCompare::ResidualCompare ( int  sampling)
inline

Definition at line 63 of file LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h.

63 : m_sampling(sampling) { }

Member Function Documentation

◆ operator()()

bool ResidualCompare::operator() ( const Residual r1,
const Residual r2 
) const

Definition at line 61 of file LArCalorimeter/LArSamplesMon/src/Residual.cxx.

62 {
63  if (!r1.hasSameRange(r2)) {
64  cout << "WARNING : residuals have different ranges, this may crash the sorting..." << endl;
65  return false;
66  }
67 
68  // Very, very important! Since samples are integers, it *will* happen that some residuals will have *identical* deltas.
69  // It turns out that (at least in the way used here), operator<(double, double) is not a strict weak ordering: we will
70  // have cases where residual1[4] == residual2[4], and then we will have residual1[4] < residual2[4] and residual2[4] < residual1[4]
71  // both true, which will confuse std::sort and cause it to crash... so add this safety (lesson of 2 days of debugging)
72  // Note: if we write a<<b iff a < b - epsilon, then << is indeed a strict weak ordering so all is fine. It does mean there
73  // will be "sorting errors", i.e. residuals that differ by less than epsilon may be sorted the wrong way. But that's fine for our usage.
74  const double epsilon = 1E-5;
75 // cout << "Comparing sample " << m_sampling << ", = "
76 // << (m_sampling == r1.upb() + 1 ? r1.time() : r1.scaledDelta(m_sampling)) << " >/< "
77 // << (m_sampling == r2.upb() + 1 ? r2.time() : r2.scaledDelta(m_sampling)) << " "
78 // << ((m_sampling == r1.upb() + 1 ? r1.time() : r1.scaledDelta(m_sampling)) < (m_sampling == r2.upb() + 1 ? r2.time() : r2.scaledDelta(m_sampling))) << endl;
79 
80  if (r1.isInRange(m_sampling)) return r1.scaledDelta(m_sampling) < r2.scaledDelta(m_sampling) - epsilon;
81  if (m_sampling == r1.upb() + 1) return r1.time() < r2.time() - epsilon;
82  cout << "WARNING : comparison on an unknown sample, this may crash the sorting..." << endl;
83  return false;
84 }

Member Data Documentation

◆ m_sampling

int LArSamples::ResidualCompare::m_sampling
private

The documentation for this class was generated from the following files:
MCP::ScaleSmearParam::r2
@ r2
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
LArSamples::ResidualCompare::m_sampling
int m_sampling
Definition: LArCalorimeter/LArSamplesMon/LArSamplesMon/Residual.h:66
MCP::ScaleSmearParam::r1
@ r1