CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

SiStripDcsInfo Class Reference

#include <DQM/SiStripMonitorCluster/interface/SiStripDcsInfo.h>

Inheritance diagram for SiStripDcsInfo:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Classes

struct  SubDetMEs

Public Member Functions

 SiStripDcsInfo (const edm::ParameterSet &ps)
 Constructor.
virtual ~SiStripDcsInfo ()
 Destructor.

Private Member Functions

void addBadModules ()
void analyze (edm::Event const &, edm::EventSetup const &)
 Analyze.
void beginJob ()
 BeginJob.
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup)
 Begin Luminosity Block.
void beginRun (edm::Run const &run, edm::EventSetup const &eSetup)
 Begin Run.
void bookStatus ()
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup)
 End Of Luminosity.
void endRun (edm::Run const &run, edm::EventSetup const &eSetup)
 EndRun.
void fillDummyStatus ()
void fillStatus ()
void readCabling (edm::EventSetup const &)
void readStatus (edm::EventSetup const &)

Private Attributes

bool bookedStatus_
MonitorElementDcsFraction_
edm::ESHandle< SiStripDetCablingdetCabling_
DQMStoredqmStore_
unsigned long long m_cacheIDCabling_
unsigned long long m_cacheIDDcs_
int nFEDConnected_
int nLumiAnalysed_
edm::ESHandle< SiStripDetVOffsiStripDetVOff_
std::map< std::string, SubDetMEsSubDetMEsMap

Detailed Description

Description: Checks the # of SiStrip FEDs from DAQ Usage: <usage>

Definition at line 41 of file SiStripDcsInfo.h.


Constructor & Destructor Documentation

SiStripDcsInfo::SiStripDcsInfo ( const edm::ParameterSet ps)

Constructor.

Definition at line 32 of file SiStripDcsInfo.cc.

References LogDebug.

                                                          : 
    dqmStore_(edm::Service<DQMStore>().operator->()), 
    m_cacheIDCabling_(0),
    m_cacheIDDcs_(0),
    bookedStatus_(false),
    nLumiAnalysed_(0)
{ 
  // Create MessageSender
  LogDebug( "SiStripDcsInfo") << "SiStripDcsInfo::Deleting SiStripDcsInfo ";
}
SiStripDcsInfo::~SiStripDcsInfo ( ) [virtual]

Destructor.

Definition at line 45 of file SiStripDcsInfo.cc.

References LogDebug.

                                {
  LogDebug("SiStripDcsInfo") << "SiStripDcsInfo::Deleting SiStripDcsInfo ";

}

Member Function Documentation

void SiStripDcsInfo::addBadModules ( ) [private]

Definition at line 317 of file SiStripDcsInfo.cc.

References DQMStore::bookInt(), DQMStore::cd(), dqmStore_, MonitorElement::Fill(), DQMStore::get(), MonitorElement::getIntValue(), SiStripUtility::goToDir(), DQMStore::pwd(), MonitorElement::Reset(), SiStripUtility::setBadModuleFlag(), DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, SubDetMEsMap, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by endRun().

                                   {
    
  dqmStore_->cd();
  std::string mdir = "MechanicalView";
  if (!SiStripUtility::goToDir(dqmStore_, mdir)) {
    dqmStore_->setCurrentFolder("SiStrip/"+mdir);
  }
  std::string mechanical_dir = dqmStore_->pwd();
  std::string tag = "DCSError";

  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
    std::vector<uint32_t> badModules = it->second.FaultyDetectors; 
    for (std::vector<uint32_t>::iterator ibad = badModules.begin(); 
         ibad != badModules.end(); ibad++) {

      std::string bad_module_folder = mechanical_dir + "/" +
                                      it->second.folder_name + "/"     
                                      "BadModuleList";      
      dqmStore_->setCurrentFolder(bad_module_folder);

      std::ostringstream detid_str;
      detid_str << (*ibad);
      std::string full_path = bad_module_folder + "/" + detid_str.str();
      MonitorElement* me = dqmStore_->get(full_path);
      uint16_t flag = 0; 
      if (me) {
        flag = me->getIntValue();
        me->Reset();
      } else me = dqmStore_->bookInt(detid_str.str());
      SiStripUtility::setBadModuleFlag(tag, flag);
      me->Fill(flag);
    }
  }   
  dqmStore_->cd();
}
void SiStripDcsInfo::analyze ( edm::Event const &  event,
edm::EventSetup const &  eSetup 
) [private, virtual]

Analyze.

Implements edm::EDAnalyzer.

