00001
00002
00003
00004 #ifndef FROOT_FROOT
00005 #define FROOT_FROOT
00006
00008
00010
00011 #include <TString.h>
00012 #include <TApplication.h>
00013 #include <TThread.h>
00014 #include <TMath.h>
00015 #include <Riostream.h>
00016
00017
00018
00019 #define _FND_OUTPUTS_USE_SUBDIR
00020
00021
00022
00023 #define FNDEVD_USE_PREAN
00024
00025
00026 #define _FND_ONL_USE_SHARED_FILES_
00027
00028
00029
00030
00032
00033
00034
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define FIDA_USE_SHORT // if defined ===> using short tracks (default from v_603 on)
00046
00047
00048
00052
00053 namespace FROOT {
00054
00055 #if defined _FND_ONL_USE_MAP_FILES_ && defined _FND_ONL_USE_SHARED_FILES_
00056 # error "FROOT.h error: <_FND_ONL_USE_[...]_FILES_> is unbiguous!"
00057 #elif !defined _FND_ONL_USE_MAP_FILES_ && !defined _FND_ONL_USE_SHARED_FILES_
00058 # error "TFndGtsMon error: <_FND_ONL_USE_[...]_FILES_> undefined!"
00059 #endif
00060
00061
00062
00063
00064
00065
00066 #define _FND_ENABLE_RAW_GTS
00067 #define _FND_ENABLE_RAW_TOF
00068 #define _FND_ENABLE_RAW_ISIM
00069 #define _FND_ENABLE_RAW_OSIM
00070 #define _FND_ENABLE_RAW_LMD
00071 #define _FND_ENABLE_RAW_STB
00072
00073 TString GetFrootVersion();
00074 Float_t GetFrootVersionID();
00075
00076 static const UInt_t Fee_Lmd_NewTdcsTime = 1045868400;
00077 static const UInt_t DTak_2006_SftwStartTime = 1145138400;
00078 static const UInt_t Fee_2006_NewSilDB_StartTime = 1154383200;
00079 static const UInt_t DTak_2006_SftwStopTime = 1183500000;
00081
00082 enum E_Fnd_Layer {
00083 E_FIN_INNER_LAYER = 1,
00084 E_FIN_OUTER_LAYER = 2
00085 };
00086
00087 enum E_Fnd_Side {
00088 E_FIN_SIDE_E = 0,
00089 E_FIN_SIDE_P = 1
00090 };
00091 enum E_Fnd_Sil_Side {
00092 E_FIN_SIL_SIDE_PH = 0,
00093 E_FIN_SIL_SIDE_ZA = 1,
00094 E_FIN_SIL_SIDE_ZB = 2
00095 };
00096
00097 TString SilSide_Name(Int_t id);
00098
00099 static const Int_t K_N_TOFINO_SLABS = 12;
00100 static const Int_t K_N_TOFONE_SLABS = 72;
00101
00102 static const Int_t K_N_LMD_LAYERS = 2;
00103 static const Int_t K_N_LMD_CHAMS_PER_LAYER = 8;
00104 static const Int_t K_N_LMD_INNER_WIRES = 12;
00105 static const Int_t K_N_LMD_OUTER_WIRES = 22;
00106 static const Int_t K_N_LMD_TOT_CHAMS = 16;
00107
00108 inline Int_t GetDataTakingFromTime(UInt_t runtime){
00109 if(runtime < DTak_2006_SftwStartTime) return 1;
00110 else if(runtime <= DTak_2006_SftwStopTime) return 2;
00111 else return 0;
00112 }
00113
00114
00115 inline Double_t TofinoZetaFromCharge(Int_t dtak,const Double_t &adcE,const Double_t &adcP)
00116 {
00117 if(! adcE || !adcP){
00118 cerr << "Error in FROOT::TofinoZetaFromCharge: NULL value received." << endl;
00119 return -1;
00120 }
00121 Double_t chdiv = adcE / adcP;
00122 Double_t logch = 0;
00123 switch(dtak){
00124 case 1:
00125 logch = TMath::Log(chdiv);
00126
00127 return (Double_t) (17.5 * logch);
00128 case 2:
00129 logch = TMath::Log( 0.136 * (chdiv + 0.1854) );
00130
00131 return (chdiv > 0.1 && chdiv < 3.5) ?
00132 (Double_t) ( ( 2.7 - ( 3.3 * chdiv ) ) * logch ) :
00133 -999.;
00134 default:
00135 cerr << "FROOT::TofinoZetaFromCharge ---> Data-taking " << dtak << " not available." << endl;
00136 return 0.;
00137 }
00138 }
00139
00140 inline Double_t TofoneZetaFromTime(Int_t dtak,const Double_t &tdcE,const Double_t &tdcP)
00141 {
00142 switch(dtak){
00143 case 1:
00144 return (Double_t) ( ( tdcP - tdcE ) / (2 ) * 16.639 );
00145 case 2:
00146 return (Double_t) ( ( tdcP - tdcE ) / (2 ) * 16.639 );
00147 default:
00148 cerr << "FROOT::TofoneZetaFromTime ---> Data-taking " << dtak << " not available." << endl;
00149 return 0.;
00150 }
00151 }
00152
00153
00154
00155
00156
00157 Double_t LmdZetaGeoAdjust(const Int_t &layer);
00158 Double_t LmdZetaGeoAdjust(const E_Fnd_Layer &layer);
00159
00160 static const Int_t K_N_STB_CROWNS = 6;
00161 static const Int_t K_N_STB_TUBES = 404;
00162
00164
00165 enum E_Fnd_Gts_Constants{
00166 K_N_GTS_SELECTORS = 2,
00167 K_N_GTS_TRIG_TYPES = 12,
00168 K_N_GTS_P_UNITS = 4,
00169 K_N_GTS_SCALER_CHANNELS = 16,
00170 K_N_GTS_SCALER_MODULES = 5,
00171 K_N_GTS_MALU = 3,
00172 };
00173
00174 enum E_Fnd_Gts_TrigTypes{
00175 K_TRIG_HYP = 0,
00176 K_TRIG_BHABHA = 1,
00177 K_TRIG_BTB_LOW = 2,
00178 K_TRIG_OR_LOW = 3,
00179 K_TRIG_BTB_HIGH = 4,
00180 K_TRIG_ORtofino_ORtofone = 5,
00181 K_TRIG_LASER = 6,
00182 K_TRIG_PULSER = 7,
00183 K_TRIG_TCALIB = 8,
00184 K_TRIG_ORtofone = 9,
00185 K_TRIG_MULTtofone = 10,
00186 K_TRIG_BTB_LOW_ORtofone = 11,
00187 };
00188
00189 TString TriggerType(E_Fnd_Gts_TrigTypes type);
00190
00191 static const Int_t K_N_Tof_AdcMod = 9;
00192 static const Int_t K_N_Tof_AdcCha = 64;
00193 static const Int_t K_N_Tof_TdcMod = 6;
00194 static const Int_t K_N_Tof_TdcCha = 96;
00195
00196 enum E_Fnd_Sil_Hardware{
00197 K_N_Sil_Crams = 27,
00198 K_N_Sil_Sects = 2,
00199 K_N_Sil_Sides = 3,
00200 K_N_Sil_AdcCha = 1024,
00201 K_N_Sil_AdcChips = 8,
00202 K_N_Sil_Strips = 1920,
00203 K_N_Sil_Phi_Strips = 1021,
00204 K_N_Sil_Z_Strips = 1920,
00205 K_N_Sil_ChaOnChip = 128,
00206 K_N_Sil_Modules = 10,
00207 K_N_Sil_FixPede = 50,
00208 K_N_Sil_MulNoise = 10,
00209 K_N_Sil_Sigma_Cut = 3,
00210 K_N_Sil_Sigma_Pre = 5,
00211 K_N_Sil_Noise_Cut = 8,
00212 };
00213
00214 static const Int_t K_Sil_Crams_BaseAddress_03 = 0xD0A0;
00215 static const Int_t K_Sil_Crams_BaseAddress_06 = 0xA0;
00216
00217
00218
00219
00220
00221
00222 static const Int_t K_N_Lmd_AdcMod = 9;
00223 static const Int_t K_N_Lmd_AdcCha = 64;
00224 static const Int_t K_N_Lmd_TdcMod = 9;
00225 static const Int_t K_N_Lmd_TdcCha = 96;
00226
00227 static const Int_t K_N_Stb_Crates = 2;
00228 static const Int_t K_N_Stb_Mod = 21;
00229 static const Int_t K_N_Stb_Cha = 96;
00230
00232
00233 #define FIN_RAW_DATA_SOCK_LEN 0x10000
00234 #define FIN_RAW_DATA_BUF_SIZE 0x12000
00235
00236
00237 enum E_Fnd_DaqRaw_Udp_Ports {
00238 FIN_DAQ_RAW_UDP_PORT = 2007,
00239 FIN_GTS_DAQ_RAW_UDP_PORT = 2001,
00240 FIN_TOF_DAQ_RAW_UDP_PORT = 2002,
00241 FIN_SIL_DAQ_RAW_UDP_PORT = 2003,
00242 FIN_LMD_DAQ_RAW_UDP_PORT = 2004,
00243 FIN_STB_DAQ_RAW_UDP_PORT = 2005,
00244 };
00245
00246
00247
00248
00249
00250
00251
00252
00253 enum E_Fnd_Raw_Header_Struct {
00254 E_FndRawHead_Length = 0,
00255 E_FndRawHead_Nev_Hw = 1,
00256 E_FndRawHead_Nev_Sw = 2,
00257 E_FndRawHead_RunTyp = 3,
00258 E_FndRawHead_RunNum = 4,
00259 E_FndRawHead_RStart = 5,
00260 E_FndRawHead_TElaps = 6,
00261 E_FndRawHead_GTSptr = 7,
00262 E_FndRawHead_TOFptr = 8,
00263 E_FndRawHead_ISIptr = 9,
00264 E_FndRawHead_OSIptr = 10,
00265 E_FndRawHead_LMDptr = 11,
00266 E_FndRawHead_STBptr = 12,
00267 E_FndRawHead_DAQmsg = 15,
00268 };
00269
00270
00271 static const UInt_t K_MAX_EQP_LEN = 100000;
00272 enum {
00273
00274 k_EvHeaderLen = 16,
00275 K_VmeScalBufLen = 82,
00276 K_GtsBufLen = 36,
00277 };
00278
00279 enum EFndDaqDetectors { FIN_GTS = 0, FIN_TOF, FIN_ISM, FIN_OSM, FIN_LMD, FIN_STB };
00280 enum EFndDetNameMode{ FIN_D_MOD_SHORT = 0, FIN_D_MOD_HDT, FIN_D_MOD_COMPLETE };
00281 TString AcquiredDetName(Int_t det,Int_t mode = 0);
00282
00284
00285 static const Int_t K_N_DB_HOSTS = 3;
00286 TString DB_Host_Name(Int_t id);
00287
00289
00290
00291 static const Int_t K_N_FND_MON_DETECTORS = 5;
00292 TString RunType_Name(Int_t id);
00293 TString MonDetName(Int_t i);
00294
00295 enum EFndOnlineFlags { ONL_OFF = 0, ONL_GTS, ONL_TOF, ONL_ISM, ONL_OSM, ONL_LMD, ONL_STB, ONL_ALL };
00296 enum EFndRunTypes { RT_FINU = 0, RT_COSM, RT_PULS, RT_PEDE, RT_CALI, RT_PLAT, RT_ONLM };
00297 enum EFndMonDetectors { D_GTS = 0, D_TOF, D_SIL, D_LMD, D_STB };
00298 enum EFndDevice { DEV_DISK = 0, DEV_TAPE, DEV_SOCKET};
00299 enum EFndDBFetchSource { K_DB_SOURCE_HOST = 0, K_DB_SOURCE_FILE };
00300
00301 static const Int_t K_MAX_BINS_ADC = 4000;
00302 static const Int_t K_MAX_BINS_TDC = 4000;
00303
00304 #ifdef _FND_ONL_USE_MAP_FILES_
00305
00306
00307 const Int_t K_GtsMapSize = 1;
00308 const Int_t K_TofMapSize = 20;
00309 const Int_t K_TofAdcMapSize = 30;
00310 const Int_t K_TofTdcMapSize = 30;
00311 const Int_t K_IsimMapSize = 30;
00312 const Int_t K_OsimMapSize = 30;
00313 const Int_t K_LmdMapSize = 5;
00314 const Int_t K_LmdIadcMapSize = 5;
00315 const Int_t K_LmdItdcMapSize = 5;
00316 const Int_t K_LmdOadcMapSize = 7;
00317 const Int_t K_LmdOtdcMapSize = 7;
00318 const Int_t K_StbMapSize = 3;
00319 const Int_t K_StbC1MapSize = 5;
00320 const Int_t K_StbC2MapSize = 5;
00321 const Int_t K_StbC3MapSize = 5;
00322 const Int_t K_StbC4MapSize = 5;
00323 const Int_t K_StbC5MapSize = 5;
00324 const Int_t K_StbC6MapSize = 5;
00325 #endif
00326
00327 TString BuildRunName(const TString &run_type,const Int_t run_num,Bool_t use_subdir=kFALSE);
00328 #if defined _FND_OUTPUTS_USE_SUBDIR
00329
00330 Int_t CreateGrpSubDir(const TString &run_type,const Int_t run_num,const TString &start_pth);
00331 #endif
00332
00333 TString DecodeRunType(UInt_t r_type_raw);
00334
00335 Int_t CheckFileExistence(const TString &filename);
00336
00337 Float_t GetRamUsage(Bool_t verbose=kFALSE);
00338
00339 enum E_FROOT_MEM_DESCR {
00340 E_FROOT_MemRes = 0,
00341 E_FROOT_MemVirt = 1
00342
00343 };
00344 Float_t GetProcMemUsage(E_FROOT_MEM_DESCR mode=E_FROOT_MemVirt,Bool_t verbose=kFALSE);
00345
00346
00347 void CompleteString(TString &str, Int_t size, const char *add_char, Bool_t after);
00348
00349
00350
00351
00352 TString ConcatFileName(const char *dir, const char *name);
00353
00354
00355 ULong64_t Convert64(UInt_t high, UInt_t low);
00356
00357
00358 UShort_t ExtractBit(const UInt_t &number, const UInt_t bit,const UInt_t limit);
00359
00360
00361 TString ExpandPathName(const char *path);
00362
00363
00364
00365 Int_t Ip2Int(const char *ip);
00366
00367 void SayToUser(const TString &Message, Int_t ntimes=1);
00368
00369 void TerminateFroot(Int_t arg=0,const TString &Error=0);
00370 }
00371
00373
00375
00376
00377
00378 #if !defined(linux) && !defined(__linux) && !defined(__linux__)
00379 #undef __GNUC__
00380 #endif
00381
00382 #if !defined(__CINT__)
00383 #include <netinet/in.h>
00384 #include <arpa/inet.h>
00385 #endif
00386
00387 #include <TSystem.h>
00388 #include <TInterpreter.h>
00389 #include <TROOT.h>
00390 #include "Varargs.h"
00391
00392
00393 #if defined(USE_BOOST)
00394 # include <boost/scoped_array.hpp>
00395 #endif
00396
00397 inline TString FROOT::GetFrootVersion() { return "9.01/02"; }
00398 inline Float_t FROOT::GetFrootVersionID() { return 901.02; }
00399
00400 inline Double_t FROOT::LmdZetaGeoAdjust(const Int_t &layer){
00401 return LmdZetaGeoAdjust((E_Fnd_Layer)layer);
00402 }
00403
00404 inline Double_t FROOT::LmdZetaGeoAdjust(const E_Fnd_Layer &layer){
00405 switch (layer){
00406 case E_FIN_INNER_LAYER: return 58.0;
00407 case E_FIN_OUTER_LAYER: return 88.04;
00408 default:
00409 gROOT->Error("FROOT::LmdZetaGeoAdjust","Layer \"%d\" not available",(Int_t)(layer) );
00410 return -1;
00411 }
00412 }
00413
00414 inline TString FROOT::TriggerType(E_Fnd_Gts_TrigTypes type){
00415 switch(type){
00416 case K_TRIG_HYP: return "HYPE";
00417 case K_TRIG_BHABHA: return "BHABHA";
00418 case K_TRIG_BTB_LOW: return "BTB_LowThreshold";
00419 case K_TRIG_OR_LOW: return "OR_tofino_LowThreshold";
00420 case K_TRIG_BTB_HIGH: return "BTB_HighThreshold";
00421 case K_TRIG_ORtofino_ORtofone: return "OR_tofino_And_OR_tofone";
00422 case K_TRIG_LASER: return "LASER";
00423 case K_TRIG_PULSER: return "PULSER";
00424 case K_TRIG_TCALIB: return "Time_Calibration";
00425 case K_TRIG_ORtofone: return "OR_tofone";
00426 case K_TRIG_MULTtofone: return "MULT_tofone > 1";
00427 case K_TRIG_BTB_LOW_ORtofone: return "BTB_LowThreshold_And_OR_tofone";
00428 default: gROOT->Warning("FROOT::TriggerType","Trigger id not defined (%d)",type); return "";
00429 }
00430 }
00431
00432 inline TString FROOT::SilSide_Name(Int_t id)
00433 {
00434
00435 switch (id){
00436 case (Int_t) E_FIN_SIL_SIDE_PH: return "PHI";
00437 case (Int_t) E_FIN_SIL_SIDE_ZA: return "ZA";
00438 case (Int_t) E_FIN_SIL_SIDE_ZB: return "ZB";
00439 default: return "";
00440 }
00441
00442 }
00443
00444 inline TString FROOT::DB_Host_Name(Int_t id)
00445 {
00446
00447
00448 switch (id){
00449 case 0: return "fnddiskfe.lnf.infn.it";
00450 case 1: return "localhost";
00451 case 2: return "tozsxl.to.infn.it";
00452 default: return "localhost";
00453 }
00454 }
00455
00456 inline TString FROOT::RunType_Name(Int_t id)
00457 {
00458
00459 switch (id){
00460 case RT_FINU: return "FINU";
00461 case RT_COSM: return "COSM";
00462 case RT_PULS: return "PULS";
00463 case RT_PEDE: return "PEDE";
00464 case RT_CALI: return "CALI";
00465 case RT_ONLM: return "ONLM";
00466 case RT_PLAT: return "PLAT";
00467
00468 default: return "ONLM";
00469 }
00470 }
00471
00472 inline TString FROOT::MonDetName(Int_t i) {
00473 switch(i){
00474 case D_GTS: return "GTS";
00475 case D_TOF: return "TOF";
00476 case D_SIL: return "SIL";
00477 case D_LMD: return "LMD";
00478 case D_STB: return "STB";
00479 default: return "BUG";
00480 }
00481 }
00482
00483 inline TString FROOT::AcquiredDetName(Int_t det,Int_t mode){
00484
00485
00486
00487 switch(det){
00488 case FIN_GTS:
00489 switch(mode){
00490 case FIN_D_MOD_SHORT: return "GTS";
00491 case FIN_D_MOD_HDT : return "fHGts";
00492 case FIN_D_MOD_COMPLETE: return "Global Trigger Supervisor";
00493 default: return "BUG";
00494 }
00495 case FIN_TOF:
00496 switch(mode){
00497 case FIN_D_MOD_SHORT: return "TOF";
00498 case FIN_D_MOD_HDT : return "fHTof";
00499 case FIN_D_MOD_COMPLETE: return "Time Of Flight system";
00500 default: return "BUG";
00501 }
00502 case FIN_ISM:
00503 switch(mode){
00504 case FIN_D_MOD_SHORT: return "ISM";
00505 case FIN_D_MOD_HDT : return "fHIsm";
00506 case FIN_D_MOD_COMPLETE: return "Isim";
00507 default: return "BUG";
00508 }
00509 case FIN_OSM:
00510 switch(mode){
00511 case FIN_D_MOD_SHORT: return "OSM";
00512 case FIN_D_MOD_HDT : return "fHOsm";
00513 case FIN_D_MOD_COMPLETE: return "Osim";
00514 default: return "BUG";
00515 }
00516 case FIN_LMD:
00517 switch(mode){
00518 case FIN_D_MOD_SHORT: return "LMD";
00519 case FIN_D_MOD_HDT : return "fHLmd";
00520 case FIN_D_MOD_COMPLETE: return "Low Mass Drift Chambers";
00521 default: return "BUG";
00522 }
00523 case FIN_STB:
00524 switch(mode){
00525 case FIN_D_MOD_SHORT: return "STB";
00526 case FIN_D_MOD_HDT : return "fHStb";
00527 case FIN_D_MOD_COMPLETE: return "Straw Tubes";
00528 default: return "BUG";
00529 }
00530 default: return "BUG";
00531 }
00532 }
00533
00534 inline TString FROOT::DecodeRunType(UInt_t r_type_raw){
00535
00536 char r_type[5]="";
00537 r_type[0]=r_type_raw & 0xff;
00538 r_type[1]=(r_type_raw & 0xff00)>>8;
00539 r_type[2]=(r_type_raw & 0xff0000)>>16;
00540 r_type[3]=(r_type_raw & 0xff000000)>>24;
00541 r_type[4]='\0';
00542 return TString(r_type);
00543 }
00544
00545 inline TString FROOT::BuildRunName(const TString &run_type,const Int_t run_num,Bool_t use_subdir)
00546 {
00547
00548
00549
00550 Bool_t consider_run_type = kFALSE;
00551
00552 TString str;
00553 if(run_num>=0) str.Form("%d",run_num);
00554 else str = ""+0;
00555 CompleteString(str,5,"0",kFALSE);
00556 str.Prepend(run_type);
00557
00558 if(use_subdir){
00559 TString subdir = "";
00560 UInt_t numdir = 1000 * (UInt_t) (run_num / 1000);
00561 TString strn;
00562 strn.Form("%u",numdir);
00563 CompleteString(strn,5,"0",kFALSE);
00564
00565 if(consider_run_type) subdir.Form("run_group_%s_%s/",run_type.Data(),strn.Data());
00566 else subdir.Form("run_group_%s/",strn.Data());
00567
00568 str.Prepend(subdir);
00569 }
00570 return str;
00571 }
00572
00573 #if defined _FND_OUTPUTS_USE_SUBDIR
00574 inline Int_t FROOT::CreateGrpSubDir(const TString &run_type,const Int_t run_num,const TString &start_pth){
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588 Bool_t consider_run_type = kFALSE;
00589
00590 TString st_pt_cmp = ExpandPathName(start_pth);
00591 if(st_pt_cmp.IsNull() || gSystem->AccessPathName(st_pt_cmp) ){
00592 gROOT->Error("FROOT::CreateGrpSubDir","Start Path not found (\"%s\")",st_pt_cmp.Data());
00593 return -1;
00594 }
00595
00596
00597 if( st_pt_cmp.EndsWith("/") ) st_pt_cmp.Resize(st_pt_cmp.Sizeof()-2);
00598
00599 TString ndir = "";
00600 UInt_t numdir = 1000 * (UInt_t) (run_num / 1000);
00601 TString strn;
00602 strn.Form("%u",numdir);
00603 CompleteString(strn,5,"0",kFALSE);
00604
00605 if(consider_run_type) ndir.Form("%s/run_group_%s_%s",st_pt_cmp.Data(),run_type.Data(),strn.Data());
00606 else ndir.Form("%s/run_group_%s",st_pt_cmp.Data(),strn.Data());
00607
00608 if( !gSystem->AccessPathName(ndir) ){
00609 gROOT->Info("FROOT::CreateGrpSubDir","directory \"%s\" already existing.",ndir.Data());
00610 return 1;
00611 }
00612
00613 Int_t res = gSystem->MakeDirectory(ndir);
00614 if(res != 0) {
00615 gROOT->Error("FROOT::CreateGrpSubDir","Can not create directory \"%s\"",ndir.Data());
00616 return -2;
00617 }
00618 return 0;
00619 }
00620 #endif
00621
00622 inline Int_t FROOT::CheckFileExistence(const TString &filename) {
00623
00624
00625
00626 Bool_t filefound = kTRUE;
00627 if (gSystem->AccessPathName(ExpandPathName(filename)) && gSystem->AccessPathName(ExpandPathName(filename + ".gz")))
00628 filefound = kFALSE;
00629 if (!filefound) {
00630 gROOT->Warning("FROOT::CheckFileExistence", "file \"%s\" not found.",filename.Data());
00631 return 0;
00632 }
00633 return 1;
00634 }
00635
00636 inline Float_t FROOT::GetRamUsage(Bool_t verbose){
00637
00638 MemInfo_t *im = new MemInfo_t();
00639 gSystem->GetMemInfo(im);
00640 Float_t tot = (Float_t)im->fMemTotal;
00641 Float_t used = (Float_t)im->fMemUsed;
00642 Float_t perc = 100. * (used / tot);
00643 if(verbose) cout << "used memory: " << used << " (" << perc << " %)" << endl;
00644 delete im;
00645 return perc;
00646 }
00647
00648 inline Float_t FROOT::GetProcMemUsage(E_FROOT_MEM_DESCR mode,Bool_t verbose){
00649
00650
00651
00652 MemInfo_t *im = new MemInfo_t();
00653 gSystem->GetMemInfo(im);
00654 ProcInfo_t *ipr = new ProcInfo_t();
00655 gSystem->GetProcInfo(ipr);
00656
00657 Float_t tot = (Float_t)im->fMemTotal;
00658 Float_t mem = 0;
00659 TString descr_str = "";
00660 Float_t perc = 0;
00661
00662 switch(mode){
00663 case E_FROOT_MemRes:
00664 descr_str = "resident";
00665 mem = (Float_t)ipr->fMemResident;
00666 break;
00667 case E_FROOT_MemVirt:
00668 descr_str = "virtual";
00669 mem = (Float_t)(ipr->fMemVirtual);
00670 break;
00671 default:
00672 gROOT->Error("FROOT::GetProcMemUsage","Wrong argument: %d",(Int_t)(mode) );
00673 break;
00674 }
00675 if(mem < 0){
00676 gROOT->Error("FROOT::GetProcMemUsage","Negative value obtained: %f",mem );
00677 return -1;
00678 }
00679 mem = mem / 1024.;
00680
00681 perc = 100. * ( mem / tot);
00682 if(verbose) cout << descr_str.Data() << " memory: " << mem << " (" << perc << " %)" << endl;
00683
00684 delete im;
00685 delete ipr;
00686 return perc;
00687 }
00688
00689 inline void FROOT::CompleteString(TString &str, Int_t size, const char *add_char, Bool_t after)
00690 {
00691 while (str.Sizeof() < size + 1) {
00692 if (after)
00693 str.Append(add_char);
00694 else
00695 str.Prepend(add_char);
00696 }
00697 }
00698
00699 inline TString FROOT::ConcatFileName(const char *dir, const char *name)
00700 {
00701 #if defined(USE_BOOST)
00702 boost::scoped_array<const char> s(gSystem->ConcatFileName(dir, name));
00703 return TString(s.get());
00704 #else
00705 const char *s = gSystem->ConcatFileName(dir, name);
00706 TString ret = s;
00707 delete[] s;
00708 return ret;
00709 #endif
00710 }
00711
00712 inline ULong64_t FROOT::Convert64(UInt_t high, UInt_t low)
00713 {
00714 return ((ULong64_t) high << (CHAR_BIT * sizeof(UInt_t))) | low;
00715 }
00716
00717 inline UShort_t FROOT::ExtractBit(const UInt_t &number, const UInt_t bit,const UInt_t limit){
00718
00719
00720
00721 if(bit > limit-1){
00722 gROOT->Error("ExtractBit","requested bit (%u) not available (limit=%u)",bit,limit); return 0;
00723 }
00724
00725 UShort_t result = (UShort_t) ( (number & ((UInt_t)TMath::Power(2,bit))) >> bit );
00726 return result;
00727 }
00728
00729
00730 inline TString FROOT::ExpandPathName(const char *path)
00731 {
00732 #if defined(USE_BOOST)
00733 boost::scoped_array<const char> s(gSystem->ExpandPathName(path));
00734 return TString(s.get());
00735 #else
00736 const char *s = gSystem->ExpandPathName(path);
00737 TString ret = s;
00738 delete[] s;
00739 return ret;
00740 #endif
00741 }
00742
00743 inline Int_t FROOT::Ip2Int(const char *ip)
00744 {
00745 in_addr_t addr = inet_addr(ip);
00746 return ntohl(addr);
00747 }
00748
00749 inline void FROOT::SayToUser(const TString &Message, Int_t ntimes){
00750
00751 TString command;
00752 command.Form("echo \'(SayText \"%s\")\' |festival --pipe",Message.Data());
00753
00754 for(Int_t i=0;i<ntimes;i++){
00755 gSystem->Exec(command);
00756 if(ntimes>1) usleep(500000);
00757 }
00758
00759 }
00760
00761 inline void FROOT::TerminateFroot(Int_t arg,const TString &Error)
00762 {
00763 Printf("");
00764 Printf(" --------------------------------------------------");
00765
00766 if(Error.IsNull()){
00767 gROOT->Error("FROOT termination","fROOT has been terminated due to an internal error.");
00768 Printf("fROOT has been terminated due to an internal error.");
00769 }
00770 else gROOT->Error("FROOT termination",Error.Data());
00771 Printf(" --------------------------------------------------");
00772 Printf("");
00773 gSystem->Exit(arg);
00774 gApplication->Terminate(arg);
00775 gInterpreter->ProcessLine(".q");
00776 }
00777
00778
00779 #endif // FROOT_FROOT