CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTtTrigDBValidation Class Reference

#include <DTtTrigDBValidation.h>

Inheritance diagram for DTtTrigDBValidation:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (edm::Event const &, edm::EventSetup const &)
void beginRun (edm::Run const &, edm::EventSetup const &)
 Operations.
 DTtTrigDBValidation (const edm::ParameterSet &pset)
 Constructor.
void endJob ()
void endRun (edm::Run const &, edm::EventSetup const &)
virtual ~DTtTrigDBValidation ()
 Destructor.

Private Member Functions

void bookHistos (int, int)
void bookHistos (int wheel)
int slFromBin (int bin) const
int stationFromBin (int bin) const

Private Attributes

DQMStoredbe
edm::ESHandle< DTGeometrydtGeom
int higherLimit
std::string labelDB
std::string labelDBRef
int lowerLimit
std::string metname
std::string outputFileName
bool outputMEsInRootFile
std::map< std::pair< int, int >
, MonitorElement * > 
tTrigDiffHistos
std::map< int, MonitorElement * > tTrigDiffWheel
std::map< DTSuperLayerId,
std::pair< float, float > > 
tTrigMap
std::map< DTSuperLayerId,
std::pair< float, float > > 
tTrigRefMap

Detailed Description

Definition at line 24 of file DTtTrigDBValidation.h.


Constructor & Destructor Documentation

DTtTrigDBValidation::DTtTrigDBValidation ( const edm::ParameterSet pset)

Constructor.

Definition at line 33 of file DTtTrigDBValidation.cc.

References dbe, metname, cmsCodeRules::cppFunctionSkipper::operator, and DQMStore::setCurrentFolder().

                                                                :
   metname("tTrigdbValidation"),
   labelDBRef(pset.getParameter<string>("labelDBRef")),
   labelDB(pset.getParameter<string>("labelDB")),
   lowerLimit(pset.getUntrackedParameter<int>("lowerLimit",1)),
   higherLimit(pset.getUntrackedParameter<int>("higherLimit",3)),
   outputMEsInRootFile(pset.getUntrackedParameter<bool>("OutputMEsInRootFile",false)),
   outputFileName(pset.getUntrackedParameter<string>("OutputFileName","tTrigDBMonitoring.root"))
 {

  LogVerbatim(metname) << "[DTtTrigDBValidation] Constructor called!";

  // Get the DQM needed services
  dbe = edm::Service<DQMStore>().operator->();
  dbe->setCurrentFolder("DT/DTDBValidation");
}
DTtTrigDBValidation::~DTtTrigDBValidation ( ) [virtual]

Destructor.

Definition at line 50 of file DTtTrigDBValidation.cc.

{}

Member Function Documentation

void DTtTrigDBValidation::analyze ( edm::Event const &  ,
edm::EventSetup const &   
) [inline, virtual]

Implements edm::EDAnalyzer.

Definition at line 36 of file DTtTrigDBValidation.h.

{}
void DTtTrigDBValidation::beginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
) [virtual]

Operations.

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file DTtTrigDBValidation.cc.

