CMS 3D CMS Logo

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(){
31  printPtaThreshold = false;
32  }
33  ~L1TMuonBarrelParamsViewer(void) override{}
34 };
35 
36 
37 #include <openssl/sha.h>
38 #include <cmath>
39 #include <iostream>
40 using namespace std;
41 
42 std::string L1TMuonBarrelParamsViewer::hash(void *buf, size_t len) const {
43  char tmp[SHA_DIGEST_LENGTH*2+1];
44  bzero(tmp,sizeof(tmp));
45  SHA_CTX ctx;
46  if( !SHA1_Init( &ctx ) )
47  throw cms::Exception("L1TMuonBarrelParamsViewer::hash")<<"SHA1 initialization error";
48 
49  if( !SHA1_Update( &ctx, buf, len ) )
50  throw cms::Exception("L1TMuonBarrelParamsViewer::hash")<<"SHA1 processing error";
51 
52  unsigned char hash[SHA_DIGEST_LENGTH];
53  if( !SHA1_Final(hash, &ctx) )
54  throw cms::Exception("L1TMuonBarrelParamsViewer::hash")<<"SHA1 finalization error";
55 
56  // re-write bytes in hex
57  for(unsigned int i=0; i<20; i++)
58  ::sprintf(&tmp[i*2], "%02x", hash[i]);
59 
60  tmp[20*2] = 0;
61  return std::string(tmp);
62 }
63 
64 
66 
68  evSetup.get<L1TMuonBarrelParamsRcd>().get( handle1 ) ;
69  boost::shared_ptr<L1TMuonBarrelParams> ptr(new L1TMuonBarrelParams(*(handle1.product ())));
70 
72 
73  cout << "AssLUTPath: " << ptr1->AssLUTPath() << endl;
74 
75  // typedef std::map<short, short, std::less<short> > LUT;
76 
77  for(size_t l=0; l<ptr1->pta_lut().size(); l++){
78  const LUT &lut = ptr1->pta_lut()[l];
79  if( !lut.empty() ){
80  cout<<" pta_lut[" << setw(2) << l << "]= ["<<lut.size()<<"] "<<flush;
81  int lut_[lut.size()], i=0;
82  for(const pair<short,short> &p : lut) lut_[i++] = p.first*0xFFFF + p.second;
83  cout << hash( lut_, sizeof(int)*lut.size() ) << endl;
84  } else {
85  cout<<" pta_lut[" << setw(2) << l << "]= [0] "<<endl;
86  }
87  }
88 
89  cout << " pta_threshold= [" << ptr1->pta_threshold().size() << "] "<<flush;
90  int pta_threshold[ptr1->pta_threshold().size()];
91  for(unsigned int i=0; i<ptr1->pta_threshold().size(); i++){
92  pta_threshold[i] = ptr1->pta_threshold()[i];
93  if( printPtaThreshold ) cout<<" "<<pta_threshold[i]<<endl;
94  }
95  if( !ptr1->pta_threshold().empty() )
96  cout << hash(pta_threshold, sizeof(int)*ptr1->pta_threshold().size()) << endl;
97  else cout<<endl;
98 
99  for(size_t l=0; l<ptr1->phi_lut().size(); l++){
100  const LUT &lut = ptr1->phi_lut()[l];
101  if( !lut.empty() ){
102  cout<<" phi_lut[" << l << "]= ["<<lut.size()<<"] "<<flush;
103  int lut_[lut.size()], i=0;
104  for(const pair<short,short> &p : lut) lut_[i++] = p.first*0xFFFF + p.second;
105  cout << hash( lut_, sizeof(int)*lut.size() ) << endl;
106  } else {
107  cout<<" phi_lut[" << l << "]= [0] "<<endl;
108  }
109  }
110 
111  for(size_t l=0; l<ptr1->ext_lut().size(); l++){
112  const LUT &lut = (ptr1->ext_lut()[l]).low;
113  if( !lut.empty() ){
114  cout<<" ext_lut_low[" << setw(2) << l << "]= ["<<lut.size()<<"] "<<flush;
115  int lut_[lut.size()], i=0;
116  for(const pair<short,short> &p : lut) lut_[i++] = p.first*0xFFFF + p.second;
117  cout << hash( lut_, sizeof(int)*lut.size() ) << endl;
118  } else {
119  cout<<" ext_lut_low[" << setw(2) << l << "]= [0] "<<endl;
120  }
121  }
122 
123  for(size_t l=0; l<ptr1->ext_lut().size(); l++){
124  const LUT &lut = (ptr1->ext_lut()[l]).high;
125  if( !lut.empty() ){
126  cout<<" ext_lut_high[" << setw(2) << l << "]= ["<<lut.size()<<"] "<<flush;
127  int lut_[lut.size()], i=0;
128  for(const pair<short,short> &p : lut) lut_[i++] = p.first*0xFFFF + p.second;
129  cout << hash( lut_, sizeof(int)*lut.size() ) << endl;
130  } else {
131  cout<<" ext_lut_high[" << setw(2) << l << "]= [0] "<<endl;
132  }
133  }
134 
135  // typedef std::map< LUTID, LUTCONT > qpLUT;
136  for(const pair< pair<short,short>, pair<short, vector<short>> > item : ptr1->qp_lut() ){
137  cout << " qp_lut[" << item.first.first << "," << item.first.second << "]= "
138  << item.second.first << ", [" << item.second.second.size() << "] " << flush;
139  if( !item.second.second.empty() ){
140  int lut_[item.second.second.size()];
141  for(size_t i=0; i<item.second.second.size(); i++) lut_[i] = item.second.second[i];
142  cout << hash( lut_, sizeof(int)*item.second.second.size() ) << endl;
143  } else {
144  cout << endl;
145  }
146  }
147 
148  // typedef std::map<short, L1MuDTEtaPattern, std::less<short> > etaLUT;
149  for(const pair<short, L1MuDTEtaPattern> &item : ptr1->eta_lut())
150  cout << " eta_lut[" << item.first << "]= " << endl << item.second << endl;
151 
152  cout << "PT_Assignment_nbits_Phi= " << ptr1->get_PT_Assignment_nbits_Phi() << endl;
153  cout << "PT_Assignment_nbits_PhiB= " << ptr1->get_PT_Assignment_nbits_PhiB() << endl;
154  cout << "PHI_Assignment_nbits_Phi= " << ptr1->get_PHI_Assignment_nbits_Phi() << endl;
155  cout << "PHI_Assignment_nbits_PhiB= " << ptr1->get_PHI_Assignment_nbits_PhiB() << endl;
156  cout << "Extrapolation_nbits_Phi= " << ptr1->get_Extrapolation_nbits_Phi() << endl;
157  cout << "Extrapolation_nbits_PhiB= " << ptr1->get_Extrapolation_nbits_PhiB() << endl;
158  cout << "BX_min= " << ptr1->get_BX_min() << endl;
159  cout << "BX_max= " << ptr1->get_BX_max() << endl;
160  cout << "Extrapolation_Filter= " << ptr1->get_Extrapolation_Filter() << endl;
161  cout << "OutOfTime_Filter_Window= " << ptr1->get_OutOfTime_Filter_Window() << endl;
162 
163  cout << boolalpha;
164  cout << "OutOfTime_Filter= " << ptr1->get_OutOfTime_Filter() << endl;
165  cout << "Open_LUTs= " << ptr1->get_Open_LUTs() << endl;
166  cout << "EtaTrackFinder= " << ptr1->get_EtaTrackFinder() << endl;
167  cout << "Extrapolation_21= " << ptr1->get_Extrapolation_21() << endl;
168  cout << "DisableNewAlgo= " << ptr1->get_DisableNewAlgo() << endl;
169  cout << noboolalpha;
170 
171  // FW version
172  cout << "fwVersion= " << ptr1->fwVersion() << endl;
173  cout << "version= " << ptr1->version_ << endl;
174 }
175 
179 
181 
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
const T & get() const
Definition: EventSetup.h:59
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
L1TMuonBarrelParamsViewer(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::string hash(void *buf, size_t len) const
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:32
T const * product() const
Definition: ESHandle.h:86