3#ifndef EICD_CalorimeterHitCollection_H
4#define EICD_CalorimeterHitCollection_H
14#include "podio/ICollectionProvider.h"
15#include "podio/CollectionBase.h"
16#include "podio/CollectionIDTable.h"
18#ifdef PODIO_JSON_OUTPUT
19#include "nlohmann/json.hpp"
43 return m_index != x.m_index;
65 return m_index != x.m_index;
107 template<
typename... Args>
111 size_t size() const final;
114 std::
string getTypeName() const final {
return std::string(
"eicd::CalorimeterHitCollection"); }
118 std::string
getDataTypeName() const final {
return std::string(
"eicd::CalorimeterHitData"); }
121 return m_isSubsetColl;
141 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
148 if (!m_isSubsetColl) {
150 [ID] (
CalorimeterHitObj* obj) { obj->id = {obj->id.index, static_cast<int>(ID)}; }
157 return m_collectionID;
166 return iterator(0, &m_storage.entries);
172 return iterator(m_storage.entries.size(), &m_storage.entries);
175 return const_iterator(m_storage.entries.size(), &m_storage.entries);
178 template<
size_t arraysize>
179 const std::array<std::uint64_t, arraysize> cellID()
const;
180 template<
size_t arraysize>
181 const std::array<float, arraysize> energy()
const;
182 template<
size_t arraysize>
183 const std::array<float, arraysize> energyError()
const;
184 template<
size_t arraysize>
185 const std::array<float, arraysize> time()
const;
186 template<
size_t arraysize>
187 const std::array<float, arraysize> timeError()
const;
188 template<
size_t arraysize>
189 const std::array<edm4hep::Vector3f, arraysize> position()
const;
190 template<
size_t arraysize>
191 const std::array<edm4hep::Vector3f, arraysize> dimension()
const;
192 template<
size_t arraysize>
193 const std::array<std::int32_t, arraysize> sector()
const;
194 template<
size_t arraysize>
195 const std::array<std::int32_t, arraysize> layer()
const;
196 template<
size_t arraysize>
197 const std::array<edm4hep::Vector3f, arraysize> local()
const;
205 bool m_isValid{
false};
206 mutable bool m_isPrepared{
false};
207 bool m_isSubsetColl{
false};
208 int m_collectionID{0};
209 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
210 mutable CalorimeterHitCollectionData m_storage{};
213std::ostream&
operator<<(std::ostream& o,
const CalorimeterHitCollection& v);
215template<
typename... Args>
217 if (m_isSubsetColl) {
218 throw std::logic_error(
"Cannot create new elements on a subset collection");
220 const int size = m_storage.entries.size();
221 auto obj =
new CalorimeterHitObj({size, m_collectionID}, {std::forward<Args>(args)...});
222 m_storage.entries.push_back(obj);
227template<
size_t arraysize>
228const std::array<std::uint64_t, arraysize> CalorimeterHitCollection::cellID()
const {
229 std::array<std::uint64_t, arraysize> tmp{};
230 const auto valid_size = std::min(arraysize, m_storage.entries.size());
231 for (
unsigned i = 0; i < valid_size; ++i) {
232 tmp[i] = m_storage.entries[i]->data.cellID;
237template<
size_t arraysize>
238const std::array<float, arraysize> CalorimeterHitCollection::energy()
const {
239 std::array<float, arraysize> tmp{};
240 const auto valid_size = std::min(arraysize, m_storage.entries.size());
241 for (
unsigned i = 0; i < valid_size; ++i) {
242 tmp[i] = m_storage.entries[i]->data.energy;
247template<
size_t arraysize>
248const std::array<float, arraysize> CalorimeterHitCollection::energyError()
const {
249 std::array<float, arraysize> tmp{};
250 const auto valid_size = std::min(arraysize, m_storage.entries.size());
251 for (
unsigned i = 0; i < valid_size; ++i) {
252 tmp[i] = m_storage.entries[i]->data.energyError;
257template<
size_t arraysize>
258const std::array<float, arraysize> CalorimeterHitCollection::time()
const {
259 std::array<float, arraysize> tmp{};
260 const auto valid_size = std::min(arraysize, m_storage.entries.size());
261 for (
unsigned i = 0; i < valid_size; ++i) {
262 tmp[i] = m_storage.entries[i]->data.time;
267template<
size_t arraysize>
268const std::array<float, arraysize> CalorimeterHitCollection::timeError()
const {
269 std::array<float, arraysize> tmp{};
270 const auto valid_size = std::min(arraysize, m_storage.entries.size());
271 for (
unsigned i = 0; i < valid_size; ++i) {
272 tmp[i] = m_storage.entries[i]->data.timeError;
277template<
size_t arraysize>
278const std::array<edm4hep::Vector3f, arraysize> CalorimeterHitCollection::position()
const {
279 std::array<edm4hep::Vector3f, arraysize> tmp{};
280 const auto valid_size = std::min(arraysize, m_storage.entries.size());
281 for (
unsigned i = 0; i < valid_size; ++i) {
282 tmp[i] = m_storage.entries[i]->data.position;
287template<
size_t arraysize>
288const std::array<edm4hep::Vector3f, arraysize> CalorimeterHitCollection::dimension()
const {
289 std::array<edm4hep::Vector3f, arraysize> tmp{};
290 const auto valid_size = std::min(arraysize, m_storage.entries.size());
291 for (
unsigned i = 0; i < valid_size; ++i) {
292 tmp[i] = m_storage.entries[i]->data.dimension;
297template<
size_t arraysize>
298const std::array<std::int32_t, arraysize> CalorimeterHitCollection::sector()
const {
299 std::array<std::int32_t, arraysize> tmp{};
300 const auto valid_size = std::min(arraysize, m_storage.entries.size());
301 for (
unsigned i = 0; i < valid_size; ++i) {
302 tmp[i] = m_storage.entries[i]->data.sector;
307template<
size_t arraysize>
308const std::array<std::int32_t, arraysize> CalorimeterHitCollection::layer()
const {
309 std::array<std::int32_t, arraysize> tmp{};
310 const auto valid_size = std::min(arraysize, m_storage.entries.size());
311 for (
unsigned i = 0; i < valid_size; ++i) {
312 tmp[i] = m_storage.entries[i]->data.layer;
317template<
size_t arraysize>
318const std::array<edm4hep::Vector3f, arraysize> CalorimeterHitCollection::local()
const {
319 std::array<edm4hep::Vector3f, arraysize> tmp{};
320 const auto valid_size = std::min(arraysize, m_storage.entries.size());
321 for (
unsigned i = 0; i < valid_size; ++i) {
322 tmp[i] = m_storage.entries[i]->data.local;
328#ifdef PODIO_JSON_OUTPUT
Definition: CalorimeterHitCollectionData.h:28
CalorimeterHitObjPointerContainer entries
Definition: CalorimeterHitCollectionData.h:33
Definition: CalorimeterHitCollection.h:82
std::string getTypeName() const final
fully qualified type name
Definition: CalorimeterHitCollection.h:114
iterator begin()
Definition: CalorimeterHitCollection.h:165
CalorimeterHitCollection(CalorimeterHitCollection &&)=default
CalorimeterHit at(unsigned int index) const
Returns the const object of given index.
Definition: CalorimeterHitCollection.cc:25
unsigned getID() const final
Definition: CalorimeterHitCollection.h:156
void push_back(CalorimeterHit object)
Append object to the collection.
Definition: CalorimeterHitCollection.cc:108
const_iterator end() const
Definition: CalorimeterHitCollection.h:174
void prepareAfterRead() final
Definition: CalorimeterHitCollection.cc:89
std::string getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition: CalorimeterHitCollection.h:116
iterator end()
Definition: CalorimeterHitCollection.h:171
std::string getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition: CalorimeterHitCollection.h:118
bool isValid() const final
Definition: CalorimeterHitCollection.h:160
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition: CalorimeterHitCollection.cc:104
const_iterator begin() const
Definition: CalorimeterHitCollection.h:168
~CalorimeterHitCollection()
Definition: CalorimeterHitCollection.cc:16
CalorimeterHitCollection(const CalorimeterHitCollection &)=delete
podio::CollectionBuffers getBuffers() final
Get the collection buffers for this collection.
Definition: CalorimeterHitCollection.cc:133
void setID(unsigned ID) final
Definition: CalorimeterHitCollection.h:146
size_t size() const final
number of elements in the collection
Definition: CalorimeterHitCollection.cc:37
void prepareForWrite() const final
Definition: CalorimeterHitCollection.cc:68
CalorimeterHitCollection & operator=(const CalorimeterHitCollection &)=delete
bool isSubsetCollection() const final
Definition: CalorimeterHitCollection.h:120
void clear() final
Definition: CalorimeterHitCollection.cc:63
CalorimeterHitCollection & operator=(CalorimeterHitCollection &&)=default
CalorimeterHitCollection()
Definition: CalorimeterHitCollection.cc:13
MutableCalorimeterHit create()
Append a new object to the collection, and return this object.
Definition: CalorimeterHitCollection.cc:52
void setSubsetCollection(bool setSubset=true) final
Definition: CalorimeterHitCollection.cc:41
Definition: CalorimeterHitCollection.h:35
bool operator!=(const CalorimeterHitCollectionIterator &x) const
Definition: CalorimeterHitCollection.h:42
CalorimeterHitCollectionIterator(const CalorimeterHitCollectionIterator &)=delete
CalorimeterHitCollectionIterator & operator=(const CalorimeterHitCollectionIterator &)=delete
CalorimeterHit * operator->()
Definition: CalorimeterHitCollection.cc:152
CalorimeterHit operator*()
Definition: CalorimeterHitCollection.cc:147
CalorimeterHitCollectionIterator(size_t index, const CalorimeterHitObjPointerContainer *collection)
Definition: CalorimeterHitCollection.h:37
CalorimeterHitCollectionIterator & operator++()
Definition: CalorimeterHitCollection.cc:157
Definition: CalorimeterHit.h:27
Definition: CalorimeterHitCollection.h:57
CalorimeterHitMutableCollectionIterator(size_t index, const CalorimeterHitObjPointerContainer *collection)
Definition: CalorimeterHitCollection.h:59
bool operator!=(const CalorimeterHitMutableCollectionIterator &x) const
Definition: CalorimeterHitCollection.h:64
CalorimeterHitMutableCollectionIterator & operator=(const CalorimeterHitMutableCollectionIterator &)=delete
CalorimeterHitMutableCollectionIterator(const CalorimeterHitMutableCollectionIterator &)=delete
MutableCalorimeterHit * operator->()
Definition: CalorimeterHitCollection.cc:169
MutableCalorimeterHit operator*()
Definition: CalorimeterHitCollection.cc:164
CalorimeterHitMutableCollectionIterator & operator++()
Definition: CalorimeterHitCollection.cc:174
Definition: CalorimeterHitObj.h:17
Definition: MutableCalorimeterHit.h:28
Definition: CalorimeterHit.cc:13
std::deque< CalorimeterHitObj * > CalorimeterHitObjPointerContainer
Definition: CalorimeterHitCollectionData.h:20
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition: CalorimeterHit.cc:93