Definition at line 131 of file SiStripDcsInfo.cc.

                                                                               {
}
void SiStripDcsInfo::beginJob ( void  ) [private, virtual]

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file SiStripDcsInfo.cc.

References SiStripDcsInfo::SubDetMEs::DcsFractionME, SiStripDcsInfo::SubDetMEs::FaultyDetectors, SiStripDcsInfo::SubDetMEs::folder_name, AlCaHLTBitMon_QueryRunRegistry::string, SubDetMEsMap, GlobalPosition_Frontier_DevDB_cff::tag, and SiStripDcsInfo::SubDetMEs::TotalDetectors.

                              {
  std::string tag;
  SubDetMEs local_mes;
  
  tag = "TIB";   
  local_mes.folder_name = "TIB";
  local_mes.DcsFractionME  = 0;
  local_mes.TotalDetectors = 0; 
  local_mes.FaultyDetectors.clear();
  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
      
  tag = "TOB";
  local_mes.folder_name = "TOB";
  local_mes.DcsFractionME  = 0;
  local_mes.TotalDetectors = 0; 
  local_mes.FaultyDetectors.clear();
  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));

  tag = "TECB";
  local_mes.folder_name = "TEC/side_1";
  local_mes.DcsFractionME  = 0;
  local_mes.TotalDetectors = 0; 
  local_mes.FaultyDetectors.clear();
  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));

  tag = "TECF";
  local_mes.folder_name = "TEC/side_2";
  local_mes.DcsFractionME  = 0;
  local_mes.TotalDetectors = 0; 
  local_mes.FaultyDetectors.clear();
  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));

  tag = "TIDB";
  local_mes.folder_name = "TID/side_1";
  local_mes.DcsFractionME  = 0;
  local_mes.TotalDetectors = 0; 
  local_mes.FaultyDetectors.clear();
  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));

  tag = "TIDF";
  local_mes.folder_name = "TID/side_2";
  local_mes.DcsFractionME  = 0;
  local_mes.TotalDetectors = 0; 
  local_mes.FaultyDetectors.clear();
  SubDetMEsMap.insert(std::pair<std::string, SubDetMEs >(tag, local_mes));
}
void SiStripDcsInfo::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  eSetup 
) [private, virtual]

Begin Luminosity Block.

Reimplemented from edm::EDAnalyzer.

Definition at line 136 of file SiStripDcsInfo.cc.

References LogDebug, nFEDConnected_, nLumiAnalysed_, readStatus(), and SubDetMEsMap.

                                                                                                        {
  LogDebug( "SiStripDcsInfo") << "SiStripDcsInfo::beginLuminosityBlock";
  
  if (nFEDConnected_ == 0) return;

  // initialise BadModule list 
  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
    it->second.FaultyDetectors.clear();
  }
  readStatus(eSetup);
  nLumiAnalysed_++;   
}
void SiStripDcsInfo::beginRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
) [private, virtual]

Begin Run.

Reimplemented from edm::EDAnalyzer.

Definition at line 101 of file SiStripDcsInfo.cc.

References bookStatus(), fillDummyStatus(), edm::EventSetup::find(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), edm::EventSetup::get(), edm::ESHandleBase::isValid(), LogDebug, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, nFEDConnected_, and readCabling().

                                                                            {
  LogDebug ("SiStripDcsInfo") <<"SiStripDcsInfo:: Begining of Run";
  nFEDConnected_ = 0;
  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID; 

  // Count Tracker FEDs from RunInfo
  edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
  if( eSetup.find( recordKey ) != 0) {
    
    edm::ESHandle<RunInfo> sumFED;
    eSetup.get<RunInfoRcd>().get(sumFED);    
    
    if ( sumFED.isValid() ) {
      std::vector<int> FedsInIds= sumFED->m_fed_in;   
      for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
        int fedID = FedsInIds[it];     
        if(fedID>=siStripFedIdMin &&  fedID<=siStripFedIdMax)  ++nFEDConnected_;
      }
      LogDebug ("SiStripDcsInfo") << " SiStripDcsInfo :: Connected FEDs " << nFEDConnected_;
    }
  } 

  bookStatus();
  fillDummyStatus();
  if (nFEDConnected_ > 0) readCabling(eSetup);
}
void SiStripDcsInfo::bookStatus ( ) [private]

Definition at line 177 of file SiStripDcsInfo.cc.

References bookedStatus_, DQMStore::bookFloat(), DQMStore::cd(), DcsFraction_, dqmStore_, SiStripUtility::getTopFolderPath(), DQMStore::setCurrentFolder(), MonitorElement::setLumiFlag(), AlCaHLTBitMon_QueryRunRegistry::string, and SubDetMEsMap.

