File indexing completed on 2026-04-07 08:08:32
0001 #include "ClusterSmallInfoContainer.h"
0002
0003 #include <iostream>
0004 #include <stdexcept>
0005 #include <bitset>
0006
0007 ClusterSmallInfoContainer::ClusterSmallInfoContainer()
0008 {
0009 _clones = new TClonesArray("ClusterSmallInfo", 50);
0010 _clones->SetOwner();
0011 _clones->SetName("ClusterSmallInfoContainer");
0012
0013 for (int i = 0; i < 50; ++i)
0014 {
0015
0016
0017 _clones->ConstructedAt(i, "C");
0018 }
0019 }
0020
0021 ClusterSmallInfoContainer::~ClusterSmallInfoContainer()
0022 {
0023 delete _clones;
0024 }
0025
0026 void ClusterSmallInfoContainer::Reset()
0027 {
0028 _size = 0;
0029 _live_trigger = 0;
0030 _scaled_trigger = 0;
0031 _bunchnumber = 0;
0032
0033
0034
0035
0036
0037 for (Int_t i = 0; i < _clones->GetEntriesFast(); ++i)
0038 {
0039 TObject* obj = _clones->UncheckedAt(i);
0040
0041 if (obj == nullptr)
0042 {
0043 std::cout << __PRETTY_FUNCTION__ << " Fatal access error:"
0044 << " _clones->GetSize() = " << _clones->GetSize()
0045 << " _clones->GetEntriesFast() = " << _clones->GetEntriesFast()
0046 << " i = " << i << std::endl;
0047 _clones->Print();
0048 }
0049
0050 assert(obj);
0051
0052 obj->Clear();
0053 obj->ResetBit(kHasUUID);
0054 obj->ResetBit(kIsReferenced);
0055 obj->SetUniqueID(0);
0056 }
0057 }
0058
0059 void ClusterSmallInfoContainer::identify(std::ostream &os) const
0060 {
0061 os << "ClusterSmallInfoContainer: live trigger = " << std::bitset<64>(_live_trigger) << std::endl;
0062 os << "ClusterSmallInfoContainer: scaled trigger = " << std::bitset<64>(_scaled_trigger) << std::endl;
0063 os << "ClusterSmallInfoContainer: bunchnumber = " << _bunchnumber << std::endl;
0064
0065 os << "ClusterSmallInfoContainer: size = " << _size << std::endl;
0066 for (size_t i = 0; i < _size; i++) {
0067 const ClusterSmallInfo *csi = get_cluster_at(i);
0068 csi->identify(os);
0069 }
0070 }
0071
0072 bool ClusterSmallInfoContainer::add_cluster(const float& eta,
0073 const float& phi,
0074 const float& ecore,
0075 const float& energy,
0076 const float& chi2)
0077 {
0078 if (_size >= 50)
0079 {
0080 std::cout << "ClusterSmallInfoContainer::_size has already reached its maximum (50). Next cluster won't be filled." << std::endl;
0081 return false;
0082 }
0083
0084 ClusterSmallInfo *csi = (ClusterSmallInfo*) _clones->ConstructedAt(_size);
0085 csi->set(eta, phi, ecore, energy, chi2);
0086 _size++;
0087
0088 return true;
0089 }
0090
0091 ClusterSmallInfo* ClusterSmallInfoContainer::get_cluster_at(int pos)
0092 {
0093 return (ClusterSmallInfo*) _clones->At(pos);
0094 }
0095
0096 const ClusterSmallInfo* ClusterSmallInfoContainer::get_cluster_at(int pos) const
0097 {
0098 return (ClusterSmallInfo*) _clones->At(pos);
0099 }
0100
0101 void ClusterSmallInfoContainer::compress()
0102 {
0103
0104 _clones->ExpandCreateFast(_size);
0105 }