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 edm::EDConsumerBase

Public Member Functions

 SpyExtractRunModule (const edm::ParameterSet &)
 
 ~SpyExtractRunModule ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 
const bool updateRun (const uint32_t aRun)
 

Private Attributes

uint32_t currentRun_
 
uint32_t errCounter_
 
std::string fileName_
 
uint32_t previousRun_
 
edm::InputTag runTag_
 
edm::EDGetTokenT< uint32_t > runToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 35 of file SiStripSpyExtractRunModule.cc.

Constructor & Destructor Documentation

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

Definition at line 77 of file SiStripSpyExtractRunModule.cc.

References runTag_, and runToken_.

sistrip::SpyExtractRunModule::~SpyExtractRunModule ( )

Definition at line 88 of file SiStripSpyExtractRunModule.cc.

88  {
89 
90  }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 100 of file SiStripSpyExtractRunModule.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file SiStripSpyExtractRunModule.cc.

References currentRun_, errCounter_, and previousRun_.

void sistrip::SpyExtractRunModule::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 123 of file SiStripSpyExtractRunModule.cc.

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

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

Definition at line 157 of file SiStripSpyExtractRunModule.cc.

References currentRun_, errCounter_, and previousRun_.

Referenced by analyze().

157  {
158  if (aRun != currentRun_){
160  currentRun_ = aRun;
161  errCounter_++;
162  return true;
163  }
164  return false;
165 
166  }

Member Data Documentation

uint32_t sistrip::SpyExtractRunModule::currentRun_
private

Definition at line 60 of file SiStripSpyExtractRunModule.cc.

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

uint32_t sistrip::SpyExtractRunModule::errCounter_
private

Definition at line 64 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 61 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 SpyExtractRunModule().

edm::EDGetTokenT<uint32_t> sistrip::SpyExtractRunModule::runToken_
private

Definition at line 57 of file SiStripSpyExtractRunModule.cc.

Referenced by analyze(), and SpyExtractRunModule().