CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

ZDCMonitorModule Class Reference

#include <ZDCMonitorModule.h>

Inheritance diagram for ZDCMonitorModule:
edm::EDAnalyzer

List of all members.

Public Member Functions

 ZDCMonitorModule (const edm::ParameterSet &ps)
 ~ZDCMonitorModule ()

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
void beginJob ()
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void beginRun (const edm::Run &run, const edm::EventSetup &c)
void CheckSubdetectorStatus (const edm::Handle< FEDRawDataCollection > &rawraw, const HcalElectronicsMap &emap)
void cleanup (void)
void endJob (void)
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
void endRun (const edm::Run &run, const edm::EventSetup &c)
void reset (void)
void setup (void)

Private Attributes

DQMStoredbe_
int debug_
const HcalElectronicsMapeMap_
bool enableCleanup_
int evtNumber_
edm::InputTag FEDRawDataCollection_
bool fedsListed_
int ievt_
bool init_
edm::InputTag inputLabelReport_
MonitorElementmeCalibType_
MonitorElementmeCurrentCalibType_
MonitorElementmeEvt_
MonitorElementmeEvtsVsLS_
MonitorElementmeFEDS_
MonitorElementmeIevt_
MonitorElementmeIevtHist_
MonitorElementmeOnline_
MonitorElementmeProcessedEndLumi_
bool mergeRuns_
MonitorElementmeRun_
MonitorElementmeStatus_
MonitorElementmeZDC_
int NLumiBlocks_
bool Online_
std::string prefixME_
int runNumber_
int ZDCpresent_

Detailed Description

Definition at line 28 of file ZDCMonitorModule.h.


Constructor & Destructor Documentation

ZDCMonitorModule::ZDCMonitorModule ( const edm::ParameterSet ps)

Definition at line 60 of file ZDCMonitorModule.cc.

References debug_, enableCleanup_, FEDRawDataCollection_, edm::ParameterSet::getUntrackedParameter(), init_, inputLabelReport_, mergeRuns_, NLumiBlocks_, Online_, and prefixME_.

{  // Set initial values
  init_=false; // first event sets up Monitor Elements and sets init_ to true

  // get ps objects
  Online_                = ps.getUntrackedParameter<bool>("online",false);
  mergeRuns_             = ps.getUntrackedParameter<bool>("mergeRuns",false);
  enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
  debug_                 = ps.getUntrackedParameter<int>("debug",0);
  
  FEDRawDataCollection_  = ps.getUntrackedParameter<edm::InputTag>("FEDRawDataCollection");
  inputLabelReport_      = ps.getUntrackedParameter<edm::InputTag>("UnpackerReport");
  
  prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
    prefixME_.append("/");
  
  NLumiBlocks_           = ps.getUntrackedParameter<int>("NLumiBlocks",4000);

} // ZDCMonitorModule::ZDCMonitorModule
ZDCMonitorModule::~ZDCMonitorModule ( )

Definition at line 83 of file ZDCMonitorModule.cc.

{

} //ZDCMonitorModule::~ZDCMonitorModule()

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 285 of file ZDCMonitorModule.cc.

References diJetCalib::calibType, CheckSubdetectorStatus(), gather_cfg::cout, FEDRawData::data(), debug_, eMap_, edm::EventID::event(), evtNumber_, f, FEDRawDataCollection_, fedsListed_, MonitorElement::Fill(), edm::Event::getByLabel(), i, edm::EventBase::id(), ievt_, init_, inputLabelReport_, LogDebug, edm::EventBase::luminosityBlock(), FEDNumbering::MAXHCALFEDID, meCalibType_, meCurrentCalibType_, meEvt_, meEvtsVsLS_, meFEDS_, meIevt_, meIevtHist_, meRun_, meStatus_, FEDNumbering::MINHCALFEDID, zeeHLT_cff::report, edm::EventID::run(), runNumber_, setup(), FEDRawData::size(), relativeConstraints::value, and ZDCpresent_.

