5 #ifndef HTBDAQ_DATA_STANDALONE 34 const int needed=0x200;
73 if (trigger+daq+header+trailer>
m_rawLength)
return false;
101 unsigned char* tp_lengths,
unsigned short* tp_samples)
const {
104 if (tp_lengths!=
nullptr) memset(tp_lengths,0,1);
106 int tp_words_total = 0;
107 int daq_words_total = 0;
114 const unsigned short* tpBase=
m_rawConst+headerLen;
116 if (tp_lengths!=
nullptr) {
117 for (wordPtr=0; wordPtr<tp_words_total; wordPtr++) {
118 tp_samples[tp_lengths[0]]=tpBase[wordPtr];
123 const unsigned short* daqBase=
m_rawConst+headerLen+triggerLen;
128 int tsamples = daq_words_total/24;
129 if (daq_lengths!=
nullptr) {
130 for ( ts = 0; ts < tsamples; ts++ ) {
131 for (
int j=0; j<12 ; j++) {
132 dat = daqBase[(ts*12+j)*2]<<16 | daqBase[(ts*12+j)*2+1];
133 dv = ( dat & 0x80000000 ) >> 31;
142 daq_lengths[ichan]=tsamples;
143 for ( ts = 0; ts < tsamples; ts++ ) {
146 if ( erdv!=1 || ( ts!=0 && (capid!=((lastCapid+1)%4)))) {
147 daq_lengths[ichan]|=0x80;
156 unsigned char* tp_lengths,
unsigned short* tp_samples,
bool do_capid) {
158 int tp_words_total=0, daq_words_total=0, headerLen, trailerLen, triggerLen;
167 if (tp_samples!=
nullptr && tp_lengths!=
nullptr) {
168 for (isample=0; isample<tp_lengths[0] && isample<12; isample++) {
169 ptr[tp_words_total]=tp_samples[isample];
179 unsigned short s1,
s2,s3;
182 for (ts=0; ts<timesamples; ts++){
184 for (j=0; j<12 ; j++) {
186 if ( daq_lengths[j*3] == 0 || ( daq_lengths[j*3] & 0xc0 ) ) {
192 if ( daq_lengths[j*3+1] == 0 || ( daq_lengths[j*3+1] & 0xc0 ) ) {
198 if ( daq_lengths[j*3+2] == 0 || ( daq_lengths[j*3+2] & 0xc0 ) ) {
218 | ( s1 & 0x1ff ) << 21
219 | ( s2 & 0x1ff ) << 11
220 | ( s3 & 0x1ff ) << 1
221 | ( s1 & 0x400 ) << 20
222 | ( s2 & 0x400 ) << 10
224 if ( somevalid ) dat |= 0x80000000;
226 if (do_capid) dat = ( dat & 0xcff3fcff ) | capid << 28 | capid << 18 | capid << 8;
227 ptr[daq_words_total++] = dat >> 16;
228 ptr[daq_words_total++] = dat & 0xffff;
234 unsigned short totalLen=headerLen+12+daq_words_total+trailerLen;
248 m_ownData[3]=((orbitn&0x1F)<<11)|(submodule&0x7FF);
251 m_ownData[6]=((firmwareRev&0x70000)>>3)|(firmwareRev&0x1FFF);
252 m_ownData[7]=(pipeline&0xFF) | ((ndd&0x1F)<<8);
268 return ((smid>>1)&0x1F);
276 return ((smid>>6)&0x1F);
285 if (fiber<1 || fiber>8 || fiberchan<0 || fiberchan>2)
return false;
288 int shift=(((fiber-1)%4)*3)+fiberchan;
289 return ((val>>shift)&0x1)!=0;
338 if (fiber1!=myfiber && fiber2!=myfiber)
return false;
341 int offset=6+mysc*4*32+capid*32;
342 if (myfiber==fiber2) offset+=3*4*32;
343 for (
int i=0;
i<32;
i++)
347 int offset=8+mysc*4*32+capid*32;
348 if (myfiber==fiber2) offset+=3*4*32;
349 for (
int i=0;
i<32;
i++)
CastorCORData & operator=(const CastorCORData &)
int getNPS() const
Get the number of presamples in daq data.
bool isCalibrationStream() const
Is this event a calibration-stream event?
static const int CHANNELS_PER_SPIGOT
void adoptData(const unsigned short *data, int length)
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 getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
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)
void unpack(unsigned char *daq_lengths, unsigned short *daq_samples, unsigned char *tp_lengths, unsigned short *tp_samples) const
Obtain the starting and ending pointers for external unpacking of the data.
unsigned int getFirmwareRevision() const
Get the COR firmware version.
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
unsigned int getSubmodule() const
Get the HTR submodule number.
unsigned int getOrbitNumber() const
Get the HTR orbit number.
int getNTP() const
Get the number of trigger data samples when not zero-suppressed (not available after FW 4) ...
int getNPrecisionWords() const
Get the total number of precision data 16-bit words.
static const int MAXIMUM_SAMPLES_PER_CHANNEL
bool isUnsuppressed() const
Is this event an unsuppresed event?
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
unsigned int getPipelineLength() const
Get the pipeline length used for this event.
unsigned short * m_ownData
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
void allocate(int version_to_create=0)
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
char data[epos_bytes_allocation]
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
bool isPatternRAMEvent() const
Is this event a pattern-ram event?
static unsigned int const shift
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
void determineStaticLengths(int &headerWords, int &trailerWords, int &triggerWords) const
const unsigned short * m_rawConst
void determineSectionLengths(int &tpWords, int &daqWords, int &headerWords, int &trailerWords, int &triggerWords) const
Was there an error on the given fiber for this event (only in histogram mode!)