CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTDataIntegrityTask Class Reference

#include <DTDataIntegrityTask.h>

Inheritance diagram for DTDataIntegrityTask:
DTDataMonitorInterface

List of all members.

Public Member Functions

 DTDataIntegrityTask (const edm::ParameterSet &ps, edm::ActivityRegistry &reg)
bool eventHasErrors () const
void fedEntry (int dduID)
void fedFatal (int dduID)
void fedNonFatal (int dduID)
void postBeginJob ()
void postEndJob ()
void preProcessEvent (const edm::EventID &iEvtid, const edm::Timestamp &iTime)
void processFED (DTDDUData &dduData, const std::vector< DTROS25Data > &rosData, int dduID)
void processROS25 (DTROS25Data &data, int dduID, int ros)
void TimeHistos (std::string histoType)
virtual ~DTDataIntegrityTask ()

Private Member Functions

void bookHistos (const int fedMin, const int fedMax)
void bookHistos (std::string folder, DTROChainCoding code)
void bookHistosROS25 (DTROChainCoding code)
void channelsInCEROS (int cerosId, int chMask, std::vector< int > &channels)
void channelsInROS (int cerosMask, std::vector< int > &channels)
std::string topFolder (bool isFEDIntegrity) const

Private Attributes

DTROChainCoding coding
DQMStoredbe
std::map< std::string,
std::map< int, MonitorElement * > > 
dduHistos
bool doTimeHisto
bool eventErrorFlag
std::set< int > fedBXIds
std::string fedIntegrityFolder
bool getSCInfo
MonitorElementhCorruptionSummary
MonitorElementhFEDEntry
MonitorElementhFEDFatal
MonitorElementhFEDNonFatal
MonitorElementhTTSSummary
std::multimap< std::string,
std::string >::iterator 
it
int mode
int myPrevEv
int myPrevFifoVal [7]
int myPrevRosVal
int myPrevTtsVal
std::multimap< std::string,
std::string > 
names
MonitorElementnEventMonitor
int nevents
int neventsDDU
int neventsROS25
std::string outputFile
edm::ParameterSet parameters
double rob_max [25]
std::map< std::string,
std::map< int, MonitorElement * > > 
robHistos
std::map< int, std::set< int > > rosBxIdsPerFED
std::map< std::string,
std::map< int, MonitorElement * > > 
rosHistos
std::map< int, std::set< int > > rosL1AIdsPerFED
std::map< std::string,
std::map< int, MonitorElement * > > 
rosSHistos
float trigger_counter

Detailed Description

Class for DT Data Integrity.

Date:
2011/06/10 13:23:25
Revision:
1.30
Author:
Marco Zanetti (INFN Padova), Gianluca Cerminara (INFN Torino)

Definition at line 38 of file DTDataIntegrityTask.h.


Constructor & Destructor Documentation

DTDataIntegrityTask::DTDataIntegrityTask ( const edm::ParameterSet ps,
edm::ActivityRegistry reg 
) [explicit]

Definition at line 36 of file DTDataIntegrityTask.cc.

References Exception, fedIntegrityFolder, getSCInfo, edm::ParameterSet::getUntrackedParameter(), LogTrace, mode, neventsDDU, neventsROS25, postBeginJob(), preProcessEvent(), dtDQMClient_cfg::processingMode, edm::ActivityRegistry::watchPostBeginJob(), and edm::ActivityRegistry::watchPreProcessEvent().

                                                                                           : nevents(0) , dbe(0) {

  // Register the methods that we want to schedule
  //   reg.watchPostEndJob(this,&DTDataIntegrityTask::postEndJob);
  reg.watchPostBeginJob(this,&DTDataIntegrityTask::postBeginJob);
  reg.watchPreProcessEvent(this,&DTDataIntegrityTask::preProcessEvent);
  
  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
    << "[DTDataIntegrityTask]: Constructor" <<endl;

  neventsDDU = 0;
  neventsROS25 = 0;

//   //If you want info VS time histos
//   doTimeHisto =  ps.getUntrackedParameter<bool>("doTimeHisto", false);
  // Plot quantities about SC
  getSCInfo = ps.getUntrackedParameter<bool>("getSCInfo", false);

  fedIntegrityFolder    = ps.getUntrackedParameter<string>("fedIntegrityFolder","DT/FEDIntegrity"); 
  
  string processingMode = ps.getUntrackedParameter<string>("processingMode","Online");

  // processing mode flag to select plots to be produced and basedirs CB vedi se farlo meglio...
  if (processingMode == "Online") {
    mode = 0;
  } else if(processingMode == "SM") {
    mode = 1;
  } else if (processingMode == "Offline") {
    mode = 2;
  } else if (processingMode == "HLT") {
    mode = 3;
  } else {
    throw cms::Exception("MissingParameter")
      << "[DTDataIntegrityTask]: processingMode :" << processingMode 
      << " invalid! Must be Online, SM, Offline or HLT !" << endl;
  }

}
DTDataIntegrityTask::~DTDataIntegrityTask ( ) [virtual]

Definition at line 77 of file DTDataIntegrityTask.cc.

References LogTrace, and neventsDDU.

                                          {
  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
    <<"[DTDataIntegrityTask]: Destructor. Analyzed "<< neventsDDU <<" events"<<endl;
}

Member Function Documentation

void DTDataIntegrityTask::bookHistos ( const int  fedMin,
const int  fedMax 
) [private]

Definition at line 102 of file DTDataIntegrityTask.cc.

References DQMStore::book1D(), DQMStore::book2D(), DQMStore::bookFloat(), dbe, hCorruptionSummary, hFEDEntry, hFEDFatal, hFEDNonFatal, hTTSSummary, nEventMonitor, MonitorElement::setAxisTitle(), MonitorElement::setBinLabel(), DQMStore::setCurrentFolder(), and topFolder().

