ATLAS Offline Software
LWBinUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class LWBinUtils //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: July 2009 //
12 // //
14 
15 #include "LWBinUtils.h"
16 #include <algorithm>
17 
18 //____________________________________________________________________
19 unsigned LWBinUtils::valueToVarBin( const double& x,
20  const float * varBinnings,
21  unsigned nbinsplus1 )
22 {
23  //varBinnings has nbinsplus1 entries
24  assert(!(x!=x));
25  assert(varBinnings);
26  assert(nbinsplus1>=2);
27  if (x<varBinnings[0])
28  return 0;
29  if (x>varBinnings[nbinsplus1-1])
30  return nbinsplus1;
31  const unsigned result = std::upper_bound(varBinnings,&(varBinnings[nbinsplus1]),x)-varBinnings;
32  assert(result<=nbinsplus1);
33  return result;
34 }
get_generator_info.result
result
Definition: get_generator_info.py:21
x
#define x
LWBinUtils::valueToVarBin
static unsigned valueToVarBin(const double &x, const float *varBinnings, unsigned nbinsplus1)
Definition: LWBinUtils.cxx:19
LWBinUtils.h