Main Page
Namespaces
Classes
Package Documentation
DQM
SiStripMonitorHardware
src
SiStripSpyExtractRunModule.cc
Go to the documentation of this file.
1
// Original Author: Anne-Marie Magnan
2
// Created: 2010/02/25
3
//
4
5
#include <sstream>
6
#include <fstream>
7
#include <iostream>
8
#include <memory>
9
#include <list>
10
#include <algorithm>
11
#include <cassert>
12
13
#include "
FWCore/Utilities/interface/EDGetToken.h
"
14
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
15
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
16
#include "
FWCore/Framework/interface/Event.h
"
17
#include "
FWCore/Framework/interface/EventSetup.h
"
18
#include "
FWCore/Framework/interface/ESHandle.h
"
19
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
20
#include "
FWCore/Utilities/interface/InputTag.h
"
21
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
22
#include "
FWCore/ServiceRegistry/interface/Service.h
"
23
#include "
FWCore/Utilities/interface/Exception.h
"
24
25
#include "
DataFormats/FEDRawData/interface/FEDNumbering.h
"
26
#include "
DataFormats/SiStripCommon/interface/ConstantsForHardwareSystems.h
"
27
28
#include "
DQM/SiStripMonitorHardware/interface/SiStripFEDSpyBuffer.h
"
29
30
//
31
// Class declaration
32
//
33
namespace
sistrip
{
34
35
class
SpyExtractRunModule
:
public
edm::EDAnalyzer
36
{
37
public
:
38
39
explicit
SpyExtractRunModule
(
const
edm::ParameterSet
&);
40
~SpyExtractRunModule
()
override
;
41
42
private
:
43
44
void
beginJob
()
override
;
45
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
46
void
endJob
()
override
;
47
48
//check when the current run changes
49
const
bool
updateRun
(
const
uint32_t aRun);
50
51
//name of the output file containing the run number
52
//get it from the input file
53
std::string
fileName_
;
54
55
//tag of spydata run number collection
56
edm::InputTag
runTag_
;
57
edm::EDGetTokenT<uint32_t>
runToken_
;
58
59
//cache of the current and previous run number
60
uint32_t
currentRun_
;
61
uint32_t
previousRun_
;
62
63
//error counter for number of times the run number changes
64
uint32_t
errCounter_
;
65
66
};
67
}
//namespace
68
69
using
edm::LogError
;
70
using
edm::LogWarning
;
71
using
edm::LogInfo
;
72
//
73
// Constructors and destructor
74
//
75
namespace
sistrip
{
76
77
SpyExtractRunModule::SpyExtractRunModule
(
const
edm::ParameterSet
& iConfig)
78
:
fileName_
(iConfig.getParameter<
std
::
string
>(
"OutputTextFile"
)),
79
runTag_
(iConfig.getParameter<
edm
::InputTag>(
"RunNumberTag"
)),
80
currentRun_
(0),
81
previousRun_
(0),
82
errCounter_
(0)
83
{
84
runToken_
= consumes<uint32_t>(
runTag_
);
85
}
86
87
88
SpyExtractRunModule::~SpyExtractRunModule
() {
89
90
}
91
92
void
SpyExtractRunModule::beginJob
()
93
{
94
currentRun_
= 0;
95
previousRun_
= 0;
96
errCounter_
= 0;
97
98
}
99
100
void
SpyExtractRunModule::analyze
(
const
edm::Event
& aEvt,
const
edm::EventSetup
& aSetup)
101
{
102
103
static
bool
lFirstEvent =
true
;
104
edm::Handle<uint32_t>
lRun;
105
aEvt.
getByToken
(
runToken_
, lRun );
106
107
const
bool
isUpdated =
updateRun
(*lRun);
108
109
if
(isUpdated && !lFirstEvent){
110
edm::LogError
(
"SpyExtractRunModule"
) <<
" -- Run number changed for event : "
<< aEvt.
id
().
event
()
111
<<
" (id().run() = "
<< aEvt.
id
().
run
()
112
<<
") from "
<<
previousRun_
<<
" to "
<<
currentRun_
113
<< std::endl;
114
}
115
116
117
lFirstEvent =
false
;
118
119
}
120
121
122
void
SpyExtractRunModule::endJob
() {
123
124
//save global run number in text file in local directory
125
//output loginfo with number of errors
126
//or throw exception ?
127
128
129
if
(
errCounter_
== 1){
130
edm::LogInfo
(
"SiStripSpyExtractRun"
) <<
" -- Writting run number "
<<
currentRun_
131
<<
" into file "
<<
fileName_
132
<< std::endl;
133
std::ofstream lOutFile;
134
lOutFile.open(
fileName_
.c_str(),
std::ios::out
);
135
if
(!lOutFile.is_open()) {
136
edm::LogError
(
"SiStripSpyExtractRun"
) <<
" -- Cannot open file : "
<<
fileName_
<<
" for writting run number "
137
<<
currentRun_
138
<< std::endl;
139
}
140
else
{
141
lOutFile <<
currentRun_
<< std::endl;
142
lOutFile.close();
143
}
144
145
}
146
else
{
147
edm::LogError
(
"SiStripSpyExtractRun"
) <<
" -- Number of times the run number changed in this job = "
<<
errCounter_
148
<<
", currentRun = "
<<
currentRun_
149
<<
", previousRun = "
<<
previousRun_
150
<< std::endl;
151
}
152
153
154
}
155
156
const
bool
SpyExtractRunModule::updateRun
(
const
uint32_t aRun) {
157
if
(aRun !=
currentRun_
){
158
previousRun_
=
currentRun_
;
159
currentRun_
= aRun;
160
errCounter_
++;
161
return
true
;
162
}
163
return
false
;
164
165
}
166
167
}
//namespace
168
169
#include "
FWCore/Framework/interface/MakerMacros.h
"
170
typedef
sistrip::SpyExtractRunModule
SiStripSpyExtractRunModule
;
171
DEFINE_FWK_MODULE
(
SiStripSpyExtractRunModule
);
edm::EventID::run
RunNumber_t run() const
Definition:
EventID.h:39
sistrip::SpyExtractRunModule::runTag_
edm::InputTag runTag_
Definition:
SiStripSpyExtractRunModule.cc:56
edm::EventID::event
EventNumber_t event() const
Definition:
EventID.h:41
MessageLogger.h
EDGetToken.h
sistrip::SpyExtractRunModule::errCounter_
uint32_t errCounter_
Definition:
SiStripSpyExtractRunModule.cc:64
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:508
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:255
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
sistrip::SpyExtractRunModule::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
SiStripSpyExtractRunModule.cc:100
Event.h
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:47
EventSetup.h
edm::LogWarning
Definition:
MessageLogger.h:142
std
Definition:
JetResolutionObject.h:76
sistrip::SpyExtractRunModule::runToken_
edm::EDGetTokenT< uint32_t > runToken_
Definition:
SiStripSpyExtractRunModule.cc:57
edm::EDGetTokenT< uint32_t >
Frameworkfwd.h
sistrip
sistrip classes
Definition:
EnsembleCalibrationLA.cc:12
ParameterSet.h
edm::LogError
Definition:
MessageLogger.h:166
SiStripFEDSpyBuffer.h
sistrip::SpyExtractRunModule::fileName_
std::string fileName_
Definition:
SiStripSpyExtractRunModule.cc:53
ESHandle.h
Service.h
edm::EventSetup
Definition:
EventSetup.h:44
sistrip::SpyExtractRunModule::updateRun
const bool updateRun(const uint32_t aRun)
Definition:
SiStripSpyExtractRunModule.cc:156
sistrip::SpyExtractRunModule::previousRun_
uint32_t previousRun_
Definition:
SiStripSpyExtractRunModule.cc:61
edm::EDAnalyzer
Definition:
EDAnalyzer.h:27
EDAnalyzer.h
edm::LogInfo
Definition:
MessageLogger.h:216
Exception.h
MillePedeFileConverter_cfg.out
out
Definition:
MillePedeFileConverter_cfg.py:31
SiStripSpyExtractRunModule
sistrip::SpyExtractRunModule SiStripSpyExtractRunModule
Definition:
SiStripSpyExtractRunModule.cc:170
sistrip::SpyExtractRunModule::endJob
void endJob() override
Definition:
SiStripSpyExtractRunModule.cc:122
ConstantsForHardwareSystems.h
Constants and enumerated types for FED/FEC systems.
sistrip::SpyExtractRunModule
Definition:
SiStripSpyExtractRunModule.cc:35
edm::EventBase::id
edm::EventID id() const
Definition:
EventBase.h:60
sistrip::SpyExtractRunModule::currentRun_
uint32_t currentRun_
Definition:
SiStripSpyExtractRunModule.cc:60
edm
HLT enums.
Definition:
AlignableModifier.h:17
sistrip::SpyExtractRunModule::~SpyExtractRunModule
~SpyExtractRunModule() override
Definition:
SiStripSpyExtractRunModule.cc:88
edm::InputTag
Definition:
InputTag.h:15
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:36
edm::Event
Definition:
Event.h:69
sistrip::SpyExtractRunModule::beginJob
void beginJob() override
Definition:
SiStripSpyExtractRunModule.cc:92
sistrip::SpyExtractRunModule::SpyExtractRunModule
SpyExtractRunModule(const edm::ParameterSet &)
Definition:
SiStripSpyExtractRunModule.cc:77
FEDNumbering.h
Generated for CMSSW Reference Manual by
1.8.11