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 public:
25  void analyze(const edm::Event&, const edm::EventSetup&) override ;
26  string hash(void *buf, size_t len) const ;
27 
28  explicit L1TMuonOverlapParamsViewer(const edm::ParameterSet& pset) : edm::EDAnalyzer(){
29  printLayerMap = pset.getUntrackedParameter<bool>("printLayerMap", false);
30  }
31  ~L1TMuonOverlapParamsViewer(void) override {}
32 };
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 
64  // Pull the config from the ES
66  evSetup.get<L1TMuonOverlapParamsRcd>().get( handle1 ) ;
67  boost::shared_ptr<L1TMuonOverlapParams> ptr1(new L1TMuonOverlapParams(*(handle1.product ())));
68 
69  cout<<"Some fields in L1TMuonOverlapParamsParams: "<<endl;
70 
71  cout<<" fwVersion() = "<<ptr1->fwVersion()<<endl;
72  cout<<" nPdfAddrBits() = "<<ptr1->nPdfAddrBits()<<endl;
73  cout<<" nPdfValBits() = "<<ptr1->nPdfValBits()<<endl;
74  cout<<" nHitsPerLayer() = "<<ptr1->nHitsPerLayer()<<endl;
75  cout<<" nPhiBits() = "<<ptr1->nPhiBits()<<endl;
76  cout<<" nPhiBins() = "<<ptr1->nPhiBins()<<endl;
77  cout<<" nRefHits() = "<<ptr1->nRefHits()<<endl;
78  cout<<" nTestRefHits() = "<<ptr1->nTestRefHits()<<endl;
79  cout<<" nProcessors() = "<<ptr1->nProcessors()<<endl;
80  cout<<" nLogicRegions() = "<<ptr1->nLogicRegions()<<endl;
81  cout<<" nInputs() = "<<ptr1->nInputs()<<endl;
82  cout<<" nLayers() = "<<ptr1->nLayers()<<endl;
83  cout<<" nRefLayers() = "<<ptr1->nRefLayers()<<endl;
84  cout<<" nGoldenPatterns() = "<<ptr1->nGoldenPatterns()<<endl;
85 
86  const std::vector<int>* gp = ptr1->generalParams();
87  cout<<" number of general parameters: = "<<gp->size()<<endl;
88  cout<<" ";
89  for(auto a : *gp) 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++) lm_[i] = (*lm)[i];
97  cout << hash( lm_, sizeof(L1TMuonOverlapParams::LayerMapNode)*(lm->size()) ) << endl;
98  if( printLayerMap ){
100  for(unsigned int i=0; i<lm->size(); i++){
101  cout<<" ["<<i<<"]: hwNumber = "<<lm_[i].hwNumber<<" logicNumber = "<<lm_[i].logicNumber<<" bendingLayer = "<<lm_[i].bendingLayer<<" connectedToLayer = "<<lm_[i].connectedToLayer<<" ("<<flush;
102  char *n = (char*)(&(lm_[i]));
103  for(unsigned int j=0; j<sizeof(L1TMuonOverlapParams::LayerMapNode); j++) cout<<"0x"<<hex<<int(*(n+j))<<dec<<", ";
104  cout<<endl;
105  }
106 // hash( (void*)(&(lm_[i])), sizeof(L1TMuonOverlapParams::LayerMapNode) ) <<endl;
107  }
108  delete [] lm_;
109  } else {
110  cout<<" layerMap() = [0] "<<endl;
111  }
112 
113  const std::vector<L1TMuonOverlapParams::RefLayerMapNode> *rlm = ptr1->refLayerMap();
114  if( !rlm->empty() ){
115  cout<<" refLayerMap() = ["<<rlm->size()<<"] ";
117  for(unsigned int i=0; i<rlm->size(); i++) rlm_[i] = (*rlm)[i];
118  cout << hash( rlm_, sizeof(L1TMuonOverlapParams::RefLayerMapNode)*(rlm->size()) ) << endl;
119  delete [] rlm_;
120  } else {
121  cout<<" refLayerMap() = [0] "<<endl;
122  }
123 
124  const std::vector<L1TMuonOverlapParams::RefHitNode> *rhn = ptr1->refHitMap();
125  if( !rhn->empty() ){
126  cout<<" refHitMap() = ["<<rhn->size()<<"] ";
128  for(unsigned int i=0; i<rhn->size(); i++) rhn_[i] = (*rhn)[i];
129  cout << hash( rhn_, sizeof(L1TMuonOverlapParams::RefHitNode)*(rhn->size()) ) << endl;
130  delete [] rhn_;
131  } else {
132  cout<<" refHitMap() = [0] "<<endl;
133  }
134 
135  const std::vector<int> *gpsm = ptr1->globalPhiStartMap();
136  if( !gpsm->empty() ){
137  cout<<" globalPhiStartMap() = ["<<gpsm->size()<<"] ";
138  int gpsm_[gpsm->size()];
139  for(unsigned int i=0; i<gpsm->size(); i++) gpsm_[i] = (*gpsm)[i];
140  cout << hash( gpsm_, sizeof(int)*(gpsm->size()) ) << endl;
141  } else {
142  cout<<" globalPhiStartMap() = [0] "<<endl;
143  }
144 
145  const std::vector<L1TMuonOverlapParams::LayerInputNode> *lim = ptr1->layerInputMap();
146  if( !lim->empty() ){
147  cout<<" layerInputMap() = ["<<lim->size()<<"] ";
149  for(unsigned int i=0; i<lim->size(); i++) lim_[i] = (*lim)[i];
150  cout << hash( lim_, sizeof(L1TMuonOverlapParams::LayerInputNode)*(lim->size()) ) << endl;
151  delete [] lim_;
152  } else {
153  cout<<" layerInputMap() = [0] "<<endl;
154  }
155 
156  const std::vector<int> *css = ptr1->connectedSectorsStart();
157  if( !css->empty() ){
158  cout<<" connectedSectorsStart() = ["<<css->size()<<"] ";
159  int css_[css->size()];
160  for(unsigned int i=0; i<css->size(); i++) css_[i] = (*css)[i];
161  cout << hash( css_, sizeof(int)*(css->size()) ) << endl;
162  } else {
163  cout<<" connectedSectorsStart() = [0] "<<endl;
164  }
165 
166  const std::vector<int> *cse = ptr1->connectedSectorsEnd();
167  if( !cse->empty() ){
168  cout<<" connectedSectorsEnd() = ["<<cse->size()<<"] ";
169  int cse_[cse->size()];
170  for(unsigned int i=0; i<cse->size(); i++) cse_[i] = (*cse)[i];
171  cout << hash( cse_, sizeof(int)*(cse->size()) ) << endl;
172  } else {
173  cout<<" connectedSectorsEnd() = [0] "<<endl;
174  }
175 
176 
177  const l1t::LUT *clut = ptr1->chargeLUT();
178  if( clut->maxSize() ){
179  cout<<" chargeLUT = ["<<clut->maxSize()<<"] ";
180  int clut_[clut->maxSize()];
181  for(unsigned int i=0; i<clut->maxSize(); i++) clut_[i] = clut->data(i);
182  cout << hash( clut_, sizeof(int)*(clut->maxSize()) ) << endl;
183  } else {
184  cout<<" chargeLUT = [0] "<<endl;
185  }
186 
187  const l1t::LUT *elut = ptr1->etaLUT();
188  if( elut->maxSize() ){
189  cout<<" etaLUT = ["<<elut->maxSize()<<"] ";
190  int elut_[elut->maxSize()];
191  for(unsigned int i=0; i<elut->maxSize(); i++) elut_[i] = elut->data(i);
192  cout << hash( elut_, sizeof(int)*(elut->maxSize()) ) << endl;
193  } else {
194  cout<<" chargeLUT = [0] "<<endl;
195  }
196 
197  const l1t::LUT *ptlut = ptr1->ptLUT();
198  if( ptlut->maxSize() ){
199  cout<<" ptLUT = ["<<ptlut->maxSize()<<"] "<<flush;
200  int ptlut_[ptlut->maxSize()];
201  for(unsigned int i=0; i<ptlut->maxSize(); i++) ptlut_[i] = ptlut->data(i);
202  cout << hash( ptlut_, sizeof(int)*(ptlut->maxSize()) ) << endl;
203  } else {
204  cout<<" ptLUT = [0] "<<endl;
205  }
206 
207  const l1t::LUT *plut = ptr1->pdfLUT();
208  if( plut->maxSize() ){
209  cout<<" pdfLUT = ["<<plut->maxSize()<<"] "<<flush;
210  int plut_[plut->maxSize()];
211  for(unsigned int i=0; i<plut->maxSize(); i++) plut_[i] = plut->data(i);
212  cout << hash( plut_, sizeof(int)*(plut->maxSize()) ) << endl;
213  } else {
214  cout<<" pdfLUT = [0] "<<endl;
215  }
216 
217  const l1t::LUT *mlut = ptr1->meanDistPhiLUT();
218  if( mlut->maxSize() ){
219  cout<<" meanDistPhiLUT = ["<<mlut->maxSize()<<"] "<<flush;
220  int mlut_[mlut->maxSize()];
221  for(unsigned int i=0; i<mlut->maxSize(); i++) mlut_[i] = mlut->data(i);
222  cout << hash( mlut_, sizeof(int)*(mlut->maxSize()) ) << endl;
223  } else {
224  cout<<" meanDistPhiLUT = [0] "<<endl;
225  }
226 
227 }
228 
232 
234 
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:53
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
unsigned int logicNumber
logic numer of the layer
int iEvent
Definition: GenABIO.cc:230
L1TMuonOverlapParamsViewer(const edm::ParameterSet &pset)
bool bendingLayer
Is this a bending layers?
Definition: LUT.h:29
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
double a
Definition: hdecay.h:121
T get() const
Definition: EventSetup.h:68
int data(unsigned int address) const
Definition: LUT.h:46
T const * product() const
Definition: ESHandle.h:84
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override