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 Member Functions | Private Attributes
SiStripFEDCheckPlugin Class Reference
Inheritance diagram for SiStripFEDCheckPlugin:
edm::EDAnalyzer

Public Member Functions

 SiStripFEDCheckPlugin (const edm::ParameterSet &)
 
 ~SiStripFEDCheckPlugin ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
void doUpdateIfNeeded ()
 
virtual void endJob ()
 
virtual void endRun ()
 
void fillFatalError (unsigned int fedId, bool fatalError)
 
void fillNonFatalError (unsigned int fedId, float nonFatalError)
 
void fillPresent (unsigned int fedId, bool present)
 
bool hasFatalError (const FEDRawData &fedData, unsigned int fedId) const
 
bool hasNonFatalError (const FEDRawData &fedData, unsigned int fedId) const
 
void updateCabling (const edm::EventSetup &eventSetup)
 
void updateHistograms ()
 

Private Attributes

const SiStripFedCablingcabling_
 
uint32_t cablingCacheId_
 
bool checkChannelLengths_
 
bool checkChannelStatusBits_
 
bool checkFELengths_
 
bool checkPacketCodes_
 
std::string dirName_
 
bool doPayloadChecks_
 
DQMStoredqm_
 
unsigned int eventCount_
 
std::vector< unsigned int > fedFatalErrorBinContents_
 
MonitorElementfedFatalErrors_
 
std::vector< unsigned int > fedNonFatalErrorBinContents_
 
MonitorElementfedNonFatalErrors_
 
MonitorElementfedsPresent_
 
std::vector< unsigned int > fedsPresentBinContents_
 
bool printDebug_
 
edm::InputTag rawDataTag_
 
unsigned int updateFrequency_
 
bool writeDQMStore_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: DQM source application to produce data integrety histograms for SiStrip data for use in HLT and Prompt reco

Definition at line 48 of file SiStripFEDDataCheck.cc.

Constructor & Destructor Documentation

SiStripFEDCheckPlugin::SiStripFEDCheckPlugin ( const edm::ParameterSet iConfig)
explicit

Definition at line 103 of file SiStripFEDDataCheck.cc.

References checkChannelLengths_, checkChannelStatusBits_, checkFELengths_, checkPacketCodes_, doPayloadChecks_, and printDebug_.

104  : rawDataTag_(iConfig.getParameter<edm::InputTag>("RawDataTag")),
105  dirName_(iConfig.getUntrackedParameter<std::string>("DirName","SiStrip/FEDIntegrity/")),
106  printDebug_(iConfig.getUntrackedParameter<bool>("PrintDebugMessages",false)),
107  writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)),
108  updateFrequency_(iConfig.getUntrackedParameter<unsigned int>("HistogramUpdateFrequency",0)),
112  eventCount_(0),
113  doPayloadChecks_(iConfig.getUntrackedParameter<bool>("DoPayloadChecks",true)),
114  checkChannelLengths_(iConfig.getUntrackedParameter<bool>("CheckChannelLengths",true)),
115  checkPacketCodes_(iConfig.getUntrackedParameter<bool>("CheckChannelPacketCodes",true)),
116  checkFELengths_(iConfig.getUntrackedParameter<bool>("CheckFELengths",true)),
117  checkChannelStatusBits_(iConfig.getUntrackedParameter<bool>("CheckChannelStatus",true)),
118  cablingCacheId_(0)
119 {
121  std::stringstream ss;
122  ss << "Payload checks are disabled but individual payload checks have been enabled. The following payload checks will be skipped: ";
123  if (checkChannelLengths_) ss << "Channel length check, ";
124  if (checkPacketCodes_) ss << "Channel packet code check, ";
125  if (checkChannelStatusBits_) ss << "Cabled channel status bits checks, ";
126  if (checkFELengths_) ss << "FE Unit legnth check";
127  edm::LogWarning("SiStripFEDCheck") << ss.str();
128  }
129 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< unsigned int > fedFatalErrorBinContents_
std::vector< unsigned int > fedsPresentBinContents_
std::vector< unsigned int > fedNonFatalErrorBinContents_
SiStripFEDCheckPlugin::~SiStripFEDCheckPlugin ( )

