CMS 3D CMS Logo

Functions
cmsShow.cc File Reference
#include "TEnv.h"
#include "TSystem.h"
#include "TEveManager.h"
#include "TRint.h"
#include "TApplication.h"
#include "TSysEvtHandler.h"
#include "Getline.h"
#include <iostream>
#include <fstream>
#include <cstring>
#include <memory>
#include <csignal>
#include "Fireworks/Core/interface/CmsShowMain.h"
#include "Fireworks/Core/interface/fwPaths.h"
#include "FWCore/MessageLogger/interface/AbstractMLscribe.h"
#include "FWCore/MessageLogger/interface/ErrorObj.h"
#include "FWCore/MessageLogger/interface/MessageLoggerQ.h"
#include "FWCore/MessageLogger/interface/MessageDrop.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
void run_app (TApplication &app, int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 117 of file cmsShow.cc.

References dir2webdir::argc, cmsBatch::argv, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, cppFunctionSkipper::exception, mps_fire::i, run_app(), fireworks::setPath(), and mps_setup::stdout.

117  {
118  const char* dummyArgvArray[] = {"cmsShow"};
119  char** dummyArgv = const_cast<char**>(dummyArgvArray);
120  int dummyArgc = 1;
121  gEnv->SetValue("Gui.BackgroundColor", "#9f9f9f");
122 
123  // print version
124  TString infoText;
125  if (gSystem->Getenv("CMSSW_VERSION")) {
126  infoText = gSystem->Getenv("CMSSW_VERSION");
127  } else {
128  TString infoFileName("data/version.txt");
129  fireworks::setPath(infoFileName);
130  std::ifstream infoFile(infoFileName);
131  infoText.ReadLine(infoFile);
132  infoFile.close();
133  }
134  printf("Starting cmsShow, version %s.\n", infoText.Data());
135  fflush(stdout);
136 
137  // check root interactive promp
138  bool isri = false;
139  for (Int_t i = 0; i < argc; i++) {
140  if (strncmp(argv[i], "-r", 2) == 0 || strncmp(argv[i], "--root", 6) == 0) {
141  isri = true;
142  }
143  }
144 
145  try {
146  if (isri) {
147  std::cerr << "" << std::endl;
148  std::cerr << "WARNING:You are running cmsShow with ROOT prompt enabled." << std::endl;
149  std::cerr << "If you encounter an issue you suspect to be a bug in " << std::endl;
150  std::cerr << "cmsShow, please re-run without this option and try to " << std::endl;
151  std::cerr << "reproduce it before submitting a bug-report. " << std::endl;
152  std::cerr << "" << std::endl;
153 
154  TRint app("cmsShow", &dummyArgc, dummyArgv);
155  run_app(app, argc, argv);
156  } else {
157  TApplication app("cmsShow", &dummyArgc, dummyArgv);
158  run_app(app, argc, argv);
159  }
160  } catch (std::exception& iException) {
161  std::cerr << "CmsShow unhandled exception " << iException.what() << std::endl;
162  return 1;
163  }
164 
165  return 0;
166 }
void run_app(TApplication &app, int argc, char **argv)
Definition: cmsShow.cc:81
void setPath(TString &v)
Definition: fwPaths.cc:15

◆ run_app()

void run_app ( TApplication &  app,
int  argc,
char **  argv 
)

Definition at line 81 of file cmsShow.cc.

References dir2webdir::argc, cmsBatch::argv, edm::MessageDrop::instance(), edm::MessageDrop::messageLoggerScribeIsRunning, edm::MessageLoggerQ::MLqEND(), edm::MLSCRIBE_RUNNING_INDICATOR, and edm::MessageLoggerQ::setMLscribe_ptr().

Referenced by main().

81  {
82  //Remove when FWLite handles the MessageLogger
84  std::shared_ptr<edm::service::AbstractMLscribe>(std::make_shared<SilentMLscribe>()));
86  //---------------------
87  std::unique_ptr<CmsShowMain> pMain(new CmsShowMain(argc, argv));
88 
89  // Avoid haing root handling various associated to an error and install
90  // back the default ones.
91  gSystem->ResetSignal(kSigBus);
92  gSystem->ResetSignal(kSigSegmentationViolation);
93  gSystem->ResetSignal(kSigIllegalInstruction);
94  gSystem->ResetSignal(kSigSystem);
95  gSystem->ResetSignal(kSigPipe);
96  gSystem->ResetSignal(kSigFloatingException);
97 
98  struct sigaction sac;
99  sac.sa_sigaction = signal_handler_wrapper;
100  sigemptyset(&sac.sa_mask);
101  sac.sa_flags = SA_SIGINFO;
102  sigaction(SIGILL, &sac, nullptr);
103  sigaction(SIGSEGV, &sac, nullptr);
104  sigaction(SIGBUS, &sac, nullptr);
105  sigaction(SIGFPE, &sac, nullptr);
106 
107  app.Run();
108  pMain.reset();
109 
110  TEveManager::Terminate();
111  app.Terminate();
112 
113  //Remove when FWLite handled the MessageLogger
115 }
static unsigned char messageLoggerScribeIsRunning
Definition: MessageDrop.h:70
static MessageDrop * instance()
Definition: MessageDrop.cc:33
static const unsigned char MLSCRIBE_RUNNING_INDICATOR
Definition: MessageDrop.h:83
static void MLqEND()
static void setMLscribe_ptr(std::shared_ptr< edm::service::AbstractMLscribe > m)