diff --git a/AculCalib/AculCalib.mk b/AculCalib/AculCalib.mk index 4aab82ebd365326cd89349e38b8389fad461519a..de43af6dee3ecf180d54391fca87f16af04665a0 100755 --- a/AculCalib/AculCalib.mk +++ b/AculCalib/AculCalib.mk @@ -14,7 +14,7 @@ $(ACULCALIB)/AculCalPars.h \ $(ACULCALIB)/AculCalParsScint.h \ $(ACULCALIB)/AculCalParsScintFile.h \ $(ACULCALIB)/AculCalParsSi.h \ -$(ACULCALIB)/linkdef.h +$(ACULCALIB)/AculCalibLinkDef.h ACULCALIBCPP_SRCS += \ $(ACULCALIB)/AculCalib.cpp \ diff --git a/AculCalib/linkdef.h b/AculCalib/AculCalibLinkDef.h similarity index 100% rename from AculCalib/linkdef.h rename to AculCalib/AculCalibLinkDef.h diff --git a/AculCalib/CMakeLists.txt b/AculCalib/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8264c513583d8e62954e99cdb97948522e646da7 --- /dev/null +++ b/AculCalib/CMakeLists.txt @@ -0,0 +1,31 @@ +############################################################################ +# CMakeLists.txt file for building AculCalib package +############################################################################ + +ROOT_STANDARD_LIBRARY_PACKAGE(AculCalib + HEADERS + AculCalib.h + AculCalibScint.h + AculCalibSi.h + AculCalPars.h + AculCalParsScintFile.h + AculCalParsScint.h + AculCalParsSi.h + SOURCES + AculCalib.cpp + # AculCalibDict.cpp + AculCalibScint.cpp + AculCalibSi.cpp + AculCalPars.cpp + AculCalParsScint.cpp + AculCalParsScintFile.cpp + AculCalParsSi.cpp +# DEPENDENCIES +# MathCore +# Matrix +# RIO + LINKDEF + AculCalibLinkDef.h +) + +ROOT_ADD_TEST_SUBDIRECTORY(test) \ No newline at end of file diff --git a/AculData/ConfigDictionary.cpp b/AculData/ConfigDictionary.cpp deleted file mode 100644 index 81465fd3b04c1a57784516fb03cebab3e65dd015..0000000000000000000000000000000000000000 --- a/AculData/ConfigDictionary.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "ConfigDictionary.h" - -ClassImp(ConfigDictionary); - -////////////////////////////////////////////////////////////////////////////// -// BEGIN_HTML -//

Config(uration)Dictionary class

-//
-// Author: Bartlomiej Hnatio 2012-08-06 -//

-// This is very useful class to convert strings containing pairs "key"="value" -// into fast dictionaries. This strings are often read from external files. -// From dictionary created in such way one can easily -// extract values in few supported formats (integer, double, boolean, string) -// It can also be used in opposite direction: when dictionary is created with -// given values and keys, one can create config string, which is most -// convenient to write in external files. -//


-// Most simple example of usage: -//

