CMS 3D CMS Logo

Public Member Functions | Private Attributes

RPCMonitorRaw Class Reference

#include <RPCMonitorRaw.h>

Inheritance diagram for RPCMonitorRaw:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 get data, convert to digis attach againe to Event
virtual void beginJob ()
virtual void endJob ()
 RPCMonitorRaw (const edm::ParameterSet &cfg)
virtual ~RPCMonitorRaw ()

Private Attributes

MonitorElementme_e [3]
MonitorElementme_mapBadEvents
MonitorElementme_mapGoodEvents
MonitorElementme_t [3]
edm::ParameterSet theConfig
unsigned int theWatchedErrorHistoPos [10]
std::vector< MonitorElement * > theWatchedErrorHistos [3]

Detailed Description

Analyse errors in raw data stream as RPCRawDataCounts produced by RPCRawToDigi

Definition at line 18 of file RPCMonitorRaw.h.


Constructor & Destructor Documentation

RPCMonitorRaw::RPCMonitorRaw ( const edm::ParameterSet cfg) [explicit]

Definition at line 29 of file RPCMonitorRaw.cc.

References edm::ParameterSet::getUntrackedParameter(), i, and theWatchedErrorHistoPos.

 : theConfig(cfg)
{
  for (unsigned int i=0; i<10;i++) theWatchedErrorHistoPos[i]=0;
  std::vector<int> algos = cfg.getUntrackedParameter<std::vector<int> >("watchedErrors");
  for (std::vector<int>::const_iterator it=algos.begin();it!= algos.end(); ++it) {
    unsigned int ialgo = *it;
    if (ialgo < 10) theWatchedErrorHistoPos[ialgo]=1;  // real position initialisain is in begin job. here mark just switched on.
  }
}
RPCMonitorRaw::~RPCMonitorRaw ( ) [virtual]

Definition at line 40 of file RPCMonitorRaw.cc.

References LogTrace.

{ LogTrace("") << "RPCMonitorRaw destructor"; }

Member Function Documentation

void RPCMonitorRaw::analyze ( const edm::Event ev,
const edm::EventSetup es 
) [virtual]

get data, convert to digis attach againe to Event

Implements edm::EDAnalyzer.

Definition at line 103 of file RPCMonitorRaw.cc.

References LinkBoardElectronicIndex::dccInputChannelNum, error, MonitorElement::Fill(), edm::Event::getByType(), me_e, me_mapBadEvents, me_mapGoodEvents, me_t, edm::Handle< T >::product(), LinkBoardElectronicIndex::tbLinkInputNum, RPCRawDataCounts::theBadEvents, RPCRawDataCounts::theGoodEvents, RPCRawDataCounts::theReadoutErrors, RPCRawDataCounts::theRecordTypes, theWatchedErrorHistoPos, theWatchedErrorHistos, rpcrawtodigi::ReadoutError::type(), and rpcrawtodigi::ReadoutError::where().

{

  edm::Handle<RPCRawDataCounts> rawCounts;
  ev.getByType( rawCounts);
  const RPCRawDataCounts & counts = *rawCounts.product(); 

  //
  // record type
  //
  for (IT it=counts.theRecordTypes.begin(); it != counts.theRecordTypes.end(); ++it) 
      me_t[it->first.first-790]->Fill(it->first.second,it->second);

  //
  // good events topology
  //
  for (IT it = counts.theGoodEvents.begin(); it != counts.theGoodEvents.end(); ++it)
     me_mapGoodEvents->Fill(it->first.second, it->first.first, it->second);

  //
  // bad events topology
  //
 for (IT it = counts.theBadEvents.begin(); it != counts.theBadEvents.end(); ++it)
    me_mapBadEvents->Fill(it->first.second, it->first.first, it->second);

  
  //
  // readout errors
  //
  for (IT it=counts.theReadoutErrors.begin(); it != counts.theReadoutErrors.end(); ++it) {
    rpcrawtodigi::ReadoutError error(it->first.second);
    LinkBoardElectronicIndex ele = error.where();    
    rpcrawtodigi::ReadoutError::ReadoutErrorType type = error.type();

    int fed = it->first.first;
    me_e[fed-790]->Fill(type, it->second);

    //
    // in addition fill location map for selected errors
    //
    int idx = theWatchedErrorHistoPos[type]-1;
    if ( idx >= 0) {
      std::vector<MonitorElement* > & wh = theWatchedErrorHistos[fed-790];
      MonitorElement* me = wh[idx]; 
      me->Fill(ele.dccInputChannelNum, ele.tbLinkInputNum, it->second);
    }
  }


//  for (int i=0; i<3; ++i) {
//    me_t[i]->update();
//    me_e[i]->update();
//    std::vector<MonitorElement* > & wh = theWatchedErrorHistos[i];
//    for (std::vector<MonitorElement* >::iterator it=wh.begin(); it != wh.end(); ++it) (*it)->update();
//  }
//  me_mapGoodEvents->update();
//  me_mapBadEvents->update();

 

}
void RPCMonitorRaw::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 42 of file RPCMonitorRaw.cc.