{
  if (!init_) this->setup();
  
  LogDebug("ZDCMonitorModule")<<"processing event "<<ievt_;
  
  // Fill Monitor Elements with run, evt, processed event info
  ++ievt_;
  runNumber_=e.id().run();
  evtNumber_=e.id().event();
  if (meRun_) meRun_->Fill(runNumber_);
  if (meEvt_) meEvt_->Fill(evtNumber_);
  if (meIevt_) meIevt_->Fill(ievt_);
  if (meIevtHist_) meIevtHist_->Fill(1);
  if (meEvtsVsLS_) meEvtsVsLS_->Fill(e.luminosityBlock(),1);
  if (ievt_==1)
    {
      LogDebug("ZDCMonitorModule") << "processing run " << runNumber_;
      // begin-of-run
      if ( meStatus_ ) meStatus_->Fill(0);
    } 
  else 
    {
      // running
      if ( meStatus_ ) meStatus_->Fill(1);
    }
  
  // Try to get raw data
  edm::Handle<FEDRawDataCollection> rawraw;  
  if (!(e.getByLabel(FEDRawDataCollection_,rawraw)))
    {
      edm::LogWarning("ZDCMonitorModule")<<" raw data with label "<<FEDRawDataCollection_ <<" not available";
      return;
    }
  
  // Get Event Calibration Type -- copy of Bryan Dahmes' filter
  int calibType=-1;
  int numEmptyFEDs = 0 ;
  std::vector<int> calibTypeCounter(8,0) ;
  for( int i = FEDNumbering::MINHCALFEDID; i <= FEDNumbering::MAXHCALFEDID; i++) 
    {
      const FEDRawData& fedData = rawraw->FEDData(i) ;
      
      if ( fedData.size() < 24 ) numEmptyFEDs++ ;
      if ( fedData.size() < 24 ) continue;

      int value = (int)((const HcalDCCHeader*)(fedData.data()))->getCalibType() ;
      if(value>7) 
        {
          edm::LogWarning("ZDCMonitorModule::CalibTypeFilter") << "Unexpected Calibration type: "<< value << " in FED: "<<i<<" (should be 0-7). I am bailing out...";
          return;
        }

      calibTypeCounter.at(value)++ ; // increment the counter for this calib type
    } // for (int i = FEDNumbering::MINHCALFEDID; ...)

  int maxCount = 0;
  int numberOfFEDIds = FEDNumbering::MAXHCALFEDID  - FEDNumbering::MINHCALFEDID + 1 ;
  for (unsigned int i=0; i<calibTypeCounter.size(); i++) {
    if ( calibTypeCounter.at(i) > maxCount )
      { calibType = i ; maxCount = calibTypeCounter.at(i) ; }
    if ( maxCount == numberOfFEDIds ) break ;
  }
  
  if ( maxCount != (numberOfFEDIds-numEmptyFEDs) )
    edm::LogWarning("ZDCMonitorModule::CalibTypeFilter") << "Conflicting calibration types found.  Assigning type "
                                           << calibType ;
  LogDebug("ZDCMonitorModule::CalibTypeFilter") << "Calibration type is: " << calibType ;
  // Fill histogram of calibration types, as well as integer to keep track of current value
  if (meCalibType_) meCalibType_->Fill(calibType);
  if (meCurrentCalibType_) meCurrentCalibType_->Fill(calibType);

  if (debug_>2) std::cout <<"\t<ZDCMonitorModule>  ievt = "<<ievt_<<"  calibration type = "<<calibType<<std::endl;

  // Check to see which subdetectors are present.
  // May only need to do this on first event?   Subdets don't appear during a run?
  if (ZDCpresent_==0)
    CheckSubdetectorStatus(rawraw, *eMap_);

  
  //  Here, we do need this information each event
  edm::Handle<HcalUnpackerReport> report;  
  if (!(e.getByLabel(inputLabelReport_,report)))
    {
      edm::LogWarning("ZDCMonitorModule")<<" Unpacker Report "<<inputLabelReport_<<" not available";
      return;
    }

  if (!fedsListed_)
    {
      const std::vector<int> feds =  (*report).getFedsUnpacked();    
      for(unsigned int f=0; f<feds.size(); ++f)
        meFEDS_->Fill(feds[f]);    
      fedsListed_ = true;
    } // if (!fedsListed_)

} // void ZDCMonitorModule::analyze(...)
void ZDCMonitorModule::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 90 of file ZDCMonitorModule.cc.

References gather_cfg::cout, dbe_, debug_, fedsListed_, ievt_, meCalibType_, meEvtsVsLS_, meFEDS_, meIevt_, meIevtHist_, meProcessedEndLumi_, meZDC_, cppFunctionSkipper::operator, and ZDCpresent_.

{
  if (debug_>0) std::cout <<"ZDCMonitorModule::beginJob()"<<std::endl;
  // Get DQM service
  dbe_ = edm::Service<DQMStore>().operator->();
  // set default values
  ievt_=0;
  fedsListed_=false;
  ZDCpresent_=0;
  // Set pointers to null
  meCalibType_=0;
  meFEDS_=0;
  meIevt_=0;
  meIevtHist_=0;
  meEvtsVsLS_=0;
  meProcessedEndLumi_=0;
  meZDC_=0;

}
void ZDCMonitorModule::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 250 of file ZDCMonitorModule.cc.