Definition at line 131 of file SiStripFEDDataCheck.cc.

132 {
133 }

Member Function Documentation

void SiStripFEDCheckPlugin::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 142 of file SiStripFEDDataCheck.cc.

References cabling_, checkChannelLengths_, checkChannelStatusBits_, checkFELengths_, checkPacketCodes_, FEDRawData::data(), doPayloadChecks_, doUpdateIfNeeded(), FEDRawDataCollection::FEDData(), fillFatalError(), fillNonFatalError(), fillPresent(), edm::Event::getByLabel(), FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, printDebug_, rawDataTag_, FEDRawData::size(), and updateCabling().

143 {
144  //update cabling
145  updateCabling(iSetup);
146 
147  //get raw data
148  edm::Handle<FEDRawDataCollection> rawDataCollectionHandle;
149  const bool gotData = iEvent.getByLabel(rawDataTag_,rawDataCollectionHandle);
150  if (!gotData) {
151  //module is required to silently do nothing when data is not present
152  return;
153  }
154  const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle;
155 
156  //get FED IDs
157  const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
158  const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
159 
160  //FED errors
161  FEDErrors lFedErrors;
162 
163  //loop over siStrip FED IDs
164  for (unsigned int fedId = siStripFedIdMin; fedId <= siStripFedIdMax; fedId++) {
165  const FEDRawData& fedData = rawDataCollection.FEDData(fedId);
166 
167  //create an object to fill all errors
168  //third param to false:save time by not initialising anything not used here
169  lFedErrors.initialiseFED(fedId,cabling_,false);
170 
171 
172  //check data exists
173  if (!fedData.size() || !fedData.data()) {
174  fillPresent(fedId,0);
175  continue;
176  }
177  //fill buffer present histogram
178  fillPresent(fedId,1);
179 
180  //check for fatal errors
181  //no need for debug output
182  bool hasFatalErrors = false;
183  float rateNonFatal = 0;
184 
185  std::auto_ptr<const sistrip::FEDBuffer> buffer;
186 
187  if (!lFedErrors.fillFatalFEDErrors(fedData,0)) {
188  hasFatalErrors = true;
189  }
190  else {
191  //need to construct full object to go any further
193 
194  buffer.reset(new sistrip::FEDBuffer(fedData.data(),fedData.size(),true));
195  if (doPayloadChecks_) {
196 
197  bool channelLengthsOK = checkChannelLengths_ ? buffer->checkChannelLengthsMatchBufferLength() : true;
198  bool channelPacketCodesOK = checkPacketCodes_ ? buffer->checkChannelPacketCodes() : true;
199  bool feLengthsOK = checkFELengths_ ? buffer->checkFEUnitLengths() : true;
200  if ( !channelLengthsOK ||
201  !channelPacketCodesOK ||
202  !feLengthsOK ) {
203  hasFatalErrors = true;
204  }
205  }
206  if (checkChannelStatusBits_) rateNonFatal = lFedErrors.fillNonFatalFEDErrors(buffer.get(),cabling_);
207  }
208  }
209 
210  if (hasFatalErrors) {
211  fillFatalError(fedId,1);
212  if (printDebug_) {
213  if (!buffer.get()) buffer.reset(new sistrip::FEDBuffer(fedData.data(),fedData.size(),true));
214  edm::LogInfo("SiStripFEDCheck") << "Fatal error with FED ID " << fedId << ". Check summary: "
215  << std::endl << buffer->checkSummary() << std::endl;
216  std::stringstream ss;
217  buffer->dump(ss);
218  edm::LogInfo("SiStripFEDCheck") << ss.str();
219  }
220  }
221  else {
222  fillFatalError(fedId,0);
223  //fill non-fatal errors histogram if there were no fatal errors
224  fillNonFatalError(fedId,rateNonFatal);
225  if (printDebug_ && rateNonFatal > 0) {
226  if (!buffer.get()) buffer.reset(new sistrip::FEDBuffer(fedData.data(),fedData.size(),true));
227  edm::LogInfo("SiStripFEDCheck") << "Non-fatal error with FED ID " << fedId
228  << " for " << rateNonFatal << " of the channels. Check summary: "
229  << std::endl << buffer->checkSummary() << std::endl;
230  std::stringstream ss;
231  buffer->dump(ss);
232  edm::LogInfo("SiStripFEDCheck") << ss.str();
233  }
234 
235  }
236  }//loop over FED IDs
237 
238  //update histograms if needed
240 }
void fillFatalError(unsigned int fedId, bool fatalError)
const SiStripFedCabling * cabling_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
void updateCabling(const edm::EventSetup &eventSetup)
void fillNonFatalError(unsigned int fedId, float nonFatalError)
void fillPresent(unsigned int fedId, bool present)
void SiStripFEDCheckPlugin::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 244 of file SiStripFEDDataCheck.cc.

