CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTSegmentAnalysisTest Class Reference

#include <DTSegmentAnalysisTest.h>

Inheritance diagram for DTSegmentAnalysisTest:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze.
void beginJob ()
 BeginJob.
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
void beginRun (const edm::Run &run, const edm::EventSetup &eSetup)
void bookHistos ()
 book the summary histograms
 DTSegmentAnalysisTest (const edm::ParameterSet &ps)
 Constructor.
void endJob (void)
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
 DQM Client Diagnostic in online mode.
void endRun (edm::Run const &run, edm::EventSetup const &c)
 DQM Client Diagnostic in offline mode.
std::string getMEName (const DTChamberId &chID, std::string histoTag)
 Get the ME name.
void performClientDiagnostic ()
 Perform client diagnostic operations.
virtual ~DTSegmentAnalysisTest ()
 Destructor.

Private Attributes

std::map< std::pair< int, int >
, MonitorElement * > 
chi2Histos
DQMStoredbe
bool detailedAnalysis
bool hltDQMMode
edm::ESHandle< DTGeometrymuonGeom
int nevents
unsigned int nLumiSegs
int nMinEvts
bool normalizeHistoPlots
edm::ParameterSet parameters
bool runOnline
std::map< std::pair< int, int >
, MonitorElement * > 
segmRecHitHistos
std::map< int, MonitorElement * > summaryHistos
std::string topHistoFolder

Detailed Description

* DQM Test Client

Date:
2011/06/10 13:50:12
Revision:
1.10
Author:
G. Mila - INFN Torino

Definition at line 41 of file DTSegmentAnalysisTest.h.


Constructor & Destructor Documentation

DTSegmentAnalysisTest::DTSegmentAnalysisTest ( const edm::ParameterSet ps)

Constructor.

Definition at line 45 of file DTSegmentAnalysisTest.cc.

References edm::ParameterSet::getUntrackedParameter(), LogTrace, cppFunctionSkipper::operator, and Parameters::parameters.

                                                                  {

  LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "[DTSegmentAnalysisTest]: Constructor";
  parameters = ps;

  dbe = Service<DQMStore>().operator->();

  // get the cfi parameters
  detailedAnalysis = parameters.getUntrackedParameter<bool>("detailedAnalysis",false);
  normalizeHistoPlots  = parameters.getUntrackedParameter<bool>("normalizeHistoPlots",false);
  runOnline  = parameters.getUntrackedParameter<bool>("runOnline",true);
  // top folder for the histograms in DQMStore
  topHistoFolder = ps.getUntrackedParameter<string>("topHistoFolder","DT/02-Segments");
  // hlt DQM mode
  hltDQMMode = ps.getUntrackedParameter<bool>("hltDQMMode",false);
  nMinEvts  = ps.getUntrackedParameter<int>("nEventsCert", 5000);

}
DTSegmentAnalysisTest::~DTSegmentAnalysisTest ( ) [virtual]

Destructor.

Definition at line 65 of file DTSegmentAnalysisTest.cc.

References LogTrace, and nevents.

                                             {

  LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "DTSegmentAnalysisTest: analyzed " << nevents << " events";
}

Member Function Documentation

void DTSegmentAnalysisTest::analyze ( const edm::Event e,
const edm::EventSetup c 
) [virtual]

Analyze.

Implements edm::EDAnalyzer.

Definition at line 99 of file DTSegmentAnalysisTest.cc.

References LogTrace, and nevents.

                                                                            {
 
  nevents++;
  if(nevents%1000 == 0)
    LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "[DTSegmentAnalysisTest]: "<<nevents<<" events";

}
void DTSegmentAnalysisTest::beginJob ( void  ) [virtual]

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 71 of file DTSegmentAnalysisTest.cc.

References bookHistos(), LogTrace, and nevents.

                                    {

  LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") <<"[DTSegmentAnalysisTest]: BeginJob"; 

  nevents = 0;

  // book the histos
  bookHistos();  

}
void DTSegmentAnalysisTest::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file DTSegmentAnalysisTest.cc.

