ATLAS Offline Software
EMInsituDatabaseEntry.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <iostream>
8 #include <utility>
9 
10 //ClassImp(EMInsituDatabaseEntry)
11 
14 {
15  clear();
16 }
17 
18 
21 {
22  clear();
23  setDatabaseID(dbaseID);
24 }
25 
27 bool EMInsituDatabaseEntry::setMatrix(const EMClusterErrorsMatrix &apClusterErrorsMatrix)
28 {
29  //std::cerr << "setMatrix called"<< std::endl;
30  if (apClusterErrorsMatrix.m_matrix.empty()) {
31  return false;
32  }
33  clear();
34  // Writing ID of EfficiencyMatrix
36 // m_ID = EMInsituDatabase_EMClusterErrorsMatrixID;
37  // Writing Special Tag of EMClusterErrors
38  m_vecInt_Info.push_back(0); // is this like the version number or something?
39  // Writing Information of EMClusterErrors
40  m_vecInt_Info.push_back((int)apClusterErrorsMatrix.m_dimensions);
41  for(unsigned i=0; i<apClusterErrorsMatrix.m_dimensions; i++) {
42  std::vector<double> axisBinning = apClusterErrorsMatrix.m_axis.at(i).getBinningInformation();
43  m_vecInt_Info.push_back((int)axisBinning.size());
44  m_vecString.push_back(apClusterErrorsMatrix.m_axis.at(i).getName());
45  for (double j : axisBinning) {
46  m_vecFloat_Info.push_back(j);
47  }
48  }
49 
50  const int matrixSize = (int)apClusterErrorsMatrix.m_matrix.size();
51  m_vecInt_Info.push_back(matrixSize);
52 
53  // push back the number of floats to store per matrix entry
54  const int vectSize = (matrixSize) ? apClusterErrorsMatrix.m_matrix.at(0).size() : 0;
55  m_vecInt_Info.push_back(vectSize);
56 
57  for (int i=0; i<matrixSize; i++) {
58  const EMClusterErrorsEntry vect = apClusterErrorsMatrix.m_matrix.at(i);
59  if ((int)vect.size() != vectSize) {
60  std::cerr << "The input APEMClusterErrorsMatrix doesn't have entries with all having the same number of floats" << std::endl; // shoudl this go to a message stream instead? The macros didn't work.
61  clear();
62  return false;
63  }
64  for (int j=0; j<vectSize; j++) {
65  m_vecFloat_Data.push_back(vect.at(j));
66  }
67  }
68  m_vecString.push_back(apClusterErrorsMatrix.getTextDescription());
69  return true;
70 }
71 
73 bool EMInsituDatabaseEntry::getMatrix(EMClusterErrorsMatrix &apClusterErrorsMatrix) const
74 {
75  apClusterErrorsMatrix.clear();
76 
77  if (m_vecInt_Info.size()<3) {
78  return false;
79  }
80  // Reading and testing ID of entry
82  return false;
83  }
84  // m_ID =m_vecInt_Info.at(0);
85  // Reading Tag of entry
86  int nTag=m_vecInt_Info.at(1);
87  if (nTag==-1) {
88  return false;
89  }
90 
91  apClusterErrorsMatrix.m_dimensions = m_vecInt_Info.at(2);
92 
93  // m_vecInt_info(3) is next, so store the index:
94  unsigned int m=3;
95 
96  // m_vecFloat_Info(0) is next, so store the index
97  unsigned int n=0;
98 
99  // m_vecString(0) is next, so store the index;
100  unsigned int s=0;
101 
102  // std::vector<APMatrixAxis> axes;
103  std::vector<double> axisBinning;
104  unsigned int ib=1;
105  for (unsigned int i=0; i<apClusterErrorsMatrix.m_dimensions; i++) {
106  axisBinning.clear();
107  for (int j=0; j<m_vecInt_Info.at(m); j++) {
108  axisBinning.push_back(m_vecFloat_Info.at(n++));
109  }
110  apClusterErrorsMatrix.m_axis.emplace_back(m_vecString.at(s++),axisBinning);
111  apClusterErrorsMatrix.m_base.push_back(ib);
112  ib+=m_vecInt_Info.at(m++);
113  }
114 
115  // for (unsigned int i=0; i<apClusterErrorsMatrix.m_dimensions; i++) {
116  // m_axis.push_back(axes.at(i));
117  // }
118 
119  const int matrixSize = m_vecInt_Info.at(m++);
120  const int vectSize = m_vecInt_Info.at(m);
121 
122  //std::cerr << "matrixSize = " << matrixSize << ", vectSize = " << vectSize << std::endl;
123 
124  // the data index;
125  unsigned int di=0;
126 
127  // std::cerr << "matrix size before is " << apClusterErrorsMatrix.m_matrix.size() << std::endl;
128  for (int i=0; i< matrixSize; i++) {
130  for (int j= 0; j < vectSize; j++) {
131  //std::cerr << "reading value: " << m_vecFloat_Data.at(di) << std::endl;
132  entry.push_back(m_vecFloat_Data.at(di++));
133  }
134  apClusterErrorsMatrix.m_matrix.push_back(entry);
135  }
136  // std::cerr << "matrix size is " << apClusterErrorsMatrix.m_matrix.size() << std::endl;
137  apClusterErrorsMatrix.setTextDescription(m_vecString.at(s));
138  return true;
139 }
140 
141 
143 void EMInsituDatabaseEntry::setDatabaseID(std::string dbaseID)
144 {
145  m_DatabaseID = std::move(dbaseID);
146 }
147 
148 
150 const std::string& EMInsituDatabaseEntry::getDatabaseID() const
151 {
152  return m_DatabaseID;
153 }
154 
155 
158 {
159 // m_ID = -1;
160  m_DatabaseID = "EMDatabaseEntry";
161  m_vecString.clear();
162  m_vecFloat_Data.clear();
163  m_vecInt_Data.clear();
164  m_vecFloat_Info.clear();
165  m_vecInt_Info.clear();
166 }
167 
169 {
170  return new EMInsituDatabaseEntry(*this);
171 }
172 
173 void EMInsituDatabaseEntry::getBasicInformation(std::string &dbaseID, unsigned int &nSize_Strings, unsigned int &nSize_FloatInfo, unsigned int &nSize_IntInfo)
174 {
175  dbaseID = m_DatabaseID;
176  nSize_Strings = m_vecString.size();
177  nSize_FloatInfo = m_vecFloat_Info.size();
178  nSize_IntInfo = m_vecInt_Info.size();
179 }
180 
182 {
183  std::cout << "*********** Dumping contents of EMInsituDatabaseEntry **********" << std::endl;
184  std::cout << " Database ID: " << m_DatabaseID << std::endl;
185 
186  std::cout << " vecString of size " << m_vecString.size() << ":\n ";
187  for (unsigned int i = 0; i < m_vecString.size(); i++) {
188  if (i!= 0) std::cout << ", ";
189  std::cout << m_vecString.at(i);
190  }
191  std::cout << std::endl;
192 
193  std::cout << " vecFloat_Data of size " << m_vecFloat_Data.size() << ":\n ";
194  for (unsigned int i = 0; i < m_vecFloat_Data.size(); i++) {
195  if (i!= 0) std::cout << ", ";
196  std::cout << m_vecFloat_Data.at(i);
197  }
198  std::cout << std::endl;
199 
200  std::cout << " vecInt_Data of size " << m_vecInt_Data.size() << ":\n ";
201  for (unsigned int i = 0; i < m_vecInt_Data.size(); i++) {
202  if (i!= 0) std::cout << ", ";
203  std::cout << m_vecInt_Data.at(i);
204  }
205  std::cout << std::endl;
206 
207  std::cout << " vecFloat_Info of size " << m_vecFloat_Info.size() << ":\n ";
208  for (unsigned int i = 0; i < m_vecFloat_Info.size(); i++) {
209  if (i!= 0) std::cout << ", ";
210  std::cout << m_vecFloat_Info.at(i);
211  }
212  std::cout << std::endl;
213 
214  std::cout << " vecInt_Info of size " << m_vecInt_Info.size() << ":\n ";
215  for (unsigned int i = 0; i < m_vecInt_Info.size(); i++) {
216  if (i!= 0) std::cout << ", ";
217  std::cout << m_vecInt_Info.at(i);
218  }
219  std::cout << std::endl;
220 }
EMInsituDatabaseEntry::setMatrix
bool setMatrix(const EMClusterErrorsMatrix &apClusterErrorsMatrix)
Fill this APEMClusterErrorsEntry from given APEMClusterErrorsMatrix.
Definition: EMInsituDatabaseEntry.cxx:27
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
EMAPMatrix::m_axis
std::vector< EMAPMatrixAxis > m_axis
Definition: EMAPMatrix.h:193
EMInsituDatabaseEntry::m_vecInt_Info
std::vector< Int_t > m_vecInt_Info
Definition: EMInsituDatabaseEntry.h:84
EMInsituDatabaseEntry::EMInsituDatabaseEntry
EMInsituDatabaseEntry()
Default Constructor.
Definition: EMInsituDatabaseEntry.cxx:13
EMInsituDatabaseEntry::m_vecFloat_Data
std::vector< Float_t > m_vecFloat_Data
Definition: EMInsituDatabaseEntry.h:81
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
EMInsituDatabaseEntry::clone
EMInsituDatabaseEntry * clone() const
Definition: EMInsituDatabaseEntry.cxx:168
EMInsituDatabaseEntry::getDatabaseID
const std::string & getDatabaseID() const
Getting DatabaseID.
Definition: EMInsituDatabaseEntry.cxx:150
EMAPMatrix::getTextDescription
const std::string & getTextDescription() const
The user can add a Description of what this matrix contains and how it was produced,...
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
EMInsituDatabaseEntry::m_vecInt_Data
std::vector< Int_t > m_vecInt_Data
Definition: EMInsituDatabaseEntry.h:82
EMInsituDatabaseEntry.h
EMInsituDatabaseEntry::clear
void clear()
clear all information
Definition: EMInsituDatabaseEntry.cxx:157
EMAPMatrix::m_dimensions
unsigned int m_dimensions
Definition: EMAPMatrix.h:191
EMAPMatrix::m_base
std::vector< unsigned int > m_base
representation of the content of matrix
Definition: EMAPMatrix.h:196
EMClusterErrorsEntry
std::vector< float > EMClusterErrorsEntry
Definition: EMClusterErrorsMatrix.h:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
EMAPMatrix::setTextDescription
void setTextDescription(const std::string &text)
The user can add a Description of what this matrix contains and how it was produced,...
EMInsituDatabaseEntry::m_vecFloat_Info
std::vector< Float_t > m_vecFloat_Info
Definition: EMInsituDatabaseEntry.h:83
EMInsituDatabaseEntry::m_DatabaseID
std::string m_DatabaseID
Definition: EMInsituDatabaseEntry.h:79
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
EMInsituDatabaseEntry
Definition: EMInsituDatabaseEntry.h:34
EMInsituDatabaseEntry::m_vecString
std::vector< std::string > m_vecString
Definition: EMInsituDatabaseEntry.h:80
EMAPMatrix::m_matrix
std::vector< T > m_matrix
Definition: EMAPMatrix.h:195
EMInsituDatabaseEntry::debugPrint
void debugPrint() const
Definition: EMInsituDatabaseEntry.cxx:181
EMClusterErrorsMatrix.h
EMAPMatrix::clear
void clear()
Clear all Matrix information (Also binning,...)
EMInsituDatabase_EMClusterErrorsMatrixID
#define EMInsituDatabase_EMClusterErrorsMatrixID
Definition: EMInsituDatabaseEntry.h:27
EMClusterErrorsMatrix
Definition: EMClusterErrorsMatrix.h:26
EMInsituDatabaseEntry::getBasicInformation
void getBasicInformation(std::string &dbaseID, unsigned int &nSize_Strings, unsigned int &nSize_FloatInfo, unsigned int &nSize_IntInfo)
Definition: EMInsituDatabaseEntry.cxx:173
multiIoVMCRecoTag.nTag
nTag
Definition: multiIoVMCRecoTag.py:70
EMInsituDatabaseEntry::getMatrix
bool getMatrix(EMClusterErrorsMatrix &apClusterErrorsMatrix) const
Fill APEfficiencyMatrix from this APEMClusterErrorsEntry object.
Definition: EMInsituDatabaseEntry.cxx:73
EMInsituDatabaseEntry::setDatabaseID
void setDatabaseID(std::string dbaseID)
Setting DatabaseID.
Definition: EMInsituDatabaseEntry.cxx:143