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::SpyExtractRunModule Class Reference
Inheritance diagram for sistrip::SpyExtractRunModule:
edm::EDAnalyzer

Public Member Functions

 SpyExtractRunModule (const edm::ParameterSet &)
 
 ~SpyExtractRunModule ()
 
- 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 ()
 
const bool updateRun (const uint32_t aRun)
 

Private Attributes

uint32_t currentRun_
 
uint32_t errCounter_
 
std::string fileName_
 
uint32_t previousRun_
 
edm::InputTag runTag_
 

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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 35 of file SiStripSpyExtractRunModule.cc.

Constructor & Destructor Documentation

sistrip::SpyExtractRunModule::SpyExtractRunModule ( const edm::ParameterSet iConfig)
explicit

Definition at line 76 of file SiStripSpyExtractRunModule.cc.

77  : fileName_(iConfig.getParameter<std::string>("OutputTextFile")),
78  runTag_(iConfig.getParameter<edm::InputTag>("RunNumberTag")),
79  currentRun_(0),
80  previousRun_(0),
81  errCounter_(0)
82  {
83 
84  }
T getParameter(std::string const &) const
sistrip::SpyExtractRunModule::~SpyExtractRunModule ( )

Definition at line 87 of file SiStripSpyExtractRunModule.cc.

87  {
88 
89  }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 99 of file SiStripSpyExtractRunModule.cc.

References currentRun_, edm::EventID::event(), edm::Event::getByLabel(), edm::EventBase::id(), previousRun_, edm::EventID::run(), runTag_, and updateRun().

100  {
101 
102  static bool lFirstEvent = true;
104  aEvt.getByLabel( runTag_, lRun );
105 
106  const bool isUpdated = updateRun(*lRun);
107 
108  if (isUpdated && !lFirstEvent){
109  edm::LogError("SpyExtractRunModule") << " -- Run number changed for event : " << aEvt.id().event()
110  << " (id().run() = " << aEvt.id().run()
111  << ") from " << previousRun_ << " to " << currentRun_
112  << std::endl;
113  }
114 
115 
116  lFirstEvent = false;
117 
118  }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
const bool updateRun(const uint32_t aRun)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::EventID id() const
Definition: EventBase.h:56
void sistrip::SpyExtractRunModule::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 91 of file SiStripSpyExtractRunModule.cc.

References currentRun_, errCounter_, and previousRun_.

void sistrip::SpyExtractRunModule::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 121 of file SiStripSpyExtractRunModule.cc.

References currentRun_, errCounter_, fileName_, dbtoconf::out, and previousRun_.

121  {
122 
123  //save global run number in text file in local directory
124  //output loginfo with number of errors
125  //or throw exception ?
126 
127 
128  if (errCounter_ == 1){
129  edm::LogInfo("SiStripSpyExtractRun") << " -- Writting run number " << currentRun_
130  << " into file " << fileName_
131  << std::endl;
132  std::ofstream lOutFile;
133  lOutFile.open(fileName_.c_str(),std::ios::out);
134  if (!lOutFile.is_open()) {
135  edm::LogError("SiStripSpyExtractRun") << " -- Cannot open file : " << fileName_ << " for writting run number "
136  << currentRun_
137  << std::endl;
138  }
139  else {
140  lOutFile << currentRun_ << std::endl;
141  lOutFile.close();
142  }
143 
144  }
145  else {
146  edm::LogError("SiStripSpyExtractRun") << " -- Number of times the run number changed in this job = " << errCounter_
147  << ", currentRun = " << currentRun_
148  << ", previousRun = " << previousRun_
149  << std::endl;
150  }
151 
152 
153  }
tuple out
Definition: dbtoconf.py:99
const bool sistrip::SpyExtractRunModule::updateRun ( const uint32_t  aRun)
private

Definition at line 155 of file SiStripSpyExtractRunModule.cc.

References currentRun_, errCounter_, and previousRun_.

Referenced by analyze().

155  {
156  if (aRun != currentRun_){
158  currentRun_ = aRun;
159  errCounter_++;
160  return true;
161  }
162  return false;
163 
164  }

Member Data Documentation

uint32_t sistrip::SpyExtractRunModule::currentRun_
private

Definition at line 59 of file SiStripSpyExtractRunModule.cc.

Referenced by analyze(), beginJob(), endJob(), and updateRun().

uint32_t sistrip::SpyExtractRunModule::errCounter_
private

Definition at line 63 of file SiStripSpyExtractRunModule.cc.

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

std::string sistrip::SpyExtractRunModule::fileName_
private

Definition at line 53 of file SiStripSpyExtractRunModule.cc.

Referenced by endJob().

uint32_t sistrip::SpyExtractRunModule::previousRun_
private

Definition at line 60 of file SiStripSpyExtractRunModule.cc.

Referenced by analyze(), beginJob(), endJob(), and updateRun().

edm::InputTag sistrip::SpyExtractRunModule::runTag_
private

Definition at line 56 of file SiStripSpyExtractRunModule.cc.

Referenced by analyze().