CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripTrackerMapCreator Class Reference

#include <SiStripTrackerMapCreator.h>

List of all members.

Public Member Functions

void create (const edm::ParameterSet &tkmapPset, const edm::ESHandle< SiStripFedCabling > &fedcabling, DQMStore *dqm_store, std::string &htype)
void createForOffline (const edm::ParameterSet &tkmapPset, DQMStore *dqm_store, std::string &htype)
bool readConfiguration ()
 SiStripTrackerMapCreator ()
 ~SiStripTrackerMapCreator ()

Private Member Functions

uint16_t getDetectorFlagAndComment (DQMStore *dqm_store, uint32_t det_id, std::ostringstream &comment)
void paintTkMapFromAlarm (uint32_t det_id, DQMStore *dqm_store)
void paintTkMapFromHistogram (DQMStore *dqm_store, MonitorElement *me, std::string &map_type)
void setTkMapFromHistogram (DQMStore *dqm_store, std::string &htype)
void setTkMapRange (std::string &map_type)

Private Attributes

int nDet
TkDetMaptkDetMap_
float tkMapMax
float tkMapMin
std::string tkMapName_
TrackerMaptrackerMap_

Detailed Description

Definition at line 19 of file SiStripTrackerMapCreator.h.


Constructor & Destructor Documentation

SiStripTrackerMapCreator::SiStripTrackerMapCreator ( )

Definition at line 15 of file SiStripTrackerMapCreator.cc.

References cmsCodeRules::cppFunctionSkipper::operator, tkDetMap_, and trackerMap_.

                                                   {
  trackerMap_ = 0;
  if(!edm::Service<TkDetMap>().isAvailable()){
    edm::LogError("TkHistoMap") <<
      "\n------------------------------------------"
      "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
      "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
      "\n------------------------------------------";
  }
  tkDetMap_=edm::Service<TkDetMap>().operator->();
}
SiStripTrackerMapCreator::~SiStripTrackerMapCreator ( )

Definition at line 29 of file SiStripTrackerMapCreator.cc.

References trackerMap_.

                                                    {
  if (trackerMap_) delete trackerMap_;
}

Member Function Documentation

void SiStripTrackerMapCreator::create ( const edm::ParameterSet tkmapPset,
const edm::ESHandle< SiStripFedCabling > &  fedcabling,
DQMStore dqm_store,
std::string &  htype 
)

Definition at line 35 of file SiStripTrackerMapCreator.cc.

References TrackerMap::fill_all_blank(), TrackerMap::fillc_all_blank(), nDet, paintTkMapFromAlarm(), TrackerMap::printonline(), TrackerMap::setTitle(), setTkMapFromHistogram(), setTkMapRange(), tkMapMax, tkMapMin, and trackerMap_.

                                                                                                 {

  if (trackerMap_) delete trackerMap_;
  trackerMap_ = new TrackerMap(tkmapPset, fedcabling);
  std::string tmap_title = " Tracker Map from  " + map_type;
  trackerMap_->setTitle(tmap_title);
 
  nDet     = 0;
  tkMapMax = 0.0; 
  tkMapMin = 0.0; 

  if (map_type == "QTestAlarm") {
    trackerMap_->fillc_all_blank();
    const std::vector<uint16_t>& feds = fedcabling->feds(); 
    uint32_t detId_save = 0;
    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++){
        
        uint32_t detId = iconn->detId();
        if (detId == 0 || detId == 0xFFFFFFFF)  continue;
        if (detId_save != detId) {
          detId_save = detId;
          paintTkMapFromAlarm(detId, dqm_store);
        }
      }
    } 
  } else {
    trackerMap_->fill_all_blank();
    setTkMapFromHistogram(dqm_store, map_type);
    setTkMapRange(map_type);
  }
  trackerMap_->printonline();
  delete trackerMap_;
  trackerMap_ = 0;
}
void SiStripTrackerMapCreator::createForOffline ( const edm::ParameterSet tkmapPset,
DQMStore dqm_store,
std::string &  htype 
)

Definition at line 76 of file SiStripTrackerMapCreator.cc.

References TrackerMap::save(), TrackerMap::setTitle(), setTkMapFromHistogram(), setTkMapRange(), tkMapMax, tkMapMin, and trackerMap_.

Referenced by SiStripActionExecutor::createOfflineTkMap().

                                                                           {
  if (trackerMap_) delete trackerMap_;
  trackerMap_ = new TrackerMap(tkmapPset);
 
  std::string tmap_title = " Tracker Map from  " + map_type;
  trackerMap_->setTitle(tmap_title);

  setTkMapFromHistogram(dqm_store, map_type);
  setTkMapRange(map_type);

  trackerMap_->save(true, tkMapMin,tkMapMax, map_type+".svg");  
  trackerMap_->save(true, tkMapMin,tkMapMax, map_type+".png",4500,2400);
  delete trackerMap_;
  trackerMap_ = 0;
}
uint16_t SiStripTrackerMapCreator::getDetectorFlagAndComment ( DQMStore dqm_store,
uint32_t  det_id,
std::ostringstream &  comment 
) [private]