References abs, DTTtrig::begin(), bookHistos(), dtGeom, DTTtrig::end(), edm::EventSetup::get(), DTTtrig::get(), higherLimit, labelDB, labelDBRef, LogTrace, lowerLimit, metname, DTTimeUnits::ns, relativeConstraints::station, tTrigDiffHistos, tTrigDiffWheel, tTrigMap, and tTrigRefMap.

                                                                             {

  LogVerbatim(metname) << "[DTtTrigDBValidation] Parameters initialization";
 
  ESHandle<DTTtrig> tTrig_Ref;
  setup.get<DTTtrigRcd>().get(labelDBRef, tTrig_Ref);
  const DTTtrig* DTTtrigRefMap = &*tTrig_Ref;
  LogVerbatim(metname) << "[DTtTrigDBValidation] reference Ttrig version: " << tTrig_Ref->version();

  ESHandle<DTTtrig> tTrig;
  setup.get<DTTtrigRcd>().get(labelDB, tTrig);
  const DTTtrig* DTTtrigMap = &*tTrig;
  LogVerbatim(metname) << "[DTtTrigDBValidation] Ttrig to validate version: " << tTrig->version();

  //book&reset the summary histos
  for(int wheel=-2; wheel<=2; wheel++){
    bookHistos(wheel);
    tTrigDiffWheel[wheel]->Reset();
  }

  // Get the geometry
  setup.get<MuonGeometryRecord>().get(dtGeom);

  // Loop over Ref DB entries
  for(DTTtrig::const_iterator it = DTTtrigRefMap->begin();
      it != DTTtrigRefMap->end(); ++it) {
    DTSuperLayerId slId((*it).first.wheelId,
                        (*it).first.stationId,
                        (*it).first.sectorId,
                        (*it).first.slId);
    float tTrigMean;
    float tTrigRms;
    float kFactor;
    DTTtrigRefMap->get(slId, tTrigMean, tTrigRms, kFactor, DTTimeUnits::ns);
    float tTrigCorr = tTrigMean + kFactor*tTrigRms;
    LogTrace(metname)<< "Ref Superlayer: " <<  slId << "\n"
                     << " Ttrig mean (ns): " << tTrigMean
                     << " Ttrig rms (ns): " << tTrigRms
                     << " Ttrig k-Factor: " << kFactor
                     << " Ttrig value (ns): " << tTrigCorr;
                     
    //tTrigRefMap[slId] = std::pair<float,float>(tTrigmean,tTrigrms);
    tTrigRefMap[slId] = pair<float,float>(tTrigCorr,tTrigRms);
  }

  // Loop over Ref DB entries
  for(DTTtrig::const_iterator it = DTTtrigMap->begin();
      it != DTTtrigMap->end(); ++it) {
    DTSuperLayerId slId((*it).first.wheelId,
                        (*it).first.stationId,
                        (*it).first.sectorId,
                        (*it).first.slId);
    float tTrigMean;
    float tTrigRms;
    float kFactor;
    DTTtrigMap->get(slId, tTrigMean, tTrigRms, kFactor, DTTimeUnits::ns);
    float tTrigCorr = tTrigMean + kFactor*tTrigRms;
    LogTrace(metname)<< "Superlayer: " <<  slId << "\n"
                     << " Ttrig mean (ns): " << tTrigMean
                     << " Ttrig rms (ns): " << tTrigRms
                     << " Ttrig k-Factor: " << kFactor
                     << " Ttrig value (ns): " << tTrigCorr;

    //tTrigMap[slId] = std::pair<float,float>(tTrigmean,tTrigrms);
    tTrigMap[slId] = pair<float,float>(tTrigCorr,tTrigRms);
  }

  for(map<DTSuperLayerId, pair<float,float> >::const_iterator it = tTrigRefMap.begin();
      it != tTrigRefMap.end(); ++it) {  
      if(tTrigMap.find((*it).first) == tTrigMap.end()) continue;

      // compute the difference
      float difference = tTrigMap[(*it).first].first - (*it).second.first;

      //book histo
      int wheel = (*it).first.chamberId().wheel();
      int sector = (*it).first.chamberId().sector();    
      if(tTrigDiffHistos.find(make_pair(wheel,sector)) == tTrigDiffHistos.end()) bookHistos(wheel,sector);
                        
      LogTrace(metname) << "Filling histos for super-layer: " << (*it).first << "  difference: " << difference;
 
      // Fill the test histos
      int entry = -1;
      int station = (*it).first.chamberId().station();  
      if(station == 1) entry=0;
      if(station == 2) entry=3;
      if(station == 3) entry=6;
      if(station == 4) entry=9;

      int slBin = entry + (*it).first.superLayer();
      if(slBin == 12) slBin=11; 

      tTrigDiffHistos[make_pair(wheel,sector)]->setBinContent(slBin, difference);
      if(abs(difference)<lowerLimit){
        tTrigDiffWheel[wheel]->setBinContent(slBin,sector,1);
      }else if(abs(difference)<higherLimit){
        tTrigDiffWheel[wheel]->setBinContent(slBin,sector,2);
      }else{
        tTrigDiffWheel[wheel]->setBinContent(slBin,sector,3);
      }
        

  } // Loop over the tTrig map reference
  
}
void DTtTrigDBValidation::bookHistos ( int  wheel,
int  sector 
) [private]

Definition at line 168 of file DTtTrigDBValidation.cc.

References DQMStore::book1D(), dbe, LogTrace, metname, DQMStore::setCurrentFolder(), and tTrigDiffHistos.

Referenced by beginRun().

                                                          {

  LogTrace(metname) << "   Booking histos for Wheel, Sector: " << wheel << ", " << sector;

  // Compose the chamber name
  stringstream str_wheel; str_wheel << wheel;
  stringstream str_sector; str_sector << sector;

  string lHistoName = "_W" + str_wheel.str() + "_Sec" + str_sector.str();

  dbe->setCurrentFolder("DT/tTrigValidation/Wheel" + str_wheel.str());

  // Create the monitor elements
  MonitorElement * hDifference;
  hDifference = dbe->book1D("htTrigDifference"+lHistoName, "difference between the two tTrig values",11,0,11);

  pair<int,int> mypair(wheel,sector);
  tTrigDiffHistos[mypair] = hDifference;

  (tTrigDiffHistos[mypair])->setBinLabel(1,"MB1_SL1",1);
  (tTrigDiffHistos[mypair])->setBinLabel(2,"MB1_SL2",1);
  (tTrigDiffHistos[mypair])->setBinLabel(3,"MB1_SL3",1);
  (tTrigDiffHistos[mypair])->setBinLabel(4,"MB2_SL1",1);
  (tTrigDiffHistos[mypair])->setBinLabel(5,"MB2_SL2",1);
  (tTrigDiffHistos[mypair])->setBinLabel(6,"MB2_SL3",1);
  (tTrigDiffHistos[mypair])->setBinLabel(7,"MB3_SL1",1);
  (tTrigDiffHistos[mypair])->setBinLabel(8,"MB3_SL2",1);
  (tTrigDiffHistos[mypair])->setBinLabel(9,"MB3_SL3",1);
  (tTrigDiffHistos[mypair])->setBinLabel(10,"MB4_SL1",1);
  (tTrigDiffHistos[mypair])->setBinLabel(11,"MB4_SL3",1);
}
void DTtTrigDBValidation::bookHistos ( int  wheel) [private]