Referenced by bookHistosROS25(), and postBeginJob().

                                                                       {

  dbe->setCurrentFolder("DT/EventInfo/Counters");
  nEventMonitor = dbe->bookFloat("nProcessedEventsDataIntegrity");

  // Standard FED integrity histos
  dbe->setCurrentFolder(topFolder(true));

  int nFED = (fedMax - fedMin)+1;

  hFEDEntry = dbe->book1D("FEDEntries","# entries per DT FED",nFED,fedMin,fedMax+1);
  hFEDFatal = dbe->book1D("FEDFatal","# fatal errors DT FED",nFED,fedMin,fedMax+1);
  hFEDNonFatal = dbe->book1D("FEDNonFatal","# NON fatal errors DT FED",nFED,fedMin,fedMax+1);


  dbe->setCurrentFolder(topFolder(false));
  hTTSSummary = dbe->book2D("TTSSummary","Summary Status TTS",nFED,fedMin,fedMax+1,9,1,10);
  hTTSSummary->setAxisTitle("FED",1);
  hTTSSummary->setBinLabel(1,"ROS PAF",2);      
  hTTSSummary->setBinLabel(2,"DDU PAF",2);      
  hTTSSummary->setBinLabel(3,"ROS PAF",2);      
  hTTSSummary->setBinLabel(4,"DDU PAF",2);      
  hTTSSummary->setBinLabel(5,"DDU Full",2);     
  hTTSSummary->setBinLabel(6,"L1A Mism.",2);    
  hTTSSummary->setBinLabel(7,"ROS Error",2);    
  hTTSSummary->setBinLabel(8,"BX Mism.",2);     
  hTTSSummary->setBinLabel(9,"DDU Logic Err.",2);       

  // bookkeeping of the 
  
  hCorruptionSummary =  dbe->book2D("DataCorruptionSummary", "Data Corruption Sources",
                                   nFED,fedMin,fedMax+1, 8, 1, 9);
  hCorruptionSummary->setAxisTitle("FED",1);
  hCorruptionSummary->setBinLabel(1,"Miss Ch.",2);      
  hCorruptionSummary->setBinLabel(2,"ROS BX mism",2);   
  hCorruptionSummary->setBinLabel(3,"DDU BX mism",2);   
  hCorruptionSummary->setBinLabel(4,"ROS L1A mism",2);  
  hCorruptionSummary->setBinLabel(5,"Miss Payload",2);  
  hCorruptionSummary->setBinLabel(6,"FCRC bit",2);      
  hCorruptionSummary->setBinLabel(7,"Header check",2);  
  hCorruptionSummary->setBinLabel(8,"Triler Check",2);  

}
void DTDataIntegrityTask::bookHistos ( std::string  folder,
DTROChainCoding  code 
) [private]
void DTDataIntegrityTask::bookHistosROS25 ( DTROChainCoding  code) [private]

Definition at line 519 of file DTDataIntegrityTask.cc.

References bookHistos(), getSCInfo, and mode.

Referenced by postBeginJob().

                                                              {
    bookHistos( string("ROS"), code);
//     for(int robId = 0; robId != 25; ++robId) {
//       code.setROB(robId);
//       bookHistos( string("TDCError"), code);
//     }
    if(mode <= 1)
      if(getSCInfo)
        bookHistos( string("SC"), code);
}
void DTDataIntegrityTask::channelsInCEROS ( int  cerosId,
int  chMask,
std::vector< int > &  channels 
) [private]

Definition at line 1167 of file DTDataIntegrityTask.cc.

Referenced by processROS25().

                                                                                        {
  for (int iCh=0; iCh<6;++iCh) {
    if ((chMask >> iCh) & 0x1){
      channels.push_back(cerosId*6+iCh);
    }
  }
  return;
}
void DTDataIntegrityTask::channelsInROS ( int  cerosMask,
std::vector< int > &  channels 
) [private]

Definition at line 1176 of file DTDataIntegrityTask.cc.

Referenced by processROS25().

                                                                           {
  for (int iCeros=0; iCeros<5;++iCeros) {
    if ((cerosMask >> iCeros) & 0x1){
      for (int iCh=0; iCh<6;++iCh) {
        channels.push_back(iCeros*6+iCh);
      }
    }
  }
  return;
}
bool DTDataIntegrityTask::eventHasErrors ( ) const

Definition at line 1131 of file DTDataIntegrityTask.cc.

References eventErrorFlag.

Referenced by DTDataErrorFilter::filter().

                                               {
  return eventErrorFlag;
}
void DTDataIntegrityTask::fedEntry ( int  dduID) [virtual]

Implements DTDataMonitorInterface.

Definition at line 1138 of file DTDataIntegrityTask.cc.

References MonitorElement::Fill(), and hFEDEntry.

                                            {
  hFEDEntry->Fill(dduID);
}
void DTDataIntegrityTask::fedFatal ( int  dduID) [virtual]

Implements DTDataMonitorInterface.

Definition at line 1145 of file DTDataIntegrityTask.cc.

References MonitorElement::Fill(), and hFEDFatal.

                                            {
  hFEDFatal->Fill(dduID);
}
void DTDataIntegrityTask::fedNonFatal ( int  dduID) [virtual]

Implements DTDataMonitorInterface.

Definition at line 1152 of file DTDataIntegrityTask.cc.

References MonitorElement::Fill(), and hFEDNonFatal.

                                               {
  hFEDNonFatal->Fill(dduID);
}
void DTDataIntegrityTask::postBeginJob ( )

Definition at line 1213 of file DTDataIntegrityTask.cc.

References bookHistos(), bookHistosROS25(), dbe, LogTrace, FEDNumbering::MAXDTFEDID, FEDNumbering::MINDTFEDID, cmsCodeRules::cppFunctionSkipper::operator, DTROChainCoding::setDDU(), and DTROChainCoding::setROS().

