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
SiStripFEDMonitorPlugin Class Reference

#include <DQM/SiStripMonitorHardware/plugins/SiStripFEDMonitor.cc>

Inheritance diagram for SiStripFEDMonitorPlugin:
edm::EDAnalyzer

Public Member Functions

 SiStripFEDMonitorPlugin (const edm::ParameterSet &)
 
 ~SiStripFEDMonitorPlugin ()
 
- 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 ()
 
virtual void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
 
void updateCabling (const edm::EventSetup &eventSetup)
 

Private Attributes

const SiStripFedCablingcabling_
 
uint32_t cablingCacheId_
 
bool doMedHists_
 
bool doTkHistoMap_
 
DQMStoredqm_
 
std::string dqmStoreFileName_
 
FEDErrors fedErrors_
 
FEDHistograms fedHists_
 
bool fillAllDetailedHistograms_
 
bool fillWithEvtNum_
 
std::string folderName_
 
unsigned int nEvt_
 
unsigned int printDebug_
 
edm::InputTag rawDataTag_
 
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)
 
- 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

Definition at line 57 of file SiStripFEDMonitor.cc.

Constructor & Destructor Documentation

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

Definition at line 114 of file SiStripFEDMonitor.cc.

References doMedHists_, doTkHistoMap_, dqmStoreFileName_, fedHists_, fillAllDetailedHistograms_, fillWithEvtNum_, folderName_, LogTrace, nEvt_, NULL, printDebug_, rawDataTag_, and writeDQMStore_.

115  : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>("RawDataTag",edm::InputTag("source",""))),
116  folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/FedMonitoringSummary")),
117  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)),
118  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)),
119  printDebug_(iConfig.getUntrackedParameter<unsigned int>("PrintDebugMessages",1)),
120  //printDebug_(iConfig.getUntrackedParameter<bool>("PrintDebugMessages",false)),
121  writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)),
122  dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>("DQMStoreFileName","DQMStore.root")),
123  dqm_(0),
124  cablingCacheId_(0)
125 {
126  //print config to debug log
127  std::ostringstream debugStream;
128  if (printDebug_>1) {
129  debugStream << "[SiStripFEDMonitorPlugin]Configuration for SiStripFEDMonitorPlugin: " << std::endl
130  << "[SiStripFEDMonitorPlugin]\tRawDataTag: " << rawDataTag_ << std::endl
131  << "[SiStripFEDMonitorPlugin]\tHistogramFolderName: " << folderName_ << std::endl
132  << "[SiStripFEDMonitorPlugin]\tFillAllDetailedHistograms? " << (fillAllDetailedHistograms_ ? "yes" : "no") << std::endl
133  << "[SiStripFEDMonitorPlugin]\tFillWithEventNumber?" << (fillWithEvtNum_ ? "yes" : "no") << std::endl
134  << "[SiStripFEDMonitorPlugin]\tPrintDebugMessages? " << (printDebug_ ? "yes" : "no") << std::endl
135  << "[SiStripFEDMonitorPlugin]\tWriteDQMStore? " << (writeDQMStore_ ? "yes" : "no") << std::endl;
136  if (writeDQMStore_) debugStream << "[SiStripFEDMonitorPlugin]\tDQMStoreFileName: " << dqmStoreFileName_ << std::endl;
137  }
138 
139  //don;t generate debug mesages if debug is disabled
140  std::ostringstream* pDebugStream = (printDebug_>1 ? &debugStream : NULL);
141 
142  fedHists_.initialise(iConfig,pDebugStream);
143 
144  doTkHistoMap_ = fedHists_.tkHistoMapEnabled();
145 
146  doMedHists_ = fedHists_.cmHistosEnabled();
147 
148  if (printDebug_) {
149  LogTrace("SiStripMonitorHardware") << debugStream.str();
150 
151  //debugStream.str("");
152 
153  //debugStream << " -- Quelle est la difference entre un canard ? " << std::endl
154  // << " -- Reponse: c'est qu'il a les deux pattes de la meme longueur, surtout la gauche." << std::endl;
155 
156  //edm::LogError("SiStripMonitorHardware") << debugStream.str();
157  }
158 
159  nEvt_ = 0;
160 
161 }
T getUntrackedParameter(std::string const &, T const &) const
#define NULL
Definition: scimark2.h:8
#define LogTrace(id)
SiStripFEDMonitorPlugin::~SiStripFEDMonitorPlugin ( )

