diff --git a/Base/CMakeLists.txt b/Base/CMakeLists.txt index 2f5f3aace4729..4008d662dea69 100644 --- a/Base/CMakeLists.txt +++ b/Base/CMakeLists.txt @@ -1,5 +1,7 @@ set(INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/Base +${Boost_INCLUDE_DIRS} +${FAIRROOT_INCLUDE_DIR} ${BASE_INCLUDE_DIRECTORIES} ${ROOT_INCLUDE_DIR} ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96e0c24753939..2c838f61beef4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,23 +16,30 @@ project(ALICEO2) #ENABLE_LANGUAGE(Fortran) # Check for needed environment variables -IF(NOT DEFINED ENV{FAIRROOTPATH}) - MESSAGE(FATAL_ERROR "You did not define the environment variable FAIRROOTPATH which is needed to find FairRoot. Please set this variable and execute cmake again.") -ENDIF(NOT DEFINED ENV{FAIRROOTPATH}) - -IF(NOT DEFINED ENV{SIMPATH}) - MESSAGE(FATAL_ERROR "You did not define the environment variable SIMPATH which is nedded to find the external packages. Please set this variable and execute cmake again.") -ENDIF(NOT DEFINED ENV{SIMPATH}) - -SET(SIMPATH $ENV{SIMPATH}) -SET(FAIRROOTPATH $ENV{FAIRROOTPATH}) - -# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ -# is checked -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") -set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules" ${CMAKE_MODULE_PATH}) - -Set(CheckSrcDir "${FAIRROOTPATH}/share/fairbase/cmake/checks") +#If not stop execution unless modular build is activated +Option(ALICEO2_MODULAR_BUILD "Modular build without environment variables" OFF) +if(NOT ALICEO2_MODULAR_BUILD) + IF(NOT DEFINED ENV{FAIRROOTPATH}) + MESSAGE(FATAL_ERROR "You did not define the environment variable FAIRROOTPATH which is needed to find FairRoot. Please set this variable and execute cmake again.") + ENDIF(NOT DEFINED ENV{FAIRROOTPATH}) + + IF(NOT DEFINED ENV{SIMPATH}) + MESSAGE(FATAL_ERROR "You did not define the environment variable SIMPATH which is nedded to find the external packages. Please set this variable and execute cmake again.") + ENDIF(NOT DEFINED ENV{SIMPATH}) + + SET(SIMPATH $ENV{SIMPATH}) + SET(FAIRROOTPATH $ENV{FAIRROOTPATH}) + + # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ + # is checked + set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) + set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules" ${CMAKE_MODULE_PATH}) + set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules_old" ${CMAKE_MODULE_PATH}) + + Set(CheckSrcDir "${FAIRROOTPATH}/share/fairbase/cmake/checks") +else(NOT ALICEO2_MODULAR_BUILD) + find_package(Boost REQUIRED) +endif(NOT ALICEO2_MODULAR_BUILD) find_package(FairRoot) @@ -88,32 +95,42 @@ CHECK_EXTERNAL_PACKAGE_INSTALL_DIR() find_package(ROOT 5.32.00 REQUIRED) find_package(Pythia8) -find_package(GENERATORS REQUIRED) -find_package(GEANT3 REQUIRED) -find_package(GEANT4) -find_package(GEANT4DATA) -find_package(GEANT4VMC) -find_package(CLHEP) +find_package(Pythia6) +if(ALICEO2_MODULAR_BUILD) + # Geant3, Geant4 installed via cmake + find_package(Geant3 REQUIRED) + find_package(Geant4 REQUIRED) +else(ALICEO2_MODULAR_BUILD) + # For old versions of VMC packages (to be removed) + find_package(GEANT3 REQUIRED) + find_package(GEANT4) + find_package(GEANT4DATA) + find_package(GEANT4VMC) + find_package(CLHEP) +endif(ALICEO2_MODULAR_BUILD) find_package(CERNLIB) find_package(HEPMC) -Set(Boost_NO_SYSTEM_PATHS TRUE) -Set(Boost_NO_BOOST_CMAKE TRUE) -If(${ROOT_LIBRARY_DIR} MATCHES /lib/root) - set(BOOST_ROOT ${SIMPATH}) - set(GSL_DIR ${SIMPATH}) -Else(${ROOT_LIBRARY_DIR} MATCHES /lib/root) - set(BOOST_ROOT ${SIMPATH}/basics/boost) - set(GSL_DIR ${SIMPATH}/basics/gsl) -EndIf(${ROOT_LIBRARY_DIR} MATCHES /lib/root) -Message("-- Looking for Boost ...") -# If an older version of boost is found both of the variables below are -# cached and in a second cmake run, a good boost version is found even -# if the version is to old. -# To overcome this problem both variables are cleared before checking -# for boost. -Unset(Boost_INCLUDE_DIR CACHE) -Unset(Boost_LIBRARY_DIRS CACHE) + +if(NOT BOOST_ROOT) + Set(Boost_NO_SYSTEM_PATHS TRUE) + Set(Boost_NO_BOOST_CMAKE TRUE) + If(${ROOT_LIBRARY_DIR} MATCHES /lib/root) + set(BOOST_ROOT ${SIMPATH}) + set(GSL_DIR ${SIMPATH}) + Else(${ROOT_LIBRARY_DIR} MATCHES /lib/root) + set(BOOST_ROOT ${SIMPATH}/basics/boost) + set(GSL_DIR ${SIMPATH}/basics/gsl) + EndIf(${ROOT_LIBRARY_DIR} MATCHES /lib/root) + Message("-- Looking for Boost ...") + # If an older version of boost is found both of the variables below are + # cached and in a second cmake run, a good boost version is found even + # if the version is to old. + # To overcome this problem both variables are cleared before checking + # for boost. + Unset(Boost_INCLUDE_DIR CACHE) + Unset(Boost_LIBRARY_DIRS CACHE) +endif(NOT BOOST_ROOT) find_package(Boost 1.41) If (Boost_FOUND) Set(Boost_Avail 1) @@ -123,7 +140,9 @@ EndIf (Boost_FOUND) # set a variable which should be used in all CMakeLists.txt # Defines all basic include directories from fairbase -SetBasicVariables() +if(NOT ALICEO2_MODULAR_BUILD) + SetBasicVariables() +endif(NOT ALICEO2_MODULAR_BUILD) # Set the library version in the main CMakeLists.txt SET(FAIRROOT_MAJOR_VERSION 0) @@ -144,9 +163,11 @@ SET(LD_LIBRARY_PATH ${_LIBDIR} ${LD_LIBRARY_PATH}) #install(DIRECTORY geometry DESTINATION pnd_install # ) +if(NOT ALICEO2_MODULAR_BUILD) # Check if the compiler support specific C++11 features # Up to now this is only a check since the code does not use # any of the features of the new standard +# does not work straightforward include(CheckCXX11Features) # Check if the compilation flag -std=c++11 is set @@ -154,6 +175,12 @@ If(NOT CMAKE_CXX_FLAGS) Message(FATAL_ERROR "No C++11 support found. AliceO2 require C++11 be build.") EndIF(NOT CMAKE_CXX_FLAGS) +else(NOT ALICEO2_MODULAR_BUILD) + # This needs to be improved + # (hopefully by making CheckCXX11Features working also with this build option) + set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") +endif(NOT ALICEO2_MODULAR_BUILD) + # Recurse into the given subdirectories. This does not actually # cause another cmake executable to run. The same process will walk through # the project's entire directory structure. @@ -162,7 +189,9 @@ add_subdirectory (Base) add_subdirectory (Data) add_subdirectory (Generators) add_subdirectory (its) +add_subdirectory (tpc) add_subdirectory (passive) +add_subdirectory (MathUtils) add_subdirectory (field) add_subdirectory (devices) Add_Subdirectory(macro) diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 88956c76bb6bf..a007040f3112b 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -1,5 +1,8 @@ set(INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/Data +${Boost_INCLUDE_DIRS} +${FAIRROOT_INCLUDE_DIR} +${AlFa_DIR}/include ${BASE_INCLUDE_DIRECTORIES} ${ROOT_INCLUDE_DIR} ) diff --git a/Data/DetectorList.h b/Data/DetectorList.h index c6c241c750226..8489f6a35876c 100644 --- a/Data/DetectorList.h +++ b/Data/DetectorList.h @@ -5,6 +5,6 @@ #define ALICEO2_DATA_DETECTORLIST_H_ // kSTOPHERE is needed for iteration over the enum. All detectors have to be put before. -enum DetectorId { kAliIts, kSTOPHERE }; +enum DetectorId { kAliIts, kAliTpc, kSTOPHERE }; #endif diff --git a/Generators/CMakeLists.txt b/Generators/CMakeLists.txt index 31dd0244c8f69..1364c27644c0a 100644 --- a/Generators/CMakeLists.txt +++ b/Generators/CMakeLists.txt @@ -4,6 +4,8 @@ set(INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIR} +${FAIRROOT_INCLUDE_DIR} +${AlFa_DIR}/include ${PYTHIA8_INCLUDE_DIR} ${SIMPATH}/include ${BASE_INCLUDE_DIRECTORIES} @@ -15,6 +17,7 @@ include_directories( ${INCLUDE_DIRECTORIES}) set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR} ${FAIRROOT_LIBRARY_DIR} +${AlFa_DIR}/lib ${SIMPATH}/lib ) diff --git a/MathUtils/CMakeLists.txt b/MathUtils/CMakeLists.txt new file mode 100644 index 0000000000000..e7a0e5ddeb33f --- /dev/null +++ b/MathUtils/CMakeLists.txt @@ -0,0 +1,34 @@ +# Create a library called "MathUtils" which includes the source files given in +# the array. +# The extension is already found. Any number of sources could be listed here. + +set(INCLUDE_DIRECTORIES +${CMAKE_SOURCE_DIR}/MathUtils +${BASE_INCLUDE_DIRECTORIES} +${FAIRROOT_INCLUDE_DIR} +${AlFa_DIR}/include +${ROOT_INCLUDE_DIR} +) + +include_directories( ${INCLUDE_DIRECTORIES}) + +set(LINK_DIRECTORIES +${CMAKE_SOURCE_DIR}/MathUtils +${FAIRROOT_LIBRARY_DIR} +${ROOT_LIBRARY_DIR} +) + +link_directories( ${LINK_DIRECTORIES}) + +set(SRCS +Chebyshev3D.cxx +Chebyshev3DCalc.cxx +) + +Set(HEADERS) +Set(LINKDEF MathUtilsLinkDef.h) +Set(LIBRARY_NAME MathUtils) +Set(DEPENDENCIES Cint Core) + +GENERATE_LIBRARY() + diff --git a/field/Chebyshev3D.cxx b/MathUtils/Chebyshev3D.cxx similarity index 93% rename from field/Chebyshev3D.cxx rename to MathUtils/Chebyshev3D.cxx index 4881c8eba63ab..1e34a588f7d00 100644 --- a/field/Chebyshev3D.cxx +++ b/MathUtils/Chebyshev3D.cxx @@ -14,13 +14,15 @@ #include "Chebyshev3DCalc.h" #include "FairLogger.h" -using namespace AliceO2::Field; +using namespace AliceO2::MathUtils; ClassImp(Chebyshev3D) +const Float_t Chebyshev3D::sMinimumPrecision = 1.e-12f; + Chebyshev3D::Chebyshev3D() : mOutputArrayDimension(0), - mPrecision(0), + mPrecision(sMinimumPrecision), mChebyshevParameter(1), mMaxCoefficients(0), mTemporaryUserResults(0), @@ -111,11 +113,11 @@ Chebyshev3D::Chebyshev3D(FILE* stream) } #ifdef _INC_CREATION_Chebyshev3D_ -Chebyshev3D::Chebyshev3D(const char* funName, int DimOut, const Float_t* bmin, const Float_t* bmax, Int_t* npoints, - Float_t prec) +Chebyshev3D::Chebyshev3D(const char* funName, int dimOut, const Float_t* bmin, const Float_t* bmax, + const Int_t* npoints, Float_t prec, const Float_t* precD) : TNamed(funName, funName), mOutputArrayDimension(0), - mPrecision(TMath::Max(1.E-12f, prec)), + mPrecision(TMath::Max(sMinimumPrecision, prec)), mChebyshevParameter(1), mMaxCoefficients(0), mTemporaryUserResults(0), @@ -124,7 +126,7 @@ Chebyshev3D::Chebyshev3D(const char* funName, int DimOut, const Float_t* bmin, c mUserMacro(0), mLogger(FairLogger::GetLogger()) { - if (DimOut < 1) { + if (dimOut < 1) { Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); exit(1); } @@ -134,7 +136,7 @@ Chebyshev3D::Chebyshev3D(const char* funName, int DimOut, const Float_t* bmin, c mTemporaryChebyshevGridOffs[i] = 0.; mTemporaryCoefficient[i] = 0; } - setDimOut(DimOut); + setDimOut(dimOut,precD); prepareBoundaries(bmin, bmax); defineGrid(npoints); setuserFunction(funName); @@ -143,10 +145,10 @@ Chebyshev3D::Chebyshev3D(const char* funName, int DimOut, const Float_t* bmin, c #endif #ifdef _INC_CREATION_Chebyshev3D_ -Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, Float_t* bmax, Int_t* npoints, - Float_t prec) +Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int dimOut, const Float_t* bmin, const Float_t* bmax, + const Int_t* npoints, Float_t prec, const Float_t* precD) : mOutputArrayDimension(0), - mPrecision(TMath::Max(1.E-12f, prec)), + mPrecision(TMath::Max(sMinimumPrecision, prec)), mChebyshevParameter(1), mMaxCoefficients(0), mTemporaryUserResults(0), @@ -155,11 +157,7 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, mUserMacro(0), mLogger(FairLogger::GetLogger()) { - if (DimOut < 1) { - Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); - exit(1); - } - if (DimOut < 1) { + if (dimOut < 1) { Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); exit(1); } @@ -169,7 +167,7 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, mTemporaryChebyshevGridOffs[i] = 0.; mTemporaryCoefficient[i] = 0; } - setDimOut(DimOut); + setDimOut(dimOut,precD); prepareBoundaries(bmin, bmax); defineGrid(npoints); setuserFunction(ptr); @@ -178,10 +176,10 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, #endif #ifdef _INC_CREATION_Chebyshev3D_ -Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, Float_t* bmax, Int_t* npX, Int_t* npY, - Int_t* npZ, Float_t prec) +Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int dimOut, const Float_t* bmin, const Float_t* bmax, + const Int_t* npX, const Int_t* npY, const Int_t* npZ, Float_t prec, const Float_t* precD) : mOutputArrayDimension(0), - mPrecision(TMath::Max(1.E-12f, prec)), + mPrecision(TMath::Max(sMinimumPrecision, prec)), mChebyshevParameter(1), mMaxCoefficients(0), mTemporaryUserResults(0), @@ -190,11 +188,7 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, mUserMacro(0), mLogger(FairLogger::GetLogger()) { - if (DimOut < 1) { - Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); - exit(1); - } - if (DimOut < 1) { + if (dimOut < 1) { Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); exit(1); } @@ -204,7 +198,7 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, mTemporaryChebyshevGridOffs[i] = 0.; mTemporaryCoefficient[i] = 0; } - setDimOut(DimOut); + setDimOut(dimOut,precD); prepareBoundaries(bmin, bmax); setuserFunction(ptr); @@ -218,10 +212,10 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, #endif #ifdef _INC_CREATION_Chebyshev3D_ -Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, Float_t* bmax, Float_t prec, - Bool_t run) +Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int dimOut, const Float_t* bmin, const Float_t* bmax, + Float_t prec, Bool_t run, const Float_t* precD) : mOutputArrayDimension(0), - mPrecision(TMath::Max(1.E-12f, prec)), + mPrecision(TMath::Max(sMinimumPrecision, prec)), mChebyshevParameter(1), mMaxCoefficients(0), mTemporaryUserResults(0), @@ -230,11 +224,11 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, mUserMacro(0), mLogger(FairLogger::GetLogger()) { - if (DimOut != 3) { + if (dimOut != 3) { Error("Chebyshev3D", "This constructor works only for 3D fits, %dD fit was requested\n", mOutputArrayDimension); exit(1); } - if (DimOut < 1) { + if (dimOut < 1) { Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); exit(1); } @@ -244,7 +238,7 @@ Chebyshev3D::Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, mTemporaryChebyshevGridOffs[i] = 0.; mTemporaryCoefficient[i] = 0; } - setDimOut(DimOut); + setDimOut(dimOut, precD); prepareBoundaries(bmin, bmax); setuserFunction(ptr); @@ -458,7 +452,7 @@ Int_t Chebyshev3D::calculateChebyshevCoefficients(const Float_t* funval, int np, #endif #ifdef _INC_CREATION_Chebyshev3D_ -void Chebyshev3D::defineGrid(Int_t* npoints) +void Chebyshev3D::defineGrid(const Int_t* npoints) { // prepare the grid of Chebyshev roots in each dimension const int kMinPoints = 1; @@ -519,8 +513,6 @@ Int_t Chebyshev3D::chebyshevFit(int dmOut) Float_t* tmpCoef2D = new Float_t[mNumberOfPoints[0] * mNumberOfPoints[1]]; Float_t* tmpCoef1D = new Float_t[maxDim]; - Float_t rTiny = 0.1 * mPrecision / Float_t(maxDim); // neglect coefficient below this threshold - // 1D Cheb.fit for 0-th dimension at current steps of remaining dimensions int ncmax = 0; @@ -528,6 +520,10 @@ Int_t Chebyshev3D::chebyshevFit(int dmOut) fflush(stdout); Chebyshev3DCalc* cheb = getChebyshevCalc(dmOut); + Float_t prec = cheb->getPrecision(); + if (precinitRows(nRows); // create needed arrays; + cheb->initializeRows(nRows); // create needed arrays; UShort_t* nColsAtRow = cheb->getNumberOfColumnsAtRow(); - UShort_t* colAtRowBg = cheb->GetColAtRowBg(); + UShort_t* colAtRowBg = cheb->getColAtRowBg(); int nCols = 0; int nElemBound2D = 0; for (int id0 = 0; id0 < nRows; id0++) { @@ -651,12 +647,12 @@ Int_t Chebyshev3D::chebyshevFit(int dmOut) nCols = nColsAtRow[id0]; } } - cheb->initCols(nCols); + cheb->initializeColumns(nCols); delete[] tmpCols; // create the 2D matrix defining the boundary of significance for 3D coeffs.matrix // and count the number of siginifacnt coefficients - cheb->InitElemBound2D(nElemBound2D); + cheb->initializeElementBound2D(nElemBound2D); UShort_t* coefBound2D0 = cheb->getCoefficientBound2D0(); UShort_t* coefBound2D1 = cheb->getCoefficientBound2D1(); mMaxCoefficients = 0; // redefine number of coeffs @@ -821,7 +817,7 @@ void Chebyshev3D::loadData(FILE* stream) } } -void Chebyshev3D::setDimOut(const int d) +void Chebyshev3D::setDimOut(const int d, const float* prec) { // init output dimensions mOutputArrayDimension = d; @@ -831,6 +827,8 @@ void Chebyshev3D::setDimOut(const int d) mTemporaryUserResults = new Float_t[mOutputArrayDimension]; mChebyshevParameter.Delete(); for (int i = 0; i < d; i++) { + Chebyshev3DCalc* clc = new Chebyshev3DCalc(); + clc->setPrecision(prec && prec[i]>sMinimumPrecision ? prec[i] : mPrecision); mChebyshevParameter.AddAtAndExpand(new Chebyshev3DCalc(), i); } } @@ -860,6 +858,10 @@ TH1* Chebyshev3D::TestRMS(int idim, int npoints, TH1* histo) if (!histo) { histo = new TH1D(GetName(), "Control: Function - Parametrization", 100, -2 * mPrecision, 2 * mPrecision); } + + float prc = getChebyshevCalc(idim)->getPrecision(); + if (prcRndmArray(3, (Float_t*)mTemporaryCoefficient); for (int i = 3; i--;) { @@ -877,7 +879,7 @@ TH1* Chebyshev3D::TestRMS(int idim, int npoints, TH1* histo) #ifdef _INC_CREATION_Chebyshev3D_ -void Chebyshev3D::estimateNumberOfPoints(float Prec, int gridBC[3][3], Int_t npd1, Int_t npd2, Int_t npd3) +void Chebyshev3D::estimateNumberOfPoints(float prec, int gridBC[3][3], Int_t npd1, Int_t npd2, Int_t npd3) { // Estimate number of points to generate a training data const int kScp = 9; @@ -904,7 +906,7 @@ void Chebyshev3D::estimateNumberOfPoints(float Prec, int gridBC[3][3], Int_t npd xyz[id1] = mMinBoundaries[id1] + kScl[i1] * (mMaxBoundaries[id1] - mMinBoundaries[id1]); for (int i2 = 0; i2 < kScp; i2++) { xyz[id2] = mMinBoundaries[id2] + kScl[i2] * (mMaxBoundaries[id2] - mMinBoundaries[id2]); - int* npt = getNcNeeded(xyz, idim, dimMN, dimMX, Prec, npdTst[idim]); // npoints for Bx,By,Bz + int* npt = getNcNeeded(xyz, idim, dimMN, dimMX, prec, npdTst[idim]); // npoints for Bx,By,Bz for (int ib = 0; ib < 3; ib++) { if (npt[ib] > gridBC[ib][idim]) { gridBC[ib][idim] = npt[ib]; diff --git a/field/Chebyshev3D.h b/MathUtils/Chebyshev3D.h similarity index 90% rename from field/Chebyshev3D.h rename to MathUtils/Chebyshev3D.h index baa899d72e271..b12a578c3fa08 100644 --- a/field/Chebyshev3D.h +++ b/MathUtils/Chebyshev3D.h @@ -2,8 +2,8 @@ /// \brief Definition of the Cheb3D class /// \author ruben.shahoyan@cern.ch 09/09/2006 -#ifndef ALICEO2_FIELD_CHEBYSHEV3D_H_ -#define ALICEO2_FIELD_CHEBYSHEV3D_H_ +#ifndef ALICEO2_MATHUTILS_CHEBYSHEV3D_H_ +#define ALICEO2_MATHUTILS_CHEBYSHEV3D_H_ #include #include @@ -21,7 +21,7 @@ class FairLogger; namespace AliceO2 { -namespace Field { +namespace MathUtils { /// Chebyshev3D produces the interpolation of the user 3D->NDimOut arbitrary function supplied in /// "void (*fcn)(float* inp,float* out)" format either in a separate macro file or as a function pointer. Only @@ -69,9 +69,10 @@ class Chebyshev3D : public TNamed { /// \param bmax : array of 3 elements with the upper boundaries of the region where the function is defined /// \param npoints : array of 3 elements with the number of points to compute in each of 3 dimension /// \param prec : max allowed absolute difference between the user function and computed parameterization on the - /// requested grid - Chebyshev3D(const char* funName, Int_t DimOut, const Float_t* bmin, const Float_t* bmax, Int_t* npoints, - Float_t prec = 1E-6); + /// requested grid, common for all 1D components + /// \param precD : optional precison per component + Chebyshev3D(const char* funName, Int_t dimOut, const Float_t* bmin, const Float_t* bmax, const Int_t* npoints, + Float_t prec = 1E-6, const Float_t* precD=0); /// Construct the parameterization for the function /// \param ptr : pointer on the function: void fun(Float_t * inp,Float_t * out) /// \param DimOut : dimension of the vector computed by the user function @@ -79,9 +80,10 @@ class Chebyshev3D : public TNamed { /// \param bmax : array of 3 elements with the upper boundaries of the region where the function is defined /// \param npoints : array of 3 elements with the number of points to compute in each of 3 dimension /// \param prec : max allowed absolute difference between the user function and computed parameterization on the - /// requested grid - Chebyshev3D(void (*ptr)(float*, float*), Int_t DimOut, Float_t* bmin, Float_t* bmax, Int_t* npoints, - Float_t prec = 1E-6); + /// requested grid, common for all 1D components + /// \param precD : optional precison per component + Chebyshev3D(void (*ptr)(float*, float*), Int_t dimOut, const Float_t* bmin, const Float_t* bmax, const Int_t* npoints, + Float_t prec = 1E-6, const Float_t* precD=0); /// Construct very economic parameterization for the function /// \param ptr : pointer on the function: void fun(Float_t * inp,Float_t * out) /// \param DimOut : dimension of the vector computed by the user function @@ -91,18 +93,21 @@ class Chebyshev3D : public TNamed { /// \param npY : array of 3 elements with the number of points to compute in each dimension for 2nd component /// \param npZ : array of 3 elements with the number of points to compute in each dimension for 3d component /// \param prec : max allowed absolute difference between the user function and computed parameterization on the - /// requested grid - Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, Float_t* bmax, Int_t* npX, Int_t* npY, Int_t* npZ, - Float_t prec = 1E-6); + /// requested grid, common for all 1D components + /// \param precD : optional precison per component + Chebyshev3D(void (*ptr)(float*, float*), int dimOut, const Float_t* bmin, const Float_t* bmax, + const Int_t* npX, const Int_t* npY, const Int_t* npZ, + Float_t prec = 1E-6, const Float_t* precD=0); /// Construct very economic parameterization for the function with automatic calculation of the root's grid /// \param ptr : pointer on the function: void fun(Float_t * inp,Float_t * out) /// \param DimOut : dimension of the vector computed by the user function /// \param bmin : array of 3 elements with the lower boundaries of the region where the function is defined /// \param bmax : array of 3 elements with the upper boundaries of the region where the function is defined /// \param prec : max allowed absolute difference between the user function and computed parameterization on the - /// \param requested grid - Chebyshev3D(void (*ptr)(float*, float*), int DimOut, Float_t* bmin, Float_t* bmax, Float_t prec = 1E-6, - Bool_t run = kTRUE); + /// \param requested grid, common for all 1D components + /// \param precD : optional precison per component + Chebyshev3D(void (*ptr)(float*, float*), int DimOut, const Float_t* bmin, const Float_t* bmax, Float_t prec = 1E-6, + Bool_t run = kTRUE, const Float_t* precD=0); #endif ~Chebyshev3D() @@ -163,8 +168,8 @@ class Chebyshev3D : public TNamed { #ifdef _INC_CREATION_Chebyshev3D_ void invertSign(); - int* getNcNeeded(float xyz[3], int DimVar, float mn, float mx, float prec, Int_t npCheck = 30); - void estimateNumberOfPoints(float Prec, int gridBC[3][3], Int_t npd1 = 30, Int_t npd2 = 30, Int_t npd3 = 30); + int* getNcNeeded(float xyz[3], int dimVar, float mn, float mx, float prec, Int_t npCheck = 30); + void estimateNumberOfPoints(float prec, int gridBC[3][3], Int_t npd1 = 30, Int_t npd2 = 30, Int_t npd3 = 30); void saveData(const char* outfile, Bool_t append = kFALSE) const; void saveData(FILE* stream = stdout) const; @@ -177,12 +182,12 @@ class Chebyshev3D : public TNamed { protected: void Clear(const Option_t* option = ""); - void setDimOut(const int d); + void setDimOut(const int d, const float* prec=0); void prepareBoundaries(const Float_t* bmin, const Float_t* bmax); #ifdef _INC_CREATION_Chebyshev3D_ void evaluateUserFunction(); - void defineGrid(Int_t* npoints); + void defineGrid(const Int_t* npoints); Int_t chebyshevFit(); // fit all output dimensions Int_t chebyshevFit(int dmOut); void setPrecision(float prec) @@ -221,7 +226,9 @@ class Chebyshev3D : public TNamed { TMethodCall* mUserMacro; //! Pointer to MethodCall for function from user macro FairLogger* mLogger; //! - ClassDef(AliceO2::Field::Chebyshev3D, 2) // Chebyshev parametrization for 3D->N function + static const Float_t sMinimumPrecision; ///< minimum precision allowed + + ClassDef(AliceO2::MathUtils::Chebyshev3D, 2) // Chebyshev parametrization for 3D->N function }; /// Checks if the point is inside of the fitted box diff --git a/field/Chebyshev3DCalc.cxx b/MathUtils/Chebyshev3DCalc.cxx similarity index 89% rename from field/Chebyshev3DCalc.cxx rename to MathUtils/Chebyshev3DCalc.cxx index 651b38caa7a9e..c201427d09286 100644 --- a/field/Chebyshev3DCalc.cxx +++ b/MathUtils/Chebyshev3DCalc.cxx @@ -6,7 +6,7 @@ #include #include "Chebyshev3DCalc.h" -using namespace AliceO2::Field; +using namespace AliceO2::MathUtils; ClassImp(Chebyshev3DCalc) @@ -15,6 +15,7 @@ Chebyshev3DCalc::Chebyshev3DCalc() mNumberOfRows(0), mNumberOfColumns(0), mNumberOfElementsBound2D(0), + mPrecision(0), mNumberOfColumnsAtRow(0), mColumnAtRowBeginning(0), mCoefficientBound2D0(0), @@ -31,6 +32,7 @@ Chebyshev3DCalc::Chebyshev3DCalc(const Chebyshev3DCalc& src) mNumberOfRows(src.mNumberOfRows), mNumberOfColumns(src.mNumberOfColumns), mNumberOfElementsBound2D(src.mNumberOfElementsBound2D), + mPrecision(src.mPrecision), mNumberOfColumnsAtRow(0), mColumnAtRowBeginning(0), mCoefficientBound2D0(0), @@ -82,6 +84,7 @@ Chebyshev3DCalc::Chebyshev3DCalc(FILE* stream) mNumberOfRows(0), mNumberOfColumns(0), mNumberOfElementsBound2D(0), + mPrecision(0), mNumberOfColumnsAtRow(0), mColumnAtRowBeginning(0), mCoefficientBound2D0(0), @@ -102,6 +105,7 @@ Chebyshev3DCalc& Chebyshev3DCalc::operator=(const Chebyshev3DCalc& rhs) mNumberOfCoefficients = rhs.mNumberOfCoefficients; mNumberOfRows = rhs.mNumberOfRows; mNumberOfColumns = rhs.mNumberOfColumns; + mPrecision = rhs.mPrecision; if (rhs.mNumberOfColumnsAtRow) { mNumberOfColumnsAtRow = new UShort_t[mNumberOfRows]; for (int i = mNumberOfRows; i--;) { @@ -176,7 +180,8 @@ void Chebyshev3DCalc::Clear(const Option_t*) void Chebyshev3DCalc::Print(const Option_t*) const { - printf("Chebyshev parameterization data %s for 3D->1 function.\n", GetName()); + printf("Chebyshev parameterization data %s for 3D->1 function, precision: %e\n", + GetName(),mPrecision); int nmax3d = 0; for (int i = mNumberOfElementsBound2D; i--;) { if (mCoefficientBound2D0[i] > nmax3d) { @@ -258,7 +263,7 @@ Float_t Chebyshev3DCalc::evaluateDerivative2(int dim1, int dim2, const Float_t* : chebyshevEvaluation1D(par[0], mTemporaryCoefficients1D, mNumberOfRows); } -#ifdef _INC_CREATION_ALICHEB3D_ +#ifdef _INC_CREATION_Chebyshev3D_ void Chebyshev3DCalc::saveData(const char* outfile, Bool_t append) const { TString strf = outfile; @@ -269,7 +274,7 @@ void Chebyshev3DCalc::saveData(const char* outfile, Bool_t append) const } #endif -#ifdef _INC_CREATION_ALICHEB3D_ +#ifdef _INC_CREATION_Chebyshev3D_ void Chebyshev3DCalc::saveData(FILE* stream) const { fprintf(stream, "#\nSTART %s\n", GetName()); @@ -289,6 +294,9 @@ void Chebyshev3DCalc::saveData(FILE* stream) const for (int i = 0; i < mNumberOfCoefficients; i++) { fprintf(stream, "%+.8e\n", mCoefficients[i]); } + fprintf(stream,"# Precision\n"); + fprintf(stream,"%+.8e\n",mPrecision); + // fprintf(stream, "END %s\n", GetName()); } #endif @@ -315,7 +323,7 @@ void Chebyshev3DCalc::loadData(FILE* stream) readLine(buffs, stream); // NRows mNumberOfRows = buffs.Atoi(); - if (mNumberOfRows < 1) { + if (mNumberOfRows < 0 || !buffs.IsDigit()) { Error("LoadData", "Expected: '', found \"%s\"\nStop\n", buffs.Data()); exit(1); } @@ -345,16 +353,15 @@ void Chebyshev3DCalc::loadData(FILE* stream) mNumberOfCoefficients += mCoefficientBound2D0[i]; } - if (mNumberOfCoefficients <= 0) { - Error("LoadData", "Negtive (%d) number of Chebychef coeffs. is obtained.\nStop\n", mNumberOfCoefficients); - exit(1); - } - initializeCoefficients(mNumberOfCoefficients); for (int i = 0; i < mNumberOfCoefficients; i++) { readLine(buffs, stream); mCoefficients[i] = buffs.Atof(); } + // read precision + readLine(buffs,stream); + mPrecision = buffs.Atof(); + // check end_of_data record readLine(buffs, stream); if (!buffs.BeginsWith("END") || !buffs.Contains(GetName())) { @@ -380,19 +387,24 @@ void Chebyshev3DCalc::initializeRows(int nr) { if (mNumberOfColumnsAtRow) { delete[] mNumberOfColumnsAtRow; + mNumberOfColumnsAtRow = 0; } if (mColumnAtRowBeginning) { delete[] mColumnAtRowBeginning; + mColumnAtRowBeginning = 0; } if (mTemporaryCoefficients1D) { delete[] mTemporaryCoefficients1D; + mTemporaryCoefficients1D = 0; } mNumberOfRows = nr; - mNumberOfColumnsAtRow = new UShort_t[mNumberOfRows]; - mTemporaryCoefficients1D = new Float_t[mNumberOfRows]; - mColumnAtRowBeginning = new UShort_t[mNumberOfRows]; - for (int i = mNumberOfRows; i--;) { - mNumberOfColumnsAtRow[i] = mColumnAtRowBeginning[i] = 0; + if (mNumberOfRows) { + mNumberOfColumnsAtRow = new UShort_t[mNumberOfRows]; + mTemporaryCoefficients1D = new Float_t[mNumberOfRows]; + mColumnAtRowBeginning = new UShort_t[mNumberOfRows]; + for (int i = mNumberOfRows; i--;) { + mNumberOfColumnsAtRow[i] = mColumnAtRowBeginning[i] = 0; + } } } @@ -401,23 +413,28 @@ void Chebyshev3DCalc::initializeColumns(int nc) mNumberOfColumns = nc; if (mTemporaryCoefficients2D) { delete[] mTemporaryCoefficients2D; + mTemporaryCoefficients2D = 0; } - mTemporaryCoefficients2D = new Float_t[mNumberOfColumns]; + if (mNumberOfColumns) mTemporaryCoefficients2D = new Float_t[mNumberOfColumns]; } void Chebyshev3DCalc::initializeElementBound2D(int ne) { if (mCoefficientBound2D0) { delete[] mCoefficientBound2D0; + mCoefficientBound2D0 = 0; } if (mCoefficientBound2D1) { delete[] mCoefficientBound2D1; + mCoefficientBound2D1 = 0; } mNumberOfElementsBound2D = ne; - mCoefficientBound2D0 = new UShort_t[mNumberOfElementsBound2D]; - mCoefficientBound2D1 = new UShort_t[mNumberOfElementsBound2D]; - for (int i = mNumberOfElementsBound2D; i--;) { - mCoefficientBound2D0[i] = mCoefficientBound2D1[i] = 0; + if (mNumberOfElementsBound2D) { + mCoefficientBound2D0 = new UShort_t[mNumberOfElementsBound2D]; + mCoefficientBound2D1 = new UShort_t[mNumberOfElementsBound2D]; + for (int i = mNumberOfElementsBound2D; i--;) { + mCoefficientBound2D0[i] = mCoefficientBound2D1[i] = 0; + } } } @@ -425,11 +442,14 @@ void Chebyshev3DCalc::initializeCoefficients(int nc) { if (mCoefficients) { delete[] mCoefficients; + mCoefficients = 0; } mNumberOfCoefficients = nc; - mCoefficients = new Float_t[mNumberOfCoefficients]; - for (int i = mNumberOfCoefficients; i--;) { - mCoefficients[i] = 0.0; + if (mNumberOfCoefficients) { + mCoefficients = new Float_t[mNumberOfCoefficients]; + for (int i = mNumberOfCoefficients; i--;) { + mCoefficients[i] = 0.0; + } } } diff --git a/field/Chebyshev3DCalc.h b/MathUtils/Chebyshev3DCalc.h similarity index 93% rename from field/Chebyshev3DCalc.h rename to MathUtils/Chebyshev3DCalc.h index 9c7b9419a55a1..35eea3eea7682 100644 --- a/field/Chebyshev3DCalc.h +++ b/MathUtils/Chebyshev3DCalc.h @@ -2,21 +2,21 @@ /// \brief Definition of the Cheb3DCalc class /// \author ruben.shahoyan@cern.ch 09/09/2006 -#ifndef ALICEO2_FIELD_CHEBYSHEV3DCALC_H_ -#define ALICEO2_FIELD_CHEBYSHEV3DCALC_H_ +#ifndef ALICEO2_MATHUTILS_CHEBYSHEV3DCALC_H_ +#define ALICEO2_MATHUTILS_CHEBYSHEV3DCALC_H_ #include class TSystem; // To decrease the compilable code size comment this define. This will exclude the routines // used for the calculation and saving of the coefficients. -//#define _INC_CREATION_ALICHEB3D_ +#define _INC_CREATION_Chebyshev3D_ // When _BRING_TO_BOUNDARY_ is defined, the point outside of the fitted folume is assumed to be on the surface // #define _BRING_TO_BOUNDARY_ namespace AliceO2 { -namespace Field { +namespace MathUtils { class Chebyshev3DCalc : public TNamed { public: @@ -52,7 +52,7 @@ class Chebyshev3DCalc : public TNamed { /// VERY IMPORTANT: par must contain the function arguments ALREADY MAPPED to [-1:1] interval Float_t evaluateDerivative2(int dim1, int dim2, const Float_t* par) const; -#ifdef _INC_CREATION_ALICHEB3D_ +#ifdef _INC_CREATION_Chebyshev3D_ /// Writes coefficients data to output text file, optionally appending on the end of existing file void saveData(const char* outfile, Bool_t append = kFALSE) const; @@ -95,11 +95,22 @@ class Chebyshev3DCalc : public TNamed { return mNumberOfColumnsAtRow; } - UShort_t* GetColAtRowBg() const + UShort_t* getColAtRowBg() const { return mColumnAtRowBeginning; } + Float_t getPrecision() const + { + return mPrecision; + } + + /// Sets requested precision + void setPrecision(Float_t prc=1e-6) + { + mPrecision = prc; + } + /// Sets maximum number of significant coefficients for given row/column of coefficients 3D matrix void initializeElementBound2D(int ne); @@ -143,6 +154,7 @@ class Chebyshev3DCalc : public TNamed { Int_t mNumberOfRows; ///< number of significant rows in the 3D coeffs matrix Int_t mNumberOfColumns; ///< max number of significant cols in the 3D coeffs matrix Int_t mNumberOfElementsBound2D; ///< number of elements (mNumberOfRows*mNumberOfColumns) to store for the 2D boundary + Float_t mPrecision; ///< requested precision /// of significant coeffs UShort_t* mNumberOfColumnsAtRow; //[mNumberOfRows] number of sighificant columns (2nd dim) at each row of 3D coefs matrix @@ -158,7 +170,7 @@ class Chebyshev3DCalc : public TNamed { Float_t* mTemporaryCoefficients2D; //[mNumberOfColumns] temp. coeffs for 2d summation Float_t* mTemporaryCoefficients1D; //[mNumberOfRows] temp. coeffs for 1d summation - ClassDef(AliceO2::Field::Chebyshev3DCalc, 2) // Class for interpolation of 3D->1 function by Chebyshev parametrization + ClassDef(AliceO2::MathUtils::Chebyshev3DCalc, 2) // Class for interpolation of 3D->1 function by Chebyshev parametrization }; /// Evaluates 1D Chebyshev parameterization. x is the argument mapped to [-1:1] interval diff --git a/MathUtils/MathUtilsLinkDef.h b/MathUtils/MathUtilsLinkDef.h new file mode 100644 index 0000000000000..62394e7fa058d --- /dev/null +++ b/MathUtils/MathUtilsLinkDef.h @@ -0,0 +1,10 @@ + +#ifdef __CINT__ +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliceO2::MathUtils::Chebyshev3D+; +#pragma link C++ class AliceO2::MathUtils::Chebyshev3DCalc+; + +#endif diff --git a/Resources/maps/mfchebKGI_meas.root b/Resources/maps/mfchebKGI_meas.root deleted file mode 100644 index 5e9ec40ff771d..0000000000000 Binary files a/Resources/maps/mfchebKGI_meas.root and /dev/null differ diff --git a/Resources/maps/mfchebKGI_sym.root b/Resources/maps/mfchebKGI_sym.root index 142e628c4baee..01b045f527df6 100644 Binary files a/Resources/maps/mfchebKGI_sym.root and b/Resources/maps/mfchebKGI_sym.root differ diff --git a/devices/CMakeLists.txt b/devices/CMakeLists.txt index a9d0c3fcf142f..51bf41816821e 100644 --- a/devices/CMakeLists.txt +++ b/devices/CMakeLists.txt @@ -1,4 +1,4 @@ add_subdirectory (flp2epn) add_subdirectory (flp2epn-dynamic) add_subdirectory (flp2epn-distributed) -add_subdirectory (alicehlt) +add_subdirectory (aliceHLTwrapper) diff --git a/devices/alicehlt/.gitignore b/devices/aliceHLTwrapper/.gitignore similarity index 100% rename from devices/alicehlt/.gitignore rename to devices/aliceHLTwrapper/.gitignore diff --git a/devices/alicehlt/AliHLTDataTypes.h b/devices/aliceHLTwrapper/AliHLTDataTypes.h similarity index 100% rename from devices/alicehlt/AliHLTDataTypes.h rename to devices/aliceHLTwrapper/AliHLTDataTypes.h diff --git a/devices/alicehlt/AliHLTHOMERData.h b/devices/aliceHLTwrapper/AliHLTHOMERData.h similarity index 100% rename from devices/alicehlt/AliHLTHOMERData.h rename to devices/aliceHLTwrapper/AliHLTHOMERData.h diff --git a/devices/alicehlt/AliHLTHOMERReader.h b/devices/aliceHLTwrapper/AliHLTHOMERReader.h similarity index 100% rename from devices/alicehlt/AliHLTHOMERReader.h rename to devices/aliceHLTwrapper/AliHLTHOMERReader.h diff --git a/devices/alicehlt/AliHLTHOMERWriter.h b/devices/aliceHLTwrapper/AliHLTHOMERWriter.h similarity index 100% rename from devices/alicehlt/AliHLTHOMERWriter.h rename to devices/aliceHLTwrapper/AliHLTHOMERWriter.h diff --git a/devices/alicehlt/CMakeLists.txt b/devices/aliceHLTwrapper/CMakeLists.txt similarity index 91% rename from devices/alicehlt/CMakeLists.txt rename to devices/aliceHLTwrapper/CMakeLists.txt index b132959036bc6..d5aefc2fb6653 100644 --- a/devices/alicehlt/CMakeLists.txt +++ b/devices/aliceHLTwrapper/CMakeLists.txt @@ -2,7 +2,9 @@ set(INCLUDE_DIRECTORIES ${BASE_INCLUDE_DIRECTORIES} ${ZMQ_INCLUDE_DIR} ${Boost_INCLUDE_DIR} - ${CMAKE_SOURCE_DIR}/devices/alicehlt + ${FAIRROOT_INCLUDE_DIR} + ${AlFa_DIR}/include + ${CMAKE_SOURCE_DIR}/devices/aliceHLTwrapper ) include_directories(${INCLUDE_DIRECTORIES}) @@ -14,6 +16,7 @@ include_directories(${INCLUDE_DIRECTORIES}) set(LINK_DIRECTORIES ${FAIRROOT_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} + ${AlFa_DIR}/lib ) link_directories(${LINK_DIRECTORIES}) diff --git a/devices/alicehlt/Component.cxx b/devices/aliceHLTwrapper/Component.cxx similarity index 100% rename from devices/alicehlt/Component.cxx rename to devices/aliceHLTwrapper/Component.cxx diff --git a/devices/alicehlt/Component.h b/devices/aliceHLTwrapper/Component.h similarity index 100% rename from devices/alicehlt/Component.h rename to devices/aliceHLTwrapper/Component.h diff --git a/devices/alicehlt/HOMERFactory.cxx b/devices/aliceHLTwrapper/HOMERFactory.cxx similarity index 100% rename from devices/alicehlt/HOMERFactory.cxx rename to devices/aliceHLTwrapper/HOMERFactory.cxx diff --git a/devices/alicehlt/HOMERFactory.h b/devices/aliceHLTwrapper/HOMERFactory.h similarity index 100% rename from devices/alicehlt/HOMERFactory.h rename to devices/aliceHLTwrapper/HOMERFactory.h diff --git a/devices/alicehlt/README b/devices/aliceHLTwrapper/README similarity index 98% rename from devices/alicehlt/README rename to devices/aliceHLTwrapper/README index 3f72e150421dc..8d1460d61fd3a 100644 --- a/devices/alicehlt/README +++ b/devices/aliceHLTwrapper/README @@ -25,7 +25,7 @@ d) set up development clone git remote add --no-tags matthias gitolite@git.uio.no:u/mrichter/FairRoot git remote update matthias git branch --track alicehlt remotes/matthias/alicehlt - git checkout alicehlt # code can be found in example/alicehlt + git checkout alicehlt # code can be found in devices/aliceHLTwrapper make install # in the build directory diff --git a/devices/alicehlt/SystemInterface.cxx b/devices/aliceHLTwrapper/SystemInterface.cxx similarity index 100% rename from devices/alicehlt/SystemInterface.cxx rename to devices/aliceHLTwrapper/SystemInterface.cxx diff --git a/devices/alicehlt/SystemInterface.h b/devices/aliceHLTwrapper/SystemInterface.h similarity index 100% rename from devices/alicehlt/SystemInterface.h rename to devices/aliceHLTwrapper/SystemInterface.h diff --git a/devices/alicehlt/WrapperDevice.cxx b/devices/aliceHLTwrapper/WrapperDevice.cxx similarity index 100% rename from devices/alicehlt/WrapperDevice.cxx rename to devices/aliceHLTwrapper/WrapperDevice.cxx diff --git a/devices/alicehlt/WrapperDevice.h b/devices/aliceHLTwrapper/WrapperDevice.h similarity index 100% rename from devices/alicehlt/WrapperDevice.h rename to devices/aliceHLTwrapper/WrapperDevice.h diff --git a/devices/alicehlt/aliceHLTWrapper.cxx b/devices/aliceHLTwrapper/aliceHLTWrapper.cxx similarity index 100% rename from devices/alicehlt/aliceHLTWrapper.cxx rename to devices/aliceHLTwrapper/aliceHLTWrapper.cxx diff --git a/devices/alicehlt/createLaunchCommands.sh b/devices/aliceHLTwrapper/createLaunchCommands.sh similarity index 100% rename from devices/alicehlt/createLaunchCommands.sh rename to devices/aliceHLTwrapper/createLaunchCommands.sh diff --git a/devices/alicehlt/macros/hltConfigurations.C b/devices/aliceHLTwrapper/macros/hltConfigurations.C similarity index 100% rename from devices/alicehlt/macros/hltConfigurations.C rename to devices/aliceHLTwrapper/macros/hltConfigurations.C diff --git a/devices/alicehlt/runComponent.cxx b/devices/aliceHLTwrapper/runComponent.cxx similarity index 100% rename from devices/alicehlt/runComponent.cxx rename to devices/aliceHLTwrapper/runComponent.cxx diff --git a/devices/flp2epn-distributed/CMakeLists.txt b/devices/flp2epn-distributed/CMakeLists.txt index e650110282c8c..97f2aba51f204 100644 --- a/devices/flp2epn-distributed/CMakeLists.txt +++ b/devices/flp2epn-distributed/CMakeLists.txt @@ -1,6 +1,8 @@ set(INCLUDE_DIRECTORIES ${BASE_INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIR} + ${FAIRROOT_INCLUDE_DIR} + ${AlFa_DIR}/include ${CMAKE_SOURCE_DIR}/devices/flp2epn-distributed ) @@ -13,6 +15,7 @@ configure_file( set(LINK_DIRECTORIES ${Boost_LIBRARY_DIRS} ${FAIRROOT_LIBRARY_DIR} + ${AlFa_DIR}/lib ) link_directories(${LINK_DIRECTORIES}) diff --git a/devices/flp2epn-dynamic/CMakeLists.txt b/devices/flp2epn-dynamic/CMakeLists.txt index 5a62c7c67e007..b54fa9d1d3a87 100644 --- a/devices/flp2epn-dynamic/CMakeLists.txt +++ b/devices/flp2epn-dynamic/CMakeLists.txt @@ -1,6 +1,8 @@ set(INCLUDE_DIRECTORIES ${BASE_INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIR} + ${FAIRROOT_INCLUDE_DIR} + ${AlFa_DIR}/include ${CMAKE_SOURCE_DIR}/devices/flp2epn-dynamic ) @@ -11,6 +13,7 @@ configure_file( ${CMAKE_SOURCE_DIR}/devices/flp2epn-dynamic/run/startFLP2EPN-dyn set(LINK_DIRECTORIES ${Boost_LIBRARY_DIRS} ${FAIRROOT_LIBRARY_DIR} + ${AlFa_DIR}/lib ) link_directories(${LINK_DIRECTORIES}) diff --git a/devices/flp2epn/CMakeLists.txt b/devices/flp2epn/CMakeLists.txt index 63d7d5ebe69f9..40fb25a4dafac 100644 --- a/devices/flp2epn/CMakeLists.txt +++ b/devices/flp2epn/CMakeLists.txt @@ -1,6 +1,8 @@ set(INCLUDE_DIRECTORIES ${BASE_INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIR} + ${FAIRROOT_INCLUDE_DIR} + ${AlFa_DIR}/include ${CMAKE_SOURCE_DIR}/devices/flp2epn ) @@ -12,6 +14,7 @@ configure_file( ${CMAKE_SOURCE_DIR}/devices/flp2epn/run/startMerger.sh.in ${CMAK set(LINK_DIRECTORIES ${Boost_LIBRARY_DIRS} ${FAIRROOT_LIBRARY_DIR} + ${AlFa_DIR}/lib ) link_directories(${LINK_DIRECTORIES}) diff --git a/field/CMakeLists.txt b/field/CMakeLists.txt index 7275e04ac966d..17fd6664b8698 100644 --- a/field/CMakeLists.txt +++ b/field/CMakeLists.txt @@ -3,17 +3,17 @@ # The extension is already found. Any number of sources could be listed here. set(INCLUDE_DIRECTORIES +${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/field ${CMAKE_SOURCE_DIR}/header ${BASE_INCLUDE_DIRECTORIES} +${FAIRROOT_INCLUDE_DIR} ${ROOT_INCLUDE_DIR} ) include_directories( ${INCLUDE_DIRECTORIES}) set(LINK_DIRECTORIES -${CMAKE_SOURCE_DIR}/base -${CMAKE_SOURCE_DIR}/field ${FAIRROOT_LIBRARY_DIR} ${ROOT_LIBRARY_DIR} ) @@ -23,14 +23,12 @@ link_directories( ${LINK_DIRECTORIES}) set(SRCS MagneticWrapperChebyshev.cxx MagneticField.cxx -Chebyshev3D.cxx -Chebyshev3DCalc.cxx ) Set(HEADERS) Set(LINKDEF fieldLinkDef.h) Set(LIBRARY_NAME Field) -Set(DEPENDENCIES Base EG Physics Cint Core) +Set(DEPENDENCIES MathUtils Cint Core) GENERATE_LIBRARY() diff --git a/field/MagneticWrapperChebyshev.cxx b/field/MagneticWrapperChebyshev.cxx index ad338015c21ff..e65922fd79718 100644 --- a/field/MagneticWrapperChebyshev.cxx +++ b/field/MagneticWrapperChebyshev.cxx @@ -9,6 +9,7 @@ #include "FairLogger.h" using namespace AliceO2::Field; +using namespace AliceO2::MathUtils; ClassImp(MagneticWrapperChebyshev) @@ -788,7 +789,7 @@ void MagneticWrapperChebyshev::getTPCRatIntegralCylindrical(const Double_t* rphi return; } -#ifdef _INC_CREATION_ALICHEB3D_ +#ifdef _INC_CREATION_Chebyshev3D_ void MagneticWrapperChebyshev::loadData(const char* inpfile) { @@ -847,7 +848,7 @@ void MagneticWrapperChebyshev::loadData(const char* inpfile) for (int ip = 0; ip < nparTPCInt; ip++) { Chebyshev3D* cheb = new Chebyshev3D(); cheb->loadData(stream); - AddParamTPCInt(cheb); + addParameterTPCIntegral(cheb); } Chebyshev3DCalc::readLine(buffs, stream); @@ -871,7 +872,7 @@ void MagneticWrapperChebyshev::loadData(const char* inpfile) for (int ip = 0; ip < nparTPCRatInt; ip++) { Chebyshev3D* cheb = new Chebyshev3D(); cheb->loadData(stream); - AddParamTPCRatInt(cheb); + addParameterTPCRatIntegral(cheb); } Chebyshev3DCalc::readLine(buffs, stream); @@ -907,8 +908,8 @@ void MagneticWrapperChebyshev::loadData(const char* inpfile) Chebyshev3DCalc::readLine(buffs, stream); - if (!buffs.BeginsWith("END DIPOLE") || !buffs.Contains(GetName())) { - Error("LoadData", "Expected: \"END DIPOLE\", found \"%s\"\nStop\n", buffs.Data()); + if (!buffs.BeginsWith("END ") && !buffs.Contains(GetName())) { + Error("LoadData", "Expected: \"END %s\", found \"%s\"\nStop\n", GetName(), buffs.Data()); exit(1); } @@ -958,7 +959,7 @@ void MagneticWrapperChebyshev::buildTableTPCRatIntegral() #endif -#ifdef _INC_CREATION_ALICHEB3D_ +#ifdef _INC_CREATION_Chebyshev3D_ MagneticWrapperChebyshev::MagneticWrapperChebyshev(const char* inputFile) : mNumberOfParameterizationSolenoid(0), mNumberOfDistinctZSegmentsSolenoid(0), @@ -1063,7 +1064,7 @@ void MagneticWrapperChebyshev::addParameterTPCRatIntegral(const Chebyshev3D* par } } -void MagneticWrapperChebyshev::AddParamDipole(const Chebyshev3D* param) +void MagneticWrapperChebyshev::addParameterDipole(const Chebyshev3D* param) { if (!mParameterizationDipole) { mParameterizationDipole = new TObjArray(); diff --git a/field/MagneticWrapperChebyshev.h b/field/MagneticWrapperChebyshev.h index d7aa2e8c12c5a..835ac870306fe 100644 --- a/field/MagneticWrapperChebyshev.h +++ b/field/MagneticWrapperChebyshev.h @@ -8,7 +8,7 @@ #include #include #include -#include "Chebyshev3D.h" +#include "MathUtils/Chebyshev3D.h" class TSystem; class TArrayF; @@ -171,24 +171,24 @@ class MagneticWrapperChebyshev : public TNamed { return mMaxRadiusTPCRat; } - Chebyshev3D* getParameterSolenoid(Int_t ipar) const + AliceO2::MathUtils::Chebyshev3D* getParameterSolenoid(Int_t ipar) const { - return (Chebyshev3D*)mParameterizationSolenoid->UncheckedAt(ipar); + return (AliceO2::MathUtils::Chebyshev3D*)mParameterizationSolenoid->UncheckedAt(ipar); } - Chebyshev3D* getParameterTPCRatIntegral(Int_t ipar) const + AliceO2::MathUtils::Chebyshev3D* getParameterTPCRatIntegral(Int_t ipar) const { - return (Chebyshev3D*)mParameterizationTPCRat->UncheckedAt(ipar); + return (AliceO2::MathUtils::Chebyshev3D*)mParameterizationTPCRat->UncheckedAt(ipar); } - Chebyshev3D* getParameterTPCIntegral(Int_t ipar) const + AliceO2::MathUtils::Chebyshev3D* getParameterTPCIntegral(Int_t ipar) const { - return (Chebyshev3D*)mParameterizationTPC->UncheckedAt(ipar); + return (AliceO2::MathUtils::Chebyshev3D*)mParameterizationTPC->UncheckedAt(ipar); } - Chebyshev3D* getParameterDipole(Int_t ipar) const + AliceO2::MathUtils::Chebyshev3D* getParameterDipole(Int_t ipar) const { - return (Chebyshev3D*)mParameterizationDipole->UncheckedAt(ipar); + return (AliceO2::MathUtils::Chebyshev3D*)mParameterizationDipole->UncheckedAt(ipar); } /// Prints info @@ -237,7 +237,7 @@ class MagneticWrapperChebyshev : public TNamed { static void cartesianToCylindrical(const Double_t* xyz, Double_t* rphiz); static void cylindricalToCartesian(const Double_t* rphiz, Double_t* xyz); -#ifdef _INC_CREATION_ALICHEB3D_ // see Cheb3D.h for explanation +#ifdef _INC_CREATION_Chebyshev3D_ // see Cheb3D.h for explanation /// Reads coefficients data from the text file void loadData(const char* inpfile); @@ -254,18 +254,18 @@ class MagneticWrapperChebyshev : public TNamed { /// Adds new parameterization piece for Solenoid /// NOTE: pieces must be added strictly in increasing R then increasing Z order - void addParameterSolenoid(const Chebyshev3D* param); + void addParameterSolenoid(const AliceO2::MathUtils::Chebyshev3D* param); // Adds new parameterization piece for TPCIntegral // NOTE: pieces must be added strictly in increasing R then increasing Z order - void addParameterTPCIntegral(const Chebyshev3D* param); + void addParameterTPCIntegral(const AliceO2::MathUtils::Chebyshev3D* param); /// Adds new parameterization piece for TPCRatInt // NOTE: pieces must be added strictly in increasing R then increasing Z order - void addParameterTPCRatIntegral(const Chebyshev3D* param); + void addParameterTPCRatIntegral(const AliceO2::MathUtils::Chebyshev3D* param); /// Adds new parameterization piece for Dipole - void addParameterDipole(const Chebyshev3D* param); + void addParameterDipole(const AliceO2::MathUtils::Chebyshev3D* param); /// Builds lookup table for dipole void buildTable(Int_t npar, TObjArray* parArr, Int_t& nZSeg, Int_t& nYSeg, Int_t& nXSeg, Float_t& minZ, Float_t& maxZ, @@ -395,7 +395,7 @@ class MagneticWrapperChebyshev : public TNamed { Float_t mMaxDipoleZ; ///< Max Z of Dipole parameterization TObjArray* mParameterizationDipole; ///< Parameterization pieces for Dipole field - FairLogger* mLogger; + FairLogger* mLogger; //! ClassDef(AliceO2::Field::MagneticWrapperChebyshev, 2) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field }; diff --git a/field/fieldLinkDef.h b/field/fieldLinkDef.h index c340fb3d5f496..a3bc529576e02 100644 --- a/field/fieldLinkDef.h +++ b/field/fieldLinkDef.h @@ -4,89 +4,7 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class AliceO2::Field::Chebyshev3D+; #pragma link C++ class AliceO2::Field::MagneticField+; #pragma link C++ class AliceO2::Field::MagneticWrapperChebyshev+; -#pragma link C++ class AliceO2::Field::Chebyshev3DCalc+; - -//map the old to the new variables: -//AliCheb3D-------OLD -//Int_t fDimOut; // dimension of the ouput array -//Float_t fPrec; // requested precision -//Float_t fBMin[3]; // min boundaries in each dimension -//Float_t fBMax[3]; // max boundaries in each dimension -//Float_t fBScale[3]; // scale for boundary mapping to [-1:1] interval -//Float_t fBOffset[3]; // offset for boundary mapping to [-1:1] interval -//TObjArray fChebCalc; // Chebyshev parameterization for each output dimension - -//Chebyshev3D-------New -//Int_t mOutputArrayDimension; ///< dimension of the ouput array -//Float_t mPrecision; ///< requested precision -//Float_t mMinBoundaries[3]; ///< min boundaries in each dimension -//Float_t mMaxBoundaries[3]; ///< max boundaries in each dimension -//Float_t mBoundaryMappingScale[3]; ///< scale for boundary mapping to [-1:1] interval -//Float_t mBoundaryMappingOffset[3]; ///< offset for boundary mapping to [-1:1] interval -//TObjArray mChebyshevParameter; ///< Chebyshev parameterization for each output dimension - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="Int_t fDimOut" \ - target="mOutputArrayDimension" \ - code="{ mOutputArrayDimension = onfile.fDimOut; }" - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="Float_t fPrec" \ - target="mPrecision" \ - code="{ mPrecision = onfile.fPrec; }" - - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="Float_t fBMin[3]" \ - target="mMinBoundaries" \ - code="{ mMinBoundaries[0] = onfile.fBMin[0];mMinBoundaries[1] = onfile.fBMin[1];mMinBoundaries[2] = onfile.fBMin[2]; }" - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="Float_t fBMax[3]" \ - target="mMaxBoundaries" \ - code="{ mMaxBoundaries[0] = onfile.fBMax[0];mMaxBoundaries[1] = onfile.fBMax[1];mMaxBoundaries[2] = onfile.fBMax[2]; }" - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="Float_t fBScale[3]" \ - target="mBoundaryMappingScale" \ - code="{ mBoundaryMappingScale[0] = onfile.fBScale[0];mBoundaryMappingScale[1] = onfile.fBScale[1];mBoundaryMappingScale[2] = onfile.fBScale[2]; }" - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="Float_t fBOffset[3]" \ - target="mBoundaryMappingScale" \ - code="{ mBoundaryMappingScale[0] = onfile.fBOffset[0];mBoundaryMappingScale[1] = onfile.fBOffset[1];mBoundaryMappingScale[2] = onfile.fBOffset[2]; }" - -#pragma read sourceClass="AliCheb3D" \ - targetClass="AliceO2::Field::Chebyshev3D" \ - version="[1-]" \ - source="TObjArray fChebCalc" \ - target="mChebyshevParameter" \ - code="{ mChebyshevParameter = onfile.fChebCalc;}" - - - - - - - - - - - #endif diff --git a/its/CMakeLists.txt b/its/CMakeLists.txt index 8d56997e969e1..aa3a5a1b45159 100644 --- a/its/CMakeLists.txt +++ b/its/CMakeLists.txt @@ -3,6 +3,9 @@ ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/its ${CMAKE_SOURCE_DIR}/header ${BASE_INCLUDE_DIRECTORIES} +${Boost_INCLUDE_DIRS} +${FAIRROOT_INCLUDE_DIR} +${AlFa_DIR}/include ${ROOT_INCLUDE_DIR} ) diff --git a/macro/CMakeLists.txt b/macro/CMakeLists.txt index 8b47f4a1818bd..d7af20bf67adb 100644 --- a/macro/CMakeLists.txt +++ b/macro/CMakeLists.txt @@ -1,11 +1,15 @@ GENERATE_ROOT_TEST_SCRIPT(${CMAKE_SOURCE_DIR}/macro/run_sim.C) -ForEach(_mcEngine IN ITEMS TGeant3 TGeant4) - Add_Test(run_sim_${_mcEngine} - ${CMAKE_BINARY_DIR}/macro/run_sim.sh 10 \"${_mcEngine}\") - Set_Tests_Properties(run_sim_${_mcEngine} PROPERTIES TIMEOUT "30") - Set_Tests_Properties(run_sim_${_mcEngine} PROPERTIES PASS_REGULAR_EXPRESSION "Macro finished succesfully") -EndForEach(_mcEngine IN ITEMS TGeant3 TGeant4) + Add_Test(run_sim_TGeant3 + ${CMAKE_BINARY_DIR}/macro/run_sim.sh 10 \"TGeant3\") + Set_Tests_Properties(run_sim_TGeant3 PROPERTIES TIMEOUT "30") + Set_Tests_Properties(run_sim_TGeant3 PROPERTIES PASS_REGULAR_EXPRESSION "Macro finished succesfully") + + Add_Test(run_sim_TGeant4 + ${CMAKE_BINARY_DIR}/macro/run_sim.sh 10 \"TGeant4\") + Set_Tests_Properties(run_sim_TGeant4 PROPERTIES DEPENDS run_sim_TGeant3) + Set_Tests_Properties(run_sim_TGeant4 PROPERTIES TIMEOUT "30") + Set_Tests_Properties(run_sim_TGeant4 PROPERTIES PASS_REGULAR_EXPRESSION "Macro finished succesfully") Install(FILES run_sim.C DESTINATION share/its diff --git a/passive/CMakeLists.txt b/passive/CMakeLists.txt index 4239087ae1ca0..e96f643bc101d 100644 --- a/passive/CMakeLists.txt +++ b/passive/CMakeLists.txt @@ -5,6 +5,7 @@ set(INCLUDE_DIRECTORIES ${BASE_INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR}/passive +${FAIRROOT_INCLUDE_DIR} ${ROOT_INCLUDE_DIR} ) diff --git a/tpc/CMakeLists.txt b/tpc/CMakeLists.txt new file mode 100644 index 0000000000000..42535e5b990ad --- /dev/null +++ b/tpc/CMakeLists.txt @@ -0,0 +1,37 @@ +# Create a library called "libO2tpc" which includes the source files given in +# the array . +# The extension is already found. Any number of sources could be listed here. + +set(INCLUDE_DIRECTORIES +${ROOT_INCLUDE_DIR} +${BASE_INCLUDE_DIRECTORIES} +${Boost_INCLUDE_DIRS} +${FAIRROOT_INCLUDE_DIR} +${AlFa_DIR}/include +#put here all directories where header files are located +${CMAKE_SOURCE_DIR}/ +${CMAKE_SOURCE_DIR}/tpc +) + +include_directories( ${INCLUDE_DIRECTORIES}) + +set(LINK_DIRECTORIES +${ROOT_LIBRARY_DIR} +${FAIRROOT_LIBRARY_DIR} + +) + +link_directories( ${LINK_DIRECTORIES}) + +set(SRCS +ContainerFactory.cxx +Point.cxx +Detector.cxx +) + +Set(LINKDEF TpcLinkDef.h) +Set(LIBRARY_NAME tpc) +Set(DEPENDENCIES + Base +) +GENERATE_LIBRARY() diff --git a/tpc/ContainerFactory.cxx b/tpc/ContainerFactory.cxx new file mode 100644 index 0000000000000..7a5abc3cbb5f5 --- /dev/null +++ b/tpc/ContainerFactory.cxx @@ -0,0 +1,54 @@ + +#include "ContainerFactory.h" +#include "FairRuntimeDb.h" + +#include +using namespace AliceO2::TPC; + +ClassImp(ContainerFactory) + +static ContainerFactory gTpcContainerFactory; + +ContainerFactory::ContainerFactory() + : FairContFact() +{ + /** Constructor (called when the library is loaded) */ + fName="ContainerFactory"; + fTitle="Factory for parameter containers in libO2tpc"; + setAllContainers(); + FairRuntimeDb::instance()->addContFactory(this); +} + +void ContainerFactory::setAllContainers() +{ + /** Creates the Container objects with all accepted + contexts and adds them to + the list of containers for the O2tpc library. + */ + + /* FairContainer* p= new FairContainer("O2tpcGeoPar", + "O2tpc Geometry Parameters", + "TestDefaultContext"); + p->addContext("TestNonDefaultContext"); + + containers->Add(p); +*/ +} + +FairParSet* ContainerFactory::createContainer(FairContainer* c) +{ + /** Calls the constructor of the corresponding parameter container. + For an actual context, which is not an empty string and not + the default context + of this container, the name is concatinated with the context. + */ + /* + const char* name=c->GetName(); + FairParSet* p=NULL; + if (strcmp(name,"O2tpcGeoPar")==0) { + p=new O2tpcGeoPar(c->getConcatName().Data(), + c->GetTitle(),c->getContext()); + } + return p; + */ +} diff --git a/tpc/ContainerFactory.h b/tpc/ContainerFactory.h new file mode 100644 index 0000000000000..df4e738ddc796 --- /dev/null +++ b/tpc/ContainerFactory.h @@ -0,0 +1,25 @@ +#ifndef ALICEO2_TPC_CONTAINERFACTORY_H_ +#define ALICEO2_TPC_CONTAINERFACTORY_H_ + +#include "FairContFact.h" + +class FairContainer; + +namespace AliceO2 { +namespace TPC { + + + +class ContainerFactory : public FairContFact +{ + private: + void setAllContainers(); + public: + ContainerFactory(); + ~ContainerFactory() {} + FairParSet* createContainer(FairContainer*); + ClassDef( AliceO2::TPC::ContainerFactory,0) // Factory for all tpc parameter containers +}; +} +} +#endif diff --git a/tpc/Detector.cxx b/tpc/Detector.cxx new file mode 100644 index 0000000000000..556a88a0413a5 --- /dev/null +++ b/tpc/Detector.cxx @@ -0,0 +1,154 @@ +#include "Detector.h" + +#include "Point.h" + +#include "FairVolume.h" +#include "FairGeoVolume.h" +#include "FairGeoNode.h" +#include "FairRootManager.h" +#include "FairGeoLoader.h" +#include "FairGeoInterface.h" +#include "FairRun.h" +#include "FairRuntimeDb.h" + +#include "Data/DetectorList.h" +#include "Data/Stack.h" + +#include "TClonesArray.h" +#include "TVirtualMC.h" + +#include +using std::cout; +using std::endl; + +using namespace AliceO2::TPC; + +Detector::Detector() + : AliceO2::Base::Detector("Detector", kTRUE, kAliTpc), + mTrackNumberID(-1), + mVolumeID(-1), + mPosition(), + mMomentum(), + mTime(-1.), + mLength(-1.), + mEnergyLoss(-1), + mPointCollection(new TClonesArray("DetectorPoint")) +{ +} + +Detector::Detector(const char* name, Bool_t active) + : AliceO2::Base::Detector(name, active, kAliTpc), + mTrackNumberID(-1), + mVolumeID(-1), + mPosition(), + mMomentum(), + mTime(-1.), + mLength(-1.), + mEnergyLoss(-1), + mPointCollection(new TClonesArray("Point")) +{ +} + +Detector::~Detector() +{ + if (mPointCollection) { + mPointCollection->Delete(); + delete mPointCollection; + } +} + +void Detector::Initialize() +{ + AliceO2::Base::Detector::Initialize(); +} + +Bool_t Detector::ProcessHits(FairVolume* vol) +{ + /** This method is called from the MC stepping */ + + //Set parameters at entrance of volume. Reset ELoss. + if ( gMC->IsTrackEntering() ) { + mEnergyLoss = 0.; + mTime = gMC->TrackTime() * 1.0e09; + mLength = gMC->TrackLength(); + gMC->TrackPosition(mPosition); + gMC->TrackMomentum(mMomentum); + } + + // Sum energy loss for all steps in the active volume + mEnergyLoss += gMC->Edep(); + + // Create DetectorPoint at exit of active volume + if ( gMC->IsTrackExiting() || + gMC->IsTrackStop() || + gMC->IsTrackDisappeared() ) { + mTrackNumberID = gMC->GetStack()->GetCurrentTrackNumber(); + mVolumeID = vol->getMCid(); + if (mEnergyLoss == 0. ) { return kFALSE; } + AddHit(mTrackNumberID, mVolumeID, TVector3(mPosition.X(), mPosition.Y(), mPosition.Z()), + TVector3(mMomentum.Px(), mMomentum.Py(), mMomentum.Pz()), mTime, mLength, + mEnergyLoss); + + // Increment number of Detector det points in TParticle + AliceO2::Data::Stack* stack = (AliceO2::Data::Stack*)gMC->GetStack(); + stack->AddPoint(kAliTpc); + + } + + return kTRUE; +} + +void Detector::EndOfEvent() +{ + + mPointCollection->Clear(); + +} + + + +void Detector::Register() +{ + + /** This will create a branch in the output tree called + DetectorPoint, setting the last parameter to kFALSE means: + this collection will not be written to the file, it will exist + only during the simulation. + */ + + FairRootManager::Instance()->Register("Point", "TPC",mPointCollection, kTRUE); + +} + + +TClonesArray* Detector::GetCollection(Int_t iColl) const +{ + if (iColl == 0) { return mPointCollection; } + else { return NULL; } +} + +void Detector::Reset() +{ + mPointCollection->Clear(); +} + +void Detector::ConstructGeometry() +{ + /** If you are using the standard ASCII input for the geometry + just copy this and use it for your detector, otherwise you can + implement here you own way of constructing the geometry. */ + +} + +Point* Detector::AddHit(Int_t trackID, Int_t detID, + TVector3 pos, TVector3 mom, + Double_t time, Double_t length, + Double_t eLoss) +{ + TClonesArray& clref = *mPointCollection; + Int_t size = clref.GetEntriesFast(); + return new(clref[size]) Point(trackID, detID, pos, mom, + time, length, eLoss); +} + +ClassImp(AliceO2::TPC::Detector) diff --git a/tpc/Detector.h b/tpc/Detector.h new file mode 100644 index 0000000000000..97d310abdfc9c --- /dev/null +++ b/tpc/Detector.h @@ -0,0 +1,103 @@ +#ifndef AliceO2_TPC_Detector_H_ +#define AliceO2_TPC_Detector_H_ + +#include "Base/Detector.h" + +#include "TVector3.h" +#include "TLorentzVector.h" + + +class FairVolume; +class TClonesArray; + +namespace AliceO2 { +namespace TPC { +class Point; + +class Detector: public AliceO2::Base::Detector { + + public: + + /** Name : Detector Name + * Active: kTRUE for active detectors (ProcessHits() will be called) + * kFALSE for inactive detectors + */ + Detector(const char* Name, Bool_t Active); + + /** default constructor */ + Detector(); + + /** destructor */ + virtual ~Detector(); + + /** Initialization of the detector is done here */ + virtual void Initialize(); + + /** this method is called for each step during simulation + * (see FairMCApplication::Stepping()) + */ + virtual Bool_t ProcessHits( FairVolume* v=0); + + /** Registers the produced collections in FAIRRootManager. */ + virtual void Register(); + + /** Gets the produced collections */ + virtual TClonesArray* GetCollection(Int_t iColl) const ; + + /** has to be called after each event to reset the containers */ + virtual void Reset(); + + /** Create the detector geometry */ + void ConstructGeometry(); + + + + /** This method is an example of how to add your own point + * of type DetectorPoint to the clones array + */ + Point* AddHit(Int_t trackID, Int_t detID, + TVector3 pos, TVector3 mom, + Double_t time, Double_t length, + Double_t eLoss); + + /** The following methods can be implemented if you need to make + * any optional action in your detector during the transport. + */ + + virtual void CopyClones( TClonesArray* cl1, TClonesArray* cl2 , + Int_t offset) {;} + virtual void SetSpecialPhysicsCuts() {;} + virtual void EndOfEvent(); + virtual void FinishPrimary() {;} + virtual void FinishRun() {;} + virtual void BeginPrimary() {;} + virtual void PostTrack() {;} + virtual void PreTrack() {;} + virtual void BeginEvent() {;} + + + private: + + /** Track information to be stored until the track leaves the + active volume. + */ + Int_t mTrackNumberID; //! track index + Int_t mVolumeID; //! volume id + TLorentzVector mPosition; //! position at entrance + TLorentzVector mMomentum; //! momentum at entrance + Double32_t mTime; //! time + Double32_t mLength; //! length + Double32_t mEnergyLoss; //! energy loss + + /** container for data points */ + + TClonesArray* mPointCollection; + + Detector(const Detector&); + Detector& operator=(const Detector&); + + ClassDef(Detector,1) +}; +} +} +#endif diff --git a/tpc/Point.cxx b/tpc/Point.cxx new file mode 100644 index 0000000000000..6b74b52f068cc --- /dev/null +++ b/tpc/Point.cxx @@ -0,0 +1,45 @@ +#include "Point.h" + +#include +using std::cout; +using std::endl; + +using namespace AliceO2::TPC; + +// ----- Default constructor ------------------------------------------- +Point::Point() + : FairMCPoint() +{ +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +Point::Point(Int_t trackID, Int_t detID, + TVector3 pos, TVector3 mom, + Double_t tof, Double_t length, + Double_t eLoss) + : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss) +{ +} +// ------------------------------------------------------------------------- + +// ----- Destructor ---------------------------------------------------- +Point::~Point() { } +// ------------------------------------------------------------------------- + +// ----- Public method Print ------------------------------------------- +void Point::Print(const Option_t* opt) const +{ + cout << "-I- Point: O2tpc point for track " << fTrackID + << " in detector " << fDetectorID << endl; + cout << " Position (" << fX << ", " << fY << ", " << fZ + << ") cm" << endl; + cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz + << ") GeV" << endl; + cout << " Time " << fTime << " ns, Length " << fLength + << " cm, Energy loss " << fELoss*1.0e06 << " keV" << endl; +} +// ------------------------------------------------------------------------- + +ClassImp(Point) + diff --git a/tpc/Point.h b/tpc/Point.h new file mode 100644 index 0000000000000..cb7ca7a54c0a5 --- /dev/null +++ b/tpc/Point.h @@ -0,0 +1,52 @@ +#ifndef ALICEO2_TPC_POINT_H +#define ALICEO2_TPC_POINT_H + + +#include "FairMCPoint.h" + +#include "TObject.h" +#include "TVector3.h" +namespace AliceO2 { +namespace TPC { + +class Point : public FairMCPoint +{ + + public: + + /** Default constructor **/ + Point(); + + + /** Constructor with arguments + *@param trackID Index of MCTrack + *@param detID Detector ID + *@param pos Ccoordinates at entrance to active volume [cm] + *@param mom Momentum of track at entrance [GeV] + *@param tof Time since event start [ns] + *@param length Track length since creation [cm] + *@param eLoss Energy deposit [GeV] + **/ + Point(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, + Double_t tof, Double_t length, Double_t eLoss); + + + + + /** Destructor **/ + virtual ~Point(); + + /** Output to screen **/ + virtual void Print(const Option_t* opt) const; + + private: + /** Copy constructor **/ + Point(const Point& point); + Point operator=(const Point& point); + + ClassDef(AliceO2::TPC::Point,1) +}; +} +} + +#endif diff --git a/tpc/TpcLinkDef.h b/tpc/TpcLinkDef.h new file mode 100644 index 0000000000000..257b9636072c2 --- /dev/null +++ b/tpc/TpcLinkDef.h @@ -0,0 +1,11 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliceO2::TPC::ContainerFactory; +#pragma link C++ class AliceO2::TPC::Detector+; +#pragma link C++ class AliceO2::TPC::Point+; + +#endif