Referenced by DTDataIntegrityTask().

                                       {
  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: postBeginJob" <<endl;
  // get the DQMStore service if needed
  dbe = edm::Service<DQMStore>().operator->();    
  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask] Get DQMStore service" << endl;
  

  
  // Loop over the DT FEDs
  int FEDIDmin = FEDNumbering::MINDTFEDID;
  int FEDIDMax = FEDNumbering::MAXDTFEDID;

  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
    << " FEDS: " << FEDIDmin  << " to " <<  FEDIDMax << " in the RO" << endl;

  // book FED integrity histos
  bookHistos(FEDIDmin, FEDIDMax);

  // static booking of the histograms
  for(int fed = FEDIDmin; fed <= FEDIDMax; ++fed) { // loop over the FEDs in the readout
    DTROChainCoding code;
    code.setDDU(fed);
    
    bookHistos( string("ROS_S"), code);

    bookHistos( string("DDU"), code);

    for(int ros = 1; ros <= 12; ++ros) {// loop over all ROS
      code.setROS(ros);
      bookHistosROS25(code);
    }
  }

}
void DTDataIntegrityTask::postEndJob ( )

Definition at line 93 of file DTDataIntegrityTask.cc.

References LogTrace.

                                    {
  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
    << "[DTDataIntegrityTask]: postEndJob called!" <<endl;

//   if(doTimeHisto) TimeHistos("Event_word_vs_time");  
        
}
void DTDataIntegrityTask::preProcessEvent ( const edm::EventID iEvtid,
const edm::Timestamp iTime 
)

Definition at line 1187 of file DTDataIntegrityTask.cc.

References eventErrorFlag, fedBXIds, MonitorElement::Fill(), LogTrace, nEventMonitor, nevents, rosBxIdsPerFED, and rosL1AIdsPerFED.

Referenced by DTDataIntegrityTask().

                                                                                             {

  nevents++;
  nEventMonitor->Fill(nevents);

  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: preProcessEvent" <<endl;
  // clear the set of BXids from the ROSs
  for(map<int, set<int> >::iterator rosBxIds = rosBxIdsPerFED.begin();
      rosBxIds != rosBxIdsPerFED.end(); ++rosBxIds) {
    (*rosBxIds).second.clear();
  }

  fedBXIds.clear();

  for(map<int, set<int> >::iterator rosL1AIds = rosL1AIdsPerFED.begin();
      rosL1AIds != rosL1AIdsPerFED.end(); ++rosL1AIds) {
    (*rosL1AIds).second.clear();
  }

  // reset the error flag
  eventErrorFlag = false;

}
void DTDataIntegrityTask::processFED ( DTDDUData dduData,
const std::vector< DTROS25Data > &  rosData,
int  dduID 
) [virtual]

Implements DTDataMonitorInterface.

Definition at line 845 of file DTDataIntegrityTask.cc.

