CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
35 #include <openssl/sha.h>
36 #include <cmath>
37 #include <iostream>
38 using namespace std;
39 
40 string L1TMuonOverlapParamsViewer::hash(void *buf, size_t len) const {
41  char tmp[SHA_DIGEST_LENGTH * 2 + 1];
42  bzero(tmp, sizeof(tmp));
43  SHA_CTX ctx;
44  if (!SHA1_Init(&ctx))
45  throw cms::Exception("L1TCaloParamsViewer::hash") << "SHA1 initialization error";
46 
47  if (!SHA1_Update(&ctx, buf, len))
48  throw cms::Exception("L1TCaloParamsViewer::hash") << "SHA1 processing error";
49 
50  unsigned char hash[SHA_DIGEST_LENGTH];
51  if (!SHA1_Final(hash, &ctx))
52  throw cms::Exception("L1TCaloParamsViewer::hash") << "SHA1 finalization error";
53 
54  // re-write bytes in hex
55  for (unsigned int i = 0; i < 20; i++)
56  ::sprintf(&tmp[i * 2], "%02x", hash[i]);
57 
58  tmp[20 * 2] = 0;
59  return string(tmp);
60 }
61 
63  // Pull the config from the ES
65  evSetup.get<L1TMuonOverlapParamsRcd>().get(handle1);
66  std::shared_ptr<L1TMuonOverlapParams> ptr1(new L1TMuonOverlapParams(*(handle1.product())));
67 
68  cout << "Some fields in L1TMuonOverlapParamsParams: " << endl;
69 
70  cout << " fwVersion() = " << ptr1->fwVersion() << endl;
71  cout << " nPdfAddrBits() = " << ptr1->nPdfAddrBits() << endl;
72  cout << " nPdfValBits() = " << ptr1->nPdfValBits() << endl;
73  cout << " nHitsPerLayer() = " << ptr1->nHitsPerLayer() << endl;
74  cout << " nPhiBits() = " << ptr1->nPhiBits() << endl;
75  cout << " nPhiBins() = " << ptr1->nPhiBins() << endl;
76  cout << " nRefHits() = " << ptr1->nRefHits() << endl;
77  cout << " nTestRefHits() = " << ptr1->nTestRefHits() << endl;
78  cout << " nProcessors() = " << ptr1->nProcessors() << endl;
79  cout << " nLogicRegions() = " << ptr1->nLogicRegions() << endl;
80  cout << " nInputs() = " << ptr1->nInputs() << endl;
81  cout << " nLayers() = " << ptr1->nLayers() << endl;
82  cout << " nRefLayers() = " << ptr1->nRefLayers() << endl;
83  cout << " nGoldenPatterns() = " << ptr1->nGoldenPatterns() << endl;
84 
85  const std::vector<int> *gp = ptr1->generalParams();
86  cout << " number of general parameters: = " << gp->size() << endl;
87  cout << " ";
88  for (auto a : *gp)
89  cout << a << ", ";
90  cout << endl;
91 
92  const std::vector<L1TMuonOverlapParams::LayerMapNode> *lm = ptr1->layerMap();
93  if (!lm->empty()) {
94  cout << " layerMap() = [" << lm->size() << "] ";
96  for (unsigned int i = 0; i < lm->size(); i++)
97  lm_[i] = (*lm)[i];
98  cout << hash(lm_, sizeof(L1TMuonOverlapParams::LayerMapNode) * (lm->size())) << endl;
99  if (printLayerMap) {
100  cout << sizeof(L1TMuonOverlapParams::LayerMapNode) << endl;
101  for (unsigned int i = 0; i < lm->size(); i++) {
102  cout << " [" << i << "]: hwNumber = " << lm_[i].hwNumber << " logicNumber = " << lm_[i].logicNumber
103  << " bendingLayer = " << lm_[i].bendingLayer << " connectedToLayer = " << lm_[i].connectedToLayer << " ("
104  << flush;
105  char *n = (char *)(&(lm_[i]));
106  for (unsigned int j = 0; j < sizeof(L1TMuonOverlapParams::LayerMapNode); j++)
107  cout << "0x" << hex << int(*(n + j)) << dec << ", ";
108  cout << endl;
109  }
110  // hash( (void*)(&(lm_[i])), sizeof(L1TMuonOverlapParams::LayerMapNode) ) <<endl;
111  }
112  delete[] lm_;
113  } else {
114  cout << " layerMap() = [0] " << endl;
115  }
116 
117  const std::vector<L1TMuonOverlapParams::RefLayerMapNode> *rlm = ptr1->refLayerMap();
118  if (!rlm->empty()) {
119  cout << " refLayerMap() = [" << rlm->size() << "] ";
121  for (unsigned int i = 0; i < rlm->size(); i++)
122  rlm_[i] = (*rlm)[i];
123  cout << hash(rlm_, sizeof(L1TMuonOverlapParams::RefLayerMapNode) * (rlm->size())) << endl;
124  delete[] rlm_;
125  } else {
126  cout << " refLayerMap() = [0] " << endl;
127  }
128 
129  const std::vector<L1TMuonOverlapParams::RefHitNode> *rhn = ptr1->refHitMap();
130  if (!rhn->empty()) {
131  cout << " refHitMap() = [" << rhn->size() << "] ";
133  for (unsigned int i = 0; i < rhn->size(); i++)
134  rhn_[i] = (*rhn)[i];
135  cout << hash(rhn_, sizeof(L1TMuonOverlapParams::RefHitNode) * (rhn->size())) << endl;
136  delete[] rhn_;
137  } else {
138  cout << " refHitMap() = [0] " << endl;
139  }
140 
141  const std::vector<int> *gpsm = ptr1->globalPhiStartMap();
142  if (!gpsm->empty()) {
143  cout << " globalPhiStartMap() = [" << gpsm->size() << "] ";
144  int gpsm_[gpsm->size()];
145  for (unsigned int i = 0; i < gpsm->size(); i++)
146  gpsm_[i] = (*gpsm)[i];
147  cout << hash(gpsm_, sizeof(int) * (gpsm->size())) << endl;
148  } else {
149  cout << " globalPhiStartMap() = [0] " << endl;
150  }
151 
152  const std::vector<L1TMuonOverlapParams::LayerInputNode> *lim = ptr1->layerInputMap();
153  if (!lim->empty()) {
154  cout << " layerInputMap() = [" << lim->size() << "] ";
156  for (unsigned int i = 0; i < lim->size(); i++)
157  lim_[i] = (*lim)[i];
158  cout << hash(lim_, sizeof(L1TMuonOverlapParams::LayerInputNode) * (lim->size())) << endl;
159  delete[] lim_;
160  } else {
161  cout << " layerInputMap() = [0] " << endl;
162  }
163 
164  const std::vector<int> *css = ptr1->connectedSectorsStart();
165  if (!css->empty()) {
166  cout << " connectedSectorsStart() = [" << css->size() << "] ";
167  int css_[css->size()];
168  for (unsigned int i = 0; i < css->size(); i++)
169  css_[i] = (*css)[i];
170  cout << hash(css_, sizeof(int) * (css->size())) << endl;
171  } else {
172  cout << " connectedSectorsStart() = [0] " << endl;
173  }
174 
175  const std::vector<int> *cse = ptr1->connectedSectorsEnd();
176  if (!cse->empty()) {
177  cout << " connectedSectorsEnd() = [" << cse->size() << "] ";
178  int cse_[cse->size()];
179  for (unsigned int i = 0; i < cse->size(); i++)
180  cse_[i] = (*cse)[i];
181  cout << hash(cse_, sizeof(int) * (cse->size())) << endl;
182  } else {
183  cout << " connectedSectorsEnd() = [0] " << endl;
184  }
185 
186  const l1t::LUT *clut = ptr1->chargeLUT();
187  if (clut->maxSize()) {
188  cout << " chargeLUT = [" << clut->maxSize() << "] ";
189  int clut_[clut->maxSize()];
190  for (unsigned int i = 0; i < clut->maxSize(); i++)
191  clut_[i] = clut->data(i);
192  cout << hash(clut_, sizeof(int) * (clut->maxSize())) << endl;
193  } else {
194  cout << " chargeLUT = [0] " << endl;
195  }
196 
197  const l1t::LUT *elut = ptr1->etaLUT();
198  if (elut->maxSize()) {
199  cout << " etaLUT = [" << elut->maxSize() << "] ";
200  int elut_[elut->maxSize()];
201  for (unsigned int i = 0; i < elut->maxSize(); i++)
202  elut_[i] = elut->data(i);
203  cout << hash(elut_, sizeof(int) * (elut->maxSize())) << endl;
204  } else {
205  cout << " chargeLUT = [0] " << endl;
206  }
207 
208  const l1t::LUT *ptlut = ptr1->ptLUT();
209  if (ptlut->maxSize()) {
210  cout << " ptLUT = [" << ptlut->maxSize() << "] " << flush;
211  int ptlut_[ptlut->maxSize()];
212  for (unsigned int i = 0; i < ptlut->maxSize(); i++)
213  ptlut_[i] = ptlut->data(i);
214  cout << hash(ptlut_, sizeof(int) * (ptlut->maxSize())) << endl;
215  } else {
216  cout << " ptLUT = [0] " << endl;
217  }
218 
219  const l1t::LUT *plut = ptr1->pdfLUT();
220  if (plut->maxSize()) {
221  cout << " pdfLUT = [" << plut->maxSize() << "] " << flush;
222  int plut_[plut->maxSize()];
223  for (unsigned int i = 0; i < plut->maxSize(); i++)
224  plut_[i] = plut->data(i);
225  cout << hash(plut_, sizeof(int) * (plut->maxSize())) << endl;
226  } else {
227  cout << " pdfLUT = [0] " << endl;
228  }
229 
230  const l1t::LUT *mlut = ptr1->meanDistPhiLUT();
231  if (mlut->maxSize()) {
232  cout << " meanDistPhiLUT = [" << mlut->maxSize() << "] " << flush;
233  int mlut_[mlut->maxSize()];
234  for (unsigned int i = 0; i < mlut->maxSize(); i++)
235  mlut_[i] = mlut->data(i);
236  cout << hash(mlut_, sizeof(int) * (mlut->maxSize())) << endl;
237  } else {
238  cout << " meanDistPhiLUT = [0] " << endl;
239  }
240 }
241 
245 
T getUntrackedParameter(std::string const &, T const &) const
string hash(void *buf, size_t len) const
void analyze(const edm::Event &, const edm::EventSetup &) override
unsigned int hwNumber
short layer number used within OMTF emulator
unsigned int maxSize() const
Definition: LUT.h:55
#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
int iEvent
Definition: GenABIO.cc:224
L1TMuonOverlapParamsViewer(const edm::ParameterSet &pset)
bool bendingLayer
Is this a bending layers?
Definition: LUT.h:29
T const * product() const
Definition: ESHandle.h:86
double a
Definition: hdecay.h:119
T get() const
Definition: EventSetup.h:88
tuple cout
Definition: gather_cfg.py:144
int data(unsigned int address) const
Definition: LUT.h:46
tmp
align.sh
Definition: createJobs.py:716