References gather_cfg::cout, and debug_.

{
  if (debug_>0) std::cout <<"ZDCMonitorModule::beginLuminosityBlock"<<std::endl;
}// void ZDCMonitorModule::beginLuminosityBlock(...)
void ZDCMonitorModule::beginRun ( const edm::Run run,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 110 of file ZDCMonitorModule.cc.

References gather_cfg::cout, debug_, eMap_, edm::EventSetup::get(), mergeRuns_, reset(), and setup().

{
  if ( debug_>0 ) std::cout << "ZDCMonitorModule: beginRun" << std::endl;
  // reset histograms & counters on a new run, unless merging allowed

  if (eMap_==0) //eMap_ not created yet
    {
      if (debug_>1) std::cout <<"\t<ZDCMonitorModule::beginRun> Getting Emap!"<<std::endl;
      edm::ESHandle<HcalDbService> pSetup;
      c.get<HcalDbRecord>().get( pSetup );
      eMap_=pSetup->getHcalMapping(); 
    }
  if (mergeRuns_) return;
  this->setup();
  this->reset();

} //ZDCMonitorModule::beginRun(....)
void ZDCMonitorModule::CheckSubdetectorStatus ( const edm::Handle< FEDRawDataCollection > &  rawraw,
const HcalElectronicsMap emap 
) [protected]

Definition at line 386 of file ZDCMonitorModule.cc.

References gather_cfg::cout, FEDRawData::data(), debug_, MonitorElement::Fill(), i, FEDNumbering::MAXHCALFEDID, meZDC_, FEDNumbering::MINHCALFEDID, FEDRawData::size(), and ZDCpresent_.

Referenced by analyze().

{

  std::vector<int> fedUnpackList;
  for (int i=FEDNumbering::MINHCALFEDID; 
       i<=FEDNumbering::MAXHCALFEDID; 
       i++) 
    fedUnpackList.push_back(i);

  if (debug_>1) std::cout <<"<ZDCMonitorModule::CheckSubdetectorStatus>  Checking ZDC "<<std::endl;
  for (std::vector<int>::const_iterator i=fedUnpackList.begin();
       i!=fedUnpackList.end(); 
       ++i) 
    {
      if (debug_>2) std::cout <<"\t<ZDCMonitorModule::CheckSubdetectorStatus>  FED = "<<*i<<std::endl;
      const FEDRawData& fed =(*rawraw).FEDData(*i);
      if (fed.size()<12) continue; // Was 16. How do such tiny events even get here?
      
      // get the DCC header
      const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fed.data());
      if (!dccHeader) return;
      //int dccid=dccHeader->getSourceId();
      
      // This is how HcalForward data is identified:
      //if (subdet == HcalForward && dccid>717 && dccid<724)
      // check for ZDC at some point -- how?
      // For now, just assume ZDC info is present, with dummy condition
      if (1>0)
        {
          ZDCpresent_=1;
          meZDC_->Fill(ZDCpresent_);
          break;
        }
    } //loop over fedUnpack list 

} // void ZDCMonitorModule::CheckSubdetectorStatus(...)
void ZDCMonitorModule::cleanup ( void  ) [protected]
void ZDCMonitorModule::endJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 268 of file ZDCMonitorModule.cc.

References cleanup(), gather_cfg::cout, dbe_, debug_, evtNumber_, MonitorElement::Fill(), DQMStore::get(), init_, meEvt_, meRun_, meStatus_, prefixME_, and runNumber_.

{
  if (debug_>0) std::cout <<"ZDCMonitorModule::endJob()"<<std::endl;
  if (dbe_)
    {
      meStatus_ = dbe_->get(prefixME_ + "/EventInfo/STATUS");
      meRun_ = dbe_->get(prefixME_ + "/EventInfo/RUN");
      meEvt_ = dbe_->get(prefixME_ + "/EventInfo/EVT");
    }
  if (meStatus_) meStatus_->Fill(2);
  if (meRun_) meRun_->Fill(runNumber_);
  if (meEvt_) meEvt_->Fill(evtNumber_);
  if (init_) this->cleanup();
} // void ZDCMonitorModule::endJob(void)
void ZDCMonitorModule::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 259 of file ZDCMonitorModule.cc.

