CMS 3D CMS Logo

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

SiStripDaqInfo Class Reference

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

Inheritance diagram for SiStripDaqInfo:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Classes

struct  SubDetMEs

Public Member Functions

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

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &)
 Analyze.
void beginJob ()
 BeginJob.
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 findExcludedModule (unsigned short fed_id, const TrackerTopology *tTopo)
void readFedIds (const edm::ESHandle< SiStripFedCabling > &fedcabling, edm::EventSetup const &iSetup)
void readSubdetFedFractions (std::vector< int > &fed_ids, edm::EventSetup const &iSetup)

Private Attributes

bool bookedStatus_
MonitorElementDaqFraction_
DQMStoredqmStore_
edm::ESHandle< SiStripFedCablingfedCabling_
unsigned long long m_cacheID_
int nFedTotal
std::map< std::string,
std::vector< unsigned short > > 
subDetFedMap
std::map< std::string, SubDetMEsSubDetMEsMap

Detailed Description

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

Definition at line 41 of file SiStripDaqInfo.h.


Constructor & Destructor Documentation

SiStripDaqInfo::SiStripDaqInfo ( const edm::ParameterSet ps)

Constructor.

Definition at line 34 of file SiStripDaqInfo.cc.

References bookedStatus_, dqmStore_, nFedTotal, and cppFunctionSkipper::operator.

                                                          {
  // Create MessageSender
  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::Deleting SiStripDaqInfo ";

  // get back-end interface
  dqmStore_ = edm::Service<DQMStore>().operator->();
  nFedTotal = 0;
  bookedStatus_ = false;
}
SiStripDaqInfo::~SiStripDaqInfo ( ) [virtual]

Destructor.

Definition at line 43 of file SiStripDaqInfo.cc.

                                {
  edm::LogInfo("SiStripDaqInfo") << "SiStripDaqInfo::Deleting SiStripDaqInfo ";

}

Member Function Documentation

void SiStripDaqInfo::analyze ( edm::Event const &  event,
edm::EventSetup const &  eSetup 
) [private, virtual]

Analyze.

Implements edm::EDAnalyzer.

Definition at line 160 of file SiStripDaqInfo.cc.

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file SiStripDaqInfo.cc.

                              {
 
}
void SiStripDaqInfo::beginRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
) [private, virtual]

Begin Run.

Reimplemented from edm::EDAnalyzer.

Definition at line 111 of file SiStripDaqInfo.cc.

References bookedStatus_, bookStatus(), DaqFraction_, fedCabling_, MonitorElement::Fill(), fillDummyStatus(), edm::EventSetup::find(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), edm::EventSetup::get(), edm::ESHandleBase::isValid(), m_cacheID_, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, nFedTotal, readFedIds(), readSubdetFedFractions(), and MonitorElement::Reset().

                                                                            {
  edm::LogInfo ("SiStripDaqInfo") <<"SiStripDaqInfo:: Begining of Run";

  // Check latest Fed cabling and create TrackerMapCreator
  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
  if (m_cacheID_ != cacheID) {
    m_cacheID_ = cacheID;       

    eSetup.get<SiStripFedCablingRcd>().get(fedCabling_); 

    readFedIds(fedCabling_, eSetup);
  }
  if (!bookedStatus_) bookStatus();  
  if (nFedTotal == 0) {
    fillDummyStatus();
    edm::LogInfo ("SiStripDaqInfo") <<" SiStripDaqInfo::No FEDs Connected!!!";
    return;
  }
  
  float nFEDConnected = 0.0;
  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID; 

  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;
      }
      edm::LogInfo ("SiStripDaqInfo") <<" SiStripDaqInfo::Total # of FEDs " << nFedTotal 
                                      << " Connected FEDs " << nFEDConnected;
      if (nFEDConnected > 0) {
        DaqFraction_->Reset();
        DaqFraction_->Fill(nFEDConnected/nFedTotal);
        readSubdetFedFractions(FedsInIds,eSetup);
      }
    }
  } 
}
void SiStripDaqInfo::bookStatus ( ) [private]

Definition at line 56 of file SiStripDaqInfo.cc.

References bookedStatus_, DQMStore::bookFloat(), DQMStore::cd(), SiStripDaqInfo::SubDetMEs::ConnectedFeds, DaqFraction_, SiStripDaqInfo::SubDetMEs::DaqFractionME, dqmStore_, SiStripUtility::getTopFolderPath(), DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, and SubDetMEsMap.

