CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

DTtTrigCalibrationTest Class Reference

#include <DTtTrigCalibrationTest.h>

Inheritance diagram for DTtTrigCalibrationTest:
edm::EDAnalyzer

List of all members.

Public Member Functions

 DTtTrigCalibrationTest (const edm::ParameterSet &ps)
 Constructor.
virtual ~DTtTrigCalibrationTest ()
 Destructor.

Protected 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 &r, const edm::EventSetup &c)
 BeginRun.
void bookHistos (const DTChamberId &ch)
 book the new ME
void bookHistos (const DTChamberId &ch, int wh)
 book the summary histograms
void endJob ()
 Endjob.
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
 DQM Client Diagnostic.
std::string getMEName (const DTSuperLayerId &slID)
 Get the ME name.

Private Attributes

DQMStoredbe
std::map< uint32_t,
MonitorElement * > 
histos
edm::ESHandle< DTGeometrymuonGeom
int nevents
unsigned int nLumiSegs
edm::ParameterSet parameters
int percentual
int prescaleFactor
int run
DTTimeBoxFittertheFitter
edm::ESHandle< DTTtrigtTrigMap
std::map< int, MonitorElement * > wheelHistos

Detailed Description

* DQM Test Client

Date:
2010/01/05 10:15:46
Revision:
1.8
Author:
M. Zanetti CERN

Definition at line 41 of file DTtTrigCalibrationTest.h.


Constructor & Destructor Documentation

DTtTrigCalibrationTest::DTtTrigCalibrationTest ( const edm::ParameterSet ps)

Constructor.

Definition at line 39 of file DTtTrigCalibrationTest.cc.

References cppFunctionSkipper::operator, Parameters::parameters, and dtDQMClient_cfg::prescaleFactor.

                                                                       {
  
  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: Constructor";

  parameters = ps;
  
  dbe = edm::Service<DQMStore>().operator->();

  theFitter = new DTTimeBoxFitter();

  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 3);

  percentual = parameters.getUntrackedParameter<int>("BadSLpercentual", 10);

}
DTtTrigCalibrationTest::~DTtTrigCalibrationTest ( ) [virtual]

Destructor.

Definition at line 56 of file DTtTrigCalibrationTest.cc.

