CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripSummaryCreator Class Reference

#include <SiStripSummaryCreator.h>

List of all members.

Public Member Functions

void createSummary (DQMStore *dqm_store)
void fillLayout (DQMStore *dqm_store)
int getFrequency ()
bool readConfiguration (std::string &file_path)
void setSummaryMENames (std::map< std::string, std::string > &me_names)
 SiStripSummaryCreator ()
virtual ~SiStripSummaryCreator ()

Private Member Functions

void fillGrandSummaryHistos (DQMStore *dqm_store)
void fillHistos (int ival, int istep, std::string htype, MonitorElement *me_src, MonitorElement *me)
void fillSummaryHistos (DQMStore *dqm_store)
MonitorElementgetSummaryME (DQMStore *dqm_store, std::string &name, std::string htype)

Private Attributes

int summaryFrequency_
std::map< std::string,
std::string > 
summaryMEMap

Detailed Description

Definition at line 14 of file SiStripSummaryCreator.h.


Constructor & Destructor Documentation

SiStripSummaryCreator::SiStripSummaryCreator ( )

Definition at line 11 of file SiStripSummaryCreator.cc.

References summaryFrequency_, and summaryMEMap.

                                             {
  edm::LogInfo("SiStripSummaryCreator") << 
    " Creating SiStripSummaryCreator " << "\n" ;
  summaryMEMap.clear();
  summaryFrequency_ = -1;
}
SiStripSummaryCreator::~SiStripSummaryCreator ( ) [virtual]

Definition at line 20 of file SiStripSummaryCreator.cc.

References summaryMEMap.

                                              {
  edm::LogInfo("SiStripSummaryCreator") << 
    " Deleting SiStripSummaryCreator " << "\n" ;
  summaryMEMap.clear();
}

Member Function Documentation

void SiStripSummaryCreator::createSummary ( DQMStore dqm_store)

Definition at line 57 of file SiStripSummaryCreator.cc.

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

Referenced by SiStripActionExecutor::createSummary(), and SiStripActionExecutor::createSummaryOffline().

                                                             {
  if (summaryMEMap.size() == 0) return;
  std::string currDir = dqm_store->pwd();
  std::vector<std::string> subdirs = dqm_store->getSubdirs();
  int nmod = 0;
  for (std::vector<std::string>::const_iterator it = subdirs.begin();
       it != subdirs.end(); it++) {
    if ( (*it).find("module_") == std::string::npos) continue;
    nmod++;       
  }  
  if (nmod > 0) {
    fillSummaryHistos(dqm_store);
  } else {  
    for (std::vector<std::string>::const_iterator it = subdirs.begin();
       it != subdirs.end(); it++) {
      dqm_store->cd(*it);
      createSummary(dqm_store);
      dqm_store->goUp();
    }
    fillGrandSummaryHistos(dqm_store);
  }
}
void SiStripSummaryCreator::fillGrandSummaryHistos ( DQMStore dqm_store) [private]

Definition at line 126 of file SiStripSummaryCreator.cc.

References DQMStore::cd(), cmsMakeMELists::contents, compare_using_db::dir_name, fillHistos(), DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getNbinsX(), DQMStore::getSubdirs(), getSummaryME(), DQMStore::goUp(), isum, mergeVDriftHistosByStation::name, DQMStore::pwd(), and summaryMEMap.

