diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000..4bbb59ed98152 --- /dev/null +++ b/.clang-format @@ -0,0 +1,49 @@ +#AccessModifierOffset: -2 +AlignEscapedNewlinesLeft: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +#AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackParameters: true +BreakBeforeBinaryOperators: false +BreakBeforeBraces: Stroustrup +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DerivePointerBinding: false +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: true +IndentFunctionDeclarationAfterType: true +IndentWidth: 2 +# It is broken on windows. Breaks all #include "header.h" +Language: Cpp +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerBindsToType: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +Standard: Cpp11 +TabWidth: 2 +UseTab: Never diff --git a/Base/BaseLinkDef.h b/Base/BaseLinkDef.h index 36dd873eb8c1a..827695264dc82 100644 --- a/Base/BaseLinkDef.h +++ b/Base/BaseLinkDef.h @@ -10,4 +10,3 @@ #pragma link C++ class AliceO2::Base::TrackReference+; #endif - diff --git a/Base/CMakeLists.txt b/Base/CMakeLists.txt index d42da16a2b77b..2f5f3aace4729 100644 --- a/Base/CMakeLists.txt +++ b/Base/CMakeLists.txt @@ -1,15 +1,15 @@ set(INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/Base -${ROOT_INCLUDE_DIR} ${BASE_INCLUDE_DIRECTORIES} +${ROOT_INCLUDE_DIR} ) include_directories( ${INCLUDE_DIRECTORIES}) set(LINK_DIRECTORIES -${ROOT_LIBRARY_DIR} -${FAIRROOT_LIBRARY_DIR} ${CMAKE_SOURCE_DIR}/Base +${FAIRROOT_LIBRARY_DIR} +${ROOT_LIBRARY_DIR} ) link_directories( ${LINK_DIRECTORIES}) diff --git a/Base/Detector.cxx b/Base/Detector.cxx index e09f249feee6f..1bace70db8eaf 100644 --- a/Base/Detector.cxx +++ b/Base/Detector.cxx @@ -72,22 +72,22 @@ void Detector::Matrix(Int_t& nmat, Float_t theta1, Float_t phi1, Float_t theta2, gMC->Matrix(nmat, theta1, phi1, theta2, phi2, theta3, phi3); } -void Detector::DefineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan) +void Detector::defineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan) { } -void Detector::SetNumberOfWrapperVolumes(Int_t n) +void Detector::setNumberOfWrapperVolumes(Int_t n) { } -void Detector::DefineLayer(const Int_t nlay, const double phi0, const Double_t r, +void Detector::defineLayer(const Int_t nlay, const double phi0, const Double_t r, const Double_t zlen, const Int_t nladd, const Int_t nmod, const Double_t lthick, const Double_t dthick, const UInt_t dettypeID, const Int_t buildLevel) { } -void Detector::DefineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, +void Detector::defineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, Int_t nmod, Double_t width, Double_t tilt, Double_t lthick, Double_t dthick, UInt_t dettypeID, Int_t buildLevel) { diff --git a/Base/Detector.h b/Base/Detector.h index 9acbd66ee924c..543346b450215 100644 --- a/Base/Detector.h +++ b/Base/Detector.h @@ -14,11 +14,6 @@ namespace Base { class Detector : public FairDetector { public: - enum Model { - test123 = 0 - }; - - Detector(const char* name, Bool_t Active, Int_t DetId = 0); /// Default Constructor @@ -28,17 +23,17 @@ class Detector : public FairDetector { virtual ~Detector(); // Module composition - virtual void Material(Int_t imat, const char* name, Float_t a, Float_t z, Float_t dens, - Float_t radl, Float_t absl, Float_t* buf = 0, Int_t nwbuf = 0) const; + virtual void Material(Int_t imat, const char* name, Float_t a, Float_t z, Float_t dens, Float_t radl, Float_t absl, + Float_t* buf = 0, Int_t nwbuf = 0) const; - virtual void Mixture(Int_t imat, const char* name, Float_t* a, Float_t* z, Float_t dens, - Int_t nlmat, Float_t* wmat) const; + virtual void Mixture(Int_t imat, const char* name, Float_t* a, Float_t* z, Float_t dens, Int_t nlmat, + Float_t* wmat) const; - virtual void Medium(Int_t numed, const char* name, Int_t nmat, Int_t isvol, Int_t ifield, - Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, - Float_t stmin, Float_t* ubuf = 0, Int_t nbuf = 0) const; + virtual void Medium(Int_t numed, const char* name, Int_t nmat, Int_t isvol, Int_t ifield, Float_t fieldm, + Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin, Float_t* ubuf = 0, + Int_t nbuf = 0) const; - /// Define a rotation matrix. Angles are in degrees. + /// Define a rotation matrix. angles are in degrees. /// \param nmat on output contains the number assigned to the rotation matrix /// \param theta1 polar angle for axis I /// \param theta2 polar angle for axis II @@ -46,35 +41,34 @@ class Detector : public FairDetector { /// \param phi1 azimuthal angle for axis I /// \param phi2 azimuthal angle for axis II /// \param phi3 azimuthal angle for axis III - virtual void Matrix(Int_t& nmat, Float_t theta1, Float_t phi1, Float_t theta2, Float_t phi2, - Float_t theta3, Float_t phi3) const; + virtual void Matrix(Int_t& nmat, Float_t theta1, Float_t phi1, Float_t theta2, Float_t phi2, Float_t theta3, + Float_t phi3) const; - static void SetDensityFactor(Float_t density) + static void setDensityFactor(Float_t density) { mDensityFactor = density; } - static Float_t GetDensityFactor() + static Float_t getDensityFactor() { return mDensityFactor; } /// Sets per wrapper volume parameters - virtual void DefineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan); + virtual void defineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan); /// Books arrays for wrapper volumes - virtual void SetNumberOfWrapperVolumes(Int_t n); + virtual void setNumberOfWrapperVolumes(Int_t n); - virtual void DefineLayer(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, - Int_t nmod, Double_t lthick = 0., Double_t dthick = 0., - UInt_t detType = 0, Int_t buildFlag = 0); + virtual void defineLayer(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, Int_t nmod, + Double_t lthick = 0., Double_t dthick = 0., UInt_t detType = 0, Int_t buildFlag = 0); - virtual void DefineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, - Int_t nmod, Double_t width, Double_t tilt, Double_t lthick = 0., - Double_t dthick = 0., UInt_t detType = 0, Int_t buildFlag = 0); + virtual void defineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, Int_t nmod, + Double_t width, Double_t tilt, Double_t lthick = 0., Double_t dthick = 0., + UInt_t detType = 0, Int_t buildFlag = 0); protected: - static Float_t mDensityFactor; ///< factor that is multiplied to all material densities (ONLY for - ///< systematic studies) + static Float_t mDensityFactor; //! factor that is multiplied to all material densities (ONLY for + // systematic studies) private: Detector(const Detector&); Detector& operator=(const Detector&); diff --git a/Base/Module.h b/Base/Module.h index d72f3d58741d7..fe5bc3b039fe3 100644 --- a/Base/Module.h +++ b/Base/Module.h @@ -23,17 +23,17 @@ class Module : public FairModule { virtual ~Module(); // Module composition - virtual void Material(Int_t imat, const char* name, Float_t a, Float_t z, Float_t dens, - Float_t radl, Float_t absl, Float_t* buf = 0, Int_t nwbuf = 0) const; + virtual void Material(Int_t imat, const char* name, Float_t a, Float_t z, Float_t dens, Float_t radl, Float_t absl, + Float_t* buf = 0, Int_t nwbuf = 0) const; - virtual void Mixture(Int_t imat, const char* name, Float_t* a, Float_t* z, Float_t dens, - Int_t nlmat, Float_t* wmat) const; + virtual void Mixture(Int_t imat, const char* name, Float_t* a, Float_t* z, Float_t dens, Int_t nlmat, + Float_t* wmat) const; - virtual void Medium(Int_t numed, const char* name, Int_t nmat, Int_t isvol, Int_t ifield, - Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, - Float_t stmin, Float_t* ubuf = 0, Int_t nbuf = 0) const; + virtual void Medium(Int_t numed, const char* name, Int_t nmat, Int_t isvol, Int_t ifield, Float_t fieldm, + Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin, Float_t* ubuf = 0, + Int_t nbuf = 0) const; - /// Define a rotation matrix. Angles are in degrees. + /// Define a rotation matrix. angles are in degrees. /// \param nmat on output contains the number assigned to the rotation matrix /// \param theta1 polar angle for axis I /// \param phi1 azimuthal angle for axis I @@ -41,15 +41,15 @@ class Module : public FairModule { /// \param phi2 azimuthal angle for axis II /// \param theta3 polar angle for axis III /// \param phi3 azimuthal angle for axis III - virtual void Matrix(Int_t& nmat, Float_t theta1, Float_t phi1, Float_t theta2, Float_t phi2, - Float_t theta3, Float_t phi3) const; + virtual void Matrix(Int_t& nmat, Float_t theta1, Float_t phi1, Float_t theta2, Float_t phi2, Float_t theta3, + Float_t phi3) const; - static void SetDensityFactor(Float_t density) + static void setDensityFactor(Float_t density) { mDensityFactor = density; } - static Float_t GetDensityFactor() + static Float_t getDensityFactor() { return mDensityFactor; } diff --git a/Base/TrackReference.cxx b/Base/TrackReference.cxx index 5421aab865363..5828423819908 100644 --- a/Base/TrackReference.cxx +++ b/Base/TrackReference.cxx @@ -32,8 +32,9 @@ TrackReference::TrackReference() // Default constructor // Creates empty object - for (Int_t i = 0; i < 16; i++) + for (Int_t i = 0; i < 16; i++) { ResetBit(BIT(i)); + } } TrackReference::TrackReference(const TrackReference& tr) @@ -94,8 +95,9 @@ TrackReference::TrackReference(Int_t label, Int_t id) // Set Up status code // Copy Bits from virtual MC - for (Int_t i = 14; i < 22; i++) + for (Int_t i = 14; i < 22; i++) { ResetBit(BIT(i)); + } SetBit(BIT(14), gMC->IsNewTrack()); SetBit(BIT(15), gMC->IsTrackAlive()); diff --git a/Base/TrackReference.h b/Base/TrackReference.h index 4e7fbfbe9c852..cf80b51930548 100644 --- a/Base/TrackReference.h +++ b/Base/TrackReference.h @@ -93,8 +93,7 @@ class TrackReference : public TObject { virtual Float_t R() const { - return TMath::Sqrt(mReferencePositionX * mReferencePositionX + - mReferencePositionY * mReferencePositionY); + return TMath::Sqrt(mReferencePositionX * mReferencePositionX + mReferencePositionY * mReferencePositionY); } virtual Float_t Pt() const @@ -162,7 +161,7 @@ class TrackReference : public TObject { mDetectorId = id; } - virtual void SetPosition(Float_t x, Float_t y, Float_t z) + virtual void setPosition(Float_t x, Float_t y, Float_t z) { mReferencePositionX = x; mReferencePositionY = y; @@ -176,7 +175,7 @@ class TrackReference : public TObject { mMomentumZ = pz; } - virtual void SetUserId(Int_t userId) + virtual void setUserId(Int_t userId) { mUserId = userId; } @@ -184,14 +183,14 @@ class TrackReference : public TObject { // Methods to get position of the track reference in // in the TPC/TRD/TOF Tracking coordinate system - virtual Float_t PhiPos() const + virtual Float_t phiPosition() const { return TMath::Pi() + TMath::ATan2(-mReferencePositionY, -mReferencePositionX); } virtual Float_t Alpha() const { - return TMath::Pi() * (20 * ((((Int_t)(PhiPos() * 180 / TMath::Pi())) / 20)) + 10) / 180.; + return TMath::Pi() * (20 * ((((Int_t)(phiPosition() * 180 / TMath::Pi())) / 20)) + 10) / 180.; } virtual Float_t LocalX() const @@ -204,7 +203,7 @@ class TrackReference : public TObject { return mReferencePositionX * TMath::Sin(-Alpha()) + mReferencePositionY * TMath::Cos(-Alpha()); } - Bool_t IsSortable() const + Bool_t isSortable() const { return kTRUE; } diff --git a/CMakeLists.txt b/CMakeLists.txt index ee6f290f2c5eb..7797001c62241 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") Set(VMCWORKDIR ${CMAKE_SOURCE_DIR}) Option(USE_PATH_INFO "Information from PATH and LD_LIBRARY_PATH are -used."OFF) +used." OFF) If(USE_PATH_INFO) Set(PATH "$PATH") If (APPLE) @@ -171,3 +171,7 @@ WRITE_CONFIG_FILE(config.sh) configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake ) + +# Create an automatically generated config header file to pass file paths to the application +configure_file(${PROJECT_SOURCE_DIR}/header/AliceO2Config.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/header/AliceO2Config.h) diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 633a6ba1099b2..4ebe3bca93ebd 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -1,15 +1,15 @@ set(INCLUDE_DIRECTORIES -${ROOT_INCLUDE_DIR} -${BASE_INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR}/Data +${BASE_INCLUDE_DIRECTORIES} +${ROOT_INCLUDE_DIR} ) include_directories( ${INCLUDE_DIRECTORIES}) set(LINK_DIRECTORIES -${ROOT_LIBRARY_DIR} -${FAIRROOT_LIBRARY_DIR} ${CMAKE_SOURCE_DIR}/Data +${FAIRROOT_LIBRARY_DIR} +${ROOT_LIBRARY_DIR} ) link_directories( ${LINK_DIRECTORIES}) diff --git a/Data/DataLinkDef.h b/Data/DataLinkDef.h index 0f71885599f53..44a42c1099317 100644 --- a/Data/DataLinkDef.h +++ b/Data/DataLinkDef.h @@ -16,4 +16,3 @@ #pragma link C++ class MCTrack+; #endif - diff --git a/Data/DetectorList.h b/Data/DetectorList.h index bd8e9a878f331..c6c241c750226 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, kSTOPHERE }; #endif diff --git a/Data/MCTrack.cxx b/Data/MCTrack.cxx index d06d325d8e6f7..5b0a9b5341801 100644 --- a/Data/MCTrack.cxx +++ b/Data/MCTrack.cxx @@ -20,12 +20,12 @@ MCTrack::MCTrack() mStartVertexCoordinatesY(0.), mStartVertexCoordinatesZ(0.), mStartVertexCoordinatesT(0.), - fNPoints(0) + mNumberOfPoints(0) { } -MCTrack::MCTrack(Int_t pdgCode, Int_t motherId, Double_t px, Double_t py, Double_t pz, Double_t x, - Double_t y, Double_t z, Double_t t, Int_t nPoints = 0) +MCTrack::MCTrack(Int_t pdgCode, Int_t motherId, Double_t px, Double_t py, Double_t pz, Double_t x, Double_t y, + Double_t z, Double_t t, Int_t nPoints = 0) : TObject(), mPdgCode(pdgCode), mMotherTrackId(motherId), @@ -36,7 +36,7 @@ MCTrack::MCTrack(Int_t pdgCode, Int_t motherId, Double_t px, Double_t py, Double mStartVertexCoordinatesY(y), mStartVertexCoordinatesZ(z), mStartVertexCoordinatesT(t), - fNPoints(nPoints) + mNumberOfPoints(nPoints) { } @@ -51,7 +51,7 @@ MCTrack::MCTrack(const MCTrack& track) mStartVertexCoordinatesY(track.mStartVertexCoordinatesY), mStartVertexCoordinatesZ(track.mStartVertexCoordinatesZ), mStartVertexCoordinatesT(track.mStartVertexCoordinatesT), - fNPoints(track.fNPoints) + mNumberOfPoints(track.mNumberOfPoints) { } @@ -66,7 +66,7 @@ MCTrack::MCTrack(TParticle* part) mStartVertexCoordinatesY(part->Vy()), mStartVertexCoordinatesZ(part->Vz()), mStartVertexCoordinatesT(part->T() * 1e09), - fNPoints(0) + mNumberOfPoints(0) { } @@ -76,12 +76,12 @@ MCTrack::~MCTrack() void MCTrack::Print(Int_t trackId) const { - LOG(DEBUG) << "Track " << trackId << ", mother : " << mMotherTrackId << ", Type " << mPdgCode - << ", momentum (" << mStartVertexMomentumX << ", " << mStartVertexMomentumY << ", " - << mStartVertexMomentumZ << ") GeV" << FairLogger::endl; - // LOG(DEBUG2) << " Ref " << GetNumberOfPoints(kREF) - // << ", TutDet " << GetNumberOfPoints(kTutDet) - // << ", Rutherford " << GetNumberOfPoints(kFairRutherford) + LOG(DEBUG) << "Track " << trackId << ", mother : " << mMotherTrackId << ", Type " << mPdgCode << ", momentum (" + << mStartVertexMomentumX << ", " << mStartVertexMomentumY << ", " << mStartVertexMomentumZ << ") GeV" + << FairLogger::endl; + // LOG(DEBUG2) << " Ref " << getNumberOfPoints(kREF) + // << ", TutDet " << getNumberOfPoints(kTutDet) + // << ", Rutherford " << getNumberOfPoints(kFairRutherford) // << FairLogger::endl; // } @@ -106,12 +106,12 @@ Double_t MCTrack::GetRapidity() const return y; } -Int_t MCTrack::GetNumberOfPoints(DetectorId detId) const +Int_t MCTrack::getNumberOfPoints(DetectorId detId) const { // // TODO: Where does this come from - // if ( detId == kREF ) { return ( fNPoints & 1); } - // else if ( detId == kTutDet ) { return ( (fNPoints & ( 7 << 1) ) >> 1); } - // else if ( detId == kFairRutherford ) { return ( (fNPoints & (31 << 4) ) >> 4); } + // if ( detId == kREF ) { return ( mNumberOfPoints & 1); } + // else if ( detId == kTutDet ) { return ( (mNumberOfPoints & ( 7 << 1) ) >> 1); } + // else if ( detId == kFairRutherford ) { return ( (mNumberOfPoints & (31 << 4) ) >> 4); } // else { // LOG(ERROR) << "Unknown detector ID " // << detId << FairLogger::endl; @@ -120,29 +120,28 @@ Int_t MCTrack::GetNumberOfPoints(DetectorId detId) const // } -void MCTrack::SetNumberOfPoints(Int_t iDet, Int_t nPoints) +void MCTrack::setNumberOfPoints(Int_t iDet, Int_t nPoints) { // // if ( iDet == kREF ) { // if ( nPoints < 0 ) { nPoints = 0; } // else if ( nPoints > 1 ) { nPoints = 1; } - // fNPoints = ( fNPoints & ( ~ 1 ) ) | nPoints; + // mNumberOfPoints = ( mNumberOfPoints & ( ~ 1 ) ) | nPoints; // } // else if ( iDet == kTutDet ) { // if ( nPoints < 0 ) { nPoints = 0; } // else if ( nPoints > 7 ) { nPoints = 7; } - // fNPoints = ( fNPoints & ( ~ ( 7 << 1 ) ) ) | ( nPoints << 1 ); + // mNumberOfPoints = ( mNumberOfPoints & ( ~ ( 7 << 1 ) ) ) | ( nPoints << 1 ); // } // else if ( iDet == kFairRutherford ) { // if ( nPoints < 0 ) { nPoints = 0; } // else if ( nPoints > 31 ) { nPoints = 31; } - // fNPoints = ( fNPoints & ( ~ ( 31 << 4 ) ) ) | ( nPoints << 4 ); + // mNumberOfPoints = ( mNumberOfPoints & ( ~ ( 31 << 4 ) ) ) | ( nPoints << 4 ); // } - // else LOG(ERROR) << "Unknown detector ID " - // << iDet << FairLogger::endl; + // else { LOG(ERROR) << "Unknown detector ID " << iDet << FairLogger::endl; } // } diff --git a/Data/MCTrack.h b/Data/MCTrack.h index 623d543e8a891..2a0e17700f6ff 100644 --- a/Data/MCTrack.h +++ b/Data/MCTrack.h @@ -27,8 +27,8 @@ class MCTrack : public TObject { MCTrack(); /// Standard constructor - MCTrack(Int_t pdgCode, Int_t motherID, Double_t px, Double_t py, Double_t pz, Double_t x, - Double_t y, Double_t z, Double_t t, Int_t nPoints); + MCTrack(Int_t pdgCode, Int_t motherID, Double_t px, Double_t py, Double_t pz, Double_t x, Double_t y, Double_t z, + Double_t t, Int_t nPoints); /// Copy constructor MCTrack(const MCTrack& track); @@ -47,7 +47,7 @@ class MCTrack : public TObject { { return mPdgCode; } - Int_t GetMotherTrackId() const + Int_t getMotherTrackId() const { return mMotherTrackId; } @@ -83,13 +83,11 @@ class MCTrack : public TObject { Double_t GetEnergy() const; Double_t GetPt() const { - return TMath::Sqrt(mStartVertexMomentumX * mStartVertexMomentumX + - mStartVertexMomentumY * mStartVertexMomentumY); + return TMath::Sqrt(mStartVertexMomentumX * mStartVertexMomentumX + mStartVertexMomentumY * mStartVertexMomentumY); } Double_t GetP() const { - return TMath::Sqrt(mStartVertexMomentumX * mStartVertexMomentumX + - mStartVertexMomentumY * mStartVertexMomentumY + + return TMath::Sqrt(mStartVertexMomentumX * mStartVertexMomentumX + mStartVertexMomentumY * mStartVertexMomentumY + mStartVertexMomentumZ * mStartVertexMomentumZ); } Double_t GetRapidity() const; @@ -98,14 +96,14 @@ class MCTrack : public TObject { void GetStartVertex(TVector3& vertex); /// Accessors to the number of MCPoints in the detectors - Int_t GetNumberOfPoints(DetectorId detId) const; + Int_t getNumberOfPoints(DetectorId detId) const; /// Modifiers void SetMotherTrackId(Int_t id) { mMotherTrackId = id; } - void SetNumberOfPoints(Int_t iDet, Int_t np); + void setNumberOfPoints(Int_t iDet, Int_t np); private: /// PDG particle code @@ -118,8 +116,7 @@ class MCTrack : public TObject { Double32_t mStartVertexMomentumX, mStartVertexMomentumY, mStartVertexMomentumZ; /// Coordinates of start vertex [cm, ns] - Double32_t mStartVertexCoordinatesX, mStartVertexCoordinatesY, mStartVertexCoordinatesZ, - mStartVertexCoordinatesT; + Double32_t mStartVertexCoordinatesX, mStartVertexCoordinatesY, mStartVertexCoordinatesZ, mStartVertexCoordinatesT; /// Bitvector representing the number of MCPoints for this track in /// each subdetector. The detectors can be represented by (example from CBM) @@ -136,7 +133,7 @@ class MCTrack : public TObject { /// with the inline functions. /// Bits 26-31 are spare for potential additional detectors. - Int_t fNPoints; + Int_t mNumberOfPoints; ClassDef(MCTrack, 1); }; @@ -145,8 +142,7 @@ inline Double_t MCTrack::GetEnergy() const { Double_t mass = GetMass(); return TMath::Sqrt(mass * mass + mStartVertexMomentumX * mStartVertexMomentumX + - mStartVertexMomentumY * mStartVertexMomentumY + - mStartVertexMomentumZ * mStartVertexMomentumZ); + mStartVertexMomentumY * mStartVertexMomentumY + mStartVertexMomentumZ * mStartVertexMomentumZ); } inline void MCTrack::GetMomentum(TVector3& momentum) @@ -156,8 +152,7 @@ inline void MCTrack::GetMomentum(TVector3& momentum) inline void MCTrack::Get4Momentum(TLorentzVector& momentum) { - momentum.SetXYZT(mStartVertexMomentumX, mStartVertexMomentumY, mStartVertexMomentumZ, - GetEnergy()); + momentum.SetXYZT(mStartVertexMomentumX, mStartVertexMomentumY, mStartVertexMomentumZ, GetEnergy()); } inline void MCTrack::GetStartVertex(TVector3& vertex) diff --git a/Data/Stack.cxx b/Data/Stack.cxx index caa31bb3561ba..5b7714ab1c6aa 100644 --- a/Data/Stack.cxx +++ b/Data/Stack.cxx @@ -61,20 +61,17 @@ Stack::~Stack() } } -void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px, Double_t py, - Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t time, - Double_t polx, Double_t poly, Double_t polz, TMCProcess proc, Int_t& ntr, - Double_t weight, Int_t is) +void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px, Double_t py, Double_t pz, Double_t e, + Double_t vx, Double_t vy, Double_t vz, Double_t time, Double_t polx, Double_t poly, Double_t polz, + TMCProcess proc, Int_t& ntr, Double_t weight, Int_t is) { - PushTrack(toBeDone, parentId, pdgCode, px, py, pz, e, vx, vy, vz, time, polx, poly, polz, proc, - ntr, weight, is, -1); + PushTrack(toBeDone, parentId, pdgCode, px, py, pz, e, vx, vy, vz, time, polx, poly, polz, proc, ntr, weight, is, -1); } -void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px, Double_t py, - Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t time, - Double_t polx, Double_t poly, Double_t polz, TMCProcess proc, Int_t& ntr, - Double_t weight, Int_t is, Int_t secondparentID) +void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px, Double_t py, Double_t pz, Double_t e, + Double_t vx, Double_t vy, Double_t vz, Double_t time, Double_t polx, Double_t poly, Double_t polz, + TMCProcess proc, Int_t& ntr, Double_t weight, Int_t is, Int_t secondparentID) { // Get TParticle array @@ -85,8 +82,8 @@ void Stack::PushTrack(Int_t toBeDone, Int_t parentId, Int_t pdgCode, Double_t px Int_t nPoints = 0; Int_t daughter1Id = -1; Int_t daughter2Id = -1; - TParticle* particle = new (partArray[mNumberOfEntriesInParticles++]) TParticle( - pdgCode, trackId, parentId, nPoints, daughter1Id, daughter2Id, px, py, pz, e, vx, vy, vz, time); + TParticle* particle = new (partArray[mNumberOfEntriesInParticles++]) + TParticle(pdgCode, trackId, parentId, nPoints, daughter1Id, daughter2Id, px, py, pz, e, vx, vy, vz, time); particle->SetPolarisation(polx, poly, polz); particle->SetWeight(weight); particle->SetUniqueID(proc); @@ -199,7 +196,7 @@ void Stack::FillTrackArray() // Set the number of points in the detectors for this track for (Int_t iDet = kAliIts; iDet < kSTOPHERE; iDet++) { pair a(iPart, iDet); - track->SetNumberOfPoints(iDet, mPointsMap[a]); + track->setNumberOfPoints(iDet, mPointsMap[a]); } mNumberOfEntriesInTracks++; } else { @@ -223,7 +220,7 @@ void Stack::UpdateTrackIndex(TRefArray* detList) // First update mother ID in MCTracks for (Int_t i = 0; i < mNumberOfEntriesInTracks; i++) { MCTrack* track = (MCTrack*)mTracks->At(i); - Int_t iMotherOld = track->GetMotherTrackId(); + Int_t iMotherOld = track->getMotherTrackId(); mIndexIterator = mIndexMap.find(iMotherOld); if (mIndexIterator == mIndexMap.end()) { mLogger->Fatal(MESSAGE_ORIGIN, "Stack: Particle index %i not found in dex map! ", iMotherOld); @@ -257,8 +254,7 @@ void Stack::UpdateTrackIndex(TRefArray* detList) mIndexIterator = mIndexMap.find(iTrack); if (mIndexIterator == mIndexMap.end()) { - mLogger->Fatal(MESSAGE_ORIGIN, "Stack: Particle index %i not found in index map! ", - iTrack); + mLogger->Fatal(MESSAGE_ORIGIN, "Stack: Particle index %i not found in index map! ", iTrack); Fatal("Stack::UpdateTrackIndex", "Particle index not found in map"); } point->SetTrackID((*mIndexIterator).second); diff --git a/Data/Stack.h b/Data/Stack.h index 984f57d8e7e96..811290a41f585 100644 --- a/Data/Stack.h +++ b/Data/Stack.h @@ -62,16 +62,13 @@ class Stack : public FairGenericStack { /// \param ntr Track number (filled by the stack) /// \param weight Particle weight /// \param is Generation status code (whatever that means) - virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode, Double_t px, Double_t py, - Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, - Double_t time, Double_t polx, Double_t poly, Double_t polz, - TMCProcess proc, Int_t& ntr, Double_t weight, Int_t is); + virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode, Double_t px, Double_t py, Double_t pz, + Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t time, Double_t polx, Double_t poly, + Double_t polz, TMCProcess proc, Int_t& ntr, Double_t weight, Int_t is); - virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode, Double_t px, Double_t py, - Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, - Double_t time, Double_t polx, Double_t poly, Double_t polz, - TMCProcess proc, Int_t& ntr, Double_t weight, Int_t is, - Int_t secondParentId); + virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode, Double_t px, Double_t py, Double_t pz, + Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t time, Double_t polx, Double_t poly, + Double_t polz, TMCProcess proc, Int_t& ntr, Double_t weight, Int_t is, Int_t secondParentId); /// Get next particle for tracking from the stack. /// Declared in TVirtualMCStack @@ -181,32 +178,32 @@ class Stack : public FairGenericStack { FairLogger* mLogger; /// STL stack (FILO) used to handle the TParticles for tracking - std::stack mStack; + std::stack mStack; //! /// Array of TParticles (contains all TParticles put into or created /// by the transport - TClonesArray* mParticles; + TClonesArray* mParticles; //! /// Array of FairMCTracks containg the tracks written to the output TClonesArray* mTracks; /// STL map from particle index to storage flag - std::map mStoreMap; - std::map::iterator mStoreIterator; + std::map mStoreMap; //! + std::map::iterator mStoreIterator; //! /// STL map from particle index to track index - std::map mIndexMap; - std::map::iterator mIndexIterator; + std::map mIndexMap; //! + std::map::iterator mIndexIterator; //! /// STL map from track index and detector ID to number of MCPoints - std::map, Int_t> mPointsMap; + std::map, Int_t> mPointsMap; //! /// Some indices and counters - Int_t mIndexOfCurrentTrack; ///< Index of current track - Int_t mNumberOfPrimaryParticles; ///< Number of primary particles - Int_t mNumberOfEntriesInParticles; ///< Number of entries in mParticles - Int_t mNumberOfEntriesInTracks; ///< Number of entries in mTracks - Int_t mIndex; ///< Used for merging + Int_t mIndexOfCurrentTrack; //! Index of current track + Int_t mNumberOfPrimaryParticles; //! Number of primary particles + Int_t mNumberOfEntriesInParticles; //! Number of entries in mParticles + Int_t mNumberOfEntriesInTracks; //! Number of entries in mTracks + Int_t mIndex; //! Used for merging /// Variables defining the criteria for output selection Bool_t mStoreMothers; diff --git a/Resources/maps/mfchebKGI_meas.root b/Resources/maps/mfchebKGI_meas.root new file mode 100644 index 0000000000000..5e9ec40ff771d Binary files /dev/null and b/Resources/maps/mfchebKGI_meas.root differ diff --git a/Resources/maps/mfchebKGI_sym.root b/Resources/maps/mfchebKGI_sym.root new file mode 100644 index 0000000000000..142e628c4baee Binary files /dev/null and b/Resources/maps/mfchebKGI_sym.root differ diff --git a/field/AliConstField.cxx b/field/AliConstField.cxx deleted file mode 100644 index 758465afddbc7..0000000000000 --- a/field/AliConstField.cxx +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -// ------------------------------------------------------------------------- -// ----- AliConstField source file ----- -// ----- Created 06/01/04 by M. Al/Turany ----- -// ----- Redesign 13/02/06 by V. Friese ----- -// ------------------------------------------------------------------------- -#include "AliConstField.h" - -#include "AliFieldPar.h" - -#include -#include - -using std::cout; -using std::cerr; -using std::endl; -using std::setw; - - -// ----- Default constructor ------------------------------------------- -AliConstField::AliConstField() - : FairField(), - fXmin(0.), - fXmax(0.), - fYmin(0.), - fYmax(0.), - fZmin(0.), - fZmax(0.), - fBx(0.), - fBy(0.), - fBz(0.) -{ - fType = 0; -} -// ------------------------------------------------------------------------- - - - -// ----- Standard constructor ------------------------------------------ -AliConstField::AliConstField(const char* name, Double_t xMin, - Double_t xMax, Double_t yMin, - Double_t yMax, Double_t zMin, - Double_t zMax, Double_t bX, - Double_t bY, Double_t bZ) - : FairField(name), - fXmin(xMin), - fXmax(xMax), - fYmin(yMin), - fYmax(yMax), - fZmin(zMin), - fZmax(zMax), - fBx(bX), - fBy(bY), - fBz(bZ) -{ - fType=0; -} -// ------------------------------------------------------------------------- - - - -// -------- Constructor from CbmFieldPar ------------------------------- -AliConstField::AliConstField(AliFieldPar* fieldPar) - : FairField(), - fXmin(0.), - fXmax(0.), - fYmin(0.), - fYmax(0.), - fZmin(0.), - fZmax(0.), - fBx(0.), - fBy(0.), - fBz(0.) -{ - if ( ! fieldPar ) { - cerr << "-W- AliConstField::AliConstField: empty parameter container!" - << endl; - fType=0; - } - else { - fXmin = fieldPar->GetXmin(); - fXmax = fieldPar->GetXmax(); - fYmin = fieldPar->GetYmin(); - fYmax = fieldPar->GetYmax(); - fZmin = fieldPar->GetZmin(); - fZmax = fieldPar->GetZmax(); - fBx = fieldPar->GetBx(); - fBy = fieldPar->GetBy(); - fBz = fieldPar->GetBz(); - fType = fieldPar->GetType(); - } -} -// ------------------------------------------------------------------------- - - - -// ----- Destructor ---------------------------------------------------- -AliConstField::~AliConstField() { } -// ------------------------------------------------------------------------- - - - -// ----- Set field region ---------------------------------------------- -void AliConstField::SetFieldRegion(Double_t xMin, Double_t xMax, - Double_t yMin, Double_t yMax, - Double_t zMin, Double_t zMax) { - fXmin = xMin; - fXmax = xMax; - fYmin = yMin; - fYmax = yMax; - fZmin = zMin; - fZmax = zMax; -} -// ------------------------------------------------------------------------- - - - -// ----- Set field values ---------------------------------------------- -void AliConstField::SetField(Double_t bX, Double_t bY, Double_t bZ) { - fBx = bX; - fBy = bY; - fBz = bZ; -} -// ------------------------------------------------------------------------- - - - -// ----- Get x component of field -------------------------------------- -Double_t AliConstField::GetBx(Double_t x, Double_t y, Double_t z) { - if ( x < fXmin || x > fXmax || - y < fYmin || y > fYmax || - z < fZmin || z > fZmax ) return 0.; - return fBx; -} -// ------------------------------------------------------------------------- - - - -// ----- Get y component of field -------------------------------------- -Double_t AliConstField::GetBy(Double_t x, Double_t y, Double_t z) { - if ( x < fXmin || x > fXmax || - y < fYmin || y > fYmax || - z < fZmin || z > fZmax ) return 0.; - return fBy; -} -// ------------------------------------------------------------------------- - - - -// ----- Get z component of field -------------------------------------- -Double_t AliConstField::GetBz(Double_t x, Double_t y, Double_t z) { - if ( x < fXmin || x > fXmax || - y < fYmin || y > fYmax || - z < fZmin || z > fZmax ) return 0.; - return fBz; -} -// ------------------------------------------------------------------------- - - - -// ----- Screen output ------------------------------------------------- -void AliConstField::Print() { - cout << "======================================================" << endl; - cout << "---- " << fTitle << " : " << fName << endl; - cout << "----" << endl; - cout << "---- Field type : constant" << endl; - cout << "----" << endl; - cout << "---- Field regions : " << endl; - cout << "---- x = " << setw(4) << fXmin << " to " << setw(4) - << fXmax << " cm" << endl; - cout << "---- y = " << setw(4) << fYmin << " to " << setw(4) - << fYmax << " cm" << endl; - cout << "---- z = " << setw(4) << fZmin << " to " << setw(4) - << fZmax << " cm" << endl; - cout.precision(4); - cout << "---- B = ( " << fBx << ", " << fBy << ", " << fBz << " ) kG" - << endl; - cout << "======================================================" << endl; -} -// ------------------------------------------------------------------------- - - - -ClassImp(AliConstField) diff --git a/field/AliConstField.h b/field/AliConstField.h deleted file mode 100644 index eb79f9945f0a6..0000000000000 --- a/field/AliConstField.h +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -// ------------------------------------------------------------------------- -// ----- AliConstField header file ----- -// ----- Created 25/03/14 by M. Al-Turany ----- -// ------------------------------------------------------------------------- - - -/** AliConstField.h - ** @author M.Al-Turany - ** @since 25.03.2014 - ** @version1.0 - ** - ** A constant (homogeneous) magnetic field - **/ - - -#ifndef AliConstField_H -#define AliConstField_H 1 - - -#include "FairField.h" - - -class AliFieldPar; - - -class AliConstField : public FairField -{ - - public: - - /** Default constructor **/ - AliConstField(); - - - /** Standard constructor - ** @param name Object name - ** @param xMin,xMax x region of field (global coordinates) - ** @param yMin,yMax y region of field (global coordinates) - ** @param zMin,zMax z region of field (global coordinates) - ** @param bX,bY,bZ Field values [kG] - **/ - AliConstField(const char* name, Double_t xMin, Double_t xMax, - Double_t yMin, Double_t yMax, Double_t zMin, - Double_t zMax, Double_t bX, Double_t bY, Double_t bZ); - - - /** Constructor from AliFieldPar **/ - AliConstField(AliFieldPar* fieldPar); - - - /** Destructor **/ - virtual ~AliConstField(); - - - /** Set the field region - ** @param xMin,xMax x region of field (global coordinates) - ** @param yMin,yMax y region of field (global coordinates) - ** @param zMin,zMax z region of field (global coordinates) - **/ - void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, - Double_t yMax, Double_t zMin, Double_t zMax); - - - /** Set the field values - ** @param bX,bY,bZ Field values [kG] - **/ - void SetField(Double_t bX, Double_t bY, Double_t bZ); - - - /** Get components of field at a given point - ** @param x,y,z Point coordinates [cm] - **/ - virtual Double_t GetBx(Double_t x, Double_t y, Double_t z); - virtual Double_t GetBy(Double_t x, Double_t y, Double_t z); - virtual Double_t GetBz(Double_t x, Double_t y, Double_t z); - - - /** Accessors to field region **/ - Double_t GetXmin() const { return fXmin; } - Double_t GetXmax() const { return fXmax; } - Double_t GetYmin() const { return fYmin; } - Double_t GetYmax() const { return fYmax; } - Double_t GetZmin() const { return fZmin; } - Double_t GetZmax() const { return fZmax; } - - - /** Accessors to field values **/ - Double_t GetBx() const { return fBx; } - Double_t GetBy() const { return fBy; } - Double_t GetBz() const { return fBz; } - - - /** Screen output **/ - virtual void Print(); - - - private: - - /** Limits of the field region **/ - Double_t fXmin; - Double_t fXmax; - Double_t fYmin; - Double_t fYmax; - Double_t fZmin; - Double_t fZmax; - - /** Field components inside the field region **/ - Double_t fBx; - Double_t fBy; - Double_t fBz; - - ClassDef(AliConstField, 1); - -}; - - -#endif diff --git a/field/AliFieldCreator.cxx b/field/AliFieldCreator.cxx deleted file mode 100644 index efed02592d8ed..0000000000000 --- a/field/AliFieldCreator.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -// ------------------------------------------------------------------------- -// ----- AliConstField header file ----- -// ----- Created 25/03/14 by M. Al-Turany ----- -// ------------------------------------------------------------------------- - -#include "AliFieldCreator.h" - -#include "AliFieldPar.h" -#include "AliConstField.h" - -#include "FairRunAna.h" -#include "FairRuntimeDb.h" -#include "FairField.h" - -#include -using std::cout; -using std::cerr; -using std::endl; - -static AliFieldCreator gAliFieldCreator; - -AliFieldCreator::AliFieldCreator() - :FairFieldFactory(), - fFieldPar(NULL) -{ - fCreator=this; -} - -AliFieldCreator::~AliFieldCreator() -{ -} - -void AliFieldCreator::SetParm() -{ - FairRunAna *Run = FairRunAna::Instance(); - FairRuntimeDb *RunDB = Run->GetRuntimeDb(); - fFieldPar = (AliFieldPar*) RunDB->getContainer("AliFieldPar"); - -} - -FairField* AliFieldCreator::createFairField() -{ - FairField *fMagneticField=0; - - if ( ! fFieldPar ) { - cerr << "-E- No field parameters available!" - << endl; - }else{ - // Instantiate correct field type - Int_t fType = fFieldPar->GetType(); - if ( fType == 0 ) fMagneticField = new AliConstField(fFieldPar); - else cerr << "-W- FairRunAna::GetField: Unknown field type " << fType - << endl; - cout << "New field at " << fMagneticField << ", type " << fType << endl; - // Initialise field - if ( fMagneticField ) { - fMagneticField->Init(); - fMagneticField->Print(); - } - } - return fMagneticField; -} - - -ClassImp(AliFieldCreator) diff --git a/field/AliFieldCreator.h b/field/AliFieldCreator.h deleted file mode 100644 index 315cabedbeab0..0000000000000 --- a/field/AliFieldCreator.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -// ------------------------------------------------------------------------- -// ----- AliFieldCreator header file ----- -// ----- Created 26/03/14 by M. Al-Turany ----- -// ------------------------------------------------------------------------- - - -#ifndef AliFieldCreator_H -#define AliFieldCreator_H - -#include "FairFieldFactory.h" - -class AliFieldPar; - -class FairField; - -class AliFieldCreator : public FairFieldFactory -{ - - public: - AliFieldCreator(); - virtual ~AliFieldCreator(); - virtual FairField* createFairField(); - virtual void SetParm(); - ClassDef(AliFieldCreator,1); - - protected: - AliFieldPar* fFieldPar; - - private: - AliFieldCreator(const AliFieldCreator&); - AliFieldCreator& operator=(const AliFieldCreator&); - -}; -#endif //AliFieldCreator_H diff --git a/field/AliFieldPar.cxx b/field/AliFieldPar.cxx deleted file mode 100644 index 134bcd1a1e0b3..0000000000000 --- a/field/AliFieldPar.cxx +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -// ------------------------------------------------------------------------- -// ----- AliFieldPar file ----- -// ----- Created 26/03/14 by M. Al-Turany ----- -// ------------------------------------------------------------------------- - - -#include "AliFieldPar.h" - -#include "AliConstField.h" -#include "FairParamList.h" - -#include -using std::cout; -using std::cerr; -using std::endl; - -const int kMaxLen = 2048; - -// ------ Constructor -------------------------------------------------- -AliFieldPar::AliFieldPar(const char* name, const char* title, - const char* context) - : FairParGenericSet(name, title, context), - fType(-1), - fXmin(0.), - fXmax(0.), - fYmin(0.), - fYmax(0.), - fZmin(0.), - fZmax(0.), - fBx(0.), - fBy(0.), - fBz(0.), - fMapName(""), - fPosX(0.), - fPosY(0.), - fPosZ(0.), - fScale(0.), - fPeak(0.), - fMiddle(0.) - -{ -} -// ------------------------------------------------------------------------- - -AliFieldPar::AliFieldPar() - : FairParGenericSet(), - fType(-1), - fXmin(0.), - fXmax(0.), - fYmin(0.), - fYmax(0.), - fZmin(0.), - fZmax(0.), - fBx(0.), - fBy(0.), - fBz(0.), - fMapName(""), - fPosX(0.), - fPosY(0.), - fPosZ(0.), - fScale(0.), - fPeak(0.), - fMiddle(0.) - -{ -} -// ------------------------------------------------------------------------- - -// ------ Destructor --------------------------------------------------- -AliFieldPar::~AliFieldPar() { } -// ------------------------------------------------------------------------- - - - -// ------ Put parameters ----------------------------------------------- -void AliFieldPar::putParams(FairParamList* list) { - - if ( ! list ) return; - - list->add("Field Type", fType); - - if ( fType == 0 ) { // constant field - list->add("Field min x", fXmin); - list->add("Field max x", fXmax); - list->add("Field min y", fYmin); - list->add("Field max y", fYmax); - list->add("Field min z", fZmin); - list->add("Field max z", fZmax); - list->add("Field Bx", fBx); - list->add("Field By", fBy); - list->add("Field Bz", fBz); - } else if (fType >=1 && fType <= kMaxFieldMapType) { // - list->add("Field Peak", fPeak); - list->add("Field Middle", fMiddle); - } else if (fType >=2 && fType <= kMaxFieldMapType) { // field map - list->add("Field map name", fMapName); - list->add("Field x position", fPosX); - list->add("Field y position", fPosY); - list->add("Field z position", fPosZ); - list->add("Field scaling factor", fScale); - - } - -} -// ------------------------------------------------------------------------- - - - -// -------- Get parameters --------------------------------------------- -Bool_t AliFieldPar::getParams(FairParamList* list) { - - if ( ! list ) return kFALSE; - - if ( ! list->fill("Field Type", &fType) ) return kFALSE; - - if ( fType == 0 ) { // constant field - if ( ! list->fill("Field min x", &fXmin) ) return kFALSE; - if ( ! list->fill("Field max x", &fXmax) ) return kFALSE; - if ( ! list->fill("Field min y", &fYmin) ) return kFALSE; - if ( ! list->fill("Field max y", &fYmax) ) return kFALSE; - if ( ! list->fill("Field min z", &fZmin) ) return kFALSE; - if ( ! list->fill("Field max z", &fZmax) ) return kFALSE; - if ( ! list->fill("Field Bx", &fBx) ) return kFALSE; - if ( ! list->fill("Field By", &fBy) ) return kFALSE; - if ( ! list->fill("Field Bz", &fBz) ) return kFALSE; - - } else if (fType >=1 && fType <= kMaxFieldMapType) { - - if ( ! list->fill("Field Peak", &fPeak) ) return kFALSE; - if ( ! list->fill("Field Middle", &fMiddle) ) return kFALSE; - - } else if (fType >=2 && fType <= kMaxFieldMapType) { // field map - Text_t mapName[80]; - if ( ! list->fill("Field map name", mapName, 80) ) return kFALSE; - fMapName = mapName; - if ( ! list->fill("Field x position", &fPosX) ) return kFALSE; - if ( ! list->fill("Field y position", &fPosY) ) return kFALSE; - if ( ! list->fill("Field z position", &fPosZ) ) return kFALSE; - if ( ! list->fill("Field scaling factor", &fScale) ) return kFALSE; - - } - - return kTRUE; - -} -// ------------------------------------------------------------------------- - - - -void AliFieldPar::SetParameters(FairField* field) { - - if ( ! field ) { - cerr << "-W- AliFieldPar::SetParameters: Empty field pointer!" << endl; - return; - } - - fType = field->GetType(); - - if ( fType == 0 ) { // constant field - AliConstField* fieldConst = (AliConstField*) field; - fBx = fieldConst->GetBx(); - fBy = fieldConst->GetBy(); - fBz = fieldConst->GetBz(); - fXmin = fieldConst->GetXmin(); - fXmax = fieldConst->GetXmax(); - fYmin = fieldConst->GetYmin(); - fYmax = fieldConst->GetYmax(); - fZmin = fieldConst->GetZmin(); - fZmax = fieldConst->GetZmax(); - fMapName = ""; - fPosX = fPosY = fPosZ = fScale = 0.; - } else { - cerr << "-W- AliFieldPar::SetParameters: Unknown field type " - << fType << "!" << endl; - fBx = fBy = fBz = 0.; - fXmin = fXmax = fYmin = fYmax = fZmin = fZmax = 0.; - fMapName = ""; - fPosX = fPosY = fPosZ = fScale = 0.; - } - - return; - -} -// ------------------------------------------------------------------------- - - - - - - -ClassImp(AliFieldPar) - diff --git a/field/AliFieldPar.h b/field/AliFieldPar.h deleted file mode 100644 index 17db4e6b4ba1e..0000000000000 --- a/field/AliFieldPar.h +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -// ------------------------------------------------------------------------- -// ----- AliFieldPar header file ----- -// ----- Created 26/03/14 by M. Al-Turany ----- -// ------------------------------------------------------------------------- - - - -#ifndef AliFieldPar_H -#define AliFieldPar_H 1 - -#include "FairParGenericSet.h" - -class FairField; -class FairParamList; - -const int kMaxFieldMapType = 5; - -class AliFieldPar : public FairParGenericSet -{ - - public: - - - /** Standard constructor **/ - AliFieldPar(const char* name, const char* title, const char* context); - -/** default constructor **/ - AliFieldPar(); - - /** Destructor **/ - ~AliFieldPar(); - - - /** Put parameters **/ - virtual void putParams(FairParamList* list); - - - /** Get parameters **/ - virtual Bool_t getParams(FairParamList* list); - - - /** Set parameters from CbmField **/ - void SetParameters(FairField* field); - - - /** Accessors **/ - Int_t GetType() const { return fType; } - Double_t GetXmin() const { return fXmin; } - Double_t GetXmax() const { return fXmax; } - Double_t GetYmin() const { return fYmin; } - Double_t GetYmax() const { return fYmax; } - Double_t GetZmin() const { return fZmin; } - Double_t GetZmax() const { return fZmax; } - Double_t GetBx() const { return fBx; } - Double_t GetBy() const { return fBy; } - Double_t GetBz() const { return fBz; } - void MapName(TString& name) { name = fMapName; } - Double_t GetPositionX() const { return fPosX; } - Double_t GetPositionY() const { return fPosY; } - Double_t GetPositionZ() const { return fPosZ; } - Double_t GetScale() const { return fScale; } - Double_t GetPeak() const { return fPeak; } - Double_t GetMiddle() const { return fMiddle; } - - - - private: - - /** Field type - ** 0 = constant field - ** 1 = field map - ** 2 = field map sym2 (symmetries in x and y) - ** 3 = field map sym3 (symmetries in x, y and z) - ** kTypeDistorted = distorted field map (its parent field can be field map or constant field) - **/ - Int_t fType; - - - /** Field limits in case of constant field **/ - Double_t fXmin, fXmax; - Double_t fYmin, fYmax; - Double_t fZmin, fZmax; - - - /** Field values in case of constant field [kG] **/ - Double_t fBx, fBy, fBz; - - - /** Field map name in case of field map **/ - TString fMapName; - - - /** Field centre position for field map **/ - Double_t fPosX, fPosY, fPosZ; - - - /** Scaling factor for field map **/ - Double_t fScale; - - /** field parameters**/ - Double_t fPeak; - Double_t fMiddle; - - - AliFieldPar(const AliFieldPar&); - AliFieldPar& operator=(const AliFieldPar&); - - ClassDef(AliFieldPar,1); - -}; - - -#endif diff --git a/field/CMakeLists.txt b/field/CMakeLists.txt index 7d4174c912197..b14c47d1c3df5 100644 --- a/field/CMakeLists.txt +++ b/field/CMakeLists.txt @@ -1,34 +1,36 @@ -# Create a library called "libField” which includes the source files given in -# the array . +# Create a library called "AliceO2Field" 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 -${BASE_INCLUDE_DIRECTORIES} +${CMAKE_SOURCE_DIR}/field +${CMAKE_SOURCE_DIR}/header +${BASE_INCLUDE_DIRECTORIES} ${ROOT_INCLUDE_DIR} -${CMAKE_SOURCE_DIR}/field ) include_directories( ${INCLUDE_DIRECTORIES}) set(LINK_DIRECTORIES -${ROOT_LIBRARY_DIR} +${CMAKE_SOURCE_DIR}/base +${CMAKE_SOURCE_DIR}/field ${FAIRROOT_LIBRARY_DIR} - +${ROOT_LIBRARY_DIR} ) - + link_directories( ${LINK_DIRECTORIES}) set(SRCS -AliConstField.cxx -AliFieldCreator.cxx -AliFieldPar.cxx +MagneticWrapperChebyshev.cxx +MagneticField.cxx +Chebyshev3D.cxx +Chebyshev3DCalc.cxx ) -set(LINKDEF FieldLinkDef.h) -Set(LIBRARY_NAME Field) -Set(DEPENDENCIES - Base -) +Set(HEADERS) +Set(LINKDEF fieldLinkDef.h) +Set(LIBRARY_NAME AliceO2Field) +Set(DEPENDENCIES Base EG Physics Cint Core) GENERATE_LIBRARY() diff --git a/field/Chebyshev3D.cxx b/field/Chebyshev3D.cxx new file mode 100644 index 0000000000000..4881c8eba63ab --- /dev/null +++ b/field/Chebyshev3D.cxx @@ -0,0 +1,1037 @@ +/// \file Cheb3D.cxx +/// \brief Implementation of the Cheb3D class +/// \author ruben.shahoyan@cern.ch 09/09/2006 + +#include +#include +#include +#include +#include +#include +#include +#include +#include "Chebyshev3D.h" +#include "Chebyshev3DCalc.h" +#include "FairLogger.h" + +using namespace AliceO2::Field; + +ClassImp(Chebyshev3D) + +Chebyshev3D::Chebyshev3D() + : mOutputArrayDimension(0), + mPrecision(0), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + // Default constructor + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = + mTemporaryCoefficient[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0; + } +} + +Chebyshev3D::Chebyshev3D(const Chebyshev3D& src) + : TNamed(src), + mOutputArrayDimension(src.mOutputArrayDimension), + mPrecision(src.mPrecision), + mChebyshevParameter(1), + mMaxCoefficients(src.mMaxCoefficients), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(src.mUserFunctionName), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + // read coefs from text file + for (int i = 3; i--;) { + mMinBoundaries[i] = src.mMinBoundaries[i]; + mMaxBoundaries[i] = src.mMaxBoundaries[i]; + mBoundaryMappingScale[i] = src.mBoundaryMappingScale[i]; + mBoundaryMappingOffset[i] = src.mBoundaryMappingOffset[i]; + mNumberOfPoints[i] = src.mNumberOfPoints[i]; + mTemporaryChebyshevGridOffs[i] = src.mTemporaryChebyshevGridOffs[i]; + mTemporaryCoefficient[i] = 0; + } + for (int i = 0; i < mOutputArrayDimension; i++) { + Chebyshev3DCalc* cbc = src.getChebyshevCalc(i); + if (cbc) { + mChebyshevParameter.AddAtAndExpand(new Chebyshev3DCalc(*cbc), i); + } + } +} + +Chebyshev3D::Chebyshev3D(const char* inpFile) + : mOutputArrayDimension(0), + mPrecision(0), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + // read coefs from text file + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0; + mTemporaryCoefficient[i] = 0; + } + loadData(inpFile); +} + +Chebyshev3D::Chebyshev3D(FILE* stream) + : mOutputArrayDimension(0), + mPrecision(0), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + // read coefs from stream + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0; + mTemporaryCoefficient[i] = 0; + } + loadData(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) + : TNamed(funName, funName), + mOutputArrayDimension(0), + mPrecision(TMath::Max(1.E-12f, prec)), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + if (DimOut < 1) { + Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); + exit(1); + } + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0.; + mTemporaryCoefficient[i] = 0; + } + setDimOut(DimOut); + prepareBoundaries(bmin, bmax); + defineGrid(npoints); + setuserFunction(funName); + chebyshevFit(); +} +#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) + : mOutputArrayDimension(0), + mPrecision(TMath::Max(1.E-12f, prec)), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + if (DimOut < 1) { + Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); + exit(1); + } + if (DimOut < 1) { + Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); + exit(1); + } + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0.; + mTemporaryCoefficient[i] = 0; + } + setDimOut(DimOut); + prepareBoundaries(bmin, bmax); + defineGrid(npoints); + setuserFunction(ptr); + chebyshevFit(); +} +#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) + : mOutputArrayDimension(0), + mPrecision(TMath::Max(1.E-12f, prec)), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + if (DimOut < 1) { + Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); + exit(1); + } + if (DimOut < 1) { + Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); + exit(1); + } + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0.; + mTemporaryCoefficient[i] = 0; + } + setDimOut(DimOut); + prepareBoundaries(bmin, bmax); + setuserFunction(ptr); + + defineGrid(npX); + chebyshevFit(0); + defineGrid(npY); + chebyshevFit(1); + defineGrid(npZ); + chebyshevFit(2); +} +#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) + : mOutputArrayDimension(0), + mPrecision(TMath::Max(1.E-12f, prec)), + mChebyshevParameter(1), + mMaxCoefficients(0), + mTemporaryUserResults(0), + mTemporaryChebyshevGrid(0), + mUserFunctionName(""), + mUserMacro(0), + mLogger(FairLogger::GetLogger()) +{ + if (DimOut != 3) { + Error("Chebyshev3D", "This constructor works only for 3D fits, %dD fit was requested\n", mOutputArrayDimension); + exit(1); + } + if (DimOut < 1) { + Error("Chebyshev3D", "Requested output dimension is %d\nStop\n", mOutputArrayDimension); + exit(1); + } + for (int i = 3; i--;) { + mMinBoundaries[i] = mMaxBoundaries[i] = mBoundaryMappingScale[i] = mBoundaryMappingOffset[i] = 0; + mNumberOfPoints[i] = 0; + mTemporaryChebyshevGridOffs[i] = 0.; + mTemporaryCoefficient[i] = 0; + } + setDimOut(DimOut); + prepareBoundaries(bmin, bmax); + setuserFunction(ptr); + + if (run) { + int gridNC[3][3]; + estimateNumberOfPoints(prec, gridNC); + defineGrid(gridNC[0]); + chebyshevFit(0); + defineGrid(gridNC[1]); + chebyshevFit(1); + defineGrid(gridNC[2]); + chebyshevFit(2); + } +} +#endif + +Chebyshev3D& Chebyshev3D::operator=(const Chebyshev3D& rhs) +{ + // assignment operator + if (this != &rhs) { + Clear(); + mOutputArrayDimension = rhs.mOutputArrayDimension; + mPrecision = rhs.mPrecision; + mMaxCoefficients = rhs.mMaxCoefficients; + mUserFunctionName = rhs.mUserFunctionName; + mUserMacro = 0; + for (int i = 3; i--;) { + mMinBoundaries[i] = rhs.mMinBoundaries[i]; + mMaxBoundaries[i] = rhs.mMaxBoundaries[i]; + mBoundaryMappingScale[i] = rhs.mBoundaryMappingScale[i]; + mBoundaryMappingOffset[i] = rhs.mBoundaryMappingOffset[i]; + mNumberOfPoints[i] = rhs.mNumberOfPoints[i]; + } + for (int i = 0; i < mOutputArrayDimension; i++) { + Chebyshev3DCalc* cbc = rhs.getChebyshevCalc(i); + if (cbc) { + mChebyshevParameter.AddAtAndExpand(new Chebyshev3DCalc(*cbc), i); + } + } + } + return *this; +} + +void Chebyshev3D::Clear(const Option_t*) +{ + // clear all dynamic structures + if (mTemporaryUserResults) { + delete[] mTemporaryUserResults; + mTemporaryUserResults = 0; + } + if (mTemporaryChebyshevGrid) { + delete[] mTemporaryChebyshevGrid; + mTemporaryChebyshevGrid = 0; + } + if (mUserMacro) { + delete mUserMacro; + mUserMacro = 0; + } + mChebyshevParameter.SetOwner(kTRUE); + mChebyshevParameter.Delete(); +} + +void Chebyshev3D::Print(const Option_t* opt) const +{ + // print info + printf("%s: Chebyshev parameterization for 3D->%dD function. Precision: %e\n", GetName(), mOutputArrayDimension, + mPrecision); + printf("Region of validity: [%+.5e:%+.5e] [%+.5e:%+.5e] [%+.5e:%+.5e]\n", mMinBoundaries[0], mMaxBoundaries[0], + mMinBoundaries[1], mMaxBoundaries[1], mMinBoundaries[2], mMaxBoundaries[2]); + TString opts = opt; + opts.ToLower(); + if (opts.Contains("l")) { + for (int i = 0; i < mOutputArrayDimension; i++) { + printf("Output dimension %d:\n", i + 1); + getChebyshevCalc(i)->Print(); + } + } +} + +void Chebyshev3D::prepareBoundaries(const Float_t* bmin, const Float_t* bmax) +{ + // Set and check boundaries defined by user, prepare coefficients for their conversion to [-1:1] interval + for (int i = 3; i--;) { + mMinBoundaries[i] = bmin[i]; + mMaxBoundaries[i] = bmax[i]; + mBoundaryMappingScale[i] = bmax[i] - bmin[i]; + if (mBoundaryMappingScale[i] <= 0) { + mLogger->Fatal(MESSAGE_ORIGIN, "Boundaries for %d-th dimension are not increasing: %+.4e %+.4e\nStop\n", i, + mMinBoundaries[i], mMaxBoundaries[i]); + } + mBoundaryMappingOffset[i] = bmin[i] + mBoundaryMappingScale[i] / 2.0; + mBoundaryMappingScale[i] = 2. / mBoundaryMappingScale[i]; + } +} + +#ifdef _INC_CREATION_Chebyshev3D_ + +// Pointer on user function (faster altrnative to TMethodCall) +void (*gUsrFunChebyshev3D)(float*, float*); + +void Chebyshev3D::evaluateUserFunction() +{ + // call user supplied function + if (gUsrFunChebyshev3D) { + gUsrFunChebyshev3D(mTemporaryCoefficient, mTemporaryUserResults); + } + else { + mUserMacro->Execute(); + } +} + +void Chebyshev3D::setuserFunction(const char* name) +{ + // load user macro with function definition and compile it + gUsrFunChebyshev3D = 0; + mUserFunctionName = name; + gSystem->ExpandPathName(mUserFunctionName); + + if (mUserMacro) { + delete mUserMacro; + } + + TString tmpst = mUserFunctionName; + tmpst += "+"; // prepare filename to compile + + if (gROOT->LoadMacro(tmpst.Data())) { + Error("SetUsrFunction", "Failed to load user function from %s\nStop\n", name); + exit(1); + } + + mUserMacro = new TMethodCall(); + tmpst = tmpst.Data() + tmpst.Last('/') + 1; // Strip away any path preceding the macro file name + int dot = tmpst.Last('.'); + + if (dot > 0) { + tmpst.Resize(dot); + } + mUserMacro->InitWithPrototype(tmpst.Data(), "Float_t *,Float_t *"); + long args[2]; + args[0] = (long)mTemporaryCoefficient; + args[1] = (long)mTemporaryUserResults; + mUserMacro->SetParamPtrs(args); +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +void Chebyshev3D::setuserFunction(void (*ptr)(float*, float*)) +{ + // assign user training function + if (mUserMacro) { + delete mUserMacro; + } + mUserMacro = 0; + mUserFunctionName = ""; + gUsrFunChebyshev3D = ptr; +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +void Chebyshev3D::evaluateUserFunction(const Float_t* x, Float_t* res) +{ + // evaluate user function value + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = x[i]; + } + + if (gUsrFunChebyshev3D) { + gUsrFunChebyshev3D(mTemporaryCoefficient, mTemporaryUserResults); + } else { + mUserMacro->Execute(); + } + + for (int i = mOutputArrayDimension; i--;) { + res[i] = mTemporaryUserResults[i]; + } +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +Int_t Chebyshev3D::calculateChebyshevCoefficients(const Float_t* funval, int np, Float_t* outCoefs, Float_t prec) +{ + // Calculate Chebyshev coeffs using precomputed function values at np roots. + // If prec>0, estimate the highest coeff number providing the needed precision + double sm; // do summations in double to minimize the roundoff error + for (int ic = 0; ic < np; ic++) { // compute coeffs + sm = 0; + for (int ir = 0; ir < np; ir++) { + float rt = TMath::Cos(ic * (ir + 0.5) * TMath::Pi() / np); + sm += funval[ir] * rt; + } + outCoefs[ic] = Float_t(sm * ((ic == 0) ? 1. / np : 2. / np)); + } + + if (prec <= 0) { + return np; + } + + sm = 0; + int cfMax = 0; + for (cfMax = np; cfMax--;) { + sm += TMath::Abs(outCoefs[cfMax]); + if (sm >= prec) { + break; + } + } + if (++cfMax == 0) { + cfMax = 1; + } + return cfMax; +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +void Chebyshev3D::defineGrid(Int_t* npoints) +{ + // prepare the grid of Chebyshev roots in each dimension + const int kMinPoints = 1; + int ntot = 0; + mMaxCoefficients = 1; + for (int id = 3; id--;) { + mNumberOfPoints[id] = npoints[id]; + if (mNumberOfPoints[id] < kMinPoints) { + Error("DefineGrid", "at %d-th dimension %d point is requested, at least %d is needed\nStop\n", id, + mNumberOfPoints[id], kMinPoints); + exit(1); + } + ntot += mNumberOfPoints[id]; + mMaxCoefficients *= mNumberOfPoints[id]; + } + printf("Computing Chebyshev nodes on [%2d/%2d/%2d] grid\n", npoints[0], npoints[1], npoints[2]); + if (mTemporaryChebyshevGrid) { + delete[] mTemporaryChebyshevGrid; + } + mTemporaryChebyshevGrid = new Float_t[ntot]; + + int curp = 0; + for (int id = 3; id--;) { + int np = mNumberOfPoints[id]; + mTemporaryChebyshevGridOffs[id] = curp; + for (int ip = 0; ip < np; ip++) { + Float_t x = TMath::Cos(TMath::Pi() * (ip + 0.5) / np); + mTemporaryChebyshevGrid[curp++] = mapToExternal(x, id); + } + } +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +Int_t Chebyshev3D::chebyshevFit() +{ + // prepare parameterization for all output dimensions + int ir = 0; + for (int i = mOutputArrayDimension; i--;) { + ir += chebyshevFit(i); + } + return ir; +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +Int_t Chebyshev3D::chebyshevFit(int dmOut) +{ + // prepare paramaterization of 3D function for dmOut-th dimension + int maxDim = 0; + for (int i = 0; i < 3; i++) { + if (maxDim < mNumberOfPoints[i]) { + maxDim = mNumberOfPoints[i]; + } + } + Float_t* fvals = new Float_t[mNumberOfPoints[0]]; + Float_t* tmpCoef3D = new Float_t[mNumberOfPoints[0] * mNumberOfPoints[1] * mNumberOfPoints[2]]; + 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; + + printf("Dim%d : 00.00%% Done", dmOut); + fflush(stdout); + Chebyshev3DCalc* cheb = getChebyshevCalc(dmOut); + + float ncals2count = mNumberOfPoints[2] * mNumberOfPoints[1] * mNumberOfPoints[0]; + float ncals = 0; + float frac = 0; + float fracStep = 0.001; + + for (int id2 = mNumberOfPoints[2]; id2--;) { + mTemporaryCoefficient[2] = mTemporaryChebyshevGrid[mTemporaryChebyshevGridOffs[2] + id2]; + + for (int id1 = mNumberOfPoints[1]; id1--;) { + mTemporaryCoefficient[1] = mTemporaryChebyshevGrid[mTemporaryChebyshevGridOffs[1] + id1]; + + for (int id0 = mNumberOfPoints[0]; id0--;) { + mTemporaryCoefficient[0] = mTemporaryChebyshevGrid[mTemporaryChebyshevGridOffs[0] + id0]; + evaluateUserFunction(); // compute function values at Chebyshev roots of 0-th dimension + fvals[id0] = mTemporaryUserResults[dmOut]; + float fr = (++ncals) / ncals2count; + if (fr - frac >= fracStep) { + frac = fr; + printf("\b\b\b\b\b\b\b\b\b\b\b"); + printf("%05.2f%% Done", fr * 100); + fflush(stdout); + } + } + int nc = calculateChebyshevCoefficients(fvals, mNumberOfPoints[0], tmpCoef1D, mPrecision); + for (int id0 = mNumberOfPoints[0]; id0--;) { + tmpCoef2D[id1 + id0 * mNumberOfPoints[1]] = tmpCoef1D[id0]; + } + if (ncmax < nc) { + ncmax = nc; // max coefs to be kept in dim0 to guarantee needed precision + } + } + // once each 1d slice of given 2d slice is parametrized, parametrize the Cheb.coeffs + for (int id0 = mNumberOfPoints[0]; id0--;) { + calculateChebyshevCoefficients(tmpCoef2D + id0 * mNumberOfPoints[1], mNumberOfPoints[1], tmpCoef1D, -1); + for (int id1 = mNumberOfPoints[1]; id1--;) { + tmpCoef3D[id2 + mNumberOfPoints[2] * (id1 + id0 * mNumberOfPoints[1])] = tmpCoef1D[id1]; + } + } + } + // now fit the last dimensions Cheb.coefs + for (int id0 = mNumberOfPoints[0]; id0--;) { + for (int id1 = mNumberOfPoints[1]; id1--;) { + calculateChebyshevCoefficients(tmpCoef3D + mNumberOfPoints[2] * (id1 + id0 * mNumberOfPoints[1]), + mNumberOfPoints[2], tmpCoef1D, -1); + for (int id2 = mNumberOfPoints[2]; id2--;) { + tmpCoef3D[id2 + mNumberOfPoints[2] * (id1 + id0 * mNumberOfPoints[1])] = tmpCoef1D[id2]; // store on place + } + } + } + + // now find 2D surface which separates significant coefficients of 3D matrix from nonsignificant ones (up to + // mPrecision) + UShort_t* tmpCoefSurf = new UShort_t[mNumberOfPoints[0] * mNumberOfPoints[1]]; + for (int id0 = mNumberOfPoints[0]; id0--;) { + for (int id1 = mNumberOfPoints[1]; id1--;) { + tmpCoefSurf[id1 + id0 * mNumberOfPoints[1]] = 0; + } + } + Double_t resid = 0; + for (int id0 = mNumberOfPoints[0]; id0--;) { + for (int id1 = mNumberOfPoints[1]; id1--;) { + for (int id2 = mNumberOfPoints[2]; id2--;) { + int id = id2 + mNumberOfPoints[2] * (id1 + id0 * mNumberOfPoints[1]); + Float_t cfa = TMath::Abs(tmpCoef3D[id]); + if (cfa < rTiny) { + tmpCoef3D[id] = 0; + continue; + } // neglect coefs below the threshold + resid += cfa; + if (resid < mPrecision) { + continue; // this coeff is negligible + } + // otherwise go back 1 step + resid -= cfa; + tmpCoefSurf[id1 + id0 * mNumberOfPoints[1]] = id2 + 1; // how many coefs to keep + break; + } + } + } + + // printf("\n\nCoeffs\n"); + // int cnt = 0; + // for (int id0=0;id0 0 && tmpCoefSurf[(id1 - 1) + id0 * mNumberOfPoints[1]] == 0) { + id1--; + } + tmpCols[id0] = id1; + } + // find max significant row + for (int id0 = nRows; id0--;) { + if (tmpCols[id0] > 0) { + break; + } + nRows--; + } + // find max significant column and fill the permanent storage for the max sigificant column of each row + cheb->initRows(nRows); // create needed arrays; + UShort_t* nColsAtRow = cheb->getNumberOfColumnsAtRow(); + UShort_t* colAtRowBg = cheb->GetColAtRowBg(); + int nCols = 0; + int nElemBound2D = 0; + for (int id0 = 0; id0 < nRows; id0++) { + nColsAtRow[id0] = tmpCols[id0]; // number of columns to store for this row + colAtRowBg[id0] = nElemBound2D; // begining of this row in 2D boundary surface + nElemBound2D += tmpCols[id0]; + if (nCols < nColsAtRow[id0]) { + nCols = nColsAtRow[id0]; + } + } + cheb->initCols(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); + UShort_t* coefBound2D0 = cheb->getCoefficientBound2D0(); + UShort_t* coefBound2D1 = cheb->getCoefficientBound2D1(); + mMaxCoefficients = 0; // redefine number of coeffs + for (int id0 = 0; id0 < nRows; id0++) { + int nCLoc = nColsAtRow[id0]; + int col0 = colAtRowBg[id0]; + for (int id1 = 0; id1 < nCLoc; id1++) { + coefBound2D0[col0 + id1] = + tmpCoefSurf[id1 + id0 * mNumberOfPoints[1]]; // number of coefs to store for 3-d dimension + coefBound2D1[col0 + id1] = mMaxCoefficients; + mMaxCoefficients += coefBound2D0[col0 + id1]; + } + } + + // create final compressed 3D matrix for significant coeffs + cheb->initializeCoefficients(mMaxCoefficients); + Float_t* coefs = cheb->getCoefficients(); + int count = 0; + for (int id0 = 0; id0 < nRows; id0++) { + int ncLoc = nColsAtRow[id0]; + int col0 = colAtRowBg[id0]; + for (int id1 = 0; id1 < ncLoc; id1++) { + int ncf2 = coefBound2D0[col0 + id1]; + for (int id2 = 0; id2 < ncf2; id2++) { + coefs[count++] = tmpCoef3D[id2 + mNumberOfPoints[2] * (id1 + id0 * mNumberOfPoints[1])]; + } + } + } + + // printf("\n\nNewSurf\n"); + // for (int id0=0;id0ExpandPathName(strf); + FILE* stream = fopen(strf, append ? "a" : "w"); + saveData(stream); + fclose(stream); +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +void Chebyshev3D::saveData(FILE* stream) const +{ + // writes coefficients data to existing output stream + fprintf(stream, "\n# These are automatically generated data for the Chebyshev interpolation of 3D->%dD function\n", + mOutputArrayDimension); + fprintf(stream, "#\nSTART %s\n", GetName()); + fprintf(stream, "# Dimensionality of the output\n%d\n", mOutputArrayDimension); + fprintf(stream, "# Interpolation abs. precision\n%+.8e\n", mPrecision); + + fprintf(stream, "# Lower boundaries of interpolation region\n"); + for (int i = 0; i < 3; i++) { + fprintf(stream, "%+.8e\n", mMinBoundaries[i]); + } + fprintf(stream, "# Upper boundaries of interpolation region\n"); + for (int i = 0; i < 3; i++) { + fprintf(stream, "%+.8e\n", mMaxBoundaries[i]); + } + fprintf(stream, "# Parameterization for each output dimension follows:\n"); + + for (int i = 0; i < mOutputArrayDimension; i++) { + getChebyshevCalc(i)->saveData(stream); + } + fprintf(stream, "#\nEND %s\n#\n", GetName()); +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ +void Chebyshev3D::invertSign() +{ + // invert the sign of all parameterizations + for (int i = mOutputArrayDimension; i--;) { + Chebyshev3DCalc* par = getChebyshevCalc(i); + int ncf = par->getNumberOfCoefficients(); + float* coefs = par->getCoefficients(); + for (int j = ncf; j--;) { + coefs[j] = -coefs[j]; + } + } +} +#endif + +void Chebyshev3D::loadData(const char* inpFile) +{ + // load coefficients data from txt file + TString strf = inpFile; + gSystem->ExpandPathName(strf); + FILE* stream = fopen(strf.Data(), "r"); + loadData(stream); + fclose(stream); +} + +void Chebyshev3D::loadData(FILE* stream) +{ + // load coefficients data from stream + if (!stream) { + mLogger->Fatal(MESSAGE_ORIGIN, "No stream provided.\nStop"); + } + TString buffs; + Clear(); + Chebyshev3DCalc::readLine(buffs, stream); + if (!buffs.BeginsWith("START")) { + mLogger->Fatal(MESSAGE_ORIGIN, "Expected: \"START \", found \"%s\"\nStop\n", buffs.Data()); + } + SetName(buffs.Data() + buffs.First(' ') + 1); + + Chebyshev3DCalc::readLine(buffs, stream); // N output dimensions + mOutputArrayDimension = buffs.Atoi(); + if (mOutputArrayDimension < 1) { + mLogger->Fatal(MESSAGE_ORIGIN, "Expected: '', found \"%s\"\nStop\n", buffs.Data()); + } + + setDimOut(mOutputArrayDimension); + + Chebyshev3DCalc::readLine(buffs, stream); // Interpolation abs. precision + mPrecision = buffs.Atof(); + if (mPrecision <= 0) { + mLogger->Fatal(MESSAGE_ORIGIN, "Expected: '', found \"%s\"\nStop\n", buffs.Data()); + } + + for (int i = 0; i < 3; i++) { // Lower boundaries of interpolation region + Chebyshev3DCalc::readLine(buffs, stream); + mMinBoundaries[i] = buffs.Atof(); + } + + for (int i = 0; i < 3; i++) { // Upper boundaries of interpolation region + Chebyshev3DCalc::readLine(buffs, stream); + mMaxBoundaries[i] = buffs.Atof(); + } + prepareBoundaries(mMinBoundaries, mMaxBoundaries); + + // data for each output dimension + for (int i = 0; i < mOutputArrayDimension; i++) { + getChebyshevCalc(i)->loadData(stream); + } + + // check end_of_data record + Chebyshev3DCalc::readLine(buffs, stream); + if (!buffs.BeginsWith("END") || !buffs.Contains(GetName())) { + mLogger->Fatal(MESSAGE_ORIGIN, "Expected \"END %s\", found \"%s\".\nStop\n", GetName(), buffs.Data()); + } +} + +void Chebyshev3D::setDimOut(const int d) +{ + // init output dimensions + mOutputArrayDimension = d; + if (mTemporaryUserResults) { + delete mTemporaryUserResults; + } + mTemporaryUserResults = new Float_t[mOutputArrayDimension]; + mChebyshevParameter.Delete(); + for (int i = 0; i < d; i++) { + mChebyshevParameter.AddAtAndExpand(new Chebyshev3DCalc(), i); + } +} + +void Chebyshev3D::shiftBound(int id, float dif) +{ + // modify the bounds of the grid + if (id < 0 || id > 2) { + printf("Maximum 3 dimensions are supported\n"); + return; + } + mMinBoundaries[id] += dif; + mMaxBoundaries[id] += dif; + mBoundaryMappingOffset[id] += dif; +} + +#ifdef _INC_CREATION_Chebyshev3D_ +TH1* Chebyshev3D::TestRMS(int idim, int npoints, TH1* histo) +{ + // fills the difference between the original function and parameterization (for idim-th component of the output) + // to supplied histogram. Calculations are done in npoints random points. + // If the hostgram was not supplied, it will be created. It is up to the user to delete it! + if (!mUserMacro) { + printf("No user function is set\n"); + return 0; + } + if (!histo) { + histo = new TH1D(GetName(), "Control: Function - Parametrization", 100, -2 * mPrecision, 2 * mPrecision); + } + for (int ip = npoints; ip--;) { + gRandom->RndmArray(3, (Float_t*)mTemporaryCoefficient); + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mMinBoundaries[i] + mTemporaryCoefficient[i] * (mMaxBoundaries[i] - mMinBoundaries[i]); + } + evaluateUserFunction(); + Float_t valFun = mTemporaryUserResults[idim]; + Eval(mTemporaryCoefficient, mTemporaryUserResults); + Float_t valPar = mTemporaryUserResults[idim]; + histo->Fill(valFun - valPar); + } + return histo; +} +#endif + +#ifdef _INC_CREATION_Chebyshev3D_ + +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; + const float kScl[9] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 }; + + const float sclDim[2] = { 0.001, 0.999 }; + const int compDim[3][2] = { { 1, 2 }, { 2, 0 }, { 0, 1 } }; + static float xyz[3]; + Int_t npdTst[3] = { npd1, npd2, npd3 }; + + for (int i = 3; i--;) { + for (int j = 3; j--;) { + gridBC[i][j] = -1; + } + } + + for (int idim = 0; idim < 3; idim++) { + float dimMN = mMinBoundaries[idim] + sclDim[0] * (mMaxBoundaries[idim] - mMinBoundaries[idim]); + float dimMX = mMinBoundaries[idim] + sclDim[1] * (mMaxBoundaries[idim] - mMinBoundaries[idim]); + + int id1 = compDim[idim][0]; // 1st fixed dim + int id2 = compDim[idim][1]; // 2nd fixed dim + for (int i1 = 0; i1 < kScp; i1++) { + 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 + for (int ib = 0; ib < 3; ib++) { + if (npt[ib] > gridBC[ib][idim]) { + gridBC[ib][idim] = npt[ib]; + } + } + } + } + } +} + +// void Chebyshev3D::estimateNumberOfPoints(float Prec, int gridBC[3][3]) +// { +// // Estimate number of points to generate a training data +// +// const float sclA[9] = {0.1, 0.5, 0.9, 0.1, 0.5, 0.9, 0.1, 0.5, 0.9} ; +// const float sclB[9] = {0.1, 0.1, 0.1, 0.5, 0.5, 0.5, 0.9, 0.9, 0.9} ; +// const float sclDim[2] = {0.01,0.99}; +// const int compDim[3][2] = { {1,2}, {2,0}, {0,1} }; +// static float xyz[3]; +// +// for (int i=3;i--;)for (int j=3;j--;) gridBC[i][j] = -1; +// +// for (int idim=0;idim<3;idim++) { +// float dimMN = mMinBoundaries[idim] + sclDim[0]*(mMaxBoundaries[idim]-mMinBoundaries[idim]); +// float dimMX = mMinBoundaries[idim] + sclDim[1]*(mMaxBoundaries[idim]-mMinBoundaries[idim]); +// +// for (int it=0;it<9;it++) { // test in 9 points +// int id1 = compDim[idim][0]; // 1st fixed dim +// int id2 = compDim[idim][1]; // 2nd fixed dim +// xyz[ id1 ] = mMinBoundaries[id1] + sclA[it]*( mMaxBoundaries[id1]-mMinBoundaries[id1] ); +// xyz[ id2 ] = mMinBoundaries[id2] + sclB[it]*( mMaxBoundaries[id2]-mMinBoundaries[id2] ); +// +// int* npt = getNcNeeded(xyz,idim, dimMN,dimMX, Prec); // npoints for Bx,By,Bz +// for (int ib=0;ib<3;ib++) if (npt[ib]>gridBC[ib][idim]) gridBC[ib][idim] = npt[ib];//+2; +// +// } +// } +// } +// +// +// int* Chebyshev3D::getNcNeeded(float xyz[3],int DimVar, float mn,float mx, float prec) +// { +// // estimate needed number of chebyshev coefs for given function description in DimVar dimension +// // The values for two other dimensions must be set beforehand +// +// static int curNC[3]; +// static int retNC[3]; +// const int kMaxPoint = 400; +// float* gridVal = new float[3*kMaxPoint]; +// float* coefs = new float[3*kMaxPoint]; +// +// float scale = mx-mn; +// float offs = mn + scale/2.0; +// scale = 2./scale; +// +// int curNP; +// int maxNC=-1; +// int maxNCPrev=-1; +// for (int i=0;i<3;i++) retNC[i] = -1; +// for (int i=0;i<3;i++) mTemporaryCoefficient[i] = xyz[i]; +// +// for (curNP=3; curNP3 && (maxNC-maxNCPrev)<1 ) break; +// maxNCPrev = maxNC; +// +// } +// delete[] gridVal; +// delete[] coefs; +// return retNC; +// } + +int* Chebyshev3D::getNcNeeded(float xyz[3], int DimVar, float mn, float mx, float prec, Int_t npCheck) +{ + // estimate needed number of chebyshev coefs for given function description in DimVar dimension + // The values for two other dimensions must be set beforehand + static int retNC[3]; + static int npChLast = 0; + static float* gridVal = 0, *coefs = 0; + if (npCheck < 3) { + npCheck = 3; + } + if (npChLast < npCheck) { + if (gridVal) { + delete[] gridVal; + } + if (coefs) { + delete[] coefs; + } + gridVal = new float[3 * npCheck]; + coefs = new float[3 * npCheck]; + npChLast = npCheck; + } + float scale = mx - mn; + float offs = mn + scale / 2.0; + scale = 2. / scale; + + for (int i = 0; i < 3; i++) { + mTemporaryCoefficient[i] = xyz[i]; + } + for (int i = 0; i < npCheck; i++) { + mTemporaryCoefficient[DimVar] = + TMath::Cos(TMath::Pi() * (i + 0.5) / npCheck) / scale + offs; // map to requested interval + evaluateUserFunction(); + for (int ib = 3; ib--;) { + gridVal[ib * npCheck + i] = mTemporaryUserResults[ib]; + } + } + for (int ib = 0; ib < 3; ib++) { + retNC[ib] = + Chebyshev3D::calculateChebyshevCoefficients(&gridVal[ib * npCheck], npCheck, &coefs[ib * npCheck], prec); + } + return retNC; +} + +#endif diff --git a/field/Chebyshev3D.h b/field/Chebyshev3D.h new file mode 100644 index 0000000000000..db48d05d38e41 --- /dev/null +++ b/field/Chebyshev3D.h @@ -0,0 +1,396 @@ +/// \file Cheb3D.h +/// \brief Definition of the Cheb3D class +/// \author ruben.shahoyan@cern.ch 09/09/2006 + +#ifndef ALICEO2_FIELD_CHEBYSHEV3D_H_ +#define ALICEO2_FIELD_CHEBYSHEV3D_H_ + +#include +#include +#include "Chebyshev3DCalc.h" + +class TString; +class TSystem; +class TRandom; +class TH1; +class TMethodCall; +class TRandom; +class TROOT; +class stdio; +class FairLogger; + +namespace AliceO2 { +namespace Field { + +/// 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 +/// coefficients needed to guarantee the requested precision are kept. The user-callable methods are: +/// To create the interpolation use: +/// Cheb3D(const char* funName, // name of the file with user function or +/// Cheb3D(void (*ptr)(float*,float*) // pointer on the user function +/// \param Int_t DimOut dimensionality of the function's output +/// \param Float_t *bmin lower 3D bounds of interpolation domain +/// \param Float_t *bmax upper 3D bounds of interpolation domain +/// \param Int_t *npoints number of points in each of 3 input dimension, defining the interpolation grid +/// \param Float_t prec=1E-6); requested max.absolute difference between the interpolation and any point on grid +/// To test obtained parameterization use the method TH1* TestRMS(int idim,int npoints = 1000,TH1* histo=0); +/// it will compare the user output of the user function and interpolation for idim-th output dimension and +/// fill the difference in the supplied histogram. If no histogram is supplied, it will be created. +/// To save the interpolation data: saveData(const char* filename, Bool_t append ) write text file with data. +/// If append is kTRUE and the output file already exists, data will be added in the end of the file. +/// Alternatively, saveData(FILE* stream) will write the data to already existing stream. +/// To read back already stored interpolation use either the constructor Chebyshev3D(const char* inpFile); +/// or the default constructor Chebyshev3D() followed by Chebyshev3D::loadData(const char* inpFile); +/// To compute the interpolation use Eval(float* par,float *res) method, with par being 3D vector of arguments +/// (inside the validity region) and res is the array of DimOut elements for the output. +/// If only one component (say, idim-th) of the output is needed, use faster Float_t Eval(Float_t *par,int idim) method +/// void Print(option="") will print the name, the ranges of validity and the absolute precision of the +/// parameterization. Option "l" will also print the information about the number of coefficients for each output +/// dimension. +/// NOTE: during the evaluation no check is done for parameter vector being outside the interpolation region. +/// If there is such a risk, use Bool_t isInside(float *par) method. Chebyshev parameterization is not +/// good for extrapolation! +/// For the properties of Chebyshev parameterization see: +/// H.Wind, CERN EP Internal Report, 81-12/Rev. +class Chebyshev3D : public TNamed { +public: + Chebyshev3D(); + Chebyshev3D(const Chebyshev3D& src); + Chebyshev3D(const char* inpFile); + Chebyshev3D(FILE* stream); + +#ifdef _INC_CREATION_Chebyshev3D_ + /// Construct the parameterization for the function + /// \param funName : name of the file containing the function: void funName(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 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); + /// 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 + /// \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 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); + /// 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 + /// \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 npX : array of 3 elements with the number of points to compute in each dimension for 1st component + /// \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); + /// 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); +#endif + + ~Chebyshev3D() + { + Clear(); + } + + Chebyshev3D& operator=(const Chebyshev3D& rhs); + void Eval(const Float_t* par, Float_t* res); + Float_t Eval(const Float_t* par, int idim); + void Eval(const Double_t* par, Double_t* res); + Double_t Eval(const Double_t* par, int idim); + + void evaluateDerivative(int dimd, const Float_t* par, Float_t* res); + void evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, Float_t* res); + Float_t evaluateDerivative(int dimd, const Float_t* par, int idim); + Float_t evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, int idim); + void evaluateDerivative3D(const Float_t* par, Float_t dbdr[3][3]); + void evaluateDerivative3D2(const Float_t* par, Float_t dbdrdr[3][3][3]); + void Print(const Option_t* opt = "") const; + Bool_t isInside(const Float_t* par) const; + Bool_t isInside(const Double_t* par) const; + + Chebyshev3DCalc* getChebyshevCalc(int i) const + { + return (Chebyshev3DCalc*)mChebyshevParameter.UncheckedAt(i); + } + + Float_t getBoundMin(int i) const + { + return mMinBoundaries[i]; + } + + Float_t getBoundMax(int i) const + { + return mMaxBoundaries[i]; + } + + Float_t* getBoundMin() const + { + return (float*)mMinBoundaries; + } + + Float_t* getBoundMax() const + { + return (float*)mMaxBoundaries; + } + + Float_t getPrecision() const + { + return mPrecision; + } + + void shiftBound(int id, float dif); + + void loadData(const char* inpFile); + void loadData(FILE* stream); + +#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); + void saveData(const char* outfile, Bool_t append = kFALSE) const; + void saveData(FILE* stream = stdout) const; + + void setuserFunction(const char* name); + void setuserFunction(void (*ptr)(float*, float*)); + void evaluateUserFunction(const Float_t* x, Float_t* res); + TH1* TestRMS(int idim, int npoints = 1000, TH1* histo = 0); + static Int_t calculateChebyshevCoefficients(const Float_t* funval, int np, Float_t* outCoefs, Float_t prec = -1); +#endif + +protected: + void Clear(const Option_t* option = ""); + void setDimOut(const int d); + void prepareBoundaries(const Float_t* bmin, const Float_t* bmax); + +#ifdef _INC_CREATION_Chebyshev3D_ + void evaluateUserFunction(); + void defineGrid(Int_t* npoints); + Int_t chebyshevFit(); // fit all output dimensions + Int_t chebyshevFit(int dmOut); + void setPrecision(float prec) + { + mPrecision = prec; + } +#endif + + Float_t mapToInternal(Float_t x, Int_t d) const; // map x to [-1:1] + Float_t mapToExternal(Float_t x, Int_t d) const + { + return x / mBoundaryMappingScale[d] + mBoundaryMappingOffset[d]; + } // map from [-1:1] to x + Double_t mapToInternal(Double_t x, Int_t d) const; // map x to [-1:1] + Double_t mapToExternal(Double_t x, Int_t d) const + { + return x / mBoundaryMappingScale[d] + mBoundaryMappingOffset[d]; + } // map from [-1:1] to x + +protected: + 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 + + Int_t mMaxCoefficients; //! max possible number of coefs per parameterization + Int_t mNumberOfPoints[3]; //! number of used points in each dimension + Float_t mTemporaryCoefficient[3]; //! temporary vector for coefs calculation + Float_t* mTemporaryUserResults; //! temporary vector for results of user function calculation + Float_t* mTemporaryChebyshevGrid; //! temporary buffer for Chebyshef roots grid + Int_t mTemporaryChebyshevGridOffs[3]; //! start of grid for each dimension + TString mUserFunctionName; //! name of user macro containing the function of "void (*fcn)(float*,float*)" format + TMethodCall* mUserMacro; //! Pointer to MethodCall for function from user macro + FairLogger* mLogger; //! + + ClassDef(Chebyshev3D, 1) // Chebyshev parametrization for 3D->N function +}; + +/// Checks if the point is inside of the fitted box +inline Bool_t Chebyshev3D::isInside(const Float_t* par) const +{ + for (int i = 3; i--;) { + if (mMinBoundaries[i] > par[i] || par[i] > mMaxBoundaries[i]) { + return kFALSE; + } + } + return kTRUE; +} + +/// Checks if the point is inside of the fitted box +inline Bool_t Chebyshev3D::isInside(const Double_t* par) const +{ + for (int i = 3; i--;) { + if (mMinBoundaries[i] > par[i] || par[i] > mMaxBoundaries[i]) { + return kFALSE; + } + } + return kTRUE; +} + +/// Evaluates Chebyshev parameterization for 3d->DimOut function +inline void Chebyshev3D::Eval(const Float_t* par, Float_t* res) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + for (int i = mOutputArrayDimension; i--;) { + res[i] = getChebyshevCalc(i)->Eval(mTemporaryCoefficient); + } +} + +/// Evaluates Chebyshev parameterization for 3d->DimOut function +inline void Chebyshev3D::Eval(const Double_t* par, Double_t* res) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + for (int i = mOutputArrayDimension; i--;) { + res[i] = getChebyshevCalc(i)->Eval(mTemporaryCoefficient); + } +} + +/// Evaluates Chebyshev parameterization for idim-th output dimension of 3d->DimOut function +inline Double_t Chebyshev3D::Eval(const Double_t* par, int idim) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + return getChebyshevCalc(idim)->Eval(mTemporaryCoefficient); +} + +/// Evaluates Chebyshev parameterization for idim-th output dimension of 3d->DimOut function +inline Float_t Chebyshev3D::Eval(const Float_t* par, int idim) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + return getChebyshevCalc(idim)->Eval(mTemporaryCoefficient); +} + +/// Returns the gradient matrix +inline void Chebyshev3D::evaluateDerivative3D(const Float_t* par, Float_t dbdr[3][3]) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + for (int ib = 3; ib--;) { + for (int id = 3; id--;) { + dbdr[ib][id] = getChebyshevCalc(ib)->evaluateDerivative(id, mTemporaryCoefficient) * mBoundaryMappingScale[id]; + } + } +} + +/// Returns the gradient matrix +inline void Chebyshev3D::evaluateDerivative3D2(const Float_t* par, Float_t dbdrdr[3][3][3]) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + for (int ib = 3; ib--;) { + for (int id = 3; id--;) { + for (int id1 = 3; id1--;) { + dbdrdr[ib][id][id1] = getChebyshevCalc(ib)->evaluateDerivative2(id, id1, mTemporaryCoefficient) * + mBoundaryMappingScale[id] * mBoundaryMappingScale[id1]; + } + } + } +} + +// Evaluates Chebyshev parameterization derivative for 3d->DimOut function +inline void Chebyshev3D::evaluateDerivative(int dimd, const Float_t* par, Float_t* res) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + for (int i = mOutputArrayDimension; i--;) { + res[i] = getChebyshevCalc(i)->evaluateDerivative(dimd, mTemporaryCoefficient) * mBoundaryMappingScale[dimd]; + }; +} + +// Evaluates Chebyshev parameterization 2nd derivative over dimd1 and dimd2 dimensions for 3d->DimOut function +inline void Chebyshev3D::evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, Float_t* res) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + for (int i = mOutputArrayDimension; i--;) { + res[i] = getChebyshevCalc(i)->evaluateDerivative2(dimd1, dimd2, mTemporaryCoefficient) * + mBoundaryMappingScale[dimd1] * mBoundaryMappingScale[dimd2]; + } +} + +/// Evaluates Chebyshev parameterization derivative over dimd dimention for idim-th output dimension of 3d->DimOut +/// function +inline Float_t Chebyshev3D::evaluateDerivative(int dimd, const Float_t* par, int idim) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + return getChebyshevCalc(idim)->evaluateDerivative(dimd, mTemporaryCoefficient) * mBoundaryMappingScale[dimd]; +} + +/// Evaluates Chebyshev parameterization 2ns derivative over dimd1 and dimd2 dimensions for idim-th output dimension of +/// 3d->DimOut function +inline Float_t Chebyshev3D::evaluateDerivative2(int dimd1, int dimd2, const Float_t* par, int idim) +{ + for (int i = 3; i--;) { + mTemporaryCoefficient[i] = mapToInternal(par[i], i); + } + return getChebyshevCalc(idim)->evaluateDerivative2(dimd1, dimd2, mTemporaryCoefficient) * + mBoundaryMappingScale[dimd1] * mBoundaryMappingScale[dimd2]; +} + +/// Μaps x to [-1:1] +inline Float_t Chebyshev3D::mapToInternal(Float_t x, Int_t d) const +{ +#ifdef _BRING_TO_BOUNDARY_ + T res = (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d]; + if (res < -1) { + return -1; + } + if (res > 1) { + return 1; + } + return res; +#else + return (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d]; +#endif +} + +/// Μaps x to [-1:1] +inline Double_t Chebyshev3D::mapToInternal(Double_t x, Int_t d) const +{ +#ifdef _BRING_TO_BOUNDARY_ + T res = (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d]; + if (res < -1) { + return -1; + } + if (res > 1) { + return 1; + } + return res; +#else + return (x - mBoundaryMappingOffset[d]) * mBoundaryMappingScale[d]; +#endif +} +} +} + +#endif diff --git a/field/Chebyshev3DCalc.cxx b/field/Chebyshev3DCalc.cxx new file mode 100644 index 0000000000000..651b38caa7a9e --- /dev/null +++ b/field/Chebyshev3DCalc.cxx @@ -0,0 +1,508 @@ +/// \file Cheb3DCalc.cxx +/// \brief Implementation of the Cheb3DCalc class +/// \author ruben.shahoyan@cern.ch 09/09/2006 + +#include +#include +#include "Chebyshev3DCalc.h" + +using namespace AliceO2::Field; + +ClassImp(Chebyshev3DCalc) + +Chebyshev3DCalc::Chebyshev3DCalc() + : mNumberOfCoefficients(0), + mNumberOfRows(0), + mNumberOfColumns(0), + mNumberOfElementsBound2D(0), + mNumberOfColumnsAtRow(0), + mColumnAtRowBeginning(0), + mCoefficientBound2D0(0), + mCoefficientBound2D1(0), + mCoefficients(0), + mTemporaryCoefficients2D(0), + mTemporaryCoefficients1D(0) +{ +} + +Chebyshev3DCalc::Chebyshev3DCalc(const Chebyshev3DCalc& src) + : TNamed(src), + mNumberOfCoefficients(src.mNumberOfCoefficients), + mNumberOfRows(src.mNumberOfRows), + mNumberOfColumns(src.mNumberOfColumns), + mNumberOfElementsBound2D(src.mNumberOfElementsBound2D), + mNumberOfColumnsAtRow(0), + mColumnAtRowBeginning(0), + mCoefficientBound2D0(0), + mCoefficientBound2D1(0), + mCoefficients(0), + mTemporaryCoefficients2D(0), + mTemporaryCoefficients1D(0) +{ + if (src.mNumberOfColumnsAtRow) { + mNumberOfColumnsAtRow = new UShort_t[mNumberOfRows]; + for (int i = mNumberOfRows; i--;) { + mNumberOfColumnsAtRow[i] = src.mNumberOfColumnsAtRow[i]; + } + } + if (src.mColumnAtRowBeginning) { + mColumnAtRowBeginning = new UShort_t[mNumberOfRows]; + for (int i = mNumberOfRows; i--;) { + mColumnAtRowBeginning[i] = src.mColumnAtRowBeginning[i]; + } + } + if (src.mCoefficientBound2D0) { + mCoefficientBound2D0 = new UShort_t[mNumberOfElementsBound2D]; + for (int i = mNumberOfElementsBound2D; i--;) { + mCoefficientBound2D0[i] = src.mCoefficientBound2D0[i]; + } + } + if (src.mCoefficientBound2D1) { + mCoefficientBound2D1 = new UShort_t[mNumberOfElementsBound2D]; + for (int i = mNumberOfElementsBound2D; i--;) { + mCoefficientBound2D1[i] = src.mCoefficientBound2D1[i]; + } + } + if (src.mCoefficients) { + mCoefficients = new Float_t[mNumberOfCoefficients]; + for (int i = mNumberOfCoefficients; i--;) { + mCoefficients[i] = src.mCoefficients[i]; + } + } + if (src.mTemporaryCoefficients2D) { + mTemporaryCoefficients2D = new Float_t[mNumberOfColumns]; + } + if (src.mTemporaryCoefficients1D) { + mTemporaryCoefficients1D = new Float_t[mNumberOfRows]; + } +} + +Chebyshev3DCalc::Chebyshev3DCalc(FILE* stream) + : mNumberOfCoefficients(0), + mNumberOfRows(0), + mNumberOfColumns(0), + mNumberOfElementsBound2D(0), + mNumberOfColumnsAtRow(0), + mColumnAtRowBeginning(0), + mCoefficientBound2D0(0), + mCoefficientBound2D1(0), + mCoefficients(0), + mTemporaryCoefficients2D(0), + mTemporaryCoefficients1D(0) +{ + loadData(stream); +} + +Chebyshev3DCalc& Chebyshev3DCalc::operator=(const Chebyshev3DCalc& rhs) +{ + if (this != &rhs) { + Clear(); + SetName(rhs.GetName()); + SetTitle(rhs.GetTitle()); + mNumberOfCoefficients = rhs.mNumberOfCoefficients; + mNumberOfRows = rhs.mNumberOfRows; + mNumberOfColumns = rhs.mNumberOfColumns; + if (rhs.mNumberOfColumnsAtRow) { + mNumberOfColumnsAtRow = new UShort_t[mNumberOfRows]; + for (int i = mNumberOfRows; i--;) { + mNumberOfColumnsAtRow[i] = rhs.mNumberOfColumnsAtRow[i]; + } + } + if (rhs.mColumnAtRowBeginning) { + mColumnAtRowBeginning = new UShort_t[mNumberOfRows]; + for (int i = mNumberOfRows; i--;) { + mColumnAtRowBeginning[i] = rhs.mColumnAtRowBeginning[i]; + } + } + if (rhs.mCoefficientBound2D0) { + mCoefficientBound2D0 = new UShort_t[mNumberOfElementsBound2D]; + for (int i = mNumberOfElementsBound2D; i--;) { + mCoefficientBound2D0[i] = rhs.mCoefficientBound2D0[i]; + } + } + if (rhs.mCoefficientBound2D1) { + mCoefficientBound2D1 = new UShort_t[mNumberOfElementsBound2D]; + for (int i = mNumberOfElementsBound2D; i--;) { + mCoefficientBound2D1[i] = rhs.mCoefficientBound2D1[i]; + } + } + if (rhs.mCoefficients) { + mCoefficients = new Float_t[mNumberOfCoefficients]; + for (int i = mNumberOfCoefficients; i--;) { + mCoefficients[i] = rhs.mCoefficients[i]; + } + } + if (rhs.mTemporaryCoefficients2D) { + mTemporaryCoefficients2D = new Float_t[mNumberOfColumns]; + } + if (rhs.mTemporaryCoefficients1D) { + mTemporaryCoefficients1D = new Float_t[mNumberOfRows]; + } + } + return *this; +} + +void Chebyshev3DCalc::Clear(const Option_t*) +{ + if (mTemporaryCoefficients2D) { + delete[] mTemporaryCoefficients2D; + mTemporaryCoefficients2D = 0; + } + if (mTemporaryCoefficients1D) { + delete[] mTemporaryCoefficients1D; + mTemporaryCoefficients1D = 0; + } + if (mCoefficients) { + delete[] mCoefficients; + mCoefficients = 0; + } + if (mCoefficientBound2D0) { + delete[] mCoefficientBound2D0; + mCoefficientBound2D0 = 0; + } + if (mCoefficientBound2D1) { + delete[] mCoefficientBound2D1; + mCoefficientBound2D1 = 0; + } + if (mNumberOfColumnsAtRow) { + delete[] mNumberOfColumnsAtRow; + mNumberOfColumnsAtRow = 0; + } + if (mColumnAtRowBeginning) { + delete[] mColumnAtRowBeginning; + mColumnAtRowBeginning = 0; + } +} + +void Chebyshev3DCalc::Print(const Option_t*) const +{ + printf("Chebyshev parameterization data %s for 3D->1 function.\n", GetName()); + int nmax3d = 0; + for (int i = mNumberOfElementsBound2D; i--;) { + if (mCoefficientBound2D0[i] > nmax3d) { + nmax3d = mCoefficientBound2D0[i]; + } + } + printf("%d coefficients in %dx%dx%d matrix\n", mNumberOfCoefficients, mNumberOfRows, mNumberOfColumns, nmax3d); +} + +Float_t Chebyshev3DCalc::evaluateDerivative(int dim, const Float_t* par) const +{ + int ncfRC; + for (int id0 = mNumberOfRows; id0--;) { + int nCLoc = mNumberOfColumnsAtRow[id0]; // number of significant coefs on this row + if (!nCLoc) { + mTemporaryCoefficients1D[id0] = 0; + continue; + } + // + int col0 = mColumnAtRowBeginning[id0]; // beginning of local column in the 2D boundary matrix + for (int id1 = nCLoc; id1--;) { + int id = id1 + col0; + if (!(ncfRC = mCoefficientBound2D0[id])) { + mTemporaryCoefficients2D[id1] = 0; + continue; + } + if (dim == 2) { + mTemporaryCoefficients2D[id1] = + chebyshevEvaluation1Derivative(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC); + } else { + mTemporaryCoefficients2D[id1] = chebyshevEvaluation1D(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC); + } + } + if (dim == 1) { + mTemporaryCoefficients1D[id0] = chebyshevEvaluation1Derivative(par[1], mTemporaryCoefficients2D, nCLoc); + } else { + mTemporaryCoefficients1D[id0] = chebyshevEvaluation1D(par[1], mTemporaryCoefficients2D, nCLoc); + } + } + return (dim == 0) ? chebyshevEvaluation1Derivative(par[0], mTemporaryCoefficients1D, mNumberOfRows) + : chebyshevEvaluation1D(par[0], mTemporaryCoefficients1D, mNumberOfRows); +} + +Float_t Chebyshev3DCalc::evaluateDerivative2(int dim1, int dim2, const Float_t* par) const +{ + Bool_t same = dim1 == dim2; + int ncfRC; + for (int id0 = mNumberOfRows; id0--;) { + int nCLoc = mNumberOfColumnsAtRow[id0]; // number of significant coefs on this row + if (!nCLoc) { + mTemporaryCoefficients1D[id0] = 0; + continue; + } + int col0 = mColumnAtRowBeginning[id0]; // beginning of local column in the 2D boundary matrix + for (int id1 = nCLoc; id1--;) { + int id = id1 + col0; + if (!(ncfRC = mCoefficientBound2D0[id])) { + mTemporaryCoefficients2D[id1] = 0; + continue; + } + if (dim1 == 2 || dim2 == 2) { + mTemporaryCoefficients2D[id1] = + same ? chebyshevEvaluation1Derivative2(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC) + : chebyshevEvaluation1Derivative(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC); + } else { + mTemporaryCoefficients2D[id1] = chebyshevEvaluation1D(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC); + } + } + if (dim1 == 1 || dim2 == 1) { + mTemporaryCoefficients1D[id0] = same ? chebyshevEvaluation1Derivative2(par[1], mTemporaryCoefficients2D, nCLoc) + : chebyshevEvaluation1Derivative(par[1], mTemporaryCoefficients2D, nCLoc); + } else { + mTemporaryCoefficients1D[id0] = chebyshevEvaluation1D(par[1], mTemporaryCoefficients2D, nCLoc); + } + } + return (dim1 == 0 || dim2 == 0) + ? (same ? chebyshevEvaluation1Derivative2(par[0], mTemporaryCoefficients1D, mNumberOfRows) + : chebyshevEvaluation1Derivative(par[0], mTemporaryCoefficients1D, mNumberOfRows)) + : chebyshevEvaluation1D(par[0], mTemporaryCoefficients1D, mNumberOfRows); +} + +#ifdef _INC_CREATION_ALICHEB3D_ +void Chebyshev3DCalc::saveData(const char* outfile, Bool_t append) const +{ + TString strf = outfile; + gSystem->ExpandPathName(strf); + FILE* stream = fopen(strf, append ? "a" : "w"); + saveData(stream); + fclose(stream); +} +#endif + +#ifdef _INC_CREATION_ALICHEB3D_ +void Chebyshev3DCalc::saveData(FILE* stream) const +{ + fprintf(stream, "#\nSTART %s\n", GetName()); + fprintf(stream, "# Number of rows\n%d\n", mNumberOfRows); + + fprintf(stream, "# Number of columns per row\n"); + for (int i = 0; i < mNumberOfRows; i++) { + fprintf(stream, "%d\n", mNumberOfColumnsAtRow[i]); + } + + fprintf(stream, "# Number of Coefs in each significant block of third dimension\n"); + for (int i = 0; i < mNumberOfElementsBound2D; i++) { + fprintf(stream, "%d\n", mCoefficientBound2D0[i]); + } + + fprintf(stream, "# Coefficients\n"); + for (int i = 0; i < mNumberOfCoefficients; i++) { + fprintf(stream, "%+.8e\n", mCoefficients[i]); + } + fprintf(stream, "END %s\n", GetName()); +} +#endif + +void Chebyshev3DCalc::loadData(FILE* stream) +{ + if (!stream) { + Error("LoadData", "No stream provided.\nStop"); + exit(1); + } + TString buffs; + Clear(); + readLine(buffs, stream); + + if (!buffs.BeginsWith("START")) { + Error("LoadData", "Expected: \"START \", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + if (buffs.First(' ') > 0) { + SetName(buffs.Data() + buffs.First(' ') + 1); + } + + readLine(buffs, stream); // NRows + mNumberOfRows = buffs.Atoi(); + + if (mNumberOfRows < 1) { + Error("LoadData", "Expected: '', found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + mNumberOfColumns = 0; + mNumberOfElementsBound2D = 0; + initializeRows(mNumberOfRows); + + for (int id0 = 0; id0 < mNumberOfRows; id0++) { + readLine(buffs, stream); // n.cols at this row + mNumberOfColumnsAtRow[id0] = buffs.Atoi(); + mColumnAtRowBeginning[id0] = mNumberOfElementsBound2D; // begining of this row in 2D boundary surface + mNumberOfElementsBound2D += mNumberOfColumnsAtRow[id0]; + if (mNumberOfColumns < mNumberOfColumnsAtRow[id0]) { + mNumberOfColumns = mNumberOfColumnsAtRow[id0]; + } + } + initializeColumns(mNumberOfColumns); + + mNumberOfCoefficients = 0; + initializeElementBound2D(mNumberOfElementsBound2D); + + for (int i = 0; i < mNumberOfElementsBound2D; i++) { + readLine(buffs, stream); // n.coeffs at 3-d dimension for the given column/row + mCoefficientBound2D0[i] = buffs.Atoi(); + mCoefficientBound2D1[i] = mNumberOfCoefficients; + 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(); + } + // check end_of_data record + readLine(buffs, stream); + if (!buffs.BeginsWith("END") || !buffs.Contains(GetName())) { + Error("LoadData", "Expected \"END %s\", found \"%s\".\nStop\n", GetName(), buffs.Data()); + exit(1); + } +} + +void Chebyshev3DCalc::readLine(TString& str, FILE* stream) +{ + while (str.Gets(stream)) { + str = str.Strip(TString::kBoth, ' '); + if (str.IsNull() || str.BeginsWith("#")) { + continue; + } + return; + } + fprintf(stderr, "Chebyshev3D::readLine: Failed to read from stream.\nStop"); + exit(1); // normally, should not reach here +} + +void Chebyshev3DCalc::initializeRows(int nr) +{ + if (mNumberOfColumnsAtRow) { + delete[] mNumberOfColumnsAtRow; + } + if (mColumnAtRowBeginning) { + delete[] mColumnAtRowBeginning; + } + if (mTemporaryCoefficients1D) { + delete[] mTemporaryCoefficients1D; + } + 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; + } +} + +void Chebyshev3DCalc::initializeColumns(int nc) +{ + mNumberOfColumns = nc; + if (mTemporaryCoefficients2D) { + delete[] mTemporaryCoefficients2D; + } + mTemporaryCoefficients2D = new Float_t[mNumberOfColumns]; +} + +void Chebyshev3DCalc::initializeElementBound2D(int ne) +{ + if (mCoefficientBound2D0) { + delete[] mCoefficientBound2D0; + } + if (mCoefficientBound2D1) { + delete[] mCoefficientBound2D1; + } + mNumberOfElementsBound2D = ne; + mCoefficientBound2D0 = new UShort_t[mNumberOfElementsBound2D]; + mCoefficientBound2D1 = new UShort_t[mNumberOfElementsBound2D]; + for (int i = mNumberOfElementsBound2D; i--;) { + mCoefficientBound2D0[i] = mCoefficientBound2D1[i] = 0; + } +} + +void Chebyshev3DCalc::initializeCoefficients(int nc) +{ + if (mCoefficients) { + delete[] mCoefficients; + } + mNumberOfCoefficients = nc; + mCoefficients = new Float_t[mNumberOfCoefficients]; + for (int i = mNumberOfCoefficients; i--;) { + mCoefficients[i] = 0.0; + } +} + +Float_t Chebyshev3DCalc::chebyshevEvaluation1Derivative(Float_t x, const Float_t* array, int ncf) +{ + if (--ncf < 1) { + return 0; + } + Float_t b0, b1, b2; + Float_t x2 = x + x; + b1 = b2 = 0; + float dcf0 = 0, dcf1, dcf2 = 0; + b0 = dcf1 = 2 * ncf * array[ncf]; + if (!(--ncf)) { + return b0 / 2; + } + + for (int i = ncf; i--;) { + b2 = b1; + b1 = b0; + dcf0 = dcf2 + 2 * (i + 1) * array[i + 1]; + b0 = dcf0 + x2 * b1 - b2; + dcf2 = dcf1; + dcf1 = dcf0; + } + + return b0 - x * b1 - dcf0 / 2; +} + +Float_t Chebyshev3DCalc::chebyshevEvaluation1Derivative2(Float_t x, const Float_t* array, int ncf) +{ + if (--ncf < 2) { + return 0; + } + Float_t b0, b1, b2; + Float_t x2 = x + x; + b1 = b2 = 0; + float dcf0 = 0, dcf1 = 0, dcf2 = 0; + float ddcf0 = 0, ddcf1, ddcf2 = 0; + + dcf2 = 2 * ncf * array[ncf]; + --ncf; + + dcf1 = 2 * ncf * array[ncf]; + b0 = ddcf1 = 2 * ncf * dcf2; + + if (!(--ncf)) { + return b0 / 2; + } + + for (int i = ncf; i--;) { + b2 = b1; + b1 = b0; + dcf0 = dcf2 + 2 * (i + 1) * array[i + 1]; + ddcf0 = ddcf2 + 2 * (i + 1) * dcf1; + b0 = ddcf0 + x2 * b1 - b2; + + ddcf2 = ddcf1; + ddcf1 = ddcf0; + + dcf2 = dcf1; + dcf1 = dcf0; + } + return b0 - x * b1 - ddcf0 / 2; +} + +Int_t Chebyshev3DCalc::getMaxColumnsAtRow() const +{ + int nmax3d = 0; + for (int i = mNumberOfElementsBound2D; i--;) { + if (mCoefficientBound2D0[i] > nmax3d) { + nmax3d = mCoefficientBound2D0[i]; + } + } + return nmax3d; +} diff --git a/field/Chebyshev3DCalc.h b/field/Chebyshev3DCalc.h new file mode 100644 index 0000000000000..ae30f8e1726e4 --- /dev/null +++ b/field/Chebyshev3DCalc.h @@ -0,0 +1,227 @@ +/// \file Cheb3DCalc.h +/// \brief Definition of the Cheb3DCalc class +/// \author ruben.shahoyan@cern.ch 09/09/2006 + +#ifndef ALICEO2_FIELD_CHEBYSHEV3DCALC_H_ +#define ALICEO2_FIELD_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_ + +// 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 { + +class Chebyshev3DCalc : public TNamed { + +public: + /// Default constructor + Chebyshev3DCalc(); + /// Copy constructor + Chebyshev3DCalc(const Chebyshev3DCalc& src); + /// Constructor from coefficients stream + Chebyshev3DCalc(FILE* stream); + /// Default destructor + ~Chebyshev3DCalc() + { + Clear(); + } + + /// Assignment operator + Chebyshev3DCalc& operator=(const Chebyshev3DCalc& rhs); + + /// Prints info + void Print(const Option_t* opt = "") const; + + /// Loads coefficients from the stream + void loadData(FILE* stream); + + /// Evaluates Chebyshev parameterization derivative in given dimension for 3D function. + /// VERY IMPORTANT: par must contain the function arguments ALREADY MAPPED to [-1:1] interval + Float_t evaluateDerivative(int dim, const Float_t* par) const; + + /// Evaluates Chebyshev parameterization 2n derivative in given dimensions for 3D function. + /// 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_ + /// 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; + + // Writes coefficients data to existing output stream + // Note: mNumberOfColumns, mNumberOfElementsBound2D and mColumnAtRowBeginning are not stored, will be computed on fly + // during the loading of this file + void saveData(FILE* stream = stdout) const; +#endif + + /// Sets maximum number of significant rows in the coefficients matrix + void initializeRows(int nr); + + /// Sets maximum number of significant columns in the coefficients matrix + void initializeColumns(int nc); + + Int_t getNumberOfCoefficients() const + { + return mNumberOfCoefficients; + } + + Int_t getNumberOfColumns() const + { + return (Int_t)mNumberOfColumns; + } + + Int_t getNumberOfRows() const + { + return (Int_t)mNumberOfRows; + } + + Int_t getNumberOfElementsBound2D() const + { + return (Int_t)mNumberOfElementsBound2D; + } + + Int_t getMaxColumnsAtRow() const; + + UShort_t* getNumberOfColumnsAtRow() const + { + return mNumberOfColumnsAtRow; + } + + UShort_t* GetColAtRowBg() const + { + return mColumnAtRowBeginning; + } + + /// Sets maximum number of significant coefficients for given row/column of coefficients 3D matrix + void initializeElementBound2D(int ne); + + UShort_t* getCoefficientBound2D0() const + { + return mCoefficientBound2D0; + } + + UShort_t* getCoefficientBound2D1() const + { + return mCoefficientBound2D1; + } + /// Deletes all dynamically allocated structures + void Clear(const Option_t* option = ""); + + static Float_t chebyshevEvaluation1D(Float_t x, const Float_t* array, int ncf); + + /// Evaluates 1D Chebyshev parameterization's derivative. x is the argument mapped to [-1:1] interval + static Float_t chebyshevEvaluation1Derivative(Float_t x, const Float_t* array, int ncf); + + /// Evaluates 1D Chebyshev parameterization's 2nd derivative. x is the argument mapped to [-1:1] interval + static Float_t chebyshevEvaluation1Derivative2(Float_t x, const Float_t* array, int ncf); + + /// Sets total number of significant coefficients + void initializeCoefficients(int nc); + + Float_t* getCoefficients() const + { + return mCoefficients; + } + + /// Reads single line from the stream, skipping empty and commented lines. EOF is not expected + static void readLine(TString& str, FILE* stream); + + Float_t Eval(const Float_t* par) const; + + Double_t Eval(const Double_t* par) const; + +protected: + Int_t mNumberOfCoefficients; ///< total number of coeeficients + 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 + /// of significant coeffs + UShort_t* + mNumberOfColumnsAtRow; //[mNumberOfRows] number of sighificant columns (2nd dim) at each row of 3D coefs matrix + UShort_t* mColumnAtRowBeginning; //[mNumberOfRows] beginning of significant columns (2nd dim) for row in the 2D + // boundary matrix + UShort_t* mCoefficientBound2D0; //[mNumberOfElementsBound2D] 2D matrix defining the boundary of significance for 3D + // coeffs.matrix + //(Ncoefs for col/row) + UShort_t* mCoefficientBound2D1; //[mNumberOfElementsBound2D] 2D matrix defining the start beginning of significant + // coeffs for col/row + Float_t* mCoefficients; //[mNumberOfCoefficients] array of Chebyshev coefficients + + Float_t* mTemporaryCoefficients2D; //[mNumberOfColumns] temp. coeffs for 2d summation + Float_t* mTemporaryCoefficients1D; //[mNumberOfRows] temp. coeffs for 1d summation + + ClassDef(Chebyshev3DCalc, 1) // Class for interpolation of 3D->1 function by Chebyshev parametrization +}; + +/// Evaluates 1D Chebyshev parameterization. x is the argument mapped to [-1:1] interval +inline Float_t Chebyshev3DCalc::chebyshevEvaluation1D(Float_t x, const Float_t* array, int ncf) +{ + if (ncf <= 0) { + return 0; + } + + Float_t b0, b1, b2, x2 = x + x; + b0 = array[--ncf]; + b1 = b2 = 0; + + for (int i = ncf; i--;) { + b2 = b1; + b1 = b0; + b0 = array[i] + x2 * b1 - b2; + } + return b0 - x * b1; +} + +/// Evaluates Chebyshev parameterization for 3D function. +/// VERY IMPORTANT: par must contain the function arguments ALREADY MAPPED to [-1:1] interval +inline Float_t Chebyshev3DCalc::Eval(const Float_t* par) const +{ + if (!mNumberOfRows) { + return 0.; + } + int ncfRC; + for (int id0 = mNumberOfRows; id0--;) { + int nCLoc = mNumberOfColumnsAtRow[id0]; // number of significant coefs on this row + int col0 = mColumnAtRowBeginning[id0]; // beginning of local column in the 2D boundary matrix + for (int id1 = nCLoc; id1--;) { + int id = id1 + col0; + mTemporaryCoefficients2D[id1] = (ncfRC = mCoefficientBound2D0[id]) + ? chebyshevEvaluation1D(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC) + : 0.0; + } + mTemporaryCoefficients1D[id0] = nCLoc > 0 ? chebyshevEvaluation1D(par[1], mTemporaryCoefficients2D, nCLoc) : 0.0; + } + return chebyshevEvaluation1D(par[0], mTemporaryCoefficients1D, mNumberOfRows); +} + +/// Evaluates Chebyshev parameterization for 3D function. +/// VERY IMPORTANT: par must contain the function arguments ALREADY MAPPED to [-1:1] interval +inline Double_t Chebyshev3DCalc::Eval(const Double_t* par) const +{ + if (!mNumberOfRows) { + return 0.; + } + int ncfRC; + for (int id0 = mNumberOfRows; id0--;) { + int nCLoc = mNumberOfColumnsAtRow[id0]; // number of significant coefs on this row + int col0 = mColumnAtRowBeginning[id0]; // beginning of local column in the 2D boundary matrix + for (int id1 = nCLoc; id1--;) { + int id = id1 + col0; + mTemporaryCoefficients2D[id1] = (ncfRC = mCoefficientBound2D0[id]) + ? chebyshevEvaluation1D(par[2], mCoefficients + mCoefficientBound2D1[id], ncfRC) + : 0.0; + } + mTemporaryCoefficients1D[id0] = nCLoc > 0 ? chebyshevEvaluation1D(par[1], mTemporaryCoefficients2D, nCLoc) : 0.0; + } + return chebyshevEvaluation1D(par[0], mTemporaryCoefficients1D, mNumberOfRows); +} +} +} + +#endif diff --git a/field/FieldLinkDef.h b/field/FieldLinkDef.h deleted file mode 100644 index 069b2a04bd5cc..0000000000000 --- a/field/FieldLinkDef.h +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence version 3 (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -// ------------------------------------------------------------------------- -// ----- M. Al-Turany June 2014 ----- -// ------------------------------------------------------------------------- - - -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class AliConstField+; -#pragma link C++ class AliFieldCreator+; -#pragma link C++ class AliFieldPar+; - -#endif diff --git a/field/MagneticField.cxx b/field/MagneticField.cxx new file mode 100644 index 0000000000000..965df32e76c76 --- /dev/null +++ b/field/MagneticField.cxx @@ -0,0 +1,574 @@ +/// \file MagF.cxx +/// \brief Implementation of the MagF class +/// \author ruben.shahoyan@cern.ch + +#include +#include +#include +#include +#include "MagneticField.h" +#include "MagneticWrapperChebyshev.h" + +#include "FairLogger.h" + +using namespace AliceO2::Field; + +ClassImp(MagneticField) + +const Double_t MagneticField::sSolenoidToDipoleZ = -700.; + +/// Explanation for polarity conventions: these are the mapping between the +/// current signs and main field components in L3 (Bz) and Dipole (Bx) (in Alice frame) +/// 1) kConvMap2005: used for the field mapping in 2005 +/// positive L3 current -> negative Bz +/// positive Dip current -> positive Bx +/// 2) kConvMapDCS2008: defined by the microswitches/cabling of power converters as of 2008 - 1st half 2009 +/// positive L3 current -> positive Bz +/// positive Dip current -> positive Bx +/// 3) kConvLHC : defined by LHC +/// positive L3 current -> positive Bz +/// positive Dip current -> negative Bx +/// +/// Note: only "negative Bz(L3) with postive Bx(Dipole)" and its inverse was mapped in 2005. Hence +/// the GRP Manager will reject the runs with the current combinations (in the convention defined by the +/// static Int_t MagneticField::getPolarityConvention()) which do not lead to such field polarities. +/// +/// Explanation on integrals in the TPC region +/// getTPCInt(xyz,b) and getTPCRatInt(xyz,b) give integrals from point (x,y,z) to point (x,y,0) +/// (irrespectively of the z sign) of the following: +/// TPCInt: b contains int{bx}, int{by}, int{bz} +/// TPCRatInt: b contains int{bx/bz}, int{by/bz}, int{(bx/bz)^2+(by/bz)^2} +/// +/// The same applies to integral in cylindrical coordinates: +/// getTPCIntCyl(rphiz,b) +/// getTPCIntRatCyl(rphiz,b) +/// They accept the R,Phi,Z coordinate (-pi 2) { + mLogger->Warning(MESSAGE_ORIGIN, "Invalid magnetic field flag: %5d; Helix tracking chosen instead", integ); + mDefaultIntegration = 2; + } + if (mDefaultIntegration == 0) { + mPrecisionInteg = 0; + } + + if (mBeamEnergy <= 0 && mBeamType != kNoBeamField) { + if (mBeamType == kBeamTypepp) { + mBeamEnergy = 7000.; // max proton energy + } + else if (mBeamType == kBeamTypeAA) { + mBeamEnergy = 2760; // max PbPb energy + } + else if (mBeamType == kBeamTypepA || mBeamType == kBeamTypeAp) { + mBeamEnergy = 2760; // same rigitiy max PbPb energy + } + FairLogger::GetLogger()->Info(MESSAGE_ORIGIN, "Maximim possible beam energy for requested beam is assumed"); + } + + const char* parname = 0; + + if (mMapType == k2kG) { + parname = mDipoleOnOffFlag ? "Sol12_Dip0_Hole" : "Sol12_Dip6_Hole"; + } else if (mMapType == k5kG) { + parname = mDipoleOnOffFlag ? "Sol30_Dip0_Hole" : "Sol30_Dip6_Hole"; + } else if (mMapType == k5kGUniform) { + parname = "Sol30_Dip6_Uniform"; + } else { + mLogger->Fatal(MESSAGE_ORIGIN, "Unknown field identifier %d is requested\n", mMapType); + } + + setDataFileName(path); + setParameterName(parname); + + loadParameterization(); + initializeMachineField(mBeamType, mBeamEnergy); + double xyz[3] = { 0., 0., 0. }; + mSolenoid = getBz(xyz); + setFactorSolenoid(factorSol); + setFactorDipole(factorDip); + Print("a"); +} + +MagneticField::MagneticField(const MagneticField& src) + : TVirtualMagField(src), + mMeasuredMap(0), + mMapType(src.mMapType), + mSolenoid(src.mSolenoid), + mBeamType(src.mBeamType), + mBeamEnergy(src.mBeamEnergy), + mDefaultIntegration(src.mDefaultIntegration), + mPrecisionInteg(src.mPrecisionInteg), + mMultipicativeFactorSolenoid(src.mMultipicativeFactorSolenoid), + mMultipicativeFactorDipole(src.mMultipicativeFactorDipole), + mMaxField(src.mMaxField), + mDipoleOnOffFlag(src.mDipoleOnOffFlag), + mQuadrupoleGradient(src.mQuadrupoleGradient), + mDipoleField(src.mDipoleField), + mCompensatorField2C(src.mCompensatorField2C), + mCompensatorField1A(src.mCompensatorField1A), + mCompensatorField2A(src.mCompensatorField2A), + mParameterNames(src.mParameterNames), + mLogger(FairLogger::GetLogger()) +{ + if (src.mMeasuredMap) { + mMeasuredMap = new MagneticWrapperChebyshev(*src.mMeasuredMap); + } +} + +MagneticField::~MagneticField() +{ + delete mMeasuredMap; +} + +Bool_t MagneticField::loadParameterization() +{ + if (mMeasuredMap) { + mLogger->Fatal(MESSAGE_ORIGIN, "Field data %s are already loaded from %s\n", getParameterName(), getDataFileName()); + } + + char* fname = gSystem->ExpandPathName(getDataFileName()); + TFile* file = TFile::Open(fname); + if (!file) { + mLogger->Fatal(MESSAGE_ORIGIN, "Failed to open magnetic field data file %s\n", fname); + } + + mMeasuredMap = dynamic_cast(file->Get(getParameterName())); + if (!mMeasuredMap) { + mLogger->Fatal(MESSAGE_ORIGIN, "Did not find field %s in %s\n", getParameterName(), fname); + } + file->Close(); + delete file; + return kTRUE; +} + +void MagneticField::Field(const Double_t* xyz, Double_t* b) +{ + // b[0]=b[1]=b[2]=0.0; + if (mMeasuredMap && xyz[2] > mMeasuredMap->getMinZ() && xyz[2] < mMeasuredMap->getMaxZ()) { + mMeasuredMap->Field(xyz, b); + if (xyz[2] > sSolenoidToDipoleZ || mDipoleOnOffFlag) { + for (int i = 3; i--;) { + b[i] *= mMultipicativeFactorSolenoid; + } + } else { + for (int i = 3; i--;) { + b[i] *= mMultipicativeFactorDipole; + } + } + } else { + MachineField(xyz, b); + } +} + +Double_t MagneticField::getBz(const Double_t* xyz) const +{ + if (mMeasuredMap && xyz[2] > mMeasuredMap->getMinZ() && xyz[2] < mMeasuredMap->getMaxZ()) { + double bz = mMeasuredMap->getBz(xyz); + return (xyz[2] > sSolenoidToDipoleZ || mDipoleOnOffFlag) ? bz * mMultipicativeFactorSolenoid + : bz * mMultipicativeFactorDipole; + } else { + return 0.; + } +} + +MagneticField& MagneticField::operator=(const MagneticField& src) +{ + if (this != &src) { + if (src.mMeasuredMap) { + if (mMeasuredMap) { + delete mMeasuredMap; + } + mMeasuredMap = new MagneticWrapperChebyshev(*src.mMeasuredMap); + } + SetName(src.GetName()); + mSolenoid = src.mSolenoid; + mBeamType = src.mBeamType; + mBeamEnergy = src.mBeamEnergy; + mDefaultIntegration = src.mDefaultIntegration; + mPrecisionInteg = src.mPrecisionInteg; + mMultipicativeFactorSolenoid = src.mMultipicativeFactorSolenoid; + mMultipicativeFactorDipole = src.mMultipicativeFactorDipole; + mMaxField = src.mMaxField; + mDipoleOnOffFlag = src.mDipoleOnOffFlag; + mParameterNames = src.mParameterNames; + } + return *this; +} + +void MagneticField::initializeMachineField(BeamType_t btype, Double_t benergy) +{ + if (btype == kNoBeamField) { + mQuadrupoleGradient = mDipoleField = mCompensatorField2C = mCompensatorField1A = mCompensatorField2A = 0.; + return; + } + + double rigScale = benergy / 7000.; // scale according to ratio of E/Enominal + // for ions assume PbPb (with energy provided per nucleon) and account for A/Z + if (btype == kBeamTypeAA /* || btype==kBeamTypepA || btype==kBeamTypeAp */) + rigScale *= 208. / 82.; + // Attention: in p-Pb the energy recorded in the GRP is the PROTON energy, no rigidity + // rescaling is needed + + mQuadrupoleGradient = 22.0002 * rigScale; + mDipoleField = 37.8781 * rigScale; + + // SIDE C + mCompensatorField2C = -9.6980; + // SIDE A + mCompensatorField1A = -13.2247; + mCompensatorField2A = 11.7905; +} + +void MagneticField::MachineField(const Double_t* x, Double_t* b) const +{ + // ---- This is the ZDC part + // Compansators for Alice Muon Arm Dipole + const Double_t kBComp1CZ = 1075., kBComp1hDZ = 260. / 2., kBComp1SqR = 4.0 * 4.0; + const Double_t kBComp2CZ = 2049., kBComp2hDZ = 153. / 2., kBComp2SqR = 4.5 * 4.5; + + const Double_t kTripQ1CZ = 2615., kTripQ1hDZ = 637. / 2., kTripQ1SqR = 3.5 * 3.5; + const Double_t kTripQ2CZ = 3480., kTripQ2hDZ = 550. / 2., kTripQ2SqR = 3.5 * 3.5; + const Double_t kTripQ3CZ = 4130., kTripQ3hDZ = 550. / 2., kTripQ3SqR = 3.5 * 3.5; + const Double_t kTripQ4CZ = 5015., kTripQ4hDZ = 637. / 2., kTripQ4SqR = 3.5 * 3.5; + + const Double_t kDip1CZ = 6310.8, kDip1hDZ = 945. / 2., kDip1SqRC = 4.5 * 4.5, kDip1SqRA = 3.375 * 3.375; + const Double_t kDip2CZ = 12640.3, kDip2hDZ = 945. / 2., kDip2SqRC = 4.5 * 4.5, kDip2SqRA = 3.75 * 3.75; + const Double_t kDip2DXC = 9.7, kDip2DXA = 9.4; + + double rad2 = x[0] * x[0] + x[1] * x[1]; + + b[0] = b[1] = b[2] = 0; + + // SIDE C + if (x[2] < 0.) { + if (TMath::Abs(x[2] + kBComp2CZ) < kBComp2hDZ && rad2 < kBComp2SqR) { + b[0] = mCompensatorField2C * mMultipicativeFactorDipole; + } else if (TMath::Abs(x[2] + kTripQ1CZ) < kTripQ1hDZ && rad2 < kTripQ1SqR) { + b[0] = mQuadrupoleGradient * x[1]; + b[1] = mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] + kTripQ2CZ) < kTripQ2hDZ && rad2 < kTripQ2SqR) { + b[0] = -mQuadrupoleGradient * x[1]; + b[1] = -mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] + kTripQ3CZ) < kTripQ3hDZ && rad2 < kTripQ3SqR) { + b[0] = -mQuadrupoleGradient * x[1]; + b[1] = -mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] + kTripQ4CZ) < kTripQ4hDZ && rad2 < kTripQ4SqR) { + b[0] = mQuadrupoleGradient * x[1]; + b[1] = mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] + kDip1CZ) < kDip1hDZ && rad2 < kDip1SqRC) { + b[1] = mDipoleField; + } else if (TMath::Abs(x[2] + kDip2CZ) < kDip2hDZ && rad2 < kDip2SqRC) { + double dxabs = TMath::Abs(x[0]) - kDip2DXC; + if ((dxabs * dxabs + x[1] * x[1]) < kDip2SqRC) { + b[1] = -mDipoleField; + } + } + } + + // SIDE A + else { + if (TMath::Abs(x[2] - kBComp1CZ) < kBComp1hDZ && rad2 < kBComp1SqR) { + // Compensator magnet at z = 1075 m + b[0] = mCompensatorField1A * mMultipicativeFactorDipole; + } + + if (TMath::Abs(x[2] - kBComp2CZ) < kBComp2hDZ && rad2 < kBComp2SqR) { + b[0] = mCompensatorField2A * mMultipicativeFactorDipole; + } else if (TMath::Abs(x[2] - kTripQ1CZ) < kTripQ1hDZ && rad2 < kTripQ1SqR) { + b[0] = -mQuadrupoleGradient * x[1]; + b[1] = -mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] - kTripQ2CZ) < kTripQ2hDZ && rad2 < kTripQ2SqR) { + b[0] = mQuadrupoleGradient * x[1]; + b[1] = mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] - kTripQ3CZ) < kTripQ3hDZ && rad2 < kTripQ3SqR) { + b[0] = mQuadrupoleGradient * x[1]; + b[1] = mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] - kTripQ4CZ) < kTripQ4hDZ && rad2 < kTripQ4SqR) { + b[0] = -mQuadrupoleGradient * x[1]; + b[1] = -mQuadrupoleGradient * x[0]; + } else if (TMath::Abs(x[2] - kDip1CZ) < kDip1hDZ && rad2 < kDip1SqRA) { + b[1] = -mDipoleField; + } else if (TMath::Abs(x[2] - kDip2CZ) < kDip2hDZ && rad2 < kDip2SqRA) { + double dxabs = TMath::Abs(x[0]) - kDip2DXA; + if ((dxabs * dxabs + x[1] * x[1]) < kDip2SqRA) { + b[1] = mDipoleField; + } + } + } +} + +void MagneticField::getTPCIntegral(const Double_t* xyz, Double_t* b) const +{ + b[0] = b[1] = b[2] = 0.0; + if (mMeasuredMap) { + mMeasuredMap->getTPCIntegral(xyz, b); + for (int i = 3; i--;) { + b[i] *= mMultipicativeFactorSolenoid; + } + } +} + +void MagneticField::getTPCRatIntegral(const Double_t* xyz, Double_t* b) const +{ + b[0] = b[1] = b[2] = 0.0; + if (mMeasuredMap) { + mMeasuredMap->getTPCRatIntegral(xyz, b); + b[2] /= 100; + } +} + +void MagneticField::getTPCIntegralCylindrical(const Double_t* rphiz, Double_t* b) const +{ + b[0] = b[1] = b[2] = 0.0; + if (mMeasuredMap) { + mMeasuredMap->getTPCIntegralCylindrical(rphiz, b); + for (int i = 3; i--;) { + b[i] *= mMultipicativeFactorSolenoid; + } + } +} + +void MagneticField::getTPCRatIntegralCylindrical(const Double_t* rphiz, Double_t* b) const +{ + b[0] = b[1] = b[2] = 0.0; + if (mMeasuredMap) { + mMeasuredMap->getTPCRatIntegralCylindrical(rphiz, b); + b[2] /= 100; + } +} + +void MagneticField::setFactorSolenoid(Float_t fc) +{ + switch (sPolarityConvention) { + case kConvDCS2008: + mMultipicativeFactorSolenoid = -fc; + break; + case kConvLHC: + mMultipicativeFactorSolenoid = -fc; + break; + default: + mMultipicativeFactorSolenoid = fc; + break; // case kConvMap2005: mMultipicativeFactorSolenoid = fc; break; + } +} + +void MagneticField::setFactorDipole(Float_t fc) +{ + switch (sPolarityConvention) { + case kConvDCS2008: + mMultipicativeFactorDipole = fc; + break; + case kConvLHC: + mMultipicativeFactorDipole = -fc; + break; + default: + mMultipicativeFactorDipole = fc; + break; // case kConvMap2005: mMultipicativeFactorDipole = fc; break; + } +} + +Double_t MagneticField::getFactorSolenoid() const +{ + switch (sPolarityConvention) { + case kConvDCS2008: + return -mMultipicativeFactorSolenoid; + case kConvLHC: + return -mMultipicativeFactorSolenoid; + default: + return mMultipicativeFactorSolenoid; // case kConvMap2005: return mMultipicativeFactorSolenoid; + } +} + +Double_t MagneticField::getFactorDipole() const +{ + switch (sPolarityConvention) { + case kConvDCS2008: + return mMultipicativeFactorDipole; + case kConvLHC: + return -mMultipicativeFactorDipole; + default: + return mMultipicativeFactorDipole; // case kConvMap2005: return mMultipicativeFactorDipole; + } +} + +MagneticField* MagneticField::createFieldMap(Float_t l3Cur, Float_t diCur, Int_t convention, Bool_t uniform, + Float_t beamenergy, const Char_t* beamtype, const Char_t* path) +{ + const Float_t l3NominalCurrent1 = 30000.; // (A) + const Float_t l3NominalCurrent2 = 12000.; // (A) + const Float_t diNominalCurrent = 6000.; // (A) + + const Float_t tolerance = 0.03; // relative current tolerance + const Float_t zero = 77.; // "zero" current (A) + + BMap_t map = k5kG; + double sclL3, sclDip; + + Float_t l3Pol = l3Cur > 0 ? 1 : -1; + Float_t diPol = diCur > 0 ? 1 : -1; + + l3Cur = TMath::Abs(l3Cur); + diCur = TMath::Abs(diCur); + + if (TMath::Abs((sclDip = diCur / diNominalCurrent) - 1.) > tolerance && !uniform) { + if (diCur <= zero) { + sclDip = 0.; // some small current.. -> Dipole OFF + } else { + FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, "Wrong dipole current (%f A)!", diCur); + } + } + + if (uniform) { + // special treatment of special MC with uniform mag field (normalized to 0.5 T) + // no check for scaling/polarities are done + map = k5kGUniform; + sclL3 = l3Cur / l3NominalCurrent1; + } else { + if (TMath::Abs((sclL3 = l3Cur / l3NominalCurrent1) - 1.) < tolerance) { + map = k5kG; + } else if (TMath::Abs((sclL3 = l3Cur / l3NominalCurrent2) - 1.) < tolerance) { + map = k2kG; + } else if (l3Cur <= zero && diCur <= zero) { + sclL3 = 0; + sclDip = 0; + map = k5kGUniform; + } else { + FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, "Wrong L3 current (%f A)!", l3Cur); + } + } + + if (sclDip != 0 && map != k5kGUniform) { + if ((l3Cur <= zero) || + ((convention == kConvLHC && l3Pol != diPol) || (convention == kConvDCS2008 && l3Pol == diPol))) { + FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, + "Wrong combination for L3/Dipole polarities (%c/%c) for convention %d", + l3Pol > 0 ? '+' : '-', diPol > 0 ? '+' : '-', getPolarityConvention()); + } + } + + if (l3Pol < 0) { + sclL3 = -sclL3; + } + if (diPol < 0) { + sclDip = -sclDip; + } + + BeamType_t btype = kNoBeamField; + TString btypestr = beamtype; + btypestr.ToLower(); + TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1"); + TPRegexp ionBeam("(lead|pb|ion|a|A)\\s*-?\\s*\\1"); + TPRegexp protonionBeam("(proton|p)\\s*-?\\s*(lead|pb|ion|a|A)"); + TPRegexp ionprotonBeam("(lead|pb|ion|a|A)\\s*-?\\s*(proton|p)"); + if (btypestr.Contains(ionBeam)) { + btype = kBeamTypeAA; + } else if (btypestr.Contains(protonBeam)) { + btype = kBeamTypepp; + } else if (btypestr.Contains(protonionBeam)) { + btype = kBeamTypepA; + } else if (btypestr.Contains(ionprotonBeam)) { + btype = kBeamTypeAp; + } else { + FairLogger::GetLogger()->Info(MESSAGE_ORIGIN, "Assume no LHC magnet field for the beam type %s,", beamtype); + } + char ttl[80]; + snprintf(ttl, 79, "L3: %+5d Dip: %+4d kA; %s | Polarities in %s convention", (int)TMath::Sign(l3Cur, float(sclL3)), + (int)TMath::Sign(diCur, float(sclDip)), uniform ? " Constant" : "", + convention == kConvLHC ? "LHC" : "DCS2008"); + // LHC and DCS08 conventions have opposite dipole polarities + if (getPolarityConvention() != convention) { + sclDip = -sclDip; + } + + return new MagneticField("MagneticFieldMap", ttl, sclL3, sclDip, map, btype, beamenergy, 2, 10., path); +} + +const char* MagneticField::getBeamTypeText() const +{ + const char* beamNA = "No Beam"; + const char* beamPP = "p-p"; + const char* beamPbPb = "A-A"; + const char* beamPPb = "p-A"; + const char* beamPbP = "A-p"; + switch (mBeamType) { + case kBeamTypepp: + return beamPP; + case kBeamTypeAA: + return beamPbPb; + case kBeamTypepA: + return beamPPb; + case kBeamTypeAp: + return beamPbP; + case kNoBeamField: + default: + return beamNA; + } +} + +void MagneticField::Print(Option_t* opt) const +{ + TString opts = opt; + opts.ToLower(); + mLogger->Info(MESSAGE_ORIGIN, "%s:%s", GetName(), GetTitle()); + mLogger->Info(MESSAGE_ORIGIN, "Solenoid (%+.2f*)%.0f kG, Dipole %s (%+.2f) %s", getFactorSolenoid(), + (mMapType == k5kG || mMapType == k5kGUniform) ? 5. : 2., mDipoleOnOffFlag ? "OFF" : "ON", + getFactorDipole(), mMapType == k5kGUniform ? " |Constant Field!" : ""); + if (opts.Contains("a")) { + mLogger->Info(MESSAGE_ORIGIN, "Machine B fields for %s beam (%.0f GeV): QGrad: %.4f Dipole: %.4f", + getBeamTypeText(), mBeamEnergy, mQuadrupoleGradient, mDipoleField); + mLogger->Info(MESSAGE_ORIGIN, "Uses %s of %s", getParameterName(), getDataFileName()); + } +} diff --git a/field/MagneticField.h b/field/MagneticField.h new file mode 100644 index 0000000000000..e52548ddd0e41 --- /dev/null +++ b/field/MagneticField.h @@ -0,0 +1,231 @@ +/// \file MagF.h +/// \brief Definition of the MagF class +/// \author ruben.shahoyan@cern.ch + +#ifndef ALICEO2_FIELD_MAGNETICFIELD_H_ +#define ALICEO2_FIELD_MAGNETICFIELD_H_ + +//#include + +#include + +#include "AliceO2Config.h" + +class FairLogger; + +namespace AliceO2 { +namespace Field { + +class MagneticWrapperChebyshev; + +/// Interface between the TVirtualMagField and MagneticWrapperChebyshev: wrapper to the set of magnetic field data + +/// Tosca +/// parameterization by Chebyshev polynomials +class MagneticField : public TVirtualMagField { + +public: + enum BMap_t { k2kG, k5kG, k5kGUniform }; + enum BeamType_t { kNoBeamField, kBeamTypepp, kBeamTypeAA, kBeamTypepA, kBeamTypeAp }; + enum PolarityConvention_t { kConvLHC, kConvDCS2008, kConvMap2005 }; + enum { kOverrideGRP = BIT(14) }; // don't recreate from GRP if set + + /// Default constructor + MagneticField(); + + /// Initialize the field with Geant integration option "integ" and max field "fmax", + /// Impose scaling of parameterized L3 field by factorSol and of dipole by factorDip. + /// The "be" is the energy of the beam in GeV/nucleon + MagneticField(const char* name, const char* title, Double_t factorSol = 1., Double_t factorDip = 1., + BMap_t maptype = k5kG, BeamType_t btype = kBeamTypepp, Double_t benergy = -1, Int_t integ = 2, + Double_t fmax = 15, const char* path = O2PROTO1_MAGF_DIR); + MagneticField(const MagneticField& src); + MagneticField& operator=(const MagneticField& src); + + /// Default destructor + virtual ~MagneticField(); + + /// Method to calculate the field at point xyz + virtual void Field(const Double_t* x, Double_t* b); + + /// Method to calculate the integral_0^z of br,bt,bz + void getTPCIntegral(const Double_t* xyz, Double_t* b) const; + + /// Method to calculate the integral_0^z of br,bt,bz + void getTPCRatIntegral(const Double_t* xyz, Double_t* b) const; + + /// Method to calculate the integral_0^z of br,bt,bz in cylindrical coordinates ( -pi 0.5 T + /// L3 current 12000 A -> 0.2 T + /// dipole current 6000 A + /// The polarities must match the convention (LHC or DCS2008) + /// unless the special uniform map was used for MC + static MagneticField* createFieldMap(Float_t l3Current = -30000., Float_t diCurrent = -6000., Int_t convention = 0, + Bool_t uniform = kFALSE, Float_t beamenergy = 7000, const Char_t* btype = "pp", + const Char_t* path = O2PROTO1_MAGF_CREATEFIELDMAP_DIR); + +protected: + // not supposed to be changed during the run, set only at the initialization via constructor + void initializeMachineField(BeamType_t btype, Double_t benergy); + + void setBeamType(BeamType_t type) + { + mBeamType = type; + } + + void setBeamEnergy(Float_t energy) + { + mBeamEnergy = energy; + } + +protected: + MagneticWrapperChebyshev* mMeasuredMap; //! Measured part of the field map + BMap_t mMapType; ///< field map type + Double_t mSolenoid; ///< Solenoid field setting + BeamType_t mBeamType; ///< Beam type: A-A (mBeamType=0) or p-p (mBeamType=1) + Double_t mBeamEnergy; ///< Beam energy in GeV + + Int_t mDefaultIntegration; ///< Default integration method as indicated in Geant + Int_t mPrecisionInteg; ///< Alternative integration method, e.g. for higher precision + Double_t mMultipicativeFactorSolenoid; ///< Multiplicative factor for solenoid + Double_t mMultipicativeFactorDipole; ///< Multiplicative factor for dipole + Double_t mMaxField; ///< Max Field as indicated in Geant + Bool_t mDipoleOnOffFlag; ///< Dipole ON/OFF flag + + Double_t mQuadrupoleGradient; ///< Gradient field for inner triplet quadrupoles + Double_t mDipoleField; ///< Field value for D1 and D2 dipoles + Double_t mCompensatorField2C; ///< Side C 2nd compensator field + Double_t mCompensatorField1A; ///< Side A 1st compensator field + Double_t mCompensatorField2A; ///< Side A 2nd compensator field + + TNamed mParameterNames; ///< file and parameterization loadad + + static const Double_t sSolenoidToDipoleZ; ///< conventional Z of transition from L3 to Dipole field + static const UShort_t sPolarityConvention; ///< convention for the mapping of the curr.sign on main component sign + + FairLogger* mLogger; + + ClassDef(MagneticField, 1) // Class for all Alice MagField wrapper for measured data + Tosca parameterization +}; +} +} + +#endif diff --git a/field/MagneticWrapperChebyshev.cxx b/field/MagneticWrapperChebyshev.cxx new file mode 100644 index 0000000000000..ad338015c21ff --- /dev/null +++ b/field/MagneticWrapperChebyshev.cxx @@ -0,0 +1,1484 @@ +/// \file MagWrapCheb.cxx +/// \brief Implementation of the MagWrapCheb class +/// \author ruben.shahoyan@cern.ch 20/03/2007 + +#include "MagneticWrapperChebyshev.h" +#include +#include +#include +#include "FairLogger.h" + +using namespace AliceO2::Field; + +ClassImp(MagneticWrapperChebyshev) + +MagneticWrapperChebyshev::MagneticWrapperChebyshev() + : mNumberOfParameterizationSolenoid(0), + mNumberOfDistinctZSegmentsSolenoid(0), + mNumberOfDistinctPSegmentsSolenoid(0), + mNumberOfDistinctRSegmentsSolenoid(0), + mCoordinatesSegmentsZSolenoid(0), + mCoordinatesSegmentsPSolenoid(0), + mCoordinatesSegmentsRSolenoid(0), + mBeginningOfSegmentsPSolenoid(0), + mNumberOfSegmentsPSolenoid(0), + mBeginningOfSegmentsRSolenoid(0), + mNumberOfRSegmentsSolenoid(0), + mSegmentIdSolenoid(0), + mMinZSolenoid(1.e6), + mMaxZSolenoid(-1.e6), + mParameterizationSolenoid(0), + mMaxRadiusSolenoid(0), + mNumberOfParameterizationTPC(0), + mNumberOfDistinctZSegmentsTPC(0), + mNumberOfDistinctPSegmentsTPC(0), + mNumberOfDistinctRSegmentsTPC(0), + mCoordinatesSegmentsZTPC(0), + mCoordinatesSegmentsPTPC(0), + mCoordinatesSegmentsRTPC(0), + mBeginningOfSegmentsPTPC(0), + mNumberOfSegmentsPTPC(0), + mBeginningOfSegmentsRTPC(0), + mNumberOfRSegmentsTPC(0), + mSegmentIdTPC(0), + mMinZTPC(1.e6), + mMaxZTPC(-1.e6), + mParameterizationTPC(0), + mMaxRadiusTPC(0), + mNumberOfParameterizationTPCRat(0), + mNumberOfDistinctZSegmentsTPCRat(0), + mNumberOfDistinctPSegmentsTPCRat(0), + mNumberOfDistinctRSegmentsTPCRat(0), + mCoordinatesSegmentsZTPCRat(0), + mCoordinatesSegmentsPTPCRat(0), + mCoordinatesSegmentsRTPCRat(0), + mBeginningOfSegmentsPTPCRat(0), + mNumberOfSegmentsPTPCRat(0), + mBeginningOfSegmentsRTPCRat(0), + mNumberOfRSegmentsTPCRat(0), + mSegmentIdTPCRat(0), + mMinZTPCRat(1.e6), + mMaxZTPCRat(-1.e6), + mParameterizationTPCRat(0), + mMaxRadiusTPCRat(0), + mNumberOfParameterizationDipole(0), + mNumberOfDistinctZSegmentsDipole(0), + mNumberOfDistinctYSegmentsDipole(0), + mNumberOfDistinctXSegmentsDipole(0), + mCoordinatesSegmentsZDipole(0), + mCoordinatesSegmentsYDipole(0), + mCoordinatesSegmentsXDipole(0), + mBeginningOfSegmentsYDipole(0), + mNumberOfSegmentsYDipole(0), + mBeginningOfSegmentsXDipole(0), + mNumberOfSegmentsXDipole(0), + mSegmentIdDipole(0), + mMinDipoleZ(1.e6), + mMaxDipoleZ(-1.e6), + mParameterizationDipole(0), + mLogger(FairLogger::GetLogger()) +{ +} + +MagneticWrapperChebyshev::MagneticWrapperChebyshev(const MagneticWrapperChebyshev& src) + : TNamed(src), + mNumberOfParameterizationSolenoid(0), + mNumberOfDistinctZSegmentsSolenoid(0), + mNumberOfDistinctPSegmentsSolenoid(0), + mNumberOfDistinctRSegmentsSolenoid(0), + mCoordinatesSegmentsZSolenoid(0), + mCoordinatesSegmentsPSolenoid(0), + mCoordinatesSegmentsRSolenoid(0), + mBeginningOfSegmentsPSolenoid(0), + mNumberOfSegmentsPSolenoid(0), + mBeginningOfSegmentsRSolenoid(0), + mNumberOfRSegmentsSolenoid(0), + mSegmentIdSolenoid(0), + mMinZSolenoid(1.e6), + mMaxZSolenoid(-1.e6), + mParameterizationSolenoid(0), + mMaxRadiusSolenoid(0), + mNumberOfParameterizationTPC(0), + mNumberOfDistinctZSegmentsTPC(0), + mNumberOfDistinctPSegmentsTPC(0), + mNumberOfDistinctRSegmentsTPC(0), + mCoordinatesSegmentsZTPC(0), + mCoordinatesSegmentsPTPC(0), + mCoordinatesSegmentsRTPC(0), + mBeginningOfSegmentsPTPC(0), + mNumberOfSegmentsPTPC(0), + mBeginningOfSegmentsRTPC(0), + mNumberOfRSegmentsTPC(0), + mSegmentIdTPC(0), + mMinZTPC(1.e6), + mMaxZTPC(-1.e6), + mParameterizationTPC(0), + mMaxRadiusTPC(0), + mNumberOfParameterizationTPCRat(0), + mNumberOfDistinctZSegmentsTPCRat(0), + mNumberOfDistinctPSegmentsTPCRat(0), + mNumberOfDistinctRSegmentsTPCRat(0), + mCoordinatesSegmentsZTPCRat(0), + mCoordinatesSegmentsPTPCRat(0), + mCoordinatesSegmentsRTPCRat(0), + mBeginningOfSegmentsPTPCRat(0), + mNumberOfSegmentsPTPCRat(0), + mBeginningOfSegmentsRTPCRat(0), + mNumberOfRSegmentsTPCRat(0), + mSegmentIdTPCRat(0), + mMinZTPCRat(1.e6), + mMaxZTPCRat(-1.e6), + mParameterizationTPCRat(0), + mMaxRadiusTPCRat(0), + mNumberOfParameterizationDipole(0), + mNumberOfDistinctZSegmentsDipole(0), + mNumberOfDistinctYSegmentsDipole(0), + mNumberOfDistinctXSegmentsDipole(0), + mCoordinatesSegmentsZDipole(0), + mCoordinatesSegmentsYDipole(0), + mCoordinatesSegmentsXDipole(0), + mBeginningOfSegmentsYDipole(0), + mNumberOfSegmentsYDipole(0), + mBeginningOfSegmentsXDipole(0), + mNumberOfSegmentsXDipole(0), + mSegmentIdDipole(0), + mMinDipoleZ(1.e6), + mMaxDipoleZ(-1.e6), + mParameterizationDipole(0), + mLogger(FairLogger::GetLogger()) +{ + copyFrom(src); +} + +void MagneticWrapperChebyshev::copyFrom(const MagneticWrapperChebyshev& src) +{ + Clear(); + SetName(src.GetName()); + SetTitle(src.GetTitle()); + + mNumberOfParameterizationSolenoid = src.mNumberOfParameterizationSolenoid; + mNumberOfDistinctZSegmentsSolenoid = src.mNumberOfDistinctZSegmentsSolenoid; + mNumberOfDistinctPSegmentsSolenoid = src.mNumberOfDistinctPSegmentsSolenoid; + mNumberOfDistinctRSegmentsSolenoid = src.mNumberOfDistinctRSegmentsSolenoid; + mMinZSolenoid = src.mMinZSolenoid; + mMaxZSolenoid = src.mMaxZSolenoid; + mMaxRadiusSolenoid = src.mMaxRadiusSolenoid; + if (src.mNumberOfParameterizationSolenoid) { + memcpy(mCoordinatesSegmentsZSolenoid = new Float_t[mNumberOfDistinctZSegmentsSolenoid], + src.mCoordinatesSegmentsZSolenoid, sizeof(Float_t) * mNumberOfDistinctZSegmentsSolenoid); + memcpy(mCoordinatesSegmentsPSolenoid = new Float_t[mNumberOfDistinctPSegmentsSolenoid], + src.mCoordinatesSegmentsPSolenoid, sizeof(Float_t) * mNumberOfDistinctPSegmentsSolenoid); + memcpy(mCoordinatesSegmentsRSolenoid = new Float_t[mNumberOfDistinctRSegmentsSolenoid], + src.mCoordinatesSegmentsRSolenoid, sizeof(Float_t) * mNumberOfDistinctRSegmentsSolenoid); + memcpy(mBeginningOfSegmentsPSolenoid = new Int_t[mNumberOfDistinctZSegmentsSolenoid], + src.mBeginningOfSegmentsPSolenoid, sizeof(Int_t) * mNumberOfDistinctZSegmentsSolenoid); + memcpy(mNumberOfSegmentsPSolenoid = new Int_t[mNumberOfDistinctZSegmentsSolenoid], src.mNumberOfSegmentsPSolenoid, + sizeof(Int_t) * mNumberOfDistinctZSegmentsSolenoid); + memcpy(mBeginningOfSegmentsRSolenoid = new Int_t[mNumberOfDistinctPSegmentsSolenoid], + src.mBeginningOfSegmentsRSolenoid, sizeof(Int_t) * mNumberOfDistinctPSegmentsSolenoid); + memcpy(mNumberOfRSegmentsSolenoid = new Int_t[mNumberOfDistinctPSegmentsSolenoid], src.mNumberOfRSegmentsSolenoid, + sizeof(Int_t) * mNumberOfDistinctPSegmentsSolenoid); + memcpy(mSegmentIdSolenoid = new Int_t[mNumberOfDistinctRSegmentsSolenoid], src.mSegmentIdSolenoid, + sizeof(Int_t) * mNumberOfDistinctRSegmentsSolenoid); + mParameterizationSolenoid = new TObjArray(mNumberOfParameterizationSolenoid); + for (int i = 0; i < mNumberOfParameterizationSolenoid; i++) { + mParameterizationSolenoid->AddAtAndExpand(new Chebyshev3D(*src.getParameterSolenoid(i)), i); + } + } + + mNumberOfParameterizationTPC = src.mNumberOfParameterizationTPC; + mNumberOfDistinctZSegmentsTPC = src.mNumberOfDistinctZSegmentsTPC; + mNumberOfDistinctPSegmentsTPC = src.mNumberOfDistinctPSegmentsTPC; + mNumberOfDistinctRSegmentsTPC = src.mNumberOfDistinctRSegmentsTPC; + mMinZTPC = src.mMinZTPC; + mMaxZTPC = src.mMaxZTPC; + mMaxRadiusTPC = src.mMaxRadiusTPC; + if (src.mNumberOfParameterizationTPC) { + memcpy(mCoordinatesSegmentsZTPC = new Float_t[mNumberOfDistinctZSegmentsTPC], src.mCoordinatesSegmentsZTPC, + sizeof(Float_t) * mNumberOfDistinctZSegmentsTPC); + memcpy(mCoordinatesSegmentsPTPC = new Float_t[mNumberOfDistinctPSegmentsTPC], src.mCoordinatesSegmentsPTPC, + sizeof(Float_t) * mNumberOfDistinctPSegmentsTPC); + memcpy(mCoordinatesSegmentsRTPC = new Float_t[mNumberOfDistinctRSegmentsTPC], src.mCoordinatesSegmentsRTPC, + sizeof(Float_t) * mNumberOfDistinctRSegmentsTPC); + memcpy(mBeginningOfSegmentsPTPC = new Int_t[mNumberOfDistinctZSegmentsTPC], src.mBeginningOfSegmentsPTPC, + sizeof(Int_t) * mNumberOfDistinctZSegmentsTPC); + memcpy(mNumberOfSegmentsPTPC = new Int_t[mNumberOfDistinctZSegmentsTPC], src.mNumberOfSegmentsPTPC, + sizeof(Int_t) * mNumberOfDistinctZSegmentsTPC); + memcpy(mBeginningOfSegmentsRTPC = new Int_t[mNumberOfDistinctPSegmentsTPC], src.mBeginningOfSegmentsRTPC, + sizeof(Int_t) * mNumberOfDistinctPSegmentsTPC); + memcpy(mNumberOfRSegmentsTPC = new Int_t[mNumberOfDistinctPSegmentsTPC], src.mNumberOfRSegmentsTPC, + sizeof(Int_t) * mNumberOfDistinctPSegmentsTPC); + memcpy(mSegmentIdTPC = new Int_t[mNumberOfDistinctRSegmentsTPC], src.mSegmentIdTPC, + sizeof(Int_t) * mNumberOfDistinctRSegmentsTPC); + mParameterizationTPC = new TObjArray(mNumberOfParameterizationTPC); + for (int i = 0; i < mNumberOfParameterizationTPC; i++) { + mParameterizationTPC->AddAtAndExpand(new Chebyshev3D(*src.getParameterTPCIntegral(i)), i); + } + } + + mNumberOfParameterizationTPCRat = src.mNumberOfParameterizationTPCRat; + mNumberOfDistinctZSegmentsTPCRat = src.mNumberOfDistinctZSegmentsTPCRat; + mNumberOfDistinctPSegmentsTPCRat = src.mNumberOfDistinctPSegmentsTPCRat; + mNumberOfDistinctRSegmentsTPCRat = src.mNumberOfDistinctRSegmentsTPCRat; + mMinZTPCRat = src.mMinZTPCRat; + mMaxZTPCRat = src.mMaxZTPCRat; + mMaxRadiusTPCRat = src.mMaxRadiusTPCRat; + if (src.mNumberOfParameterizationTPCRat) { + memcpy(mCoordinatesSegmentsZTPCRat = new Float_t[mNumberOfDistinctZSegmentsTPCRat], src.mCoordinatesSegmentsZTPCRat, + sizeof(Float_t) * mNumberOfDistinctZSegmentsTPCRat); + memcpy(mCoordinatesSegmentsPTPCRat = new Float_t[mNumberOfDistinctPSegmentsTPCRat], src.mCoordinatesSegmentsPTPCRat, + sizeof(Float_t) * mNumberOfDistinctPSegmentsTPCRat); + memcpy(mCoordinatesSegmentsRTPCRat = new Float_t[mNumberOfDistinctRSegmentsTPCRat], src.mCoordinatesSegmentsRTPCRat, + sizeof(Float_t) * mNumberOfDistinctRSegmentsTPCRat); + memcpy(mBeginningOfSegmentsPTPCRat = new Int_t[mNumberOfDistinctZSegmentsTPCRat], src.mBeginningOfSegmentsPTPCRat, + sizeof(Int_t) * mNumberOfDistinctZSegmentsTPCRat); + memcpy(mNumberOfSegmentsPTPCRat = new Int_t[mNumberOfDistinctZSegmentsTPCRat], src.mNumberOfSegmentsPTPCRat, + sizeof(Int_t) * mNumberOfDistinctZSegmentsTPCRat); + memcpy(mBeginningOfSegmentsRTPCRat = new Int_t[mNumberOfDistinctPSegmentsTPCRat], src.mBeginningOfSegmentsRTPCRat, + sizeof(Int_t) * mNumberOfDistinctPSegmentsTPCRat); + memcpy(mNumberOfRSegmentsTPCRat = new Int_t[mNumberOfDistinctPSegmentsTPCRat], src.mNumberOfRSegmentsTPCRat, + sizeof(Int_t) * mNumberOfDistinctPSegmentsTPCRat); + memcpy(mSegmentIdTPCRat = new Int_t[mNumberOfDistinctRSegmentsTPCRat], src.mSegmentIdTPCRat, + sizeof(Int_t) * mNumberOfDistinctRSegmentsTPCRat); + mParameterizationTPCRat = new TObjArray(mNumberOfParameterizationTPCRat); + for (int i = 0; i < mNumberOfParameterizationTPCRat; i++) { + mParameterizationTPCRat->AddAtAndExpand(new Chebyshev3D(*src.getParameterTPCRatIntegral(i)), i); + } + } + + mNumberOfParameterizationDipole = src.mNumberOfParameterizationDipole; + mNumberOfDistinctZSegmentsDipole = src.mNumberOfDistinctZSegmentsDipole; + mNumberOfDistinctYSegmentsDipole = src.mNumberOfDistinctYSegmentsDipole; + mNumberOfDistinctXSegmentsDipole = src.mNumberOfDistinctXSegmentsDipole; + mMinDipoleZ = src.mMinDipoleZ; + mMaxDipoleZ = src.mMaxDipoleZ; + if (src.mNumberOfParameterizationDipole) { + memcpy(mCoordinatesSegmentsZDipole = new Float_t[mNumberOfDistinctZSegmentsDipole], src.mCoordinatesSegmentsZDipole, + sizeof(Float_t) * mNumberOfDistinctZSegmentsDipole); + memcpy(mCoordinatesSegmentsYDipole = new Float_t[mNumberOfDistinctYSegmentsDipole], src.mCoordinatesSegmentsYDipole, + sizeof(Float_t) * mNumberOfDistinctYSegmentsDipole); + memcpy(mCoordinatesSegmentsXDipole = new Float_t[mNumberOfDistinctXSegmentsDipole], src.mCoordinatesSegmentsXDipole, + sizeof(Float_t) * mNumberOfDistinctXSegmentsDipole); + memcpy(mBeginningOfSegmentsYDipole = new Int_t[mNumberOfDistinctZSegmentsDipole], src.mBeginningOfSegmentsYDipole, + sizeof(Int_t) * mNumberOfDistinctZSegmentsDipole); + memcpy(mNumberOfSegmentsYDipole = new Int_t[mNumberOfDistinctZSegmentsDipole], src.mNumberOfSegmentsYDipole, + sizeof(Int_t) * mNumberOfDistinctZSegmentsDipole); + memcpy(mBeginningOfSegmentsXDipole = new Int_t[mNumberOfDistinctYSegmentsDipole], src.mBeginningOfSegmentsXDipole, + sizeof(Int_t) * mNumberOfDistinctYSegmentsDipole); + memcpy(mNumberOfSegmentsXDipole = new Int_t[mNumberOfDistinctYSegmentsDipole], src.mNumberOfSegmentsXDipole, + sizeof(Int_t) * mNumberOfDistinctYSegmentsDipole); + memcpy(mSegmentIdDipole = new Int_t[mNumberOfDistinctXSegmentsDipole], src.mSegmentIdDipole, + sizeof(Int_t) * mNumberOfDistinctXSegmentsDipole); + mParameterizationDipole = new TObjArray(mNumberOfParameterizationDipole); + for (int i = 0; i < mNumberOfParameterizationDipole; i++) { + mParameterizationDipole->AddAtAndExpand(new Chebyshev3D(*src.getParameterDipole(i)), i); + } + } +} + +MagneticWrapperChebyshev& MagneticWrapperChebyshev::operator=(const MagneticWrapperChebyshev& rhs) +{ + if (this != &rhs) { + Clear(); + copyFrom(rhs); + } + return *this; +} + +void MagneticWrapperChebyshev::Clear(const Option_t*) +{ + if (mNumberOfParameterizationSolenoid) { + mParameterizationSolenoid->SetOwner(kTRUE); + delete mParameterizationSolenoid; + mParameterizationSolenoid = 0; + delete[] mCoordinatesSegmentsZSolenoid; + mCoordinatesSegmentsZSolenoid = 0; + delete[] mCoordinatesSegmentsPSolenoid; + mCoordinatesSegmentsPSolenoid = 0; + delete[] mCoordinatesSegmentsRSolenoid; + mCoordinatesSegmentsRSolenoid = 0; + delete[] mBeginningOfSegmentsPSolenoid; + mBeginningOfSegmentsPSolenoid = 0; + delete[] mNumberOfSegmentsPSolenoid; + mNumberOfSegmentsPSolenoid = 0; + delete[] mBeginningOfSegmentsRSolenoid; + mBeginningOfSegmentsRSolenoid = 0; + delete[] mNumberOfRSegmentsSolenoid; + mNumberOfRSegmentsSolenoid = 0; + delete[] mSegmentIdSolenoid; + mSegmentIdSolenoid = 0; + } + + mNumberOfParameterizationSolenoid = mNumberOfDistinctZSegmentsSolenoid = mNumberOfDistinctPSegmentsSolenoid = + mNumberOfDistinctRSegmentsSolenoid = 0; + mMinZSolenoid = 1e6; + mMaxZSolenoid = -1e6; + mMaxRadiusSolenoid = 0; + + if (mNumberOfParameterizationTPC) { + mParameterizationTPC->SetOwner(kTRUE); + delete mParameterizationTPC; + mParameterizationTPC = 0; + delete[] mCoordinatesSegmentsZTPC; + mCoordinatesSegmentsZTPC = 0; + delete[] mCoordinatesSegmentsPTPC; + mCoordinatesSegmentsPTPC = 0; + delete[] mCoordinatesSegmentsRTPC; + mCoordinatesSegmentsRTPC = 0; + delete[] mBeginningOfSegmentsPTPC; + mBeginningOfSegmentsPTPC = 0; + delete[] mNumberOfSegmentsPTPC; + mNumberOfSegmentsPTPC = 0; + delete[] mBeginningOfSegmentsRTPC; + mBeginningOfSegmentsRTPC = 0; + delete[] mNumberOfRSegmentsTPC; + mNumberOfRSegmentsTPC = 0; + delete[] mSegmentIdTPC; + mSegmentIdTPC = 0; + } + + mNumberOfParameterizationTPC = mNumberOfDistinctZSegmentsTPC = mNumberOfDistinctPSegmentsTPC = + mNumberOfDistinctRSegmentsTPC = 0; + mMinZTPC = 1e6; + mMaxZTPC = -1e6; + mMaxRadiusTPC = 0; + + if (mNumberOfParameterizationTPCRat) { + mParameterizationTPCRat->SetOwner(kTRUE); + delete mParameterizationTPCRat; + mParameterizationTPCRat = 0; + delete[] mCoordinatesSegmentsZTPCRat; + mCoordinatesSegmentsZTPCRat = 0; + delete[] mCoordinatesSegmentsPTPCRat; + mCoordinatesSegmentsPTPCRat = 0; + delete[] mCoordinatesSegmentsRTPCRat; + mCoordinatesSegmentsRTPCRat = 0; + delete[] mBeginningOfSegmentsPTPCRat; + mBeginningOfSegmentsPTPCRat = 0; + delete[] mNumberOfSegmentsPTPCRat; + mNumberOfSegmentsPTPCRat = 0; + delete[] mBeginningOfSegmentsRTPCRat; + mBeginningOfSegmentsRTPCRat = 0; + delete[] mNumberOfRSegmentsTPCRat; + mNumberOfRSegmentsTPCRat = 0; + delete[] mSegmentIdTPCRat; + mSegmentIdTPCRat = 0; + } + + mNumberOfParameterizationTPCRat = mNumberOfDistinctZSegmentsTPCRat = mNumberOfDistinctPSegmentsTPCRat = + mNumberOfDistinctRSegmentsTPCRat = 0; + mMinZTPCRat = 1e6; + mMaxZTPCRat = -1e6; + mMaxRadiusTPCRat = 0; + + if (mNumberOfParameterizationDipole) { + mParameterizationDipole->SetOwner(kTRUE); + delete mParameterizationDipole; + mParameterizationDipole = 0; + delete[] mCoordinatesSegmentsZDipole; + mCoordinatesSegmentsZDipole = 0; + delete[] mCoordinatesSegmentsYDipole; + mCoordinatesSegmentsYDipole = 0; + delete[] mCoordinatesSegmentsXDipole; + mCoordinatesSegmentsXDipole = 0; + delete[] mBeginningOfSegmentsYDipole; + mBeginningOfSegmentsYDipole = 0; + delete[] mNumberOfSegmentsYDipole; + mNumberOfSegmentsYDipole = 0; + delete[] mBeginningOfSegmentsXDipole; + mBeginningOfSegmentsXDipole = 0; + delete[] mNumberOfSegmentsXDipole; + mNumberOfSegmentsXDipole = 0; + delete[] mSegmentIdDipole; + mSegmentIdDipole = 0; + } + + mNumberOfParameterizationDipole = mNumberOfDistinctZSegmentsDipole = mNumberOfDistinctYSegmentsDipole = + mNumberOfDistinctXSegmentsDipole = 0; + mMinDipoleZ = 1e6; + mMaxDipoleZ = -1e6; +} + +void MagneticWrapperChebyshev::Field(const Double_t* xyz, Double_t* b) const +{ + Double_t rphiz[3]; + +#ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested + b[0] = b[1] = b[2] = 0; +#endif + + if (xyz[2] > mMinZSolenoid) { + cartesianToCylindrical(xyz, rphiz); + fieldCylindricalSolenoid(rphiz, b); + // convert field to cartesian system + cylindricalToCartesianCylB(rphiz, b, b); + return; + } + + int iddip = findDipoleSegment(xyz); + if (iddip < 0) { + return; + } + Chebyshev3D* par = getParameterDipole(iddip); +#ifndef _BRING_TO_BOUNDARY_ + if (!par->isInside(xyz)) { + return; + } +#endif + par->Eval(xyz, b); +} + +Double_t MagneticWrapperChebyshev::getBz(const Double_t* xyz) const +{ + Double_t rphiz[3]; + + if (xyz[2] > mMinZSolenoid) { + cartesianToCylindrical(xyz, rphiz); + return fieldCylindricalSolenoidBz(rphiz); + } + + int iddip = findDipoleSegment(xyz); + if (iddip < 0) { + return 0.; + } + Chebyshev3D* par = getParameterDipole(iddip); +#ifndef _BRING_TO_BOUNDARY_ + if (!par->isInside(xyz)) { + return 0.; + } +#endif + return par->Eval(xyz, 2); +} + +void MagneticWrapperChebyshev::Print(Option_t*) const +{ + printf("Alice magnetic field parameterized by Chebyshev polynomials\n"); + printf("Segmentation for Solenoid (%+.2fPrint(); + } + } + + printf("Segmentation for TPC field integral (%+.2fPrint(); + } + } + + printf("Segmentation for TPC field ratios integral (%+.2fPrint(); + } + } + + printf("Segmentation for Dipole (%+.2fPrint(); + } + } +} + +Int_t MagneticWrapperChebyshev::findDipoleSegment(const Double_t* xyz) const +{ + if (!mNumberOfParameterizationDipole) { + return -1; + } + int xid, yid, zid = TMath::BinarySearch(mNumberOfDistinctZSegmentsDipole, mCoordinatesSegmentsZDipole, + (Float_t)xyz[2]); // find zsegment + + Bool_t reCheck = kFALSE; + while (1) { + int ysegBeg = mBeginningOfSegmentsYDipole[zid]; + + for (yid = 0; yid < mNumberOfSegmentsYDipole[zid]; yid++) { + if (xyz[1] < mCoordinatesSegmentsYDipole[ysegBeg + yid]) { + break; + } + } + if (--yid < 0) { + yid = 0; + } + yid += ysegBeg; + + int xsegBeg = mBeginningOfSegmentsXDipole[yid]; + for (xid = 0; xid < mNumberOfSegmentsXDipole[yid]; xid++) { + if (xyz[0] < mCoordinatesSegmentsXDipole[xsegBeg + xid]) { + break; + } + } + + if (--xid < 0) { + xid = 0; + } + xid += xsegBeg; + + // to make sure that due to the precision problems we did not pick the next Zbin + if (!reCheck && (xyz[2] - mCoordinatesSegmentsZDipole[zid] < 3.e-5) && zid && + !getParameterDipole(mSegmentIdDipole[xid])->isInside(xyz)) { // check the previous Z bin + zid--; + reCheck = kTRUE; + continue; + } + break; + } + return mSegmentIdDipole[xid]; +} + +Int_t MagneticWrapperChebyshev::findSolenoidSegment(const Double_t* rpz) const +{ + if (!mNumberOfParameterizationSolenoid) { + return -1; + } + int rid, pid, zid = TMath::BinarySearch(mNumberOfDistinctZSegmentsSolenoid, mCoordinatesSegmentsZSolenoid, + (Float_t)rpz[2]); // find zsegment + + Bool_t reCheck = kFALSE; + while (1) { + int psegBeg = mBeginningOfSegmentsPSolenoid[zid]; + for (pid = 0; pid < mNumberOfSegmentsPSolenoid[zid]; pid++) { + if (rpz[1] < mCoordinatesSegmentsPSolenoid[psegBeg + pid]) { + break; + } + } + if (--pid < 0) { + pid = 0; + } + pid += psegBeg; + + int rsegBeg = mBeginningOfSegmentsRSolenoid[pid]; + for (rid = 0; rid < mNumberOfRSegmentsSolenoid[pid]; rid++) { + if (rpz[0] < mCoordinatesSegmentsRSolenoid[rsegBeg + rid]) { + break; + } + } + if (--rid < 0) { + rid = 0; + } + rid += rsegBeg; + + // to make sure that due to the precision problems we did not pick the next Zbin + if (!reCheck && (rpz[2] - mCoordinatesSegmentsZSolenoid[zid] < 3.e-5) && zid && + !getParameterSolenoid(mSegmentIdSolenoid[rid])->isInside(rpz)) { // check the previous Z bin + zid--; + reCheck = kTRUE; + continue; + } + break; + } + return mSegmentIdSolenoid[rid]; +} + +Int_t MagneticWrapperChebyshev::findTPCSegment(const Double_t* rpz) const +{ + if (!mNumberOfParameterizationTPC) { + return -1; + } + int rid, pid, zid = TMath::BinarySearch(mNumberOfDistinctZSegmentsTPC, mCoordinatesSegmentsZTPC, + (Float_t)rpz[2]); // find zsegment + + Bool_t reCheck = kFALSE; + while (1) { + int psegBeg = mBeginningOfSegmentsPTPC[zid]; + + for (pid = 0; pid < mNumberOfSegmentsPTPC[zid]; pid++) { + if (rpz[1] < mCoordinatesSegmentsPTPC[psegBeg + pid]) { + break; + } + } + if (--pid < 0) { + pid = 0; + } + pid += psegBeg; + + int rsegBeg = mBeginningOfSegmentsRTPC[pid]; + for (rid = 0; rid < mNumberOfRSegmentsTPC[pid]; rid++) { + if (rpz[0] < mCoordinatesSegmentsRTPC[rsegBeg + rid]) { + break; + } + } + if (--rid < 0) { + rid = 0; + } + rid += rsegBeg; + + // to make sure that due to the precision problems we did not pick the next Zbin + if (!reCheck && (rpz[2] - mCoordinatesSegmentsZTPC[zid] < 3.e-5) && zid && + !getParameterTPCIntegral(mSegmentIdTPC[rid])->isInside(rpz)) { // check the previous Z bin + zid--; + reCheck = kTRUE; + continue; + } + break; + } + return mSegmentIdTPC[rid]; +} + +Int_t MagneticWrapperChebyshev::findTPCRatSegment(const Double_t* rpz) const +{ + if (!mNumberOfParameterizationTPCRat) { + return -1; + } + int rid, pid, zid = TMath::BinarySearch(mNumberOfDistinctZSegmentsTPCRat, mCoordinatesSegmentsZTPCRat, + (Float_t)rpz[2]); // find zsegment + + Bool_t reCheck = kFALSE; + while (1) { + int psegBeg = mBeginningOfSegmentsPTPCRat[zid]; + + for (pid = 0; pid < mNumberOfSegmentsPTPCRat[zid]; pid++) { + if (rpz[1] < mCoordinatesSegmentsPTPCRat[psegBeg + pid]) { + break; + } + } + if (--pid < 0) { + pid = 0; + } + pid += psegBeg; + + int rsegBeg = mBeginningOfSegmentsRTPCRat[pid]; + for (rid = 0; rid < mNumberOfRSegmentsTPCRat[pid]; rid++) { + if (rpz[0] < mCoordinatesSegmentsRTPCRat[rsegBeg + rid]) { + break; + } + } + if (--rid < 0) { + rid = 0; + } + rid += rsegBeg; + + // to make sure that due to the precision problems we did not pick the next Zbin + if (!reCheck && (rpz[2] - mCoordinatesSegmentsZTPCRat[zid] < 3.e-5) && zid && + !getParameterTPCRatIntegral(mSegmentIdTPCRat[rid])->isInside(rpz)) { // check the previous Z bin + zid--; + reCheck = kTRUE; + continue; + } + break; + } + return mSegmentIdTPCRat[rid]; +} + +void MagneticWrapperChebyshev::getTPCIntegral(const Double_t* xyz, Double_t* b) const +{ + static Double_t rphiz[3]; + + // TPCInt region + // convert coordinates to cyl system + cartesianToCylindrical(xyz, rphiz); +#ifndef _BRING_TO_BOUNDARY_ + if ((rphiz[2] > getMaxZTPCIntegral() || rphiz[2] < getMinZTPCIntegral()) || rphiz[0] > getMaxRTPCIntegral()) { + for (int i = 3; i--;) { + b[i] = 0; + } + return; + } +#endif + + getTPCIntegralCylindrical(rphiz, b); + + // convert field to cartesian system + cylindricalToCartesianCylB(rphiz, b, b); +} + +void MagneticWrapperChebyshev::getTPCRatIntegral(const Double_t* xyz, Double_t* b) const +{ + static Double_t rphiz[3]; + + // TPCRatIntegral region + // convert coordinates to cylindrical system + cartesianToCylindrical(xyz, rphiz); +#ifndef _BRING_TO_BOUNDARY_ + if ((rphiz[2] > getMaxZTPCRatIntegral() || rphiz[2] < getMinZTPCRatIntegral()) || + rphiz[0] > getMaxRTPCRatIntegral()) { + for (int i = 3; i--;) { + b[i] = 0; + } + return; + } +#endif + + getTPCRatIntegralCylindrical(rphiz, b); + + // convert field to cartesian system + cylindricalToCartesianCylB(rphiz, b, b); +} + +void MagneticWrapperChebyshev::fieldCylindricalSolenoid(const Double_t* rphiz, Double_t* b) const +{ + int id = findSolenoidSegment(rphiz); + if (id < 0) { + return; + } + Chebyshev3D* par = getParameterSolenoid(id); +#ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested + if (!par->isInside(rphiz)) { + return; + } +#endif + par->Eval(rphiz, b); + return; +} + +Double_t MagneticWrapperChebyshev::fieldCylindricalSolenoidBz(const Double_t* rphiz) const +{ + int id = findSolenoidSegment(rphiz); + if (id < 0) { + return 0.; + } + Chebyshev3D* par = getParameterSolenoid(id); +#ifndef _BRING_TO_BOUNDARY_ + return par->isInside(rphiz) ? par->Eval(rphiz, 2) : 0; +#else + return par->Eval(rphiz, 2); +#endif +} + +void MagneticWrapperChebyshev::getTPCIntegralCylindrical(const Double_t* rphiz, Double_t* b) const +{ + int id = findTPCSegment(rphiz); + if (id < 0) { + b[0] = b[1] = b[2] = 0; + return; + } + if (id >= mNumberOfParameterizationTPC) { + mLogger->Error(MESSAGE_ORIGIN, "Wrong TPCParam segment %d", id); + b[0] = b[1] = b[2] = 0; + return; + } + Chebyshev3D* par = getParameterTPCIntegral(id); + if (par->isInside(rphiz)) { + par->Eval(rphiz, b); + return; + } + b[0] = b[1] = b[2] = 0; + return; +} + +void MagneticWrapperChebyshev::getTPCRatIntegralCylindrical(const Double_t* rphiz, Double_t* b) const +{ + int id = findTPCRatSegment(rphiz); + if (id < 0) { + b[0] = b[1] = b[2] = 0; + return; + } + if (id >= mNumberOfParameterizationTPCRat) { + mLogger->Error(MESSAGE_ORIGIN, "Wrong TPCRatParam segment %d", id); + b[0] = b[1] = b[2] = 0; + return; + } + Chebyshev3D* par = getParameterTPCRatIntegral(id); + if (par->isInside(rphiz)) { + par->Eval(rphiz, b); + return; + } + b[0] = b[1] = b[2] = 0; + return; +} + +#ifdef _INC_CREATION_ALICHEB3D_ + +void MagneticWrapperChebyshev::loadData(const char* inpfile) +{ + TString strf = inpfile; + gSystem->ExpandPathName(strf); + FILE* stream = fopen(strf, "r"); + + if (!stream) { + printf("Did not find input file %s\n", strf.Data()); + return; + } + + TString buffs; + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("START")) { + Error("LoadData", "Expected: \"START \", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + if (buffs.First(' ') > 0) { + SetName(buffs.Data() + buffs.First(' ') + 1); + } + + // Solenoid part + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("START SOLENOID")) { + Error("LoadData", "Expected: \"START SOLENOID\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + Chebyshev3DCalc::readLine(buffs, stream); // nparam + int nparSol = buffs.Atoi(); + + for (int ip = 0; ip < nparSol; ip++) { + Chebyshev3D* cheb = new Chebyshev3D(); + cheb->loadData(stream); + addParameterSolenoid(cheb); + } + + Chebyshev3DCalc::readLine(buffs, stream); + if (!buffs.BeginsWith("END SOLENOID")) { + Error("LoadData", "Expected \"END SOLENOID\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + // TPCInt part + Chebyshev3DCalc::readLine(buffs, stream); + if (!buffs.BeginsWith("START TPCINT")) { + Error("LoadData", "Expected: \"START TPCINT\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + Chebyshev3DCalc::readLine(buffs, stream); // nparam + int nparTPCInt = buffs.Atoi(); + + for (int ip = 0; ip < nparTPCInt; ip++) { + Chebyshev3D* cheb = new Chebyshev3D(); + cheb->loadData(stream); + AddParamTPCInt(cheb); + } + + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("END TPCINT")) { + Error("LoadData", "Expected \"END TPCINT\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + // TPCRatInt part + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("START TPCRatINT")) { + Error("LoadData", "Expected: \"START TPCRatINT\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + Chebyshev3DCalc::readLine(buffs, stream); // nparam + int nparTPCRatInt = buffs.Atoi(); + + for (int ip = 0; ip < nparTPCRatInt; ip++) { + Chebyshev3D* cheb = new Chebyshev3D(); + cheb->loadData(stream); + AddParamTPCRatInt(cheb); + } + + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("END TPCRatINT")) { + Error("LoadData", "Expected \"END TPCRatINT\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + // Dipole part + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("START DIPOLE")) { + Error("LoadData", "Expected: \"START DIPOLE\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + Chebyshev3DCalc::readLine(buffs, stream); // nparam + int nparDip = buffs.Atoi(); + + for (int ip = 0; ip < nparDip; ip++) { + Chebyshev3D* cheb = new Chebyshev3D(); + cheb->loadData(stream); + addParameterDipole(cheb); + } + + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("END DIPOLE")) { + Error("LoadData", "Expected \"END DIPOLE\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + Chebyshev3DCalc::readLine(buffs, stream); + + if (!buffs.BeginsWith("END DIPOLE") || !buffs.Contains(GetName())) { + Error("LoadData", "Expected: \"END DIPOLE\", found \"%s\"\nStop\n", buffs.Data()); + exit(1); + } + + fclose(stream); + buildTableSolenoid(); + buildTableDipole(); + buildTableTPCIntegral(); + buildTableTPCRatIntegral(); + + printf("Loaded magnetic field \"%s\" from %s\n", GetName(), strf.Data()); +} + +void MagneticWrapperChebyshev::buildTableSolenoid() +{ + buildTable(mNumberOfParameterizationSolenoid, mParameterizationSolenoid, mNumberOfDistinctZSegmentsSolenoid, + mNumberOfDistinctPSegmentsSolenoid, mNumberOfDistinctRSegmentsSolenoid, mMinZSolenoid, mMaxZSolenoid, + &mCoordinatesSegmentsZSolenoid, &mCoordinatesSegmentsPSolenoid, &mCoordinatesSegmentsRSolenoid, + &mBeginningOfSegmentsPSolenoid, &mNumberOfSegmentsPSolenoid, &mBeginningOfSegmentsRSolenoid, + &mNumberOfRSegmentsSolenoid, &mSegmentIdSolenoid); +} + +void MagneticWrapperChebyshev::buildTableDipole() +{ + buildTable(mNumberOfParameterizationDipole, mParameterizationDipole, mNumberOfDistinctZSegmentsDipole, + mNumberOfDistinctYSegmentsDipole, mNumberOfDistinctXSegmentsDipole, mMinDipoleZ, mMaxDipoleZ, + &mCoordinatesSegmentsZDipole, &mCoordinatesSegmentsYDipole, &mCoordinatesSegmentsXDipole, + &mBeginningOfSegmentsYDipole, &mNumberOfSegmentsYDipole, &mBeginningOfSegmentsXDipole, + &mNumberOfSegmentsXDipole, &mSegmentIdDipole); +} + +void MagneticWrapperChebyshev::buildTableTPCIntegral() +{ + buildTable(mNumberOfParameterizationTPC, mParameterizationTPC, mNumberOfDistinctZSegmentsTPC, + mNumberOfDistinctPSegmentsTPC, mNumberOfDistinctRSegmentsTPC, mMinZTPC, mMaxZTPC, + &mCoordinatesSegmentsZTPC, &mCoordinatesSegmentsPTPC, &mCoordinatesSegmentsRTPC, &mBeginningOfSegmentsPTPC, + &mNumberOfSegmentsPTPC, &mBeginningOfSegmentsRTPC, &mNumberOfRSegmentsTPC, &mSegmentIdTPC); +} + +void MagneticWrapperChebyshev::buildTableTPCRatIntegral() +{ + buildTable(mNumberOfParameterizationTPCRat, mParameterizationTPCRat, mNumberOfDistinctZSegmentsTPCRat, + mNumberOfDistinctPSegmentsTPCRat, mNumberOfDistinctRSegmentsTPCRat, mMinZTPCRat, mMaxZTPCRat, + &mCoordinatesSegmentsZTPCRat, &mCoordinatesSegmentsPTPCRat, &mCoordinatesSegmentsRTPCRat, + &mBeginningOfSegmentsPTPCRat, &mNumberOfSegmentsPTPCRat, &mBeginningOfSegmentsRTPCRat, + &mNumberOfRSegmentsTPCRat, &mSegmentIdTPCRat); +} + +#endif + +#ifdef _INC_CREATION_ALICHEB3D_ +MagneticWrapperChebyshev::MagneticWrapperChebyshev(const char* inputFile) + : mNumberOfParameterizationSolenoid(0), + mNumberOfDistinctZSegmentsSolenoid(0), + mNumberOfDistinctPSegmentsSolenoid(0), + mNumberOfDistinctRSegmentsSolenoid(0), + mCoordinatesSegmentsZSolenoid(0), + mCoordinatesSegmentsPSolenoid(0), + mCoordinatesSegmentsRSolenoid(0), + mBeginningOfSegmentsPSolenoid(0), + mNumberOfSegmentsPSolenoid(0), + mBeginningOfSegmentsRSolenoid(0), + mNumberOfRSegmentsSolenoid(0), + mSegmentIdSolenoid(0), + mMinZSolenoid(1.e6), + mMaxZSolenoid(-1.e6), + mParameterizationSolenoid(0), + mMaxRadiusSolenoid(0), + mNumberOfParameterizationTPC(0), + mNumberOfDistinctZSegmentsTPC(0), + mNumberOfDistinctPSegmentsTPC(0), + mNumberOfDistinctRSegmentsTPC(0), + mCoordinatesSegmentsZTPC(0), + mCoordinatesSegmentsPTPC(0), + mCoordinatesSegmentsRTPC(0), + mBeginningOfSegmentsPTPC(0), + mNumberOfSegmentsPTPC(0), + mBeginningOfSegmentsRTPC(0), + mNumberOfRSegmentsTPC(0), + mSegmentIdTPC(0), + mMinZTPC(1.e6), + mMaxZTPC(-1.e6), + mParameterizationTPC(0), + mMaxRadiusTPC(0), + mNumberOfParameterizationTPCRat(0), + mNumberOfDistinctZSegmentsTPCRat(0), + mNumberOfDistinctPSegmentsTPCRat(0), + mNumberOfDistinctRSegmentsTPCRat(0), + mCoordinatesSegmentsZTPCRat(0), + mCoordinatesSegmentsPTPCRat(0), + mCoordinatesSegmentsRTPCRat(0), + mBeginningOfSegmentsPTPCRat(0), + mNumberOfSegmentsPTPCRat(0), + mBeginningOfSegmentsRTPCRat(0), + mNumberOfRSegmentsTPCRat(0), + mSegmentIdTPCRat(0), + mMinZTPCRat(1.e6), + mMaxZTPCRat(-1.e6), + mParameterizationTPCRat(0), + mMaxRadiusTPCRat(0), + mNumberOfParameterizationDipole(0), + mNumberOfDistinctZSegmentsDipole(0), + mNumberOfDistinctYSegmentsDipole(0), + mNumberOfDistinctXSegmentsDipole(0), + mCoordinatesSegmentsZDipole(0), + mCoordinatesSegmentsYDipole(0), + mCoordinatesSegmentsXDipole(0), + mBeginningOfSegmentsYDipole(0), + mNumberOfSegmentsYDipole(0), + mBeginningOfSegmentsXDipole(0), + mNumberOfSegmentsXDipole(0), + mSegmentIdDipole(0), + mMinDipoleZ(1.e6), + mMaxDipoleZ(-1.e6), + mParameterizationDipole(0) +{ + loadData(inputFile); +} + +void MagneticWrapperChebyshev::addParameterSolenoid(const Chebyshev3D* param) +{ + if (!mParameterizationSolenoid) { + mParameterizationSolenoid = new TObjArray(); + } + mParameterizationSolenoid->Add((Chebyshev3D*)param); + mNumberOfParameterizationSolenoid++; + if (mMaxRadiusSolenoid < param->getBoundMax(0)) { + mMaxRadiusSolenoid = param->getBoundMax(0); + } +} + +void MagneticWrapperChebyshev::addParameterTPCIntegral(const Chebyshev3D* param) +{ + if (!mParameterizationTPC) { + mParameterizationTPC = new TObjArray(); + } + mParameterizationTPC->Add((Chebyshev3D*)param); + mNumberOfParameterizationTPC++; + if (mMaxRadiusTPC < param->getBoundMax(0)) { + mMaxRadiusTPC = param->getBoundMax(0); + } +} + +void MagneticWrapperChebyshev::addParameterTPCRatIntegral(const Chebyshev3D* param) +{ + if (!mParameterizationTPCRat) { + mParameterizationTPCRat = new TObjArray(); + } + mParameterizationTPCRat->Add((Chebyshev3D*)param); + mNumberOfParameterizationTPCRat++; + if (mMaxRadiusTPCRat < param->getBoundMax(0)) { + mMaxRadiusTPCRat = param->getBoundMax(0); + } +} + +void MagneticWrapperChebyshev::AddParamDipole(const Chebyshev3D* param) +{ + if (!mParameterizationDipole) { + mParameterizationDipole = new TObjArray(); + } + mParameterizationDipole->Add((Chebyshev3D*)param); + mNumberOfParameterizationDipole++; +} + +void MagneticWrapperChebyshev::resetDipole() +{ + if (mNumberOfParameterizationDipole) { + delete mParameterizationDipole; + mParameterizationDipole = 0; + delete[] mCoordinatesSegmentsZDipole; + mCoordinatesSegmentsZDipole = 0; + delete[] mCoordinatesSegmentsXDipole; + mCoordinatesSegmentsXDipole = 0; + delete[] mCoordinatesSegmentsYDipole; + mCoordinatesSegmentsYDipole = 0; + delete[] mBeginningOfSegmentsYDipole; + mBeginningOfSegmentsYDipole = 0; + delete[] mNumberOfSegmentsYDipole; + mNumberOfSegmentsYDipole = 0; + delete[] mBeginningOfSegmentsXDipole; + mBeginningOfSegmentsXDipole = 0; + delete[] mNumberOfSegmentsXDipole; + mNumberOfSegmentsXDipole = 0; + delete[] mSegmentIdDipole; + mSegmentIdDipole = 0; + } + mNumberOfParameterizationDipole = mNumberOfDistinctZSegmentsDipole = mNumberOfDistinctXSegmentsDipole = + mNumberOfDistinctYSegmentsDipole = 0; + mMinDipoleZ = 1e6; + mMaxDipoleZ = -1e6; +} + +void MagneticWrapperChebyshev::resetSolenoid() +{ + if (mNumberOfParameterizationSolenoid) { + delete mParameterizationSolenoid; + mParameterizationSolenoid = 0; + delete[] mCoordinatesSegmentsZSolenoid; + mCoordinatesSegmentsZSolenoid = 0; + delete[] mCoordinatesSegmentsPSolenoid; + mCoordinatesSegmentsPSolenoid = 0; + delete[] mCoordinatesSegmentsRSolenoid; + mCoordinatesSegmentsRSolenoid = 0; + delete[] mBeginningOfSegmentsPSolenoid; + mBeginningOfSegmentsPSolenoid = 0; + delete[] mNumberOfSegmentsPSolenoid; + mNumberOfSegmentsPSolenoid = 0; + delete[] mBeginningOfSegmentsRSolenoid; + mBeginningOfSegmentsRSolenoid = 0; + delete[] mNumberOfRSegmentsSolenoid; + mNumberOfRSegmentsSolenoid = 0; + delete[] mSegmentIdSolenoid; + mSegmentIdSolenoid = 0; + } + mNumberOfParameterizationSolenoid = mNumberOfDistinctZSegmentsSolenoid = mNumberOfDistinctPSegmentsSolenoid = + mNumberOfDistinctRSegmentsSolenoid = 0; + mMinZSolenoid = 1e6; + mMaxZSolenoid = -1e6; + mMaxRadiusSolenoid = 0; +} + +void MagneticWrapperChebyshev::resetTPCIntegral() +{ + if (mNumberOfParameterizationTPC) { + delete mParameterizationTPC; + mParameterizationTPC = 0; + delete[] mCoordinatesSegmentsZTPC; + mCoordinatesSegmentsZTPC = 0; + delete[] mCoordinatesSegmentsPTPC; + mCoordinatesSegmentsPTPC = 0; + delete[] mCoordinatesSegmentsRTPC; + mCoordinatesSegmentsRTPC = 0; + delete[] mBeginningOfSegmentsPTPC; + mBeginningOfSegmentsPTPC = 0; + delete[] mNumberOfSegmentsPTPC; + mNumberOfSegmentsPTPC = 0; + delete[] mBeginningOfSegmentsRTPC; + mBeginningOfSegmentsRTPC = 0; + delete[] mNumberOfRSegmentsTPC; + mNumberOfRSegmentsTPC = 0; + delete[] mSegmentIdTPC; + mSegmentIdTPC = 0; + } + mNumberOfParameterizationTPC = mNumberOfDistinctZSegmentsTPC = mNumberOfDistinctPSegmentsTPC = + mNumberOfDistinctRSegmentsTPC = 0; + mMinZTPC = 1e6; + mMaxZTPC = -1e6; + mMaxRadiusTPC = 0; +} + +void MagneticWrapperChebyshev::resetTPCRatIntegral() +{ + if (mNumberOfParameterizationTPCRat) { + delete mParameterizationTPCRat; + mParameterizationTPCRat = 0; + delete[] mCoordinatesSegmentsZTPCRat; + mCoordinatesSegmentsZTPCRat = 0; + delete[] mCoordinatesSegmentsPTPCRat; + mCoordinatesSegmentsPTPCRat = 0; + delete[] mCoordinatesSegmentsRTPCRat; + mCoordinatesSegmentsRTPCRat = 0; + delete[] mBeginningOfSegmentsPTPCRat; + mBeginningOfSegmentsPTPCRat = 0; + delete[] mNumberOfSegmentsPTPCRat; + mNumberOfSegmentsPTPCRat = 0; + delete[] mBeginningOfSegmentsRTPCRat; + mBeginningOfSegmentsRTPCRat = 0; + delete[] mNumberOfRSegmentsTPCRat; + mNumberOfRSegmentsTPCRat = 0; + delete[] mSegmentIdTPCRat; + mSegmentIdTPCRat = 0; + } + mNumberOfParameterizationTPCRat = mNumberOfDistinctZSegmentsTPCRat = mNumberOfDistinctPSegmentsTPCRat = + mNumberOfDistinctRSegmentsTPCRat = 0; + mMinZTPCRat = 1e6; + mMaxZTPCRat = -1e6; + mMaxRadiusTPCRat = 0; +} + +void MagneticWrapperChebyshev::buildTable(Int_t npar, TObjArray* parArr, Int_t& nZSeg, Int_t& nYSeg, Int_t& nXSeg, + Float_t& minZ, Float_t& maxZ, Float_t** segZ, Float_t** segY, Float_t** segX, + Int_t** begSegY, Int_t** nSegY, Int_t** begSegX, Int_t** nSegX, Int_t** segID) +{ + if (npar < 1) { + return; + } + TArrayF segYArr, segXArr; + TArrayI begSegYDipArr, begSegXDipArr; + TArrayI nSegYDipArr, nSegXDipArr; + TArrayI segIDArr; + float* tmpSegZ, *tmpSegY, *tmpSegX; + + // create segmentation in Z + nZSeg = segmentDimension(&tmpSegZ, parArr, npar, 2, 1, -1, 1, -1, 1, -1) - 1; + nYSeg = 0; + nXSeg = 0; + + // for each Z slice create segmentation in Y + begSegYDipArr.Set(nZSeg); + nSegYDipArr.Set(nZSeg); + float xyz[3]; + for (int iz = 0; iz < nZSeg; iz++) { + printf("\nZSegment#%d %+e : %+e\n", iz, tmpSegZ[iz], tmpSegZ[iz + 1]); + int ny = segmentDimension(&tmpSegY, parArr, npar, 1, 1, -1, 1, -1, tmpSegZ[iz], tmpSegZ[iz + 1]) - 1; + segYArr.Set(ny + nYSeg); + for (int iy = 0; iy < ny; iy++) { + segYArr[nYSeg + iy] = tmpSegY[iy]; + } + begSegYDipArr[iz] = nYSeg; + nSegYDipArr[iz] = ny; + printf(" Found %d YSegments, to start from %d\n", ny, begSegYDipArr[iz]); + + // for each slice in Z and Y create segmentation in X + begSegXDipArr.Set(nYSeg + ny); + nSegXDipArr.Set(nYSeg + ny); + xyz[2] = (tmpSegZ[iz] + tmpSegZ[iz + 1]) / 2.; // mean Z of this segment + + for (int iy = 0; iy < ny; iy++) { + int isg = nYSeg + iy; + printf("\n YSegment#%d %+e : %+e\n", iy, tmpSegY[iy], tmpSegY[iy + 1]); + int nx = + segmentDimension(&tmpSegX, parArr, npar, 0, 1, -1, tmpSegY[iy], tmpSegY[iy + 1], tmpSegZ[iz], tmpSegZ[iz + 1]) - + 1; + + segXArr.Set(nx + nXSeg); + for (int ix = 0; ix < nx; ix++) { + segXArr[nXSeg + ix] = tmpSegX[ix]; + } + begSegXDipArr[isg] = nXSeg; + nSegXDipArr[isg] = nx; + printf(" Found %d XSegments, to start from %d\n", nx, begSegXDipArr[isg]); + + segIDArr.Set(nXSeg + nx); + + // find corresponding params + xyz[1] = (tmpSegY[iy] + tmpSegY[iy + 1]) / 2.; // mean Y of this segment + + for (int ix = 0; ix < nx; ix++) { + xyz[0] = (tmpSegX[ix] + tmpSegX[ix + 1]) / 2.; // mean X of this segment + for (int ipar = 0; ipar < npar; ipar++) { + Chebyshev3D* cheb = (Chebyshev3D*)parArr->At(ipar); + if (!cheb->isInside(xyz)) { + continue; + } + segIDArr[nXSeg + ix] = ipar; + break; + } + } + nXSeg += nx; + + delete[] tmpSegX; + } + delete[] tmpSegY; + nYSeg += ny; + } + + minZ = tmpSegZ[0]; + maxZ = tmpSegZ[nZSeg]; + (*segZ) = new Float_t[nZSeg]; + for (int i = nZSeg; i--;) { + (*segZ)[i] = tmpSegZ[i]; + } + delete[] tmpSegZ; + + (*segY) = new Float_t[nYSeg]; + (*segX) = new Float_t[nXSeg]; + (*begSegY) = new Int_t[nZSeg]; + (*nSegY) = new Int_t[nZSeg]; + (*begSegX) = new Int_t[nYSeg]; + (*nSegX) = new Int_t[nYSeg]; + (*segID) = new Int_t[nXSeg]; + + for (int i = nYSeg; i--;) { + (*segY)[i] = segYArr[i]; + } + for (int i = nXSeg; i--;) { + (*segX)[i] = segXArr[i]; + } + for (int i = nZSeg; i--;) { + (*begSegY)[i] = begSegYDipArr[i]; + (*nSegY)[i] = nSegYDipArr[i]; + } + for (int i = nYSeg; i--;) { + (*begSegX)[i] = begSegXDipArr[i]; + (*nSegX)[i] = nSegXDipArr[i]; + } + for (int i = nXSeg; i--;) { + (*segID)[i] = segIDArr[i]; + } +} + +// void MagneticWrapperChebyshev::BuildTableDip() +// { +// // build lookup table for dipole +// +// if (mNumberOfParameterizationDipole<1) return; +// TArrayF segY,segX; +// TArrayI begSegYDip,begSegXDip; +// TArrayI nsegYDip,nsegXDip; +// TArrayI segID; +// float *tmpSegZ,*tmpSegY,*tmpSegX; +// +// // create segmentation in Z +// mNumberOfDistinctZSegmentsDipole = segmentDimension(&tmpSegZ, mParameterizationDipole, +// mNumberOfParameterizationDipole, 2, 1,-1, 1,-1, 1,-1) - 1; +// mNumberOfDistinctYSegmentsDipole = 0; +// mNumberOfDistinctXSegmentsDipole = 0; +// +// // for each Z slice create segmentation in Y +// begSegYDip.Set(mNumberOfDistinctZSegmentsDipole); +// nsegYDip.Set(mNumberOfDistinctZSegmentsDipole); +// float xyz[3]; +// for (int iz=0;izAt(ipar); +// if (!cheb->isInside(xyz)) continue; +// segID[mNumberOfDistinctXSegmentsDipole+ix] = ipar; +// break; +// } +// } +// mNumberOfDistinctXSegmentsDipole += nx; +// +// delete[] tmpSegX; +// } +// delete[] tmpSegY; +// mNumberOfDistinctYSegmentsDipole += ny; +// } +// +// mMinDipoleZ = tmpSegZ[0]; +// mMaxDipoleZ = tmpSegZ[mNumberOfDistinctZSegmentsDipole]; +// mCoordinatesSegmentsZDipole = new Float_t[mNumberOfDistinctZSegmentsDipole]; +// for (int i=mNumberOfDistinctZSegmentsDipole;i--;) mCoordinatesSegmentsZDipole[i] = tmpSegZ[i]; +// delete[] tmpSegZ; +// +// mCoordinatesSegmentsYDipole = new Float_t[mNumberOfDistinctYSegmentsDipole]; +// mCoordinatesSegmentsXDipole = new Float_t[mNumberOfDistinctXSegmentsDipole]; +// mBeginningOfSegmentsYDipole = new Int_t[mNumberOfDistinctZSegmentsDipole]; +// mNumberOfSegmentsYDipole = new Int_t[mNumberOfDistinctZSegmentsDipole]; +// mBeginningOfSegmentsXDipole = new Int_t[mNumberOfDistinctYSegmentsDipole]; +// mNumberOfSegmentsXDipole = new Int_t[mNumberOfDistinctYSegmentsDipole]; +// mSegmentIdDipole = new Int_t[mNumberOfDistinctXSegmentsDipole]; +// +// for (int i=mNumberOfDistinctYSegmentsDipole;i--;) mCoordinatesSegmentsYDipole[i] = segY[i]; +// for (int i=mNumberOfDistinctXSegmentsDipole;i--;) mCoordinatesSegmentsXDipole[i] = segX[i]; +// for (int i=mNumberOfDistinctZSegmentsDipole;i--;) {mBeginningOfSegmentsYDipole[i] = begSegYDip[i]; +// mNumberOfSegmentsYDipole[i] = nsegYDip[i];} +// for (int i=mNumberOfDistinctYSegmentsDipole;i--;) {mBeginningOfSegmentsXDipole[i] = begSegXDip[i]; +// mNumberOfSegmentsXDipole[i] = nsegXDip[i];} +// for (int i=mNumberOfDistinctXSegmentsDipole;i--;) {mSegmentIdDipole[i] = segID[i];} +// } + +void MagneticWrapperChebyshev::saveData(const char* outfile) const +{ + TString strf = outfile; + gSystem->ExpandPathName(strf); + FILE* stream = fopen(strf, "w+"); + + // Solenoid part + fprintf(stream, "# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n", GetName()); + fprintf(stream, "START SOLENOID\n#Number of pieces\n%d\n", mNumberOfParameterizationSolenoid); + for (int ip = 0; ip < mNumberOfParameterizationSolenoid; ip++) { + getParameterSolenoid(ip)->saveData(stream); + } + fprintf(stream, "#\nEND SOLENOID\n"); + + // TPCIntegral part + fprintf(stream, "# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n", GetName()); + fprintf(stream, "START TPCINT\n#Number of pieces\n%d\n", mNumberOfParameterizationTPC); + for (int ip = 0; ip < mNumberOfParameterizationTPC; ip++) + getParameterTPCIntegral(ip)->saveData(stream); + fprintf(stream, "#\nEND TPCINT\n"); + + // TPCRatIntegral part + fprintf(stream, "# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n", GetName()); + fprintf(stream, "START TPCRatINT\n#Number of pieces\n%d\n", mNumberOfParameterizationTPCRat); + for (int ip = 0; ip < mNumberOfParameterizationTPCRat; ip++) { + getParameterTPCRatIntegral(ip)->saveData(stream); + } + fprintf(stream, "#\nEND TPCRatINT\n"); + + // Dipole part + fprintf(stream, "START DIPOLE\n#Number of pieces\n%d\n", mNumberOfParameterizationDipole); + for (int ip = 0; ip < mNumberOfParameterizationDipole; ip++) { + getParameterDipole(ip)->saveData(stream); + } + fprintf(stream, "#\nEND DIPOLE\n"); + + fprintf(stream, "#\nEND %s\n", GetName()); + + fclose(stream); +} + +Int_t MagneticWrapperChebyshev::segmentDimension(float** seg, const TObjArray* par, int npar, int dim, float xmn, + float xmx, float ymn, float ymx, float zmn, float zmx) +{ + float* tmpC = new float[2 * npar]; + int* tmpInd = new int[2 * npar]; + int nseg0 = 0; + for (int ip = 0; ip < npar; ip++) { + Chebyshev3D* cheb = (Chebyshev3D*)par->At(ip); + if (xmn < xmx && (cheb->getBoundMin(0) > (xmx + xmn) / 2 || cheb->getBoundMax(0) < (xmn + xmx) / 2)) { + continue; + } + if (ymn < ymx && (cheb->getBoundMin(1) > (ymx + ymn) / 2 || cheb->getBoundMax(1) < (ymn + ymx) / 2)) { + continue; + } + if (zmn < zmx && (cheb->getBoundMin(2) > (zmx + zmn) / 2 || cheb->getBoundMax(2) < (zmn + zmx) / 2)) { + continue; + } + + tmpC[nseg0++] = cheb->getBoundMin(dim); + tmpC[nseg0++] = cheb->getBoundMax(dim); + } + // range Dim's boundaries in increasing order + TMath::Sort(nseg0, tmpC, tmpInd, kFALSE); + // count number of really different Z's + int nseg = 0; + float cprev = -1e6; + for (int ip = 0; ip < nseg0; ip++) { + if (TMath::Abs(cprev - tmpC[tmpInd[ip]]) > 1e-4) { + cprev = tmpC[tmpInd[ip]]; + nseg++; + } else { + tmpInd[ip] = -1; // supress redundant Z + } + } + + *seg = new float[nseg]; // create final Z segmenations + nseg = 0; + for (int ip = 0; ip < nseg0; ip++) { + if (tmpInd[ip] >= 0) { + (*seg)[nseg++] = tmpC[tmpInd[ip]]; + } + } + + delete[] tmpC; + delete[] tmpInd; + return nseg; +} + +#endif diff --git a/field/MagneticWrapperChebyshev.h b/field/MagneticWrapperChebyshev.h new file mode 100644 index 0000000000000..00fababf52327 --- /dev/null +++ b/field/MagneticWrapperChebyshev.h @@ -0,0 +1,471 @@ +/// \file MagWrapCheb.h +/// \brief Definition of the MagWrapCheb class +/// \author ruben.shahoyan@cern.ch 20/03/2007 + +#ifndef ALICEO2_FIELD_MAGNETICWRAPPERCHEBYSHEV_H_ +#define ALICEO2_FIELD_MAGNETICWRAPPERCHEBYSHEV_H_ + +#include +#include +#include +#include "Chebyshev3D.h" + +class TSystem; +class TArrayF; +class TArrayI; +class FairLogger; + +namespace AliceO2 { +namespace Field { + +/// Wrapper for the set of mag.field parameterizations by Chebyshev polinomials +/// To obtain the field in cartesian coordinates/components use +/// Field(double* xyz, double* bxyz); +/// For cylindrical coordinates/components: +/// fieldCylindrical(double* rphiz, double* brphiz) +/// The solenoid part is parameterized in the volume R<500, -550UncheckedAt(ipar); + } + + Chebyshev3D* getParameterTPCRatIntegral(Int_t ipar) const + { + return (Chebyshev3D*)mParameterizationTPCRat->UncheckedAt(ipar); + } + + Chebyshev3D* getParameterTPCIntegral(Int_t ipar) const + { + return (Chebyshev3D*)mParameterizationTPC->UncheckedAt(ipar); + } + + Chebyshev3D* getParameterDipole(Int_t ipar) const + { + return (Chebyshev3D*)mParameterizationDipole->UncheckedAt(ipar); + } + + /// Prints info + virtual void Print(Option_t* = "") const; + + /// Computes field in cartesian coordinates. If point is outside of the parameterized region + /// it gets it at closest valid point + virtual void Field(const Double_t* xyz, Double_t* b) const; + /// Computes Bz for the point in cartesian coordinates. If point is outside of the parameterized region + /// it gets it at closest valid point + Double_t getBz(const Double_t* xyz) const; + + void fieldCylindrical(const Double_t* rphiz, Double_t* b) const; + + /// Computes TPC region field integral in cartesian coordinates. + /// If point is outside of the parameterized region it gets it at closeset valid point + void getTPCIntegral(const Double_t* xyz, Double_t* b) const; + + // Computes field integral in TPC region in Cylindircal coordinates + // note: the check for the point being inside the parameterized region is done outside + void getTPCIntegralCylindrical(const Double_t* rphiz, Double_t* b) const; + + /// Computes TPCRat region field integral in cartesian coordinates. + /// If point is outside of the parameterized region it gets it at closeset valid point + void getTPCRatIntegral(const Double_t* xyz, Double_t* b) const; + + // Computes field integral in TPCRat region in Cylindircal coordinates + // note: the check for the point being inside the parameterized region is done outside + void getTPCRatIntegralCylindrical(const Double_t* rphiz, Double_t* b) const; + + /// Finds the segment containing point xyz. If it is outside it finds the closest segment + Int_t findSolenoidSegment(const Double_t* xyz) const; + + /// Finds the segment containing point xyz. If it is outside it finds the closest segment + Int_t findTPCSegment(const Double_t* xyz) const; + + /// Finds the segment containing point xyz. If it is outside it finds the closest segment + Int_t findTPCRatSegment(const Double_t* xyz) const; + + /// Finds the segment containing point xyz. If it is outside it finds the closest segment + Int_t findDipoleSegment(const Double_t* xyz) const; + static void cylindricalToCartesianCylB(const Double_t* rphiz, const Double_t* brphiz, Double_t* bxyz); + static void cylindricalToCartesianCartB(const Double_t* xyz, const Double_t* brphiz, Double_t* bxyz); + static void cartesianToCylindricalCartB(const Double_t* xyz, const Double_t* bxyz, Double_t* brphiz); + static void cartesianToCylindricalCylB(const Double_t* rphiz, const Double_t* bxyz, Double_t* brphiz); + 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 + /// Reads coefficients data from the text file + void loadData(const char* inpfile); + + /// Construct from coefficients from the text file + MagneticWrapperChebyshev(const char* inputFile); + + /// Writes coefficients data to output text file + void saveData(const char* outfile) const; + + /// Finds all boundaries in dimension dim for boxes in given region. + /// if mn > mx for given projection the check is not done for it. + Int_t segmentDimension(Float_t** seg, const TObjArray* par, int npar, int dim, Float_t xmn, Float_t xmx, Float_t ymn, + Float_t ymx, Float_t zmn, Float_t zmx); + + /// Adds new parameterization piece for Solenoid + /// NOTE: pieces must be added strictly in increasing R then increasing Z order + void addParameterSolenoid(const 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); + /// Adds new parameterization piece for TPCRatInt + // NOTE: pieces must be added strictly in increasing R then increasing Z order + void addParameterTPCRatIntegral(const Chebyshev3D* param); + + /// Adds new parameterization piece for Dipole + void addParameterDipole(const 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, + Float_t** segZ, Float_t** segY, Float_t** segX, Int_t** begSegY, Int_t** nSegY, Int_t** begSegX, + Int_t** nSegX, Int_t** segID); + + /// Builds lookup table + void buildTableSolenoid(); + + /// Builds lookup table + void buildTableDipole(); + + /// Builds lookup table + void buildTableTPCIntegral(); + + /// Builds lookup table + void buildTableTPCRatIntegral(); + + /// Cleans TPC field integral (used for update) + void resetTPCIntegral(); + + /// Cleans TPCRat field integral (used for update) + void resetTPCRatIntegral(); + + /// Cleans Solenoid field (used for update) + void resetSolenoid(); + + /// Cleans Dipole field (used for update) + void resetDipole(); +#endif + +protected: + /// Compute Solenoid field in Cylindircal coordinates + /// note: if the point is outside the volume it gets the field in closest parameterized point + void fieldCylindricalSolenoid(const Double_t* rphiz, Double_t* b) const; + + /// Compute Solenoid field in Cylindircal coordinates + /// note: if the point is outside the volume it gets the field in closest parameterized point + Double_t fieldCylindricalSolenoidBz(const Double_t* rphiz) const; + +protected: + Int_t mNumberOfParameterizationSolenoid; ///< Total number of parameterization pieces for solenoid + Int_t mNumberOfDistinctZSegmentsSolenoid; ///< number of distinct Z segments in Solenoid + Int_t mNumberOfDistinctPSegmentsSolenoid; ///< number of distinct P segments in Solenoid + Int_t mNumberOfDistinctRSegmentsSolenoid; ///< number of distinct R segments in Solenoid + Float_t* + mCoordinatesSegmentsZSolenoid; //[mNumberOfDistinctZSegmentsSolenoid] coordinates of distinct Z segments in Solenoid + Float_t* mCoordinatesSegmentsPSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] coordinates of P segments for each + // Zsegment in Solenoid + Float_t* mCoordinatesSegmentsRSolenoid; //[mNumberOfDistinctRSegmentsSolenoid] coordinates of R segments for each + // Psegment in Solenoid + Int_t* mBeginningOfSegmentsPSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] beginning of P segments array for each Z + // segment + Int_t* mNumberOfSegmentsPSolenoid; //[mNumberOfDistinctZSegmentsSolenoid] number of P segments for each Z segment + Int_t* mBeginningOfSegmentsRSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] beginning of R segments array for each P + // segment + Int_t* mNumberOfRSegmentsSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] number of R segments for each P segment + Int_t* + mSegmentIdSolenoid; //[mNumberOfDistinctRSegmentsSolenoid] ID of the solenoid parameterization for given RPZ segment + Float_t mMinZSolenoid; ///< Min Z of Solenoid parameterization + Float_t mMaxZSolenoid; ///< Max Z of Solenoid parameterization + TObjArray* mParameterizationSolenoid; ///< Parameterization pieces for Solenoid field + Float_t mMaxRadiusSolenoid; ///< max radius for Solenoid field + + Int_t mNumberOfParameterizationTPC; ///< Total number of parameterization pieces for TPCint + Int_t mNumberOfDistinctZSegmentsTPC; ///< number of distinct Z segments in TPCint + Int_t mNumberOfDistinctPSegmentsTPC; ///< number of distinct P segments in TPCint + Int_t mNumberOfDistinctRSegmentsTPC; ///< number of distinct R segments in TPCint + Float_t* mCoordinatesSegmentsZTPC; //[mNumberOfDistinctZSegmentsTPC] coordinates of distinct Z segments in TPCint + Float_t* + mCoordinatesSegmentsPTPC; //[mNumberOfDistinctPSegmentsTPC] coordinates of P segments for each Zsegment in TPCint + Float_t* + mCoordinatesSegmentsRTPC; //[mNumberOfDistinctRSegmentsTPC] coordinates of R segments for each Psegment in TPCint + Int_t* mBeginningOfSegmentsPTPC; //[mNumberOfDistinctPSegmentsTPC] beginning of P segments array for each Z segment + Int_t* mNumberOfSegmentsPTPC; //[mNumberOfDistinctZSegmentsTPC] number of P segments for each Z segment + Int_t* mBeginningOfSegmentsRTPC; //[mNumberOfDistinctPSegmentsTPC] beginning of R segments array for each P segment + Int_t* mNumberOfRSegmentsTPC; //[mNumberOfDistinctPSegmentsTPC] number of R segments for each P segment + Int_t* mSegmentIdTPC; //[mNumberOfDistinctRSegmentsTPC] ID of the TPCint parameterization for given RPZ segment + Float_t mMinZTPC; ///< Min Z of TPCint parameterization + Float_t mMaxZTPC; ///< Max Z of TPCint parameterization + TObjArray* mParameterizationTPC; ///< Parameterization pieces for TPCint field + Float_t mMaxRadiusTPC; ///< max radius for Solenoid field integral in TPC + + Int_t + mNumberOfParameterizationTPCRat; ///< Total number of parameterization pieces for tr.field to Bz integrals in TPC + ///< region + Int_t mNumberOfDistinctZSegmentsTPCRat; ///< number of distinct Z segments in TpcRatInt + Int_t mNumberOfDistinctPSegmentsTPCRat; ///< number of distinct P segments in TpcRatInt + Int_t mNumberOfDistinctRSegmentsTPCRat; ///< number of distinct R segments in TpcRatInt + Float_t* + mCoordinatesSegmentsZTPCRat; //[mNumberOfDistinctZSegmentsTPCRat] coordinates of distinct Z segments in TpcRatInt + Float_t* mCoordinatesSegmentsPTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] coordinates of P segments for each Zsegment + // in TpcRatInt + Float_t* mCoordinatesSegmentsRTPCRat; //[mNumberOfDistinctRSegmentsTPCRat] coordinates of R segments for each Psegment + // in TpcRatInt + Int_t* + mBeginningOfSegmentsPTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] beginning of P segments array for each Z segment + Int_t* mNumberOfSegmentsPTPCRat; //[mNumberOfDistinctZSegmentsTPCRat] number of P segments for each Z segment + Int_t* + mBeginningOfSegmentsRTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] beginning of R segments array for each P segment + Int_t* mNumberOfRSegmentsTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] number of R segments for each P segment + Int_t* + mSegmentIdTPCRat; //[mNumberOfDistinctRSegmentsTPCRat] ID of the TpcRatInt parameterization for given RPZ segment + Float_t mMinZTPCRat; ///< Min Z of TpcRatInt parameterization + Float_t mMaxZTPCRat; ///< Max Z of TpcRatInt parameterization + TObjArray* mParameterizationTPCRat; ///< Parameterization pieces for TpcRatInt field + Float_t mMaxRadiusTPCRat; ///< max radius for Solenoid field ratios integral in TPC + + Int_t mNumberOfParameterizationDipole; ///< Total number of parameterization pieces for dipole + Int_t mNumberOfDistinctZSegmentsDipole; ///< number of distinct Z segments in Dipole + Int_t mNumberOfDistinctYSegmentsDipole; ///< number of distinct Y segments in Dipole + Int_t mNumberOfDistinctXSegmentsDipole; ///< number of distinct X segments in Dipole + Float_t* + mCoordinatesSegmentsZDipole; //[mNumberOfDistinctZSegmentsDipole] coordinates of distinct Z segments in Dipole + Float_t* mCoordinatesSegmentsYDipole; //[mNumberOfDistinctYSegmentsDipole] coordinates of Y segments for each Zsegment + // in Dipole + Float_t* mCoordinatesSegmentsXDipole; //[mNumberOfDistinctXSegmentsDipole] coordinates of X segments for each Ysegment + // in Dipole + Int_t* + mBeginningOfSegmentsYDipole; //[mNumberOfDistinctZSegmentsDipole] beginning of Y segments array for each Z segment + Int_t* mNumberOfSegmentsYDipole; //[mNumberOfDistinctZSegmentsDipole] number of Y segments for each Z segment + Int_t* + mBeginningOfSegmentsXDipole; //[mNumberOfDistinctYSegmentsDipole] beginning of X segments array for each Y segment + Int_t* mNumberOfSegmentsXDipole; //[mNumberOfDistinctYSegmentsDipole] number of X segments for each Y segment + Int_t* mSegmentIdDipole; //[mNumberOfDistinctXSegmentsDipole] ID of the dipole parameterization for given XYZ segment + Float_t mMinDipoleZ; ///< Min Z of Dipole parameterization + Float_t mMaxDipoleZ; ///< Max Z of Dipole parameterization + TObjArray* mParameterizationDipole; ///< Parameterization pieces for Dipole field + + FairLogger* mLogger; + ClassDef(MagneticWrapperChebyshev, 1) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field +}; + +/// Computes field in Cylindircal coordinates +inline void MagneticWrapperChebyshev::fieldCylindrical(const Double_t* rphiz, Double_t* b) const +{ + // if (rphiz[2]GetMaxZSol() || rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;} + b[0] = b[1] = b[2] = 0; + fieldCylindricalSolenoid(rphiz, b); +} + +/// Converts field in cylindrical coordinates to cartesian system, point is in cyl.system +inline void MagneticWrapperChebyshev::cylindricalToCartesianCylB(const Double_t* rphiz, const Double_t* brphiz, + Double_t* bxyz) +{ + Double_t btr = TMath::Sqrt(brphiz[0] * brphiz[0] + brphiz[1] * brphiz[1]); + Double_t psiPLUSphi = TMath::ATan2(brphiz[1], brphiz[0]) + rphiz[1]; + bxyz[0] = btr * TMath::Cos(psiPLUSphi); + bxyz[1] = btr * TMath::Sin(psiPLUSphi); + bxyz[2] = brphiz[2]; +} + +/// Converts field in cylindrical coordinates to cartesian system, point is in cart.system +inline void MagneticWrapperChebyshev::cylindricalToCartesianCartB(const Double_t* xyz, const Double_t* brphiz, + Double_t* bxyz) +{ + Double_t btr = TMath::Sqrt(brphiz[0] * brphiz[0] + brphiz[1] * brphiz[1]); + Double_t phiPLUSpsi = TMath::ATan2(xyz[1], xyz[0]) + TMath::ATan2(brphiz[1], brphiz[0]); + bxyz[0] = btr * TMath::Cos(phiPLUSpsi); + bxyz[1] = btr * TMath::Sin(phiPLUSpsi); + bxyz[2] = brphiz[2]; +} + +/// Converts field in cylindrical coordinates to cartesian system, poin is in cart.system +inline void MagneticWrapperChebyshev::cartesianToCylindricalCartB(const Double_t* xyz, const Double_t* bxyz, + Double_t* brphiz) +{ + Double_t btr = TMath::Sqrt(bxyz[0] * bxyz[0] + bxyz[1] * bxyz[1]); + Double_t psiMINphi = TMath::ATan2(bxyz[1], bxyz[0]) - TMath::ATan2(xyz[1], xyz[0]); + + brphiz[0] = btr * TMath::Cos(psiMINphi); + brphiz[1] = btr * TMath::Sin(psiMINphi); + brphiz[2] = bxyz[2]; +} + +/// Converts field in cylindrical coordinates to cartesian system, point is in cyl.system +inline void MagneticWrapperChebyshev::cartesianToCylindricalCylB(const Double_t* rphiz, const Double_t* bxyz, + Double_t* brphiz) +{ + Double_t btr = TMath::Sqrt(bxyz[0] * bxyz[0] + bxyz[1] * bxyz[1]); + Double_t psiMINphi = TMath::ATan2(bxyz[1], bxyz[0]) - rphiz[1]; + brphiz[0] = btr * TMath::Cos(psiMINphi); + brphiz[1] = btr * TMath::Sin(psiMINphi); + brphiz[2] = bxyz[2]; +} + +inline void MagneticWrapperChebyshev::cartesianToCylindrical(const Double_t* xyz, Double_t* rphiz) +{ + rphiz[0] = TMath::Sqrt(xyz[0] * xyz[0] + xyz[1] * xyz[1]); + rphiz[1] = TMath::ATan2(xyz[1], xyz[0]); + rphiz[2] = xyz[2]; +} + +inline void MagneticWrapperChebyshev::cylindricalToCartesian(const Double_t* rphiz, Double_t* xyz) +{ + xyz[0] = rphiz[0] * TMath::Cos(rphiz[1]); + xyz[1] = rphiz[0] * TMath::Sin(rphiz[1]); + xyz[2] = rphiz[2]; +} +} +} + +#endif diff --git a/field/fieldLinkDef.h b/field/fieldLinkDef.h new file mode 100644 index 0000000000000..580fe61dd1a08 --- /dev/null +++ b/field/fieldLinkDef.h @@ -0,0 +1,13 @@ + +#ifdef __CINT__ + +#pragma link off all globals; +#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+; + +#endif diff --git a/header/AliceO2Config.h.in b/header/AliceO2Config.h.in new file mode 100644 index 0000000000000..43e9580ae22a9 --- /dev/null +++ b/header/AliceO2Config.h.in @@ -0,0 +1,3 @@ +#define O2PROTO1_MAGF_DIR "@CMAKE_SOURCE_DIR@/Resources/maps/mfchebKGI_sym.root" +#define O2PROTO1_MAGF_CREATEFIELDMAP_DIR "@CMAKE_SOURCE_DIR@/Resources/maps/mfchebKGI_sym.root" + diff --git a/its/CMakeLists.txt b/its/CMakeLists.txt index 3e45ced6a2a00..d9ec38a684dcf 100644 --- a/its/CMakeLists.txt +++ b/its/CMakeLists.txt @@ -1,8 +1,9 @@ set(INCLUDE_DIRECTORIES -${ROOT_INCLUDE_DIR} -${BASE_INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/its +${CMAKE_SOURCE_DIR}/header +${BASE_INCLUDE_DIRECTORIES} +${ROOT_INCLUDE_DIR} ) include_directories( ${INCLUDE_DIRECTORIES}) diff --git a/its/Detector.cxx b/its/Detector.cxx index 908648794d957..1dc33215632d8 100644 --- a/its/Detector.cxx +++ b/its/Detector.cxx @@ -10,6 +10,8 @@ #include "Data/DetectorList.h" #include "Data/Stack.h" +#include "field/MagneticField.h" + #include "FairVolume.h" #include "FairGeoVolume.h" #include "FairGeoNode.h" @@ -24,6 +26,7 @@ #include "TGeoTube.h" #include "TGeoVolume.h" #include "TVirtualMC.h" +#include "TGeoGlobalMagField.h" #include #include @@ -33,7 +36,7 @@ using std::endl; using namespace AliceO2::ITS; -AliceO2::ITS::Detector::Detector() +Detector::Detector() : AliceO2::Base::Detector("ITS", kTRUE, kAliIts), mLayerID(0), mTrackNumberID(-1), @@ -80,7 +83,7 @@ AliceO2::ITS::Detector::Detector() { } -AliceO2::ITS::Detector::Detector(const char* name, Bool_t active, const Int_t nlay) +Detector::Detector(const char* name, Bool_t active, const Int_t nlay) : AliceO2::Base::Detector(name, active, kAliIts), mLayerID(0), mTrackNumberID(-1), @@ -128,8 +131,9 @@ AliceO2::ITS::Detector::Detector(const char* name, Bool_t active, const Int_t nl { mLayerName = new TString[mNumberLayers]; - for (Int_t j = 0; j < mNumberLayers; j++) - mLayerName[j].Form("%s%d", UpgradeGeometryTGeo::GetITSSensorPattern(), j); // See UpgradeV1Layer + for (Int_t j = 0; j < mNumberLayers; j++) { + mLayerName[j].Form("%s%d", UpgradeGeometryTGeo::getITSSensorPattern(), j); // See UpgradeV1Layer + } mTurboLayer = new Bool_t[mNumberLayers]; mLayerPhi0 = new Double_t[mNumberLayers]; @@ -162,7 +166,7 @@ AliceO2::ITS::Detector::Detector(const char* name, Bool_t active, const Int_t nl } } -AliceO2::ITS::Detector::~Detector() +Detector::~Detector() { delete[] mTurboLayer; delete[] mLayerPhi0; @@ -190,7 +194,7 @@ AliceO2::ITS::Detector::~Detector() delete[] mLayerID; } -AliceO2::ITS::Detector& AliceO2::ITS::Detector::operator=(const AliceO2::ITS::Detector& h) +Detector& Detector::operator=(const Detector& h) { // The standard = operator // Inputs: @@ -218,7 +222,7 @@ AliceO2::ITS::Detector& AliceO2::ITS::Detector::operator=(const AliceO2::ITS::De return *this; } -void AliceO2::ITS::Detector::Initialize() +void Detector::Initialize() { if (!mLayerID) { mLayerID = new Int_t[mNumberLayers]; @@ -236,19 +240,19 @@ void AliceO2::ITS::Detector::Initialize() // O2itsGeoPar* par=(O2itsGeoPar*)(rtdb->getContainer("O2itsGeoPar")); } -void AliceO2::ITS::Detector::InitParameterContainers() +void Detector::initializeParameterContainers() { LOG(INFO) << "Initialize aliitsdet misallign parameters" << FairLogger::endl; - mNumberOfDetectors = mMisalignmentParameter->GetNumberOfDetectors(); - mShiftX = mMisalignmentParameter->GetShiftX(); - mShiftY = mMisalignmentParameter->GetShiftY(); - mShiftZ = mMisalignmentParameter->GetShiftZ(); - mRotX = mMisalignmentParameter->GetRotX(); - mRotY = mMisalignmentParameter->GetRotY(); - mRotZ = mMisalignmentParameter->GetRotZ(); + mNumberOfDetectors = mMisalignmentParameter->getNumberOfDetectors(); + mShiftX = mMisalignmentParameter->getShiftX(); + mShiftY = mMisalignmentParameter->getShiftY(); + mShiftZ = mMisalignmentParameter->getShiftZ(); + mRotX = mMisalignmentParameter->getRotX(); + mRotY = mMisalignmentParameter->getRotY(); + mRotZ = mMisalignmentParameter->getRotZ(); } -void AliceO2::ITS::Detector::SetParameterContainers() +void Detector::setParameterContainers() { LOG(INFO) << "Set tutdet misallign parameters" << FairLogger::endl; // Get Base Container @@ -260,7 +264,7 @@ void AliceO2::ITS::Detector::SetParameterContainers() mMisalignmentParameter = (MisalignmentParameter*)(rtdb->getContainer("MisallignmentParameter")); } -Bool_t AliceO2::ITS::Detector::ProcessHits(FairVolume* vol) +Bool_t Detector::ProcessHits(FairVolume* vol) { // This method is called from the MC stepping if (!(gMC->TrackCharge())) { @@ -288,7 +292,7 @@ Bool_t AliceO2::ITS::Detector::ProcessHits(FairVolume* vol) gMC->CurrentVolOffID(1, cpn1); gMC->CurrentVolOffID(2, cpn0); - mod = mGeometryTGeo->GetChipIndex(lay, cpn0, cpn1); + mod = mGeometryTGeo->getChipIndex(lay, cpn0, cpn1); // Record information on the points mEnergyLoss = gMC->Edep(); @@ -311,7 +315,7 @@ Bool_t AliceO2::ITS::Detector::ProcessHits(FairVolume* vol) } // Create Point on every step of the active volume - AddHit(mTrackNumberID, mVolumeID, + addHit(mTrackNumberID, mVolumeID, TVector3(mEntrancePosition.X(), mEntrancePosition.Y(), mEntrancePosition.Z()), TVector3(mPosition.X(), mPosition.Y(), mPosition.Z()), TVector3(mMomentum.Px(), mMomentum.Py(), mMomentum.Pz()), mEntranceTime, mTime, mLength, @@ -328,14 +332,10 @@ Bool_t AliceO2::ITS::Detector::ProcessHits(FairVolume* vol) return kTRUE; } -void AliceO2::ITS::Detector::CreateMaterials() +void Detector::createMaterials() { - // Int_t ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); - // Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max(); - // FIXME: values taken from the AliMagF constructor. These must (?) be provided by the run_sim - // macro instead - Int_t ifield = 2; - Float_t fieldm = 10.; + Int_t ifield = ((AliceO2::Field::MagneticField*)TGeoGlobalMagField::Instance()->GetField())->Integral(); + Float_t fieldm = ((AliceO2::Field::MagneticField*)TGeoGlobalMagField::Instance()->GetField())->Max(); Float_t tmaxfd = 0.1; // 1.0; // Degree Float_t stemax = 1.0; // cm @@ -459,21 +459,21 @@ void AliceO2::ITS::Detector::CreateMaterials() epsil, stmin); } -void AliceO2::ITS::Detector::EndOfEvent() +void Detector::EndOfEvent() { mPointCollection->Clear(); } -void AliceO2::ITS::Detector::Register() +void Detector::Register() { // This will create a branch in the output tree called Point, setting the last // parameter to kFALSE means that this collection will not be written to the file, // it will exist only during the simulation - FairRootManager::Instance()->Register("AliceO2::ITS::Point", "ITS", mPointCollection, kTRUE); + FairRootManager::Instance()->Register("Point", "ITS", mPointCollection, kTRUE); } -TClonesArray* AliceO2::ITS::Detector::GetCollection(Int_t iColl) const +TClonesArray* Detector::GetCollection(Int_t iColl) const { if (iColl == 0) { return mPointCollection; @@ -482,12 +482,12 @@ TClonesArray* AliceO2::ITS::Detector::GetCollection(Int_t iColl) const } } -void AliceO2::ITS::Detector::Reset() +void Detector::Reset() { mPointCollection->Clear(); } -void AliceO2::ITS::Detector::SetNumberOfWrapperVolumes(Int_t n) +void Detector::setNumberOfWrapperVolumes(Int_t n) { // book arrays for wrapper volumes if (mNumberOfWrapperVolumes) { @@ -508,7 +508,7 @@ void AliceO2::ITS::Detector::SetNumberOfWrapperVolumes(Int_t n) } } -void AliceO2::ITS::Detector::DefineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, +void Detector::defineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan) { // set parameters of id-th wrapper volume @@ -522,7 +522,7 @@ void AliceO2::ITS::Detector::DefineWrapperVolume(Int_t id, Double_t rmin, Double mWrapperZSpan[id] = zspan; } -void AliceO2::ITS::Detector::DefineLayer(Int_t nlay, double phi0, Double_t r, Double_t zlen, +void Detector::defineLayer(Int_t nlay, double phi0, Double_t r, Double_t zlen, Int_t nstav, Int_t nunit, Double_t lthick, Double_t dthick, UInt_t dettypeID, Int_t buildLevel) { @@ -565,7 +565,7 @@ void AliceO2::ITS::Detector::DefineLayer(Int_t nlay, double phi0, Double_t r, Do mBuildLevel[nlay] = buildLevel; } -void AliceO2::ITS::Detector::DefineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, +void Detector::defineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nstav, Int_t nunit, Double_t width, Double_t tilt, Double_t lthick, Double_t dthick, UInt_t dettypeID, Int_t buildLevel) @@ -615,7 +615,7 @@ void AliceO2::ITS::Detector::DefineLayerTurbo(Int_t nlay, Double_t phi0, Double_ mBuildLevel[nlay] = buildLevel; } -void AliceO2::ITS::Detector::GetLayerParameters(Int_t nlay, Double_t& phi0, Double_t& r, +void Detector::getLayerParameters(Int_t nlay, Double_t& phi0, Double_t& r, Double_t& zlen, Int_t& nstav, Int_t& nmod, Double_t& width, Double_t& tilt, Double_t& lthick, Double_t& dthick, UInt_t& dettype) const @@ -655,7 +655,7 @@ void AliceO2::ITS::Detector::GetLayerParameters(Int_t nlay, Double_t& phi0, Doub dettype = mChipTypeID[nlay]; } -TGeoVolume* AliceO2::ITS::Detector::CreateWrapperVolume(Int_t id) +TGeoVolume* Detector::createWrapperVolume(Int_t id) { // Creates an air-filled wrapper cylindrical volume @@ -670,26 +670,26 @@ TGeoVolume* AliceO2::ITS::Detector::CreateWrapperVolume(Int_t id) TGeoMedium* medAir = gGeoManager->GetMedium("ITS_AIR$"); char volnam[30]; - snprintf(volnam, 29, "%s%d", UpgradeGeometryTGeo::GetITSWrapVolPattern(), id); + snprintf(volnam, 29, "%s%d", UpgradeGeometryTGeo::getITSWrapVolPattern(), id); TGeoVolume* wrapper = new TGeoVolume(volnam, tube, medAir); return wrapper; } -void AliceO2::ITS::Detector::ConstructGeometry() +void Detector::ConstructGeometry() { // Create the detector materials - CreateMaterials(); + createMaterials(); // Construct the detector geometry - ConstructDetectorGeometry(); + constructDetectorGeometry(); // Define the list of sensitive volumes - DefineSensitiveVolumes(); + defineSensitiveVolumes(); } -void AliceO2::ITS::Detector::ConstructDetectorGeometry() +void Detector::constructDetectorGeometry() { // Create the geometry and insert it in the mother volume ITSV TGeoManager* geoManager = gGeoManager; @@ -700,9 +700,9 @@ void AliceO2::ITS::Detector::ConstructDetectorGeometry() LOG(FATAL) << "Could not find the top volume" << FairLogger::endl; } - new TGeoVolumeAssembly(UpgradeGeometryTGeo::GetITSVolPattern()); - TGeoVolume* vITSV = geoManager->GetVolume(UpgradeGeometryTGeo::GetITSVolPattern()); - vITSV->SetUniqueID(UpgradeGeometryTGeo::GetUIDShift()); // store modID -> midUUID bitshift + new TGeoVolumeAssembly(UpgradeGeometryTGeo::getITSVolPattern()); + TGeoVolume* vITSV = geoManager->GetVolume(UpgradeGeometryTGeo::getITSVolPattern()); + vITSV->SetUniqueID(UpgradeGeometryTGeo::getUIDShift()); // store modID -> midUUID bitshift vALIC->AddNode(vITSV, 2, 0); // Copy number is 2 to cheat AliGeoManager::CheckSymNamesLUT const Int_t kLength = 100; @@ -767,7 +767,7 @@ void AliceO2::ITS::Detector::ConstructDetectorGeometry() if (mNumberOfWrapperVolumes) { wrapVols = new TGeoVolume* [mNumberOfWrapperVolumes]; for (int id = 0; id < mNumberOfWrapperVolumes; id++) { - wrapVols[id] = CreateWrapperVolume(id); + wrapVols[id] = createWrapperVolume(id); vITSV->AddNode(wrapVols[id], 1, 0); } } @@ -781,33 +781,33 @@ void AliceO2::ITS::Detector::ConstructDetectorGeometry() if (mTurboLayer[j]) { mUpgradeGeometry[j] = new UpgradeV1Layer(j, kTRUE, kFALSE); - mUpgradeGeometry[j]->SetStaveWidth(mStaveWidth[j]); - mUpgradeGeometry[j]->SetStaveTilt(mStaveTilt[j]); + mUpgradeGeometry[j]->setStaveWidth(mStaveWidth[j]); + mUpgradeGeometry[j]->setStaveTilt(mStaveTilt[j]); } else { mUpgradeGeometry[j] = new UpgradeV1Layer(j, kFALSE); } - mUpgradeGeometry[j]->SetPhi0(mLayerPhi0[j]); - mUpgradeGeometry[j]->SetRadius(mLayerRadii[j]); - mUpgradeGeometry[j]->SetZLength(mLayerZLength[j]); - mUpgradeGeometry[j]->SetNumberOfStaves(mStavePerLayer[j]); - mUpgradeGeometry[j]->SetNumberOfUnits(mUnitPerStave[j]); - mUpgradeGeometry[j]->SetChipType(mChipTypeID[j]); - mUpgradeGeometry[j]->SetBuildLevel(mBuildLevel[j]); + mUpgradeGeometry[j]->setPhi0(mLayerPhi0[j]); + mUpgradeGeometry[j]->setRadius(mLayerRadii[j]); + mUpgradeGeometry[j]->setZLength(mLayerZLength[j]); + mUpgradeGeometry[j]->setNumberOfStaves(mStavePerLayer[j]); + mUpgradeGeometry[j]->setNumberOfUnits(mUnitPerStave[j]); + mUpgradeGeometry[j]->setChipType(mChipTypeID[j]); + mUpgradeGeometry[j]->setBuildLevel(mBuildLevel[j]); if (j < 3) { - mUpgradeGeometry[j]->SetStaveModel(mStaveModelInnerBarrel); + mUpgradeGeometry[j]->setStaveModel(mStaveModelInnerBarrel); } else { - mUpgradeGeometry[j]->SetStaveModel(mStaveModelOuterBarrel); + mUpgradeGeometry[j]->setStaveModel(mStaveModelOuterBarrel); } LOG(DEBUG1) << "mBuildLevel: " << mBuildLevel[j] << FairLogger::endl; if (mStaveThickness[j] != 0) { - mUpgradeGeometry[j]->SetStaveThick(mStaveThickness[j]); + mUpgradeGeometry[j]->setStaveThick(mStaveThickness[j]); } if (mDetectorThickness[j] != 0) { - mUpgradeGeometry[j]->SetSensorThick(mDetectorThickness[j]); + mUpgradeGeometry[j]->setSensorThick(mDetectorThickness[j]); } for (int iw = 0; iw < mNumberOfWrapperVolumes; iw++) { @@ -825,16 +825,16 @@ void AliceO2::ITS::Detector::ConstructDetectorGeometry() break; } } - mUpgradeGeometry[j]->CreateLayer(dest); + mUpgradeGeometry[j]->createLayer(dest); } - CreateServiceBarrel(kTRUE, wrapVols[0]); - CreateServiceBarrel(kFALSE, wrapVols[2]); + createServiceBarrel(kTRUE, wrapVols[0]); + createServiceBarrel(kFALSE, wrapVols[2]); delete[] wrapVols; // delete pointer only, not the volumes } // Service Barrel -void AliceO2::ITS::Detector::CreateServiceBarrel(const Bool_t innerBarrel, TGeoVolume* dest, +void Detector::createServiceBarrel(const Bool_t innerBarrel, TGeoVolume* dest, const TGeoManager* mgr) { // Creates the Service Barrel (as a simple cylinder) for IB and OB @@ -870,7 +870,7 @@ void AliceO2::ITS::Detector::CreateServiceBarrel(const Bool_t innerBarrel, TGeoV return; } -void AliceO2::ITS::Detector::DefineSensitiveVolumes() +void Detector::defineSensitiveVolumes() { TGeoManager* geoManager = gGeoManager; TGeoVolume* v; @@ -879,13 +879,13 @@ void AliceO2::ITS::Detector::DefineSensitiveVolumes() // The names of the ITS sensitive volumes have the format: ITSUSensor(0...mNumberLayers-1) for (Int_t j = 0; j < mNumberLayers; j++) { - volumeName = UpgradeGeometryTGeo::GetITSSensorPattern() + TString::Itoa(j, 10); + volumeName = UpgradeGeometryTGeo::getITSSensorPattern() + TString::Itoa(j, 10); v = geoManager->GetVolume(volumeName.Data()); AddSensitiveVolume(v); } } -Point* AliceO2::ITS::Detector::AddHit(Int_t trackID, Int_t detID, TVector3 startPos, TVector3 pos, +Point* Detector::addHit(Int_t trackID, Int_t detID, TVector3 startPos, TVector3 pos, TVector3 mom, Double_t startTime, Double_t time, Double_t length, Double_t eLoss, Int_t shunt) { @@ -895,7 +895,7 @@ Point* AliceO2::ITS::Detector::AddHit(Int_t trackID, Int_t detID, TVector3 start Point(trackID, detID, startPos, pos, mom, startTime, time, length, eLoss, shunt); } -TParticle* AliceO2::ITS::Detector::GetParticle() const +TParticle* Detector::GetParticle() const { // Returns the pointer to the TParticle for the particle that created // this hit. From the TParticle all kinds of information about this @@ -910,7 +910,7 @@ TParticle* AliceO2::ITS::Detector::GetParticle() const return ((AliceO2::Data::Stack*)gMC->GetStack())->GetParticle(GetTrack()); } -void AliceO2::ITS::Detector::Print(ostream* os) const +void Detector::Print(ostream* os) const { // Standard output format for this class. // Inputs: @@ -948,7 +948,7 @@ void AliceO2::ITS::Detector::Print(ostream* os) const return; } -void AliceO2::ITS::Detector::Read(istream* is) +void Detector::Read(istream* is) { // Standard input format for this class. // Inputs: @@ -965,7 +965,7 @@ void AliceO2::ITS::Detector::Read(istream* is) return; } -ostream& operator<<(ostream& os, AliceO2::ITS::Detector& p) +ostream& operator<<(ostream& os, Detector& p) { // Standard output streaming function. // Inputs: @@ -980,7 +980,7 @@ ostream& operator<<(ostream& os, AliceO2::ITS::Detector& p) return os; } -istream& operator>>(istream& is, AliceO2::ITS::Detector& r) +istream& operator>>(istream& is, Detector& r) { // Standard input streaming function. // Inputs: diff --git a/its/Detector.h b/its/Detector.h index ab29b538747ac..08981ea27c9da 100644 --- a/its/Detector.h +++ b/its/Detector.h @@ -70,13 +70,12 @@ class Detector : public AliceO2::Base::Detector { /// \param innerBarrel if true, build IB service barrel, otherwise for OB /// \param dest the mother volume holding the service barrel /// \param mgr the gGeoManager pointer (used to get the material) - void CreateServiceBarrel(const Bool_t innerBarrel, TGeoVolume* dest, - const TGeoManager* mgr = gGeoManager); + void createServiceBarrel(const Bool_t innerBarrel, TGeoVolume* dest, const TGeoManager* mgr = gGeoManager); /// Initialize the parameter containers - virtual void InitParameterContainers(); + virtual void initializeParameterContainers(); - void SetParameterContainers(); + void setParameterContainers(); /// Sets the layer parameters /// \param nlay layer number @@ -90,9 +89,8 @@ class Detector : public AliceO2::Base::Detector { /// \param dthick detector thickness (if omitted, defaults to 0) /// \param dettypeID ?? /// \param buildLevel (if 0, all geometry is build, used for material budget studies) - virtual void DefineLayer(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, - Int_t nmod, Double_t lthick = 0., Double_t dthick = 0., - UInt_t detType = 0, Int_t buildFlag = 0); + virtual void defineLayer(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, Int_t nmod, + Double_t lthick = 0., Double_t dthick = 0., UInt_t detType = 0, Int_t buildFlag = 0); /// Sets the layer parameters for a "turbo" layer /// (i.e. a layer whose staves overlap in phi) @@ -109,9 +107,9 @@ class Detector : public AliceO2::Base::Detector { /// \param dthick detector thickness (if omitted, defaults to 0) /// \param dettypeID ?? /// \param buildLevel (if 0, all geometry is build, used for material budget studies) - virtual void DefineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, - Int_t nmod, Double_t width, Double_t tilt, Double_t lthick = 0., - Double_t dthick = 0., UInt_t detType = 0, Int_t buildFlag = 0); + virtual void defineLayerTurbo(Int_t nlay, Double_t phi0, Double_t r, Double_t zlen, Int_t nladd, Int_t nmod, + Double_t width, Double_t tilt, Double_t lthick = 0., Double_t dthick = 0., + UInt_t detType = 0, Int_t buildFlag = 0); /// Gets the layer parameters /// \param nlay layer number @@ -126,19 +124,19 @@ class Detector : public AliceO2::Base::Detector { /// \param lthick stave thickness /// \param dthick detector thickness /// \param dettype detector type - virtual void GetLayerParameters(Int_t nlay, Double_t& phi0, Double_t& r, Double_t& zlen, - Int_t& nladd, Int_t& nmod, Double_t& width, Double_t& tilt, - Double_t& lthick, Double_t& mthick, UInt_t& dettype) const; + virtual void getLayerParameters(Int_t nlay, Double_t& phi0, Double_t& r, Double_t& zlen, Int_t& nladd, Int_t& nmod, + Double_t& width, Double_t& tilt, Double_t& lthick, Double_t& mthick, + UInt_t& dettype) const; /// This method is an example of how to add your own point of type Point to the clones array - Point* AddHit(Int_t trackID, Int_t detID, TVector3 startPos, TVector3 pos, TVector3 mom, - Double_t startTime, Double_t time, Double_t length, Double_t eLoss, Int_t shunt); + Point* addHit(Int_t trackID, Int_t detID, TVector3 startPos, TVector3 pos, TVector3 mom, Double_t startTime, + Double_t time, Double_t length, Double_t eLoss, Int_t shunt); /// Book arrays for wrapper volumes - virtual void SetNumberOfWrapperVolumes(Int_t n); + virtual void setNumberOfWrapperVolumes(Int_t n); /// Set per wrapper volume parameters - virtual void DefineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan); + virtual void defineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan); // The following methods can be implemented if you need to make // any optional action in your detector during the transport @@ -156,7 +154,7 @@ class Detector : public AliceO2::Base::Detector { { ; } - virtual void FinishRun() + virtual void finishRun() { ; } @@ -202,64 +200,64 @@ class Detector : public AliceO2::Base::Detector { void Read(istream* is); /// Returns the number of layers - Int_t GetNumberOfLayers() const + Int_t getNumberOfLayers() const { return mNumberLayers; } - virtual void SetStaveModelIB(UpgradeModel model) + virtual void setStaveModelIB(UpgradeModel model) { mStaveModelInnerBarrel = model; } - virtual void SetStaveModelOB(UpgradeModel model) + virtual void setStaveModelOB(UpgradeModel model) { mStaveModelOuterBarrel = model; } - virtual UpgradeModel GetStaveModelIB() const + virtual UpgradeModel getStaveModelIB() const { return mStaveModelInnerBarrel; } - virtual UpgradeModel GetStaveModelOB() const + virtual UpgradeModel getStaveModelOB() const { return mStaveModelOuterBarrel; } - UpgradeGeometryTGeo* mGeometryTGeo; ///< access to geometry details + UpgradeGeometryTGeo* mGeometryTGeo; //! access to geometry details protected: - Int_t* mLayerID; ///< [mNumberLayers] layer identifier - Int_t mNumberLayers; ///< Number of layers - Int_t mStatus; ///< Track Status - Int_t mModule; ///< Module number - Float_t mParticlePx; ///< PX of particle at the point of the hit - Float_t mParticlePy; ///< PY of particle at the point of the hit - Float_t mParticlePz; ///< PZ of particle at the point of the hit - Float_t mEnergyDepositionStep; ///< Energy deposited in the current step - Float_t mTof; ///< Time of flight at the point of the hit - Int_t mStatus0; ///< Track Status of Starting point - Float_t mStartingStepX; ///< Starting point of this step - Float_t mStartingStepY; ///< Starting point of this step - Float_t mStartingStepZ; ///< Starting point of this step - Float_t mStartingStepT; ///< Starting point of this step - Int_t mTrackNumber; ///< Track number - Float_t mPositionX; ///< X position of the hit - Float_t mPositionY; ///< Y position of the hit - Float_t mPositionZ; ///< Z position of the hit - TString* mLayerName; ///<[mNumberLayers] layer identifier + Int_t* mLayerID; //! [mNumberLayers] layer identifier + Int_t mNumberLayers; //! Number of layers + Int_t mStatus; //! Track Status + Int_t mModule; //! Module number + Float_t mParticlePx; //! PX of particle at the point of the hit + Float_t mParticlePy; //! PY of particle at the point of the hit + Float_t mParticlePz; //! PZ of particle at the point of the hit + Float_t mEnergyDepositionStep; //! Energy deposited in the current step + Float_t mTof; //! Time of flight at the point of the hit + Int_t mStatus0; //! Track Status of Starting point + Float_t mStartingStepX; //! Starting point of this step + Float_t mStartingStepY; //! Starting point of this step + Float_t mStartingStepZ; //! Starting point of this step + Float_t mStartingStepT; //! Starting point of this step + Int_t mTrackNumber; //! Track number + Float_t mPositionX; //! X position of the hit + Float_t mPositionY; //! Y position of the hit + Float_t mPositionZ; //! Z position of the hit + TString* mLayerName; //![mNumberLayers] layer identifier private: /// Track information to be stored until the track leaves the /// active volume. - Int_t mTrackNumberID; ///< track index - Int_t mVolumeID; ///< volume id - Int_t mShunt; ///< shunt - TLorentzVector mPosition; ///< position - TLorentzVector mEntrancePosition; ///< position at entrance - TLorentzVector mMomentum; ///< momentum - Double32_t mEntranceTime; ///< time at entrance - Double32_t mTime; ///< time - Double32_t mLength; ///< length - Double32_t mEnergyLoss; ///< energy loss + Int_t mTrackNumberID; //! track index + Int_t mVolumeID; //! volume id + Int_t mShunt; //! shunt + TLorentzVector mPosition; //! position + TLorentzVector mEntrancePosition; //! position at entrance + TLorentzVector mMomentum; //! momentum + Double32_t mEntranceTime; //! time at entrance + Double32_t mTime; //! time + Double32_t mLength; //! length + Double32_t mEnergyLoss; //! energy loss Int_t mNumberOfDetectors; TArrayD mShiftX; @@ -271,38 +269,38 @@ class Detector : public AliceO2::Base::Detector { Bool_t mModifyGeometry; - Int_t mNumberOfWrapperVolumes; ///< number of wrapper volumes - Double_t* mWrapperMinRadius; ///< min radius of wrapper volume - Double_t* mWrapperMaxRadius; ///< max radius of wrapper volume - Double_t* mWrapperZSpan; ///< Z span of wrapper volume - Int_t* mWrapperLayerId; ///< id of wrapper layer to which layer belongs (-1 if not wrapped) - Bool_t* mTurboLayer; ///< True for "turbo" layers - Double_t* mLayerPhi0; ///< Vector of layer's 1st stave phi in lab - Double_t* mLayerRadii; ///< Vector of layer radii - Double_t* mLayerZLength; ///< Vector of layer length along Z - Int_t* mStavePerLayer; ///< Vector of number of staves per layer - Int_t* mUnitPerStave; ///< Vector of number of "units" per stave - Double_t* mStaveThickness; ///< Vector of stave thicknesses - Double_t* mStaveWidth; ///< Vector of stave width (only used for turbo) - Double_t* mStaveTilt; ///< Vector of stave tilt (only used for turbo) - Double_t* mDetectorThickness; ///< Vector of detector thicknesses - UInt_t* mChipTypeID; ///< Vector of detector type id - Int_t* mBuildLevel; ///< Vector of Material Budget Studies + Int_t mNumberOfWrapperVolumes; //! number of wrapper volumes + Double_t* mWrapperMinRadius; //! min radius of wrapper volume + Double_t* mWrapperMaxRadius; //! max radius of wrapper volume + Double_t* mWrapperZSpan; //! Z span of wrapper volume + Int_t* mWrapperLayerId; //! id of wrapper layer to which layer belongs (-1 if not wrapped) + Bool_t* mTurboLayer; //! True for "turbo" layers + Double_t* mLayerPhi0; //! Vector of layer's 1st stave phi in lab + Double_t* mLayerRadii; //! Vector of layer radii + Double_t* mLayerZLength; //! Vector of layer length along Z + Int_t* mStavePerLayer; //! Vector of number of staves per layer + Int_t* mUnitPerStave; //! Vector of number of "units" per stave + Double_t* mStaveThickness; //! Vector of stave thicknesses + Double_t* mStaveWidth; //! Vector of stave width (only used for turbo) + Double_t* mStaveTilt; //! Vector of stave tilt (only used for turbo) + Double_t* mDetectorThickness; //! Vector of detector thicknesses + UInt_t* mChipTypeID; //! Vector of detector type id + Int_t* mBuildLevel; //! Vector of Material Budget Studies /// Container for data points TClonesArray* mPointCollection; /// Creates an air-filled wrapper cylindrical volume - TGeoVolume* CreateWrapperVolume(const Int_t nLay); + TGeoVolume* createWrapperVolume(const Int_t nLay); /// Create the detector materials - virtual void CreateMaterials(); + virtual void createMaterials(); /// Construct the detector geometry - void ConstructDetectorGeometry(); + void constructDetectorGeometry(); /// Define the sensitive volumes of the geometry - void DefineSensitiveVolumes(); + void defineSensitiveVolumes(); Detector(const Detector&); Detector& operator=(const Detector&); diff --git a/its/GeometryHandler.cxx b/its/GeometryHandler.cxx index a793465f7e8f8..4576479452276 100644 --- a/its/GeometryHandler.cxx +++ b/its/GeometryHandler.cxx @@ -46,14 +46,14 @@ Int_t GeometryHandler::Init(Bool_t isSimulation) return 1; } -void GeometryHandler::LocalToGlobal(Double_t* local, Double_t* global, Int_t detectorId) +void GeometryHandler::localToGlobal(Double_t* local, Double_t* global, Int_t detectorId) { - TString path = ConstructFullPathFromDetectorId(detectorId); - NavigateTo(path); + TString path = constructFullPathFromDetectorId(detectorId); + navigateTo(path); gGeoManager->LocalToMaster(local, global); } -TString GeometryHandler::ConstructFullPathFromDetectorId(Int_t detectorId) +TString GeometryHandler::constructFullPathFromDetectorId(Int_t detectorId) { TString volumeString = "/cave_1/tutorial4_0/tut4_det_"; TString volumePath = volumeString; @@ -61,24 +61,24 @@ TString GeometryHandler::ConstructFullPathFromDetectorId(Int_t detectorId) return volumePath; } -Int_t GeometryHandler::GetUniqueDetectorId(TString volumeName) +Int_t GeometryHandler::getUniqueDetectorId(TString volumeName) { if (mGeometryPathHash != volumeName.Hash()) { - NavigateTo(volumeName); + navigateTo(volumeName); } - return GetUniqueDetectorId(); + return getUniqueDetectorId(); } -Int_t GeometryHandler::GetUniqueDetectorId() +Int_t GeometryHandler::getUniqueDetectorId() { Int_t detectorNumber = 0; - CurrentVolumeOffId(0, detectorNumber); + currentVolumeOffId(0, detectorNumber); return detectorNumber; } -Int_t GeometryHandler::VolumeIdGeo(const char* name) const +Int_t GeometryHandler::volumeIdGeo(const char* name) const { Int_t uid = gGeoManager->GetUID(name); if (uid < 0) { @@ -88,7 +88,7 @@ Int_t GeometryHandler::VolumeIdGeo(const char* name) const return uid; } -Int_t GeometryHandler::VolumeId(const Text_t* name) const +Int_t GeometryHandler::volumeId(const Text_t* name) const { if (mIsSimulation) { return gMC->VolId(name); @@ -97,16 +97,16 @@ Int_t GeometryHandler::VolumeId(const Text_t* name) const Int_t length = strlen(name) - 1; if (name[length] != ' ') { - return VolumeIdGeo(name); + return volumeIdGeo(name); } strncpy(sname, name, length); sname[length] = 0; - return VolumeIdGeo(sname); + return volumeIdGeo(sname); } } -Int_t GeometryHandler::CurrentVolumeId(Int_t& copy) const +Int_t GeometryHandler::currentVolumeId(Int_t& copy) const { if (mIsSimulation) { return gMC->CurrentVolID(copy); @@ -122,7 +122,7 @@ Int_t GeometryHandler::CurrentVolumeId(Int_t& copy) const } //_____________________________________________________________________________ -Int_t GeometryHandler::CurrentVolumeOffId(Int_t off, Int_t& copy) const +Int_t GeometryHandler::currentVolumeOffId(Int_t off, Int_t& copy) const { if (mIsSimulation) { return gMC->CurrentVolOffID(off, copy); @@ -132,7 +132,7 @@ Int_t GeometryHandler::CurrentVolumeOffId(Int_t off, Int_t& copy) const } if (off == 0) { - return CurrentVolumeId(copy); + return currentVolumeId(copy); } TGeoNode* node = gGeoManager->GetMother(off); @@ -146,7 +146,7 @@ Int_t GeometryHandler::CurrentVolumeOffId(Int_t off, Int_t& copy) const } } -const char* GeometryHandler::CurrentVolumeName() const +const char* GeometryHandler::currentVolumeName() const { if (mIsSimulation) { return gMC->CurrentVolName(); @@ -159,7 +159,7 @@ const char* GeometryHandler::CurrentVolumeName() const } } -const char* GeometryHandler::CurrentVolumeOffName(Int_t off) const +const char* GeometryHandler::currentVolumeOffName(Int_t off) const { if (mIsSimulation) { return gMC->CurrentVolOffName(off); @@ -169,7 +169,7 @@ const char* GeometryHandler::CurrentVolumeOffName(Int_t off) const } if (off == 0) { - return CurrentVolumeName(); + return currentVolumeName(); } TGeoNode* node = gGeoManager->GetMother(off); @@ -182,7 +182,7 @@ const char* GeometryHandler::CurrentVolumeOffName(Int_t off) const } } -void GeometryHandler::NavigateTo(TString volumeName) +void GeometryHandler::navigateTo(TString volumeName) { if (mIsSimulation) { LOG(FATAL) << "This method is not supported in simulation mode" << FairLogger::endl; diff --git a/its/GeometryHandler.h b/its/GeometryHandler.h index b9b3a597d410e..8aab28f1039f3 100644 --- a/its/GeometryHandler.h +++ b/its/GeometryHandler.h @@ -27,56 +27,56 @@ class GeometryHandler : public TObject { /// Default destructor ~GeometryHandler() {}; - Int_t GetUniqueDetectorId(); + Int_t getUniqueDetectorId(); - Int_t GetUniqueDetectorId(TString volumeName); + Int_t getUniqueDetectorId(TString volumeName); // Int_t GetDetectorId(Int_t uniqueId); Int_t Init(Bool_t isSimulation = kFALSE); - void FillDetectorInfoArray(Int_t uniqueId); + void fillDetectorInfoArray(Int_t uniqueId); - void NavigateTo(TString volumeName); + void navigateTo(TString volumeName); // Implement Interface functions to the TGeoManager to be // the same as for the VMC /// Return the current volume "off" upward in the geometrical tree ID and copy number - Int_t CurrentVolumeOffId(Int_t off, Int_t& copy) const; + Int_t currentVolumeOffId(Int_t off, Int_t& copy) const; /// Returns the current volume ID and copy number - Int_t CurrentVolumeId(Int_t& copy) const; + Int_t currentVolumeId(Int_t& copy) const; /// Returns the unique numeric identifier for volume name - Int_t VolumeId(const Text_t* name) const; + Int_t volumeId(const Text_t* name) const; /// Returns the unique numeric identifier for volume name - Int_t VolumeIdGeo(const char* name) const; + Int_t volumeIdGeo(const char* name) const; /// Returns the current volume name - const char* CurrentVolumeName() const; + const char* currentVolumeName() const; /// Returns the current volume "off" upward in the geometrical tree ID, name and copy number /// if name=0 no name is returned - const char* CurrentVolumeOffName(Int_t off) const; + const char* currentVolumeOffName(Int_t off) const; - void LocalToGlobal(Double_t* local, Double_t* global, Int_t detectorId); + void localToGlobal(Double_t* local, Double_t* global, Int_t detectorId); // Int_t CheckGeometryVersion(); private: - Bool_t mIsSimulation; + Bool_t mIsSimulation; //! - Int_t mLastUsedDetectorId; + Int_t mLastUsedDetectorId; //! - UInt_t mGeometryPathHash; - TGeoVolume* mCurrentVolume; - TGeoBBox* mVolumeShape; - Double_t mGlobalCentre[3]; ///< Global centre of volume - TGeoHMatrix* mGlobalMatrix; + UInt_t mGeometryPathHash; //! + TGeoVolume* mCurrentVolume; //! + TGeoBBox* mVolumeShape; //! + Double_t mGlobalCentre[3]; //! Global centre of volume + TGeoHMatrix* mGlobalMatrix; //! - TString ConstructFullPathFromDetectorId(Int_t detectorId); + TString constructFullPathFromDetectorId(Int_t detectorId); GeometryHandler(const GeometryHandler&); diff --git a/its/GeometryManager.cxx b/its/GeometryManager.cxx index 78587bcfe6025..99d004666ab71 100644 --- a/its/GeometryManager.cxx +++ b/its/GeometryManager.cxx @@ -36,7 +36,7 @@ GeometryManager::~GeometryManager() { } -Bool_t GeometryManager::GetOriginalGlobalMatrix(const char* symname, TGeoHMatrix& m) +Bool_t GeometryManager::getOriginalGlobalMatrix(const char* symname, TGeoHMatrix& m) { m.Clear(); @@ -70,10 +70,10 @@ Bool_t GeometryManager::GetOriginalGlobalMatrix(const char* symname, TGeoHMatrix path = symname; } - return GetOriginalGlobalMatrixFromPath(path, m); + return getOriginalGlobalMatrixFromPath(path, m); } -Bool_t GeometryManager::GetOriginalGlobalMatrixFromPath(const char* path, TGeoHMatrix& m) +Bool_t GeometryManager::getOriginalGlobalMatrixFromPath(const char* path, TGeoHMatrix& m) { m.Clear(); diff --git a/its/GeometryManager.h b/its/GeometryManager.h index 017c64cacaea6..a9568222908cf 100644 --- a/its/GeometryManager.h +++ b/its/GeometryManager.h @@ -53,7 +53,7 @@ class GeometryManager : public TObject { /// The alignable volume is identified by 'symname' which has to be either a valid symbolic /// name, the query being performed after alignment, or a valid volume path if the query is /// performed before alignment. - static Bool_t GetOriginalGlobalMatrix(const char* symname, TGeoHMatrix& m); + static Bool_t getOriginalGlobalMatrix(const char* symname, TGeoHMatrix& m); /// Default destructor ~GeometryManager(); @@ -65,7 +65,7 @@ class GeometryManager : public TObject { /// The method returns the global matrix for the volume identified by 'path' in the ideal /// detector geometry. The output global matrix is stored in 'm'. /// Returns kFALSE in case TGeo has not been initialized or the volume path is not valid. - static Bool_t GetOriginalGlobalMatrixFromPath(const char* path, TGeoHMatrix& m); + static Bool_t getOriginalGlobalMatrixFromPath(const char* path, TGeoHMatrix& m); static TGeoManager* mGeometry; diff --git a/its/MisalignmentParameter.cxx b/its/MisalignmentParameter.cxx index 8e9004fd0d48e..38ef20bb2211f 100644 --- a/its/MisalignmentParameter.cxx +++ b/its/MisalignmentParameter.cxx @@ -30,7 +30,7 @@ void MisalignmentParameter::Clear(void) { } -void MisalignmentParameter::PutParams(FairParamList* list) +void MisalignmentParameter::putParams(FairParamList* list) { if (!list) { return; @@ -45,7 +45,7 @@ void MisalignmentParameter::PutParams(FairParamList* list) list->add("RotationZ", mRotZ); } -Bool_t MisalignmentParameter::GetParams(FairParamList* list) +Bool_t MisalignmentParameter::getParams(FairParamList* list) { if (!list) { return kFALSE; diff --git a/its/MisalignmentParameter.h b/its/MisalignmentParameter.h index 64eb0cb67caee..a065ee2d833c6 100644 --- a/its/MisalignmentParameter.h +++ b/its/MisalignmentParameter.h @@ -18,41 +18,40 @@ namespace ITS { class MisalignmentParameter : public FairParGenericSet { public: - MisalignmentParameter( - const char* name = "MisalignmentParameter", - const char* title = "Misalignment parameter for AliceO2ITSHitProducerIdealMisallign Parameters", - const char* context = "TestDefaultContext"); + MisalignmentParameter(const char* name = "MisalignmentParameter", + const char* title = "Misalignment parameter for AliceO2ITSHitProducerIdealMisallign Parameters", + const char* context = "TestDefaultContext"); ~MisalignmentParameter(void); void Clear(void); - void PutParams(FairParamList*); - Bool_t GetParams(FairParamList*); + void putParams(FairParamList*); + Bool_t getParams(FairParamList*); - TArrayD GetShiftX() + TArrayD getShiftX() { return mShiftX; } - TArrayD GetShiftY() + TArrayD getShiftY() { return mShiftY; } - TArrayD GetShiftZ() + TArrayD getShiftZ() { return mShiftZ; } - TArrayD GetRotX() + TArrayD getRotX() { return mRotX; } - TArrayD GetRotY() + TArrayD getRotY() { return mRotY; } - TArrayD GetRotZ() + TArrayD getRotZ() { return mRotZ; } - Int_t GetNumberOfDetectors() + Int_t getNumberOfDetectors() { return mNumberOfDetectors; } diff --git a/its/Point.h b/its/Point.h index f1758954c3c4f..5455dc92a405d 100644 --- a/its/Point.h +++ b/its/Point.h @@ -29,8 +29,8 @@ class Point : public FairMCPoint { /// \param length Track length since creation [cm] /// \param eLoss Energy deposit [GeV] /// \param shunt Shunt value - Point(Int_t trackID, Int_t detID, TVector3 startPos, TVector3 pos, TVector3 mom, - Double_t startTime, Double_t time, Double_t length, Double_t eLoss, Int_t shunt); + Point(Int_t trackID, Int_t detID, TVector3 startPos, TVector3 pos, TVector3 mom, Double_t startTime, Double_t time, + Double_t length, Double_t eLoss, Int_t shunt); // Default Destructor virtual ~Point(); diff --git a/its/Segmentation.h b/its/Segmentation.h index 8127cb5afa9c9..2308ba4147992 100644 --- a/its/Segmentation.h +++ b/its/Segmentation.h @@ -31,7 +31,7 @@ class Segmentation : public TObject { /// Set Detector Segmentation Parameters /// Detector size - virtual void SetDetSize(Float_t p1, Float_t p2, Float_t p3) + virtual void setDetectorSize(Float_t p1, Float_t p2, Float_t p3) { mDx = p1; mDz = p2; @@ -39,73 +39,73 @@ class Segmentation : public TObject { } /// Cell size - virtual void SetPadSize(Float_t, Float_t) + virtual void setPadSize(Float_t, Float_t) { MayNotUse("SetPadSize"); } /// Maximum number of cells along the two coordinates - virtual void SetNPads(Int_t, Int_t) = 0; + virtual void setNumberOfPads(Int_t, Int_t) = 0; /// Returns the maximum number of cells (digits) posible - virtual Int_t GetNPads() const = 0; + virtual Int_t getNumberOfPads() const = 0; /// Set layer - virtual void SetLayer(Int_t) + virtual void setLayer(Int_t) { MayNotUse("SetLayer"); } /// Number of Chips - virtual Int_t GetNumberOfChips() const + virtual Int_t getNumberOfChips() const { MayNotUse("GetNumberOfChips"); return 0; } - virtual Int_t GetMaximumChipIndex() const + virtual Int_t getMaximumChipIndex() const { MayNotUse("GetNumberOfChips"); return 0; } /// Chip number from local coordinates - virtual Int_t GetChipFromLocal(Float_t, Float_t) const + virtual Int_t getChipFromLocal(Float_t, Float_t) const { MayNotUse("GetChipFromLocal"); return 0; } - virtual Int_t GetChipsInLocalWindow(Int_t* /*array*/, Float_t /*zmin*/, Float_t /*zmax*/, - Float_t /*xmin*/, Float_t /*xmax*/) const + virtual Int_t getChipsInLocalWindow(Int_t* /*array*/, Float_t /*zmin*/, Float_t /*zmax*/, Float_t /*xmin*/, + Float_t /*xmax*/) const { MayNotUse("GetChipsInLocalWindow"); return 0; } /// Chip number from channel number - virtual Int_t GetChipFromChannel(Int_t, Int_t) const + virtual Int_t getChipFromChannel(Int_t, Int_t) const { MayNotUse("GetChipFromChannel"); return 0; } /// Transform from real to cell coordinates - virtual void GetPadIxz(Float_t, Float_t, Int_t&, Int_t&) const = 0; + virtual void getPadIxz(Float_t, Float_t, Int_t&, Int_t&) const = 0; /// Transform from cell to real coordinates - virtual void GetPadCxz(Int_t, Int_t, Float_t&, Float_t&) const = 0; + virtual void getPadCxz(Int_t, Int_t, Float_t&, Float_t&) const = 0; /// Local transformation of real local coordinates - - virtual void GetPadTxz(Float_t&, Float_t&) const = 0; + virtual void getPadTxz(Float_t&, Float_t&) const = 0; /// Transformation from Geant cm detector center local coordinates /// to detector segmentation/cell coordiantes starting from (0,0). - virtual Bool_t LocalToDetector(Float_t, Float_t, Int_t&, Int_t&) const = 0; + virtual Bool_t localToDetector(Float_t, Float_t, Int_t&, Int_t&) const = 0; /// Transformation from detector segmentation/cell coordiantes starting /// from (0,0) to Geant cm detector center local coordinates. - virtual void DetectorToLocal(Int_t, Int_t, Float_t&, Float_t&) const = 0; + virtual void detectorToLocal(Int_t, Int_t, Float_t&, Float_t&) const = 0; /// Initialisation virtual void Init() = 0; @@ -131,19 +131,19 @@ class Segmentation : public TObject { } /// Cell size in x - virtual Float_t Dpx(Int_t) const = 0; + virtual Float_t cellSizeX(Int_t) const = 0; /// Cell size in z - virtual Float_t Dpz(Int_t) const = 0; + virtual Float_t cellSizeZ(Int_t) const = 0; /// Maximum number of Cells in x - virtual Int_t Npx() const = 0; + virtual Int_t numberOfCellsInX() const = 0; /// Maximum number of Cells in z - virtual Int_t Npz() const = 0; + virtual Int_t numberOfCellsInZ() const = 0; /// Layer - virtual Int_t GetLayer() const + virtual Int_t getLayer() const { MayNotUse("GetLayer"); return 0; @@ -152,33 +152,33 @@ class Segmentation : public TObject { /// Set hit position // virtual void SetHit(Float_t, Float_t) {} - /// Angles - virtual void Angles(Float_t& /* p */, Float_t& /* n */) const + /// angles + virtual void angles(Float_t& /* p */, Float_t& /* n */) const { MayNotUse("Angles"); } /// Get next neighbours - virtual void Neighbours(Int_t, Int_t, Int_t*, Int_t[10], Int_t[10]) const + virtual void neighbours(Int_t, Int_t, Int_t*, Int_t[10], Int_t[10]) const { MayNotUse("Neighbours"); } /// Function for systematic corrections /// Set the correction function - virtual void SetCorrFunc(TF1* fc) + virtual void setCorrectionFunction(TF1* fc) { mCorrection = fc; } /// Get the correction Function - virtual TF1* CorrFunc() + virtual TF1* getCorrectionFunction() { return mCorrection; } /// Print Default parameters - virtual void PrintDefaultParameters() const = 0; + virtual void printDefaultParameters() const = 0; protected: virtual void Copy(TObject& obj) const; diff --git a/its/UpgradeGeometryTGeo.cxx b/its/UpgradeGeometryTGeo.cxx index b9420e035eb8b..8753d6d016036 100644 --- a/its/UpgradeGeometryTGeo.cxx +++ b/its/UpgradeGeometryTGeo.cxx @@ -239,25 +239,25 @@ UpgradeGeometryTGeo& UpgradeGeometryTGeo::operator=(const UpgradeGeometryTGeo& s return *this; } -Int_t UpgradeGeometryTGeo::GetChipIndex(Int_t lay, Int_t sta, Int_t chipInStave) const +Int_t UpgradeGeometryTGeo::getChipIndex(Int_t lay, Int_t sta, Int_t chipInStave) const { - return GetFirstChipIndex(lay) + mNumberOfChipsPerStave[lay] * sta + chipInStave; + return getFirstChipIndex(lay) + mNumberOfChipsPerStave[lay] * sta + chipInStave; } -Int_t UpgradeGeometryTGeo::GetChipIndex(Int_t lay, Int_t sta, Int_t substa, Int_t chipInSStave) +Int_t UpgradeGeometryTGeo::getChipIndex(Int_t lay, Int_t sta, Int_t substa, Int_t chipInSStave) const { - int n = GetFirstChipIndex(lay) + mNumberOfChipsPerStave[lay] * sta + chipInSStave; + int n = getFirstChipIndex(lay) + mNumberOfChipsPerStave[lay] * sta + chipInSStave; if (mNumberOfHalfStaves[lay] && substa > 0) { n += mNumberOfChipsPerHalfStave[lay] * substa; } return n; } -Int_t UpgradeGeometryTGeo::GetChipIndex(Int_t lay, Int_t sta, Int_t substa, Int_t md, +Int_t UpgradeGeometryTGeo::getChipIndex(Int_t lay, Int_t sta, Int_t substa, Int_t md, Int_t chipInMod) const { - int n = GetFirstChipIndex(lay) + mNumberOfChipsPerStave[lay] * sta + chipInMod; + int n = getFirstChipIndex(lay) + mNumberOfChipsPerStave[lay] * sta + chipInMod; if (mNumberOfHalfStaves[lay] && substa > 0) { n += mNumberOfChipsPerHalfStave[lay] * substa; } @@ -267,14 +267,14 @@ Int_t UpgradeGeometryTGeo::GetChipIndex(Int_t lay, Int_t sta, Int_t substa, Int_ return n; } -Bool_t UpgradeGeometryTGeo::GetLayer(Int_t index, Int_t& lay, Int_t& indexInLr) const +Bool_t UpgradeGeometryTGeo::getLayer(Int_t index, Int_t& lay, Int_t& indexInLr) const { - lay = GetLayer(index); - indexInLr = index - GetFirstChipIndex(lay); + lay = getLayer(index); + indexInLr = index - getFirstChipIndex(lay); return kTRUE; } -Int_t UpgradeGeometryTGeo::GetLayer(Int_t index) const +Int_t UpgradeGeometryTGeo::getLayer(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { @@ -283,17 +283,17 @@ Int_t UpgradeGeometryTGeo::GetLayer(Int_t index) const return lay; } -Int_t UpgradeGeometryTGeo::GetStave(Int_t index) const +Int_t UpgradeGeometryTGeo::getStave(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { lay++; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); return index / mNumberOfChipsPerStave[lay]; } -Int_t UpgradeGeometryTGeo::GetHalfStave(Int_t index) const +Int_t UpgradeGeometryTGeo::getHalfStave(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { @@ -302,12 +302,12 @@ Int_t UpgradeGeometryTGeo::GetHalfStave(Int_t index) const if (mNumberOfHalfStaves[lay] < 0) { return -1; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); index %= mNumberOfChipsPerStave[lay]; return index / mNumberOfChipsPerHalfStave[lay]; } -Int_t UpgradeGeometryTGeo::GetModule(Int_t index) const +Int_t UpgradeGeometryTGeo::getModule(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { @@ -316,7 +316,7 @@ Int_t UpgradeGeometryTGeo::GetModule(Int_t index) const if (mNumberOfModules[lay] < 0) { return 0; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); index %= mNumberOfChipsPerStave[lay]; if (mNumberOfHalfStaves[lay]) { index %= mNumberOfChipsPerHalfStave[lay]; @@ -324,51 +324,51 @@ Int_t UpgradeGeometryTGeo::GetModule(Int_t index) const return index / mNumberOfChipsPerModule[lay]; } -Int_t UpgradeGeometryTGeo::GetChipIdInLayer(Int_t index) const +Int_t UpgradeGeometryTGeo::getChipIdInLayer(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { lay++; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); return index; } -Int_t UpgradeGeometryTGeo::GetChipIdInStave(Int_t index) const +Int_t UpgradeGeometryTGeo::getChipIdInStave(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { lay++; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); return index % mNumberOfChipsPerStave[lay]; } -Int_t UpgradeGeometryTGeo::GetChipIdInHalfStave(Int_t index) const +Int_t UpgradeGeometryTGeo::getChipIdInHalfStave(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { lay++; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); return index % mNumberOfChipsPerHalfStave[lay]; } -Int_t UpgradeGeometryTGeo::GetChipIdInModule(Int_t index) const +Int_t UpgradeGeometryTGeo::getChipIdInModule(Int_t index) const { int lay = 0; while (index > mLastChipIndex[lay]) { lay++; } - index -= GetFirstChipIndex(lay); + index -= getFirstChipIndex(lay); return index % mNumberOfChipsPerModule[lay]; } -Bool_t UpgradeGeometryTGeo::GetChipId(Int_t index, Int_t& lay, Int_t& sta, Int_t& hsta, Int_t& mod, +Bool_t UpgradeGeometryTGeo::getChipId(Int_t index, Int_t& lay, Int_t& sta, Int_t& hsta, Int_t& mod, Int_t& chip) const { - lay = GetLayer(index); - index -= GetFirstChipIndex(lay); + lay = getLayer(index); + index -= getFirstChipIndex(lay); sta = index / mNumberOfChipsPerStave[lay]; index %= mNumberOfChipsPerStave[lay]; hsta = mNumberOfHalfStaves[lay] > 0 ? index / mNumberOfChipsPerHalfStave[lay] : -1; @@ -379,10 +379,10 @@ Bool_t UpgradeGeometryTGeo::GetChipId(Int_t index, Int_t& lay, Int_t& sta, Int_t return kTRUE; } -const char* UpgradeGeometryTGeo::GetSymbolicName(Int_t index) const +const char* UpgradeGeometryTGeo::getSymbolicName(Int_t index) const { Int_t lay, index2; - if (!GetLayer(index, lay, index2)) { + if (!getLayer(index, lay, index2)) { return NULL; } // return @@ -390,8 +390,8 @@ const char* UpgradeGeometryTGeo::GetSymbolicName(Int_t index) const // RS: this is not optimal, but we cannod access directly GeometryManager, since the latter has // hardwired layers // TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( - // GeometryManager::LayerToVolUID(lay+1,index2) ); - TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(ChipVolUID(index)); + // GeometryManager::layerToVolUID(lay+1,index2) ); + TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(chipVolUID(index)); if (!pne) { LOG(ERROR) << "Failed to find alignable entry with index " << index << ": (Lr" << lay << " Chip:" << index2 << ") !" << FairLogger::endl; @@ -400,46 +400,46 @@ const char* UpgradeGeometryTGeo::GetSymbolicName(Int_t index) const return pne->GetName(); } -const char* UpgradeGeometryTGeo::ComposeSymNameITS() +const char* UpgradeGeometryTGeo::composeSymNameITS() { return "ITS"; } -const char* UpgradeGeometryTGeo::ComposeSymNameLayer(Int_t lr) +const char* UpgradeGeometryTGeo::composeSymNameLayer(Int_t lr) { - return Form("%s/%s%d", ComposeSymNameITS(), GetITSLayerPattern(), lr); + return Form("%s/%s%d", composeSymNameITS(), getITSLayerPattern(), lr); } -const char* UpgradeGeometryTGeo::ComposeSymNameStave(Int_t lr, Int_t stave) +const char* UpgradeGeometryTGeo::composeSymNameStave(Int_t lr, Int_t stave) { - return Form("%s/%s%d", ComposeSymNameLayer(lr), GetITSStavePattern(), stave); + return Form("%s/%s%d", composeSymNameLayer(lr), getITSStavePattern(), stave); } -const char* UpgradeGeometryTGeo::ComposeSymNameHalfStave(Int_t lr, Int_t stave, Int_t substave) +const char* UpgradeGeometryTGeo::composeSymNameHalfStave(Int_t lr, Int_t stave, Int_t substave) { return substave >= 0 - ? Form("%s/%s%d", ComposeSymNameStave(lr, stave), GetITSHalfStavePattern(), substave) - : ComposeSymNameStave(lr, stave); + ? Form("%s/%s%d", composeSymNameStave(lr, stave), getITSHalfStavePattern(), substave) + : composeSymNameStave(lr, stave); } -const char* UpgradeGeometryTGeo::ComposeSymNameModule(Int_t lr, Int_t stave, Int_t substave, +const char* UpgradeGeometryTGeo::composeSymNameModule(Int_t lr, Int_t stave, Int_t substave, Int_t mod) { - return mod >= 0 ? Form("%s/%s%d", ComposeSymNameHalfStave(lr, stave, substave), - GetITSModulePattern(), mod) - : ComposeSymNameHalfStave(lr, stave, substave); + return mod >= 0 ? Form("%s/%s%d", composeSymNameHalfStave(lr, stave, substave), + getITSModulePattern(), mod) + : composeSymNameHalfStave(lr, stave, substave); } -const char* UpgradeGeometryTGeo::ComposeSymNameChip(Int_t lr, Int_t sta, Int_t substave, Int_t mod, +const char* UpgradeGeometryTGeo::composeSymNameChip(Int_t lr, Int_t sta, Int_t substave, Int_t mod, Int_t chip) { - return Form("%s/%s%d", ComposeSymNameModule(lr, sta, substave, mod), GetITSChipPattern(), chip); + return Form("%s/%s%d", composeSymNameModule(lr, sta, substave, mod), getITSChipPattern(), chip); } TGeoHMatrix* UpgradeGeometryTGeo::GetMatrix(Int_t index) const { static TGeoHMatrix matTmp; - TGeoPNEntry* pne = GetPNEntry(index); + TGeoPNEntry* pne = getPNEntry(index); if (!pne) { return NULL; } @@ -476,7 +476,7 @@ Bool_t UpgradeGeometryTGeo::GetTranslation(Int_t index, Double_t t[3]) const return kTRUE; } -Bool_t UpgradeGeometryTGeo::GetRotation(Int_t index, Double_t r[9]) const +Bool_t UpgradeGeometryTGeo::getRotation(Int_t index, Double_t r[9]) const { TGeoHMatrix* m = GetMatrix(index); if (!m) { @@ -495,15 +495,15 @@ Bool_t UpgradeGeometryTGeo::GetOriginalMatrix(Int_t index, TGeoHMatrix& m) const { m.Clear(); - const char* symname = GetSymbolicName(index); + const char* symname = getSymbolicName(index); if (!symname) { return kFALSE; } - return GeometryManager::GetOriginalGlobalMatrix(symname, m); + return GeometryManager::getOriginalGlobalMatrix(symname, m); } -Bool_t UpgradeGeometryTGeo::GetOriginalTranslation(Int_t index, Double_t t[3]) const +Bool_t UpgradeGeometryTGeo::getOriginalTranslation(Int_t index, Double_t t[3]) const { TGeoHMatrix m; if (!GetOriginalMatrix(index, m)) { @@ -518,7 +518,7 @@ Bool_t UpgradeGeometryTGeo::GetOriginalTranslation(Int_t index, Double_t t[3]) c return kTRUE; } -Bool_t UpgradeGeometryTGeo::GetOriginalRotation(Int_t index, Double_t r[9]) const +Bool_t UpgradeGeometryTGeo::getOriginalRotation(Int_t index, Double_t r[9]) const { TGeoHMatrix m; if (!GetOriginalMatrix(index, m)) { @@ -533,9 +533,9 @@ Bool_t UpgradeGeometryTGeo::GetOriginalRotation(Int_t index, Double_t r[9]) cons return kTRUE; } -TGeoHMatrix* UpgradeGeometryTGeo::ExtractMatrixTrackingToLocal(Int_t index) const +TGeoHMatrix* UpgradeGeometryTGeo::extractMatrixTrackingToLocal(Int_t index) const { - TGeoPNEntry* pne = GetPNEntry(index); + TGeoPNEntry* pne = getPNEntry(index); if (!pne) { return NULL; } @@ -548,7 +548,7 @@ TGeoHMatrix* UpgradeGeometryTGeo::ExtractMatrixTrackingToLocal(Int_t index) cons return m; } -Bool_t UpgradeGeometryTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix& m) +Bool_t UpgradeGeometryTGeo::getTrackingMatrix(Int_t index, TGeoHMatrix& m) { m.Clear(); @@ -557,7 +557,7 @@ Bool_t UpgradeGeometryTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix& m) return kFALSE; } - const TGeoHMatrix* m2 = GetMatrixT2L(index); + const TGeoHMatrix* m2 = getMatrixT2L(index); if (!m2) { return kFALSE; } @@ -568,30 +568,30 @@ Bool_t UpgradeGeometryTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix& m) return kTRUE; } -TGeoHMatrix* UpgradeGeometryTGeo::ExtractMatrixSensor(Int_t index) const +TGeoHMatrix* UpgradeGeometryTGeo::extractMatrixSensor(Int_t index) const { Int_t lay, stav, sstav, mod, chipInMod; - GetChipId(index, lay, stav, sstav, mod, chipInMod); + getChipId(index, lay, stav, sstav, mod, chipInMod); int wrID = mLayerToWrapper[lay]; - TString path = Form("/cave_1/%s_2/", UpgradeGeometryTGeo::GetITSVolPattern()); + TString path = Form("/cave_1/%s_2/", UpgradeGeometryTGeo::getITSVolPattern()); if (wrID >= 0) { - path += Form("%s%d_1/", GetITSWrapVolPattern(), wrID); + path += Form("%s%d_1/", getITSWrapVolPattern(), wrID); } - path += Form("%s%d_1/%s%d_%d/", UpgradeGeometryTGeo::GetITSLayerPattern(), lay, - UpgradeGeometryTGeo::GetITSStavePattern(), lay, stav); + path += Form("%s%d_1/%s%d_%d/", UpgradeGeometryTGeo::getITSLayerPattern(), lay, + UpgradeGeometryTGeo::getITSStavePattern(), lay, stav); if (mNumberOfHalfStaves[lay] > 0) { - path += Form("%s%d_%d/", UpgradeGeometryTGeo::GetITSHalfStavePattern(), lay, sstav); + path += Form("%s%d_%d/", UpgradeGeometryTGeo::getITSHalfStavePattern(), lay, sstav); } if (mNumberOfModules[lay] > 0) { - path += Form("%s%d_%d/", UpgradeGeometryTGeo::GetITSModulePattern(), lay, mod); + path += Form("%s%d_%d/", UpgradeGeometryTGeo::getITSModulePattern(), lay, mod); } - path += Form("%s%d_%d/%s%d_1", UpgradeGeometryTGeo::GetITSChipPattern(), lay, chipInMod, - UpgradeGeometryTGeo::GetITSSensorPattern(), lay); + path += Form("%s%d_%d/%s%d_1", UpgradeGeometryTGeo::getITSChipPattern(), lay, chipInMod, + UpgradeGeometryTGeo::getITSSensorPattern(), lay); static TGeoHMatrix matTmp; gGeoManager->PushPath(); @@ -611,7 +611,7 @@ TGeoHMatrix* UpgradeGeometryTGeo::ExtractMatrixSensor(Int_t index) const return &matTmp; } -TGeoPNEntry* UpgradeGeometryTGeo::GetPNEntry(Int_t index) const +TGeoPNEntry* UpgradeGeometryTGeo::getPNEntry(Int_t index) const { if (index >= mNumberOfChips) { LOG(ERROR) << "Invalid ITS chip index: " << index << " (0 -> " << mNumberOfChips << ") !" @@ -624,8 +624,8 @@ TGeoPNEntry* UpgradeGeometryTGeo::GetPNEntry(Int_t index) const << FairLogger::endl; return NULL; } - TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(ChipVolUID(index)); - // TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymbolicName(index)); + TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(chipVolUID(index)); + // TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(getSymbolicName(index)); if (!pne) { LOG(ERROR) << "The index " << index << " does not correspond to a physical entry!" @@ -644,7 +644,7 @@ void UpgradeGeometryTGeo::Build(Bool_t loadSegmentations) LOG(FATAL) << "Geometry is not loaded" << FairLogger::endl; } - mNumberOfLayers = ExtractNumberOfLayers(); + mNumberOfLayers = extractNumberOfLayers(); if (!mNumberOfLayers) { return; } @@ -662,11 +662,11 @@ void UpgradeGeometryTGeo::Build(Bool_t loadSegmentations) mNumberOfChips = 0; for (int i = 0; i < mNumberOfLayers; i++) { - mLayerChipType[i] = ExtractLayerChipType(i); - mNumberOfStaves[i] = ExtractNumberOfStaves(i); - mNumberOfHalfStaves[i] = ExtractNumberOfHalfStaves(i); - mNumberOfModules[i] = ExtractNumberOfModules(i); - mNumberOfChipsPerModule[i] = ExtractNumberOfChipsPerModule(i, mNumberOfChipRowsPerModule[i]); + mLayerChipType[i] = extractLayerChipType(i); + mNumberOfStaves[i] = extractNumberOfStaves(i); + mNumberOfHalfStaves[i] = extractNumberOfHalfStaves(i); + mNumberOfModules[i] = extractNumberOfModules(i); + mNumberOfChipsPerModule[i] = extractNumberOfChipsPerModule(i, mNumberOfChipRowsPerModule[i]); mNumberOfChipsPerHalfStave[i] = mNumberOfChipsPerModule[i] * Max(1, mNumberOfModules[i]); mNumberOfChipsPerStave[i] = mNumberOfChipsPerHalfStave[i] * Max(1, mNumberOfHalfStaves[i]); mNumberOfChipsPerLayer[i] = mNumberOfChipsPerStave[i] * mNumberOfStaves[i]; @@ -674,25 +674,25 @@ void UpgradeGeometryTGeo::Build(Bool_t loadSegmentations) mLastChipIndex[i] = mNumberOfChips - 1; } - FetchMatrices(); + fetchMatrices(); mVersion = kITSVUpg; if (loadSegmentations) { // fetch segmentations mSegmentations = new TObjArray(); - UpgradeSegmentationPixel::LoadSegmentations(mSegmentations, GetITSsegmentationFileName()); + UpgradeSegmentationPixel::loadSegmentations(mSegmentations, getITSsegmentationFileName()); } } -Int_t UpgradeGeometryTGeo::ExtractNumberOfLayers() +Int_t UpgradeGeometryTGeo::extractNumberOfLayers() { Int_t numberOfLayers = 0; - TGeoVolume* itsV = gGeoManager->GetVolume(GetITSVolPattern()); + TGeoVolume* itsV = gGeoManager->GetVolume(getITSVolPattern()); if (!itsV) { - LOG(FATAL) << "ITS volume " << GetITSVolPattern() << " is not in the geometry" + LOG(FATAL) << "ITS volume " << getITSVolPattern() << " is not in the geometry" << FairLogger::endl; } - SetUIDShift(itsV->GetUniqueID()); + setUIDShift(itsV->GetUniqueID()); // Loop on all ITSV nodes, count Layer volumes by checking names // Build on the fly layer - wrapper correspondence @@ -704,18 +704,18 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfLayers() TGeoNode* nd = (TGeoNode*)nodes->At(j); const char* name = nd->GetName(); - if (strstr(name, GetITSLayerPattern())) { + if (strstr(name, getITSLayerPattern())) { numberOfLayers++; - if ((lrID = ExtractVolumeCopy(name, UpgradeGeometryTGeo::GetITSLayerPattern())) < 0) { + if ((lrID = extractVolumeCopy(name, UpgradeGeometryTGeo::getITSLayerPattern())) < 0) { LOG(FATAL) << "Failed to extract layer ID from the " << name << FairLogger::endl; exit(1); } mLayerToWrapper[lrID] = -1; // not wrapped } else if (strstr(name, - GetITSWrapVolPattern())) { // this is a wrapper volume, may cointain layers + getITSWrapVolPattern())) { // this is a wrapper volume, may cointain layers int wrID = -1; - if ((wrID = ExtractVolumeCopy(name, UpgradeGeometryTGeo::GetITSWrapVolPattern())) < 0) { + if ((wrID = extractVolumeCopy(name, UpgradeGeometryTGeo::getITSWrapVolPattern())) < 0) { LOG(FATAL) << "Failed to extract wrapper ID from the " << name << FairLogger::endl; exit(1); } @@ -725,9 +725,9 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfLayers() for (Int_t jw = 0; jw < nNodesW; jw++) { TGeoNode* ndW = (TGeoNode*)nodesW->At(jw); - if (strstr(ndW->GetName(), GetITSLayerPattern())) { - if ((lrID = ExtractVolumeCopy(ndW->GetName(), - UpgradeGeometryTGeo::GetITSLayerPattern())) < 0) { + if (strstr(ndW->GetName(), getITSLayerPattern())) { + if ((lrID = extractVolumeCopy(ndW->GetName(), + UpgradeGeometryTGeo::getITSLayerPattern())) < 0) { LOG(FATAL) << "Failed to extract layer ID from the " << name << FairLogger::endl; exit(1); } @@ -740,11 +740,11 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfLayers() return numberOfLayers; } -Int_t UpgradeGeometryTGeo::ExtractNumberOfStaves(Int_t lay) const +Int_t UpgradeGeometryTGeo::extractNumberOfStaves(Int_t lay) const { Int_t numberOfStaves = 0; char laynam[30]; - snprintf(laynam, 30, "%s%d", GetITSLayerPattern(), lay); + snprintf(laynam, 30, "%s%d", getITSLayerPattern(), lay); TGeoVolume* volLr = gGeoManager->GetVolume(laynam); if (!volLr) { LOG(FATAL) << "can't find " << laynam << " volume" << FairLogger::endl; @@ -756,22 +756,22 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfStaves(Int_t lay) const for (Int_t j = 0; j < nNodes; j++) { // LOG(INFO) << "L" << lay << " " << j << " of " << nNodes << " " // << volLr->GetNodes()->At(j)->GetName() << " " - // << GetITSStavePattern() << " -> " << numberOfStaves << FairLogger::endl; - if (strstr(volLr->GetNodes()->At(j)->GetName(), GetITSStavePattern())) { + // << getITSStavePattern() << " -> " << numberOfStaves << FairLogger::endl; + if (strstr(volLr->GetNodes()->At(j)->GetName(), getITSStavePattern())) { numberOfStaves++; } } return numberOfStaves; } -Int_t UpgradeGeometryTGeo::ExtractNumberOfHalfStaves(Int_t lay) const +Int_t UpgradeGeometryTGeo::extractNumberOfHalfStaves(Int_t lay) const { if (mHalfStaveName.IsNull()) { return 0; // for the setup w/o substave defined the stave and the substave is the same thing } Int_t nSS = 0; char stavnam[30]; - snprintf(stavnam, 30, "%s%d", GetITSStavePattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSStavePattern(), lay); TGeoVolume* volLd = gGeoManager->GetVolume(stavnam); if (!volLd) { LOG(FATAL) << "can't find volume " << stavnam << FairLogger::endl; @@ -779,14 +779,14 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfHalfStaves(Int_t lay) const // Loop on all stave nodes, count Chip volumes by checking names Int_t nNodes = volLd->GetNodes()->GetEntries(); for (Int_t j = 0; j < nNodes; j++) { - if (strstr(volLd->GetNodes()->At(j)->GetName(), GetITSHalfStavePattern())) { + if (strstr(volLd->GetNodes()->At(j)->GetName(), getITSHalfStavePattern())) { nSS++; } } return nSS; } -Int_t UpgradeGeometryTGeo::ExtractNumberOfModules(Int_t lay) const +Int_t UpgradeGeometryTGeo::extractNumberOfModules(Int_t lay) const { if (mModuleName.IsNull()) { return 0; @@ -796,11 +796,11 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfModules(Int_t lay) const TGeoVolume* volLd = 0; if (!mHalfStaveName.IsNull()) { - snprintf(stavnam, 30, "%s%d", GetITSHalfStavePattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSHalfStavePattern(), lay); volLd = gGeoManager->GetVolume(stavnam); } if (!volLd) { // no substaves, check staves - snprintf(stavnam, 30, "%s%d", GetITSStavePattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSStavePattern(), lay); volLd = gGeoManager->GetVolume(stavnam); } if (!volLd) { @@ -813,31 +813,31 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfModules(Int_t lay) const Int_t nNodes = volLd->GetNodes()->GetEntries(); for (Int_t j = 0; j < nNodes; j++) { - if (strstr(volLd->GetNodes()->At(j)->GetName(), GetITSModulePattern())) { + if (strstr(volLd->GetNodes()->At(j)->GetName(), getITSModulePattern())) { nMod++; } } return nMod; } -Int_t UpgradeGeometryTGeo::ExtractNumberOfChipsPerModule(Int_t lay, int& nrow) const +Int_t UpgradeGeometryTGeo::extractNumberOfChipsPerModule(Int_t lay, int& nrow) const { Int_t numberOfChips = 0; char stavnam[30]; TGeoVolume* volLd = 0; if (!mModuleName.IsNull()) { - snprintf(stavnam, 30, "%s%d", GetITSModulePattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSModulePattern(), lay); volLd = gGeoManager->GetVolume(stavnam); } if (!volLd) { // no modules on this layer, check substaves if (!mHalfStaveName.IsNull()) { - snprintf(stavnam, 30, "%s%d", GetITSHalfStavePattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSHalfStavePattern(), lay); volLd = gGeoManager->GetVolume(stavnam); } } if (!volLd) { // no substaves on this layer, check staves - snprintf(stavnam, 30, "%s%d", GetITSStavePattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSStavePattern(), lay); volLd = gGeoManager->GetVolume(stavnam); } if (!volLd) { @@ -855,7 +855,7 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfChipsPerModule(Int_t lay, int& nrow) c // AliInfo(Form("L%d %d of %d %s %s -> // %d",lay,j,nNodes,volLd->GetNodes()->At(j)->GetName(),GetITSChipPattern(),numberOfChips)); TGeoNodeMatrix* node = (TGeoNodeMatrix*)volLd->GetNodes()->At(j); - if (!strstr(node->GetName(), GetITSChipPattern())) { + if (!strstr(node->GetName(), getITSChipPattern())) { continue; } node->LocalToMaster(loc, lab); @@ -900,10 +900,10 @@ Int_t UpgradeGeometryTGeo::ExtractNumberOfChipsPerModule(Int_t lay, int& nrow) c return numberOfChips; } -Int_t UpgradeGeometryTGeo::ExtractLayerChipType(Int_t lay) const +Int_t UpgradeGeometryTGeo::extractLayerChipType(Int_t lay) const { char stavnam[30]; - snprintf(stavnam, 30, "%s%d", GetITSLayerPattern(), lay); + snprintf(stavnam, 30, "%s%d", getITSLayerPattern(), lay); TGeoVolume* volLd = gGeoManager->GetVolume(stavnam); if (!volLd) { LOG(FATAL) << "can't find volume " << stavnam << FairLogger::endl; @@ -912,7 +912,7 @@ Int_t UpgradeGeometryTGeo::ExtractLayerChipType(Int_t lay) const return volLd->GetUniqueID(); } -UInt_t UpgradeGeometryTGeo::ComposeChipTypeId(UInt_t segmId) +UInt_t UpgradeGeometryTGeo::composeChipTypeId(UInt_t segmId) { if (segmId >= kMaxSegmPerChipType) { LOG(FATAL) << "Id=" << segmId << " is >= max.allowed " << kMaxSegmPerChipType @@ -935,11 +935,11 @@ void UpgradeGeometryTGeo::Print(Option_t*) const ? mNumberOfChipsPerModule[i] / mNumberOfChipRowsPerModule[i] : 0, mNumberOfModules[i], mNumberOfHalfStaves[i], mNumberOfStaves[i], mLayerChipType[i], - GetFirstChipIndex(i), GetLastChipIndex(i), mLayerToWrapper[i]); + getFirstChipIndex(i), getLastChipIndex(i), mLayerToWrapper[i]); } } -void UpgradeGeometryTGeo::FetchMatrices() +void UpgradeGeometryTGeo::fetchMatrices() { if (!gGeoManager) { LOG(FATAL) << "Geometry is not loaded" << FairLogger::endl; @@ -947,12 +947,12 @@ void UpgradeGeometryTGeo::FetchMatrices() mSensorMatrices = new TObjArray(mNumberOfChips); mSensorMatrices->SetOwner(kTRUE); for (int i = 0; i < mNumberOfChips; i++) { - mSensorMatrices->AddAt(new TGeoHMatrix(*ExtractMatrixSensor(i)), i); + mSensorMatrices->AddAt(new TGeoHMatrix(*extractMatrixSensor(i)), i); } - CreateT2LMatrices(); + createT2LMatrices(); } -void UpgradeGeometryTGeo::CreateT2LMatrices() +void UpgradeGeometryTGeo::createT2LMatrices() { // create tracking to local (Sensor!) matrices mTrackingToLocalMatrices = new TObjArray(mNumberOfChips); @@ -960,7 +960,7 @@ void UpgradeGeometryTGeo::CreateT2LMatrices() TGeoHMatrix matLtoT; double locA[3] = { -100, 0, 0 }, locB[3] = { 100, 0, 0 }, gloA[3], gloB[3]; for (int isn = 0; isn < mNumberOfChips; isn++) { - const TGeoHMatrix* matSens = GetMatrixSensor(isn); + const TGeoHMatrix* matSens = getMatrixSensor(isn); if (!matSens) { LOG(FATAL) << "Failed to get matrix for sensor " << isn << FairLogger::endl; return; @@ -1012,7 +1012,7 @@ void UpgradeGeometryTGeo::CreateT2LMatrices() } //______________________________________________________________________ -Int_t UpgradeGeometryTGeo::ExtractVolumeCopy(const char* name, const char* prefix) const +Int_t UpgradeGeometryTGeo::extractVolumeCopy(const char* name, const char* prefix) const { TString nms = name; if (!nms.BeginsWith(prefix)) { diff --git a/its/UpgradeGeometryTGeo.h b/its/UpgradeGeometryTGeo.h index 8f44d1c54d767..27d0f316bc289 100644 --- a/its/UpgradeGeometryTGeo.h +++ b/its/UpgradeGeometryTGeo.h @@ -38,7 +38,7 @@ class Segmentation; /// composed as: /// CoarseType*kMaxSegmPerChipType + segmentationType /// The only requirement on the segmentationType that should be < kMaxSegmPerChipType. -/// The methods like GetLayerChipTypeID return the full chip type +/// The methods like getLayerChipTypeID return the full chip type class UpgradeGeometryTGeo : public TObject { public: @@ -59,63 +59,61 @@ class UpgradeGeometryTGeo : public TObject { UpgradeGeometryTGeo& operator=(const UpgradeGeometryTGeo& geom); - Int_t GetNumberOfChips() const + Int_t getNumberOfChips() const { return mNumberOfChips; } - Int_t GetNumberOfChipRowsPerModule(Int_t lay) const + Int_t getNumberOfChipRowsPerModule(Int_t lay) const { return mNumberOfChipRowsPerModule[lay]; } - Int_t GetNumberOfChipColsPerModule(Int_t lay) const + Int_t getNumberOfChipColsPerModule(Int_t lay) const { - return mNumberOfChipRowsPerModule[lay] - ? mNumberOfChipsPerModule[lay] / mNumberOfChipRowsPerModule[lay] - : -1; + return mNumberOfChipRowsPerModule[lay] ? mNumberOfChipsPerModule[lay] / mNumberOfChipRowsPerModule[lay] : -1; } - Int_t GetNumberOfChipsPerModule(Int_t lay) const + Int_t getNumberOfChipsPerModule(Int_t lay) const { return mNumberOfChipsPerModule[lay]; } - Int_t GetNumberOfChipsPerHalfStave(Int_t lay) const + Int_t getNumberOfChipsPerHalfStave(Int_t lay) const { return mNumberOfChipsPerHalfStave[lay]; } - Int_t GetNumberOfChipsPerStave(Int_t lay) const + Int_t getNumberOfChipsPerStave(Int_t lay) const { return mNumberOfChipsPerStave[lay]; } - Int_t GetNumberOfChipsPerLayer(Int_t lay) const + Int_t getNumberOfChipsPerLayer(Int_t lay) const { return mNumberOfChipsPerLayer[lay]; } - Int_t GetNumberOfModules(Int_t lay) const + Int_t getNumberOfModules(Int_t lay) const { return mNumberOfModules[lay]; } - Int_t GetNumberOfHalfStaves(Int_t lay) const + Int_t getNumberOfHalfStaves(Int_t lay) const { return mNumberOfHalfStaves[lay]; } - Int_t GetNumberOfStaves(Int_t lay) const + Int_t getNumberOfStaves(Int_t lay) const { return mNumberOfStaves[lay]; } - Int_t GetNumberOfLayers() const + Int_t getNumberOfLayers() const { return mNumberOfLayers; } - Int_t GetChipIndex(Int_t lay, int detInLay) const + Int_t getChipIndex(Int_t lay, int detInLay) const { - return GetFirstChipIndex(lay) + detInLay; + return getFirstChipIndex(lay) + detInLay; } /// This routine computes the chip index number from the layer, stave, and chip number in stave /// \param Int_t lay The layer number. Starting from 0. /// \param Int_t sta The stave number. Starting from 0 /// \param Int_t chipInStave The chip number in the stave. Starting from 0 - Int_t GetChipIndex(Int_t lay, Int_t sta, Int_t detInSta) const; + Int_t getChipIndex(Int_t lay, Int_t sta, Int_t detInSta) const; /// This routine computes the chip index number from the layer, stave, substave and chip number /// in substave @@ -123,7 +121,7 @@ class UpgradeGeometryTGeo : public TObject { /// \param Int_t sta The stave number. Starting from 0 /// \param Int_t substa The substave number. Starting from 0 /// \param Int_t chipInSStave The chip number in the sub stave. Starting from 0 - Int_t GetChipIndex(Int_t lay, Int_t sta, Int_t subSta, Int_t detInSubSta) const; + Int_t getChipIndex(Int_t lay, Int_t sta, Int_t subSta, Int_t detInSubSta) const; /// This routine computes the chip index number from the layer,stave, substave module and /// chip number in module. @@ -132,7 +130,7 @@ class UpgradeGeometryTGeo : public TObject { /// \param Int_t substa The substave number. Starting from 0 /// \param Int_t module The module number ... /// \param Int_t chipInSStave The chip number in the module. Starting from 0 - Int_t GetChipIndex(Int_t lay, Int_t sta, Int_t subSta, Int_t md, Int_t detInMod) const; + Int_t getChipIndex(Int_t lay, Int_t sta, Int_t subSta, Int_t md, Int_t detInMod) const; /// This routine computes the layer, stave, substave, module and chip number /// given the chip index number @@ -142,45 +140,45 @@ class UpgradeGeometryTGeo : public TObject { /// \param Int_t ssta The halfstave number. Starting from 0 /// \param Int_t mod The module number. Starting from 0 /// \param Int_t chip The detector number. Starting from 0 - Bool_t GetChipId(Int_t index, Int_t& lay, Int_t& sta, Int_t& ssta, Int_t& mod, Int_t& chip) const; + Bool_t getChipId(Int_t index, Int_t& lay, Int_t& sta, Int_t& ssta, Int_t& mod, Int_t& chip) const; /// Get chip layer, from 0 - Int_t GetLayer(Int_t index) const; + Int_t getLayer(Int_t index) const; /// Get chip stave, from 0 - Int_t GetStave(Int_t index) const; + Int_t getStave(Int_t index) const; /// Get chip substave id in stave, from 0 - Int_t GetHalfStave(Int_t index) const; + Int_t getHalfStave(Int_t index) const; /// Get chip module id in substave, from 0 - Int_t GetModule(Int_t index) const; + Int_t getModule(Int_t index) const; /// Get chip number within layer, from 0 - Int_t GetChipIdInLayer(Int_t index) const; + Int_t getChipIdInLayer(Int_t index) const; /// Get chip number within stave, from 0 - Int_t GetChipIdInStave(Int_t index) const; + Int_t getChipIdInStave(Int_t index) const; /// Get chip number within stave, from 0 - Int_t GetChipIdInHalfStave(Int_t index) const; + Int_t getChipIdInHalfStave(Int_t index) const; /// Get chip number within module, from 0 - Int_t GetChipIdInModule(Int_t index) const; + Int_t getChipIdInModule(Int_t index) const; - Int_t GetLastChipIndex(Int_t lay) const + Int_t getLastChipIndex(Int_t lay) const { return mLastChipIndex[lay]; } - Int_t GetFirstChipIndex(Int_t lay) const + Int_t getFirstChipIndex(Int_t lay) const { return (lay == 0) ? 0 : mLastChipIndex[lay - 1] + 1; } /// Get the TGeoPNEntry symbolic name for a given chip identified by 'index' - const char* GetSymbolicName(Int_t index) const; + const char* getSymbolicName(Int_t index) const; - const char* GetSymbolicName(Int_t lay, Int_t sta, Int_t det) const; + const char* getSymbolicName(Int_t lay, Int_t sta, Int_t det) const; // Attention: these are the matrices for the alignable volumes of the chips, i.e. not necessarily // the sensors @@ -194,8 +192,8 @@ class UpgradeGeometryTGeo : public TObject { Bool_t GetTranslation(Int_t lay, Int_t sta, Int_t det, Double_t t[3]) const; /// Get the rotation matrix for a given chip 'index' by quering the TGeoManager - Bool_t GetRotation(Int_t index, Double_t r[9]) const; - Bool_t GetRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const; + Bool_t getRotation(Int_t index, Double_t r[9]) const; + Bool_t getRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const; /// Get the original (ideal geometry) TGeo matrix for a given chip identified by 'index' /// The method is slow, so it should be used with great care @@ -204,237 +202,237 @@ class UpgradeGeometryTGeo : public TObject { /// Get the original translation vector (ideal geometry) /// for a given chip 'index' by quering the TGeoManager - Bool_t GetOriginalTranslation(Int_t index, Double_t t[3]) const; - Bool_t GetOriginalTranslation(Int_t lay, Int_t sta, Int_t det, Double_t t[3]) const; + Bool_t getOriginalTranslation(Int_t index, Double_t t[3]) const; + Bool_t getOriginalTranslation(Int_t lay, Int_t sta, Int_t det, Double_t t[3]) const; /// Get the original rotation matrix (ideal geometry) /// for a given chip 'index' by quering the TGeoManager - Bool_t GetOriginalRotation(Int_t index, Double_t r[9]) const; - Bool_t GetOriginalRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const; + Bool_t getOriginalRotation(Int_t index, Double_t r[9]) const; + Bool_t getOriginalRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const; - const TGeoHMatrix* GetMatrixT2L(Int_t index); - const TGeoHMatrix* GetMatrixT2L(Int_t lay, Int_t sta, Int_t det) + const TGeoHMatrix* getMatrixT2L(Int_t index); + const TGeoHMatrix* getMatrixT2L(Int_t lay, Int_t sta, Int_t det) { - return GetMatrixT2L(GetChipIndex(lay, sta, det)); + return getMatrixT2L(getChipIndex(lay, sta, det)); } - const TGeoHMatrix* GetMatrixSensor(Int_t index); - const TGeoHMatrix* GetMatrixSensor(Int_t lay, Int_t sta, Int_t det) + const TGeoHMatrix* getMatrixSensor(Int_t index); + const TGeoHMatrix* getMatrixSensor(Int_t lay, Int_t sta, Int_t det) { - return GetMatrixSensor(GetChipIndex(lay, sta, det)); + return getMatrixSensor(getChipIndex(lay, sta, det)); } /// Get the matrix which transforms from the tracking r.s. to the global one /// Returns kFALSE in case of error. - Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix& m); - Bool_t GetTrackingMatrix(Int_t lay, Int_t sta, Int_t det, TGeoHMatrix& m); + Bool_t getTrackingMatrix(Int_t index, TGeoHMatrix& m); + Bool_t getTrackingMatrix(Int_t lay, Int_t sta, Int_t det, TGeoHMatrix& m); // Attention: these are transformations wrt sensitive volume! - void LocalToGlobal(Int_t index, const Double_t* loc, Double_t* glob); - void LocalToGlobal(Int_t lay, Int_t sta, Int_t det, const Double_t* loc, Double_t* glob); + void localToGlobal(Int_t index, const Double_t* loc, Double_t* glob); + void localToGlobal(Int_t lay, Int_t sta, Int_t det, const Double_t* loc, Double_t* glob); - void GlobalToLocal(Int_t index, const Double_t* glob, Double_t* loc); - void GlobalToLocal(Int_t lay, Int_t sta, Int_t det, const Double_t* glob, Double_t* loc); + void globalToLocal(Int_t index, const Double_t* glob, Double_t* loc); + void globalToLocal(Int_t lay, Int_t sta, Int_t det, const Double_t* glob, Double_t* loc); - void LocalToGlobalVector(Int_t index, const Double_t* loc, Double_t* glob); - void GlobalToLocalVector(Int_t index, const Double_t* glob, Double_t* loc); + void localToGlobalVector(Int_t index, const Double_t* loc, Double_t* glob); + void globalToLocalVector(Int_t index, const Double_t* glob, Double_t* loc); - Int_t GetLayerChipTypeId(Int_t lr) const; - Int_t GetChipChipTypeId(Int_t id) const; + Int_t getLayerChipTypeId(Int_t lr) const; + Int_t getChipChipTypeId(Int_t id) const; - const Segmentation* GetSegmentationById(Int_t id) const; - const Segmentation* GetSegmentation(Int_t lr) const; + const Segmentation* getSegmentationById(Int_t id) const; + const Segmentation* getSegmentation(Int_t lr) const; - TObjArray* GetSegmentations() const + TObjArray* getSegmentations() const { return (TObjArray*)mSegmentations; } virtual void Print(Option_t* opt = "") const; - static UInt_t GetUIDShift() + static UInt_t getUIDShift() { return mUIDShift; } - static void SetUIDShift(UInt_t s = 16) + static void setUIDShift(UInt_t s = 16) { mUIDShift = s < 16 ? s : 16; } - static const char* GetITSVolPattern() + static const char* getITSVolPattern() { return mVolumeName.Data(); } - static const char* GetITSLayerPattern() + static const char* getITSLayerPattern() { return mLayerName.Data(); } - static const char* GetITSWrapVolPattern() + static const char* getITSWrapVolPattern() { return mWrapperVolumeName.Data(); } - static const char* GetITSStavePattern() + static const char* getITSStavePattern() { return mStaveName.Data(); } - static const char* GetITSHalfStavePattern() + static const char* getITSHalfStavePattern() { return mHalfStaveName.Data(); } - static const char* GetITSModulePattern() + static const char* getITSModulePattern() { return mModuleName.Data(); } - static const char* GetITSChipPattern() + static const char* getITSChipPattern() { return mChipName.Data(); } - static const char* GetITSSensorPattern() + static const char* getITSSensorPattern() { return mSensorName.Data(); } - static const char* GetITSsegmentationFileName() + static const char* getITSsegmentationFileName() { return mSegmentationFileName.Data(); } - static const char* GetChipTypeName(Int_t i); + static const char* getChipTypeName(Int_t i); - static void SetITSVolPattern(const char* nm) + static void setITSVolPattern(const char* nm) { mVolumeName = nm; } - static void SetITSLayerPattern(const char* nm) + static void setITSLayerPattern(const char* nm) { mLayerName = nm; } - static void SetITSWrapVolPattern(const char* nm) + static void setITSWrapVolPattern(const char* nm) { mWrapperVolumeName = nm; } - static void SetITSStavePattern(const char* nm) + static void setITSStavePattern(const char* nm) { mStaveName = nm; } - static void SetITSHalfStavePattern(const char* nm) + static void setITSHalfStavePattern(const char* nm) { mHalfStaveName = nm; } - static void SetITSModulePattern(const char* nm) + static void setITSModulePattern(const char* nm) { mModuleName = nm; } - static void SetITSChipPattern(const char* nm) + static void setITSChipPattern(const char* nm) { mChipName = nm; } - static void SetITSSensorPattern(const char* nm) + static void setITSSensorPattern(const char* nm) { mSensorName = nm; } - static void SetChipTypeName(Int_t i, const char* nm); - static void SetITSsegmentationFileName(const char* nm) + static void setChipTypeName(Int_t i, const char* nm); + static void setITSsegmentationFileName(const char* nm) { mSegmentationFileName = nm; } - static UInt_t ComposeChipTypeId(UInt_t segmId); + static UInt_t composeChipTypeId(UInt_t segmId); /// sym name of the layer - static const char* ComposeSymNameITS(); + static const char* composeSymNameITS(); /// sym name of the layer - static const char* ComposeSymNameLayer(Int_t lr); + static const char* composeSymNameLayer(Int_t lr); /// Sym name of the stave at given layer - static const char* ComposeSymNameStave(Int_t lr, Int_t sta); + static const char* composeSymNameStave(Int_t lr, Int_t sta); /// Sym name of the stave at given layer - static const char* ComposeSymNameHalfStave(Int_t lr, Int_t sta, Int_t ssta); + static const char* composeSymNameHalfStave(Int_t lr, Int_t sta, Int_t ssta); /// Sym name of the substave at given layer/stave - static const char* ComposeSymNameModule(Int_t lr, Int_t sta, Int_t ssta, Int_t mod); + static const char* composeSymNameModule(Int_t lr, Int_t sta, Int_t ssta, Int_t mod); /// Sym name of the chip in the given layer/stave/substave/module - static const char* ComposeSymNameChip(Int_t lr, Int_t sta, Int_t ssta, Int_t mod, Int_t chip); + static const char* composeSymNameChip(Int_t lr, Int_t sta, Int_t ssta, Int_t mod, Int_t chip); // hack to avoid using AliGeomManager - Int_t LayerToVolUID(Int_t lay, int detInLay) const + Int_t layerToVolUID(Int_t lay, int detInLay) const { - return ChipVolUID(GetChipIndex(lay, detInLay)); + return chipVolUID(getChipIndex(lay, detInLay)); } - static Int_t ChipVolUID(Int_t mod) + static Int_t chipVolUID(Int_t mod) { return (mod & 0xffff) << mUIDShift; } protected: /// Store pointer on often used matrices for faster access - void FetchMatrices(); - void CreateT2LMatrices(); + void fetchMatrices(); + void createT2LMatrices(); /// Get the matrix which transforms from the tracking to local r.s. /// The method queries directly the TGeoPNEntry - TGeoHMatrix* ExtractMatrixTrackingToLocal(Int_t index) const; + TGeoHMatrix* extractMatrixTrackingToLocal(Int_t index) const; /// Get the transformation matrix of the SENSOR (not necessary the same as the chip) /// for a given chip 'index' by quering the TGeoManager - TGeoHMatrix* ExtractMatrixSensor(Int_t index) const; + TGeoHMatrix* extractMatrixSensor(Int_t index) const; /// This routine computes the layer number a given the chip index /// \param Int_t index The chip index number, starting from zero. /// \param Int_t indexInLr The chip index inside a layer, starting from zero. /// \param Int_t lay The layer number. Starting from 0. - Bool_t GetLayer(Int_t index, Int_t& lay, Int_t& index2) const; + Bool_t getLayer(Int_t index, Int_t& lay, Int_t& index2) const; /// Get a pointer to the TGeoPNEntry of a chip identified by 'index' /// Returns NULL in case of invalid index, missing TGeoManager or invalid symbolic name - TGeoPNEntry* GetPNEntry(Int_t index) const; + TGeoPNEntry* getPNEntry(Int_t index) const; /// Determines the number of chips per module on the (sub)stave in the Upgrade Geometry /// Also extract the layout: span of module centers in Z and X /// \param lay: layer number from 0 - Int_t ExtractNumberOfChipsPerModule(Int_t lay, Int_t& nrow) const; + Int_t extractNumberOfChipsPerModule(Int_t lay, Int_t& nrow) const; /// Determines the number of layers in the Upgrade Geometry /// \param lay: layer number, starting from 0 - Int_t ExtractNumberOfStaves(Int_t lay) const; + Int_t extractNumberOfStaves(Int_t lay) const; /// Determines the number of substaves in the stave of the layer /// \param lay: layer number, starting from 0 - Int_t ExtractNumberOfHalfStaves(Int_t lay) const; + Int_t extractNumberOfHalfStaves(Int_t lay) const; /// Determines the number of modules in substave in the stave of the layer /// \param lay: layer number, starting from 0 /// For the setup w/o modules defined the module and the stave or the substave is the same thing - Int_t ExtractNumberOfModules(Int_t lay) const; + Int_t extractNumberOfModules(Int_t lay) const; /// Determines the layer detector type the Upgrade Geometry and /// returns the detector type id for the layer /// \param lay: layer number from 0 - Int_t ExtractLayerChipType(Int_t lay) const; + Int_t extractLayerChipType(Int_t lay) const; /// Determines the number of layers in the Upgrade Geometry - Int_t ExtractNumberOfLayers(); + Int_t extractNumberOfLayers(); /// Exract ITS Upgrade parameters from TGeo void Build(Bool_t loadSegmentations); /// Extract number following the prefix in the name string - Int_t ExtractVolumeCopy(const char* name, const char* prefix) const; + Int_t extractVolumeCopy(const char* name, const char* prefix) const; protected: - Int_t mVersion; ///< ITS Version - Int_t mNumberOfLayers; ///< number of layers - Int_t mNumberOfChips; ///< The total number of chips - Int_t* mNumberOfStaves; ///< [mNumberOfLayers] Array of the number of staves/layer(layer) - Int_t* mNumberOfHalfStaves; ///< [mNumberOfLayers] Array of the number of substaves/stave(layer) - Int_t* mNumberOfModules; ///< [mNumberOfLayers] Array of the number of modules/substave(layer) - Int_t* mNumberOfChipsPerModule; ///< [mNumberOfLayers] Array of the number of chips per module - ///< (group of chips on the substaves) - Int_t* mNumberOfChipRowsPerModule; ///< [mNumberOfLayers] Array of the number of chips rows per - ///< module (relevant for OB modules) - Int_t* mNumberOfChipsPerHalfStave; ///< [mNumberOfLayers] Array of number of chips per substave - Int_t* mNumberOfChipsPerStave; ///< [mNumberOfLayers] Array of the number of chips per stave - Int_t* mNumberOfChipsPerLayer; ///< [mNumberOfLayers] Array of the number of chips per stave - Int_t* mLayerChipType; ///< [mNumberOfLayers] Array of layer chip types - Int_t* mLastChipIndex; ///< [mNumberOfLayers] max ID of the detctor in the layer + Int_t mVersion; ///< ITS Version + Int_t mNumberOfLayers; ///< number of layers + Int_t mNumberOfChips; ///< The total number of chips + Int_t* mNumberOfStaves; //[mNumberOfLayers] Array of the number of staves/layer(layer) + Int_t* mNumberOfHalfStaves; //[mNumberOfLayers] Array of the number of substaves/stave(layer) + Int_t* mNumberOfModules; //[mNumberOfLayers] Array of the number of modules/substave(layer) + Int_t* mNumberOfChipsPerModule; //[mNumberOfLayers] Array of the number of chips per module + // (group of chips on the substaves) + Int_t* mNumberOfChipRowsPerModule; //[mNumberOfLayers] Array of the number of chips rows per + // module (relevant for OB modules) + Int_t* mNumberOfChipsPerHalfStave; //[mNumberOfLayers] Array of number of chips per substave + Int_t* mNumberOfChipsPerStave; //[mNumberOfLayers] Array of the number of chips per stave + Int_t* mNumberOfChipsPerLayer; //[mNumberOfLayers] Array of the number of chips per stave + Int_t* mLayerChipType; //[mNumberOfLayers] Array of layer chip types + Int_t* mLastChipIndex; //[mNumberOfLayers] max ID of the detctor in the layer Char_t mLayerToWrapper[gMaxLayers]; ///< Layer to wrapper correspondence TObjArray* mSensorMatrices; ///< Sensor's matrices pointers in the geometry TObjArray* mTrackingToLocalMatrices; ///< Tracking to Local matrices pointers in the geometry @@ -457,129 +455,120 @@ class UpgradeGeometryTGeo : public TObject { }; /// Returns ymbolic name -inline const char* UpgradeGeometryTGeo::GetSymbolicName(Int_t lay, Int_t sta, Int_t det) const +inline const char* UpgradeGeometryTGeo::getSymbolicName(Int_t lay, Int_t sta, Int_t det) const { - return GetSymbolicName(GetChipIndex(lay, sta, det)); + return getSymbolicName(getChipIndex(lay, sta, det)); } /// Returns chip current matrix inline TGeoHMatrix* UpgradeGeometryTGeo::GetMatrix(Int_t lay, Int_t sta, Int_t det) const { - return GetMatrix(GetChipIndex(lay, sta, det)); + return GetMatrix(getChipIndex(lay, sta, det)); } /// Returns translation -inline Bool_t UpgradeGeometryTGeo::GetTranslation(Int_t lay, Int_t sta, Int_t det, Double_t t[3]) - const +inline Bool_t UpgradeGeometryTGeo::GetTranslation(Int_t lay, Int_t sta, Int_t det, Double_t t[3]) const { - return GetTranslation(GetChipIndex(lay, sta, det), t); + return GetTranslation(getChipIndex(lay, sta, det), t); } /// Returns rotation -inline Bool_t UpgradeGeometryTGeo::GetRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const +inline Bool_t UpgradeGeometryTGeo::getRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const { - return GetRotation(GetChipIndex(lay, sta, det), r); + return getRotation(getChipIndex(lay, sta, det), r); } /// Returns original matrix -inline Bool_t UpgradeGeometryTGeo::GetOriginalMatrix(Int_t lay, Int_t sta, Int_t det, - TGeoHMatrix& m) const +inline Bool_t UpgradeGeometryTGeo::GetOriginalMatrix(Int_t lay, Int_t sta, Int_t det, TGeoHMatrix& m) const { - return GetOriginalMatrix(GetChipIndex(lay, sta, det), m); + return GetOriginalMatrix(getChipIndex(lay, sta, det), m); } /// Returns original translation -inline Bool_t UpgradeGeometryTGeo::GetOriginalTranslation(Int_t lay, Int_t sta, Int_t det, - Double_t t[3]) const +inline Bool_t UpgradeGeometryTGeo::getOriginalTranslation(Int_t lay, Int_t sta, Int_t det, Double_t t[3]) const { - return GetOriginalTranslation(GetChipIndex(lay, sta, det), t); + return getOriginalTranslation(getChipIndex(lay, sta, det), t); } /// Original rotation -inline Bool_t UpgradeGeometryTGeo::GetOriginalRotation(Int_t lay, Int_t sta, Int_t det, - Double_t r[9]) const +inline Bool_t UpgradeGeometryTGeo::getOriginalRotation(Int_t lay, Int_t sta, Int_t det, Double_t r[9]) const { - return GetOriginalRotation(GetChipIndex(lay, sta, det), r); + return getOriginalRotation(getChipIndex(lay, sta, det), r); } /// Tracking matrix -inline Bool_t UpgradeGeometryTGeo::GetTrackingMatrix(Int_t lay, Int_t sta, Int_t det, - TGeoHMatrix& m) +inline Bool_t UpgradeGeometryTGeo::getTrackingMatrix(Int_t lay, Int_t sta, Int_t det, TGeoHMatrix& m) { - return GetTrackingMatrix(GetChipIndex(lay, sta, det), m); + return getTrackingMatrix(getChipIndex(lay, sta, det), m); } /// Detector type ID of layer -inline Int_t UpgradeGeometryTGeo::GetLayerChipTypeId(Int_t lr) const +inline Int_t UpgradeGeometryTGeo::getLayerChipTypeId(Int_t lr) const { return mLayerChipType[lr]; } // Detector type ID of chip -inline Int_t UpgradeGeometryTGeo::GetChipChipTypeId(Int_t id) const +inline Int_t UpgradeGeometryTGeo::getChipChipTypeId(Int_t id) const { - return GetLayerChipTypeId(GetLayer(id)); + return getLayerChipTypeId(getLayer(id)); } /// Access global to sensor matrix -inline const TGeoHMatrix* UpgradeGeometryTGeo::GetMatrixSensor(Int_t index) +inline const TGeoHMatrix* UpgradeGeometryTGeo::getMatrixSensor(Int_t index) { if (!mSensorMatrices) { - FetchMatrices(); + fetchMatrices(); } return (TGeoHMatrix*)mSensorMatrices->At(index); } /// Access tracking to local matrix -inline const TGeoHMatrix* UpgradeGeometryTGeo::GetMatrixT2L(Int_t index) +inline const TGeoHMatrix* UpgradeGeometryTGeo::getMatrixT2L(Int_t index) { if (!mTrackingToLocalMatrices) { - FetchMatrices(); + fetchMatrices(); } return (TGeoHMatrix*)mTrackingToLocalMatrices->At(index); } /// Sensor local to global -inline void UpgradeGeometryTGeo::LocalToGlobal(Int_t index, const Double_t* loc, Double_t* glob) +inline void UpgradeGeometryTGeo::localToGlobal(Int_t index, const Double_t* loc, Double_t* glob) { - GetMatrixSensor(index)->LocalToMaster(loc, glob); + getMatrixSensor(index)->LocalToMaster(loc, glob); } /// Global to sensor local -inline void UpgradeGeometryTGeo::GlobalToLocal(Int_t index, const Double_t* glob, Double_t* loc) +inline void UpgradeGeometryTGeo::globalToLocal(Int_t index, const Double_t* glob, Double_t* loc) { - GetMatrixSensor(index)->MasterToLocal(glob, loc); + getMatrixSensor(index)->MasterToLocal(glob, loc); } /// Sensor local to global -inline void UpgradeGeometryTGeo::LocalToGlobalVector(Int_t index, const Double_t* loc, - Double_t* glob) +inline void UpgradeGeometryTGeo::localToGlobalVector(Int_t index, const Double_t* loc, Double_t* glob) { - GetMatrixSensor(index)->LocalToMasterVect(loc, glob); + getMatrixSensor(index)->LocalToMasterVect(loc, glob); } /// Global to sensor local -inline void UpgradeGeometryTGeo::GlobalToLocalVector(Int_t index, const Double_t* glob, - Double_t* loc) +inline void UpgradeGeometryTGeo::globalToLocalVector(Int_t index, const Double_t* glob, Double_t* loc) { - GetMatrixSensor(index)->MasterToLocalVect(glob, loc); + getMatrixSensor(index)->MasterToLocalVect(glob, loc); } /// Local2Master (sensor) -inline void UpgradeGeometryTGeo::LocalToGlobal(Int_t lay, Int_t sta, Int_t det, const Double_t* loc, - Double_t* glob) +inline void UpgradeGeometryTGeo::localToGlobal(Int_t lay, Int_t sta, Int_t det, const Double_t* loc, Double_t* glob) { - LocalToGlobal(GetChipIndex(lay, sta, det), loc, glob); + localToGlobal(getChipIndex(lay, sta, det), loc, glob); } /// Master2local (sensor) -inline void UpgradeGeometryTGeo::GlobalToLocal(Int_t lay, Int_t sta, Int_t det, - const Double_t* glob, Double_t* loc) +inline void UpgradeGeometryTGeo::globalToLocal(Int_t lay, Int_t sta, Int_t det, const Double_t* glob, Double_t* loc) { - GlobalToLocal(GetChipIndex(lay, sta, det), glob, loc); + globalToLocal(getChipIndex(lay, sta, det), glob, loc); } -inline const char* UpgradeGeometryTGeo::GetChipTypeName(Int_t i) +inline const char* UpgradeGeometryTGeo::getChipTypeName(Int_t i) { if (i >= kNChipTypes) { i /= kMaxSegmPerChipType; // full type is provided @@ -587,7 +576,7 @@ inline const char* UpgradeGeometryTGeo::GetChipTypeName(Int_t i) return mChipTypeName[i].Data(); } -inline void UpgradeGeometryTGeo::SetChipTypeName(Int_t i, const char* nm) +inline void UpgradeGeometryTGeo::setChipTypeName(Int_t i, const char* nm) { if (i >= kNChipTypes) { i /= kMaxSegmPerChipType; // full type is provided @@ -596,15 +585,15 @@ inline void UpgradeGeometryTGeo::SetChipTypeName(Int_t i, const char* nm) } /// Get segmentation by ID -inline const Segmentation* UpgradeGeometryTGeo::GetSegmentationById(Int_t id) const +inline const Segmentation* UpgradeGeometryTGeo::getSegmentationById(Int_t id) const { return mSegmentations ? (Segmentation*)mSegmentations->At(id) : 0; } /// Get segmentation of layer -inline const Segmentation* UpgradeGeometryTGeo::GetSegmentation(Int_t lr) const +inline const Segmentation* UpgradeGeometryTGeo::getSegmentation(Int_t lr) const { - return mSegmentations ? (Segmentation*)mSegmentations->At(GetLayerChipTypeId(lr)) : 0; + return mSegmentations ? (Segmentation*)mSegmentations->At(getLayerChipTypeId(lr)) : 0; } } } diff --git a/its/UpgradeSegmentationPixel.cxx b/its/UpgradeSegmentationPixel.cxx index 0c5b60e7a540b..e4b3fbe650d6b 100644 --- a/its/UpgradeSegmentationPixel.cxx +++ b/its/UpgradeSegmentationPixel.cxx @@ -49,12 +49,12 @@ UpgradeSegmentationPixel::UpgradeSegmentationPixel(UInt_t id, int nchips, int nc { // Default constructor, sizes in cm if (nchips) { - SetUniqueID(UpgradeGeometryTGeo::ComposeChipTypeId(id)); + SetUniqueID(UpgradeGeometryTGeo::composeChipTypeId(id)); } mChipSizeDZ = (mNumberOfColumnsPerChip - 2) * mPitchZ + mPitchZLeftColumn + mPitchZRightColumn; mDxActive = mNumberOfRows * mPitchX; mDzActive = mNumberOfChips * mChipSizeDZ; - SetDetSize(mDxActive + mGuardTop + mGuardBottom, mDzActive + mGuardLeft + mGuardRight, thickness); + setDetectorSize(mDxActive + mGuardTop + mGuardBottom, mDzActive + mGuardLeft + mGuardRight, thickness); } UpgradeSegmentationPixel::~UpgradeSegmentationPixel() @@ -64,10 +64,10 @@ UpgradeSegmentationPixel::~UpgradeSegmentationPixel() delete[] mDiodShiftMatZ; } -void UpgradeSegmentationPixel::GetPadIxz(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const +void UpgradeSegmentationPixel::getPadIxz(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const { ix = int(x / mPitchX); - iz = int(ZToColumn(z)); + iz = int(zToColumn(z)); if (iz < 0) { LOG(WARNING) << "Z=" << z << " gives col=" << iz << " outside [0:" << mNumberOfColumns << ")" @@ -89,19 +89,19 @@ void UpgradeSegmentationPixel::GetPadIxz(Float_t x, Float_t z, Int_t& ix, Int_t& } } -void UpgradeSegmentationPixel::GetPadTxz(Float_t& x, Float_t& z) const +void UpgradeSegmentationPixel::getPadTxz(Float_t& x, Float_t& z) const { x /= mPitchX; - z = ZToColumn(z); + z = zToColumn(z); } -void UpgradeSegmentationPixel::GetPadCxz(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const +void UpgradeSegmentationPixel::getPadCxz(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const { x = Float_t((ix + 0.5) * mPitchX); - z = ColumnToZ(iz); + z = columnToZ(iz); } -Float_t UpgradeSegmentationPixel::ZToColumn(Float_t z) const +Float_t UpgradeSegmentationPixel::zToColumn(Float_t z) const { int chip = int(z / mChipSizeDZ); float col = chip * mNumberOfColumnsPerChip; @@ -112,7 +112,7 @@ Float_t UpgradeSegmentationPixel::ZToColumn(Float_t z) const return col; } -Float_t UpgradeSegmentationPixel::ColumnToZ(Int_t col) const +Float_t UpgradeSegmentationPixel::columnToZ(Int_t col) const { int nchip = col / mNumberOfColumnsPerChip; col %= mNumberOfColumnsPerChip; @@ -208,12 +208,12 @@ UpgradeSegmentationPixel::UpgradeSegmentationPixel(const UpgradeSegmentationPixe } } -Float_t UpgradeSegmentationPixel::Dpx(Int_t) const +Float_t UpgradeSegmentationPixel::cellSizeX(Int_t) const { return mPitchX; } -Float_t UpgradeSegmentationPixel::Dpz(Int_t col) const +Float_t UpgradeSegmentationPixel::cellSizeZ(Int_t col) const { col %= mNumberOfColumnsPerChip; if (!col) { @@ -225,7 +225,7 @@ Float_t UpgradeSegmentationPixel::Dpz(Int_t col) const return mPitchZ; } -void UpgradeSegmentationPixel::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_t xlist[8], +void UpgradeSegmentationPixel::neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_t xlist[8], Int_t zlist[8]) const { *nlist = 8; @@ -250,26 +250,26 @@ void UpgradeSegmentationPixel::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_ zlist[7] = iZ - 1; } -Bool_t UpgradeSegmentationPixel::LocalToDetector(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const +Bool_t UpgradeSegmentationPixel::localToDetector(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const { - x += 0.5 * DxActive() + mShiftLocalX; // get X,Z wrt bottom/left corner - z += 0.5 * DzActive() + mShiftLocalZ; + x += 0.5 * dxActive() + mShiftLocalX; // get X,Z wrt bottom/left corner + z += 0.5 * dzActive() + mShiftLocalZ; ix = iz = -1; - if (x < 0 || x > DxActive()) { + if (x < 0 || x > dxActive()) { return kFALSE; // outside x range. } - if (z < 0 || z > DzActive()) { + if (z < 0 || z > dzActive()) { return kFALSE; // outside z range. } ix = int(x / mPitchX); - iz = ZToColumn(z); + iz = zToColumn(z); return kTRUE; // Found ix and iz, return. } -void UpgradeSegmentationPixel::DetectorToLocal(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const +void UpgradeSegmentationPixel::detectorToLocal(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const { - x = -0.5 * DxActive(); // default value. - z = -0.5 * DzActive(); // default value. + x = -0.5 * dxActive(); // default value. + z = -0.5 * dzActive(); // default value. if (ix < 0 || ix >= mNumberOfRows) { LOG(WARNING) << "Obtained row " << ix << " is not in range [0:" << mNumberOfRows << ")" << FairLogger::endl; @@ -283,22 +283,22 @@ void UpgradeSegmentationPixel::DetectorToLocal(Int_t ix, Int_t iz, Float_t& x, F x += (ix + 0.5) * mPitchX - mShiftLocalX; // RS: we go to the center of the pad, i.e. + pitch/2, not // to the boundary as in SPD - z += ColumnToZ(iz) - mShiftLocalZ; + z += columnToZ(iz) - mShiftLocalZ; return; // Found x and z, return. } -void UpgradeSegmentationPixel::CellBoundries(Int_t ix, Int_t iz, Double_t& xl, Double_t& xu, +void UpgradeSegmentationPixel::cellBoundries(Int_t ix, Int_t iz, Double_t& xl, Double_t& xu, Double_t& zl, Double_t& zu) const { Float_t x, z; - DetectorToLocal(ix, iz, x, z); + detectorToLocal(ix, iz, x, z); if (ix < 0 || ix >= mNumberOfRows || iz < 0 || iz >= mNumberOfColumns) { xl = xu = -0.5 * Dx(); // default value. zl = zu = -0.5 * Dz(); // default value. return; // outside of detctor } - float zpitchH = Dpz(iz) * 0.5; + float zpitchH = cellSizeZ(iz) * 0.5; float xpitchH = mPitchX * 0.5; xl -= xpitchH; xu += xpitchH; @@ -307,7 +307,7 @@ void UpgradeSegmentationPixel::CellBoundries(Int_t ix, Int_t iz, Double_t& xl, D return; // Found x and z, return. } -Int_t UpgradeSegmentationPixel::GetChipFromChannel(Int_t, Int_t iz) const +Int_t UpgradeSegmentationPixel::getChipFromChannel(Int_t, Int_t iz) const { if (iz >= mNumberOfColumns || iz < 0) { LOG(WARNING) << "Bad cell number" << FairLogger::endl; @@ -316,17 +316,17 @@ Int_t UpgradeSegmentationPixel::GetChipFromChannel(Int_t, Int_t iz) const return iz / mNumberOfColumnsPerChip; } -Int_t UpgradeSegmentationPixel::GetChipFromLocal(Float_t, Float_t zloc) const +Int_t UpgradeSegmentationPixel::getChipFromLocal(Float_t, Float_t zloc) const { Int_t ix0, iz; - if (!LocalToDetector(0, zloc, ix0, iz)) { + if (!localToDetector(0, zloc, ix0, iz)) { LOG(WARNING) << "Bad local coordinate" << FairLogger::endl; return -1; } - return GetChipFromChannel(ix0, iz); + return getChipFromChannel(ix0, iz); } -Int_t UpgradeSegmentationPixel::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, +Int_t UpgradeSegmentationPixel::getChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const { if (zmin > zmax) { @@ -336,8 +336,8 @@ Int_t UpgradeSegmentationPixel::GetChipsInLocalWindow(Int_t* array, Float_t zmin Int_t nChipInW = 0; - Float_t zminDet = -0.5 * DzActive() - mShiftLocalZ; - Float_t zmaxDet = 0.5 * DzActive() - mShiftLocalZ; + Float_t zminDet = -0.5 * dzActive() - mShiftLocalZ; + Float_t zmaxDet = 0.5 * dzActive() - mShiftLocalZ; if (zmin < zminDet) { zmin = zminDet; } @@ -345,11 +345,11 @@ Int_t UpgradeSegmentationPixel::GetChipsInLocalWindow(Int_t* array, Float_t zmin zmax = zmaxDet; } - Int_t n1 = GetChipFromLocal(0, zmin); + Int_t n1 = getChipFromLocal(0, zmin); array[nChipInW] = n1; nChipInW++; - Int_t n2 = GetChipFromLocal(0, zmax); + Int_t n2 = getChipFromLocal(0, zmax); if (n2 != n1) { Int_t imin = Min(n1, n2); @@ -394,7 +394,7 @@ Bool_t UpgradeSegmentationPixel::Store(const char* outf) if (!arr) { arr = new TObjArray(); } else if (arr->At(id)) { - LOG(FATAL) << "Segmenation " << id << " already exists in file " << outf << FairLogger::endl; + LOG(FATAL) << "Segmentation " << id << " already exists in file " << outf << FairLogger::endl; return kFALSE; } @@ -409,7 +409,7 @@ Bool_t UpgradeSegmentationPixel::Store(const char* outf) return kTRUE; } -UpgradeSegmentationPixel* UpgradeSegmentationPixel::LoadWithId(UInt_t id, const char* inpf) +UpgradeSegmentationPixel* UpgradeSegmentationPixel::loadWithId(UInt_t id, const char* inpf) { TString fns = inpf; gSystem->ExpandPathName(fns); @@ -444,7 +444,7 @@ UpgradeSegmentationPixel* UpgradeSegmentationPixel::LoadWithId(UInt_t id, const return segm; } -void UpgradeSegmentationPixel::LoadSegmentations(TObjArray* dest, const char* inpf) +void UpgradeSegmentationPixel::loadSegmentations(TObjArray* dest, const char* inpf) { if (!dest) { return; @@ -479,7 +479,7 @@ void UpgradeSegmentationPixel::LoadSegmentations(TObjArray* dest, const char* in delete arr; } -void UpgradeSegmentationPixel::SetDiodShiftMatrix(Int_t nrow, Int_t ncol, const Float_t* shiftX, +void UpgradeSegmentationPixel::setDiodShiftMatrix(Int_t nrow, Int_t ncol, const Float_t* shiftX, const Float_t* shiftZ) { if (mDiodShiftMatDimension) { @@ -503,7 +503,7 @@ void UpgradeSegmentationPixel::SetDiodShiftMatrix(Int_t nrow, Int_t ncol, const } } -void UpgradeSegmentationPixel::SetDiodShiftMatrix(Int_t nrow, Int_t ncol, const Double_t* shiftX, +void UpgradeSegmentationPixel::setDiodShiftMatrix(Int_t nrow, Int_t ncol, const Double_t* shiftX, const Double_t* shiftZ) { if (mDiodShiftMatDimension) { @@ -532,7 +532,7 @@ void UpgradeSegmentationPixel::Print(Option_t* /*option*/) const { const double kmc = 1e4; printf("Segmentation %d: Active Size: DX: %.1f DY: %.1f DZ: %.1f | Pitch: X:%.1f Z:%.1f\n", - GetUniqueID(), kmc * DxActive(), kmc * Dy(), kmc * DzActive(), kmc * Dpx(1), kmc * Dpz(1)); + GetUniqueID(), kmc * dxActive(), kmc * Dy(), kmc * dzActive(), kmc * cellSizeX(1), kmc * cellSizeZ(1)); printf("Passive Edges: Bottom: %.1f Right: %.1f Top: %.1f Left: %.1f -> DX: %.1f DZ: %.1f Shift: " "x:%.1f z:%.1f\n", kmc * mGuardBottom, kmc * mGuardRight, kmc * mGuardTop, kmc * mGuardLeft, kmc * Dx(), @@ -551,7 +551,7 @@ void UpgradeSegmentationPixel::Print(Option_t* /*option*/) const printf("Diod shift (fraction of pitch) periodicity pattern (X,Z[row][col])\n"); for (int irow = 0; irow < mDiodShiftMatNRow; irow++) { for (int icol = 0; icol < mDiodShiftMatNColumn; icol++) { - GetDiodShift(irow, icol, dx, dz); + getDiodShift(irow, icol, dx, dz); printf("%.1f/%.1f |", dx, dz); } printf("\n"); @@ -559,7 +559,7 @@ void UpgradeSegmentationPixel::Print(Option_t* /*option*/) const } } -void UpgradeSegmentationPixel::GetDiodShift(Int_t row, Int_t col, Float_t& dx, Float_t& dz) const +void UpgradeSegmentationPixel::getDiodShift(Int_t row, Int_t col, Float_t& dx, Float_t& dz) const { // obtain optional diod shift if (!mDiodShiftMatDimension) { diff --git a/its/UpgradeSegmentationPixel.h b/its/UpgradeSegmentationPixel.h index d4b5a30b31bc9..c05ab08352a4f 100644 --- a/its/UpgradeSegmentationPixel.h +++ b/its/UpgradeSegmentationPixel.h @@ -20,10 +20,9 @@ namespace ITS { class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { public: - UpgradeSegmentationPixel(UInt_t id = 0, int nchips = 0, int ncol = 0, int nrow = 0, - float pitchX = 0, float pitchZ = 0, float thickness = 0, - float pitchLftC = -1, float pitchRgtC = -1, float edgL = 0, - float edgR = 0, float edgT = 0, float edgB = 0); + UpgradeSegmentationPixel(UInt_t id = 0, int nchips = 0, int ncol = 0, int nrow = 0, float pitchX = 0, + float pitchZ = 0, float thickness = 0, float pitchLftC = -1, float pitchRgtC = -1, + float edgL = 0, float edgR = 0, float edgT = 0, float edgB = 0); // UpgradeSegmentationPixel(Option_t *opt="" ); UpgradeSegmentationPixel(const UpgradeSegmentationPixel& source); @@ -32,27 +31,27 @@ class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { virtual void Init(); - virtual void SetNPads(Int_t, Int_t) + virtual void setNumberOfPads(Int_t, Int_t) { MayNotUse("SetPadSize"); } - virtual Int_t GetNPads() const + virtual Int_t getNumberOfPads() const { return mNumberOfColumns * mNumberOfRows; } /// Returns pixel coordinates (ix,iz) for given coordinates (x,z counted from corner of col/row /// 0:0). Expects x, z in cm - virtual void GetPadIxz(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const; + virtual void getPadIxz(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const; /// Transform from pixel to real local coordinates /// Eeturns x, z in cm. wrt corner of col/row 0:0 - virtual void GetPadCxz(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const; + virtual void getPadCxz(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const; /// Local transformation of real local coordinates (x,z) /// Expects x, z in cm (wrt corner of col/row 0:0 - virtual void GetPadTxz(Float_t& x, Float_t& z) const; + virtual void getPadTxz(Float_t& x, Float_t& z) const; /// Transformation from Geant detector centered local coordinates (cm) to /// Pixel cell numbers ix and iz. @@ -65,7 +64,7 @@ class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { /// the center of the sensitive volulme. /// \param Int_t ix Detector x cell coordinate. Has the range 0 <= ix < mNumberOfRows /// \param Int_t iz Detector z cell coordinate. Has the range 0 <= iz < mNumberOfColumns - virtual Bool_t LocalToDetector(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const; + virtual Bool_t localToDetector(Float_t x, Float_t z, Int_t& ix, Int_t& iz) const; /// Transformation from Detector cell coordiantes to Geant detector centered /// local coordinates (cm) @@ -77,7 +76,7 @@ class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { /// center of the sensitive volulme. /// If ix and or iz is outside of the segmentation range a value of -0.5*Dx() /// or -0.5*Dz() is returned. - virtual void DetectorToLocal(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const; + virtual void detectorToLocal(Int_t ix, Int_t iz, Float_t& x, Float_t& z) const; /// Transformation from Detector cell coordiantes to Geant detector centered /// local coordinates (cm) @@ -91,124 +90,122 @@ class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { /// respect to the center of the sensitive volulme. /// \param Double_t zu Detector local coordinate upper bounds z in cm with /// respect to the center of the sensitive volulme. - /// If ix and or iz is outside of the segmentation range a value of -0.5*DxActive() - /// and -0.5*DxActive() or -0.5*DzActive() and -0.5*DzActive() are returned. - virtual void CellBoundries(Int_t ix, Int_t iz, Double_t& xl, Double_t& xu, Double_t& zl, - Double_t& zu) const; + /// If ix and or iz is outside of the segmentation range a value of -0.5*dxActive() + /// and -0.5*dxActive() or -0.5*dzActive() and -0.5*dzActive() are returned. + virtual void cellBoundries(Int_t ix, Int_t iz, Double_t& xl, Double_t& xu, Double_t& zl, Double_t& zu) const; - virtual Int_t GetNumberOfChips() const + virtual Int_t getNumberOfChips() const { return mNumberOfChips; } - virtual Int_t GetMaximumChipIndex() const + virtual Int_t getMaximumChipIndex() const { return mNumberOfChips - 1; } /// Returns chip number (in range 0-4) starting from local Geant coordinates - virtual Int_t GetChipFromLocal(Float_t, Float_t zloc) const; + virtual Int_t getChipFromLocal(Float_t, Float_t zloc) const; /// Returns the number of chips containing a road defined by given local Geant coordinate limits - virtual Int_t GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, - Float_t) const; + virtual Int_t getChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const; /// Returns chip number (in range 0-4) starting from channel number - virtual Int_t GetChipFromChannel(Int_t, Int_t iz) const; + virtual Int_t getChipFromChannel(Int_t, Int_t iz) const; /// Returs x pixel pitch for a give pixel - virtual Float_t Dpx(Int_t ix = 0) const; + virtual Float_t cellSizeX(Int_t ix = 0) const; /// Returns z pixel pitch for a given pixel (cols starts from 0) - virtual Float_t Dpz(Int_t iz) const; + virtual Float_t cellSizeZ(Int_t iz) const; - Float_t DxActive() const + Float_t dxActive() const { return mDxActive; } - Float_t DzActive() const + Float_t dzActive() const { return mDzActive; } - Float_t GetShiftXLoc() const + Float_t getShiftXLoc() const { return mShiftLocalX; } - Float_t GetShiftZLoc() const + Float_t getShiftZLoc() const { return mShiftLocalZ; } - Float_t GetGuardLft() const + Float_t getGuardLft() const { return mGuardLeft; } - Float_t GetGuardRgt() const + Float_t getGuardRgt() const { return mGuardRight; } - Float_t GetGuardTop() const + Float_t getGuardTop() const { return mGuardTop; } - Float_t GetGuardBot() const + Float_t getGuardBot() const { return mGuardBottom; } - Int_t GetNumberOfRows() const + Int_t getNumberOfRows() const { return mNumberOfRows; } - Int_t GetNumberOfColumns() const + Int_t getNumberOfColumns() const { return mNumberOfColumns; } - virtual Int_t Npx() const + virtual Int_t numberOfCellsInX() const { - return GetNumberOfRows(); + return getNumberOfRows(); } - virtual Int_t Npz() const + virtual Int_t numberOfCellsInZ() const { - return GetNumberOfColumns(); + return getNumberOfColumns(); } /// Returns the neighbouring pixels for use in Cluster Finders and the like. - virtual void Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[10], Int_t Zlist[10]) const; + virtual void neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[10], Int_t Zlist[10]) const; - virtual void PrintDefaultParameters() const + virtual void printDefaultParameters() const { LOG(WARNING) << "No def. parameters defined as const static data members" << FairLogger::endl; } virtual void Print(Option_t* option = "") const; - virtual Int_t GetChipTypeID() const + virtual Int_t getChipTypeID() const { return GetUniqueID(); } /// Set matrix of periodic shifts of diod center. Provided arrays must be in the format /// shift[nrow][ncol] - void SetDiodShiftMatrix(Int_t nrow, Int_t ncol, const Float_t* shiftX, const Float_t* shiftZ); + void setDiodShiftMatrix(Int_t nrow, Int_t ncol, const Float_t* shiftX, const Float_t* shiftZ); /// Set matrix of periodic shifts of diod center. Provided arrays must be in the format /// shift[nrow][ncol] - void SetDiodShiftMatrix(Int_t nrow, Int_t ncol, const Double_t* shiftX, const Double_t* shiftZ); - void GetDiodShift(Int_t row, Int_t col, Float_t& dx, Float_t& dz) const; - void GetDiodShift(Int_t row, Int_t col, Double_t& dx, Double_t& dz) const + void setDiodShiftMatrix(Int_t nrow, Int_t ncol, const Double_t* shiftX, const Double_t* shiftZ); + void getDiodShift(Int_t row, Int_t col, Float_t& dx, Float_t& dz) const; + void getDiodShift(Int_t row, Int_t col, Double_t& dx, Double_t& dz) const { float dxf, dzf; - GetDiodShift(row, col, dxf, dzf); + getDiodShift(row, col, dxf, dzf); dx = dxf; dz = dzf; } @@ -217,17 +214,17 @@ class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { Bool_t Store(const char* outf); /// Store in the special list under given ID - static UpgradeSegmentationPixel* LoadWithId(UInt_t id, const char* inpf); + static UpgradeSegmentationPixel* loadWithId(UInt_t id, const char* inpf); /// Store in the special list under given ID - static void LoadSegmentations(TObjArray* dest, const char* inpf); + static void loadSegmentations(TObjArray* dest, const char* inpf); protected: /// Get column number (from 0) from local Z (wrt bottom left corner of the active matrix) - Float_t ZToColumn(Float_t z) const; + Float_t zToColumn(Float_t z) const; /// Convert column number (from 0) to Z coordinate wrt bottom left corner of the active matrix - Float_t ColumnToZ(Int_t col) const; + Float_t columnToZ(Int_t col) const; protected: Float_t mGuardLeft; ///< left guard edge @@ -250,8 +247,9 @@ class UpgradeSegmentationPixel : public AliceO2::ITS::Segmentation { Int_t mDiodShiftMatNColumn; ///< periodicity of diod shift in columns Int_t mDiodShiftMatNRow; ///< periodicity of diod shift in rows Int_t mDiodShiftMatDimension; ///< dimension of diod shift matrix - Float_t* mDiodShiftMatX; ///< diod shift in X (along column), in fraction of X pitch - Float_t* mDiodShiftMatZ; ///< diod shift in Z (along row), in fraction of Z pitch + Float_t* mDiodShiftMatX; //[mDiodShiftMatDimension] diod shift in X (along column), in fraction of + // X pitch + Float_t* mDiodShiftMatZ; //[mDiodShiftMatDimension] diod shift in Z (along row), in fraction of Z pitch static const char* sSegmentationsListName; ///< pattern for segmentations list name diff --git a/its/UpgradeV1Layer.cxx b/its/UpgradeV1Layer.cxx index 6b0c4a1c691ad..3e46d2dfa0eb8 100644 --- a/its/UpgradeV1Layer.cxx +++ b/its/UpgradeV1Layer.cxx @@ -167,7 +167,7 @@ UpgradeV1Layer::UpgradeV1Layer(Int_t lay, Bool_t turbo, Int_t debug) } UpgradeV1Layer::UpgradeV1Layer(const UpgradeV1Layer& s) - : V11Geometry(s.GetDebug()), + : V11Geometry(s.getDebug()), mLayerNumber(s.mLayerNumber), mPhi0(s.mPhi0), mLayerRadius(s.mLayerRadius), @@ -221,7 +221,7 @@ UpgradeV1Layer::~UpgradeV1Layer() { } -void UpgradeV1Layer::CreateLayer(TGeoVolume* motherVolume) +void UpgradeV1Layer::createLayer(TGeoVolume* motherVolume) { char volumeName[30]; Double_t xpos, ypos, zpos; @@ -268,7 +268,7 @@ void UpgradeV1Layer::CreateLayer(TGeoVolume* motherVolume) // If a Turbo layer is requested, do it and exit if (mIsTurbo) { - CreateLayerTurbo(motherVolume); + createLayerTurbo(motherVolume); return; } @@ -277,7 +277,7 @@ void UpgradeV1Layer::CreateLayer(TGeoVolume* motherVolume) // mStaveWidth = mLayerRadius*Tan(alpha); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSLayerPattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSLayerPattern(), mLayerNumber); TGeoVolume* layerVolume = new TGeoVolumeAssembly(volumeName); layerVolume->SetUniqueID(mChipTypeID); @@ -285,15 +285,15 @@ void UpgradeV1Layer::CreateLayer(TGeoVolume* motherVolume) layerVolume->SetVisibility(kTRUE); layerVolume->SetLineColor(1); - TGeoVolume* stavVol = CreateStave(); + TGeoVolume* stavVol = createStave(); // Now build up the layer alpha = 360. / mNumberOfStaves; Double_t r = mLayerRadius + ((TGeoBBox*)stavVol->GetShape())->GetDY(); for (Int_t j = 0; j < mNumberOfStaves; j++) { Double_t phi = j * alpha + mPhi0; - xpos = r * CosD(phi); // r*SinD(-phi); - ypos = r * SinD(phi); // r*CosD(-phi); + xpos = r * cosD(phi); // r*sinD(-phi); + ypos = r * sinD(phi); // r*cosD(-phi); zpos = 0.; phi += 90; layerVolume->AddNode(stavVol, j, @@ -307,7 +307,7 @@ void UpgradeV1Layer::CreateLayer(TGeoVolume* motherVolume) return; } -void UpgradeV1Layer::CreateLayerTurbo(TGeoVolume* motherVolume) +void UpgradeV1Layer::createLayerTurbo(TGeoVolume* motherVolume) { char volumeName[30]; Double_t xpos, ypos, zpos; @@ -323,20 +323,20 @@ void UpgradeV1Layer::CreateLayerTurbo(TGeoVolume* motherVolume) << FairLogger::endl; } - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSLayerPattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSLayerPattern(), mLayerNumber); TGeoVolume* layerVolume = new TGeoVolumeAssembly(volumeName); layerVolume->SetUniqueID(mChipTypeID); layerVolume->SetVisibility(kTRUE); layerVolume->SetLineColor(1); - TGeoVolume* stavVol = CreateStave(); + TGeoVolume* stavVol = createStave(); // Now build up the layer alpha = 360. / mNumberOfStaves; Double_t r = mLayerRadius /* +chip thick ?! */; for (Int_t j = 0; j < mNumberOfStaves; j++) { Double_t phi = j * alpha + mPhi0; - xpos = r * CosD(phi); // r*SinD(-phi); - ypos = r * SinD(phi); // r*CosD(-phi); + xpos = r * cosD(phi); // r*sinD(-phi); + ypos = r * sinD(phi); // r*cosD(-phi); zpos = 0.; phi += 90; layerVolume->AddNode( @@ -350,7 +350,7 @@ void UpgradeV1Layer::CreateLayerTurbo(TGeoVolume* motherVolume) return; } -TGeoVolume* UpgradeV1Layer::CreateStave(const TGeoManager* /*mgr*/) +TGeoVolume* UpgradeV1Layer::createStave(const TGeoManager* /*mgr*/) { char volumeName[30]; @@ -379,7 +379,7 @@ TGeoVolume* UpgradeV1Layer::CreateStave(const TGeoManager* /*mgr*/) // We have all shapes: now create the real volumes - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSStavePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSStavePattern(), mLayerNumber); // TGeoVolume *staveVol = new TGeoVolume(volumeName, stave, medAir); TGeoVolume* staveVol = new TGeoVolumeAssembly(volumeName); @@ -390,12 +390,12 @@ TGeoVolume* UpgradeV1Layer::CreateStave(const TGeoManager* /*mgr*/) // Now build up the stave if (mLayerNumber < sNumberOmInnerLayers) { - TGeoVolume* modVol = CreateStaveInnerB(xlen, ylen, zlen); + TGeoVolume* modVol = createStaveInnerB(xlen, ylen, zlen); staveVol->AddNode(modVol, 0); mHierarchy[kHalfStave] = 1; // Mechanical stave structure - mechStaveVol = CreateStaveStructInnerB(xlen, zlen); + mechStaveVol = createStaveStructInnerB(xlen, zlen); if (mechStaveVol) { ypos = ((TGeoBBox*)(modVol->GetShape()))->GetDY() + ((TGeoBBox*)(mechStaveVol->GetShape()))->GetDY(); @@ -403,18 +403,18 @@ TGeoVolume* UpgradeV1Layer::CreateStave(const TGeoManager* /*mgr*/) new TGeoCombiTrans(0, -ypos, 0, new TGeoRotation("", 0, 0, 180))); } } else { - TGeoVolume* hstaveVol = CreateStaveOuterB(); + TGeoVolume* hstaveVol = createStaveOuterB(); if (mStaveModel == Detector::kOBModel0) { // Create simplified stave struct as in v0 staveVol->AddNode(hstaveVol, 0); mHierarchy[kHalfStave] = 1; } else { // (if mStaveModel) Create new stave struct as in TDR xpos = ((TGeoBBox*)(hstaveVol->GetShape()))->GetDX() - sOBHalfStaveXOverlap / 2; - // ypos is CF height as computed in CreateSpaceFrameOuterB1 + // ypos is CF height as computed in createSpaceFrameOuterB1 ypos = (sOBSpaceFrameTotHigh - sOBHalfStaveYTrans) / 2; staveVol->AddNode(hstaveVol, 0, new TGeoTranslation(-xpos, ypos, 0)); staveVol->AddNode(hstaveVol, 1, new TGeoTranslation(xpos, ypos + sOBHalfStaveYTrans, 0)); mHierarchy[kHalfStave] = 2; // RS - mechStaveVol = CreateSpaceFrameOuterB(); + mechStaveVol = createSpaceFrameOuterB(); if (mechStaveVol) { staveVol->AddNode(mechStaveVol, 1, @@ -426,14 +426,14 @@ TGeoVolume* UpgradeV1Layer::CreateStave(const TGeoManager* /*mgr*/) return staveVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveInnerB(const Double_t xsta, const Double_t ysta, +TGeoVolume* UpgradeV1Layer::createStaveInnerB(const Double_t xsta, const Double_t ysta, const Double_t zsta, const TGeoManager* mgr) { Double_t xmod, ymod, zmod; char volumeName[30]; // First we create the module (i.e. the HIC with 9 chips) - TGeoVolume* moduleVol = CreateModuleInnerB(xsta, ysta, zsta); + TGeoVolume* moduleVol = createModuleInnerB(xsta, ysta, zsta); // Then we create the fake halfstave and the actual stave xmod = ((TGeoBBox*)(moduleVol->GetShape()))->GetDX(); @@ -444,7 +444,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveInnerB(const Double_t xsta, const Double_ TGeoMedium* medAir = mgr->GetMedium("ITS_AIR$"); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSHalfStavePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSHalfStavePattern(), mLayerNumber); TGeoVolume* hstaveVol = new TGeoVolume(volumeName, hstave, medAir); // Finally build it up @@ -455,7 +455,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveInnerB(const Double_t xsta, const Double_ return hstaveVol; } -TGeoVolume* UpgradeV1Layer::CreateModuleInnerB(Double_t xmod, Double_t ymod, Double_t zmod, +TGeoVolume* UpgradeV1Layer::createModuleInnerB(Double_t xmod, Double_t ymod, Double_t zmod, const TGeoManager* mgr) { Double_t zchip; @@ -464,14 +464,14 @@ TGeoVolume* UpgradeV1Layer::CreateModuleInnerB(Double_t xmod, Double_t ymod, Dou // First create the single chip zchip = zmod / sIBChipsPerRow; - TGeoVolume* chipVol = CreateChipInnerB(xmod, ymod, zchip); + TGeoVolume* chipVol = createChipInnerB(xmod, ymod, zchip); // Then create the module and populate it with the chips TGeoBBox* module = new TGeoBBox(xmod, ymod, zmod); TGeoMedium* medAir = mgr->GetMedium("ITS_AIR$"); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSModulePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSModulePattern(), mLayerNumber); TGeoVolume* modVol = new TGeoVolume(volumeName, module, medAir); // mm (not used) zlen = ((TGeoBBox*)chipVol->GetShape())->GetDZ(); @@ -484,29 +484,29 @@ TGeoVolume* UpgradeV1Layer::CreateModuleInnerB(Double_t xmod, Double_t ymod, Dou return modVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveStructInnerB(const Double_t xsta, const Double_t zsta, +TGeoVolume* UpgradeV1Layer::createStaveStructInnerB(const Double_t xsta, const Double_t zsta, const TGeoManager* mgr) { TGeoVolume* mechStavVol = 0; switch (mStaveModel) { case Detector::kIBModelDummy: - mechStavVol = CreateStaveModelInnerBDummy(xsta, zsta, mgr); + mechStavVol = createStaveModelInnerBDummy(xsta, zsta, mgr); break; case Detector::kIBModel0: - mechStavVol = CreateStaveModelInnerB0(xsta, zsta, mgr); + mechStavVol = createStaveModelInnerB0(xsta, zsta, mgr); break; case Detector::kIBModel1: - mechStavVol = CreateStaveModelInnerB1(xsta, zsta, mgr); + mechStavVol = createStaveModelInnerB1(xsta, zsta, mgr); break; case Detector::kIBModel21: - mechStavVol = CreateStaveModelInnerB21(xsta, zsta, mgr); + mechStavVol = createStaveModelInnerB21(xsta, zsta, mgr); break; case Detector::kIBModel22: - mechStavVol = CreateStaveModelInnerB22(xsta, zsta, mgr); + mechStavVol = createStaveModelInnerB22(xsta, zsta, mgr); break; case Detector::kIBModel3: - mechStavVol = CreateStaveModelInnerB3(xsta, zsta, mgr); + mechStavVol = createStaveModelInnerB3(xsta, zsta, mgr); break; default: LOG(FATAL) << "Unknown stave model " << mStaveModel << FairLogger::endl; @@ -515,14 +515,14 @@ TGeoVolume* UpgradeV1Layer::CreateStaveStructInnerB(const Double_t xsta, const D return mechStavVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerBDummy(const Double_t, const Double_t, +TGeoVolume* UpgradeV1Layer::createStaveModelInnerBDummy(const Double_t, const Double_t, const TGeoManager*) const { // Done, return the stave structur return 0; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB0(const Double_t xsta, const Double_t zsta, +TGeoVolume* UpgradeV1Layer::createStaveModelInnerB0(const Double_t xsta, const Double_t zsta, const TGeoManager* mgr) { // Materials defined in Detector @@ -556,7 +556,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB0(const Double_t xsta, const D LOG(DEBUG1) << "BuildLevel " << mBuildLevel << FairLogger::endl; char volumeName[30]; - snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::GetITSStavePattern(), + snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::getITSStavePattern(), mLayerNumber); Double_t z = 0, y = -0.011 + 0.0150, x = 0; @@ -725,7 +725,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB0(const Double_t xsta, const D return mechStavVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB1(const Double_t xsta, const Double_t zsta, +TGeoVolume* UpgradeV1Layer::createStaveModelInnerB1(const Double_t xsta, const Double_t zsta, const TGeoManager* mgr) { // Materials defined in Detector @@ -758,7 +758,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB1(const Double_t xsta, const D TGeoVolume* mechStavVol = 0; char volumeName[30]; - snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::GetITSStavePattern(), + snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::getITSStavePattern(), mLayerNumber); // detailed structure ++++++++++++++ @@ -931,7 +931,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB1(const Double_t xsta, const D return mechStavVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB21(const Double_t xsta, const Double_t zsta, +TGeoVolume* UpgradeV1Layer::createStaveModelInnerB21(const Double_t xsta, const Double_t zsta, const TGeoManager* mgr) { // Materials defined in Detector @@ -969,7 +969,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB21(const Double_t xsta, const Int_t loop = (Int_t)(kStaveLength / (2 * kL1)); char volumeName[30]; - snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::GetITSStavePattern(), + snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::getITSStavePattern(), mLayerNumber); Double_t z = 0, y = -(kConeOutRadius + 0.03) + 0.0385, x = 0; @@ -1227,7 +1227,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB21(const Double_t xsta, const return mechStavVol; } // new model22 -TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB22(const Double_t xsta, const Double_t zsta, +TGeoVolume* UpgradeV1Layer::createStaveModelInnerB22(const Double_t xsta, const Double_t zsta, const TGeoManager* mgr) { // Materials defined in Detector @@ -1270,7 +1270,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB22(const Double_t xsta, const Int_t loop = (Int_t)(kStaveLength / (2 * kL1)); char volumeName[30]; - snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::GetITSStavePattern(), + snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::getITSStavePattern(), mLayerNumber); Double_t z = 0, y = -(2 * kConeOutRadius) + klay1 + klay2 + mSensorThickness / 2 - 0.0004, x = 0; @@ -1547,7 +1547,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB22(const Double_t xsta, const } // model3 -TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB3(const Double_t xsta, const Double_t zsta, +TGeoVolume* UpgradeV1Layer::createStaveModelInnerB3(const Double_t xsta, const Double_t zsta, const TGeoManager* mgr) { // Materials defined in Detector @@ -1597,7 +1597,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB3(const Double_t xsta, const D Double_t smcSpace = 0.01; char volumeName[30]; - snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::GetITSStavePattern(), + snprintf(volumeName, 30, "%s%d_StaveStruct", UpgradeGeometryTGeo::getITSStavePattern(), mLayerNumber); // detailed structure ++++++++++++++ @@ -2048,19 +2048,19 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelInnerB3(const Double_t xsta, const D return mechStavVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveOuterB(const TGeoManager* mgr) +TGeoVolume* UpgradeV1Layer::createStaveOuterB(const TGeoManager* mgr) { TGeoVolume* mechStavVol = 0; switch (mStaveModel) { case Detector::kOBModelDummy: - mechStavVol = CreateStaveModelOuterBDummy(mgr); + mechStavVol = createStaveModelOuterBDummy(mgr); break; case Detector::kOBModel0: - mechStavVol = CreateStaveModelOuterB0(mgr); + mechStavVol = createStaveModelOuterB0(mgr); break; case Detector::kOBModel1: - mechStavVol = CreateStaveModelOuterB1(mgr); + mechStavVol = createStaveModelOuterB1(mgr); break; default: LOG(FATAL) << "Unknown stave model " << mStaveModel << FairLogger::endl; @@ -2069,13 +2069,13 @@ TGeoVolume* UpgradeV1Layer::CreateStaveOuterB(const TGeoManager* mgr) return mechStavVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterBDummy(const TGeoManager*) const +TGeoVolume* UpgradeV1Layer::createStaveModelOuterBDummy(const TGeoManager*) const { // Done, return the stave structure return 0; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB0(const TGeoManager* mgr) +TGeoVolume* UpgradeV1Layer::createStaveModelOuterB0(const TGeoManager* mgr) { Double_t xmod, ymod, zmod; Double_t xlen, ylen, zlen; @@ -2088,7 +2088,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB0(const TGeoManager* mgr) ylen = 0.5 * mStaveThickness; // TO BE CHECKED zlen = sOBModuleZLength / 2; - TGeoVolume* chipVol = CreateChipInnerB(xlen, ylen, zlen); + TGeoVolume* chipVol = createChipInnerB(xlen, ylen, zlen); xmod = ((TGeoBBox*)chipVol->GetShape())->GetDX(); ymod = ((TGeoBBox*)chipVol->GetShape())->GetDY(); @@ -2102,11 +2102,11 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB0(const TGeoManager* mgr) // We have all shapes: now create the real volumes TGeoMedium* medAir = mgr->GetMedium("ITS_AIR$"); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSModulePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSModulePattern(), mLayerNumber); TGeoVolume* modVol = new TGeoVolume(volumeName, module, medAir); modVol->SetVisibility(kTRUE); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSHalfStavePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSHalfStavePattern(), mLayerNumber); TGeoVolume* hstaveVol = new TGeoVolume(volumeName, hstave, medAir); // Finally build it up @@ -2123,7 +2123,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB0(const TGeoManager* mgr) return hstaveVol; } -TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB1(const TGeoManager* mgr) +TGeoVolume* UpgradeV1Layer::createStaveModelOuterB1(const TGeoManager* mgr) { Double_t yFlex1 = sOBFlexCableAlThick; Double_t yFlex2 = sOBFlexCableKapThick; @@ -2144,7 +2144,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB1(const TGeoManager* mgr) zlen = (mNumberOfModules * sOBModuleZLength + (mNumberOfModules - 1) * sOBModuleGap) / 2; // First create all needed shapes - TGeoVolume* moduleVol = CreateModuleOuterB(); + TGeoVolume* moduleVol = createModuleOuterB(); moduleVol->SetVisibility(kTRUE); ymod = ((TGeoBBox*)(moduleVol->GetShape()))->GetDY(); zmod = ((TGeoBBox*)(moduleVol->GetShape()))->GetDZ(); @@ -2283,7 +2283,7 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB1(const TGeoManager* mgr) fleectubVol->SetFillColor(fleectubVol->GetLineColor()); fleectubVol->SetFillStyle(4000); // 0% transparent - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSHalfStavePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSHalfStavePattern(), mLayerNumber); TGeoVolume* halmStaveVol = new TGeoVolume(volumeName, halmStave, medAir); // halmStaveVol->SetLineColor(12); // halmStaveVol->SetFillColor(12); @@ -2400,17 +2400,17 @@ TGeoVolume* UpgradeV1Layer::CreateStaveModelOuterB1(const TGeoManager* mgr) return halmStaveVol; } -TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB(const TGeoManager* mgr) +TGeoVolume* UpgradeV1Layer::createSpaceFrameOuterB(const TGeoManager* mgr) { TGeoVolume* mechStavVol = 0; switch (mStaveModel) { case Detector::kOBModelDummy: case Detector::kOBModel0: - mechStavVol = CreateSpaceFrameOuterBDummy(mgr); + mechStavVol = createSpaceFrameOuterBDummy(mgr); break; case Detector::kOBModel1: - mechStavVol = CreateSpaceFrameOuterB1(mgr); + mechStavVol = createSpaceFrameOuterB1(mgr); break; default: LOG(FATAL) << "Unknown stave model " << mStaveModel << FairLogger::endl; @@ -2420,13 +2420,13 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB(const TGeoManager* mgr) return mechStavVol; } -TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterBDummy(const TGeoManager*) const +TGeoVolume* UpgradeV1Layer::createSpaceFrameOuterBDummy(const TGeoManager*) const { // Done, return the stave structur return 0; } -TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) +TGeoVolume* UpgradeV1Layer::createSpaceFrameOuterB1(const TGeoManager* mgr) { // Materials defined in Detector TGeoMedium* medCarbon = mgr->GetMedium("ITS_CARBON$"); @@ -2455,7 +2455,7 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) zlen = mNumberOfModules * sOBModuleZLength + (mNumberOfModules - 1) * sOBModuleGap; - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSHalfStavePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSHalfStavePattern(), mLayerNumber); if (gGeoManager->GetVolume(volumeName)) { // Should always be so sframeHeight -= ((TGeoBBox*)gGeoManager->GetVolume(volumeName)->GetShape())->GetDY() * 2; zlen = ((TGeoBBox*)gGeoManager->GetVolume(volumeName)->GetShape())->GetDZ() * 2; @@ -2474,12 +2474,12 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) // SpaceFrame //--- the top V of the Carbon Fiber Stave (segment) - TGeoArb8* cmStavTop1 = CreateStaveSide("CFstavTopCornerVol1shape", seglen / 2., halmTheta, -1, + TGeoArb8* cmStavTop1 = createStaveSide("CFstavTopCornerVol1shape", seglen / 2., halmTheta, -1, staveLa, staveHa, stavel); TGeoVolume* cmStavTopVol1 = new TGeoVolume("CFstavTopCornerVol1", cmStavTop1, medCarbon); cmStavTopVol1->SetLineColor(35); - TGeoArb8* cmStavTop2 = CreateStaveSide("CFstavTopCornerVol2shape", seglen / 2., halmTheta, 1, + TGeoArb8* cmStavTop2 = createStaveSide("CFstavTopCornerVol2shape", seglen / 2., halmTheta, 1, staveLa, staveHa, stavel); TGeoVolume* cmStavTopVol2 = new TGeoVolume("CFstavTopCornerVol2", cmStavTop2, medCarbon); cmStavTopVol2->SetLineColor(35); @@ -2488,12 +2488,12 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) //--- the 2 side V TGeoArb8* cmStavSide1 = - CreateStaveSide("CFstavSideCornerVol1shape", seglen / 2., beta, -1, staveLb, staveHb, stavel); + createStaveSide("CFstavSideCornerVol1shape", seglen / 2., beta, -1, staveLb, staveHb, stavel); TGeoVolume* cmStavSideVol1 = new TGeoVolume("CFstavSideCornerVol1", cmStavSide1, medCarbon); cmStavSideVol1->SetLineColor(35); TGeoArb8* cmStavSide2 = - CreateStaveSide("CFstavSideCornerVol2shape", seglen / 2., beta, 1, staveLb, staveHb, stavel); + createStaveSide("CFstavSideCornerVol2shape", seglen / 2., beta, 1, staveLb, staveHb, stavel); TGeoVolume* cmStavSideVol2 = new TGeoVolume("CFstavSideCornerVol2", cmStavSide2, medCarbon); cmStavSideVol2->SetLineColor(35); @@ -2515,7 +2515,7 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) // Beams on the sides Double_t beamPhiPrime = TMath::ASin( 1. / TMath::Sqrt((1 + TMath::Sin(2 * beta) * TMath::Sin(2 * beta) / - (TanD(sOBSFrameBeamSidePhi) * TanD(sOBSFrameBeamSidePhi))))); + (tanD(sOBSFrameBeamSidePhi) * tanD(sOBSFrameBeamSidePhi))))); Double_t beamLength = TMath::Sqrt(sframeHeight * sframeHeight / (TMath::Sin(beamPhiPrime) * TMath::Sin(beamPhiPrime)) + sframeWidth * sframeWidth / 4.) - @@ -2540,17 +2540,17 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) beamTransf[0] = new TGeoCombiTrans(xpos, ypos, -3 * zpos, beamRot1); beamTransf[1] = new TGeoCombiTrans(xpos, ypos, -3 * zpos, beamRot1); - AddTranslationToCombiTrans(beamTransf[1], 0, 0, seglen / 2); + addTranslationToCombiTrans(beamTransf[1], 0, 0, seglen / 2); beamTransf[2] = new TGeoCombiTrans(xpos, ypos, -zpos, beamRot2); beamTransf[3] = new TGeoCombiTrans(xpos, ypos, -zpos, beamRot2); - AddTranslationToCombiTrans(beamTransf[3], 0, 0, seglen / 2); + addTranslationToCombiTrans(beamTransf[3], 0, 0, seglen / 2); beamTransf[4] = new TGeoCombiTrans(-xpos, ypos, -3 * zpos, beamRot3); beamTransf[5] = new TGeoCombiTrans(-xpos, ypos, -3 * zpos, beamRot3); - AddTranslationToCombiTrans(beamTransf[5], 0, 0, seglen / 2); + addTranslationToCombiTrans(beamTransf[5], 0, 0, seglen / 2); beamTransf[6] = new TGeoCombiTrans(-xpos, ypos, -zpos, beamRot4); beamTransf[7] = new TGeoCombiTrans(-xpos, ypos, 3 * zpos, beamRot4); @@ -2567,7 +2567,7 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) bottomBeam2Vol->SetLineColor(35); TGeoTubeSeg* bottomBeam3 = new TGeoTubeSeg( - 0, staveBeamRadius, 0.5 * sframeWidth / SinD(bottomBeamAngle) - staveLb / 3, 0, 180); + 0, staveBeamRadius, 0.5 * sframeWidth / sinD(bottomBeamAngle) - staveLb / 3, 0, 180); TGeoVolume* bottomBeam3Vol = new TGeoVolume("CFstavBottomBeam3Vol", bottomBeam3, medCarbon); bottomBeam3Vol->SetLineColor(35); @@ -2614,7 +2614,7 @@ TGeoVolume* UpgradeV1Layer::CreateSpaceFrameOuterB1(const TGeoManager* mgr) return spaceFrameVol; } -TGeoVolume* UpgradeV1Layer::CreateChipInnerB(const Double_t xchip, const Double_t ychip, +TGeoVolume* UpgradeV1Layer::createChipInnerB(const Double_t xchip, const Double_t ychip, const Double_t zchip, const TGeoManager* mgr) { char volumeName[30]; @@ -2635,12 +2635,12 @@ TGeoVolume* UpgradeV1Layer::CreateChipInnerB(const Double_t xchip, const Double_ // We have all shapes: now create the real volumes TGeoMedium* medSi = mgr->GetMedium("ITS_SI$"); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSChipPattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSChipPattern(), mLayerNumber); TGeoVolume* chipVol = new TGeoVolume(volumeName, chip, medSi); chipVol->SetVisibility(kTRUE); chipVol->SetLineColor(1); - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSSensorPattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSSensorPattern(), mLayerNumber); TGeoVolume* sensVol = new TGeoVolume(volumeName, sensor, medSi); sensVol->SetVisibility(kTRUE); sensVol->SetLineColor(8); @@ -2659,7 +2659,7 @@ TGeoVolume* UpgradeV1Layer::CreateChipInnerB(const Double_t xchip, const Double_ return chipVol; } -TGeoVolume* UpgradeV1Layer::CreateModuleOuterB(const TGeoManager* mgr) +TGeoVolume* UpgradeV1Layer::createModuleOuterB(const TGeoManager* mgr) { char volumeName[30]; @@ -2677,7 +2677,7 @@ TGeoVolume* UpgradeV1Layer::CreateModuleOuterB(const TGeoManager* mgr) ylen = 0.5 * mStaveThickness; // TO BE CHECKED zlen = (sOBModuleZLength - (sOBChipsPerRow - 1) * zGap) / (2 * sOBChipsPerRow); - TGeoVolume* chipVol = CreateChipInnerB(xlen, ylen, zlen); + TGeoVolume* chipVol = createChipInnerB(xlen, ylen, zlen); xchip = ((TGeoBBox*)chipVol->GetShape())->GetDX(); ychip = ((TGeoBBox*)chipVol->GetShape())->GetDY(); @@ -2734,7 +2734,7 @@ TGeoVolume* UpgradeV1Layer::CreateModuleOuterB(const TGeoManager* mgr) flexKapVol->SetFillColor(flexKapVol->GetLineColor()); flexKapVol->SetFillStyle(4000); // 0% transparent - snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::GetITSModulePattern(), mLayerNumber); + snprintf(volumeName, 30, "%s%d", UpgradeGeometryTGeo::getITSModulePattern(), mLayerNumber); TGeoVolume* modVol = new TGeoVolume(volumeName, module, medAir); modVol->SetVisibility(kTRUE); @@ -2765,7 +2765,7 @@ TGeoVolume* UpgradeV1Layer::CreateModuleOuterB(const TGeoManager* mgr) return modVol; } -Double_t UpgradeV1Layer::RadiusOmTurboContainer() +Double_t UpgradeV1Layer::radiusOmTurboContainer() { Double_t rr, delta, z, lstav, rstav; @@ -2774,20 +2774,20 @@ Double_t UpgradeV1Layer::RadiusOmTurboContainer() } rstav = mLayerRadius + 0.5 * mStaveThickness; - delta = (0.5 * mStaveThickness) / CosD(mStaveTilt); - z = (0.5 * mStaveThickness) * TanD(mStaveTilt); + delta = (0.5 * mStaveThickness) / cosD(mStaveTilt); + z = (0.5 * mStaveThickness) * tanD(mStaveTilt); rr = rstav - delta; lstav = (0.5 * mStaveWidth) - z; - if ((rr * SinD(mStaveTilt) < lstav)) { - return (rr * CosD(mStaveTilt)); + if ((rr * sinD(mStaveTilt) < lstav)) { + return (rr * cosD(mStaveTilt)); } else { return -1; } } -void UpgradeV1Layer::SetNumberOfUnits(Int_t u) +void UpgradeV1Layer::setNumberOfUnits(Int_t u) { if (mLayerNumber < sNumberOmInnerLayers) { mNumberOfChips = u; @@ -2797,7 +2797,7 @@ void UpgradeV1Layer::SetNumberOfUnits(Int_t u) } } -void UpgradeV1Layer::SetStaveTilt(const Double_t t) +void UpgradeV1Layer::setStaveTilt(const Double_t t) { if (mIsTurbo) { mStaveTilt = t; @@ -2806,7 +2806,7 @@ void UpgradeV1Layer::SetStaveTilt(const Double_t t) } } -void UpgradeV1Layer::SetStaveWidth(const Double_t w) +void UpgradeV1Layer::setStaveWidth(const Double_t w) { if (mIsTurbo) { mStaveWidth = w; @@ -2815,7 +2815,7 @@ void UpgradeV1Layer::SetStaveWidth(const Double_t w) } } -TGeoArb8* UpgradeV1Layer::CreateStaveSide(const char* name, Double_t dz, Double_t angle, +TGeoArb8* UpgradeV1Layer::createStaveSide(const char* name, Double_t dz, Double_t angle, Double_t xSign, Double_t L, Double_t H, Double_t l) { // Create one half of the V shape corner of CF stave @@ -2844,10 +2844,10 @@ TGeoArb8* UpgradeV1Layer::CreateStaveSide(const char* name, Double_t dz, Double_ return cmStavSide; } -TGeoCombiTrans* UpgradeV1Layer::CreateCombiTrans(const char* name, Double_t dy, Double_t dz, +TGeoCombiTrans* UpgradeV1Layer::createCombiTrans(const char* name, Double_t dy, Double_t dz, Double_t dphi, Bool_t planeSym) { - TGeoTranslation t1(dy * CosD(90. + dphi), dy * SinD(90. + dphi), dz); + TGeoTranslation t1(dy * cosD(90. + dphi), dy * sinD(90. + dphi), dz); TGeoRotation r1("", 0., 0., dphi); TGeoRotation r2("", 90, 180, -90 - dphi); @@ -2861,7 +2861,7 @@ TGeoCombiTrans* UpgradeV1Layer::CreateCombiTrans(const char* name, Double_t dy, return combiTrans1; } -void UpgradeV1Layer::AddTranslationToCombiTrans(TGeoCombiTrans* ct, Double_t dx, Double_t dy, +void UpgradeV1Layer::addTranslationToCombiTrans(TGeoCombiTrans* ct, Double_t dx, Double_t dy, Double_t dz) const { // Add a dx,dy,dz translation to the initial TGeoCombiTrans diff --git a/its/UpgradeV1Layer.h b/its/UpgradeV1Layer.h index 951f4a303ec9f..3658ed04707fc 100644 --- a/its/UpgradeV1Layer.h +++ b/its/UpgradeV1Layer.h @@ -46,91 +46,91 @@ class UpgradeV1Layer : public V11Geometry { /// Default destructor virtual ~UpgradeV1Layer(); - Bool_t IsTurbo() const + Bool_t isTurbo() const { return mIsTurbo; }; - Double_t GetStaveThick() const + Double_t getStaveThick() const { return mStaveThickness; }; - Double_t GetStaveTilt() const + Double_t getStaveTilt() const { return mStaveTilt; }; - Double_t GetStaveWidth() const + Double_t getStaveWidth() const { return mStaveWidth; }; - Double_t GetSensorThick() const + Double_t getSensorThick() const { return mSensorThickness; }; - Double_t GetNStaves() const + Double_t getNumberOfStaves() const { return mNumberOfStaves; }; - Double_t GetNChips() const + Double_t getNumberOfChips() const { return mNumberOfChips; }; - Double_t GetRadius() const + Double_t getRadius() const { return mLayerRadius; }; - Double_t GetPhi0() const + Double_t getPhi0() const { return mPhi0; }; - Double_t GetZLength() const + Double_t getZLength() const { return mZLength; }; - Int_t GetChipType() const + Int_t getChipType() const { return mChipTypeID; } - Int_t GetNStavesPerParent() const + Int_t getNumberOfStavesPerParent() const { return mHierarchy[kStave]; } - Int_t GetNHalfStavesPerParent() const + Int_t getNumberOfHalfStavesPerParent() const { return mHierarchy[kHalfStave]; } - Int_t GetNModulesPerParent() const + Int_t getNumberOfModulesPerParent() const { return mHierarchy[kModule]; } - Int_t GetNChipsPerParent() const + Int_t getNumberOfChipsPerParent() const { return mHierarchy[kChip]; } - AliceO2::ITS::Detector::UpgradeModel GetStaveModel() const + AliceO2::ITS::Detector::UpgradeModel getStaveModel() const { return mStaveModel; } - void SetStaveThick(Double_t t) + void setStaveThick(Double_t t) { mStaveThickness = t; }; /// Sets the Stave tilt angle (for turbo layers only) /// \param t The stave tilt angle - void SetStaveTilt(Double_t t); + void setStaveTilt(Double_t t); /// Sets the Stave width (for turbo layers only) /// \param w The stave width - void SetStaveWidth(Double_t w); - void SetSensorThick(Double_t t) + void setStaveWidth(Double_t w); + void setSensorThick(Double_t t) { mSensorThickness = t; }; - void SetNumberOfStaves(Int_t n) + void setNumberOfStaves(Int_t n) { mHierarchy[kStave] = mNumberOfStaves = n; }; @@ -139,36 +139,36 @@ class UpgradeV1Layer : public V11Geometry { /// for the Inner Barrel: the number of chips per stave /// for the Outer Barrel: the number of modules per half stave /// \param u the number of units - void SetNumberOfUnits(Int_t u); + void setNumberOfUnits(Int_t u); - void SetRadius(Double_t r) + void setRadius(Double_t r) { mLayerRadius = r; }; - void SetPhi0(Double_t phi) + void setPhi0(Double_t phi) { mPhi0 = phi; } - void SetZLength(Double_t z) + void setZLength(Double_t z) { mZLength = z; }; - void SetChipType(Int_t tp) + void setChipType(Int_t tp) { mChipTypeID = tp; } - void SetBuildLevel(Int_t buildLevel) + void setBuildLevel(Int_t buildLevel) { mBuildLevel = buildLevel; } - void SetStaveModel(AliceO2::ITS::Detector::UpgradeModel model) + void setStaveModel(AliceO2::ITS::Detector::UpgradeModel model) { mStaveModel = model; } /// Creates the actual Layer and places inside its mother volume /// \param motherVolume the TGeoVolume owing the volume structure - virtual void CreateLayer(TGeoVolume* motherVolume); + virtual void createLayer(TGeoVolume* motherVolume); private: /// Creates the actual Layer and places inside its mother volume @@ -176,125 +176,119 @@ class UpgradeV1Layer : public V11Geometry { /// User can set width and tilt angle, no check is performed here /// to avoid volume overlaps /// \param motherVolume The TGeoVolume owing the volume structure - void CreateLayerTurbo(TGeoVolume* motherVolume); + void createLayerTurbo(TGeoVolume* motherVolume); /// Computes the inner radius of the air container for the Turbo configuration /// as the radius of either the circle tangent to the stave or the circle /// passing for the stave's lower vertex. Returns the radius of the container /// if >0, else flag to use the lower vertex - Double_t RadiusOmTurboContainer(); + Double_t radiusOmTurboContainer(); /// Creates the actual Stave /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStave(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStave(const TGeoManager* mgr = gGeoManager); - // TGeoVolume* CreateChip(Double_t x, Double_t z, const TGeoManager *mgr=gGeoManager); + // TGeoVolume* createChip(Double_t x, Double_t z, const TGeoManager *mgr=gGeoManager); /// Creates the IB Module: (only the chips for the time being) /// Returns the module as a TGeoVolume /// \param xmod, ymod, zmod X, Y, Z module half lengths /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateModuleInnerB(Double_t x, Double_t y, Double_t z, - const TGeoManager* mgr = gGeoManager); + TGeoVolume* createModuleInnerB(Double_t x, Double_t y, Double_t z, const TGeoManager* mgr = gGeoManager); /// Creates the actual Chip /// \param xchip,ychip,zchip The chip dimensions /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateChipInnerB(Double_t x, Double_t y, Double_t z, - const TGeoManager* mgr = gGeoManager); + TGeoVolume* createChipInnerB(Double_t x, Double_t y, Double_t z, const TGeoManager* mgr = gGeoManager); /// Creates the OB Module: HIC + FPC + Carbon plate /// Returns the module as a TGeoVolume /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateModuleOuterB(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createModuleOuterB(const TGeoManager* mgr = gGeoManager); /// Create the chip stave for the Inner Barrel(Here we fake the halfstave volume to have the /// same formal geometry hierarchy as for the Outer Barrel) /// \param xsta, ysta, zsta X, Y, Z stave half lengths /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveInnerB(Double_t x, Double_t y, Double_t z, - const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveInnerB(Double_t x, Double_t y, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create the mechanical stave structure /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveStructInnerB(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveStructInnerB(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create a dummy stave /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelInnerBDummy(Double_t x, Double_t z, - const TGeoManager* mgr = gGeoManager) const; + TGeoVolume* createStaveModelInnerBDummy(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager) const; /// Create the mechanical stave structure for Model 0 of TDR /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelInnerB0(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelInnerB0(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create the mechanical stave structure for Model 1 of TDR /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelInnerB1(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelInnerB1(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create the mechanical stave structure for Model 2.1 of TDR /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelInnerB21(Double_t x, Double_t z, - const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelInnerB21(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create the mechanical stave structure for Model 2.2 of TDR /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelInnerB22(Double_t x, Double_t z, - const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelInnerB22(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create the mechanical stave structure for Model 3 of TDR /// \param xsta X length /// \param zsta Z length /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelInnerB3(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelInnerB3(Double_t x, Double_t z, const TGeoManager* mgr = gGeoManager); /// Create the chip stave for the Outer Barrel /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveOuterB(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveOuterB(const TGeoManager* mgr = gGeoManager); /// Create dummy stave /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelOuterBDummy(const TGeoManager* mgr = gGeoManager) const; + TGeoVolume* createStaveModelOuterBDummy(const TGeoManager* mgr = gGeoManager) const; /// Creation of the mechanical stave structure for the Outer Barrel as in v0 /// (we fake the module and halfstave volumes to have always /// the same formal geometry hierarchy) /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelOuterB0(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelOuterB0(const TGeoManager* mgr = gGeoManager); /// Create the mechanical half stave structure or the Outer Barrel as in TDR /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateStaveModelOuterB1(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createStaveModelOuterB1(const TGeoManager* mgr = gGeoManager); /// Create the space frame for the Outer Barrel /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateSpaceFrameOuterB(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createSpaceFrameOuterB(const TGeoManager* mgr = gGeoManager); /// Create dummy stave /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateSpaceFrameOuterBDummy(const TGeoManager* mgr = gGeoManager) const; + TGeoVolume* createSpaceFrameOuterBDummy(const TGeoManager* mgr = gGeoManager) const; /// Create the space frame for the Outer Barrel (Model 1) /// Returns a TGeoVolume with the Space Frame of a stave /// \param mgr The GeoManager (used only to get the proper material) - TGeoVolume* CreateSpaceFrameOuterB1(const TGeoManager* mgr = gGeoManager); + TGeoVolume* createSpaceFrameOuterB1(const TGeoManager* mgr = gGeoManager); /// Creates the V-shaped sides of the OB space frame (from a similar method with same /// name and function in V11GeometrySDD class by L.Gaudichet) - TGeoArb8* CreateStaveSide(const char* name, Double_t dz, Double_t angle, Double_t xSign, - Double_t L, Double_t H, Double_t l); + TGeoArb8* createStaveSide(const char* name, Double_t dz, Double_t angle, Double_t xSign, Double_t L, Double_t H, + Double_t l); /// Help method to create a TGeoCombiTrans matrix from a similar method with same name and /// function in V11GeometrySDD class by L.Gaudichet) @@ -302,13 +296,11 @@ class UpgradeV1Layer : public V11Geometry { /// in the global coord system. If planeSym = true, the rotation places the object /// symetrically (with respect to the transverse plane) to its position in the /// case planeSym = false - TGeoCombiTrans* CreateCombiTrans(const char* name, Double_t dy, Double_t dz, Double_t dphi, - Bool_t planeSym = kFALSE); + TGeoCombiTrans* createCombiTrans(const char* name, Double_t dy, Double_t dz, Double_t dphi, Bool_t planeSym = kFALSE); /// Help method to add a translation to a TGeoCombiTrans matrix (from a similar method /// with same name and function in V11GeometrySDD class by L.Gaudichet) - void AddTranslationToCombiTrans(TGeoCombiTrans* ct, Double_t dx = 0, Double_t dy = 0, - Double_t dz = 0) const; + void addTranslationToCombiTrans(TGeoCombiTrans* ct, Double_t dx = 0, Double_t dy = 0, Double_t dz = 0) const; Int_t mLayerNumber; ///< Current layer number Double_t mPhi0; ///< lab phi of 1st stave, in degrees!!! @@ -319,13 +311,11 @@ class UpgradeV1Layer : public V11Geometry { Double_t mStaveWidth; ///< Stave width (for turbo layers only) Double_t mStaveTilt; ///< Stave tilt angle (for turbo layers only) in degrees Int_t mNumberOfStaves; ///< Number of staves in this layer - Int_t - mNumberOfModules; ///< Number of modules per container if defined (HalfStave, Stave, whatever is - ///< container) - Int_t mNumberOfChips; ///< Number chips per container (module, HalfStave, Stave, whatever is + Int_t mNumberOfModules; ///< Number of modules per container if defined (HalfStave, Stave, whatever is + ///< container) + Int_t mNumberOfChips; ///< Number chips per container (module, HalfStave, Stave, whatever is /// container) - Int_t mHierarchy - [kNHLevels]; ///< array to query number of staves, hstaves, modules, chips per its parent volume + Int_t mHierarchy[kNHLevels]; ///< array to query number of staves, hstaves, modules, chips per its parent volume UInt_t mChipTypeID; ///< detector type id Bool_t mIsTurbo; ///< True if this layer is a "turbo" layer diff --git a/its/V11Geometry.cxx b/its/V11Geometry.cxx index b8010cf62ead5..e57e70fab95e9 100644 --- a/its/V11Geometry.cxx +++ b/its/V11Geometry.cxx @@ -43,7 +43,7 @@ const Double_t V11Geometry::sKEV = 1.0e-6; // GeV default const Double_t V11Geometry::sMEV = 1.0e-3; // GeV default const Double_t V11Geometry::sGEV = 1.0; // GeV default -void V11Geometry::IntersectLines(Double_t m, Double_t x0, Double_t y0, Double_t n, Double_t x1, +void V11Geometry::intersectLines(Double_t m, Double_t x0, Double_t y0, Double_t n, Double_t x1, Double_t y1, Double_t& xi, Double_t& yi) const { if (TMath::Abs(m - n) < 0.000001) { @@ -57,7 +57,7 @@ void V11Geometry::IntersectLines(Double_t m, Double_t x0, Double_t y0, Double_t return; } -Bool_t V11Geometry::IntersectCircle(Double_t m, Double_t x0, Double_t y0, Double_t rr, Double_t xc, +Bool_t V11Geometry::intersectCircle(Double_t m, Double_t x0, Double_t y0, Double_t rr, Double_t xc, Double_t yc, Double_t& xi1, Double_t& yi1, Double_t& xi2, Double_t& yi2) { @@ -80,7 +80,7 @@ Bool_t V11Geometry::IntersectCircle(Double_t m, Double_t x0, Double_t y0, Double } } -Double_t V11Geometry::Yfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x) +Double_t V11Geometry::yFrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x) const { if (x0 == x1 && y0 == y1) { @@ -90,7 +90,7 @@ Double_t V11Geometry::Yfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double return 0.0; } // end if if (x0 == x1) { - printf("Warning: V11Geometry::Yfrom2Points x0=%e == x1=%e. " + printf("Warning: V11Geometry::yFrom2Points x0=%e == x1=%e. " "line vertical " "returning mean y", x0, x1); @@ -100,7 +100,7 @@ Double_t V11Geometry::Yfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double return m * (x - x0) + y0; } -Double_t V11Geometry::Xfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t y) +Double_t V11Geometry::xFrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t y) const { if (x0 == x1 && y0 == y1) { @@ -110,7 +110,7 @@ Double_t V11Geometry::Xfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double return 0.0; } // end if if (y0 == y1) { - printf("Warrning: V11Geometry::Yfrom2Points y0=%e == y1=%e. " + printf("Warrning: V11Geometry::yFrom2Points y0=%e == y1=%e. " "line horizontal returning mean x", y0, y1); return 0.5 * (x0 + x1); @@ -119,7 +119,7 @@ Double_t V11Geometry::Xfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double return m * (y - y0) + x0; } -Double_t V11Geometry::RmaxFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const +Double_t V11Geometry::rMaxFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const { Double_t d0, d1, d2, r; @@ -130,37 +130,37 @@ Double_t V11Geometry::RmaxFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Dou return r; } -Double_t V11Geometry::RminFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const +Double_t V11Geometry::rMinFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const { return p->GetRmin(i2) + (p->GetRmin(i1) - p->GetRmin(i2)) * (z - p->GetZ(i2)) / (p->GetZ(i1) - p->GetZ(i2)); } -Double_t V11Geometry::RFrom2Points(const Double_t* p, const Double_t* az, Int_t i1, Int_t i2, +Double_t V11Geometry::rFrom2Points(const Double_t* p, const Double_t* az, Int_t i1, Int_t i2, Double_t z) const { return p[i2] + (p[i1] - p[i2]) * (z - az[i2]) / (az[i1] - az[i2]); } -Double_t V11Geometry::Zfrom2MinPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const +Double_t V11Geometry::zFrom2MinPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const { return p->GetZ(i2) + (p->GetZ(i1) - p->GetZ(i2)) * (r - p->GetRmin(i2)) / (p->GetRmin(i1) - p->GetRmin(i2)); } -Double_t V11Geometry::Zfrom2MaxPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const +Double_t V11Geometry::zFrom2MaxPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const { return p->GetZ(i2) + (p->GetZ(i1) - p->GetZ(i2)) * (r - p->GetRmax(i2)) / (p->GetRmax(i1) - p->GetRmax(i2)); } -Double_t V11Geometry::Zfrom2Points(const Double_t* z, const Double_t* ar, Int_t i1, Int_t i2, +Double_t V11Geometry::zFrom2Points(const Double_t* z, const Double_t* ar, Int_t i1, Int_t i2, Double_t r) const { return z[i2] + (z[i1] - z[i2]) * (r - ar[i2]) / (ar[i1] - ar[i2]); } -Double_t V11Geometry::RmaxFromZpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t z, +Double_t V11Geometry::rMaxFromZpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t z, Double_t th) const { Double_t tantc = TMath::Tan(tc * TMath::DegToRad()); @@ -169,7 +169,7 @@ Double_t V11Geometry::RmaxFromZpCone(const TGeoPcon* p, int ip, Double_t tc, Dou return -tantc * (z - p->GetZ(ip)) + p->GetRmax(ip) + th / costc; } -Double_t V11Geometry::RFromZpCone(const Double_t* ar, const Double_t* az, int ip, Double_t tc, +Double_t V11Geometry::rFromZpCone(const Double_t* ar, const Double_t* az, int ip, Double_t tc, Double_t z, Double_t th) const { Double_t tantc = TMath::Tan(tc * TMath::DegToRad()); @@ -178,7 +178,7 @@ Double_t V11Geometry::RFromZpCone(const Double_t* ar, const Double_t* az, int ip return -tantc * (z - az[ip]) + ar[ip] + th / costc; } -Double_t V11Geometry::RminFromZpCone(const TGeoPcon* p, Int_t ip, Double_t tc, Double_t z, +Double_t V11Geometry::rMinFromZpCone(const TGeoPcon* p, Int_t ip, Double_t tc, Double_t z, Double_t th) const { Double_t tantc = TMath::Tan(tc * TMath::DegToRad()); @@ -187,7 +187,7 @@ Double_t V11Geometry::RminFromZpCone(const TGeoPcon* p, Int_t ip, Double_t tc, D return -tantc * (z - p->GetZ(ip)) + p->GetRmin(ip) + th / costc; } -Double_t V11Geometry::ZFromRmaxpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, +Double_t V11Geometry::zFromRMaxpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, Double_t th) const { Double_t tantc = TMath::Tan(tc * TMath::DegToRad()); @@ -196,7 +196,7 @@ Double_t V11Geometry::ZFromRmaxpCone(const TGeoPcon* p, int ip, Double_t tc, Dou return p->GetZ(ip) + (p->GetRmax(ip) + th / costc - r) / tantc; } -Double_t V11Geometry::ZFromRmaxpCone(const Double_t* ar, const Double_t* az, int ip, Double_t tc, +Double_t V11Geometry::zFromRMaxpCone(const Double_t* ar, const Double_t* az, int ip, Double_t tc, Double_t r, Double_t th) const { Double_t tantc = TMath::Tan(tc * TMath::DegToRad()); @@ -205,7 +205,7 @@ Double_t V11Geometry::ZFromRmaxpCone(const Double_t* ar, const Double_t* az, int return az[ip] + (ar[ip] + th / costc - r) / tantc; } -Double_t V11Geometry::ZFromRminpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, +Double_t V11Geometry::zFromRMinpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, Double_t th) const { Double_t tantc = TMath::Tan(tc * TMath::DegToRad()); @@ -214,7 +214,7 @@ Double_t V11Geometry::ZFromRminpCone(const TGeoPcon* p, int ip, Double_t tc, Dou return p->GetZ(ip) + (p->GetRmin(ip) + th / costc - r) / tantc; } -void V11Geometry::RadiusOfCurvature(Double_t rc, Double_t theta0, Double_t z0, Double_t r0, +void V11Geometry::radiusOfCurvature(Double_t rc, Double_t theta0, Double_t z0, Double_t r0, Double_t theta1, Double_t& z1, Double_t& r1) const { z1 = rc * (TMath::Sin(theta1 * TMath::DegToRad()) - TMath::Sin(theta0 * TMath::DegToRad())) + z0; @@ -222,7 +222,7 @@ void V11Geometry::RadiusOfCurvature(Double_t rc, Double_t theta0, Double_t z0, D return; } -void V11Geometry::InsidePoint(const TGeoPcon* p, Int_t i1, Int_t i2, Int_t i3, Double_t c, +void V11Geometry::insidePoint(const TGeoPcon* p, Int_t i1, Int_t i2, Int_t i3, Double_t c, TGeoPcon* q, Int_t j1, Bool_t max) const { Double_t x0, y0, x1, y1, x2, y2, x, y; @@ -251,7 +251,7 @@ void V11Geometry::InsidePoint(const TGeoPcon* p, Int_t i1, Int_t i2, Int_t i3, D x1 = p->GetZ(i2); // cout <<"L407 x1="<GetZ(i3); // cout <<"L408 x2="<Z(j1) = x; if (max) { @@ -262,7 +262,7 @@ void V11Geometry::InsidePoint(const TGeoPcon* p, Int_t i1, Int_t i2, Int_t i3, D return; } -void V11Geometry::InsidePoint(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x2, +void V11Geometry::insidePoint(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t c, Double_t& x, Double_t& y) const { Double_t dx01, dx12, dy01, dy12, r01, r12, m; @@ -301,9 +301,9 @@ void V11Geometry::InsidePoint(Double_t x0, Double_t y0, Double_t x1, Double_t y1 return; } -void V11Geometry::PrintArb8(const TGeoArb8* a) const +void V11Geometry::printArb8(const TGeoArb8* a) const { - if (!GetDebug()) { + if (!getDebug()) { return; } printf("%s", a->GetName()); @@ -311,9 +311,9 @@ void V11Geometry::PrintArb8(const TGeoArb8* a) const return; } -void V11Geometry::PrintPcon(const TGeoPcon* a) const +void V11Geometry::printPcon(const TGeoPcon* a) const { - if (!GetDebug()) { + if (!getDebug()) { return; } cout << a->GetName() << ": N=" << a->GetNz() << " Phi1=" << a->GetPhi1() @@ -326,9 +326,9 @@ void V11Geometry::PrintPcon(const TGeoPcon* a) const return; } -void V11Geometry::PrintTube(const TGeoTube* a) const +void V11Geometry::printTube(const TGeoTube* a) const { - if (!GetDebug()) { + if (!getDebug()) { return; } cout << a->GetName() << ": Rmin=" << a->GetRmin() << " Rmax=" << a->GetRmax() @@ -336,9 +336,9 @@ void V11Geometry::PrintTube(const TGeoTube* a) const return; } -void V11Geometry::PrintTubeSeg(const TGeoTubeSeg* a) const +void V11Geometry::printTubeSeg(const TGeoTubeSeg* a) const { - if (!GetDebug()) { + if (!getDebug()) { return; } cout << a->GetName() << ": Phi1=" << a->GetPhi1() << " Phi2=" << a->GetPhi2() @@ -346,9 +346,9 @@ void V11Geometry::PrintTubeSeg(const TGeoTubeSeg* a) const return; } -void V11Geometry::PrintConeSeg(const TGeoConeSeg* a) const +void V11Geometry::printConeSeg(const TGeoConeSeg* a) const { - if (!GetDebug()) { + if (!getDebug()) { return; } cout << a->GetName() << ": Phi1=" << a->GetPhi1() << " Phi2=" << a->GetPhi2() @@ -357,9 +357,9 @@ void V11Geometry::PrintConeSeg(const TGeoConeSeg* a) const return; } -void V11Geometry::PrintBBox(const TGeoBBox* a) const +void V11Geometry::printBBox(const TGeoBBox* a) const { - if (!GetDebug()) { + if (!getDebug()) { return; } cout << a->GetName() << ": Dx=" << a->GetDX() << " Dy=" << a->GetDY() << " Dz=" << a->GetDZ() @@ -367,7 +367,7 @@ void V11Geometry::PrintBBox(const TGeoBBox* a) const return; } -void V11Geometry::CreateDefaultMaterials() +void V11Geometry::createDefaultMaterials() { Int_t i; Double_t w; @@ -870,7 +870,7 @@ void V11Geometry::CreateDefaultMaterials() */ } -void V11Geometry::DrawCrossSection(const TGeoPcon* p, Int_t fillc, Int_t fills, Int_t linec, +void V11Geometry::drawCrossSection(const TGeoPcon* p, Int_t fillc, Int_t fills, Int_t linec, Int_t lines, Int_t linew, Int_t markc, Int_t marks, Float_t marksize) const { @@ -922,7 +922,7 @@ void V11Geometry::DrawCrossSection(const TGeoPcon* p, Int_t fillc, Int_t fills, return; } -Bool_t V11Geometry::AngleOfIntersectionWithLine(Double_t x0, Double_t y0, Double_t x1, Double_t y1, +Bool_t V11Geometry::angleOfIntersectionWithLine(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t xc, Double_t yc, Double_t rc, Double_t& t0, Double_t& t1) const { @@ -1023,7 +1023,7 @@ Bool_t V11Geometry::AngleOfIntersectionWithLine(Double_t x0, Double_t y0, Double return kTRUE; } -Double_t V11Geometry::AngleForRoundedCorners0(Double_t dx, Double_t dy, Double_t sdr) const +Double_t V11Geometry::angleForRoundedCorners0(Double_t dx, Double_t dy, Double_t sdr) const { Double_t a, b; @@ -1037,7 +1037,7 @@ Double_t V11Geometry::AngleForRoundedCorners0(Double_t dx, Double_t dy, Double_t return TMath::ATan2(a, b) * TMath::RadToDeg(); } -Double_t V11Geometry::AngleForRoundedCorners1(Double_t dx, Double_t dy, Double_t sdr) const +Double_t V11Geometry::angleForRoundedCorners1(Double_t dx, Double_t dy, Double_t sdr) const { Double_t a, b; @@ -1051,19 +1051,19 @@ Double_t V11Geometry::AngleForRoundedCorners1(Double_t dx, Double_t dy, Double_t return TMath::ATan2(a, b) * TMath::RadToDeg(); } -void V11Geometry::AnglesForRoundedCorners(Double_t x0, Double_t y0, Double_t r0, Double_t x1, +void V11Geometry::anglesForRoundedCorners(Double_t x0, Double_t y0, Double_t r0, Double_t x1, Double_t y1, Double_t r1, Double_t& t0, Double_t& t1) const { Double_t t; if (r0 >= 0.0 && r1 >= 0.0) { // Inside to inside ++ - t = AngleForRoundedCorners1(x1 - x0, y1 - y0, r1 - r0); + t = angleForRoundedCorners1(x1 - x0, y1 - y0, r1 - r0); t0 = t1 = t; return; } else if (r0 >= 0.0 && r1 <= 0.0) { // Inside to Outside +- r1 = -r1; // make positive - t = AngleForRoundedCorners0(x1 - x0, y1 - y0, r1 + r0); + t = angleForRoundedCorners0(x1 - x0, y1 - y0, r1 + r0); t0 = 180.0 + t; if (t0 < 0.0) { t += 360.; @@ -1075,7 +1075,7 @@ void V11Geometry::AnglesForRoundedCorners(Double_t x0, Double_t y0, Double_t r0, return; } else if (r0 <= 0.0 && r1 >= 0.0) { // Outside to Inside -+ r0 = -r0; // make positive - t = AngleForRoundedCorners1(x1 - x0, y1 - y0, r1 + r0); + t = angleForRoundedCorners1(x1 - x0, y1 - y0, r1 + r0); t0 = 180.0 + t; if (t0 > 180.) { t0 -= 360.; @@ -1088,14 +1088,14 @@ void V11Geometry::AnglesForRoundedCorners(Double_t x0, Double_t y0, Double_t r0, } else if (r0 <= 0.0 && r1 <= 0.0) { // Outside to outside -- r0 = -r0; // make positive r1 = -r1; // make positive - t = AngleForRoundedCorners0(x1 - x0, y1 - y0, r1 - r0); + t = angleForRoundedCorners0(x1 - x0, y1 - y0, r1 - r0); t0 = t1 = t; return; } return; } -void V11Geometry::MakeFigure1(Double_t x0, Double_t y0, Double_t r0, Double_t x1, Double_t y1, +void V11Geometry::makeFigure1(Double_t x0, Double_t y0, Double_t r0, Double_t x1, Double_t y1, Double_t r1) { Double_t t0[4], t1[4], xa0[4], ya0[4], xa1[4], ya1[4], ra0[4], ra1[4]; @@ -1111,11 +1111,11 @@ void V11Geometry::MakeFigure1(Double_t x0, Double_t y0, Double_t r0, Double_t x1 if (j > 1) { ra1[j] = -r1; } - AnglesForRoundedCorners(x0, y0, ra0[j], x1, y1, ra1[j], t0[j], t1[j]); - xa0[j] = TMath::Abs(r0) * CosD(t0[j]) + x0; - ya0[j] = TMath::Abs(r0) * SinD(t0[j]) + y0; - xa1[j] = TMath::Abs(r1) * CosD(t1[j]) + x1; - ya1[j] = TMath::Abs(r1) * SinD(t1[j]) + y1; + anglesForRoundedCorners(x0, y0, ra0[j], x1, y1, ra1[j], t0[j], t1[j]); + xa0[j] = TMath::Abs(r0) * cosD(t0[j]) + x0; + ya0[j] = TMath::Abs(r0) * sinD(t0[j]) + y0; + xa1[j] = TMath::Abs(r1) * cosD(t1[j]) + x1; + ya1[j] = TMath::Abs(r1) * sinD(t1[j]) + y1; } if (r0 < 0.0) { r0 = -r0; diff --git a/its/V11Geometry.h b/its/V11Geometry.h index f8358921664e8..721ac8deb4d69 100644 --- a/its/V11Geometry.h +++ b/its/V11Geometry.h @@ -32,19 +32,19 @@ class V11Geometry : public TObject { virtual ~V11Geometry() {}; /// Sets the debug flag for debugging output - void SetDebug(Int_t level = 5) + void setDebug(Int_t level = 5) { mDebug = level; } /// Clears the debug flag so no debugging output will be generated - void SetNoDebug() + void setNoDebug() { mDebug = 0; } /// Returns the debug flag value - Bool_t GetDebug(Int_t level = 1) const + Bool_t getDebug(Int_t level = 1) const { return mDebug >= level; } @@ -53,19 +53,19 @@ class V11Geometry : public TObject { /// Define Trig functions for use with degrees (standerd TGeo angles). /// Sine function - Double_t SinD(Double_t deg) const + Double_t sinD(Double_t deg) const { return TMath::Sin(deg * TMath::DegToRad()); } /// Cosine function - Double_t CosD(Double_t deg) const + Double_t cosD(Double_t deg) const { return TMath::Cos(deg * TMath::DegToRad()); } /// Tangent function - Double_t TanD(Double_t deg) const + Double_t tanD(Double_t deg) const { return TMath::Tan(deg * TMath::DegToRad()); } @@ -79,8 +79,8 @@ class V11Geometry : public TObject { /// \param Double_t n The slope of the second line /// \param Double_t x1,y1 The x and y coord. of the second point /// As an output it gives the coordinates xi and yi of the intersection point - void IntersectLines(Double_t m, Double_t x0, Double_t y0, Double_t n, Double_t x1, Double_t y1, - Double_t& xi, Double_t& yi) const; + void intersectLines(Double_t m, Double_t x0, Double_t y0, Double_t n, Double_t x1, Double_t y1, Double_t& xi, + Double_t& yi) const; /// Determine the intersection of a line and a circle /// Given a line passing by (x0,y0) with slope m and a circle with @@ -92,9 +92,8 @@ class V11Geometry : public TObject { /// \param Double_t xc,yc The x and y coord. of the center of circle /// As an output it gives the coordinates xi and yi of the intersection points /// Returns kFALSE if the line does not intercept the circle, otherwise kTRUE - static Bool_t IntersectCircle(Double_t m, Double_t x0, Double_t y0, Double_t rr, Double_t xc, - Double_t yc, Double_t& xi1, Double_t& yi1, Double_t& xi2, - Double_t& yi2); + static Bool_t intersectCircle(Double_t m, Double_t x0, Double_t y0, Double_t rr, Double_t xc, Double_t yc, + Double_t& xi1, Double_t& yi1, Double_t& xi2, Double_t& yi2); /// Given the two points (x0,y0) and (x1,y1) and the location x, returns /// the value y corresponding to that point x on the line defined by the @@ -105,7 +104,7 @@ class V11Geometry : public TObject { /// \param Double_t x1 The second x value defining the line /// \param Double_t y1 The second y value defining the line /// \param Double_t x The x value for which the y value is wanted. - Double_t Yfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x) const; + Double_t yFrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x) const; /// Given the two points (x0,y0) and (x1,y1) and the location y, returns /// the value x corresponding to that point y on the line defined by the @@ -116,7 +115,7 @@ class V11Geometry : public TObject { /// \param Double_t x1 The second x value defining the line /// \param Double_t y1 The second y value defining the line /// \param Double_t y The y value for which the x value is wanted. - Double_t Xfrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t y) const; + Double_t xFrom2Points(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t y) const; /// Functions require at parts of Volume A to be already defined. /// Returns the value of Rmax corresponding to point z alone the line @@ -127,7 +126,7 @@ class V11Geometry : public TObject { /// \param Int_t i2 Point 2 /// \param Double_t z The value of z for which Rmax is to be found /// \param Double_t Rmx the value corresponding to z - Double_t RmaxFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const; + Double_t rMaxFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const; /// Returns the value of Rmin corresponding to point z alone the line /// defined by the two points p->GetRmin(i1),p->GetZ(i1) and @@ -137,7 +136,7 @@ class V11Geometry : public TObject { /// \param Int_t i2 Point 2 /// \param Double_t z The value of z for which Rmax is to be found /// \param Double_t Rmx the value corresponding to z - Double_t RminFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const; + Double_t rMinFrom2Points(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t z) const; /// Returns the value of Rmin corresponding to point z alone the line /// defined by the two points p->GetRmin(i1),p->GetZ(i1) and @@ -148,8 +147,7 @@ class V11Geometry : public TObject { /// \param Int_t i1 First Point in arrays /// \param Int_t i2 Second Point in arrays /// \param Double_t z Value z at which r is to be found - Double_t RFrom2Points(const Double_t* ar, const Double_t* az, Int_t i1, Int_t i2, - Double_t z) const; + Double_t rFrom2Points(const Double_t* ar, const Double_t* az, Int_t i1, Int_t i2, Double_t z) const; /// Returns the value of Z corresponding to point R alone the line /// defined by the two points p->GetRmin(i1),p->GetZ(i1) and @@ -159,7 +157,7 @@ class V11Geometry : public TObject { /// \param Int_t i1 First Point in arrays /// \param Int_t i2 Second Point in arrays /// \param Double_t r Value r min at which z is to be found - Double_t Zfrom2MinPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const; + Double_t zFrom2MinPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const; /// Returns the value of Z corresponding to point R alone the line /// defined by the two points p->GetRmax(i1),p->GetZ(i1) and @@ -169,7 +167,7 @@ class V11Geometry : public TObject { /// \param Int_t i1 First Point in arrays /// \param Int_t i2 Second Point in arrays /// \param Double_t r Value r max at which z is to be found - Double_t Zfrom2MaxPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const; + Double_t zFrom2MaxPoints(const TGeoPcon* p, Int_t i1, Int_t i2, Double_t r) const; /// Returns the value of z corresponding to point R alone the line /// defined by the two points p->GetRmax(i1),p->GetZ(i1) and @@ -180,8 +178,7 @@ class V11Geometry : public TObject { /// \param Int_t i1 First Point in arrays /// \param Int_t i2 Second Point in arrays /// \param Double_t r Value r at which z is to be found - Double_t Zfrom2Points(const Double_t* az, const Double_t* ar, Int_t i1, Int_t i2, - Double_t r) const; + Double_t zFrom2Points(const Double_t* az, const Double_t* ar, Int_t i1, Int_t i2, Double_t r) const; /// General Outer Cone surface equation Rmax /// Given 1 point from a TGeoPcon(z and Rmax) the angle tc returns r for @@ -193,8 +190,7 @@ class V11Geometry : public TObject { /// \param Double_t tc The angle of that part of the cone is at /// \param Double_t z The value of z to compute Rmax from /// \param Double_t th The perpendicular distance the parralell line is from the point ip - Double_t RmaxFromZpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t z, - Double_t th = 0.0) const; + Double_t rMaxFromZpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t z, Double_t th = 0.0) const; // General Cone surface equation R(z). Returns the value R correstponding to the line at // angle th, offset by th, and the point p->GetZ/Rmax[ip] at the location z. @@ -204,7 +200,7 @@ class V11Geometry : public TObject { // \param Double_t tc The angle of that part of the cone is at // \param Double_t z The value of z to compute R from // \param Double_t th The perpendicular distance the parralell line is from the point ip - Double_t RFromZpCone(const Double_t* ar, const Double_t* az, int ip, Double_t tc, Double_t z, + Double_t rFromZpCone(const Double_t* ar, const Double_t* az, int ip, Double_t tc, Double_t z, Double_t th = 0.0) const; /// General Inner Cone surface equation Rmin. @@ -217,8 +213,7 @@ class V11Geometry : public TObject { /// \param Double_t tc The angle of that part of the cone is at /// \param Double_t z The value of z to compute Rmin from /// \param Double_t th The perpendicular distance the parralell line is from the point ip - Double_t RminFromZpCone(const TGeoPcon* p, Int_t ip, Double_t tc, Double_t z, - Double_t th = 0.0) const; + Double_t rMinFromZpCone(const TGeoPcon* p, Int_t ip, Double_t tc, Double_t z, Double_t th = 0.0) const; /// General Outer cone Surface equation for z. /// Given 1 point from a TGeoPcon(z and Rmax) the angle tc returns z for @@ -230,8 +225,7 @@ class V11Geometry : public TObject { /// \param Double_t tc The angle of that part of the cone is at /// \param Double_t r The value of Rmax to compute z from /// \param Double_t th The perpendicular distance the parralell line is from the point ip - Double_t ZFromRmaxpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, - Double_t th = 0.0) const; + Double_t zFromRMaxpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, Double_t th = 0.0) const; /// General Outer cone Surface equation for z. /// Returns the value Z correstponding to the line at angle th, offeset by @@ -242,7 +236,7 @@ class V11Geometry : public TObject { /// \param Double_t tc The angle of that part of the cone is at /// \param Double_t r The value of Rmax to compute z from /// \param Double_t th The perpendicular distance the parralell line is from the point ip - Double_t ZFromRmaxpCone(const Double_t* ar, const Double_t* az, Int_t ip, Double_t tc, Double_t r, + Double_t zFromRMaxpCone(const Double_t* ar, const Double_t* az, Int_t ip, Double_t tc, Double_t r, Double_t th = 0.0) const; /// General Inner cone Surface equation for z. @@ -255,8 +249,7 @@ class V11Geometry : public TObject { /// \param Double_t tc The angle of that part of the cone is at /// \param Double_t r The value of Rmin to compute z from /// \param Double_t th The perpendicular distance the parralell line is from the point ip - Double_t ZFromRminpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, - Double_t th = 0.0) const; + Double_t zFromRMinpCone(const TGeoPcon* p, int ip, Double_t tc, Double_t r, Double_t th = 0.0) const; /// Given two lines defined by the points i1, i2,i3 in the TGeoPcon /// class p that intersect at point p->GetZ(i2) return the point z,r @@ -275,8 +268,8 @@ class V11Geometry : public TObject { /// \param Int_t j1 Point in class q where data is to be stored. /// \param Bool_t ma if kTRUE, then a Rmax value is computed, else a Rmin valule is computed /// \param TGeoPcon *q Pointer to class for results to be put into. - void InsidePoint(const TGeoPcon* p, Int_t i1, Int_t i2, Int_t i3, Double_t Cthick, TGeoPcon* q, - Int_t j1, Bool_t max) const; + void insidePoint(const TGeoPcon* p, Int_t i1, Int_t i2, Int_t i3, Double_t Cthick, TGeoPcon* q, Int_t j1, + Bool_t max) const; /// Given two intersecting lines defined by the points (x0,y0), (x1,y1) and /// (x1,y1), (x2,y2) {intersecting at (x1,y1)} the point (x,y) a distance @@ -291,8 +284,8 @@ class V11Geometry : public TObject { /// \param Double_t c Distance the two sets of lines are from each other /// \param Double_t x X point for the intersecting sets of parellel lines /// \param Double_t y Y point for the intersecting sets of parellel lines - void InsidePoint(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x2, Double_t y2, - Double_t c, Double_t& x, Double_t& y) const; + void insidePoint(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t c, + Double_t& x, Double_t& y) const; /// Given an initial point z0,r0, the initial angle theta0, and the radius /// of curvature, returns the point z1, r1 at the angle theta1. Theta @@ -304,34 +297,34 @@ class V11Geometry : public TObject { /// \param Double_t theta1 The ending angle (degrees) /// \param Double_t &z1 The value of z at theta1 /// \param Double_t &r1 The value of r at theta1 - void RadiusOfCurvature(Double_t rc, Double_t theta0, Double_t z0, Double_t r0, Double_t theta1, - Double_t& z1, Double_t& r1) const; + void radiusOfCurvature(Double_t rc, Double_t theta0, Double_t z0, Double_t r0, Double_t theta1, Double_t& z1, + Double_t& r1) const; // Output functions for debugging /// Prints out the content of the TGeoArb8 /// \param TGeoArb8 *a - void PrintArb8(const TGeoArb8* a) const; + void printArb8(const TGeoArb8* a) const; /// Prints out the contents of the TGeoPcon /// \param TGeoPcon *a - void PrintPcon(const TGeoPcon* a) const; + void printPcon(const TGeoPcon* a) const; /// Prints out the contents of the TGeoTube /// \param TGeoTube *a - void PrintTube(const TGeoTube* a) const; + void printTube(const TGeoTube* a) const; /// Prints out the contents of the TGeoTubeSeg /// \param TGeoTubeSeg *a - void PrintTubeSeg(const TGeoTubeSeg* a) const; + void printTubeSeg(const TGeoTubeSeg* a) const; /// Prints out the contents of the TGeoConeSeg /// \param TGeoConeSeg *a - void PrintConeSeg(const TGeoConeSeg* a) const; + void printConeSeg(const TGeoConeSeg* a) const; /// Prints out the contents of the TGeoBBox /// \param TGeoBBox *a - void PrintBBox(const TGeoBBox* a) const; + void printBBox(const TGeoBBox* a) const; /// Draws a cross sectional view of the TGeoPcon, Primarily for debugging. /// A TCanvas should exist first. @@ -344,9 +337,8 @@ class V11Geometry : public TObject { /// \param Int_t markc The markder color to be used /// \param Int_t marks The markder style to be used /// \param Float_t marksize The marker size - void DrawCrossSection(const TGeoPcon* p, Int_t fillc = 7, Int_t fills = 4050, Int_t linec = 3, - Int_t lines = 1, Int_t linew = 4, Int_t markc = 2, Int_t marks = 4, - Float_t marksize = 1.0) const; + void drawCrossSection(const TGeoPcon* p, Int_t fillc = 7, Int_t fills = 4050, Int_t linec = 3, Int_t lines = 1, + Int_t linew = 4, Int_t markc = 2, Int_t marks = 4, Float_t marksize = 1.0) const; /// Computes the angles, t0 and t1 corresponding to the intersection of /// the line, defined by {x0,y0} {x1,y1}, and the circle, defined by @@ -364,9 +356,8 @@ class V11Geometry : public TObject { /// \param Double_t r radius of circle /// \param Double_t &t0 First angle where line intersects circle /// \param Double_t &t1 Second angle where line intersects circle - Bool_t AngleOfIntersectionWithLine(Double_t x0, Double_t y0, Double_t x1, Double_t y1, - Double_t xc, Double_t yc, Double_t rc, Double_t& t0, - Double_t& t1) const; + Bool_t angleOfIntersectionWithLine(Double_t x0, Double_t y0, Double_t x1, Double_t y1, Double_t xc, Double_t yc, + Double_t rc, Double_t& t0, Double_t& t1) const; /// Function to compute the ending angle, for arc 0, and starting angle, /// for arc 1, such that a straight line will connect them with no discontinuities. @@ -383,29 +374,29 @@ class V11Geometry : public TObject { /// \param Double_t r1 Radius of curvature of arc 1. For signe see figure. /// \param Double_t t0 Ending angle of arch 0, with respect to x axis, Degrees. /// \param Double_t t1 Starting angle of arch 1, with respect to x axis, Degrees. - void AnglesForRoundedCorners(Double_t x0, Double_t y0, Double_t r0, Double_t x1, Double_t y1, - Double_t r1, Double_t& t0, Double_t& t1) const; + void anglesForRoundedCorners(Double_t x0, Double_t y0, Double_t r0, Double_t x1, Double_t y1, Double_t r1, + Double_t& t0, Double_t& t1) const; - /// Define a general CreateMaterials function here so that if + /// Define a general createMaterials function here so that if /// any specific subdetector does not define it this null function /// will due. This function is not declaired const so that a sub- /// detector's version may use class variables if they wish. /// Defined media here should correspond to the one defined in galice.cuts /// File which is red in (AliMC*) fMCApp::Init() { ReadTransPar(); } - void CreateDefaultMaterials(); + void createDefaultMaterials(); - virtual void CreateMaterials() {}; + virtual void createMaterials() {}; /// Function to create the figure describing how the function - /// AnglesForRoundedCorners works. + /// anglesForRoundedCorners works. /// \param Double_t x0 X Coordinate of arc 0 center. /// \param Double_t y0 Y Coordinate of arc 0 center. /// \param Double_t r0 Radius of curvature of arc 0. For signe see figure. /// \param Double_t x1 X Coordinate of arc 1 center. /// \param Double_t y1 Y Coordinate of arc 1 center. /// \param Double_t r1 Radius of curvature of arc 1. For signe see figure. - void MakeFigure1(Double_t x0 = 0.0, Double_t y0 = 0.0, Double_t r0 = 2.0, Double_t x1 = -4.0, - Double_t y1 = -2.0, Double_t r1 = 1.0); + void makeFigure1(Double_t x0 = 0.0, Double_t y0 = 0.0, Double_t r0 = 2.0, Double_t x1 = -4.0, Double_t y1 = -2.0, + Double_t r1 = 1.0); protected: // Units, Convert from k?? to cm,degree,GeV,seconds, @@ -432,7 +423,7 @@ class V11Geometry : public TObject { /// \param Double_t dx difference in x locations of the circle centers /// \param Double_t dy difference in y locations of the circle centers /// \param Double_t sdr difference or sum of the circle radii - Double_t AngleForRoundedCorners0(Double_t dx, Double_t dy, Double_t sdr) const; + Double_t angleForRoundedCorners0(Double_t dx, Double_t dy, Double_t sdr) const; /// Basic function used to determine the ending angle and starting angles /// for rounded corners given the relative distance between the centers @@ -440,9 +431,9 @@ class V11Geometry : public TObject { /// \param Double_t dx difference in x locations of the circle centers /// \param Double_t dy difference in y locations of the circle centers /// \param Double_t sdr difference or sum of the circle radii - Double_t AngleForRoundedCorners1(Double_t dx, Double_t dy, Double_t sdr) const; + Double_t angleForRoundedCorners1(Double_t dx, Double_t dy, Double_t sdr) const; - Int_t mDebug; ///< Debug flag/level + Int_t mDebug; //! Debug flag/level ClassDef(V11Geometry, 1) // Base class for ITS v11 geometry }; } diff --git a/its/itsLinkDef.h b/its/itsLinkDef.h index 47e99cac4a9ce..2585fd1632848 100644 --- a/its/itsLinkDef.h +++ b/its/itsLinkDef.h @@ -4,16 +4,16 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class AliceO2::ITS::UpgradeGeometryTGeo + ; -#pragma link C++ class AliceO2::ITS::V11Geometry + ; -#pragma link C++ class AliceO2::ITS::UpgradeV1Layer + ; -#pragma link C++ class AliceO2::ITS::Segmentation + ; -#pragma link C++ class AliceO2::ITS::UpgradeSegmentationPixel + ; -#pragma link C++ class AliceO2::ITS::GeometryManager + ; -#pragma link C++ class AliceO2::ITS::Detector + ; +#pragma link C++ class AliceO2::ITS::UpgradeGeometryTGeo+; +#pragma link C++ class AliceO2::ITS::V11Geometry+; +#pragma link C++ class AliceO2::ITS::UpgradeV1Layer+; +#pragma link C++ class AliceO2::ITS::Segmentation+; +#pragma link C++ class AliceO2::ITS::UpgradeSegmentationPixel+; +#pragma link C++ class AliceO2::ITS::GeometryManager+; +#pragma link C++ class AliceO2::ITS::Detector+; #pragma link C++ class AliceO2::ITS::ContainerFactory; -#pragma link C++ class AliceO2::ITS::GeometryHandler + ; -#pragma link C++ class AliceO2::ITS::MisalignmentParameter + ; -#pragma link C++ class AliceO2::ITS::Point + ; +#pragma link C++ class AliceO2::ITS::GeometryHandler+; +#pragma link C++ class AliceO2::ITS::MisalignmentParameter+; +#pragma link C++ class AliceO2::ITS::Point+; #endif diff --git a/macro/run_sim.C b/macro/run_sim.C index 879104316d531..b6cae21482132 100644 --- a/macro/run_sim.C +++ b/macro/run_sim.C @@ -46,6 +46,8 @@ void run_sim(Int_t nEvents = 10, TString mcEngine = "TGeant3") // tpc->SetGeometry(); // run->AddModule(tpc); + TGeoGlobalMagField::Instance()->SetField(new AliceO2::Field::MagneticField("Maps","Maps", -1., -1., AliceO2::Field::MagneticField::k5kG)); + AliceO2::Base::Detector* its = new AliceO2::ITS::Detector("ITS", kTRUE, 7); run->AddModule(its); @@ -100,24 +102,24 @@ void run_sim(Int_t nEvents = 10, TString mcEngine = "TGeant3") kGuardRing, // top kReadOutEdge // bottom ); // see UpgradeSegmentationPixel.h for extra options - seg0->Store(AliceO2::ITS::UpgradeGeometryTGeo::GetITSsegmentationFileName()); + seg0->Store(AliceO2::ITS::UpgradeGeometryTGeo::getITSsegmentationFileName()); seg0->Print(); double dzLr, rLr, phi0, turbo; int nStaveLr, nModPerStaveLr, idLr; - its->SetStaveModelIB(AliceO2::ITS::Detector::kIBModel22); - its->SetStaveModelOB(AliceO2::ITS::Detector::kOBModel1); + its->setStaveModelIB(AliceO2::ITS::Detector::kIBModel22); + its->setStaveModelOB(AliceO2::ITS::Detector::kOBModel1); const int kNWrapVol = 3; const double wrpRMin[kNWrapVol] = { 2.1, 15.0, 32.0 }; const double wrpRMax[kNWrapVol] = { 7.0, 27.0 + 2.5, 43.0 + 1.5 }; const double wrpZSpan[kNWrapVol] = { 28.0, 86.0, 150.0 }; - its->SetNumberOfWrapperVolumes(kNWrapVol); // define wrapper volumes for layers + its->setNumberOfWrapperVolumes(kNWrapVol); // define wrapper volumes for layers for (int iw = 0; iw < kNWrapVol; iw++) { - its->DefineWrapperVolume(iw, wrpRMin[iw], wrpRMax[iw], wrpZSpan[iw]); + its->defineWrapperVolume(iw, wrpRMin[iw], wrpRMax[iw], wrpZSpan[iw]); } for (int idLr = 0; idLr < kNLr; idLr++) { @@ -129,15 +131,15 @@ void run_sim(Int_t nEvents = 10, TString mcEngine = "TGeant3") int nChipsPerStaveLr = nModPerStaveLr; if (idLr >= kNLrInner) { nChipsPerStaveLr *= nChipsPerModule; - its->DefineLayer(idLr, phi0, rLr, nChipsPerStaveLr * seg0->Dz(), nStaveLr, nModPerStaveLr, - kSiThickOB, seg0->Dy(), seg0->GetChipTypeID(), kBuildLevel); + its->defineLayer(idLr, phi0, rLr, nChipsPerStaveLr * seg0->Dz(), nStaveLr, nModPerStaveLr, + kSiThickOB, seg0->Dy(), seg0->getChipTypeID(), kBuildLevel); // printf("Add Lr%d: R=%6.2f DZ:%6.2f Staves:%3d NMod/Stave:%3d\n", // idLr,rLr,nChipsPerStaveLr*seg0->Dz(),nStaveLr,nModPerStaveLr); } else { turbo = -radii2Turbo(tdr5dat[idLr][kRmn], rLr, tdr5dat[idLr][kRmx], seg0->Dx()); - its->DefineLayerTurbo(idLr, phi0, rLr, nChipsPerStaveLr * seg0->Dz(), nStaveLr, + its->defineLayerTurbo(idLr, phi0, rLr, nChipsPerStaveLr * seg0->Dz(), nStaveLr, nChipsPerStaveLr, seg0->Dx(), turbo, kSiThickIB, seg0->Dy(), - seg0->GetChipTypeID(), kBuildLevel); + seg0->getChipTypeID(), kBuildLevel); // printf("Add Lr%d: R=%6.2f DZ:%6.2f Turbo:%+6.2f Staves:%3d NMod/Stave:%3d\n", // idLr,rLr,nChipsPerStaveLr*seg0->Dz(),turbo,nStaveLr,nModPerStaveLr); }