Referenced by beginRun(), fillDummyStatus(), and fillStatus().

                                {
  if (!bookedStatus_) {
    std::string strip_dir = "";
    SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir); 
    if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
    else dqmStore_->setCurrentFolder("SiStrip/EventInfo");
       
    DcsFraction_= dqmStore_->bookFloat("DCSSummary");  
    
    DcsFraction_->setLumiFlag();
    
    dqmStore_->cd();
    if (strip_dir.size() > 0)  dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/DCSContents");
    else dqmStore_->setCurrentFolder("SiStrip/EventInfo/DCSContents"); 
    for (std::map<std::string,SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
      SubDetMEs local_mes;      
      std::string me_name;
      me_name = "SiStrip_" + it->first;
      it->second.DcsFractionME = dqmStore_->bookFloat(me_name);  
      it->second.DcsFractionME->setLumiFlag();  
    } 
    bookedStatus_ = true;
    dqmStore_->cd();
  }
}
void SiStripDcsInfo::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  iSetup 
) [private, virtual]

End Of Luminosity.

Reimplemented from edm::EDAnalyzer.

Definition at line 152 of file SiStripDcsInfo.cc.

References fillStatus(), LogDebug, nFEDConnected_, and readStatus().

                                                                                                      {
  LogDebug( "SiStripDcsInfo") << "SiStripDcsInfo::endLuminosityBlock";

  if (nFEDConnected_ == 0) return;
  readStatus(eSetup);
  fillStatus();
}
void SiStripDcsInfo::endRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
) [private, virtual]

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 162 of file SiStripDcsInfo.cc.

References addBadModules(), fillStatus(), LogDebug, nFEDConnected_, readStatus(), and SubDetMEsMap.

                                                                         {
  LogDebug ("SiStripDcsInfo") <<"SiStripDcsInfo::EndRun";

  if (nFEDConnected_ == 0) return;

  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
    it->second.FaultyDetectors.clear();
  }
  readStatus(eSetup); 
  fillStatus();
  addBadModules();
} 
void SiStripDcsInfo::fillDummyStatus ( ) [private]

Definition at line 303 of file SiStripDcsInfo.cc.

References bookedStatus_, bookStatus(), DcsFraction_, MonitorElement::Fill(), MonitorElement::Reset(), and SubDetMEsMap.

Referenced by beginRun().

                                     {
  if (!bookedStatus_) bookStatus();
  if (bookedStatus_) {
    for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
      it->second.DcsFractionME->Reset();
      it->second.DcsFractionME->Fill(-1.0);
    }
    DcsFraction_->Reset();
    DcsFraction_->Fill(-1.0);
  }
}
void SiStripDcsInfo::fillStatus ( ) [private]

Definition at line 275 of file SiStripDcsInfo.cc.

References bookedStatus_, bookStatus(), DcsFraction_, MonitorElement::Fill(), nFEDConnected_, MonitorElement::Reset(), and SubDetMEsMap.

Referenced by endLuminosityBlock(), and endRun().

                               {
  if (!bookedStatus_) bookStatus();
  if (bookedStatus_) {
    float total_det = 0.0;
    float faulty_det = 0.0;
    float fraction;
    for (std::map<std::string,SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
      int total_subdet  = it->second.TotalDetectors;
      int faulty_subdet = it->second.FaultyDetectors.size(); 
      if  (nFEDConnected_ == 0  || total_subdet == 0) fraction = -1;
      else fraction = 1.0  - faulty_subdet*1.0/total_subdet;   
      it->second.DcsFractionME->Reset();
      it->second.DcsFractionME->Fill(fraction);
      edm::LogInfo( "SiStripDcsInfo") << " SiStripDcsInfo::fillStatus : Sub Detector "
        << it->first << " Total Number " << total_subdet  
        << " Faulty ones " << faulty_subdet;
      total_det += total_subdet;
      faulty_det += faulty_subdet;
    }
    if (nFEDConnected_ == 0 || total_det == 0) fraction = -1.0;
    else fraction = 1 - faulty_det/total_det;
    DcsFraction_->Reset();
    DcsFraction_->Fill(fraction);
  } 
}
void SiStripDcsInfo::readCabling ( edm::EventSetup const &  eSetup) [private]

Definition at line 205 of file SiStripDcsInfo.cc.

References detCabling_, edm::EventSetup::get(), SiStripUtility::getSubDetectorTag(), LogDebug, m_cacheIDCabling_, edm::ESHandle< T >::product(), AlCaHLTBitMon_QueryRunRegistry::string, xuti::subdet_tag(), and SubDetMEsMap.