Referenced by createSummary().

                                                                      {
  std::map<std::string, MonitorElement*> MEMap;
  std::string currDir = dqm_store->pwd();
  std::string dir_name =  currDir.substr(currDir.find_last_of("/")+1);
  if ((dir_name.find("SiStrip") == 0) ||
      (dir_name.find("Collector") == 0) ||
      (dir_name.find("MechanicalView") == 0) ||
      (dir_name.find("FU") == 0) ) return;
  std::vector<std::string> subdirs = dqm_store->getSubdirs();
  if (subdirs.size() == 0) return;;
  for (std::map<std::string,std::string>::const_iterator isum = summaryMEMap.begin();
       isum != summaryMEMap.end(); isum++) {
    std::string name, summary_name;
    name = isum->first;
    if (isum->second == "sum" || isum->second == "sum")    
      summary_name = "Summary_" + isum->first;
    else 
      summary_name = "Summary_Mean" + isum->first;
    std::string htype = isum->second;
    int ibinStep =0;
    for (std::vector<std::string>::const_iterator it = subdirs.begin();
         it != subdirs.end(); it++) {
      dqm_store->cd(*it);
      std::vector<MonitorElement*> contents = dqm_store->getContents(dqm_store->pwd());
      dqm_store->goUp();
      for (std::vector<MonitorElement *>::const_iterator im = contents.begin();
                im != contents.end(); im++) {
        MonitorElement * me_i = (*im);
        if (!me_i) continue;
        std::string name_i = me_i->getName();
        if (name_i.find((summary_name)) != std::string::npos) {
          
          std::map<std::string, MonitorElement*>::iterator iPos = MEMap.find(name); 
          MonitorElement* me; 
          if (iPos == MEMap.end()) {
            if (htype == "sum" || htype == "Sum") {
              me = getSummaryME(dqm_store, name, htype);
            } else {
              me = getSummaryME(dqm_store, name, "bin-by-bin");              
            }
            MEMap.insert(std::pair<std::string, MonitorElement*>(name, me));
          } else  me =  iPos->second;
          if (htype == "sum" || htype == "Sum") {
            fillHistos(0, ibinStep, htype, me_i, me);
          } else {
            fillHistos(0, ibinStep,"bin-by-bin", me_i, me);
          }
          ibinStep += me_i->getNbinsX();
          break;
        }
      }
    }
  }
}
void SiStripSummaryCreator::fillHistos ( int  ival,
int  istep,
std::string  htype,
MonitorElement me_src,
MonitorElement me 
) [private]

Definition at line 297 of file SiStripSummaryCreator.cc.

References cond::ecalcond::bad(), MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH2F, python::tagInventory::entries, MonitorElement::Fill(), MonitorElement::getBinContent(), MonitorElement::getEntries(), MonitorElement::getMean(), MonitorElement::getName(), MonitorElement::getNbinsX(), MonitorElement::getTH1(), MonitorElement::getTH1F(), MonitorElement::getTH2F(), gen::k, MonitorElement::kind(), pileupCalc::nbins, and MonitorElement::setBinContent().

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

                                                                   {
  
  if (me->getTH1()) {
    //    TProfile* prof = 0;
    TH1F* hist1 = 0;
    TH2F* hist2 = 0;
    if (me->kind() == MonitorElement::DQM_KIND_TH1F)    hist1 = me->getTH1F();
    if (me->kind() == MonitorElement::DQM_KIND_TH2F)    hist2 = me->getTH2F();
    //    if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) prof = me->getTProfile();
    
    int nbins = me_src->getNbinsX();
    std::string name = me_src->getName();
    if (htype == "mean" || htype == "Mean" ) {
      if (hist2 &&  name.find("NoisyStrips") != std::string::npos) {
        float bad = 0.0;
        float entries = me_src->getEntries();
        if (entries > 0.0) {
          float binEntry = entries/nbins;
          for (int k=1; k<nbins+1; k++) {
            float noisy = me_src->getBinContent(k,3)+me_src->getBinContent(k,5);
            float dead = me_src->getBinContent(k,2)+me_src->getBinContent(k,4);
//          float good = me_src->getBinContent(k,1);
            if (noisy >= binEntry*0.5 || dead >= binEntry*0.5) bad++;
          }
          bad = bad*100.0/nbins;    
          me->Fill(ival, bad);
        }
      } else me->Fill(ival, me_src->getMean());
    } else if (htype == "bin-by-bin" || htype == "Bin-by-Bin") {
      for (int k=1; k<nbins+1; k++) {
        me->setBinContent(istep+k,me_src->getBinContent(k));
      }
    } else if (htype == "sum" || htype == "Sum") {  
      if ( hist1) {
        for (int k=1; k<nbins+1; k++) {
          float val = me_src->getBinContent(k) + me->getBinContent(k) ;
          me->setBinContent(k,val);
        }
      }        
    }
  }
}
void SiStripSummaryCreator::fillLayout ( DQMStore dqm_store)
void SiStripSummaryCreator::fillSummaryHistos ( DQMStore dqm_store) [private]

