CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

DTNoiseTest Class Reference

#include <DTNoiseTest.h>

Inheritance diagram for DTNoiseTest:
edm::EDAnalyzer

List of all members.

Public Member Functions

 DTNoiseTest (const edm::ParameterSet &ps)
 Constructor.
virtual ~DTNoiseTest ()
 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, std::string folder, std::string histoTag)
 book the new ME
void bookHistos (const DTLayerId &ch, int nWire, std::string folder, std::string histoTag)
void endJob ()
 Endjob.
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
 DQM Client Diagnostic.
std::string getMEName (const DTChamberId &ch)
 Get the ME name.
std::string getMEName (const DTLayerId &ly)

Private Attributes

DQMStoredbe
bool debug
std::map< std::string,
std::map< uint32_t,
MonitorElement * > > 
histos
edm::ESHandle< DTGeometrymuonGeom
unsigned int nLumiSegs
edm::ParameterSet parameters
int prescaleFactor
int run
std::vector< DTWireIdtheNoisyChannels
edm::ESHandle< DTTtrigtTrigMap
int updates

Detailed Description

* DQM Test Client

Date:
2010/01/05 10:15:46
Revision:
1.8

A. Gresele - INFN Trento G. Mila - INFN Torino M. Zanetti - CERN PH

Definition at line 52 of file DTNoiseTest.h.


Constructor & Destructor Documentation

DTNoiseTest::DTNoiseTest ( const edm::ParameterSet ps)

Constructor.

Definition at line 38 of file DTNoiseTest.cc.

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

                                                 {

  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: Constructor";  

  parameters = ps;
  
  dbe = edm::Service<DQMStore>().operator->();
  dbe->setCurrentFolder("DT/Tests/Noise");

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

}
DTNoiseTest::~DTNoiseTest ( ) [virtual]

Destructor.

