26 :
verbosity(conf.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
31 testCRC(conf.getParameter<unsigned
int>(
"testCRC")),
32 testID(conf.getParameter<unsigned
int>(
"testID")),
36 EC_min(conf.getUntrackedParameter<unsigned
int>(
"EC_min", 10)),
37 BC_min(conf.getUntrackedParameter<unsigned
int>(
"BC_min", 10)),
39 EC_fraction(conf.getUntrackedParameter<double>(
"EC_fraction", 0.6)),
40 BC_fraction(conf.getUntrackedParameter<double>(
"BC_fraction", 0.6)) {}
44 map<TotemFramePosition, RawToDigiConverter::Record> &records) {
50 for (
auto &
p :
mapping.VFATMapping) {
53 records[
p.first] = {&
p.second,
nullptr, st};
64 bool problemsPresent =
false;
65 bool stopProcessing =
false;
68 auto records_it = records.find(fr.Position());
69 if (records_it == records.end()) {
77 record.status.setMissing(
false);
78 record.status.setNumberOfClustersSpecified(
record.frame->isNumberOfClustersPresent());
79 record.status.setNumberOfClusters(
record.frame->getNumberOfClusters());
83 problemsPresent =
true;
86 fes <<
" invalid footprint" << endl;
89 record.status.setFootprintError();
90 stopProcessing =
true;
96 problemsPresent =
true;
99 fes <<
" CRC failure" << endl;
102 record.status.setCRCError();
103 stopProcessing =
true;
109 (
record.frame->getChipID() & 0xFFF) != (
record.info->hwID & 0xFFF)) {
111 fes <<
" ID mismatch (data: 0x" << hex <<
record.frame->getChipID() <<
", mapping: 0x" <<
record.info->hwID
112 <<
dec <<
", symbId: " <<
record.info->symbolicID.symbolicID <<
")" << endl;
115 record.status.setIDMismatch();
116 stopProcessing =
true;
122 string message = (stopProcessing) ?
"(and will be dropped)" :
"(but will be used though)";
124 ees <<
" Frame at " << fr.Position() <<
" seems corrupted " << message <<
":" << endl;
127 ees <<
" Frame at " << fr.Position() <<
" seems corrupted " << message <<
"." << endl;
135 if (fr.Data()->isECPresent())
136 ECChecker.
Fill(fr.Data()->getEC(), fr.Position());
138 if (fr.Data()->isBCPresent())
139 BCChecker.
Fill(fr.Data()->getBC(), fr.Position());
151 for (
const auto &
p : records) {
152 if (
p.second.status.isMissing())
153 ees <<
"Frame for VFAT " <<
p.first <<
" is not present in the data." << endl;
158 if (
verbosity > 0 && !ees.rdbuf()->str().empty()) {
160 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::runCommon > " 161 <<
"event contains the following problems:" << endl
162 << ees.rdbuf() << endl;
164 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::runCommon > " 165 <<
"event contains problems." << endl;
170 for (
const auto &it : records) {
171 if (!it.second.status.isOK()) {
173 m[it.second.status]++;
185 map<TotemFramePosition, Record> records;
191 for (
auto &
p : records) {
196 uint8_t chipPosition = chipId.
chip();
200 record.status.setChipPosition(chipPosition);
203 if (
record.status.isOK()) {
211 anMa = analysisIter->second;
213 record.status.setFullyMaskedOut();
215 record.status.setPartiallyMaskedOut();
219 unsigned short offset = chipPosition * 128;
220 const vector<unsigned char> &activeChannels =
record.frame->getActiveChannels();
222 for (
auto ch : activeChannels) {
243 map<TotemFramePosition, Record> records;
249 for (
auto &
p : records) {
255 if (
record.status.isOK()) {
280 map<TotemFramePosition, Record> records;
286 for (
auto &
p : records) {
288 if (!
record.status.isOK())
304 auto channelwaveformPtr = records.find(frameposdata);
305 auto eventInfoPtr = records.find(frameposEvtInfo);
307 if (channelwaveformPtr != records.end() && eventInfoPtr != records.end()) {
308 Record &channelwaveform = records[frameposdata];
314 (
const uint8_t *)
eventInfo.frame->getData());
316 if (totemSampicFrame.valid()) {
319 totemSampicFrame.getL1ATimestamp(),
320 totemSampicFrame.getBunchNumber(),
321 totemSampicFrame.getOrbitNumber(),
322 totemSampicFrame.getEventNumber(),
323 totemSampicFrame.getChannelMap(),
324 totemSampicFrame.getL1ALatency(),
325 totemSampicFrame.getNumberOfSentSamples(),
326 totemSampicFrame.getOffsetOfSamples(),
327 totemSampicFrame.getPLLInfo());
329 totemSampicFrame.getFPGATimestamp(),
330 totemSampicFrame.getTimestampA(),
331 totemSampicFrame.getTimestampB(),
332 totemSampicFrame.getCellInfo(),
333 totemSampicFrame.getSamples(),
338 mapping.getTimingChannel(totemSampicFrame.getHardwareId());
340 if (totemSampicFrame.getFWVersion() == 0)
344 LogWarning(
"Totem") <<
"Error in RawToDigiConverter::TotemTiming > " 345 <<
"HwId not recognized! hwId: " << std::hex
346 << (
unsigned int)totemSampicFrame.getHardwareId() << endl;
348 detId.setPlane(SWpair.
plane % 4);
349 detId.setChannel(SWpair.
channel);
353 const int HWplane = totemSampicFrame.getDetPlane() % 16;
354 const int HWchannel = totemSampicFrame.getDetChannel() % 16;
358 LogWarning(
"Totem") <<
"Warning in RawToDigiConverter::TotemTiming > " 359 <<
"HwId not recognized! hwId: " << std::hex
360 << (
unsigned int)totemSampicFrame.getHardwareId()
361 <<
"\tUsing plane and ch from HW without check!" << endl;
364 LogWarning(
"Totem") <<
"Warning in RawToDigiConverter::TotemTiming > " 365 <<
"Hw mapping different from SW mapping. hwId: " << std::hex
366 << (
unsigned int)totemSampicFrame.getHardwareId() <<
"HW: " <<
std::dec << HWplane
367 <<
":" << HWchannel <<
"\tSW " << SWpair.
plane <<
":" << SWpair.
channel 368 <<
"\tUsing plane and ch from HW!" << endl;
370 detId.setPlane(HWplane % 4);
371 detId.setChannel(HWchannel);
388 map<TotemFramePosition, Record> records;
394 for (
auto &
p : records) {
400 if (
record.status.isOK()) {
425 ees << vit.first << endl;
427 for (
const auto &it : vit.second)
428 ees <<
" " << it.first <<
" : " << it.second << endl;
431 LogWarning(
"Totem") <<
"RawToDigiConverter: error summary (error signature : number of such events)\n" 435 LogInfo(
"Totem") <<
"RawToDigiConverter: no errors to be reported.";
444 ees <<
" " << it.first <<
" : " << it.second << endl;
447 <<
"RawToDigiConverter: frames found in data, but not in the mapping (frame position : number of events)\n" 451 LogInfo(
"Totem") <<
"RawToDigiConverter: no unknown frames to be reported.";
uint8_t geoId(const VFATFrame &frame)
retrieve the GEO information for this channel
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...
Detector ID class for Totem T2 detectors. Bits [19:31] : Base CTPPSDetId class attributes Bits [16:18...
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
uint8_t channelMarker(const VFATFrame &frame)
retrieve this channel marker
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
uint16_t trailingEdgeTime(const VFATFrame &frame)
get timing information for single trailing edge
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
uint8_t channelId(const VFATFrame &frame)
retrieve this channel identifier
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 ...
uint16_t leadingEdgeTime(const VFATFrame &frame)
get timing information for single leading edge
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...