ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_ConditionsAlgorithms Namespace Reference

SCT_SimpleHisto.h C++ projects. More...

Namespaces

namespace  CoveritySafe

Typedefs

typedef std::map< float, unsigned int > S_t

Functions

bool init (S_t &s, const float xlo, const float xhi, const unsigned int nbins)
 Initialize a map to be used as a histogram.
int fill (S_t &s, const float value)
std::string asXmlString (const S_t &s)
std::string xmlHeader (const std::string &version="1.0", const std::string &encoding="UTF-8")
std::string stylesheet (const std::string &path)

Detailed Description

SCT_SimpleHisto.h C++ projects.

Created by sroe on 13/11/2009.

Typedef Documentation

◆ S_t

typedef std::map<float, unsigned int> SCT_ConditionsAlgorithms::S_t

Definition at line 22 of file SCT_SimpleHisto.h.

Function Documentation

◆ asXmlString()

std::string SCT_ConditionsAlgorithms::asXmlString ( const S_t & s)

Definition at line 53 of file SCT_SimpleHisto.h.

53 {
54 std::ostringstream os;
55 os<<"<histogram>\n";
56 for (S_t::const_iterator i{s.begin()}; i!=s.end(); ++i) {
57 os<<"<b x=\""<<i->first<<"\">"<<i->second<<"</b>\n";
58 }
59 os<<"</histogram>\n";
60 return os.str();
61 }//asXmlString

◆ fill()

int SCT_ConditionsAlgorithms::fill ( S_t & s,
const float value )

Definition at line 40 of file SCT_SimpleHisto.h.

40 {
41 S_t::const_iterator start{s.begin()};
42 S_t::const_iterator end{s.end()};
43 unsigned int nbins{static_cast<unsigned int>(s.size())};
44 if (value * nbins > ((--end)->first - start->first) * (nbins+1)) return 1;
45 S_t::iterator i=s.upper_bound(value);
46 if (i==start) return -1;
47 ++((--i)->second);
48 return 0;
49 }//fill function

◆ init()

bool SCT_ConditionsAlgorithms::init ( S_t & s,
const float xlo,
const float xhi,
const unsigned int nbins )

Initialize a map to be used as a histogram.

Definition at line 26 of file SCT_SimpleHisto.h.

26 {
27 if ((xhi <= xlo) or (nbins<2)) return false;
28 float increment{(xhi-xlo)/nbins};
29 float acc{xlo};
30 unsigned int init{0};
31 for (unsigned int i{0}; i!=nbins; ++i) {
32 s[acc]=init;
33 acc+=increment;
34 }
35 return (s.size()==nbins); //should be true now
36 }//initHisto function
bool init(S_t &s, const float xlo, const float xhi, const unsigned int nbins)
Initialize a map to be used as a histogram.

◆ stylesheet()

std::string SCT_ConditionsAlgorithms::stylesheet ( const std::string & path)

Definition at line 68 of file SCT_SimpleHisto.h.

68 {
69 return "<?xml-stylesheet type=\"text/xsl\" href=\""+path+"\"?>";
70 }

◆ xmlHeader()

std::string SCT_ConditionsAlgorithms::xmlHeader ( const std::string & version = "1.0",
const std::string & encoding = "UTF-8" )

Definition at line 64 of file SCT_SimpleHisto.h.

64 {
65 return "<?xml version=\""+version+"\" encoding=\""+encoding+"\" standalone=\"yes\"?>";
66 }