27 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
32 testCRC(conf.getParameter<unsigned
int>(
"testCRC")),
33 testID(conf.getParameter<unsigned
int>(
"testID")),
37 EC_min(conf.getUntrackedParameter<unsigned
int>(
"EC_min", 10)),
38 BC_min(conf.getUntrackedParameter<unsigned
int>(
"BC_min", 10)),
40 EC_fraction(conf.getUntrackedParameter<double>(
"EC_fraction", 0.6)),
41 BC_fraction(conf.getUntrackedParameter<double>(
"BC_fraction", 0.6)),
43 olderTotemT2FileTest(conf.getParameter<
bool>(
"useOlderT2TestFile")) {}
47 map<TotemFramePosition, RawToDigiConverter::Record> &records) {
53 for (
auto &
p :
mapping.VFATMapping) {
56 records[
p.first] = {&
p.second,
nullptr, st};
67 bool problemsPresent =
false;
68 bool stopProcessing =
false;
71 auto records_it = records.find(fr.Position());
72 if (records_it == records.end()) {
80 record.status.setMissing(
false);
81 record.status.setNumberOfClustersSpecified(
record.frame->isNumberOfClustersPresent());
82 record.status.setNumberOfClusters(
record.frame->getNumberOfClusters());
85 int rawT2 = fr.Position().getRawPosition();
86 bool isT2Frame = (rawT2 >> 18);
91 problemsPresent =
true;
94 fes <<
" invalid footprint" << endl;
97 record.status.setFootprintError();
98 stopProcessing =
true;
105 problemsPresent =
true;
108 fes <<
" CRC failure" << endl;
111 record.status.setCRCError();
112 stopProcessing =
true;
118 (
record.frame->getChipID() & 0xFFF) != (
record.info->hwID & 0xFFF)) {
120 fes <<
" ID mismatch (data: 0x" << hex <<
record.frame->getChipID() <<
", mapping: 0x" <<
record.info->hwID
121 <<
dec <<
", symbId: " <<
record.info->symbolicID.symbolicID <<
")" << endl;
124 record.status.setIDMismatch();
125 stopProcessing =
true;
131 string message = (stopProcessing) ?
"(and will be dropped)" :
"(but will be used though)";
135 ees <<
" Frame at " << fr.Position() <<
" seems corrupted " << message <<
":" << endl;
138 ees <<
" Frame at " << fr.Position() <<
" seems corrupted " << message <<
"." << endl;
146 if (fr.Data()->isECPresent())
147 ECChecker.
Fill(fr.Data()->getEC(), fr.Position());
149 if (fr.Data()->isBCPresent())
150 BCChecker.
Fill(fr.Data()->getBC(), fr.Position());
162 for (
const auto &
p : records) {
163 if (
p.second.status.isMissing())
164 ees <<
"Frame for VFAT " <<
p.first <<
" is not present in the data." << endl;
169 if (
verbosity > 0 && !ees.rdbuf()->str().empty()) {
171 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::runCommon > " 172 <<
"event contains the following problems:" << endl
173 << ees.rdbuf() << endl;
175 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::runCommon > " 176 <<
"event contains problems." << endl;
181 for (
const auto &
it : records) {
182 if (!
it.second.status.isOK()) {
184 m[
it.second.status]++;
196 map<TotemFramePosition, Record> records;
202 for (
auto &
p : records) {
207 uint8_t chipPosition = chipId.
chip();
211 record.status.setChipPosition(chipPosition);
214 if (
record.status.isOK()) {
222 anMa = analysisIter->second;
224 record.status.setFullyMaskedOut();
226 record.status.setPartiallyMaskedOut();
230 unsigned short offset = chipPosition * 128;
231 const vector<unsigned char> &activeChannels =
record.frame->getActiveChannels();
233 for (
auto ch : activeChannels) {
254 map<TotemFramePosition, Record> records;
260 for (
auto &
p : records) {
266 if (
record.status.isOK()) {
291 map<TotemFramePosition, Record> records;
297 for (
auto &
p : records) {
299 if (!
record.status.isOK())
315 auto channelwaveformPtr = records.find(frameposdata);
316 auto eventInfoPtr = records.find(frameposEvtInfo);
318 if (channelwaveformPtr != records.end() && eventInfoPtr != records.end()) {
319 Record &channelwaveform = records[frameposdata];
325 (
const uint8_t *)
eventInfo.frame->getData());
327 if (totemSampicFrame.valid()) {
330 totemSampicFrame.getL1ATimestamp(),
331 totemSampicFrame.getBunchNumber(),
332 totemSampicFrame.getOrbitNumber(),
333 totemSampicFrame.getEventNumber(),
334 totemSampicFrame.getChannelMap(),
335 totemSampicFrame.getL1ALatency(),
336 totemSampicFrame.getNumberOfSentSamples(),
337 totemSampicFrame.getOffsetOfSamples(),
338 totemSampicFrame.getPLLInfo());
340 totemSampicFrame.getFPGATimestamp(),
341 totemSampicFrame.getTimestampA(),
342 totemSampicFrame.getTimestampB(),
343 totemSampicFrame.getCellInfo(),
344 totemSampicFrame.getSamples(),
349 mapping.getTimingChannel(totemSampicFrame.getHardwareId());
351 if (totemSampicFrame.getFWVersion() == 0)
355 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::TotemTiming > " 356 <<
"HwId not recognized! hwId: " << std::hex
357 << (
unsigned int)totemSampicFrame.getHardwareId() << endl;
364 const int HWplane = totemSampicFrame.getDetPlane() % 16;
365 const int HWchannel = totemSampicFrame.getDetChannel() % 16;
369 LogWarning(
"Totem") <<
"Warning in RawToDigiConverter::TotemTiming > " 370 <<
"HwId not recognized! hwId: " << std::hex
371 << (
unsigned int)totemSampicFrame.getHardwareId()
372 <<
"\tUsing plane and ch from HW without check!" << endl;
375 LogWarning(
"Totem") <<
"Warning in RawToDigiConverter::TotemTiming > " 376 <<
"Hw mapping different from SW mapping. hwId: " << std::hex
377 << (
unsigned int)totemSampicFrame.getHardwareId() <<
"HW: " <<
std::dec << HWplane
378 <<
":" << HWchannel <<
"\tSW " << SWpair.
plane <<
":" << SWpair.
channel 379 <<
"\tUsing plane and ch from HW!" << endl;
381 detId.setPlane(HWplane % 4);
382 detId.setChannel(HWchannel);
399 map<TotemFramePosition, Record> records;
410 for (
auto &
p : records) {
417 if (
record.status.isOK()) {
422 LogWarning(
"Totem") <<
"RawToDigiConverter: VFAT frame number " << allT2
423 <<
" is OK , mapping HW_ID (decimal) is: " << (
record.info->hwID)
424 <<
", T2DetId arm/plane/channel = " << (
detId) << endl;
425 LogWarning(
"Totem") <<
"HW_id_16b CH0 (dec), LE CH0, TE CH0, marker CH0, HW_id_16b CH1 (dec), LE CH1," 426 <<
" TE CH1, marker CH1 = ";
427 for (
size_t y = 0;
y < 2;
y++) {
436 hw_id ==
record.info->hwID) {
447 LogWarning(
"Totem") <<
"HW_ID comparison fail (CH#/Channel HwID/Mapping HwID): " << ((
int)frame_id) <<
"/" 448 << ((
unsigned int)hw_id) <<
"/" << (
record.info->hwID) << endl;
453 LogWarning(
"Totem") <<
"Bad T2 record, is missing/IDmismatch/footprintError" 454 <<
"/CRCerror/ECprogressBad/BCprogressBad: " <<
record.status.isMissing() <<
"/" 455 <<
record.status.isIDMismatch() <<
"/" <<
record.status.isFootprintError() <<
"/" 456 <<
record.status.isCRCError() <<
"/" <<
record.status.isECProgressError() <<
"/" 457 <<
record.status.isBCProgressError() <<
"/" << endl;
465 LogWarning(
"Totem") <<
"RawToDigiConverter:: VFAT frames per event, total/good/matched the xml mapping" 466 <<
" (T2Digi created): " << allT2 <<
"/" << goodT2 <<
"/" << foundT2 << endl;
475 ees << vit.first << endl;
477 for (
const auto &
it : vit.second)
478 ees <<
" " <<
it.first <<
" : " <<
it.second << endl;
481 LogWarning(
"Totem") <<
"RawToDigiConverter: error summary (error signature : number of such events)\n" 485 LogInfo(
"Totem") <<
"RawToDigiConverter: no errors to be reported.";
494 ees <<
" " <<
it.first <<
" : " <<
it.second << endl;
497 <<
"RawToDigiConverter: frames found in data, but not in the mapping (frame position : number of events)\n" 501 LogInfo(
"Totem") <<
"RawToDigiConverter: no unknown frames to be reported.";
Detector ID class for TOTEM Si strip detectors.
const unsigned int testID
uint32_t getLeadingEdgeTime(const VFATFrame &frame)
get timing information for single leading edge
Contains data on masked channels of a VFAT.
const unsigned int testCRC
void push_back(const T &t)
VFATFrame::word * getData()
void runCommon(const VFATFrameCollection &input, const TotemDAQMapping &mapping, std::map< TotemFramePosition, Record > &records)
Common processing for all VFAT based sub-systems.
Class for finding the most popular both EC and BC counter, and filling the conversion status 'wrong E...
Detector ID class for Totem T2 detectors. Bits [19:31] : Base CTPPSDetId class attributes Bits [16:18...
uint16_t leadingEdgeTime(const VFATFrame &frame, size_t ch_id)
get timing information for single leading edge
const unsigned int BC_min
void Analyze(T &status, bool error, std::ostream &es)
summarizes and fill the status (wrong EC and BC progress error for some frames)
RawToDigiConverter(const edm::ParameterSet &conf)
const unsigned int testFootprint
flags for which tests to run
const unsigned char verbosity
std::map< TotemSymbID, TotemVFATAnalysisMask > analysisMask
unsigned short getOptoRxId() const
static std::string const input
reference find_or_insert(det_id_type id)
uint16_t trailingEdgeTime(const VFATFrame &frame, size_t ch_id)
get timing information for single trailing edge
VFATFrame::word getMultihit(const VFATFrame &frame)
flag stating whether the HPTDC channel encountered multiple hits
uint32_t getTrailingEdgeTime(const VFATFrame &frame)
get timing information for single trailing edge
const double EC_fraction
the minimal required (relative) occupancy of the most frequent counter value to be accepted ...
const bool printErrorSummary
const unsigned int testECMostFrequent
uint16_t newChannelId(const VFATFrame &frame, size_t ch_id)
retrieve the HW identifier for this channel, in firmware >2.1
VFATFrame::word getHptdcErrorFlag(const VFATFrame &frame)
retrieve the list of error/status flags for the HPTDC when the frame was recorded ...
the VFATFrameCollection interator
unsigned short getSubSystemId() const
the getters and setters below are deprecated
decltype(auto) emplace_back(Args &&... args)
The mapping between FramePosition and VFATInfo.
uint32_t getThresholdVoltage(const VFATFrame &frame)
retrieve the threshold voltage for this channel
unsigned short getTOTFEDId() const
const unsigned int EC_min
the minimal required number of frames to determine the most frequent counter value ...
const bool olderTotemT2FileTest
bool fullMask
whether all channels of the VFAT shall be masked
unsigned short getGOHId() const
void setMissing(bool val=true)
Hw Id mapping for Totem Timing (dynamical mapping in Sampic)
uint8_t statusMarker(const VFATFrame &frame)
retrieve the header status flags
Log< level::Info, false > LogInfo
TotemRPDetId planeId() const
std::map< TotemFramePosition, unsigned int > unknownSummary
const bool printUnknownFrameSummary
static constexpr size_t num_channels_per_payload
multiplicity of channels combined into a single payload
const unsigned int testBCMostFrequent
unsigned short getIdxInFiber() const
void Fill(word counter, TotemFramePosition fr)
add new value to map, counter takes value of EC or BC number
void printSummaries() const
Print error summaries.
std::set< unsigned char > maskedChannels
list of channels to be masked
std::map< TotemFramePosition, std::map< TotemVFATStatus, unsigned int > > errorSummary
error summaries
uint8_t channelMarker(const VFATFrame &frame, size_t ch_id)
retrieve this channel marker
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
bool IsEnd()
returns whether the iterator points over the end of the collection
eventInfo
add run, event number and lumi section
Log< level::Warning, false > LogWarning
void run(const VFATFrameCollection &coll, const TotemDAQMapping &mapping, const TotemAnalysisMask &mask, edm::DetSetVector< TotemRPDigi > &digi, edm::DetSetVector< TotemVFATStatus > &status)
Creates RP digi.
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...