Definition at line 201 of file DTtTrigDBValidation.cc.

References DQMStore::book2D(), dbe, DQMStore::setCurrentFolder(), and tTrigDiffWheel.

                                              {

  stringstream wh; wh << wheel;

  dbe->setCurrentFolder("DT/tTrigValidation/Wheel" + wh.str());
  tTrigDiffWheel[wheel] = dbe->book2D("htTrigDifference_W"+wh.str(), "W"+wh.str()+": summary of tTrig differences",11,1,12,14,1,15);
  tTrigDiffWheel[wheel]->setBinLabel(1,"MB1_SL1",1);
  tTrigDiffWheel[wheel]->setBinLabel(2,"MB1_SL2",1);
  tTrigDiffWheel[wheel]->setBinLabel(3,"MB1_SL3",1);
  tTrigDiffWheel[wheel]->setBinLabel(4,"MB2_SL1",1);
  tTrigDiffWheel[wheel]->setBinLabel(5,"MB2_SL2",1);
  tTrigDiffWheel[wheel]->setBinLabel(6,"MB2_SL3",1);
  tTrigDiffWheel[wheel]->setBinLabel(7,"MB3_SL1",1);
  tTrigDiffWheel[wheel]->setBinLabel(8,"MB3_SL2",1);
  tTrigDiffWheel[wheel]->setBinLabel(9,"MB3_SL3",1);
  tTrigDiffWheel[wheel]->setBinLabel(10,"MB4_SL1",1);
  tTrigDiffWheel[wheel]->setBinLabel(11,"MB4_SL3",1);


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

Reimplemented from edm::EDAnalyzer.

Definition at line 160 of file DTtTrigDBValidation.cc.

References dbe, outputFileName, outputMEsInRootFile, and DQMStore::save().

                                {

  if(outputMEsInRootFile){
     // write the histos on a file
     dbe->save(outputFileName);
  }
}
void DTtTrigDBValidation::endRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 158 of file DTtTrigDBValidation.cc.

{}
int DTtTrigDBValidation::slFromBin ( int  bin) const [private]

Definition at line 227 of file DTtTrigDBValidation.cc.

References runTheMatrix::ret.

                                                {
  int ret = bin%3;
  if(ret == 0 || bin == 11) ret = 3;
  
  return ret;
}
int DTtTrigDBValidation::stationFromBin ( int  bin) const [private]

Definition at line 223 of file DTtTrigDBValidation.cc.

                                                     {
  return (int) (bin /3.1)+1;
}

Member Data Documentation

Definition at line 54 of file DTtTrigDBValidation.h.

Referenced by bookHistos(), DTtTrigDBValidation(), and endJob().

Definition at line 56 of file DTtTrigDBValidation.h.

Referenced by beginRun().

Definition at line 48 of file DTtTrigDBValidation.h.

Referenced by beginRun().

std::string DTtTrigDBValidation::labelDB [private]

Definition at line 45 of file DTtTrigDBValidation.h.

Referenced by beginRun().

std::string DTtTrigDBValidation::labelDBRef [private]

Definition at line 44 of file DTtTrigDBValidation.h.

Referenced by beginRun().

Definition at line 47 of file DTtTrigDBValidation.h.

Referenced by beginRun().

std::string DTtTrigDBValidation::metname [private]

Definition at line 42 of file DTtTrigDBValidation.h.

Referenced by beginRun(), bookHistos(), and DTtTrigDBValidation().

std::string DTtTrigDBValidation::outputFileName [private]

Definition at line 52 of file DTtTrigDBValidation.h.

Referenced by endJob().

Definition at line 51 of file DTtTrigDBValidation.h.

Referenced by endJob().

std::map<std::pair<int,int>, MonitorElement* > DTtTrigDBValidation::tTrigDiffHistos [private]

Definition at line 63 of file DTtTrigDBValidation.h.

Referenced by beginRun(), and bookHistos().

Definition at line 64 of file DTtTrigDBValidation.h.

Referenced by beginRun(), and bookHistos().

std::map<DTSuperLayerId, std::pair<float,float> > DTtTrigDBValidation::tTrigMap [private]

Definition at line 60 of file DTtTrigDBValidation.h.

Referenced by beginRun().

std::map<DTSuperLayerId, std::pair<float,float> > DTtTrigDBValidation::tTrigRefMap [private]

Definition at line 59 of file DTtTrigDBValidation.h.

Referenced by beginRun().