CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

ESRawDataTask Class Reference

#include <ESRawDataTask.h>

Inheritance diagram for ESRawDataTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

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_
DQMStoredqmStore_
bool enableCleanup_
edm::InputTag FEDRawDataCollection_
int ievt_
bool init_
MonitorElementmeBXDCCErrors_
MonitorElementmeBXDiff_
MonitorElementmeL1ADCCErrors_
MonitorElementmeL1ADiff_
MonitorElementmeOrbitNumberDCCErrors_
MonitorElementmeOrbitNumberDiff_
bool mergeRuns_
std::string prefixME_
int runNum_

Detailed Description

Definition at line 11 of file ESRawDataTask.h.


Constructor & Destructor Documentation

ESRawDataTask::ESRawDataTask ( const edm::ParameterSet ps)

Definition at line 32 of file ESRawDataTask.cc.

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

                                                   {

   init_ = false;

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

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

   FEDRawDataCollection_ = ps.getParameter<InputTag>("FEDRawDataCollection");
   dccCollections_       = ps.getParameter<InputTag>("ESDCCCollections");

}
ESRawDataTask::~ESRawDataTask ( ) [virtual]

Definition at line 47 of file ESRawDataTask.cc.

                              {
}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 161 of file ESRawDataTask.cc.

References edm::EventBase::bunchCrossing(), FEDRawData::data(), ESDCCHeaderBlock::fedId(), ESDCCHeaderBlock::getBX(), edm::Event::getByLabel(), ESDCCHeaderBlock::getLV1(), ESDCCHeaderBlock::getOrbitNumber(), errorMatrix2Lands::header, edm::EventBase::id(), edm::EventBase::orbitNumber(), edm::EventID::run(), HcalObjRepresent::setup(), and FEDRawData::size().

                                                              {

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

   ievt_++;
   runNum_ = e.id().run();

   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;

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

   int gtFedDataSize = 0;
   
   if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {
     
     // 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("ESRawDataTask") << dccCollections_ << " not available";
       }

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

   // DCC 
   vector<int> fiberStatus;
   if ( e.getByLabel(dccCollections_, dccs) ) {
     
     for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
       ESDCCHeaderBlock dcc = (*dccItr);
       
       //if (dcc.getRunNumber() != runNum_) {
       //meRunNumberErrors_->Fill(dcc.fedId());
       //cout<<"Run # err : "<<dcc.getRunNumber()<<" "<<runNum_<<endl;
       //}
       
       if (dcc.getLV1() != gt_L1A) {
         meL1ADCCErrors_->Fill(dcc.fedId());
         //cout<<"L1A err : "<<dcc.getLV1()<<" "<<gt_L1A<<endl;
         Float_t l1a_diff = dcc.getLV1() - gt_L1A;
         if (l1a_diff > 100) l1a_diff = 100;
         else if (l1a_diff < -100) l1a_diff = -100;
         meL1ADiff_->Fill(l1a_diff);
       }
       
       if (dcc.getBX() != gt_BX) {
         meBXDCCErrors_->Fill(dcc.fedId());
         //cout<<"BX err : "<<dcc.getBX()<<" "<<gt_BX<<endl;
         Float_t bx_diff = dcc.getBX() - gt_BX;
         if (bx_diff > 100) bx_diff = 100;
         else if (bx_diff < -100) bx_diff = -100;
         meBXDiff_->Fill(bx_diff);
       }
       if (dcc.getOrbitNumber() != gt_OrbitNumber) {
         meOrbitNumberDCCErrors_->Fill(dcc.fedId());
         //cout<<"Orbit err : "<<dcc.getOrbitNumber()<<" "<<gt_OrbitNumber<<endl;
         Float_t orbitnumber_diff = dcc.getOrbitNumber() - gt_OrbitNumber;
         if (orbitnumber_diff > 100) orbitnumber_diff = 100;
         else if (orbitnumber_diff < -100) orbitnumber_diff = -100;
         meOrbitNumberDiff_->Fill(orbitnumber_diff);
       }
     }
   }

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file ESRawDataTask.cc.

                                 {

   ievt_ = 0;

   if ( dqmStore_ ) {
      dqmStore_->setCurrentFolder(prefixME_ + "/ESRawDataTask");
      dqmStore_->rmdir(prefixME_ + "/ESRawDataTask");
   }

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 61 of file ESRawDataTask.cc.

References reset().

                                                              {

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

}
void ESRawDataTask::cleanup ( void  ) [protected]

Cleanup.

Definition at line 122 of file ESRawDataTask.cc.

                               {

   if ( ! init_ ) return;

   if ( dqmStore_ ) {
     //if ( meRunNumberErrors_ ) dqmStore_->removeElement( meRunNumberErrors_->getName() );
     //meRunNumberErrors_ = 0;

     if ( meL1ADCCErrors_ ) dqmStore_->removeElement( meL1ADCCErrors_->getName() );
     meL1ADCCErrors_ = 0;

     if ( meBXDCCErrors_ ) dqmStore_->removeElement( meBXDCCErrors_->getName() );
     meBXDCCErrors_ = 0;

     if ( meOrbitNumberDCCErrors_ ) dqmStore_->removeElement( meOrbitNumberDCCErrors_->getName() );
     meOrbitNumberDCCErrors_ = 0;

     if ( meL1ADiff_ ) dqmStore_->removeElement( meL1ADiff_->getName() );
     meL1ADiff_ = 0;

     if ( meBXDiff_ ) dqmStore_->removeElement( meBXDiff_->getName() );
     meBXDiff_ = 0;

     if ( meOrbitNumberDiff_ ) dqmStore_->removeElement( meOrbitNumberDiff_->getName() );
     meOrbitNumberDiff_ = 0;
   }

   init_ = false;

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

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 153 of file ESRawDataTask.cc.

References edm::cleanup().

                              {

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

   if ( enableCleanup_ ) this->cleanup();

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file ESRawDataTask.cc.

                                                            {

}
void ESRawDataTask::reset ( void  ) [protected]

Reset.

Definition at line 71 of file ESRawDataTask.cc.

                              {

}
void ESRawDataTask::setup ( void  ) [protected]

Setup.

Definition at line 75 of file ESRawDataTask.cc.

References interpolateCardsSimple::histo.

                             {

   init_ = true;

   char histo[200];

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

      //sprintf(histo, "ES run number errors");
      //meRunNumberErrors_ = dqmStore_->book1D(histo, histo, 56, 519.5, 575.5); 
      //meRunNumberErrors_->setAxisTitle("ES FED", 1);
      //meRunNumberErrors_->setAxisTitle("Num of Events", 2);

      sprintf(histo, "ES L1A DCC errors");
      meL1ADCCErrors_ = dqmStore_->book1D(histo, histo, 56, 519.5, 575.5); 
      meL1ADCCErrors_->setAxisTitle("ES FED", 1);
      meL1ADCCErrors_->setAxisTitle("Num of Events", 2);

      sprintf(histo, "ES BX DCC errors");
      meBXDCCErrors_ = dqmStore_->book1D(histo, histo, 56, 519.5, 575.5); 
      meBXDCCErrors_->setAxisTitle("ES FED", 1);
      meBXDCCErrors_->setAxisTitle("Num of Events", 2);

      sprintf(histo, "ES Orbit Number DCC errors");
      meOrbitNumberDCCErrors_ = dqmStore_->book1D(histo, histo, 56, 519.5, 575.5); 
      meOrbitNumberDCCErrors_->setAxisTitle("ES FED", 1);
      meOrbitNumberDCCErrors_->setAxisTitle("Num of Events", 2);
      
      sprintf(histo, "Difference between ES and GT L1A");
      meL1ADiff_ = dqmStore_->book1D(histo, histo, 201, -100.5, 100.5);
      meL1ADiff_->setAxisTitle("ES - GT L1A", 1);
      meL1ADiff_->setAxisTitle("Num of Events", 2);

      sprintf(histo, "Difference between ES and GT BX");
      meBXDiff_ = dqmStore_->book1D(histo, histo, 201, -100.5, 100.5);
      meBXDiff_->setAxisTitle("ES - GT BX", 1);
      meBXDiff_->setAxisTitle("Num of Events", 2);

      sprintf(histo, "Difference between ES and GT Orbit Number");
      meOrbitNumberDiff_ = dqmStore_->book1D(histo, histo, 201, -100.5, 100.5);
      meOrbitNumberDiff_->setAxisTitle("ES - GT orbit number", 1);
      meOrbitNumberDiff_->setAxisTitle("Num of Events", 2);
   }

}

Member Data Documentation

Definition at line 55 of file ESRawDataTask.h.

Definition at line 48 of file ESRawDataTask.h.

Definition at line 52 of file ESRawDataTask.h.

Definition at line 56 of file ESRawDataTask.h.

int ESRawDataTask::ievt_ [private]

Definition at line 46 of file ESRawDataTask.h.

bool ESRawDataTask::init_ [private]

Definition at line 66 of file ESRawDataTask.h.

Definition at line 60 of file ESRawDataTask.h.

Definition at line 63 of file ESRawDataTask.h.

Definition at line 59 of file ESRawDataTask.h.

Definition at line 62 of file ESRawDataTask.h.

Definition at line 61 of file ESRawDataTask.h.

Definition at line 64 of file ESRawDataTask.h.

bool ESRawDataTask::mergeRuns_ [private]

Definition at line 53 of file ESRawDataTask.h.

std::string ESRawDataTask::prefixME_ [private]

Definition at line 50 of file ESRawDataTask.h.

int ESRawDataTask::runNum_ [private]

Definition at line 67 of file ESRawDataTask.h.