References DQMStore::book1D(), DQMStore::book2D(), RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(), RPCRawDataCountsHistoMaker::emptyReadoutErrorMapHisto(), RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(), getTH1F(), MonitorElement::getTH2F(), timingPdfMaker::histo, i, me_e, me_mapBadEvents, me_mapGoodEvents, me_t, cmsCodeRules::cppFunctionSkipper::operator, DQMStore::setCurrentFolder(), theWatchedErrorHistoPos, and theWatchedErrorHistos.

{

// Get DQM interface
  DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
  
  theDMBE->setCurrentFolder("RPC/LinkMonitor");
  
  me_t[0]=theDMBE->book1D("recordType_790",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(790));
  me_t[1]=theDMBE->book1D("recordType_791",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(791));
  me_t[2]=theDMBE->book1D("recordType_792",RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(792));
  for (int i=0;i<3;++i)me_t[i]->getTH1F()->SetStats(0);
  
  me_e[0]=theDMBE->book1D("readoutErrors_790",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(790));
  me_e[1]=theDMBE->book1D("readoutErrors_791",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(791));
  me_e[2]=theDMBE->book1D("readoutErrors_792",RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(792));
  for (int i=0;i<3;++i)me_e[i]->getTH1F()->SetStats(0);

  me_mapGoodEvents=theDMBE->book2D("mapGoodRecords","mapGoodRecords",36,-0.5,35.5, 3, 789.5,792.5);
  me_mapGoodEvents->getTH2F()->SetNdivisions(3,"y");
  me_mapGoodEvents->getTH2F()->SetXTitle("rmb");
  me_mapGoodEvents->getTH2F()->SetYTitle("fed");
  me_mapGoodEvents->getTH2F()->SetStats(0);
  me_mapBadEvents =theDMBE->book2D("mapErrorRecords", "mapErrorRecords", 36,-0.5,35.5, 3, 789.5,792.5);
  me_mapBadEvents->getTH2F()->SetXTitle("fed");
  me_mapBadEvents->getTH2F()->SetYTitle("rmb");
  me_mapBadEvents->getTH2F()->SetNdivisions(3,"y");
  me_mapBadEvents->getTH2F()->SetStats(0);

  for (unsigned int i=0; i<=9; ++i) {
    if (theWatchedErrorHistoPos[i]) {
      for (unsigned int fed=790; fed <=792; ++fed) {
        TH2F * histo = RPCRawDataCountsHistoMaker::emptyReadoutErrorMapHisto(fed,i);
        MonitorElement* watched = theDMBE->book2D(histo->GetName(),histo);
        theWatchedErrorHistos[fed-790].push_back(watched);
        theWatchedErrorHistoPos[i] = theWatchedErrorHistos[fed-790].size();
      }
    } 
  }

}
void RPCMonitorRaw::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file RPCMonitorRaw.cc.

References f, MonitorElement::getTH1F(), MonitorElement::getTH2F(), edm::ParameterSet::getUntrackedParameter(), histoFile, i, me_e, me_mapBadEvents, me_mapGoodEvents, me_t, theConfig, and theWatchedErrorHistos.

{
bool writeHistos = theConfig.getUntrackedParameter<bool>("writeHistograms", false);
  if (writeHistos) {
    std::string histoFile = theConfig.getUntrackedParameter<std::string>("histoFileName"); 
    TFile f(histoFile.c_str(),"RECREATE");
    for (int i=0; i<3; ++i) {
      me_t[i]->getTH1F()->Write();
      me_e[i]->getTH1F()->Write();
      std::vector<MonitorElement* > & wh = theWatchedErrorHistos[i];
      for (std::vector<MonitorElement* >::const_iterator it=wh.begin(); it != wh.end(); ++it)(*it)->getTH2F()->Write(); 
    }
    me_mapGoodEvents->getTH2F()->Write();
    me_mapBadEvents->getTH2F()->Write();
    edm::LogInfo(" END JOB, histos saved!");
    f.Close();
  }
}

Member Data Documentation

Definition at line 34 of file RPCMonitorRaw.h.

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

Definition at line 36 of file RPCMonitorRaw.h.

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

Definition at line 35 of file RPCMonitorRaw.h.

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

Definition at line 33 of file RPCMonitorRaw.h.

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

Definition at line 38 of file RPCMonitorRaw.h.

Referenced by endJob().

unsigned int RPCMonitorRaw::theWatchedErrorHistoPos[10] [private]

Definition at line 42 of file RPCMonitorRaw.h.

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

Definition at line 39 of file RPCMonitorRaw.h.

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