CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

sistrip::SpyIdentifyRunsModule Class Reference

Inheritance diagram for sistrip::SpyIdentifyRunsModule:
edm::EDAnalyzer

List of all members.

Public Member Functions

 SpyIdentifyRunsModule (const edm::ParameterSet &)
 ~SpyIdentifyRunsModule ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()
void writeRunInFile (const unsigned int aRunNumber)

Private Attributes

std::string fileName_
std::ofstream outFile_
uint32_t prevRun_
edm::InputTag srcTag_

Detailed Description

Definition at line 37 of file SiStripSpyIdentifyRuns.cc.


Constructor & Destructor Documentation

sistrip::SpyIdentifyRunsModule::SpyIdentifyRunsModule ( const edm::ParameterSet iConfig) [explicit]

Definition at line 73 of file SiStripSpyIdentifyRuns.cc.

    : fileName_(iConfig.getParameter<std::string>("OutputTextFile")),
      srcTag_(iConfig.getParameter<edm::InputTag>("InputProductLabel")),
      prevRun_(0)
  {

  }
sistrip::SpyIdentifyRunsModule::~SpyIdentifyRunsModule ( )

Definition at line 82 of file SiStripSpyIdentifyRuns.cc.

                                                {

  }

Member Function Documentation

void sistrip::SpyIdentifyRunsModule::analyze ( const edm::Event aEvt,
const edm::EventSetup aSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 100 of file SiStripSpyIdentifyRuns.cc.

References FEDRawData::data(), alignCSCRings::e, FEDRawDataCollection::FEDData(), edm::Event::getByLabel(), edm::EventBase::id(), LaserDQM_cfg::input, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, prevRun_, edm::EventID::run(), FEDRawData::size(), srcTag_, cms::Exception::what(), and writeRunInFile().

  {

    //static bool lFirstEvent = true;
    //if (!lFirstEvent) return;
    uint32_t lRunNum = aEvt.id().run();
    if (lRunNum == prevRun_) return;

    edm::Handle<FEDRawDataCollection> lHandle;
    aEvt.getByLabel( srcTag_, lHandle ); 
    const FEDRawDataCollection& buffers = *lHandle;

    for (unsigned int iFed(FEDNumbering::MINSiStripFEDID);
         iFed <= FEDNumbering::MAXSiStripFEDID;
         iFed++)
      {

        //retrieve FED raw data for given FED 
        const FEDRawData& input = buffers.FEDData( static_cast<int>(iFed) );
        //check on FEDRawData pointer and size
        if ( !input.data() ||!input.size() ) continue;
          
        //construct FEDBuffer
        std::auto_ptr<sistrip::FEDSpyBuffer> buffer;
        try {
          buffer.reset(new sistrip::FEDSpyBuffer(input.data(),input.size()));
        } catch (const cms::Exception& e) { 
          edm::LogWarning("SiStripSpyIdentifyRuns")
            << "Exception caught when creating FEDSpyBuffer object for FED " << iFed << ": " << e.what();
          //if (!(buffer->readoutMode() == READOUT_MODE_SPY)) break;
          std::string lErrStr = e.what();
          if (lErrStr.find("Buffer is not from spy channel")!=lErrStr.npos) break;
          else {
            writeRunInFile(lRunNum);
            break;
          }
        } // end of buffer reset try.
        edm::LogWarning("SiStripSpyIdentifyRuns")
          << " -- this is a spy file, run " << lRunNum << std::endl;
        writeRunInFile(lRunNum);
        break;
      }
    //lFirstEvent = false;
    prevRun_ = lRunNum;

  }
void sistrip::SpyIdentifyRunsModule::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file SiStripSpyIdentifyRuns.cc.

References fileName_, dbtoconf::out, and outFile_.

  {
    outFile_.open(fileName_.c_str(),std::ios::out);
    if (!outFile_.is_open()) {
      edm::LogError("SiStripSpyIdentifyRuns")  << " -- Cannot open file : " << fileName_ << " for writting." 
                                               << std::endl;
      edm::LogInfo("SiStripSpyIdentifyRuns")  << " *** SPY RUNS *** "<< std::endl;

    }
    else {
      outFile_ << " *** SPY RUNS *** " << std::endl;
    }
  }
void sistrip::SpyIdentifyRunsModule::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 157 of file SiStripSpyIdentifyRuns.cc.

References outFile_.

                                     {

    //save global run number in text file in local directory
    //output loginfo with number of errors
    //or throw exception ?
    if (outFile_.is_open()) outFile_.close();

  }
void sistrip::SpyIdentifyRunsModule::writeRunInFile ( const unsigned int  aRunNumber) [private]

Definition at line 147 of file SiStripSpyIdentifyRuns.cc.

References outFile_.

Referenced by analyze().

                                                                         {
    if (!outFile_.is_open()) {
      edm::LogInfo("SiStripSpyIdentifyRuns") << aRunNumber
                                             << std::endl;
    }
    else {
      outFile_ << aRunNumber  << std::endl;
    }
  }

Member Data Documentation

Definition at line 54 of file SiStripSpyIdentifyRuns.cc.

Referenced by beginJob().

Definition at line 55 of file SiStripSpyIdentifyRuns.cc.

Referenced by beginJob(), endJob(), and writeRunInFile().

Definition at line 60 of file SiStripSpyIdentifyRuns.cc.

Referenced by analyze().

Definition at line 58 of file SiStripSpyIdentifyRuns.cc.

Referenced by analyze().