References nevents.

                                               {

  edm::LogVerbatim ("tTrigCalibration") <<"DTtTrigCalibrationTest: analyzed " << nevents << " events";

  delete theFitter;

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 93 of file DTtTrigCalibrationTest.cc.

References nevents.

                                                                                   {

  nevents++;
  edm::LogVerbatim ("tTrigCalibration") << "[DTtTrigCalibrationTest]: "<<nevents<<" events";

}
void DTtTrigCalibrationTest::beginJob ( void  ) [protected, virtual]

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 65 of file DTtTrigCalibrationTest.cc.

References nevents.

                                     {

  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: BeginJob";

  nevents = 0;

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

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file DTtTrigCalibrationTest.cc.

References edm::LuminosityBlockBase::run(), and DTTTrigCorrFirst::run.

                                                                                                           {

  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: Begin of LS transition";

  // Get the run number
  run = lumiSeg.run();

}
void DTtTrigCalibrationTest::beginRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file DTtTrigCalibrationTest.cc.

References edm::EventSetup::get().

                                                                               {

  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: BeginRun";

  // Get the geometry
  context.get<MuonGeometryRecord>().get(muonGeom);

}
void DTtTrigCalibrationTest::bookHistos ( const DTChamberId ch) [protected]

book the new ME

Definition at line 242 of file DTtTrigCalibrationTest.cc.

References mergeVDriftHistosByStation::histos, DetId::rawId(), DTChamberId::sector(), relativeConstraints::station, DTChamberId::station(), and DTChamberId::wheel().

                                                              {

  stringstream wheel; wheel << ch.wheel();      
  stringstream station; station << ch.station();        
  stringstream sector; sector << ch.sector();   

  string histoName =  "tTrigTest_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str(); 

  dbe->setCurrentFolder("DT/Tests/DTtTrigCalibration");
  
  histos[ch.rawId()] = dbe->book1D(histoName.c_str(),histoName.c_str(),3,0,2);

}
void DTtTrigCalibrationTest::bookHistos ( const DTChamberId ch,
int  wh 
) [protected]

book the summary histograms

Definition at line 256 of file DTtTrigCalibrationTest.cc.

                                                                      {
  
  dbe->setCurrentFolder("DT/Tests/DTtTrigCalibration/SummaryPlot");

  if(wheelHistos.find(3) == wheelHistos.end()){
    string histoName =  "t_TrigSummary_testFailedByAtLeastBadSL";
    wheelHistos[3] = dbe->book2D(histoName.c_str(),histoName.c_str(),14,0,14,5,-2,2);
    wheelHistos[3]->setBinLabel(1,"Sector1",1);
    wheelHistos[3]->setBinLabel(1,"Sector1",1);
    wheelHistos[3]->setBinLabel(2,"Sector2",1);
    wheelHistos[3]->setBinLabel(3,"Sector3",1);
    wheelHistos[3]->setBinLabel(4,"Sector4",1);
    wheelHistos[3]->setBinLabel(5,"Sector5",1);
    wheelHistos[3]->setBinLabel(6,"Sector6",1);
    wheelHistos[3]->setBinLabel(7,"Sector7",1);
    wheelHistos[3]->setBinLabel(8,"Sector8",1);
    wheelHistos[3]->setBinLabel(9,"Sector9",1);
    wheelHistos[3]->setBinLabel(10,"Sector10",1);
    wheelHistos[3]->setBinLabel(11,"Sector11",1);
    wheelHistos[3]->setBinLabel(12,"Sector12",1);
    wheelHistos[3]->setBinLabel(13,"Sector13",1);
    wheelHistos[3]->setBinLabel(14,"Sector14",1);
    wheelHistos[3]->setBinLabel(1,"Wheel-2",2);
    wheelHistos[3]->setBinLabel(2,"Wheel-1",2);
    wheelHistos[3]->setBinLabel(3,"Wheel0",2);
    wheelHistos[3]->setBinLabel(4,"Wheel+1",2);
    wheelHistos[3]->setBinLabel(5,"Wheel+2",2);
  }

  stringstream wheel; wheel <<wh;
  string histoName =  "t_TrigSummary_testFailed_W" + wheel.str();
  wheelHistos[wh] = dbe->book2D(histoName.c_str(),histoName.c_str(),14,0,14,11,0,11);
  wheelHistos[wh]->setBinLabel(1,"Sector1",1);
  wheelHistos[wh]->setBinLabel(2,"Sector2",1);
  wheelHistos[wh]->setBinLabel(3,"Sector3",1);
  wheelHistos[wh]->setBinLabel(4,"Sector4",1);
  wheelHistos[wh]->setBinLabel(5,"Sector5",1);
  wheelHistos[wh]->setBinLabel(6,"Sector6",1);
  wheelHistos[wh]->setBinLabel(7,"Sector7",1);
  wheelHistos[wh]->setBinLabel(8,"Sector8",1);
  wheelHistos[wh]->setBinLabel(9,"Sector9",1);
  wheelHistos[wh]->setBinLabel(10,"Sector10",1);
  wheelHistos[wh]->setBinLabel(11,"Sector11",1);
  wheelHistos[wh]->setBinLabel(12,"Sector12",1);
  wheelHistos[wh]->setBinLabel(13,"Sector13",1);
  wheelHistos[wh]->setBinLabel(14,"Sector14",1);
  wheelHistos[wh]->setBinLabel(1,"MB1_SL1",2);
  wheelHistos[wh]->setBinLabel(2,"MB1_SL2",2);
  wheelHistos[wh]->setBinLabel(3,"MB1_SL3",2);
  wheelHistos[wh]->setBinLabel(4,"MB2_SL1",2);
  wheelHistos[wh]->setBinLabel(5,"MB2_SL2",2);
  wheelHistos[wh]->setBinLabel(6,"MB2_SL3",2);
  wheelHistos[wh]->setBinLabel(7,"MB3_SL1",2);
  wheelHistos[wh]->setBinLabel(8,"MB3_SL2",2);
  wheelHistos[wh]->setBinLabel(9,"MB3_SL3",2);
  wheelHistos[wh]->setBinLabel(10,"MB4_SL1",2);
  wheelHistos[wh]->setBinLabel(11,"MB4_SL3",2);

}
void DTtTrigCalibrationTest::endJob ( void  ) [protected, virtual]

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 205 of file DTtTrigCalibrationTest.cc.

                                   {

  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest] endjob called!";

  dbe->rmdir("DT/Tests/DTtTrigCalibration");
}
void DTtTrigCalibrationTest::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  c 
) [protected, virtual]

