CMS 3D CMS Logo

SiStripTrackerMapCreator.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripMonitorClient/interface/SiStripTrackerMapCreator.h"
00002 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
00003 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00004 #include "DQM/SiStripMonitorClient/interface/SiStripUtility.h"
00005 #include "DQM/SiStripMonitorClient/interface/SiStripConfigParser.h"
00006 #include "DQMServices/Core/interface/DQMStore.h"
00007 #include <iostream>
00008 using namespace std;
00009 //
00010 // -- Constructor
00011 // 
00012 SiStripTrackerMapCreator::SiStripTrackerMapCreator() {
00013   tkMapFrequency_ = -1;
00014   trackerMap_ = 0;
00015 }
00016 //
00017 // -- Destructor
00018 //
00019 SiStripTrackerMapCreator::~SiStripTrackerMapCreator() {
00020   if (trackerMap_) delete trackerMap_;
00021 }
00022 //
00023 // -- Read ME list
00024 //
00025 bool SiStripTrackerMapCreator::readConfiguration() {
00026   SiStripConfigParser config_parser;
00027   string localPath = string("DQM/SiStripMonitorClient/data/sistrip_monitorelement_config.xml");
00028   config_parser.getDocument(edm::FileInPath(localPath).fullPath());
00029   if (!config_parser.getFrequencyForTrackerMap(tkMapFrequency_)){
00030     cout << "SiStripActionExecutor::readConfiguration: Failed to read TrackerMap configuration parameters!! ";
00031     tkMapFrequency_ = -1;
00032     return false;
00033   }
00034 
00035   if (!config_parser.getMENamesForTrackerMap(tkMapName_, meNames_)){  
00036     cout << "SiStripTrackerMapCreator::readConfiguration: Failed to read TrackerMap configuration parameters!! ";
00037     return false;
00038   }
00039   cout << " # of MEs in Tk Map " << meNames_.size() << endl;
00040   return true;
00041 }
00042 //
00043 // -- Get Tracker Map ME names
00044 //
00045 int SiStripTrackerMapCreator::getMENames(vector<string>& me_names) {
00046   if (meNames_.size() == 0) return 0;
00047   for (vector<string>::const_iterator im = meNames_.begin();
00048        im != meNames_.end(); im++) {
00049     me_names.push_back(*im);
00050   }
00051   return me_names.size();
00052 }
00053 //
00054 // -- Create Geometric and Fed Tracker Map
00055 //
00056 void SiStripTrackerMapCreator::create(const edm::ParameterSet & tkmapPset, 
00057            const edm::ESHandle<SiStripFedCabling>& fedcabling, DQMStore* dqm_store) {
00058 
00059   if (meNames_.size() == 0) return;
00060   if (!trackerMap_)     trackerMap_    = new TrackerMap(tkmapPset, fedcabling);
00061 
00062   const vector<uint16_t>& feds = fedcabling->feds(); 
00063   uint32_t detId_save = 0;
00064   map<MonitorElement*,int> local_mes;
00065   SiStripFolderOrganizer folder_organizer;
00066   for(vector<unsigned short>::const_iterator ifed = feds.begin(); 
00067                       ifed < feds.end(); ifed++){
00068     const std::vector<FedChannelConnection> fedChannels = fedcabling->connections( *ifed );
00069     for(std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); iconn < fedChannels.end(); iconn++){
00070       
00071       uint32_t detId = iconn->detId();
00072       if (detId == 0 || detId == 0xFFFFFFFF)  continue;
00073       if (detId_save != detId) {
00074         detId_save = detId;
00075         local_mes.clear();
00076         string dir_path;
00077         folder_organizer.getFolderName(detId, dir_path);
00078         vector<MonitorElement*> all_mes = dqm_store->getContents(dir_path);
00079         for (vector<MonitorElement *>::const_iterator it = all_mes.begin();
00080              it!= all_mes.end(); it++) {
00081           if (!(*it)) continue;
00082           string me_name = (*it)->getName();        
00083           int istat = 0;
00084           for (vector<string>::const_iterator im = meNames_.begin();
00085                im != meNames_.end(); im++) {
00086             if (me_name.find(*im) == string::npos) continue;
00087             istat =  SiStripUtility::getMEStatus((*it)); 
00088             local_mes.insert(pair<MonitorElement*, int>((*it), istat));
00089           }
00090         }
00091         paintTkMap(detId,local_mes);              
00092       }
00093     }
00094   }
00095 
00096   trackerMap_->printonline();
00097 }
00098 //
00099 // -- Draw Monitor Elements
00100 //
00101 void SiStripTrackerMapCreator::paintTkMap(int det_id, map<MonitorElement*, int>& me_map) {
00102   int icol;
00103   string tag;
00104 
00105   ostringstream comment;
00106   comment << "Mean Value(s) : ";
00107   int gstatus = 0;
00108 
00109   MonitorElement* me;
00110   for (map<MonitorElement*,int>::const_iterator it = me_map.begin(); 
00111               it != me_map.end(); it++) {
00112     me = it->first;
00113     if (!me) continue;
00114     float mean = me->getMean();
00115     comment <<   mean <<  " : " ;
00116     // global status 
00117     if (it->second > gstatus ) gstatus = it->second;
00118     SiStripUtility::getMEStatusColor(it->second, icol, tag);   
00119   }
00120   if (0) {cout << " Detector ID : " << det_id 
00121                << " " << comment.str()
00122                << " Status : " << gstatus  << endl;
00123   }
00124   trackerMap_->setText(det_id, comment.str());
00125   int rval, gval, bval;
00126   SiStripUtility::getMEStatusColor(gstatus, rval, gval, bval);
00127   trackerMap_->fillc(det_id, rval, gval, bval);
00128 }

Generated on Tue Jun 9 17:33:35 2009 for CMSSW by  doxygen 1.5.4