References DTDDUSecondStatusWord::busyROSPAF(), FEDHeader::bxID(), DTDDUSecondStatusWord::bxIDError(), FEDTrailer::check(), FEDHeader::check(), DTDDUData::crcErrorBit(), dduHistos, fedBXIds, DTDDUSecondStatusWord::fifoAlmostFull(), DTDDUSecondStatusWord::fifoFull(), MonitorElement::Fill(), DTDDUData::getDDUHeader(), DTROChainCoding::getDDUID(), DTDDUData::getDDUTrailer(), DTDDUData::getFirstStatusWord(), DTDDUData::getSecondStatusWord(), hCorruptionSummary, MultipleCompare::header, hFEDEntry, hFEDFatal, hTTSSummary, i, DTDDUSecondStatusWord::inputFifoAlmostFull(), DTDDUSecondStatusWord::inputFifoFull(), DTDDUSecondStatusWord::l1AIDError(), FEDTrailer::lenght(), LogTrace, FEDHeader::lvl1ID(), mode, neventsDDU, DTDDUSecondStatusWord::outOfSynchROSError(), DTDDUSecondStatusWord::outputFifoAlmostFull(), DTDDUSecondStatusWord::outputFifoFull(), rosBxIdsPerFED, rosL1AIdsPerFED, DTDDUSecondStatusWord::rosList(), DTROChainCoding::setDDU(), FEDHeader::triggerType(), FEDTrailer::ttsBits(), and DTDDUSecondStatusWord::warningROSPAF().

                                                                                                      {

  neventsDDU++;
  if (neventsDDU%1000 == 0)
    LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
      << "[DTDataIntegrityTask]: " << neventsDDU << " events analyzed by processFED" << endl;


  DTROChainCoding code;
  code.setDDU(ddu);

  hFEDEntry->Fill(code.getDDUID());

  FEDTrailer trailer = data.getDDUTrailer();
  FEDHeader header = data.getDDUHeader();

  // check consistency of header and trailer
  if(!header.check()) {
    // error code 7
    hFEDFatal->Fill(code.getDDUID());
    hCorruptionSummary->Fill(code.getDDUID(), 7);
  }

  if(!trailer.check()) {
    // error code 8
    hFEDFatal->Fill(code.getDDUID());
    hCorruptionSummary->Fill(code.getDDUID(), 8);
  }

  // check CRC error bit set by DAQ before sending data on SLink
  if(data.crcErrorBit()) {
    // error code 6
    hFEDFatal->Fill(code.getDDUID());
    hCorruptionSummary->Fill(code.getDDUID(), 6);
  }

  DTDDUSecondStatusWord secondWord = data.getSecondStatusWord();

  // Fill the status summary of the TTS


  //1D HISTO WITH TTS VALUES form trailer (7 bins = 7 values)
  int ttsCodeValue = -1;
  int ttsSummaryBin = -1;

  switch(trailer.ttsBits()) {
  case 0:{ //disconnected
    ttsCodeValue = 0;
    break;
  }
  case 1:{ //warning overflow
    ttsCodeValue = 1;
    if(secondWord.warningROSPAF()) { // ROS PAF
      ttsSummaryBin = 1;
    } else { // DDU PAF
      ttsSummaryBin = 2;
    }
    
    break;
  }
  case 2:{ //out of sinch
    ttsCodeValue = 2;
    bool knownOrigin = false;
    if(secondWord.outOfSynchROSError()) {// ROS Error
      ttsSummaryBin = 7;
      knownOrigin = true;
    }
    if(secondWord.l1AIDError()) {// L1A Mism.
      ttsSummaryBin = 6;
      knownOrigin = true;
    }
    if(secondWord.bxIDError()) {// BX Mism.
      ttsSummaryBin = 8;
      knownOrigin = true;
    }
    if(secondWord.outputFifoFull() || secondWord.inputFifoFull() || secondWord.fifoFull()) { // DDU Full
      ttsSummaryBin = 5;
      knownOrigin = true;
    }
    if(!knownOrigin) ttsSummaryBin = 9; // Error in DDU logic

    break;
  }
  case 4:{ //busy
    ttsCodeValue = 3;
    bool knownOrigin = false;
    if(secondWord.busyROSPAF()) { // ROS PAF
      ttsSummaryBin = 3;
      knownOrigin = true;
    } 
    if(secondWord.outputFifoAlmostFull() || secondWord.inputFifoAlmostFull() || secondWord.fifoAlmostFull() ){ // DDU PAF
      ttsSummaryBin = 4;
      knownOrigin = true;
    }
    if(!knownOrigin) ttsSummaryBin = 9; // Error in DDU logic
    break;
  }
  case 8:{ //ready
    ttsCodeValue = 4;
    break;
  }
  case 12:{ //error
    ttsCodeValue = 5;
    break;
  }
  case 16:{ //disconnected
    ttsCodeValue = 6;
    break;
  }
  default:{
    LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
      <<"[DTDataIntegrityTask] DDU control: wrong TTS value "<<trailer.ttsBits()<<endl;
    ttsCodeValue = 7;
  }
  }
  if(mode <= 1) dduHistos["TTSValues"][code.getDDUID()]->Fill(ttsCodeValue);
  if(ttsSummaryBin != -1) {
    hTTSSummary->Fill(ddu, ttsSummaryBin);
  }






  //2D HISTO: ROS VS STATUS (8 BIT = 8 BIN) from 1st-2nd status words (9th BIN FROM LIST OF ROS in 2nd status word)
  MonitorElement* hROSStatus = dduHistos["ROSStatus"][code.getDDUID()];
  //1D HISTO: NUMBER OF ROS IN THE EVENTS from 2nd status word

  int rosList = secondWord.rosList();
  set<int> rosPositions;
  for(int i=0;i<12;i++) {
    if(rosList & 0x1) {
      rosPositions.insert(i);
      //9th BIN FROM LIST OF ROS in 2nd status word
      if(mode <= 2) hROSStatus->Fill(8,i,1);
    }
    rosList >>= 1;
  }

  int channel=0;
  for (vector<DTDDUFirstStatusWord>::const_iterator fsw_it = data.getFirstStatusWord().begin();
       fsw_it != data.getFirstStatusWord().end(); fsw_it++) {
    // assuming association one-to-one between DDU channel and ROS
    if(mode <= 2) {
      hROSStatus->Fill(0,channel,(*fsw_it).channelEnabled());
      hROSStatus->Fill(1,channel,(*fsw_it).timeout());
      hROSStatus->Fill(2,channel,(*fsw_it).eventTrailerLost());
      hROSStatus->Fill(3,channel,(*fsw_it).opticalFiberSignalLost());
      hROSStatus->Fill(4,channel,(*fsw_it).tlkPropagationError());
      hROSStatus->Fill(5,channel,(*fsw_it).tlkPatternError());
      hROSStatus->Fill(6,channel,(*fsw_it).tlkSignalLost());
      hROSStatus->Fill(7,channel,(*fsw_it).errorFromROS());
    }
    // check that the enabled channel was also in the read-out
    if((*fsw_it).channelEnabled() == 1 &&
       rosPositions.find(channel) == rosPositions.end()) {
      if(mode <= 2) hROSStatus->Fill(9,channel,1);
      // error code 1
      hFEDFatal->Fill(code.getDDUID());
      hCorruptionSummary->Fill(code.getDDUID(), 1);
    }
    channel++;
  }


  // ---------------------------------------------------------------------
  // cross checks between FED and ROS data
  // check the BX ID against the ROSs
  set<int> rosBXIds = rosBxIdsPerFED[ddu];
  if((rosBXIds.size() > 1 || rosBXIds.find(header.bxID()) == rosBXIds.end()) && rosBXIds.size() != 0) { // in this case look for faulty ROSs
    for(vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
        rosControlData != rosData.end(); ++rosControlData) { // loop over the ROS data
      for (vector<DTROSDebugWord>::const_iterator debug_it = (*rosControlData).getROSDebugs().begin();
           debug_it != (*rosControlData).getROSDebugs().end(); debug_it++) { // Loop over ROS debug words
        if ((*debug_it).debugType() == 0 && (*debug_it).debugMessage() != header.bxID()) { // check the BX
          int ros = (*rosControlData).getROSID();
          // fill the error bin
          if(mode <= 2) hROSStatus->Fill(11,ros-1);
          // error code 2
          hFEDFatal->Fill(code.getDDUID());
          hCorruptionSummary->Fill(code.getDDUID(), 2);
        }
      }
    }
  }

  // check the BX ID against other FEDs
  fedBXIds.insert(header.bxID());
  if(fedBXIds.size() != 1) {
    LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
      << "ERROR: FED " << ddu << " BX ID different from other feds: " << header.bxID() << endl;
    // error code 3
    hFEDFatal->Fill(code.getDDUID());
    hCorruptionSummary->Fill(code.getDDUID(), 3);
  }


  // check the L1A ID against the ROSs 
  set<int> rosL1AIds = rosL1AIdsPerFED[ddu];
  if((rosL1AIds.size() > 1 || rosL1AIds.find(header.lvl1ID()-1) == rosL1AIds.end()) && rosL1AIds.size() != 0) { // in this case look for faulty ROSs
    //If L1A_ID error identify which ROS has wrong L1A 
    for (vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
         rosControlData != rosData.end(); rosControlData++) { // loop over the ROS data
      int ROSHeader_TTCCount = ((*rosControlData).getROSHeader().TTCEventCounter() + 1) % 0x1000000; // fix comparison in case of last counting bin in ROS /first one in DDU
      if( ROSHeader_TTCCount != header.lvl1ID() ) { 
        int ros = (*rosControlData).getROSID();
        if(mode <= 2) hROSStatus->Fill(10,ros-1);
        // error code 4
        hFEDFatal->Fill(code.getDDUID());
        hCorruptionSummary->Fill(code.getDDUID(), 4);
      }
    }
  }

  //1D HISTOS: EVENT LENGHT from trailer
  int fedEvtLenght = trailer.lenght()*8;
  //   if(fedEvtLenght > 16000) fedEvtLenght = 16000; // overflow bin
  dduHistos["EventLenght"][code.getDDUID()]->Fill(fedEvtLenght);

  if(mode > 1) return;


  // size of the list of ROS in the Read-Out
  dduHistos["ROSList"][code.getDDUID()]->Fill(rosPositions.size());


  //2D HISTO: FIFO STATUS from 2nd status word
  MonitorElement *hFIFOStatus = dduHistos["FIFOStatus"][code.getDDUID()];
  int inputFifoFull = secondWord.inputFifoFull();
  int inputFifoAlmostFull = secondWord.inputFifoAlmostFull();
  int fifoFull = secondWord.fifoFull();
  int fifoAlmostFull = secondWord.fifoAlmostFull();
  int outputFifoFull = secondWord.outputFifoFull();
  int outputFifoAlmostFull = secondWord.outputFifoAlmostFull();
  for(int i=0;i<3;i++){
    if(inputFifoFull & 0x1){
      hFIFOStatus->Fill(i,0);
    }
    if(inputFifoAlmostFull & 0x1){
      hFIFOStatus->Fill(i,1);
    }
    if(fifoFull & 0x1){
      hFIFOStatus->Fill(3+i,0);
    }
    if(fifoAlmostFull & 0x1){
      hFIFOStatus->Fill(3+i,1);
    }
    if(!(inputFifoFull & 0x1) && !(inputFifoAlmostFull & 0x1)){
      hFIFOStatus->Fill(i,2);
    }
    if(!(fifoFull & 0x1) && !(fifoAlmostFull & 0x1)){
      hFIFOStatus->Fill(3+i,2);
    }
    inputFifoFull >>= 1;
    inputFifoAlmostFull >>= 1;
    fifoFull >>= 1;
    fifoAlmostFull >>= 1;
  }

  if(outputFifoFull){
    hFIFOStatus->Fill(6,0);
  }
  if(outputFifoAlmostFull){
    hFIFOStatus->Fill(6,1);
  }
  if(!outputFifoFull && !outputFifoAlmostFull){
    hFIFOStatus->Fill(6,2);
  }



 



  //1D HISTO: EVENT TYPE from header
  dduHistos["EventType"][code.getDDUID()]->Fill(header.triggerType());

  // fill the distribution of the BX ids
  dduHistos["BXID"][code.getDDUID()]->Fill(header.bxID());


}
void DTDataIntegrityTask::processROS25 ( DTROS25Data data,
int  dduID,
int  ros 
) [virtual]

