CMS 3D CMS Logo

printutil.cc
Go to the documentation of this file.
1 // .
2 // ..: P. Chang, philip@physics.ucsd.edu
3 
4 #include "printutil.h"
5 
7 //
8 //
9 // Printing utilities
10 //
11 //
13 
14 //_________________________________________________________________________________________________
15 void RooUtil::clearline(int numchar) {
16  printf("\r");
17  for (int i = 0; i < numchar; ++i)
18  printf(" ");
19  printf("\r");
20 }
21 
22 //_________________________________________________________________________________________________
23 void RooUtil::print(TString msg, const char* fname, int flush_before, int flush_after) {
25  clearline();
26  if (flush_before)
27  printf("\n");
28  if (strlen(fname) == 0)
29  printf("RooUtil:: %s\n", msg.Data());
30  else
31  printf("RooUtil:: [in func %s()] %s\n", fname, msg.Data());
32  if (flush_after)
33  printf("\n");
34  fflush(stdout);
35 }
36 
37 //_________________________________________________________________________________________________
38 void RooUtil::warning(TString msg, const char* fname) {
40  print("WARNING - " + msg + ".\n", fname);
41 }
42 
43 //_________________________________________________________________________________________________
44 void RooUtil::error(TString msg, const char* fname, int is_error) {
46  if (!is_error)
47  return;
48  //exit();
49  print("ERROR - " + msg + ", exiting.\n", fname);
50  abort();
51 }
52 
53 //_________________________________________________________________________________________________
54 void RooUtil::start(int q, int sleep_time) {
56  if (q)
57  return;
58  print("System info:");
59  gSystem->Exec("hostname");
60  gSystem->Exec("uname -a");
61  gSystem->Exec("date");
62  gSystem->Exec("whoami");
63  gSystem->Exec("pwd");
64  print(" _");
65  print("/\\\\");
66  print("\\ \\\\ \\__/ \\__/");
67  print(" \\ \\\\ (oo) (oo) Here we come!");
68  print(" \\_\\\\/~~\\_/~~\\_");
69  print(" _.-~===========~-._");
70  print("(___________________)");
71  print(" \\_______/");
72  print("");
73  print(" Your friendly aliens");
74  print(" Surf & Turf");
75  print();
76  fflush(stdout);
77  if (sleep_time > 0)
78  sleep(sleep_time);
79 }
80 
81 //_________________________________________________________________________________________________
82 void RooUtil::announce(TString msg, Int_t q) {
84  if (q)
85  return;
86  // Random
87  srand(time(NULL)); // Init rand seed
88  Int_t r = rand() % 10 + 1; // Generate rand number
89  Int_t moose = r > 4 ? 1 : 0;
90  // Moose type
91  TString eyes = "open";
92  if (r == 9)
93  eyes = "closed";
94  else if (r == 8)
95  eyes = "dead";
96  else if (r == 7)
97  eyes = "small";
98  else if (r == 7)
99  eyes = "sunny";
100  else if (r == 6)
101  eyes = "calc";
102  else if (r == 4)
103  eyes = "crazy";
104  else if (r == 3)
105  eyes = "vampire";
106  else if (r == 2)
107  eyes = "rich";
108  else if (r == 1)
109  eyes = "sick";
110  print();
111  if (msg.Length() > 0)
112  print("________________________________________");
113  if (msg.Length() > 0)
114  print(msg);
115  if (msg.Length() > 0)
116  print("--O-------------------------------------");
117  if (moose)
118  print(" O \\_\\_ _/_/");
119  if (moose)
120  print(" O \\__/");
121  else
122  print(" O ^__^");
123  if (eyes == "open")
124  print(" o (oo)\\_______");
125  else if (eyes == "closed")
126  print(" o (==)\\_______");
127  else if (eyes == "dead")
128  print(" o (xx)\\_______");
129  else if (eyes == "small")
130  print(" o (..)\\_______");
131  else if (eyes == "sunny")
132  print(" o (66)\\_______");
133  else if (eyes == "calc")
134  print(" o (00)\\_______");
135  else if (eyes == "crazy")
136  print(" o (**)\\_______");
137  else if (eyes == "vampire")
138  print(" o (@@)\\_______");
139  else if (eyes == "rich")
140  print(" o ($$)\\_______");
141  else if (eyes == "sick")
142  print(" o (++)\\_______");
143  if (true)
144  print(" o (__)\\ )\\/\\");
145  if (eyes == "dead")
146  print(" U ||----w |");
147  else if (eyes == "crazy")
148  print(" U ||----w |");
149  else if (eyes == "sick")
150  print(" U ||----w |");
151  else if (eyes == "vampire")
152  print(" VV ||----w |");
153  else
154  print(" ||----w |");
155  if (true)
156  print(" || ||");
157  print();
158  //sleep(0);
159 }
160 
161 //_________________________________________________________________________________________________
162 void RooUtil::end(int q) {
164  if (q)
165  return;
166  print();
167  print(" \\__/ \\__/");
168  print(" S (oo) (oo)");
169  print("(\\//~~\\\\ //~~\\\\");
170  print(" \\/\\__// \\\\__//\\T");
171  print(" |||| ||\\\\ Who cares!");
172  print("__ |||| __ |||| ___");
173  print(" (_)(_) (_)(_)");
174  print();
175 }
176 
177 //_________________________________________________________________________________________________
179  TString str = TString::Format(
180  "(pt, eta, phi, m, e) = %7.2f %5.2f %5.2f %7.2f %7.2f", lv.pt(), lv.eta(), lv.phi(), lv.mass(), lv.e());
181  return str.Data();
182 }
183 
184 //eof
void warning(TString msg, const char *fname="")
Definition: printutil.cc:38
void print(TString msg="", const char *fname="", int flush_before=0, int flush_after=0)
Definition: printutil.cc:23
math::XYZTLorentzVectorD LV
void error(TString msg, const char *fname="", int is_error=1)
Definition: printutil.cc:44
void announce(TString msg="", int quiet=0)
void clearline(int numchar=100)
Definition: printutil.cc:15
void start(int quiet=0, int sleep_time=0)
Definition: printutil.cc:54
std::string getstr(const LV &lv)
Definition: printutil.cc:178
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
tuple msg
Definition: mps_check.py:286
string fname
main script
#define str(s)
void end(int quiet=0)
Definition: printutil.cc:162