|
ATLAS Offline Software
|
Go to the documentation of this file.
13 #include "AthLinks/ElementLink.h"
37 cell_t (
int the_cell = 0,
52 const float NWEIGHT_SCALE = 1000;
55 const int INDEX_BITS = 18;
58 const unsigned int INDEX_MASK = (1<<INDEX_BITS) - 1;
61 const int ISEQ_BITS = 32 - INDEX_BITS;
64 const unsigned int ISEQ_MAX = (1 << ISEQ_BITS) - 1;
89 "CaloCellLinkContainerCnv_p2")
90 <<
"Inconsistent sequence array lengths: "
97 std::vector<unsigned>::const_iterator cIterI = pers->
m_linkI.begin();
98 std::vector<unsigned>::const_iterator cIterIe = pers->
m_linkI.end();
99 std::vector<float>::const_iterator cIterW = pers->
m_linkW.begin();
100 std::vector<float>::const_iterator cIterWe = pers->
m_linkW.end();
102 for (
unsigned int iCluster=0; iCluster<pers->
m_nClusters; iCluster++) {
104 std::vector<float>::const_iterator cIterWb = cIterW;
108 trans->
at(iCluster)=lnk;
114 unsigned int ncells = 0;
115 for(
unsigned iCell=0; iCell<pers->
m_vISizes[iCluster]; iCell++) {
116 if (cIterI >= cIterIe) {
118 "CaloCellLinkContainerCnv_p2")
119 <<
"Cell index array overrun";
123 ncells += (*(cIterI+iCell)) >> INDEX_BITS;
125 if (ncells > 1000) ncells = 1000;
128 for(
unsigned iCell=0; iCell<pers->
m_vISizes[iCluster]; iCell++) {
129 unsigned int compositeI = *cIterI++;
130 unsigned int realI = compositeI & INDEX_MASK;
131 unsigned int lSEQ = compositeI>>INDEX_BITS;
134 if (cIterW >= cIterWe) {
136 "CaloCellLinkContainerCnv_p2")
137 <<
"Cell weight array overrun";
141 float compositeW = *cIterW++;
142 nw =
static_cast<unsigned int> (compositeW*(1./NWEIGHT_SCALE));
143 weight = compositeW - (nw*NWEIGHT_SCALE);
154 "CaloCellLinkContainerCnv_p2")
155 <<
"Weight/index arrays out of sync";
159 if (cIterW - cIterWb !=
static_cast<int> (pers->
m_vWSizes[iCluster])) {
161 "CaloCellLinkContainerCnv_p2")
162 <<
"Wrong number of weight sequences";
169 "CaloCellLinkContainerCnv_p2")
170 <<
"Missing cell container name";
176 "CaloCellLinkContainerCnv_p2")
177 <<
"Discarding cluster cells";
197 unsigned int nclus = trans->
size();
206 pers->
m_linkI.reserve (5*nclus);
207 pers->
m_linkW.reserve (5*nclus);
216 std::vector<cell_t>
cells;
217 for (
unsigned int iCluster = 0; iCluster < nclus; ++iCluster) {
227 for (;it_cell!=it_cell_e;it_cell++) {
229 it_cell.getInternalIterator();
232 float weight = citer->second;
234 if (fabs (
weight) > NWEIGHT_SCALE) {
236 "CaloCellLinkContainerCnv_p2")
237 <<
"Crazy cluster cell weight " <<
weight
242 size_t index = citer->first.index();
247 thinningCache->
thinning (citer->first.key());
267 pers->
m_contName = *citer->first.source()->keyToString (
key);
270 else if (first_key !=
key) {
272 "CaloCellLinkContainerCnv_p2")
273 <<
"Multiple container names seen; "
274 <<
"cannot be persistified correctly: "
276 <<
" != " << *citer->first.source()->keyToString (
key)
281 if ((
index & ~INDEX_MASK) != 0) {
283 "CaloCellLinkContainerCnv_p2")
284 <<
"Bad cell index " <<
index
285 <<
" had high bits masked off.";
294 unsigned int& nlseq = pers->
m_vISizes[iCluster];
295 unsigned int& nwseq = pers->
m_vWSizes[iCluster];
298 int last_cell = -9999;
299 float last_weight = -9999;
300 unsigned int nl_in_seq = 0;
301 unsigned int nw_in_seq = 0;
304 cells.push_back (cell_t (-99999, -99999));
306 size_t ncells =
cells.size();
307 for (
size_t i = 0;
i < ncells; ++
i) {
310 if (
static_cast<int>(last_cell + nl_in_seq) ==
cell.cell &&
311 nl_in_seq < ISEQ_MAX)
317 pers->
m_linkI.push_back (last_cell | (nl_in_seq << INDEX_BITS));
320 last_cell =
cell.cell;
334 float w1 = (nw_in_seq+1)*NWEIGHT_SCALE + last_weight;
335 float w2 = (nw_in_seq+1)*NWEIGHT_SCALE +
cell.weight;
337 if (
equal (nextafterf (w1, w2), w2) && nw_in_seq < 255)
343 pers->
m_linkW.push_back (nw_in_seq*NWEIGHT_SCALE + last_weight);
346 last_weight =
cell.weight;
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
bool operator<(const DataVector< T > &a, const DataVector< T > &b)
Vector ordering relation.
std::vector< unsigned > m_vISizes
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
Hold thinning decisions for one container.
void insertElement(const CONT *objectContainer, const constituent_type *constituentObject, const RPAR &objectParameter=RPAR(), size_t sizeHint=0)
Container class for CaloCellLink.
virtual object_iter begin() const
Hold thinning decisions for one container.
virtual object_iter end() const
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
std::vector< unsigned > m_linkI
virtual void persToTransWithKey(const CaloCellLinkContainer_p2 *pers, CaloCellLinkContainer *trans, const std::string &key, MsgStream &log) const override
Convert from persistent to transient object.
std::vector< float > m_linkW
Simple store for CaloCell links. This object is fully navigable.
std::vector< unsigned > m_vWSizes
Workaround x86 precision issues for FP inequality comparisons.
virtual void transToPersWithKey(const CaloCellLinkContainer *trans, CaloCellLinkContainer_p2 *pers, const std::string &key, MsgStream &log) const override
Convert from transient to persistent object.
Helpers to retrieve the current thinning cache from the event context.
Navigable< CaloCellContainer, double >::object_iter cell_iterator
Forward internal iterator type to clients.
static const std::size_t RemovedIdx
Flag used to show that an index has been thinned away.
const SG::ThinningCache * getThinningCache(const EventContext &ctx)
Retrieve the current thinning cache from the event context.
void clear()
Erase all the elements in the collection.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
void resize(size_type sz)
Resizes the collection to the specified number of elements.
Helpers for checking error return status codes and reporting errors.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Navigable template generalization to handle navigation.
size_t index(size_t ndxOrig) const
Return the index corresponding to ndxOrig after thinning.
const ThinningDecisionBase * thinning(const std::string &key) const
Return thinning for key.
virtual unsigned int size() const
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
const T * at(size_type n) const
Access an element, as an rvalue.
Cache thinning decisions for converters.
size_type size() const noexcept
Returns the number of elements in the collection.