Implements DTDataMonitorInterface.

Definition at line 531 of file DTDataIntegrityTask.cc.

References DTROBHeaderWord::bunchID(), channelsInCEROS(), channelsInROS(), eventErrorFlag, DTROSTrailerWord::EventWordCount(), MonitorElement::Fill(), FirstRos, DTROChainCoding::getDDUID(), DTROChainCoding::getROB(), DTROS25Data::getROBHeaders(), DTROS25Data::getROBTrailers(), DTROChainCoding::getROS(), DTROS25Data::getROSDebugs(), DTROS25Data::getROSErrors(), DTROS25Data::getROSHeader(), DTROChainCoding::getROSID(), DTROS25Data::getROSTrailer(), DTROChainCoding::getSCID(), getSCInfo, DTROS25Data::getSCPrivHeader(), DTROS25Data::getSCTrailer(), DTROS25Data::getTDCData(), DTROS25Data::getTDCError(), DTROSTrailerWord::l1AFifoOccupancy(), LogTrace, mode, nevents, neventsROS25, DTLocalTriggerSectorCollectorHeaderWord::NumberOf16bitWords(), DTTDCMeasurementWord::PC(), ResetCount_unfolded, DTROBHeaderWord::robID(), rosBxIdsPerFED, rosHistos, rosL1AIdsPerFED, rosSHistos, ROSWords_t(), DTROChainCoding::setDDU(), DTROChainCoding::setROB(), DTROChainCoding::setROS(), DTROSTrailerWord::TPX(), DTROSHeaderWord::TTCEventCounter(), and DTLocalTriggerTrailerWord::wordCount().

                                                                           {
  neventsROS25++; // FIXME: implement a counter which makes sense

//   if (neventsROS25%1000 == 0)
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << "[DTDataIntegrityTask]: " << neventsROS25 << " events analyzed by processROS25" << endl;

  // The ID of the RO board (used to map the histos)
  DTROChainCoding code;
  code.setDDU(ddu);
  code.setROS(ros);

  MonitorElement* ROSSummary = rosSHistos["ROSSummary"][code.getDDUID()];

  // Summary of all ROB errors
  MonitorElement* ROSError = 0;
  if(mode <= 2) ROSError = rosHistos["ROSError"][code.getROSID()];

  // L1A ids to be checked against FED one
  rosL1AIdsPerFED[ddu].insert(data.getROSHeader().TTCEventCounter());

  // ROS errors


  // check for TPX errors
  if (data.getROSTrailer().TPX() != 0) {
    LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << " TXP error en ROS "
                                                                      << code.getROS() << endl;
    ROSSummary->Fill(9,code.getROS());
  }

  // L1 Buffer almost full (non-critical error!)
  if(data.getROSTrailer().l1AFifoOccupancy() > 31) {
     ROSSummary->Fill(10,code.getROS());
   }
  
  // FIXME: what is this about???
  if (neventsROS25 == 1) FirstRos = code.getROSID();
  if (code.getROSID() == FirstRos) nevents++ ;


  for (vector<DTROSErrorWord>::const_iterator error_it = data.getROSErrors().begin();
       error_it != data.getROSErrors().end(); error_it++) { // Loop over ROS error words
    
    LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << " Error in ROS " << code.getROS()
                                                                      << " ROB Id " << (*error_it).robID()
                                                                      << " Error type " << (*error_it).errorType() << endl;

    // Fill the ROSSummary (1 per FED) histo
    ROSSummary->Fill((*error_it).errorType(), code.getROS());
    if((*error_it).errorType() <= 11) { // set error flag
       eventErrorFlag = true;
    }
    
    if(mode <= 2) {
      // Fill the ROB Summary (1 per ROS) histo
      if ((*error_it).robID() != 31) {
        ROSError->Fill((*error_it).errorType(),(*error_it).robID());
      }
      else if ((*error_it).errorType() == 4) {
        vector<int> channelBins;
        channelsInROS((*error_it).cerosID(),channelBins);
        vector<int>::const_iterator channelIt  = channelBins.begin();
        vector<int>::const_iterator channelEnd = channelBins.end();
        for(;channelIt!=channelEnd;++channelIt) {
          ROSError->Fill(4,(*channelIt));
        }
      }
    }
  }


  int ROSDebug_BunchNumber = -1;
  int ROSDebug_BcntResCntLow = 0;
  int ROSDebug_BcntResCntHigh = 0;
  int ROSDebug_BcntResCnt = 0;
  
  for (vector<DTROSDebugWord>::const_iterator debug_it = data.getROSDebugs().begin();
       debug_it != data.getROSDebugs().end(); debug_it++) { // Loop over ROS debug words
    
    int debugROSSummary = 0;
    int debugROSError   = 0;
    vector<int> debugBins;
    bool hasEvIdMis = false;
    vector<int> evIdMisBins;

    if ((*debug_it).debugType() == 0 ) {
      ROSDebug_BunchNumber = (*debug_it).debugMessage();
    } else if ((*debug_it).debugType() == 1 ) {
      ROSDebug_BcntResCntLow = (*debug_it).debugMessage();
    } else if ((*debug_it).debugType() == 2 ) {
      ROSDebug_BcntResCntHigh = (*debug_it).debugMessage();
    } else if ((*debug_it).debugType() == 3) {
      if ((*debug_it).dontRead()){  
        debugROSSummary = 11;
        debugROSError   = 8;
        if (mode <= 2) channelsInCEROS((*debug_it).cerosIdCerosStatus(),(*debug_it).dontRead(),debugBins);
      } if ((*debug_it).evIdMis()){
        hasEvIdMis = true;
        if (mode <= 2) channelsInCEROS((*debug_it).cerosIdCerosStatus(),(*debug_it).evIdMis(),evIdMisBins);
      }
    } else if ((*debug_it).debugType() == 4 &&
               (*debug_it).cerosIdRosStatus()){
      debugROSSummary = 13;
      debugROSError   = 10;
      if (mode <= 2) channelsInROS((*debug_it).cerosIdRosStatus(),debugBins);
    }
 
    if (debugROSSummary) {
      ROSSummary->Fill(debugROSSummary,code.getROS());
      if (mode <= 2) {
        vector<int>::const_iterator channelIt  = debugBins.begin();
        vector<int>::const_iterator channelEnd = debugBins.end();
        for (;channelIt!=channelEnd;++channelIt) {
          ROSError->Fill(debugROSError,(*channelIt));
        }
      }
    }
    
    if (hasEvIdMis) {
      ROSSummary->Fill(12,code.getROS());
      if (mode <= 2) {
        vector<int>::const_iterator channelIt  = evIdMisBins.begin();
        vector<int>::const_iterator channelEnd = evIdMisBins.end();
        for (;channelIt!=channelEnd;++channelIt) {
          ROSError->Fill(9,(*channelIt));
        }
      }
    }
        
  }
  
  ROSDebug_BcntResCnt = (ROSDebug_BcntResCntHigh << 15) + ROSDebug_BcntResCntLow;
  //   LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
  //     << " ROS: " << code.getROS() << " ROSDebug_BunchNumber " << ROSDebug_BunchNumber
  //     << " ROSDebug_BcntResCnt " << ROSDebug_BcntResCnt << endl;
  

  //     Event words vs time
  // FIXME: what is this doing???
  ROSWords_t(ResetCount_unfolded,code.getROS(),ROSDebug_BcntResCnt,nevents);

  // fill hists it here
  //   histoType = "Event_word_vs_time";          
  //   if (rosHistos[histoType].find(code.getROSID()) != rosHistos[histoType].end()){
  //   (rosHistos.find(histoType)->second).find(code.getROSID())->second->
  //            Fill((ResetCount_unfolded),data.getROSTrailer().EventWordCount());
  //   (rosHistos.find(histoType)->second).find(code.getROSID())->second->setAxisTitle("Time(s)",1);
  //    }
  //   else {
  //      (rosHistos.find(histoType)->second).find(code.getROSID())->second->
  //                    Fill((ResetCount_unfolded),data.getROSTrailer().EventWordCount());}  


        

  // ROB Group Header
  // Check the BX of the ROB headers against the BX of the ROS
  for (vector<DTROBHeader>::const_iterator rob_it = data.getROBHeaders().begin();
       rob_it != data.getROBHeaders().end(); rob_it++) { // loop over ROB headers
    
    code.setROB((*rob_it).first);
    DTROBHeaderWord robheader = (*rob_it).second;  

    rosBxIdsPerFED[ddu].insert(ROSDebug_BunchNumber);
    
    if (robheader.bunchID() != ROSDebug_BunchNumber) {
      // fill ROS Summary plot
      ROSSummary->Fill(8,code.getROS());
      eventErrorFlag = true;
      
      // fill ROB Summary plot for that particular ROS
      if(mode <= 2) ROSError->Fill(7,robheader.robID());
    }
  }


  if(mode <= 1) { // produce only when not in HLT 
    // ROB Trailer
    for (vector<DTROBTrailerWord>::const_iterator robt_it = data.getROBTrailers().begin();
         robt_it != data.getROBTrailers().end(); robt_it++) { // loop over ROB trailers 
      float  wCount = (*robt_it).wordCount()<100. ? (*robt_it).wordCount() : 99.9; 
      rosHistos["ROB_mean"][code.getROSID()]->Fill((*robt_it).robID(),wCount);
    }

//     // Trigger frequency 
//     double frequency = 0;
//     // FIXME: how is the frequency computed
//     ROS_L1A_Frequency(code.getROS(),ROSDebug_BcntResCnt,neventsROS25,frequency,trigger_counter);
//     rosHistos["Trigger_frequency"][code.getROSID()]->Fill(frequency);

    // Plot the event lenght //NOHLT
    int rosEventLenght = data.getROSTrailer().EventWordCount()*4;
    if(rosEventLenght > 1600) rosEventLenght = 1600;
    rosHistos["ROSEventLenght"][code.getROSID()]->Fill(rosEventLenght);
  }

   
  // TDC Data  
  for (vector<DTTDCData>::const_iterator tdc_it = data.getTDCData().begin();
       tdc_it != data.getTDCData().end(); tdc_it++) { // loop over TDC data

    DTTDCMeasurementWord tdcDatum = (*tdc_it).second;

    if ( tdcDatum.PC() !=0)  {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " PC error in ROS " << code.getROS() << " TDC " << (*tdc_it).first << endl;
      //     fill ROS Summary plot
      ROSSummary->Fill(7,code.getROS());

      eventErrorFlag = true;

      // fill ROB Summary plot for that particular ROS
      if(mode <= 2) ROSError->Fill(6,(*tdc_it).first);
    }
  }

  // TDC Error  
  for (vector<DTTDCError>::const_iterator tdc_it = data.getTDCError().begin();
       tdc_it != data.getTDCError().end(); tdc_it++) { // loop over TDC errors

    code.setROB((*tdc_it).first);

    int tdcError_ROSSummary = 0;
    int tdcError_ROSError = 0;
    int tdcError_TDCHisto = 0;

    if(((*tdc_it).second).tdcError() & 0x4000 ) {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " ROS " << code.getROS() << " ROB " << code.getROB()
        << " Internal fatal Error 4000 in TDC " << (*tdc_it).first << endl;

      tdcError_ROSSummary = 14;
      tdcError_ROSError   = 11;
      tdcError_TDCHisto   = 0;

    } else if ( ((*tdc_it).second).tdcError() & 0x0249 ) {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " ROS " << code.getROS() << " ROB " << code.getROB()
        << " TDC FIFO overflow in TDC " << (*tdc_it).first << endl;

      tdcError_ROSSummary = 15;
      tdcError_ROSError   = 12;
      tdcError_TDCHisto   = 1;

    } else if ( ((*tdc_it).second).tdcError() & 0x0492 ) {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " ROS " << code.getROS() << " ROB " << code.getROB()
        << " TDC L1 buffer overflow in TDC " << (*tdc_it).first << endl;
      
      tdcError_ROSSummary = 16;
      tdcError_ROSError   = 13;
      tdcError_TDCHisto   = 2;

    } else if ( ((*tdc_it).second).tdcError() & 0x2000 ) {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " ROS " << code.getROS() << " ROB " << code.getROB()
        << " TDC L1A FIFO overflow in TDC " << (*tdc_it).first << endl;
      
      tdcError_ROSSummary = 17;
      tdcError_ROSError   = 14;
      tdcError_TDCHisto   = 3;

    } else if ( ((*tdc_it).second).tdcError() & 0x0924 ) {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " ROS " << code.getROS() << " ROB " << code.getROB()
        << " TDC hit error in TDC " << (*tdc_it).first << endl;
      
      tdcError_ROSSummary = 18;
      tdcError_ROSError   = 15;
      tdcError_TDCHisto   = 4;

    } else if ( ((*tdc_it).second).tdcError() & 0x1000 ) {
      LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " ROS " << code.getROS() << " ROB " << code.getROB()
        << " TDC hit rejected in TDC " << (*tdc_it).first << endl;
      
      tdcError_ROSSummary = 19;
      tdcError_ROSError   = 16;
      tdcError_TDCHisto   = 5;

    } else {
      LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
        << " TDC error code not known " << ((*tdc_it).second).tdcError() << endl;
    }
    
    ROSSummary->Fill(tdcError_ROSSummary,code.getROS());

    if(tdcError_ROSSummary <= 15) {
      eventErrorFlag = true;
    }

    if(mode <= 2) {
      ROSError->Fill(tdcError_ROSError,(*tdc_it).first);
      if(mode <= 1)
        rosHistos["TDCError"][code.getROSID()]->Fill(tdcError_TDCHisto+6*((*tdc_it).second).tdcID(),(*tdc_it).first);
    }
  }

  // Read SC data
  if (mode <= 1 && getSCInfo) {
    // SC Data

    // NumberOf16bitWords counts the # of words + 1 subheader
    // the SC includes the SC "private header" and the ROS header and trailer (= NumberOf16bitWords +3)
    rosHistos["SCSizeVsROSSize"][code.getSCID()]->Fill(ros,data.getSCPrivHeader().NumberOf16bitWords()+3-data.getSCTrailer().wordCount());
    
  }




}
void DTDataIntegrityTask::TimeHistos ( std::string  histoType)