References gather_cfg::cout, debug_, MonitorElement::Fill(), edm::LuminosityBlockBase::luminosityBlock(), and meProcessedEndLumi_.

{
  if (debug_>0) std::cout <<"ZDCMonitorModule::endLuminosityBlock"<<std::endl;
  meProcessedEndLumi_->Fill(lumiSeg.luminosityBlock());
}// void ZDCMonitorModule::endLuminosityBlock(...)
void ZDCMonitorModule::endRun ( const edm::Run run,
const edm::EventSetup c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 129 of file ZDCMonitorModule.cc.

References gather_cfg::cout, debug_, evtNumber_, MonitorElement::Fill(), meEvt_, meRun_, meStatus_, and runNumber_.

                                                                     {

  if ( debug_>0 ) std::cout << "ZDCMonitorModule: endRun" << std::endl;

  // end-of-run
  if ( meStatus_ ) meStatus_->Fill(2);

  if ( meRun_ ) meRun_->Fill(runNumber_);
  if ( meEvt_ ) meEvt_->Fill(evtNumber_);
}
void ZDCMonitorModule::reset ( void  ) [protected]

Definition at line 140 of file ZDCMonitorModule.cc.

References gather_cfg::cout, debug_, fedsListed_, MonitorElement::Fill(), ievt_, meCalibType_, meEvtsVsLS_, meFEDS_, meIevt_, meIevtHist_, meProcessedEndLumi_, meZDC_, MonitorElement::Reset(), and ZDCpresent_.

Referenced by beginRun().

{
  if (debug_>0) std::cout <<"ZDCMonitorModule::reset"<<std::endl;
  // Call Reset() on all MonitorElement histograms
  if (meCalibType_) meCalibType_->Reset();
  if (meFEDS_) meFEDS_->Reset();
  if (meIevt_) meIevt_->Fill(0);
  if (meIevtHist_) meIevtHist_->Reset();
  if (meEvtsVsLS_) meEvtsVsLS_->Reset();
  ievt_=0;
  if (meProcessedEndLumi_) meProcessedEndLumi_->Fill(-1);
  if (meZDC_) meZDC_->Fill(-1);
  ZDCpresent_=0;
  
  fedsListed_=false;
} // void ZDCMonitorModule::reset(void)
void ZDCMonitorModule::setup ( void  ) [protected]

Definition at line 157 of file ZDCMonitorModule.cc.

References DQMStore::book1D(), DQMStore::bookInt(), gather_cfg::cout, dbe_, debug_, MonitorElement::Fill(), init_, FEDNumbering::MAXHCALFEDID, meCalibType_, meCurrentCalibType_, meEvt_, meEvtsVsLS_, meFEDS_, meIevt_, meIevtHist_, meOnline_, meProcessedEndLumi_, meRun_, meStatus_, meZDC_, FEDNumbering::MINHCALFEDID, NLumiBlocks_, Online_, prefixME_, MonitorElement::setBinLabel(), and DQMStore::setCurrentFolder().

Referenced by analyze(), and beginRun().

{
  // Run this on first event in run; set up all necessary monitor elements
  if (debug_>0) std::cout <<"ZDCMonitorModule::setup"<<std::endl;
  init_=true;
  if (dbe_)
    {
      dbe_->setCurrentFolder(prefixME_+"ZDCInfo");
      meStatus_ = dbe_->bookInt("STATUS");
      if (meStatus_) meStatus_->Fill(-1);
      meRun_ = dbe_->bookInt("RUN");
      if (meRun_) meRun_->Fill(-1);
      meEvt_ = dbe_->bookInt("EVT");
      if (meEvt_) meEvt_->Fill(-1);
      meIevt_ = dbe_->bookInt("EventsProcessed");
      if (meIevt_) meIevt_->Fill(-1);
      meIevtHist_ = dbe_->book1D("EventsInZDCMonitorModule","Events Seen by ZDCMonitorModule",1,0.5,1.5);
      meIevtHist_->setBinLabel(1,"Nevents",1);
      meEvtsVsLS_ = dbe_->book1D("EventsVsLS","Events vs. Luminosity Section;LS;# events",NLumiBlocks_,0.5,NLumiBlocks_+0.5);
      meOnline_ = dbe_->bookInt("Online");
      meOnline_->Fill((int)Online_);
      meProcessedEndLumi_ = dbe_->bookInt("EndLumiBlock_MonitorModule");
      if (meProcessedEndLumi_) meProcessedEndLumi_->Fill(-1);
      meCurrentCalibType_= dbe_->bookInt("CURRENT_EVENT_TYPE");
      if (meCurrentCalibType_) meCurrentCalibType_->Fill(-1);
      
      meZDC_ = dbe_->bookInt("ZDCpresent");
      if (meZDC_) meZDC_->Fill(-1);

      meFEDS_    = dbe_->book1D("FEDs Unpacked","FEDs Unpacked; Hcal FEDs 700-731",1+(FEDNumbering::MAXHCALFEDID-FEDNumbering::MINHCALFEDID),FEDNumbering::MINHCALFEDID-0.5,FEDNumbering::MAXHCALFEDID+0.5);

      meCalibType_ = dbe_->book1D("CalibrationType","Calibration Type",9,-0.5,8.5);
      meCalibType_->setBinLabel(1,"Normal",1);
      meCalibType_->setBinLabel(2,"Ped",1);
      meCalibType_->setBinLabel(3,"RADDAM",1);
      meCalibType_->setBinLabel(4,"HBHEHPD",1);
      meCalibType_->setBinLabel(5,"HOHPD",1);
      meCalibType_->setBinLabel(6,"HFPMT",1);
      meCalibType_->setBinLabel(7,"ZDC",1); // Is this used for ZDC calibraitons??
      meCalibType_->setBinLabel(8,"CASTOR",1);

    } // if (dbe_)
  return;
} // void ZDCMonitorModule::setup(void)

Member Data Documentation

Definition at line 111 of file ZDCMonitorModule.h.

Referenced by beginJob(), cleanup(), endJob(), and setup().

int ZDCMonitorModule::debug_ [private]

Definition at line 113 of file ZDCMonitorModule.h.

Referenced by analyze(), and beginRun().

Definition at line 102 of file ZDCMonitorModule.h.

Referenced by cleanup(), and ZDCMonitorModule().

Definition at line 81 of file ZDCMonitorModule.h.

Referenced by analyze(), endJob(), and endRun().

Definition at line 105 of file ZDCMonitorModule.h.

Referenced by analyze(), and ZDCMonitorModule().

Definition at line 98 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), cleanup(), and reset().