Definition at line 53 of file DTNoiseTest.cc.

                         {

  edm::LogVerbatim ("noise") <<"DTNoiseTest: analyzed " << updates << " events";

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 91 of file DTNoiseTest.cc.

                                                                        {

  updates++;
  edm::LogVerbatim ("noise") << "[DTNoiseTest]: "<<updates<<" events";

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 61 of file DTNoiseTest.cc.

                          {

  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: BeginJob";

  updates = 0;

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

Reimplemented from edm::EDAnalyzer.

Definition at line 81 of file DTNoiseTest.cc.

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

                                                                                                {

  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: Begin of LS transition";

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

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 70 of file DTNoiseTest.cc.

References edm::EventSetup::get().

                                                                         {

  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: BeginRun";

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

}
void DTNoiseTest::bookHistos ( const DTChamberId ch,
std::string  folder,
std::string  histoTag 
) [protected]

book the new ME

void DTNoiseTest::bookHistos ( const DTLayerId ch,
int  nWire,
std::string  folder,
std::string  histoTag 
) [protected]
void DTNoiseTest::endJob ( void  ) [protected, virtual]

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 262 of file DTNoiseTest.cc.

                        {

  edm::LogVerbatim ("noise") <<"[DTNoiseTest] endjob called!";
  
  //if ( parameters.getUntrackedParameter<bool>("writeHisto", true) ) 
  //  dbe->save(parameters.getUntrackedParameter<string>("outputFile", "DTNoiseTest.root"));
  
  dbe->rmdir("DT/Tests/Noise");
}
void DTNoiseTest::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  c 
) [protected, virtual]

DQM Client Diagnostic.

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file DTNoiseTest.cc.

References PDRates::average, begin, bookHistos(), DTTimeUnits::counts, end, spr::find(), edm::EventSetup::get(), QReport::getBadChannels(), MonitorElement::getTH2F(), mergeVDriftHistosByStation::histos, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), Mean, nevents, Parameters::parameters, dtDQMClient_cfg::prescaleFactor, edm::second(), crabStatusFromReport::statusMap, DTSuperLayerId::superLayer(), and w().

                                                                                              {

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

  //edm::LogVerbatim ("noise") <<"[DTNoiseTest]: "<<updates<<" updates";


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

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

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

  edm::LogVerbatim ("noise") <<"[DTNoiseTest]: "<<nLumiSegs<<" updates";

  ESHandle<DTStatusFlag> statusMap;
  context.get<DTStatusFlagRcd>().get(statusMap);
  
  context.get<DTTtrigRcd>().get(tTrigMap);
  float tTrig, tTrigRMS, kFactor;

  string histoTag;
  // loop over chambers
  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 ch = (*ch_it)->id();
    vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin(); 
    vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
            
    MonitorElement * noiseME = dbe->get(getMEName(ch));
    if (noiseME) {
      TH2F * noiseHisto = noiseME->getTH2F();

      // WARNING uncorrect normalization!! TO BE PROVIDED CENTRALLY
      double nevents = (int) noiseHisto->GetEntries();  
        
      double normalization =0;

      float average=0;
      float nOfChannels=0;
      float noiseStatistics=0;
      int newNoiseChannels=0;

      for(; sl_it != sl_end; ++sl_it) {
        const DTSuperLayerId & slID = (*sl_it)->id();
            
        // ttrig and rms are counts
        tTrigMap->get(slID, tTrig, tTrigRMS, kFactor, DTTimeUnits::counts);
        if (tTrig==0) tTrig=1;
        const double ns_s = 1e9*(32/25);
        normalization = ns_s/float(tTrig*nevents);
            
        noiseHisto->Scale(normalization);
            
        // loop over layers
            
        for (int binY=(slID.superLayer()-1)*4+1 ; binY <= (slID.superLayer()-1)*4+4; binY++) {
              
          int Y = binY - 4*(slID.superLayer()-1);
              
          // the layer
              
          const DTLayerId theLayer(slID,Y);
             
          // loop over channels 
          for (int binX=1; binX <= noiseHisto->GetNbinsX(); binX++) {
                
            if (noiseHisto->GetBinContent(binX,binY) > parameters.getUntrackedParameter<int>("HzThreshold", 300))
              theNoisyChannels.push_back(DTWireId(theLayer, binX));
                  
            // get rid of the dead channels
            else {
              average += noiseHisto->GetBinContent(binX,binY); 
              nOfChannels++; 
            }
          }
        }
            
        if (nOfChannels) noiseStatistics = average/nOfChannels;
        histoTag = "NoiseAverage";

        if (histos[histoTag].find((*ch_it)->id().rawId()) == histos[histoTag].end()) bookHistos((*ch_it)->id(),string("NoiseAverage"), histoTag );
        histos[histoTag].find((*ch_it)->id().rawId())->second->setBinContent(slID.superLayer(),noiseStatistics); 

        for ( vector<DTWireId>::const_iterator nb_it = theNoisyChannels.begin();
              nb_it != theNoisyChannels.end(); ++nb_it) {
              
          bool isNoisy = false;
          bool isFEMasked = false;
          bool isTDCMasked = false;
          bool isTrigMask = false;
          bool isDead = false;
          bool isNohv = false;
          statusMap->cellStatus((*nb_it), isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
                      
          if (!isNoisy) newNoiseChannels++;
        }
        theNoisyChannels.clear();
        histoTag = "NewNoisyChannels";
        if (histos[histoTag].find((*ch_it)->id().rawId()) == histos[histoTag].end()) bookHistos((*ch_it)->id(),string("NewNoisyChannels"), histoTag );
        histos[histoTag].find((*ch_it)->id().rawId())->second->setBinContent(slID.superLayer(), newNoiseChannels);   
      }
    }
    //To compute the Noise Mean test
    vector<const DTSuperLayer*>::const_iterator sl2_it = (*ch_it)->superLayers().begin(); 
    vector<const DTSuperLayer*>::const_iterator sl2_end = (*ch_it)->superLayers().end();
    for(; sl2_it != sl2_end; ++sl2_it) {
      vector<const DTLayer*>::const_iterator l_it = (*sl2_it)->layers().begin(); 
      vector<const DTLayer*>::const_iterator l_end = (*sl2_it)->layers().end();
      for(; l_it != l_end; ++l_it) {
        
        DTLayerId lID = (*l_it)->id();
        MonitorElement * noisePerEventME = dbe->get(getMEName(lID));

        if (noisePerEventME) {
          TH2F * noiseHistoPerEvent = noisePerEventME->getTH2F();
          int nWires = muonGeom->layer(lID)->specificTopology().channels();
          double MeanNumerator=0, MeanDenominator=0;
          histoTag = "MeanDigiPerEvent";
          for (int w=1; w<=nWires; w++){
            for(int numDigi=1; numDigi<=10; numDigi++){
              MeanNumerator+=(noiseHistoPerEvent->GetBinContent(w,numDigi)*(numDigi-1));
              MeanDenominator+=noiseHistoPerEvent->GetBinContent(w,numDigi);
            }
            double Mean=MeanNumerator/MeanDenominator;
            if (histos[histoTag].find((*l_it)->id().rawId()) == histos[histoTag].end()) bookHistos((*l_it)->id(),nWires, string("MeanDigiPerEvent"), histoTag );
            histos[histoTag].find((*l_it)->id().rawId())->second->setBinContent(w, Mean);   
          } 
        }
      }
    }
  }
  
  // Noise Mean test 
  histoTag = "MeanDigiPerEvent";
  string MeanCriterionName = parameters.getUntrackedParameter<string>("meanTestName","NoiseMeanInRange");
  for(map<uint32_t, MonitorElement*>::const_iterator hMean = histos[histoTag].begin();
      hMean != histos[histoTag].end();
      hMean++) {
    const QReport * theMeanQReport = (*hMean).second->getQReport(MeanCriterionName);
    if(theMeanQReport) {
      vector<dqm::me_util::Channel> badChannels = theMeanQReport->getBadChannels();
      for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); 
           channel != badChannels.end(); channel++) {
        LogVerbatim ("tTrigCalibration")<<"LayerId : "<<(*hMean).first<<" Bad mean channels: "<<(*channel).getBin()<<"  Contents : "<<(*channel).getContents();
        // FIXME: getMessage() sometimes returns and invalid string (null pointer inside QReport data member)
        // LogVerbatim ("tTrigCalibration") << "-------- LayerId : "<<(*hMean).first<<"  "<<theMeanQReport->getMessage()<<" ------- "<<theMeanQReport->getStatus(); 
      }
    }
  }
  
}
string DTNoiseTest::getMEName ( const DTChamberId ch) [protected]

