CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripBadComponentsDQMService Class Reference

#include <SiStripBadComponentsDQMService.h>

Inheritance diagram for SiStripBadComponentsDQMService:
SiStripCondObjBuilderBase< SiStripBadStrip >

List of all members.

Public Member Functions

virtual bool checkForCompatibility (std::string ss)
 Check is the transfer is needed.
void getMetaDataString (std::stringstream &ss)
 Used to fill the logDB.
void getObj (SiStripBadStrip *&obj)
 SiStripBadComponentsDQMService (const edm::ParameterSet &, const edm::ActivityRegistry &)
 ~SiStripBadComponentsDQMService ()

Private Member Functions

void getModuleFolderList (DQMStore *dqm_store, std::vector< std::string > &mfolders)
uint32_t getRunNumber () const
bool goToDir (DQMStore *dqm_store, std::string name)
void openRequestedFile ()
void readBadComponents ()

Private Attributes

DQMStoredqmStore_
edm::FileInPath fp_
edm::ParameterSet iConfig_
bool notAlreadyRead_

Detailed Description

Author:
M. De Mattia, S. Dutta, D. Giordano to read modules flagged by the DQM as bad and write in the database.

Definition at line 22 of file SiStripBadComponentsDQMService.h.


Constructor & Destructor Documentation

SiStripBadComponentsDQMService::SiStripBadComponentsDQMService ( const edm::ParameterSet iConfig,
const edm::ActivityRegistry aReg 
) [explicit]

Definition at line 14 of file SiStripBadComponentsDQMService.cc.

References SiStripCondObjBuilderBase< SiStripBadStrip >::obj_.

                                                                                                                            :
  SiStripCondObjBuilderBase<SiStripBadStrip>::SiStripCondObjBuilderBase(iConfig),
  iConfig_(iConfig),
  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
  notAlreadyRead_(true)
{
  obj_ = 0;
  edm::LogInfo("SiStripBadComponentsDQMService") <<  "[SiStripBadComponentsDQMService::SiStripBadComponentsDQMService]";
}
SiStripBadComponentsDQMService::~SiStripBadComponentsDQMService ( )

Definition at line 24 of file SiStripBadComponentsDQMService.cc.

{
  edm::LogInfo("SiStripBadComponentsDQMService") <<  "[SiStripBadComponentsDQMService::~SiStripBadComponentsDQMService]";
}

Member Function Documentation

bool SiStripBadComponentsDQMService::checkForCompatibility ( std::string  ss) [virtual]

Check is the transfer is needed.

Reimplemented from SiStripCondObjBuilderBase< SiStripBadStrip >.

Definition at line 36 of file SiStripBadComponentsDQMService.cc.

References getMetaDataString().

{
  std::stringstream localString;
  getMetaDataString(localString);
  if( ss == localString.str() ) return false;

  return true;
}
void SiStripBadComponentsDQMService::getMetaDataString ( std::stringstream &  ss) [virtual]
void SiStripBadComponentsDQMService::getModuleFolderList ( DQMStore dqm_store,
std::vector< std::string > &  mfolders 
) [private]

Definition at line 167 of file SiStripBadComponentsDQMService.cc.

References DQMStore::cd(), DQMStore::getSubdirs(), DQMStore::goUp(), and DQMStore::pwd().

Referenced by readBadComponents().

{
  std::string currDir = dqm_store->pwd();
  if (currDir.find("module_") != std::string::npos)  {
    //    std::string mId = currDir.substr(currDir.find("module_")+7, 9);
    mfolders.push_back(currDir);
  } else {  
    std::vector<std::string> subdirs = dqm_store->getSubdirs();
    for( std::vector<std::string>::const_iterator it = subdirs.begin();
         it != subdirs.end(); ++it) {
      dqm_store->cd(*it);
      getModuleFolderList(dqm_store, mfolders);
      dqm_store->goUp();
    }
  }
}
void SiStripBadComponentsDQMService::getObj ( SiStripBadStrip *&  obj) [inline, virtual]
uint32_t SiStripBadComponentsDQMService::getRunNumber ( ) const [private]

Definition at line 145 of file SiStripBadComponentsDQMService.cc.

References edm::ParameterSet::getParameter(), and iConfig_.

Referenced by getMetaDataString().

                                                            {
  edm::LogInfo("SiStripBadComponentsDQMService") <<  "[SiStripBadComponentsDQMService::getRunNumber] " << iConfig_.getParameter<uint32_t>("RunNb");
  return iConfig_.getParameter<uint32_t>("RunNb");
}
bool SiStripBadComponentsDQMService::goToDir ( DQMStore dqm_store,
std::string  name 
) [private]

Definition at line 150 of file SiStripBadComponentsDQMService.cc.

References DQMStore::cd(), TrackerOfflineValidation_Dqm_cff::dirName, DQMStore::getSubdirs(), DQMStore::goUp(), and DQMStore::pwd().

Referenced by readBadComponents().

{
  std::string currDir = dqm_store->pwd();
  std::string dirName = currDir.substr(currDir.find_last_of("/")+1);
  if (dirName.find(name) == 0) {
    return true;
  }
  std::vector<std::string> subDirVec = dqm_store->getSubdirs();
  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
       ic != subDirVec.end(); ic++) {
    dqm_store->cd(*ic);
    if (!goToDir(dqm_store, name))  dqm_store->goUp();
    else return true;
  }
  return false;
}
void SiStripBadComponentsDQMService::openRequestedFile ( ) [private]

