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 ------------
EcalTPGScale::getTPGInGeV
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:18
input
static const std::string input
Definition: EdmProvDump.cc:48
EcalTPGScale
Definition: EcalTPGScale.h:8
MessageLogger.h
ESHandle.h
L1CaloEcalScaleRcd
Definition: L1CaloEcalScaleRcd.h:12
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1CaloHcalScale::et
double et(unsigned short rank, unsigned short eta, short etaSign) const
convert from rank to physically meaningful quantity
Definition: L1CaloHcalScale.cc:64
L1CaloEcalScale::et
double et(unsigned short rank, unsigned short eta, short etaSign) const
convert from rank to physically meaningful quantity
Definition: L1CaloEcalScale.cc:64
EcalTPGScale::setEventSetup
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:16
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
CaloTPGTranscoder.h
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
L1CaloHcalScale.h
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ESHandle
Definition: DTSurvey.h:22
EcalTrigTowerDetId.h
EcalEndcap
Definition: EcalSubdetector.h:10
L1CaloInputScaleTester::beginJob
void beginJob() override
Definition: L1CaloInputScaleTester.cc:190
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
L1CaloInputScaleTester::endJob
void endJob() override
Definition: L1CaloInputScaleTester.cc:193
CaloTPGRecord
Definition: CaloTPGRecord.h:26
L1CaloInputScaleTester::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1CaloInputScaleTester.cc:56
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
CaloTPGRecord.h
get
#define get
L1CaloInputScaleTester.h
L1CaloEcalScaleRcd.h
L1CaloHcalScaleRcd.h
L1CaloInputScaleTester::~L1CaloInputScaleTester
~L1CaloInputScaleTester() override
Definition: L1CaloInputScaleTester.cc:46
L1CaloEcalScale.h
Frameworkfwd.h
EventSetup.h
CaloTPGTranscoder::hcaletValue
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
edm::Event
Definition: Event.h:73
EcalTPGScale.h
L1CaloHcalScaleRcd
Definition: L1CaloHcalScaleRcd.h:13
L1CaloInputScaleTester::L1CaloInputScaleTester
L1CaloInputScaleTester(const edm::ParameterSet &)
Definition: L1CaloInputScaleTester.cc:40