Get the ME name.

Definition at line 273 of file DTNoiseTest.cc.

References Parameters::parameters, 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 folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
  string folderTag = parameters.getUntrackedParameter<string>("folderTag", "Occupancies");
  string folderName = 
    folderRoot + "DT/DTDigiTask/Wheel" +  wheel.str() +
    "/Station" + station.str() +
    "/Sector" + sector.str() + "/" + folderTag + "/";

  string histoTag = parameters.getUntrackedParameter<string>("histoTag", "OccupancyNoise_perCh");
  string histoname = folderName + histoTag  
    + "_W" + wheel.str() 
    + "_St" + station.str() 
    + "_Sec" + sector.str(); 
    
    
  return histoname;
  
}
string DTNoiseTest::getMEName ( const DTLayerId ly) [protected]

Definition at line 297 of file DTNoiseTest.cc.

References DTLayerId::layer(), Parameters::parameters, DTChamberId::sector(), relativeConstraints::station, DTChamberId::station(), DTSuperLayerId::superlayer(), and DTChamberId::wheel().

                                                  {
  
  stringstream wheel; wheel << ly.wheel();      
  stringstream station; station << ly.station();        
  stringstream sector; sector << ly.sector();
  stringstream superLayer; superLayer << ly.superlayer();
  stringstream layer; layer << ly.layer();
  
  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
  string folderTag = parameters.getUntrackedParameter<string>("folderTagForDigiPerEventTest", "DigiPerEvent");
  string folderName = 
    folderRoot + "DT/DTDigiForNoiseTask/Wheel" +  wheel.str() +
    "/Station" + station.str() +
    "/Sector" + sector.str() + "/" + folderTag + "/";
  
  string histoTag = parameters.getUntrackedParameter<string>("histoTagForDigiPerEventTest", "DigiPerEvent");
  string histoname = folderName + histoTag  
    + "_W" + wheel.str() 
    + "_St" + station.str() 
    + "_Sec" + sector.str()
    + "_SL" + superLayer.str()
    + "_L" + layer.str();
    
    
  return histoname;

}

Member Data Documentation

Definition at line 102 of file DTNoiseTest.h.

bool DTNoiseTest::debug [private]

Definition at line 96 of file DTNoiseTest.h.

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

Definition at line 115 of file DTNoiseTest.h.

Definition at line 105 of file DTNoiseTest.h.

unsigned int DTNoiseTest::nLumiSegs [private]

Definition at line 98 of file DTNoiseTest.h.

Definition at line 104 of file DTNoiseTest.h.

Definition at line 99 of file DTNoiseTest.h.

int DTNoiseTest::run [private]

Definition at line 100 of file DTNoiseTest.h.

std::vector<DTWireId> DTNoiseTest::theNoisyChannels [private]

Definition at line 111 of file DTNoiseTest.h.

Definition at line 106 of file DTNoiseTest.h.

int DTNoiseTest::updates [private]

Definition at line 97 of file DTNoiseTest.h.