Definition at line 163 of file SiStripFEDMonitor.cc.

164 {
165 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 174 of file SiStripFEDMonitor.cc.

References cabling_, doMedHists_, doTkHistoMap_, edm::EventID::event(), FEDRawDataCollection::FEDData(), fedErrors_, fedHists_, fillWithEvtNum_, edm::Event::getByLabel(), edm::EventBase::id(), FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, nEvt_, edm::EventBase::orbitNumber(), printDebug_, rawDataTag_, and updateCabling().

176 {
177  //update cabling
178  updateCabling(iSetup);
179 
180  //get raw data
181  edm::Handle<FEDRawDataCollection> rawDataCollectionHandle;
182  iEvent.getByLabel(rawDataTag_,rawDataCollectionHandle);
183  const FEDRawDataCollection& rawDataCollection = *rawDataCollectionHandle;
184 
185  fedErrors_.initialiseEvent();
186 
187  //initialise map of fedId/bad channel number
188  std::map<unsigned int,std::pair<unsigned short,unsigned short> > badChannelFraction;
189 
190  unsigned int lNFEDMonitoring = 0;
191  unsigned int lNFEDUnpacker = 0;
192  unsigned int lNChannelMonitoring = 0;
193  unsigned int lNChannelUnpacker = 0;
194 
195  unsigned int lNTotBadFeds = 0;
196  unsigned int lNTotBadChannels = 0;
197  unsigned int lNTotBadActiveChannels = 0;
198 
199  //loop over siStrip FED IDs
200  for (unsigned int fedId = FEDNumbering::MINSiStripFEDID;
202  fedId++) {//loop over FED IDs
203  const FEDRawData& fedData = rawDataCollection.FEDData(fedId);
204 
205  //create an object to fill all errors
206  fedErrors_.initialiseFED(fedId,cabling_);
207  bool lFullDebug = false;
208 
209  //Do detailed check
210  //first check if data exists
211  bool lDataExist = fedErrors_.checkDataPresent(fedData);
212  if (!lDataExist) {
213  fedHists_.fillFEDHistograms(fedErrors_,lFullDebug);
214  continue;
215  }
216 
217 
218 
219  //check for problems and fill detailed histograms
220  fedErrors_.fillFEDErrors(fedData,
221  lFullDebug,
222  printDebug_,
223  lNChannelMonitoring,
224  lNChannelUnpacker,
225  doMedHists_,
226  fedHists_.cmHistPointer(false),
227  fedHists_.cmHistPointer(true)
228  );
229 
230  //check filled in previous method.
231  bool lFailUnpackerFEDcheck = fedErrors_.failUnpackerFEDCheck();
232 
233  fedErrors_.incrementFEDCounters();
234  fedHists_.fillFEDHistograms(fedErrors_,lFullDebug);
235 
236 
237  bool lFailMonitoringFEDcheck = fedErrors_.failMonitoringFEDCheck();
238  if (lFailMonitoringFEDcheck) lNTotBadFeds++;
239 
240 
241  //sanity check: if something changed in the unpacking code
242  //but wasn't propagated here
243  //print only the summary, and more info if printDebug>1
244  if (lFailMonitoringFEDcheck != lFailUnpackerFEDcheck) {
245  if (printDebug_>1) {
246  std::ostringstream debugStream;
247  debugStream << " --- WARNING: FED " << fedId << std::endl
248  << " ------ Monitoring FED check " ;
249  if (lFailMonitoringFEDcheck) debugStream << "failed." << std::endl;
250  else debugStream << "passed." << std::endl ;
251  debugStream << " ------ Unpacker FED check " ;
252  if (lFailUnpackerFEDcheck) debugStream << "failed." << std::endl;
253  else debugStream << "passed." << std::endl ;
254  edm::LogError("SiStripMonitorHardware") << debugStream.str();
255  }
256 
257  if (lFailMonitoringFEDcheck) lNFEDMonitoring++;
258  else if (lFailUnpackerFEDcheck) lNFEDUnpacker++;
259  }
260 
261 
262  //Fill TkHistoMap:
263  //add an entry for all channels (good = 0),
264  //so that tkHistoMap knows which channels should be there.
265  if (doTkHistoMap_ && !fedHists_.tkHistoMapPointer()) {
266  edm::LogWarning("SiStripMonitorHardware") << " -- Fedid " << fedId
267  << ", TkHistoMap enabled but pointer is null." << std::endl;
268  }
269 
270  fedErrors_.fillBadChannelList(doTkHistoMap_,
271  fedHists_.tkHistoMapPointer(),
272  lNTotBadChannels,
273  lNTotBadActiveChannels);
274  }//loop over FED IDs
275 
276  if ((lNTotBadFeds> 0 || lNTotBadChannels>0) && printDebug_>1) {
277  std::ostringstream debugStream;
278  debugStream << "[SiStripFEDMonitorPlugin] --- Total number of bad feds = "
279  << lNTotBadFeds << std::endl
280  << "[SiStripFEDMonitorPlugin] --- Total number of bad channels = "
281  << lNTotBadChannels << std::endl
282  << "[SiStripFEDMonitorPlugin] --- Total number of bad active channels = "
283  << lNTotBadActiveChannels << std::endl;
284  edm::LogInfo("SiStripMonitorHardware") << debugStream.str();
285  }
286 
287  if ((lNFEDMonitoring > 0 || lNFEDUnpacker > 0 || lNChannelMonitoring > 0 || lNChannelUnpacker > 0) && printDebug_) {
288  std::ostringstream debugStream;
289  debugStream
290  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
291  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
292  << "[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at FED level : " << std::endl
293  << "[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNFEDMonitoring << std::endl
294  << "[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNFEDUnpacker << std::endl
295  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
296  << "[SiStripFEDMonitorPlugin]-- Summary of differences between unpacker and monitoring at Channel level : " << std::endl
297  << "[SiStripFEDMonitorPlugin] ---- Number of times monitoring fails but not unpacking = " << lNChannelMonitoring << std::endl
298  << "[SiStripFEDMonitorPlugin] ---- Number of times unpacking fails but not monitoring = " << lNChannelUnpacker << std::endl
299  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl
300  << "[SiStripFEDMonitorPlugin]-------------------------------------------------------------------------" << std::endl ;
301  edm::LogError("SiStripMonitorHardware") << debugStream.str();
302 
303  }
304 
305  FEDErrors::getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels;
306  FEDErrors::getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels;
307 
308  //fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(), nEvt_);
309  //time in seconds since beginning of the run or event number
310  if (fillWithEvtNum_) fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(),FEDErrors::getChannelErrorsCounters(),iEvent.id().event());
311  else fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(),FEDErrors::getChannelErrorsCounters(),iEvent.orbitNumber()/11223.);
312 
313 
314  nEvt_++;
315 
316 }//analyze method
EventNumber_t event() const
Definition: EventID.h:44
const SiStripFedCabling * cabling_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int orbitNumber() const
Definition: EventBase.h:63
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
edm::EventID id() const
Definition: EventBase.h:56
void updateCabling(const edm::EventSetup &eventSetup)
void SiStripFEDMonitorPlugin::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 320 of file SiStripFEDMonitor.cc.

