15 template <
class Coll,
class DetIdClass>
17 if (pt==
nullptr)
return 0;
19 typename Coll::const_iterator
i=pt->find(DetIdClass(did));
21 presamples=i->presamples();
23 for (
int j=0; j<
size; j++)
24 buffer[j]=(*i)[j].raw();
31 unsigned short* buffer,
int &presamples) {
43 int nl1a,
int orbitn,
int bcn,
57 spigots[spigot].
allocate(CORFormatVersion);
61 for (
int fiber=1; fiber<=12; fiber++)
62 for (
int fiberchan=0; fiberchan<3; fiberchan++) {
63 int linear=(fiber-1)*3+fiberchan;
71 if (!emap.
lookup(partialEid,fullEid,genId))
continue;
76 int mysamples=findSamples(genId,inputs,database,mypresamples);
80 edm::LogError(
"CASTOR") <<
"Mismatch of samples in a single COR (unsupported) " << mysamples <<
" != " <<
samples;
84 presamples=mypresamples;
86 }
else if (mypresamples!=presamples) {
87 edm::LogError(
"CASTOR") <<
"Mismatch of presamples in a single COR (unsupported) " << mypresamples <<
" != " <<
presamples;
97 spigots[spigot].
pack(&(preclen[0]),&(precdata[0]),
98 &(triglen[0]),&(trigdata[0]),
103 submodule|=(exampleEId.
htrSlot()&0x1F)<<1;
118 for (
int spigot=0; spigot<2; spigot++) {
119 theSize+=spigots[spigot].
getRawLength()*
sizeof(
unsigned short);
124 theSize+=mergerdata.
getRawLength()*
sizeof(
unsigned short);
127 theSize+=(8-(theSize%8))%8;
136 for (
int spigot=0; spigot<2; spigot++) {
137 if (spigots[spigot].getRawLength()>0)
static const int CHANNELS_PER_SPIGOT
void pack(unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples, bool do_capid=false)
Unpack the HTR data into TP and DAQ data sorted by channel.
int readoutVMECrateId() const
const int getRawLength() const
Get the length of the raw data.
void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int orbitn, int pipeline, int ndd, int nps, int firmwareRev=0)
pack header and trailer (call after pack)
const CastorDigiCollection * castorCont
size_t size() const
Lenght of the data buffer in bytes.
static void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
void resize(size_t newsize)
static const int MAXIMUM_SAMPLES_PER_CHANNEL
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
void allocate(int version_to_create=0)
const int getRawLength() const
Get the length of the raw data.
static int findSamples(const DetId &did, const CastorCollections &inputs, unsigned short *buffer, int &presamples)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
constexpr Detector det() const
get the detector field from this detid