CMS 3D CMS Logo

L1TCaloParamsViewer.cc
Go to the documentation of this file.
5 
8 
12 #include <iomanip>
13 
15 private:
22 
23  std::string hash(void *buf, size_t len) const ;
24 
25 public:
26  virtual void analyze(const edm::Event&, const edm::EventSetup&);
27 
29  printPUSParams = pset.getUntrackedParameter<bool>("printPUSParams", false);
30  printTauCalibLUT = pset.getUntrackedParameter<bool>("printTauCalibLUT",false);
31  printJetCalibLUT = pset.getUntrackedParameter<bool>("printJetCalibLUT",false);
32  printJetCalibPar = pset.getUntrackedParameter<bool>("printJetCalibParams",false);
33  printEgCalibLUT = pset.getUntrackedParameter<bool>("printEgCalibLUT", false);
34  printEgIsoLUT = pset.getUntrackedParameter<bool>("printEgIsoLUT", false);
35  }
36 
37  virtual ~L1TCaloParamsViewer(void){}
38 };
39 
40 #include <openssl/sha.h>
41 #include <math.h>
42 #include <iostream>
43 using namespace std;
44 
45 std::string L1TCaloParamsViewer::hash(void *buf, size_t len) const {
46  char tmp[SHA_DIGEST_LENGTH*2+1];
47  bzero(tmp,sizeof(tmp));
48  SHA_CTX ctx;
49  if( !SHA1_Init( &ctx ) )
50  throw cms::Exception("L1TCaloParamsViewer::hash")<<"SHA1 initialization error";
51 
52  if( !SHA1_Update( &ctx, buf, len ) )
53  throw cms::Exception("L1TCaloParamsViewer::hash")<<"SHA1 processing error";
54 
55  unsigned char hash[SHA_DIGEST_LENGTH];
56  if( !SHA1_Final(hash, &ctx) )
57  throw cms::Exception("L1TCaloParamsViewer::hash")<<"SHA1 finalization error";
58 
59  // re-write bytes in hex
60  for(unsigned int i=0; i<20; i++)
61  ::sprintf(&tmp[i*2], "%02x", hash[i]);
62 
63  tmp[20*2] = 0;
64  return std::string(tmp);
65 }
66 
68 
70  evSetup.get<L1TCaloParamsRcd>().get( handle1 ) ;
71  boost::shared_ptr<l1t::CaloParams> ptr(new l1t::CaloParams(*(handle1.product ())));
72 
73  l1t::CaloParamsHelper *ptr1 = 0;
74  ptr1 = (l1t::CaloParamsHelper*) (&(*ptr));
75 
76  edm::LogInfo("")<<"L1TCaloParamsViewer:";
77 
78  cout<<endl<<" Towers: "<<endl;
79  cout<<" towerLsbH= "<<ptr1->towerLsbH()<<endl;
80  cout<<" towerLsbE= "<<ptr1->towerLsbE()<<endl;
81  cout<<" towerLsbSum= "<<ptr1->towerLsbSum()<<endl;
82  cout<<" towerNBitsH= "<<ptr1->towerNBitsH()<<endl;
83  cout<<" towerNBitsE= "<<ptr1->towerNBitsE()<<endl;
84  cout<<" towerNBitsSum= "<<ptr1->towerNBitsSum()<<endl;
85  cout<<" towerNBitsRatio= "<<ptr1->towerNBitsRatio()<<endl;
86  cout<<" towerMaskE= "<<ptr1->towerMaskE()<<endl;
87  cout<<" towerMaskH= "<<ptr1->towerMaskH()<<endl;
88  cout<<" towerMaskSum= "<<ptr1->towerMaskSum()<<endl;
89  cout<<" towerEncoding= "<<ptr1->doTowerEncoding()<<endl;
90 
91  cout<<endl<<" Regions: "<<endl;
92  cout<<" regionLsb= "<<ptr1->regionLsb()<<endl;
93  cout<<" regionPUSType= "<<ptr1->regionPUSType()<<endl;
94  cout<<" regionPUSParams= ["<<ptr1->regionPUSParams().size()<<"] ";
95  float pusParams[ptr1->regionPUSParams().size()];
96 
97  for(unsigned int i=0; i<ptr1->regionPUSParams().size(); i++){
98  pusParams[i] = ceil(2*ptr1->regionPUSParams()[i]);
99  if( printPUSParams ) cout<<" "<<ceil(2*pusParams[i])<<endl;
100  }
101 
102  if( ptr1->regionPUSParams().size() )
103  cout << hash(pusParams, sizeof(float)*ptr1->regionPUSParams().size()) << endl;
104  else cout<<endl;
105 
106 
107  cout<<endl<<" EG: "<<endl;
108  cout<<" egLsb= "<<ptr1->egLsb()<<endl;
109  cout<<" egSeedThreshold= "<<ptr1->egSeedThreshold()<<endl;
110  cout<<" egNeighbourThreshold= "<<ptr1->egNeighbourThreshold()<<endl;
111  cout<<" egHcalThreshold= "<<ptr1->egHcalThreshold()<<endl;
112 
113  if( !ptr1->egTrimmingLUT()->empty() ){
114  cout<<" egTrimmingLUT= ["<<ptr1->egTrimmingLUT()->maxSize()<<"] "<<flush;
115  int egTrimming[ptr1->egTrimmingLUT()->maxSize()];
116  for(unsigned int i=0; i<ptr1->egTrimmingLUT()->maxSize(); i++) egTrimming[i] = ptr1->egTrimmingLUT()->data(i);
117  cout << hash( egTrimming, sizeof(int)*ptr1->egTrimmingLUT()->maxSize() ) << endl;
118  } else {
119  cout<<" egTrimmingLUT= [0] "<<endl;
120  }
121 
122  cout<<" egMaxHcalEt= "<<ptr1->egMaxHcalEt()<<endl;
123  cout<<" egMaxPtHOverE= "<<ptr1->egMaxPtHOverE()<<endl;
124  cout<<" egMinPtJetIsolation= "<<ptr1->egMinPtJetIsolation()<<endl;
125  cout<<" egMaxPtJetIsolation= "<<ptr1->egMaxPtJetIsolation()<<endl;
126  cout<<" egMinPtHOverEIsolation= "<<ptr1->egMinPtHOverEIsolation()<<endl;
127  cout<<" egMaxPtHOverEIsolation= "<<ptr1->egMaxPtHOverEIsolation()<<endl;
128 
129  if( !ptr1->egMaxHOverELUT()->empty() ){
130  cout<<" egMaxHOverELUT= ["<<ptr1->egMaxHOverELUT()->maxSize()<<"] ";
131  int egMaxHOverE[ptr1->egMaxHOverELUT()->maxSize()];
132  for(unsigned int i=0; i<ptr1->egMaxHOverELUT()->maxSize(); i++) egMaxHOverE[i] = ptr1->egMaxHOverELUT()->data(i);
133  cout << hash( egMaxHOverE, sizeof(int)*ptr1->egMaxHOverELUT()->maxSize() ) << endl;
134  } else {
135  cout<<" egMaxHOverELUT= [0]"<<endl;
136  }
137 
138  if( !ptr1->egCompressShapesLUT()->empty() ){
139  cout<<" egCompressShapesLUT= ["<<ptr1->egCompressShapesLUT()->maxSize()<<"] ";
140  int egCompressShapes[ptr1->egCompressShapesLUT()->maxSize()];
141  for(unsigned int i=0; i<ptr1->egCompressShapesLUT()->maxSize(); i++) egCompressShapes[i] = ptr1->egCompressShapesLUT()->data(i);
142  cout << hash( egCompressShapes, sizeof(int)*ptr1->egCompressShapesLUT()->maxSize() ) << endl;
143  } else {
144  cout<<" egCompressShapesLUT= [0]"<<endl;
145  }
146 
147  // cout<<" egShapeIdType= "<<ptr1->egShapeIdType()<<endl;
148  // cout<<" egShapeIdVersion= "<<ptr1->egShapeIdVersion()<<endl;
149  if( !ptr1->egShapeIdLUT()->empty() ){
150  cout<<" egShapeIdLUT= ["<<ptr1->egShapeIdLUT()->maxSize()<<"] "<<flush;
151  int egShapeId[ptr1->egShapeIdLUT()->maxSize()];
152  for(unsigned int i=0; i<ptr1->egShapeIdLUT()->maxSize(); i++) egShapeId[i] = ptr1->egShapeIdLUT()->data(i);
153  cout << hash( egShapeId, sizeof(int)*ptr1->egShapeIdLUT()->maxSize() )<<endl;
154  } else {
155  cout<<" egShapeIdLUT= [0]"<<endl;
156  }
157 
158  cout<<" egBypassEGVetos= "<<ptr1->egBypassEGVetos()<<endl;
159  cout<<" egHOverEcutBarrel= "<<ptr1->egHOverEcutBarrel()<<endl;
160  cout<<" egHOverEcutEndcap= "<<ptr1->egHOverEcutEndcap()<<endl;
161 
162  cout<<" egPUSType= "<<ptr1->egPUSType()<<endl;
163 
164  cout<<" egIsolationType= "<<ptr1->egIsolationType()<<endl;
165  if( !ptr1->egIsolationLUT()->empty() ){
166  cout<<" egIsoLUT= ["<<ptr1->egIsolationLUT()->maxSize()<<"] "<<flush;
167  int egIsolation[ptr1->egIsolationLUT()->maxSize()];
168  for(unsigned int i=0; i<ptr1->egIsolationLUT()->maxSize(); i++) egIsolation[i] = ptr1->egIsolationLUT()->data(i);
169  cout << hash( egIsolation, sizeof(int)*ptr1->egIsolationLUT()->maxSize() ) << endl;
170  if( printEgIsoLUT )
171  for(unsigned int i=0; i<ptr1->egIsolationLUT()->maxSize(); i++)
172  cout<<i<<" " << egIsolation[i]<<endl;
173  } else {
174  cout<<" egIsoLUT= [0]"<<endl;
175  }
176 
177  cout<<" egIsoAreaNrTowersEta= "<<ptr1->egIsoAreaNrTowersEta()<<endl;
178  cout<<" egIsoAreaNrTowersPhi= "<<ptr1->egIsoAreaNrTowersPhi()<<endl;
179  cout<<" egIsoVetoNrTowersPhi= "<<ptr1->egIsoVetoNrTowersPhi()<<endl;
180  cout<<" egPUSParams= ["<<ptr1->egPUSParams().size()<<"] "<<flush;
181  float egPUSParams[ptr1->egPUSParams().size()];
182  for(unsigned int i=0; i<ptr1->egPUSParams().size(); i++) egPUSParams[i] = ptr1->egPUSParams()[i];
183 
184  if( ptr1->egPUSParams().size() )
185  cout << hash( egPUSParams, sizeof(float)*ptr1->egPUSParams().size() ) << endl;
186  else cout<<endl;
187 
188  cout<<" egCalibrationParams= ["<<ptr1->egCalibrationParams().size()<<"] "<<flush;
189  double egCalibrationParams[ptr1->egCalibrationParams().size()];
190  for(unsigned int i=0; i<ptr1->egCalibrationParams().size(); i++) egCalibrationParams[i] = ptr1->egCalibrationParams()[i];
191 
192  if( ptr1->egCalibrationParams().size() )
193  cout << hash( egCalibrationParams, sizeof(double)*ptr1->egCalibrationParams().size() ) << endl;
194  else cout<<endl;
195 
196  cout<<" egCalibrationType= "<<ptr1->egCalibrationType()<<endl;
197  // cout<<" egCalibrationVersion= "<<ptr1->egCalibrationVersion()<<endl;
198  if( !ptr1->egCalibrationLUT()->empty() ){
199  cout<<" egCalibrationLUT= ["<<ptr1->egCalibrationLUT()->maxSize()<<"] "<<flush;
200  int egCalibration[ptr1->egCalibrationLUT()->maxSize()];
201  for(unsigned int i=0; i<ptr1->egCalibrationLUT()->maxSize(); i++) egCalibration[i] = ptr1->egCalibrationLUT()->data(i);
202  cout << hash( egCalibration, sizeof(int)*ptr1->egCalibrationLUT()->maxSize() ) << endl;
203  if( printEgCalibLUT )
204  for(unsigned int i=0; i<ptr1->egCalibrationLUT()->maxSize(); i++)
205  cout<<i<<" " << egCalibration[i]<<endl;
206  } else {
207  cout<<" egCalibrationLUT= [0]"<<endl;
208  }
209 
210  cout<<endl<<" Tau: "<<endl;
211  cout<<" tauLsb= "<<ptr1->tauLsb()<<endl;
212  cout<<" tauSeedThreshold= "<<ptr1->tauSeedThreshold()<<endl;
213  cout<<" tauNeighbourThreshold= "<<ptr1->tauNeighbourThreshold()<<endl;
214  cout<<" tauMaxPtTauVeto= "<<ptr1->tauMaxPtTauVeto()<<endl;
215  cout<<" tauMinPtJetIsolationB= "<<ptr1->tauMinPtJetIsolationB()<<endl;
216  cout<<" tauPUSType= "<<ptr1->tauPUSType()<<endl;
217  cout<<" tauMaxJetIsolationB= "<<ptr1->tauMaxJetIsolationB()<<endl;
218  cout<<" tauMaxJetIsolationA= "<<ptr1->tauMaxJetIsolationA()<<endl;
219  cout<<" tauIsoAreaNrTowersEta= "<<ptr1->tauIsoAreaNrTowersEta()<<endl;
220  cout<<" tauIsoAreaNrTowersPhi= "<<ptr1->tauIsoAreaNrTowersPhi()<<endl;
221  cout<<" tauIsoVetoNrTowersPhi= "<<ptr1->tauIsoVetoNrTowersPhi()<<endl;
222  if( !ptr1->tauIsolationLUT()->empty() ){
223  cout<<" tauIsoLUT= ["<<ptr1->tauIsolationLUT()->maxSize()<<"] "<<flush;
224  int tauIsolation[ptr1->tauIsolationLUT()->maxSize()];
225  for(unsigned int i=0; i<ptr1->tauIsolationLUT()->maxSize(); i++) tauIsolation[i] = ptr1->tauIsolationLUT()->data(i);
226  cout << hash( tauIsolation, sizeof(int)*ptr1->tauIsolationLUT()->maxSize() ) << endl;
227  } else {
228  cout<<" tauIsoLUT= [0]"<<endl;
229  }
230 
231  if( !ptr1->tauCalibrationLUT()->empty() ){
232  cout<<" tauCalibrationLUT= ["<<ptr1->tauCalibrationLUT()->maxSize()<<"] "<<flush;
233  int tauCalibration[512]; //ptr1->tauCalibrationLUT()->maxSize()];
234  for(unsigned int i=0; i<512; i++)//ptr1->tauCalibrationLUT()->maxSize(); i++)
235  tauCalibration[i] = ptr1->tauCalibrationLUT()->data(i);
236  cout << hash( tauCalibration, sizeof(int)*512/*ptr1->tauCalibrationLUT()->maxSize() */) << endl;
237 
238  if( printTauCalibLUT )
239  for(unsigned int i=0; i<512/*ptr1->tauCalibrationLUT()->maxSize()*/; i++)
240  cout<<i<<" "<<tauCalibration[i]<<endl;
241 
242  } else {
243  cout<<" tauCalibrationLUT= [0]"<<endl;
244  }
245 
246  if( !ptr1->tauEtToHFRingEtLUT()->empty() ){
247  cout<<" tauEtToHFRingEtLUT= ["<<ptr1->tauEtToHFRingEtLUT()->maxSize()<<"] "<<flush;
248  int tauEtToHFRingEt[ptr1->tauEtToHFRingEtLUT()->maxSize()];
249  for(unsigned int i=0; i<ptr1->tauEtToHFRingEtLUT()->maxSize(); i++) tauEtToHFRingEt[i] = ptr1->tauEtToHFRingEtLUT()->data(i);
250 
251  cout << hash( tauEtToHFRingEt, sizeof(int)*ptr1->tauEtToHFRingEtLUT()->maxSize() ) << endl;
252  } else {
253  cout<<" tauEtToHFRingEtLUT= [0]"<<endl;
254  }
255 
256  cout<<" isoTauEtaMin= "<<ptr1->isoTauEtaMin()<<endl;
257  cout<<" isoTauEtaMax= "<<ptr1->isoTauEtaMax()<<endl;
258  cout<<" tauPUSParams= ["<<ptr1->tauPUSParams().size()<<"] "<<flush;
259  float tauPUSParams[ptr1->tauPUSParams().size()];
260  for(unsigned int i=0; i<ptr1->tauPUSParams().size(); i++) tauPUSParams[i] = ptr1->tauPUSParams()[i];
261 
262  if( ptr1->tauPUSParams().size() )
263  cout << hash( tauPUSParams, sizeof(float)*ptr1->tauPUSParams().size() ) << endl;
264  else cout<<endl;
265 
266  cout<<endl<<" Jets: "<<endl;
267  cout<<" jetLsb= "<<ptr1->jetLsb()<<endl;
268  cout<<" jetSeedThreshold= "<<ptr1->jetSeedThreshold()<<endl;
269  cout<<" jetNeighbourThreshold= "<<ptr1->jetNeighbourThreshold()<<endl;
270  cout<<" jetPUSType= "<<ptr1->jetPUSType()<<endl;
271  cout<<" jetCalibrationType= "<<ptr1->jetCalibrationType()<<endl;
272  cout<<" jetCalibrationParams= ["<<ptr1->jetCalibrationParams().size()<<"] "<<flush;
273  float jetCalibrationParams[ptr1->jetCalibrationParams().size()]; // deliberately drop double precision
274  for(unsigned int i=0; i<ptr1->jetCalibrationParams().size(); i++) jetCalibrationParams[i] = ptr1->jetCalibrationParams()[i];
275 
276  if( ptr1->jetCalibrationParams().size() ){
277  cout << hash( jetCalibrationParams, sizeof(float)*ptr1->jetCalibrationParams().size() ) << endl;
278  if( printJetCalibPar )
279  for(unsigned int i=0; i<ptr1->jetCalibrationParams().size(); i++)
280  cout<<i<<" " << std::setprecision(14) << jetCalibrationParams[i]<<endl;
281 
282  } else cout<<endl;
283 
284  if( !ptr1->jetCalibrationLUT()->empty() ){
285  cout<<" jetCalibrationLUT= ["<<ptr1->jetCalibrationLUT()->maxSize()<<"] "<<flush;
286  int jetCalibration[ptr1->jetCalibrationLUT()->maxSize()];
287  for(unsigned int i=0; i<ptr1->jetCalibrationLUT()->maxSize(); i++)
288  jetCalibration[i] = ptr1->jetCalibrationLUT()->data(i);
289 
290  cout << hash( jetCalibration, sizeof(int)*ptr1->jetCalibrationLUT()->maxSize() ) << endl;
291 
292  if( printJetCalibLUT )
293  for(unsigned int i=0; i<ptr1->jetCalibrationLUT()->maxSize(); i++)
294  cout<<i<<" "<<jetCalibration[i]<<endl;
295 
296  } else {
297  cout<<" jetCalibrationLUT= [0]"<<endl;
298  }
299 
300  cout<<endl<<" Sums: "<<endl;
301  unsigned int nEntities = 0;
302  cout<<" etSumLsb= "<<ptr1->etSumLsb()<<endl;
303  cout<<" etSumEtaMin= ["; for(unsigned int i=0; ptr1->etSumEtaMin(i)>0.001; i++) cout<<(i==0?"":",")<<ptr1->etSumEtaMin(i); cout<<"]"<<endl;
304  cout<<" etSumEtaMax= ["; for(unsigned int i=0; ptr1->etSumEtaMax(i)>0.001; i++,nEntities++) cout<<(i==0?"":",")<<ptr1->etSumEtaMax(i); cout<<"]"<<endl;
305  cout<<" etSumEtThreshold= ["; for(unsigned int i=0; i<nEntities; i++) cout<<(i==0?"":",")<<ptr1->etSumEtThreshold(i); cout<<"]"<<endl;
306 
307  cout<<endl<<" HI centrality trigger: "<<endl;
308  cout<<" centralityLUT= ["; for(unsigned int i=0; i<ptr1->centralityLUT()->maxSize(); i++) cout<<(i==0?"":",")<<ptr1->centralityLUT()->data(i); cout<<"]"<<endl;
309 
310  std::vector<int> mbt = ptr1->minimumBiasThresholds();
311  cout<<" minimumBiasThresholds= ["; for(unsigned int i=0; i<mbt.size(); i++) cout<<mbt[i]; cout<<"]"<<endl;
312 
313  cout<<endl<<"centralityRegionMask() = "<<ptr1->centralityRegionMask()<<endl;
314  cout<<endl<<"jetRegionMask() = "<<ptr1->jetRegionMask()<<endl;
315  cout<<endl<<"tauRegionMask() = "<<ptr1->tauRegionMask()<<endl;
316 
317  cout<<endl<<" HI Q2 trigger: "<<endl;
318  cout<<" q2LUT= ["; for(unsigned int i=0; i<ptr1->q2LUT()->maxSize(); i++) cout<<(i==0?"":",")<<ptr1->q2LUT()->data(i); cout<<"]"<<endl;
319 
320  cout<<endl<<" Layer1: "<<endl;
321  std::vector<double> ecalSF = ptr1->layer1ECalScaleFactors();
322  cout<<" layer1ECalScaleFactors= ["<< ecalSF.size()<<"] "<<flush;
323  float _ecalSF[ ecalSF.size() ];
324  for(unsigned int i=0; i<ecalSF.size(); i++) _ecalSF[i] = ecalSF[i];
325  cout << hash( _ecalSF , sizeof(float)*ecalSF.size() ) << endl;
326  //for(unsigned int i=0; i<ecalSF.size(); i++) cout<<(i==0?"":",")<<ecalSF[i]; cout<<"]"<<endl;
327  std::vector<double> hcalSF = ptr1->layer1HCalScaleFactors();
328  cout<<" layer1HCalScaleFactors= ["<< hcalSF.size()<<"] "<<flush;
329  float _hcalSF[ hcalSF.size() ];
330  for(unsigned int i=0; i<hcalSF.size(); i++){
331  // round false precision
332 // double significand;
333 // int exponent;
334 // significand = frexp( hcalSF[i], &exponent );
335 // _hcalSF[i] = ldexp( int(significand*10000)/10000., exponent );
336  _hcalSF[i] = int(hcalSF[i]*1000.)/1000.;
337  }
338  cout << hash( _hcalSF, sizeof(float)*hcalSF.size() ) << endl;
339  //for(unsigned int i=0; i<hcalSF.size(); i++) cout<<(i==0?"":",")<<hcalSF[i]; cout<<"]"<<endl;
340  std::vector<double> hfSF = ptr1->layer1HFScaleFactors();
341  cout<<" layer1HFScaleFactors= ["<< hfSF.size()<<"] "<<flush;
342  float _hfSF[ hfSF.size() ];
343  for(unsigned int i=0; i<hfSF.size(); i++) _hfSF[i] = hfSF[i];
344  cout << hash( _hfSF, sizeof(float)*hfSF.size() ) << endl;
345  //for(unsigned int i=0; i<hfSF.size(); i++) cout<<(i==0?"":",")<<hfSF[i]; cout<<"]"<<endl;
346 
347  std::vector<int> ecalScaleET = ptr1->layer1ECalScaleETBins();
348  cout<<" layer1ECalScaleETBins= ["; for(unsigned int i=0; i<ecalScaleET.size(); i++) cout<<(i==0?"":",")<<ecalScaleET[i]; cout<<"]"<<endl;
349  std::vector<int> hcalScaleET = ptr1->layer1HCalScaleETBins();
350  cout<<" layer1HCalScaleETBins= ["; for(unsigned int i=0; i<hcalScaleET.size(); i++) cout<<(i==0?"":",")<<hcalScaleET[i]; cout<<"]"<<endl;
351  std::vector<int> hfScaleET = ptr1->layer1HFScaleETBins();
352  cout<<" layer1HFScaleETBins= ["; for(unsigned int i=0; i<hfScaleET.size(); i++) cout<<(i==0?"":",")<<hfScaleET[i]; cout<<"]"<<endl;
353 }
354 
358 
360 
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
virtual ~L1TCaloParamsViewer(void)
L1TCaloParamsViewer(const edm::ParameterSet &pset)
const T & get() const
Definition: EventSetup.h:56
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
std::string hash(void *buf, size_t len) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T const * product() const
Definition: ESHandle.h:86