Definition at line 483 of file DTDataIntegrityTask.cc.

References newFWLiteAna::bin, dbe, DQMStore::get(), MonitorElement::getBinContent(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), it, j, names, and MonitorElement::setAxisRange().

                                                    {  
  
 if(histoType == "Event_word_vs_time"){   

  for (it = names.begin(); it != names.end(); it++) {    

    if ((*it).first==histoType){
     
     MonitorElement * h1 =dbe->get((*it).second);

 int first_bin = -1, last_bin=-1;
   for( int bin=1; bin < h1->getNbinsX()+1; bin++ ){
    for( int j=1; j < h1->getNbinsY(); j++ ){
     if( h1->getBinContent(bin,j) > 0 ) {    
      if( first_bin == -1 ) { first_bin = bin; }
      last_bin = bin;
   }
  }
 }
 
  if( first_bin > 1 ) { first_bin -= 1; }
  if( last_bin < h1-> getNbinsX() ){ last_bin += 1; }
    h1->setAxisRange(0,last_bin,1);
   }
  }
 }  
}
std::string DTDataIntegrityTask::topFolder ( bool  isFEDIntegrity) const [private]

Definition at line 1156 of file DTDataIntegrityTask.cc.

References fedIntegrityFolder, and mode.

Referenced by bookHistos().

                                                                  {

  string folder = isFEDIntegrity ? fedIntegrityFolder : "DT/00-DataIntegrity";
  
  if (!isFEDIntegrity)
    folder += (mode==1) ? "_SM/" : (mode==3) ? "_EvF/" : "/";

  return folder;

}