Suppose you have two variables fD and fI: -//
-------------------
-//    Double_t fD;
-//    Int_t fI;
-//
-//fD = 3.14;
-//fI = 2012;
-//-----------------------
-// To save its parameters into file you can create ConfigDictionary class -// instance and use SetDouble and SetInt functions to -// insert parameters values with arbitrarly defined keys (let them be -// really long and descriptive in this example): -//
---------------------
-//ConfigDictionary CD;
-//CD.SetDouble("Most important variable D",fD);
-//CD.SetInt("Equally important integer I",fI);
-//---------------------
-// Now configuration string saved in ConfigDictionary CD -// can be obtained with ToString method and should look like: -//
-//"Most important variable D"="3.14" "Equally important integer I"="2012"
-//
-//
It can be easily saved to a file using simplest fstream -// methods. And the advantage is that as a key one can use any string, -// so configuration file created in such way is very self-explanatory. -//
-//
-// Now lets suppose the opposite action - loading config from file. -// Imagine, that you have 1000 objects of A class, which config was saved -// to file - one object per line: -//
-----------------
-//"Most important variable D"="3.14" "Equally important integer I"="2012"
-//"Equally important integer I"="1011" "Most important variable D"="8.15"
-//"Most important variable D"="13.16" "Equally important integer I"="10"
-//(...)
-//----------------
-// Please notice that order in which pairs of keys and values are placed -// in file doesn't make any difference to the ConfigDictionary class. -// To recreate objects, you just read each line containing single -// config string and then create with it ConfigDictionary object -// using special constructor with string as argument, -// or using FromString method. After this, you can -// extract parameters (using GetDouble and GetInt methods) -// with using same keys as were used for saving, and ConfigDictionary -// will return their values: -//
----------------------
-//string line;//This line you read from file
-//ConfigDictionary CD(line);
-//fD = CD.GetDouble("Most important variable D");
-//fI = CD.GetInt("Equally important integer I");
-//--------------------
-//
-// And last but not least: what happens, if key requested by user doesn't -// exist in dictionary? (This can be caused by many reasons, mostly errors on -// user side, but not always). -// When you try to extract non-existent key using Get functions, -// an exception is risen. In normal program it should end execution and print -// some information about where program stopped working. -// But lets say that you don't want that, i.e. program may use default -// configs instead of those from files, or not all keys were that important. -// You can surround all uses of Get methods with try/catch clause. -// So when exception is risen, you will catch it, and decide, if you want -// the program to stop running, or anything else. Simple example is -// shown below: -//
-------------------
-//ConfigDictionary CD(some_string);
-//try{//try to read important variables:
-//  double d = CD.GetDouble("crucial var");
-//  bool b = CD.GetBool("most important b");
-//  int i = CD.GetInt("unique ID");
-//  //...and so on
-//}catch(std::string & e){//catch any kind of exception
-//  Error("Some crucial variable wasn't read, ending program!");
-//  return SOME_REALLY_BAD_ERROR_CODE;
-//}
-//try{//now less important, or optional:
-//  string name = CD.GetString("least important variable");
-//  double p = CD.GetDouble("optional parameter");
-//  //...and so on
-//}catch(std::string & f){
-//  Info("Some optional variables wasn't read!");
-//}
-//--------------------
-// END_HTML -////////////////////////////////////////////////////////////////////////////// - -//_____________________________________________________________________________ -ConfigDictionary::ConfigDictionary(){ - //just empty map... -} - -//_____________________________________________________________________________ -ConfigDictionary::ConfigDictionary(std::string params){ - //Just creates dictionary using FromString method - FromString(params); -} - -//_____________________________________________________________________________ -std::string ConfigDictionary::ToString(){ - //Builds string that can be easily saved to file. - //Same format that can be read from files or from QtGui - //This should work same way for all uses - - std::map::iterator it;//Iterator to map elements - std::stringstream ss;//stream helpful with adding strings - //iterate whole dictionary: - for (it=configMap.begin();it!=configMap.end();++it){ - //insert pairs "key"="value": - ss<<"\""<first<<"\""<<"="<<"\""<second<<"\""<<" "; - } - return ss.str(); -} - -//_____________________________________________________________________________ -void ConfigDictionary::FromString(std::string params){ - //params - TString containing list of key=value pairs - // - //Changes string formatted: - //"key1"="value1" "key2"="value with spaces 2" ... - //into map with keys and values - //Useful in lots of I/O functions, - //when we want to have a nice, readable format of data - - std::stringstream loading(params); - std::string k,v; - - while(!loading.fail()){ - getline(loading,k,'\"');//removes everything to first " - getline(loading,k,'\"');//All chars between first two "" are the key - getline(loading,v,'\"');//removes all until third " - getline(loading,v,'\"');//All between another pair of "" is the value - if (!loading.fail()) - configMap[k]=v; - } -} - -//_____________________________________________________________________________ -std::string ConfigDictionary::GetString(std::string key)throw(std::string){ - //Extracts string from given key - //(if it exist, otherwise raises exception) - - if (configMap.find(key) == configMap.end()){ - Error("ConfigDictionary::GetString", - "Couldn't find the key: %s!",key.c_str()); - throw(key); - } - return configMap[key]; -} - -//_____________________________________________________________________________ -int ConfigDictionary::GetInt(std::string key)throw(std::string){ - //Extracts integer from given key - //(if it exist, otherwise raises exception) - if (configMap.find(key) == configMap.end()){ - Error("ConfigDictionary::GetInt", - "Couldn't find the key: %s!",key.c_str()); - throw(key); - } - int returned=0; - //Convert string to int: - std::stringstream ss(configMap[key]); - ss>>returned; - return returned; -} - -//_____________________________________________________________________________ -double ConfigDictionary::GetDouble(std::string key)throw(std::string){ - //Extracts integer from given key - //(if it exist, otherwise raises exception) - if (configMap.find(key) == configMap.end()){ - Error("ConfigDictionary::GetDouble", - "Couldn't find the key: %s!",key.c_str()); - throw(key); - } - double returned=0.0; - //Convert string to double: - std::stringstream ss(configMap[key]); - ss>>returned; - return returned; -} - -//_____________________________________________________________________________ -bool ConfigDictionary::GetBool(std::string key)throw(std::string){ - //Extracts boolean from given key - //(if it exist, otherwise raises exception) - if (configMap.find(key) == configMap.end()){ - Error("ConfigDictionary::GetBool", - "Couldn't find the key: %s!",key.c_str()); - throw(key); - } - //Convert string to bool: - if (configMap[key].compare("true") == 0) - return true; - else return false; -} - -//_____________________________________________________________________________ -void ConfigDictionary::SetString(std::string key,std::string value){ - //Sets value to key, no comments needed here... - configMap[key] = value; -} - -//_____________________________________________________________________________ -void ConfigDictionary::SetDouble(std::string key,double value){ - //Sets value to key, converts double to string first - std::stringstream ss; - ss< -#include -#include -#include "TLorentzVector.h" -#include -#include "TMath.h" -#include "TString.h" -#include "TTree.h" - - -class ConfigDictionary{ -public: - typedef std::map::iterator CDIter; - ConfigDictionary(); - ConfigDictionary(std::string); - virtual ~ConfigDictionary(){};//empty virtual destructor - - ClassDef(ConfigDictionary,1); - std::string ToString(); - void FromString(std::string); - - //These throw errors if couldn't find key: - std::string GetString(std::string)throw(std::string); - int GetInt(std::string)throw(std::string); - double GetDouble(std::string)throw(std::string); - bool GetBool(std::string)throw(std::string); - - //These will always set 'something' into map: - void SetString(std::string,std::string); - void SetDouble(std::string,double); - void SetInt(std::string,int); - void SetBool(std::string,bool); - - CDIter Begin(){return configMap.begin();}; - CDIter End(){return configMap.end();}; - -private: - std::map configMap; -}; - -#endif diff --git a/AculData/ReturnCodes.h b/AculData/ReturnCodes.h deleted file mode 100644 index 9bf1432ce593c96df4def92a529b9b862612e5f0..0000000000000000000000000000000000000000 --- a/AculData/ReturnCodes.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RETURN_CODES_H -#define RETURN_CODES_H - -//Some useful return codes - - const static int SUCCESS = 0; - const static int IOEXCEPTION = -1; - const static int NOTFOUND = -2; - const static int NULLPOINTER = -3; - const static int UNKNOWN = -4; - const static int FAILURE = -5; - const static int CDEXCEPTION = -6; - const static int EMPTYCONTAINER = -7; - const static int NOTDEFINED = -8; - const static int EXCEPTION = -11; - -#endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b667c5fd8fcfd6f38102b8d7ece0413b034bef2..4b2e6407dc84ed4b9696a2427230dd2528148336 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,17 @@ message(STATUS "ROOT include directories: ${ROOT_INCLUDE_DIRS}") # Add the subdirectories add_subdirectory(TELoss) +add_subdirectory(AculCalib) add_subdirectory(AculData) +add_subdirectory(Utilities) # Set the output directory for the dictionary files set(GEN_DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") -message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}") \ No newline at end of file +message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") +message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}") +message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") + +# add_custom_target(clean_all +# COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/* +# ) \ No newline at end of file diff --git a/README b/README index ee77b5340a77c18e1278bd18f996130e91d25b97..55de3b8d0b7802caff590afae6b5b03929f19567 100755 --- a/README +++ b/README @@ -1,5 +1,6 @@ Tested with root_6.28_04 (precompiled binaries for Ubuntu 20.04) +root-6.22.08 (compiled from source at nra161: /LynxOS/mbsusr/mbsdaq/analysis/root/root-6.22.08) I. Use with GNU make diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..460ad7bf4ebb16e1dc03fa53179d6e20feb4faf5 --- /dev/null +++ b/Utilities/CMakeLists.txt @@ -0,0 +1,23 @@ +############################################################################ +# CMakeLists.txt file for building Utilities package +############################################################################ + +ROOT_STANDARD_LIBRARY_PACKAGE(Utilities + HEADERS + CalPars.h + ConfigDictionary.h + CsICalib.h + ReturnCodes.h + SOURCES + CalPars.cpp + ConfigDictionary.cpp + CsICalib.cpp +# DEPENDENCIES +# MathCore +# Matrix +# RIO + LINKDEF + UtilitiesLinkDef.h +) + +ROOT_ADD_TEST_SUBDIRECTORY(test) \ No newline at end of file diff --git a/Utilities/Utilities.mk b/Utilities/Utilities.mk index cdbdc4a263f92b4111aa343219766d4f4931847f..9e12153f092a2012ba6e449d5df246f9a4dcf842 100644 --- a/Utilities/Utilities.mk +++ b/Utilities/Utilities.mk @@ -11,7 +11,7 @@ UTILITIES_HEADERS += \ $(UTILITIES)/CalPars.h \ $(UTILITIES)/CsICalib.h \ $(UTILITIES)/ConfigDictionary.h \ -$(UTILITIES)/linkdef.h +$(UTILITIES)/UtilitiesLinkDef.h UTILITIESCPP_SRCS += \ $(UTILITIES)/CalPars.cpp \ diff --git a/Utilities/linkdef.h b/Utilities/UtilitiesLinkDef.h similarity index 100% rename from Utilities/linkdef.h rename to Utilities/UtilitiesLinkDef.h