Definition at line 126 of file SiStripBadComponentsDQMService.cc.

References dqmStore_, convertXMLtoSQLite_cfg::fileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), iConfig_, DQMStore::open(), cppFunctionSkipper::operator, and DQMStore::setVerbose().

Referenced by readBadComponents().

{
  dqmStore_ = edm::Service<DQMStore>().operator->();

  // ** FIXME ** // 
  dqmStore_->setVerbose(0); //add config param

  if( iConfig_.getParameter<bool>("accessDQMFile") ){
    
    std::string fileName = iConfig_.getUntrackedParameter<std::string>("FILE_NAME","");
    
    edm::LogInfo("SiStripBadComponentsDQMService") <<  "[SiStripBadComponentsDQMService::openRequestedFile] Accessing root File" << fileName;

    dqmStore_->open(fileName, false); 
  } else {
    edm::LogInfo("SiStripBadComponentsDQMService") <<  "[SiStripBadComponentsDQMService::openRequestedFile] Accessing dqmStore stream in Online Operation";
  }
}
void SiStripBadComponentsDQMService::readBadComponents ( ) [private]

Definition at line 45 of file SiStripBadComponentsDQMService.cc.

References DQMStore::cd(), gather_cfg::cout, DQMStore::dirExists(), dqmStore_, SiStripBadStrip::encode(), fp_, edm::FileInPath::fullPath(), DQMStore::getContents(), getModuleFolderList(), goToDir(), LogDebug, notAlreadyRead_, SiStripCondObjBuilderBase< SiStripBadStrip >::obj_, openRequestedFile(), SiStripBadStrip::put(), DQMStore::pwd(), and matplotRender::reader.

Referenced by getMetaDataString(), and getObj().

{
  // Do this only if it was not already read
  if( notAlreadyRead_ ) {
    //*LOOP OVER THE LIST OF SUMMARY OBJECTS TO INSERT IN DB*//

      openRequestedFile();

    std::cout << "[readBadComponents]: opened requested file" << std::endl;

    obj_=new SiStripBadStrip();

    SiStripDetInfoFileReader reader(fp_.fullPath());

    dqmStore_->cd();

    std::string mdir = "MechanicalView";
    if (!goToDir(dqmStore_, mdir)) return;
    std::string mechanicalview_dir = dqmStore_->pwd();

    std::vector<std::string> subdet_folder;
    subdet_folder.push_back("TIB");
    subdet_folder.push_back("TOB");
    subdet_folder.push_back("TEC/side_1");
    subdet_folder.push_back("TEC/side_2");
    subdet_folder.push_back("TID/side_1");
    subdet_folder.push_back("TID/side_2");

    int nDetsTotal = 0;
    int nDetsWithErrorTotal = 0;
    for( std::vector<std::string>::const_iterator im = subdet_folder.begin(); im != subdet_folder.end(); ++im ) {
      std::string dname = mechanicalview_dir + "/" + (*im);
      if (!dqmStore_->dirExists(dname)) continue;

      dqmStore_->cd(dname);
      std::vector<std::string> module_folders;
      getModuleFolderList(dqmStore_, module_folders);
      int nDets = module_folders.size();

      int nDetsWithError = 0;
      std::string bad_module_folder = dname + "/" + "BadModuleList";
      if (dqmStore_->dirExists(bad_module_folder)) {
        std::vector<MonitorElement *> meVec = dqmStore_->getContents(bad_module_folder);
        for( std::vector<MonitorElement *>::const_iterator it = meVec.begin(); it != meVec.end(); ++it ) {
          nDetsWithError++;
          std::cout << (*it)->getName() <<  " " << (*it)->getIntValue() << std::endl;
          uint32_t detId = boost::lexical_cast<uint32_t>((*it)->getName());
          short flag = (*it)->getIntValue();

          std::vector<unsigned int> theSiStripVector;

          unsigned short firstBadStrip=0, NconsecutiveBadStrips=0;
          unsigned int theBadStripRange;

          // for(std::vector<uint32_t>::const_iterator is=BadApvList_.begin(); is!=BadApvList_.end(); ++is){

          //   firstBadStrip=(*is)*128;
          NconsecutiveBadStrips=reader.getNumberOfApvsAndStripLength(detId).first*128;

          theBadStripRange = obj_->encode(firstBadStrip,NconsecutiveBadStrips,flag);

          LogDebug("SiStripBadComponentsDQMService") << "detid " << detId << " \t"
                                                     << ", flag " << flag
                                                     << std::endl;

          theSiStripVector.push_back(theBadStripRange);
          // }

          SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
          if ( !obj_->put(detId,range) ) {
            edm::LogError("SiStripBadFiberBuilder")<<"[SiStripBadFiberBuilder::analyze] detid already exists"<<std::endl;
          }
        }
      }
      nDetsTotal += nDets;
      nDetsWithErrorTotal += nDetsWithError;        
    }
    dqmStore_->cd();
  }
}

Member Data Documentation

Definition at line 45 of file SiStripBadComponentsDQMService.h.

Referenced by openRequestedFile(), and readBadComponents().

Definition at line 48 of file SiStripBadComponentsDQMService.h.

Referenced by readBadComponents().

Definition at line 47 of file SiStripBadComponentsDQMService.h.

Referenced by getRunNumber(), and openRequestedFile().

Definition at line 50 of file SiStripBadComponentsDQMService.h.

Referenced by readBadComponents().