Member Data Documentation

Definition at line 89 of file DTDataIntegrityTask.h.

Definition at line 87 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), postBeginJob(), and TimeHistos().

std::map<std::string, std::map<int, MonitorElement*> > DTDataIntegrityTask::dduHistos [private]

Definition at line 94 of file DTDataIntegrityTask.h.

Referenced by processFED().

Definition at line 80 of file DTDataIntegrityTask.h.

Definition at line 127 of file DTDataIntegrityTask.h.

Referenced by eventHasErrors(), preProcessEvent(), and processROS25().

std::set<int> DTDataIntegrityTask::fedBXIds [private]

Definition at line 130 of file DTDataIntegrityTask.h.

Referenced by preProcessEvent(), and processFED().

Definition at line 135 of file DTDataIntegrityTask.h.

Referenced by DTDataIntegrityTask(), and topFolder().

Definition at line 82 of file DTDataIntegrityTask.h.

Referenced by bookHistosROS25(), DTDataIntegrityTask(), and processROS25().

Definition at line 106 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), and processFED().

Definition at line 103 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), fedEntry(), and processFED().

Definition at line 104 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), fedFatal(), and processFED().

Definition at line 105 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), and fedNonFatal().

Definition at line 109 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), and processFED().

std::multimap<std::string, std::string>::iterator DTDataIntegrityTask::it [private]

