CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Attributes | Private Attributes
evf::ExceptionGenerator Class Reference

#include <ExceptionGenerator.h>

Inheritance diagram for evf::ExceptionGenerator:
edm::EDAnalyzer evf::ModuleWeb edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 
void beginJob ()
 
void beginRun (edm::Run &r, const edm::EventSetup &iSetup)
 
void defaultWebPage (xgi::Input *in, xgi::Output *out)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
 ExceptionGenerator (const edm::ParameterSet &)
 
void publish (xdata::InfoSpace *)
 
virtual void publishForkInfo (moduleweb::ForkInfoObj *forkInfoObj)
 
 ~ExceptionGenerator ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 
- Public Member Functions inherited from evf::ModuleWeb
 ModuleWeb (const std::string &)
 
virtual void publishToXmas (xdata::InfoSpace *)
 
virtual ~ModuleWeb ()
 

Static Public Attributes

static const std::string menu [menu_items]
 
static const int menu_items = 14
 

Private Attributes

int actionId_
 
bool actionRequired_
 
unsigned int intqualifier_
 
std::string original_referrer_
 
std::string qualifier_
 
TH1D * timingHisto_
 
timeval tv_start_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from evf::ModuleWeb
std::string moduleName_
 

Detailed Description

Definition at line 21 of file ExceptionGenerator.h.

Constructor & Destructor Documentation

evf::ExceptionGenerator::ExceptionGenerator ( const edm::ParameterSet pset)
explicit

Definition at line 34 of file ExceptionGenerator.cc.

34  :
35  ModuleWeb("ExceptionGenerator"),
36  actionId_(pset.getUntrackedParameter<int>("defaultAction",-1)),
37  intqualifier_(pset.getUntrackedParameter<unsigned int>("defaultQualifier",0)),
39  {
40 
41  }
T getUntrackedParameter(std::string const &, T const &) const
ModuleWeb(const std::string &)
Definition: ModuleWeb.cc:15
evf::ExceptionGenerator::~ExceptionGenerator ( )
inline

Definition at line 28 of file ExceptionGenerator.h.

28 {};

Member Function Documentation