References LogTrace.

                                                                                                          {

  LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") <<"[DTSegmentAnalysisTest]: Begin of LS transition";

}
void DTSegmentAnalysisTest::beginRun ( const edm::Run run,
const edm::EventSetup eSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file DTSegmentAnalysisTest.cc.

References edm::EventSetup::get(), and LogTrace.

                                                                             {

  LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") <<"[DTSegmentAnalysisTest]: BeginRun"; 

  context.get<MuonGeometryRecord>().get(muonGeom);

}
void DTSegmentAnalysisTest::bookHistos ( )

book the summary histograms

Definition at line 328 of file DTSegmentAnalysisTest.cc.

                                       {

  for(int wh=-2; wh<=2; wh++){
      stringstream wheel; wheel << wh;
      string histoName =  "segmentSummary_W" + wheel.str();
      dbe->setCurrentFolder(topHistoFolder);
      summaryHistos[wh] = dbe->book2D(histoName.c_str(),histoName.c_str(),12,1,13,4,1,5);
      summaryHistos[wh]->setAxisTitle("Sector",1);
      summaryHistos[wh]->setBinLabel(1,"MB1",2);
      summaryHistos[wh]->setBinLabel(2,"MB2",2);
      summaryHistos[wh]->setBinLabel(3,"MB3",2);
      summaryHistos[wh]->setBinLabel(4,"MB4",2);

      if(detailedAnalysis){
        for(int sect=1; sect<=14; sect++){
          stringstream sector; sector << sect;
          string chi2HistoName =  "chi2BadSegmPercentual_W" + wheel.str() + "_Sec" + sector.str();
          dbe->setCurrentFolder(topHistoFolder + "/Wheel" + wheel.str() + "/Tests");
          chi2Histos[make_pair(wh,sect)] = dbe->book1D(chi2HistoName.c_str(),chi2HistoName.c_str(),4,1,5);
          chi2Histos[make_pair(wh,sect)]->setBinLabel(1,"MB1");
          chi2Histos[make_pair(wh,sect)]->setBinLabel(2,"MB2");
          chi2Histos[make_pair(wh,sect)]->setBinLabel(3,"MB3");
          chi2Histos[make_pair(wh,sect)]->setBinLabel(4,"MB4");
          
          string segmHistoName =  "residualsOnSegmRecHitNumber_W" + wheel.str() + "_Sec" + sector.str();
          segmRecHitHistos[make_pair(wh,sect)] = dbe->book1D(segmHistoName.c_str(),segmHistoName.c_str(),4,1,5);
          segmRecHitHistos[make_pair(wh,sect)]->setBinLabel(1,"MB1");
          segmRecHitHistos[make_pair(wh,sect)]->setBinLabel(2,"MB2");
          segmRecHitHistos[make_pair(wh,sect)]->setBinLabel(3,"MB3");
          segmRecHitHistos[make_pair(wh,sect)]->setBinLabel(4,"MB4");
          
        }
      }
  }
  
  string histoName =  "segmentSummary";
  dbe->setCurrentFolder(topHistoFolder);
  summaryHistos[3] = dbe->book2D(histoName.c_str(),histoName.c_str(),12,1,13,5,-2,3);
  summaryHistos[3]->setAxisTitle("Sector",1);
  summaryHistos[3]->setAxisTitle("Wheel",2); 

  summaryHistos[4] = dbe->book2D("SegmentGlbSummary",histoName.c_str(),12,1,13,5,-2,3);
  summaryHistos[4]->setAxisTitle("Sector",1);
  summaryHistos[4]->setAxisTitle("Wheel",2); 


}
void DTSegmentAnalysisTest::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 379 of file DTSegmentAnalysisTest.cc.

                                   {
}
void DTSegmentAnalysisTest::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  c 
) [virtual]

DQM Client Diagnostic in online mode.

Reimplemented from edm::EDAnalyzer.

Definition at line 108 of file DTSegmentAnalysisTest.cc.

References edm::LuminosityBlockBase::id(), LogTrace, and edm::LuminosityBlockID::luminosityBlock().

                                                                                                        {

  // counts number of lumiSegs 
  nLumiSegs = lumiSeg.id().luminosityBlock();
 
  if (runOnline) {
    LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
      <<"[DTSegmentAnalysisTest]: End of LS " << nLumiSegs 
      << ". Client called in online mode , perform DQM client operation";
    performClientDiagnostic();
  }

}
void DTSegmentAnalysisTest::endRun ( edm::Run const &  run,
edm::EventSetup const &  c 
) [virtual]

DQM Client Diagnostic in offline mode.

Reimplemented from edm::EDAnalyzer.

Definition at line 122 of file DTSegmentAnalysisTest.cc.

