CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PixelPopConCalibChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PixelPopConCalibChecker
4 // Class: PixelPopConCalibChecker
5 //
13 //
14 // Original Author: M. Eads
15 // Created: August 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <string>
22 #include <iostream>
23 
24 // user include files
34 
35 //
36 // class decleration
37 //
39 public:
41  ~PixelPopConCalibChecker() override;
42  void analyze(const edm::Event&, const edm::EventSetup&) override;
43 
44 private:
45  // ----------member data ---------------------------
48  const int _messageLevel;
49 };
50 
51 using namespace std;
52 
53 //
54 // constructors and destructor
55 //
57  : gainCalibToken_(esConsumes()),
58  _filename(iConfig.getParameter<string>("filename")),
59  _messageLevel(iConfig.getUntrackedParameter("messageLevel", 0)) {
60  if (_messageLevel > 0)
61  edm::LogPrint("PixelPopConCalibChecker") << "********* PixelPopConCalibChecker ************" << endl;
62 }
63 
65 
66 //
67 // member functions
68 //
69 
70 // ------------ method called to for each event ------------
72  using namespace edm;
73 
74  bool isSame = true;
75 
76  // get the run and event number from the EmptyIOVSource
77  if (_messageLevel > 0) {
78  EventID eventID = iEvent.id();
79  edm::LogPrint("PixelPopConCalibChecker") << "Comparing SiPixelCalibConfiguration object from database for run "
80  << eventID.run() << " to calib.dat file at " << _filename << endl;
81  } // if (_messageLevel > 0)
82 
83  // get the calib config object in the database from the event setup
84  const SiPixelCalibConfiguration* calibES = &iSetup.getData(gainCalibToken_);
85 
86  // get the calib config object from the calib.dat file
88  SiPixelCalibConfiguration* calibFile = new SiPixelCalibConfiguration(fancyCalib);
89 
90  // check if mode matches
91  string modeES = calibES->getCalibrationMode();
92  string modeFile = calibFile->getCalibrationMode();
93  if (_messageLevel > 1) {
94  edm::LogPrint("PixelPopConCalibChecker") << "*** Checking calibration mode ***" << endl;
95  edm::LogPrint("PixelPopConCalibChecker") << " mode from DB: " << modeES << endl;
96  edm::LogPrint("PixelPopConCalibChecker") << " mode from file: " << modeFile << endl;
97  }
98  if (modeES != modeFile) {
99  isSame = false;
100  if (_messageLevel > 0) {
101  edm::LogPrint("PixelPopConCalibChecker") << "Mismatch in calibration mode!" << endl;
102  edm::LogPrint("PixelPopConCalibChecker") << " " << modeES << " in database, " << modeFile << " in file" << endl;
103  }
104  }
105 
106  // check if the number of triggers matches
107  short ntriggerES = calibES->getNTriggers();
108  short ntriggerFile = calibFile->getNTriggers();
109  if (_messageLevel > 1) {
110  edm::LogPrint("PixelPopConCalibChecker") << "*** Checking number of triggers ***" << endl;
111  edm::LogPrint("PixelPopConCalibChecker") << " NTriggers from DB: " << ntriggerES << endl;
112  edm::LogPrint("PixelPopConCalibChecker") << " NTriggers from file: " << ntriggerFile << endl;
113  }
114  if (ntriggerES != ntriggerFile) {
115  isSame = false;
116  if (_messageLevel > 0) {
117  edm::LogPrint("PixelPopConCalibChecker") << "Mismatch in number of triggers!" << endl;
118  edm::LogPrint("PixelPopConCalibChecker")
119  << " " << ntriggerES << " in database, " << ntriggerFile << " in file" << endl;
120  }
121  }
122 
123  // check if vcal values match
124  vector<short> vcalES = calibES->getVCalValues();
125  vector<short> vcalFile = calibFile->getVCalValues();
126  if (_messageLevel > 1) {
127  edm::LogPrint("PixelPopConCalibChecker") << "*** Checking vcal values ***" << endl;
128  edm::LogPrint("PixelPopConCalibChecker") << " vcal values from DB: ";
129  for (vector<short>::const_iterator it = vcalES.begin(); it != vcalES.end(); ++it)
130  edm::LogPrint("PixelPopConCalibChecker") << *it << ", ";
131  edm::LogPrint("PixelPopConCalibChecker") << endl;
132  edm::LogPrint("PixelPopConCalibChecker") << " vcal values from file: ";
133  for (vector<short>::const_iterator it = vcalFile.begin(); it != vcalFile.end(); ++it)
134  edm::LogPrint("PixelPopConCalibChecker") << *it << ", ";
135  edm::LogPrint("PixelPopConCalibChecker") << endl;
136  }
137  if (vcalES != vcalFile) {
138  isSame = false;
139  if (_messageLevel > 0) {
140  edm::LogPrint("PixelPopConCalibChecker") << "Mismatch in vcal values!" << endl;
141  }
142  }
143 
144  // check if column values match
145  vector<short> colES = calibES->getColumnPattern();
146  vector<short> colFile = calibFile->getColumnPattern();
147  if (_messageLevel > 1) {
148  edm::LogPrint("PixelPopConCalibChecker") << "*** Checking column pattern values ***" << endl;
149  edm::LogPrint("PixelPopConCalibChecker") << " column pattern from DB: ";
150  for (vector<short>::const_iterator it = colES.begin(); it != colES.end(); ++it)
151  edm::LogPrint("PixelPopConCalibChecker") << *it << ", ";
152  edm::LogPrint("PixelPopConCalibChecker") << endl;
153  edm::LogPrint("PixelPopConCalibChecker") << " column pattern from file: ";
154  for (vector<short>::const_iterator it = colFile.begin(); it != colFile.end(); ++it)
155  edm::LogPrint("PixelPopConCalibChecker") << *it << ", ";
156  edm::LogPrint("PixelPopConCalibChecker") << endl;
157  }
158  if (colES != colFile) {
159  isSame = false;
160  if (_messageLevel > 0) {
161  edm::LogPrint("PixelPopConCalibChecker") << "Mismatch in column pattern!" << endl;
162  }
163  }
164 
165  // check if row values match
166  vector<short> rowES = calibES->getRowPattern();
167  vector<short> rowFile = calibFile->getRowPattern();
168  if (_messageLevel > 1) {
169  edm::LogPrint("PixelPopConCalibChecker") << "*** Checking row pattern values ***" << endl;
170  edm::LogPrint("PixelPopConCalibChecker") << " row pattern from DB: ";
171  for (vector<short>::const_iterator it = rowES.begin(); it != rowES.end(); ++it)
172  edm::LogPrint("PixelPopConCalibChecker") << *it << ", ";
173  edm::LogPrint("PixelPopConCalibChecker") << endl;
174  edm::LogPrint("PixelPopConCalibChecker") << " row pattern from file: ";
175  for (vector<short>::const_iterator it = rowFile.begin(); it != rowFile.end(); ++it)
176  edm::LogPrint("PixelPopConCalibChecker") << *it << ", ";
177  edm::LogPrint("PixelPopConCalibChecker") << endl;
178  }
179  if (rowES != rowFile) {
180  isSame = false;
181  if (_messageLevel > 0) {
182  edm::LogPrint("PixelPopConCalibChecker") << "Mismatch in row pattern!" << endl;
183  }
184  }
185 
186  edm::LogPrint("PixelPopConCalibChecker") << endl;
187  if (isSame) {
188  edm::LogPrint("PixelPopConCalibChecker")
189  << "*** Calibration configuration in database and file match. Go forth and calibrate." << endl;
190  } else {
191  edm::LogPrint("PixelPopConCalibChecker")
192  << "*** WARNING! Calibration configuration is database and file DO NOT match!" << endl;
193  }
194 
195 } // PixelPopConCalibChecker::analyze()
196 
197 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:38
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool getData(T &iHolder) const
Definition: EventSetup.h:122
int iEvent
Definition: GenABIO.cc:224
This class implements the steps that are used in a scan over Threshold and CalDelay.
Log< level::Warning, true > LogPrint
~PixelPopConCalibChecker() override
PixelPopConCalibChecker(const edm::ParameterSet &)
edm::EventID id() const
Definition: EventBase.h:59
const edm::ESGetToken< SiPixelCalibConfiguration, SiPixelCalibConfigurationRcd > gainCalibToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void analyze(const edm::Event &, const edm::EventSetup &) override
This class implements the steps that are used in a scan over Threshold and CalDelay.