Referenced by beginRun(), and fillDummyStatus().

                                {
   edm::LogInfo( "SiStripDcsInfo") << " SiStripDaqInfo::bookStatus " << bookedStatus_;
  if (!bookedStatus_) {
    dqmStore_->cd();
    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");

    
    DaqFraction_= dqmStore_->bookFloat("DAQSummary");  

    dqmStore_->cd();    
    if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/DAQContents");
    else dqmStore_->setCurrentFolder("SiStrip/EventInfo/DAQContents");
      
    std::vector<std::string> det_type;
    det_type.push_back("TIB");
    det_type.push_back("TOB");
    det_type.push_back("TIDF");
    det_type.push_back("TIDB");
    det_type.push_back("TECF");
    det_type.push_back("TECB");
      
    for ( std::vector<std::string>::iterator it = det_type.begin(); it != det_type.end(); it++) {
      std::string det = (*it);
      
      SubDetMEs local_mes;      
      std::string me_name;
      me_name = "SiStrip_" + det;    
      local_mes.DaqFractionME = dqmStore_->bookFloat(me_name);          
      local_mes.ConnectedFeds = 0;
      SubDetMEsMap.insert(make_pair(det, local_mes));
    } 
    bookedStatus_ = true;
    dqmStore_->cd();
  }
}
void SiStripDaqInfo::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  iSetup 
) [private, virtual]

End Of Luminosity.

Reimplemented from edm::EDAnalyzer.

Definition at line 166 of file SiStripDaqInfo.cc.

                                                                                                      {
  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::endLuminosityBlock";
}
void SiStripDaqInfo::endRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
) [private, virtual]

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 172 of file SiStripDaqInfo.cc.

                                                                         {
  edm::LogInfo ("SiStripDaqInfo") <<"SiStripDaqInfo::EndRun";
}
void SiStripDaqInfo::fillDummyStatus ( ) [private]

Definition at line 97 of file SiStripDaqInfo.cc.

References bookedStatus_, bookStatus(), DaqFraction_, 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.DaqFractionME->Reset();
      it->second.DaqFractionME->Fill(-1.0);
    }
    DaqFraction_->Reset();
    DaqFraction_->Fill(-1.0);
  }
}
void SiStripDaqInfo::findExcludedModule ( unsigned short  fed_id,
const TrackerTopology tTopo 
) [private]

Definition at line 257 of file SiStripDaqInfo.cc.

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

Referenced by readSubdetFedFractions().

                                                                                           {
  dqmStore_->cd();
  std::string mdir = "MechanicalView";
  if (!SiStripUtility::goToDir(dqmStore_, mdir)) {
    dqmStore_->setCurrentFolder("SiStrip/"+mdir);
  }
  std::string mechanical_dir = dqmStore_->pwd();
  const std::vector<FedChannelConnection> fedChannels = fedCabling_->connections(fed_id);
  int ichannel = 0;
  std::string tag = "ExcludedFedChannel";
  std::string bad_module_folder;
  for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); 
                                                         iconn < fedChannels.end(); iconn++){
    if (!iconn->isConnected()) continue;
    uint32_t detId = iconn->detId();
    if (detId == 0 || detId == 0xFFFFFFFF)  continue;
    
    ichannel++;
    if (ichannel == 1) {
      std::string subdet_folder ;
      SiStripFolderOrganizer folder_organizer;
      folder_organizer.getSubDetFolder(detId,tTopo,subdet_folder);
      if (!dqmStore_->dirExists(subdet_folder)) {
        subdet_folder = mechanical_dir + subdet_folder.substr(subdet_folder.find(mdir)+mdir.size());
      }
      bad_module_folder = subdet_folder + "/" + "BadModuleList";
      dqmStore_->setCurrentFolder(bad_module_folder);    
    }
    std::ostringstream detid_str;
    detid_str << detId;
    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 SiStripDaqInfo::readFedIds ( const edm::ESHandle< SiStripFedCabling > &  fedcabling,
edm::EventSetup const &  iSetup 
) [private]

Definition at line 178 of file SiStripDaqInfo.cc.

References fedCabling_, edm::EventSetup::get(), SiStripUtility::getSubDetectorTag(), nFedTotal, edm::ESHandle< T >::product(), AlCaHLTBitMon_QueryRunRegistry::string, xuti::subdet_tag(), and subDetFedMap.

Referenced by beginRun().

                                                                                                             {

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

  const std::vector<uint16_t>& feds = fedCabling_->feds(); 

  nFedTotal = feds.size();
  for(std::vector<unsigned short>::const_iterator ifed = feds.begin(); ifed != feds.end(); ifed++){
    const std::vector<FedChannelConnection> fedChannels = fedCabling_->connections( *ifed );
    for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); iconn < fedChannels.end(); iconn++){
      if (!iconn->isConnected()) continue;
      uint32_t detId = iconn->detId();
      if (detId == 0 || detId == 0xFFFFFFFF)  continue;
      std::string subdet_tag;
      SiStripUtility::getSubDetectorTag(detId,subdet_tag,tTopo);
      subDetFedMap[subdet_tag].push_back(*ifed); 
      break;
    }
  }  
}
void SiStripDaqInfo::readSubdetFedFractions ( std::vector< int > &  fed_ids,
edm::EventSetup const &  iSetup 
) [private]

