CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCaloLayer1Validator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TCaloLayer1
4 // Class: L1TCaloLayer1Validator
5 //
14 //
15 // Original Author: Sridhara Dasu
16 // Created: Sun, 11 Oct 2015 08:14:01 GMT
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
34 using namespace l1t;
35 
36 //
37 // class declaration
38 //
39 
41  public:
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 
48  private:
49  virtual void beginJob() override;
50  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
51  virtual void endJob() override;
52 
53  //virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
54  //virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
55  //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
56  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
57 
58  // ----------member data ---------------------------
59 
64 
65  uint32_t eventCount;
66  uint32_t badEventCount;
67  uint32_t towerCount;
68  uint32_t badTowerCount;
71 
72  bool verbose;
73 
74 };
75 
76 //
77 // constants, enums and typedefs
78 //
79 
80 //
81 // static data member definitions
82 //
83 
84 //
85 // constructors and destructor
86 //
88  testSource(consumes<CaloTowerBxCollection>(iConfig.getParameter<edm::InputTag>("testSource"))),
89  emulSource(consumes<CaloTowerBxCollection>(iConfig.getParameter<edm::InputTag>("emulSource"))),
90  eventCount(0),
91  badEventCount(0),
92  towerCount(0),
93  badTowerCount(0),
94  nonZeroTowerCount(0),
95  badNonZeroTowerCount(0),
96  verbose(iConfig.getParameter<bool>("verbose")) {}
97 
99 
100 //
101 // member functions
102 //
103 
104 // ------------ method called for each event ------------
105 void
107 {
108  using namespace edm;
109  bool badEvent = false;
111  iEvent.getByToken(testSource, testTowers);
113  iEvent.getByToken(emulSource, emulTowers);
114  int theBX = 0;
115  for(std::vector<CaloTower>::const_iterator testTower = testTowers->begin(theBX);
116  testTower != testTowers->end(theBX);
117  ++testTower) {
118  for(std::vector<CaloTower>::const_iterator emulTower = emulTowers->begin(theBX);
119  emulTower != emulTowers->end(theBX);
120  ++emulTower) {
121  int test_iEta = testTower->hwEta();
122  int test_iPhi = testTower->hwPhi();
123  int test_et = testTower->hwPt();
124  int test_er = testTower->hwEtRatio();
125  int test_fb = testTower->hwQual();
126  int emul_iEta = emulTower->hwEta();
127  int emul_iPhi = emulTower->hwPhi();
128  int emul_et = emulTower->hwPt();
129  int emul_er = emulTower->hwEtRatio();
130  int emul_fb = emulTower->hwQual();
131  bool success = true;
132  if(test_iEta == emul_iEta && test_iPhi == emul_iPhi) {
133  if(test_et != emul_et) {success = false;}
134  if(test_er != emul_er) {success = false;}
135  if(test_fb != emul_fb) {success = false;}
136  if(!success) {
137  if(test_et != emul_et) {if(verbose) std::cout << "ET ";}
138  if(test_er != emul_er) {if(verbose) std::cout << "ER ";}
139  if(test_fb != emul_fb) {if(verbose) std::cout << "FB ";}
140  if(verbose) std::cout << "Checks failed for ("
141  << test_iEta << ", "
142  << test_iPhi << ") : ("
143  << test_et << ", "
144  << test_er << ", "
145  << test_fb << ") != ("
146  << emul_et << ", "
147  << emul_er << ", "
148  << emul_fb << ")" << std::endl;
149  badEvent = true;
150  badTowerCount++;
151  if(test_et > 0) badNonZeroTowerCount++;
152  }
153  towerCount++;
154  if(test_et > 0) nonZeroTowerCount++;
155  }
156  if(!success && test_et == emul_et && test_iPhi == emul_iPhi) {
157  if(verbose) std::cout << "Incidental match for ("
158  << test_iEta << ", "
159  << test_iPhi << ") : ("
160  << test_et << ", "
161  << test_er << ", "
162  << test_fb << ") != ("
163  << emul_iEta <<","
164  << emul_iPhi<<") :("
165  << emul_et << ", "
166  << emul_er << ", "
167  << emul_fb << ")" << std::endl;
168  }
169  }
170  }
171  if(badEvent) badEventCount++;
172  eventCount++;
173 }
174 
175 // ------------ method called once each job just before starting event loop ------------
176 void
178 {
179 }
180 
181 // ------------ method called once each job just after ending the event loop ------------
182 void
184 {
185  std::cout << "L1TCaloLayer1Vaidator: Summary is Non-Zero Bad Tower / Bad Tower / Event Count = ("
186  << badNonZeroTowerCount << " of " << nonZeroTowerCount << ") / ("
187  << badTowerCount << " of " << towerCount << ") / ("
188  << badEventCount << " of " << eventCount << ")" << std::endl;
189 }
190 
191 // ------------ method called when starting to processes a run ------------
192 /*
193 void
194 L1TCaloLayer1Validator::beginRun(edm::Run const&, edm::EventSetup const&)
195 {
196 }
197 */
198 
199 // ------------ method called when ending the processing of a run ------------
200 /*
201 void
202 L1TCaloLayer1Validator::endRun(edm::Run const&, edm::EventSetup const&)
203 {
204 }
205 */
206 
207 // ------------ method called when starting to processes a luminosity block ------------
208 /*
209 void
210 L1TCaloLayer1Validator::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
211 {
212 }
213 */
214 
215 // ------------ method called when ending the processing of a luminosity block ------------
216 /*
217 void
218 L1TCaloLayer1Validator::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
219 {
220 }
221 */
222 
223 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
224 void
226  //The following says we do not know what parameters are allowed so do no validation
227  // Please change this to state exactly what you do use, even if it is no parameters
229  desc.setUnknown();
230  descriptions.addDefault(desc);
231 }
232 
233 //define this as a plug-in
virtual void beginJob() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:15
edm::EDGetTokenT< CaloTowerBxCollection > emulSource
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
L1TCaloLayer1Validator(const edm::ParameterSet &)
virtual void endJob() override
edm::EDGetTokenT< CaloTowerBxCollection > testSource
tuple cout
Definition: gather_cfg.py:145