CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::SpyIdentifyRunsModule Class Reference
Inheritance diagram for sistrip::SpyIdentifyRunsModule:
edm::EDAnalyzer

Public Member Functions

 SpyIdentifyRunsModule (const edm::ParameterSet &)
 
 ~SpyIdentifyRunsModule ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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.

74  : fileName_(iConfig.getParameter<std::string>("OutputTextFile")),
75  srcTag_(iConfig.getParameter<edm::InputTag>("InputProductLabel")),
76  prevRun_(0)
77  {
78 
79  }
T getParameter(std::string const &) const
sistrip::SpyIdentifyRunsModule::~SpyIdentifyRunsModule ( )

Definition at line 82 of file SiStripSpyIdentifyRuns.cc.

82  {
83 
84  }

Member Function Documentation

void sistrip::SpyIdentifyRunsModule::analyze ( const edm::Event aEvt,
const edm::EventSetup aSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 100 of file SiStripSpyIdentifyRuns.cc.

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

101  {
102 
103  //static bool lFirstEvent = true;
104  //if (!lFirstEvent) return;
105  uint32_t lRunNum = aEvt.id().run();
106  if (lRunNum == prevRun_) return;
107 
109  aEvt.getByLabel( srcTag_, lHandle );
110  const FEDRawDataCollection& buffers = *lHandle;
111 
112  for (unsigned int iFed(FEDNumbering::MINSiStripFEDID);
114  iFed++)
115  {
116 
117  //retrieve FED raw data for given FED
118  const FEDRawData& input = buffers.FEDData( static_cast<int>(iFed) );
119  //check on FEDRawData pointer and size
120  if ( !input.data() ||!input.size() ) continue;
121 
122  //construct FEDBuffer
123  std::auto_ptr<sistrip::FEDSpyBuffer> buffer;
124  try {
125  buffer.reset(new sistrip::FEDSpyBuffer(input.data(),input.size()));
126  } catch (const cms::Exception& e) {
127  edm::LogWarning("SiStripSpyIdentifyRuns")
128  << "Exception caught when creating FEDSpyBuffer object for FED " << iFed << ": " << e.what();
129  //if (!(buffer->readoutMode() == READOUT_MODE_SPY)) break;
130  std::string lErrStr = e.what();
131  if (lErrStr.find("Buffer is not from spy channel")!=lErrStr.npos) break;
132  else {
133  writeRunInFile(lRunNum);
134  break;
135  }
136  } // end of buffer reset try.
137  edm::LogWarning("SiStripSpyIdentifyRuns")
138  << " -- this is a spy file, run " << lRunNum << std::endl;
139  writeRunInFile(lRunNum);
140  break;
141  }
142  //lFirstEvent = false;
143  prevRun_ = lRunNum;
144 
145  }
RunNumber_t run() const
Definition: EventID.h:42
virtual char const * what() const
Definition: Exception.cc:97
void writeRunInFile(const unsigned int aRunNumber)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
tuple input
Definition: collect_tpl.py:10
edm::EventID id() const
Definition: EventBase.h:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
void sistrip::SpyIdentifyRunsModule::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file SiStripSpyIdentifyRuns.cc.

References fileName_, dbtoconf::out, and outFile_.

87  {
88  outFile_.open(fileName_.c_str(),std::ios::out);
89  if (!outFile_.is_open()) {
90  edm::LogError("SiStripSpyIdentifyRuns") << " -- Cannot open file : " << fileName_ << " for writting."
91  << std::endl;
92  edm::LogInfo("SiStripSpyIdentifyRuns") << " *** SPY RUNS *** "<< std::endl;
93 
94  }
95  else {
96  outFile_ << " *** SPY RUNS *** " << std::endl;
97  }
98  }
tuple out
Definition: dbtoconf.py:99
void sistrip::SpyIdentifyRunsModule::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 157 of file SiStripSpyIdentifyRuns.cc.

References outFile_.

157  {
158 
159  //save global run number in text file in local directory
160  //output loginfo with number of errors
161  //or throw exception ?
162  if (outFile_.is_open()) outFile_.close();
163 
164  }
void sistrip::SpyIdentifyRunsModule::writeRunInFile ( const unsigned int  aRunNumber)
private

Definition at line 147 of file SiStripSpyIdentifyRuns.cc.

References outFile_.

Referenced by analyze().

147  {
148  if (!outFile_.is_open()) {
149  edm::LogInfo("SiStripSpyIdentifyRuns") << aRunNumber
150  << std::endl;
151  }
152  else {
153  outFile_ << aRunNumber << std::endl;
154  }
155  }

Member Data Documentation

std::string sistrip::SpyIdentifyRunsModule::fileName_
private

Definition at line 54 of file SiStripSpyIdentifyRuns.cc.

Referenced by beginJob().

std::ofstream sistrip::SpyIdentifyRunsModule::outFile_
private

Definition at line 55 of file SiStripSpyIdentifyRuns.cc.

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

uint32_t sistrip::SpyIdentifyRunsModule::prevRun_
private

Definition at line 60 of file SiStripSpyIdentifyRuns.cc.

Referenced by analyze().

edm::InputTag sistrip::SpyIdentifyRunsModule::srcTag_
private

Definition at line 58 of file SiStripSpyIdentifyRuns.cc.

Referenced by analyze().