Definition at line 214 of file SiStripTrackerMapCreator.cc.

References DQMStore::dirExists(), MonitorElement::DQM_KIND_INT, DQMStore::get(), SiStripUtility::getBadModuleStatus(), MonitorElement::getIntValue(), SiStripFolderOrganizer::getSubDetFolder(), MonitorElement::kind(), argparse::message, and DQMStore::pwd().

Referenced by paintTkMapFromAlarm(), and paintTkMapFromHistogram().

                                                                                                                            {
  comment << " DetId " << det_id << " : ";
  uint16_t flag = 0;

  SiStripFolderOrganizer folder_organizer;
  std::string subdet_folder, badmodule_folder;

  folder_organizer.getSubDetFolder(det_id, subdet_folder);
  if (dqm_store->dirExists(subdet_folder)){ 
    badmodule_folder = subdet_folder + "/BadModuleList";
  } else {
    badmodule_folder = dqm_store->pwd() + "/BadModuleList"; 
  }
  if (!dqm_store->dirExists(badmodule_folder)) return flag;

  std::ostringstream badmodule_path;
  badmodule_path << badmodule_folder << "/" << det_id;

  MonitorElement* bad_module_me = dqm_store->get(badmodule_path.str());
  if (bad_module_me && bad_module_me->kind() == MonitorElement::DQM_KIND_INT) {
    flag = bad_module_me->getIntValue();
    std::string message;
    SiStripUtility::getBadModuleStatus(flag, message);
    comment << message.c_str();
  }
  return flag;
}
void SiStripTrackerMapCreator::paintTkMapFromAlarm ( uint32_t  det_id,
DQMStore dqm_store 
) [private]

Definition at line 95 of file SiStripTrackerMapCreator.cc.

References comment, TrackerMap::fillc(), getDetectorFlagAndComment(), SiStripUtility::getDetectorStatusColor(), TrackerMap::setText(), and trackerMap_.

Referenced by create().

                                                                                       {
  
  std::ostringstream comment;
  uint16_t flag = 0; 
  flag = getDetectorFlagAndComment(dqm_store, det_id, comment);

  int rval, gval, bval;
  SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
  trackerMap_->setText(det_id, comment.str());
  trackerMap_->fillc(det_id, rval, gval, bval);
}
void SiStripTrackerMapCreator::paintTkMapFromHistogram ( DQMStore dqm_store,
MonitorElement me,
std::string &  map_type 
) [private]

Definition at line 157 of file SiStripTrackerMapCreator.cc.

References comment, MonitorElement::DQM_KIND_TPROFILE2D, TrackerMap::fill_current_val(), TrackerMap::fillc(), MonitorElement::getBinContent(), getDetectorFlagAndComment(), SiStripUtility::getDetectorStatusColor(), TkDetMap::getDetsForLayer(), TkDetMap::getLayerNum(), MonitorElement::getName(), MonitorElement::getTProfile2D(), TkDetMap::getXY(), TkLayerMap::XYbin::ix, TkLayerMap::XYbin::iy, MonitorElement::kind(), AlCaRecoCosmics_cfg::name, nDet, TrackerMap::setText(), tkDetMap_, tkMapMax, and trackerMap_.

Referenced by setTkMapFromHistogram().

                                                                                                                {
  std::string name  = me->getName();
  std::string lname = name.substr(name.find("TkHMap_")+7);  
  lname = lname.substr(lname.find("_T")+1);
  std::vector<uint32_t> layer_detids;
  tkDetMap_->getDetsForLayer(tkDetMap_->getLayerNum(lname), layer_detids);
  for (std::vector<uint32_t>::const_iterator idet = layer_detids.begin(); idet != layer_detids.end(); idet++) {
    uint32_t det_id= (*idet);
    if (det_id <= 0) continue;
    nDet++;
    std::ostringstream comment;
    uint32_t flag = 0;
    flag = getDetectorFlagAndComment(dqm_store, det_id, comment);
    trackerMap_->setText(det_id, comment.str());
    const TkLayerMap::XYbin& xyval = tkDetMap_->getXY(det_id);
    float fval = 0.0;
    if ( (name.find("NumberOfOfffTrackCluster") != std::string::npos) || 
         (name.find("NumberOfOnTrackCluster") != std::string::npos) ) {
      if (me->kind() == MonitorElement::DQM_KIND_TPROFILE2D) {   
        TProfile2D* tp = me->getTProfile2D() ;
        fval =  tp->GetBinEntries(tp->GetBin(xyval.ix, xyval.iy)) * tp->GetBinContent(xyval.ix, xyval.iy);
      }
    } else  fval = me->getBinContent(xyval.ix, xyval.iy);
    if (htype == "QTestAlarm") {
      int rval, gval, bval;
      SiStripUtility::getDetectorStatusColor(flag, rval, gval, bval);
      trackerMap_->fillc(det_id, rval, gval, bval);
    } else {
      tkMapMax += fval;
      if (fval == 0.0) trackerMap_->fillc(det_id,255, 255, 255);  
      else {
        trackerMap_->fill_current_val(det_id, fval);
      }
    }
  }
} 
bool SiStripTrackerMapCreator::readConfiguration ( )
void SiStripTrackerMapCreator::setTkMapFromHistogram ( DQMStore dqm_store,
std::string &  htype 
) [private]

