CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<<" egMaxHcalEt= "<<ptr1->egMaxHcalEt()<<endl;
125  cout<<" egMinPtJetIsolation= "<<ptr1->egMinPtJetIsolation()<<endl;
126  cout<<" egMaxPtJetIsolation= "<<ptr1->egMaxPtJetIsolation()<<endl;
127  cout<<" egMinPtHOverEIsolation= "<<ptr1->egMinPtHOverEIsolation()<<endl;
128  cout<<" egMaxPtHOverEIsolation= "<<ptr1->egMaxPtHOverEIsolation()<<endl;
129 
130  if( !ptr1->egMaxHOverELUT()->empty() ){
131  cout<<" egMaxHOverELUT= ["<<ptr1->egMaxHOverELUT()->maxSize()<<"] ";
132  int egMaxHOverE[ptr1->egMaxHOverELUT()->maxSize()];
133  for(unsigned int i=0; i<ptr1->egMaxHOverELUT()->maxSize(); i++) egMaxHOverE[i] = ptr1->egMaxHOverELUT()->data(i);
134  cout << hash( egMaxHOverE, sizeof(int)*ptr1->egMaxHOverELUT()->maxSize() ) << endl;
135  } else {
136  cout<<" egMaxHOverELUT= [0]"<<endl;
137  }
138 
139  if( !ptr1->egCompressShapesLUT()->empty() ){
140  cout<<" egCompressShapesLUT= ["<<ptr1->egCompressShapesLUT()->maxSize()<<"] ";
141  int egCompressShapes[ptr1->egCompressShapesLUT()->maxSize()];
142  for(unsigned int i=0; i<ptr1->egCompressShapesLUT()->maxSize(); i++) egCompressShapes[i] = ptr1->egCompressShapesLUT()->data(i);
143  cout << hash( egCompressShapes, sizeof(int)*ptr1->egCompressShapesLUT()->maxSize() ) << endl;
144  } else {
145  cout<<" egCompressShapesLUT= [0]"<<endl;
146  }
147 
148  // cout<<" egShapeIdType= "<<ptr1->egShapeIdType()<<endl;
149  // cout<<" egShapeIdVersion= "<<ptr1->egShapeIdVersion()<<endl;
150  if( !ptr1->egShapeIdLUT()->empty() ){
151  cout<<" egShapeIdLUT= ["<<ptr1->egShapeIdLUT()->maxSize()<<"] "<<flush;
152  int egShapeId[ptr1->egShapeIdLUT()->maxSize()];
153  for(unsigned int i=0; i<ptr1->egShapeIdLUT()->maxSize(); i++) egShapeId[i] = ptr1->egShapeIdLUT()->data(i);
154  cout << hash( egShapeId, sizeof(int)*ptr1->egShapeIdLUT()->maxSize() )<<endl;
155  } else {
156  cout<<" egShapeIdLUT= [0]"<<endl;
157  }
158 
159  cout<<" egPUSType= "<<ptr1->egPUSType()<<endl;
160 
161  if( !ptr1->egIsolationLUT()->empty() ){
162  cout<<" egIsoLUT= ["<<ptr1->egIsolationLUT()->maxSize()<<"] "<<flush;
163  int egIsolation[ptr1->egIsolationLUT()->maxSize()];
164  for(unsigned int i=0; i<ptr1->egIsolationLUT()->maxSize(); i++) egIsolation[i] = ptr1->egIsolationLUT()->data(i);
165  cout << hash( egIsolation, sizeof(int)*ptr1->egIsolationLUT()->maxSize() ) << endl;
166  if( printEgIsoLUT )
167  for(unsigned int i=0; i<ptr1->egIsolationLUT()->maxSize(); i++)
168  cout<<i<<" " << egIsolation[i]<<endl;
169  } else {
170  cout<<" egIsoLUT= [0]"<<endl;
171  }
172 
173  cout<<" egIsoAreaNrTowersEta= "<<ptr1->egIsoAreaNrTowersEta()<<endl;
174  cout<<" egIsoAreaNrTowersPhi= "<<ptr1->egIsoAreaNrTowersPhi()<<endl;
175  cout<<" egIsoVetoNrTowersPhi= "<<ptr1->egIsoVetoNrTowersPhi()<<endl;
176  cout<<" egPUSParams= ["<<ptr1->egPUSParams().size()<<"] "<<flush;
177  float egPUSParams[ptr1->egPUSParams().size()];
178  for(unsigned int i=0; i<ptr1->egPUSParams().size(); i++) egPUSParams[i] = ptr1->egPUSParams()[i];
179 
180  if( ptr1->egPUSParams().size() )
181  cout << hash( egPUSParams, sizeof(float)*ptr1->egPUSParams().size() ) << endl;
182  else cout<<endl;
183 
184  cout<<" egCalibrationType= "<<ptr1->egCalibrationType()<<endl;
185  // cout<<" egCalibrationVersion= "<<ptr1->egCalibrationVersion()<<endl;
186  if( !ptr1->egCalibrationLUT()->empty() ){
187  cout<<" egCalibrationLUT= ["<<ptr1->egCalibrationLUT()->maxSize()<<"] "<<flush;
188  int egCalibration[ptr1->egCalibrationLUT()->maxSize()];
189  for(unsigned int i=0; i<ptr1->egCalibrationLUT()->maxSize(); i++) egCalibration[i] = ptr1->egCalibrationLUT()->data(i);
190  cout << hash( egCalibration, sizeof(int)*ptr1->egCalibrationLUT()->maxSize() ) << endl;
191  if( printEgCalibLUT )
192  for(unsigned int i=0; i<ptr1->egCalibrationLUT()->maxSize(); i++)
193  cout<<i<<" " << egCalibration[i]<<endl;
194  } else {
195  cout<<" egCalibrationLUT= [0]"<<endl;
196  }
197 
198  cout<<endl<<" Tau: "<<endl;
199  cout<<" tauLsb= "<<ptr1->tauLsb()<<endl;
200  cout<<" tauSeedThreshold= "<<ptr1->tauSeedThreshold()<<endl;
201  cout<<" tauNeighbourThreshold= "<<ptr1->tauNeighbourThreshold()<<endl;
202  cout<<" tauMaxPtTauVeto= "<<ptr1->tauMaxPtTauVeto()<<endl;
203  cout<<" tauMinPtJetIsolationB= "<<ptr1->tauMinPtJetIsolationB()<<endl;
204  cout<<" tauPUSType= "<<ptr1->tauPUSType()<<endl;
205  cout<<" tauMaxJetIsolationB= "<<ptr1->tauMaxJetIsolationB()<<endl;
206  cout<<" tauMaxJetIsolationA= "<<ptr1->tauMaxJetIsolationA()<<endl;
207  cout<<" tauIsoAreaNrTowersEta= "<<ptr1->tauIsoAreaNrTowersEta()<<endl;
208  cout<<" tauIsoAreaNrTowersPhi= "<<ptr1->tauIsoAreaNrTowersPhi()<<endl;
209  cout<<" tauIsoVetoNrTowersPhi= "<<ptr1->tauIsoVetoNrTowersPhi()<<endl;
210  if( !ptr1->tauIsolationLUT()->empty() ){
211  cout<<" tauIsoLUT= ["<<ptr1->tauIsolationLUT()->maxSize()<<"] "<<flush;
212  int tauIsolation[ptr1->tauIsolationLUT()->maxSize()];
213  for(unsigned int i=0; i<ptr1->tauIsolationLUT()->maxSize(); i++) tauIsolation[i] = ptr1->tauIsolationLUT()->data(i);
214  cout << hash( tauIsolation, sizeof(int)*ptr1->tauIsolationLUT()->maxSize() ) << endl;
215  } else {
216  cout<<" tauIsoLUT= [0]"<<endl;
217  }
218 
219  if( !ptr1->tauCalibrationLUT()->empty() ){
220  cout<<" tauCalibrationLUT= ["<<ptr1->tauCalibrationLUT()->maxSize()<<"] "<<flush;
221  int tauCalibration[ptr1->tauCalibrationLUT()->maxSize()];
222  for(unsigned int i=0; i<ptr1->tauCalibrationLUT()->maxSize(); i++)
223  tauCalibration[i] = ptr1->tauCalibrationLUT()->data(i);
224  cout << hash( tauCalibration, sizeof(int)*ptr1->tauCalibrationLUT()->maxSize() ) << endl;
225 
226  if( printTauCalibLUT )
227  for(unsigned int i=0; i<ptr1->tauCalibrationLUT()->maxSize(); i++)
228  cout<<i<<" "<<tauCalibration[i]<<endl;
229 
230  } else {
231  cout<<" tauCalibrationLUT= [0]"<<endl;
232  }
233 
234  if( !ptr1->tauEtToHFRingEtLUT()->empty() ){
235  cout<<" tauEtToHFRingEtLUT= ["<<ptr1->tauEtToHFRingEtLUT()->maxSize()<<"] "<<flush;
236  int tauEtToHFRingEt[ptr1->tauEtToHFRingEtLUT()->maxSize()];
237  for(unsigned int i=0; i<ptr1->tauEtToHFRingEtLUT()->maxSize(); i++) tauEtToHFRingEt[i] = ptr1->tauEtToHFRingEtLUT()->data(i);
238 
239  cout << hash( tauEtToHFRingEt, sizeof(int)*ptr1->tauEtToHFRingEtLUT()->maxSize() ) << endl;
240  } else {
241  cout<<" tauEtToHFRingEtLUT= [0]"<<endl;
242  }
243 
244  cout<<" isoTauEtaMin= "<<ptr1->isoTauEtaMin()<<endl;
245  cout<<" isoTauEtaMax= "<<ptr1->isoTauEtaMax()<<endl;
246  cout<<" tauPUSParams= ["<<ptr1->tauPUSParams().size()<<"] "<<flush;
247  float tauPUSParams[ptr1->tauPUSParams().size()];
248  for(unsigned int i=0; i<ptr1->tauPUSParams().size(); i++) tauPUSParams[i] = ptr1->tauPUSParams()[i];
249 
250  if( ptr1->tauPUSParams().size() )
251  cout << hash( tauPUSParams, sizeof(float)*ptr1->tauPUSParams().size() ) << endl;
252  else cout<<endl;
253 
254  cout<<endl<<" Jets: "<<endl;
255  cout<<" jetLsb= "<<ptr1->jetLsb()<<endl;
256  cout<<" jetSeedThreshold= "<<ptr1->jetSeedThreshold()<<endl;
257  cout<<" jetNeighbourThreshold= "<<ptr1->jetNeighbourThreshold()<<endl;
258  cout<<" jetPUSType= "<<ptr1->jetPUSType()<<endl;
259  cout<<" jetCalibrationType= "<<ptr1->jetCalibrationType()<<endl;
260  cout<<" jetCalibrationParams= ["<<ptr1->jetCalibrationParams().size()<<"] "<<flush;
261  float jetCalibrationParams[ptr1->jetCalibrationParams().size()]; // deliberately drop double precision
262  for(unsigned int i=0; i<ptr1->jetCalibrationParams().size(); i++) jetCalibrationParams[i] = ptr1->jetCalibrationParams()[i];
263 
264  if( ptr1->jetCalibrationParams().size() ){
265  cout << hash( jetCalibrationParams, sizeof(float)*ptr1->jetCalibrationParams().size() ) << endl;
266  if( printJetCalibPar )
267  for(unsigned int i=0; i<ptr1->jetCalibrationParams().size(); i++)
268  cout<<i<<" " << std::setprecision(14) << jetCalibrationParams[i]<<endl;
269 
270  } else cout<<endl;
271 
272  if( !ptr1->jetCalibrationLUT()->empty() ){
273  cout<<" jetCalibrationLUT= ["<<ptr1->jetCalibrationLUT()->maxSize()<<"] "<<flush;
274  int jetCalibration[ptr1->jetCalibrationLUT()->maxSize()];
275  for(unsigned int i=0; i<ptr1->jetCalibrationLUT()->maxSize(); i++)
276  jetCalibration[i] = ptr1->jetCalibrationLUT()->data(i);
277 
278  cout << hash( jetCalibration, sizeof(int)*ptr1->jetCalibrationLUT()->maxSize() ) << endl;
279 
280  if( printJetCalibLUT )
281  for(unsigned int i=0; i<ptr1->jetCalibrationLUT()->maxSize(); i++)
282  cout<<i<<" "<<jetCalibration[i]<<endl;
283 
284  } else {
285  cout<<" jetCalibrationLUT= [0]"<<endl;
286  }
287 
288  cout<<endl<<" Sums: "<<endl;
289  cout<<" etSumLsb= "<<ptr1->etSumLsb()<<endl;
293 
294  cout<<endl<<" HI centrality trigger: "<<endl;
295  cout<<" centralityLUT= ["; for(unsigned int i=0; i<ptr1->centralityLUT()->maxSize(); i++) cout<<(i==0?"":",")<<ptr1->centralityLUT()->data(i); cout<<"]"<<endl;
296 
297  std::vector<int> mbt = ptr1->minimumBiasThresholds();
298  cout<<" minimumBiasThresholds= ["; for(unsigned int i=0; i<mbt.size(); i++) cout<<mbt[i]; cout<<"]"<<endl;
299 
300  cout<<endl<<"centralityRegionMask() = "<<ptr1->centralityRegionMask()<<endl;
301  cout<<endl<<"jetRegionMask() = "<<ptr1->jetRegionMask()<<endl;
302  cout<<endl<<"tauRegionMask() = "<<ptr1->tauRegionMask()<<endl;
303 
304  cout<<endl<<" HI Q2 trigger: "<<endl;
305  cout<<" q2LUT= ["; for(unsigned int i=0; i<ptr1->q2LUT()->maxSize(); i++) cout<<(i==0?"":",")<<ptr1->q2LUT()->data(i); cout<<"]"<<endl;
306 
307  cout<<endl<<" Layer1: "<<endl;
308  std::vector<double> ecalSF = ptr1->layer1ECalScaleFactors();
309  cout<<" layer1ECalScaleFactors= ["<< ecalSF.size()<<"] "<<flush;
310  float _ecalSF[ ecalSF.size() ];
311  for(unsigned int i=0; i<ecalSF.size(); i++) _ecalSF[i] = ecalSF[i];
312  cout << hash( _ecalSF , sizeof(float)*ecalSF.size() ) << endl;
313  //for(unsigned int i=0; i<ecalSF.size(); i++) cout<<(i==0?"":",")<<ecalSF[i]; cout<<"]"<<endl;
314  std::vector<double> hcalSF = ptr1->layer1HCalScaleFactors();
315  cout<<" layer1HCalScaleFactors= ["<< hcalSF.size()<<"] "<<flush;
316  float _hcalSF[ hcalSF.size() ];
317  for(unsigned int i=0; i<hcalSF.size(); i++){
318  // round false precision
319 // double significand;
320 // int exponent;
321 // significand = frexp( hcalSF[i], &exponent );
322 // _hcalSF[i] = ldexp( int(significand*10000)/10000., exponent );
323  _hcalSF[i] = int(hcalSF[i]*1000.)/1000.;
324  }
325  cout << hash( _hcalSF, sizeof(float)*hcalSF.size() ) << endl;
326  //for(unsigned int i=0; i<hcalSF.size(); i++) cout<<(i==0?"":",")<<hcalSF[i]; cout<<"]"<<endl;
327  std::vector<double> hfSF = ptr1->layer1HFScaleFactors();
328  cout<<" layer1HFScaleFactors= ["<< hfSF.size()<<"] "<<flush;
329  float _hfSF[ hfSF.size() ];
330  for(unsigned int i=0; i<hfSF.size(); i++) _hfSF[i] = hfSF[i];
331  cout << hash( _hfSF, sizeof(float)*hfSF.size() ) << endl;
332  //for(unsigned int i=0; i<hfSF.size(); i++) cout<<(i==0?"":",")<<hfSF[i]; cout<<"]"<<endl;
333 
334  std::vector<int> ecalScaleET = ptr1->layer1ECalScaleETBins();
335  cout<<" layer1ECalScaleETBins= ["; for(unsigned int i=0; i<ecalScaleET.size(); i++) cout<<(i==0?"":",")<<ecalScaleET[i]; cout<<"]"<<endl;
336  std::vector<int> hcalScaleET = ptr1->layer1HCalScaleETBins();
337  cout<<" layer1HCalScaleETBins= ["; for(unsigned int i=0; i<hcalScaleET.size(); i++) cout<<(i==0?"":",")<<hcalScaleET[i]; cout<<"]"<<endl;
338  std::vector<int> hfScaleET = ptr1->layer1HFScaleETBins();
339  cout<<" layer1HFScaleETBins= ["; for(unsigned int i=0; i<hfScaleET.size(); i++) cout<<(i==0?"":",")<<hfScaleET[i]; cout<<"]"<<endl;
340 }
341 
345 
347 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
#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
T const * product() const
Definition: ESHandle.h:86
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:145
std::string hash(void *buf, size_t len) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)