int ZDCMonitorModule::ievt_ [private]

Definition at line 79 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), and reset().

bool ZDCMonitorModule::init_ [private]

Definition at line 104 of file ZDCMonitorModule.h.

Referenced by analyze(), cleanup(), endJob(), setup(), and ZDCMonitorModule().

Definition at line 106 of file ZDCMonitorModule.h.

Referenced by analyze(), and ZDCMonitorModule().

Definition at line 89 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), cleanup(), reset(), and setup().

Definition at line 90 of file ZDCMonitorModule.h.

Referenced by analyze(), cleanup(), and setup().

Definition at line 87 of file ZDCMonitorModule.h.

Referenced by analyze(), cleanup(), endJob(), endRun(), and setup().

Definition at line 94 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), reset(), and setup().

Definition at line 88 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), cleanup(), reset(), and setup().

Definition at line 92 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), cleanup(), reset(), and setup().

Definition at line 93 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), cleanup(), reset(), and setup().

Definition at line 96 of file ZDCMonitorModule.h.

Referenced by setup().

Definition at line 95 of file ZDCMonitorModule.h.

Referenced by beginJob(), cleanup(), endLuminosityBlock(), reset(), and setup().

Definition at line 101 of file ZDCMonitorModule.h.

Referenced by beginRun(), and ZDCMonitorModule().

Definition at line 86 of file ZDCMonitorModule.h.

Referenced by analyze(), cleanup(), endJob(), endRun(), and setup().

Definition at line 85 of file ZDCMonitorModule.h.

Referenced by analyze(), cleanup(), endJob(), endRun(), and setup().

Definition at line 91 of file ZDCMonitorModule.h.

Referenced by beginJob(), CheckSubdetectorStatus(), cleanup(), reset(), and setup().

Definition at line 108 of file ZDCMonitorModule.h.

Referenced by setup(), and ZDCMonitorModule().

bool ZDCMonitorModule::Online_ [private]

Definition at line 100 of file ZDCMonitorModule.h.

Referenced by setup(), and ZDCMonitorModule().

std::string ZDCMonitorModule::prefixME_ [private]

Definition at line 107 of file ZDCMonitorModule.h.

Referenced by cleanup(), endJob(), setup(), and ZDCMonitorModule().

Definition at line 80 of file ZDCMonitorModule.h.

Referenced by analyze(), endJob(), and endRun().

Definition at line 110 of file ZDCMonitorModule.h.

Referenced by analyze(), beginJob(), CheckSubdetectorStatus(), cleanup(), and reset().