DQM Client Diagnostic.

Reimplemented from edm::EDAnalyzer.

Definition at line 101 of file DTtTrigCalibrationTest.cc.

References bookHistos(), DTTimeUnits::counts, edm::EventSetup::get(), MonitorElement::getTH1F(), interpolateCardsSimple::histo, mergeVDriftHistosByStation::histos, i, edm::LuminosityBlockBase::id(), j, edm::LuminosityBlockID::luminosityBlock(), Parameters::parameters, dtDQMClient_cfg::prescaleFactor, edm::second(), and DTSuperLayerId::superLayer().

                                                                                                         {


  // counts number of updats (online mode) or number of events (standalone mode)
  //nevents++;
  // if running in standalone perform diagnostic only after a reasonalbe amount of events
  //if ( parameters.getUntrackedParameter<bool>("runningStandalone", false) && 
  //   nevents%parameters.getUntrackedParameter<int>("diagnosticPrescale", 1000) != 0 ) return;
  //edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: "<<nevents<<" updates";


  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: End of LS transition, performing the DQM client operation";

  // counts number of lumiSegs 
  nLumiSegs = lumiSeg.id().luminosityBlock();

  // prescale factor
  if ( nLumiSegs%prescaleFactor != 0 ) return;

  for(map<int, MonitorElement*> ::const_iterator histo = wheelHistos.begin();
      histo != wheelHistos.end();
      histo++) {
    (*histo).second->Reset();
  }
  
  edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: "<<nLumiSegs<<" updates";

  context.get<DTTtrigRcd>().get(tTrigMap);
  float tTrig, tTrigRMS,kFactor;

  map <pair<int,int>, int> cmsHistos;
  cmsHistos.clear();
  map <pair<int,int>, bool> filled;
  for(int i=-2; i<3; i++){
    for(int j=1; j<15; j++){
      filled[make_pair(i,j)]=false;
    }
  }
  
  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) {
    
    vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin(); 
    vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
    for(; sl_it != sl_end; ++sl_it) {
      
      DTSuperLayerId slID = (*sl_it)->id();
      
      MonitorElement * tb_histo = dbe->get(getMEName(slID));
      if (tb_histo) {
        
        edm::LogVerbatim ("tTrigCalibration") <<"[DTtTrigCalibrationTest]: I've got the histo!!";       

        TH1F * tb_histo_root = tb_histo->getTH1F();
            
        pair<double, double> meanAndSigma = theFitter->fitTimeBox(tb_histo_root);
            
        // ttrig and rms are counts
        tTrigMap->get(slID, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts );

        if (histos.find((*ch_it)->id().rawId()) == histos.end()) bookHistos((*ch_it)->id());
        histos.find((*ch_it)->id().rawId())->second->setBinContent(slID.superLayer(), meanAndSigma.first-tTrig);

      }
    }
    
    if (histos.find((*ch_it)->id().rawId()) != histos.end()) {
      string criterionName = parameters.getUntrackedParameter<string>("tTrigTestName","tTrigOffSet"); 
      const QReport * theQReport = histos.find((*ch_it)->id().rawId())->second->getQReport(criterionName);
      if(theQReport) {
        vector<dqm::me_util::Channel> badChannels = theQReport->getBadChannels();
        for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); 
             channel != badChannels.end(); channel++) {
          edm::LogError ("tTrigCalibration") <<"Chamber ID : "<<(*ch_it)->id()<<" Bad channels: "<<(*channel).getBin()<<" "<<(*channel).getContents();
          if(wheelHistos.find((*ch_it)->id().wheel()) == wheelHistos.end()) bookHistos((*ch_it)->id(), (*ch_it)->id().wheel());
          // fill the wheel summary histos if the SL has not passed the test
          if(!((*ch_it)->id().station() == 4 && (*channel).getBin() == 3))
            wheelHistos[(*ch_it)->id().wheel()]->Fill((*ch_it)->id().sector()-1,((*channel).getBin()-1)+3*((*ch_it)->id().station()-1));
          else 
            wheelHistos[(*ch_it)->id().wheel()]->Fill((*ch_it)->id().sector()-1,10);
          // fill the cms summary histo if the percentual of SL which have not passed the test 
          // is more than a predefined treshold
          cmsHistos[make_pair((*ch_it)->id().wheel(),(*ch_it)->id().sector())]++;
          if(((*ch_it)->id().sector()<13 &&
              double(cmsHistos[make_pair((*ch_it)->id().wheel(),(*ch_it)->id().sector())])/11>double(percentual)/100 &&
              filled[make_pair((*ch_it)->id().wheel(),(*ch_it)->id().sector())]==false) ||
             ((*ch_it)->id().sector()>=13 && 
              double(cmsHistos[make_pair((*ch_it)->id().wheel(),(*ch_it)->id().sector())])/2>double(percentual)/100 &&
              filled[make_pair((*ch_it)->id().wheel(),(*ch_it)->id().sector())]==false)){
            filled[make_pair((*ch_it)->id().wheel(),(*ch_it)->id().sector())]=true;
            wheelHistos[3]->Fill((*ch_it)->id().sector()-1,(*ch_it)->id().wheel());
          }
        }
        // FIXME: getMessage() sometimes returns and invalid string (null pointer inside QReport data member)
        // edm::LogWarning ("tTrigCalibration") <<"-------- "<<theQReport->getMessage()<<" ------- "<<theQReport->getStatus();
      } 
    }

  }

}
string DTtTrigCalibrationTest::getMEName ( const DTSuperLayerId slID) [protected]

