Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
24 #include "GaudiKernel/SystemOfUnits.h"
132 pars.m_nseq_max = 0x3fff;
136 pars.m_prov_max = 0x1fff;
137 pars.m_prov_max_tile = 0x1f1f;
140 pars.m_cbrt_e1_norm_res = cbrt(
static_cast<double>(
pars.m_e1_norm_res));
141 pars.m_cbrt_e1_high_res = cbrt(
static_cast<double>(
pars.m_e1_high_res));
142 pars.m_cbrt_low_tile = cbrt(
static_cast<double>(
pars.m_low_tile));
143 pars.m_cbrt_high_tile = cbrt(
static_cast<double>(
pars.m_high_tile));
146 pars.m_log_t0 =
log(
static_cast<double>(
pars.m_t0));
147 pars.m_log_t1 =
log(
static_cast<double>(
pars.m_t1));
152 pars.m_crtae_norm_field =
154 pars.m_cbrt_e1_norm_res);
155 pars.m_crtae_high_field =
157 pars.m_cbrt_e1_high_res);
161 pars.m_egain_tile_field =
163 pars.m_crtae_tile_high_field =
165 pars.m_cbrt_high_tile);
166 pars.m_crtae_tile_low_field =
168 pars.m_cbrt_low_tile);
175 pars.m_egain_field.in (
pars.m_enhig) |
176 pars.m_qualy_field.in (
pars.m_qabad) |
177 pars.m_crtae_norm_field.in (cbrt (
pars.m_e1_norm_res)) |
181 pars.m_egain_tile_field.in (
pars.m_glow) |
182 pars.m_qualy_field.in (
pars.m_qabad) |
183 pars.m_crtae_tile_high_field.in (
pars.m_cbrt_high_tile) |
184 pars.m_esign_tile_mask;
189 pars.m_lar_dummy_subst = (
pars.m_lar_dummy & ~
pars.m_crtae_mask) |
193 pars.m_tile_dummy_subst = (
pars.m_tile_dummy & ~
pars.m_crtae_tile_mask) |
194 etile.
in (etile.
out (
pars.m_tile_dummy)-1);
218 float ltime =
pars.m_log_t0;
255 if( (
cell->provenance() & 0x2000) == 0x2000 )
256 qualflag=
pars.m_qgood;
258 qualflag=
pars.m_qabad;
269 gainflag =
pars.m_enlow;
275 gainflag =
pars.m_ehhig;
279 gainflag =
pars.m_enmed;
285 gainflag =
pars.m_ehhig;
289 gainflag =
pars.m_enhig;
297 if (gainflag == -999) {
298 it.set (
pars.m_lar_dummy);
302 double crtae = cbrt(fabs(
energy));
304 (cbrt_flag ?
pars.m_crtae_high_field.in (crtae)
305 :
pars.m_crtae_norm_field.in (crtae));
314 data |=
pars.m_egain_field.in (gainflag) |
315 pars.m_qualy_field.in (qualflag);
324 if ( qualflag !=
pars.m_qabad){
326 if (
pars.m_version >= 500)
347 double ene[2] = {
cell->ene1(),
cell->ene2()};
349 int qbit[2] = {
cell->qbit1(),
cell->qbit2()};
355 bool write_qual =
false;
356 for (
int ipmt=0; ipmt<2; ++ipmt) {
358 bool write_time =
false;
371 int qualflag =
pars.m_qabad;
373 qualflag =
pars.m_qgood;
379 double crtae = cbrt(fabs(ene[ipmt]));
381 data =
pars.m_crtae_tile_high_field.in (crtae);
383 data =
pars.m_crtae_tile_low_field.in (crtae);
389 if (ene[ipmt] < 0 &&
data != 0)
394 pars.m_egain_tile_field.in (
gain[ipmt]) |
395 pars.m_qualy_field.in (qualflag);
409 if (
pars.m_version >= 502 && write_qual) {
433 pars.m_hash_field.in(
hash) |
pars.m_nseq_field.in(nseq);
436 it.set ((
data>>16) & 0xffff);
442 pars.m_ncells_larem += nseq;
446 pars.m_ncells_larhec += nseq;
450 pars.m_ncells_larfcal += nseq;
451 ++
pars.m_seq_larfcal;
454 pars.m_ncells_tile += nseq;
480 std::vector<short unsigned int> vProvenance;
496 (
packed.compact_begin_output (
pars.m_length));
501 (
packed.compact_begin_output (
pars.m_length));
504 unsigned int seqhash =
static_cast<unsigned int> (-1);
508 unsigned int nseq = 0;
514 short unsigned int prevCellProvenance=0;
530 size_t icell =
static_cast<size_t>(-1);;
548 nseq >=
pars.m_nseq_max ||
550 seqhash + nseq !=
hash ||
579 (
cell->provenance() &
pars.m_prov_max_tile) != prevCellProvenance)
581 prevCellProvenance =
cell->provenance() &
pars.m_prov_max_tile;
584 pars.m_prov_field.in(prevCellProvenance);
585 vProvenance.push_back ((
data>>16) & 0xffff);
586 vProvenance.push_back (
data & 0xffff);
594 (
cell->provenance() &
pars.m_prov_max) != prevCellProvenance)
596 prevCellProvenance =
cell->provenance() &
pars.m_prov_max;
599 pars.m_prov_field.in(prevCellProvenance);
600 vProvenance.push_back ((
data>>16) & 0xffff);
601 vProvenance.push_back (
data & 0xffff);
611 pars.m_lengthProvenance = vProvenance.size();
613 assert (outit.
used() +
pars.m_length + vProvenance.size()/2 + 1 <=
maxsize);
615 if (
pars.m_lengthProvenance > 0) {
623 if (
x!=
y) outit.
set(0);
627 for (
unsigned short & iter : vProvenance)
651 std::vector<CaloCompactCellContainer::value_type>
726 int gainflag =
pars.m_egain_field.out (
data);
727 int qualflag =
pars.m_qualy_field.out (
data);
734 if ( gainflag ==
pars.m_ehhig ) {
742 if ( gainflag ==
pars.m_enhig ) {
745 else if ( gainflag ==
pars.m_enmed ) {
748 else if ( gainflag ==
pars.m_enlow) {
762 if ( qualflag !=
pars.m_qabad ) {
764 if (
pars.m_version >= 500)
766 provenance = provenance | 0x2000;
797 bool read_qual =
false;
799 for (
int ipmt = 0; ipmt < 2; ++ipmt) {
818 int qualflag =
pars.m_qualy_field.out (
data);
819 int gainflag =
pars.m_egain_tile_field.out (
data);
821 gain[ipmt] = gainflag;
825 if (gainflag !=
pars.m_glow)
826 e =
pars.m_crtae_tile_high_field.out (
data);
828 e =
pars.m_crtae_tile_low_field.out (
data);
831 ene[ipmt] = -ene[ipmt];
834 if (qualflag !=
pars.m_qabad) {
846 if (
pars.m_version >= 502) {
847 qbit[0] |=
pars.m_tile_qual1_field.out (provenance);
848 qbit[1] |=
pars.m_tile_qual2_field.out (provenance);
851 qual[0] =
pars.m_tile_qual1_field.out (qualp);
852 qual[1] =
pars.m_tile_qual2_field.out (qualp);
882 const std::vector<int>& vheader,
891 pars.m_seq_larem = 0;
892 pars.m_seq_larhec = 0;
893 pars.m_seq_larfcal = 0;
894 pars.m_lengthProvenance = 0;
895 pars.m_ncells_tile = 0;
896 pars.m_ncells_larhec = 0;
897 pars.m_ncells_larfcal = 0;
898 pars.m_ncells_larem = 0;
901 const int* headerbeg = &*vheader.begin();
902 const int* headerend = headerbeg + vheader.size();
903 size_t nheader = headerend - headerbeg;
904 size_t parsize =
sizeof(
header) /
sizeof(
int);
905 size_t ncopy =
std::min (nheader, parsize);
906 int* parsbeg =
reinterpret_cast<int*
>(&
pars);
907 std::copy (headerbeg, headerbeg+ncopy, parsbeg);
908 if (nheader > parsize) {
912 "CaloCellPacker_400_500 ")
913 <<
"Corrupted data: Compact cell header is "
914 << nheader <<
" words long, longer than the largest expected value of "
917 else if (ncopy < parsize) {
922 std::fill (parsbeg + ncopy, parsbeg + parsize, 0);
930 unsigned nprov =
pars.m_lengthProvenance/2;
931 if (nprov + vheader.size() >
packed.getData().size()) {
933 "CaloCellPacker_400_500 ")
934 <<
"Corrupted data: Provenance count too large "
935 <<
pars.m_lengthProvenance <<
".";
936 pars.m_lengthProvenance = 0;
942 packed.compact_begin_input_from(
pars.m_lengthProvenance/2);
946 short unsigned int currProvValue=0;
948 short unsigned int nextProvValue=0;
949 if (
pars.m_lengthProvenance) {
950 unsigned int provhash = provIt.
next();
951 provhash = (provhash<<16) | provIt.
next();
952 nextProvValue =
pars.m_prov_field.out (provhash);
953 nextProvHash =
pars.m_hash_field.out (provhash);
965 throw std::runtime_error(
"Failed to initialize ReadCondHandleKey for CaloSuperCellDetDescrManager");
968 ddmgr = *caloSuperCellMgrHandle;
974 throw std::runtime_error(
"Failed to initialize ReadCondHandleKey for CaloDetDescrManager");
977 ddmgr = *caloMgrHandle;
984 pars.m_ncells_larem +
pars.m_ncells_larhec +
985 pars.m_ncells_larfcal +
pars.m_ncells_tile;
988 "CaloCellPacker_400_500 ")
989 <<
"Corrupted data: Too many cells " << totcells <<
".";
992 cells.reserve (totcells);
996 packed.compact_begin_input();
999 std::vector<CaloCompactCellContainer::value_type>::const_iterator pend =
1000 packed.getData().end() - (
pars.m_lengthProvenance+1)/2;
1003 unsigned int ncells =
1004 pars.m_ncells_larem +
1005 pars.m_ncells_larhec +
1006 pars.m_ncells_larfcal +
1008 unsigned int nseqs =
1011 pars.m_seq_larfcal +
1021 if (ncells > hashmax || nseqs > hashmax || nseqs > ncells) {
1023 "CaloCellPacker_400_500 ")
1024 <<
"Corrupted data: Bad counts"
1025 <<
": ncells " << ncells <<
" nseqs " << nseqs <<
" hashmax " << hashmax;
1034 if (
it.base() >= pend) {
1036 "CaloCellPacker_400_500 ")
1037 <<
"Corrupted data: cell vector overrun.";
1043 unsigned int hashlength =
data << 16;
1044 hashlength |=
it.next();
1046 unsigned int hash =
pars.m_hash_field.out (hashlength);
1047 unsigned int nseq =
pars.m_nseq_field.out (hashlength);
1049 if (nseq > ncells ||
hash+nseq > hashmax)
1052 "CaloCellPacker_400_500 ")
1053 <<
"Corrupted data: bad sequence. "
1054 <<
"nseq " << nseq <<
" hash " <<
hash <<
" ncells " << ncells
1055 <<
" hashmax " << hashmax;
1064 if (subcalo != prevcalo) {
1067 cells.updateCaloEndIterators (prevcalo,
cells.size());
1068 if (subcalo < prevcalo) {
1070 "CaloCellPacker_400_500 ")
1071 <<
"Cells not in subcalo order; iterators will be wrong.";
1074 cells.updateCaloBeginIterators (subcalo,
cells.size());
1076 cells.setHasCalo (subcalo);
1085 if (dde ==
nullptr) {
1087 "CaloCellPacker_400_500 ")
1088 <<
"Corrupted data: can't find DDE for cell with hash " <<
hash;
1132 if (
hash==
static_cast<unsigned int>(nextProvHash)){
1133 currProvValue = nextProvValue;
1135 unsigned int provhash = provIt.
next();
1136 provhash = (provhash<<16) | provIt.
next();
1137 nextProvValue =
pars.m_prov_field.out (provhash);
1138 nextProvHash =
pars.m_hash_field.out (provhash);
1150 pars, currProvValue));
1171 cells.updateCaloEndIterators (prevcalo,
cells.size());
1175 if (
it.base() < pend-2) {
1177 "CaloCellPacker_400_500 ")
1178 <<
"Corrupted data: didn't consume all packed data.";
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
char data[hepevt_bytes_allocation_ATLAS]
Helper for packing a float into/out of a bit field.
Helper for packing a float into/out of a bit field, with a minimum of 0.
TileCell unpack_tile(CaloCompactCellContainer::compact_input_iterator &it, const CaloDetDescrElement *dde, const pars500 &pars, uint16_t provenance) const
Unpack a tile cell.
void init_header(header &header, int version) const
Initialize header with the current version of the packing parameters.
std::vector< Identifier > ID
CaloCell_Base_ID::size_type size_type
int used() const
Return the number of underlying value_type words used.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Calo cell packer/unpacker v400/500.
int value_type
value type for the internal data
Hold thinning decisions for one container.
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
void pack_lar(const CaloCell *cell, CaloCell_ID::SUBCALO subcalo, CaloCompactCellContainer::compact_output_iterator &it, const pars500 &pars) const
Pack one LAr cell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
void clear_header(header &header) const
Clear the counters in the event header.
bool thinned(size_t ndx) const
Return true if element ndx should be thinned.
CaloCell * unpack_lar(CaloCompactCellContainer::compact_input_iterator &it, CaloCell_ID::SUBCALO subcalo, LArCell *cell, const pars500 &pars, uint16_t provenance) const
Unpack a LAr cell.
double unpack_time(CaloCompactCellContainer::compact_input_iterator &it, const pars500 &pars) const
Unpack the time word.
Hold thinning decisions for one container.
Helper for packing into/out of a bit field.
Definition of CaloDetDescrManager.
unsigned int in(unsigned int x) const
Shift and mask a value into the bitfield.
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
const CaloCell_Base_ID * get_calo_helper() const
get Calo Cell ID helper
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
H5::CompType packed(H5::CompType in)
IdentifierHash calo_hash() const
cell calo hash
container class for CaloCompactCell objects
::StatusCode StatusCode
StatusCode definition for legacy code.
const CaloCell_Base_ID * getCaloCell_ID() const
get calo cell ID helper
void unpack(const CaloCompactCellContainer &packed, const std::vector< CaloCompactCellContainer::value_type > &vheader, CaloCellContainer &cells, DataPool< LArCell > &larpool, DataPool< TileCell > &tilepool) const
Unpack cells.
void pack(const CaloCellContainer &cells, CaloCompactCellContainer &packed, const SG::ThinningDecisionBase *dec, int version) const
Pack cells.
SUBCALO
enumeration of sub calorimeters
void write_header(const header &header, CaloCompactCellContainer &packed) const
Write the header to the output container.
int sub_calo(const Identifier id) const
returns an int taken from SUBCALO enum and describing the subCalo to which the Id belongs.
void pack_time(float time, CaloCompactCellContainer::compact_output_iterator &it, const pars500 &pars) const
Pack a time value.
void init_derived(pars500 &pars) const
Initialize the derived packing parameters from the constants in the header.
void fill(H5::Group &out_file, size_t iterations)
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
header501 header
The most recent header version.
unsigned short value_type
value type for the compact CaloCell data
void finish_seq(unsigned int hash, unsigned int nseq, CaloCompactCellContainer::compact_output_iterator &it, CaloCell_ID::SUBCALO subcalo, pars500 &pars) const
Finish up one cell sequence.
Helpers for checking error return status codes and reporting errors.
Data object for LAr calorimeter readout cell.
Container class for CaloCell.
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
void set(CaloCompactCell::value_type x)
Set the next value, and advance the iterator.
unsigned int out(unsigned int x) const
Extract a value from the bitfield.
Data object for each calorimeter readout cell.
def time(flags, cells_name, *args, **kw)
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
const CaloDetDescriptor * descriptor() const
cell descriptor
Derived packing parmeters.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Helper base class for offline cell identifiers.
void pack_tile(const TileCell *cell, CaloCompactCellContainer::compact_output_iterator &it, const pars500 &pars) const
Pack one tile cell.
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
Simple iterator-like object for writing to the container.