References DQMStore::book1D(), dirName_, dqm_, fedFatalErrors_, fedNonFatalErrors_, fedsPresent_, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, MonitorElement::setAxisTitle(), and DQMStore::setCurrentFolder().

245 {
246  //get FED IDs
247  const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
248  const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
249  //get DQM store
252  //book histograms
253  fedsPresent_ = dqm_->book1D("FEDEntries",
254  "Number of times FED buffer is present in data",
255  siStripFedIdMax-siStripFedIdMin+1,
256  siStripFedIdMin-0.5,siStripFedIdMax+0.5);
257  fedsPresent_->setAxisTitle("FED-ID",1);
258  fedFatalErrors_ = dqm_->book1D("FEDFatal",
259  "Number of fatal errors in FED buffer",
260  siStripFedIdMax-siStripFedIdMin+1,
261  siStripFedIdMin-0.5,siStripFedIdMax+0.5);
262  fedFatalErrors_->setAxisTitle("FED-ID",1);
263  fedNonFatalErrors_ = dqm_->book1D("FEDNonFatal",
264  "Number of non fatal errors in FED buffer",
265  siStripFedIdMax-siStripFedIdMin+1,
266  siStripFedIdMin-0.5,siStripFedIdMax+0.5);
267  fedNonFatalErrors_->setAxisTitle("FED-ID",1);
268 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * fedNonFatalErrors_
MonitorElement * fedFatalErrors_
MonitorElement * fedsPresent_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void SiStripFEDCheckPlugin::doUpdateIfNeeded ( )
private

Definition at line 323 of file SiStripFEDDataCheck.cc.

References eventCount_, updateFrequency_, and updateHistograms().

Referenced by analyze().

324 {
325  eventCount_++;
328  }
329 }
void SiStripFEDCheckPlugin::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 279 of file SiStripFEDDataCheck.cc.

References dqm_, DQMStore::save(), and writeDQMStore_.

