ATLAS Offline Software
StorePIDinfo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
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!!!
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 }
max
#define max(a, b)
Definition: cfImp.cxx:41
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
bin
Definition: BinsDiffFromStripMedian.h:43
athena.value
value
Definition: athena.py:122
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
StorePIDinfo::check
StatusCode check(int gas, int detpart) const
Definition: StorePIDinfo.cxx:44
StorePIDinfo::GetBin
int GetBin(float input) const
Definition: StorePIDinfo.cxx:65
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
StorePIDinfo::m_min
float m_min
Definition: StorePIDinfo.h:33
StorePIDinfo::m_nbins
unsigned int m_nbins
Definition: StorePIDinfo.h:32
StorePIDinfo::update
void update(int nbins, float min, float max, const std::vector< float > &values)
Definition: StorePIDinfo.cxx:16
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
StorePIDinfo::m_max
float m_max
Definition: StorePIDinfo.h:34
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
StorePIDinfo.h
min
#define min(a, b)
Definition: cfImp.cxx:40
StorePIDinfo::StorePIDinfo
StorePIDinfo()=default
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
StorePIDinfo::push_back
void push_back(float value)
Definition: StorePIDinfo.cxx:31
StorePIDinfo::m_values
std::vector< float > m_values
Definition: StorePIDinfo.h:35