test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TGlobalPrescalesVetosViewer.cc
Go to the documentation of this file.
5 
8 
11 
13 private:
16 
17  std::string hash(void *buf, size_t len) const ;
18 
19 public:
20  virtual void analyze(const edm::Event&, const edm::EventSetup&);
21 
23  prescale_table_verbosity = pset.getUntrackedParameter<int32_t>("prescale_table_verbosity", 0);
24  bxmask_map_verbosity = pset.getUntrackedParameter<int32_t>("bxmask_map_verbosity", 0);
25  }
26 
28 };
29 
30 #include <openssl/sha.h>
31 #include <math.h>
32 #include <iostream>
33 using namespace std;
34 
35 std::string L1TGlobalPrescalesVetosViewer::hash(void *buf, size_t len) const {
36  char tmp[SHA_DIGEST_LENGTH*2+1];
37  bzero(tmp,sizeof(tmp));
38  SHA_CTX ctx;
39  if( !SHA1_Init( &ctx ) )
40  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash")<<"SHA1 initialization error";
41 
42  if( !SHA1_Update( &ctx, buf, len ) )
43  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash")<<"SHA1 processing error";
44 
45  unsigned char hash[SHA_DIGEST_LENGTH];
46  if( !SHA1_Final(hash, &ctx) )
47  throw cms::Exception("L1TGlobalPrescalesVetosViewer::hash")<<"SHA1 finalization error";
48 
49  // re-write bytes in hex
50  for(unsigned int i=0; i<20; i++)
51  ::sprintf(&tmp[i*2], "%02x", hash[i]);
52 
53  tmp[20*2] = 0;
54  return std::string(tmp);
55 }
56 
58 
60  evSetup.get<L1TGlobalPrescalesVetosRcd>().get( handle1 ) ;
61  boost::shared_ptr<L1TGlobalPrescalesVetos> ptr(new L1TGlobalPrescalesVetos(*(handle1.product ())));
62 
63  edm::LogInfo("")<<"L1TGlobalPrescalesVetosViewer:";
64 
65  cout<<endl;
66  cout<<" version_ = "<<ptr->version_<<endl;
67  cout<<" bxmask_default_ = "<<ptr->bxmask_default_<<endl;
68 
69  size_t len_prescale_table_ = 0;
70  for(size_t col=0; col<ptr->prescale_table_.size(); col++){
71  size_t nRows = (ptr->prescale_table_)[ col ].size();
72  len_prescale_table_ += nRows;
73  if( prescale_table_verbosity > 0 ){
74  int column[ nRows ];
75  for(size_t row=0; row<nRows; row++)
76  column[ row ] = (ptr->prescale_table_)[ col ][ row ];
77  cout << " prescale_table_[" << col<< "][" << nRows << "] = ";
78  if( nRows )
79  cout << hash( column, sizeof(int)*nRows ) << endl;
80  else cout << 0 << endl;
81  }
82  }
83  int prescale_table_[len_prescale_table_];
84  for(size_t col=0, pos=0; col<ptr->prescale_table_.size(); col++){
85  size_t nRows = (ptr->prescale_table_)[ col ].size();
86  for(size_t row=0; row<nRows; row++,pos++)
87  prescale_table_[ pos ] = (ptr->prescale_table_)[ col ][ row ];
88  }
89  cout << " prescale_table_[["<<len_prescale_table_<<"]] = ";
90  if( len_prescale_table_ )
91  cout << hash( prescale_table_, sizeof(int)*len_prescale_table_ ) << endl;
92  else cout << 0 << endl;
93 
94  size_t len_bxmask_map_ = 0;
95  for(std::map<int, std::vector<int> >::const_iterator it = (ptr->bxmask_map_).begin(); it != (ptr->bxmask_map_).end(); it++){
96  len_bxmask_map_ += it->second.size();
97  if( bxmask_map_verbosity > 0 ){
98  int masks[ it->second.size() ];
99  for(size_t i=0; i<it->second.size(); i++)
100  masks[ i ] = it->second[i];
101  cout << " bxmask_map_[" << it->first << "][" << it->second.size() << "] = ";
102  if( it->second.size() )
103  cout << hash( masks, sizeof(int)*it->second.size() ) << endl;
104  else cout << 0 << endl;
105  }
106  }
107  int bxmask_map_[ len_bxmask_map_ ];
108  size_t pos = 0;
109  for(std::map<int, std::vector<int> >::const_iterator it = (ptr->bxmask_map_).begin(); it != (ptr->bxmask_map_).end(); it++){
110  for(size_t i=0; i<it->second.size(); i++,pos++) bxmask_map_[ pos ] = it->second[i];
111  }
112  cout << " bxmask_map_[["<< len_bxmask_map_ <<"]] = ";
113  if( len_bxmask_map_ )
114  cout << hash( bxmask_map_, sizeof(int)*len_bxmask_map_ ) << endl;
115  else cout << 0 << endl;
116 
117  int veto_[ (ptr->veto_).size() ];
118  for(size_t i=0; i<(ptr->veto_).size(); i++) veto_[i] = (ptr->veto_)[i];
119  cout << " veto_[" << (ptr->veto_).size() << "] = ";
120  if( (ptr->veto_).size() )
121  cout << hash( veto_, sizeof(int)*(ptr->veto_).size() ) << endl;
122  else cout << 0 << endl;
123 
124  int exp_ints_[ (ptr->exp_ints_).size() ];
125  for(size_t i=0; i<(ptr->exp_ints_).size(); i++) exp_ints_[i] = (ptr->exp_ints_)[i];
126  cout << " exp_ints_[" << (ptr->exp_ints_).size() << "] = ";
127  if( (ptr->exp_ints_).size() )
128  cout << hash( exp_ints_, sizeof(int)*(ptr->exp_ints_).size() ) << endl;
129  else cout << 0 << endl;
130 
131  int exp_doubles_[ (ptr->exp_doubles_).size() ];
132  for(size_t i=0; i<(ptr->exp_doubles_).size(); i++) exp_ints_[i] = (ptr->exp_doubles_)[i];
133  cout << " exp_doubles_[" << (ptr->exp_doubles_).size() << "] = ";
134  if( (ptr->exp_doubles_).size() )
135  cout << hash( exp_doubles_, sizeof(int)*(ptr->exp_doubles_).size() ) << endl;
136  else cout << 0 << endl;
137 }
138 
142 
144 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
L1TGlobalPrescalesVetosViewer(const edm::ParameterSet &pset)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
#define end
Definition: vmac.h:37
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
constexpr uint32_t masks[]
Definition: CaloRecHit.cc:12
tuple cout
Definition: gather_cfg.py:145
int col
Definition: cuy.py:1008
std::string hash(void *buf, size_t len) const
tuple size
Write out results.