Definition at line 204 of file SiStripDaqInfo.cc.

References findExcludedModule(), edm::EventSetup::get(), Association::map, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, mergeVDriftHistosByStation::name, edm::ESHandle< T >::product(), AlCaHLTBitMon_QueryRunRegistry::string, subDetFedMap, and SubDetMEsMap.

Referenced by beginRun().

                                                                                                {

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

  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID; 

  // initialiase 
  for (std::map<std::string, std::vector<unsigned short> >::const_iterator it = subDetFedMap.begin();
       it != subDetFedMap.end(); it++) {
    std::string name = it->first;
    std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(name);
    if (iPos == SubDetMEsMap.end()) continue;
    iPos->second.ConnectedFeds = 0;
  }
  // count sub detector feds

  
  for (std::map<std::string, std::vector<unsigned short> >::const_iterator it = subDetFedMap.begin();
           it != subDetFedMap.end(); it++) {
    std::string name = it->first;
    std::vector<unsigned short> subdetIds = it->second; 
    std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(name);
    if (iPos == SubDetMEsMap.end()) continue;
    iPos->second.ConnectedFeds = 0;
    for (std::vector<unsigned short>::iterator iv = subdetIds.begin();
         iv != subdetIds.end(); iv++) {
      bool fedid_found = false;
      for(unsigned int it = 0; it < fed_ids.size(); ++it) {
        unsigned short fedID = fed_ids[it];     
        if(fedID < siStripFedIdMin ||  fedID > siStripFedIdMax) continue;
        if ((*iv) == fedID) {
          fedid_found = true;
          iPos->second.ConnectedFeds++;
          break;
        }
      }
      if (!fedid_found) findExcludedModule((*iv),tTopo);   
    }
    int nFedsConnected   = iPos->second.ConnectedFeds;
    int nFedSubDet       = subdetIds.size();
    if (nFedSubDet > 0) {
      iPos->second.DaqFractionME->Reset();
      iPos->second.DaqFractionME->Fill(nFedsConnected*1.0/nFedSubDet);
    }
  }
}

Member Data Documentation

Definition at line 91 of file SiStripDaqInfo.h.

Referenced by beginRun(), bookStatus(), fillDummyStatus(), and SiStripDaqInfo().

Definition at line 80 of file SiStripDaqInfo.h.

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

Definition at line 79 of file SiStripDaqInfo.h.

Referenced by bookStatus(), findExcludedModule(), and SiStripDaqInfo().

Definition at line 93 of file SiStripDaqInfo.h.

Referenced by beginRun(), findExcludedModule(), and readFedIds().

unsigned long long SiStripDaqInfo::m_cacheID_ [private]

Definition at line 89 of file SiStripDaqInfo.h.

Referenced by beginRun().

Definition at line 90 of file SiStripDaqInfo.h.

Referenced by beginRun(), readFedIds(), and SiStripDaqInfo().

std::map<std::string,std::vector<unsigned short> > SiStripDaqInfo::subDetFedMap [private]

Definition at line 77 of file SiStripDaqInfo.h.

Referenced by readFedIds(), and readSubdetFedFractions().

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

Definition at line 87 of file SiStripDaqInfo.h.

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