280 {
281  if (writeDQMStore_) dqm_->save("DQMStore.root");
282 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
void SiStripFEDCheckPlugin::endRun ( void  )
privatevirtual

Definition at line 272 of file SiStripFEDDataCheck.cc.

References updateHistograms().

273 {
275 }
void SiStripFEDCheckPlugin::fillFatalError ( unsigned int  fedId,
bool  fatalError 
)
inlineprivate

Definition at line 304 of file SiStripFEDDataCheck.cc.

References fedFatalErrorBinContents_, fedFatalErrors_, MonitorElement::Fill(), and updateFrequency_.

Referenced by analyze().

305 {
306  if (updateFrequency_) {
307  if (fatalError) fedFatalErrorBinContents_[fedId]++;
308  } else {
309  //fedFatalErrors_->Fill( fatalError ? 1 : 0 );
310  if (fatalError) fedFatalErrors_->Fill(fedId);
311  }
312 }
void Fill(long long x)
std::vector< unsigned int > fedFatalErrorBinContents_
MonitorElement * fedFatalErrors_
void SiStripFEDCheckPlugin::fillNonFatalError ( unsigned int  fedId,
float  nonFatalError 
)
inlineprivate

Definition at line 314 of file SiStripFEDDataCheck.cc.

References fedNonFatalErrorBinContents_, fedNonFatalErrors_, MonitorElement::Fill(), and updateFrequency_.

Referenced by analyze().

315 {
316  if (updateFrequency_) {
317  if (nonFatalError>0) fedNonFatalErrorBinContents_[fedId]++;//nonFatalError;
318  } else {
319  if (nonFatalError>0) fedNonFatalErrors_->Fill(fedId);
320  }
321 }
MonitorElement * fedNonFatalErrors_
void Fill(long long x)
std::vector< unsigned int > fedNonFatalErrorBinContents_
void SiStripFEDCheckPlugin::fillPresent ( unsigned int  fedId,
bool  present 
)
inlineprivate

Definition at line 296 of file SiStripFEDDataCheck.cc.

References fedsPresent_, fedsPresentBinContents_, MonitorElement::Fill(), and updateFrequency_.

Referenced by analyze().

297 {
298  if (present) {
300  else fedsPresent_->Fill(fedId);
301  }
302 }
void Fill(long long x)
std::vector< unsigned int > fedsPresentBinContents_
MonitorElement * fedsPresent_
bool SiStripFEDCheckPlugin::hasFatalError ( const FEDRawData fedData,
unsigned int  fedId 
) const
private
bool SiStripFEDCheckPlugin::hasNonFatalError ( const FEDRawData fedData,
unsigned int  fedId 
) const
private
void SiStripFEDCheckPlugin::updateCabling ( const edm::EventSetup eventSetup)
private

Definition at line 285 of file SiStripFEDDataCheck.cc.

References cabling_, cablingCacheId_, edm::EventSetup::get(), and edm::ESHandle< class >::product().

Referenced by analyze().

286 {
287  uint32_t currentCacheId = eventSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
288  if (cablingCacheId_ != currentCacheId) {
289  edm::ESHandle<SiStripFedCabling> cablingHandle;
290  eventSetup.get<SiStripFedCablingRcd>().get(cablingHandle);
291  cabling_ = cablingHandle.product();
292  cablingCacheId_ = currentCacheId;
293  }
294 }
const SiStripFedCabling * cabling_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void SiStripFEDCheckPlugin::updateHistograms ( )
private

Definition at line 331 of file SiStripFEDDataCheck.cc.

References newFWLiteAna::bin, fedFatalErrorBinContents_, fedFatalErrors_, fedNonFatalErrorBinContents_, fedNonFatalErrors_, fedsPresent_, fedsPresentBinContents_, MonitorElement::getTH1(), FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, and updateFrequency_.

Referenced by doUpdateIfNeeded(), and endRun().

332 {
333  //if the cache is not being used then do nothing
334  if (!updateFrequency_) return;
335  const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
336  const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
337  unsigned int entriesFedsPresent = 0;
338  unsigned int entriesFatalErrors = 0;
339  unsigned int entriesNonFatalErrors = 0;
340  for (unsigned int fedId = siStripFedIdMin, bin = 1; fedId < siStripFedIdMax+1; fedId++, bin++) {
341  unsigned int fedsPresentBin = fedsPresentBinContents_[fedId];
342  fedsPresent_->getTH1()->SetBinContent(bin,fedsPresentBin);
343  entriesFedsPresent += fedsPresentBin;
344  unsigned int fedFatalErrorsBin = fedFatalErrorBinContents_[fedId];
345  fedFatalErrors_->getTH1()->SetBinContent(bin,fedFatalErrorsBin);
346  entriesFatalErrors += fedFatalErrorsBin;
347  unsigned int fedNonFatalErrorsBin = fedNonFatalErrorBinContents_[fedId];
348  fedNonFatalErrors_->getTH1()->SetBinContent(bin,fedNonFatalErrorsBin);
349  entriesNonFatalErrors += fedNonFatalErrorsBin;
350  }
351  fedsPresent_->getTH1()->SetEntries(entriesFedsPresent);
352  fedFatalErrors_->getTH1()->SetEntries(entriesFatalErrors);
353  fedNonFatalErrors_->getTH1()->SetEntries(entriesNonFatalErrors);
354 }
MonitorElement * fedNonFatalErrors_
TH1 * getTH1(void) const
std::vector< unsigned int > fedFatalErrorBinContents_
std::vector< unsigned int > fedsPresentBinContents_
MonitorElement * fedFatalErrors_
MonitorElement * fedsPresent_
std::vector< unsigned int > fedNonFatalErrorBinContents_

Member Data Documentation

const SiStripFedCabling* SiStripFEDCheckPlugin::cabling_
private

Definition at line 95 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and updateCabling().

uint32_t SiStripFEDCheckPlugin::cablingCacheId_
private

Definition at line 94 of file SiStripFEDDataCheck.cc.

Referenced by updateCabling().

bool SiStripFEDCheckPlugin::checkChannelLengths_
private

Definition at line 91 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and SiStripFEDCheckPlugin().

bool SiStripFEDCheckPlugin::checkChannelStatusBits_
private

Definition at line 91 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and SiStripFEDCheckPlugin().

bool SiStripFEDCheckPlugin::checkFELengths_
private

Definition at line 91 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and SiStripFEDCheckPlugin().

bool SiStripFEDCheckPlugin::checkPacketCodes_
private

Definition at line 91 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and SiStripFEDCheckPlugin().

std::string SiStripFEDCheckPlugin::dirName_
private

Definition at line 72 of file SiStripFEDDataCheck.cc.

Referenced by beginJob().

bool SiStripFEDCheckPlugin::doPayloadChecks_
private

Definition at line 91 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and SiStripFEDCheckPlugin().

DQMStore* SiStripFEDCheckPlugin::dqm_
private

Definition at line 77 of file SiStripFEDDataCheck.cc.

Referenced by beginJob(), and endJob().

unsigned int SiStripFEDCheckPlugin::eventCount_
private

Definition at line 88 of file SiStripFEDDataCheck.cc.

Referenced by doUpdateIfNeeded().

std::vector<unsigned int> SiStripFEDCheckPlugin::fedFatalErrorBinContents_
private

Definition at line 86 of file SiStripFEDDataCheck.cc.

Referenced by fillFatalError(), and updateHistograms().

MonitorElement* SiStripFEDCheckPlugin::fedFatalErrors_
private

Definition at line 79 of file SiStripFEDDataCheck.cc.

Referenced by beginJob(), fillFatalError(), and updateHistograms().

std::vector<unsigned int> SiStripFEDCheckPlugin::fedNonFatalErrorBinContents_
private

Definition at line 87 of file SiStripFEDDataCheck.cc.

Referenced by fillNonFatalError(), and updateHistograms().

MonitorElement* SiStripFEDCheckPlugin::fedNonFatalErrors_
private

Definition at line 80 of file SiStripFEDDataCheck.cc.

Referenced by beginJob(), fillNonFatalError(), and updateHistograms().

MonitorElement* SiStripFEDCheckPlugin::fedsPresent_
private

Definition at line 78 of file SiStripFEDDataCheck.cc.

Referenced by beginJob(), fillPresent(), and updateHistograms().

std::vector<unsigned int> SiStripFEDCheckPlugin::fedsPresentBinContents_
private

Definition at line 85 of file SiStripFEDDataCheck.cc.

Referenced by fillPresent(), and updateHistograms().

bool SiStripFEDCheckPlugin::printDebug_
private

Definition at line 73 of file SiStripFEDDataCheck.cc.

Referenced by analyze(), and SiStripFEDCheckPlugin().

edm::InputTag SiStripFEDCheckPlugin::rawDataTag_
private

Definition at line 71 of file SiStripFEDDataCheck.cc.

Referenced by analyze().

unsigned int SiStripFEDCheckPlugin::updateFrequency_
private
bool SiStripFEDCheckPlugin::writeDQMStore_
private

Definition at line 74 of file SiStripFEDDataCheck.cc.

Referenced by endJob().