References dqm_, fedHists_, fillAllDetailedHistograms_, folderName_, nEvt_, and DQMStore::setCurrentFolder().

321 {
322  //get DQM store
325 
326  //this propagates dqm_ to the histoclass, must be called !
327  fedHists_.bookTopLevelHistograms(dqm_);
328 
329  if (fillAllDetailedHistograms_) fedHists_.bookAllFEDHistograms();
330 
331  nEvt_ = 0;
332 
333  //const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
334  //const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
335 
336  //mark all channels as inactive until they have been 'locked' at least once
337  // activeChannels_.resize(siStripFedIdMax+1);
338  // for (unsigned int fedId = siStripFedIdMin;
339  // fedId <= siStripFedIdMax;
340  // fedId++) {
341  // activeChannels_[fedId].resize(sistrip::FEDCH_PER_FED,false);
342  // }
343 
344 
345 
346 
347 }
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
void SiStripFEDMonitorPlugin::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 359 of file SiStripFEDMonitor.cc.

References fedErrors_.

361 {
362 
363  fedErrors_.initialiseLumiBlock();
364 
365 }
void SiStripFEDMonitorPlugin::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 351 of file SiStripFEDMonitor.cc.

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

352 {
354 }
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:1883
void SiStripFEDMonitorPlugin::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 369 of file SiStripFEDMonitor.cc.

