CMS 3D CMS Logo

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

Collection of code to convert TOTEM raw data into digi. More...

#include <RawToDigiConverter.h>

Classes

struct  Record
 

Public Member Functions

void PrintSummaries ()
 Print error summaries. More...
 
 RawToDigiConverter (const edm::ParameterSet &conf)
 
void Run (const VFATFrameCollection &coll, const TotemDAQMapping &mapping, const TotemAnalysisMask &mask, edm::DetSetVector< TotemRPDigi > &digi, edm::DetSetVector< TotemVFATStatus > &status)
 Creates RP digi. More...
 

Private Types

enum  TestFlag { tfNoTest, tfWarn, tfErr }
 

Private Member Functions

void RunCommon (const VFATFrameCollection &input, const TotemDAQMapping &mapping, std::map< TotemFramePosition, Record > &records)
 Common processing for all VFAT based sub-systems. More...
 

Private Attributes

double BC_fraction
 
unsigned int BC_min
 
double EC_fraction
 the minimal required (relative) occupancy of the most frequent counter value to be accepted More...
 
unsigned int EC_min
 the minimal required number of frames to determine the most frequent counter value More...
 
std::map< TotemFramePosition,
std::map< TotemVFATStatus,
unsigned int > > 
errorSummary
 error summaries More...
 
unsigned int printErrorSummary
 
unsigned int printUnknownFrameSummary
 
unsigned int testBCMostFrequent
 
unsigned int testCRC
 
unsigned int testECDAQ
 
unsigned int testECMostFrequent
 
unsigned int testECRaw
 
unsigned int testFootprint
 flags for which tests to run More...
 
unsigned int testID
 
std::map< TotemFramePosition,
unsigned int > 
unknownSummary
 
unsigned char verbosity
 

Detailed Description

Collection of code to convert TOTEM raw data into digi.

Definition at line 26 of file RawToDigiConverter.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

RawToDigiConverter::RawToDigiConverter ( const edm::ParameterSet conf)

Definition at line 24 of file RawToDigiConverter.cc.