Referenced by beginRun().

                                                            {

  //Retrieve tracker topology from geometry
  edm::ESHandle<TrackerTopology> tTopoHandle;
  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
  const TrackerTopology* const tTopo = tTopoHandle.product();

  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
  if (m_cacheIDCabling_ != cacheID) {
    m_cacheIDCabling_ = cacheID;
    LogDebug("SiStripDcsInfo") <<"SiStripDcsInfo::readCabling : "
                                   << " Change in Cache";
    eSetup.get<SiStripDetCablingRcd>().get(detCabling_);

    std::vector<uint32_t> SelectedDetIds;
    detCabling_->addActiveDetectorsRawIds(SelectedDetIds);
    LogDebug( "SiStripDcsInfo") << " SiStripDcsInfo::readCabling : "  
                                    << " Total Detectors " << SelectedDetIds.size();
    

    // initialise total # of detectors first
    for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
      it->second.TotalDetectors = 0;
    }
    
    for (std::vector<uint32_t>::const_iterator idetid=SelectedDetIds.begin(); idetid != SelectedDetIds.end(); ++idetid){    
      uint32_t detId = *idetid;
      if (detId == 0 || detId == 0xFFFFFFFF) continue;
      std::string subdet_tag;
      SiStripUtility::getSubDetectorTag(detId,subdet_tag,tTopo);         
      
      std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(subdet_tag);
      if (iPos != SubDetMEsMap.end()){    
        iPos->second.TotalDetectors++;
      }
    }
  }
}
void SiStripDcsInfo::readStatus ( edm::EventSetup const &  eSetup) [private]

Definition at line 246 of file SiStripDcsInfo.cc.

References detCabling_, spr::find(), edm::EventSetup::get(), SiStripUtility::getSubDetectorTag(), LogDebug, edm::ESHandle< T >::product(), siStripDetVOff_, AlCaHLTBitMon_QueryRunRegistry::string, xuti::subdet_tag(), and SubDetMEsMap.

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

                                                           {

  //Retrieve tracker topology from geometry
  edm::ESHandle<TrackerTopology> tTopoHandle;
  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
  const TrackerTopology* const tTopo = tTopoHandle.product();

  eSetup.get<SiStripDetVOffRcd>().get(siStripDetVOff_);
  std::vector <uint32_t> FaultyDetIds;
  siStripDetVOff_->getDetIds(FaultyDetIds);
  LogDebug( "SiStripDcsInfo") << " SiStripDcsInfo::readStatus : "
                                  << " Faulty Detectors " << FaultyDetIds.size();
  // Read and fille bad modules
  for (std::vector<uint32_t>::const_iterator ihvoff=FaultyDetIds.begin(); ihvoff!=FaultyDetIds.end();++ihvoff){
    uint32_t detId_hvoff = (*ihvoff);
    if (!detCabling_->IsConnected(detId_hvoff)) continue;    
    std::string subdet_tag;
    SiStripUtility::getSubDetectorTag(detId_hvoff,subdet_tag,tTopo);         
    
    std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(subdet_tag);
    if (iPos != SubDetMEsMap.end()){  
      std::vector<uint32_t>::iterator ibad = std::find(iPos->second.FaultyDetectors.begin(), iPos->second.FaultyDetectors.end(), detId_hvoff);
      if (ibad ==  iPos->second.FaultyDetectors.end()) iPos->second.FaultyDetectors.push_back( detId_hvoff);
    }
  }
}

Member Data Documentation

Definition at line 94 of file SiStripDcsInfo.h.

Referenced by bookStatus(), fillDummyStatus(), and fillStatus().

Definition at line 82 of file SiStripDcsInfo.h.

Referenced by bookStatus(), fillDummyStatus(), and fillStatus().

Definition at line 101 of file SiStripDcsInfo.h.

Referenced by readCabling(), and readStatus().

Definition at line 81 of file SiStripDcsInfo.h.

Referenced by addBadModules(), and bookStatus().

unsigned long long SiStripDcsInfo::m_cacheIDCabling_ [private]

Definition at line 92 of file SiStripDcsInfo.h.

Referenced by readCabling().

unsigned long long SiStripDcsInfo::m_cacheIDDcs_ [private]

Definition at line 93 of file SiStripDcsInfo.h.

Definition at line 99 of file SiStripDcsInfo.h.

Referenced by beginLuminosityBlock().

Definition at line 96 of file SiStripDcsInfo.h.

Referenced by readStatus().

std::map<std::string, SubDetMEs> SiStripDcsInfo::SubDetMEsMap [private]