Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-19 23:20:31

0001 //  .
0002 // ..: P. Chang, philip@physics.ucsd.edu
0003 
0004 #include "printutil.h"
0005 
0006 ///////////////////////////////////////////////////////////////////////////////////////////////////
0007 //
0008 //
0009 // Printing utilities
0010 //
0011 //
0012 ///////////////////////////////////////////////////////////////////////////////////////////////////
0013 
0014 //_________________________________________________________________________________________________
0015 void RooUtil::clearline(int numchar) {
0016   printf("\r");
0017   for (int i = 0; i < numchar; ++i)
0018     printf(" ");
0019   printf("\r");
0020 }
0021 
0022 //_________________________________________________________________________________________________
0023 void RooUtil::print(TString msg, const char* fname, int flush_before, int flush_after) {
0024   /// printf replacement
0025   clearline();
0026   if (flush_before)
0027     printf("\n");
0028   if (strlen(fname) == 0)
0029     printf("RooUtil:: %s\n", msg.Data());
0030   else
0031     printf("RooUtil:: [in func %s()] %s\n", fname, msg.Data());
0032   if (flush_after)
0033     printf("\n");
0034   fflush(stdout);
0035 }
0036 
0037 //_________________________________________________________________________________________________
0038 void RooUtil::warning(TString msg, const char* fname) {
0039   /// warning message. Does not exit the program.
0040   print("WARNING - " + msg + ".\n", fname);
0041 }
0042 
0043 //_________________________________________________________________________________________________
0044 void RooUtil::error(TString msg, const char* fname, int is_error) {
0045   /// Error & exit
0046   if (!is_error)
0047     return;
0048   //exit();
0049   print("ERROR - " + msg + ", exiting.\n", fname);
0050   abort();
0051 }
0052 
0053 //_________________________________________________________________________________________________
0054 void RooUtil::start(int q, int sleep_time) {
0055   /// Fun start (from TM Hong's BaBar days)
0056   if (q)
0057     return;
0058   print("System info:");
0059   gSystem->Exec("hostname");
0060   gSystem->Exec("uname -a");
0061   gSystem->Exec("date");
0062   gSystem->Exec("whoami");
0063   gSystem->Exec("pwd");
0064   print(" _");
0065   print("/\\\\");
0066   print("\\ \\\\  \\__/ \\__/");
0067   print(" \\ \\\\ (oo) (oo)  Here we come!");
0068   print("  \\_\\\\/~~\\_/~~\\_");
0069   print(" _.-~===========~-._");
0070   print("(___________________)");
0071   print("      \\_______/");
0072   print("");
0073   print(" Your friendly aliens");
0074   print("     Surf & Turf");
0075   print();
0076   fflush(stdout);
0077   if (sleep_time > 0)
0078     sleep(sleep_time);
0079 }
0080 
0081 //_________________________________________________________________________________________________
0082 void RooUtil::announce(TString msg, Int_t q) {
0083   /// Fun message presented by the moose
0084   if (q)
0085     return;
0086   // Random
0087   srand(time(NULL));          // Init rand seed
0088   Int_t r = rand() % 10 + 1;  // Generate rand number
0089   Int_t moose = r > 4 ? 1 : 0;
0090   // Moose type
0091   TString eyes = "open";
0092   if (r == 9)
0093     eyes = "closed";
0094   else if (r == 8)
0095     eyes = "dead";
0096   else if (r == 7)
0097     eyes = "small";
0098   else if (r == 7)
0099     eyes = "sunny";
0100   else if (r == 6)
0101     eyes = "calc";
0102   else if (r == 4)
0103     eyes = "crazy";
0104   else if (r == 3)
0105     eyes = "vampire";
0106   else if (r == 2)
0107     eyes = "rich";
0108   else if (r == 1)
0109     eyes = "sick";
0110   print();
0111   if (msg.Length() > 0)
0112     print("________________________________________");
0113   if (msg.Length() > 0)
0114     print(msg);
0115   if (msg.Length() > 0)
0116     print("--O-------------------------------------");
0117   if (moose)
0118     print("  O    \\_\\_    _/_/");
0119   if (moose)
0120     print("   O       \\__/");
0121   else
0122     print("   O       ^__^");
0123   if (eyes == "open")
0124     print("    o      (oo)\\_______");
0125   else if (eyes == "closed")
0126     print("    o      (==)\\_______");
0127   else if (eyes == "dead")
0128     print("    o      (xx)\\_______");
0129   else if (eyes == "small")
0130     print("    o      (..)\\_______");
0131   else if (eyes == "sunny")
0132     print("    o      (66)\\_______");
0133   else if (eyes == "calc")
0134     print("    o      (00)\\_______");
0135   else if (eyes == "crazy")
0136     print("    o      (**)\\_______");
0137   else if (eyes == "vampire")
0138     print("    o      (@@)\\_______");
0139   else if (eyes == "rich")
0140     print("    o      ($$)\\_______");
0141   else if (eyes == "sick")
0142     print("    o      (++)\\_______");
0143   if (true)
0144     print("     o     (__)\\       )\\/\\");
0145   if (eyes == "dead")
0146     print("            U  ||----w |");
0147   else if (eyes == "crazy")
0148     print("            U  ||----w |");
0149   else if (eyes == "sick")
0150     print("            U  ||----w |");
0151   else if (eyes == "vampire")
0152     print("            VV ||----w |");
0153   else
0154     print("               ||----w |");
0155   if (true)
0156     print("               ||     ||");
0157   print();
0158   //sleep(0);
0159 }
0160 
0161 //_________________________________________________________________________________________________
0162 void RooUtil::end(int q) {
0163   /// Fun exit (from TM Hong's BaBar days)
0164   if (q)
0165     return;
0166   print();
0167   print("   \\__/    \\__/");
0168   print(" S (oo)    (oo)");
0169   print("(\\//~~\\\\  //~~\\\\");
0170   print(" \\/\\__//  \\\\__//\\T");
0171   print("   ||||    ||\\\\ Who cares!");
0172   print("__ |||| __ |||| ___");
0173   print("  (_)(_)  (_)(_)");
0174   print();
0175 }
0176 
0177 //_________________________________________________________________________________________________
0178 std::string RooUtil::getstr(const LV& lv) {
0179   TString str = TString::Format(
0180       "(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());
0181   return str.Data();
0182 }
0183 
0184 //eof