24 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
29 testCRC(conf.getParameter<unsigned
int>(
"testCRC")),
30 testID(conf.getParameter<unsigned
int>(
"testID")),
34 EC_min(conf.getUntrackedParameter<unsigned
int>(
"EC_min", 10)),
35 BC_min(conf.getUntrackedParameter<unsigned
int>(
"BC_min", 10)),
37 EC_fraction(conf.getUntrackedParameter<double>(
"EC_fraction", 0.6)),
38 BC_fraction(conf.getUntrackedParameter<double>(
"BC_fraction", 0.6)) {}
42 map<TotemFramePosition, RawToDigiConverter::Record> &records) {
48 for (
auto &
p :
mapping.VFATMapping) {
51 records[
p.first] = {&
p.second,
nullptr, st};
62 bool problemsPresent =
false;
63 bool stopProcessing =
false;
66 auto records_it = records.find(fr.Position());
67 if (records_it == records.end()) {
75 record.status.setMissing(
false);
76 record.status.setNumberOfClustersSpecified(
record.frame->isNumberOfClustersPresent());
77 record.status.setNumberOfClusters(
record.frame->getNumberOfClusters());
81 problemsPresent =
true;
84 fes <<
" invalid footprint" << endl;
87 record.status.setFootprintError();
88 stopProcessing =
true;
94 problemsPresent =
true;
97 fes <<
" CRC failure" << endl;
100 record.status.setCRCError();
101 stopProcessing =
true;
107 (
record.frame->getChipID() & 0xFFF) != (
record.info->hwID & 0xFFF)) {
109 fes <<
" ID mismatch (data: 0x" << hex <<
record.frame->getChipID() <<
", mapping: 0x" <<
record.info->hwID
110 <<
dec <<
", symbId: " <<
record.info->symbolicID.symbolicID <<
")" << endl;
113 record.status.setIDMismatch();
114 stopProcessing =
true;
120 string message = (stopProcessing) ?
"(and will be dropped)" :
"(but will be used though)";
122 ees <<
" Frame at " << fr.Position() <<
" seems corrupted " << message <<
":" << endl;
125 ees <<
" Frame at " << fr.Position() <<
" seems corrupted " << message <<
"." << endl;
133 if (fr.Data()->isECPresent())
134 ECChecker.
Fill(fr.Data()->getEC(), fr.Position());
136 if (fr.Data()->isBCPresent())
137 BCChecker.
Fill(fr.Data()->getBC(), fr.Position());
149 for (
const auto &
p : records) {
150 if (
p.second.status.isMissing())
151 ees <<
"Frame for VFAT " <<
p.first <<
" is not present in the data." << endl;
156 if (
verbosity > 0 && !ees.rdbuf()->str().empty()) {
158 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::runCommon > " 159 <<
"event contains the following problems:" << endl
160 << ees.rdbuf() << endl;
162 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::runCommon > " 163 <<
"event contains problems." << endl;
168 for (
const auto &it : records) {
169 if (!it.second.status.isOK()) {
171 m[it.second.status]++;
183 map<TotemFramePosition, Record> records;
189 for (
auto &
p : records) {
194 uint8_t chipPosition = chipId.
chip();
198 record.status.setChipPosition(chipPosition);
201 if (
record.status.isOK()) {
209 anMa = analysisIter->second;
211 record.status.setFullyMaskedOut();
213 record.status.setPartiallyMaskedOut();
217 unsigned short offset = chipPosition * 128;
218 const vector<unsigned char> &activeChannels =
record.frame->getActiveChannels();
220 for (
auto ch : activeChannels) {
241 map<TotemFramePosition, Record> records;
247 for (
auto &
p : records) {
253 if (
record.status.isOK()) {
278 map<TotemFramePosition, Record> records;
284 for (
auto &
p : records) {
286 if (!
record.status.isOK())
302 auto channelwaveformPtr = records.find(frameposdata);
303 auto eventInfoPtr = records.find(frameposEvtInfo);
305 if (channelwaveformPtr != records.end() && eventInfoPtr != records.end()) {
306 Record &channelwaveform = records[frameposdata];
312 (
const uint8_t *)
eventInfo.frame->getData());
314 if (totemSampicFrame.valid()) {
317 totemSampicFrame.getL1ATimestamp(),
318 totemSampicFrame.getBunchNumber(),
319 totemSampicFrame.getOrbitNumber(),
320 totemSampicFrame.getEventNumber(),
321 totemSampicFrame.getChannelMap(),
322 totemSampicFrame.getL1ALatency(),
323 totemSampicFrame.getNumberOfSentSamples(),
324 totemSampicFrame.getOffsetOfSamples(),
325 totemSampicFrame.getPLLInfo());
327 totemSampicFrame.getFPGATimestamp(),
328 totemSampicFrame.getTimestampA(),
329 totemSampicFrame.getTimestampB(),
330 totemSampicFrame.getCellInfo(),
331 totemSampicFrame.getSamples(),
336 mapping.getTimingChannel(totemSampicFrame.getHardwareId());
338 if (totemSampicFrame.getFWVersion() == 0)
342 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::TotemTiming > " 343 <<
"HwId not recognized! hwId: " << std::hex
344 << (
unsigned int)totemSampicFrame.getHardwareId() << endl;
346 detId.setPlane(SWpair.
plane % 4);
347 detId.setChannel(SWpair.
channel);
351 const int HWplane = totemSampicFrame.getDetPlane() % 16;
352 const int HWchannel = totemSampicFrame.getDetChannel() % 16;
356 LogWarning(
"Totem") <<
"Warning in RawToDigiConverter::TotemTiming > " 357 <<
"HwId not recognized! hwId: " << std::hex
358 << (
unsigned int)totemSampicFrame.getHardwareId()
359 <<
"\tUsing plane and ch from HW without check!" << endl;
362 LogWarning(
"Totem") <<
"Warning in RawToDigiConverter::TotemTiming > " 363 <<
"Hw mapping different from SW mapping. hwId: " << std::hex
364 << (
unsigned int)totemSampicFrame.getHardwareId() <<
"HW: " <<
std::dec << HWplane
365 <<
":" << HWchannel <<
"\tSW " << SWpair.
plane <<
":" << SWpair.
channel 366 <<
"\tUsing plane and ch from HW!" << endl;
368 detId.setPlane(HWplane % 4);
369 detId.setChannel(HWchannel);
386 ees << vit.first << endl;
388 for (
const auto &it : vit.second)
389 ees <<
" " << it.first <<
" : " << it.second << endl;
392 LogWarning(
"Totem") <<
"RawToDigiConverter: error summary (error signature : number of such events)\n" 396 LogInfo(
"Totem") <<
"RawToDigiConverter: no errors to be reported.";
405 ees <<
" " << it.first <<
" : " << it.second << endl;
408 <<
"RawToDigiConverter: frames found in data, but not in the mapping (frame position : number of events)\n" 412 LogInfo(
"Totem") <<
"RawToDigiConverter: no unknown frames to be reported.";
Detector ID class for TOTEM Si strip detectors.
uint32_t getLeadingEdgeTime(const VFATFrame &frame)
get timing information for single leading edge
Contains data on masked channels of a VFAT.
void push_back(const T &t)
unsigned int testECMostFrequent
unsigned int printErrorSummary
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...
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)
unsigned int testFootprint
flags for which tests to run
std::map< TotemSymbID, TotemVFATAnalysisMask > analysisMask
unsigned short getOptoRxId() const
static std::string const input
reference find_or_insert(det_id_type id)
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
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 int printUnknownFrameSummary
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
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)
Log< level::Info, false > LogInfo
TotemRPDetId planeId() const
std::map< TotemFramePosition, unsigned int > unknownSummary
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
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
double EC_fraction
the minimal required (relative) occupancy of the most frequent counter value to be accepted ...
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.
unsigned int EC_min
the minimal required number of frames to determine the most frequent counter value ...
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...