Get the ME name.

Definition at line 237 of file DTChamberEfficiencyTest.cc.

References Parameters::parameters, DTChamberId::sector(), relativeConstraints::station, DTChamberId::station(), and DTChamberId::wheel().

                                                                                   {

  stringstream wheel; wheel << chID.wheel();
  stringstream station; station << chID.station();
  stringstream sector; sector << chID.sector();
 
  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
  string folderName = 
    folderRoot + "DT/01-DTChamberEfficiency/Task/Wheel" +  wheel.str() +
    "/Sector" + sector.str() +
    "/Station" + station.str() + "/";

  string histoname = folderName + histoTag  
    + "_W" + wheel.str() 
    + "_St" + station.str() 
    + "_Sec" + sector.str();
  
  return histoname;
  
}

Member Data Documentation

Definition at line 90 of file DTtTrigCalibrationTest.h.

std::map< uint32_t , MonitorElement* > DTtTrigCalibrationTest::histos [private]

Definition at line 99 of file DTtTrigCalibrationTest.h.

Definition at line 93 of file DTtTrigCalibrationTest.h.

Definition at line 84 of file DTtTrigCalibrationTest.h.

unsigned int DTtTrigCalibrationTest::nLumiSegs [private]

Definition at line 85 of file DTtTrigCalibrationTest.h.

Definition at line 92 of file DTtTrigCalibrationTest.h.

Definition at line 88 of file DTtTrigCalibrationTest.h.

Definition at line 86 of file DTtTrigCalibrationTest.h.

Definition at line 87 of file DTtTrigCalibrationTest.h.

Definition at line 96 of file DTtTrigCalibrationTest.h.

Definition at line 94 of file DTtTrigCalibrationTest.h.

Definition at line 102 of file DTtTrigCalibrationTest.h.