CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TMuonBarrelParamsViewer.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <iostream>
3 
5 
8 
11 
18 
19 #include <iostream>
20 using namespace std;
21 
23 private:
24  std::string hash(void *buf, size_t len) const;
26 
27 public:
28  void analyze(const edm::Event &, const edm::EventSetup &) override;
29 
30  explicit L1TMuonBarrelParamsViewer(const edm::ParameterSet &) : edm::EDAnalyzer() { printPtaThreshold = false; }
31  ~L1TMuonBarrelParamsViewer(void) override {}
32 };
33 
34 #include <openssl/sha.h>
35 #include <cmath>
36 #include <iostream>
37 using namespace std;
38 
40  char tmp[SHA_DIGEST_LENGTH * 2 + 1];
41  bzero(tmp, sizeof(tmp));
42  SHA_CTX ctx;
43  if (!SHA1_Init(&ctx))
44  throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 initialization error";
45 
46  if (!SHA1_Update(&ctx, buf, len))
47  throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 processing error";
48 
49  unsigned char hash[SHA_DIGEST_LENGTH];
50  if (!SHA1_Final(hash, &ctx))
51  throw cms::Exception("L1TMuonBarrelParamsViewer::hash") << "SHA1 finalization error";
52 
53  // re-write bytes in hex
54  for (unsigned int i = 0; i < 20; i++)
55  ::sprintf(&tmp[i * 2], "%02x", hash[i]);
56 
57  tmp[20 * 2] = 0;
58  return std::string(tmp);
59 }
60 
63  evSetup.get<L1TMuonBarrelParamsRcd>().get(handle1);
64  std::shared_ptr<L1TMuonBarrelParams> ptr(new L1TMuonBarrelParams(*(handle1.product())));
65 
67 
68  cout << "AssLUTPath: " << ptr1->AssLUTPath() << endl;
69 
70  // typedef std::map<short, short, std::less<short> > LUT;
71 
72  size_t k = 0; // avoid using l
73  for (const auto &lut : ptr1->pta_lut()) {
74  if (!lut.empty()) {
75  cout << " pta_lut[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
76  int lut_[lut.size()], i = 0;
77  for (const pair<const short, short> &p : lut)
78  lut_[i++] = p.first * 0xFFFF + p.second;
79  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
80  } else {
81  cout << " pta_lut[" << setw(2) << k << "]= [0] " << endl;
82  }
83  k++;
84  }
85 
86  cout << " pta_threshold= [" << ptr1->pta_threshold().size() << "] " << flush;
87  int pta_threshold[ptr1->pta_threshold().size()];
88  for (unsigned int i = 0; i < ptr1->pta_threshold().size(); i++) {
89  pta_threshold[i] = ptr1->pta_threshold()[i];
90  if (printPtaThreshold)
91  cout << " " << pta_threshold[i] << endl;
92  }
93  if (!ptr1->pta_threshold().empty())
94  cout << hash(pta_threshold, sizeof(int) * ptr1->pta_threshold().size()) << endl;
95  else
96  cout << endl;
97 
98  k = 0;
99  for (const auto &lut : ptr1->pta_lut()) {
100  if (!lut.empty()) {
101  cout << " phi_lut[" << k << "]= [" << lut.size() << "] " << flush;
102  int lut_[lut.size()], i = 0;
103  for (const pair<const short, short> &p : lut)
104  lut_[i++] = p.first * 0xFFFF + p.second;
105  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
106  } else {
107  cout << " phi_lut[" << k << "]= [0] " << endl;
108  }
109  k++;
110  }
111 
112  k = 0;
113  for (const auto &lu : ptr1->ext_lut()) {
114  const auto &lut = lu.low;
115  if (!lut.empty()) {
116  cout << " ext_lut_low[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
117  int lut_[lut.size()], i = 0;
118  for (const pair<const short, short> &p : lut)
119  lut_[i++] = p.first * 0xFFFF + p.second;
120  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
121  } else {
122  cout << " ext_lut_low[" << setw(2) << k << "]= [0] " << endl;
123  }
124  k++;
125  }
126 
127  k = 0;
128  for (const auto &lu : ptr1->ext_lut()) {
129  const auto &lut = lu.high;
130  if (!lut.empty()) {
131  cout << " ext_lut_high[" << setw(2) << k << "]= [" << lut.size() << "] " << flush;
132  int lut_[lut.size()], i = 0;
133  for (const pair<const short, short> &p : lut)
134  lut_[i++] = p.first * 0xFFFF + p.second;
135  cout << hash(lut_, sizeof(int) * lut.size()) << endl;
136  } else {
137  cout << " ext_lut_high[" << setw(2) << k << "]= [0] " << endl;
138  }
139  k++;
140  }
141 
142  // typedef std::map< LUTID, LUTCONT > qpLUT;
143  for (const auto &item : ptr1->qp_lut()) {
144  cout << " qp_lut[" << item.first.first << "," << item.first.second << "]= " << item.second.first << ", ["
145  << item.second.second.size() << "] " << flush;
146  if (!item.second.second.empty()) {
147  int lut_[item.second.second.size()];
148  for (size_t i = 0; i < item.second.second.size(); i++)
149  lut_[i] = item.second.second[i];
150  cout << hash(lut_, sizeof(int) * item.second.second.size()) << endl;
151  } else {
152  cout << endl;
153  }
154  }
155 
156  // typedef std::map<short, L1MuDTEtaPattern, std::less<short> > etaLUT;
157  for (const pair<const short, L1MuDTEtaPattern> &item : ptr1->eta_lut())
158  cout << " eta_lut[" << item.first << "]= " << endl << item.second << endl;
159 
160  cout << "PT_Assignment_nbits_Phi= " << ptr1->get_PT_Assignment_nbits_Phi() << endl;
161  cout << "PT_Assignment_nbits_PhiB= " << ptr1->get_PT_Assignment_nbits_PhiB() << endl;
162  cout << "PHI_Assignment_nbits_Phi= " << ptr1->get_PHI_Assignment_nbits_Phi() << endl;
163  cout << "PHI_Assignment_nbits_PhiB= " << ptr1->get_PHI_Assignment_nbits_PhiB() << endl;
164  cout << "Extrapolation_nbits_Phi= " << ptr1->get_Extrapolation_nbits_Phi() << endl;
165  cout << "Extrapolation_nbits_PhiB= " << ptr1->get_Extrapolation_nbits_PhiB() << endl;
166  cout << "BX_min= " << ptr1->get_BX_min() << endl;
167  cout << "BX_max= " << ptr1->get_BX_max() << endl;
168  cout << "Extrapolation_Filter= " << ptr1->get_Extrapolation_Filter() << endl;
169  cout << "OutOfTime_Filter_Window= " << ptr1->get_OutOfTime_Filter_Window() << endl;
170 
171  cout << boolalpha;
172  cout << "OutOfTime_Filter= " << ptr1->get_OutOfTime_Filter() << endl;
173  cout << "Open_LUTs= " << ptr1->get_Open_LUTs() << endl;
174  cout << "EtaTrackFinder= " << ptr1->get_EtaTrackFinder() << endl;
175  cout << "Extrapolation_21= " << ptr1->get_Extrapolation_21() << endl;
176  cout << "DisableNewAlgo= " << ptr1->get_DisableNewAlgo() << endl;
177  cout << noboolalpha;
178 
179  // FW version
180  cout << "fwVersion= " << ptr1->fwVersion() << endl;
181  cout << "version= " << ptr1->version_ << endl;
182 }
183 
187 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
L1TMuonBarrelParamsViewer(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override
T get() const
Definition: EventSetup.h:88
tuple cout
Definition: gather_cfg.py:144
std::string hash(void *buf, size_t len) const
tmp
align.sh
Definition: createJobs.py:716