References fedErrors_, and fedHists_.

371 {
372  fedHists_.fillLumiHistograms(fedErrors_.getLumiErrors());
373 }
void SiStripFEDMonitorPlugin::updateCabling ( const edm::EventSetup eventSetup)
private

Definition at line 378 of file SiStripFEDMonitor.cc.

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

Referenced by analyze().

379 {
380  uint32_t currentCacheId = eventSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
381  if (cablingCacheId_ != currentCacheId) {
382  edm::ESHandle<SiStripFedCabling> cablingHandle;
383  eventSetup.get<SiStripFedCablingRcd>().get(cablingHandle);
384  cabling_ = cablingHandle.product();
385  cablingCacheId_ = currentCacheId;
386  }
387 }
const SiStripFedCabling * cabling_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62

Member Data Documentation

const SiStripFedCabling* SiStripFEDMonitorPlugin::cabling_
private

Definition at line 95 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and updateCabling().

uint32_t SiStripFEDMonitorPlugin::cablingCacheId_
private

Definition at line 94 of file SiStripFEDMonitor.cc.

Referenced by updateCabling().

bool SiStripFEDMonitorPlugin::doMedHists_
private

Definition at line 99 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

bool SiStripFEDMonitorPlugin::doTkHistoMap_
private

Definition at line 98 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

DQMStore* SiStripFEDMonitorPlugin::dqm_
private

Definition at line 92 of file SiStripFEDMonitor.cc.

Referenced by beginJob(), and endJob().

std::string SiStripFEDMonitorPlugin::dqmStoreFileName_
private

Definition at line 90 of file SiStripFEDMonitor.cc.

Referenced by endJob(), and SiStripFEDMonitorPlugin().

FEDErrors SiStripFEDMonitorPlugin::fedErrors_
private

Definition at line 105 of file SiStripFEDMonitor.cc.

Referenced by analyze(), beginLuminosityBlock(), and endLuminosityBlock().

FEDHistograms SiStripFEDMonitorPlugin::fedHists_
private
bool SiStripFEDMonitorPlugin::fillAllDetailedHistograms_
private

Definition at line 82 of file SiStripFEDMonitor.cc.

Referenced by beginJob(), and SiStripFEDMonitorPlugin().

bool SiStripFEDMonitorPlugin::fillWithEvtNum_
private

Definition at line 84 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

std::string SiStripFEDMonitorPlugin::folderName_
private

Definition at line 80 of file SiStripFEDMonitor.cc.

Referenced by beginJob(), and SiStripFEDMonitorPlugin().

unsigned int SiStripFEDMonitorPlugin::nEvt_
private

Definition at line 101 of file SiStripFEDMonitor.cc.

Referenced by analyze(), beginJob(), and SiStripFEDMonitorPlugin().

unsigned int SiStripFEDMonitorPlugin::printDebug_
private

Definition at line 86 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

edm::InputTag SiStripFEDMonitorPlugin::rawDataTag_
private

Definition at line 76 of file SiStripFEDMonitor.cc.

Referenced by analyze(), and SiStripFEDMonitorPlugin().

bool SiStripFEDMonitorPlugin::writeDQMStore_
private

Definition at line 89 of file SiStripFEDMonitor.cc.

Referenced by endJob(), and SiStripFEDMonitorPlugin().