CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

ESFEDIntegrityTask Class Reference

#include <ESFEDIntegrityTask.h>

Inheritance diagram for ESFEDIntegrityTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

 ESFEDIntegrityTask (const edm::ParameterSet &ps)
virtual ~ESFEDIntegrityTask ()

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze.
void beginJob (void)
 BeginJob.
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 BeginRun.
void cleanup (void)
 Cleanup.
void endJob (void)
 EndJob.
void endRun (const edm::Run &r, const edm::EventSetup &c)
 EndRun.
void reset (void)
 Reset.
void setup (void)
 Setup.

Private Attributes

edm::InputTag dccCollections_
bool debug_
DQMStoredqmStore_
bool enableCleanup_
std::string fedDirName_
edm::InputTag FEDRawDataCollection_
int ievt_
bool init_
edm::InputTag kchipCollections_
MonitorElementmeESFedsEntries_
MonitorElementmeESFedsFatal_
MonitorElementmeESFedsNonFatal_
bool mergeRuns_
std::string prefixME_

Detailed Description

Definition at line 12 of file ESFEDIntegrityTask.h.


Constructor & Destructor Documentation

ESFEDIntegrityTask::ESFEDIntegrityTask ( const edm::ParameterSet ps)

Definition at line 29 of file ESFEDIntegrityTask.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), cmsCodeRules::cppFunctionSkipper::operator, and prefixME_.

                                                             {

  init_ = false;

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

  prefixME_      = ps.getUntrackedParameter<string>("prefixME", "");
  fedDirName_    = ps.getUntrackedParameter<string>("FEDDirName", "FEDIntegrity");
  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
  mergeRuns_     = ps.getUntrackedParameter<bool>("mergeRuns", false);
  debug_         = ps.getUntrackedParameter<bool>("debug", false);

  dccCollections_       = ps.getParameter<InputTag>("ESDCCCollections");
  kchipCollections_     = ps.getParameter<InputTag>("ESKChipCollections");
  FEDRawDataCollection_ = ps.getParameter<edm::InputTag>("FEDRawDataCollection");

  meESFedsEntries_  = 0;
  meESFedsFatal_    = 0;
  meESFedsNonFatal_ = 0;
  
}
ESFEDIntegrityTask::~ESFEDIntegrityTask ( ) [virtual]