void evf::ExceptionGenerator::analyze ( const edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 157 of file ExceptionGenerator.cc.

References actionId_, actionRequired_, data, edm::hlt::Exception, cmsRelvalreport::exit, getHLTprescales::index, intqualifier_, j, create_public_lumi_plots::log, pi, qualifier_, random, stor::utils::sleep(), mathSSE::sqrt(), relval_parameters_module::step, timingHisto_, tv_start_, and relativeConstraints::value.

158  {
159  float dummy = 0.;
160  unsigned int iterations = 0;
161  if(actionRequired_)
162  {
163  int *pi = 0;
164  int ind = 0;
165  int step = 1;
166  switch(actionId_)
167  {
168  case 0:
169  ::usleep(intqualifier_*1000);
170  break;
171  case 1:
172  ::sleep(0xFFFFFFF);
173  break;
174  case 2:
175  throw cms::Exception(qualifier_) << "This exception was generated by the ExceptionGenerator";
176  break;
177  case 3:
178  exit(-1);
179  break;
180  case 4:
181  abort();
182  break;
183  case 5:
184  throw qualifier_;
185  break;
186  case 6:
187  while(1){ind+=step; if(ind>1000000) step = -1; if(ind==0) step = 1;}
188  break;
189  case 7:
190  edm::LogError("TestErrorMessage") << qualifier_;
191  break;
192  case 8:
193  *pi=0;
194  break;
195  case 9:
196  for(unsigned int j=0; j<intqualifier_*1000;j++){
197  dummy += sqrt(log(float(j+1)))/float(j*j);
198  }
199  break;
200  case 10:
201  iterations = static_cast<unsigned int>(
202  timingHisto_->GetRandom() * intqualifier_*17. + 0.5
203  );
204  for(unsigned int j=0; j<iterations;j++){
205  dummy += sqrt(log(float(j+1)))/float(j*j);
206  }
207  break;
208  case 11:
209  {
210  iterations = static_cast<unsigned int>(
211  timingHisto_->GetRandom() * intqualifier_*12. + 0.5
212  );
213  TRandom3 random(iterations);
214  const size_t dataSize = 32*500; // 124kB
215  std::vector<double> data(dataSize);
216  random.RndmArray(dataSize, &data[0]);
217 
218  for(unsigned int j=0; j<iterations;j++){
219  const size_t index = static_cast<size_t>(random.Rndm() * dataSize + 0.5);
220  const double value = data[index];
221  dummy += sqrt(log(value+1))/(value*value);
222  if ( random.Rndm() < 0.1 )
223  data[index] = dummy;
224  }
225  }
226  break;
227  case 12:
228  {
229  timeval tv_now;
230  gettimeofday(&tv_now,0);
231  if (static_cast<unsigned long>(tv_now.tv_sec-tv_start_.tv_sec) > intqualifier_)
232  *pi=0;
233  }
234  break;
235  case 13:
236  void *vp = malloc(1024);
237  memset((char *)vp - 32, 0, 1024);
238  free(vp);
239  break;
240  }
241  }
242  }
TRandom random
Definition: MVATrainer.cc:138
void sleep(Duration_t)
Definition: Utils.h:163
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double pi
void evf::ExceptionGenerator::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 42 of file ExceptionGenerator.cc.

References timingHisto_.

43  {
44  // timing destribution from (https://twiki.cern.ch/twiki/bin/viewauth/CMS/HLTCpuTimingFAQ#2011_Most_Recent_Data)
45  // /castor/cern.ch/user/d/dsperka/HLT/triggerSkim_HLTPhysics_run178479_68_188.root
46  // Baseline result with CMSSW_4_2_9_HLT3_hltpatch3 and /online/collisions/2011/5e33/v2.1/HLT/V9 :
47  // vocms110:/store/timing_178479/outfile-178479-col1.root
48 
49  timingHisto_ = new TH1D("timingHisto_","Total time for all modules per event",100,0,1000);
50  timingHisto_->SetBinContent(1,5016);
51  timingHisto_->SetBinContent(2,4563);
52  timingHisto_->SetBinContent(3,3298);
53  timingHisto_->SetBinContent(4,1995);
54  timingHisto_->SetBinContent(5,1708);
55  timingHisto_->SetBinContent(6,1167);
56  timingHisto_->SetBinContent(7,928);
57  timingHisto_->SetBinContent(8,785);
58  timingHisto_->SetBinContent(9,643);
59  timingHisto_->SetBinContent(10,486);
60  timingHisto_->SetBinContent(11,427);
61  timingHisto_->SetBinContent(12,335);
62  timingHisto_->SetBinContent(13,332);
63  timingHisto_->SetBinContent(14,327);
64  timingHisto_->SetBinContent(15,258);
65  timingHisto_->SetBinContent(16,257);
66  timingHisto_->SetBinContent(17,222);
67  timingHisto_->SetBinContent(18,253);
68  timingHisto_->SetBinContent(19,223);
69  timingHisto_->SetBinContent(20,177);
70  timingHisto_->SetBinContent(21,148);
71  timingHisto_->SetBinContent(22,148);
72  timingHisto_->SetBinContent(23,113);
73  timingHisto_->SetBinContent(24,83);
74  timingHisto_->SetBinContent(25,84);
75  timingHisto_->SetBinContent(26,75);
76  timingHisto_->SetBinContent(27,61);
77  timingHisto_->SetBinContent(28,66);
78  timingHisto_->SetBinContent(29,51);
79  timingHisto_->SetBinContent(30,43);
80  timingHisto_->SetBinContent(31,38);
81  timingHisto_->SetBinContent(32,27);
82  timingHisto_->SetBinContent(33,34);
83  timingHisto_->SetBinContent(34,28);
84  timingHisto_->SetBinContent(35,18);
85  timingHisto_->SetBinContent(36,26);
86  timingHisto_->SetBinContent(37,18);
87  timingHisto_->SetBinContent(38,11);
88  timingHisto_->SetBinContent(39,11);
89  timingHisto_->SetBinContent(40,12);
90  timingHisto_->SetBinContent(41,14);
91  timingHisto_->SetBinContent(42,11);
92  timingHisto_->SetBinContent(43,8);
93  timingHisto_->SetBinContent(44,4);
94  timingHisto_->SetBinContent(45,2);
95  timingHisto_->SetBinContent(46,5);
96  timingHisto_->SetBinContent(47,3);
97  timingHisto_->SetBinContent(48,4);
98  timingHisto_->SetBinContent(49,6);
99  timingHisto_->SetBinContent(50,6);
100  timingHisto_->SetBinContent(51,3);
101  timingHisto_->SetBinContent(52,5);
102  timingHisto_->SetBinContent(53,6);
103  timingHisto_->SetBinContent(54,6);
104  timingHisto_->SetBinContent(55,6);
105  timingHisto_->SetBinContent(56,4);
106  timingHisto_->SetBinContent(57,5);
107  timingHisto_->SetBinContent(58,9);
108  timingHisto_->SetBinContent(59,3);
109  timingHisto_->SetBinContent(60,3);
110  timingHisto_->SetBinContent(61,8);
111  timingHisto_->SetBinContent(62,7);
112  timingHisto_->SetBinContent(63,5);
113  timingHisto_->SetBinContent(64,7);
114  timingHisto_->SetBinContent(65,5);
115  timingHisto_->SetBinContent(66,5);
116  timingHisto_->SetBinContent(67,4);
117  timingHisto_->SetBinContent(68,2);
118  timingHisto_->SetBinContent(69,2);
119  timingHisto_->SetBinContent(70,4);
120  timingHisto_->SetBinContent(71,5);
121  timingHisto_->SetBinContent(72,4);
122  timingHisto_->SetBinContent(73,5);
123  timingHisto_->SetBinContent(74,3);
124  timingHisto_->SetBinContent(75,5);
125  timingHisto_->SetBinContent(76,3);
126  timingHisto_->SetBinContent(77,9);
127  timingHisto_->SetBinContent(78,2);
128  timingHisto_->SetBinContent(79,2);
129  timingHisto_->SetBinContent(80,5);
130  timingHisto_->SetBinContent(81,5);
131  timingHisto_->SetBinContent(82,5);
132  timingHisto_->SetBinContent(83,5);
133  timingHisto_->SetBinContent(84,4);
134  timingHisto_->SetBinContent(85,4);
135  timingHisto_->SetBinContent(86,9);
136  timingHisto_->SetBinContent(87,5);
137  timingHisto_->SetBinContent(88,4);
138  timingHisto_->SetBinContent(89,4);
139  timingHisto_->SetBinContent(90,5);
140  timingHisto_->SetBinContent(91,3);
141  timingHisto_->SetBinContent(92,3);
142  timingHisto_->SetBinContent(93,3);
143  timingHisto_->SetBinContent(94,7);
144  timingHisto_->SetBinContent(95,5);
145  timingHisto_->SetBinContent(96,6);
146  timingHisto_->SetBinContent(97,2);
147  timingHisto_->SetBinContent(98,3);
148  timingHisto_->SetBinContent(99,5);
149  timingHisto_->SetBinContent(101,147);
150  timingHisto_->SetEntries(24934);
151  }
void evf::ExceptionGenerator::beginRun ( edm::Run r,
const edm::EventSetup iSetup 
)

Definition at line 152 of file ExceptionGenerator.cc.

References tv_start_.

153  {
154  gettimeofday(&tv_start_,0);
155  }
void evf::ExceptionGenerator::defaultWebPage ( xgi::Input in,
xgi::Output out 
)
virtual

Reimplemented from evf::ModuleWeb.

Definition at line 249 of file ExceptionGenerator.cc.

References actionId_, actionRequired_, gather_cfg::cout, alignCSCRings::e, cppFunctionSkipper::exception, first, i, LaserDQM_cfg::input, intqualifier_, menu, menu_items, evf::ModuleWeb::moduleName_, original_referrer_, getHLTPrescaleColumns::path, pos, qualifier_, o2o::query, edm::second(), benchmark_cfg::select, AlCaHLTBitMon_QueryRunRegistry::string, and tv_start_.

250  {
251  gettimeofday(&tv_start_,0);
253  std::string urn;
254  std::string mname;
256  try
257  {
258  cgicc::Cgicc cgi(in);
259  if ( xgi::Utils::hasFormElement(cgi,"exceptiontype") )
260  {
261  actionId_ = xgi::Utils::getFormElement(cgi, "exceptiontype")->getIntegerValue();
262  try {
263  qualifier_ = xgi::Utils::getFormElement(cgi, "qualifier")->getValue();
264  intqualifier_ = xgi::Utils::getFormElement(cgi, "qualifier")->getIntegerValue();
265  }
266  catch (...) {
267  //didn't have some parameters
268  }
269  actionRequired_ = true;
270  }
271  if ( xgi::Utils::hasFormElement(cgi,"module") )
272  mname = xgi::Utils::getFormElement(cgi, "module")->getValue();
273  cgicc::CgiEnvironment cgie(in);
274  if(original_referrer_ == "")
275  original_referrer_ = cgie.getReferrer();
276  path = cgie.getPathInfo();
277  query = cgie.getQueryString();
278  if(actionId_>=0)
279  std::cout << " requested action " << actionId_ << " "
280  << menu[actionId_] << ". Number of cycles "
281  << intqualifier_ << std::endl;
282  }
283  catch (const std::exception & e)
284  {
285  // don't care if it did not work
286  }
287 
288  using std::endl;
289  *out << "<html>" << endl;
290  *out << "<head>" << endl;
291 
292 
293  *out << "<STYLE type=\"text/css\"> #T1 {border-width: 2px; border: solid blue; text-align: center} </STYLE> " << endl;
294  *out << "<link type=\"text/css\" rel=\"stylesheet\"";
295  *out << " href=\"/" << urn
296  << "/styles.css\"/>" << endl;
297 
298  *out << "<title>" << moduleName_
299  << " MAIN</title>" << endl;
300 
301  *out << "</head>" << endl;
302  *out << "<body onload=\"loadXMLDoc()\">" << endl;
303  *out << "<table border=\"0\" width=\"100%\">" << endl;
304  *out << "<tr>" << endl;
305  *out << " <td align=\"left\">" << endl;
306  *out << " <img" << endl;
307  *out << " align=\"middle\"" << endl;
308  *out << " src=\"/evf/images/systemerror.jpg\"" << endl;
309  *out << " alt=\"main\"" << endl;
310  *out << " width=\"90\"" << endl;
311  *out << " height=\"64\"" << endl;
312  *out << " border=\"\"/>" << endl;
313  *out << " <b>" << endl;
314  *out << moduleName_ << endl;
315  *out << " </b>" << endl;
316  *out << " </td>" << endl;
317  *out << " <td width=\"32\">" << endl;
318  *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
319  *out << " <img" << endl;
320  *out << " align=\"middle\"" << endl;
321  *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
322  *out << " alt=\"HyperDAQ\"" << endl;
323  *out << " width=\"32\"" << endl;
324  *out << " height=\"32\"" << endl;
325  *out << " border=\"\"/>" << endl;
326  *out << " </a>" << endl;
327  *out << " </td>" << endl;
328  *out << " <td width=\"32\">" << endl;
329  *out << " </td>" << endl;
330  *out << " <td width=\"32\">" << endl;
331  *out << " <a href=\"" << original_referrer_ << "\">" << endl;
332  *out << " <img" << endl;
333  *out << " align=\"middle\"" << endl;
334  *out << " src=\"/evf/images/spoticon.jpg\"" << endl;
335  *out << " alt=\"main\"" << endl;
336  *out << " width=\"32\"" << endl;
337  *out << " height=\"32\"" << endl;
338  *out << " border=\"\"/>" << endl;
339  *out << " </a>" << endl;
340  *out << " </td>" << endl;
341  *out << "</tr>" << endl;
342  *out << "</table>" << endl;
343 
344  *out << "<hr/>" << endl;
345 
346  *out << cgicc::form().set("method","GET").set("action", path )
347  << std::endl;
348  boost::char_separator<char> sep("&");
349  boost::tokenizer<boost::char_separator<char> > tokens(query, sep);
350  for (boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
351  tok_iter != tokens.end(); ++tok_iter){
352  size_t pos = (*tok_iter).find_first_of("=");
353  if(pos != std::string::npos){
354  std::string first = (*tok_iter).substr(0 , pos);
355  std::string second = (*tok_iter).substr(pos+1, (*tok_iter).length()-pos-1);
356  *out << cgicc::input().set("type","hidden").set("name",first).set("value", second)
357  << std::endl;
358  }
359  }
360 
361  *out << "Select " << endl;
362  *out << cgicc::select().set("name","exceptiontype") << std::endl;
363  char istring[2];
364 
365  for(int i = 0; i < menu_items; i++)
366  {
367  sprintf(istring,"%d",i);
368  *out << cgicc::option().set("value",istring) << menu[i] << cgicc::option() << std::endl;
369  }
370  *out << cgicc::select() << std::endl;
371  *out << "<br>" << endl;
372  *out << "Qualifier" << endl;
373  *out << cgicc::input().set("type","text").set("name","qualifier") << std::endl;
374  *out << cgicc::input().set("type","submit").set("value","Do It !") << std::endl;
375  *out << cgicc::form() << std::endl;
376 
377  *out << "</body>" << endl;
378  *out << "</html>" << endl;
379  }
int i
Definition: DBlmapReader.cc:9
boost::tokenizer< boost::char_separator< char > > tokenizer
U second(std::pair< T, U > const &p)
bool first
Definition: L1TdeRCT.cc:94
std::string moduleName_
Definition: ModuleWeb.h:61
static const int menu_items
tuple out
Definition: dbtoconf.py:99
static const std::string menu[menu_items]
tuple query
Definition: o2o.py:269
tuple cout
Definition: gather_cfg.py:121
void evf::ExceptionGenerator::endLuminosityBlock ( edm::LuminosityBlock const &  lb,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 244 of file ExceptionGenerator.cc.

245  {
246 
247  }
void evf::ExceptionGenerator::publish ( xdata::InfoSpace *  is)
virtual

Implements evf::ModuleWeb.

Definition at line 380 of file ExceptionGenerator.cc.

381  {
382  }
void evf::ExceptionGenerator::publishForkInfo ( moduleweb::ForkInfoObj forkInfoObj)
virtual

Reimplemented from evf::ModuleWeb.

Definition at line 383 of file ExceptionGenerator.cc.

384  {
385  }

Member Data Documentation

int evf::ExceptionGenerator::actionId_
private

Definition at line 39 of file ExceptionGenerator.h.

Referenced by analyze(), and defaultWebPage().

bool evf::ExceptionGenerator::actionRequired_
private

Definition at line 42 of file ExceptionGenerator.h.

Referenced by analyze(), and defaultWebPage().

unsigned int evf::ExceptionGenerator::intqualifier_
private

Definition at line 40 of file ExceptionGenerator.h.

Referenced by analyze(), and defaultWebPage().

const std::string evf::ExceptionGenerator::menu
static
Initial value:
=
{"Sleep x ms", "SleepForever", "Cms Exception", "Exit with error", "Abort", "Unknown Exception", "Endless loop", "Generate Error Message", "Segfault",
"Burn CPU","HLT timing distribution","HLT timing with memory access","Timed segfault","Invalid free()"}

Definition at line 25 of file ExceptionGenerator.h.

Referenced by defaultWebPage(), Vispa.Gui.WidgetContainer.WidgetContainer::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.WidgetContainer.WidgetContainer::showMenu(), and Vispa.Gui.WidgetContainer.WidgetContainer::toggleCollapse().

const int evf::ExceptionGenerator::menu_items = 14
static

Definition at line 24 of file ExceptionGenerator.h.

Referenced by defaultWebPage().

std::string evf::ExceptionGenerator::original_referrer_
private

Definition at line 43 of file ExceptionGenerator.h.

Referenced by defaultWebPage().

std::string evf::ExceptionGenerator::qualifier_
private

Definition at line 41 of file ExceptionGenerator.h.

Referenced by analyze(), and defaultWebPage().

TH1D* evf::ExceptionGenerator::timingHisto_
private

Definition at line 44 of file ExceptionGenerator.h.

Referenced by analyze(), and beginJob().

timeval evf::ExceptionGenerator::tv_start_
private

Definition at line 45 of file ExceptionGenerator.h.

Referenced by analyze(), beginRun(), and defaultWebPage().