CMS 3D CMS Logo

L1CaloInputScaleTester.cc
Go to the documentation of this file.
2 
3 // system include files
4 #include <memory>
5 #include <iostream>
6 using std::cout;
7 using std::endl;
8 #include <iomanip>
9 using std::setprecision;
10 
11 // user include files
13 
17 
19 
28 
29 //
30 // constants, enums and typedefs
31 //
32 
33 //
34 // static data member definitions
35 //
36 
37 //
38 // constructors and destructor
39 //
41 
42 {
43  //now do what ever initialization is needed
44 }
45 
47  // do anything here that needs to be done at destruction time
48  // (e.g. close files, deallocate resources etc.)
49 }
50 
51 //
52 // member functions
53 //
54 
55 // ------------ method called to for each event ------------
57  using namespace edm;
58 
59 #ifdef THIS_IS_AN_EVENT_EXAMPLE
61  iEvent.getByLabel("example", pIn);
62 #endif
63 
64 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
65  ESHandle<SetupData> pSetup;
66  iSetup.get<SetupRecord>().get(pSetup);
67 #endif
68 
69  ESHandle<L1CaloEcalScale> caloEcalScale;
70  ESHandle<L1CaloHcalScale> caloHcalScale;
71  ESHandle<CaloTPGTranscoder> caloTPGTranscoder;
72  iSetup.get<L1CaloEcalScaleRcd>().get(caloEcalScale);
73  iSetup.get<L1CaloHcalScaleRcd>().get(caloHcalScale);
74  iSetup.get<CaloTPGRecord>().get(caloTPGTranscoder);
75 
76  EcalTPGScale* ecalTPGScale = new EcalTPGScale();
77  ecalTPGScale->setEventSetup(iSetup);
78 
79  bool ecalIsConsistent = true;
80  bool hcalIsConsistent = true;
81 
82  double ecal1;
83  double ecal2;
84  double hcal1;
85  double hcal2;
86  double hcal3;
87  double hcal4;
88 
89  // compare the ecal scales
90 
91  // 8 bits of input energy
92  for (unsigned short input = 0; input <= 0xFF; input++) {
93  // loop over ietas, barrel first
94  for (unsigned short absIeta = 1; absIeta <= 17; absIeta++) {
95  // positive eta
96  ecal1 = ecalTPGScale->getTPGInGeV((unsigned int)input, EcalTrigTowerDetId(1, EcalBarrel, absIeta, 1));
97  ecal2 = caloEcalScale->et(input, absIeta, 1);
98 
99  if (!(ecal1 == ecal2)) {
100  ecalIsConsistent = false;
101  /*LogWarning("InconsistentData")
102  << "ECAL scales not consistent! (pos eta barrel)"
103  << "old ECAL is " << setprecision (8) << ecal1
104  << " new ECAL is " << setprecision (8) << ecal2
105  << " difference is " << (ecal1 - ecal2) ; */
106  }
107 
108  // negative eta
109  ecal1 = ecalTPGScale->getTPGInGeV((unsigned int)input, EcalTrigTowerDetId(-1, EcalBarrel, absIeta, 2));
110  ecal2 = caloEcalScale->et(input, absIeta, -1);
111 
112  if (!(ecal1 == ecal2)) {
113  ecalIsConsistent = false;
114  /*LogWarning("InconsistentData")
115  << "ECAL scales not consistent! (neg eta barrel)"
116  << "old ECAL is " << setprecision (8) << ecal1
117  << " new ECAL is " << setprecision (8) << ecal2
118  << " difference is " << (ecal1 - ecal2) ; */
119  }
120  }
121  // now loop over endcap ietas
122  for (unsigned short absIeta = 18; absIeta <= 28; absIeta++) {
123  // positive eta
124  ecal1 = ecalTPGScale->getTPGInGeV((unsigned int)input, EcalTrigTowerDetId(1, EcalEndcap, absIeta, 1));
125  ecal2 = caloEcalScale->et(input, absIeta, 1);
126 
127  if (!(ecal1 == ecal2)) {
128  ecalIsConsistent = false;
129  /*LogWarning("InconsistentData")
130  << "ECAL scales not consistent! (pos eta endcap)"
131  << "old ECAL is " << setprecision (8) << ecal1
132  << " new ECAL is " << setprecision (8) << ecal2
133  << " difference is " << (ecal1 - ecal2) ; */
134  }
135 
136  // negative eta
137  ecal1 = ecalTPGScale->getTPGInGeV((unsigned int)input, EcalTrigTowerDetId(-1, EcalEndcap, absIeta, 2));
138  ecal2 = caloEcalScale->et(input, absIeta, -1);
139 
140  if (!(ecal1 == ecal2)) {
141  ecalIsConsistent = false;
142  /*LogWarning("InconsistentData")
143  << "ECAL scales not consistent! (neg eta endcap)"
144  << "old ECAL is " << setprecision (8) << ecal1
145  << " new ECAL is " << setprecision (8) << ecal2
146  << " difference is " << (ecal1 - ecal2) ; */
147  }
148  }
149  }
150 
151  if (!ecalIsConsistent) {
152  // do something
153  //cout << "WARNING: ECAL scales not consistent!" << endl;
154  LogWarning("InconsistentData") << "ECAL scales not consistent!";
155  } else {
156  // do something else
157  //cout << "ECAL scales okay" << endl;
158  }
159 
160  // compare the hcal scales
161 
162  for (unsigned short input = 0; input <= 0xFF; input++) {
163  // loop over ietas
164  for (unsigned short absIeta = 1; absIeta <= 32; absIeta++) {
165  hcal1 = caloTPGTranscoder->hcaletValue(absIeta, input); // no eta-
166  hcal2 = caloHcalScale->et(input, absIeta, 1); // sign in transcoder
167  hcal3 = caloTPGTranscoder->hcaletValue(-absIeta, input); // no eta-
168  hcal4 = caloHcalScale->et(input, absIeta, -1); // sign in transcoder
169 
170  if ((!(hcal1 == hcal2)) || (!(hcal3 == hcal4))) {
171  hcalIsConsistent = false;
172  /*LogWarning("InconsistentData")
173  << "HCAL scales not consistent!"
174  << "old HCAL is " << hcal1
175  << " new HCAL is " << hcal2 ; */
176  }
177  }
178  }
179  if (!hcalIsConsistent) {
180  // do something
181  //cout << "WARNING: HCAL scales not consistent!" << endl;
182  LogWarning("InconsistentData") << "HCAL scales not consistent!";
183  } else {
184  // do something else
185  //cout << "HCAL scales okay" << endl;
186  }
187 }
188 
189 // ------------ method called once each job just before starting event loop ------------
191 
192 // ------------ method called once each job just after ending the event loop ------------
L1CaloInputScaleTester(const edm::ParameterSet &)
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:16
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:18
double et(unsigned short rank, unsigned short eta, short etaSign) const
convert from rank to physically meaningful quantity
static std::string const input
Definition: EdmProvDump.cc:48
int iEvent
Definition: GenABIO.cc:224
double et(unsigned short rank, unsigned short eta, short etaSign) const
convert from rank to physically meaningful quantity
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
HLT enums.
T get() const
Definition: EventSetup.h:73
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
void analyze(const edm::Event &, const edm::EventSetup &) override