References LogTrace, and DTTimeEvolutionHisto::normalizeTo().

                                                                            {

  if (!runOnline) {
    LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
      <<"[DTSegmentAnalysisTest]: endRun. Client called in offline mode , perform DQM client operation";
    performClientDiagnostic();
  }

  if(normalizeHistoPlots) {
    LogTrace ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << " Performing time-histo normalization" << endl;
    MonitorElement* hNevtPerLS = 0;
    if(hltDQMMode) hNevtPerLS = dbe->get(topHistoFolder + "/NevtPerLS");
    else  hNevtPerLS = dbe->get("DT/EventInfo/NevtPerLS");

    if(hNevtPerLS != 0) {
      for(int wheel = -2; wheel != 3; ++wheel) { // loop over wheels
        for(int sector = 1; sector <= 12; ++sector) { // loop over sectors
          stringstream wheelstr; wheelstr << wheel;     
          stringstream sectorstr; sectorstr << sector;
          string sectorHistoName = topHistoFolder + "/Wheel" + wheelstr.str() +
            "/Sector" + sectorstr.str() +
            "/NSegmPerEvent_W" + wheelstr.str() +
            "_Sec" + sectorstr.str();
          DTTimeEvolutionHisto hNSegmPerLS(&(*dbe), sectorHistoName);
          hNSegmPerLS.normalizeTo(hNevtPerLS);
        }
      }
    } else {
      LogError ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "Histo NevtPerLS not found!" << endl;
    }
  }

}
std::string DTSegmentAnalysisTest::getMEName ( const DTChamberId chID,
std::string  histoTag 
)

Get the ME name.

void DTSegmentAnalysisTest::performClientDiagnostic ( )

Perform client diagnostic operations.

Definition at line 156 of file DTSegmentAnalysisTest.cc.

