CMS 3D CMS Logo

L1TGlobalPrescalesVetosViewer.cc
Go to the documentation of this file.
1 #include <iomanip>
6 
9 
12 
14 private:
17  int32_t veto_verbosity;
18 
19  std::string hash(void *buf, size_t len) const ;
20 
21 public:
22  void analyze(const edm::Event&, const edm::EventSetup&) override;
23 
25  prescale_table_verbosity = pset.getUntrackedParameter<int32_t>("prescale_table_verbosity", 0);
26  bxmask_map_verbosity = pset.getUntrackedParameter<int32_t>("bxmask_map_verbosity", 0);
27  veto_verbosity = pset.getUntrackedParameter<int32_t>("veto_verbosity", 0);
28  }
29 
31 };
32 
33 #include <openssl/sha.h>
34 #include <cmath>
35 #include <iostream>
36 using namespace std;
37 
38 std::string L1TGlobalPrescalesVetosViewer::hash(void *buf, size_t len) const {
39  char tmp[SHA_DIGEST_LENGTH*2+1];
40  bzero(tmp,sizeof(tmp));
41  SHA_CTX ctx;
42  if( !SHA1_Init( &ctx ) )
43  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash")<<"SHA1 initialization error";
44 
45  if( !SHA1_Update( &ctx, buf, len ) )
46  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash")<<"SHA1 processing error";
47 
48  unsigned char hash[SHA_DIGEST_LENGTH];
49  if( !SHA1_Final(hash, &ctx) )
50  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash")<<"SHA1 finalization error";
51 
52  // re-write bytes in hex
53  for(unsigned int i=0; i<20; i++)
54  ::sprintf(&tmp[i*2], "%02x", hash[i]);
55 
56  tmp[20*2] = 0;
57  return std::string(tmp);
58 }
59 
61 
63  evSetup.get<L1TGlobalPrescalesVetosRcd>().get( handle1 ) ;
64  boost::shared_ptr<L1TGlobalPrescalesVetos> ptr(new L1TGlobalPrescalesVetos(*(handle1.product ())));
65 
66  edm::LogInfo("")<<"L1TGlobalPrescalesVetosViewer:";
67 
68  cout<<endl;
69  cout<<" version_ = "<<ptr->version_<<endl;
70  cout<<" bxmask_default_ = "<<ptr->bxmask_default_<<endl;
71 
72  size_t len_prescale_table_ = 0;
73  for(size_t col=0; col<ptr->prescale_table_.size(); col++){
74  size_t nRows = (ptr->prescale_table_)[ col ].size();
75  len_prescale_table_ += nRows;
76  if( prescale_table_verbosity > 0 ){
77  int column[ nRows ];
78  for(size_t row=0; row<nRows; row++)
79  column[ row ] = (ptr->prescale_table_)[ col ][ row ];
80  cout << " prescale_table_[" << col<< "][" << nRows << "] = ";
81  if( nRows )
82  cout << hash( column, sizeof(int)*nRows ) << endl;
83  else cout << 0 << endl;
84  }
85  }
86  int prescale_table_[len_prescale_table_];
87  for(size_t col=0, pos=0; col<ptr->prescale_table_.size(); col++){
88  size_t nRows = (ptr->prescale_table_)[ col ].size();
89  for(size_t row=0; row<nRows; row++,pos++)
90  prescale_table_[ pos ] = (ptr->prescale_table_)[ col ][ row ];
91  }
92  cout << " prescale_table_[["<<len_prescale_table_<<"]] = ";
93  if( len_prescale_table_ )
94  cout << hash( prescale_table_, sizeof(int)*len_prescale_table_ ) << endl;
95  else cout << 0 << endl;
96 
97  if( prescale_table_verbosity > 1 ){
98  cout << endl << " Detailed view on the prescales * masks: " << endl;
99  for(size_t col=0; col<ptr->prescale_table_.size(); col++)
100  cout << setw(8) << " Index " << col;
101  cout << endl;
102  size_t nRows = (ptr->prescale_table_)[ 0 ].size();
103  for(size_t row=0; row<nRows; row++){
104  for(size_t col=0; col<ptr->prescale_table_.size(); col++)
105  cout << setw(8) << (ptr->prescale_table_)[ col ][ row ] ;
106  cout << endl;
107  }
108  cout << endl;
109  }
110 
111  size_t len_bxmask_map_ = 0;
112  for(std::map<int, std::vector<int> >::const_iterator it = (ptr->bxmask_map_).begin(); it != (ptr->bxmask_map_).end(); it++){
113  len_bxmask_map_ += it->second.size();
114  if( bxmask_map_verbosity == 1 ){
115  int masks[ it->second.size() ];
116  for(size_t i=0; i<it->second.size(); i++)
117  masks[ i ] = it->second[i];
118  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
119  if( !it->second.empty() )
120  cout << hash( masks, sizeof(int)*it->second.size() ) << endl;
121  else cout << 0 << endl;
122  }
123  if( bxmask_map_verbosity > 1 ){
124  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
125  for(size_t algo=0; algo<it->second.size(); algo++) cout << it->second[algo] << ", ";
126  cout << endl;
127  }
128  }
129  int bxmask_map_[ len_bxmask_map_ ];
130  size_t pos = 0;
131  for(std::map<int, std::vector<int> >::const_iterator it = (ptr->bxmask_map_).begin(); it != (ptr->bxmask_map_).end(); it++){
132  for(size_t i=0; i<it->second.size(); i++,pos++) bxmask_map_[ pos ] = it->second[i];
133  }
134  cout << " bxmask_map_[["<< len_bxmask_map_ <<"]] = ";
135  if( len_bxmask_map_ )
136  cout << hash( bxmask_map_, sizeof(int)*len_bxmask_map_ ) << endl;
137  else cout << 0 << endl;
138 
139  int veto_[ (ptr->veto_).size() ];
140  bool veto_allZeros = true;
141  for(size_t i=0; i<(ptr->veto_).size(); i++){
142  veto_[i] = (ptr->veto_)[i];
143  if( veto_[i] ) veto_allZeros = false;
144  }
145  cout << " veto_[" << (ptr->veto_).size() << "] = ";
146  if( veto_verbosity == 0 ){
147  if( !(ptr->veto_).empty() ){
148  cout << hash( veto_, sizeof(int)*(ptr->veto_).size() );
149  if( veto_allZeros ) cout << " (all zeros)" << endl;
150  else cout << endl;
151  } else cout << 0 << endl;
152  } else
153  for(size_t i=0; i<(ptr->veto_).size() ;i++) cout << veto_[i] << endl;
154 
155  int exp_ints_[ (ptr->exp_ints_).size() ];
156  for(size_t i=0; i<(ptr->exp_ints_).size(); i++) exp_ints_[i] = (ptr->exp_ints_)[i];
157  cout << " exp_ints_[" << (ptr->exp_ints_).size() << "] = ";
158  if( !(ptr->exp_ints_).empty() )
159  cout << hash( exp_ints_, sizeof(int)*(ptr->exp_ints_).size() ) << endl;
160  else cout << 0 << endl;
161 
162  int exp_doubles_[ (ptr->exp_doubles_).size() ];
163  for(size_t i=0; i<(ptr->exp_doubles_).size(); i++) exp_ints_[i] = (ptr->exp_doubles_)[i];
164  cout << " exp_doubles_[" << (ptr->exp_doubles_).size() << "] = ";
165  if( !(ptr->exp_doubles_).empty() )
166  cout << hash( exp_doubles_, sizeof(int)*(ptr->exp_doubles_).size() ) << endl;
167  else cout << 0 << endl;
168 }
169 
173 
175 
size
Write out results.
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
L1TGlobalPrescalesVetosViewer(const edm::ParameterSet &pset)
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
#define end
Definition: vmac.h:39
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
T get() const
Definition: EventSetup.h:63
col
Definition: cuy.py:1009
std::string hash(void *buf, size_t len) const
T const * product() const
Definition: ESHandle.h:86