CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CastorCtdcUnpacker Class Reference

#include <CastorCtdcUnpacker.h>

Public Member Functions

 CastorCtdcUnpacker (int sourceIdOffset, int beg, int end)
 for normal data More...
 
void unpack (const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report)
 

Private Attributes

int endSample_
 last sample from fed raw data to copy (if present) More...
 
int sourceIdOffset_
 number to subtract from the source id to get the dcc id More...
 
int startSample_
 first sample from fed raw data to copy More...
 
std::set< CastorElectronicsIdunknownIds_
 
std::set< CastorElectronicsIdunknownIdsTrig_
 Recorded to limit number of times a log message is generated. More...
 

Detailed Description

Definition at line 14 of file CastorCtdcUnpacker.h.

Constructor & Destructor Documentation

CastorCtdcUnpacker::CastorCtdcUnpacker ( int  sourceIdOffset,
int  beg,
int  end 
)

for normal data

Definition at line 12 of file CastorCtdcUnpacker.cc.

References end, endSample_, CastorDataFrame::MAXSAMPLES, and startSample_.

12  : sourceIdOffset_(sourceIdOffset)
13 {
14  if ( beg >= 0 && beg <= CastorDataFrame::MAXSAMPLES -1 ) {
15  startSample_ = beg;
16  } else {
17  startSample_ = 0;
18  }
19  if ( end >= 0 && end <= CastorDataFrame::MAXSAMPLES -1 && end >= beg ) {
20  endSample_ = end;
21  } else {
23  }
24 }
int endSample_
last sample from fed raw data to copy (if present)
int sourceIdOffset_
number to subtract from the source id to get the dcc id
int startSample_
first sample from fed raw data to copy
#define end
Definition: vmac.h:37
static const int MAXSAMPLES

Member Function Documentation

void CastorCtdcUnpacker::unpack ( const FEDRawData raw,
const CastorElectronicsMap emap,
CastorRawCollections conts,
HcalUnpackerReport report 
)

work through all channels

Definition at line 27 of file CastorCtdcUnpacker.cc.

References CastorRawCollections::castorCont, CastorCORData::CHANNELS_PER_SPIGOT, CastorCORData::check(), HcalUnpackerReport::countSpigotFormatError(), HcalUnpackerReport::countUnmappedDigi(), FEDRawData::data(), endSample_, newFWLiteAna::found, CastorCORData::getNPS(), CastorCTDCHeader::getSourceId(), CastorCTDCHeader::getSpigotData(), CastorCTDCHeader::getSpigotPresent(), CastorCORData::isHistogramEvent(), CastorElectronicsMap::lookup(), CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL, compare_using_db::sample, CastorDataFrame::setPresamples(), CastorDataFrame::setSample(), CastorDataFrame::setSize(), FEDRawData::size(), sourceIdOffset_, CastorCTDCHeader::SPIGOT_COUNT, startSample_, unknownIds_, and CastorCORData::unpack().

Referenced by CastorRawToDigi::produce().