References abs, newFWLiteAna::bin, HcalObjRepresent::Fill(), QReport::getBadChannels(), MonitorElement::getFloatValue(), MonitorElement::getTH1F(), MonitorElement::getTH2F(), timingPdfMaker::histo, pileupCalc::nbins, Parameters::parameters, DTChamberId::sector(), DTChamberId::station(), dtDQMClient_cfg::threshold, CommonMethods::weight(), and DTChamberId::wheel().

                                                    {

  summaryHistos[3]->Reset();
  summaryHistos[4]->Reset();
  vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
  vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
 
  for (; ch_it != ch_end; ++ch_it) {
    DTChamberId chID = (*ch_it)->id();
    
    MonitorElement * hNHits = dbe->get(getMEName(chID, "h4DSegmNHits"));
    MonitorElement * hSegmOcc = dbe->get(getMEName(chID, "numberOfSegments"));
   
    if (hNHits && hSegmOcc) {
      
      TH1F * hNHits_root = hNHits->getTH1F();
      TH2F * hSegmOcc_root = hSegmOcc->getTH2F();
      TH2F * summary_histo_root = summaryHistos[3]->getTH2F();
      
      int sector = chID.sector();
      if(sector == 13) sector=4;
      if(sector == 14) sector=10;
      
      
      if((chID.station()!=4 && hNHits_root->GetMaximumBin() != 12)||
         (chID.station()==4 &&  hNHits_root->GetMaximumBin() != 8)){
        summaryHistos[chID.wheel()]->setBinContent(sector, chID.station(),1);
        if(summary_histo_root->GetBinContent(sector, chID.wheel()+3)<1)
          summaryHistos[3]->setBinContent(sector, chID.wheel()+3,1);  
      }
      else
        summaryHistos[chID.wheel()]->setBinContent(sector, chID.station(),0);
    
      if(detailedAnalysis) {
        if(chID.station()!=4)
          segmRecHitHistos[make_pair(chID.wheel(),chID.sector())]->Fill(chID.station(),abs(12-hNHits_root->GetMaximumBin()));
        else
           segmRecHitHistos[make_pair(chID.wheel(),chID.sector())]->Fill(chID.station(),abs(8-hNHits_root->GetMaximumBin()));
      }

      TH2F * summary2_histo_root = summaryHistos[3]->getTH2F();
      
      if(hSegmOcc_root->GetBinContent(sector,chID.station())==0){
        summaryHistos[chID.wheel()]->setBinContent(sector, chID.station(),2);
        if(summary2_histo_root->GetBinContent(sector, chID.wheel()+3)<2)
          summaryHistos[3]->setBinContent(sector, chID.wheel()+3,2);
      } else {
        // Fill the percentage of segment occupancy
        float weight = 1./4.;
        if((sector == 4 || sector == 10) && chID.station() == 4) weight = 1./8.;
        summaryHistos[4]->Fill(sector, chID.wheel(),weight);
      }
      
    } else {
      LogVerbatim ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
        << "[DTSegmentAnalysisTest]: histos not found!!"; // FIXME
    }

    if(detailedAnalysis){ // switch on detailed analysis
   
      //test on chi2 segment quality
      MonitorElement * chi2_histo = dbe->get(getMEName(chID, "h4DChi2"));
      if(chi2_histo) {
        TH1F * chi2_histo_root = chi2_histo->getTH1F();
        double threshold = parameters.getUntrackedParameter<double>("chi2Threshold", 5);
        double maximum = chi2_histo_root->GetXaxis()->GetXmax();
        double minimum = chi2_histo_root->GetXaxis()->GetXmin();
        int nbins = chi2_histo_root->GetXaxis()->GetNbins();
        int thresholdBin = int(threshold/((maximum-minimum)/nbins));
        
        double badSegments=0;
        for(int bin=thresholdBin; bin<=nbins; bin++){
          badSegments+=chi2_histo_root->GetBinContent(bin);
        }
      
        if(chi2_histo_root->GetEntries()!=0){
          double badSegmentsPercentual= badSegments/double(chi2_histo_root->GetEntries());
          chi2Histos[make_pair(chID.wheel(),chID.sector())]->Fill(chID.station(),badSegmentsPercentual);
        }
      } else {
        LogVerbatim ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
          <<"[DTSegmentAnalysisTest]: Histo: " << getMEName(chID, "h4DChi2") << " not found!" << endl;
      }
    } // end of switch for detailed analysis
    
  } //loop over all the chambers

  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsSegment";
  MonitorElement * meProcEvts = dbe->get(nEvtsName);

  if (meProcEvts) {
    int nProcEvts = meProcEvts->getFloatValue();
    summaryHistos[4]->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
  } else {
    summaryHistos[4]->setEntries(nMinEvts + 1);
    LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
                       <<  nEvtsName << " not found!" << endl;
  }

  if(detailedAnalysis){
    
    string chi2CriterionName = parameters.getUntrackedParameter<string>("chi2TestName","chi2InRange");
    for(map<pair<int, int>, MonitorElement*> ::const_iterator histo = chi2Histos.begin();
        histo != chi2Histos.end();
        histo++) {

      const QReport * theChi2QReport = (*histo).second->getQReport(chi2CriterionName);
      if(theChi2QReport) {
        vector<dqm::me_util::Channel> badChannels = theChi2QReport->getBadChannels();
        for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); 
             channel != badChannels.end(); channel++) {
          // FIXME: log into a ME
          LogError ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "Wheel: "<<(*histo).first.first
                                                                   << " Sector: "<<(*histo).first.second
                                                                   << " Bad stations: "<<(*channel).getBin()
                                                                   <<"  Contents : "<<(*channel).getContents();
        }
      }
    }
    
    string segmRecHitCriterionName = parameters.getUntrackedParameter<string>("segmRecHitTestName","segmRecHitInRange");
    for(map<pair<int, int>, MonitorElement*> ::const_iterator histo = segmRecHitHistos.begin();
        histo != segmRecHitHistos.end();
        histo++) {

      const QReport * theSegmRecHitQReport = (*histo).second->getQReport(segmRecHitCriterionName);
      if(theSegmRecHitQReport) {
        vector<dqm::me_util::Channel> badChannels = theSegmRecHitQReport->getBadChannels();
        for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); 
             channel != badChannels.end(); channel++) {
          // FIXME: log into a ME
          LogError ("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "Wheel: "<<(*histo).first.first
                                                                   << " Sector: "<<(*histo).first.second
                                                                   << " Bad stations on recHit number: "
                                                                   <<(*channel).getBin()
                                                                   <<"  Contents : "
                                                                   <<(*channel).getContents();
        }
      }
    }

  } // end of detailedAnalysis

}

Member Data Documentation

std::map< std::pair<int,int>, MonitorElement* > DTSegmentAnalysisTest::chi2Histos [private]

Definition at line 95 of file DTSegmentAnalysisTest.h.

Definition at line 89 of file DTSegmentAnalysisTest.h.

Definition at line 84 of file DTSegmentAnalysisTest.h.

Definition at line 102 of file DTSegmentAnalysisTest.h.

Definition at line 92 of file DTSegmentAnalysisTest.h.

Definition at line 81 of file DTSegmentAnalysisTest.h.

unsigned int DTSegmentAnalysisTest::nLumiSegs [private]

Definition at line 82 of file DTSegmentAnalysisTest.h.

Definition at line 85 of file DTSegmentAnalysisTest.h.

Definition at line 98 of file DTSegmentAnalysisTest.h.

Definition at line 91 of file DTSegmentAnalysisTest.h.

Definition at line 87 of file DTSegmentAnalysisTest.h.

std::map< std::pair<int,int>, MonitorElement* > DTSegmentAnalysisTest::segmRecHitHistos [private]

Definition at line 96 of file DTSegmentAnalysisTest.h.

Definition at line 97 of file DTSegmentAnalysisTest.h.

Definition at line 100 of file DTSegmentAnalysisTest.h.