Definition at line 82 of file SiStripSummaryCreator.cc.

References DQMStore::cd(), cmsMakeMELists::contents, fillHistos(), DQMStore::getContents(), MonitorElement::getName(), MonitorElement::getNbinsX(), DQMStore::getSubdirs(), getSummaryME(), DQMStore::goUp(), isum, mergeVDriftHistosByStation::name, DQMStore::pwd(), and summaryMEMap.

Referenced by createSummary().

                                                                 {
  std::string currDir = dqm_store->pwd();
  std::map<std::string, MonitorElement*> MEMap;
  std::vector<std::string> subdirs = dqm_store->getSubdirs();
  if (subdirs.size() ==0) return;
  

  for (std::map<std::string,std::string>::const_iterator isum = summaryMEMap.begin();
       isum != summaryMEMap.end(); isum++) {    
    std::string name = isum->first;
    int iBinStep = 0;
    int ndet = 0;
    std::string htype = isum->second;
    for (std::vector<std::string>::const_iterator it = subdirs.begin();
         it != subdirs.end(); it++) {
      if ( (*it).find("module_") == std::string::npos) continue;
      dqm_store->cd(*it);
      ndet++;
      std::vector<MonitorElement*> contents = dqm_store->getContents(dqm_store->pwd());
      dqm_store->goUp();
      for (std::vector<MonitorElement *>::const_iterator im = contents.begin();
                im != contents.end(); im++) {
        MonitorElement * me_i = (*im);
        if (!me_i) continue;
        std::string name_i = me_i->getName();
        if (name_i.find(name) == std::string::npos) continue;
        std::map<std::string, MonitorElement*>::iterator iPos = MEMap.find(name); 
        MonitorElement* me;
        // Get the Summary ME
        if (iPos == MEMap.end()){
            me = getSummaryME(dqm_store, name, htype);
            MEMap.insert(std::pair<std::string, MonitorElement*>(name, me));
        } else  me =  iPos->second;
        // Fill it now
        fillHistos(ndet, iBinStep, htype, me_i, me); 
        iBinStep += me_i->getNbinsX();
        break;
      }
    }
  }
}
int SiStripSummaryCreator::getFrequency ( ) [inline]

Definition at line 26 of file SiStripSummaryCreator.h.

References summaryFrequency_.

{ return summaryFrequency_;}
MonitorElement * SiStripSummaryCreator::getSummaryME ( DQMStore dqm_store,
std::string &  name,
std::string  htype 
) [private]

Definition at line 1398 of file SiPixelActionExecutor.cc.

References DQMStore::book1D(), cmsMakeMELists::contents, spr::find(), DQMStore::get(), DQMStore::getMEs(), DQMStore::pwd(), and MonitorElement::Reset().

