CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCaloParamsReader.cc
Go to the documentation of this file.
5 
8 
12 
14 private:
18 
19  std::string hash(void *buf, size_t len) const ;
20 
21 public:
22  virtual void analyze(const edm::Event&, const edm::EventSetup&);
23 
25  printPUSParams = pset.getUntrackedParameter<bool>("printPUSParams", false);
26  printTauCalibLUT = pset.getUntrackedParameter<bool>("printTauCalibLUT",false);
27  printJetCalibLUT = pset.getUntrackedParameter<bool>("printJetCalibLUT",false);
28  }
29 
30  virtual ~L1TCaloParamsReader(void){}
31 };
32 
33 #include <openssl/sha.h>
34 #include <math.h>
35 #include <iostream>
36 using namespace std;
37 
38 std::string L1TCaloParamsReader::hash(void *buf, size_t len) const {
39  char tmp[SHA_DIGEST_LENGTH*2+1];
40  bzero(tmp,sizeof(tmp));
41  SHA_CTX ctx;
42  if( !SHA1_Init( &ctx ) )
43  throw cms::Exception("L1TCaloParamsReader::hash")<<"SHA1 initialization error";
44 
45  if( !SHA1_Update( &ctx, buf, len ) )
46  throw cms::Exception("L1TCaloParamsReader::hash")<<"SHA1 processing error";
47 
48  unsigned char hash[SHA_DIGEST_LENGTH];
49  if( !SHA1_Final(hash, &ctx) )
50  throw cms::Exception("L1TCaloParamsReader::hash")<<"SHA1 finalization error";
51 
52  // re-write bytes in hex
53  for(unsigned int i=0; i<20; i++)
54  ::sprintf(&tmp[i*2], "%02x", hash[i]);
55 
56  tmp[20*2] = 0;
57  return std::string(tmp);
58 }
59 
61 
63  evSetup.get<L1TCaloParamsRcd>().get( handle1 ) ;
64  boost::shared_ptr<l1t::CaloParams> ptr(new l1t::CaloParams(*(handle1.product ())));
65 
66  l1t::CaloParamsHelper *ptr1 = 0;
67  ptr1 = (l1t::CaloParamsHelper*) (&(*ptr));
68 
69  edm::LogInfo("")<<"L1TCaloParamsReader:";
70 
71  cout<<endl<<" Towers: "<<endl;
72  cout<<" towerLsbH= "<<ptr1->towerLsbH()<<endl;
73  cout<<" towerLsbE= "<<ptr1->towerLsbE()<<endl;
74  cout<<" towerLsbSum= "<<ptr1->towerLsbSum()<<endl;
75  cout<<" towerNBitsH= "<<ptr1->towerNBitsH()<<endl;
76  cout<<" towerNBitsE= "<<ptr1->towerNBitsE()<<endl;
77  cout<<" towerNBitsSum= "<<ptr1->towerNBitsSum()<<endl;
78  cout<<" towerNBitsRatio= "<<ptr1->towerNBitsRatio()<<endl;
79  cout<<" towerMaskE= "<<ptr1->towerMaskE()<<endl;
80  cout<<" towerMaskH= "<<ptr1->towerMaskH()<<endl;
81  cout<<" towerMaskSum= "<<ptr1->towerMaskSum()<<endl;
82  cout<<" towerEncoding= "<<ptr1->doTowerEncoding()<<endl;
83 
84  cout<<endl<<" Regions: "<<endl;
85  cout<<" regionLsb= "<<ptr1->regionLsb()<<endl;
86  cout<<" regionPUSType= "<<ptr1->regionPUSType()<<endl;
87  cout<<" regionPUSParams= ["<<ptr1->regionPUSParams().size()<<"] ";
88  double pusParams[ptr1->regionPUSParams().size()];
89 
90  for(unsigned int i=0; i<ptr1->regionPUSParams().size(); i++){
91  pusParams[i] = ceil(2*ptr1->regionPUSParams()[i]);
92  if( printPUSParams ) cout<<" "<<ceil(2*pusParams[i])<<endl;
93  }
94 
95  if( ptr1->regionPUSParams().size() )
96  cout << hash(pusParams, sizeof(double)*ptr1->regionPUSParams().size()) << endl;
97  else cout<<endl;
98 
99 
100  cout<<endl<<" EG: "<<endl;
101  cout<<" egLsb= "<<ptr1->egLsb()<<endl;
102  cout<<" egSeedThreshold= "<<ptr1->egSeedThreshold()<<endl;
103  cout<<" egNeighbourThreshold= "<<ptr1->egNeighbourThreshold()<<endl;
104  cout<<" egHcalThreshold= "<<ptr1->egHcalThreshold()<<endl;
105 
106  if( !ptr1->egTrimmingLUT()->empty() ){
107  cout<<" egTrimmingLUT= ["<<ptr1->egTrimmingLUT()->maxSize()<<"] "<<flush;
108  int egTrimming[ptr1->egTrimmingLUT()->maxSize()];
109  for(unsigned int i=0; i<ptr1->egTrimmingLUT()->maxSize(); i++) egTrimming[i] = ptr1->egTrimmingLUT()->data(i);
110  cout << hash( egTrimming, sizeof(int)*ptr1->egTrimmingLUT()->maxSize() ) << endl;
111  } else {
112  cout<<" egTrimmingLUT= [0] "<<endl;
113  }
114 
115  cout<<" egMaxHcalEt= "<<ptr1->egMaxHcalEt()<<endl;
116  cout<<" egMaxPtHOverE= "<<ptr1->egMaxPtHOverE()<<endl;
117  cout<<" egMaxHcalEt= "<<ptr1->egMaxHcalEt()<<endl;
118  cout<<" egMinPtJetIsolation= "<<ptr1->egMinPtJetIsolation()<<endl;
119  cout<<" egMaxPtJetIsolation= "<<ptr1->egMaxPtJetIsolation()<<endl;
120  cout<<" egMinPtHOverEIsolation= "<<ptr1->egMinPtHOverEIsolation()<<endl;
121  cout<<" egMaxPtHOverEIsolation= "<<ptr1->egMaxPtHOverEIsolation()<<endl;
122 
123  if( !ptr1->egMaxHOverELUT()->empty() ){
124  cout<<" egMaxHOverELUT= ["<<ptr1->egMaxHOverELUT()->maxSize()<<"] ";
125  int egMaxHOverE[ptr1->egMaxHOverELUT()->maxSize()];
126  for(unsigned int i=0; i<ptr1->egMaxHOverELUT()->maxSize(); i++) egMaxHOverE[i] = ptr1->egMaxHOverELUT()->data(i);
127  cout << hash( egMaxHOverE, sizeof(int)*ptr1->egMaxHOverELUT()->maxSize() ) << endl;
128  } else {
129  cout<<" egMaxHOverELUT= [0]"<<endl;
130  }
131 
132  if( !ptr1->egCompressShapesLUT()->empty() ){
133  cout<<" egCompressShapesLUT= ["<<ptr1->egCompressShapesLUT()->maxSize()<<"] ";
134  int egCompressShapes[ptr1->egCompressShapesLUT()->maxSize()];
135  for(unsigned int i=0; i<ptr1->egCompressShapesLUT()->maxSize(); i++) egCompressShapes[i] = ptr1->egCompressShapesLUT()->data(i);
136  cout << hash( egCompressShapes, sizeof(int)*ptr1->egCompressShapesLUT()->maxSize() ) << endl;
137  } else {
138  cout<<" egCompressShapesLUT= [0]"<<endl;
139  }
140 
141  // cout<<" egShapeIdType= "<<ptr1->egShapeIdType()<<endl;
142  // cout<<" egShapeIdVersion= "<<ptr1->egShapeIdVersion()<<endl;
143  if( !ptr1->egShapeIdLUT()->empty() ){
144  cout<<" egShapeIdLUT= ["<<ptr1->egShapeIdLUT()->maxSize()<<"] "<<flush;
145  int egShapeId[ptr1->egShapeIdLUT()->maxSize()];
146  for(unsigned int i=0; i<ptr1->egShapeIdLUT()->maxSize(); i++) egShapeId[i] = ptr1->egShapeIdLUT()->data(i);
147  cout << hash( egShapeId, sizeof(int)*ptr1->egShapeIdLUT()->maxSize() )<<endl;
148  } else {
149  cout<<" egShapeIdLUT= [0]"<<endl;
150  }
151 
152  cout<<" egPUSType= "<<ptr1->egPUSType()<<endl;
153 
154  if( !ptr1->egIsolationLUT()->empty() ){
155  cout<<" egIsoLUT= ["<<ptr1->egIsolationLUT()->maxSize()<<"] "<<flush;
156  int egIsolation[ptr1->egIsolationLUT()->maxSize()];
157  for(unsigned int i=0; i<ptr1->egIsolationLUT()->maxSize(); i++) egIsolation[i] = ptr1->egIsolationLUT()->data(i);
158  cout << hash( egIsolation, sizeof(int)*ptr1->egIsolationLUT()->maxSize() ) << endl;
159  } else {
160  cout<<" egIsoLUT= [0]"<<endl;
161  }
162 
163  cout<<" egIsoAreaNrTowersEta= "<<ptr1->egIsoAreaNrTowersEta()<<endl;
164  cout<<" egIsoAreaNrTowersPhi= "<<ptr1->egIsoAreaNrTowersPhi()<<endl;
165  cout<<" egIsoVetoNrTowersPhi= "<<ptr1->egIsoVetoNrTowersPhi()<<endl;
166  cout<<" egPUSParams= ["<<ptr1->egPUSParams().size()<<"] "<<flush;
167  double egPUSParams[ptr1->egPUSParams().size()];
168  for(unsigned int i=0; i<ptr1->egPUSParams().size(); i++) egPUSParams[i] = ptr1->egPUSParams()[i];
169 
170  if( ptr1->egPUSParams().size() )
171  cout << hash( egPUSParams, sizeof(double)*ptr1->egPUSParams().size() ) << endl;
172  else cout<<endl;
173 
174  cout<<" egCalibrationType= "<<ptr1->egCalibrationType()<<endl;
175  // cout<<" egCalibrationVersion= "<<ptr1->egCalibrationVersion()<<endl;
176  if( !ptr1->egCalibrationLUT()->empty() ){
177  cout<<" egCalibrationLUT= ["<<ptr1->egCalibrationLUT()->maxSize()<<"] "<<flush;
178  int egCalibration[ptr1->egCalibrationLUT()->maxSize()];
179  for(unsigned int i=0; i<ptr1->egCalibrationLUT()->maxSize(); i++) egCalibration[i] = ptr1->egCalibrationLUT()->data(i);
180  cout << hash( egCalibration, sizeof(int)*ptr1->egCalibrationLUT()->maxSize() ) << endl;
181  } else {
182  cout<<" egCalibrationLUT= [0]"<<endl;
183  }
184 
185  cout<<endl<<" Tau: "<<endl;
186  cout<<" tauLsb= "<<ptr1->tauLsb()<<endl;
187  cout<<" tauSeedThreshold= "<<ptr1->tauSeedThreshold()<<endl;
188  cout<<" tauNeighbourThreshold= "<<ptr1->tauNeighbourThreshold()<<endl;
189  cout<<" tauMaxPtTauVeto= "<<ptr1->tauMaxPtTauVeto()<<endl;
190  cout<<" tauMinPtJetIsolationB= "<<ptr1->tauMinPtJetIsolationB()<<endl;
191  cout<<" tauPUSType= "<<ptr1->tauPUSType()<<endl;
192  cout<<" tauMaxJetIsolationB= "<<ptr1->tauMaxJetIsolationB()<<endl;
193  cout<<" tauMaxJetIsolationA= "<<ptr1->tauMaxJetIsolationA()<<endl;
194  cout<<" tauIsoAreaNrTowersEta= "<<ptr1->tauIsoAreaNrTowersEta()<<endl;
195  cout<<" tauIsoAreaNrTowersPhi= "<<ptr1->tauIsoAreaNrTowersPhi()<<endl;
196  cout<<" tauIsoVetoNrTowersPhi= "<<ptr1->tauIsoVetoNrTowersPhi()<<endl;
197  if( !ptr1->tauIsolationLUT()->empty() ){
198  cout<<" tauIsoLUT= ["<<ptr1->tauIsolationLUT()->maxSize()<<"] "<<flush;
199  int tauIsolation[ptr1->tauIsolationLUT()->maxSize()];
200  for(unsigned int i=0; i<ptr1->tauIsolationLUT()->maxSize(); i++) tauIsolation[i] = ptr1->tauIsolationLUT()->data(i);
201  cout << hash( tauIsolation, sizeof(int)*ptr1->tauIsolationLUT()->maxSize() ) << endl;
202  } else {
203  cout<<" tauIsoLUT= [0]"<<endl;
204  }
205 
206  if( !ptr1->tauCalibrationLUT()->empty() ){
207  cout<<" tauCalibrationLUT= ["<<ptr1->tauCalibrationLUT()->maxSize()<<"] "<<flush;
208  int tauCalibration[ptr1->tauCalibrationLUT()->maxSize()];
209  for(unsigned int i=0; i<ptr1->tauCalibrationLUT()->maxSize(); i++)
210  tauCalibration[i] = ptr1->tauCalibrationLUT()->data(i);
211  cout << hash( tauCalibration, sizeof(int)*ptr1->tauCalibrationLUT()->maxSize() ) << endl;
212 
213  if( printTauCalibLUT )
214  for(unsigned int i=0; i<ptr1->tauCalibrationLUT()->maxSize(); i++)
215  cout<<i<<" "<<tauCalibration[i]<<endl;
216 
217  } else {
218  cout<<" tauCalibrationLUT= [0]"<<endl;
219  }
220 
221  if( !ptr1->tauEtToHFRingEtLUT()->empty() ){
222  cout<<" tauEtToHFRingEtLUT= ["<<ptr1->tauEtToHFRingEtLUT()->maxSize()<<"] "<<flush;
223  int tauEtToHFRingEt[ptr1->tauEtToHFRingEtLUT()->maxSize()];
224  for(unsigned int i=0; i<ptr1->tauEtToHFRingEtLUT()->maxSize(); i++) tauEtToHFRingEt[i] = ptr1->tauEtToHFRingEtLUT()->data(i);
225 
226  cout << hash( tauEtToHFRingEt, sizeof(int)*ptr1->tauEtToHFRingEtLUT()->maxSize() ) << endl;
227  } else {
228  cout<<" tauEtToHFRingEtLUT= [0]"<<endl;
229  }
230 
231  cout<<" isoTauEtaMin= "<<ptr1->isoTauEtaMin()<<endl;
232  cout<<" isoTauEtaMax= "<<ptr1->isoTauEtaMax()<<endl;
233  cout<<" tauPUSParams= ["<<ptr1->tauPUSParams().size()<<"] "<<flush;
234  double tauPUSParams[ptr1->tauPUSParams().size()];
235  for(unsigned int i=0; i<ptr1->tauPUSParams().size(); i++) tauPUSParams[i] = ptr1->tauPUSParams()[i];
236 
237  if( ptr1->tauPUSParams().size() )
238  cout << hash( tauPUSParams, sizeof(double)*ptr1->tauPUSParams().size() ) << endl;
239  else cout<<endl;
240 
241  cout<<endl<<" Jets: "<<endl;
242  cout<<" jetLsb= "<<ptr1->jetLsb()<<endl;
243  cout<<" jetSeedThreshold= "<<ptr1->jetSeedThreshold()<<endl;
244  cout<<" jetNeighbourThreshold= "<<ptr1->jetNeighbourThreshold()<<endl;
245  cout<<" jetPUSType= "<<ptr1->jetPUSType()<<endl;
246  cout<<" jetCalibrationType= "<<ptr1->jetCalibrationType()<<endl;
247  cout<<" jetCalibrationParams= ["<<ptr1->jetCalibrationParams().size()<<"] "<<flush;
248  double jetCalibrationParams[ptr1->jetCalibrationParams().size()];
249  for(unsigned int i=0; i<ptr1->jetCalibrationParams().size(); i++) jetCalibrationParams[i] = ptr1->jetCalibrationParams()[i];
250 
251  if( ptr1->jetCalibrationParams().size() )
252  cout << hash( jetCalibrationParams, sizeof(double)*ptr1->jetCalibrationParams().size() ) << endl;
253  else cout<<endl;
254 
255  if( !ptr1->jetCalibrationLUT()->empty() ){
256  cout<<" jetCalibrationLUT= ["<<ptr1->jetCalibrationLUT()->maxSize()<<"] "<<flush;
257  int jetCalibration[ptr1->jetCalibrationLUT()->maxSize()];
258  for(unsigned int i=0; i<ptr1->jetCalibrationLUT()->maxSize(); i++)
259  jetCalibration[i] = ptr1->jetCalibrationLUT()->data(i);
260 
261  cout << hash( jetCalibration, sizeof(int)*ptr1->jetCalibrationLUT()->maxSize() ) << endl;
262 
263  if( printJetCalibLUT )
264  for(unsigned int i=0; i<ptr1->jetCalibrationLUT()->maxSize(); i++)
265  cout<<i<<" "<<jetCalibration[i]<<endl;
266 
267  } else {
268  cout<<" jetCalibrationLUT= [0]"<<endl;
269  }
270 
271  cout<<endl<<" Sums: "<<endl;
272  cout<<" etSumLsb= "<<ptr1->etSumLsb()<<endl;
276 
277  cout<<endl<<" HI centrality trigger: "<<endl;
278  cout<<" centralityLUT= ["; for(unsigned int i=0; i<ptr1->centralityLUT()->maxSize(); i++) cout<<(i==0?"":",")<<ptr1->centralityLUT()->data(i); cout<<"]"<<endl;
279 
280  cout<<endl<<"centralityRegionMask() = "<<ptr1->centralityRegionMask()<<endl;
281  cout<<endl<<"jetRegionMask() = "<<ptr1->jetRegionMask()<<endl;
282  cout<<endl<<"tauRegionMask() = "<<ptr1->tauRegionMask()<<endl;
283 
284  cout<<endl<<" HI Q2 trigger: "<<endl;
285  cout<<" q2LUT= ["; for(unsigned int i=0; i<ptr1->q2LUT()->maxSize(); i++) cout<<(i==0?"":",")<<ptr1->q2LUT()->data(i); cout<<"]"<<endl;
286 
287 }
288 
292 
294 
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 ~L1TCaloParamsReader(void)
std::string hash(void *buf, size_t len) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:145
L1TCaloParamsReader(const edm::ParameterSet &pset)