ATLAS Offline Software
Loading...
Searching...
No Matches
CscCondDataCollection.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CSCCONDDATACOLLECTION_H
6#define CSCCONDDATACOLLECTION_H
17//#include "AthenaKernel/CLASS_DEF.h"
20#include <sstream>
21
22
23
24namespace MuonCalib {
25 //Might be a neater way to do this. For now, this lets the collection name its
26 //type
27 template<typename type> class typeNamer {
28 public:
29 std::string nameType() const {
30 return "unknownType";
31 }
32 };
33
34 template<> class typeNamer<uint8_t> {
35 public:
36 std::string nameType() const {
37 return "uint8_t";
38 }
39 };
40
41 template<> class typeNamer<uint16_t> {
42 public:
43 std::string nameType() const {
44 return "uint16_t";
45 }
46 };
47
48 template<> class typeNamer<uint32_t> {
49 public:
50 std::string nameType() const {
51 return "uint32_t";
52 }
53 };
54
55 template<> class typeNamer<int> {
56 public:
57 std::string nameType() const {
58 return "int";
59 }
60 };
61
62 template<> class typeNamer<float> {
63 public:
64 std::string nameType() const {
65 return "float";
66 }
67 };
68
69 template<> class typeNamer<bool> {
70 public:
71 std::string nameType() const {
72 return "bool";
73 }
74 };
75
76 template<> class typeNamer<double> {
77 public:
78 std::string nameType() const {
79 return "double";
80 }
81 };
82
83 template<> class typeNamer<std::string> {
84 public:
85 std::string nameType() const {
86 return "string";
87 }
88 };
89
90 template <typename data_type>
91 class CscCondDataCollection : public CscCondDataCollectionBase, public DataVector< CscCondData<data_type> > {
92 public:
96
97 //Reinitializes internal DataVector to point to empty entries, but
98 //keeps size the same (if size was set with setSize())
99 virtual inline void reset() {
100 this->clear();
101 this->resize(m_size);
102 //std::cout << "Reset " << this->getParName() << ". Value of first index is " << (*this)[0] << std::endl;
103
104 }
105
106 //set parameter default from a string
107 virtual void setParDefault(const std::string & parDefault) {
108 std::istringstream ss(parDefault);
109 ss >> m_parDefault;
110
111
112 }
113
114 //virtual void print();
115 virtual std::string getParDataType() const {
116 return m_typeNamer.nameType();
117 }
118
119
120 virtual const data_type & getParDefault() const { return m_parDefault;}
121
122 virtual void setSize(const unsigned int & size) {
123 m_size = size;
124 this->resize(size);
125 }
126 virtual size_t getSize() const { return this->size(); }
127
128
129 StatusCode recordFromSS(std::istringstream & ss,const unsigned int &index);
130 StatusCode record(const data_type &, const int & index);
131
132 //check that there is a non-null pointer at index
133 virtual inline int check(unsigned int & index) const {
134 if(index >= this->size())
135 return 0;
136 //std::cout << "checking index" << index << " of " << this->getParName() << ". have " << (*this)[index] << "\n";
137
138 if((*this)[index])
139 return 1;
140 else
141 return 0;
142 }
143
144 private:
146 data_type m_parDefault;
147
148
149 };
150
151
152 //Retrieves a single word from an istreamstream, stores the value into CscCondDataCollection
153 template <typename data_type>
154 inline StatusCode CscCondDataCollection<data_type>::recordFromSS(std::istringstream & ss, const unsigned int & index) {
155 data_type data;
156 ss >> data;
157 return record(data, index);
158 }
159
160 //Store a bit of data into CscCondDataCollection
161 template <typename data_type>
162 inline StatusCode CscCondDataCollection<data_type>::record(const data_type & data, const int &index) {
163
164 //std::cout << "Storing [" << index << "] - " << data << std::endl;
165 //std::cout << "Currently we have pointer to: " << this->at(index) << std::endl;
166
167 //Check to see if this channel is already used. Don't allow overwriting in order to
168 //catch bugs
169 if(this->at(index))
170 return StatusCode::RECOVERABLE;
171 this->at(index) = new CscCondData<data_type>(data);
172 return StatusCode::SUCCESS;
173 }
174
175 //CLASS_DEF(MuonCalib::CscCondDataContainer, 1173850174, 1)
176
177}//end namespace MuonCalib
178#endif
An STL vector of pointers that by default owns its pointed-to elements.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t ss
const CscCondData< data_type > * at(size_type n) const
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
size_type size() const noexcept
CscCondDataCollection(SG::OwnershipPolicy own=SG::OWN_ELEMENTS)
virtual std::string getParDataType() const
StatusCode record(const data_type &, const int &index)
virtual void setParDefault(const std::string &parDefault)
virtual void setSize(const unsigned int &size)
virtual const data_type & getParDefault() const
StatusCode recordFromSS(std::istringstream &ss, const unsigned int &index)
virtual int check(unsigned int &index) const
std::string nameType() const
STL class.
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
Definition index.py:1
STL namespace.