Referenced by fillGrandSummaryHistos(), and fillSummaryHistos().

                                                                    {
  //printing cout<<"Entering SiPixelActionExecutor::getSummaryME for: "<<me_name<<endl;
  MonitorElement* me = 0;
  if((bei->pwd()).find("Pixel")==string::npos) return me;
  vector<string> contents = bei->getMEs();    
        
  for (vector<string>::const_iterator it = contents.begin();
       it != contents.end(); it++) {
    if ((*it).find(me_name) == 0) {
      string fullpathname = bei->pwd() + "/" + (*it); 
      me = bei->get(fullpathname);
                        
      if (me) {
        //printing cout<<"got this ME: "<<fullpathname<<endl;
        me->Reset();
        return me;
      }
    }
  }
  contents.clear();
//      cout << me_name.c_str() 
//              << "\t" << ((me_name.find("SUMOFF")==string::npos)?"true":"false")
//              << "\t" << ((me_name.find("Blade_")!= string::npos)?"true":"false")
//              << "\t" << ((me_name.find("Layer1_")!=string::npos)?"true":"false")
//              << "\t" << ((me_name.find("Layer2_")!=string::npos)?"true":"false")
//              << "\t" << ((me_name.find("Layer3_")!=string::npos)?"true":"false")
//              << "\t" << ((me_name.find("Disk_")!=string::npos)?"true":"false")
//              << endl;
  if(me_name.find("SUMOFF")==string::npos){
        if(me_name.find("Blade_")!=string::npos)me = bei->book1D(me_name.c_str(), me_name.c_str(),7,1.,8.);
        else me = bei->book1D(me_name.c_str(), me_name.c_str(),4,1.,5.);
//    if(me_name.find("Panel_2")!=string::npos)  me = bei->book1D(me_name.c_str(), me_name.c_str(),3,1.,4.);
//    else me = bei->book1D(me_name.c_str(), me_name.c_str(),4,1.,5.);
  }else if(me_name.find("Layer_1")!=string::npos){ me = bei->book1D(me_name.c_str(), me_name.c_str(),10,1.,11.);
  }else if(me_name.find("Layer_2")!=string::npos){ me = bei->book1D(me_name.c_str(), me_name.c_str(),16,1.,17.);
  }else if(me_name.find("Layer_3")!=string::npos){ me = bei->book1D(me_name.c_str(), me_name.c_str(),22,1.,23.);
  }else if(me_name.find("Disk_")!=string::npos){ me = bei->book1D(me_name.c_str(), me_name.c_str(),12,1.,13.);
  }
        
  //  if(me) cout<<"Finally got this ME: "<<me_name<<endl;
  //if(me_name.find("ALLMODS_adc_")!=string::npos) me = bei->book1D(me_name.c_str(), me_name.c_str(),256, 0., 256.);
        
  //printing cout<<"...leaving SiPixelActionExecutor::getSummaryME!"<<endl;
  return me;
}
bool SiStripSummaryCreator::readConfiguration ( std::string &  file_path)

Definition at line 28 of file SiStripSummaryCreator.cc.

References gather_cfg::cout, DQMParserBase::getDocument(), SiStripConfigParser::getFrequencyForSummary(), SiStripConfigParser::getMENamesForSummary(), summaryFrequency_, and summaryMEMap.

Referenced by SiStripActionExecutor::readConfiguration().

                                                                  {
    summaryMEMap.clear();
  SiStripConfigParser config_parser;
  config_parser.getDocument(edm::FileInPath(file_path).fullPath());
  if (!config_parser.getFrequencyForSummary(summaryFrequency_)){
    std::cout << "SiStripSummaryCreator::readConfiguration: Failed to read Summary configuration parameters!! ";
    summaryFrequency_ = -1;
    return false;
  }  
  if (!config_parser.getMENamesForSummary(summaryMEMap)) {
    std::cout << "SiStripSummaryCreator::readConfiguration: Failed to read Summary configuration parameters!! ";
    return false;
  }
  return true;
}
void SiStripSummaryCreator::setSummaryMENames ( std::map< std::string, std::string > &  me_names)

Definition at line 46 of file SiStripSummaryCreator.cc.

References isum, and summaryMEMap.

                                                                                    {

  summaryMEMap.clear();
  for (std::map<std::string,std::string>::const_iterator isum = me_names.begin();
       isum != me_names.end(); isum++) {    
    summaryMEMap.insert(std::pair<std::string,std::string>(isum->first, isum->second));
  }
}

Member Data Documentation

Definition at line 41 of file SiStripSummaryCreator.h.

Referenced by getFrequency(), readConfiguration(), and SiStripSummaryCreator().

std::map<std::string, std::string> SiStripSummaryCreator::summaryMEMap [private]