CMS 3D CMS Logo

L1TMuonOverlapParamsViewer.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <iostream>
3 
5 
8 
11 
17 
18 #include <iostream>
19 using namespace std;
20 
22 private:
24 
25 public:
26  void analyze(const edm::Event &, const edm::EventSetup &) override;
27  string hash(void *buf, size_t len) const;
28 
29  explicit L1TMuonOverlapParamsViewer(const edm::ParameterSet &pset) : edm::EDAnalyzer() {
30  printLayerMap = pset.getUntrackedParameter<bool>("printLayerMap", false);
31  }
32  ~L1TMuonOverlapParamsViewer(void) override {}
33 };
34 
36 #include <cmath>
37 #include <iostream>
38 using namespace std;
39 
40 string L1TMuonOverlapParamsViewer::hash(void *buf, size_t len) const {
42  EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
43  const EVP_MD *md = EVP_get_digestbyname("SHA1");
44  if (!EVP_DigestInit_ex(mdctx, md, nullptr))
45  throw cms::Exception("L1TCaloParamsViewer::hash") << "SHA1 initialization error";
46 
47  if (!EVP_DigestUpdate(mdctx, buf, len))
48  throw cms::Exception("L1TCaloParamsViewer::hash") << "SHA1 processing error";
49 
50  unsigned char hash[EVP_MAX_MD_SIZE];
51  unsigned int md_len = 0;
52  if (!EVP_DigestFinal_ex(mdctx, hash, &md_len))
53  throw cms::Exception("L1TCaloParamsViewer::hash") << "SHA1 finalization error";
54 
55  EVP_MD_CTX_free(mdctx);
56 
57  // re-write bytes in hex
58  char tmp[EVP_MAX_MD_SIZE * 2 + 1];
59  if (md_len > 20)
60  md_len = 20;
61  for (unsigned int i = 0; i < md_len; i++)
62  ::sprintf(&tmp[i * 2], "%02x", hash[i]);
63 
64  tmp[md_len * 2] = 0;
65  return string(tmp);
66 }
67 
69  // Pull the config from the ES
71  evSetup.get<L1TMuonOverlapParamsRcd>().get(handle1);
72  std::shared_ptr<L1TMuonOverlapParams> ptr1(new L1TMuonOverlapParams(*(handle1.product())));
73 
74  cout << "Some fields in L1TMuonOverlapParamsParams: " << endl;
75 
76  cout << " fwVersion() = " << ptr1->fwVersion() << endl;
77  cout << " nPdfAddrBits() = " << ptr1->nPdfAddrBits() << endl;
78  cout << " nPdfValBits() = " << ptr1->nPdfValBits() << endl;
79  cout << " nHitsPerLayer() = " << ptr1->nHitsPerLayer() << endl;
80  cout << " nPhiBits() = " << ptr1->nPhiBits() << endl;
81  cout << " nPhiBins() = " << ptr1->nPhiBins() << endl;
82  cout << " nRefHits() = " << ptr1->nRefHits() << endl;
83  cout << " nTestRefHits() = " << ptr1->nTestRefHits() << endl;
84  cout << " nProcessors() = " << ptr1->nProcessors() << endl;
85  cout << " nLogicRegions() = " << ptr1->nLogicRegions() << endl;
86  cout << " nInputs() = " << ptr1->nInputs() << endl;
87  cout << " nLayers() = " << ptr1->nLayers() << endl;
88  cout << " nRefLayers() = " << ptr1->nRefLayers() << endl;
89  cout << " nGoldenPatterns() = " << ptr1->nGoldenPatterns() << endl;
90 
91  const std::vector<int> *gp = ptr1->generalParams();
92  cout << " number of general parameters: = " << gp->size() << endl;
93  cout << " ";
94  for (auto a : *gp)
95  cout << a << ", ";
96  cout << endl;
97 
98  const std::vector<L1TMuonOverlapParams::LayerMapNode> *lm = ptr1->layerMap();
99  if (!lm->empty()) {
100  cout << " layerMap() = [" << lm->size() << "] ";
102  for (unsigned int i = 0; i < lm->size(); i++)
103  lm_[i] = (*lm)[i];
104  cout << hash(lm_, sizeof(L1TMuonOverlapParams::LayerMapNode) * (lm->size())) << endl;
105  if (printLayerMap) {
106  cout << sizeof(L1TMuonOverlapParams::LayerMapNode) << endl;
107  for (unsigned int i = 0; i < lm->size(); i++) {
108  cout << " [" << i << "]: hwNumber = " << lm_[i].hwNumber << " logicNumber = " << lm_[i].logicNumber
109  << " bendingLayer = " << lm_[i].bendingLayer << " connectedToLayer = " << lm_[i].connectedToLayer << " ("
110  << flush;
111  char *n = (char *)(&(lm_[i]));
112  for (unsigned int j = 0; j < sizeof(L1TMuonOverlapParams::LayerMapNode); j++)
113  cout << "0x" << hex << int(*(n + j)) << dec << ", ";
114  cout << endl;
115  }
116  // hash( (void*)(&(lm_[i])), sizeof(L1TMuonOverlapParams::LayerMapNode) ) <<endl;
117  }
118  delete[] lm_;
119  } else {
120  cout << " layerMap() = [0] " << endl;
121  }
122 
123  const std::vector<L1TMuonOverlapParams::RefLayerMapNode> *rlm = ptr1->refLayerMap();
124  if (!rlm->empty()) {
125  cout << " refLayerMap() = [" << rlm->size() << "] ";
127  for (unsigned int i = 0; i < rlm->size(); i++)
128  rlm_[i] = (*rlm)[i];
129  cout << hash(rlm_, sizeof(L1TMuonOverlapParams::RefLayerMapNode) * (rlm->size())) << endl;
130  delete[] rlm_;
131  } else {
132  cout << " refLayerMap() = [0] " << endl;
133  }
134 
135  const std::vector<L1TMuonOverlapParams::RefHitNode> *rhn = ptr1->refHitMap();
136  if (!rhn->empty()) {
137  cout << " refHitMap() = [" << rhn->size() << "] ";
139  for (unsigned int i = 0; i < rhn->size(); i++)
140  rhn_[i] = (*rhn)[i];
141  cout << hash(rhn_, sizeof(L1TMuonOverlapParams::RefHitNode) * (rhn->size())) << endl;
142  delete[] rhn_;
143  } else {
144  cout << " refHitMap() = [0] " << endl;
145  }
146 
147  const std::vector<int> *gpsm = ptr1->globalPhiStartMap();
148  if (!gpsm->empty()) {
149  cout << " globalPhiStartMap() = [" << gpsm->size() << "] ";
150  int gpsm_[gpsm->size()];
151  for (unsigned int i = 0; i < gpsm->size(); i++)
152  gpsm_[i] = (*gpsm)[i];
153  cout << hash(gpsm_, sizeof(int) * (gpsm->size())) << endl;
154  } else {
155  cout << " globalPhiStartMap() = [0] " << endl;
156  }
157 
158  const std::vector<L1TMuonOverlapParams::LayerInputNode> *lim = ptr1->layerInputMap();
159  if (!lim->empty()) {
160  cout << " layerInputMap() = [" << lim->size() << "] ";
162  for (unsigned int i = 0; i < lim->size(); i++)
163  lim_[i] = (*lim)[i];
164  cout << hash(lim_, sizeof(L1TMuonOverlapParams::LayerInputNode) * (lim->size())) << endl;
165  delete[] lim_;
166  } else {
167  cout << " layerInputMap() = [0] " << endl;
168  }
169 
170  const std::vector<int> *css = ptr1->connectedSectorsStart();
171  if (!css->empty()) {
172  cout << " connectedSectorsStart() = [" << css->size() << "] ";
173  int css_[css->size()];
174  for (unsigned int i = 0; i < css->size(); i++)
175  css_[i] = (*css)[i];
176  cout << hash(css_, sizeof(int) * (css->size())) << endl;
177  } else {
178  cout << " connectedSectorsStart() = [0] " << endl;
179  }
180 
181  const std::vector<int> *cse = ptr1->connectedSectorsEnd();
182  if (!cse->empty()) {
183  cout << " connectedSectorsEnd() = [" << cse->size() << "] ";
184  int cse_[cse->size()];
185  for (unsigned int i = 0; i < cse->size(); i++)
186  cse_[i] = (*cse)[i];
187  cout << hash(cse_, sizeof(int) * (cse->size())) << endl;
188  } else {
189  cout << " connectedSectorsEnd() = [0] " << endl;
190  }
191 
192  const l1t::LUT *clut = ptr1->chargeLUT();
193  if (clut->maxSize()) {
194  cout << " chargeLUT = [" << clut->maxSize() << "] ";
195  int clut_[clut->maxSize()];
196  for (unsigned int i = 0; i < clut->maxSize(); i++)
197  clut_[i] = clut->data(i);
198  cout << hash(clut_, sizeof(int) * (clut->maxSize())) << endl;
199  } else {
200  cout << " chargeLUT = [0] " << endl;
201  }
202 
203  const l1t::LUT *elut = ptr1->etaLUT();
204  if (elut->maxSize()) {
205  cout << " etaLUT = [" << elut->maxSize() << "] ";
206  int elut_[elut->maxSize()];
207  for (unsigned int i = 0; i < elut->maxSize(); i++)
208  elut_[i] = elut->data(i);
209  cout << hash(elut_, sizeof(int) * (elut->maxSize())) << endl;
210  } else {
211  cout << " chargeLUT = [0] " << endl;
212  }
213 
214  const l1t::LUT *ptlut = ptr1->ptLUT();
215  if (ptlut->maxSize()) {
216  cout << " ptLUT = [" << ptlut->maxSize() << "] " << flush;
217  int ptlut_[ptlut->maxSize()];
218  for (unsigned int i = 0; i < ptlut->maxSize(); i++)
219  ptlut_[i] = ptlut->data(i);
220  cout << hash(ptlut_, sizeof(int) * (ptlut->maxSize())) << endl;
221  } else {
222  cout << " ptLUT = [0] " << endl;
223  }
224 
225  const l1t::LUT *plut = ptr1->pdfLUT();
226  if (plut->maxSize()) {
227  cout << " pdfLUT = [" << plut->maxSize() << "] " << flush;
228  int plut_[plut->maxSize()];
229  for (unsigned int i = 0; i < plut->maxSize(); i++)
230  plut_[i] = plut->data(i);
231  cout << hash(plut_, sizeof(int) * (plut->maxSize())) << endl;
232  } else {
233  cout << " pdfLUT = [0] " << endl;
234  }
235 
236  const l1t::LUT *mlut = ptr1->meanDistPhiLUT();
237  if (mlut->maxSize()) {
238  cout << " meanDistPhiLUT = [" << mlut->maxSize() << "] " << flush;
239  int mlut_[mlut->maxSize()];
240  for (unsigned int i = 0; i < mlut->maxSize(); i++)
241  mlut_[i] = mlut->data(i);
242  cout << hash(mlut_, sizeof(int) * (mlut->maxSize())) << endl;
243  } else {
244  cout << " meanDistPhiLUT = [0] " << endl;
245  }
246 }
247 
251 
void openssl_init()
Definition: openssl_init.cc:5
void analyze(const edm::Event &, const edm::EventSetup &) override
unsigned int maxSize() const
Definition: LUT.h:55
unsigned int hwNumber
short layer number used within OMTF emulator
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned int logicNumber
logic numer of the layer
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
#define EVP_MD_CTX_free
Definition: openssl_init.h:7
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
#define EVP_MD_CTX_new
Definition: openssl_init.h:6
int data(unsigned int address) const
Definition: LUT.h:46
T get() const
Definition: EventSetup.h:82
L1TMuonOverlapParamsViewer(const edm::ParameterSet &pset)
bool bendingLayer
Is this a bending layers?
Definition: LUT.h:29
string hash(void *buf, size_t len) const
HLT enums.
double a
Definition: hdecay.h:119
tmp
align.sh
Definition: createJobs.py:716