24  :
25  verbosity(conf.getUntrackedParameter<unsigned int>("verbosity", 0)),
26  printErrorSummary(conf.getUntrackedParameter<unsigned int>("printErrorSummary", 1)),
27  printUnknownFrameSummary(conf.getUntrackedParameter<unsigned int>("printUnknownFrameSummary", 1)),
28 
29  testFootprint(conf.getParameter<unsigned int>("testFootprint")),
30  testCRC(conf.getParameter<unsigned int>("testCRC")),
31  testID(conf.getParameter<unsigned int>("testID")),
32  testECMostFrequent(conf.getParameter<unsigned int>("testECMostFrequent")),
33  testBCMostFrequent(conf.getParameter<unsigned int>("testBCMostFrequent")),
34 
35  EC_min(conf.getUntrackedParameter<unsigned int>("EC_min", 10)),
36  BC_min(conf.getUntrackedParameter<unsigned int>("BC_min", 10)),
37 
38  EC_fraction(conf.getUntrackedParameter<double>("EC_fraction", 0.6)),
39  BC_fraction(conf.getUntrackedParameter<double>("BC_fraction", 0.6))
40 {
41 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int testECMostFrequent
unsigned int printErrorSummary
unsigned int testFootprint
flags for which tests to run
unsigned int printUnknownFrameSummary
unsigned char verbosity
unsigned int testBCMostFrequent
double EC_fraction
the minimal required (relative) occupancy of the most frequent counter value to be accepted ...
unsigned int EC_min
the minimal required number of frames to determine the most frequent counter value ...

Member Function Documentation

void RawToDigiConverter::PrintSummaries ( )

Print error summaries.

Definition at line 276 of file RawToDigiConverter.cc.

References errorSummary, printErrorSummary, printUnknownFrameSummary, and unknownSummary.

277 {
278  if (printErrorSummary)
279  {
280  LogVerbatim("Totem") << "* Error summary (error signature : number of such events)" << endl;
281  for (const auto &vit : errorSummary)
282  {
283  LogVerbatim("Totem") << vit.first << endl;
284 
285  for (const auto &it : vit.second)
286  LogVerbatim("Totem") << " " << it.first << " : " << it.second << endl;
287  }
288  }
289 
291  {
292  LogVerbatim("Totem") << "* Frames found in data, but not in the mapping (frame position : number of events)" << endl;
293  for (const auto &it : unknownSummary)
294  LogVerbatim("Totem") << " " << it.first << " : " << it.second << endl;
295  }
296 }
unsigned int printErrorSummary
unsigned int printUnknownFrameSummary
std::map< TotemFramePosition, unsigned int > unknownSummary
std::map< TotemFramePosition, std::map< TotemVFATStatus, unsigned int > > errorSummary
error summaries
void RawToDigiConverter::Run ( const VFATFrameCollection coll,
const TotemDAQMapping mapping,
const TotemAnalysisMask mask,
edm::DetSetVector< TotemRPDigi > &  digi,
edm::DetSetVector< TotemVFATStatus > &  status 
)

Creates RP digi.

Definition at line 200 of file RawToDigiConverter.cc.

References TotemAnalysisMask::analysisMask, TotemVFATInfo::data, TotemRPDetId::decToRawId(), edm::DetSetVector< T >::find_or_insert(), RawToDigiConverter::Record::frame, TotemVFATAnalysisMask::fullMask, VFATFrame::getActiveChannels(), RawToDigiConverter::Record::info, TotemVFATStatus::isOK(), TotemVFATAnalysisMask::maskedChannels, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_ParallelJobs::p, edm::DetSet< T >::push_back(), record, TotemSymbID::RP, RunCommon(), TotemVFATStatus::setChipPosition(), TotemVFATStatus::setFullyMaskedOut(), TotemVFATStatus::setPartiallyMaskedOut(), RawToDigiConverter::Record::status, TotemSymbID::subSystem, TotemSymbID::symbolicID, TotemVFATInfo::symbolicID, and TotemVFATInfo::type.

Referenced by TotemVFATRawToDigi::run().

203 {
204  // structure merging vfat frame data with the mapping
205  map<TotemFramePosition, Record> records;
206 
207  // common processing - frame validation
208  RunCommon(input, mapping, records);
209 
210  // second loop over data
211  for (auto &p : records)
212  {
213  Record &record = p.second;
214 
215  // check whether the data come from RP VFATs
216  if (record.info->symbolicID.subSystem != TotemSymbID::RP)
217  {
218  LogProblem("Totem") << "Error in RawToDigiConverter::Run > "
219  << "VFAT is not from RP. subSystem = " << record.info->symbolicID.subSystem;
220  continue;
221  }
222 
223  // silently ignore RP CC VFATs
224  if (record.info->type != TotemVFATInfo::data)
225  continue;
226 
227  // calculate ids
228  unsigned short chipId = record.info->symbolicID.symbolicID;
229  det_id_type detId = TotemRPDetId::decToRawId(chipId / 10);
230  uint8_t chipPosition = chipId % 10;
231 
232  // update chipPosition in status
233  record.status.setChipPosition(chipPosition);
234 
235  // produce digi only for good frames
236  if (record.status.isOK())
237  {
238  // find analysis mask (needs a default=no mask, if not in present the mapping)
240  anMa.fullMask = false;
241 
242  auto analysisIter = analysisMask.analysisMask.find(record.info->symbolicID);
243  if (analysisIter != analysisMask.analysisMask.end())
244  {
245  // if there is some information about masked channels - save it into conversionStatus
246  anMa = analysisIter->second;
247  if (anMa.fullMask)
248  record.status.setFullyMaskedOut();
249  else
250  record.status.setPartiallyMaskedOut();
251  }
252 
253  // create the digi
254  unsigned short offset = chipPosition * 128;
255  const vector<unsigned char> &activeChannels = record.frame->getActiveChannels();
256 
257  for (auto ch : activeChannels)
258  {
259  // skip masked channels
260  if (!anMa.fullMask && anMa.maskedChannels.find(ch) == anMa.maskedChannels.end())
261  {
262  DetSet<TotemRPDigi> &digiDetSet = rpData.find_or_insert(detId);
263  digiDetSet.push_back(TotemRPDigi(offset + ch));
264  }
265  }
266  }
267 
268  // save status
269  DetSet<TotemVFATStatus> &statusDetSet = finalStatus.find_or_insert(detId);
270  statusDetSet.push_back(record.status);
271  }
272 }
Contains data on masked channels of a VFAT.
void push_back(const T &t)
Definition: DetSet.h:68
JetCorrectorParameters::Record record
Definition: classes.h:7
static std::string const input
Definition: EdmProvDump.cc:44
bool fullMask
whether all channels of the VFAT shall be masked
uint32_t det_id_type
Definition: DetSet.h:21
std::set< unsigned char > maskedChannels
list of channels to be masked
static unsigned int decToRawId(unsigned int dec)
fast conversion Decimal to Raw ID
Definition: TotemRPDetId.h:129
void RunCommon(const VFATFrameCollection &input, const TotemDAQMapping &mapping, std::map< TotemFramePosition, Record > &records)
Common processing for all VFAT based sub-systems.
void RawToDigiConverter::RunCommon ( const VFATFrameCollection input,
const TotemDAQMapping mapping,
std::map< TotemFramePosition, Record > &  records 
)
private

Common processing for all VFAT based sub-systems.

Definition at line 45 of file RawToDigiConverter.cc.

References CounterChecker::Analyze(), BC_fraction, BC_min, CounterChecker::BCChecker, VFATFrame::checkCRC(), VFATFrame::checkFootprint(), TauDecayModes::dec, EC_fraction, EC_min, CounterChecker::ECChecker, errorSummary, CounterChecker::Fill(), RawToDigiConverter::Record::frame, VFATFrame::getChipID(), VFATFrame::getNumberOfClusters(), TotemVFATInfo::hwID, RawToDigiConverter::Record::info, VFATFrameCollection::Iterator::IsEnd(), VFATFrame::isIDPresent(), VFATFrame::isNumberOfClustersPresent(), visualization-live-secondInstance_cfg::m, python.rootplot.argparse::message, NULL, AlCaHLTBitMon_ParallelJobs::p, printErrorSummary, record, TotemVFATStatus::setCRCError(), TotemVFATStatus::setFootprintError(), TotemVFATStatus::setIDMismatch(), TotemVFATStatus::setMissing(), TotemVFATStatus::setNumberOfClusters(), TotemVFATStatus::setNumberOfClustersSpecified(), RawToDigiConverter::Record::status, TotemSymbID::symbolicID, TotemVFATInfo::symbolicID, testBCMostFrequent, testCRC, testECMostFrequent, testFootprint, testID, tfErr, tfNoTest, unknownSummary, verbosity, and TotemDAQMapping::VFATMapping.

Referenced by Run().

47 {
48  // EC and BC checks (wrt. the most frequent value), BC checks per subsystem
51 
52  // initialise structure merging vfat frame data with the mapping
53  for (auto &p : mapping.VFATMapping)
54  {
55  TotemVFATStatus st;
56  st.setMissing(true);
57  records[p.first] = { &p.second, NULL, st };
58  }
59 
60  // event error message buffer
61  stringstream ees;
62 
63  // associate data frames with records
64  for (VFATFrameCollection::Iterator fr(&input); !fr.IsEnd(); fr.Next())
65  {
66  // frame error message buffer
67  stringstream fes;
68 
69  bool problemsPresent = false;
70  bool stopProcessing = false;
71 
72  // skip data frames not listed in the DAQ mapping
73  auto records_it = records.find(fr.Position());
74  if (records_it == records.end())
75  {
76  unknownSummary[fr.Position()]++;
77  continue;
78  }
79 
80  // update record
81  Record &record = records_it->second;
82  record.frame = fr.Data();
83  record.status.setMissing(false);
84 
85  record.status.setNumberOfClustersSpecified(record.frame->isNumberOfClustersPresent());
86  record.status.setNumberOfClusters(record.frame->getNumberOfClusters());
87 
88  // check footprint
89  if (testFootprint != tfNoTest && !record.frame->checkFootprint())
90  {
91  problemsPresent = true;
92 
93  if (verbosity > 0)
94  fes << " invalid footprint\n";
95 
96  if ((testFootprint == tfErr))
97  {
98  record.status.setFootprintError();
99  stopProcessing = true;
100  }
101  }
102 
103  // check CRC
104  if (testCRC != tfNoTest && !record.frame->checkCRC())
105  {
106  problemsPresent = true;
107 
108  if (verbosity > 0)
109  fes << " CRC failure\n";
110 
111  if (testCRC == tfErr)
112  {
113  record.status.setCRCError();
114  stopProcessing = true;
115  }
116  }
117 
118  // check the id mismatch
119  if (testID != tfNoTest && record.frame->isIDPresent() && (record.frame->getChipID() & 0xFFF) != (record.info->hwID & 0xFFF))
120  {
121  problemsPresent = true;
122 
123  if (verbosity > 0)
124  fes << " ID mismatch (data: 0x" << hex << record.frame->getChipID()
125  << ", mapping: 0x" << record.info->hwID << dec << ", symbId: " << record.info->symbolicID.symbolicID << ")\n";
126 
127  if (testID == tfErr)
128  {
129  record.status.setIDMismatch();
130  stopProcessing = true;
131  }
132  }
133 
134  // if there were errors, put the information to ees buffer
135  if (verbosity > 0 && problemsPresent)
136  {
137  string message = (stopProcessing) ? "(and will be dropped)" : "(but will be used though)";
138  if (verbosity > 2)
139  {
140  ees << " Frame at " << fr.Position() << " seems corrupted " << message << ":\n";
141  ees << fes.rdbuf();
142  } else
143  ees << " Frame at " << fr.Position() << " seems corrupted " << message << ".\n";
144  }
145 
146  // if there were serious errors, do not process this frame
147  if (stopProcessing)
148  continue;
149 
150  // fill EC and BC values to the statistics
151  if (fr.Data()->isECPresent())
152  ECChecker.Fill(fr.Data()->getEC(), fr.Position());
153 
154  if (fr.Data()->isBCPresent())
155  BCChecker.Fill(fr.Data()->getBC(), fr.Position());
156  }
157 
158  // analyze EC and BC statistics
160  ECChecker.Analyze(records, (testECMostFrequent == tfErr), ees);
161 
163  BCChecker.Analyze(records, (testBCMostFrequent == tfErr), ees);
164 
165  // add error message for missing frames
166  if (verbosity > 1)
167  {
168  for (const auto &p : records)
169  {
170  if (p.second.status.isMissing())
171  ees << "Frame for VFAT " << p.first << " is not present in the data.\n";
172  }
173  }
174 
175  // print error message
176  if (verbosity > 0 && !ees.rdbuf()->str().empty())
177  {
178  if (verbosity > 1)
179  LogProblem("Totem") << "Error in RawToDigiConverter::RunCommon > " << "event contains the following problems:\n" << ees.rdbuf() << endl;
180  else
181  LogProblem("Totem") << "Error in RawToDigiConverter::RunCommon > " << "event contains problems." << endl;
182  }
183 
184  // increase error counters
185  if (printErrorSummary)
186  {
187  for (const auto &it : records)
188  {
189  if (!it.second.status.isOK())
190  {
191  auto &m = errorSummary[it.first];
192  m[it.second.status]++;
193  }
194  }
195  }
196 }
unsigned int testECMostFrequent
unsigned int printErrorSummary
Class for finding the most popular both EC and BC counter, and filling the conversion status &#39;wrong E...
JetCorrectorParameters::Record record
Definition: classes.h:7
#define NULL
Definition: scimark2.h:8
unsigned int testFootprint
flags for which tests to run
the VFATFrameCollection interator
void setMissing(bool val=true)
unsigned char verbosity
std::map< TotemFramePosition, unsigned int > unknownSummary
unsigned int testBCMostFrequent
std::map< TotemFramePosition, TotemVFATInfo > VFATMapping
std::map< TotemFramePosition, std::map< TotemVFATStatus, unsigned int > > errorSummary
error summaries
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 ...
unsigned int EC_min
the minimal required number of frames to determine the most frequent counter value ...

Member Data Documentation

double RawToDigiConverter::BC_fraction
private

Definition at line 66 of file RawToDigiConverter.h.

Referenced by RunCommon().

unsigned int RawToDigiConverter::BC_min
private

Definition at line 63 of file RawToDigiConverter.h.

Referenced by RunCommon().

double RawToDigiConverter::EC_fraction
private

the minimal required (relative) occupancy of the most frequent counter value to be accepted

Definition at line 66 of file RawToDigiConverter.h.

Referenced by RunCommon().

unsigned int RawToDigiConverter::EC_min
private

the minimal required number of frames to determine the most frequent counter value

Definition at line 63 of file RawToDigiConverter.h.

Referenced by RunCommon().

std::map<TotemFramePosition, std::map<TotemVFATStatus, unsigned int> > RawToDigiConverter::errorSummary
private

error summaries

Definition at line 69 of file RawToDigiConverter.h.

Referenced by PrintSummaries(), and RunCommon().

unsigned int RawToDigiConverter::printErrorSummary
private

Definition at line 48 of file RawToDigiConverter.h.

Referenced by PrintSummaries(), and RunCommon().

unsigned int RawToDigiConverter::printUnknownFrameSummary
private

Definition at line 49 of file RawToDigiConverter.h.

Referenced by PrintSummaries().

unsigned int RawToDigiConverter::testBCMostFrequent
private

Definition at line 60 of file RawToDigiConverter.h.

Referenced by RunCommon().

unsigned int RawToDigiConverter::testCRC
private

Definition at line 55 of file RawToDigiConverter.h.

Referenced by RunCommon().

unsigned int RawToDigiConverter::testECDAQ
private

Definition at line 58 of file RawToDigiConverter.h.

unsigned int RawToDigiConverter::testECMostFrequent
private

Definition at line 59 of file RawToDigiConverter.h.

Referenced by RunCommon().

unsigned int RawToDigiConverter::testECRaw
private

Definition at line 57 of file RawToDigiConverter.h.

unsigned int RawToDigiConverter::testFootprint
private

flags for which tests to run

Definition at line 54 of file RawToDigiConverter.h.

Referenced by RunCommon().

unsigned int RawToDigiConverter::testID
private

Definition at line 56 of file RawToDigiConverter.h.

Referenced by RunCommon().

std::map<TotemFramePosition, unsigned int> RawToDigiConverter::unknownSummary
private

Definition at line 70 of file RawToDigiConverter.h.

Referenced by PrintSummaries(), and RunCommon().

unsigned char RawToDigiConverter::verbosity
private

Definition at line 46 of file RawToDigiConverter.h.

Referenced by RunCommon().