Definition at line 51 of file ESFEDIntegrityTask.cc.

                                        {

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 135 of file ESFEDIntegrityTask.cc.

References edm::EventBase::bunchCrossing(), gather_cfg::cout, FEDRawData::data(), ESDCCHeaderBlock::fedId(), ESDCCHeaderBlock::getBX(), edm::Event::getByLabel(), ESDCCHeaderBlock::getDCCErrors(), ESDCCHeaderBlock::getFEChannelStatus(), ESDCCHeaderBlock::getLV1(), ESDCCHeaderBlock::getOptoRX0(), ESDCCHeaderBlock::getOptoRX1(), ESDCCHeaderBlock::getOptoRX2(), ESDCCHeaderBlock::getOrbitNumber(), MultipleCompare::header, i, edm::EventBase::orbitNumber(), HcalObjRepresent::setup(), and FEDRawData::size().

                                                                   {

  if ( ! init_ ) this->setup();

  ievt_++;

  int gt_L1A = 0, gt_OrbitNumber = 0, gt_BX = 0;
  int esDCC_L1A_MostFreqCounts = 0;
  int esDCC_BX_MostFreqCounts = 0;
  int esDCC_OrbitNumber_MostFreqCounts = 0;
  int gtFedDataSize = 0;

  Handle<ESRawDataCollection> dccs;
  Handle<FEDRawDataCollection> allFedRawData;

  if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {

    // ES FEDs
    for (int esFED=520; esFED<=575; ++esFED) { 

      const FEDRawData& fedData = allFedRawData->FEDData(esFED);
      int length = fedData.size()/sizeof(uint64_t);
      
      if ( length > 0 ) 
        if ( meESFedsEntries_ ) meESFedsEntries_->Fill(esFED);
    }

    // GT FED data
    const FEDRawData& gtFedData = allFedRawData->FEDData(812);
     
    gtFedDataSize = gtFedData.size()/sizeof(uint64_t);
     
    if ( gtFedDataSize > 0 ) {
       
      FEDHeader header(gtFedData.data());
       
      gt_L1A         = header.lvl1ID();
      gt_OrbitNumber = e.orbitNumber();
      gt_BX          = e.bunchCrossing();
    } else {

      map<int, int> esDCC_L1A_FreqMap;
      map<int, int> esDCC_BX_FreqMap;
      map<int, int> esDCC_OrbitNumber_FreqMap;

      if ( e.getByLabel(dccCollections_, dccs) ) {
        
        for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
          ESDCCHeaderBlock esdcc = (*dccItr);
          
          esDCC_L1A_FreqMap[esdcc.getLV1()]++;
          esDCC_BX_FreqMap[esdcc.getBX()]++;
          esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()]++;
          
          if (esDCC_L1A_FreqMap[esdcc.getLV1()] > esDCC_L1A_MostFreqCounts) {
            esDCC_L1A_MostFreqCounts = esDCC_L1A_FreqMap[esdcc.getLV1()];
            gt_L1A = esdcc.getLV1();
          } 
          
          if (esDCC_BX_FreqMap[esdcc.getBX()] > esDCC_BX_MostFreqCounts) {
            esDCC_BX_MostFreqCounts = esDCC_BX_FreqMap[esdcc.getBX()];
            gt_BX = esdcc.getBX();
          } 
          
          if (esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()] > esDCC_OrbitNumber_MostFreqCounts) {
            esDCC_OrbitNumber_MostFreqCounts = esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()];
            gt_OrbitNumber = esdcc.getOrbitNumber();
          } 
          
        }
      } else {
        LogWarning("ESFEDIntegrityTask") << dccCollections_ << " not available";
      }

    }

  } else {
    LogWarning("ESFEDIntegrityTask") << FEDRawDataCollection_ << " not available";
  }

  vector<int> fiberStatus;
  if ( e.getByLabel(dccCollections_, dccs) ) {
    for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
      ESDCCHeaderBlock dcc = (*dccItr);
      
      if (dcc.getDCCErrors() > 0) {
        
        if ( meESFedsFatal_ ) meESFedsFatal_->Fill(dcc.fedId());
        
      } else {
        if (debug_) cout<<dcc.fedId()<<" "<<dcc.getOptoRX0()<<" "<<dcc.getOptoRX1()<<" "<<dcc.getOptoRX2()<<endl;
        fiberStatus = dcc.getFEChannelStatus();
        
        if (dcc.getOptoRX0() == 128) {
          meESFedsNonFatal_->Fill(dcc.fedId(), 1./3.);
        } else if (dcc.getOptoRX0() == 129) {
          for (unsigned int i=0; i<12; ++i) {
            if (fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
              if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Fill(dcc.fedId(), 1./12.);
          }
        }
        if (dcc.getOptoRX1() == 128) { 
          meESFedsNonFatal_->Fill(dcc.fedId(), 1./3.);
        }       else if (dcc.getOptoRX1() == 129) {
          for (unsigned int i=12; i<24; ++i) {
            if (fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
              if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Fill(dcc.fedId(), 1./12.);
          }
        }
        if (dcc.getOptoRX2() == 128) {
          meESFedsNonFatal_->Fill(dcc.fedId(), 1./3.);
        } else if (dcc.getOptoRX2() == 129){
          for (unsigned int i=24; i<36; ++i) {
            if (fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
              if ( meESFedsNonFatal_ ) meESFedsNonFatal_->Fill(dcc.fedId(), 1./12.);
          }
        }
      }
      
      if (dcc.getLV1() != gt_L1A) meESFedsNonFatal_->Fill(dcc.fedId());
      //if (dcc.getBX() != gt_BX) meESFedsNonFatal_->Fill(dcc.fedId());
      //if (dcc.getOrbitNumber() != gt_OrbitNumber) meESFedsNonFatal_->Fill(dcc.fedId());
    }
  }

  //for (ESLocalRawDataCollection::const_iterator kItr = kchips->begin(); kItr != kchips->end(); ++kItr) {

  //ESKCHIPBlock kchip = (*kItr);

  //Int_t nErr = 0;
  //if (kchip.getFlag1() > 0) nErr++; 
  //if (kchip.getFlag2() > 0) nErr++;
  //if (kchip.getBC() != kchip.getOptoBC()) nErr++;
  //if (kchip.getEC() != kchip.getOptoEC()) nErr++;
  //if (nErr>0) meESFedsNonFatal_->Fill(dcc.fedId());
  //}

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file ESFEDIntegrityTask.cc.

References prefixME_.

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 66 of file ESFEDIntegrityTask.cc.

References reset().

                                                                   {

  if ( ! mergeRuns_ ) this->reset();

}
void ESFEDIntegrityTask::cleanup ( void  ) [protected]
void ESFEDIntegrityTask::endJob ( void  ) [protected, virtual]

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 127 of file ESFEDIntegrityTask.cc.

References edm::cleanup().

                                   {

  LogInfo("ESFEDIntegrityTask") << "analyzed " << ievt_ << " events";

  if ( enableCleanup_ ) this->cleanup();

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 72 of file ESFEDIntegrityTask.cc.

                                                                 {

}
void ESFEDIntegrityTask::reset ( void  ) [protected]
void ESFEDIntegrityTask::setup ( void  ) [protected]

Setup.

Definition at line 84 of file ESFEDIntegrityTask.cc.

References timingPdfMaker::histo, and prefixME_.

                                  {

  init_ = true;

  char histo[200];

  if ( dqmStore_ ) {
    dqmStore_->setCurrentFolder(prefixME_ + "/" + fedDirName_);

    sprintf(histo, "FEDEntries");
    meESFedsEntries_ = dqmStore_->book1D(histo, histo, 56, 520, 576);

    sprintf(histo, "FEDFatal");
    meESFedsFatal_ = dqmStore_->book1D(histo, histo, 56, 520, 576);

    sprintf(histo, "FEDNonFatal");
    meESFedsNonFatal_ = dqmStore_->book1D(histo, histo, 56, 520, 576);
  }

}

Member Data Documentation

Definition at line 57 of file ESFEDIntegrityTask.h.

Definition at line 55 of file ESFEDIntegrityTask.h.

Definition at line 49 of file ESFEDIntegrityTask.h.

Definition at line 53 of file ESFEDIntegrityTask.h.

std::string ESFEDIntegrityTask::fedDirName_ [private]

Definition at line 52 of file ESFEDIntegrityTask.h.

Definition at line 59 of file ESFEDIntegrityTask.h.

Definition at line 47 of file ESFEDIntegrityTask.h.

bool ESFEDIntegrityTask::init_ [private]

Definition at line 65 of file ESFEDIntegrityTask.h.

Definition at line 58 of file ESFEDIntegrityTask.h.

Definition at line 61 of file ESFEDIntegrityTask.h.

Definition at line 62 of file ESFEDIntegrityTask.h.

Definition at line 63 of file ESFEDIntegrityTask.h.

Definition at line 54 of file ESFEDIntegrityTask.h.

std::string ESFEDIntegrityTask::prefixME_ [private]

Definition at line 51 of file ESFEDIntegrityTask.h.