CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExceptionGenerator.cc
Go to the documentation of this file.
1 #include "ExceptionGenerator.h"
2 
3 #include <iostream>
4 #include <typeinfo>
5 #include <map>
6 #include <sstream>
7 #include <sys/time.h>
8 
9 #include "TRandom3.h"
10 
13 
14 #include "boost/tokenizer.hpp"
15 
16 #include <stdio.h>
17 #include <sys/types.h>
18 #include <signal.h>
19 
20 using namespace std;
21 
22 namespace evf{
23 
24 
26  actionId_(pset.getUntrackedParameter<int>("defaultAction",-1)),
27  intqualifier_(pset.getUntrackedParameter<int>("defaultQualifier",0)),
28  qualifier2_(pset.getUntrackedParameter<double>("secondQualifier",1)),
29  actionRequired_(actionId_!=-1)
30  {
31  // timing destribution from (https://twiki.cern.ch/twiki/bin/viewauth/CMS/HLTCpuTimingFAQ#2011_Most_Recent_Data)
32  // /castor/cern.ch/user/d/dsperka/HLT/triggerSkim_HLTPhysics_run178479_68_188.root
33  // Baseline result with CMSSW_4_2_9_HLT3_hltpatch3 and /online/collisions/2011/5e33/v2.1/HLT/V9 :
34  // vocms110:/store/timing_178479/outfile-178479-col1.root
35 
36  timingHisto_ = new TH1D("timingHisto_","Total time for all modules per event",100,0,1000);
37  timingHisto_->SetBinContent(1,5016);
38  timingHisto_->SetBinContent(2,4563);
39  timingHisto_->SetBinContent(3,3298);
40  timingHisto_->SetBinContent(4,1995);
41  timingHisto_->SetBinContent(5,1708);
42  timingHisto_->SetBinContent(6,1167);
43  timingHisto_->SetBinContent(7,928);
44  timingHisto_->SetBinContent(8,785);
45  timingHisto_->SetBinContent(9,643);
46  timingHisto_->SetBinContent(10,486);
47  timingHisto_->SetBinContent(11,427);
48  timingHisto_->SetBinContent(12,335);
49  timingHisto_->SetBinContent(13,332);
50  timingHisto_->SetBinContent(14,327);
51  timingHisto_->SetBinContent(15,258);
52  timingHisto_->SetBinContent(16,257);
53  timingHisto_->SetBinContent(17,222);
54  timingHisto_->SetBinContent(18,253);
55  timingHisto_->SetBinContent(19,223);
56  timingHisto_->SetBinContent(20,177);
57  timingHisto_->SetBinContent(21,148);
58  timingHisto_->SetBinContent(22,148);
59  timingHisto_->SetBinContent(23,113);
60  timingHisto_->SetBinContent(24,83);
61  timingHisto_->SetBinContent(25,84);
62  timingHisto_->SetBinContent(26,75);
63  timingHisto_->SetBinContent(27,61);
64  timingHisto_->SetBinContent(28,66);
65  timingHisto_->SetBinContent(29,51);
66  timingHisto_->SetBinContent(30,43);
67  timingHisto_->SetBinContent(31,38);
68  timingHisto_->SetBinContent(32,27);
69  timingHisto_->SetBinContent(33,34);
70  timingHisto_->SetBinContent(34,28);
71  timingHisto_->SetBinContent(35,18);
72  timingHisto_->SetBinContent(36,26);
73  timingHisto_->SetBinContent(37,18);
74  timingHisto_->SetBinContent(38,11);
75  timingHisto_->SetBinContent(39,11);
76  timingHisto_->SetBinContent(40,12);
77  timingHisto_->SetBinContent(41,14);
78  timingHisto_->SetBinContent(42,11);
79  timingHisto_->SetBinContent(43,8);
80  timingHisto_->SetBinContent(44,4);
81  timingHisto_->SetBinContent(45,2);
82  timingHisto_->SetBinContent(46,5);
83  timingHisto_->SetBinContent(47,3);
84  timingHisto_->SetBinContent(48,4);
85  timingHisto_->SetBinContent(49,6);
86  timingHisto_->SetBinContent(50,6);
87  timingHisto_->SetBinContent(51,3);
88  timingHisto_->SetBinContent(52,5);
89  timingHisto_->SetBinContent(53,6);
90  timingHisto_->SetBinContent(54,6);
91  timingHisto_->SetBinContent(55,6);
92  timingHisto_->SetBinContent(56,4);
93  timingHisto_->SetBinContent(57,5);
94  timingHisto_->SetBinContent(58,9);
95  timingHisto_->SetBinContent(59,3);
96  timingHisto_->SetBinContent(60,3);
97  timingHisto_->SetBinContent(61,8);
98  timingHisto_->SetBinContent(62,7);
99  timingHisto_->SetBinContent(63,5);
100  timingHisto_->SetBinContent(64,7);
101  timingHisto_->SetBinContent(65,5);
102  timingHisto_->SetBinContent(66,5);
103  timingHisto_->SetBinContent(67,4);
104  timingHisto_->SetBinContent(68,2);
105  timingHisto_->SetBinContent(69,2);
106  timingHisto_->SetBinContent(70,4);
107  timingHisto_->SetBinContent(71,5);
108  timingHisto_->SetBinContent(72,4);
109  timingHisto_->SetBinContent(73,5);
110  timingHisto_->SetBinContent(74,3);
111  timingHisto_->SetBinContent(75,5);
112  timingHisto_->SetBinContent(76,3);
113  timingHisto_->SetBinContent(77,9);
114  timingHisto_->SetBinContent(78,2);
115  timingHisto_->SetBinContent(79,2);
116  timingHisto_->SetBinContent(80,5);
117  timingHisto_->SetBinContent(81,5);
118  timingHisto_->SetBinContent(82,5);
119  timingHisto_->SetBinContent(83,5);
120  timingHisto_->SetBinContent(84,4);
121  timingHisto_->SetBinContent(85,4);
122  timingHisto_->SetBinContent(86,9);
123  timingHisto_->SetBinContent(87,5);
124  timingHisto_->SetBinContent(88,4);
125  timingHisto_->SetBinContent(89,4);
126  timingHisto_->SetBinContent(90,5);
127  timingHisto_->SetBinContent(91,3);
128  timingHisto_->SetBinContent(92,3);
129  timingHisto_->SetBinContent(93,3);
130  timingHisto_->SetBinContent(94,7);
131  timingHisto_->SetBinContent(95,5);
132  timingHisto_->SetBinContent(96,6);
133  timingHisto_->SetBinContent(97,2);
134  timingHisto_->SetBinContent(98,3);
135  timingHisto_->SetBinContent(99,5);
136  timingHisto_->SetBinContent(101,147);
137  timingHisto_->SetEntries(24934);
138  }
139 
141  {
142 
143  gettimeofday(&tv_start_,0);
144  }
145 
146  void __attribute__((optimize("O0"))) ExceptionGenerator::analyze(const edm::Event & e, const edm::EventSetup& c)
147  {
148  float dummy = 0.;
149  unsigned int iterations = 0;
150  if(actionRequired_)
151  {
152  int *pi = 0;
153  int ind = 0;
154  int step = 1;
155  switch(actionId_)
156  {
157  case 0:
158  ::usleep(intqualifier_*1000);
159  break;
160  case 1:
161  ::sleep(0xFFFFFFF);
162  break;
163  case 2:
164  throw cms::Exception(qualifier_) << "This exception was generated by the ExceptionGenerator";
165  break;
166  case 3:
167  exit(-1);
168  break;
169  case 4:
170  abort();
171  break;
172  case 5:
173  throw qualifier_;
174  break;
175  case 6:
176  while(1){ind+=step; if(ind>1000000) step = -1; if(ind==0) step = 1;}
177  break;
178  case 7:
179  edm::LogError("TestErrorMessage") << qualifier_;
180  break;
181  case 8:
182  *pi=0;
183  break;
184  case 9:
185  for(unsigned int j=0; j<intqualifier_*1000*100;j++){
186  dummy += sqrt(log(float(j+1)))/float(j*j);
187  }
188  break;
189  case 10:
190  iterations = 100*static_cast<unsigned int>(
191  timingHisto_->GetRandom() * intqualifier_*17. + 0.5
192  );
193  for(unsigned int j=0; j<iterations;j++){
194  dummy += sqrt(log(float(j+1)))/float(j*j);
195  }
196  break;
197  case 11:
198  {
199  iterations = static_cast<unsigned int>(
200  timingHisto_->GetRandom() * intqualifier_*12. + 0.5
201  );
202  TRandom3 random(iterations);
203  const size_t dataSize = 32*500; // 124kB
204  std::vector<double> data(dataSize);
205  random.RndmArray(dataSize, &data[0]);
206 
207  for(unsigned int j=0; j<iterations;j++){
208  const size_t index = static_cast<size_t>(random.Rndm() * dataSize + 0.5);
209  const double value = data[index];
210  dummy += sqrt(log(value+1))/(value*value);
211  if ( random.Rndm() < 0.1 )
212  data[index] = dummy;
213  }
214  }
215  break;
216  case 12:
217  {
218  timeval tv_now;
219  gettimeofday(&tv_now,0);
220  if ((unsigned)(tv_now.tv_sec-tv_start_.tv_sec)>intqualifier_)
221  *pi=0;
222  }
223  break;
224  case 13:
225  {
226  void *vp = malloc(1024);
227  memset((char *)vp - 32, 0, 1024);
228  free(vp);
229  }
230  break;
231  case 14:
232  {
233  float mean = 60.; // timingHisto_->GetMean();
234  float scale = intqualifier_ / mean;
235  float off = intqualifier_ * (1. - qualifier2_);
236  scale = scale*qualifier2_; // scale factor (1 default)
237  iterations = static_cast<unsigned int>(max(1.,off + timingHisto_->GetRandom() * scale));
238  //std::cout << " off " << off << " scale " << scale << " " << iterations << std::endl;
239  ::usleep(iterations*1000);
240  }
241  break;
242  case 15:
243  {
244  float mean = 60.; // timingHisto_->GetMean();
245  float scale = intqualifier_ / mean;
246  float off = intqualifier_ * (1. - qualifier2_);
247  scale = scale*qualifier2_; // scale factor (1 default)
248  iterations = static_cast<unsigned int>(max(1.,off + timingHisto_->GetRandom() * scale));
249  iterations *= 100000;
250  for(unsigned int j=0; j<iterations;j++){
251  dummy += sqrt(log(float(j+1)))/float(j*j);
252  }
253  }
254  break;
255  default:
256  break;
257  }
258 
259  }
260  }
261 
263  {
264 
265  }
266 
267 
268 } // end namespace evf
TRandom random
Definition: MVATrainer.cc:138
const Double_t pi
void __attribute__((optimize("O0"))) ExceptionGenerator
T sqrt(T t)
Definition: SSEVec.h:18
int j
Definition: DBlmapReader.cc:9
string const
Definition: compareJSON.py:14
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void beginRun(edm::Run &r, const edm::EventSetup &iSetup)
Definition: Run.h:43