Go to the documentation of this file.00001
00002
00003
00004 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaParPaths.h"
00005
00006 ClassImp(TEcnaParPaths)
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 TEcnaParPaths::~TEcnaParPaths()
00037 {
00038
00039
00040
00041 }
00042
00043
00044
00045
00046
00047
00048 TEcnaParPaths::TEcnaParPaths()
00049 {
00050
00051
00052
00053
00054 Init();
00055
00056
00057 GetPathForResultsRootFiles();
00058 GetPathForResultsAsciiFiles();
00059 GetPathForHistoryRunListFiles();
00060
00061 GetCMSSWParameters();
00062 }
00063
00064 void TEcnaParPaths::Init()
00065 {
00066 fgMaxCar = (Int_t)512;
00067
00068 fTTBELL = '\007';
00069
00070
00071 fCnaCommand = 0;
00072 fCnaError = 0;
00073
00074
00075
00076 fPathForResultsRootFiles = kFALSE;
00077 fPathForResultsAsciiFiles = kFALSE;
00078 fPathForHistoryRunListFiles = kFALSE;
00079
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 void TEcnaParPaths::GetPathForResultsRootFiles()
00091 {
00092 GetPathForResultsRootFiles("");
00093 }
00094
00095 void TEcnaParPaths::GetPathForResultsRootFiles(const TString argFileName)
00096 {
00097
00098
00099
00100
00101 Int_t MaxCar = fgMaxCar;
00102 fCfgResultsRootFilePath.Resize(MaxCar);
00103 fCfgResultsRootFilePath = "?";
00104
00105
00106
00107
00108 if ( argFileName == "" )
00109 {
00110 string cFileNameForCnaPaths = "ECNA/path_results_root";
00111 TString s_file_name = cFileNameForCnaPaths.c_str();
00112 const Text_t *t_file_name = (const Text_t *)s_file_name.Data();
00113
00114 TString s_path_name = gSystem->Getenv("HOME");
00115
00116 fFileForResultsRootFilePath = s_path_name;
00117 fFileForResultsRootFilePath.Append('/');
00118 fFileForResultsRootFilePath.Append(t_file_name);
00119 }
00120 else
00121 {
00122 fFileForResultsRootFilePath = argFileName.Data();
00123 }
00124
00125
00126
00127
00128 fFcin_rr.open(fFileForResultsRootFilePath.Data());
00129 if(fFcin_rr.fail() == kFALSE)
00130 {
00131 fFcin_rr.clear();
00132 string xResultsFileP;
00133 fFcin_rr >> xResultsFileP;
00134 fCfgResultsRootFilePath = xResultsFileP.c_str();
00135 fFcin_rr.close();
00136 fPathForResultsRootFiles = kTRUE;
00137 }
00138 else
00139 {
00140 fFcin_rr.clear();
00141 fCnaError++;
00142 cout << fTTBELL << endl
00143 << " ***************************************************************************************** " << endl;
00144 cout << " !CNA(TEcnaParPaths) (" << fCnaError << ") *** ERROR *** " << endl << endl
00145 << " " << fFileForResultsRootFilePath.Data() << ": file not found. " << endl << endl
00146 << " Please create a subdirectory named ECNA in your HOME directory (if not already done)" << endl
00147 << " and create a file named path_results_root in the subdirectory ECNA." << endl << endl
00148 << " The file " << fFileForResultsRootFilePath.Data() << " is a configuration file" << endl
00149 << " for the CNA and must contain one line with the following syntax:" << endl << endl
00150 << " PATH_OF_THE_RESULTS_ROOT_FILE ($HOME/etc...) (without slash at the end of line)" << endl
00151 << " ================================"
00152 << endl << endl
00153 << " Example: $HOME/scratch0/cna/results_root" << endl << endl
00154 << " ***************************************************************************************** "
00155 << fTTBELL << endl;
00156
00157 fFcin_rr.close();
00158 fPathForResultsRootFiles = kFALSE;
00159 }
00160 }
00161
00162
00163
00164 void TEcnaParPaths::GetPathForResultsAsciiFiles()
00165 {
00166 GetPathForResultsAsciiFiles("");
00167 }
00168
00169 void TEcnaParPaths::GetPathForResultsAsciiFiles(const TString argFileName)
00170 {
00171
00172
00173
00174
00175 Int_t MaxCar = fgMaxCar;
00176 fCfgResultsAsciiFilePath.Resize(MaxCar);
00177 fCfgResultsAsciiFilePath = "?";
00178
00179
00180
00181
00182 if ( argFileName == "" )
00183 {
00184 string cFileNameForCnaPaths = "ECNA/path_results_ascii";
00185 TString s_file_name = cFileNameForCnaPaths.c_str();
00186 const Text_t *t_file_name = (const Text_t *)s_file_name.Data();
00187
00188 TString s_path_name = gSystem->Getenv("HOME");
00189
00190 fFileForResultsAsciiFilePath = s_path_name;
00191 fFileForResultsAsciiFilePath.Append('/');
00192 fFileForResultsAsciiFilePath.Append(t_file_name);
00193 }
00194 else
00195 {
00196 fFileForResultsAsciiFilePath = argFileName.Data();
00197 }
00198
00199
00200
00201
00202 fFcin_ra.open(fFileForResultsAsciiFilePath.Data());
00203 if(fFcin_ra.fail() == kFALSE)
00204 {
00205 fFcin_ra.clear();
00206 string xResultsFileP;
00207 fFcin_ra >> xResultsFileP;
00208 fCfgResultsAsciiFilePath = xResultsFileP.c_str();
00209 fFcin_ra.close();
00210 fPathForResultsAsciiFiles = kTRUE;
00211 }
00212 else
00213 {
00214 fFcin_ra.clear();
00215 fCnaError++;
00216 cout << fTTBELL << endl
00217 << " ***************************************************************************************** " << endl;
00218 cout << " !CNA(TEcnaParPaths) (" << fCnaError << ") *** ERROR *** " << endl << endl
00219 << " " << fFileForResultsAsciiFilePath.Data() << ": file not found. " << endl << endl
00220 << " Please create a subdirectory named ECNA in your HOME directory (if not already done)" << endl
00221 << " and create a file named path_results_ascii in the subdirectory ECNA." << endl << endl
00222 << " The file " << fFileForResultsAsciiFilePath.Data() << " is a configuration file" << endl
00223 << " for the CNA and must contain one line with the following syntax:" << endl << endl
00224 << " PATH_OF_THE_RESULTS_ASCII_FILE ($HOME/etc...) (without slash at the end of line)" << endl
00225 << " ================================"
00226 << endl << endl
00227 << " Example: $HOME/scratch0/cna/results_ascii" << endl << endl
00228 << " ***************************************************************************************** "
00229 << fTTBELL << endl;
00230
00231 fFcin_ra.close();
00232 fPathForResultsAsciiFiles = kFALSE;
00233 }
00234 }
00235
00236
00237
00238 void TEcnaParPaths::GetPathForHistoryRunListFiles()
00239 {
00240 GetPathForHistoryRunListFiles("");
00241 }
00242
00243 void TEcnaParPaths::GetPathForHistoryRunListFiles(const TString argFileName)
00244 {
00245
00246
00247
00248
00249 Int_t MaxCar = fgMaxCar;
00250 fCfgHistoryRunListFilePath.Resize(MaxCar);
00251 fCfgHistoryRunListFilePath = "?";
00252
00253
00254
00255
00256 if ( argFileName == "" )
00257 {
00258 string cFileNameForCnaPaths = "ECNA/path_runlist_history_plots";
00259 TString s_file_name = cFileNameForCnaPaths.c_str();
00260 const Text_t *t_file_name = (const Text_t *)s_file_name.Data();
00261
00262 TString s_path_name = gSystem->Getenv("HOME");
00263
00264 fFileForHistoryRunListFilePath = s_path_name;
00265 fFileForHistoryRunListFilePath.Append('/');
00266 fFileForHistoryRunListFilePath.Append(t_file_name);
00267 }
00268 else
00269 {
00270 fFileForHistoryRunListFilePath = argFileName.Data();
00271 }
00272
00273
00274
00275
00276 fFcin_lor.open(fFileForHistoryRunListFilePath.Data());
00277 if(fFcin_lor.fail() == kFALSE)
00278 {
00279 fFcin_lor.clear();
00280 string xHistoryRunListP;
00281 fFcin_lor >> xHistoryRunListP;
00282 fCfgHistoryRunListFilePath = xHistoryRunListP.c_str();
00283 fFcin_lor.close();
00284 fPathForHistoryRunListFiles = kTRUE;
00285 }
00286 else
00287 {
00288 fFcin_lor.clear();
00289 fCnaError++;
00290 cout << fTTBELL << endl
00291 << " ******************************************************************************************************** " << endl;
00292 cout << " !CNA(TEcnaParPaths) (" << fCnaError << ") *** ERROR *** " << endl << endl
00293 << " " << fFileForHistoryRunListFilePath.Data() << ": file not found. " << endl << endl
00294 << " Please create a subdirectory named ECNA in your HOME directory (if not already done)" << endl
00295 << " and create a file named path_runlist_history_plots in the subdirectory ECNA." << endl << endl
00296 << " The file " << fFileForHistoryRunListFilePath.Data() << " is a configuration file" << endl
00297 << " for the CNA and must contain one line with the following syntax:" << endl << endl
00298 << " PATH_OF_THE_LIST_OF_RUNS_FOR_HISTORY_PLOTS_FILE ($HOME/etc...) (without slash at the end of line)" << endl
00299 << " ================================"
00300 << endl << endl
00301 << " Example: $HOME/scratch0/cna/runlist_history_plots" << endl << endl
00302 << " ******************************************************************************************************** "
00303 << fTTBELL << endl;
00304
00305 fFcin_lor.close();
00306 fPathForHistoryRunListFiles = kFALSE;
00307 }
00308 }
00309
00310
00311
00312 #define ANAP
00313 #ifndef ANAP
00314
00315 void TEcnaParPaths::GetPathForAnalyzerParametersFiles()
00316 {
00317 GetPathForAnalyzerParametersFiles("");
00318 }
00319
00320 void TEcnaParPaths::GetPathForAnalyzerParametersFiles(const TString argFileName)
00321 {
00322
00323
00324
00325
00326
00327 Int_t MaxCar = fgMaxCar;
00328 fCfgAnalyzerParametersFilePath.Resize(MaxCar);
00329 fCfgAnalyzerParametersFilePath = "?";
00330
00331
00332
00333
00334 if ( argFileName == "" )
00335 {
00336 string cFileNameForCnaPaths = "path_analyzer_parameters.ecna";
00337 TString s_file_name = cFileNameForCnaPaths.c_str();
00338 const Text_t *t_file_name = (const Text_t *)s_file_name.Data();
00339
00340 TString s_path_name = gSystem->Getenv("HOME");
00341
00342 fFileForAnalyzerParametersFilePath = s_path_name;
00343 fFileForAnalyzerParametersFilePath.Append('/');
00344 fFileForAnalyzerParametersFilePath.Append(t_file_name);
00345 }
00346 else
00347 {
00348 fFileForAnalyzerParametersFilePath = argFileName.Data();
00349 }
00350
00351
00352
00353
00354 fFcin_anapar.open(fFileForAnalyzerParametersFilePath.Data());
00355 if(fFcin_anapar.fail() == kFALSE)
00356 {
00357 fFcin_anapar.clear();
00358 string xAnalyzerParametersP;
00359 fFcin_anapar >> xAnalyzerParametersP;
00360 fCfgAnalyzerParametersFilePath = xAnalyzerParametersP.c_str();
00361 fFcin_anapar.close();
00362 }
00363 else
00364 {
00365 fFcin_anapar.clear();
00366 fCnaError++;
00367 cout << fTTBELL << endl
00368 << " ***************************************************************************** " << endl;
00369 cout << " !CNA(TEcnaParPaths) (" << fCnaError << ") *** ERROR *** " << endl << endl
00370 << " "
00371 << fFileForAnalyzerParametersFilePath.Data() << " : file not found. " << endl
00372 << " "
00373 << " Please create this file in your HOME directory and then restart."
00374 << endl << endl
00375 << " "
00376 << " The file " << fFileForAnalyzerParametersFilePath.Data()
00377 << " is a configuration file for the CNA and"
00378 << " must contain one line with the following syntax:" << endl << endl
00379 << " "
00380 << " path of the analyzer parameters files ($HOME/etc...) " << endl
00381 << " "
00382 << " (without slash at the end of line)" << endl
00383 << endl << endl
00384 << " "
00385 << " EXAMPLE:" << endl << endl
00386 << " "
00387 << " $HOME/scratch0/cna/analyzer_parameters" << endl << endl
00388 << " ***************************************************************************** "
00389 << fTTBELL << endl;
00390
00391 fFcin_anapar.close();
00392 }
00393 }
00394 #endif // ANAP
00395
00396
00397 void TEcnaParPaths::GetCMSSWParameters()
00398 {
00399 GetCMSSWParameters("");
00400 }
00401
00402 void TEcnaParPaths::GetCMSSWParameters(const TString argFileName)
00403 {
00404
00405
00406
00407
00408
00409 Int_t MaxCar = fgMaxCar;
00410 fCfgCMSSWVersion.Resize(MaxCar);
00411 fCfgCMSSWVersion = "?";
00412 fCfgCMSSWSubsystem.Resize(MaxCar);
00413 fCfgCMSSWSubsystem = "?";
00414 fCfgCMSSWSlc.Resize(MaxCar);
00415 fCfgCMSSWSlc = "?";
00416
00417
00418
00419
00420 if ( argFileName == "" )
00421 {
00422 string cFileNameForCMSSWParameters = "ECNA/cmssw_parameters";
00423 TString s_file_name = cFileNameForCMSSWParameters.c_str();
00424 const Text_t *t_file_name = (const Text_t *)s_file_name.Data();
00425
00426 TString s_path_name = gSystem->Getenv("HOME");
00427
00428 fFileForCMSSWParameters = s_path_name;
00429 fFileForCMSSWParameters.Append('/');
00430 fFileForCMSSWParameters.Append(t_file_name);
00431 }
00432 else
00433 {
00434 fFileForCMSSWParameters = argFileName.Data();
00435 }
00436
00437
00438
00439
00440 fFcin_cmssw.open(fFileForCMSSWParameters.Data());
00441 if(fFcin_cmssw.fail() == kFALSE)
00442 {
00443 fFcin_cmssw.clear();
00444
00445 string xCMSSWVersionFileP;
00446 fFcin_cmssw >> xCMSSWVersionFileP;
00447 fCfgCMSSWVersion = xCMSSWVersionFileP.c_str();
00448
00449 string xCMSSWSubsystemFileP;
00450 fFcin_cmssw >> xCMSSWSubsystemFileP;
00451 fCfgCMSSWSubsystem = xCMSSWSubsystemFileP.c_str();
00452
00453 string xCMSSWSlcFileP;
00454 fFcin_cmssw >> xCMSSWSlcFileP;
00455 fCfgCMSSWSlc = xCMSSWSlcFileP.c_str();
00456
00457 fFcin_cmssw.close();
00458 }
00459 else
00460 {
00461 fFcin_cmssw.clear();
00462 fCnaError++;
00463 cout << fTTBELL << endl
00464 << " ************************************************************************************************** " << endl;
00465 cout << " !CNA(TEcnaParPaths) (" << fCnaError << ") *** ERROR *** " << endl << endl
00466 << " " << fFileForCMSSWParameters.Data() << ": file not found. " << endl << endl
00467 << " Please create a subdirectory named ECNA in your HOME directory (if not already done)" << endl
00468 << " and create a file named cmssw_parameters in the subdirectory ECNA." << endl << endl
00469 << " The file " << fFileForCMSSWParameters.Data() << " is a configuration file" << endl
00470 << " for the CNA and must contain one line with the following syntax:" << endl << endl
00471 << " CMSSW_VERSION SUBSYSTEM_NAME TEST_SUBDIRECTORY_NAME" << endl
00472 << endl << endl
00473 << " Example: CMSSW_2_1_19 CalibCalorimetry slc4_ia32_gcc345" << endl << endl
00474 << " ************************************************************************************************** "
00475 << fTTBELL << endl;
00476
00477 fFcin_cmssw.close();
00478 }
00479 }
00480
00481
00482
00483
00484
00485
00486 TString TEcnaParPaths::ResultsRootFilePath() {return fCfgResultsRootFilePath;}
00487 TString TEcnaParPaths::ResultsAsciiFilePath() {return fCfgResultsAsciiFilePath;}
00488 TString TEcnaParPaths::HistoryRunListFilePath() {return fCfgHistoryRunListFilePath;}
00489 TString TEcnaParPaths::CMSSWVersion() {return fCfgCMSSWVersion;}
00490 TString TEcnaParPaths::CMSSWSubsystem() {return fCfgCMSSWSubsystem;}
00491 TString TEcnaParPaths::CMSSWSlc() {return fCfgCMSSWSlc;}
00492
00493
00494 TString TEcnaParPaths::PathModulesData()
00495 {
00496
00497 TString ModulesdataPath = "";
00498
00499 TString s_path_name = gSystem->Getenv("HOME");
00500 const Text_t *t_path_name = (const Text_t *)s_path_name.Data();
00501 ModulesdataPath.Append(t_path_name);
00502 ModulesdataPath.Append('/');
00503
00504 TString s_cmssw = "cmssw";
00505 const Text_t *t_cmssw = (const Text_t *)s_cmssw.Data();
00506 ModulesdataPath.Append(t_cmssw);
00507 ModulesdataPath.Append('/');
00508
00509 const Text_t *t_cmssw_version = (const Text_t *)CMSSWVersion().Data();
00510 ModulesdataPath.Append(t_cmssw_version);
00511 ModulesdataPath.Append('/');
00512
00513 TString s_src = "src";
00514 const Text_t *t_src = (const Text_t *)s_src.Data();
00515 ModulesdataPath.Append(t_src);
00516 ModulesdataPath.Append('/');
00517
00518 const Text_t *t_cmssw_subsystem = (const Text_t *)CMSSWSubsystem().Data();
00519 ModulesdataPath.Append(t_cmssw_subsystem);
00520 ModulesdataPath.Append('/');
00521
00522 TString s_package_data_path = "EcalCorrelatedNoiseAnalysisModules/data";
00523 const Text_t *t_package_data_path = (const Text_t *)s_package_data_path.Data();
00524 ModulesdataPath.Append(t_package_data_path);
00525 ModulesdataPath.Append('/');
00526
00527
00528 return ModulesdataPath;
00529 }
00530
00531 TString TEcnaParPaths::PathTestSlc()
00532 {
00533
00534 TString TestslcPath = "";
00535
00536 TString s_path_name = gSystem->Getenv("HOME");
00537 const Text_t *t_path_name = (const Text_t *)s_path_name.Data();
00538 TestslcPath.Append(t_path_name);
00539 TestslcPath.Append('/');
00540
00541 TString s_cmssw = "cmssw";
00542 const Text_t *t_cmssw = (const Text_t *)s_cmssw.Data();
00543 TestslcPath.Append(t_cmssw);
00544 TestslcPath.Append('/');
00545
00546 const Text_t *t_cmssw_version = (const Text_t *)CMSSWVersion().Data();
00547 TestslcPath.Append(t_cmssw_version);
00548 TestslcPath.Append('/');
00549
00550 TString s_test = "test";
00551 const Text_t *t_test = (const Text_t *)s_test.Data();
00552 TestslcPath.Append(t_test);
00553 TestslcPath.Append('/');
00554
00555 const Text_t *t_cmssw_subsystem = (const Text_t *)CMSSWSlc().Data();
00556 TestslcPath.Append(t_cmssw_subsystem);
00557 TestslcPath.Append('/');
00558
00559 return TestslcPath;
00560 }
00561
00562
00563
00564 void TEcnaParPaths::SetResultsRootFilePath(const TString ImposedPath) {fCfgResultsRootFilePath = ImposedPath;}
00565 void TEcnaParPaths::SetResultsAsciiFilePath(const TString ImposedPath){fCfgResultsAsciiFilePath = ImposedPath;}
00566
00567 void TEcnaParPaths::TruncateResultsRootFilePath(const Int_t& n1, const Int_t& nbcar)
00568 {fCfgResultsRootFilePath.Remove(n1,nbcar);}
00569
00570 void TEcnaParPaths::TruncateResultsAsciiFilePath(const Int_t& n1, const Int_t& nbcar)
00571 {fCfgResultsAsciiFilePath.Remove(n1,nbcar);}
00572
00573 TString TEcnaParPaths::BeginningOfResultsRootFilePath()
00574 {TString sBegin = "?";
00575 if( fCfgResultsRootFilePath.BeginsWith("$HOME") ){sBegin = "$HOME";}
00576 return sBegin;}
00577
00578 TString TEcnaParPaths::BeginningOfResultsAsciiFilePath()
00579 {TString sBegin = "?";
00580 if( fCfgResultsAsciiFilePath.BeginsWith("$HOME") ){sBegin = "$HOME";}
00581 return sBegin;}
00582
00583 void TEcnaParPaths::AppendResultsRootFilePath(const Text_t * t_file_nohome)
00584 {fCfgResultsRootFilePath.Append(t_file_nohome);}
00585
00586 void TEcnaParPaths::AppendResultsAsciiFilePath(const Text_t * t_file_nohome)
00587 {fCfgResultsAsciiFilePath.Append(t_file_nohome);}