ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigAnalysis
TrigInDetAnalysisUser
Analysis
src
Contour.h
Go to the documentation of this file.
1
/* emacs: this is -*- c++ -*- */
10
11
12
#ifndef CONTOUR_H
13
#define CONTOUR_H
14
15
#include <iostream>
16
#include <vector>
17
#include <cstdlib>
18
#include <cstdio>
19
20
#include "
TrigInDetAnalysis/TIDDirectory.h
"
21
22
23
template
<
typename
T>
24
class
Contour
:
public
std::vector< std::pair<double, T*> > {
25
26
typedef
std::pair<double, T*>
value_type
;
27
28
public
:
29
30
Contour
(
const
std::string& s) :
mname
(s),
mdir
(s) { }
31
32
virtual
~Contour
() {
33
for
(
unsigned
i=this->
size
()-1 ; i-- ; )
if
( this->at(i).second )
delete
this->at(i).second;
34
}
35
36
void
ranges
(
const
std::vector<double>& d, T* t ) {
37
if
( d.empty() )
return
;
38
ranges
( &d[0], d.size(), t );
39
}
40
41
void
ranges
(
const
double
* d,
unsigned
N, T* t ) {
42
mdir
.push();
43
for
(
unsigned
i=1 ; i<N ; i++ ) {
44
this->push_back(
value_type
( d[i-1],
new
T(*t) ) );
45
}
46
this->push_back(
value_type
( d[N-1], 0 ) );
47
mdir
.pop();
48
}
49
50
T*
find
(
double
d ) {
51
if
( this->
empty
() )
return
0;
52
for
(
unsigned
i=this->
size
()-1 ; i-- ; ) {
53
if
( d>=this->at(i).first && d<this->at(i+1).first )
return
this->at(i).second;
54
}
55
return
0;
56
}
57
58
std::string
name
()
const
{
return
mname
; }
59
60
void
Write
(
const
std::string& s=
""
) {
61
mdir
.push();
62
for
(
unsigned
i=this->
size
()-1 ; i-- ; ) {
63
if
( this->at(i).second ) {
64
char
_name[64];
65
if
( s==
""
) std::sprintf( _name,
"%s_%d"
,
mname
.c_str(), i-1 );
66
else
std::sprintf( _name,
"%s_%d"
, s.c_str(), i-1 );
67
this->at(i).second->Bayes()->Write(_name);
68
}
69
}
70
mdir
.pop();
71
}
72
73
TIDDirectory
*
dir
() {
return
&
mdir
; }
74
75
private
:
76
77
std::string
mname
;
78
79
TIDDirectory
mdir
;
80
81
};
82
83
template
<
typename
T>
84
inline
std::ostream&
operator<<
( std::ostream& s,
const
Contour<T>
& _c ) {
85
s <<
"Contour : "
<< _c.
name
() <<
"\n"
;
86
for
(
unsigned
i=0 ; i<_c.size() ; i++ ) s <<
"\t d "
<< _c[i].first <<
"\n"
;
87
return
s;
88
}
89
90
91
#endif
// CONTOUR_H
92
93
94
95
96
97
98
99
100
101
operator<<
std::ostream & operator<<(std::ostream &s, const Contour< T > &_c)
Definition
Contour.h:84
size
size_t size() const
Number of registered mappings.
TIDDirectory.h
empty
static const Attributes_t empty
Definition
XmlStreamer.cxx:16
Contour
Definition
Contour.h:24
Contour::find
T * find(double d)
Definition
Contour.h:50
Contour::mname
std::string mname
Definition
Contour.h:77
Contour::value_type
std::pair< double, T * > value_type
Definition
Contour.h:26
Contour::Contour
Contour(const std::string &s)
Definition
Contour.h:30
Contour::dir
TIDDirectory * dir()
Definition
Contour.h:73
Contour::~Contour
virtual ~Contour()
Definition
Contour.h:32
Contour::ranges
void ranges(const double *d, unsigned N, T *t)
Definition
Contour.h:41
Contour::ranges
void ranges(const std::vector< double > &d, T *t)
Definition
Contour.h:36
Contour::Write
void Write(const std::string &s="")
Definition
Contour.h:60
Contour::name
std::string name() const
Definition
Contour.h:58
Contour::mdir
TIDDirectory mdir
Definition
Contour.h:79
TIDDirectory
Definition
TIDDirectory.h:25
Generated on
for ATLAS Offline Software by
1.17.0