ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsData
src
StorePIDinfo.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
TRT_ConditionsData/StorePIDinfo.h
"
5
#include "
AthenaKernel/getMessageSvc.h
"
6
#include "GaudiKernel/MsgStream.h"
7
#include <iostream>
8
#include <utility>
9
10
11
StorePIDinfo::StorePIDinfo
(
int
nbins,
float
min
,
float
max
,
const
std::vector<float>& values){
12
update
(nbins,
min
,
max
, values);
13
}
14
15
16
void
StorePIDinfo::update
(
int
nbins,
float
min
,
float
max
,
const
std::vector<float>& values){
17
m_nbins
= nbins ;
18
m_min
=
min
;
19
m_max
=
max
;
20
if
(values.size()!=
m_nbins
){
21
MsgStream log(
Athena::getMessageSvc
(),
"StorePIDinfo"
);
22
log << MSG::ERROR <<
" Different Values of n_bins and vector size!!!"
<<
endmsg
;
23
}
24
m_values
.clear();
25
for
(
float
value : values){
26
m_values
.push_back( value);
27
}
28
}
29
30
// THIS HAS TO BE CALLED in order!!!
31
void
StorePIDinfo::push_back
(
float
value ){
32
// Just to read the DB
33
if
(
m_nbins
==0) {
34
m_nbins
= int(value) ;
35
m_min
= -9999.9 ;
36
m_max
= 10000000*2 ;
37
m_values
.clear() ;
38
}
39
else
if
(
m_min
< -9999)
m_min
= value ;
40
else
if
(
m_max
> 10000000)
m_max
= value ;
41
else
m_values
.push_back(value);
42
}
43
44
StatusCode
StorePIDinfo::check
(
int
gas,
int
detpart)
const
{
45
MsgStream log(
Athena::getMessageSvc
(),
"StorePIDinfo"
);
46
if
(
m_nbins
== 0)
47
{
48
49
log << MSG::ERROR <<
" StorePIDinfo: No bins in the DB!! Gas: "
<< gas <<
" detpart "
<< detpart <<
endmsg
;
50
return
StatusCode::FAILURE;
51
}
52
else
if
(
m_nbins
!=
m_values
.size() )
53
{
54
log << MSG::ERROR <<
" Different number of PID numbers!!!!! "
<<
endmsg
;
55
return
StatusCode::FAILURE;
56
}
57
else
if
( (
m_max
<
m_min
) || (
m_max
==
m_min
) )
58
{
59
log << MSG::ERROR <<
" Max is smaller or equal than min!!!"
<<
endmsg
;
60
return
StatusCode::FAILURE;
61
}
62
return
StatusCode::SUCCESS;
63
}
64
65
int
StorePIDinfo::GetBin
(
float
input)
const
66
{
67
if
(input <
m_min
){
68
return
0;
69
}
70
else
if
(input >=
m_max
){
71
return
m_nbins
- 1;
72
}
73
float
dr = (
m_max
-
m_min
) /
m_nbins
;
74
unsigned
int
bin
= int((input -
m_min
) / dr);
75
return
bin
;
76
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
StorePIDinfo.h
min
#define min(a, b)
Definition
cfImp.cxx:40
max
#define max(a, b)
Definition
cfImp.cxx:41
StorePIDinfo::StorePIDinfo
StorePIDinfo()=default
StorePIDinfo::m_max
float m_max
Definition
StorePIDinfo.h:34
StorePIDinfo::GetBin
int GetBin(float input) const
Definition
StorePIDinfo.cxx:65
StorePIDinfo::m_nbins
unsigned int m_nbins
Definition
StorePIDinfo.h:32
StorePIDinfo::push_back
void push_back(float value)
Definition
StorePIDinfo.cxx:31
StorePIDinfo::m_min
float m_min
Definition
StorePIDinfo.h:33
StorePIDinfo::update
void update(int nbins, float min, float max, const std::vector< float > &values)
Definition
StorePIDinfo.cxx:16
StorePIDinfo::check
StatusCode check(int gas, int detpart) const
Definition
StorePIDinfo.cxx:44
StorePIDinfo::m_values
std::vector< float > m_values
Definition
StorePIDinfo.h:35
bin
Definition
BinsDiffFromStripMedian.h:43
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
Generated on
for ATLAS Offline Software by
1.17.0