28  {
29 
30  if (raw.size()<16) {
31  edm::LogWarning("Invalid Data") << "Empty/invalid DCC data, size = " << raw.size();
32  return;
33  }
34 
35  // get the CTDC header
36  const CastorCTDCHeader* ctdcHeader=(const CastorCTDCHeader*)(raw.data());
37  int ctdcid=ctdcHeader->getSourceId()-sourceIdOffset_;
38 
39  // space for unpacked data from one COR
42  std::vector<unsigned char> preclen(CastorCORData::CHANNELS_PER_SPIGOT);
43  std::vector<unsigned char> triglen(CastorCORData::CHANNELS_PER_SPIGOT);
44 
45  // walk through the COR data...
46  CastorCORData cor;
47  for (int spigot=0; spigot<CastorCTDCHeader::SPIGOT_COUNT; spigot++) {
48  if (!ctdcHeader->getSpigotPresent(spigot)) continue;
49 
50  int retval=ctdcHeader->getSpigotData(spigot,cor,raw.size());
51  if (retval!=0) {
52  if (retval==-1) {
53  edm::LogWarning("Invalid Data") << "Invalid COR data (data beyond payload size) observed on spigot " << spigot << " of CTDC with source id " << ctdcHeader->getSourceId();
54  report.countSpigotFormatError();
55  }
56  continue;
57  }
58  // check
59  if (!cor.check()) {
60  edm::LogWarning("Invalid Data") << "Invalid COR data observed on spigot " << spigot << " of CTDC with source id " << ctdcHeader->getSourceId();
61  report.countSpigotFormatError();
62  continue;
63  }
64  if (cor.isHistogramEvent()) {
65  edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot << " of CTDC with source id " << ctdcHeader->getSourceId();
66  continue;
67 
68  }
69  // calculate "real" number of presamples
70  int nps=cor.getNPS()-startSample_;
71 
72  // new: do not use get pointers .. instead make use of CastorCORData::unpack
73 
74  cor.unpack(&(preclen[0]),&(precdata[0]),
75  &(triglen[0]),&(trigdata[0]));
76 
77 
79  int ichan;
80  for ( ichan = 0; ichan<CastorCORData::CHANNELS_PER_SPIGOT; ichan++) {
81  if ( preclen[ichan] == 0 || preclen[ichan] & 0xc0 ) continue;
82  int fiber = ichan/3;
83  int fiberchan = ichan%3;
84  // lookup the right channel
85  CastorElectronicsId partialEid(fiberchan,fiber+1,spigot,ctdcid);
86  // does this partial id exist?
88  HcalGenericDetId did;
89  bool found;
90  found = emap.lookup(partialEid,eid,did);
91 
92  if (found) {
94  // set parameters - presamples
95  digi.setPresamples(nps);
96 
97  int ntaken = 0;
98  for ( int sample = startSample_; sample <= endSample_; sample++ ) {
99  digi.setSample(ntaken,precdata[ichan*CastorCORData::MAXIMUM_SAMPLES_PER_CHANNEL+sample]);
100  ntaken++;
101  }
102  digi.setSize(ntaken);
103  colls.castorCont->push_back(digi);
104  } else {
105  report.countUnmappedDigi();
106  if (unknownIds_.find(partialEid)==unknownIds_.end()) {
107  edm::LogWarning("CASTOR") << "CastorCtdcUnpacker: No match found for electronics partialEid :" << partialEid;
108  unknownIds_.insert(partialEid);
109  }
110  }
111  }
112 
113  }
114 }
int getSpigotData(int nspigot, CastorCORData &decodeTool, int validSize) const
int getNPS() const
Get the number of presamples in daq data.
static const int CHANNELS_PER_SPIGOT
Definition: CastorCORData.h:16
void setSample(int i, const HcalQIESample &sam)
std::set< CastorElectronicsId > unknownIds_
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.
static const int SPIGOT_COUNT
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const DetId lookup(CastorElectronicsId fId) const
lookup the logical detid associated with the given electronics id
int endSample_
last sample from fed raw data to copy (if present)
static const int MAXIMUM_SAMPLES_PER_CHANNEL
Definition: CastorCORData.h:17
int sourceIdOffset_
number to subtract from the source id to get the dcc id
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
int startSample_
first sample from fed raw data to copy
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
void setPresamples(int ps)
int getSourceId() const
void setSize(int size)

Member Data Documentation

int CastorCtdcUnpacker::endSample_
private

last sample from fed raw data to copy (if present)

Definition at line 23 of file CastorCtdcUnpacker.h.

Referenced by CastorCtdcUnpacker(), and unpack().

int CastorCtdcUnpacker::sourceIdOffset_
private

number to subtract from the source id to get the dcc id

Definition at line 21 of file CastorCtdcUnpacker.h.

Referenced by unpack().

int CastorCtdcUnpacker::startSample_
private

first sample from fed raw data to copy

Definition at line 22 of file CastorCtdcUnpacker.h.

Referenced by CastorCtdcUnpacker(), and unpack().

std::set<CastorElectronicsId> CastorCtdcUnpacker::unknownIds_
private

Definition at line 24 of file CastorCtdcUnpacker.h.

Referenced by unpack().

std::set<CastorElectronicsId> CastorCtdcUnpacker::unknownIdsTrig_
private

Recorded to limit number of times a log message is generated.

Definition at line 24 of file CastorCtdcUnpacker.h.