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:
25 
26 public:
27  void analyze(const edm::Event &, const edm::EventSetup &) override;
28  string hash(void *buf, size_t len) const;
29 
31  printLayerMap = pset.getUntrackedParameter<bool>("printLayerMap", false);
32  }
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
70  L1TMuonOverlapParams const &ptr1 = evSetup.getData(token_);
71 
72  cout << "Some fields in L1TMuonOverlapParamsParams: " << endl;
73 
74  cout << " fwVersion() = " << ptr1.fwVersion() << endl;
75  cout << " nPdfAddrBits() = " << ptr1.nPdfAddrBits() << endl;
76  cout << " nPdfValBits() = " << ptr1.nPdfValBits() << endl;
77  cout << " nHitsPerLayer() = " << ptr1.nHitsPerLayer() << endl;
78  cout << " nPhiBits() = " << ptr1.nPhiBits() << endl;
79  cout << " nPhiBins() = " << ptr1.nPhiBins() << endl;
80  cout << " nRefHits() = " << ptr1.nRefHits() << endl;
81  cout << " nTestRefHits() = " << ptr1.nTestRefHits() << endl;
82  cout << " nProcessors() = " << ptr1.nProcessors() << endl;
83  cout << " nLogicRegions() = " << ptr1.nLogicRegions() << endl;
84  cout << " nInputs() = " << ptr1.nInputs() << endl;
85  cout << " nLayers() = " << ptr1.nLayers() << endl;
86  cout << " nRefLayers() = " << ptr1.nRefLayers() << endl;
87  cout << " nGoldenPatterns() = " << ptr1.nGoldenPatterns() << endl;
88 
89  const std::vector<int> *gp = ptr1.generalParams();
90  cout << " number of general parameters: = " << gp->size() << endl;
91  cout << " ";
92  for (auto a : *gp)
93  cout << a << ", ";
94  cout << endl;
95 
96  const std::vector<L1TMuonOverlapParams::LayerMapNode> *lm = ptr1.layerMap();
97  if (!lm->empty()) {
98  cout << " layerMap() = [" << lm->size() << "] ";
100  for (unsigned int i = 0; i < lm->size(); i++)
101  lm_[i] = (*lm)[i];
102  cout << hash(lm_, sizeof(L1TMuonOverlapParams::LayerMapNode) * (lm->size())) << endl;
103  if (printLayerMap) {
104  cout << sizeof(L1TMuonOverlapParams::LayerMapNode) << endl;
105  for (unsigned int i = 0; i < lm->size(); i++) {
106  cout << " [" << i << "]: hwNumber = " << lm_[i].hwNumber << " logicNumber = " << lm_[i].logicNumber
107  << " bendingLayer = " << lm_[i].bendingLayer << " connectedToLayer = " << lm_[i].connectedToLayer << " ("
108  << flush;
109  char *n = (char *)(&(lm_[i]));
110  for (unsigned int j = 0; j < sizeof(L1TMuonOverlapParams::LayerMapNode); j++)
111  cout << "0x" << hex << int(*(n + j)) << dec << ", ";
112  cout << endl;
113  }
114  // hash( (void*)(&(lm_[i])), sizeof(L1TMuonOverlapParams::LayerMapNode) ) <<endl;
115  }
116  delete[] lm_;
117  } else {
118  cout << " layerMap() = [0] " << endl;
119  }
120 
121  const std::vector<L1TMuonOverlapParams::RefLayerMapNode> *rlm = ptr1.refLayerMap();
122  if (!rlm->empty()) {
123  cout << " refLayerMap() = [" << rlm->size() << "] ";
125  for (unsigned int i = 0; i < rlm->size(); i++)
126  rlm_[i] = (*rlm)[i];
127  cout << hash(rlm_, sizeof(L1TMuonOverlapParams::RefLayerMapNode) * (rlm->size())) << endl;
128  delete[] rlm_;
129  } else {
130  cout << " refLayerMap() = [0] " << endl;
131  }
132 
133  const std::vector<L1TMuonOverlapParams::RefHitNode> *rhn = ptr1.refHitMap();
134  if (!rhn->empty()) {
135  cout << " refHitMap() = [" << rhn->size() << "] ";
137  for (unsigned int i = 0; i < rhn->size(); i++)
138  rhn_[i] = (*rhn)[i];
139  cout << hash(rhn_, sizeof(L1TMuonOverlapParams::RefHitNode) * (rhn->size())) << endl;
140  delete[] rhn_;
141  } else {
142  cout << " refHitMap() = [0] " << endl;
143  }
144 
145  const std::vector<int> *gpsm = ptr1.globalPhiStartMap();
146  if (!gpsm->empty()) {
147  cout << " globalPhiStartMap() = [" << gpsm->size() << "] ";
148  int gpsm_[gpsm->size()];
149  for (unsigned int i = 0; i < gpsm->size(); i++)
150  gpsm_[i] = (*gpsm)[i];
151  cout << hash(gpsm_, sizeof(int) * (gpsm->size())) << endl;
152  } else {
153  cout << " globalPhiStartMap() = [0] " << endl;
154  }
155 
156  const std::vector<L1TMuonOverlapParams::LayerInputNode> *lim = ptr1.layerInputMap();
157  if (!lim->empty()) {
158  cout << " layerInputMap() = [" << lim->size() << "] ";
160  for (unsigned int i = 0; i < lim->size(); i++)
161  lim_[i] = (*lim)[i];
162  cout << hash(lim_, sizeof(L1TMuonOverlapParams::LayerInputNode) * (lim->size())) << endl;
163  delete[] lim_;
164  } else {
165  cout << " layerInputMap() = [0] " << endl;
166  }
167 
168  const std::vector<int> *css = ptr1.connectedSectorsStart();
169  if (!css->empty()) {
170  cout << " connectedSectorsStart() = [" << css->size() << "] ";
171  int css_[css->size()];
172  for (unsigned int i = 0; i < css->size(); i++)
173  css_[i] = (*css)[i];
174  cout << hash(css_, sizeof(int) * (css->size())) << endl;
175  } else {
176  cout << " connectedSectorsStart() = [0] " << endl;
177  }
178 
179  const std::vector<int> *cse = ptr1.connectedSectorsEnd();
180  if (!cse->empty()) {
181  cout << " connectedSectorsEnd() = [" << cse->size() << "] ";
182  int cse_[cse->size()];
183  for (unsigned int i = 0; i < cse->size(); i++)
184  cse_[i] = (*cse)[i];
185  cout << hash(cse_, sizeof(int) * (cse->size())) << endl;
186  } else {
187  cout << " connectedSectorsEnd() = [0] " << endl;
188  }
189 
190  const l1t::LUT *clut = ptr1.chargeLUT();
191  if (clut->maxSize()) {
192  cout << " chargeLUT = [" << clut->maxSize() << "] ";
193  int clut_[clut->maxSize()];
194  for (unsigned int i = 0; i < clut->maxSize(); i++)
195  clut_[i] = clut->data(i);
196  cout << hash(clut_, sizeof(int) * (clut->maxSize())) << endl;
197  } else {
198  cout << " chargeLUT = [0] " << endl;
199  }
200 
201  const l1t::LUT *elut = ptr1.etaLUT();
202  if (elut->maxSize()) {
203  cout << " etaLUT = [" << elut->maxSize() << "] ";
204  int elut_[elut->maxSize()];
205  for (unsigned int i = 0; i < elut->maxSize(); i++)
206  elut_[i] = elut->data(i);
207  cout << hash(elut_, sizeof(int) * (elut->maxSize())) << endl;
208  } else {
209  cout << " chargeLUT = [0] " << endl;
210  }
211 
212  const l1t::LUT *ptlut = ptr1.ptLUT();
213  if (ptlut->maxSize()) {
214  cout << " ptLUT = [" << ptlut->maxSize() << "] " << flush;
215  int ptlut_[ptlut->maxSize()];
216  for (unsigned int i = 0; i < ptlut->maxSize(); i++)
217  ptlut_[i] = ptlut->data(i);
218  cout << hash(ptlut_, sizeof(int) * (ptlut->maxSize())) << endl;
219  } else {
220  cout << " ptLUT = [0] " << endl;
221  }
222 
223  const l1t::LUT *plut = ptr1.pdfLUT();
224  if (plut->maxSize()) {
225  cout << " pdfLUT = [" << plut->maxSize() << "] " << flush;
226  int plut_[plut->maxSize()];
227  for (unsigned int i = 0; i < plut->maxSize(); i++)
228  plut_[i] = plut->data(i);
229  cout << hash(plut_, sizeof(int) * (plut->maxSize())) << endl;
230  } else {
231  cout << " pdfLUT = [0] " << endl;
232  }
233 
234  const l1t::LUT *mlut = ptr1.meanDistPhiLUT();
235  if (mlut->maxSize()) {
236  cout << " meanDistPhiLUT = [" << mlut->maxSize() << "] " << flush;
237  int mlut_[mlut->maxSize()];
238  for (unsigned int i = 0; i < mlut->maxSize(); i++)
239  mlut_[i] = mlut->data(i);
240  cout << hash(mlut_, sizeof(int) * (mlut->maxSize())) << endl;
241  } else {
242  cout << " meanDistPhiLUT = [0] " << endl;
243  }
244 }
245 
249 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void openssl_init()
Definition: openssl_init.cc:5
const std::vector< int > * generalParams() const
General definitions.
void analyze(const edm::Event &, const edm::EventSetup &) override
unsigned int maxSize() const
Definition: LUT.h:55
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const l1t::LUT * chargeLUT() const
Golden Patterns definitions.
unsigned int hwNumber
short layer number used within OMTF emulator
unsigned int logicNumber
logic numer of the layer
const std::vector< LayerMapNode > * layerMap() const
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
#define EVP_MD_CTX_free
Definition: openssl_init.h:7
const std::vector< LayerInputNode > * layerInputMap() const
edm::ESGetToken< L1TMuonOverlapParams, L1TMuonOverlapParamsRcd > token_
int nPdfAddrBits() const
Access to specific general settings.
int iEvent
Definition: GenABIO.cc:224
#define EVP_MD_CTX_new
Definition: openssl_init.h:6
int data(unsigned int address) const
Definition: LUT.h:46
const l1t::LUT * pdfLUT() const
unsigned fwVersion() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TMuonOverlapParamsViewer(const edm::ParameterSet &pset)
bool bendingLayer
Is this a bending layers?
Definition: LUT.h:29
string hash(void *buf, size_t len) const
const std::vector< int > * connectedSectorsEnd() const
double a
Definition: hdecay.h:119
const l1t::LUT * meanDistPhiLUT() const
const std::vector< RefLayerMapNode > * refLayerMap() const
const std::vector< int > * connectedSectorsStart() const
const l1t::LUT * ptLUT() const
const std::vector< RefHitNode > * refHitMap() const
const std::vector< int > * globalPhiStartMap() const
tmp
align.sh
Definition: createJobs.py:716
const l1t::LUT * etaLUT() const