10 template <
class Coll,
class DetIdClass>
11 int process(
const Coll*
pt,
const DetId& did,
unsigned short* buffer,
int& presamples) {
14 typename Coll::const_iterator
i=pt->find(DetIdClass(did));
16 presamples=i->presamples();
19 buffer[
j]=(*i)[
j].raw();
25 unsigned short* buffer,
int &presamples) {
31 size=process<CastorDigiCollection,HcalCastorDetId>(inputs.
castorCont,did,buffer,presamples);
37 int nl1a,
int orbitn,
int bcn,
45 static const int HTRFormatVersion=3;
49 for (
int spigot=0; spigot<15; spigot++) {
50 spigots[spigot].
allocate(HTRFormatVersion);
53 int presamples=-1, samples=-1;
54 for (
int fiber=1; fiber<=8; fiber++)
55 for (
int fiberchan=0; fiberchan<3; fiberchan++) {
56 int linear=(fiber-1)*3+fiberchan;
58 unsigned short chanid=chanSample.
raw()&0xF800;
65 if (!emap.
lookup(partialEid,fullEid,genId))
continue;
70 int mysamples=
findSamples(genId,inputs,database,mypresamples);
73 if (samples<0) samples=mysamples;
74 else if (samples!=mysamples) {
75 edm::LogError(
"CASTOR") <<
"Mismatch of samples in a single HTR (unsupported) " << mysamples <<
" != " << samples;
79 presamples=mypresamples;
81 }
else if (mypresamples!=presamples) {
82 edm::LogError(
"CASTOR") <<
"Mismatch of presamples in a single HTR (unsupported) " << mypresamples <<
" != " << presamples;
85 for (
int ii=0;
ii<samples;
ii++)
86 database[
ii]=(database[
ii]&0x7FF)|chanid;
87 preclen[linear]=(
unsigned char)(samples);
93 spigots[spigot].
pack(&(preclen[0]),&(precdata[0]),
94 &(triglen[0]),&(trigdata[0]),
96 static const int pipeline=0x22;
97 static const int firmwareRev=0;
99 submodule|=(exampleEId.
htrSlot()&0x1F)<<1;
114 for (
int spigot=0; spigot<15; spigot++) {
115 theSize+=spigots[spigot].
getRawLength()*
sizeof(
unsigned short);
118 theSize+=(8-(theSize%8))%8;
127 for (
int spigot=0; spigot<15; spigot++) {
128 if (spigots[spigot].getRawLength()>0)
uint16_t raw() const
get the raw word
int readoutVMECrateId() const
int findSamples(const DetId &did, const CastorCollections &inputs, unsigned short *buffer, int &presamples)
static const int CHANNELS_PER_SPIGOT
const CastorDigiCollection * castorCont
static const int MAXIMUM_SAMPLES_PER_CHANNEL
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
size_t size() const
Lenght of the data buffer in bytes.
void allocate(int version_to_create=0)
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
void resize(size_t newsize)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
const int getRawLength() const
Get the length of the raw data.
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.
void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
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 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] ...
Detector det() const
get the detector field from this detid
tuple size
Write out results.