Definition at line 109 of file SiStripTrackerMapCreator.cc.

References DQMStore::cd(), DQMStore::dirExists(), DQMStore::getContents(), DQMStore::getSubdirs(), SiStripUtility::goToDir(), AlCaRecoCosmics_cfg::name, nDet, paintTkMapFromHistogram(), DQMStore::pwd(), tkMapMax, and tkMapMin.

Referenced by create(), and createForOffline().

                                                                                          {
  dqm_store->cd();

  std::string mdir = "MechanicalView";
  if (!SiStripUtility::goToDir(dqm_store, mdir)) return;
  std::string mechanicalview_dir = dqm_store->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");

  nDet     = 0;
  tkMapMax = 0.0; 
  tkMapMin = 0.0; 

  for (std::vector<std::string>::const_iterator it = subdet_folder.begin(); it != subdet_folder.end(); it++) {
    std::string dname = mechanicalview_dir + "/" + (*it);
    if (!dqm_store->dirExists(dname)) continue;
    dqm_store->cd(dname);  
    std::vector<std::string> layerVec = dqm_store->getSubdirs();
    for (std::vector<std::string>::const_iterator iLayer = layerVec.begin(); iLayer != layerVec.end(); iLayer++) { 
      if ((*iLayer).find("BadModuleList") !=std::string::npos) continue;
      std::vector<MonitorElement*> meVec = dqm_store->getContents((*iLayer));
      MonitorElement* tkhmap_me = 0;
      std::string name;
      for (std::vector<MonitorElement*>::const_iterator itkh = meVec.begin();  itkh != meVec.end(); itkh++) {
        name = (*itkh)->getName();
        if (name.find("TkHMap") == std::string::npos) continue;
        if (htype == "QTestAlarm" ){
          tkhmap_me = (*itkh);
          break;
        } else if (name.find(htype) != std::string::npos) {
          tkhmap_me = (*itkh);
          break; 
        } 
      }
      if (tkhmap_me != 0) {
        paintTkMapFromHistogram(dqm_store,tkhmap_me, htype);
      } 
    }
    dqm_store->cd(mechanicalview_dir);
  }
  dqm_store->cd();
}
void SiStripTrackerMapCreator::setTkMapRange ( std::string &  map_type) [private]

Definition at line 196 of file SiStripTrackerMapCreator.cc.

References nDet, TrackerMap::setRange(), tkMapMax, tkMapMin, and trackerMap_.

Referenced by create(), and createForOffline().

                                                                {
  tkMapMin = 0.0;
  if (tkMapMax == 0.0) { 
    if (map_type.find("FractionOfBadChannels") != std::string::npos)        tkMapMax = 1.0;
    else if (map_type.find("NumberOfCluster") != std::string::npos)         tkMapMax = 0.01;
    else if (map_type.find("NumberOfDigi") != std::string::npos)            tkMapMax = 0.6;
    else if (map_type.find("NumberOfOffTrackCluster") != std::string::npos) tkMapMax = 100.0;
    else if (map_type.find("NumberOfOnTrackCluster") != std::string::npos)  tkMapMax = 50.0;
    else if (map_type.find("StoNCorrOnTrack") != std::string::npos)         tkMapMax = 200.0;
  } else {
    tkMapMax = tkMapMax/nDet*1.0;
    tkMapMax = tkMapMax * 2.5;
 }
  trackerMap_->setRange(tkMapMin, tkMapMax);
}

Member Data Documentation

Definition at line 47 of file SiStripTrackerMapCreator.h.

Referenced by paintTkMapFromHistogram(), and SiStripTrackerMapCreator().

std::string SiStripTrackerMapCreator::tkMapName_ [private]

Definition at line 42 of file SiStripTrackerMapCreator.h.