Definition at line 75 of file DTDataIntegrityTask.h.

Referenced by TimeHistos().

Definition at line 118 of file DTDataIntegrityTask.h.

Definition at line 123 of file DTDataIntegrityTask.h.

Definition at line 122 of file DTDataIntegrityTask.h.

Definition at line 121 of file DTDataIntegrityTask.h.

std::multimap<std::string, std::string> DTDataIntegrityTask::names [private]

Definition at line 74 of file DTDataIntegrityTask.h.

Referenced by TimeHistos().

Definition at line 92 of file DTDataIntegrityTask.h.

Referenced by bookHistos(), and preProcessEvent().

Definition at line 84 of file DTDataIntegrityTask.h.

Referenced by preProcessEvent(), and processROS25().

Definition at line 111 of file DTDataIntegrityTask.h.

Referenced by DTDataIntegrityTask(), processFED(), and ~DTDataIntegrityTask().

Definition at line 112 of file DTDataIntegrityTask.h.

Referenced by DTDataIntegrityTask(), and processROS25().

std::string DTDataIntegrityTask::outputFile [private]

Definition at line 114 of file DTDataIntegrityTask.h.

Definition at line 77 of file DTDataIntegrityTask.h.

double DTDataIntegrityTask::rob_max[25] [private]

Definition at line 115 of file DTDataIntegrityTask.h.

std::map<std::string, std::map<int, MonitorElement*> > DTDataIntegrityTask::robHistos [private]

Definition at line 100 of file DTDataIntegrityTask.h.

std::map<int, std::set<int> > DTDataIntegrityTask::rosBxIdsPerFED [private]

Definition at line 129 of file DTDataIntegrityTask.h.

Referenced by preProcessEvent(), processFED(), and processROS25().

std::map<std::string, std::map<int, MonitorElement*> > DTDataIntegrityTask::rosHistos [private]

Definition at line 98 of file DTDataIntegrityTask.h.

Referenced by processROS25().

std::map<int, std::set<int> > DTDataIntegrityTask::rosL1AIdsPerFED [private]

Definition at line 131 of file DTDataIntegrityTask.h.

Referenced by preProcessEvent(), processFED(), and processROS25().

std::map<std::string, std::map<int, MonitorElement*> > DTDataIntegrityTask::rosSHistos [private]

Definition at line 96 of file DTDataIntegrityTask.h.

Referenced by processROS25().

Definition at line 113 of file DTDataIntegrityTask.h.