From 50f5a404c88c62f229afe2c953461adbfaeb677a Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Wed, 27 Nov 2024 12:19:09 +0100 Subject: [PATCH 01/12] det(must): Add first version of the MUST detector The commit does not changes anything in the build process of cbmroot. It only introduces first version of the MUST detector directories to: 'core/data', 'core/detectors', 'sim/detectors' and 'macro'. --- core/data/must/CbmMustHit.cxx | 46 + core/data/must/CbmMustHit.h | 131 ++ core/data/must/CbmMustPoint.cxx | 72 ++ core/data/must/CbmMustPoint.h | 137 +++ core/detectors/must/CMakeLists.txt | 46 + core/detectors/must/CbmGeoMust.cxx | 45 + core/detectors/must/CbmGeoMust.h | 41 + core/detectors/must/CbmGeoMustPar.cxx | 70 ++ core/detectors/must/CbmGeoMustPar.h | 53 + core/detectors/must/CbmMustBaseLinkDef.h | 18 + core/detectors/must/CbmMustContFact.cxx | 61 + core/detectors/must/CbmMustContFact.h | 35 + core/detectors/must/CbmMustMapCreator.cxx | 426 +++++++ core/detectors/must/CbmMustMapCreator.h | 79 ++ core/detectors/must/CbmMustSingleStraw.cxx | 1287 ++++++++++++++++++++ core/detectors/must/CbmMustSingleStraw.h | 281 +++++ core/detectors/must/CbmMustTube.cxx | 93 ++ core/detectors/must/CbmMustTube.h | 49 + macro/must/run_sim.C | 135 ++ sim/detectors/must/CMakeLists.txt | 35 + sim/detectors/must/CbmMust.cxx | 405 ++++++ sim/detectors/must/CbmMust.h | 186 +++ sim/detectors/must/CbmMustSimLinkDef.h | 13 + 23 files changed, 3744 insertions(+) create mode 100644 core/data/must/CbmMustHit.cxx create mode 100644 core/data/must/CbmMustHit.h create mode 100644 core/data/must/CbmMustPoint.cxx create mode 100644 core/data/must/CbmMustPoint.h create mode 100644 core/detectors/must/CMakeLists.txt create mode 100644 core/detectors/must/CbmGeoMust.cxx create mode 100644 core/detectors/must/CbmGeoMust.h create mode 100644 core/detectors/must/CbmGeoMustPar.cxx create mode 100644 core/detectors/must/CbmGeoMustPar.h create mode 100644 core/detectors/must/CbmMustBaseLinkDef.h create mode 100644 core/detectors/must/CbmMustContFact.cxx create mode 100644 core/detectors/must/CbmMustContFact.h create mode 100644 core/detectors/must/CbmMustMapCreator.cxx create mode 100644 core/detectors/must/CbmMustMapCreator.h create mode 100644 core/detectors/must/CbmMustSingleStraw.cxx create mode 100644 core/detectors/must/CbmMustSingleStraw.h create mode 100644 core/detectors/must/CbmMustTube.cxx create mode 100644 core/detectors/must/CbmMustTube.h create mode 100644 macro/must/run_sim.C create mode 100644 sim/detectors/must/CMakeLists.txt create mode 100644 sim/detectors/must/CbmMust.cxx create mode 100644 sim/detectors/must/CbmMust.h create mode 100644 sim/detectors/must/CbmMustSimLinkDef.h diff --git a/core/data/must/CbmMustHit.cxx b/core/data/must/CbmMustHit.cxx new file mode 100644 index 0000000000..e4dc864620 --- /dev/null +++ b/core/data/must/CbmMustHit.cxx @@ -0,0 +1,46 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustHit source file ----- +// ----- Created 2024-11-26 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +#include "CbmMustHit.h" + +#include "CbmDefs.h" + +#include <iostream> +#include "TMath.h" +/** Default constructor **/ +CbmMustHit::CbmMustHit() : fIsochrone(0.), fIsochroneError(0.), fPulse(0.), fDepCharge(0.), fTubeID(0), fChamberID(0), fLayerID(0), fSkewed(0) +{ + // ClearHit(); +} + +CbmMustHit::CbmMustHit(Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, Int_t skew, Int_t mcindex, TVector3 &pos, TVector3 &dpos, Double_t p, Double_t isochrone, + Double_t isochroneError, Double_t chDep) + : FairHit(detID, pos, dpos, mcindex), fIsochrone(isochrone), fIsochroneError(isochroneError), fPulse(p), fDepCharge(chDep), fTubeID(tubeID), fChamberID(chamberID), + fLayerID(layerID), fSkewed(skew) +{ + SetTimeStamp(p); +} + +/** Public method ClearHit **/ +void CbmMustHit::ClearHit() +{ + fTubeID = 0; + fChamberID = 0; + fLayerID = 0; + fSkewed = 0; + fPulse = 0; + fIsochrone = 0.; + fIsochroneError = 0.; + fDepCharge = 0.; +} + +/** Destructor **/ +CbmMustHit::~CbmMustHit() {} + +ClassImp(CbmMustHit) diff --git a/core/data/must/CbmMustHit.h b/core/data/must/CbmMustHit.h new file mode 100644 index 0000000000..161fe35f8a --- /dev/null +++ b/core/data/must/CbmMustHit.h @@ -0,0 +1,131 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustHit header file ----- +// ----- Created 2024-11-26 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +/** + ** + ** Meaning of RefIndex: Index of corresponding MCPoint + ** -1 if fake or background hit + ** + ** Meaning of Flag: 0 = Hit ok + ** -1 : Hit lost due to detection inefficiency + **/ + +#ifndef CBMMUSTHIT_H +#define CBMMUSTHIT_H 1 + +#include "TVector3.h" +#include "FairHit.h" + +class CbmMustHit : public FairHit { + + public: + /** Default constructor **/ + CbmMustHit(); + + /** Standard constructor + *@param detID Detector unique volume ID + *@param tubeID Unique tube ID + *@param chamberID Unique chamber ID + *@param layerID Unique layer ID + *@param skew flag for skewed tube + *@param mcindex Index of corresponding MCPoint + *@param pos Position coordinates of the tube [cm] + *@param dpos Errors in position coordinates [cm] + *@param isochrone The radial measurement + *@param isoerror The erroon on the radial measurement + *@param chDep Deposited charge (arbitrary unit) + **/ + + // THIS ONE! + CbmMustHit(Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, Int_t skew, Int_t mcindex, TVector3 &pos, TVector3 &dpos, Double_t p, Double_t isochrone, + Double_t isochroneError, Double_t chDep); + + /** Destructor **/ + virtual ~CbmMustHit(); + + /** Output to screen (not yet implemented) **/ + virtual void Print(const Option_t *opt = nullptr) const + { + std::cout << " opt = " << opt << std::endl; + return; + } + + /** Public method ClearHit + ** Resets the isochrone and it's error to 0 + **/ + void ClearHit(); + + /** Accessors **/ + Double_t GetIsochrone() const { return fIsochrone; }; + Double_t GetIsochroneError() const { return fIsochroneError; }; + Double_t GetPulse() const { return fPulse; }; + Double_t GetDepCharge() const { return fDepCharge; }; + Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; + + /** Modifiers **/ + void SetIsochrone(Double_t isochrone) { fIsochrone = isochrone; }; + void SetIsochroneError(Double_t isochroneError) { fIsochroneError = isochroneError; }; + void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } + + // tube ID // CHECK added + void SetTubeID(Int_t tubeid) { fTubeID = tubeid; } + Int_t GetTubeID() const { return fTubeID; } + void SetChamberID(Int_t chamberid) { fChamberID = chamberid; } + Int_t GetChamberID() const { return fChamberID; } + void SetLayerID(Int_t layerid) { fLayerID = layerid; } + Int_t GetLayerID() const { return fLayerID; } + Int_t GetSkewed() const { return fSkewed; } + + virtual bool equal(FairTimeStamp *data) + { + CbmMustHit *myDigi = dynamic_cast<CbmMustHit *>(data); + if (myDigi != nullptr) { + if (fTubeID == myDigi->GetTubeID()) + return true; + } + return false; + } + + virtual bool operator<(const CbmMustHit &myDigi) const + { + if (fTubeID < myDigi.GetTubeID()) + return true; + else + return false; + } + + friend std::ostream &operator<<(std::ostream &out, CbmMustHit &digi) + { + out << "CbmSttHit in Tube: " << digi.GetTubeID() << " Isochrone: " << digi.GetIsochrone() << " +/- " << digi.GetIsochroneError() << " Charge: " << digi.GetDepCharge() + << " Pulse: " << digi.GetPulse() << std::endl; + return out; + } + + protected: + /** This variable contains the radial distance to the wire **/ + Double_t fIsochrone; + /** This variable contains the error on the radial distance to the wire **/ + Double_t fIsochroneError; + + /** time pulse **/ + Double_t fPulse; + + /** deposit charge (arbitrary units) **/ + Double_t fDepCharge; + + /** tube id **/ + Int_t fTubeID; // CHECK added + Int_t fChamberID; + Int_t fLayerID; + Int_t fSkewed; + + ClassDef(CbmMustHit, 1); +}; + +#endif diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx new file mode 100644 index 0000000000..23c3304237 --- /dev/null +++ b/core/data/must/CbmMustPoint.cxx @@ -0,0 +1,72 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustPoint source file ----- +// ----- Created 2024-11-26 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +#include "CbmMustPoint.h" + +#include "CbmDefs.h" // for kMCTrack + +#include <FairLink.h> // for FairLink +#include <FairMCPoint.h> // for FairMCPoint + +#include <iostream> +#include "math.h" +#include "FairLogger.h" +using std::cout; +using std::endl; + +// ----- Default constructor ------------------------------------------- +CbmMustPoint::CbmMustPoint() + : FairMCPoint(), fX_out_local(0), fY_out_local(0), fZ_out_local(0), fX_in_local(0.), fY_in_local(0), fZ_in_local(0), fPx_out(0), fPy_out(0), fPz_out(0), fPx_in(0), fPy_in(0), + fPz_in(0), fMass(0), fTubeID(0), fChamberID(0), fLayerID(0) +{ +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, + TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass) + : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss), fX_out_local(posOutLocal.X()), fY_out_local(posOutLocal.Y()), fZ_out_local(posOutLocal.Z()), + fX_in_local(posInLocal.X()), fY_in_local(posInLocal.Y()), fZ_in_local(posInLocal.Z()), fPx_out(momOut.Px()), fPy_out(momOut.Py()), fPz_out(momOut.Pz()), fPx_in(momIn.Px()), + fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fTubeID(tubeID), fChamberID(chamberID), fLayerID(layerID) +{ + // reset MC momentum + fPx = (momIn.Px() + momOut.Px()) / 2.; + fPy = (momIn.Py() + momOut.Py()) / 2.; + fPz = (momIn.Pz() + momOut.Pz()) / 2.; + SetLink(FairLink(ToIntegralType(ECbmDataType::kMCTrack), trackID)); +} +// ------------------------------------------------------------------------- + +// ----- Destructor ---------------------------------------------------- +CbmMustPoint::~CbmMustPoint() {} +// ------------------------------------------------------------------------- + +// ----- Copy constructor ------------------------------------------ +CbmMustPoint::CbmMustPoint(const CbmMustPoint &point) + : FairMCPoint(point.fTrackID, point.fDetectorID, TVector3(point.fX, point.fY, point.fZ), TVector3(point.fPx, point.fPy, point.fPz), point.fTime, point.fLength, point.fELoss, + point.fEventId), + fX_out_local(point.fX_out_local), fY_out_local(point.fY_out_local), fZ_out_local(point.fZ_out_local), fX_in_local(point.fX_in_local), fY_in_local(point.fY_in_local), + fZ_in_local(point.fZ_in_local), fPx_out(point.fPx_out), fPy_out(point.fPy_out), fPz_out(point.fPz_out), fPx_in(point.fPx_in), fPy_in(point.fPy_in), fPz_in(point.fPz_in), + fMass(point.fMass), fTubeID(point.fTubeID), fChamberID(point.fChamberID), fLayerID(point.fLayerID) +{ +} +// ------------------------------------------------------------------------- + +// ----- Public method Print ------------------------------------------- +void CbmMustPoint::Print(const Option_t *opt) const +{ + LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in detector " << fDetectorID; + cout << " Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl; + cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl; + cout << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" + << " opt=" << opt << endl; +} +// ------------------------------------------------------------------------- + +ClassImp(CbmMustPoint) diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h new file mode 100644 index 0000000000..9c7d8deeea --- /dev/null +++ b/core/data/must/CbmMustPoint.h @@ -0,0 +1,137 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustPoint header file ----- +// ----- Created 2024-11-26 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +#ifndef CBMMUSTPOINT_H +#define CBMMUSTPOINT_H + +#include "TObject.h" +#include "TVector3.h" +#include "FairMCPoint.h" + +class CbmMustPoint : public FairMCPoint { + + public: + /** Default constructor **/ + CbmMustPoint(); + + /** Constructor with arguments + *@param trackID Index of MCTrack + *@param detID Detector ID + *tubeID Number of tube + *ChamberID number of chamber + *LayerID + *@param pos Coordinates at wire center of active volume [cm] + *@param posInLocal Local coordinates at entrance to active volume [cm] + *@param posOutLocal Local coordinates at exit of active volume [cm] + *@param momIn Momentum of track at entrance [GeV] + *@param momOut Momentum of track at exit [GeV] + *@param tof Time since event start [ns] + *@param length Track length since creation [cm] + *@param eLoss Energy deposit [GeV] + **/ + CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, + Double_t tof, Double_t length, Double_t eLoss, Double_t mass); + + /** Copy constructor **/ + CbmMustPoint(const CbmMustPoint &point); + + /** Destructor **/ + virtual ~CbmMustPoint(); + + // da cancellare + Double_t GetXtot() const { return GetX(); } + Double_t GetYtot() const { return GetY(); } + Double_t GetZtot() const { return GetZ(); } + + Double_t GetPxOut() const { return fPx_out; } + Double_t GetPyOut() const { return fPy_out; } + Double_t GetPzOut() const { return fPz_out; } + + ////// + + /** Accessors **/ + Double_t GetXOutLocal() const { return fX_out_local; } + Double_t GetYOutLocal() const { return fY_out_local; } + Double_t GetZOutLocal() const { return fZ_out_local; } + Double_t GetXInLocal() const { return fX_in_local; } + Double_t GetYInLocal() const { return fY_in_local; } + Double_t GetZInLocal() const { return fZ_in_local; } + + // Double_t GetXWireDirection() const { return fX_wire_dir; } + // Double_t GetYWireDirection() const { return fY_wire_dir; } + // Double_t GetZWireDirection() const { return fZ_wire_dir; } + + Double_t GetMass() const { return fMass; } + + void PositionOutLocal(TVector3 &pos) { pos.SetXYZ(fX_out_local, fY_out_local, fZ_out_local); } + void PositionInLocal(TVector3 &pos) { pos.SetXYZ(fX_in_local, fY_in_local, fZ_in_local); } + void MomentumOut(TVector3 &mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); } + // void WireDirection(TVector3& wire) { wire.SetXYZ(fX_wire_dir, fY_wire_dir, fZ_wire_dir); } + + /** Modifiers **/ + void SetPositionOutLocal(TVector3 pos); + void SetPositionInLocal(TVector3 pos); + void SetMomentumOut(TVector3 mom); + // void SetWireDirection(TVector3 wire); + + // tube ID // CHECK added + void SetTubeID(Int_t tubeid) { fTubeID = tubeid; } + Int_t GetTubeID() { return fTubeID; } + void SetChamberID(Int_t chamberid) { fChamberID = chamberid; } + void SetLayerID(Int_t layerid) { fLayerID = layerid; } + Int_t GetChamberID() { return fChamberID; } + Int_t GetLayerID() { return fLayerID; } + + /** Output to screen **/ + virtual void Print(const Option_t *opt) const; + + protected: + // exit coordinates in straw frame + Double_t fX_out_local, fY_out_local, fZ_out_local; + // entry coordinates in straw frame + Double_t fX_in_local, fY_in_local, fZ_in_local; + + Double_t fPx_out, fPy_out, fPz_out; + Double_t fPx_in, fPy_in, fPz_in; + // wire direction + // Double_t fX_wire_dir, fY_wire_dir, fZ_wire_dir; + + // particle mass + Double_t fMass; + Int_t fTubeID; + Int_t fChamberID; + Int_t fLayerID; + + ////// + + ClassDef(CbmMustPoint, 1) +}; + +inline void CbmMustPoint::SetPositionOutLocal(TVector3 pos) +{ + fX_out_local = pos.X(); + fY_out_local = pos.Y(); + fZ_out_local = pos.Z(); +} + +inline void CbmMustPoint::SetPositionInLocal(TVector3 pos) +{ + fX_in_local = pos.X(); + fY_in_local = pos.Y(); + fZ_in_local = pos.Z(); +} + +inline void CbmMustPoint::SetMomentumOut(TVector3 mom) +{ + fPx_out = mom.Px(); + fPy_out = mom.Py(); + fPz_out = mom.Pz(); +} + +#endif diff --git a/core/detectors/must/CMakeLists.txt b/core/detectors/must/CMakeLists.txt new file mode 100644 index 0000000000..fb375281e3 --- /dev/null +++ b/core/detectors/must/CMakeLists.txt @@ -0,0 +1,46 @@ +set(INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR} + ) + + +set(SRCS + CbmGeoMust.cxx + CbmGeoMustPar.cxx + CbmMustContFact.cxx + CbmMustMapCreator.cxx + CbmMustSingleStraw.cxx + CbmMustTube.cxx +) + + +# ---- Enable OpenMP ------------------------------------- +find_package(OpenMP) +if (OPENMP_FOUND) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +endif() +# --------------------------------------------------------- + +set(LIBRARY_NAME CbmMustBase) +set(LINKDEF ${LIBRARY_NAME}LinkDef.h) +set(PUBLIC_DEPENDENCIES + FairRoot::Base + FairRoot::ParBase + CbmBase + ROOT::Core + ROOT::Geom + ROOT::Gpad + ROOT::Hist + ROOT::MathCore + ROOT::Physics + ) + +set(PRIVATE_DEPENDENCIES + FairLogger::FairLogger + CbmData + ROOT::Graf + ROOT::MLP + ROOT::Tree + ) + +generate_cbm_library() diff --git a/core/detectors/must/CbmGeoMust.cxx b/core/detectors/must/CbmGeoMust.cxx new file mode 100644 index 0000000000..68f7f74652 --- /dev/null +++ b/core/detectors/must/CbmGeoMust.cxx @@ -0,0 +1,45 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmGeoMust source file +// +// Class for geometry of MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmGeoFts by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#include "CbmGeoMust.h" +// from FairRoot +#include <FairGeoNode.h> +// from fmt +#include <fmt/core.h> + +ClassImp(CbmGeoMust) + + CbmGeoMust::CbmGeoMust() +{ + // Constructor + fName = "must"; + maxSectors = 0; + maxModules = 40; +} + +const char *CbmGeoMust::getModuleName(Int_t m) +{ + // Returns the module name of MUST number m + modName = fmt::format("must{:02d}", m + 1); + + return modName.c_str(); +} + +const char *CbmGeoMust::getEleName(Int_t m) +{ + // Returns the element name of MUST number m + eleName = fmt::format("must{:02d}", m + 1); + + return eleName.c_str(); +} diff --git a/core/detectors/must/CbmGeoMust.h b/core/detectors/must/CbmGeoMust.h new file mode 100644 index 0000000000..95dadf489f --- /dev/null +++ b/core/detectors/must/CbmGeoMust.h @@ -0,0 +1,41 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmGeoMust header file +// +// Class for geometry of MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmGeoFts by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMGEOMUST_H +#define CBMGEOMUST_H + +// from FairRoot +#include <FairGeoSet.h> + +class CbmGeoMust : public FairGeoSet { + protected: + std::string modName; // name of module + std::string eleName; // substring for elements in module + public: + CbmGeoMust(); + ~CbmGeoMust() {} + const char *getModuleName(Int_t); + const char *getEleName(Int_t); + inline Int_t getModNumInMod(const TString &); + ClassDef(CbmGeoMust, 0) // Class for Must +}; + +inline Int_t CbmGeoMust::getModNumInMod(const TString &name) +{ + // returns the module index from module name + + return (Int_t)(name[2] - '0') - 1; +} + +#endif /* !CBMGEOMUST_H */ diff --git a/core/detectors/must/CbmGeoMustPar.cxx b/core/detectors/must/CbmGeoMustPar.cxx new file mode 100644 index 0000000000..1d88b58f30 --- /dev/null +++ b/core/detectors/must/CbmGeoMustPar.cxx @@ -0,0 +1,70 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmGeoMustPar source file +// +// Class for geometry parameters of MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmGeoFtsPar by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#include "CbmGeoMustPar.h" +// from FairRoot +#include <FairParamList.h> +// standard +#include <iostream> +#include <iomanip> + +ClassImp(CbmGeoMustPar) + + CbmGeoMustPar::CbmGeoMustPar(const char *name, const char *title, const char *context) + : FairParGenericSet(name, title, context), fGeoSensNodes(new TObjArray()), fGeoPassNodes(new TObjArray()), fGeoType(-1), fTubeInRad(0), fTubeOutRad(0) +{ +} + +CbmGeoMustPar::~CbmGeoMustPar(void) {} + +void CbmGeoMustPar::clear(void) +{ + if (fGeoSensNodes) { + fGeoSensNodes->Delete(); + delete fGeoSensNodes; + } + if (fGeoPassNodes) { + fGeoPassNodes->Delete(); + delete fGeoPassNodes; + } +} + +void CbmGeoMustPar::putParams(FairParamList *l) +{ + if (!l) + return; + l->addObject("FairGeoNodes Sensitive List", fGeoSensNodes); + l->addObject("FairGeoNodes Passive List", fGeoPassNodes); + l->add("Tube Innen Radius", fTubeInRad); + l->add("Tube Outer Radius", fTubeOutRad); + l->add("Geometry Type", fGeoType); +} + +Bool_t CbmGeoMustPar::getParams(FairParamList *l) +{ + if (!l) + return kFALSE; + if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes)) + return kFALSE; + if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes)) + return kFALSE; + if (!l->fill("Tube Innen Radius", &fTubeInRad)) + return kFALSE; + if (!l->fill("Tube Outer Radius", &fTubeOutRad)) + return kFALSE; + if (!l->fill("Geometry Type", &fGeoType)) + return kFALSE; + + return kTRUE; +} diff --git a/core/detectors/must/CbmGeoMustPar.h b/core/detectors/must/CbmGeoMustPar.h new file mode 100644 index 0000000000..107b3b3314 --- /dev/null +++ b/core/detectors/must/CbmGeoMustPar.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmGeoMustPar header file +// +// Class for geometry parameters of MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmGeoFtsPar by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMGEOMUSTPAR_H +#define CBMGEOMUSTPAR_H +// from FairRoot +#include <FairParGenericSet.h> +// from ROOT +#include <TH1F.h> +#include <TObjArray.h> + +class CbmGeoMustPar : public FairParGenericSet { + private: + TObjArray *fGeoSensNodes; /** List of FairGeoNodes for sensitive volumes*/ + TObjArray *fGeoPassNodes; /** List of FairGeoNodes for sensitive volumes*/ + Int_t fGeoType; // modif + Double_t fTubeInRad, fTubeOutRad; // modif + + CbmGeoMustPar(const CbmGeoMustPar &L); + CbmGeoMustPar &operator=(const CbmGeoMustPar &) { return *this; } + + public: + CbmGeoMustPar(const char *name = "CbmGeoMustPar", const char *title = "Must Geometry Parameters", const char *context = "TestDefaultContext"); + ~CbmGeoMustPar(void); + void clear(void); + void putParams(FairParamList *); + Bool_t getParams(FairParamList *); + TObjArray *GetGeoSensitiveNodes() { return fGeoSensNodes; } + TObjArray *GetGeoPassiveNodes() { return fGeoPassNodes; } + + // Additional function + void SetGeometryType(Int_t geoType) { fGeoType = geoType; } + void SetTubeInRad(Double_t inrad) { fTubeInRad = inrad; } + void SetTubeOutRad(Double_t outrad) { fTubeOutRad = outrad; } + Int_t GetGeometryType() { return (Int_t)fGeoType; }; + Double_t GetTubeInRad() { return (Double_t)fTubeInRad; }; + Double_t GetTubeOutRad() { return (Double_t)fTubeOutRad; }; + + ClassDef(CbmGeoMustPar, 1) +}; + +#endif /* !CBMGEOMUSTPAR_H */ diff --git a/core/detectors/must/CbmMustBaseLinkDef.h b/core/detectors/must/CbmMustBaseLinkDef.h new file mode 100644 index 0000000000..c5408f2704 --- /dev/null +++ b/core/detectors/must/CbmMustBaseLinkDef.h @@ -0,0 +1,18 @@ +/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Volker Friese [committer] */ + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class CbmGeoMust + ; +#pragma link C++ class CbmGeoMustPar + ; +#pragma link C++ class CbmMustContFact + ; +#pragma link C++ class CbmMustMapCreator + ; +#pragma link C++ class CbmMustSingleStraw + ; +#pragma link C++ class CbmMustTube + ; + +#endif /* __CINT__ */ diff --git a/core/detectors/must/CbmMustContFact.cxx b/core/detectors/must/CbmMustContFact.cxx new file mode 100644 index 0000000000..f4e8483a37 --- /dev/null +++ b/core/detectors/must/CbmMustContFact.cxx @@ -0,0 +1,61 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustContFact source file +// +// Factory for the parameter containers in libMust +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmMustContFact by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#include "CbmMustContFact.h" +// from CbnRoot, this library +#include "CbmGeoMustPar.h" +// from FairRoot +#include <FairRuntimeDb.h> +#include <FairParRootFileIo.h> +#include <FairParAsciiFileIo.h> +// standard +#include <iostream> +#include <iomanip> + +ClassImp(CbmMustContFact) + + static CbmMustContFact gCbmMustContFact; + +CbmMustContFact::CbmMustContFact() +{ + // Constructor (called when the library is loaded) + fName = "CbmMustContFact"; + fTitle = "Factory for parameter containers in libMust"; + setAllContainers(); + FairRuntimeDb::instance()->addContFactory(this); +} + +void CbmMustContFact::setAllContainers() +{ + /** Creates the Container objects with all accepted contexts and adds them to + * the list of containers for the MUST library.*/ + FairContainer *p1 = new FairContainer("CbmGeoMustPar", "Must Geometry Parameters", "TestDefaultContext"); + p1->addContext("TestNonDefaultContext"); + containers->Add(p1); +} + +FairParSet *CbmMustContFact::createContainer(FairContainer *c) +{ + /** Calls the constructor of the corresponding parameter container. + * For an actual context, which is not an empty string and not the default context + * of this container, the name is concatinated with the context. */ + const char *name = c->GetName(); + std::cout << "[MUST] CbmMustContFact createContainer name " << name << std::endl; + FairParSet *p = 0; + + if (strcmp(name, "CbmGeoMustPar") == 0) { + p = new CbmGeoMustPar(c->getConcatName().Data(), c->GetTitle(), c->getContext()); + } + return p; +} diff --git a/core/detectors/must/CbmMustContFact.h b/core/detectors/must/CbmMustContFact.h new file mode 100644 index 0000000000..61e9a5edd6 --- /dev/null +++ b/core/detectors/must/CbmMustContFact.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustContFact header file +// +// Factory for the parameter containers in libMust +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmMustContFact by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMMUSTCONTFACT_H +#define CBMMUSTCONTFACT_H + +// from FairRoot +#include <FairContFact.h> + +class FairContainer; + +class CbmMustContFact : public FairContFact { + private: + void setAllContainers(); + + public: + CbmMustContFact(); + ~CbmMustContFact() {} + FairParSet *createContainer(FairContainer *); + // void activateParIo(FairParIo* io); + ClassDef(CbmMustContFact, 0) // Factory for all MUST parameter containers +}; + +#endif /* !CBMMUSTCONTFACT_H */ diff --git a/core/detectors/must/CbmMustMapCreator.cxx b/core/detectors/must/CbmMustMapCreator.cxx new file mode 100644 index 0000000000..a94e1dd800 --- /dev/null +++ b/core/detectors/must/CbmMustMapCreator.cxx @@ -0,0 +1,426 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustMapCreator source file +// +// Mapper for MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmGeoFts by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +// from CbmRoot, this library +#include "CbmMustMapCreator.h" +#include "CbmMustTube.h" +#include "CbmGeoMustPar.h" +// from FairRoot +#include <FairGeoNode.h> +#include <FairGeoVolume.h> +#include <FairGeoTransform.h> +#include <FairGeoVector.h> +#include <FairGeoRotation.h> +#include <FairGeoTube.h> +// from ROOT +#include <TGeoTube.h> +#include <TVector3.h> +#include <TObjArray.h> +#include <TString.h> +#include <TGeoVolume.h> +#include <TGeoTube.h> +#include <TClonesArray.h> +#include <FairRootManager.h> +// standard +#include <iostream> +#include <fstream> + +using namespace std; + +CbmMustMapCreator::CbmMustMapCreator() : fGeoType(0), fTubeInRad(0), fTubeOutRad(0), fMustParameters(new CbmGeoMustPar()) {} + +// CbmMustMapCreator::CbmMustMapCreator(){} +// to use in CbmMust +CbmMustMapCreator::CbmMustMapCreator(Int_t geoType) : fGeoType(geoType), fTubeInRad(0), fTubeOutRad(0), fMustParameters(new CbmGeoMustPar("CbmGeoMustPar", "MUST Geometry Parameters")) +{ + if (fGeoType != 1) + LOG(fatal) << "[MUST] CbmMustMapCreator. Geometry " << fGeoType << " not supported by map"; + // cout << "Creating mapper with geotype = " << fGeoType << endl; + // cout << "fMustParameters name is " << fMustParameters->GetName() << endl; +} + +CbmMustMapCreator::CbmMustMapCreator(CbmGeoMustPar *mustPar) : fMustParameters(mustPar) +{ + fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius + fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius + // choose geometry type + fGeoType = mustPar->GetGeometryType(); // classic, optimized, average, detailed, CAD + // cout << "Creating map with geoType = " << fGeoType << ", radius = " << fTubeInRad << " / " << fTubeOutRad << endl; +} + +CbmMustMapCreator::~CbmMustMapCreator() {} + +void CbmMustMapCreator::SetGeneralParameters() +{ // CHECK whether it depends on geometry or not + fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius + fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius +} + +Int_t CbmMustMapCreator::GetTubeIDFromPath(TString path) +{ + TString tmpstring = GetNameFromPath(path); + return GetTubeIDFromName(tmpstring); +} + +// ===== GEO TYPE 1 ===== +// sensitive volume is gas +// when reading the parameters we use must01tube to retrieve geometrical information +// OK +// during simulation + +Int_t CbmMustMapCreator::GetTubeIDFromName(TString name) +{ + + TString tmpstring = name; + tmpstring.ReplaceAll('_', '#'); + + if (tmpstring.Contains("#")) { + int start = tmpstring.Index("#") + 1; + tmpstring = tmpstring(start, tmpstring.Sizeof()); + } else { + int start = tmpstring.Index("e") + 1; + tmpstring = tmpstring(start, tmpstring.Sizeof()); + } + + // cout << "GetTubeIDFromName(" << name.Data() << ") = " << tmpstring.Data() << " = " << tmpstring.Atoi() << endl; + + return tmpstring.Atoi(); +} + +// name as in geo file: from path "_" to name "#" +TString CbmMustMapCreator::GetNameFromPath(TString path) +{ + TString tmpstring = path; + tmpstring.Remove(tmpstring.Last('/'), tmpstring.Length()); + + tmpstring.Remove(0, tmpstring.Last('/')); + + return tmpstring; +} + +int CbmMustMapCreator::GetTypeNumTube(TString path, int &module_type, int &module_number, int &tube_in_module) +{ + + if (path.Contains("cave") && path.Contains("assembly")) + path.Replace(0, 34, ""); + path.Replace(0, path.First("M") - 1, ""); + module_type = path.Atoi(); + path.Replace(0, path.First("M") + 1, ""); + module_number = path.Atoi(); + path.Replace(0, path.First("M") + 1, ""); + path.Replace(0, path.First("_") + 1, ""); + tube_in_module = path.Atoi(); + // cout << "GetTypeNumTube will return " << module_type << ", " << module_number << ", " << tube_in_module << endl; + return 0; +} + +Int_t CbmMustMapCreator::GetLayerID(Int_t chamberid, TString path) +{ + + int module_type{0}; + int module_number{0}; + int tube_in_module{0}; + GetTypeNumTube(path, module_type, module_number, tube_in_module); + // cout << "Point detected in module S" << module_type << " number " << module_number << " in the tube " << tube_in_module << " of the module." << endl; + + int layerid = 0; + if (chamberid % 2 == 1) { + if (module_type == 1) { + if (tube_in_module <= 64 && module_number <= 5) + layerid = 1; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 5) + layerid = 2; + else if (tube_in_module <= 64 && 5 < module_number && module_number <= 10) + layerid = 3; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 5 < module_number && module_number <= 10) + layerid = 4; + else if (tube_in_module <= 64 && 10 < module_number && module_number <= 15) + layerid = 5; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 10 < module_number && module_number <= 15) + layerid = 6; + else if (tube_in_module <= 64 && 15 < module_number && module_number <= 20) + layerid = 7; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 15 < module_number && module_number <= 20) + layerid = 8; + } + if (module_type == 2) { + if (tube_in_module <= 64 && module_number <= 4) + layerid = 1; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 4) + layerid = 2; + else if (tube_in_module <= 64 && 4 < module_number && module_number <= 8) + layerid = 3; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 4 < module_number && module_number <= 8) + layerid = 4; + else if (tube_in_module <= 64 && 8 < module_number && module_number <= 12) + layerid = 5; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 8 < module_number && module_number <= 12) + layerid = 6; + else if (tube_in_module <= 64 && 12 < module_number && module_number <= 16) + layerid = 7; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 12 < module_number && module_number <= 16) + layerid = 8; + } + if (module_type == 3) { + if (tube_in_module <= 32 && module_number <= 3) + layerid = 1; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && module_number <= 3) + layerid = 2; + else if (tube_in_module <= 32 && 3 < module_number && module_number <= 6) + layerid = 3; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 3 < module_number && module_number <= 6) + layerid = 4; + else if (tube_in_module <= 32 && 6 < module_number && module_number <= 9) + layerid = 5; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 6 < module_number && module_number <= 9) + layerid = 6; + else if (tube_in_module <= 32 && 9 < module_number && module_number <= 12) + layerid = 7; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 9 < module_number && module_number <= 12) + layerid = 8; + } + } else if (chamberid % 2 == 0) { + if (module_type == 1) { + if (tube_in_module <= 64 && module_number <= 7) + layerid = 1; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 7) + layerid = 2; + else if (tube_in_module <= 64 && 7 < module_number && module_number <= 14) + layerid = 3; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 7 < module_number && module_number <= 14) + layerid = 4; + else if (tube_in_module <= 64 && 14 < module_number && module_number <= 21) + layerid = 5; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 14 < module_number && module_number <= 21) + layerid = 6; + else if (tube_in_module <= 64 && 21 < module_number && module_number <= 28) + layerid = 7; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 21 < module_number && module_number <= 28) + layerid = 8; + } + if (module_type == 2) { + if (tube_in_module <= 64 && module_number <= 2) + layerid = 1; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 2) + layerid = 2; + else if (tube_in_module <= 64 && 2 < module_number && module_number <= 4) + layerid = 3; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 2 < module_number && module_number <= 4) + layerid = 4; + else if (tube_in_module <= 64 && 4 < module_number && module_number <= 6) + layerid = 5; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 4 < module_number && module_number <= 6) + layerid = 6; + else if (tube_in_module <= 64 && 6 < module_number && module_number <= 8) + layerid = 7; + else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 6 < module_number && module_number <= 8) + layerid = 8; + } + if (module_type == 3) { + if (tube_in_module <= 32 && module_number <= 3) + layerid = 1; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && module_number <= 3) + layerid = 2; + else if (tube_in_module <= 32 && 3 < module_number && module_number <= 6) + layerid = 3; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 3 < module_number && module_number <= 6) + layerid = 4; + else if (tube_in_module <= 32 && 6 < module_number && module_number <= 9) + layerid = 5; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 6 < module_number && module_number <= 9) + layerid = 6; + else if (tube_in_module <= 32 && 9 < module_number && module_number <= 12) + layerid = 7; + else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 9 < module_number && module_number <= 12) + layerid = 8; + } + layerid = layerid + 8; + } + // cout << "will return layer id = " << layerid << endl; + return layerid; +} + +Int_t CbmMustMapCreator::IsSkew(Int_t layerid) +{ + Int_t skew = 0; + // inclination of +5deg: skew=+1 + if (layerid == 3 || layerid == 4 || layerid == 11 || layerid == 12 || layerid == 19 || layerid == 20 || layerid == 27 || layerid == 28 || layerid == 35 || layerid == 36 || + layerid == 43 || layerid == 44) { + skew = 1; + } + // inclination of -5deg: skew=-1 + if (layerid == 5 || layerid == 6 || layerid == 13 || layerid == 14 || layerid == 21 || layerid == 22 || layerid == 29 || layerid == 30 || layerid == 37 || layerid == 38 || + layerid == 45 || layerid == 46) { + skew = -1; + } + + return skew; +} + +Int_t CbmMustMapCreator::GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, Int_t tube_in_module, Int_t strawCh12) +{ + int tubeidtot = 0; + int modStraws[3] = {64, 64, 32}; + if (chamberid % 2 == 1) { + tubeidtot = tube_in_module + fModShiftMUST1[module_type - 1][module_number - 1] + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); + } else if (chamberid % 2 == 0) { + tubeidtot = tube_in_module + fModShiftMUST2[module_type - 1][module_number - 1] + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); + } + return tubeidtot; +} + +Int_t CbmMustMapCreator::GetTubeIDTot(Int_t chamberid, Int_t layerid, TString path) +{ + + TString tmpstring = path; + Int_t tube = 0; + Int_t totTubeID = 0; + Int_t strawCh12 = 672; + int module_type{0}; + int module_number{0}; + int tube_in_module{0}; + GetTypeNumTube(path, module_type, module_number, tube_in_module); + tube = GetMUSTTubeIDTot(chamberid, layerid, module_type, module_number, tube_in_module, strawCh12); + // cout << path << " : " << chamberid << " / " << layerid << " / " << module_type << " / " << module_number << " / " << tube_in_module << " -> " << tube << endl; + if (chamberid % 2 == 1) { + totTubeID = tube; + } + if (chamberid % 2 == 0) { + totTubeID = tube + strawCh12 * 8; + } + return totTubeID; +} + +///////////////////////////////////////////////////////////// +/// this function will be used in CbmMustHitProducesRealFast +//////////////////////////////////////////////////////////// + +CbmMustTube *CbmMustMapCreator::GetTubeFromNameToFill(TString tubename, Int_t, Int_t) +{ // tubeid layerid //[R.K.03/2017] unused variable(s) + + TObjArray *geoPassNodes = fMustParameters->GetGeoPassiveNodes(); + // Bool_t isCopy = kTRUE; //[R.K. 01/2017] unused variable + // try as if it was a copy stt01tube#XXX + + FairGeoNode *pnode = (FairGeoNode *)geoPassNodes->FindObject(tubename); + if (!pnode) { // try as if it was a solo stt01tubeXXX + // isCopy = kFALSE; //[R.K. 01/2017] unused variable + // tubename = GetNameFromTubeID(tubeid, isCopy); + // pnode = (FairGeoNode*) geoPassNodes->FindObject(tubename); + } + + if (!pnode) { + cout << "CbmMustMapCreator::GetTubeFromNameToFill: tube " << tubename << " not found (nor as a copy)" << endl; + return nullptr; + } + + FairGeoTransform *lab = pnode->getLabTransform(); + FairGeoVector tra = lab->getTransVector(); + FairGeoRotation rot = lab->getRotMatrix(); + + // geometrical info + double x = tra.getX() / 10.; // in cm + double y = tra.getY() / 10.; // in cm + double z = tra.getZ() / 10.; // in cm + + // std::cout<<"tubename="<<tubename<<" tubeid="<<tubeid<<" x="<<x<<" z="<<z<<std::endl; + // Int_t skew=IsSkew(layerid); //[R.K. 01/2017] unused variable? + // double angle=5*3.14159/180; + // x=(x+skew*(tra.getY()*sin(angle))/10.1); + // std::cout<<"tubename="<<tubename<<" tubeid="<<tubeid<<" skew="<<skew<<" newx="<<x<<std::endl; + + double r[3][3]; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + r[i][j] = rot.getElement(i, j); + + TGeoVolume *rootvol = pnode->getRootVolume(); + TGeoTube *tube = (TGeoTube *)rootvol->GetShape(); + Double_t halflength = tube->GetDz(); // in cm + // sets up the correspondence int (tubeID) <--> int (1 = copy/0 = solo) + // copy_map[key] = alloc + // fCopy_Map[tubeid] = isCopy; + + return new CbmMustTube((float)x, (float)y, (float)z, r[0][0], r[0][1], r[0][2], r[1][0], r[1][1], r[1][2], r[2][0], r[2][1], r[2][2], fTubeInRad, fTubeOutRad, halflength); +} + +TClonesArray *CbmMustMapCreator::FillTubeArray() +{ + // ofstream myfile("testNumber.txt"); + TObjArray *geoPassNodes = fMustParameters->GetGeoPassiveNodes(); + TClonesArray *tubeArray = new TClonesArray("CbmMustTube"); + // tubeArray->Delete(); + // int mytest=0; //[R.K. 01/2017] unused variable? + // cout << "TA: entries: " << geoPassNodes->GetEntriesFast() << endl; + for (int i = 0; i < geoPassNodes->GetEntriesFast(); i++) { + FairGeoNode *pnode = (FairGeoNode *)geoPassNodes->At(i); + if (!pnode) { + cout << "CbmMustMapCreator::FillTubeArray : tubename=" << pnode->GetName() << " not existing!!!" << endl; + continue; + } + TString tubename = pnode->GetName(); + + // cout<<"CbmMustMapCreator::FillTubeArray : tubename="<<tubename<< endl; + if ((!tubename.Contains("tube")) || (!tubename.Contains("must"))) { + // myfile<<"CbmMustMapCreator::FillTubeArray : skipping tubename="<<tubename<<endl; + continue; + } + + tubename.ReplaceAll("#", "_"); + Int_t tempChamber = GetChamberIDFromName(tubename); + Int_t tempLayer = GetLayerID(tempChamber, tubename); + Int_t totTubeID = GetTubeIDTot(tempChamber, tempLayer, tubename); + + // cout<<"CbmMustMapCreator::FillTubeArray : totTubeID="<<totTubeID<< endl; + tubename = pnode->GetName(); + + // cout << "TUBE " << tempChamber << " / " << tubeID << " / " << tempLayer << " / " << totTubeID << endl; + + CbmMustTube *musttube = GetTubeFromNameToFill(tubename, totTubeID, tempLayer); + new ((*tubeArray)[totTubeID]) CbmMustTube(*musttube); + + delete (musttube); + // myfile << tubename << " " << totTubeID << " "<<tempLayer<<endl; + } + // cout << "end: " << tubeArray->GetEntriesFast() << endl; + return tubeArray; +} + +Int_t CbmMustMapCreator::GetChamberIDFromName(TString name) +{ + TString pathstring = name; + if (pathstring.Contains("must01")) { + return 1; + } + if (pathstring.Contains("must02")) { + return 2; + } + LOG(fatal) << "[MUST] GetChamberIDFromName failed (" << name.Data() << ")"; + return -1; +} + +Int_t CbmMustMapCreator::GetChamberIDFromPath(TString path) +{ + TString pathstring = path; + if (pathstring.Contains("must01tube")) { + return 1; + } + if (pathstring.Contains("must02tube")) { + return 2; + } + LOG(fatal) << "[MUST] GetChamberIDFromPath failed (" << path.Data() << ")"; + return -1; +} + +ClassImp(CbmMustMapCreator) diff --git a/core/detectors/must/CbmMustMapCreator.h b/core/detectors/must/CbmMustMapCreator.h new file mode 100644 index 0000000000..d87f704bcd --- /dev/null +++ b/core/detectors/must/CbmMustMapCreator.h @@ -0,0 +1,79 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustMapCreator source file +// +// Mapper for MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmGeoFts by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMMUSTMAPCREATOR_H +#define CBMMUSTMAPCREATOR_H + +// from ROOT +#include <TObject.h> +// standard +#include <iostream> +#include <map> + +class CbmMustTube; +class CbmGeoMustPar; +class CbmGeoMustPar; + +class TClonesArray; + +class CbmMustMapCreator : public TObject { + public: + CbmMustMapCreator(); + CbmMustMapCreator(Int_t geoType); + CbmMustMapCreator(CbmGeoMustPar *par); + ~CbmMustMapCreator(); + + // general functions + void SetGeneralParameters(); + + // general functions, to be specified depending on geo type + Int_t GetTubeIDFromPath(TString path); + CbmMustTube *GetTubeFromTubeID(Int_t tubeid); + TClonesArray *FillTubeArray(); + Int_t GetChamberIDFromPath(TString path); + Int_t GetChamberIDFromName(TString name); + Int_t GetLayerID(Int_t chamberid, TString path); + Int_t IsSkew(Int_t layerid); + Int_t GetTubeIDTot(Int_t chamberid, Int_t layerid, TString path); + Int_t GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, Int_t tube_in_module, Int_t strawCh12); + + private: + Int_t GetTubeIDFromName(TString name); + TString GetNameFromPath(TString path); + TString GetNameFromTubeID(Int_t tubeid, Bool_t isCopy); + CbmMustTube *GetTubeFromNameToFill(TString tubename, Int_t tubeid, Int_t layerid); + int GetTypeNumTube(TString path, int &module_type, int &module_number, int &tube_in_module); + + Int_t fGeoType{0}; + Double_t fTubeInRad{0.}, fTubeOutRad{0.}; + CbmGeoMustPar *fMustParameters{nullptr}; + int fModShiftMUST1[3][20] = {{192, 256, 320, 384, 448, 1536, 1600, 1664, 1728, 1792, 2880, 2944, 3008, 3072, 3136, 4224, 4288, 4352, 4416, 4480}, + {64, 128, 512, 576, 1408, 1472, 1856, 1920, 2752, 2816, 3200, 3264, 4096, 4160, 4544, 4608, 0, 0, 0, 0}, + {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0}}; + int fModShiftMUST2[3][28] = { + {128, 192, 256, 320, 384, 448, 512, 1472, 1536, 1600, 1664, 1728, 1792, 1856, 2816, 2880, 2944, 3008, 3072, 3136, 3200, 4160, 4224, 4288, 4352, 4416, 4480, 4544}, + {64, 576, 1408, 1920, 2752, 3264, 4096, 4608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + + // fGeoType1 + // std::map<int, int> fCopy_Map; + + CbmMustMapCreator(const CbmMustMapCreator &L); + CbmMustMapCreator &operator=(const CbmMustMapCreator &) { return *this; } + + protected: + ClassDef(CbmMustMapCreator, 1) +}; + +#endif diff --git a/core/detectors/must/CbmMustSingleStraw.cxx b/core/detectors/must/CbmMustSingleStraw.cxx new file mode 100644 index 0000000000..6f17848e7b --- /dev/null +++ b/core/detectors/must/CbmMustSingleStraw.cxx @@ -0,0 +1,1287 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustSingleStraw source file +// +// Copied from CbmFtsSingleStraw +// +// authors: Radoslaw Karabowicz, GSI, 2024 +//////////////////////////////////////////////////////////////////////////// + +// +// ============================================================================ +// +// Straw tube response simulation +// Corrections to StrawCharge and Eject for delta electrons (dec 2007) +// +// version with one threshold only Julich signal +// +// mandatory call at the beginning +// once to set constants +// +// void TConst(Double_t Radius, Double_t pSTP, Double_t ArP, Double_t CO2P); +// +// Pysical (Garfield) values: +// Radius Press (pSTP) % Ar (ArP) % CO2 (CO2P) +// 0.4 1 0.9 0.1 +// 0.5 1 0.9 0.1 +// 0.5 2 0.8 0.2 +// +// ------------------------------------------------------------------------------ +// +// Full simulation: calls at each track for MC applications +// +// define particle and its in-out hits +// +// void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, +// Double_t w4, Double_t w5, Double_t w6); define the wire +// +// Double_t PartToTime(Double_t Mass, Double_t Momentum, +// Double_t InOut[] ); straw time +// +// +// Double_t TimnsToDiscm(Double_t time); from time (ns) +// to the reconstructed distance (cm) +// +// Double_t PartToADC(); ADC charge +// signal corresponding to the energy loss of StrawCharge +// for energy loss simulation +// +// +//----------------------------------------------------------------------------- +// +// Fast simulation: calls at each track for MC applications +// +// define particle and its in-out hits +// +// void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, +// Double_t w4, Double_t w5, Double_t w6); define the wire +// +// Double_t FastRec(Double_t TrueDcm, Int_t Flag); fast approximation: +// from the true distance (cm) +// to the reconstructed one (cm) +// Flag=0 standard +// Flag=1 Julich expt. curve +// (active with press =2 in TCo +// +// void TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[]); constant initialization +// +// Double_t FastPartToADC(); ADC charge +// signal corresponding to the energy loss of StrawCharge +// with the Urban model for energy loss simulation +// +// ---------------------------------------------------------------------------- +// where: +// +// time: measured drift time in ns +// +// pSTP = pressure in bar +// Radius = tube radius +// ArP and CO2P percentages of Argon and CO2 +// w1:w6 = coordinates of the extremes of the straw wire (straw axis) +// Mass, Momentm = mass and momentum of the MC particle +// InOut[0:5] = straw input and output coordinates traversed from the MC particle +// +// +// +// For other applications see the routines listed in CbmMustSingleStraw.h +// +// Author: A. Rotondi (november 2005, revised and extended in August 2006) +// +// ================================================================================ +// + +#include "CbmMustSingleStraw.h" + +// from CbmRoot, CbmData +#include <CbmMustHit.h> +// from ROOT +#include <TImage.h> +#include <TMath.h> +#include <TMatrixD.h> +#include <TMatrixDEigen.h> +#include <TRandom.h> +#include <TVector3.h> +#include <TVectorD.h> +// standard +#include <iostream> +#include <string> + +using namespace std; + +ClassImp(CbmMustSingleStraw); + +// ============================================================ +CbmMustSingleStraw::CbmMustSingleStraw() + : CDist(), CDistC(), CNele(), CNeleT(), TeleTime(), AmplSig(), Pulse(), PulseT(), WDist(), Wi(0), ArPerc(0), CO2Perc(0), CH4Perc(0), ArWPerc(0), CO2WPerc(0), CH4WPerc(0), + pSTP(0), Radius(0), AAr(0), ZAr(0), RhoAr(0), NclAr(0), EmedAr(0), EminAr(0), EmpAr(0), CsiAr(0), IAr(0), WiAr(0), Ncl(0), Ecl(0), Lcl(0), Ntote(0), GasGain(0), Cutoff(0), + EmedCO2(0), EminCO2(0), EmpCO2(0), CsiCO2(0), ACO2(0), ZCO2(0), RhoCO2(0), ICO2(0), WiCO2(0), NclCO2(0), EmedCH4(0), EmpCH4(0), CsiCH4(0), EminCH4(0), ACH4(0), ZCH4(0), + RhoCH4(0), ICH4(0), WiCH4(0), NclCH4(0), RhoMixCO2(0), RhoMixCH4(0), PZeta(0), piMass(0), PMass(0), PMom(0), Dx(0), eMass(0), prMass(0), Delta(0), CNumb(0), PEn(0), beta(0), + gamma(0), Emed(0), Emin(0), Csi(0), Emax(0), Emp(0), NNClus(0), Xin(0), Yin(0), Zin(0), Xout(0), Yout(0), Zout(0), Rpath(0), NPolya(0), Xmax(0), bPolya(0), Calpha(0), Cbeta(0), + Cgamma(0), NUrban(0), SigUrb(0), Eup(0), AvUrb(0), Wx1(0), Wy1(0), Wz1(0), Wx2(0), Wy2(0), Wz2(0), Wp(0), Wq(0), Wr(0), PulseMax(0), PulseTime(0), Thresh1(0), Thresh2(0), + Nchann(0), Out1(0), Out2(0), Out3(0) +{ + // class constructor + + // clear + memset(CumClus, 0, sizeof(CumClus)); + memset(CH4Clus, 0, sizeof(CH4Clus)); + memset(PolyaCum, 0, sizeof(PolyaCum)); + memset(Xs, 0, sizeof(Xs)); + + CDist.clear(); + CDistC.clear(); + CNele.clear(); + CNeleT.clear(); + TeleTime.clear(); + AmplSig.clear(); + Pulse.clear(); + PulseT.clear(); + WDist.clear(); +} + +// ---------------------------------------------------------------------- +void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t C1) +{ + + // set constants for the simulation + // Input + // P1 = tube absolute pressure pSTP + // R1 = tube radius Radius + // A1 = argon percentage ArPerc + // C1 = C=2 percentage C=2Perc + // + + Radius = R1; + pSTP = P1; + // Input for the media (volume percentages) + ArPerc = A1; + CO2Perc = C1; + + // cluster dimensions in Ar and CO2 (experimantal values) + + // Double_t PClus[20] = + // {0., .656, .150, .064, .035, .0225, .0155, .0105, .0081, + // .0061, .0049, .0039, .0030, .0025, .0020, .0016, .0012, + // .00095, .00075, .00063}; // Fischle fit + + Double_t PClus[20] = {0., .802, .0707, .020, .013, .008, .006, .005, .006, .008, .009, .007, .0050, .0040, .0033, .0029, .0025, .0023, .0022, .002}; // Lapique 1st calculation + + // Double_t PClus[20] = + // {0., .841, .0340, .021, .013, .008, .006, .004, .003, + // .008, .013, .008, .0050, .004, .0030, .0028, .0025, + // .0023, .0022, .002}; // Lapique 2nd calculation + + // Double_t PClus[20] = + // {0., .656, .150, .064, .035, .0225, .0155, .0105, .0081, + // .0061, .0049, .0039, .0030, .0025, .0020, .0016, .0012, + // .00080, .00059, .00045}; // Fischle empirical + + // PDouble_t Clus[20] = + // {0., .656, .148, .0649, .0337, .0244, .0141, .0078, .0095, + // .0063, .0062, .0042, .0028, .0018, .0023, .0017, .0014, + // .00060, .00050, .00063}; // Fischle exp + + Double_t CO2Clus[20] = {0., .730, .162, .038, .020, .0110, .0147, .0060, .0084, .0052, .0020, .0042, .0021, .0025, .0038, .0021, .0009, .00013, .00064, .00048}; // Fischle exp + + // Double_t CH4Clus[20] = + // {0., .786, .120, .032, .013, .0098, .0055, .0057, .0027, + // .0029, .0020, .0016, .0013, .0010, .0012, .0006, .0005, + // .00042, .00037, .00033}; // Fischle exp + + CH4Perc = 0.07; + + // ----------------------------------------------------- + // gain of the avalanche + // Ar/CO2 90/10 1 bar (NTP) MAGY GARFIELD 20-7-2006 + GasGain = 100000.; + + // argon ---------------------------------------------------- + AAr = 39.948; // Argon (39.948) + ZAr = 18.0; // Argon (18) + RhoAr = pSTP * 1.78 * 1.e-03; // g/cm3 (1.78 mg/cm3) + IAr = 188 * 1.e-09; // ionization potential (GeV) (188 eV) + WiAr = 27.0; // energy to create an ion pair (standard 26.7 eV) + NclAr = 25.; // cluster/cm in Argon + // CO2 ----------------------------------------------------- + ACO2 = 44; // CO2 + ZCO2 = 22.; // CO2 + RhoCO2 = pSTP * 1.98 * 1.e-03; // g/cm3 CO2 (1.98 mg/cm3) + ICO2 = 95.8 * 1.e-09; // ionization potential (GeV) (96 eV) + WiCO2 = 33.0; // energy to create an ion pair (33 eV) + NclCO2 = 35.5; // clusters/cm CO2 35.5 + // Methane CH4 --------------------------------------------------------- + ACH4 = 16; // CO2 (39.948) + ZCH4 = 10.; // CO2 (18) + RhoCH4 = pSTP * 0.71 * 1.e-03; // g/cm3 CO2 (0.71 mg/cm3) + ICH4 = 40.6 * 1.e-09; // ionization potential (GeV) (45 eV) + WiCH4 = 28.0; // energy to create an ion pair + NclCH4 = 25.0; + // Input for the media (weight percentages) ---------------------------- + ArWPerc = ArPerc * AAr / (ArPerc * AAr + CO2Perc * ACO2); + CO2WPerc = CO2Perc * ACO2 / (ArPerc * AAr + CO2Perc * ACO2); + + // mixture densiies ---------------------------------------------------- + RhoMixCO2 = 1. / ((ArWPerc / RhoAr) + (CO2WPerc / RhoCO2)); + RhoMixCH4 = 1. / ((ArWPerc / RhoAr) + (CH4WPerc / RhoCH4)); + + //---------------------------------------------------------------------- + // particles (Gev, energy losses in Kev) + + PZeta = 1; // projectile charge + piMass = 0.139; // particle mass (GeV) + eMass = 0.511 / 1000.; // electron mass (GeV) (0.511 MeV) + prMass = 0.93827; // proton mass (GeV) + + // --------------------------------------------------------------------- + // thresholds for the straw tubes (default values) see TInit for current values + Thresh1 = 10; + Thresh2 = 30; + // channels for the signal + Nchann = 500; + + // ---------------------------------------------Emin------------------------ + + NPolya = 100; // steps for the calculation of the Polya distributions + Xmax = 0.; // Polya istribution is calculated between o and Xmax (see Polya) + bPolya = 0.5; + Polya(bPolya); // cumulative of the Polya distribution + // ----------------------------------------------------------------------- + + // cumulative for the number of electron per cluster + + Double_t Wnorm = (ArPerc * NclAr + CO2Perc * NclCO2); + CumClus[0] = (ArPerc * NclAr * PClus[0] + CO2Perc * NclCO2 * CO2Clus[0]) / Wnorm; + + for (Int_t i = 1; i < 20; i++) { + CumClus[i] = (ArPerc * NclAr * PClus[i] + CO2Perc * NclCO2 * CO2Clus[i]) / Wnorm + CumClus[i - 1]; + } + CumClus[20] = 1.; + + /* + Double_t sum = 0.; + for (Int_t i = 0; i < 20; i++) { + sum += PClus[i]; + // cout<<" PClus["<<i<<"] = "<<PClus[i]<<endl; + } + // for (Int_t i = 0; i <= 20; i++) { // cout<<"CumClus["<<i<<"] = "<<CumClus[i]<<endl; + // } + // cout<<" Sum of Probabilities = "<<sum<<endl; + */ +} + +// ============================================================== +void CbmMustSingleStraw::PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, Double_t w4, Double_t w5, Double_t w6) +{ + // get wire coordinates + + Wx1 = w1; + Wy1 = w2; + Wz1 = w3; + + Wx2 = w4; + Wy2 = w5; + Wz2 = w6; +} +// ============================================================= + +void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[]) +{ + + // initialization of the constants for each track and each straw + + // transfer of data + // track geometrical quantities + Xin = InOut[0]; + Yin = InOut[1]; + Zin = InOut[2]; + Xout = InOut[3]; + Yout = InOut[4]; + Zout = InOut[5]; + PMass = xPMass; + PMom = xPMom; + + // path into the straw + Dx = sqrt((Xout - Xin) * (Xout - Xin) + (Yout - Yin) * (Yout - Yin) + (Zout - Zin) * (Zout - Zin)); + + // clear + CNumb = 0; + PulseMax = 0; + PulseTime = 0; + CDist.clear(); + CDistC.clear(); + CNele.clear(); + CNeleT.clear(); + WDist.clear(); + TeleTime.clear(); + AmplSig.clear(); + Pulse.clear(); + PulseT.clear(); + + // --------------------------------------------------------------------- + + // initialization of the constants + // maximum energy transfer Emax (GeV) and related quantities + + PEn = sqrt(PMom * PMom + PMass * PMass); // particle energy GeV + beta = PMom / PEn; + gamma = 1 / sqrt(1. - beta * beta); + Double_t begam = beta * gamma; // local + Double_t mratio = eMass / PMass; // local + + // calculation of the polarization Sternheimer factor for Argon + Double_t ms = 2.80; + Double_t Xst = log10(begam * sqrt(pSTP)); + Double_t Cs = -11.92; + Double_t X1 = 4; + Double_t Xo = 1.96; + Double_t as = 0.389; + Delta = 0; + if (Xo <= Xst && Xst <= X1) + Delta = 4.6051702 * Xst + Cs + as * pow(X1 - Xst, ms); + else if (X1 < Xst) + Delta = 4.6051702 * Xst + Cs; + if (Delta < 0) + Delta = 0; + + // calculation of other typical quantites + + Emax = (1.022 * begam * begam / (1. + 2. * gamma * mratio + mratio * mratio)) / 1000.; // GeV + + CsiAr = 0.5 * 0.3071 * PZeta * PZeta * ZAr * RhoAr / (beta * beta * AAr) * 1e-03; // GeV + Double_t fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (IAr * IAr); + EmedAr = 2. * CsiAr * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm + EminAr = pSTP * 2.70 * 1.e-06; // GeV/cm (2.5 keV) + // most prob energy (GeV) + EmpAr = EmedAr + CsiAr * (0.422784 + beta * beta + log(CsiAr / Emax)); + + CsiCO2 = 0.5 * 0.3071 * PZeta * PZeta * ZCO2 * RhoCO2 / (beta * beta * ACO2) * 1e-03; // GeV + fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (ICO2 * ICO2); + EmedCO2 = 2. * CsiCO2 * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm + EminCO2 = pSTP * 3.60 * 1.e-06; // GeV/cm (2.5 keV) + // most prob energy (GeV) + EmpCO2 = EmedCO2 + CsiCO2 * (0.422784 + beta * beta + log(CsiCO2 / Emax)); + + Csi = RhoMixCO2 * ((ArWPerc * CsiAr / RhoAr) + (CO2WPerc * CsiCO2 / RhoCO2)); + ; + Emed = RhoMixCO2 * ((ArWPerc * EmedAr / RhoAr) + (CO2WPerc * EmedCO2 / RhoCO2)); + Emin = RhoMixCO2 * ((ArWPerc * EminAr / RhoAr) + (CO2WPerc * EminCO2 / RhoCO2)); + Emp = RhoMixCO2 * ((ArWPerc * EmpAr / RhoAr) + (CO2WPerc * EmpCO2 / RhoCO2)); + + // mean weighted interaction + Wi = (ArPerc * NclAr * WiAr + CO2Perc * NclCO2 * WiCO2) / (ArPerc * NclAr + CO2Perc * NclCO2); + // number of clusters + Double_t nAr = ArWPerc * RhoMixCO2 / AAr; + Double_t nCO2 = CO2WPerc * RhoMixCO2 / ACO2; + // Ncl=pSTP*((ArPerc*NclAr)+(CO2Perc*NclCO2))*Emed/Emin; // <--- Cluster/cm + Ncl = pSTP * ((nAr * NclAr + nCO2 * NclCO2) / (nAr + nCO2)) * Emed / Emin; // <--- Cluster/cm + + Lcl = 1. / Ncl; // mean free path between clusters (cm) + Ecl = 2.8; // mean number of electrons per clusters (def 2.8) + Cutoff = Ncl * Ecl * 25; // limit to the number of primary electrons (*20) + Ntote = Ecl * Ncl; // total mean number of electrons per cm + + // --------------------------------------------------------------------- + // thresholds for the straw tubes (current values) + // total number of electrons * scaling factor (max of signal x electron=1) + + Thresh1 = Ncl * Ecl * 0.10; + Thresh2 = Ncl * Ecl * 0.15; + + // ----------------------------------------------------------------------- + + TDirCos(); // director cosine of the track + + // control prints + + // cout<<" Dx "<<Dx<<" Csi "<<Csi*1.e+09<<" Emax MeV "<< + // Emax*1.e+03<<" PMass "<<PMass<<" gamma "<< + // gamma<<endl; + // cout<<" RRise "<<RRise(gamma)<<endl; + // cout<<" Thresh1 = "<<Thresh1<<" Thresh2 = "<<Thresh2<<endl; +} + +// ============================================================= + +// energy loss in GeV +Double_t CbmMustSingleStraw::STEloss() +{ + + return gRandom->Landau(Emp * Dx, Csi * Dx); // in GeV +} +// ============================================================= + +Double_t CbmMustSingleStraw::STUrban() +{ + + // + // energy loss in GeV from the Urbam distribution NIM A 362(1995)416 + // Author: A. Rotondi December 2007 + // + + Double_t Sig1Ar, Sig2Ar, Sig3Ar; + Double_t Sig1Mix, Sig2Mix, Sig3Mix; + Double_t Sig1CO2, Sig2CO2, Sig3CO2, IMix, nAr, nCO2; + Double_t f1, f2, e1, e2, e2f, ru, Cu, Cuc; + Double_t N1Mix, N2Mix, N3Mix, E1Mix, E2Mix, E3Mix, ZMix; + Double_t Sig21, Sig22, Sig23, Medd; + + Double_t eVGeV = 1.e-09; + + // ru= 0.6; + ru = 0.55; + + Cuc = 2. * PMass * beta * beta * gamma * gamma; + + // calculation for Argon + + Cu = EmedAr; + f2 = 2. / ZAr; + f1 = 1. - f2; + e2 = 10. * ZAr * ZAr * eVGeV; + e2f = TMath::Power(e2, f2); + e1 = TMath::Power(IAr / e2f, 1. / f1); + Sig1Ar = (1. - ru) * Cu * (f1 / e1) * (TMath::Log(Cuc / e1) - beta * beta) / (TMath::Log(Cuc / IAr) - beta * beta); + Sig2Ar = (1. - ru) * Cu * (f2 / e2) * (TMath::Log(Cuc / e2) - beta * beta) / (TMath::Log(Cuc / IAr) - beta * beta); + Sig3Ar = Cu * Emax * ru / (IAr * (Emax + IAr) * TMath::Log((Emax + IAr) / IAr)); + + // Calculation for CO2 + + Cu = EmedCO2; + f2 = 2. / ZCO2; + f1 = 1. - f2; + e2 = 10. * ZCO2 * ZCO2 * eVGeV; + e2f = TMath::Power(e2, f2); + e1 = TMath::Power(ICO2 / e2f, 1. / f1); + + Sig1CO2 = (1. - ru) * Cu * (f1 / e1) * (TMath::Log(Cuc / e1) - beta * beta) / (TMath::Log(Cuc / ICO2) - beta * beta); + Sig2CO2 = (1. - ru) * Cu * (f2 / e2) * (TMath::Log(Cuc / e2) - beta * beta) / (TMath::Log(Cuc / ICO2) - beta * beta); + Sig3CO2 = Cu * Emax * ru / (ICO2 * (Emax + ICO2) * TMath::Log((Emax + ICO2) / ICO2)); + + // calculation for the mixture + + nAr = ArWPerc * RhoMixCO2 / AAr; + nCO2 = CO2WPerc * RhoMixCO2 / ACO2; + IMix = TMath::Exp((nAr * ZAr * TMath::Log(IAr) + nCO2 * ZCO2 * TMath::Log(ICO2)) / (nAr * ZAr + nCO2 * ZCO2)); + + ZMix = ArWPerc * ZAr + CO2WPerc * ZCO2; + f2 = 2. / ZMix; + f1 = 1. - f2; + E2Mix = 10. * ZMix * ZMix * eVGeV; + e2f = TMath::Power(E2Mix, f2); + E1Mix = TMath::Power(IMix / e2f, 1. / f1); + + Sig1Mix = Dx * RhoMixCO2 * (ArWPerc * Sig1Ar / RhoAr + CO2WPerc * Sig1CO2 / RhoCO2); + Sig2Mix = Dx * RhoMixCO2 * (ArWPerc * Sig2Ar / RhoAr + CO2WPerc * Sig2CO2 / RhoCO2); + Sig3Mix = Dx * RhoMixCO2 * (ArWPerc * Sig3Ar / RhoAr + CO2WPerc * Sig3CO2 / RhoCO2); + + NUrban = Sig1Mix + Sig2Mix + Sig3Mix; // total number of collisions (mean value) + + // Urban distribution calculation + + N1Mix = gRandom->Poisson(Sig1Mix); + N2Mix = gRandom->Poisson(Sig2Mix); + N3Mix = gRandom->Poisson(Sig3Mix); + + Int_t N3 = TMath::Nint(N3Mix + gRandom->Uniform()); + + E3Mix = 0.; + for (Int_t j = 1; j <= N3; j++) { + E3Mix += ((Emax + IMix) * IMix) / (IMix + Emax * (1. - gRandom->Uniform())); + } + + // variance calculation + + Eup = IMix / (1. - 0.98 * Emax / (Emax + IMix)); // 98% of the delta electron area (GeV) + Sig21 = IMix * (Emax + IMix) / Emax; + Medd = Sig21 * TMath::Log(Eup / IMix); + Sig22 = Sig21 * Eup - Medd * Medd; + Sig23 = Sig1Mix * E1Mix * E1Mix + Sig2Mix * E2Mix * E2Mix + Sig3Mix * Medd * Medd + Sig3Mix * Sig22; + + AvUrb = Sig1Mix * E1Mix + Sig2Mix * E2Mix + Sig3Mix * Medd; + + SigUrb = TMath::Sqrt(Sig23); + + // return the energy lost in keV + + return N1Mix * E1Mix + N2Mix * E2Mix + E3Mix; // in GeV +} +// ============================================================= + +Double_t CbmMustSingleStraw::StrawCharge() +{ + + // sampling of the ionization energy loss, number of + // primary electrons and their wire distances for each track + // energy loss in GeV + + // clear + Double_t TotEnEle = 0., ClusEner = 0., Ecurr; + CNeleT.clear(); + WDist.clear(); + + // threshold for delta rays (>1.5 KeV from NIM A301(1991)202) + // total energy released by the electrons + // Number of cluster in the length + NNClus = Cluster(); // set vectors CDist CDistC e CNele + // calculation of total energy released by the electrons + for (Int_t j = 1; j <= NNClus; j++) { + ClusEner = 0.; + for (Int_t jj = 1; jj <= (Int_t)(CNele.at(j - 1)); jj++) { + Ecurr = Wi; + TotEnEle += Ecurr; + ClusEner += Ecurr; + } + + // effective number of electrons per cluster + + CNeleT.push_back(int(ClusEner / Wi)); + } + + // record the distance from the wire of any electron + // adding the diffusion effects + Int_t owfl = 0; + for (Int_t k = 1; k <= NNClus; k++) { + for (Int_t kk = 0; kk < (Int_t)CNeleT.at(k - 1); kk++) { + if (owfl > (Int_t)Cutoff) + break; + owfl++; + WDist.push_back(WDistCalc(CDistC.at(k - 1))); + } + } + + return TotEnEle * 1.e-09; // in Gev +} + +// ============================================================= + +Int_t CbmMustSingleStraw::Cluster() +{ + + // calculate the number of clusters CNumb + // their distance CDist and + // their number of electrons CNele + + CNumb = 0; + CDist.clear(); + CDistC.clear(); + CNele.clear(); + + Double_t DisTot = 0; + + for (Int_t k = 1; k <= 1000; k++) { + // distance + + Double_t path = -Lcl * log(1 - gRandom->Uniform() + 0.000001); + DisTot += path; + if (DisTot > Dx) + break; + CNumb = k; + CDist.push_back(path); + CDistC.push_back(DisTot); + CNele.push_back((Double_t)Eject()); + } + + return CNumb; +} + +// ============================================================= + +Int_t CbmMustSingleStraw::Eject() +{ + // find the number of electrons in a cluster + Int_t Inelect; + Double_t nelect = 0.; + + nelect = TMath::BinarySearch(21, CumClus, gRandom->Uniform()); + if (nelect < 19) { + return Inelect = (Int_t)(nelect) + 1; + } else { + // long delta electron tail + return Inelect = (Int_t)(20. / (1.03 - gRandom->Uniform())); + } +} + +// ============================================================= + +Double_t CbmMustSingleStraw::RRise(Double_t gamma2) +{ + + // interpolate the relativisic rise of the + // number of cluster per cm, starting from the one + // measured at the ionization minimum + + Double_t Rise; + Double_t lg = log10(gamma2); + + if (1. <= gamma2 && gamma2 <= 2.2) { + Rise = -2.159 * lg + 1.7; + } else if (2.2 <= gamma2 && gamma2 <= 6.) { + Rise = 1.; + } else if (6. <= gamma2 && gamma2 <= 200.) { + Rise = 0.302 * lg + 0.765; + } else if (200. <= gamma2 && gamma2 <= 1000.) { + Rise = 0.1431 * lg + 1.131; + } else if (1000. <= gamma2) { + Rise = 1.54; + } else { + Rise = 1.7; + } + + return Rise; +} + +// ========================================================================== + +void CbmMustSingleStraw::Polya(Double_t bpar) +{ + + // calculate the cumulative of the Polya distribution + // for samplig the gain fluctuations + + Double_t eps = 0.0001; + Double_t Dxx = 0.05, xx = 0., x1, x2; + Double_t PMax; + + Double_t k = 1. / bpar - 1.; + + // find Xmax + + PMax = eps * pow(k, k) * exp(-k); + Double_t value = 1.e+06; + Xmax = 2 * k; + while (value > PMax) { + Xmax += Dxx; + value = pow(Xmax, k) * exp(-Xmax); + } + Xmax += -0.5 * Dxx; + + // calculate the cumulative + + Double_t dx = Xmax / NPolya; + Xs[0] = 0; + for (Int_t i = 1; i < NPolya; i++) { + x1 = xx; + xx += dx; + x2 = xx; + Xs[i] = x2; + if (i > 1) + PolyaCum[i] = PolyaCum[i - 1] + 0.5 * dx * (pow(x1, k) * exp(-x1) + pow(x2, k) * exp(-x2)) / TMath::Gamma(k + 1); + else + PolyaCum[i] = PolyaCum[i - 1] + 0.5 * dx * pow(x2, k) * exp(-x2) / TMath::Gamma(k + 1); + } + + // adjust the normalization + + for (Int_t ii = 0; ii < NPolya; ii++) + PolyaCum[ii] /= PolyaCum[NPolya - 1]; +} + +// ===================================================================== + +Double_t CbmMustSingleStraw::PolyaSamp() +{ + + // sampling a wire gain fluctuation in the gas + + Double_t xr = gRandom->Uniform(); + Int_t n = TMath::BinarySearch(NPolya, PolyaCum, xr); + Double_t xsamp = Xmax; + if (n < NPolya - 1) { + xsamp = Xs[n] + ((xr - PolyaCum[n]) / (PolyaCum[n + 1] - PolyaCum[n])) * (Xs[n + 1] - Xs[n]); + } + return xsamp; +} + +// ===================================================================== + +TVector3 CbmMustSingleStraw::WDistCalc(Double_t DisTot) +{ + + // calculation of the distance of the cluster from the wire + // DisTot is the cluster distance from the track entrance + // diffusion effects are considered + + // wire director cosines + + Double_t Wlength = sqrt((Wx2 - Wx1) * (Wx2 - Wx1) + (Wy2 - Wy1) * (Wy2 - Wy1) + (Wz2 - Wz1) * (Wz2 - Wz1)); + Wp = (Wx2 - Wx1) / Wlength; + Wq = (Wy2 - Wy1) / Wlength; + Wr = (Wz2 - Wz1) / Wlength; + + // current track coordinates + Double_t xcor = Calpha * DisTot + Xin; + Double_t ycor = Cbeta * DisTot + Yin; + Double_t zcor = Cgamma * DisTot + Zin; + + // cross product VV1= (wire x track) for the distance + Double_t XX1 = Wr * (ycor - Wy1) - Wq * (zcor - Wz1); + Double_t YY1 = Wp * (zcor - Wz1) - Wr * (xcor - Wx1); + Double_t ZZ1 = Wq * (xcor - Wx1) - Wp * (ycor - Wy1); + + // vector for the 3-D distance from the wire (from wire x VV1) + Double_t XX = Wq * ZZ1 - Wr * YY1; + Double_t YY = Wr * XX1 - Wp * ZZ1; + Double_t ZZ = Wp * YY1 - Wq * XX1; + // cout<<" XYZ "<<XX<<" "<<YY<<" "<<ZZ<<endl; + Double_t DDistcm = sqrt(XX * XX + YY * YY + ZZ * ZZ); + + // director cosines of the distance vector + Double_t cosx = XX / DDistcm; + Double_t cosy = YY / DDistcm; + Double_t cosz = ZZ / DDistcm; + + // sampling of the diffusion + // Double_t DDist = DDistcm*10.; // distance in mm + + // longitudinal coefficient of diffusion (GARFIELD) cm --> micron + // MAGY Ar/CO2 90/10 20-7-2006 GARFIELD + Double_t SigL = DiffLong(DDistcm); + // ... in cm + SigL *= 1.e-04; // in cm + + // tranverse coefficient (GARFIELD) cm--> micron + // MAGY Ar/CO2 90/10 20-7-2006 GARFIELD + Double_t SigT = DiffTran(DDistcm); + SigT *= 1.e-04; // in cm + + // sampling of Longitudinal and Transverse diffusion + Double_t difL = gRandom->Gaus(0., SigL); + Double_t difT = gRandom->Gaus(0., SigT); + + // vector addition to the distance + // the transverse component has the same dir cos of the wire + XX += difL * cosx + difT * Wp; + YY += difL * cosy + difT * Wq; + ZZ += difL * cosz + difT * Wr; + // cout<<" XYZ+ dif "<<XX<<" "<<YY<<" "<<ZZ<<endl; + // cout<<" --------------------------------------------------- "<<endl; + TVector3 TDist(XX, YY, ZZ); + + return TDist; +} + +// ===================================================================== + +void CbmMustSingleStraw::TDirCos() +{ + + // director cosines of the track (called for each track) + + // path into the straw + Rpath = sqrt((Xout - Xin) * (Xout - Xin) + (Yout - Yin) * (Yout - Yin) + (Zout - Zin) * (Zout - Zin)); + + // director cosines + Calpha = (Xout - Xin) / Rpath; + Cbeta = (Yout - Yin) / Rpath; + Cgamma = (Zout - Zin) / Rpath; +} + +// ===================================================================== + +Int_t CbmMustSingleStraw::TimeEle() +{ + + TeleTime.clear(); + + // calculate the arrival times (ns) for each electron in TeleTime + // from cm to ns <--------------------------------- + // return the number of electrons + // Author:A. Rotondi 20-7-2006 + + Int_t ido = WDist.size(); + Double_t etime; + + // cutoff the total charge to 20 times the average + if (ido > (Int_t)Cutoff) + ido = (Int_t)Cutoff; + + for (Int_t k = 0; k < ido; k++) { + Double_t dst = WDist.at(k).Mag(); // distance in cm + + // space to time calculation from GARFIELD + + if (pSTP < 1.9) { + if (Radius < 0.5) { + // V=1600V diameter 4 mm 90/10 + etime = -1.624e-05 + 0.1258 * dst + 0.8079 * pow(dst, 2) - 2.918 * pow(dst, 3) + 10.33 * pow(dst, 4) - 10.84 * pow(dst, 5); + } else { + // V=1600V diameter 5 mm 90/10 + etime = -6.763e-05 + 0.1471 * dst + 0.3625 * pow(dst, 2) + 0.3876 * pow(dst, 3) + 1.04 * pow(dst, 4) - 1.693 * pow(dst, 5); + } + } else { + // 2 bar 2000V, 5 mm, 80/20 + etime = -0.0001014 + 0.1463 * dst - 0.1694 * pow(dst, 2) + 2.4248 * pow(dst, 3) - 1.793 * pow(dst, 4); + } + + etime *= 1000.; // nano seconds + TeleTime.push_back(etime); + } + + return TeleTime.size(); +} + +// ===================================================================== + +Double_t CbmMustSingleStraw::Signal(Double_t t, Double_t t0) +{ + + // electric signal at time t of a cluster arriving at t0 + Double_t elesig; + // Double_t A = 1.03e-03; //[R.K. 01/2017] unused variable? + // Double_t B = 3.95; //[R.K. 01/2017] unused variable? + // Double_t C = 0.228; //[R.K. 01/2017] unused variable? + // Double_t D = -3.839e-02; //[R.K. 01/2017] unused variable? + // Double_t E = 1.148e-03; //[R.K. 01/2017] unused variable? + + Double_t x = t - t0; + // if(x>0) elesig = A*exp(B*log(x)-C*x)*(1+D*x+E*x*x); // Sokolov Signal + if (x > 0) + elesig = pow(2. * x / 10., 2) * exp(-2. * x / 10.); // Wirtz signal + else + elesig = 0.; + + return elesig; +} + +// ===================================================================== + +Int_t CbmMustSingleStraw::StrawSignal(Int_t nsteps) +{ + + // creation of nstep values of + // the straw global Pulse (sum on all clusters) + // return the number of primary electrons + + PulseMax = 0; + Pulse.clear(); + PulseT.clear(); + AmplSig.clear(); + + Int_t neltot = TimeEle(); // creation and size of TeleTime (electron times) + + Double_t Tmax = 1.e-25; + for (Int_t k = 0; k < neltot; k++) + if (Tmax < TeleTime.at(k)) + Tmax = TeleTime.at(k); + Tmax += 100.; + + Double_t Dt = Tmax / nsteps; // number of steps of the signal + + // AmplSig is the amplitude of each electron + + for (Int_t j = 0; j < neltot; j++) { + AmplSig.push_back(bPolya * PolyaSamp()); + } + + // creation of the signal Pulse(PulseT) time in ns + for (Int_t j = 0; j < nsteps; j++) { + Double_t te = j * Dt; + Double_t sumele = 0.; + for (Int_t jj = 0; jj < neltot; jj++) { + Double_t te0 = TeleTime.at(jj); + sumele += AmplSig.at(jj) * Signal(te, te0); + } + + Pulse.push_back(sumele); + PulseT.push_back(te); + } + + // add a random noise (3% of maximum) plus + // a 1% of 200 ns periodic signal + + Double_t Pmax = 1.e-25; + for (Int_t k = 0; k < (Int_t)Pulse.size(); k++) + if (Pmax < Pulse.at(k)) + Pmax = Pulse.at(k); + + for (Int_t k = 0; k < (Int_t)Pulse.size(); k++) { + Pulse.at(k) += 0.03 * Pmax * gRandom->Uniform() + 0.01 * Pmax * (sin(6.28 * PulseT.at(k) / 120.)); + // if(Pulse[k]<0) Pulse[k] *= -1.; + } + + PulseMax = Pmax; + + // set variable threshold for the signals (constant fraction) + // Thresh1=0.05*Pmax; + // Thresh2=0.15*Pmax; + + return neltot; +} + +// ===================================================================== + +Int_t CbmMustSingleStraw::StrawTime() +{ + + // simulate the discrimination of the straw signal + // and give the time + // discriminator technique: set 2 threshold, select the first one + // (the low one) only if the second one is fired (FINUDA system) + + PulseTime = 0.; + + Int_t ind = 0; + Int_t flag1 = 0; + Int_t flag2 = 1; + + for (Int_t k = 0; k < (Int_t)Pulse.size(); k++) { + if (flag1 == 0 && Pulse[k] > Thresh1) { + flag1 = 1; + ind = k; + } + + // if(Pulse[k]<Thresh1) {flag1=0; ind=0;} // reset if signal decreases + + // if(flag1==1 && Pulse[k]>Thresh2) { + // flag2=1; + // break; + // } + } + if (flag1 == 1 && flag2 == 1) + PulseTime = PulseT.at(ind); + + return ind; +} + +// ===================================================================== + +Double_t CbmMustSingleStraw::TrueDist(Double_t Point[]) +{ + // service routine that finds the distance in cm from the wire + // by knowing the wire coordinates (class variables) + // and the input-output points Point[6] + + Double_t truedist = 0; + + // wire director cosines + Double_t Wlength = sqrt((Wx2 - Wx1) * (Wx2 - Wx1) + (Wy2 - Wy1) * (Wy2 - Wy1) + (Wz2 - Wz1) * (Wz2 - Wz1)); + Wp = (Wx2 - Wx1) / Wlength; + Wq = (Wy2 - Wy1) / Wlength; + Wr = (Wz2 - Wz1) / Wlength; + + // director cosines of the given track + Double_t Modu = sqrt((Point[3] * Point[0]) * (Point[3] * Point[0]) + (Point[4] * Point[1]) * (Point[4] * Point[1]) + (Point[5] * Point[2]) * (Point[5] * Point[2])); + Double_t dcx = (Point[3] - Point[0]) / Modu; + Double_t dcy = (Point[4] - Point[1]) / Modu; + Double_t dcz = (Point[5] - Point[2]) / Modu; + + // distance formula + Double_t p1 = (Point[0] - Wx1) * (dcy * Wr - dcz * Wq); + Double_t p2 = -(Point[1] - Wy1) * (dcx * Wr - dcz * Wp); + Double_t p3 = (Point[2] - Wz1) * (dcx * Wq - dcy * Wp); + Double_t Det = p1 + p2 + p3; + Double_t Disc = sqrt((dcy * Wr - dcz * Wq) * (dcy * Wr - dcz * Wq) + (dcz * Wp - dcx * Wr) * (dcz * Wp - dcx * Wr) + (dcx * Wq - dcy * Wp) * (dcx * Wq - dcy * Wp)); + if (Disc > 0) + truedist = TMath::Abs(Det / Disc); + + return truedist; // distance in cm +} + +// ===================================================================== + +Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) +{ + + // distance in cm from time in ns for pSTP =1 and pSTP=2 atm + // utility routine for the track reconstruction + // last update: A. Rotondi 3-3-2007 + + Double_t drift; + + // 1 absolute atm (NTP) 20-7-2006 GARFIELd Ar/CO2 90/10 MAGY + // ns --> mm + + if (pSTP < 1.9) { + if (Radius < 0.5) { + + drift = -0.0140 - 1.37281e-01 + 5.13978e-02 * time + 7.65443e-05 * pow(time, 2) - 9.53479e-06 * pow(time, 3) + 1.19432e-07 * pow(time, 4) - 6.19861e-10 * pow(time, 5) + + 1.35458e-12 * pow(time, 6) - 1.10933e-15 * pow(time, 7); + } + + else { + // 1600 V 5 mm + if (time < 120.) { + + drift = 0.0300 - 1.07377e-01 + 3.65134e-02 * time + 1.20909e-03 * pow(time, 2) - 4.56678e-05 * pow(time, 3) + 6.70207e-07 * pow(time, 4) - 4.99204e-09 * pow(time, 5) + + 2.19079e-11 * pow(time, 6) - 8.01791e-14 * pow(time, 7) + 2.16778e-16 * pow(time, 8); + } else { + + drift = 0.0300 - 8.91701e-01 + 4.68487e-02 * time + 1.00902e-03 * pow(time, 2) - 4.00359e-05 * pow(time, 3) + 6.23768e-07 * pow(time, 4) - 5.20556e-09 * pow(time, 5) + + 2.41502e-11 * pow(time, 6) - 5.85450e-14 * pow(time, 7) + 5.77250e-17 * pow(time, 8); + } + } + } + + else { + // 2 absolute atm 5 mm 80/20 (1 bar overpressure) + if (time <= 50.) { + + // on thresh static 10% + + drift = -0.0300 + 1.28551e-02 + 1.44029e-02 * time - 3.67834e-03 * pow(time, 2) + 3.32034e-04 * pow(time, 3) - 6.36592e-06 * pow(time, 4) - 7.82907e-08 * pow(time, 5) + + 3.58931e-09 * pow(time, 6) - 2.93491e-11 * pow(time, 7); + + // one thresh static 3% + // drift = +5.35238e-02 + // -4.25959e-02 *time + // +7.59448e-03 *pow(time,2) + // -1.44009e-04 *pow(time,3) + // -1.76365e-06 *pow(time,4) + // +3.29531e-08 *pow(time,5) + // +1.12115e-09 *pow(time,6) + // -1.72919e-11 *pow(time,7) ; + + } else if (50. < time && time < 130.) { + + // on thresh static 10% + + drift = -0.0190 + 4.40993e-01 - 2.91442e-02 * time + 3.06237e-03 * pow(time, 2) - 6.07870e-05 * pow(time, 3) + 5.97431e-07 * pow(time, 4) - 3.09238e-09 * pow(time, 5) + + 7.70537e-12 * pow(time, 6) - 6.49086e-15 * pow(time, 7); + + // one thresh static 3% + // drift = +2.25702e-02 + // +5.17806e-02 *time + // +2.53060e-04 *pow(time,2) + // -1.60338e-05 *pow(time,3) + // +2.14805e-07 *pow(time,4) + // -1.30249e-09 *pow(time,5) + // +3.38791e-12 *pow(time,6) + // -2.10503e-15 *pow(time,7) ; + + } + + else { + + // on thresh static 10% + drift = -0.0100 + 4.28757e-01 - 1.95413e-02 * time + 3.02333e-03 * pow(time, 2) - 6.13920e-05 * pow(time, 3) + 5.93656e-07 * pow(time, 4) - 3.05271e-09 * pow(time, 5) + + 8.05446e-12 * pow(time, 6) - 8.59626e-15 * pow(time, 7); + + // one thresh static 3% + // drift = +1.57217e-01 + // +5.79365e-02*time + // +2.15636e-04*pow(time,2) + // -1.66405e-05*pow(time,3) + // +2.13726e-07*pow(time,4) + // -1.26888e-09 *pow(time,5) + // +3.68533e-12 *pow(time,6) + // -4.24032e-15 *pow(time,7) ; + } + } + + drift = 0.1 * drift; + if (drift < 0.) + drift = 0.; + return drift; +} + +// -------------------------------------------------------------------------------- + +Double_t CbmMustSingleStraw::PartToTime(Double_t xPMass, Double_t xPMom, Double_t InOut[]) +{ + + // find the time of a particle of mass xPmass, momentum xPMom, with + // input-output coordinate InOut[6] + // Useful for MC pplication after a call to PutWireXYZ + + TInit(xPMass, xPMom, InOut); // start the event + Out1 = StrawCharge(); // energy loss (GeV) to generate charge + Out2 = StrawSignal(Nchann); // generate the straw signal + Out3 = StrawTime(); // find the straw drift time PulseTime + + return PulseTime; +} + +// -------------------------------------------------------------------------------- +Double_t CbmMustSingleStraw::PartToADC() +{ + + // return the energy loss in the tube as charge signal + // taking into account the Polya fluctuations + Double_t ADCsignal = 0.; + + for (Int_t j = 1; j <= NNClus; j++) { + + for (Int_t jc = 1; jc <= (Int_t)CNeleT[j - 1]; jc++) + ADCsignal += bPolya * GasGain * PolyaSamp(); + } + + return ADCsignal; +} + +// -------------------------------------------------------------------------------- + +Double_t CbmMustSingleStraw::FastPartToADC() +{ + + // return the energy loss (from the Urban distribution) + // in the tube as charge signal + // taking into account the Polya fluctuations + + Double_t ADCsignal = 0.; + + // number of elecrons. Wi is the mean energy lost per free + // electrn in eV + Int_t NtotEle = (Int_t)(1.e+09 * STUrban() / Wi); + + for (Int_t j = 1; j <= NtotEle; j++) { + + ADCsignal += bPolya * GasGain * PolyaSamp(); + } + + return ADCsignal; +} + +// ---------------------------------------------------------------------------------- +Double_t CbmMustSingleStraw::FastRec(Double_t TrueDcm, Int_t Flag) +{ + + // having the true distance TrueDcm (cm) as input, + // return the reconstructed distance (cm), in a fast + // and approximated way + // by sampling on the simulated reconstruction curve + // When Press =2 and Flag=1 one uses the julich experimental data + // A. Rotondi March 2007 + + Double_t resmic; + + // 1 atm pressure + if (pSTP < 1.9) { + if (Radius < 0.45) { + if (TrueDcm < 0.38) { + resmic = + 1.24506e+02 - 1.80117e+02 * TrueDcm + 3.76905e+03 * pow(TrueDcm, 2) - 4.63251e+04 * pow(TrueDcm, 3) + 1.80068e+05 * pow(TrueDcm, 4) - 2.21094e+05 * pow(TrueDcm, 5); + } else + resmic = 57.; + } + // radius > 0.4 cm + else { + if (TrueDcm < 0.48) { + resmic = 1.53656e+02 - 5.07749e+03 * TrueDcm + 1.73707e+05 * pow(TrueDcm, 2) - 2.72285e+06 * pow(TrueDcm, 3) + 2.28719e+07 * pow(TrueDcm, 4) - + 1.12921e+08 * pow(TrueDcm, 5) + 3.39427e+08 * pow(TrueDcm, 6) - 6.12741e+08 * pow(TrueDcm, 7) + 6.12041e+08 * pow(TrueDcm, 8) - 2.60444e+08 * pow(TrueDcm, 9); + } else + resmic = 72.; + } + } + // 2 atm pressure radius 5 cm + + else { + if (Flag == 0) { + if (TrueDcm < 0.48) { + resmic = +1.06966e+02 - 4.03073e+03 * TrueDcm + 1.60851e+05 * pow(TrueDcm, 2) - 2.87722e+06 * pow(TrueDcm, 3) + 2.67581e+07 * pow(TrueDcm, 4) - + 1.43397e+08 * pow(TrueDcm, 5) + 4.61046e+08 * pow(TrueDcm, 6) - 8.79170e+08 * pow(TrueDcm, 7) + 9.17095e+08 * pow(TrueDcm, 8) - 4.03253e+08 * pow(TrueDcm, 9); + } else + resmic = 30.; + } else { + // data from julich + if (TrueDcm < 0.48) { + resmic = 20. + 1.48048e+02 - 3.35951e+02 * TrueDcm - 1.87575e+03 * pow(TrueDcm, 2) + 1.92910e+04 * pow(TrueDcm, 3) - 6.90036e+04 * pow(TrueDcm, 4) + + 1.07960e+05 * pow(TrueDcm, 5) - 5.90064e+04 * pow(TrueDcm, 6); + } else + resmic = 65.; + } + } + + // real distance in cm + Double_t rsim = gRandom->Gaus(TrueDcm, resmic * 0.0001); + if (rsim < 0.) + rsim = TrueDcm - TrueDcm * gRandom->Uniform(0., 1.); + else if (rsim > 0.5) + rsim = TrueDcm + (0.5 - TrueDcm) * gRandom->Uniform(0., 1.); + + return rsim; +} +// -------------------------------------------------------------------------------- +Double_t CbmMustSingleStraw::DiffLong(Double_t Distcm) +{ + + // return the longitudinal diffusion + // from cm to microns + // MAGY GARFIELD Ar/CO2 90/10 1 bar (NTP) 20-7-2006 + // + Double_t DiffMic; + + if (pSTP < 1.9) { + if (Radius < 0.5) { + // 4 mm 1600 V 90/10 + DiffMic = 0.896 + 1387. * Distcm - 1.888e+04 * pow(Distcm, 2) + 1.799e+05 * pow(Distcm, 3) - 9.848e+05 * pow(Distcm, 4) + 3.009e+06 * pow(Distcm, 5) - + 4.777e+06 * pow(Distcm, 6) + 3.074e+06 * pow(Distcm, 7); + } else { + // 5 mm 1600 V + DiffMic = 1.537 + 1246. * Distcm - 1.357e+04 * pow(Distcm, 2) + 1.049e+05 * pow(Distcm, 3) - 4.755e+05 * pow(Distcm, 4) + 1.211e+06 * pow(Distcm, 5) - + 1.6e+06 * pow(Distcm, 6) + 8.533e+05 * pow(Distcm, 7); + } + } + + else { + // 2000V 5 mm 2 bar 80/20 + DiffMic = 2.135 + 818. * Distcm - 1.044e+04 * pow(Distcm, 2) + 8.31e+04 * pow(Distcm, 3) - 3.492e+05 * pow(Distcm, 4) + 7.959e+05 * pow(Distcm, 5) - + 9.378e+05 * pow(Distcm, 6) + 4.492e+05 * pow(Distcm, 7); + } + return DiffMic; +} +// -------------------------------------------------------------------------------- +Double_t CbmMustSingleStraw::DiffTran(Double_t Distcm) +{ + + // return the transverse diffusion in microns + // from cm to microns + // MAGY GARFIELD Ar/CO2 90/10 1 bar (NTP) 20-7-2006 + // + Double_t DiffMic; + + if (pSTP < 1.9) { + if (Radius < 0.5) { + // 4 mm 1600 V 90/10 + // DiffMic = + 0.8513 + 1648.*Distcm - 1.085e+04*pow(Distcm,2) + // + 7.38e+04*pow(Distcm,3) - 3.025e+05*pow(Distcm,4) + // + 6.067e+05*pow(Distcm,5) - 4.643e+04*pow(Distcm,6); + DiffMic = + +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); + } else { + // 5 mm 1600 V 90/10 + DiffMic = + +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); + } + } else { + + // 5 mm 2000 V 2 bar 80/20 + DiffMic = +2.094 + 1138. * Distcm - 7557. * pow(Distcm, 2) + 2.968e+04 * pow(Distcm, 3) - 6.577e+04 * pow(Distcm, 4) + 7.581e+04 * pow(Distcm, 5) - 3.497e+04 * pow(Distcm, 6); + } + return DiffMic; +} +// -------------------------------------------------------- +Double_t CbmMustSingleStraw::DistEle(Double_t time) +{ + + // dist in cm from time in ns for pSTP =1 and pSTP=2 + // utility routine for the >SINGLE< electron reconstruction + // last update: A. Rotondi 20-7-2006 + + Double_t drift; + + // 1 absolute atm (NTP) 20-7-2006 GARFIELd Ar/CO2 90/10 MAGY + // ns --> cm + + time *= 0.001; // time in micro s + + if (pSTP < 2.) { + if (Radius < 0.5) { + // 1600 V 4 mm 90/10 + drift = 0.001629 + 6.194 * time - 56.55 * pow(time, 2) + 355.8 * pow(time, 3) - 903.2 * pow(time, 4); + } else { + // 1600 V 5 mm 90/10 + drift = 0.003365 + 5.734 * time - 41.88 * pow(time, 2) + 191.2 * pow(time, 3) - 333.4 * pow(time, 4); + } + } + + else { + + // 2 absolute atm 2000 V 5 mm 80/20 (1 bar overpressure) + + drift = 0.003365 + 7.056 * time - 62.28 * pow(time, 2) + 306.1 * pow(time, 3) - 558.7 * pow(time, 4); + } + return drift; // in cm +} diff --git a/core/detectors/must/CbmMustSingleStraw.h b/core/detectors/must/CbmMustSingleStraw.h new file mode 100644 index 0000000000..656fc98f08 --- /dev/null +++ b/core/detectors/must/CbmMustSingleStraw.h @@ -0,0 +1,281 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustSingleStraw header file +// +// Copied from CbmFtsSingleStraw +// +// authors: Radoslaw Karabowicz, GSI, 2024 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMMUSTSINGLESTRAW_H +#define CBMMUSTSINGLESTRAW_H 1 +// from ROOT +#include <TH2.h> +#include <TMatrix.h> +#include <TMatrixD.h> +#include <TNamed.h> +#include <TVector3.h> +// standard +#include <vector> + +// ClassImp(TMatrixDBase) +// class TMatrixD;; + +class TH2F; + +class CbmMustSingleStraw : public TNamed { + + // -------------------------------------------------------------------- + public: + CbmMustSingleStraw(); + virtual ~CbmMustSingleStraw(){}; + ClassDef(CbmMustSingleStraw, 1); + + // Get methods + + Double_t GetCDist(Int_t k) { return CDist[k]; }; + Double_t GetCNele(Int_t k) { return CNele[k]; }; + Double_t GetCNeleT(Int_t k) { return CNeleT[k]; }; + Double_t GetTeleTime(Int_t k) { return TeleTime[k]; }; + Double_t GetPulse(Int_t k) { return Pulse[k]; }; + Double_t GetPulseT(Int_t k) { return PulseT[k]; }; + Double_t GetWi() { return Wi * 1.e-09; }; // in GeV + Double_t GetGasGain() { return GasGain; }; + Double_t GetXmax() { return Xmax; }; + Double_t GetDx() { return Dx; }; + Double_t GetEmed() { return Emed; }; + Double_t GetEmin() { return Emin; }; + Double_t GetNcl() { return Ncl; }; + Double_t GetCsi() { return Csi; }; + Double_t GetDelta() { return Delta; }; + Double_t GetEmax() { return Emax; }; + Double_t GetIAr() { return IAr; }; + Int_t GetNNClus() { return NNClus; }; + Int_t GetNchann() { return Nchann; }; + Double_t GetPulseMax() { return PulseMax; }; + Double_t GetGamma() { return gamma; }; + Double_t GetBeta() { return beta; }; + Double_t GetpSTP() { return pSTP; }; + Double_t GetPulseTime() { return PulseTime; }; + Double_t GetbPolya() { return bPolya; }; + Double_t GetSigUrb() { return SigUrb; }; + Double_t GetNUrban() { return NUrban; }; + Double_t GetEup() { return Eup; }; + Double_t GetAvUrb() { return AvUrb; }; + + // coordinates + Double_t GetXin() { return Xin; }; + Double_t GetYin() { return Yin; }; + Double_t GetZin() { return Zin; }; + Double_t GetXout() { return Xout; }; + Double_t GetYout() { return Yout; }; + Double_t GetZout() { return Zout; }; + Double_t GetRpath() { return Rpath; }; + + TVector3 GetWDist(Int_t k) { return WDist[k]; }; + + // put methods + void PutTrackXYZ(Double_t v1, Double_t v2, Double_t v3, Double_t v4, Double_t v5, Double_t v6) + { + Xin = v1; + Yin = v2; + Zin = v3; + Xout = v4; + Yout = v5; + Zout = v6; + }; + void PutRpath(Double_t value) { Rpath = value; }; + + void PutPolya(Double_t par) { bPolya = par; }; + + void PutRadius(Double_t value) { Radius = value; }; + void PutPress(Double_t value) { pSTP = value; }; + + // ---------------------------------------------------------------------------- + // calls at each track for MC applications + + // define the wire + void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, Double_t w4, Double_t w5, Double_t w6); + // straw time + Double_t PartToTime(Double_t Mass, Double_t Momentum, Double_t InOut[]); + // ADC signal corresponding to the energy loss of StrawCharge + Double_t PartToADC(); + + // fast reconstructed distance in cm + Double_t FastRec(Double_t TrueDcm, Int_t Flag); + + // ADC signal charge fast simulation + Double_t FastPartToADC(); + + // ---------------------------------------------------------------------------- + // standard calls + + // once to set constants + + void TConst(Double_t Radius, Double_t pSTP, Double_t ArP, Double_t CO2P); + + // to define the track + void TInit(Double_t Mass, Double_t Momentum, Double_t InOut[]); // for each track + + // other possible calls + + Double_t StrawCharge(); // total discharge electron calculation + + Int_t StrawSignal(Int_t nsteps); // oscilloscope signal generation (ns) + // Pulse[PulseT] in ns + // return number of primary electrons + Int_t StrawTime(); // output time of the straw (ns) & + // PulseTime[Int_t] in ns + // Int_t StrawTot(); // Time over threshold time of the straw (ns) not implemented + + Double_t TimnsToDiscm(Double_t time); // from time (ns) to radius in cm + + //----------------------------------------------------------------------------- + // utility methods + + void TDirCos(); // track director cosines + Double_t TrueDist(Double_t Point[]); // true distance wire-track + Double_t DiffLong(Double_t distcm); // longituinal diffusion in microns + Double_t DiffTran(Double_t distcm); // transverse diffusion in microns + void Polya(Double_t bpar); // Polya cumulative calculation + Double_t PolyaSamp(); // sampling from Polya distribution + Double_t RRise(Double_t gamma); // relativistic rise calculation + Int_t Cluster(); // cluster generation + Int_t Eject(); // primary electron generation + TVector3 WDistCalc(Double_t d); // distance electron-wire + Double_t Signal(Double_t t, Double_t t0); // signal functional form + Double_t STEloss(); // Landau energy loss + Double_t STUrban(); // Urban energy loss + Int_t TimeEle(); // arrivals times of all the electrons + Double_t DistEle(Double_t tns); // distance of all the electrons + + //------------------------------------------------------------------------------ + + private: + //----------------------------------------------------------------- + + // distance, number of electrons (with delta rays), + // distance from wire of the cluster + std::vector<Double_t> CDist, CDistC, CNele, CNeleT, TeleTime, AmplSig; + std::vector<Double_t> Pulse, PulseT; + std::vector<TVector3> WDist; + + // set constants + // masses in GeV, energies in GeV, cgs system + + // Input for the medium + + // Double_t PClus[20], CO2Clus[20], CumClus[21], CH4Clus[20]; + Double_t CumClus[21], CH4Clus[20]; // shadows deleted + + Double_t Wi; + Double_t ArPerc, CO2Perc, CH4Perc; // volume percentages + Double_t ArWPerc, CO2WPerc, CH4WPerc; // weight percentages + Double_t pSTP; // pressure (STP reference) + Double_t Radius; // straw radius + Double_t AAr; // Argon + Double_t ZAr; // Argon + Double_t RhoAr; // g/cm3 (1.78 mg/cm3) + Double_t NclAr; // clusters/cm + + Double_t EmedAr; + Double_t EminAr; + Double_t EmpAr; + Double_t CsiAr; + Double_t IAr; // ionization potential (188 eV) + Double_t WiAr; // energy to reate an ion pair in Argon + Double_t Ncl; // mean number of cluster in the mixture + Double_t Ecl; // electron per cluster + Double_t Lcl; // mean free path between clusters + Double_t Ntote; // mean total number of eletrons + Double_t GasGain; // gain of the gas + Double_t Cutoff; // limit the number of primry electrons + // CO2 + Double_t EmedCO2; + Double_t EminCO2; + Double_t EmpCO2; + Double_t CsiCO2; + Double_t ACO2; // CO2 (39.948) + Double_t ZCO2; // CO2 (18) + Double_t RhoCO2; // g/cm3 CO2 (1.98 mg/cm3) + Double_t ICO2; // ionization potential (GeV) (188 eV) + Double_t WiCO2; // energy to create an ion pair + Double_t NclCO2; // clusters/cm + + // Methane CH4 ------------------------------------------------ + Double_t EmedCH4; + Double_t EmpCH4; + Double_t CsiCH4; + Double_t EminCH4; + Double_t ACH4; // CO2 (39.948) + Double_t ZCH4; // CO2 (18) + Double_t RhoCH4; // g/cm3 CO2 (0.71 mg/cm3) + Double_t ICH4; // ionization potential (GeV) (188 eV) + Double_t WiCH4; // energy to create an ion pair + Double_t NclCH4; // clusters/cm + + Double_t RhoMixCO2; + Double_t RhoMixCH4; + //---------------------------------------------------------------------- + // Input for the particle (Gev, energy loses in Kev + + Double_t PZeta; // charge + Double_t piMass; // particle mass (GeV) + Double_t PMass; // incident particle mass + Double_t PMom; // particle momentum (GeV) + Double_t Dx; // distance travelled in gas (cm) + Double_t eMass; // electron mass (GeV) (0.511 MeV) + Double_t prMass; // proton mass + Double_t Delta; // polarization Sternheimer parameter + Int_t CNumb; // current number of clusters + + // ------------------------------------------------------ + // quantities for each track + // calculated in TInit + + Double_t PEn; // particle energy GeV + Double_t beta; + Double_t gamma; + Double_t Emed; // GeV + Double_t Emin; // GeV/cm (2.7 keV) + Double_t Csi; + Double_t Emax; + Double_t Emp; // most probable energy + Int_t NNClus; // number of clusters + + // --------------------------------------------------------------------- + // mathematical and statistical parameters + + Double_t PolyaCum[100], Xs[100]; + Double_t Xin, Yin, Zin, Xout, Yout, Zout, Rpath; + Int_t NPolya; + Double_t Xmax; + Double_t bPolya; + Double_t Calpha, Cbeta, Cgamma; + Double_t NUrban; // total number of collision in the Urban model + Double_t SigUrb; // std dev of the Urban distribution (routine STUrban) + Double_t Eup; // upper limit of the Urban distribution (routine STUrban) + Double_t AvUrb; // average of the Urban distribution (routine STUrban) + + // -------------------------------------------------------------- + // for the straws + + Double_t Wx1, Wy1, Wz1, Wx2, Wy2, Wz2; // wire coordinates + Double_t Wp, Wq, Wr; // director cosine of the wire + Double_t PulseMax; + Double_t PulseTime; + Double_t Thresh1; // first threshold + Double_t Thresh2; + Int_t Nchann; // number of channels for the straw signal + + // ---------------------------------------------------------------------- + // dummy + + Double_t Out1; + Int_t Out2, Out3; +}; + +#endif diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx new file mode 100644 index 0000000000..876245ff3e --- /dev/null +++ b/core/detectors/must/CbmMustTube.cxx @@ -0,0 +1,93 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustTube header file +// +// Copied from PndFtsTube +// +// authors: Radoslaw Karabowicz, GSI, 2024 +//////////////////////////////////////////////////////////////////////////// + +#include "CbmMustTube.h" +// standard +#include <iostream> + +CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(0), fRadOut(0), fHalfLength(0) +{ + fRotationMatrix[0][0] = -1.; + fRotationMatrix[0][1] = -1.; + fRotationMatrix[0][2] = -1.; + + fRotationMatrix[1][0] = -1.; + fRotationMatrix[1][1] = -1.; + fRotationMatrix[1][2] = -1.; + + fRotationMatrix[2][0] = -1.; + fRotationMatrix[2][1] = -1.; + fRotationMatrix[2][2] = -1.; +} + +CbmMustTube::CbmMustTube(CbmMustTube &tube) + : TObject(tube), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength()) +{ + fRotationMatrix.ResizeTo(3, 3); + fRotationMatrix = tube.GetRotationMatrix(); +} + +CbmMustTube::CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, + Double_t r33, Double_t radin, Double_t radout, Double_t hl) + : fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl) +{ + + fRotationMatrix[0][0] = r11; + fRotationMatrix[0][1] = r12; + fRotationMatrix[0][2] = r13; + + fRotationMatrix[1][0] = r21; + fRotationMatrix[1][1] = r22; + fRotationMatrix[1][2] = r23; + + fRotationMatrix[2][0] = r31; + fRotationMatrix[2][1] = r32; + fRotationMatrix[2][2] = r33; +} + +CbmMustTube::~CbmMustTube() +{ + // fCenPosition.Delete(); + // fRotationMatrix.Delete(); +} + +TVector3 CbmMustTube::GetPosition() const +{ + return fCenPosition; +} + +TMatrixT<Double_t> CbmMustTube::GetRotationMatrix() const +{ + return fRotationMatrix; +} + +Double_t CbmMustTube::GetRadIn() const +{ + return fRadIn; +} + +Double_t CbmMustTube::GetRadOut() const +{ + return fRadOut; +} + +Double_t CbmMustTube::GetHalfLength() const +{ + return fHalfLength; +} + +TVector3 CbmMustTube::GetWireDirection() const +{ + return TVector3(fRotationMatrix[0][2], fRotationMatrix[1][2], fRotationMatrix[2][2]); +} + +ClassImp(CbmMustTube) diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h new file mode 100644 index 0000000000..224547f5fa --- /dev/null +++ b/core/detectors/must/CbmMustTube.h @@ -0,0 +1,49 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMustTube header file +// +// Copied from PndFtsTube +// +// authors: Radoslaw Karabowicz, GSI, 2024 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMMUSTTUBE_H +#define CBMMUSTTUBE_H 1 + +// from ROOT +#include "TVector3.h" +#include "TMatrixT.h" +#include "TObject.h" + +class CbmMustTube : public TObject { + + public: + /** Default constructor **/ + CbmMustTube(); + CbmMustTube(CbmMustTube &tube); + + ~CbmMustTube(); + CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33, + Double_t radin, Double_t radout, Double_t hl); + + TVector3 GetPosition() const; + TMatrixT<Double_t> GetRotationMatrix() const; + Double_t GetRadIn() const; + Double_t GetRadOut() const; + Double_t GetHalfLength() const; + TVector3 GetWireDirection() const; + + bool IsSkew() const { return (0. != GetWireDirection().X()); } + + private: + TVector3 fCenPosition; + TMatrixT<double> fRotationMatrix; + Double_t fRadIn, fRadOut, fHalfLength; + + ClassDef(CbmMustTube, 1); +}; + +#endif diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C new file mode 100644 index 0000000000..23fc129f8c --- /dev/null +++ b/macro/must/run_sim.C @@ -0,0 +1,135 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0) +{ + // 2212 proton + TStopwatch timer; + timer.Start(); + gDebug = 0; + + TString dir = getenv("VMCWORKDIR"); + + TString tut_configdir = dir + "/sim/transport/gconfig/"; + gSystem->Setenv("CONFIG_DIR", tut_configdir.Data()); + + FairRunSim *fRun = new FairRunSim(); + + // set the MC version used + fRun->SetName("TGeant4"); + + // Cave geometry + TString caveGeom = "cave.geo"; + // Target geometry + TString targetGeom = "tpassive/targetbox_v22c.gdml"; + // Beam pipe geometry + TString pipeGeom = "pipe/pipe_v22d.geo.root"; + // Magnet geometry and field map + TString magnetGeom = "magnet/magnet_v22b.geo.root"; + TString fieldMap = "field_v22d"; + Double_t fieldZ = 50.; // z position of field centre + Double_t fieldScale = 1.; // field scaling factor + + std::string outFile = "points.root"; + std::string parFile = "params.root"; + + fRun->SetSink(new FairRootFileSink(outFile)); + + // Fill the Parameter containers for this run + //------------------------------------------- + + FairRuntimeDb *rtdb = fRun->GetRuntimeDb(); + Bool_t kParameterMerged = kTRUE; + FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged); + output->open(parFile.c_str()); + rtdb->setOutput(output); + + // Set Material file Name + fRun->SetMaterials("media.geo"); + + + // ----- Create geometry ---------------------------------------------- + FairModule* cave = new CbmCave("CAVE"); + cave->SetGeometryFileName(caveGeom); + fRun->AddModule(cave); + + FairModule* pipe = new CbmPipe("PIPE"); + pipe->SetGeometryFileName(pipeGeom); + fRun->AddModule(pipe); + + // FairModule* target = new CbmTarget("Target"); + // target->SetGeometryFileName(targetGeom); + // fRun->AddModule(target); + + FairModule* magnet = new CbmMagnet("MAGNET"); + magnet->SetGeometryFileName(magnetGeom); + fRun->AddModule(magnet); + + FairDetector *must = new CbmMust("MUST", kTRUE); + must->SetGeometryFileName("must/must.geo"); + fRun->AddModule(must); + + // Create and Set Event Generator + //------------------------------- + + FairPrimaryGenerator *primGen = new FairPrimaryGenerator(); + fRun->SetGenerator(primGen); + + // Box Generator + FairBoxGenerator *boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl. + if (p2 < 0.) + p2 = p1; + boxGen->SetPRange(p1, p1); // GeV/c //setPRange vs setPtRange + boxGen->SetPhiRange(45, 45); // Azimuth angle range [degree] + boxGen->SetThetaRange(20, 20); // Polar angle in lab system range [degree] + boxGen->SetCosTheta(); + boxGen->SetXYZ(0., 0., 0.); + primGen->AddGenerator(boxGen); + + fRun->SetStoreTraj(kTRUE); + fRun->SetBeamMom(15.); + + // ----- Create magnetic field ---------------------------------------- + CbmFieldMap* magField = new CbmFieldMapSym3(fieldMap); + magField->SetPosition(0., 0., fieldZ); + magField->SetScale(fieldScale); + fRun->SetField(magField); + + fRun->Init(); + + // Transport nEvents + // ----------------- + fRun->Run(nEvents); + + rtdb->saveOutput(); + rtdb->print(); + + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime); + + TChain chain("cbmsim"); + chain.Add(outFile.c_str()); + auto nofE = chain.GetEntries(); + auto nofT = chain.Draw("MCTrack.fPx", "", "goff"); + auto nofP = chain.Draw("MUSTPoint.fPx", "", "goff"); + cout << "Output chain has " << nofE << " events, " << nofT << " tracks, " << nofP << " points." << endl; + + if (nofE < nEvents) { + std::cerr << "Not enough events (" << nofE << " < " << nEvents << ") in the output chain." << endl; + return 1; + } + if (nofT < nEvents) { + std::cerr << "Not enough tracks (" << nofT << " < " << nEvents << ") in the output chain." << endl; + return 1; + } + if (nofP < nEvents * 10) { + std::cerr << "Not enough points (" << nofP << " < " << nEvents * 10 << ") in the output chain." << endl; + return 1; + } + cout << "Simulation successful." << endl; + + return 0; +} diff --git a/sim/detectors/must/CMakeLists.txt b/sim/detectors/must/CMakeLists.txt new file mode 100644 index 0000000000..41bb26c301 --- /dev/null +++ b/sim/detectors/must/CMakeLists.txt @@ -0,0 +1,35 @@ +set(INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR} + ) + + +set(SRCS + CbmMust.cxx + ) + + +set(LIBRARY_NAME CbmMustSim) +set(LINKDEF ${LIBRARY_NAME}LinkDef.h) +set(PUBLIC_DEPENDENCIES + CbmBase + CbmData + CbmMustBase + FairRoot::Base + ROOT::Core + ROOT::Hist + ROOT::MathCore + ) + +set(PRIVATE_DEPENDENCIES + CbmSimBase + FairRoot::ParBase + ROOT::EG + ROOT::Geom + ROOT::Gpad + ROOT::Physics + ROOT::RIO + ) + +generate_cbm_library() + + diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx new file mode 100644 index 0000000000..9722a80964 --- /dev/null +++ b/sim/detectors/must/CbmMust.cxx @@ -0,0 +1,405 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMust source file +// +// Class for simulation of MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmMust by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#include "CbmMust.h" +// from CbmRoot, this library +#include "CbmGeoMustPar.h" +#include "CbmGeoMust.h" +#include "CbmDefs.h" +#include "CbmStack.h" +#include "CbmMustMapCreator.h" +// from FairRoot +#include <FairRun.h> +#include <FairGeoInterface.h> +#include <FairGeoLoader.h> +#include <FairGeoNode.h> +#include <FairGeoRootBuilder.h> +#include <FairRootManager.h> +#include <FairRuntimeDb.h> +#include <FairVolume.h> +#include <FairLogger.h> +// from ROOT +#include <TClonesArray.h> +#include <TLorentzVector.h> +#include <TParticle.h> +#include <TVirtualMC.h> +#include <TGeoMatrix.h> +#include <TObjArray.h> +#include <TGeoTube.h> +#include <TGeoMedium.h> +#include <TGeoVolume.h> +// standard +#include <iostream> + +using std::string; + +// TODO: read this from geant initialization +#define innerStrawDiameter 1. +// #define redefineLambdaChargedDecay 0 + +// ----- Default constructor ------------------------------------------- +CbmMust::CbmMust() + : fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0), fMomIn(0, 0, 0, 0), + fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0), fpostotin(0, 0, 0, 0), + fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0) +{ + fMustCollection = new TClonesArray("CbmMustPoint"); + fVerboseLevel = 0; +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +CbmMust::CbmMust(const char *name, Bool_t active) + : FairDetector(name, active), fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0), + fMomIn(0, 0, 0, 0), fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0), + fpostotin(0, 0, 0, 0), fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0) +{ + fMustCollection = new TClonesArray("CbmMustPoint"); + fVerboseLevel = 0; + fGeoType = 1; // CHECK +} +// ------------------------------------------------------------------------- + +// ----- Destructor ---------------------------------------------------- +CbmMust::~CbmMust() +{ + if (fMustCollection) { + fMustCollection->Delete(); + delete fMustCollection; + } +} +// ------------------------------------------------------------------------- + +// ----- Private method GetSquaredDistanceFromWire ----------------------- +float CbmMust::GetSquaredDistanceFromWire() +{ + TLorentzVector entryPosition; + + float positionInMother[3], positionInStraw[3]; + + gMC->TrackPosition(entryPosition); + positionInMother[0] = entryPosition.X(); + positionInMother[1] = entryPosition.Y(); + positionInMother[2] = entryPosition.Z(); + gMC->Gmtod(positionInMother, positionInStraw, 1); + + return positionInStraw[0] * positionInStraw[0] + positionInStraw[1] * positionInStraw[1]; +} +// ------------------------------------------------------------------------- + +bool CbmMust::Split(string &aDest, string &aSrc, char aDelim) +{ + if (aSrc.empty()) + return false; + + string::size_type pos = aSrc.find(aDelim); + + aDest = aSrc.substr(0, pos); + + if (pos != string::npos) + aSrc = aSrc.substr(pos + 1); + else + aSrc = ""; + + return true; +} + +string CbmMust::GetStringPart(string &aSrc, Int_t part, char aDelim) +{ + string retval = "", sub; + + int counter = 0; + + while (Split(sub, aSrc, aDelim)) { + if (counter == part) { + retval = sub; + break; + } + counter++; + } + + return retval; +} + +// ----- Public method ProcessHits -------------------------------------- +Bool_t CbmMust::ProcessHits(FairVolume *vol) +{ + + // TParticle* particle = gMC->GetStack()->GetCurrentTrack(); //[R.K. 01/2017] unused variable? + // TGeoMedium *medium = (TGeoMedium*) vol->getGeoNode()->getRootVolume()->GetMedium(); //[R.K. 01/2017] unused variable? + // Double_t epsil = medium->GetParam(6); //[R.K. 01/2017] unused variable? + + TString vol_name(gMC->CurrentVolName()); + TGeoHMatrix M; + gMC->GetTransformation(gMC->CurrentVolPath(), M); + TString name(gMC->CurrentVolName()); + + if (gMC->TrackCharge() != 0.) { + + if (gMC->IsTrackEntering()) { + valid = kTRUE; + + // Set parameters at entrance of volume. Reset ELoss. + fELoss = 0.; + fTime = gMC->TrackTime() * 1.0e09; + fLength = gMC->TrackLength(); + gMC->TrackPosition(fPos); + gMC->TrackMomentum(fMomIn); + gMC->TrackPosition(fpostotin); // da cancellare + Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified + Double_t localPos[3] = {0., 0., 0.}; // stt1 modified + + globalPos[0] = fPos.X(); + globalPos[1] = fPos.Y(); + globalPos[2] = fPos.Z(); + + gMC->Gmtod(globalPos, localPos, 1); + fPosInLocal.SetXYZM(localPos[0], localPos[1], localPos[2], 0.0); + } + + // Sum energy loss for all steps in the active volume + fELoss += gMC->Edep(); + + // Create CbmMustPoint at exit of active volume -- but not into the wire + if (gMC->IsTrackExiting() && valid == kTRUE) { + valid = kFALSE; + fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); + fVolumeID = static_cast<int>(ECbmModuleId::kEcal); // vol->getMCid(); + + if (fTrackID != 0) { + if (fVerboseLevel > 2) + LOG(info) << "[MUST] test Vol----------" << vol->getMCid(); + if (fVerboseLevel > 2) + LOG(info) << "fTrackID-----" << fTrackID; + } + + fMass = gMC->TrackMass(); // mass (GeV) + gMC->TrackPosition(fPosOut); + gMC->TrackMomentum(fMomOut); + gMC->TrackPosition(fpostotout); // da cancellare + Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified + Double_t localPos[3] = {0., 0., 0.}; // stt1 modified + + gMC->Gdtom(localPos, globalPos, 1); + + fPos.SetXYZM(globalPos[0], globalPos[1], globalPos[2], 0.0); + + globalPos[0] = fPosOut.X(); + globalPos[1] = fPosOut.Y(); + globalPos[2] = fPosOut.Z(); + + gMC->Gmtod(globalPos, localPos, 1); + fPosOutLocal.SetXYZM(localPos[0], localPos[1], localPos[2], 0.0); + + // string basename("stt1tube"); + string basename; + TString volumename; + string hashmark("#"), volName, fullName, number, specialname, volPath(gMC->CurrentVolPath()), volPath2(gMC->CurrentVolPath()); + + volumename = volPath; + volName = GetStringPart(volPath, 2, '/'); + number = GetStringPart(volName, 1, '_'); + + if (fTrackID != 0) { + if (fVerboseLevel > 2) + LOG(info) << "[MUST] befor Mapper------"; + } + + fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0); + + // CHECK map creator------------------------------------------------- + // CbmMustMapCreator *mapper = new CbmMustMapCreator(fGeotype); + // testTubeID=tube number as in the geometry file.... + // we need to calculate the real number in order to have a different + // number for each tube (also for up and down short tubes) + // Int_t tubeID = fMapper->GetTubeIDFromPath(gMC->CurrentVolPath()); + Int_t chamberID = fMapper->GetChamberIDFromPath(gMC->CurrentVolPath()); + Int_t layerID = fMapper->GetLayerID(chamberID, gMC->CurrentVolPath()); + // LOG(info)<<"LAYERID==========="<<layerID; + // tubeID=at each tube corresponds only one id number..... + Int_t totTubeID = fMapper->GetTubeIDTot(chamberID, layerID, gMC->CurrentVolPath()); + // LOG(info)<<gMC->CurrentVolPath() << " -> " << "CbmMust.cxx. layer + chamber + tubeID -> totTubeId = "<<layerID<<" + "<<chamberID<<" + "<<tubeID<<" -> "<<totTubeID; + ////---------------------------------------------------------------- + + AddHit(fTrackID, fVolumeID, totTubeID, chamberID, layerID, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()), + TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), + fTime, fLength, fELoss, fMass); + + if (fTrackID != 0) { + if (fVerboseLevel > 2) + LOG(info) << "AddHit CbmMust.cxx= " << fTrackID; + } + + // Increment number of stt points for TParticle + CbmStack *stack = (CbmStack *)gMC->GetStack(); + stack->AddPoint(ECbmModuleId::kEcal); + ResetParameters(); + } + } + + return kTRUE; +} +// ------------------------------------------------------------------------- + +// ----- Public method EndOfEvent -------------------------------------- +void CbmMust::EndOfEvent() +{ + if (fVerboseLevel) + Print(); + fMustCollection->Delete(); + fPosIndex = 0; +} +// ------------------------------------------------------------------------- + +// ----- Public method Register ---------------------------------------- +void CbmMust::Register() +{ + FairRootManager::Instance()->Register("MUSTPoint", "Must", fMustCollection, kTRUE); +} +// ------------------------------------------------------------------------- + +// ----- Public method GetCollection ----------------------------------- +TClonesArray *CbmMust::GetCollection(Int_t iColl) const +{ + if (iColl == 0) + return fMustCollection; + else + return nullptr; +} +// ------------------------------------------------------------------------- + +// ----- Public method Print ------------------------------------------- +void CbmMust::Print(Option_t *) const +{ + Int_t nHits = fMustCollection->GetEntriesFast(); + + LOG(info) << " CbmMust: " << nHits << " points registered in this event."; + + if (fVerboseLevel > 1) + for (Int_t i = 0; i < nHits; i++) + (*fMustCollection)[i]->Print(); +} +// ------------------------------------------------------------------------- + +// ----- Public method Reset ------------------------------------------- +void CbmMust::Reset() +{ + fMustCollection->Delete(); + ResetParameters(); +} +// ------------------------------------------------------------------------- + +// ----- Public method CopyClones -------------------------------------- +void CbmMust::CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) +{ + Int_t nEntries = cl1->GetEntriesFast(); + + LOG(info) << " CbmMust: " << nEntries << " entries to add."; + + TClonesArray &clref = *cl2; + + CbmMustPoint *oldpoint = nullptr; + for (Int_t i = 0; i < nEntries; i++) { + oldpoint = (CbmMustPoint *)cl1->At(i); + + Int_t index = oldpoint->GetTrackID() + offset; + + oldpoint->SetTrackID(index); + new (clref[fPosIndex]) CbmMustPoint(*oldpoint); + fPosIndex++; + } + LOG(info) << " CbmMust: " << cl2->GetEntriesFast() << " merged entries."; +} +// ------------------------------------------------------------------------- + +void CbmMust::Initialize() +{ + LOG(info) << " -I- Initializing CbmMust()"; + FairDetector::Initialize(); +} + +// ----- Public method ConstructGeometry ------------------------------- +void CbmMust::ConstructGeometry() +{ + FairGeoLoader *geoLoad = FairGeoLoader::Instance(); + FairGeoInterface *geoFace = geoLoad->getGeoInterface(); + CbmGeoMust *Geo = new CbmGeoMust(); + Geo->setGeomFile(GetGeometryFileName()); + geoFace->addGeoModule(Geo); + + Bool_t rc = geoFace->readSet(Geo); + if (rc) + Geo->create(geoLoad->getGeoBuilder()); + + TList *volList = Geo->getListOfVolumes(); + + // store geo parameter + FairRun *fRun = FairRun::Instance(); + FairRuntimeDb *rtdb = FairRun::Instance()->GetRuntimeDb(); + CbmGeoMustPar *par; + par = (CbmGeoMustPar *)(rtdb->getContainer("CbmGeoMustPar")); + rtdb->getListOfContainers()->Print(); + TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); + fPassNodes = par->GetGeoPassiveNodes(); + + TListIter iter(volList); + FairGeoNode *node = nullptr; + FairGeoVolume *aVol = nullptr; + + while ((node = (FairGeoNode *)iter.Next())) { + aVol = dynamic_cast<FairGeoVolume *>(node); + // if (fGeoType == 2) + // LOG(info) << "Volume " << aVol->GetName() << " is" << (node->isSensitive() ? "" : " not") << " sensitive"; + if (node->isSensitive()) { + fSensNodes->AddLast(aVol); + } else { + fPassNodes->AddLast(aVol); + } + } + + par->SetGeometryType(fGeoType); + if (fGeoType == 1) { + par->SetTubeInRad(0.4903 / 2.); // cm + par->SetTubeOutRad(0.00127); // cm + } else { + LOG(fatal) << "[MUST] GeoType " << fGeoType << " not supported"; + } + + par->setChanged(); + par->setInputVersion(fRun->GetRunId(), 1); + ProcessNodes(volList); + + fMapper = new CbmMustMapCreator(fGeoType); +} +// ------------------------------------------------------------------------- + +// ----- Private method AddHit ----------------------------------------- +CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, + TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass) // da cancellare postot +{ + TClonesArray &clref = *fMustCollection; + + Int_t size = clref.GetEntriesFast(); + + CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, tubeID, chamberID, layerID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass); + + pointnew->SetTubeID(tubeID); + pointnew->SetChamberID(chamberID); + pointnew->SetLayerID(layerID); + + return pointnew; +} +// ------------------------------------------------------------------------- + +ClassImp(CbmMust) diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h new file mode 100644 index 0000000000..416e10b925 --- /dev/null +++ b/sim/detectors/must/CbmMust.h @@ -0,0 +1,186 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +//////////////////////////////////////////////////////////////////////////// +// CbmMust header file +// +// Class for simulation of MUST +// +// authors: Radoslaw Karabowicz, GSI, 2024 +// +// modified from CbmMust by Nafija Ibrišimović in 2023 +//////////////////////////////////////////////////////////////////////////// + +#ifndef CBMMUST_H +#define CBMMUST_H + +// from CbmRoot, this library +#include "CbmGeoMustPar.h" +#include "CbmMustMapCreator.h" +// from CbmRoot, CbmData +#include <CbmMustPoint.h> +// from FairRoot +#include <FairDetector.h> +#include <FairRun.h> +// from ROOT +#include <TClonesArray.h> +#include <TLorentzVector.h> +#include <TVector3.h> +// standard +#include <string> +#include <sstream> + +class TClonesArray; +class FairVolume; + +class CbmMust : public FairDetector { + + public: + /** Default constructor **/ + CbmMust(); + + /** Standard constructor. + *@param name detetcor name + *@param active sensitivity flag + **/ + CbmMust(const char *name, Bool_t active); + + /** Destructor **/ + virtual ~CbmMust(); + + /** Virtual method ProcessHits + ** + ** Defines the action to be taken when a step is inside the + ** active volume. Creates CbmMustPoints and adds them to the + ** collection. + *@param vol Pointer to the active volume + **/ + virtual Bool_t ProcessHits(FairVolume *vol = 0) override; + + /** Virtual method EndOfEvent + ** + ** If verbosity level is set, print hit collection at the + ** end of the event and resets it afterwards. + **/ + virtual void EndOfEvent() override; + + /** Virtual method Register + ** + ** Registers the hit collection in the ROOT manager. + **/ + virtual void Register() override; + + /** Accessor to the hit collection **/ + virtual TClonesArray *GetCollection(Int_t iColl) const override; + + /** Virtual method Print + ** + ** Screen output of hit collection. + **/ + virtual void Print(Option_t * /*option*/ = "") const override; + + /** Virtual method Reset + ** + ** Clears the hit collection + **/ + virtual void Reset() override; + + virtual void Initialize() override; + + /** Virtual method CopyClones + ** + ** Copies the hit collection with a given track index offset + *@param cl1 Origin + *@param cl2 Target + *@param offset Index offset + **/ + virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override; + + /** Virtual method Construct geometry + ** + ** Constructs the STT geometry + **/ + virtual void ConstructGeometry() override; + + private: + /** GFTrack information to be stored until the track leaves the + active volume. **/ + Int_t fTrackID; //! track index + Int_t fVolumeID; //! volume id + TLorentzVector fPos; //! wire position in global frame + TLorentzVector fPosIn; //! entry position in global frame + TLorentzVector fPosOut; //! exit position in global frame + TLorentzVector fPosInLocal; //! entry position in straw frame + TLorentzVector fPosOutLocal; //! exit position in straw frame + TLorentzVector fMomIn; //! momentum + TLorentzVector fMomOut; //! momentum + Double_t fTime; //! time + Double_t fLength; //! length + Double_t fELoss; //! energy loss + Double_t fMass; //! particle mass + Bool_t fIsInitialized; + + Int_t fPosIndex; //! + TClonesArray *fMustCollection; //! Hit collection + TLorentzVector fpostot; // global frame hit position (in)// da cancellare + TLorentzVector fpostotin; // global frame hit position (in)// da cancellare + TLorentzVector fpostotout; // global frame hit position (in)// da cancellare + + TObjArray *fPassNodes; //! + // geometry type + Bool_t valid; + Int_t fGeoType; + + CbmMustMapCreator *fMapper; //! + + /** Private method AddHit + ** + ** Adds a CbmTrdPoint to the HitCollection + **/ + CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, + TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass); + + std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim); + bool Split(std::string &aDest, std::string &aSrc, char aDelim); + + /** Private method ResetParameters + ** + ** Resets the private members for the track parameters + **/ + void ResetParameters(); + + /** Private method GetSquaredDistanceFromWire + ** + ** Returns the square of the distance of the current trackpoint to the wire + *@return distance + **/ + float GetSquaredDistanceFromWire(); + + CbmMust(const CbmMust &L); + CbmMust &operator=(const CbmMust &) { return *this; } + + ClassDef(CbmMust, 1) +}; + +inline void CbmMust::ResetParameters() +{ + fTrackID = fVolumeID = 0; + fPos.SetXYZM(0.0, 0.0, 0.0, 0.0); + fPosInLocal.SetXYZM(0.0, 0.0, 0.0, 0.0); + fPosOutLocal.SetXYZM(0.0, 0.0, 0.0, 0.0); + fMomIn.SetXYZM(0.0, 0.0, 0.0, 0.0); + fMomOut.SetXYZM(0.0, 0.0, 0.0, 0.0); + fTime = fLength = fELoss = 0; + fPosIndex = 0; + fpostot.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare + fpostotin.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare + fpostotout.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare + fPosIn.SetXYZM(0.0, 0.0, 0.0, 0.0); + fPosOut.SetXYZM(0.0, 0.0, 0.0, 0.0); + fMass = 0; + fIsInitialized = kFALSE; + valid = kFALSE; +} + +#endif // CBMMUST_H diff --git a/sim/detectors/must/CbmMustSimLinkDef.h b/sim/detectors/must/CbmMustSimLinkDef.h new file mode 100644 index 0000000000..e423834418 --- /dev/null +++ b/sim/detectors/must/CbmMustSimLinkDef.h @@ -0,0 +1,13 @@ +/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Volker Friese [committer] */ + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class CbmMust + ; + +#endif /* __CINT__ */ -- GitLab From 60df2e6b0618c9be3732a6f3d034ae76d408fce2 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Wed, 27 Nov 2024 12:24:26 +0100 Subject: [PATCH 02/12] det(must): Compile the MUST software Introduce proper changes to the `cbmroot` changes to compile MUST classes. --- core/CMakeLists.txt | 1 + core/data/CMakeLists.txt | 4 ++++ core/data/CbmDataLinkDef.h | 3 +++ sim/detectors/CMakeLists.txt | 1 + 4 files changed, 9 insertions(+) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7fa667426b..cf78e94fe0 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -15,6 +15,7 @@ add_subdirectory(detectors/tof) add_subdirectory(detectors/sts) add_subdirectory(detectors/psd) add_subdirectory(detectors/fsd) +add_subdirectory(detectors/must) If(ROOT_opengl_FOUND) Message(STATUS "OpenGL support found. Build the eventdisplay.") diff --git a/core/data/CMakeLists.txt b/core/data/CMakeLists.txt index b5b59dd078..78fecaae59 100644 --- a/core/data/CMakeLists.txt +++ b/core/data/CMakeLists.txt @@ -15,6 +15,7 @@ set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/rich ${CMAKE_CURRENT_SOURCE_DIR}/psd ${CMAKE_CURRENT_SOURCE_DIR}/fsd + ${CMAKE_CURRENT_SOURCE_DIR}/must ${CMAKE_CURRENT_SOURCE_DIR}/global ) @@ -108,6 +109,9 @@ set(SRCS fsd/CbmFsdPoint.cxx fsd/CbmFsdAddress.cxx + must/CbmMustPoint.cxx + must/CbmMustHit.cxx + global/CbmGlobalTrack.cxx global/CbmVertex.cxx global/CbmTrackParam.cxx diff --git a/core/data/CbmDataLinkDef.h b/core/data/CbmDataLinkDef.h index b418995a9f..6427ce233f 100644 --- a/core/data/CbmDataLinkDef.h +++ b/core/data/CbmDataLinkDef.h @@ -109,6 +109,9 @@ #pragma link C++ namespace CbmFsdAddress; #pragma link C++ enum CbmFsdAddress::Level; +#pragma link C++ class CbmMustPoint + ; +#pragma link C++ class CbmMustHit + ; + // --- data/global #pragma link C++ class CbmGlobalTrack + ; #pragma link C++ class CbmVertex + ; diff --git a/sim/detectors/CMakeLists.txt b/sim/detectors/CMakeLists.txt index aa91290cdd..ebbc2b7d86 100644 --- a/sim/detectors/CMakeLists.txt +++ b/sim/detectors/CMakeLists.txt @@ -10,3 +10,4 @@ add_subdirectory(tof) add_subdirectory(fsd) add_subdirectory(psd) add_subdirectory(bmon) +add_subdirectory(must) -- GitLab From 779e067ad1dcf7cd56243dfcd7a93a3331ae53bf Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Wed, 18 Dec 2024 11:49:03 +0100 Subject: [PATCH 03/12] det(must): Add changes to read root geometry Changed CbmMustPoint to reflect the root geometry. Introduced fLayerID, fModuleID, fStrawID, removed unneeded variables and the map creator. Changed CbmMust detector to read geometry from root file. Changed run_sim macro accordingly. --- core/data/must/CbmMustPoint.cxx | 18 ++++----- core/data/must/CbmMustPoint.h | 24 ++++++------ macro/must/run_sim.C | 10 ++--- sim/detectors/must/CbmMust.cxx | 65 ++++++++++++++------------------- sim/detectors/must/CbmMust.h | 17 ++++++--- 5 files changed, 65 insertions(+), 69 deletions(-) diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx index 23c3304237..71c0b06363 100644 --- a/core/data/must/CbmMustPoint.cxx +++ b/core/data/must/CbmMustPoint.cxx @@ -23,17 +23,17 @@ using std::endl; // ----- Default constructor ------------------------------------------- CbmMustPoint::CbmMustPoint() : FairMCPoint(), fX_out_local(0), fY_out_local(0), fZ_out_local(0), fX_in_local(0.), fY_in_local(0), fZ_in_local(0), fPx_out(0), fPy_out(0), fPz_out(0), fPx_in(0), fPy_in(0), - fPz_in(0), fMass(0), fTubeID(0), fChamberID(0), fLayerID(0) + fPz_in(0), fMass(0), fLayerID(0), fModuleID(0), fStrawID(0) { } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ -CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, +CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass) : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss), fX_out_local(posOutLocal.X()), fY_out_local(posOutLocal.Y()), fZ_out_local(posOutLocal.Z()), fX_in_local(posInLocal.X()), fY_in_local(posInLocal.Y()), fZ_in_local(posInLocal.Z()), fPx_out(momOut.Px()), fPy_out(momOut.Py()), fPz_out(momOut.Pz()), fPx_in(momIn.Px()), - fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fTubeID(tubeID), fChamberID(chamberID), fLayerID(layerID) + fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fLayerID(layerID), fModuleID(moduleID), fStrawID(strawID) { // reset MC momentum fPx = (momIn.Px() + momOut.Px()) / 2.; @@ -53,7 +53,7 @@ CbmMustPoint::CbmMustPoint(const CbmMustPoint &point) point.fEventId), fX_out_local(point.fX_out_local), fY_out_local(point.fY_out_local), fZ_out_local(point.fZ_out_local), fX_in_local(point.fX_in_local), fY_in_local(point.fY_in_local), fZ_in_local(point.fZ_in_local), fPx_out(point.fPx_out), fPy_out(point.fPy_out), fPz_out(point.fPz_out), fPx_in(point.fPx_in), fPy_in(point.fPy_in), fPz_in(point.fPz_in), - fMass(point.fMass), fTubeID(point.fTubeID), fChamberID(point.fChamberID), fLayerID(point.fLayerID) + fMass(point.fMass), fLayerID(point.fLayerID), fModuleID(point.fModuleID), fStrawID(point.fStrawID) { } // ------------------------------------------------------------------------- @@ -61,11 +61,11 @@ CbmMustPoint::CbmMustPoint(const CbmMustPoint &point) // ----- Public method Print ------------------------------------------- void CbmMustPoint::Print(const Option_t *opt) const { - LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in detector " << fDetectorID; - cout << " Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl; - cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl; - cout << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" - << " opt=" << opt << endl; + LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in det/lay/mod/str " << fDetectorID << "/" << fLayerID << "/" << fModuleID << "/" << fStrawID; + LOG(info) << " Position (" << fX << ", " << fY << ", " << fZ << ") cm"; + LOG(info) << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV"; + LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" + << " opt=" << opt; } // ------------------------------------------------------------------------- diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h index 9c7d8deeea..a0a1f99cdf 100644 --- a/core/data/must/CbmMustPoint.h +++ b/core/data/must/CbmMustPoint.h @@ -23,9 +23,9 @@ class CbmMustPoint : public FairMCPoint { /** Constructor with arguments *@param trackID Index of MCTrack *@param detID Detector ID - *tubeID Number of tube - *ChamberID number of chamber - *LayerID + *@param LayerID MUST layerID (1...12) + *@param moduleID moduleID in layer (1...36) + *@param strawID strawID in module (1...128) *@param pos Coordinates at wire center of active volume [cm] *@param posInLocal Local coordinates at entrance to active volume [cm] *@param posOutLocal Local coordinates at exit of active volume [cm] @@ -35,7 +35,7 @@ class CbmMustPoint : public FairMCPoint { *@param length Track length since creation [cm] *@param eLoss Energy deposit [GeV] **/ - CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, + CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass); /** Copy constructor **/ @@ -81,12 +81,12 @@ class CbmMustPoint : public FairMCPoint { // void SetWireDirection(TVector3 wire); // tube ID // CHECK added - void SetTubeID(Int_t tubeid) { fTubeID = tubeid; } - Int_t GetTubeID() { return fTubeID; } - void SetChamberID(Int_t chamberid) { fChamberID = chamberid; } - void SetLayerID(Int_t layerid) { fLayerID = layerid; } - Int_t GetChamberID() { return fChamberID; } - Int_t GetLayerID() { return fLayerID; } + Int_t GetLayerID () { return fLayerID; } + Int_t GetModuleID() { return fModuleID; } + Int_t GetStrawID () { return fStrawID; } + void SetLayerID (Int_t layerid) { fLayerID = layerid; } + void SetModuleID(Int_t moduleid) { fModuleID = moduleid; } + void SetStrawID (Int_t strawid) { fStrawID = strawid; } /** Output to screen **/ virtual void Print(const Option_t *opt) const; @@ -104,9 +104,9 @@ class CbmMustPoint : public FairMCPoint { // particle mass Double_t fMass; - Int_t fTubeID; - Int_t fChamberID; Int_t fLayerID; + Int_t fModuleID; + Int_t fStrawID; ////// diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C index 23fc129f8c..9364eb3224 100644 --- a/macro/must/run_sim.C +++ b/macro/must/run_sim.C @@ -2,7 +2,7 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Radoslaw Karabowicz */ -int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0) +int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0) { // 2212 proton TStopwatch timer; @@ -67,7 +67,7 @@ int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 fRun->AddModule(magnet); FairDetector *must = new CbmMust("MUST", kTRUE); - must->SetGeometryFileName("must/must.geo"); + must->SetGeometryFileName("must/must_v24a_mcbm.geo.root"); fRun->AddModule(must); // Create and Set Event Generator @@ -80,9 +80,9 @@ int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 FairBoxGenerator *boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl. if (p2 < 0.) p2 = p1; - boxGen->SetPRange(p1, p1); // GeV/c //setPRange vs setPtRange - boxGen->SetPhiRange(45, 45); // Azimuth angle range [degree] - boxGen->SetThetaRange(20, 20); // Polar angle in lab system range [degree] + boxGen->SetPRange(p1, p2); // GeV/c //setPRange vs setPtRange + boxGen->SetPhiRange(270, 450); // Azimuth angle range [degree] + boxGen->SetThetaRange(6, 22); // Polar angle in lab system range [degree] boxGen->SetCosTheta(); boxGen->SetXYZ(0., 0., 0.); primGen->AddGenerator(boxGen); diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx index 9722a80964..59f3eee44b 100644 --- a/sim/detectors/must/CbmMust.cxx +++ b/sim/detectors/must/CbmMust.cxx @@ -18,7 +18,8 @@ #include "CbmGeoMust.h" #include "CbmDefs.h" #include "CbmStack.h" -#include "CbmMustMapCreator.h" +// from CbmRoot +#include "CbmGeometryUtils.h" // from FairRoot #include <FairRun.h> #include <FairGeoInterface.h> @@ -135,7 +136,7 @@ string CbmMust::GetStringPart(string &aSrc, Int_t part, char aDelim) // ----- Public method ProcessHits -------------------------------------- Bool_t CbmMust::ProcessHits(FairVolume *vol) { - + // LOG(info) << "ProcessHits called!"; // TParticle* particle = gMC->GetStack()->GetCurrentTrack(); //[R.K. 01/2017] unused variable? // TGeoMedium *medium = (TGeoMedium*) vol->getGeoNode()->getRootVolume()->GetMedium(); //[R.K. 01/2017] unused variable? // Double_t epsil = medium->GetParam(6); //[R.K. 01/2017] unused variable? @@ -202,37 +203,18 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) gMC->Gmtod(globalPos, localPos, 1); fPosOutLocal.SetXYZM(localPos[0], localPos[1], localPos[2], 0.0); - // string basename("stt1tube"); - string basename; - TString volumename; - string hashmark("#"), volName, fullName, number, specialname, volPath(gMC->CurrentVolPath()), volPath2(gMC->CurrentVolPath()); - - volumename = volPath; - volName = GetStringPart(volPath, 2, '/'); - number = GetStringPart(volName, 1, '_'); - - if (fTrackID != 0) { - if (fVerboseLevel > 2) - LOG(info) << "[MUST] befor Mapper------"; - } + string volPath(gMC->CurrentVolPath()); fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0); - // CHECK map creator------------------------------------------------- - // CbmMustMapCreator *mapper = new CbmMustMapCreator(fGeotype); - // testTubeID=tube number as in the geometry file.... - // we need to calculate the real number in order to have a different - // number for each tube (also for up and down short tubes) - // Int_t tubeID = fMapper->GetTubeIDFromPath(gMC->CurrentVolPath()); - Int_t chamberID = fMapper->GetChamberIDFromPath(gMC->CurrentVolPath()); - Int_t layerID = fMapper->GetLayerID(chamberID, gMC->CurrentVolPath()); - // LOG(info)<<"LAYERID==========="<<layerID; - // tubeID=at each tube corresponds only one id number..... - Int_t totTubeID = fMapper->GetTubeIDTot(chamberID, layerID, gMC->CurrentVolPath()); - // LOG(info)<<gMC->CurrentVolPath() << " -> " << "CbmMust.cxx. layer + chamber + tubeID -> totTubeId = "<<layerID<<" + "<<chamberID<<" + "<<tubeID<<" -> "<<totTubeID; - ////---------------------------------------------------------------- - - AddHit(fTrackID, fVolumeID, totTubeID, chamberID, layerID, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()), + LOG(debug) << " --> " << volPath; + volPath = volPath.substr(volPath.find("strawAssembly_")+14,8); + int layerId = atoi(volPath.substr(1,2).c_str()); + int moduleId = atoi(volPath.substr(3,2).c_str()); + int strawId = atoi(volPath.substr(5,3).c_str()); + LOG(debug) << " l/m/t = " << layerId << "/" << moduleId << "/" << strawId; + + AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()), TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, fLength, fELoss, fMass); @@ -332,6 +314,18 @@ void CbmMust::Initialize() // ----- Public method ConstructGeometry ------------------------------- void CbmMust::ConstructGeometry() { + + TString fileName = GetGeometryFileName(); + + // --- Only ROOT geometries are supported + if (fileName.EndsWith(".root")) { + LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data(); + TGeoCombiTrans* fCombiTrans = NULL; + Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans); + return; + } + LOG(info) << "Constructing Must geometry from text file " << fileName.Data(); + FairGeoLoader *geoLoad = FairGeoLoader::Instance(); FairGeoInterface *geoFace = geoLoad->getGeoInterface(); CbmGeoMust *Geo = new CbmGeoMust(); @@ -380,23 +374,18 @@ void CbmMust::ConstructGeometry() par->setInputVersion(fRun->GetRunId(), 1); ProcessNodes(volList); - fMapper = new CbmMustMapCreator(fGeoType); } // ------------------------------------------------------------------------- // ----- Private method AddHit ----------------------------------------- -CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, - TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass) // da cancellare postot +CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, + TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass) { TClonesArray &clref = *fMustCollection; Int_t size = clref.GetEntriesFast(); - CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, tubeID, chamberID, layerID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass); - - pointnew->SetTubeID(tubeID); - pointnew->SetChamberID(chamberID); - pointnew->SetLayerID(layerID); + CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, layID, modID, strID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass); return pointnew; } diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h index 416e10b925..825e87cdda 100644 --- a/sim/detectors/must/CbmMust.h +++ b/sim/detectors/must/CbmMust.h @@ -17,7 +17,6 @@ // from CbmRoot, this library #include "CbmGeoMustPar.h" -#include "CbmMustMapCreator.h" // from CbmRoot, CbmData #include <CbmMustPoint.h> // from FairRoot @@ -65,6 +64,16 @@ class CbmMust : public FairDetector { **/ virtual void EndOfEvent() override; + /** @brief Check whether a volume is sensitive. + ** + ** @param(name) Volume name + ** @value kTRUE if volume is sensitive, else kFALSE + ** + ** The decision is based on the volume name (has to contain "Sensor"). + ** Virtual from FairModule. + **/ + virtual Bool_t IsSensitive(const std::string& name) override { return (TString(name).Contains("active") ? kTRUE : kFALSE); } + /** Virtual method Register ** ** Registers the hit collection in the ROOT manager. @@ -132,14 +141,12 @@ class CbmMust : public FairDetector { Bool_t valid; Int_t fGeoType; - CbmMustMapCreator *fMapper; //! - /** Private method AddHit ** ** Adds a CbmTrdPoint to the HitCollection **/ - CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, - TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass); + CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, + TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass); std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim); bool Split(std::string &aDest, std::string &aSrc, char aDelim); -- GitLab From 20f1d43bbcb30e4aab38585682f72b23ed3e57b9 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Thu, 30 Jan 2025 11:14:36 +0100 Subject: [PATCH 04/12] feat(must): Add MUST geometry parameter classes CbmMustGeoScheme allows access to MUST geometry via CbmMustStation, CbmMustLayer, CbmMustModule and CbmMustTube arrays. Design based on CbmMuchGeoScheme. --- core/detectors/must/CMakeLists.txt | 5 +- core/detectors/must/CbmMustBaseLinkDef.h | 5 +- core/detectors/must/CbmMustGeoScheme.cxx | 192 +++++++++++++++++++++++ core/detectors/must/CbmMustGeoScheme.h | 92 +++++++++++ core/detectors/must/CbmMustLayer.cxx | 84 ++++++++++ core/detectors/must/CbmMustLayer.h | 72 +++++++++ core/detectors/must/CbmMustModule.cxx | 80 ++++++++++ core/detectors/must/CbmMustModule.h | 72 +++++++++ core/detectors/must/CbmMustStation.cxx | 81 ++++++++++ core/detectors/must/CbmMustStation.h | 60 +++++++ core/detectors/must/CbmMustTube.cxx | 14 +- core/detectors/must/CbmMustTube.h | 55 ++++--- 12 files changed, 783 insertions(+), 29 deletions(-) create mode 100644 core/detectors/must/CbmMustGeoScheme.cxx create mode 100644 core/detectors/must/CbmMustGeoScheme.h create mode 100644 core/detectors/must/CbmMustLayer.cxx create mode 100644 core/detectors/must/CbmMustLayer.h create mode 100644 core/detectors/must/CbmMustModule.cxx create mode 100644 core/detectors/must/CbmMustModule.h create mode 100644 core/detectors/must/CbmMustStation.cxx create mode 100644 core/detectors/must/CbmMustStation.h diff --git a/core/detectors/must/CMakeLists.txt b/core/detectors/must/CMakeLists.txt index fb375281e3..c44dcca3c4 100644 --- a/core/detectors/must/CMakeLists.txt +++ b/core/detectors/must/CMakeLists.txt @@ -7,8 +7,11 @@ set(SRCS CbmGeoMust.cxx CbmGeoMustPar.cxx CbmMustContFact.cxx - CbmMustMapCreator.cxx CbmMustSingleStraw.cxx + CbmMustGeoScheme.cxx + CbmMustStation.cxx + CbmMustLayer.cxx + CbmMustModule.cxx CbmMustTube.cxx ) diff --git a/core/detectors/must/CbmMustBaseLinkDef.h b/core/detectors/must/CbmMustBaseLinkDef.h index c5408f2704..8840ace841 100644 --- a/core/detectors/must/CbmMustBaseLinkDef.h +++ b/core/detectors/must/CbmMustBaseLinkDef.h @@ -11,8 +11,11 @@ #pragma link C++ class CbmGeoMust + ; #pragma link C++ class CbmGeoMustPar + ; #pragma link C++ class CbmMustContFact + ; -#pragma link C++ class CbmMustMapCreator + ; #pragma link C++ class CbmMustSingleStraw + ; +#pragma link C++ class CbmMustGeoScheme + ; +#pragma link C++ class CbmMustStation + ; +#pragma link C++ class CbmMustLayer + ; +#pragma link C++ class CbmMustModule + ; #pragma link C++ class CbmMustTube + ; #endif /* __CINT__ */ diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx new file mode 100644 index 0000000000..7cd7e54713 --- /dev/null +++ b/core/detectors/must/CbmMustGeoScheme.cxx @@ -0,0 +1,192 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ +/** CbmMustGeoScheme + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** Based on CbmMuchGeoScheme by Evgeny Kryshen <e.kryshen@gsi.de> + ** + **/ +#include "CbmMustGeoScheme.h" + +#include "CbmMustLayer.h" // for CbmMustLayer +#include "CbmMustStation.h" // for CbmMustStation + +#include <Logger.h> // for LOG + +#include <TArrayD.h> // for TArrayD +#include <TArrayI.h> // for TArrayI +#include <TClonesArray.h> // for TClonesArray +#include <TFile.h> // for TFile, gFile +#include <TGeoBBox.h> // for TGeoBBox +#include <TGeoTube.h> // for TGeoTube +#include <TGeoManager.h> // for TGeoManager, gGeoManager +#include <TGeoNode.h> // for TGeoNode +#include <TGeoVolume.h> // for TGeoVolume +#include <TMath.h> // for Cos, Sqrt +#include <TObjArray.h> // for TObjArray +#include <TObject.h> // for TObject +#include <TVector3.h> // for TVector3 + +#include <cassert> // for assert +#include <stdexcept> // for out_of_range +#include <utility> // for pair +#include <vector> + +#include <math.h> // for sqrt + +using std::vector; + +CbmMustGeoScheme* CbmMustGeoScheme::fInstance = nullptr; + +// ------------------------------------------------------------------------- +CbmMustGeoScheme::CbmMustGeoScheme() + : TObject() +{ + LOG(debug) << "CbmMustGeoScheme created"; +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +CbmMustGeoScheme::~CbmMustGeoScheme() +{ + + if (fInstance != nullptr) delete fInstance; +} +// ------------------------------------------------------------------------- + + +// ------------------------------------------------------------------------- +CbmMustGeoScheme* CbmMustGeoScheme::Instance() +{ + + if (!fInstance) fInstance = new CbmMustGeoScheme(); + return fInstance; +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void CbmMustGeoScheme::Init(TObjArray* stations) +{ + if (!fInitialized) { + fStations = stations; + fInitialized = kTRUE; + } + LOG(debug) << "CbmMustGeoScheme init successful"; +} +// ------------------------------------------------------------------------- + + +// ------------------------------------------------------------------------- +void CbmMustGeoScheme::Init(TString parFileName) +{ + + /// Save old global file and folder pointer to avoid messing with FairRoot + TFile* oldFile = gFile; + TDirectory* oldDir = gDirectory; + + TFile* file = new TFile(parFileName); + LOG_IF(fatal, !file) << "File " << parFileName << " does not exist"; + TObjArray* stations = file->Get<TObjArray>("stations"); + LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << parFileName; + file->Close(); + file->Delete(); + + /// Restore old global file and folder pointer to avoid messing with FairRoot + gFile = oldFile; + gDirectory = oldDir; + + Init(stations); +} +// ------------------------------------------------------------------------- + + +// ------------------------------------------------------------------------- +CbmMustStation* CbmMustGeoScheme::GetStation(int iStation) const +{ + + if (!fStations) return nullptr; + Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntriesFast()); + + return result ? (CbmMustStation*) fStations->At(iStation) : nullptr; +} +// ------------------------------------------------------------------------- + +CbmMustStation* CbmMustGeoScheme::FindStation(int detid) +{ + if ( !fStations ) + fStations = new TObjArray(); + for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj)); + if ( tempStation->GetDetectorId() == detid ) + return tempStation; + } + return nullptr; +} + +bool CbmMustGeoScheme::AddStation(CbmMustStation* station) +{ + for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj)); + if ( tempStation->GetDetectorId() == station->GetDetectorId() ) + return false; + } + + fStations->Add(station); + return true; +} + +void CbmMustGeoScheme::Show() { + LOG(info) << "MustGeoScheme:"; + for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj)); + tempStation->Show(); + } +} + +// ------------------------------------------------------------------------- +void CbmMustGeoScheme::StoreGeoScheme() +{ + + /// Save old global file and folder pointer to avoid messing with FairRoot + TFile* oldFile = gFile; + TDirectory* oldDir = gDirectory; + + std::string geoSchemeFileName("must_geoScheme.root"); + TFile* file = new TFile(geoSchemeFileName.c_str(),"recreate"); + LOG_IF(fatal, !file) << "File " << geoSchemeFileName << " does not exist"; + file->WriteObject(fStations,"stations"); + // fStations->Write(); + file->Close(); + file->Delete(); + + /// Restore old global file and folder pointer to avoid messing with FairRoot + gFile = oldFile; + gDirectory = oldDir; +} +// ------------------------------------------------------------------------- +CbmMustLayer* CbmMustGeoScheme::GetLayer(int iStation, int iLayer) const +{ + + CbmMustStation* station = GetStation(iStation); + return station ? station->GetLayer(iLayer) : nullptr; +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void CbmMustGeoScheme::NavigateTo(const TString& path) +{ + gGeoManager->cd(path.Data()); + // fGeoPathHash; + // fGeoPathHash = path.Hash(); + TGeoVolume* fCurrentVolume = gGeoManager->GetCurrentVolume(); + // TGeoBBox* fVolumeBoxShape = (TGeoBBox*) fCurrentVolume->GetShape(); + Double_t local[3] = {0., 0., 0.}; + gGeoManager->LocalToMaster(local, fGlobal); + // LOG(info) << "position: " << fGlobal[0] << "," << fGlobal[1] << "," << fGlobal[2]; +} +// ------------------------------------------------------------------------- + +ClassImp(CbmMustGeoScheme) diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h new file mode 100644 index 0000000000..f6f40858c9 --- /dev/null +++ b/core/detectors/must/CbmMustGeoScheme.h @@ -0,0 +1,92 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustGeoScheme header file ----- +// ----- Created 18/02/08 by E. Kryshen ----- +// ----- Modified 08/01/2025 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +/** CbmMustGeoScheme + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** Based on CbmMuchGeoScheme by Evgeny Kryshen <e.kryshen@gsi.de> + ** + **/ + +#ifndef CbmMustGeoScheme_H +#define CbmMustGeoScheme_H 1 + +#include <Rtypes.h> // for THashConsistencyHolder, ClassDef +#include <RtypesCore.h> // for Int_t, Double_t, Bool_t, Float_t, Char_t +#include <TArrayC.h> // for TArrayC +#include <TArrayD.h> // for TArrayD +#include <TArrayI.h> // for TArrayI +#include <TGeoBBox.h> // for TGeoBBox +#include <TGeoCone.h> // for TGeoCone +#include <TObjArray.h> // for TObjArray +#include <TObject.h> // for TObject +#include <TString.h> // for TString +#include <TVector3.h> // for TVector3 + +#include <map> // for map +#include <vector> // for vector + +class CbmMustLayer; +class CbmMustModule; +class CbmMustStation; +class TGeoHMatrix; +class TGeoNode; +class TGeoTrap; +class TGeoVolume; + +class CbmMustGeoScheme : public TObject { + +public: + /** Destructor. */ + ~CbmMustGeoScheme(); + //void Init(Bool_t isSimulation = kFALSE); + static CbmMustGeoScheme* Instance(); + /** Gets whether the geometry scheme is initialized. */ + Bool_t IsInitialized() { return fInitialized; } + + // Get geometry objects by indices + TObjArray* GetStations() const {return fStations;}; + CbmMustStation* GetStation(int iStation) const; + CbmMustLayer* GetLayer(int iStation, int iLayer) const; + + int GetNStations() const { return fStations->GetEntriesFast(); } + + CbmMustStation* FindStation(int detid); + bool AddStation(CbmMustStation* station); + void Show(); + void StoreGeoScheme(); + + void Init(TObjArray* stations); + void Init(TString parFileName); + + void NavigateTo(const TString& path); + // void NavigateToBBox(const TString& path); + // void NavigateToTube(const TString& path); + + TVector3 GetGlobal() { return TVector3(fGlobal); } + +private: + static CbmMustGeoScheme* fInstance; + + CbmMustGeoScheme(); + + bool fInitialized {false}; + TObjArray* fStations {nullptr}; //! + double fGlobal[3] {0.,0.,0.}; + + CbmMustGeoScheme(const CbmMustGeoScheme&); + CbmMustGeoScheme& operator=(const CbmMustGeoScheme&); + + ClassDef(CbmMustGeoScheme, 1); +}; + +#endif diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx new file mode 100644 index 0000000000..21bd3d7806 --- /dev/null +++ b/core/detectors/must/CbmMustLayer.cxx @@ -0,0 +1,84 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +/** CbmMustLayer.cxx + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** This class holds the transport geometry parameters + ** of one MuST tracking layer. + ** Based on CbmMuchLayer by M.Ryzhinskiy <m.ryzhinskiy@gsi.de> + ** + **/ +#include "CbmMustLayer.h" + +#include <Logger.h> // for LOG + +#include <TMathBase.h> // for Abs +#include <TObject.h> // for TObject +#include <TVector3.h> // for TVector3 + +// ----- Default constructor ------------------------------------------- +CbmMustLayer::CbmMustLayer() + : TObject() +{ +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +CbmMustLayer::CbmMustLayer(int detId, double z, double zRel) + : TObject() + , fDetectorId(detId) + , fZ(z) + , fZtoStationCenter(zRel) +{ +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel) + : TObject() + , fDetectorId(iStation*1e7+iLayer*1e5) + , fZ(z) + , fZtoStationCenter(zRel) + +{ +} +// ------------------------------------------------------------------------- + +// ----- Destructor ---------------------------------------------------- +CbmMustLayer::~CbmMustLayer() {} +// ------------------------------------------------------------------------- + +CbmMustModule* CbmMustLayer::FindModule(int detid) +{ + for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { + CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj)); + if ( tempModule->GetDetectorId() == detid ) + return tempModule; + } + return nullptr; +} + +bool CbmMustLayer::AddModule(CbmMustModule* module) { + for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { + CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj)); + if ( tempModule->GetDetectorId() == module->GetDetectorId() ) + return false; + } + + fModules.Add(module); + return true; +} + +void CbmMustLayer::Show() { + LOG(info) << " Layer " << fDetectorId << " (@ z = " << fZ << "):"; + for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { + CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj)); + tempModule->Show(); + } +} + +ClassImp(CbmMustLayer) diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h new file mode 100644 index 0000000000..7f282b3f1f --- /dev/null +++ b/core/detectors/must/CbmMustLayer.h @@ -0,0 +1,72 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +/** CbmMustLayer.h + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** This class holds the transport geometry parameters + ** of one MuST tracking layer. + ** Based on CbmMuchLayer by M.Ryzhinskiy <m.ryzhinskiy@gsi.de> + ** + **/ + + +#ifndef CBMMUSTLAYER_H +#define CBMMUSTLAYER_H 1 + +#include <Rtypes.h> // for THashConsistencyHolder, ClassDef +#include <RtypesCore.h> // for Double_t, Int_t, Bool_t, Double32_t +#include <TObject.h> // for TObject +#include <TObjArray.h> // for TObjArray +#include "CbmMustModule.h" + +class CbmMustLayer : public TObject { + +public: + /** Default constructor **/ + CbmMustLayer(); + + /** Standard constructor + *@param detId Detector ID + *@param z z position of layer center [cm] + *@param zRel z position of layer center relative to station center [cm] + **/ + CbmMustLayer(int detId, double z, double zRel); + + /** Standard constructor + *@param iStation Station index + *@param iLayer Layer index + *@param z z position of layer center [cm] + *@param zRel z position of layer center relative to station center [cm] + **/ + CbmMustLayer(int iStation, int iLayer, double z, double zRel); + + /** Destructor **/ + virtual ~CbmMustLayer(); + + /** Accessors **/ + int GetDetectorId() const { return fDetectorId; } + double GetZ() const { return fZ; } + double GetZtoStationCenter() const { return fZtoStationCenter; } + + int GetNModules() const { return fModules.GetEntriesFast(); } + + CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); } + + CbmMustModule* FindModule(int detid); + bool AddModule(CbmMustModule* module); + void Show(); + +protected: + int fDetectorId {0}; // Unique detector ID + double fZ {0.}; + double fZtoStationCenter {0.}; // Relative position of the layer center with respect + // to the station center + TObjArray fModules; // Array of CbmMustModules + + ClassDef(CbmMustLayer, 1); +}; +#endif diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx new file mode 100644 index 0000000000..2bd5689e3e --- /dev/null +++ b/core/detectors/must/CbmMustModule.cxx @@ -0,0 +1,80 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +/** CbmMustModule.cxx + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** This class holds geometry parameters of must modules + ** Based on CbmMuchModule by M.Ryzhinskiy <m.ryzhinskiy@gsi.de> + ** + **/ +#include "CbmMustModule.h" + +#include <Logger.h> // for LOG + +#include <TObject.h> // for TObject +#include <TVector3.h> // for TVector3 + +// ----- Default constructor ------------------------------------------- +CbmMustModule::CbmMustModule() + : TObject() + , fDetectorId(0) + , fPosition(TVector3()) + , fDirection(TVector3()) +{ +} +// ------------------------------------------------------------------------- + + +// ----- Standard constructor ------------------------------------------ +CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction) + : TObject() + , fDetectorId(iStation*1e7+iLayer*1e5+iModule*1e3) + , fPosition(position) + , fDirection(direction) +{ +} +// ------------------------------------------------------------------------- + +CbmMustTube* CbmMustModule::FindTube(int detid) +{ + for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { + CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); + if ( tempTube->GetTubeNumber() == detid ) + return tempTube; + } + return nullptr; +} + +bool CbmMustModule::AddTube(CbmMustTube* tube) { + for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { + CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); + if ( tempTube->GetTubeNumber() == tube->GetTubeNumber() ) + return false; + } + fTubes.Add(tube); + return true; +} + +void CbmMustModule::Show() { + LOG(info) << " Module " << fDetectorId << " (@ (" << fPosition.X() << "," << fPosition.Y() << "," << fPosition.Z() << ") -> (" << fDirection.X() << "," << fDirection.Y() << "," << fDirection.Z() << "):"; + std::string tubeString(128, '.'); + std::string tubeNumbDec(128, '0'); + std::string tubeNumbOne(128, '0'); + for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { + CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); + // if ( iobj == 0 ) + LOG(info) << " Tube " << tempTube->GetDetectorId() << " @ " << tempTube->GetPosition().X() << "," << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z(); + tubeNumbDec[iobj] = char(tempTube->GetTubeNumber()/10+48); + tubeNumbOne[iobj] = char(tempTube->GetTubeNumber()%10+48); + tubeString[tempTube->GetTubeNumber()-1] = '*'; + } + LOG(info) << " Tubes " << tubeString; + LOG(info) << " - " << tubeNumbDec; + LOG(info) << " - " << tubeNumbOne; +} + +ClassImp(CbmMustModule) diff --git a/core/detectors/must/CbmMustModule.h b/core/detectors/must/CbmMustModule.h new file mode 100644 index 0000000000..777996e869 --- /dev/null +++ b/core/detectors/must/CbmMustModule.h @@ -0,0 +1,72 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +/** CbmMustModule.h + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** This class holds geometry parameters of must modules + ** Based on CbmMuchModule by M.Ryzhinskiy <m.ryzhinskiy@gsi.de> + ** + **/ + +#ifndef CBMMUSTMODULE_H +#define CBMMUSTMODULE_H 1 + +#include <Rtypes.h> // for THashConsistencyHolder, ClassDef +#include <RtypesCore.h> // for Color_t +#include <TObjArray.h> // for TObjArray +#include <TObject.h> // for TObject +#include <TVector3.h> // for TVector3 +#include "CbmMustTube.h" + +#include <map> // for multimap +#include <utility> // for pair + +class CbmMustModule : public TObject { +public: + /** Default constructor **/ + CbmMustModule(); + /** Standard constructor + *@param iStation Station index + *@param iLayer Layer index + *@param iModule Module index + *@param position Location of the module center in global c.s. (all dimensions in [cm]) + *@param direction Direction of the module + **/ + CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction); + /** Destructor **/ + virtual ~CbmMustModule() {} + + /** Accessors */ + int GetDetectorId() const { return fDetectorId; } + TVector3 GetPosition() const { return fPosition; } + TVector3 GetDirection() const { return fDirection; } + + int GetNTubes() const { return fTubes.GetEntriesFast(); } + + CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); } + + CbmMustTube* FindTube(int detid); + bool AddTube(CbmMustTube* tube); + void SortTubes() { fTubes.Sort(); } + void Show(); + + virtual bool InitModule() { return kTRUE; } + virtual void DrawModule(Color_t) {} + +protected: + int fDetectorId; // Unique detector ID + TVector3 fPosition; // Location vector of the module center in global c.s. (all dimensions in [cm]) + TVector3 fDirection; // Direction vector of the module + TObjArray fTubes; // Array of CbmMustTubes + +private: + CbmMustModule(const CbmMustModule&); + CbmMustModule& operator=(const CbmMustModule&); + + ClassDef(CbmMustModule, 2); +}; +#endif diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx new file mode 100644 index 0000000000..ea637e0112 --- /dev/null +++ b/core/detectors/must/CbmMustStation.cxx @@ -0,0 +1,81 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +/** CbmMustStation.cxx + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** This class holds the transport geometry parameters + ** of one Must tracking station. + ** Based on CbmMuchStation by M.Ryzhinskiy <m.ryzhinskiy@gsi.de> + **/ +#include "CbmMustStation.h" + +#include "CbmMustLayer.h" // for CbmMustLayer + +#include <Logger.h> // for LOG + +#include <TMathBase.h> // for Abs +#include <TObjArray.h> // for TObjArray + +// ----- Default constructor ------------------------------------------- +CbmMustStation::CbmMustStation() + : TObject() + , fDetectorId(0) + , fZ(0.) + , fLayers() +{ +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +CbmMustStation::CbmMustStation(int iStation, double z) + : TObject() + , fDetectorId(iStation*1e7) + , fZ(z) + , fLayers() +{ +} +// ------------------------------------------------------------------------- + +// ----- Destructor ---------------------------------------------------- +CbmMustStation::~CbmMustStation() {} +// ------------------------------------------------------------------------- + +// ----- Public method AddSector --------------------------------------- +CbmMustLayer* CbmMustStation::FindLayer(int detid) +{ + for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { + CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj)); + if ( tempLayer->GetDetectorId() == detid ) + return tempLayer; + } + return nullptr; +} +// ------------------------------------------------------------------------- + +// ----- Public method AddSector --------------------------------------- +bool CbmMustStation::AddLayer(CbmMustLayer* layer) +{ + for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { + CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj)); + if ( tempLayer->GetDetectorId() == layer->GetDetectorId() ) + return false; + } + + fLayers.Add(layer); + return true; +} +// ------------------------------------------------------------------------- + +void CbmMustStation::Show() { + LOG(info) << " Station " << fDetectorId << " (@ z = " << fZ << "):"; + for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { + CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj)); + tempLayer->Show(); + } +} + +ClassImp(CbmMustStation) diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h new file mode 100644 index 0000000000..dcec28c373 --- /dev/null +++ b/core/detectors/must/CbmMustStation.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +/** CbmMustStation.h + *@author R.Karabowicz <r.karabowicz@gsi.de> + *@version 1.0 + *@since 2025.01.08 + ** + ** This class holds the transport geometry parameters + ** of one Must tracking station. + ** Based on CbmMuchStation by M.Ryzhinskiy <m.ryzhinskiy@gsi.de> + ** + **/ + + +#ifndef CBMMUSTSTATION_H +#define CBMMUSTSTATION_H 1 + +#include "CbmMustLayer.h" // for CbmMustLayer + +#include <Rtypes.h> // for THashConsistencyHolder, ClassDef +#include <TObjArray.h> // for TObjArray +#include <TObject.h> // for TObject + +class CbmMustStation : public TObject { +public: + /** Default constructor **/ + CbmMustStation(); + + + /** Standard constructor + *@param iStation Station index + *@param z z position of station center in global cs [cm] + **/ + CbmMustStation(int iStation, double z); + + + /** Destructor **/ + virtual ~CbmMustStation(); + + /** Accessors **/ + int GetDetectorId() const { return fDetectorId; } + double GetZ() const { return fZ; } + int GetNLayers() const { return fLayers.GetEntriesFast(); } + + CbmMustLayer* GetLayer(int iLayer) const { return (CbmMustLayer*) fLayers.At(iLayer); } + + /** Add one sector to the array **/ + CbmMustLayer* FindLayer(int detid); + bool AddLayer(CbmMustLayer* layer); + void Show(); + +protected: + int fDetectorId; // Unique detector ID + double fZ; // z position of station center (midplane) [cm] in global cs + TObjArray fLayers; // Array of CbmMustLayers + ClassDef(CbmMustStation, 1); +}; +#endif diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx index 876245ff3e..4b39cfb99b 100644 --- a/core/detectors/must/CbmMustTube.cxx +++ b/core/detectors/must/CbmMustTube.cxx @@ -30,15 +30,15 @@ CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TM } CbmMustTube::CbmMustTube(CbmMustTube &tube) - : TObject(tube), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength()) + : TObject(tube), fTubeNumber(tube.GetTubeNumber()), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength()) { fRotationMatrix.ResizeTo(3, 3); fRotationMatrix = tube.GetRotationMatrix(); } -CbmMustTube::CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, +CbmMustTube::CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33, Double_t radin, Double_t radout, Double_t hl) - : fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl) + : fDetectorId(detectorId), fTubeNumber(tubeNumber), fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl) { fRotationMatrix[0][0] = r11; @@ -90,4 +90,12 @@ TVector3 CbmMustTube::GetWireDirection() const return TVector3(fRotationMatrix[0][2], fRotationMatrix[1][2], fRotationMatrix[2][2]); } +Int_t CbmMustTube::Compare(const TObject *obj) const { + if ( ((CbmMustTube*)obj)->GetTubeNumber() == this->GetTubeNumber() ) + return 0; + if ( ((CbmMustTube*)obj)->GetTubeNumber() < this->GetTubeNumber() ) + return 1; + return -1; +} + ClassImp(CbmMustTube) diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h index 224547f5fa..71f189c3a8 100644 --- a/core/detectors/must/CbmMustTube.h +++ b/core/detectors/must/CbmMustTube.h @@ -20,30 +20,37 @@ class CbmMustTube : public TObject { - public: - /** Default constructor **/ - CbmMustTube(); - CbmMustTube(CbmMustTube &tube); - - ~CbmMustTube(); - CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33, - Double_t radin, Double_t radout, Double_t hl); - - TVector3 GetPosition() const; - TMatrixT<Double_t> GetRotationMatrix() const; - Double_t GetRadIn() const; - Double_t GetRadOut() const; - Double_t GetHalfLength() const; - TVector3 GetWireDirection() const; - - bool IsSkew() const { return (0. != GetWireDirection().X()); } - - private: - TVector3 fCenPosition; - TMatrixT<double> fRotationMatrix; - Double_t fRadIn, fRadOut, fHalfLength; - - ClassDef(CbmMustTube, 1); +public: + /** Default constructor **/ + CbmMustTube(); + CbmMustTube(CbmMustTube &tube); + + ~CbmMustTube(); + CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33, + Double_t radin, Double_t radout, Double_t hl); + + int GetDetectorId() const {return fDetectorId;} + int GetTubeNumber() const {return fTubeNumber;} + TVector3 GetPosition() const; + TMatrixT<Double_t> GetRotationMatrix() const; + Double_t GetRadIn() const; + Double_t GetRadOut() const; + Double_t GetHalfLength() const; + TVector3 GetWireDirection() const; + + bool IsSkew() const { return (0. != GetWireDirection().X()); } + + Int_t Compare(const TObject *obj) const override; + Bool_t IsSortable() const override {return kTRUE;} + +private: + int fDetectorId {0}; + int fTubeNumber {0}; + TVector3 fCenPosition; + TMatrixT<double> fRotationMatrix; + Double_t fRadIn, fRadOut, fHalfLength; + + ClassDef(CbmMustTube, 1); }; #endif -- GitLab From a5e5d19d298314e6789f6bee9343aa6cb791cd02 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Thu, 30 Jan 2025 11:22:34 +0100 Subject: [PATCH 05/12] feat(must): Add way to generate MUST parameters during simulation The CbmMust class is now able to produce CbmMustGeoScheme while running simulation. Currenty works only for the mcbm setup. The functionality is disable on default. --- sim/detectors/must/CbmMust.cxx | 134 +++++++++++++++++++++++---------- sim/detectors/must/CbmMust.h | 4 +- 2 files changed, 95 insertions(+), 43 deletions(-) diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx index 59f3eee44b..df2be2ed66 100644 --- a/sim/detectors/must/CbmMust.cxx +++ b/sim/detectors/must/CbmMust.cxx @@ -14,9 +14,14 @@ #include "CbmMust.h" // from CbmRoot, this library +#include "CbmDefs.h" #include "CbmGeoMustPar.h" #include "CbmGeoMust.h" -#include "CbmDefs.h" +#include "CbmMustGeoScheme.h" +#include "CbmMustStation.h" +#include "CbmMustLayer.h" +#include "CbmMustModule.h" +#include "CbmMustTube.h" #include "CbmStack.h" // from CbmRoot #include "CbmGeometryUtils.h" @@ -99,40 +104,6 @@ float CbmMust::GetSquaredDistanceFromWire() } // ------------------------------------------------------------------------- -bool CbmMust::Split(string &aDest, string &aSrc, char aDelim) -{ - if (aSrc.empty()) - return false; - - string::size_type pos = aSrc.find(aDelim); - - aDest = aSrc.substr(0, pos); - - if (pos != string::npos) - aSrc = aSrc.substr(pos + 1); - else - aSrc = ""; - - return true; -} - -string CbmMust::GetStringPart(string &aSrc, Int_t part, char aDelim) -{ - string retval = "", sub; - - int counter = 0; - - while (Split(sub, aSrc, aDelim)) { - if (counter == part) { - retval = sub; - break; - } - counter++; - } - - return retval; -} - // ----- Public method ProcessHits -------------------------------------- Bool_t CbmMust::ProcessHits(FairVolume *vol) { @@ -145,7 +116,7 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) TGeoHMatrix M; gMC->GetTransformation(gMC->CurrentVolPath(), M); TString name(gMC->CurrentVolName()); - + // LOG(info) << "\"" << gMC->CurrentVolPath() << "\" - \"" << gMC->CurrentVolName() << "\""; if (gMC->TrackCharge() != 0.) { if (gMC->IsTrackEntering()) { @@ -208,10 +179,70 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0); LOG(debug) << " --> " << volPath; - volPath = volPath.substr(volPath.find("strawAssembly_")+14,8); - int layerId = atoi(volPath.substr(1,2).c_str()); - int moduleId = atoi(volPath.substr(3,2).c_str()); - int strawId = atoi(volPath.substr(5,3).c_str()); + string strawName = volPath.substr(volPath.find("strawAssembly_")+14,8); + int statId = 1; + int layerId = atoi(strawName.substr(1,2).c_str()); + int moduleId = atoi(strawName.substr(3,2).c_str()); + int strawId = atoi(strawName.substr(5,3).c_str()); + + if ( 1 == 0 ) { + CbmMustGeoScheme* mustGeoScheme = CbmMustGeoScheme::Instance(); + // add station + int detId = statId*1e7; + CbmMustStation* mustStation = mustGeoScheme->FindStation(detId); + if ( !mustStation ) { + LOG(info) << "STATION --> " << volPath; + string statPath = volPath.substr(0,volPath.find("/layer")); + LOG(info) << "STATION --> " << statPath; + mustGeoScheme->NavigateTo(statPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustStation = new CbmMustStation(statId,globPos[2]); // change z! + } + mustGeoScheme->AddStation(mustStation); + // add layer + detId = detId + layerId*1e5; + CbmMustLayer* mustLayer = mustStation->FindLayer(detId); + if ( !mustLayer ) { + LOG(info) << "LAYER --> " << volPath; + string layerPath = volPath.substr(0,volPath.find("/module")); + LOG(info) << "LAYER --> " << layerPath; + mustGeoScheme->NavigateTo(volPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustLayer = new CbmMustLayer(statId,layerId,globPos[2],globPos[2]-mustStation->GetZ()); + } + mustStation->AddLayer(mustLayer); + // add module + detId = detId + moduleId*1e3; + CbmMustModule* mustModule = mustLayer->FindModule(detId); + TVector3 directionVector(0.,1.,0.); + if ( layerId == 2 || layerId == 3 ) { + double angle = 5.*TMath::DegToRad(); + if ( layerId == 3 ) angle = -angle; + directionVector[0] = TMath::Sin(angle); + directionVector[1] = TMath::Cos(angle); + } + if ( !mustModule ) { + mustGeoScheme->NavigateTo(volPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustModule = new CbmMustModule(statId,layerId,moduleId,globPos,directionVector); + } + mustLayer->AddModule(mustModule); + // add tube + detId = detId + strawId; + CbmMustTube* mustTube = mustModule->FindTube(detId); + if ( !mustTube ) { + mustGeoScheme->NavigateTo(volPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustTube = new CbmMustTube(detId,strawId, + globPos[0],globPos[1],globPos[2], + directionVector[1],-directionVector[0],0., + directionVector[0], directionVector[1],0., + 0.,0.,1., + 0.0127,0.49,110.); + } + mustModule->AddTube(mustTube); + } + LOG(debug) << " l/m/t = " << layerId << "/" << moduleId << "/" << strawId; AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()), @@ -241,6 +272,29 @@ void CbmMust::EndOfEvent() Print(); fMustCollection->Delete(); fPosIndex = 0; + + if ( 1 == 0 ) { + int nofTubes = 0; + TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations(); + for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*)(stations->At(iobj)); + for ( int ilay = 0 ; ilay < tempStation->GetNLayers() ; ilay++ ) { + CbmMustLayer* tempLayer = tempStation->GetLayer(ilay); + for ( int imod = 0 ; imod < tempLayer->GetNModules() ; imod++ ) { + CbmMustModule* tempModule = tempLayer->GetModule(imod); + tempModule->SortTubes(); + nofTubes += tempModule->GetNTubes(); + } + } + } + + LOG(info) << "got " << nofTubes << " tubes"; + if ( nofTubes == 256 && !fGeoSchemeSaved ) { + CbmMustGeoScheme::Instance()->Show(); + CbmMustGeoScheme::Instance()->StoreGeoScheme(); + fGeoSchemeSaved = true; + } + } } // ------------------------------------------------------------------------- diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h index 825e87cdda..03b6269e2e 100644 --- a/sim/detectors/must/CbmMust.h +++ b/sim/detectors/must/CbmMust.h @@ -140,6 +140,7 @@ class CbmMust : public FairDetector { // geometry type Bool_t valid; Int_t fGeoType; + bool fGeoSchemeSaved{false}; /** Private method AddHit ** @@ -148,9 +149,6 @@ class CbmMust : public FairDetector { CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass); - std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim); - bool Split(std::string &aDest, std::string &aSrc, char aDelim); - /** Private method ResetParameters ** ** Resets the private members for the track parameters -- GitLab From 24e46cbb39420a1217215d317f044e1860fb0df1 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Fri, 31 Jan 2025 15:47:41 +0100 Subject: [PATCH 06/12] feat(must): Add CbmMustDigi class Plus some fixes to CbmMustPoint and CbmMustHit. --- core/data/CMakeLists.txt | 1 + core/data/CbmDataLinkDef.h | 1 + core/data/must/CbmMustDigi.cxx | 46 +++++++++++ core/data/must/CbmMustDigi.h | 93 ++++++++++++++++++++++ core/data/must/CbmMustHit.cxx | 25 +++--- core/data/must/CbmMustHit.h | 138 +++++++++++++++++---------------- core/data/must/CbmMustPoint.h | 6 +- 7 files changed, 230 insertions(+), 80 deletions(-) create mode 100644 core/data/must/CbmMustDigi.cxx create mode 100644 core/data/must/CbmMustDigi.h diff --git a/core/data/CMakeLists.txt b/core/data/CMakeLists.txt index 78fecaae59..a728ff5212 100644 --- a/core/data/CMakeLists.txt +++ b/core/data/CMakeLists.txt @@ -110,6 +110,7 @@ set(SRCS fsd/CbmFsdAddress.cxx must/CbmMustPoint.cxx + must/CbmMustDigi.cxx must/CbmMustHit.cxx global/CbmGlobalTrack.cxx diff --git a/core/data/CbmDataLinkDef.h b/core/data/CbmDataLinkDef.h index 6427ce233f..a4d542f498 100644 --- a/core/data/CbmDataLinkDef.h +++ b/core/data/CbmDataLinkDef.h @@ -110,6 +110,7 @@ #pragma link C++ enum CbmFsdAddress::Level; #pragma link C++ class CbmMustPoint + ; +#pragma link C++ class CbmMustDigi + ; #pragma link C++ class CbmMustHit + ; // --- data/global diff --git a/core/data/must/CbmMustDigi.cxx b/core/data/must/CbmMustDigi.cxx new file mode 100644 index 0000000000..015aaa2bce --- /dev/null +++ b/core/data/must/CbmMustDigi.cxx @@ -0,0 +1,46 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustDigi header file ----- +// ----- Created 2025-01-26 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +#include "CbmMustDigi.h" + +#include "CbmDefs.h" + +#include <iostream> +#include "TMath.h" + +/** Default constructor **/ +CbmMustDigi::CbmMustDigi() : TObject() +{ + // ClearDigi(); +} + +CbmMustDigi::CbmMustDigi(Int_t detectorId, Int_t skew, Double_t signalTime, Double_t signalError, Double_t chargeDep) + : TObject() + , fDetectorId(detectorId) + , fSkewed(skew) + , fSignalTime(signalTime) + , fSignalError(signalError) + , fDepCharge(chargeDep) +{ +} + +/** Public method ClearDigi **/ +void CbmMustDigi::ClearDigi() +{ + fDetectorId = 0; + fSkewed = 0; + fSignalTime = 0.; + fSignalError = 0.; + fDepCharge = 0.; +} + +/** Destructor **/ +CbmMustDigi::~CbmMustDigi() {} + +ClassImp(CbmMustDigi) diff --git a/core/data/must/CbmMustDigi.h b/core/data/must/CbmMustDigi.h new file mode 100644 index 0000000000..d75a127e84 --- /dev/null +++ b/core/data/must/CbmMustDigi.h @@ -0,0 +1,93 @@ +/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustDigi header file ----- +// ----- Created 2025-01-26 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +/** + ** + ** Meaning of RefIndex: Index of corresponding MCPoint + ** -1 if fake or background digi + ** + ** Meaning of Flag: 0 = Digi ok + ** -1 : Digi lost due to detection inefficiency + **/ + +#ifndef CBMMUSTDIGI_H +#define CBMMUSTDIGI_H 1 + +#include "TObject.h" +#include "TVector3.h" +#include "FairHit.h" + +class CbmMustDigi : public TObject { + + public: + /** Default constructor **/ + CbmMustDigi(); + + /** Standard constructor + *@param detectorId Tube unique volume ID + *@param skew flag for skewed tube + *@param signalTime The signal drift time + *@param signalError The error on signal + *@param chargeDep Deposited charge (arbitrary unit) + **/ + + // THIS ONE! + CbmMustDigi(Int_t detectorId, Int_t skew, + Double_t signalTime, Double_t signalError, Double_t chargeDep); + + /** Destructor **/ + virtual ~CbmMustDigi(); + + /** Output to screen (not yet implemented) **/ + virtual void Print(const Option_t *opt = nullptr) const + { + std::cout << " opt = " << opt << std::endl; + return; + } + + /** Public method ClearDigi + ** Resets the isochrone and it's error to 0 + **/ + void ClearDigi(); + + /** Accessors **/ + Double_t GetSignalTime() const { return fSignalTime; }; + Double_t GetSignalError() const { return fSignalError; }; + Double_t GetDepCharge() const { return fDepCharge; }; + Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; + + Double_t GetTime() const { return fSignalTime; }; + Double_t GetSkewed() const { return fSkewed; }; + + /** Modifiers **/ + void SetSignalTime(Double_t signalTime) { fSignalTime = signalTime; }; + void SetSignalError(Double_t signalError) { fSignalError = signalError; }; + void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } + + void SetTime(Double_t signalTime) { fSignalTime = signalTime; }; + + // tube ID // CHECK added + void SetDetectorId(Int_t detectorId) { fDetectorId = detectorId; } + Int_t GetDetectorId() const { return fDetectorId; } + +protected: + Double_t fSignalTime {0.}; + Double_t fSignalError{0.}; + + /** deposit charge (arbitrary units) **/ + Double_t fDepCharge {0.}; + + /** tube id **/ + Int_t fDetectorId {0}; + Int_t fSkewed {0}; + + ClassDef(CbmMustDigi, 1); +}; + +#endif diff --git a/core/data/must/CbmMustHit.cxx b/core/data/must/CbmMustHit.cxx index e4dc864620..fe6361ae22 100644 --- a/core/data/must/CbmMustHit.cxx +++ b/core/data/must/CbmMustHit.cxx @@ -14,30 +14,37 @@ #include <iostream> #include "TMath.h" /** Default constructor **/ -CbmMustHit::CbmMustHit() : fIsochrone(0.), fIsochroneError(0.), fPulse(0.), fDepCharge(0.), fTubeID(0), fChamberID(0), fLayerID(0), fSkewed(0) +CbmMustHit::CbmMustHit() + : FairHit() { // ClearHit(); } -CbmMustHit::CbmMustHit(Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, Int_t skew, Int_t mcindex, TVector3 &pos, TVector3 &dpos, Double_t p, Double_t isochrone, - Double_t isochroneError, Double_t chDep) - : FairHit(detID, pos, dpos, mcindex), fIsochrone(isochrone), fIsochroneError(isochroneError), fPulse(p), fDepCharge(chDep), fTubeID(tubeID), fChamberID(chamberID), - fLayerID(layerID), fSkewed(skew) +CbmMustHit::CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, + TVector3 pos, TVector3 dpos, TVector3 dir, + Double_t pulse, Double_t isochrone, Double_t isochroneError, Double_t chDep) + : FairHit(sysId, pos, dpos, mcindex) + , fDirection(dir) + , fIsochrone(isochrone) + , fIsochroneError(isochroneError) + , fPulse(pulse) + , fDepCharge(chDep) + , fDetectorId(detectorId) + , fSkewed(skew) { - SetTimeStamp(p); + SetTimeStamp(pulse); } /** Public method ClearHit **/ void CbmMustHit::ClearHit() { - fTubeID = 0; - fChamberID = 0; - fLayerID = 0; + fDetectorId = 0; fSkewed = 0; fPulse = 0; fIsochrone = 0.; fIsochroneError = 0.; fDepCharge = 0.; + fDirection.SetXYZ(0.,0.,0.); } /** Destructor **/ diff --git a/core/data/must/CbmMustHit.h b/core/data/must/CbmMustHit.h index 161fe35f8a..44ad586bfa 100644 --- a/core/data/must/CbmMustHit.h +++ b/core/data/must/CbmMustHit.h @@ -29,22 +29,23 @@ class CbmMustHit : public FairHit { CbmMustHit(); /** Standard constructor - *@param detID Detector unique volume ID - *@param tubeID Unique tube ID - *@param chamberID Unique chamber ID - *@param layerID Unique layer ID + *@param sysId Detector system unique volume ID + *@param detectorId Tube unique ID *@param skew flag for skewed tube *@param mcindex Index of corresponding MCPoint - *@param pos Position coordinates of the tube [cm] + *@param pos Position coordinates of the tube [cm] *@param dpos Errors in position coordinates [cm] + *@param dir Direction of the tube [radians] + *@param p Pulse *@param isochrone The radial measurement *@param isoerror The erroon on the radial measurement *@param chDep Deposited charge (arbitrary unit) **/ // THIS ONE! - CbmMustHit(Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, Int_t skew, Int_t mcindex, TVector3 &pos, TVector3 &dpos, Double_t p, Double_t isochrone, - Double_t isochroneError, Double_t chDep); + CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, + TVector3 pos, TVector3 dpos, TVector3 dir, + Double_t pulse, Double_t isochrone, Double_t isochroneError, Double_t chDep); /** Destructor **/ virtual ~CbmMustHit(); @@ -56,74 +57,75 @@ class CbmMustHit : public FairHit { return; } - /** Public method ClearHit - ** Resets the isochrone and it's error to 0 - **/ - void ClearHit(); - - /** Accessors **/ - Double_t GetIsochrone() const { return fIsochrone; }; - Double_t GetIsochroneError() const { return fIsochroneError; }; - Double_t GetPulse() const { return fPulse; }; - Double_t GetDepCharge() const { return fDepCharge; }; - Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; - - /** Modifiers **/ - void SetIsochrone(Double_t isochrone) { fIsochrone = isochrone; }; - void SetIsochroneError(Double_t isochroneError) { fIsochroneError = isochroneError; }; - void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } - - // tube ID // CHECK added - void SetTubeID(Int_t tubeid) { fTubeID = tubeid; } - Int_t GetTubeID() const { return fTubeID; } - void SetChamberID(Int_t chamberid) { fChamberID = chamberid; } - Int_t GetChamberID() const { return fChamberID; } - void SetLayerID(Int_t layerid) { fLayerID = layerid; } - Int_t GetLayerID() const { return fLayerID; } - Int_t GetSkewed() const { return fSkewed; } - - virtual bool equal(FairTimeStamp *data) - { - CbmMustHit *myDigi = dynamic_cast<CbmMustHit *>(data); - if (myDigi != nullptr) { - if (fTubeID == myDigi->GetTubeID()) - return true; + /** Public method ClearHit + ** Resets the isochrone and it's error to 0 + **/ + void ClearHit(); + + /** Accessors **/ + Double_t GetIsochrone() const { return fIsochrone; }; + Double_t GetIsochroneError() const { return fIsochroneError; }; + Double_t GetPulse() const { return fPulse; }; + Double_t GetDepCharge() const { return fDepCharge; }; + Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; + + TVector3 GetDirection() const { return fDirection; }; + + /** Modifiers **/ + void SetIsochrone(Double_t isochrone) { fIsochrone = isochrone; }; + void SetIsochroneError(Double_t isochroneError) { fIsochroneError = isochroneError; }; + void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } + + // tube ID // CHECK added + void SetDetSysId(Int_t sysId) { fDetSysId = sysId; } + Int_t GetDetSysId() const { return fDetSysId; } + void SetTubeId(Int_t tubeId) { fDetectorId = tubeId; } + Int_t GetTubeId() const { return fDetectorId; } + Int_t GetSkewed() const { return fSkewed; } + + virtual bool equal(FairTimeStamp *data) + { + CbmMustHit *myHit = dynamic_cast<CbmMustHit *>(data); + if (myHit != nullptr) { + if (fDetectorId == myHit->GetTubeId()) + return true; + } + return false; } - return false; - } - virtual bool operator<(const CbmMustHit &myDigi) const - { - if (fTubeID < myDigi.GetTubeID()) - return true; - else - return false; - } + virtual bool operator<(const CbmMustHit &myHit) const + { + if (fDetectorId < myHit.GetTubeId()) + return true; + else + return false; + } - friend std::ostream &operator<<(std::ostream &out, CbmMustHit &digi) - { - out << "CbmSttHit in Tube: " << digi.GetTubeID() << " Isochrone: " << digi.GetIsochrone() << " +/- " << digi.GetIsochroneError() << " Charge: " << digi.GetDepCharge() - << " Pulse: " << digi.GetPulse() << std::endl; - return out; - } + friend std::ostream &operator<<(std::ostream &out, CbmMustHit &digi) + { + out << "CbmSttHit in Tube: " << digi.GetTubeId() << " Isochrone: " << digi.GetIsochrone() << " +/- " << digi.GetIsochroneError() << " Charge: " << digi.GetDepCharge() + << " Pulse: " << digi.GetPulse() << std::endl; + return out; + } - protected: - /** This variable contains the radial distance to the wire **/ - Double_t fIsochrone; - /** This variable contains the error on the radial distance to the wire **/ - Double_t fIsochroneError; +protected: + TVector3 fDirection {0.,0.,0.}; + + /** This variable contains the radial distance to the wire **/ + Double_t fIsochrone {0.};; + /** This variable contains the error on the radial distance to the wire **/ + Double_t fIsochroneError {0.}; - /** time pulse **/ - Double_t fPulse; + /** time pulse **/ + Double_t fPulse {0.}; - /** deposit charge (arbitrary units) **/ - Double_t fDepCharge; + /** deposit charge (arbitrary units) **/ + Double_t fDepCharge {0.}; - /** tube id **/ - Int_t fTubeID; // CHECK added - Int_t fChamberID; - Int_t fLayerID; - Int_t fSkewed; + /** tube id **/ + Int_t fDetSysId {0}; // CHECK added + Int_t fDetectorId {0}; + Int_t fSkewed {0}; ClassDef(CbmMustHit, 1); }; diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h index a0a1f99cdf..8a5b98154a 100644 --- a/core/data/must/CbmMustPoint.h +++ b/core/data/must/CbmMustPoint.h @@ -81,9 +81,9 @@ class CbmMustPoint : public FairMCPoint { // void SetWireDirection(TVector3 wire); // tube ID // CHECK added - Int_t GetLayerID () { return fLayerID; } - Int_t GetModuleID() { return fModuleID; } - Int_t GetStrawID () { return fStrawID; } + Int_t GetLayerID () const { return fLayerID; } + Int_t GetModuleID() const { return fModuleID; } + Int_t GetStrawID () const { return fStrawID; } void SetLayerID (Int_t layerid) { fLayerID = layerid; } void SetModuleID(Int_t moduleid) { fModuleID = moduleid; } void SetStrawID (Int_t strawid) { fStrawID = strawid; } -- GitLab From e3f2ebeb0f32ee882513b3ce5d5824731f308361 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Fri, 31 Jan 2025 15:49:10 +0100 Subject: [PATCH 07/12] feat(must) Add CbmMustDigitize class --- sim/detectors/must/CMakeLists.txt | 1 + sim/detectors/must/CbmMustDigitize.cxx | 124 +++++++++++++++++++++++++ sim/detectors/must/CbmMustDigitize.h | 61 ++++++++++++ sim/detectors/must/CbmMustSimLinkDef.h | 1 + 4 files changed, 187 insertions(+) create mode 100644 sim/detectors/must/CbmMustDigitize.cxx create mode 100644 sim/detectors/must/CbmMustDigitize.h diff --git a/sim/detectors/must/CMakeLists.txt b/sim/detectors/must/CMakeLists.txt index 41bb26c301..4bc2ceb0b2 100644 --- a/sim/detectors/must/CMakeLists.txt +++ b/sim/detectors/must/CMakeLists.txt @@ -5,6 +5,7 @@ set(INCLUDE_DIRECTORIES set(SRCS CbmMust.cxx + CbmMustDigitize.cxx ) diff --git a/sim/detectors/must/CbmMustDigitize.cxx b/sim/detectors/must/CbmMustDigitize.cxx new file mode 100644 index 0000000000..29739a03ca --- /dev/null +++ b/sim/detectors/must/CbmMustDigitize.cxx @@ -0,0 +1,124 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustDigitize source file ----- +// ----- Created 2025-01-30 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +/** @file CbmMustDigitize.cxx + ** @author Radoslaw Karabowicz <r.karabowicz@gsi.de> + ** @since 30.01.2025 + **/ + +// Include class header +#include "CbmMustDigitize.h" + +// Includes from ROOT +#include "TClonesArray.h" + +// Includes from FairRoot +#include "FairEventHeader.h" +#include "FairField.h" +#include "FairLink.h" +#include "FairMCEventHeader.h" +#include "FairMCPoint.h" +#include "FairRunAna.h" +#include "FairRunSim.h" +#include "FairRuntimeDb.h" +#include <Logger.h> + +// Includes from CbmRoot +#include "CbmMCTrack.h" +#include "CbmMustDigi.h" +#include "CbmMustPoint.h" + +// ----- Standard constructor ------------------------------------------ +CbmMustDigitize::CbmMustDigitize() + : FairTask("MustDigitizer") +{ +} +// ------------------------------------------------------------------------- + + +// ----- Destructor ---------------------------------------------------- +CbmMustDigitize::~CbmMustDigitize() {} +// ------------------------------------------------------------------------- + +// ----- Task execution ------------------------------------------------ +void CbmMustDigitize::Exec(Option_t* /*opt*/) +{ + assert(fPointArray); + fDigiArray->Delete(); + + // LOG(info) << "got " << fPointArray->GetEntriesFast() << " points"; + for (Int_t iPoint = 0; iPoint < fPointArray->GetEntriesFast(); iPoint++) { + const CbmMustPoint* point = (const CbmMustPoint*) fPointArray->At(iPoint); + // LOG(info) << "point from " << point->GetXInLocal() << "," << point->GetYInLocal() << "," << point->GetZInLocal() + // << " to " << point->GetXOutLocal() << "," << point->GetYOutLocal() << "," << point->GetZOutLocal(); + int detectorId = 1e7 + point->GetLayerID()*1e5 + point->GetModuleID()*1e3 + point->GetStrawID(); + int skew = 0; + if ( point->GetLayerID() == 2 ) skew = 1; + if ( point->GetLayerID() == 3 ) skew = -11; + + double driftTime = GetDriftTime(point); + + // ideal output... + CbmMustDigi* digi = new ((*fDigiArray)[iPoint]) CbmMustDigi(detectorId, skew, driftTime, 5, 1); + } +} +// ------------------------------------------------------------------------- + +// ----- Private function to get drift time ---------------------------- +double CbmMustDigitize::GetDriftTime(const CbmMustPoint* point) { + double closestDist = TMath::Sqrt((point->GetXInLocal()+point->GetXOutLocal())*(point->GetXInLocal()+point->GetXOutLocal())+ + (point->GetYInLocal()+point->GetYOutLocal())*(point->GetYInLocal()+point->GetYOutLocal())); + // LOG(info) << "closest distance = " << closestDist << " cm ---> " << closestDist*400. << " ns"; + return closestDist * 400.; +} +// ------------------------------------------------------------------------- + +// ----- Finish run --------------------------------------------------- +void CbmMustDigitize::Finish() +{ +} +// ------------------------------------------------------------------------- + +// ----- Initialisation ----------------------------------------------- +InitStatus CbmMustDigitize::Init() +{ + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) { + std::cout << "-E- CbmMustDigitize::Init: " /// todo replace with logger! + << "RootManager not instantiated!" << std::endl; + return kFATAL; + } + + fPointArray = static_cast<TClonesArray*>(ioman->GetObject("MUSTPoint")); + if (!fPointArray) { + std::cout << "-W- CbmMustDigitize::Init: " + << "No Point array!" << std::endl; + return kERROR; + } + + // Create and register output array + fDigiArray = new TClonesArray("CbmMustDigi"); + ioman->Register("MUSTDigi", "MUST", fDigiArray, kTRUE); + + // Set static initialisation flag + fIsInitialised = kTRUE; + + return kSUCCESS; +} +// ------------------------------------------------------------------------- + +// ----- Private method ReInit ----------------------------------------- +InitStatus CbmMustDigitize::ReInit() +{ + + return kSUCCESS; +} +// ------------------------------------------------------------------------- + +ClassImp(CbmMustDigitize) diff --git a/sim/detectors/must/CbmMustDigitize.h b/sim/detectors/must/CbmMustDigitize.h new file mode 100644 index 0000000000..1d93491669 --- /dev/null +++ b/sim/detectors/must/CbmMustDigitize.h @@ -0,0 +1,61 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustDigitize header file ----- +// ----- Created 2025-01-30 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +#ifndef CBMMUSTDIGITIZE_H +#define CBMMUSTDIGITIZE_H 1 + +#include "CbmDefs.h" +#include "CbmDigitize.h" +#include "CbmMustDigi.h" +#include "CbmMustPoint.h" + +/** @class CbmMustDigitize + ** @brief Task class for simulating the detector response of the MUST + ** @author Radoslaw Karabowicz <r.karabowicz@gsi.de> + ** @since 30.01.2025 + ** @version 1.0 + ** + **/ +class CbmMustDigitize : public FairTask { + +public: + /** Constructor **/ + CbmMustDigitize(); + + /** Destructor **/ + virtual ~CbmMustDigitize(); + + /** Virtual method Exec **/ + void Exec(Option_t* opt) override; + + /** Re-initialisation **/ + virtual InitStatus ReInit(); + +private: + Bool_t fIsInitialised; ///< kTRUE if Init() was called + + TClonesArray* fPointArray {nullptr}; ///< Input array of CbmMustPoint + TClonesArray* fDigiArray {nullptr}; + + double GetDriftTime(const CbmMustPoint* point); + + /** End-of-run action **/ + void Finish() override; + + /** Initialisation **/ + InitStatus Init() override; + + /** Prevent usage of copy constructor and assignment operator **/ + CbmMustDigitize(const CbmMustDigitize&); + CbmMustDigitize operator=(const CbmMustDigitize&); + + ClassDef(CbmMustDigitize, 1); +}; + +#endif diff --git a/sim/detectors/must/CbmMustSimLinkDef.h b/sim/detectors/must/CbmMustSimLinkDef.h index e423834418..3f56058f4e 100644 --- a/sim/detectors/must/CbmMustSimLinkDef.h +++ b/sim/detectors/must/CbmMustSimLinkDef.h @@ -9,5 +9,6 @@ #pragma link off all functions; #pragma link C++ class CbmMust + ; +#pragma link C++ class CbmMustDigitize + ; #endif /* __CINT__ */ -- GitLab From 5362f04ce077ecc4c2644e114ae3838acce903da Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Fri, 31 Jan 2025 15:51:40 +0100 Subject: [PATCH 08/12] feat(must) Changes to CbmMust geo scheme classes --- core/detectors/must/CbmMustGeoScheme.cxx | 12 ++++++++++-- core/detectors/must/CbmMustGeoScheme.h | 3 +++ core/detectors/must/CbmMustLayer.cxx | 7 +++++++ core/detectors/must/CbmMustLayer.h | 3 +++ core/detectors/must/CbmMustModule.cxx | 4 +++- core/detectors/must/CbmMustStation.cxx | 7 +++++++ core/detectors/must/CbmMustStation.h | 4 ++++ core/detectors/must/CbmMustTube.cxx | 2 +- 8 files changed, 38 insertions(+), 4 deletions(-) diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx index 7cd7e54713..6111ccdc74 100644 --- a/core/detectors/must/CbmMustGeoScheme.cxx +++ b/core/detectors/must/CbmMustGeoScheme.cxx @@ -11,8 +11,10 @@ **/ #include "CbmMustGeoScheme.h" -#include "CbmMustLayer.h" // for CbmMustLayer #include "CbmMustStation.h" // for CbmMustStation +#include "CbmMustLayer.h" // for CbmMustLayer +#include "CbmMustModule.h" +#include "CbmMustTube.h" #include <Logger.h> // for LOG @@ -78,7 +80,6 @@ void CbmMustGeoScheme::Init(TObjArray* stations) } // ------------------------------------------------------------------------- - // ------------------------------------------------------------------------- void CbmMustGeoScheme::Init(TString parFileName) { @@ -126,6 +127,13 @@ CbmMustStation* CbmMustGeoScheme::FindStation(int detid) return nullptr; } +CbmMustTube* CbmMustGeoScheme::GetTube(int detid) { + int stationid = detid / 1e7 - 1; + CbmMustStation* tempStat = GetStation(stationid); + // LOG(info) << "trying to get tube " << detid % 10000000 << " from station " << stationid; + return tempStat ? tempStat->GetTube(detid % 10000000) : nullptr; +} + bool CbmMustGeoScheme::AddStation(CbmMustStation* station) { for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h index f6f40858c9..4c92c9cdc2 100644 --- a/core/detectors/must/CbmMustGeoScheme.h +++ b/core/detectors/must/CbmMustGeoScheme.h @@ -35,6 +35,7 @@ #include <map> // for map #include <vector> // for vector +class CbmMustTube; class CbmMustLayer; class CbmMustModule; class CbmMustStation; @@ -60,6 +61,8 @@ public: int GetNStations() const { return fStations->GetEntriesFast(); } + CbmMustTube* GetTube(int detid); + CbmMustStation* FindStation(int detid); bool AddStation(CbmMustStation* station); void Show(); diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx index 21bd3d7806..612a5e31ec 100644 --- a/core/detectors/must/CbmMustLayer.cxx +++ b/core/detectors/must/CbmMustLayer.cxx @@ -52,6 +52,13 @@ CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel) CbmMustLayer::~CbmMustLayer() {} // ------------------------------------------------------------------------- +CbmMustTube* CbmMustLayer::GetTube(int detid) { + int moduleid = detid / 1e3 -1; + CbmMustModule* tempModule = GetModule(moduleid); + // LOG(info) << "trying to get tube " << detid % 1000 << " from module " << moduleid; + return tempModule ? tempModule->GetTube(detid % 1000 - 1) : nullptr; +} + CbmMustModule* CbmMustLayer::FindModule(int detid) { for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h index 7f282b3f1f..e8afd0799a 100644 --- a/core/detectors/must/CbmMustLayer.h +++ b/core/detectors/must/CbmMustLayer.h @@ -22,6 +22,7 @@ #include <TObject.h> // for TObject #include <TObjArray.h> // for TObjArray #include "CbmMustModule.h" +#include "CbmMustTube.h" class CbmMustLayer : public TObject { @@ -56,6 +57,8 @@ public: CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); } + CbmMustTube* GetTube(int detid); + CbmMustModule* FindModule(int detid); bool AddModule(CbmMustModule* module); void Show(); diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx index 2bd5689e3e..3e958454b8 100644 --- a/core/detectors/must/CbmMustModule.cxx +++ b/core/detectors/must/CbmMustModule.cxx @@ -67,7 +67,9 @@ void CbmMustModule::Show() { for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); // if ( iobj == 0 ) - LOG(info) << " Tube " << tempTube->GetDetectorId() << " @ " << tempTube->GetPosition().X() << "," << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z(); + LOG(info) << " Tube " << tempTube->GetDetectorId() + << " @ " << tempTube->GetPosition().X() << "," << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z() + << " -> " << tempTube->GetWireDirection().X() << "," << tempTube->GetWireDirection().Y() << "," << tempTube->GetWireDirection().Z(); tubeNumbDec[iobj] = char(tempTube->GetTubeNumber()/10+48); tubeNumbOne[iobj] = char(tempTube->GetTubeNumber()%10+48); tubeString[tempTube->GetTubeNumber()-1] = '*'; diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx index ea637e0112..820ab6f978 100644 --- a/core/detectors/must/CbmMustStation.cxx +++ b/core/detectors/must/CbmMustStation.cxx @@ -44,6 +44,13 @@ CbmMustStation::CbmMustStation(int iStation, double z) CbmMustStation::~CbmMustStation() {} // ------------------------------------------------------------------------- +CbmMustTube* CbmMustStation::GetTube(int detid) { + int layerid = detid / 1e5 - 1; + CbmMustLayer* tempLay = GetLayer(layerid); + // LOG(info) << "trying to get tube " << detid % 100000 << " from layer " << layerid; + return tempLay ? tempLay->GetTube(detid % 100000) : nullptr; +} + // ----- Public method AddSector --------------------------------------- CbmMustLayer* CbmMustStation::FindLayer(int detid) { diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h index dcec28c373..c9a6d8fa08 100644 --- a/core/detectors/must/CbmMustStation.h +++ b/core/detectors/must/CbmMustStation.h @@ -19,6 +19,8 @@ #include "CbmMustLayer.h" // for CbmMustLayer +#include "CbmMustTube.h" + #include <Rtypes.h> // for THashConsistencyHolder, ClassDef #include <TObjArray.h> // for TObjArray #include <TObject.h> // for TObject @@ -44,6 +46,8 @@ public: double GetZ() const { return fZ; } int GetNLayers() const { return fLayers.GetEntriesFast(); } + CbmMustTube* GetTube(int detid); + CbmMustLayer* GetLayer(int iLayer) const { return (CbmMustLayer*) fLayers.At(iLayer); } /** Add one sector to the array **/ diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx index 4b39cfb99b..2e02d66f4e 100644 --- a/core/detectors/must/CbmMustTube.cxx +++ b/core/detectors/must/CbmMustTube.cxx @@ -87,7 +87,7 @@ Double_t CbmMustTube::GetHalfLength() const TVector3 CbmMustTube::GetWireDirection() const { - return TVector3(fRotationMatrix[0][2], fRotationMatrix[1][2], fRotationMatrix[2][2]); + return TVector3(-fRotationMatrix[0][1], fRotationMatrix[1][1], fRotationMatrix[2][1]); } Int_t CbmMustTube::Compare(const TObject *obj) const { -- GitLab From af24b2a487130c15b4b118b0531b7f1c140692f8 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Fri, 31 Jan 2025 15:53:18 +0100 Subject: [PATCH 09/12] feat(must) Add CbmMustFindHits class --- reco/detectors/CMakeLists.txt | 1 + reco/detectors/must/CMakeLists.txt | 39 ++++++++ reco/detectors/must/CbmMustFindHits.cxx | 110 +++++++++++++++++++++++ reco/detectors/must/CbmMustFindHits.h | 50 +++++++++++ reco/detectors/must/CbmMustRecoLinkDef.h | 13 +++ 5 files changed, 213 insertions(+) create mode 100644 reco/detectors/must/CMakeLists.txt create mode 100644 reco/detectors/must/CbmMustFindHits.cxx create mode 100644 reco/detectors/must/CbmMustFindHits.h create mode 100644 reco/detectors/must/CbmMustRecoLinkDef.h diff --git a/reco/detectors/CMakeLists.txt b/reco/detectors/CMakeLists.txt index 3b70d1eded..0cf3fa9389 100644 --- a/reco/detectors/CMakeLists.txt +++ b/reco/detectors/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory(bmon) add_subdirectory(much) +add_subdirectory(must) add_subdirectory(mvd) add_subdirectory(psd) add_subdirectory(fsd) diff --git a/reco/detectors/must/CMakeLists.txt b/reco/detectors/must/CMakeLists.txt new file mode 100644 index 0000000000..539d73343a --- /dev/null +++ b/reco/detectors/must/CMakeLists.txt @@ -0,0 +1,39 @@ +set(INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +set(SRCS + CbmMustFindHits.cxx + ) + + +set(LIBRARY_NAME CbmMustReco) +set(LINKDEF ${LIBRARY_NAME}LinkDef.h) +set(PUBLIC_DEPENDENCIES + CbmData + CbmMustBase + CbmRecoBase + FairRoot::Base + ROOT::Core + ROOT::Hist + ) + +set(PRIVATE_DEPENDENCIES + CbmBase + CbmQaBase + FairRoot::ParBase + ROOT::Gpad + ROOT::Graf + ROOT::MathCore + ROOT::Physics + ROOT::RHTTP + ROOT::RIO + ) + +set(INTERFACE_DEPENDENCIES + FairLogger::FairLogger + external::fles_ipc + ) + + +generate_cbm_library() diff --git a/reco/detectors/must/CbmMustFindHits.cxx b/reco/detectors/must/CbmMustFindHits.cxx new file mode 100644 index 0000000000..8ea5d929eb --- /dev/null +++ b/reco/detectors/must/CbmMustFindHits.cxx @@ -0,0 +1,110 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustFindHits source file ----- +// ----- Created 2025-01-30 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +/** @file CbmMustFindHits.cxx + ** @author Radoslaw Karabowicz <r.karabowicz@gsi.de> + ** @since 30.01.2025 + **/ +#include "CbmMustFindHits.h" + +#include "CbmMustDigi.h" +#include "CbmMustHit.h" +#include "CbmMustTube.h" + +#include "FairRootManager.h" + +#include "TFile.h" +#include "TMath.h" +#include "TStopwatch.h" + +#include <algorithm> +#include <iomanip> +#include <iostream> + +using std::cout; +using std::endl; +using std::fixed; +using std::left; +using std::multimap; +using std::right; +using std::setw; +using std::vector; + +// ------------------------------------------------------------------------- +CbmMustFindHits::CbmMustFindHits() + : FairTask("MustFindHits", 1) +{ +} + +// ----- Destructor ---------------------------------------------------- +CbmMustFindHits::~CbmMustFindHits() {} +// ------------------------------------------------------------------------- + +// ----- Task execution ------------------------------------------------ +void CbmMustFindHits::Exec(Option_t* /*opt*/) +{ + assert(fDigiArray); + fHitArray->Delete(); + + // LOG(info) << "got " << fDigiArray->GetEntriesFast() << " points"; + for (Int_t iDigi = 0; iDigi < fDigiArray->GetEntriesFast(); iDigi++) { + const CbmMustDigi* digi = (const CbmMustDigi*) fDigiArray->At(iDigi); + if ( !digi ) LOG(info) << "no digi"; + auto isochrone = GetIsochrone(digi); + + // LOG(info) << "trying to get tube number " << digi->GetDetectorId(); + CbmMustTube* tube = fGeoScheme->GetTube(digi->GetDetectorId()); + if ( !tube ) LOG(info) << "no tube"; + + CbmMustHit* hit = new ((*fHitArray)[iDigi]) CbmMustHit(7,digi->GetDetectorId(), digi->GetSkewed(), 0, + tube->GetPosition(), {0.,0.,0.}, tube->GetWireDirection(), + digi->GetSignalTime(), isochrone.first, isochrone.second, digi->GetDepCharge()); + } +} +// ------------------------------------------------------------------------- + +// ----- Private function to get isochronoe ---------------------------- +std::pair<double,double> CbmMustFindHits::GetIsochrone(const CbmMustDigi* digi) +{ + return std::pair<double,double> (digi->GetSignalTime()/400.,digi->GetSignalError()/400.); +} +// ------------------------------------------------------------------------- + + +// ----- Initialisation ----------------------------------------------- +InitStatus CbmMustFindHits::Init() +{ + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) { + std::cout << "-E- CbmMustFindHits::Init: " /// todo replace with logger! + << "RootManager not instantiated!" << std::endl; + return kFATAL; + } + + fDigiArray = static_cast<TClonesArray*>(ioman->GetObject("MUSTDigi")); + if (!fDigiArray) { + std::cout << "-W- CbmMustFindHits::Init: " + << "No Digi array!" << std::endl; + return kERROR; + } + + // Create and register output array + fHitArray = new TClonesArray("CbmMustHit"); + ioman->Register("MUSTHit", "MUST", fHitArray, kTRUE); + + fGeoScheme = CbmMustGeoScheme::Instance(); + fGeoScheme->Init("$VMCWORKDIR/parameters/must/must_geoScheme.root"); + + fGeoScheme->Show(); + + return kSUCCESS; +} +// ------------------------------------------------------------------------- + +ClassImp(CbmMustFindHits) diff --git a/reco/detectors/must/CbmMustFindHits.h b/reco/detectors/must/CbmMustFindHits.h new file mode 100644 index 0000000000..5c2016730b --- /dev/null +++ b/reco/detectors/must/CbmMustFindHits.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radoslaw Karabowicz */ + +// ------------------------------------------------------------------------- +// ----- CbmMustFindHits header file ----- +// ----- Created 2025-01-30 by R. Karabowicz ----- +// ------------------------------------------------------------------------- + +/** @file CbmMustDigitize.cxx + ** @author Radoslaw Karabowicz <r.karabowicz@gsi.de> + ** @since 30.01.2025 + **/ + +#ifndef CBMMUSTFINDHITS_H +#define CBMMUSTFINDHITS_H 1 + +#include "CbmMustDigi.h" +#include "CbmMustGeoScheme.h" + +#include "FairTask.h" + +#include "TString.h" +#include "TClonesArray.h" + +#include <vector> + +class CbmMustFindHits : public FairTask { + public: + CbmMustFindHits(); + virtual ~CbmMustFindHits(); + virtual void Exec(Option_t* opt); + + private: + virtual InitStatus Init(); + TString fDigiFile = "must_geoScheme.root"; // Digitization file + + TClonesArray* fDigiArray {nullptr}; + TClonesArray* fHitArray {nullptr}; + CbmMustGeoScheme* fGeoScheme {nullptr}; // Geometry scheme + + std::pair<double,double> GetIsochrone(const CbmMustDigi* digi); + + CbmMustFindHits(const CbmMustFindHits&); + CbmMustFindHits operator=(const CbmMustFindHits&); + + ClassDef(CbmMustFindHits, 1); +}; + +#endif diff --git a/reco/detectors/must/CbmMustRecoLinkDef.h b/reco/detectors/must/CbmMustRecoLinkDef.h new file mode 100644 index 0000000000..2da13a8a06 --- /dev/null +++ b/reco/detectors/must/CbmMustRecoLinkDef.h @@ -0,0 +1,13 @@ +/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Florian Uhlig [committer] */ + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class CbmMustFindHits + ; + +#endif -- GitLab From 64bf8716121d572bae101ffe17a5092016909f20 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Fri, 31 Jan 2025 15:54:50 +0100 Subject: [PATCH 10/12] feat(must) Add digi and hit finder macros for must --- macro/must/run_digi.C | 86 +++++++++++++++++++++++++++++++++++++++++++ macro/must/run_hit.C | 86 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 macro/must/run_digi.C create mode 100644 macro/must/run_hit.C diff --git a/macro/must/run_digi.C b/macro/must/run_digi.C new file mode 100644 index 0000000000..08b194da79 --- /dev/null +++ b/macro/must/run_digi.C @@ -0,0 +1,86 @@ +#include <TStopwatch.h> +#include <TString.h> +#include <iostream> +#include <memory> + +using std::cout; +using std::endl; + +void run_digi() +{ + FairLogger* logger = FairLogger::GetLogger(); + // logger->SetLogFileName("MyLog.log"); + // logger->SetLogToScreen(kTRUE); + // logger->SetLogToFile(kTRUE); + logger->SetLogVerbosityLevel("LOW"); + // logger->SetLogFileLevel("DEBUG4"); + // logger->SetLogScreenLevel("DEBUG"); + + // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) + Int_t iVerbose = 0; // just forget about it, for the moment + + // Input file (MC events) + TString inFile = "points.root"; + + // Parameter file + TString parFile = "params.root"; + + // Output file + TString outFile = "digis.root"; + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + + // ----- Reconstruction run ------------------------------------------- + FairRunAna run{}; + FairFileSource* fFileSource = new FairFileSource(inFile); + run.SetSource(fFileSource); + run.SetSink(std::make_unique<FairRootFileSink>(outFile)); + run.SetUseFairLinks(kTRUE); + FairLinkManager::Instance()->AddIncludeType(0); + // FairLinkManager::Instance()->AddIncludeType(1); + run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + + FairRuntimeDb* rtdb = run.GetRuntimeDb(); + FairParRootFileIo* parInput1 = new FairParRootFileIo(); + parInput1->open(parFile.Data()); + rtdb->setFirstInput(parInput1); + + // ----- TorinoDetector hit producers --------------------------------- + CbmMustDigitize* digiTask = new CbmMustDigitize(); + run.AddTask(digiTask); + + run.Init(); + + timer.Start(); + run.Run(); + + // ----- Finish ------------------------------------------------------- + + cout << endl << endl; + + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + cout << maxMemory; + cout << "</DartMeasurement>" << endl; + + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + + Float_t cpuUsage = ctime / rtime; + cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + cout << cpuUsage; + cout << "</DartMeasurement>" << endl; + + cout << endl << endl; + cout << "Output file is " << outFile << endl; + cout << "Parameter file is " << parFile << endl; + cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; + cout << "Macro finished successfully." << endl; + + // ------------------------------------------------------------------------ +} diff --git a/macro/must/run_hit.C b/macro/must/run_hit.C new file mode 100644 index 0000000000..3d192fb5dd --- /dev/null +++ b/macro/must/run_hit.C @@ -0,0 +1,86 @@ +#include <TStopwatch.h> +#include <TString.h> +#include <iostream> +#include <memory> + +using std::cout; +using std::endl; + +void run_hit() +{ + FairLogger* logger = FairLogger::GetLogger(); + // logger->SetLogFileName("MyLog.log"); + // logger->SetLogToScreen(kTRUE); + // logger->SetLogToFile(kTRUE); + logger->SetLogVerbosityLevel("LOW"); + // logger->SetLogFileLevel("DEBUG4"); + // logger->SetLogScreenLevel("DEBUG"); + + // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) + Int_t iVerbose = 0; // just forget about it, for the moment + + // Input file (MC events) + TString inFile = "digis.root"; + + // Parameter file + TString parFile = "params.root"; + + // Output file + TString outFile = "hits.root"; + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + + // ----- Reconstruction run ------------------------------------------- + FairRunAna run{}; + FairFileSource* fFileSource = new FairFileSource(inFile); + run.SetSource(fFileSource); + run.SetSink(std::make_unique<FairRootFileSink>(outFile)); + run.SetUseFairLinks(kTRUE); + FairLinkManager::Instance()->AddIncludeType(0); + // FairLinkManager::Instance()->AddIncludeType(1); + run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + + FairRuntimeDb* rtdb = run.GetRuntimeDb(); + FairParRootFileIo* parInput1 = new FairParRootFileIo(); + parInput1->open(parFile.Data()); + rtdb->setFirstInput(parInput1); + + // ----- TorinoDetector hit producers --------------------------------- + CbmMustFindHits* hitTask = new CbmMustFindHits(); + run.AddTask(hitTask); + + run.Init(); + + timer.Start(); + run.Run(); + + // ----- Finish ------------------------------------------------------- + + cout << endl << endl; + + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + cout << maxMemory; + cout << "</DartMeasurement>" << endl; + + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + + Float_t cpuUsage = ctime / rtime; + cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + cout << cpuUsage; + cout << "</DartMeasurement>" << endl; + + cout << endl << endl; + cout << "Output file is " << outFile << endl; + cout << "Parameter file is " << parFile << endl; + cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; + cout << "Macro finished successfully." << endl; + + // ------------------------------------------------------------------------ +} -- GitLab From 854823268ac05d6e181b6c9889cc48a1f31dabb3 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Thu, 6 Feb 2025 17:11:55 +0100 Subject: [PATCH 11/12] chore(must): Apply format --- core/data/must/CbmMustDigi.cxx | 28 +- core/data/must/CbmMustDigi.h | 77 ++- core/data/must/CbmMustHit.cxx | 42 +- core/data/must/CbmMustHit.h | 131 +++-- core/data/must/CbmMustPoint.cxx | 90 +++- core/data/must/CbmMustPoint.h | 31 +- core/detectors/must/CMakeLists.txt | 1 - core/detectors/must/CbmGeoMust.cxx | 10 +- core/detectors/must/CbmGeoMust.h | 18 +- core/detectors/must/CbmGeoMustPar.cxx | 40 +- core/detectors/must/CbmGeoMustPar.h | 33 +- core/detectors/must/CbmMustBaseLinkDef.h | 1 - core/detectors/must/CbmMustContFact.cxx | 20 +- core/detectors/must/CbmMustContFact.h | 8 +- core/detectors/must/CbmMustGeoScheme.cxx | 79 ++- core/detectors/must/CbmMustGeoScheme.h | 72 +-- core/detectors/must/CbmMustLayer.cxx | 64 ++- core/detectors/must/CbmMustLayer.h | 61 +-- core/detectors/must/CbmMustMapCreator.cxx | 136 ++--- core/detectors/must/CbmMustMapCreator.h | 29 +- core/detectors/must/CbmMustModule.cxx | 82 ++- core/detectors/must/CbmMustModule.h | 59 +-- core/detectors/must/CbmMustSingleStraw.cxx | 564 +++++++++++++-------- core/detectors/must/CbmMustSingleStraw.h | 156 +++--- core/detectors/must/CbmMustStation.cxx | 70 ++- core/detectors/must/CbmMustStation.h | 31 +- core/detectors/must/CbmMustTube.cxx | 70 +-- core/detectors/must/CbmMustTube.h | 69 +-- macro/must/run_digi.C | 155 +++--- macro/must/run_hit.C | 155 +++--- macro/must/run_sim.C | 29 +- reco/detectors/must/CbmMustFindHits.cxx | 99 ++-- reco/detectors/must/CbmMustFindHits.h | 20 +- sim/detectors/must/CbmMust.cxx | 372 ++++++++------ sim/detectors/must/CbmMust.h | 84 +-- sim/detectors/must/CbmMustDigitize.cxx | 112 ++-- sim/detectors/must/CbmMustDigitize.h | 52 +- 37 files changed, 1675 insertions(+), 1475 deletions(-) diff --git a/core/data/must/CbmMustDigi.cxx b/core/data/must/CbmMustDigi.cxx index 015aaa2bce..5af6165ae5 100644 --- a/core/data/must/CbmMustDigi.cxx +++ b/core/data/must/CbmMustDigi.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustDigi header file ----- @@ -10,34 +10,34 @@ #include "CbmMustDigi.h" #include "CbmDefs.h" +#include "TMath.h" #include <iostream> -#include "TMath.h" /** Default constructor **/ -CbmMustDigi::CbmMustDigi() : TObject() +CbmMustDigi::CbmMustDigi() : TObject() { // ClearDigi(); } CbmMustDigi::CbmMustDigi(Int_t detectorId, Int_t skew, Double_t signalTime, Double_t signalError, Double_t chargeDep) - : TObject() - , fDetectorId(detectorId) - , fSkewed(skew) - , fSignalTime(signalTime) - , fSignalError(signalError) - , fDepCharge(chargeDep) + : TObject() + , fDetectorId(detectorId) + , fSkewed(skew) + , fSignalTime(signalTime) + , fSignalError(signalError) + , fDepCharge(chargeDep) { } /** Public method ClearDigi **/ void CbmMustDigi::ClearDigi() { - fDetectorId = 0; - fSkewed = 0; - fSignalTime = 0.; + fDetectorId = 0; + fSkewed = 0; + fSignalTime = 0.; fSignalError = 0.; - fDepCharge = 0.; + fDepCharge = 0.; } /** Destructor **/ diff --git a/core/data/must/CbmMustDigi.h b/core/data/must/CbmMustDigi.h index d75a127e84..d0d90568bf 100644 --- a/core/data/must/CbmMustDigi.h +++ b/core/data/must/CbmMustDigi.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustDigi header file ----- @@ -19,9 +19,9 @@ #ifndef CBMMUSTDIGI_H #define CBMMUSTDIGI_H 1 +#include "FairHit.h" #include "TObject.h" #include "TVector3.h" -#include "FairHit.h" class CbmMustDigi : public TObject { @@ -38,56 +38,55 @@ class CbmMustDigi : public TObject { **/ // THIS ONE! - CbmMustDigi(Int_t detectorId, Int_t skew, - Double_t signalTime, Double_t signalError, Double_t chargeDep); + CbmMustDigi(Int_t detectorId, Int_t skew, Double_t signalTime, Double_t signalError, Double_t chargeDep); - /** Destructor **/ - virtual ~CbmMustDigi(); + /** Destructor **/ + virtual ~CbmMustDigi(); - /** Output to screen (not yet implemented) **/ - virtual void Print(const Option_t *opt = nullptr) const - { - std::cout << " opt = " << opt << std::endl; - return; - } + /** Output to screen (not yet implemented) **/ + virtual void Print(const Option_t* opt = nullptr) const + { + std::cout << " opt = " << opt << std::endl; + return; + } - /** Public method ClearDigi + /** Public method ClearDigi ** Resets the isochrone and it's error to 0 **/ - void ClearDigi(); + void ClearDigi(); - /** Accessors **/ - Double_t GetSignalTime() const { return fSignalTime; }; - Double_t GetSignalError() const { return fSignalError; }; - Double_t GetDepCharge() const { return fDepCharge; }; - Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; + /** Accessors **/ + Double_t GetSignalTime() const { return fSignalTime; }; + Double_t GetSignalError() const { return fSignalError; }; + Double_t GetDepCharge() const { return fDepCharge; }; + Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; - Double_t GetTime() const { return fSignalTime; }; - Double_t GetSkewed() const { return fSkewed; }; + Double_t GetTime() const { return fSignalTime; }; + Double_t GetSkewed() const { return fSkewed; }; - /** Modifiers **/ - void SetSignalTime(Double_t signalTime) { fSignalTime = signalTime; }; - void SetSignalError(Double_t signalError) { fSignalError = signalError; }; - void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } + /** Modifiers **/ + void SetSignalTime(Double_t signalTime) { fSignalTime = signalTime; }; + void SetSignalError(Double_t signalError) { fSignalError = signalError; }; + void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } - void SetTime(Double_t signalTime) { fSignalTime = signalTime; }; + void SetTime(Double_t signalTime) { fSignalTime = signalTime; }; - // tube ID // CHECK added - void SetDetectorId(Int_t detectorId) { fDetectorId = detectorId; } - Int_t GetDetectorId() const { return fDetectorId; } + // tube ID // CHECK added + void SetDetectorId(Int_t detectorId) { fDetectorId = detectorId; } + Int_t GetDetectorId() const { return fDetectorId; } -protected: - Double_t fSignalTime {0.}; - Double_t fSignalError{0.}; + protected: + Double_t fSignalTime{0.}; + Double_t fSignalError{0.}; - /** deposit charge (arbitrary units) **/ - Double_t fDepCharge {0.}; + /** deposit charge (arbitrary units) **/ + Double_t fDepCharge{0.}; - /** tube id **/ - Int_t fDetectorId {0}; - Int_t fSkewed {0}; + /** tube id **/ + Int_t fDetectorId{0}; + Int_t fSkewed{0}; - ClassDef(CbmMustDigi, 1); + ClassDef(CbmMustDigi, 1); }; #endif diff --git a/core/data/must/CbmMustHit.cxx b/core/data/must/CbmMustHit.cxx index fe6361ae22..6e86ef8666 100644 --- a/core/data/must/CbmMustHit.cxx +++ b/core/data/must/CbmMustHit.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustHit source file ----- @@ -10,27 +10,25 @@ #include "CbmMustHit.h" #include "CbmDefs.h" +#include "TMath.h" #include <iostream> -#include "TMath.h" /** Default constructor **/ -CbmMustHit::CbmMustHit() - : FairHit() +CbmMustHit::CbmMustHit() : FairHit() { // ClearHit(); } -CbmMustHit::CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, - TVector3 pos, TVector3 dpos, TVector3 dir, - Double_t pulse, Double_t isochrone, Double_t isochroneError, Double_t chDep) - : FairHit(sysId, pos, dpos, mcindex) - , fDirection(dir) - , fIsochrone(isochrone) - , fIsochroneError(isochroneError) - , fPulse(pulse) - , fDepCharge(chDep) - , fDetectorId(detectorId) - , fSkewed(skew) +CbmMustHit::CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, TVector3 pos, TVector3 dpos, + TVector3 dir, Double_t pulse, Double_t isochrone, Double_t isochroneError, Double_t chDep) + : FairHit(sysId, pos, dpos, mcindex) + , fDirection(dir) + , fIsochrone(isochrone) + , fIsochroneError(isochroneError) + , fPulse(pulse) + , fDepCharge(chDep) + , fDetectorId(detectorId) + , fSkewed(skew) { SetTimeStamp(pulse); } @@ -38,13 +36,13 @@ CbmMustHit::CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, /** Public method ClearHit **/ void CbmMustHit::ClearHit() { - fDetectorId = 0; - fSkewed = 0; - fPulse = 0; - fIsochrone = 0.; + fDetectorId = 0; + fSkewed = 0; + fPulse = 0; + fIsochrone = 0.; fIsochroneError = 0.; - fDepCharge = 0.; - fDirection.SetXYZ(0.,0.,0.); + fDepCharge = 0.; + fDirection.SetXYZ(0., 0., 0.); } /** Destructor **/ diff --git a/core/data/must/CbmMustHit.h b/core/data/must/CbmMustHit.h index 44ad586bfa..4d6e21205d 100644 --- a/core/data/must/CbmMustHit.h +++ b/core/data/must/CbmMustHit.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustHit header file ----- @@ -19,8 +19,8 @@ #ifndef CBMMUSTHIT_H #define CBMMUSTHIT_H 1 -#include "TVector3.h" #include "FairHit.h" +#include "TVector3.h" class CbmMustHit : public FairHit { @@ -43,89 +43,88 @@ class CbmMustHit : public FairHit { **/ // THIS ONE! - CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, - TVector3 pos, TVector3 dpos, TVector3 dir, + CbmMustHit(Int_t sysId, Int_t detectorId, Int_t skew, Int_t mcindex, TVector3 pos, TVector3 dpos, TVector3 dir, Double_t pulse, Double_t isochrone, Double_t isochroneError, Double_t chDep); /** Destructor **/ virtual ~CbmMustHit(); /** Output to screen (not yet implemented) **/ - virtual void Print(const Option_t *opt = nullptr) const + virtual void Print(const Option_t* opt = nullptr) const { std::cout << " opt = " << opt << std::endl; return; } - /** Public method ClearHit + /** Public method ClearHit ** Resets the isochrone and it's error to 0 **/ - void ClearHit(); - - /** Accessors **/ - Double_t GetIsochrone() const { return fIsochrone; }; - Double_t GetIsochroneError() const { return fIsochroneError; }; - Double_t GetPulse() const { return fPulse; }; - Double_t GetDepCharge() const { return fDepCharge; }; - Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; - - TVector3 GetDirection() const { return fDirection; }; - - /** Modifiers **/ - void SetIsochrone(Double_t isochrone) { fIsochrone = isochrone; }; - void SetIsochroneError(Double_t isochroneError) { fIsochroneError = isochroneError; }; - void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } - - // tube ID // CHECK added - void SetDetSysId(Int_t sysId) { fDetSysId = sysId; } - Int_t GetDetSysId() const { return fDetSysId; } - void SetTubeId(Int_t tubeId) { fDetectorId = tubeId; } - Int_t GetTubeId() const { return fDetectorId; } - Int_t GetSkewed() const { return fSkewed; } - - virtual bool equal(FairTimeStamp *data) - { - CbmMustHit *myHit = dynamic_cast<CbmMustHit *>(data); - if (myHit != nullptr) { - if (fDetectorId == myHit->GetTubeId()) - return true; - } - return false; + void ClearHit(); + + /** Accessors **/ + Double_t GetIsochrone() const { return fIsochrone; }; + Double_t GetIsochroneError() const { return fIsochroneError; }; + Double_t GetPulse() const { return fPulse; }; + Double_t GetDepCharge() const { return fDepCharge; }; + Double_t GetEnergyLoss() const { return fDepCharge / 1e6; }; + + TVector3 GetDirection() const { return fDirection; }; + + /** Modifiers **/ + void SetIsochrone(Double_t isochrone) { fIsochrone = isochrone; }; + void SetIsochroneError(Double_t isochroneError) { fIsochroneError = isochroneError; }; + void SetDepCharge(Double_t depcharge) { fDepCharge = depcharge; } + + // tube ID // CHECK added + void SetDetSysId(Int_t sysId) { fDetSysId = sysId; } + Int_t GetDetSysId() const { return fDetSysId; } + void SetTubeId(Int_t tubeId) { fDetectorId = tubeId; } + Int_t GetTubeId() const { return fDetectorId; } + Int_t GetSkewed() const { return fSkewed; } + + virtual bool equal(FairTimeStamp* data) + { + CbmMustHit* myHit = dynamic_cast<CbmMustHit*>(data); + if (myHit != nullptr) { + if (fDetectorId == myHit->GetTubeId()) return true; } + return false; + } - virtual bool operator<(const CbmMustHit &myHit) const - { - if (fDetectorId < myHit.GetTubeId()) - return true; - else - return false; - } + virtual bool operator<(const CbmMustHit& myHit) const + { + if (fDetectorId < myHit.GetTubeId()) + return true; + else + return false; + } - friend std::ostream &operator<<(std::ostream &out, CbmMustHit &digi) - { - out << "CbmSttHit in Tube: " << digi.GetTubeId() << " Isochrone: " << digi.GetIsochrone() << " +/- " << digi.GetIsochroneError() << " Charge: " << digi.GetDepCharge() - << " Pulse: " << digi.GetPulse() << std::endl; - return out; - } + friend std::ostream& operator<<(std::ostream& out, CbmMustHit& digi) + { + out << "CbmSttHit in Tube: " << digi.GetTubeId() << " Isochrone: " << digi.GetIsochrone() << " +/- " + << digi.GetIsochroneError() << " Charge: " << digi.GetDepCharge() << " Pulse: " << digi.GetPulse() << std::endl; + return out; + } + + protected: + TVector3 fDirection{0., 0., 0.}; -protected: - TVector3 fDirection {0.,0.,0.}; - - /** This variable contains the radial distance to the wire **/ - Double_t fIsochrone {0.};; - /** This variable contains the error on the radial distance to the wire **/ - Double_t fIsochroneError {0.}; + /** This variable contains the radial distance to the wire **/ + Double_t fIsochrone{0.}; + ; + /** This variable contains the error on the radial distance to the wire **/ + Double_t fIsochroneError{0.}; - /** time pulse **/ - Double_t fPulse {0.}; + /** time pulse **/ + Double_t fPulse{0.}; - /** deposit charge (arbitrary units) **/ - Double_t fDepCharge {0.}; + /** deposit charge (arbitrary units) **/ + Double_t fDepCharge{0.}; - /** tube id **/ - Int_t fDetSysId {0}; // CHECK added - Int_t fDetectorId {0}; - Int_t fSkewed {0}; + /** tube id **/ + Int_t fDetSysId{0}; // CHECK added + Int_t fDetectorId{0}; + Int_t fSkewed{0}; ClassDef(CbmMustHit, 1); }; diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx index 71c0b06363..ffce57cf2a 100644 --- a/core/data/must/CbmMustPoint.cxx +++ b/core/data/must/CbmMustPoint.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustPoint source file ----- @@ -10,30 +10,60 @@ #include "CbmMustPoint.h" #include "CbmDefs.h" // for kMCTrack +#include "FairLogger.h" +#include "math.h" #include <FairLink.h> // for FairLink #include <FairMCPoint.h> // for FairMCPoint #include <iostream> -#include "math.h" -#include "FairLogger.h" using std::cout; using std::endl; // ----- Default constructor ------------------------------------------- CbmMustPoint::CbmMustPoint() - : FairMCPoint(), fX_out_local(0), fY_out_local(0), fZ_out_local(0), fX_in_local(0.), fY_in_local(0), fZ_in_local(0), fPx_out(0), fPy_out(0), fPz_out(0), fPx_in(0), fPy_in(0), - fPz_in(0), fMass(0), fLayerID(0), fModuleID(0), fStrawID(0) + : FairMCPoint() + , fX_out_local(0) + , fY_out_local(0) + , fZ_out_local(0) + , fX_in_local(0.) + , fY_in_local(0) + , fZ_in_local(0) + , fPx_out(0) + , fPy_out(0) + , fPz_out(0) + , fPx_in(0) + , fPy_in(0) + , fPz_in(0) + , fMass(0) + , fLayerID(0) + , fModuleID(0) + , fStrawID(0) { } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ -CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, - TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass) - : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss), fX_out_local(posOutLocal.X()), fY_out_local(posOutLocal.Y()), fZ_out_local(posOutLocal.Z()), - fX_in_local(posInLocal.X()), fY_in_local(posInLocal.Y()), fZ_in_local(posInLocal.Z()), fPx_out(momOut.Px()), fPy_out(momOut.Py()), fPz_out(momOut.Pz()), fPx_in(momIn.Px()), - fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fLayerID(layerID), fModuleID(moduleID), fStrawID(strawID) +CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, + TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t tof, + Double_t length, Double_t eLoss, Double_t mass) + : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss) + , fX_out_local(posOutLocal.X()) + , fY_out_local(posOutLocal.Y()) + , fZ_out_local(posOutLocal.Z()) + , fX_in_local(posInLocal.X()) + , fY_in_local(posInLocal.Y()) + , fZ_in_local(posInLocal.Z()) + , fPx_out(momOut.Px()) + , fPy_out(momOut.Py()) + , fPz_out(momOut.Pz()) + , fPx_in(momIn.Px()) + , fPy_in(momIn.Py()) + , fPz_in(momIn.Pz()) + , fMass(mass) + , fLayerID(layerID) + , fModuleID(moduleID) + , fStrawID(strawID) { // reset MC momentum fPx = (momIn.Px() + momOut.Px()) / 2.; @@ -48,24 +78,38 @@ CbmMustPoint::~CbmMustPoint() {} // ------------------------------------------------------------------------- // ----- Copy constructor ------------------------------------------ -CbmMustPoint::CbmMustPoint(const CbmMustPoint &point) - : FairMCPoint(point.fTrackID, point.fDetectorID, TVector3(point.fX, point.fY, point.fZ), TVector3(point.fPx, point.fPy, point.fPz), point.fTime, point.fLength, point.fELoss, - point.fEventId), - fX_out_local(point.fX_out_local), fY_out_local(point.fY_out_local), fZ_out_local(point.fZ_out_local), fX_in_local(point.fX_in_local), fY_in_local(point.fY_in_local), - fZ_in_local(point.fZ_in_local), fPx_out(point.fPx_out), fPy_out(point.fPy_out), fPz_out(point.fPz_out), fPx_in(point.fPx_in), fPy_in(point.fPy_in), fPz_in(point.fPz_in), - fMass(point.fMass), fLayerID(point.fLayerID), fModuleID(point.fModuleID), fStrawID(point.fStrawID) +CbmMustPoint::CbmMustPoint(const CbmMustPoint& point) + : FairMCPoint(point.fTrackID, point.fDetectorID, TVector3(point.fX, point.fY, point.fZ), + TVector3(point.fPx, point.fPy, point.fPz), point.fTime, point.fLength, point.fELoss, point.fEventId) + , fX_out_local(point.fX_out_local) + , fY_out_local(point.fY_out_local) + , fZ_out_local(point.fZ_out_local) + , fX_in_local(point.fX_in_local) + , fY_in_local(point.fY_in_local) + , fZ_in_local(point.fZ_in_local) + , fPx_out(point.fPx_out) + , fPy_out(point.fPy_out) + , fPz_out(point.fPz_out) + , fPx_in(point.fPx_in) + , fPy_in(point.fPy_in) + , fPz_in(point.fPz_in) + , fMass(point.fMass) + , fLayerID(point.fLayerID) + , fModuleID(point.fModuleID) + , fStrawID(point.fStrawID) { } // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- -void CbmMustPoint::Print(const Option_t *opt) const +void CbmMustPoint::Print(const Option_t* opt) const { - LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in det/lay/mod/str " << fDetectorID << "/" << fLayerID << "/" << fModuleID << "/" << fStrawID; - LOG(info) << " Position (" << fX << ", " << fY << ", " << fZ << ") cm"; - LOG(info) << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV"; - LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" - << " opt=" << opt; + LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in det/lay/mod/str " << fDetectorID << "/" + << fLayerID << "/" << fModuleID << "/" << fStrawID; + LOG(info) << " Position (" << fX << ", " << fY << ", " << fZ << ") cm"; + LOG(info) << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV"; + LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" + << " opt=" << opt; } // ------------------------------------------------------------------------- diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h index 8a5b98154a..8e782506e2 100644 --- a/core/data/must/CbmMustPoint.h +++ b/core/data/must/CbmMustPoint.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustPoint header file ----- @@ -10,9 +10,9 @@ #ifndef CBMMUSTPOINT_H #define CBMMUSTPOINT_H +#include "FairMCPoint.h" #include "TObject.h" #include "TVector3.h" -#include "FairMCPoint.h" class CbmMustPoint : public FairMCPoint { @@ -35,11 +35,12 @@ class CbmMustPoint : public FairMCPoint { *@param length Track length since creation [cm] *@param eLoss Energy deposit [GeV] **/ - CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, - Double_t tof, Double_t length, Double_t eLoss, Double_t mass); + CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, + TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t tof, + Double_t length, Double_t eLoss, Double_t mass); /** Copy constructor **/ - CbmMustPoint(const CbmMustPoint &point); + CbmMustPoint(const CbmMustPoint& point); /** Destructor **/ virtual ~CbmMustPoint(); @@ -69,9 +70,9 @@ class CbmMustPoint : public FairMCPoint { Double_t GetMass() const { return fMass; } - void PositionOutLocal(TVector3 &pos) { pos.SetXYZ(fX_out_local, fY_out_local, fZ_out_local); } - void PositionInLocal(TVector3 &pos) { pos.SetXYZ(fX_in_local, fY_in_local, fZ_in_local); } - void MomentumOut(TVector3 &mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); } + void PositionOutLocal(TVector3& pos) { pos.SetXYZ(fX_out_local, fY_out_local, fZ_out_local); } + void PositionInLocal(TVector3& pos) { pos.SetXYZ(fX_in_local, fY_in_local, fZ_in_local); } + void MomentumOut(TVector3& mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); } // void WireDirection(TVector3& wire) { wire.SetXYZ(fX_wire_dir, fY_wire_dir, fZ_wire_dir); } /** Modifiers **/ @@ -81,15 +82,15 @@ class CbmMustPoint : public FairMCPoint { // void SetWireDirection(TVector3 wire); // tube ID // CHECK added - Int_t GetLayerID () const { return fLayerID; } + Int_t GetLayerID() const { return fLayerID; } Int_t GetModuleID() const { return fModuleID; } - Int_t GetStrawID () const { return fStrawID; } - void SetLayerID (Int_t layerid) { fLayerID = layerid; } - void SetModuleID(Int_t moduleid) { fModuleID = moduleid; } - void SetStrawID (Int_t strawid) { fStrawID = strawid; } + Int_t GetStrawID() const { return fStrawID; } + void SetLayerID(Int_t layerid) { fLayerID = layerid; } + void SetModuleID(Int_t moduleid) { fModuleID = moduleid; } + void SetStrawID(Int_t strawid) { fStrawID = strawid; } /** Output to screen **/ - virtual void Print(const Option_t *opt) const; + virtual void Print(const Option_t* opt) const; protected: // exit coordinates in straw frame diff --git a/core/detectors/must/CMakeLists.txt b/core/detectors/must/CMakeLists.txt index c44dcca3c4..9a533cd763 100644 --- a/core/detectors/must/CMakeLists.txt +++ b/core/detectors/must/CMakeLists.txt @@ -7,7 +7,6 @@ set(SRCS CbmGeoMust.cxx CbmGeoMustPar.cxx CbmMustContFact.cxx - CbmMustSingleStraw.cxx CbmMustGeoScheme.cxx CbmMustStation.cxx CbmMustLayer.cxx diff --git a/core/detectors/must/CbmGeoMust.cxx b/core/detectors/must/CbmGeoMust.cxx index 68f7f74652..a8215fc9d2 100644 --- a/core/detectors/must/CbmGeoMust.cxx +++ b/core/detectors/must/CbmGeoMust.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmGeoMust source file @@ -23,12 +23,12 @@ ClassImp(CbmGeoMust) CbmGeoMust::CbmGeoMust() { // Constructor - fName = "must"; + fName = "must"; maxSectors = 0; maxModules = 40; } -const char *CbmGeoMust::getModuleName(Int_t m) +const char* CbmGeoMust::getModuleName(Int_t m) { // Returns the module name of MUST number m modName = fmt::format("must{:02d}", m + 1); @@ -36,7 +36,7 @@ const char *CbmGeoMust::getModuleName(Int_t m) return modName.c_str(); } -const char *CbmGeoMust::getEleName(Int_t m) +const char* CbmGeoMust::getEleName(Int_t m) { // Returns the element name of MUST number m eleName = fmt::format("must{:02d}", m + 1); diff --git a/core/detectors/must/CbmGeoMust.h b/core/detectors/must/CbmGeoMust.h index 95dadf489f..f18d4ed53f 100644 --- a/core/detectors/must/CbmGeoMust.h +++ b/core/detectors/must/CbmGeoMust.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmGeoMust header file @@ -20,18 +20,18 @@ class CbmGeoMust : public FairGeoSet { protected: - std::string modName; // name of module - std::string eleName; // substring for elements in module + std::string modName; // name of module + std::string eleName; // substring for elements in module public: CbmGeoMust(); ~CbmGeoMust() {} - const char *getModuleName(Int_t); - const char *getEleName(Int_t); - inline Int_t getModNumInMod(const TString &); - ClassDef(CbmGeoMust, 0) // Class for Must + const char* getModuleName(Int_t); + const char* getEleName(Int_t); + inline Int_t getModNumInMod(const TString&); + ClassDef(CbmGeoMust, 0) // Class for Must }; -inline Int_t CbmGeoMust::getModNumInMod(const TString &name) +inline Int_t CbmGeoMust::getModNumInMod(const TString& name) { // returns the module index from module name diff --git a/core/detectors/must/CbmGeoMustPar.cxx b/core/detectors/must/CbmGeoMustPar.cxx index 1d88b58f30..bc48bc12f1 100644 --- a/core/detectors/must/CbmGeoMustPar.cxx +++ b/core/detectors/must/CbmGeoMustPar.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmGeoMustPar source file @@ -16,13 +16,18 @@ // from FairRoot #include <FairParamList.h> // standard -#include <iostream> #include <iomanip> +#include <iostream> ClassImp(CbmGeoMustPar) - CbmGeoMustPar::CbmGeoMustPar(const char *name, const char *title, const char *context) - : FairParGenericSet(name, title, context), fGeoSensNodes(new TObjArray()), fGeoPassNodes(new TObjArray()), fGeoType(-1), fTubeInRad(0), fTubeOutRad(0) + CbmGeoMustPar::CbmGeoMustPar(const char* name, const char* title, const char* context) + : FairParGenericSet(name, title, context) + , fGeoSensNodes(new TObjArray()) + , fGeoPassNodes(new TObjArray()) + , fGeoType(-1) + , fTubeInRad(0) + , fTubeOutRad(0) { } @@ -40,10 +45,9 @@ void CbmGeoMustPar::clear(void) } } -void CbmGeoMustPar::putParams(FairParamList *l) +void CbmGeoMustPar::putParams(FairParamList* l) { - if (!l) - return; + if (!l) return; l->addObject("FairGeoNodes Sensitive List", fGeoSensNodes); l->addObject("FairGeoNodes Passive List", fGeoPassNodes); l->add("Tube Innen Radius", fTubeInRad); @@ -51,20 +55,14 @@ void CbmGeoMustPar::putParams(FairParamList *l) l->add("Geometry Type", fGeoType); } -Bool_t CbmGeoMustPar::getParams(FairParamList *l) +Bool_t CbmGeoMustPar::getParams(FairParamList* l) { - if (!l) - return kFALSE; - if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes)) - return kFALSE; - if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes)) - return kFALSE; - if (!l->fill("Tube Innen Radius", &fTubeInRad)) - return kFALSE; - if (!l->fill("Tube Outer Radius", &fTubeOutRad)) - return kFALSE; - if (!l->fill("Geometry Type", &fGeoType)) - return kFALSE; + if (!l) return kFALSE; + if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes)) return kFALSE; + if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes)) return kFALSE; + if (!l->fill("Tube Innen Radius", &fTubeInRad)) return kFALSE; + if (!l->fill("Tube Outer Radius", &fTubeOutRad)) return kFALSE; + if (!l->fill("Geometry Type", &fGeoType)) return kFALSE; return kTRUE; } diff --git a/core/detectors/must/CbmGeoMustPar.h b/core/detectors/must/CbmGeoMustPar.h index 107b3b3314..ce3058005f 100644 --- a/core/detectors/must/CbmGeoMustPar.h +++ b/core/detectors/must/CbmGeoMustPar.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmGeoMustPar header file @@ -22,30 +22,31 @@ class CbmGeoMustPar : public FairParGenericSet { private: - TObjArray *fGeoSensNodes; /** List of FairGeoNodes for sensitive volumes*/ - TObjArray *fGeoPassNodes; /** List of FairGeoNodes for sensitive volumes*/ - Int_t fGeoType; // modif - Double_t fTubeInRad, fTubeOutRad; // modif + TObjArray* fGeoSensNodes; /** List of FairGeoNodes for sensitive volumes*/ + TObjArray* fGeoPassNodes; /** List of FairGeoNodes for sensitive volumes*/ + Int_t fGeoType; // modif + Double_t fTubeInRad, fTubeOutRad; // modif - CbmGeoMustPar(const CbmGeoMustPar &L); - CbmGeoMustPar &operator=(const CbmGeoMustPar &) { return *this; } + CbmGeoMustPar(const CbmGeoMustPar& L); + CbmGeoMustPar& operator=(const CbmGeoMustPar&) { return *this; } public: - CbmGeoMustPar(const char *name = "CbmGeoMustPar", const char *title = "Must Geometry Parameters", const char *context = "TestDefaultContext"); + CbmGeoMustPar(const char* name = "CbmGeoMustPar", const char* title = "Must Geometry Parameters", + const char* context = "TestDefaultContext"); ~CbmGeoMustPar(void); void clear(void); - void putParams(FairParamList *); - Bool_t getParams(FairParamList *); - TObjArray *GetGeoSensitiveNodes() { return fGeoSensNodes; } - TObjArray *GetGeoPassiveNodes() { return fGeoPassNodes; } + void putParams(FairParamList*); + Bool_t getParams(FairParamList*); + TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } + TObjArray* GetGeoPassiveNodes() { return fGeoPassNodes; } // Additional function void SetGeometryType(Int_t geoType) { fGeoType = geoType; } void SetTubeInRad(Double_t inrad) { fTubeInRad = inrad; } void SetTubeOutRad(Double_t outrad) { fTubeOutRad = outrad; } - Int_t GetGeometryType() { return (Int_t)fGeoType; }; - Double_t GetTubeInRad() { return (Double_t)fTubeInRad; }; - Double_t GetTubeOutRad() { return (Double_t)fTubeOutRad; }; + Int_t GetGeometryType() { return (Int_t) fGeoType; }; + Double_t GetTubeInRad() { return (Double_t) fTubeInRad; }; + Double_t GetTubeOutRad() { return (Double_t) fTubeOutRad; }; ClassDef(CbmGeoMustPar, 1) }; diff --git a/core/detectors/must/CbmMustBaseLinkDef.h b/core/detectors/must/CbmMustBaseLinkDef.h index 8840ace841..d994d020bb 100644 --- a/core/detectors/must/CbmMustBaseLinkDef.h +++ b/core/detectors/must/CbmMustBaseLinkDef.h @@ -11,7 +11,6 @@ #pragma link C++ class CbmGeoMust + ; #pragma link C++ class CbmGeoMustPar + ; #pragma link C++ class CbmMustContFact + ; -#pragma link C++ class CbmMustSingleStraw + ; #pragma link C++ class CbmMustGeoScheme + ; #pragma link C++ class CbmMustStation + ; #pragma link C++ class CbmMustLayer + ; diff --git a/core/detectors/must/CbmMustContFact.cxx b/core/detectors/must/CbmMustContFact.cxx index f4e8483a37..d9631af9c9 100644 --- a/core/detectors/must/CbmMustContFact.cxx +++ b/core/detectors/must/CbmMustContFact.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmMustContFact source file @@ -16,12 +16,12 @@ // from CbnRoot, this library #include "CbmGeoMustPar.h" // from FairRoot -#include <FairRuntimeDb.h> -#include <FairParRootFileIo.h> #include <FairParAsciiFileIo.h> +#include <FairParRootFileIo.h> +#include <FairRuntimeDb.h> // standard -#include <iostream> #include <iomanip> +#include <iostream> ClassImp(CbmMustContFact) @@ -30,7 +30,7 @@ ClassImp(CbmMustContFact) CbmMustContFact::CbmMustContFact() { // Constructor (called when the library is loaded) - fName = "CbmMustContFact"; + fName = "CbmMustContFact"; fTitle = "Factory for parameter containers in libMust"; setAllContainers(); FairRuntimeDb::instance()->addContFactory(this); @@ -40,19 +40,19 @@ void CbmMustContFact::setAllContainers() { /** Creates the Container objects with all accepted contexts and adds them to * the list of containers for the MUST library.*/ - FairContainer *p1 = new FairContainer("CbmGeoMustPar", "Must Geometry Parameters", "TestDefaultContext"); + FairContainer* p1 = new FairContainer("CbmGeoMustPar", "Must Geometry Parameters", "TestDefaultContext"); p1->addContext("TestNonDefaultContext"); containers->Add(p1); } -FairParSet *CbmMustContFact::createContainer(FairContainer *c) +FairParSet* CbmMustContFact::createContainer(FairContainer* c) { /** Calls the constructor of the corresponding parameter container. * For an actual context, which is not an empty string and not the default context * of this container, the name is concatinated with the context. */ - const char *name = c->GetName(); + const char* name = c->GetName(); std::cout << "[MUST] CbmMustContFact createContainer name " << name << std::endl; - FairParSet *p = 0; + FairParSet* p = 0; if (strcmp(name, "CbmGeoMustPar") == 0) { p = new CbmGeoMustPar(c->getConcatName().Data(), c->GetTitle(), c->getContext()); diff --git a/core/detectors/must/CbmMustContFact.h b/core/detectors/must/CbmMustContFact.h index 61e9a5edd6..5b1537422e 100644 --- a/core/detectors/must/CbmMustContFact.h +++ b/core/detectors/must/CbmMustContFact.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmMustContFact header file @@ -27,9 +27,9 @@ class CbmMustContFact : public FairContFact { public: CbmMustContFact(); ~CbmMustContFact() {} - FairParSet *createContainer(FairContainer *); + FairParSet* createContainer(FairContainer*); // void activateParIo(FairParIo* io); - ClassDef(CbmMustContFact, 0) // Factory for all MUST parameter containers + ClassDef(CbmMustContFact, 0) // Factory for all MUST parameter containers }; #endif /* !CBMMUSTCONTFACT_H */ diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx index 6111ccdc74..b9de8c7442 100644 --- a/core/detectors/must/CbmMustGeoScheme.cxx +++ b/core/detectors/must/CbmMustGeoScheme.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustGeoScheme *@author R.Karabowicz <r.karabowicz@gsi.de> *@version 1.0 @@ -11,9 +11,9 @@ **/ #include "CbmMustGeoScheme.h" -#include "CbmMustStation.h" // for CbmMustStation -#include "CbmMustLayer.h" // for CbmMustLayer +#include "CbmMustLayer.h" // for CbmMustLayer #include "CbmMustModule.h" +#include "CbmMustStation.h" // for CbmMustStation #include "CbmMustTube.h" #include <Logger.h> // for LOG @@ -23,9 +23,9 @@ #include <TClonesArray.h> // for TClonesArray #include <TFile.h> // for TFile, gFile #include <TGeoBBox.h> // for TGeoBBox -#include <TGeoTube.h> // for TGeoTube #include <TGeoManager.h> // for TGeoManager, gGeoManager #include <TGeoNode.h> // for TGeoNode +#include <TGeoTube.h> // for TGeoTube #include <TGeoVolume.h> // for TGeoVolume #include <TMath.h> // for Cos, Sqrt #include <TObjArray.h> // for TObjArray @@ -44,11 +44,7 @@ using std::vector; CbmMustGeoScheme* CbmMustGeoScheme::fInstance = nullptr; // ------------------------------------------------------------------------- -CbmMustGeoScheme::CbmMustGeoScheme() - : TObject() -{ - LOG(debug) << "CbmMustGeoScheme created"; -} +CbmMustGeoScheme::CbmMustGeoScheme() : TObject() { LOG(debug) << "CbmMustGeoScheme created"; } // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- @@ -73,7 +69,7 @@ CbmMustGeoScheme* CbmMustGeoScheme::Instance() void CbmMustGeoScheme::Init(TObjArray* stations) { if (!fInitialized) { - fStations = stations; + fStations = stations; fInitialized = kTRUE; } LOG(debug) << "CbmMustGeoScheme init successful"; @@ -88,7 +84,7 @@ void CbmMustGeoScheme::Init(TString parFileName) TFile* oldFile = gFile; TDirectory* oldDir = gDirectory; - TFile* file = new TFile(parFileName); + TFile* file = new TFile(parFileName); LOG_IF(fatal, !file) << "File " << parFileName << " does not exist"; TObjArray* stations = file->Get<TObjArray>("stations"); LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << parFileName; @@ -117,41 +113,40 @@ CbmMustStation* CbmMustGeoScheme::GetStation(int iStation) const CbmMustStation* CbmMustGeoScheme::FindStation(int detid) { - if ( !fStations ) - fStations = new TObjArray(); - for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { - CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj)); - if ( tempStation->GetDetectorId() == detid ) - return tempStation; - } - return nullptr; + if (!fStations) fStations = new TObjArray(); + for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj)); + if (tempStation->GetDetectorId() == detid) return tempStation; + } + return nullptr; } -CbmMustTube* CbmMustGeoScheme::GetTube(int detid) { - int stationid = detid / 1e7 - 1; - CbmMustStation* tempStat = GetStation(stationid); - // LOG(info) << "trying to get tube " << detid % 10000000 << " from station " << stationid; - return tempStat ? tempStat->GetTube(detid % 10000000) : nullptr; +CbmMustTube* CbmMustGeoScheme::GetTube(int detid) +{ + int stationid = detid / 1e7 - 1; + CbmMustStation* tempStat = GetStation(stationid); + // LOG(info) << "trying to get tube " << detid % 10000000 << " from station " << stationid; + return tempStat ? tempStat->GetTube(detid % 10000000) : nullptr; } bool CbmMustGeoScheme::AddStation(CbmMustStation* station) { - for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { - CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj)); - if ( tempStation->GetDetectorId() == station->GetDetectorId() ) - return false; - } - - fStations->Add(station); - return true; + for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj)); + if (tempStation->GetDetectorId() == station->GetDetectorId()) return false; + } + + fStations->Add(station); + return true; } -void CbmMustGeoScheme::Show() { - LOG(info) << "MustGeoScheme:"; - for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { - CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj)); - tempStation->Show(); - } +void CbmMustGeoScheme::Show() +{ + LOG(info) << "MustGeoScheme:"; + for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj)); + tempStation->Show(); + } } // ------------------------------------------------------------------------- @@ -163,9 +158,9 @@ void CbmMustGeoScheme::StoreGeoScheme() TDirectory* oldDir = gDirectory; std::string geoSchemeFileName("must_geoScheme.root"); - TFile* file = new TFile(geoSchemeFileName.c_str(),"recreate"); + TFile* file = new TFile(geoSchemeFileName.c_str(), "recreate"); LOG_IF(fatal, !file) << "File " << geoSchemeFileName << " does not exist"; - file->WriteObject(fStations,"stations"); + file->WriteObject(fStations, "stations"); // fStations->Write(); file->Close(); file->Delete(); @@ -189,7 +184,7 @@ void CbmMustGeoScheme::NavigateTo(const TString& path) gGeoManager->cd(path.Data()); // fGeoPathHash; // fGeoPathHash = path.Hash(); - TGeoVolume* fCurrentVolume = gGeoManager->GetCurrentVolume(); + TGeoVolume* fCurrentVolume = gGeoManager->GetCurrentVolume(); // TGeoBBox* fVolumeBoxShape = (TGeoBBox*) fCurrentVolume->GetShape(); Double_t local[3] = {0., 0., 0.}; gGeoManager->LocalToMaster(local, fGlobal); diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h index 4c92c9cdc2..896174698b 100644 --- a/core/detectors/must/CbmMustGeoScheme.h +++ b/core/detectors/must/CbmMustGeoScheme.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustGeoScheme header file ----- @@ -46,50 +46,50 @@ class TGeoVolume; class CbmMustGeoScheme : public TObject { -public: - /** Destructor. */ - ~CbmMustGeoScheme(); - //void Init(Bool_t isSimulation = kFALSE); - static CbmMustGeoScheme* Instance(); - /** Gets whether the geometry scheme is initialized. */ - Bool_t IsInitialized() { return fInitialized; } + public: + /** Destructor. */ + ~CbmMustGeoScheme(); + //void Init(Bool_t isSimulation = kFALSE); + static CbmMustGeoScheme* Instance(); + /** Gets whether the geometry scheme is initialized. */ + Bool_t IsInitialized() { return fInitialized; } - // Get geometry objects by indices - TObjArray* GetStations() const {return fStations;}; - CbmMustStation* GetStation(int iStation) const; - CbmMustLayer* GetLayer(int iStation, int iLayer) const; + // Get geometry objects by indices + TObjArray* GetStations() const { return fStations; }; + CbmMustStation* GetStation(int iStation) const; + CbmMustLayer* GetLayer(int iStation, int iLayer) const; - int GetNStations() const { return fStations->GetEntriesFast(); } + int GetNStations() const { return fStations->GetEntriesFast(); } - CbmMustTube* GetTube(int detid); + CbmMustTube* GetTube(int detid); - CbmMustStation* FindStation(int detid); - bool AddStation(CbmMustStation* station); - void Show(); - void StoreGeoScheme(); + CbmMustStation* FindStation(int detid); + bool AddStation(CbmMustStation* station); + void Show(); + void StoreGeoScheme(); - void Init(TObjArray* stations); - void Init(TString parFileName); + void Init(TObjArray* stations); + void Init(TString parFileName); - void NavigateTo(const TString& path); - // void NavigateToBBox(const TString& path); - // void NavigateToTube(const TString& path); + void NavigateTo(const TString& path); + // void NavigateToBBox(const TString& path); + // void NavigateToTube(const TString& path); - TVector3 GetGlobal() { return TVector3(fGlobal); } - -private: - static CbmMustGeoScheme* fInstance; + TVector3 GetGlobal() { return TVector3(fGlobal); } - CbmMustGeoScheme(); + private: + static CbmMustGeoScheme* fInstance; - bool fInitialized {false}; - TObjArray* fStations {nullptr}; //! - double fGlobal[3] {0.,0.,0.}; - - CbmMustGeoScheme(const CbmMustGeoScheme&); - CbmMustGeoScheme& operator=(const CbmMustGeoScheme&); + CbmMustGeoScheme(); - ClassDef(CbmMustGeoScheme, 1); + bool fInitialized{false}; + TObjArray* fStations{nullptr}; //! + double fGlobal[3]{0., 0., 0.}; + + CbmMustGeoScheme(const CbmMustGeoScheme&); + CbmMustGeoScheme& operator=(const CbmMustGeoScheme&); + + ClassDef(CbmMustGeoScheme, 1); }; #endif diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx index 612a5e31ec..1422079cbb 100644 --- a/core/detectors/must/CbmMustLayer.cxx +++ b/core/detectors/must/CbmMustLayer.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustLayer.cxx *@author R.Karabowicz <r.karabowicz@gsi.de> @@ -21,10 +21,7 @@ #include <TVector3.h> // for TVector3 // ----- Default constructor ------------------------------------------- -CbmMustLayer::CbmMustLayer() - : TObject() -{ -} +CbmMustLayer::CbmMustLayer() : TObject() {} // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ @@ -40,7 +37,7 @@ CbmMustLayer::CbmMustLayer(int detId, double z, double zRel) // ----- Standard constructor ------------------------------------------ CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel) : TObject() - , fDetectorId(iStation*1e7+iLayer*1e5) + , fDetectorId(iStation * 1e7 + iLayer * 1e5) , fZ(z) , fZtoStationCenter(zRel) @@ -52,40 +49,41 @@ CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel) CbmMustLayer::~CbmMustLayer() {} // ------------------------------------------------------------------------- -CbmMustTube* CbmMustLayer::GetTube(int detid) { - int moduleid = detid / 1e3 -1; - CbmMustModule* tempModule = GetModule(moduleid); - // LOG(info) << "trying to get tube " << detid % 1000 << " from module " << moduleid; - return tempModule ? tempModule->GetTube(detid % 1000 - 1) : nullptr; +CbmMustTube* CbmMustLayer::GetTube(int detid) +{ + int moduleid = detid / 1e3 - 1; + CbmMustModule* tempModule = GetModule(moduleid); + // LOG(info) << "trying to get tube " << detid % 1000 << " from module " << moduleid; + return tempModule ? tempModule->GetTube(detid % 1000 - 1) : nullptr; } CbmMustModule* CbmMustLayer::FindModule(int detid) { - for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { - CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj)); - if ( tempModule->GetDetectorId() == detid ) - return tempModule; - } - return nullptr; + for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { + CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj)); + if (tempModule->GetDetectorId() == detid) return tempModule; + } + return nullptr; } -bool CbmMustLayer::AddModule(CbmMustModule* module) { - for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { - CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj)); - if ( tempModule->GetDetectorId() == module->GetDetectorId() ) - return false; - } - - fModules.Add(module); - return true; +bool CbmMustLayer::AddModule(CbmMustModule* module) +{ + for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { + CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj)); + if (tempModule->GetDetectorId() == module->GetDetectorId()) return false; + } + + fModules.Add(module); + return true; } -void CbmMustLayer::Show() { - LOG(info) << " Layer " << fDetectorId << " (@ z = " << fZ << "):"; - for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { - CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj)); - tempModule->Show(); - } +void CbmMustLayer::Show() +{ + LOG(info) << " Layer " << fDetectorId << " (@ z = " << fZ << "):"; + for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) { + CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj)); + tempModule->Show(); + } } ClassImp(CbmMustLayer) diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h index e8afd0799a..1c60c30e64 100644 --- a/core/detectors/must/CbmMustLayer.h +++ b/core/detectors/must/CbmMustLayer.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustLayer.h *@author R.Karabowicz <r.karabowicz@gsi.de> @@ -17,58 +17,59 @@ #ifndef CBMMUSTLAYER_H #define CBMMUSTLAYER_H 1 +#include "CbmMustModule.h" +#include "CbmMustTube.h" + #include <Rtypes.h> // for THashConsistencyHolder, ClassDef #include <RtypesCore.h> // for Double_t, Int_t, Bool_t, Double32_t -#include <TObject.h> // for TObject #include <TObjArray.h> // for TObjArray -#include "CbmMustModule.h" -#include "CbmMustTube.h" +#include <TObject.h> // for TObject class CbmMustLayer : public TObject { -public: - /** Default constructor **/ - CbmMustLayer(); + public: + /** Default constructor **/ + CbmMustLayer(); - /** Standard constructor + /** Standard constructor *@param detId Detector ID *@param z z position of layer center [cm] *@param zRel z position of layer center relative to station center [cm] **/ - CbmMustLayer(int detId, double z, double zRel); + CbmMustLayer(int detId, double z, double zRel); - /** Standard constructor + /** Standard constructor *@param iStation Station index *@param iLayer Layer index *@param z z position of layer center [cm] *@param zRel z position of layer center relative to station center [cm] **/ - CbmMustLayer(int iStation, int iLayer, double z, double zRel); + CbmMustLayer(int iStation, int iLayer, double z, double zRel); - /** Destructor **/ - virtual ~CbmMustLayer(); + /** Destructor **/ + virtual ~CbmMustLayer(); - /** Accessors **/ - int GetDetectorId() const { return fDetectorId; } - double GetZ() const { return fZ; } - double GetZtoStationCenter() const { return fZtoStationCenter; } + /** Accessors **/ + int GetDetectorId() const { return fDetectorId; } + double GetZ() const { return fZ; } + double GetZtoStationCenter() const { return fZtoStationCenter; } - int GetNModules() const { return fModules.GetEntriesFast(); } + int GetNModules() const { return fModules.GetEntriesFast(); } - CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); } + CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); } - CbmMustTube* GetTube(int detid); + CbmMustTube* GetTube(int detid); - CbmMustModule* FindModule(int detid); - bool AddModule(CbmMustModule* module); - void Show(); + CbmMustModule* FindModule(int detid); + bool AddModule(CbmMustModule* module); + void Show(); -protected: - int fDetectorId {0}; // Unique detector ID - double fZ {0.}; - double fZtoStationCenter {0.}; // Relative position of the layer center with respect - // to the station center - TObjArray fModules; // Array of CbmMustModules + protected: + int fDetectorId{0}; // Unique detector ID + double fZ{0.}; + double fZtoStationCenter{0.}; // Relative position of the layer center with respect + // to the station center + TObjArray fModules; // Array of CbmMustModules ClassDef(CbmMustLayer, 1); }; diff --git a/core/detectors/must/CbmMustMapCreator.cxx b/core/detectors/must/CbmMustMapCreator.cxx index a94e1dd800..e538e6dfbb 100644 --- a/core/detectors/must/CbmMustMapCreator.cxx +++ b/core/detectors/must/CbmMustMapCreator.cxx @@ -14,57 +14,67 @@ // from CbmRoot, this library #include "CbmMustMapCreator.h" -#include "CbmMustTube.h" + #include "CbmGeoMustPar.h" +#include "CbmMustTube.h" // from FairRoot #include <FairGeoNode.h> -#include <FairGeoVolume.h> -#include <FairGeoTransform.h> -#include <FairGeoVector.h> #include <FairGeoRotation.h> +#include <FairGeoTransform.h> #include <FairGeoTube.h> +#include <FairGeoVector.h> +#include <FairGeoVolume.h> // from ROOT +#include <FairRootManager.h> + +#include <TClonesArray.h> #include <TGeoTube.h> -#include <TVector3.h> +#include <TGeoVolume.h> #include <TObjArray.h> #include <TString.h> -#include <TGeoVolume.h> -#include <TGeoTube.h> -#include <TClonesArray.h> -#include <FairRootManager.h> +#include <TVector3.h> // standard -#include <iostream> #include <fstream> +#include <iostream> using namespace std; -CbmMustMapCreator::CbmMustMapCreator() : fGeoType(0), fTubeInRad(0), fTubeOutRad(0), fMustParameters(new CbmGeoMustPar()) {} +CbmMustMapCreator::CbmMustMapCreator() + : fGeoType(0) + , fTubeInRad(0) + , fTubeOutRad(0) + , fMustParameters(new CbmGeoMustPar()) +{ +} // CbmMustMapCreator::CbmMustMapCreator(){} // to use in CbmMust -CbmMustMapCreator::CbmMustMapCreator(Int_t geoType) : fGeoType(geoType), fTubeInRad(0), fTubeOutRad(0), fMustParameters(new CbmGeoMustPar("CbmGeoMustPar", "MUST Geometry Parameters")) +CbmMustMapCreator::CbmMustMapCreator(Int_t geoType) + : fGeoType(geoType) + , fTubeInRad(0) + , fTubeOutRad(0) + , fMustParameters(new CbmGeoMustPar("CbmGeoMustPar", "MUST Geometry Parameters")) { - if (fGeoType != 1) - LOG(fatal) << "[MUST] CbmMustMapCreator. Geometry " << fGeoType << " not supported by map"; + if (fGeoType != 1) LOG(fatal) << "[MUST] CbmMustMapCreator. Geometry " << fGeoType << " not supported by map"; // cout << "Creating mapper with geotype = " << fGeoType << endl; // cout << "fMustParameters name is " << fMustParameters->GetName() << endl; } -CbmMustMapCreator::CbmMustMapCreator(CbmGeoMustPar *mustPar) : fMustParameters(mustPar) +CbmMustMapCreator::CbmMustMapCreator(CbmGeoMustPar* mustPar) : fMustParameters(mustPar) { - fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius - fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius + fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius + fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius // choose geometry type - fGeoType = mustPar->GetGeometryType(); // classic, optimized, average, detailed, CAD + fGeoType = mustPar->GetGeometryType(); // classic, optimized, average, detailed, CAD // cout << "Creating map with geoType = " << fGeoType << ", radius = " << fTubeInRad << " / " << fTubeOutRad << endl; } CbmMustMapCreator::~CbmMustMapCreator() {} void CbmMustMapCreator::SetGeneralParameters() -{ // CHECK whether it depends on geometry or not - fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius - fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius +{ // CHECK whether it depends on geometry or not + fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius + fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius } Int_t CbmMustMapCreator::GetTubeIDFromPath(TString path) @@ -88,7 +98,8 @@ Int_t CbmMustMapCreator::GetTubeIDFromName(TString name) if (tmpstring.Contains("#")) { int start = tmpstring.Index("#") + 1; tmpstring = tmpstring(start, tmpstring.Sizeof()); - } else { + } + else { int start = tmpstring.Index("e") + 1; tmpstring = tmpstring(start, tmpstring.Sizeof()); } @@ -109,11 +120,10 @@ TString CbmMustMapCreator::GetNameFromPath(TString path) return tmpstring; } -int CbmMustMapCreator::GetTypeNumTube(TString path, int &module_type, int &module_number, int &tube_in_module) +int CbmMustMapCreator::GetTypeNumTube(TString path, int& module_type, int& module_number, int& tube_in_module) { - if (path.Contains("cave") && path.Contains("assembly")) - path.Replace(0, 34, ""); + if (path.Contains("cave") && path.Contains("assembly")) path.Replace(0, 34, ""); path.Replace(0, path.First("M") - 1, ""); module_type = path.Atoi(); path.Replace(0, path.First("M") + 1, ""); @@ -190,7 +200,8 @@ Int_t CbmMustMapCreator::GetLayerID(Int_t chamberid, TString path) else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 9 < module_number && module_number <= 12) layerid = 8; } - } else if (chamberid % 2 == 0) { + } + else if (chamberid % 2 == 0) { if (module_type == 1) { if (tube_in_module <= 64 && module_number <= 7) layerid = 1; @@ -255,27 +266,31 @@ Int_t CbmMustMapCreator::IsSkew(Int_t layerid) { Int_t skew = 0; // inclination of +5deg: skew=+1 - if (layerid == 3 || layerid == 4 || layerid == 11 || layerid == 12 || layerid == 19 || layerid == 20 || layerid == 27 || layerid == 28 || layerid == 35 || layerid == 36 || - layerid == 43 || layerid == 44) { + if (layerid == 3 || layerid == 4 || layerid == 11 || layerid == 12 || layerid == 19 || layerid == 20 || layerid == 27 + || layerid == 28 || layerid == 35 || layerid == 36 || layerid == 43 || layerid == 44) { skew = 1; } // inclination of -5deg: skew=-1 - if (layerid == 5 || layerid == 6 || layerid == 13 || layerid == 14 || layerid == 21 || layerid == 22 || layerid == 29 || layerid == 30 || layerid == 37 || layerid == 38 || - layerid == 45 || layerid == 46) { + if (layerid == 5 || layerid == 6 || layerid == 13 || layerid == 14 || layerid == 21 || layerid == 22 || layerid == 29 + || layerid == 30 || layerid == 37 || layerid == 38 || layerid == 45 || layerid == 46) { skew = -1; } return skew; } -Int_t CbmMustMapCreator::GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, Int_t tube_in_module, Int_t strawCh12) +Int_t CbmMustMapCreator::GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, + Int_t tube_in_module, Int_t strawCh12) { - int tubeidtot = 0; + int tubeidtot = 0; int modStraws[3] = {64, 64, 32}; if (chamberid % 2 == 1) { - tubeidtot = tube_in_module + fModShiftMUST1[module_type - 1][module_number - 1] + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); - } else if (chamberid % 2 == 0) { - tubeidtot = tube_in_module + fModShiftMUST2[module_type - 1][module_number - 1] + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); + tubeidtot = tube_in_module + fModShiftMUST1[module_type - 1][module_number - 1] + + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); + } + else if (chamberid % 2 == 0) { + tubeidtot = tube_in_module + fModShiftMUST2[module_type - 1][module_number - 1] + + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); } return tubeidtot; } @@ -284,9 +299,9 @@ Int_t CbmMustMapCreator::GetTubeIDTot(Int_t chamberid, Int_t layerid, TString pa { TString tmpstring = path; - Int_t tube = 0; - Int_t totTubeID = 0; - Int_t strawCh12 = 672; + Int_t tube = 0; + Int_t totTubeID = 0; + Int_t strawCh12 = 672; int module_type{0}; int module_number{0}; int tube_in_module{0}; @@ -306,15 +321,15 @@ Int_t CbmMustMapCreator::GetTubeIDTot(Int_t chamberid, Int_t layerid, TString pa /// this function will be used in CbmMustHitProducesRealFast //////////////////////////////////////////////////////////// -CbmMustTube *CbmMustMapCreator::GetTubeFromNameToFill(TString tubename, Int_t, Int_t) -{ // tubeid layerid //[R.K.03/2017] unused variable(s) +CbmMustTube* CbmMustMapCreator::GetTubeFromNameToFill(TString tubename, Int_t, Int_t) +{ // tubeid layerid //[R.K.03/2017] unused variable(s) - TObjArray *geoPassNodes = fMustParameters->GetGeoPassiveNodes(); + TObjArray* geoPassNodes = fMustParameters->GetGeoPassiveNodes(); // Bool_t isCopy = kTRUE; //[R.K. 01/2017] unused variable // try as if it was a copy stt01tube#XXX - FairGeoNode *pnode = (FairGeoNode *)geoPassNodes->FindObject(tubename); - if (!pnode) { // try as if it was a solo stt01tubeXXX + FairGeoNode* pnode = (FairGeoNode*) geoPassNodes->FindObject(tubename); + if (!pnode) { // try as if it was a solo stt01tubeXXX // isCopy = kFALSE; //[R.K. 01/2017] unused variable // tubename = GetNameFromTubeID(tubeid, isCopy); // pnode = (FairGeoNode*) geoPassNodes->FindObject(tubename); @@ -325,14 +340,14 @@ CbmMustTube *CbmMustMapCreator::GetTubeFromNameToFill(TString tubename, Int_t, I return nullptr; } - FairGeoTransform *lab = pnode->getLabTransform(); - FairGeoVector tra = lab->getTransVector(); - FairGeoRotation rot = lab->getRotMatrix(); + FairGeoTransform* lab = pnode->getLabTransform(); + FairGeoVector tra = lab->getTransVector(); + FairGeoRotation rot = lab->getRotMatrix(); // geometrical info - double x = tra.getX() / 10.; // in cm - double y = tra.getY() / 10.; // in cm - double z = tra.getZ() / 10.; // in cm + double x = tra.getX() / 10.; // in cm + double y = tra.getY() / 10.; // in cm + double z = tra.getZ() / 10.; // in cm // std::cout<<"tubename="<<tubename<<" tubeid="<<tubeid<<" x="<<x<<" z="<<z<<std::endl; // Int_t skew=IsSkew(layerid); //[R.K. 01/2017] unused variable? @@ -345,26 +360,27 @@ CbmMustTube *CbmMustMapCreator::GetTubeFromNameToFill(TString tubename, Int_t, I for (int j = 0; j < 3; j++) r[i][j] = rot.getElement(i, j); - TGeoVolume *rootvol = pnode->getRootVolume(); - TGeoTube *tube = (TGeoTube *)rootvol->GetShape(); - Double_t halflength = tube->GetDz(); // in cm + TGeoVolume* rootvol = pnode->getRootVolume(); + TGeoTube* tube = (TGeoTube*) rootvol->GetShape(); + Double_t halflength = tube->GetDz(); // in cm // sets up the correspondence int (tubeID) <--> int (1 = copy/0 = solo) // copy_map[key] = alloc // fCopy_Map[tubeid] = isCopy; - return new CbmMustTube((float)x, (float)y, (float)z, r[0][0], r[0][1], r[0][2], r[1][0], r[1][1], r[1][2], r[2][0], r[2][1], r[2][2], fTubeInRad, fTubeOutRad, halflength); + return new CbmMustTube((float) x, (float) y, (float) z, r[0][0], r[0][1], r[0][2], r[1][0], r[1][1], r[1][2], r[2][0], + r[2][1], r[2][2], fTubeInRad, fTubeOutRad, halflength); } -TClonesArray *CbmMustMapCreator::FillTubeArray() +TClonesArray* CbmMustMapCreator::FillTubeArray() { // ofstream myfile("testNumber.txt"); - TObjArray *geoPassNodes = fMustParameters->GetGeoPassiveNodes(); - TClonesArray *tubeArray = new TClonesArray("CbmMustTube"); + TObjArray* geoPassNodes = fMustParameters->GetGeoPassiveNodes(); + TClonesArray* tubeArray = new TClonesArray("CbmMustTube"); // tubeArray->Delete(); // int mytest=0; //[R.K. 01/2017] unused variable? // cout << "TA: entries: " << geoPassNodes->GetEntriesFast() << endl; for (int i = 0; i < geoPassNodes->GetEntriesFast(); i++) { - FairGeoNode *pnode = (FairGeoNode *)geoPassNodes->At(i); + FairGeoNode* pnode = (FairGeoNode*) geoPassNodes->At(i); if (!pnode) { cout << "CbmMustMapCreator::FillTubeArray : tubename=" << pnode->GetName() << " not existing!!!" << endl; continue; @@ -379,15 +395,15 @@ TClonesArray *CbmMustMapCreator::FillTubeArray() tubename.ReplaceAll("#", "_"); Int_t tempChamber = GetChamberIDFromName(tubename); - Int_t tempLayer = GetLayerID(tempChamber, tubename); - Int_t totTubeID = GetTubeIDTot(tempChamber, tempLayer, tubename); + Int_t tempLayer = GetLayerID(tempChamber, tubename); + Int_t totTubeID = GetTubeIDTot(tempChamber, tempLayer, tubename); // cout<<"CbmMustMapCreator::FillTubeArray : totTubeID="<<totTubeID<< endl; tubename = pnode->GetName(); // cout << "TUBE " << tempChamber << " / " << tubeID << " / " << tempLayer << " / " << totTubeID << endl; - CbmMustTube *musttube = GetTubeFromNameToFill(tubename, totTubeID, tempLayer); + CbmMustTube* musttube = GetTubeFromNameToFill(tubename, totTubeID, tempLayer); new ((*tubeArray)[totTubeID]) CbmMustTube(*musttube); delete (musttube); diff --git a/core/detectors/must/CbmMustMapCreator.h b/core/detectors/must/CbmMustMapCreator.h index d87f704bcd..33b0addf3d 100644 --- a/core/detectors/must/CbmMustMapCreator.h +++ b/core/detectors/must/CbmMustMapCreator.h @@ -31,7 +31,7 @@ class CbmMustMapCreator : public TObject { public: CbmMustMapCreator(); CbmMustMapCreator(Int_t geoType); - CbmMustMapCreator(CbmGeoMustPar *par); + CbmMustMapCreator(CbmGeoMustPar* par); ~CbmMustMapCreator(); // general functions @@ -39,38 +39,41 @@ class CbmMustMapCreator : public TObject { // general functions, to be specified depending on geo type Int_t GetTubeIDFromPath(TString path); - CbmMustTube *GetTubeFromTubeID(Int_t tubeid); - TClonesArray *FillTubeArray(); + CbmMustTube* GetTubeFromTubeID(Int_t tubeid); + TClonesArray* FillTubeArray(); Int_t GetChamberIDFromPath(TString path); Int_t GetChamberIDFromName(TString name); Int_t GetLayerID(Int_t chamberid, TString path); Int_t IsSkew(Int_t layerid); Int_t GetTubeIDTot(Int_t chamberid, Int_t layerid, TString path); - Int_t GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, Int_t tube_in_module, Int_t strawCh12); + Int_t GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, Int_t tube_in_module, + Int_t strawCh12); private: Int_t GetTubeIDFromName(TString name); TString GetNameFromPath(TString path); TString GetNameFromTubeID(Int_t tubeid, Bool_t isCopy); - CbmMustTube *GetTubeFromNameToFill(TString tubename, Int_t tubeid, Int_t layerid); - int GetTypeNumTube(TString path, int &module_type, int &module_number, int &tube_in_module); + CbmMustTube* GetTubeFromNameToFill(TString tubename, Int_t tubeid, Int_t layerid); + int GetTypeNumTube(TString path, int& module_type, int& module_number, int& tube_in_module); Int_t fGeoType{0}; Double_t fTubeInRad{0.}, fTubeOutRad{0.}; - CbmGeoMustPar *fMustParameters{nullptr}; - int fModShiftMUST1[3][20] = {{192, 256, 320, 384, 448, 1536, 1600, 1664, 1728, 1792, 2880, 2944, 3008, 3072, 3136, 4224, 4288, 4352, 4416, 4480}, - {64, 128, 512, 576, 1408, 1472, 1856, 1920, 2752, 2816, 3200, 3264, 4096, 4160, 4544, 4608, 0, 0, 0, 0}, - {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0}}; + CbmGeoMustPar* fMustParameters{nullptr}; + int fModShiftMUST1[3][20] = { + {192, 256, 320, 384, 448, 1536, 1600, 1664, 1728, 1792, 2880, 2944, 3008, 3072, 3136, 4224, 4288, 4352, 4416, 4480}, + {64, 128, 512, 576, 1408, 1472, 1856, 1920, 2752, 2816, 3200, 3264, 4096, 4160, 4544, 4608, 0, 0, 0, 0}, + {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0}}; int fModShiftMUST2[3][28] = { - {128, 192, 256, 320, 384, 448, 512, 1472, 1536, 1600, 1664, 1728, 1792, 1856, 2816, 2880, 2944, 3008, 3072, 3136, 3200, 4160, 4224, 4288, 4352, 4416, 4480, 4544}, + {128, 192, 256, 320, 384, 448, 512, 1472, 1536, 1600, 1664, 1728, 1792, 1856, + 2816, 2880, 2944, 3008, 3072, 3136, 3200, 4160, 4224, 4288, 4352, 4416, 4480, 4544}, {64, 576, 1408, 1920, 2752, 3264, 4096, 4608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; // fGeoType1 // std::map<int, int> fCopy_Map; - CbmMustMapCreator(const CbmMustMapCreator &L); - CbmMustMapCreator &operator=(const CbmMustMapCreator &) { return *this; } + CbmMustMapCreator(const CbmMustMapCreator& L); + CbmMustMapCreator& operator=(const CbmMustMapCreator&) { return *this; } protected: ClassDef(CbmMustMapCreator, 1) diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx index 3e958454b8..26502ec98d 100644 --- a/core/detectors/must/CbmMustModule.cxx +++ b/core/detectors/must/CbmMustModule.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustModule.cxx *@author R.Karabowicz <r.karabowicz@gsi.de> @@ -15,24 +15,18 @@ #include <Logger.h> // for LOG -#include <TObject.h> // for TObject +#include <TObject.h> // for TObject #include <TVector3.h> // for TVector3 // ----- Default constructor ------------------------------------------- -CbmMustModule::CbmMustModule() - : TObject() - , fDetectorId(0) - , fPosition(TVector3()) - , fDirection(TVector3()) -{ -} +CbmMustModule::CbmMustModule() : TObject(), fDetectorId(0), fPosition(TVector3()), fDirection(TVector3()) {} // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction) : TObject() - , fDetectorId(iStation*1e7+iLayer*1e5+iModule*1e3) + , fDetectorId(iStation * 1e7 + iLayer * 1e5 + iModule * 1e3) , fPosition(position) , fDirection(direction) { @@ -41,42 +35,44 @@ CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 pos CbmMustTube* CbmMustModule::FindTube(int detid) { - for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { - CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); - if ( tempTube->GetTubeNumber() == detid ) - return tempTube; - } - return nullptr; + for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { + CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj)); + if (tempTube->GetTubeNumber() == detid) return tempTube; + } + return nullptr; } -bool CbmMustModule::AddTube(CbmMustTube* tube) { - for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { - CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); - if ( tempTube->GetTubeNumber() == tube->GetTubeNumber() ) - return false; - } - fTubes.Add(tube); - return true; +bool CbmMustModule::AddTube(CbmMustTube* tube) +{ + for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { + CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj)); + if (tempTube->GetTubeNumber() == tube->GetTubeNumber()) return false; + } + fTubes.Add(tube); + return true; } -void CbmMustModule::Show() { - LOG(info) << " Module " << fDetectorId << " (@ (" << fPosition.X() << "," << fPosition.Y() << "," << fPosition.Z() << ") -> (" << fDirection.X() << "," << fDirection.Y() << "," << fDirection.Z() << "):"; - std::string tubeString(128, '.'); - std::string tubeNumbDec(128, '0'); - std::string tubeNumbOne(128, '0'); - for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { - CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj)); - // if ( iobj == 0 ) - LOG(info) << " Tube " << tempTube->GetDetectorId() - << " @ " << tempTube->GetPosition().X() << "," << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z() - << " -> " << tempTube->GetWireDirection().X() << "," << tempTube->GetWireDirection().Y() << "," << tempTube->GetWireDirection().Z(); - tubeNumbDec[iobj] = char(tempTube->GetTubeNumber()/10+48); - tubeNumbOne[iobj] = char(tempTube->GetTubeNumber()%10+48); - tubeString[tempTube->GetTubeNumber()-1] = '*'; - } - LOG(info) << " Tubes " << tubeString; - LOG(info) << " - " << tubeNumbDec; - LOG(info) << " - " << tubeNumbOne; +void CbmMustModule::Show() +{ + LOG(info) << " Module " << fDetectorId << " (@ (" << fPosition.X() << "," << fPosition.Y() << "," + << fPosition.Z() << ") -> (" << fDirection.X() << "," << fDirection.Y() << "," << fDirection.Z() << "):"; + std::string tubeString(128, '.'); + std::string tubeNumbDec(128, '0'); + std::string tubeNumbOne(128, '0'); + for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) { + CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj)); + // if ( iobj == 0 ) + LOG(info) << " Tube " << tempTube->GetDetectorId() << " @ " << tempTube->GetPosition().X() << "," + << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z() << " -> " + << tempTube->GetWireDirection().X() << "," << tempTube->GetWireDirection().Y() << "," + << tempTube->GetWireDirection().Z(); + tubeNumbDec[iobj] = char(tempTube->GetTubeNumber() / 10 + 48); + tubeNumbOne[iobj] = char(tempTube->GetTubeNumber() % 10 + 48); + tubeString[tempTube->GetTubeNumber() - 1] = '*'; + } + LOG(info) << " Tubes " << tubeString; + LOG(info) << " - " << tubeNumbDec; + LOG(info) << " - " << tubeNumbOne; } ClassImp(CbmMustModule) diff --git a/core/detectors/must/CbmMustModule.h b/core/detectors/must/CbmMustModule.h index 777996e869..65f96123cc 100644 --- a/core/detectors/must/CbmMustModule.h +++ b/core/detectors/must/CbmMustModule.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustModule.h *@author R.Karabowicz <r.karabowicz@gsi.de> @@ -15,55 +15,56 @@ #ifndef CBMMUSTMODULE_H #define CBMMUSTMODULE_H 1 +#include "CbmMustTube.h" + #include <Rtypes.h> // for THashConsistencyHolder, ClassDef #include <RtypesCore.h> // for Color_t #include <TObjArray.h> // for TObjArray -#include <TObject.h> // for TObject +#include <TObject.h> // for TObject #include <TVector3.h> // for TVector3 -#include "CbmMustTube.h" #include <map> // for multimap #include <utility> // for pair class CbmMustModule : public TObject { -public: - /** Default constructor **/ - CbmMustModule(); - /** Standard constructor + public: + /** Default constructor **/ + CbmMustModule(); + /** Standard constructor *@param iStation Station index *@param iLayer Layer index *@param iModule Module index *@param position Location of the module center in global c.s. (all dimensions in [cm]) *@param direction Direction of the module **/ - CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction); - /** Destructor **/ - virtual ~CbmMustModule() {} + CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction); + /** Destructor **/ + virtual ~CbmMustModule() {} - /** Accessors */ - int GetDetectorId() const { return fDetectorId; } - TVector3 GetPosition() const { return fPosition; } - TVector3 GetDirection() const { return fDirection; } + /** Accessors */ + int GetDetectorId() const { return fDetectorId; } + TVector3 GetPosition() const { return fPosition; } + TVector3 GetDirection() const { return fDirection; } - int GetNTubes() const { return fTubes.GetEntriesFast(); } + int GetNTubes() const { return fTubes.GetEntriesFast(); } - CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); } + CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); } - CbmMustTube* FindTube(int detid); - bool AddTube(CbmMustTube* tube); - void SortTubes() { fTubes.Sort(); } - void Show(); + CbmMustTube* FindTube(int detid); + bool AddTube(CbmMustTube* tube); + void SortTubes() { fTubes.Sort(); } + void Show(); - virtual bool InitModule() { return kTRUE; } - virtual void DrawModule(Color_t) {} + virtual bool InitModule() { return kTRUE; } + virtual void DrawModule(Color_t) {} -protected: - int fDetectorId; // Unique detector ID - TVector3 fPosition; // Location vector of the module center in global c.s. (all dimensions in [cm]) - TVector3 fDirection; // Direction vector of the module - TObjArray fTubes; // Array of CbmMustTubes + protected: + int fDetectorId; // Unique detector ID + TVector3 fPosition; // Location vector of the module center in global c.s. (all dimensions in [cm]) + TVector3 fDirection; // Direction vector of the module + TObjArray fTubes; // Array of CbmMustTubes -private: + private: CbmMustModule(const CbmMustModule&); CbmMustModule& operator=(const CbmMustModule&); diff --git a/core/detectors/must/CbmMustSingleStraw.cxx b/core/detectors/must/CbmMustSingleStraw.cxx index 6f17848e7b..d1ccd9a173 100644 --- a/core/detectors/must/CbmMustSingleStraw.cxx +++ b/core/detectors/must/CbmMustSingleStraw.cxx @@ -115,13 +115,114 @@ ClassImp(CbmMustSingleStraw); // ============================================================ CbmMustSingleStraw::CbmMustSingleStraw() - : CDist(), CDistC(), CNele(), CNeleT(), TeleTime(), AmplSig(), Pulse(), PulseT(), WDist(), Wi(0), ArPerc(0), CO2Perc(0), CH4Perc(0), ArWPerc(0), CO2WPerc(0), CH4WPerc(0), - pSTP(0), Radius(0), AAr(0), ZAr(0), RhoAr(0), NclAr(0), EmedAr(0), EminAr(0), EmpAr(0), CsiAr(0), IAr(0), WiAr(0), Ncl(0), Ecl(0), Lcl(0), Ntote(0), GasGain(0), Cutoff(0), - EmedCO2(0), EminCO2(0), EmpCO2(0), CsiCO2(0), ACO2(0), ZCO2(0), RhoCO2(0), ICO2(0), WiCO2(0), NclCO2(0), EmedCH4(0), EmpCH4(0), CsiCH4(0), EminCH4(0), ACH4(0), ZCH4(0), - RhoCH4(0), ICH4(0), WiCH4(0), NclCH4(0), RhoMixCO2(0), RhoMixCH4(0), PZeta(0), piMass(0), PMass(0), PMom(0), Dx(0), eMass(0), prMass(0), Delta(0), CNumb(0), PEn(0), beta(0), - gamma(0), Emed(0), Emin(0), Csi(0), Emax(0), Emp(0), NNClus(0), Xin(0), Yin(0), Zin(0), Xout(0), Yout(0), Zout(0), Rpath(0), NPolya(0), Xmax(0), bPolya(0), Calpha(0), Cbeta(0), - Cgamma(0), NUrban(0), SigUrb(0), Eup(0), AvUrb(0), Wx1(0), Wy1(0), Wz1(0), Wx2(0), Wy2(0), Wz2(0), Wp(0), Wq(0), Wr(0), PulseMax(0), PulseTime(0), Thresh1(0), Thresh2(0), - Nchann(0), Out1(0), Out2(0), Out3(0) + : CDist() + , CDistC() + , CNele() + , CNeleT() + , TeleTime() + , AmplSig() + , Pulse() + , PulseT() + , WDist() + , Wi(0) + , ArPerc(0) + , CO2Perc(0) + , CH4Perc(0) + , ArWPerc(0) + , CO2WPerc(0) + , CH4WPerc(0) + , pSTP(0) + , Radius(0) + , AAr(0) + , ZAr(0) + , RhoAr(0) + , NclAr(0) + , EmedAr(0) + , EminAr(0) + , EmpAr(0) + , CsiAr(0) + , IAr(0) + , WiAr(0) + , Ncl(0) + , Ecl(0) + , Lcl(0) + , Ntote(0) + , GasGain(0) + , Cutoff(0) + , EmedCO2(0) + , EminCO2(0) + , EmpCO2(0) + , CsiCO2(0) + , ACO2(0) + , ZCO2(0) + , RhoCO2(0) + , ICO2(0) + , WiCO2(0) + , NclCO2(0) + , EmedCH4(0) + , EmpCH4(0) + , CsiCH4(0) + , EminCH4(0) + , ACH4(0) + , ZCH4(0) + , RhoCH4(0) + , ICH4(0) + , WiCH4(0) + , NclCH4(0) + , RhoMixCO2(0) + , RhoMixCH4(0) + , PZeta(0) + , piMass(0) + , PMass(0) + , PMom(0) + , Dx(0) + , eMass(0) + , prMass(0) + , Delta(0) + , CNumb(0) + , PEn(0) + , beta(0) + , gamma(0) + , Emed(0) + , Emin(0) + , Csi(0) + , Emax(0) + , Emp(0) + , NNClus(0) + , Xin(0) + , Yin(0) + , Zin(0) + , Xout(0) + , Yout(0) + , Zout(0) + , Rpath(0) + , NPolya(0) + , Xmax(0) + , bPolya(0) + , Calpha(0) + , Cbeta(0) + , Cgamma(0) + , NUrban(0) + , SigUrb(0) + , Eup(0) + , AvUrb(0) + , Wx1(0) + , Wy1(0) + , Wz1(0) + , Wx2(0) + , Wy2(0) + , Wz2(0) + , Wp(0) + , Wq(0) + , Wr(0) + , PulseMax(0) + , PulseTime(0) + , Thresh1(0) + , Thresh2(0) + , Nchann(0) + , Out1(0) + , Out2(0) + , Out3(0) { // class constructor @@ -155,9 +256,9 @@ void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t // Radius = R1; - pSTP = P1; + pSTP = P1; // Input for the media (volume percentages) - ArPerc = A1; + ArPerc = A1; CO2Perc = C1; // cluster dimensions in Ar and CO2 (experimantal values) @@ -167,7 +268,8 @@ void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t // .0061, .0049, .0039, .0030, .0025, .0020, .0016, .0012, // .00095, .00075, .00063}; // Fischle fit - Double_t PClus[20] = {0., .802, .0707, .020, .013, .008, .006, .005, .006, .008, .009, .007, .0050, .0040, .0033, .0029, .0025, .0023, .0022, .002}; // Lapique 1st calculation + Double_t PClus[20] = {0., .802, .0707, .020, .013, .008, .006, .005, .006, .008, + .009, .007, .0050, .0040, .0033, .0029, .0025, .0023, .0022, .002}; // Lapique 1st calculation // Double_t PClus[20] = // {0., .841, .0340, .021, .013, .008, .006, .004, .003, @@ -184,7 +286,8 @@ void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t // .0063, .0062, .0042, .0028, .0018, .0023, .0017, .0014, // .00060, .00050, .00063}; // Fischle exp - Double_t CO2Clus[20] = {0., .730, .162, .038, .020, .0110, .0147, .0060, .0084, .0052, .0020, .0042, .0021, .0025, .0038, .0021, .0009, .00013, .00064, .00048}; // Fischle exp + Double_t CO2Clus[20] = {0., .730, .162, .038, .020, .0110, .0147, .0060, .0084, .0052, + .0020, .0042, .0021, .0025, .0038, .0021, .0009, .00013, .00064, .00048}; // Fischle exp // Double_t CH4Clus[20] = // {0., .786, .120, .032, .013, .0098, .0055, .0057, .0027, @@ -199,28 +302,28 @@ void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t GasGain = 100000.; // argon ---------------------------------------------------- - AAr = 39.948; // Argon (39.948) - ZAr = 18.0; // Argon (18) - RhoAr = pSTP * 1.78 * 1.e-03; // g/cm3 (1.78 mg/cm3) - IAr = 188 * 1.e-09; // ionization potential (GeV) (188 eV) - WiAr = 27.0; // energy to create an ion pair (standard 26.7 eV) - NclAr = 25.; // cluster/cm in Argon + AAr = 39.948; // Argon (39.948) + ZAr = 18.0; // Argon (18) + RhoAr = pSTP * 1.78 * 1.e-03; // g/cm3 (1.78 mg/cm3) + IAr = 188 * 1.e-09; // ionization potential (GeV) (188 eV) + WiAr = 27.0; // energy to create an ion pair (standard 26.7 eV) + NclAr = 25.; // cluster/cm in Argon // CO2 ----------------------------------------------------- - ACO2 = 44; // CO2 - ZCO2 = 22.; // CO2 - RhoCO2 = pSTP * 1.98 * 1.e-03; // g/cm3 CO2 (1.98 mg/cm3) - ICO2 = 95.8 * 1.e-09; // ionization potential (GeV) (96 eV) - WiCO2 = 33.0; // energy to create an ion pair (33 eV) - NclCO2 = 35.5; // clusters/cm CO2 35.5 + ACO2 = 44; // CO2 + ZCO2 = 22.; // CO2 + RhoCO2 = pSTP * 1.98 * 1.e-03; // g/cm3 CO2 (1.98 mg/cm3) + ICO2 = 95.8 * 1.e-09; // ionization potential (GeV) (96 eV) + WiCO2 = 33.0; // energy to create an ion pair (33 eV) + NclCO2 = 35.5; // clusters/cm CO2 35.5 // Methane CH4 --------------------------------------------------------- - ACH4 = 16; // CO2 (39.948) - ZCH4 = 10.; // CO2 (18) - RhoCH4 = pSTP * 0.71 * 1.e-03; // g/cm3 CO2 (0.71 mg/cm3) - ICH4 = 40.6 * 1.e-09; // ionization potential (GeV) (45 eV) - WiCH4 = 28.0; // energy to create an ion pair + ACH4 = 16; // CO2 (39.948) + ZCH4 = 10.; // CO2 (18) + RhoCH4 = pSTP * 0.71 * 1.e-03; // g/cm3 CO2 (0.71 mg/cm3) + ICH4 = 40.6 * 1.e-09; // ionization potential (GeV) (45 eV) + WiCH4 = 28.0; // energy to create an ion pair NclCH4 = 25.0; // Input for the media (weight percentages) ---------------------------- - ArWPerc = ArPerc * AAr / (ArPerc * AAr + CO2Perc * ACO2); + ArWPerc = ArPerc * AAr / (ArPerc * AAr + CO2Perc * ACO2); CO2WPerc = CO2Perc * ACO2 / (ArPerc * AAr + CO2Perc * ACO2); // mixture densiies ---------------------------------------------------- @@ -230,10 +333,10 @@ void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t //---------------------------------------------------------------------- // particles (Gev, energy losses in Kev) - PZeta = 1; // projectile charge - piMass = 0.139; // particle mass (GeV) - eMass = 0.511 / 1000.; // electron mass (GeV) (0.511 MeV) - prMass = 0.93827; // proton mass (GeV) + PZeta = 1; // projectile charge + piMass = 0.139; // particle mass (GeV) + eMass = 0.511 / 1000.; // electron mass (GeV) (0.511 MeV) + prMass = 0.93827; // proton mass (GeV) // --------------------------------------------------------------------- // thresholds for the straw tubes (default values) see TInit for current values @@ -244,16 +347,16 @@ void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t // ---------------------------------------------Emin------------------------ - NPolya = 100; // steps for the calculation of the Polya distributions - Xmax = 0.; // Polya istribution is calculated between o and Xmax (see Polya) + NPolya = 100; // steps for the calculation of the Polya distributions + Xmax = 0.; // Polya istribution is calculated between o and Xmax (see Polya) bPolya = 0.5; - Polya(bPolya); // cumulative of the Polya distribution + Polya(bPolya); // cumulative of the Polya distribution // ----------------------------------------------------------------------- // cumulative for the number of electron per cluster Double_t Wnorm = (ArPerc * NclAr + CO2Perc * NclCO2); - CumClus[0] = (ArPerc * NclAr * PClus[0] + CO2Perc * NclCO2 * CO2Clus[0]) / Wnorm; + CumClus[0] = (ArPerc * NclAr * PClus[0] + CO2Perc * NclCO2 * CO2Clus[0]) / Wnorm; for (Int_t i = 1; i < 20; i++) { CumClus[i] = (ArPerc * NclAr * PClus[i] + CO2Perc * NclCO2 * CO2Clus[i]) / Wnorm + CumClus[i - 1]; @@ -294,21 +397,21 @@ void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[] // transfer of data // track geometrical quantities - Xin = InOut[0]; - Yin = InOut[1]; - Zin = InOut[2]; - Xout = InOut[3]; - Yout = InOut[4]; - Zout = InOut[5]; + Xin = InOut[0]; + Yin = InOut[1]; + Zin = InOut[2]; + Xout = InOut[3]; + Yout = InOut[4]; + Zout = InOut[5]; PMass = xPMass; - PMom = xPMom; + PMom = xPMom; // path into the straw Dx = sqrt((Xout - Xin) * (Xout - Xin) + (Yout - Yin) * (Yout - Yin) + (Zout - Zin) * (Zout - Zin)); // clear - CNumb = 0; - PulseMax = 0; + CNumb = 0; + PulseMax = 0; PulseTime = 0; CDist.clear(); CDistC.clear(); @@ -325,42 +428,41 @@ void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[] // initialization of the constants // maximum energy transfer Emax (GeV) and related quantities - PEn = sqrt(PMom * PMom + PMass * PMass); // particle energy GeV - beta = PMom / PEn; - gamma = 1 / sqrt(1. - beta * beta); - Double_t begam = beta * gamma; // local - Double_t mratio = eMass / PMass; // local + PEn = sqrt(PMom * PMom + PMass * PMass); // particle energy GeV + beta = PMom / PEn; + gamma = 1 / sqrt(1. - beta * beta); + Double_t begam = beta * gamma; // local + Double_t mratio = eMass / PMass; // local // calculation of the polarization Sternheimer factor for Argon - Double_t ms = 2.80; + Double_t ms = 2.80; Double_t Xst = log10(begam * sqrt(pSTP)); - Double_t Cs = -11.92; - Double_t X1 = 4; - Double_t Xo = 1.96; - Double_t as = 0.389; - Delta = 0; + Double_t Cs = -11.92; + Double_t X1 = 4; + Double_t Xo = 1.96; + Double_t as = 0.389; + Delta = 0; if (Xo <= Xst && Xst <= X1) Delta = 4.6051702 * Xst + Cs + as * pow(X1 - Xst, ms); else if (X1 < Xst) Delta = 4.6051702 * Xst + Cs; - if (Delta < 0) - Delta = 0; + if (Delta < 0) Delta = 0; // calculation of other typical quantites - Emax = (1.022 * begam * begam / (1. + 2. * gamma * mratio + mratio * mratio)) / 1000.; // GeV + Emax = (1.022 * begam * begam / (1. + 2. * gamma * mratio + mratio * mratio)) / 1000.; // GeV - CsiAr = 0.5 * 0.3071 * PZeta * PZeta * ZAr * RhoAr / (beta * beta * AAr) * 1e-03; // GeV + CsiAr = 0.5 * 0.3071 * PZeta * PZeta * ZAr * RhoAr / (beta * beta * AAr) * 1e-03; // GeV Double_t fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (IAr * IAr); - EmedAr = 2. * CsiAr * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm - EminAr = pSTP * 2.70 * 1.e-06; // GeV/cm (2.5 keV) + EmedAr = 2. * CsiAr * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm + EminAr = pSTP * 2.70 * 1.e-06; // GeV/cm (2.5 keV) // most prob energy (GeV) EmpAr = EmedAr + CsiAr * (0.422784 + beta * beta + log(CsiAr / Emax)); - CsiCO2 = 0.5 * 0.3071 * PZeta * PZeta * ZCO2 * RhoCO2 / (beta * beta * ACO2) * 1e-03; // GeV - fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (ICO2 * ICO2); - EmedCO2 = 2. * CsiCO2 * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm - EminCO2 = pSTP * 3.60 * 1.e-06; // GeV/cm (2.5 keV) + CsiCO2 = 0.5 * 0.3071 * PZeta * PZeta * ZCO2 * RhoCO2 / (beta * beta * ACO2) * 1e-03; // GeV + fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (ICO2 * ICO2); + EmedCO2 = 2. * CsiCO2 * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm + EminCO2 = pSTP * 3.60 * 1.e-06; // GeV/cm (2.5 keV) // most prob energy (GeV) EmpCO2 = EmedCO2 + CsiCO2 * (0.422784 + beta * beta + log(CsiCO2 / Emax)); @@ -368,20 +470,20 @@ void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[] ; Emed = RhoMixCO2 * ((ArWPerc * EmedAr / RhoAr) + (CO2WPerc * EmedCO2 / RhoCO2)); Emin = RhoMixCO2 * ((ArWPerc * EminAr / RhoAr) + (CO2WPerc * EminCO2 / RhoCO2)); - Emp = RhoMixCO2 * ((ArWPerc * EmpAr / RhoAr) + (CO2WPerc * EmpCO2 / RhoCO2)); + Emp = RhoMixCO2 * ((ArWPerc * EmpAr / RhoAr) + (CO2WPerc * EmpCO2 / RhoCO2)); // mean weighted interaction Wi = (ArPerc * NclAr * WiAr + CO2Perc * NclCO2 * WiCO2) / (ArPerc * NclAr + CO2Perc * NclCO2); // number of clusters - Double_t nAr = ArWPerc * RhoMixCO2 / AAr; + Double_t nAr = ArWPerc * RhoMixCO2 / AAr; Double_t nCO2 = CO2WPerc * RhoMixCO2 / ACO2; // Ncl=pSTP*((ArPerc*NclAr)+(CO2Perc*NclCO2))*Emed/Emin; // <--- Cluster/cm - Ncl = pSTP * ((nAr * NclAr + nCO2 * NclCO2) / (nAr + nCO2)) * Emed / Emin; // <--- Cluster/cm + Ncl = pSTP * ((nAr * NclAr + nCO2 * NclCO2) / (nAr + nCO2)) * Emed / Emin; // <--- Cluster/cm - Lcl = 1. / Ncl; // mean free path between clusters (cm) - Ecl = 2.8; // mean number of electrons per clusters (def 2.8) - Cutoff = Ncl * Ecl * 25; // limit to the number of primary electrons (*20) - Ntote = Ecl * Ncl; // total mean number of electrons per cm + Lcl = 1. / Ncl; // mean free path between clusters (cm) + Ecl = 2.8; // mean number of electrons per clusters (def 2.8) + Cutoff = Ncl * Ecl * 25; // limit to the number of primary electrons (*20) + Ntote = Ecl * Ncl; // total mean number of electrons per cm // --------------------------------------------------------------------- // thresholds for the straw tubes (current values) @@ -392,7 +494,7 @@ void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[] // ----------------------------------------------------------------------- - TDirCos(); // director cosine of the track + TDirCos(); // director cosine of the track // control prints @@ -409,7 +511,7 @@ void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[] Double_t CbmMustSingleStraw::STEloss() { - return gRandom->Landau(Emp * Dx, Csi * Dx); // in GeV + return gRandom->Landau(Emp * Dx, Csi * Dx); // in GeV } // ============================================================= @@ -437,24 +539,24 @@ Double_t CbmMustSingleStraw::STUrban() // calculation for Argon - Cu = EmedAr; - f2 = 2. / ZAr; - f1 = 1. - f2; - e2 = 10. * ZAr * ZAr * eVGeV; - e2f = TMath::Power(e2, f2); - e1 = TMath::Power(IAr / e2f, 1. / f1); + Cu = EmedAr; + f2 = 2. / ZAr; + f1 = 1. - f2; + e2 = 10. * ZAr * ZAr * eVGeV; + e2f = TMath::Power(e2, f2); + e1 = TMath::Power(IAr / e2f, 1. / f1); Sig1Ar = (1. - ru) * Cu * (f1 / e1) * (TMath::Log(Cuc / e1) - beta * beta) / (TMath::Log(Cuc / IAr) - beta * beta); Sig2Ar = (1. - ru) * Cu * (f2 / e2) * (TMath::Log(Cuc / e2) - beta * beta) / (TMath::Log(Cuc / IAr) - beta * beta); Sig3Ar = Cu * Emax * ru / (IAr * (Emax + IAr) * TMath::Log((Emax + IAr) / IAr)); // Calculation for CO2 - Cu = EmedCO2; - f2 = 2. / ZCO2; - f1 = 1. - f2; - e2 = 10. * ZCO2 * ZCO2 * eVGeV; + Cu = EmedCO2; + f2 = 2. / ZCO2; + f1 = 1. - f2; + e2 = 10. * ZCO2 * ZCO2 * eVGeV; e2f = TMath::Power(e2, f2); - e1 = TMath::Power(ICO2 / e2f, 1. / f1); + e1 = TMath::Power(ICO2 / e2f, 1. / f1); Sig1CO2 = (1. - ru) * Cu * (f1 / e1) * (TMath::Log(Cuc / e1) - beta * beta) / (TMath::Log(Cuc / ICO2) - beta * beta); Sig2CO2 = (1. - ru) * Cu * (f2 / e2) * (TMath::Log(Cuc / e2) - beta * beta) / (TMath::Log(Cuc / ICO2) - beta * beta); @@ -462,22 +564,22 @@ Double_t CbmMustSingleStraw::STUrban() // calculation for the mixture - nAr = ArWPerc * RhoMixCO2 / AAr; + nAr = ArWPerc * RhoMixCO2 / AAr; nCO2 = CO2WPerc * RhoMixCO2 / ACO2; IMix = TMath::Exp((nAr * ZAr * TMath::Log(IAr) + nCO2 * ZCO2 * TMath::Log(ICO2)) / (nAr * ZAr + nCO2 * ZCO2)); - ZMix = ArWPerc * ZAr + CO2WPerc * ZCO2; - f2 = 2. / ZMix; - f1 = 1. - f2; + ZMix = ArWPerc * ZAr + CO2WPerc * ZCO2; + f2 = 2. / ZMix; + f1 = 1. - f2; E2Mix = 10. * ZMix * ZMix * eVGeV; - e2f = TMath::Power(E2Mix, f2); + e2f = TMath::Power(E2Mix, f2); E1Mix = TMath::Power(IMix / e2f, 1. / f1); Sig1Mix = Dx * RhoMixCO2 * (ArWPerc * Sig1Ar / RhoAr + CO2WPerc * Sig1CO2 / RhoCO2); Sig2Mix = Dx * RhoMixCO2 * (ArWPerc * Sig2Ar / RhoAr + CO2WPerc * Sig2CO2 / RhoCO2); Sig3Mix = Dx * RhoMixCO2 * (ArWPerc * Sig3Ar / RhoAr + CO2WPerc * Sig3CO2 / RhoCO2); - NUrban = Sig1Mix + Sig2Mix + Sig3Mix; // total number of collisions (mean value) + NUrban = Sig1Mix + Sig2Mix + Sig3Mix; // total number of collisions (mean value) // Urban distribution calculation @@ -494,9 +596,9 @@ Double_t CbmMustSingleStraw::STUrban() // variance calculation - Eup = IMix / (1. - 0.98 * Emax / (Emax + IMix)); // 98% of the delta electron area (GeV) + Eup = IMix / (1. - 0.98 * Emax / (Emax + IMix)); // 98% of the delta electron area (GeV) Sig21 = IMix * (Emax + IMix) / Emax; - Medd = Sig21 * TMath::Log(Eup / IMix); + Medd = Sig21 * TMath::Log(Eup / IMix); Sig22 = Sig21 * Eup - Medd * Medd; Sig23 = Sig1Mix * E1Mix * E1Mix + Sig2Mix * E2Mix * E2Mix + Sig3Mix * Medd * Medd + Sig3Mix * Sig22; @@ -506,7 +608,7 @@ Double_t CbmMustSingleStraw::STUrban() // return the energy lost in keV - return N1Mix * E1Mix + N2Mix * E2Mix + E3Mix; // in GeV + return N1Mix * E1Mix + N2Mix * E2Mix + E3Mix; // in GeV } // ============================================================= @@ -525,11 +627,11 @@ Double_t CbmMustSingleStraw::StrawCharge() // threshold for delta rays (>1.5 KeV from NIM A301(1991)202) // total energy released by the electrons // Number of cluster in the length - NNClus = Cluster(); // set vectors CDist CDistC e CNele + NNClus = Cluster(); // set vectors CDist CDistC e CNele // calculation of total energy released by the electrons for (Int_t j = 1; j <= NNClus; j++) { ClusEner = 0.; - for (Int_t jj = 1; jj <= (Int_t)(CNele.at(j - 1)); jj++) { + for (Int_t jj = 1; jj <= (Int_t) (CNele.at(j - 1)); jj++) { Ecurr = Wi; TotEnEle += Ecurr; ClusEner += Ecurr; @@ -544,15 +646,14 @@ Double_t CbmMustSingleStraw::StrawCharge() // adding the diffusion effects Int_t owfl = 0; for (Int_t k = 1; k <= NNClus; k++) { - for (Int_t kk = 0; kk < (Int_t)CNeleT.at(k - 1); kk++) { - if (owfl > (Int_t)Cutoff) - break; + for (Int_t kk = 0; kk < (Int_t) CNeleT.at(k - 1); kk++) { + if (owfl > (Int_t) Cutoff) break; owfl++; WDist.push_back(WDistCalc(CDistC.at(k - 1))); } } - return TotEnEle * 1.e-09; // in Gev + return TotEnEle * 1.e-09; // in Gev } // ============================================================= @@ -576,12 +677,11 @@ Int_t CbmMustSingleStraw::Cluster() Double_t path = -Lcl * log(1 - gRandom->Uniform() + 0.000001); DisTot += path; - if (DisTot > Dx) - break; + if (DisTot > Dx) break; CNumb = k; CDist.push_back(path); CDistC.push_back(DisTot); - CNele.push_back((Double_t)Eject()); + CNele.push_back((Double_t) Eject()); } return CNumb; @@ -597,10 +697,11 @@ Int_t CbmMustSingleStraw::Eject() nelect = TMath::BinarySearch(21, CumClus, gRandom->Uniform()); if (nelect < 19) { - return Inelect = (Int_t)(nelect) + 1; - } else { + return Inelect = (Int_t) (nelect) + 1; + } + else { // long delta electron tail - return Inelect = (Int_t)(20. / (1.03 - gRandom->Uniform())); + return Inelect = (Int_t) (20. / (1.03 - gRandom->Uniform())); } } @@ -618,15 +719,20 @@ Double_t CbmMustSingleStraw::RRise(Double_t gamma2) if (1. <= gamma2 && gamma2 <= 2.2) { Rise = -2.159 * lg + 1.7; - } else if (2.2 <= gamma2 && gamma2 <= 6.) { + } + else if (2.2 <= gamma2 && gamma2 <= 6.) { Rise = 1.; - } else if (6. <= gamma2 && gamma2 <= 200.) { + } + else if (6. <= gamma2 && gamma2 <= 200.) { Rise = 0.302 * lg + 0.765; - } else if (200. <= gamma2 && gamma2 <= 1000.) { + } + else if (200. <= gamma2 && gamma2 <= 1000.) { Rise = 0.1431 * lg + 1.131; - } else if (1000. <= gamma2) { + } + else if (1000. <= gamma2) { Rise = 1.54; - } else { + } + else { Rise = 1.7; } @@ -649,9 +755,9 @@ void CbmMustSingleStraw::Polya(Double_t bpar) // find Xmax - PMax = eps * pow(k, k) * exp(-k); + PMax = eps * pow(k, k) * exp(-k); Double_t value = 1.e+06; - Xmax = 2 * k; + Xmax = 2 * k; while (value > PMax) { Xmax += Dxx; value = pow(Xmax, k) * exp(-Xmax); @@ -661,11 +767,11 @@ void CbmMustSingleStraw::Polya(Double_t bpar) // calculate the cumulative Double_t dx = Xmax / NPolya; - Xs[0] = 0; + Xs[0] = 0; for (Int_t i = 1; i < NPolya; i++) { x1 = xx; xx += dx; - x2 = xx; + x2 = xx; Xs[i] = x2; if (i > 1) PolyaCum[i] = PolyaCum[i - 1] + 0.5 * dx * (pow(x1, k) * exp(-x1) + pow(x2, k) * exp(-x2)) / TMath::Gamma(k + 1); @@ -686,8 +792,8 @@ Double_t CbmMustSingleStraw::PolyaSamp() // sampling a wire gain fluctuation in the gas - Double_t xr = gRandom->Uniform(); - Int_t n = TMath::BinarySearch(NPolya, PolyaCum, xr); + Double_t xr = gRandom->Uniform(); + Int_t n = TMath::BinarySearch(NPolya, PolyaCum, xr); Double_t xsamp = Xmax; if (n < NPolya - 1) { xsamp = Xs[n] + ((xr - PolyaCum[n]) / (PolyaCum[n + 1] - PolyaCum[n])) * (Xs[n + 1] - Xs[n]); @@ -707,9 +813,9 @@ TVector3 CbmMustSingleStraw::WDistCalc(Double_t DisTot) // wire director cosines Double_t Wlength = sqrt((Wx2 - Wx1) * (Wx2 - Wx1) + (Wy2 - Wy1) * (Wy2 - Wy1) + (Wz2 - Wz1) * (Wz2 - Wz1)); - Wp = (Wx2 - Wx1) / Wlength; - Wq = (Wy2 - Wy1) / Wlength; - Wr = (Wz2 - Wz1) / Wlength; + Wp = (Wx2 - Wx1) / Wlength; + Wq = (Wy2 - Wy1) / Wlength; + Wr = (Wz2 - Wz1) / Wlength; // current track coordinates Double_t xcor = Calpha * DisTot + Xin; @@ -740,12 +846,12 @@ TVector3 CbmMustSingleStraw::WDistCalc(Double_t DisTot) // MAGY Ar/CO2 90/10 20-7-2006 GARFIELD Double_t SigL = DiffLong(DDistcm); // ... in cm - SigL *= 1.e-04; // in cm + SigL *= 1.e-04; // in cm // tranverse coefficient (GARFIELD) cm--> micron // MAGY Ar/CO2 90/10 20-7-2006 GARFIELD Double_t SigT = DiffTran(DDistcm); - SigT *= 1.e-04; // in cm + SigT *= 1.e-04; // in cm // sampling of Longitudinal and Transverse diffusion Double_t difL = gRandom->Gaus(0., SigL); @@ -775,7 +881,7 @@ void CbmMustSingleStraw::TDirCos() // director cosines Calpha = (Xout - Xin) / Rpath; - Cbeta = (Yout - Yin) / Rpath; + Cbeta = (Yout - Yin) / Rpath; Cgamma = (Zout - Zin) / Rpath; } @@ -795,28 +901,31 @@ Int_t CbmMustSingleStraw::TimeEle() Double_t etime; // cutoff the total charge to 20 times the average - if (ido > (Int_t)Cutoff) - ido = (Int_t)Cutoff; + if (ido > (Int_t) Cutoff) ido = (Int_t) Cutoff; for (Int_t k = 0; k < ido; k++) { - Double_t dst = WDist.at(k).Mag(); // distance in cm + Double_t dst = WDist.at(k).Mag(); // distance in cm // space to time calculation from GARFIELD if (pSTP < 1.9) { if (Radius < 0.5) { // V=1600V diameter 4 mm 90/10 - etime = -1.624e-05 + 0.1258 * dst + 0.8079 * pow(dst, 2) - 2.918 * pow(dst, 3) + 10.33 * pow(dst, 4) - 10.84 * pow(dst, 5); - } else { + etime = -1.624e-05 + 0.1258 * dst + 0.8079 * pow(dst, 2) - 2.918 * pow(dst, 3) + 10.33 * pow(dst, 4) + - 10.84 * pow(dst, 5); + } + else { // V=1600V diameter 5 mm 90/10 - etime = -6.763e-05 + 0.1471 * dst + 0.3625 * pow(dst, 2) + 0.3876 * pow(dst, 3) + 1.04 * pow(dst, 4) - 1.693 * pow(dst, 5); + etime = -6.763e-05 + 0.1471 * dst + 0.3625 * pow(dst, 2) + 0.3876 * pow(dst, 3) + 1.04 * pow(dst, 4) + - 1.693 * pow(dst, 5); } - } else { + } + else { // 2 bar 2000V, 5 mm, 80/20 etime = -0.0001014 + 0.1463 * dst - 0.1694 * pow(dst, 2) + 2.4248 * pow(dst, 3) - 1.793 * pow(dst, 4); } - etime *= 1000.; // nano seconds + etime *= 1000.; // nano seconds TeleTime.push_back(etime); } @@ -839,7 +948,7 @@ Double_t CbmMustSingleStraw::Signal(Double_t t, Double_t t0) Double_t x = t - t0; // if(x>0) elesig = A*exp(B*log(x)-C*x)*(1+D*x+E*x*x); // Sokolov Signal if (x > 0) - elesig = pow(2. * x / 10., 2) * exp(-2. * x / 10.); // Wirtz signal + elesig = pow(2. * x / 10., 2) * exp(-2. * x / 10.); // Wirtz signal else elesig = 0.; @@ -860,15 +969,14 @@ Int_t CbmMustSingleStraw::StrawSignal(Int_t nsteps) PulseT.clear(); AmplSig.clear(); - Int_t neltot = TimeEle(); // creation and size of TeleTime (electron times) + Int_t neltot = TimeEle(); // creation and size of TeleTime (electron times) Double_t Tmax = 1.e-25; for (Int_t k = 0; k < neltot; k++) - if (Tmax < TeleTime.at(k)) - Tmax = TeleTime.at(k); + if (Tmax < TeleTime.at(k)) Tmax = TeleTime.at(k); Tmax += 100.; - Double_t Dt = Tmax / nsteps; // number of steps of the signal + Double_t Dt = Tmax / nsteps; // number of steps of the signal // AmplSig is the amplitude of each electron @@ -878,7 +986,7 @@ Int_t CbmMustSingleStraw::StrawSignal(Int_t nsteps) // creation of the signal Pulse(PulseT) time in ns for (Int_t j = 0; j < nsteps; j++) { - Double_t te = j * Dt; + Double_t te = j * Dt; Double_t sumele = 0.; for (Int_t jj = 0; jj < neltot; jj++) { Double_t te0 = TeleTime.at(jj); @@ -893,11 +1001,10 @@ Int_t CbmMustSingleStraw::StrawSignal(Int_t nsteps) // a 1% of 200 ns periodic signal Double_t Pmax = 1.e-25; - for (Int_t k = 0; k < (Int_t)Pulse.size(); k++) - if (Pmax < Pulse.at(k)) - Pmax = Pulse.at(k); + for (Int_t k = 0; k < (Int_t) Pulse.size(); k++) + if (Pmax < Pulse.at(k)) Pmax = Pulse.at(k); - for (Int_t k = 0; k < (Int_t)Pulse.size(); k++) { + for (Int_t k = 0; k < (Int_t) Pulse.size(); k++) { Pulse.at(k) += 0.03 * Pmax * gRandom->Uniform() + 0.01 * Pmax * (sin(6.28 * PulseT.at(k) / 120.)); // if(Pulse[k]<0) Pulse[k] *= -1.; } @@ -923,14 +1030,14 @@ Int_t CbmMustSingleStraw::StrawTime() PulseTime = 0.; - Int_t ind = 0; + Int_t ind = 0; Int_t flag1 = 0; Int_t flag2 = 1; - for (Int_t k = 0; k < (Int_t)Pulse.size(); k++) { + for (Int_t k = 0; k < (Int_t) Pulse.size(); k++) { if (flag1 == 0 && Pulse[k] > Thresh1) { flag1 = 1; - ind = k; + ind = k; } // if(Pulse[k]<Thresh1) {flag1=0; ind=0;} // reset if signal decreases @@ -940,8 +1047,7 @@ Int_t CbmMustSingleStraw::StrawTime() // break; // } } - if (flag1 == 1 && flag2 == 1) - PulseTime = PulseT.at(ind); + if (flag1 == 1 && flag2 == 1) PulseTime = PulseT.at(ind); return ind; } @@ -958,26 +1064,27 @@ Double_t CbmMustSingleStraw::TrueDist(Double_t Point[]) // wire director cosines Double_t Wlength = sqrt((Wx2 - Wx1) * (Wx2 - Wx1) + (Wy2 - Wy1) * (Wy2 - Wy1) + (Wz2 - Wz1) * (Wz2 - Wz1)); - Wp = (Wx2 - Wx1) / Wlength; - Wq = (Wy2 - Wy1) / Wlength; - Wr = (Wz2 - Wz1) / Wlength; + Wp = (Wx2 - Wx1) / Wlength; + Wq = (Wy2 - Wy1) / Wlength; + Wr = (Wz2 - Wz1) / Wlength; // director cosines of the given track - Double_t Modu = sqrt((Point[3] * Point[0]) * (Point[3] * Point[0]) + (Point[4] * Point[1]) * (Point[4] * Point[1]) + (Point[5] * Point[2]) * (Point[5] * Point[2])); - Double_t dcx = (Point[3] - Point[0]) / Modu; - Double_t dcy = (Point[4] - Point[1]) / Modu; - Double_t dcz = (Point[5] - Point[2]) / Modu; + Double_t Modu = sqrt((Point[3] * Point[0]) * (Point[3] * Point[0]) + (Point[4] * Point[1]) * (Point[4] * Point[1]) + + (Point[5] * Point[2]) * (Point[5] * Point[2])); + Double_t dcx = (Point[3] - Point[0]) / Modu; + Double_t dcy = (Point[4] - Point[1]) / Modu; + Double_t dcz = (Point[5] - Point[2]) / Modu; // distance formula - Double_t p1 = (Point[0] - Wx1) * (dcy * Wr - dcz * Wq); - Double_t p2 = -(Point[1] - Wy1) * (dcx * Wr - dcz * Wp); - Double_t p3 = (Point[2] - Wz1) * (dcx * Wq - dcy * Wp); - Double_t Det = p1 + p2 + p3; - Double_t Disc = sqrt((dcy * Wr - dcz * Wq) * (dcy * Wr - dcz * Wq) + (dcz * Wp - dcx * Wr) * (dcz * Wp - dcx * Wr) + (dcx * Wq - dcy * Wp) * (dcx * Wq - dcy * Wp)); - if (Disc > 0) - truedist = TMath::Abs(Det / Disc); - - return truedist; // distance in cm + Double_t p1 = (Point[0] - Wx1) * (dcy * Wr - dcz * Wq); + Double_t p2 = -(Point[1] - Wy1) * (dcx * Wr - dcz * Wp); + Double_t p3 = (Point[2] - Wz1) * (dcx * Wq - dcy * Wp); + Double_t Det = p1 + p2 + p3; + Double_t Disc = sqrt((dcy * Wr - dcz * Wq) * (dcy * Wr - dcz * Wq) + (dcz * Wp - dcx * Wr) * (dcz * Wp - dcx * Wr) + + (dcx * Wq - dcy * Wp) * (dcx * Wq - dcy * Wp)); + if (Disc > 0) truedist = TMath::Abs(Det / Disc); + + return truedist; // distance in cm } // ===================================================================== @@ -997,20 +1104,24 @@ Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) if (pSTP < 1.9) { if (Radius < 0.5) { - drift = -0.0140 - 1.37281e-01 + 5.13978e-02 * time + 7.65443e-05 * pow(time, 2) - 9.53479e-06 * pow(time, 3) + 1.19432e-07 * pow(time, 4) - 6.19861e-10 * pow(time, 5) + - 1.35458e-12 * pow(time, 6) - 1.10933e-15 * pow(time, 7); + drift = -0.0140 - 1.37281e-01 + 5.13978e-02 * time + 7.65443e-05 * pow(time, 2) - 9.53479e-06 * pow(time, 3) + + 1.19432e-07 * pow(time, 4) - 6.19861e-10 * pow(time, 5) + 1.35458e-12 * pow(time, 6) + - 1.10933e-15 * pow(time, 7); } else { // 1600 V 5 mm if (time < 120.) { - drift = 0.0300 - 1.07377e-01 + 3.65134e-02 * time + 1.20909e-03 * pow(time, 2) - 4.56678e-05 * pow(time, 3) + 6.70207e-07 * pow(time, 4) - 4.99204e-09 * pow(time, 5) + - 2.19079e-11 * pow(time, 6) - 8.01791e-14 * pow(time, 7) + 2.16778e-16 * pow(time, 8); - } else { + drift = 0.0300 - 1.07377e-01 + 3.65134e-02 * time + 1.20909e-03 * pow(time, 2) - 4.56678e-05 * pow(time, 3) + + 6.70207e-07 * pow(time, 4) - 4.99204e-09 * pow(time, 5) + 2.19079e-11 * pow(time, 6) + - 8.01791e-14 * pow(time, 7) + 2.16778e-16 * pow(time, 8); + } + else { - drift = 0.0300 - 8.91701e-01 + 4.68487e-02 * time + 1.00902e-03 * pow(time, 2) - 4.00359e-05 * pow(time, 3) + 6.23768e-07 * pow(time, 4) - 5.20556e-09 * pow(time, 5) + - 2.41502e-11 * pow(time, 6) - 5.85450e-14 * pow(time, 7) + 5.77250e-17 * pow(time, 8); + drift = 0.0300 - 8.91701e-01 + 4.68487e-02 * time + 1.00902e-03 * pow(time, 2) - 4.00359e-05 * pow(time, 3) + + 6.23768e-07 * pow(time, 4) - 5.20556e-09 * pow(time, 5) + 2.41502e-11 * pow(time, 6) + - 5.85450e-14 * pow(time, 7) + 5.77250e-17 * pow(time, 8); } } } @@ -1021,8 +1132,9 @@ Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) // on thresh static 10% - drift = -0.0300 + 1.28551e-02 + 1.44029e-02 * time - 3.67834e-03 * pow(time, 2) + 3.32034e-04 * pow(time, 3) - 6.36592e-06 * pow(time, 4) - 7.82907e-08 * pow(time, 5) + - 3.58931e-09 * pow(time, 6) - 2.93491e-11 * pow(time, 7); + drift = -0.0300 + 1.28551e-02 + 1.44029e-02 * time - 3.67834e-03 * pow(time, 2) + 3.32034e-04 * pow(time, 3) + - 6.36592e-06 * pow(time, 4) - 7.82907e-08 * pow(time, 5) + 3.58931e-09 * pow(time, 6) + - 2.93491e-11 * pow(time, 7); // one thresh static 3% // drift = +5.35238e-02 @@ -1033,13 +1145,14 @@ Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) // +3.29531e-08 *pow(time,5) // +1.12115e-09 *pow(time,6) // -1.72919e-11 *pow(time,7) ; - - } else if (50. < time && time < 130.) { + } + else if (50. < time && time < 130.) { // on thresh static 10% - drift = -0.0190 + 4.40993e-01 - 2.91442e-02 * time + 3.06237e-03 * pow(time, 2) - 6.07870e-05 * pow(time, 3) + 5.97431e-07 * pow(time, 4) - 3.09238e-09 * pow(time, 5) + - 7.70537e-12 * pow(time, 6) - 6.49086e-15 * pow(time, 7); + drift = -0.0190 + 4.40993e-01 - 2.91442e-02 * time + 3.06237e-03 * pow(time, 2) - 6.07870e-05 * pow(time, 3) + + 5.97431e-07 * pow(time, 4) - 3.09238e-09 * pow(time, 5) + 7.70537e-12 * pow(time, 6) + - 6.49086e-15 * pow(time, 7); // one thresh static 3% // drift = +2.25702e-02 @@ -1050,14 +1163,14 @@ Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) // -1.30249e-09 *pow(time,5) // +3.38791e-12 *pow(time,6) // -2.10503e-15 *pow(time,7) ; - } else { // on thresh static 10% - drift = -0.0100 + 4.28757e-01 - 1.95413e-02 * time + 3.02333e-03 * pow(time, 2) - 6.13920e-05 * pow(time, 3) + 5.93656e-07 * pow(time, 4) - 3.05271e-09 * pow(time, 5) + - 8.05446e-12 * pow(time, 6) - 8.59626e-15 * pow(time, 7); + drift = -0.0100 + 4.28757e-01 - 1.95413e-02 * time + 3.02333e-03 * pow(time, 2) - 6.13920e-05 * pow(time, 3) + + 5.93656e-07 * pow(time, 4) - 3.05271e-09 * pow(time, 5) + 8.05446e-12 * pow(time, 6) + - 8.59626e-15 * pow(time, 7); // one thresh static 3% // drift = +1.57217e-01 @@ -1072,8 +1185,7 @@ Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) } drift = 0.1 * drift; - if (drift < 0.) - drift = 0.; + if (drift < 0.) drift = 0.; return drift; } @@ -1086,10 +1198,10 @@ Double_t CbmMustSingleStraw::PartToTime(Double_t xPMass, Double_t xPMom, Double_ // input-output coordinate InOut[6] // Useful for MC pplication after a call to PutWireXYZ - TInit(xPMass, xPMom, InOut); // start the event - Out1 = StrawCharge(); // energy loss (GeV) to generate charge - Out2 = StrawSignal(Nchann); // generate the straw signal - Out3 = StrawTime(); // find the straw drift time PulseTime + TInit(xPMass, xPMom, InOut); // start the event + Out1 = StrawCharge(); // energy loss (GeV) to generate charge + Out2 = StrawSignal(Nchann); // generate the straw signal + Out3 = StrawTime(); // find the straw drift time PulseTime return PulseTime; } @@ -1104,7 +1216,7 @@ Double_t CbmMustSingleStraw::PartToADC() for (Int_t j = 1; j <= NNClus; j++) { - for (Int_t jc = 1; jc <= (Int_t)CNeleT[j - 1]; jc++) + for (Int_t jc = 1; jc <= (Int_t) CNeleT[j - 1]; jc++) ADCsignal += bPolya * GasGain * PolyaSamp(); } @@ -1124,7 +1236,7 @@ Double_t CbmMustSingleStraw::FastPartToADC() // number of elecrons. Wi is the mean energy lost per free // electrn in eV - Int_t NtotEle = (Int_t)(1.e+09 * STUrban() / Wi); + Int_t NtotEle = (Int_t) (1.e+09 * STUrban() / Wi); for (Int_t j = 1; j <= NtotEle; j++) { @@ -1151,17 +1263,20 @@ Double_t CbmMustSingleStraw::FastRec(Double_t TrueDcm, Int_t Flag) if (pSTP < 1.9) { if (Radius < 0.45) { if (TrueDcm < 0.38) { - resmic = - 1.24506e+02 - 1.80117e+02 * TrueDcm + 3.76905e+03 * pow(TrueDcm, 2) - 4.63251e+04 * pow(TrueDcm, 3) + 1.80068e+05 * pow(TrueDcm, 4) - 2.21094e+05 * pow(TrueDcm, 5); - } else + resmic = 1.24506e+02 - 1.80117e+02 * TrueDcm + 3.76905e+03 * pow(TrueDcm, 2) - 4.63251e+04 * pow(TrueDcm, 3) + + 1.80068e+05 * pow(TrueDcm, 4) - 2.21094e+05 * pow(TrueDcm, 5); + } + else resmic = 57.; } // radius > 0.4 cm else { if (TrueDcm < 0.48) { - resmic = 1.53656e+02 - 5.07749e+03 * TrueDcm + 1.73707e+05 * pow(TrueDcm, 2) - 2.72285e+06 * pow(TrueDcm, 3) + 2.28719e+07 * pow(TrueDcm, 4) - - 1.12921e+08 * pow(TrueDcm, 5) + 3.39427e+08 * pow(TrueDcm, 6) - 6.12741e+08 * pow(TrueDcm, 7) + 6.12041e+08 * pow(TrueDcm, 8) - 2.60444e+08 * pow(TrueDcm, 9); - } else + resmic = 1.53656e+02 - 5.07749e+03 * TrueDcm + 1.73707e+05 * pow(TrueDcm, 2) - 2.72285e+06 * pow(TrueDcm, 3) + + 2.28719e+07 * pow(TrueDcm, 4) - 1.12921e+08 * pow(TrueDcm, 5) + 3.39427e+08 * pow(TrueDcm, 6) + - 6.12741e+08 * pow(TrueDcm, 7) + 6.12041e+08 * pow(TrueDcm, 8) - 2.60444e+08 * pow(TrueDcm, 9); + } + else resmic = 72.; } } @@ -1170,16 +1285,21 @@ Double_t CbmMustSingleStraw::FastRec(Double_t TrueDcm, Int_t Flag) else { if (Flag == 0) { if (TrueDcm < 0.48) { - resmic = +1.06966e+02 - 4.03073e+03 * TrueDcm + 1.60851e+05 * pow(TrueDcm, 2) - 2.87722e+06 * pow(TrueDcm, 3) + 2.67581e+07 * pow(TrueDcm, 4) - - 1.43397e+08 * pow(TrueDcm, 5) + 4.61046e+08 * pow(TrueDcm, 6) - 8.79170e+08 * pow(TrueDcm, 7) + 9.17095e+08 * pow(TrueDcm, 8) - 4.03253e+08 * pow(TrueDcm, 9); - } else + resmic = +1.06966e+02 - 4.03073e+03 * TrueDcm + 1.60851e+05 * pow(TrueDcm, 2) - 2.87722e+06 * pow(TrueDcm, 3) + + 2.67581e+07 * pow(TrueDcm, 4) - 1.43397e+08 * pow(TrueDcm, 5) + 4.61046e+08 * pow(TrueDcm, 6) + - 8.79170e+08 * pow(TrueDcm, 7) + 9.17095e+08 * pow(TrueDcm, 8) - 4.03253e+08 * pow(TrueDcm, 9); + } + else resmic = 30.; - } else { + } + else { // data from julich if (TrueDcm < 0.48) { - resmic = 20. + 1.48048e+02 - 3.35951e+02 * TrueDcm - 1.87575e+03 * pow(TrueDcm, 2) + 1.92910e+04 * pow(TrueDcm, 3) - 6.90036e+04 * pow(TrueDcm, 4) + - 1.07960e+05 * pow(TrueDcm, 5) - 5.90064e+04 * pow(TrueDcm, 6); - } else + resmic = 20. + 1.48048e+02 - 3.35951e+02 * TrueDcm - 1.87575e+03 * pow(TrueDcm, 2) + + 1.92910e+04 * pow(TrueDcm, 3) - 6.90036e+04 * pow(TrueDcm, 4) + 1.07960e+05 * pow(TrueDcm, 5) + - 5.90064e+04 * pow(TrueDcm, 6); + } + else resmic = 65.; } } @@ -1206,19 +1326,23 @@ Double_t CbmMustSingleStraw::DiffLong(Double_t Distcm) if (pSTP < 1.9) { if (Radius < 0.5) { // 4 mm 1600 V 90/10 - DiffMic = 0.896 + 1387. * Distcm - 1.888e+04 * pow(Distcm, 2) + 1.799e+05 * pow(Distcm, 3) - 9.848e+05 * pow(Distcm, 4) + 3.009e+06 * pow(Distcm, 5) - - 4.777e+06 * pow(Distcm, 6) + 3.074e+06 * pow(Distcm, 7); - } else { + DiffMic = 0.896 + 1387. * Distcm - 1.888e+04 * pow(Distcm, 2) + 1.799e+05 * pow(Distcm, 3) + - 9.848e+05 * pow(Distcm, 4) + 3.009e+06 * pow(Distcm, 5) - 4.777e+06 * pow(Distcm, 6) + + 3.074e+06 * pow(Distcm, 7); + } + else { // 5 mm 1600 V - DiffMic = 1.537 + 1246. * Distcm - 1.357e+04 * pow(Distcm, 2) + 1.049e+05 * pow(Distcm, 3) - 4.755e+05 * pow(Distcm, 4) + 1.211e+06 * pow(Distcm, 5) - - 1.6e+06 * pow(Distcm, 6) + 8.533e+05 * pow(Distcm, 7); + DiffMic = 1.537 + 1246. * Distcm - 1.357e+04 * pow(Distcm, 2) + 1.049e+05 * pow(Distcm, 3) + - 4.755e+05 * pow(Distcm, 4) + 1.211e+06 * pow(Distcm, 5) - 1.6e+06 * pow(Distcm, 6) + + 8.533e+05 * pow(Distcm, 7); } } else { // 2000V 5 mm 2 bar 80/20 - DiffMic = 2.135 + 818. * Distcm - 1.044e+04 * pow(Distcm, 2) + 8.31e+04 * pow(Distcm, 3) - 3.492e+05 * pow(Distcm, 4) + 7.959e+05 * pow(Distcm, 5) - - 9.378e+05 * pow(Distcm, 6) + 4.492e+05 * pow(Distcm, 7); + DiffMic = 2.135 + 818. * Distcm - 1.044e+04 * pow(Distcm, 2) + 8.31e+04 * pow(Distcm, 3) + - 3.492e+05 * pow(Distcm, 4) + 7.959e+05 * pow(Distcm, 5) - 9.378e+05 * pow(Distcm, 6) + + 4.492e+05 * pow(Distcm, 7); } return DiffMic; } @@ -1238,17 +1362,20 @@ Double_t CbmMustSingleStraw::DiffTran(Double_t Distcm) // DiffMic = + 0.8513 + 1648.*Distcm - 1.085e+04*pow(Distcm,2) // + 7.38e+04*pow(Distcm,3) - 3.025e+05*pow(Distcm,4) // + 6.067e+05*pow(Distcm,5) - 4.643e+04*pow(Distcm,6); - DiffMic = - +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); - } else { + DiffMic = +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) + - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); + } + else { // 5 mm 1600 V 90/10 - DiffMic = - +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); + DiffMic = +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) + - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); } - } else { + } + else { // 5 mm 2000 V 2 bar 80/20 - DiffMic = +2.094 + 1138. * Distcm - 7557. * pow(Distcm, 2) + 2.968e+04 * pow(Distcm, 3) - 6.577e+04 * pow(Distcm, 4) + 7.581e+04 * pow(Distcm, 5) - 3.497e+04 * pow(Distcm, 6); + DiffMic = +2.094 + 1138. * Distcm - 7557. * pow(Distcm, 2) + 2.968e+04 * pow(Distcm, 3) - 6.577e+04 * pow(Distcm, 4) + + 7.581e+04 * pow(Distcm, 5) - 3.497e+04 * pow(Distcm, 6); } return DiffMic; } @@ -1265,13 +1392,14 @@ Double_t CbmMustSingleStraw::DistEle(Double_t time) // 1 absolute atm (NTP) 20-7-2006 GARFIELd Ar/CO2 90/10 MAGY // ns --> cm - time *= 0.001; // time in micro s + time *= 0.001; // time in micro s if (pSTP < 2.) { if (Radius < 0.5) { // 1600 V 4 mm 90/10 drift = 0.001629 + 6.194 * time - 56.55 * pow(time, 2) + 355.8 * pow(time, 3) - 903.2 * pow(time, 4); - } else { + } + else { // 1600 V 5 mm 90/10 drift = 0.003365 + 5.734 * time - 41.88 * pow(time, 2) + 191.2 * pow(time, 3) - 333.4 * pow(time, 4); } @@ -1283,5 +1411,5 @@ Double_t CbmMustSingleStraw::DistEle(Double_t time) drift = 0.003365 + 7.056 * time - 62.28 * pow(time, 2) + 306.1 * pow(time, 3) - 558.7 * pow(time, 4); } - return drift; // in cm + return drift; // in cm } diff --git a/core/detectors/must/CbmMustSingleStraw.h b/core/detectors/must/CbmMustSingleStraw.h index 656fc98f08..1114d8d1fa 100644 --- a/core/detectors/must/CbmMustSingleStraw.h +++ b/core/detectors/must/CbmMustSingleStraw.h @@ -42,7 +42,7 @@ class CbmMustSingleStraw : public TNamed { Double_t GetTeleTime(Int_t k) { return TeleTime[k]; }; Double_t GetPulse(Int_t k) { return Pulse[k]; }; Double_t GetPulseT(Int_t k) { return PulseT[k]; }; - Double_t GetWi() { return Wi * 1.e-09; }; // in GeV + Double_t GetWi() { return Wi * 1.e-09; }; // in GeV Double_t GetGasGain() { return GasGain; }; Double_t GetXmax() { return Xmax; }; Double_t GetDx() { return Dx; }; @@ -80,9 +80,9 @@ class CbmMustSingleStraw : public TNamed { // put methods void PutTrackXYZ(Double_t v1, Double_t v2, Double_t v3, Double_t v4, Double_t v5, Double_t v6) { - Xin = v1; - Yin = v2; - Zin = v3; + Xin = v1; + Yin = v2; + Zin = v3; Xout = v4; Yout = v5; Zout = v6; @@ -118,39 +118,39 @@ class CbmMustSingleStraw : public TNamed { void TConst(Double_t Radius, Double_t pSTP, Double_t ArP, Double_t CO2P); // to define the track - void TInit(Double_t Mass, Double_t Momentum, Double_t InOut[]); // for each track + void TInit(Double_t Mass, Double_t Momentum, Double_t InOut[]); // for each track // other possible calls - Double_t StrawCharge(); // total discharge electron calculation + Double_t StrawCharge(); // total discharge electron calculation - Int_t StrawSignal(Int_t nsteps); // oscilloscope signal generation (ns) - // Pulse[PulseT] in ns - // return number of primary electrons - Int_t StrawTime(); // output time of the straw (ns) & - // PulseTime[Int_t] in ns + Int_t StrawSignal(Int_t nsteps); // oscilloscope signal generation (ns) + // Pulse[PulseT] in ns + // return number of primary electrons + Int_t StrawTime(); // output time of the straw (ns) & + // PulseTime[Int_t] in ns // Int_t StrawTot(); // Time over threshold time of the straw (ns) not implemented - Double_t TimnsToDiscm(Double_t time); // from time (ns) to radius in cm + Double_t TimnsToDiscm(Double_t time); // from time (ns) to radius in cm //----------------------------------------------------------------------------- // utility methods - void TDirCos(); // track director cosines - Double_t TrueDist(Double_t Point[]); // true distance wire-track - Double_t DiffLong(Double_t distcm); // longituinal diffusion in microns - Double_t DiffTran(Double_t distcm); // transverse diffusion in microns - void Polya(Double_t bpar); // Polya cumulative calculation - Double_t PolyaSamp(); // sampling from Polya distribution - Double_t RRise(Double_t gamma); // relativistic rise calculation - Int_t Cluster(); // cluster generation - Int_t Eject(); // primary electron generation - TVector3 WDistCalc(Double_t d); // distance electron-wire - Double_t Signal(Double_t t, Double_t t0); // signal functional form - Double_t STEloss(); // Landau energy loss - Double_t STUrban(); // Urban energy loss - Int_t TimeEle(); // arrivals times of all the electrons - Double_t DistEle(Double_t tns); // distance of all the electrons + void TDirCos(); // track director cosines + Double_t TrueDist(Double_t Point[]); // true distance wire-track + Double_t DiffLong(Double_t distcm); // longituinal diffusion in microns + Double_t DiffTran(Double_t distcm); // transverse diffusion in microns + void Polya(Double_t bpar); // Polya cumulative calculation + Double_t PolyaSamp(); // sampling from Polya distribution + Double_t RRise(Double_t gamma); // relativistic rise calculation + Int_t Cluster(); // cluster generation + Int_t Eject(); // primary electron generation + TVector3 WDistCalc(Double_t d); // distance electron-wire + Double_t Signal(Double_t t, Double_t t0); // signal functional form + Double_t STEloss(); // Landau energy loss + Double_t STUrban(); // Urban energy loss + Int_t TimeEle(); // arrivals times of all the electrons + Double_t DistEle(Double_t tns); // distance of all the electrons //------------------------------------------------------------------------------ @@ -169,82 +169,82 @@ class CbmMustSingleStraw : public TNamed { // Input for the medium // Double_t PClus[20], CO2Clus[20], CumClus[21], CH4Clus[20]; - Double_t CumClus[21], CH4Clus[20]; // shadows deleted + Double_t CumClus[21], CH4Clus[20]; // shadows deleted Double_t Wi; - Double_t ArPerc, CO2Perc, CH4Perc; // volume percentages - Double_t ArWPerc, CO2WPerc, CH4WPerc; // weight percentages - Double_t pSTP; // pressure (STP reference) - Double_t Radius; // straw radius - Double_t AAr; // Argon - Double_t ZAr; // Argon - Double_t RhoAr; // g/cm3 (1.78 mg/cm3) - Double_t NclAr; // clusters/cm + Double_t ArPerc, CO2Perc, CH4Perc; // volume percentages + Double_t ArWPerc, CO2WPerc, CH4WPerc; // weight percentages + Double_t pSTP; // pressure (STP reference) + Double_t Radius; // straw radius + Double_t AAr; // Argon + Double_t ZAr; // Argon + Double_t RhoAr; // g/cm3 (1.78 mg/cm3) + Double_t NclAr; // clusters/cm Double_t EmedAr; Double_t EminAr; Double_t EmpAr; Double_t CsiAr; - Double_t IAr; // ionization potential (188 eV) - Double_t WiAr; // energy to reate an ion pair in Argon - Double_t Ncl; // mean number of cluster in the mixture - Double_t Ecl; // electron per cluster - Double_t Lcl; // mean free path between clusters - Double_t Ntote; // mean total number of eletrons - Double_t GasGain; // gain of the gas - Double_t Cutoff; // limit the number of primry electrons + Double_t IAr; // ionization potential (188 eV) + Double_t WiAr; // energy to reate an ion pair in Argon + Double_t Ncl; // mean number of cluster in the mixture + Double_t Ecl; // electron per cluster + Double_t Lcl; // mean free path between clusters + Double_t Ntote; // mean total number of eletrons + Double_t GasGain; // gain of the gas + Double_t Cutoff; // limit the number of primry electrons // CO2 Double_t EmedCO2; Double_t EminCO2; Double_t EmpCO2; Double_t CsiCO2; - Double_t ACO2; // CO2 (39.948) - Double_t ZCO2; // CO2 (18) - Double_t RhoCO2; // g/cm3 CO2 (1.98 mg/cm3) - Double_t ICO2; // ionization potential (GeV) (188 eV) - Double_t WiCO2; // energy to create an ion pair - Double_t NclCO2; // clusters/cm + Double_t ACO2; // CO2 (39.948) + Double_t ZCO2; // CO2 (18) + Double_t RhoCO2; // g/cm3 CO2 (1.98 mg/cm3) + Double_t ICO2; // ionization potential (GeV) (188 eV) + Double_t WiCO2; // energy to create an ion pair + Double_t NclCO2; // clusters/cm // Methane CH4 ------------------------------------------------ Double_t EmedCH4; Double_t EmpCH4; Double_t CsiCH4; Double_t EminCH4; - Double_t ACH4; // CO2 (39.948) - Double_t ZCH4; // CO2 (18) - Double_t RhoCH4; // g/cm3 CO2 (0.71 mg/cm3) - Double_t ICH4; // ionization potential (GeV) (188 eV) - Double_t WiCH4; // energy to create an ion pair - Double_t NclCH4; // clusters/cm + Double_t ACH4; // CO2 (39.948) + Double_t ZCH4; // CO2 (18) + Double_t RhoCH4; // g/cm3 CO2 (0.71 mg/cm3) + Double_t ICH4; // ionization potential (GeV) (188 eV) + Double_t WiCH4; // energy to create an ion pair + Double_t NclCH4; // clusters/cm Double_t RhoMixCO2; Double_t RhoMixCH4; //---------------------------------------------------------------------- // Input for the particle (Gev, energy loses in Kev - Double_t PZeta; // charge - Double_t piMass; // particle mass (GeV) - Double_t PMass; // incident particle mass - Double_t PMom; // particle momentum (GeV) - Double_t Dx; // distance travelled in gas (cm) - Double_t eMass; // electron mass (GeV) (0.511 MeV) - Double_t prMass; // proton mass - Double_t Delta; // polarization Sternheimer parameter - Int_t CNumb; // current number of clusters + Double_t PZeta; // charge + Double_t piMass; // particle mass (GeV) + Double_t PMass; // incident particle mass + Double_t PMom; // particle momentum (GeV) + Double_t Dx; // distance travelled in gas (cm) + Double_t eMass; // electron mass (GeV) (0.511 MeV) + Double_t prMass; // proton mass + Double_t Delta; // polarization Sternheimer parameter + Int_t CNumb; // current number of clusters // ------------------------------------------------------ // quantities for each track // calculated in TInit - Double_t PEn; // particle energy GeV + Double_t PEn; // particle energy GeV Double_t beta; Double_t gamma; - Double_t Emed; // GeV - Double_t Emin; // GeV/cm (2.7 keV) + Double_t Emed; // GeV + Double_t Emin; // GeV/cm (2.7 keV) Double_t Csi; Double_t Emax; - Double_t Emp; // most probable energy - Int_t NNClus; // number of clusters + Double_t Emp; // most probable energy + Int_t NNClus; // number of clusters // --------------------------------------------------------------------- // mathematical and statistical parameters @@ -255,21 +255,21 @@ class CbmMustSingleStraw : public TNamed { Double_t Xmax; Double_t bPolya; Double_t Calpha, Cbeta, Cgamma; - Double_t NUrban; // total number of collision in the Urban model - Double_t SigUrb; // std dev of the Urban distribution (routine STUrban) - Double_t Eup; // upper limit of the Urban distribution (routine STUrban) - Double_t AvUrb; // average of the Urban distribution (routine STUrban) + Double_t NUrban; // total number of collision in the Urban model + Double_t SigUrb; // std dev of the Urban distribution (routine STUrban) + Double_t Eup; // upper limit of the Urban distribution (routine STUrban) + Double_t AvUrb; // average of the Urban distribution (routine STUrban) // -------------------------------------------------------------- // for the straws - Double_t Wx1, Wy1, Wz1, Wx2, Wy2, Wz2; // wire coordinates - Double_t Wp, Wq, Wr; // director cosine of the wire + Double_t Wx1, Wy1, Wz1, Wx2, Wy2, Wz2; // wire coordinates + Double_t Wp, Wq, Wr; // director cosine of the wire Double_t PulseMax; Double_t PulseTime; - Double_t Thresh1; // first threshold + Double_t Thresh1; // first threshold Double_t Thresh2; - Int_t Nchann; // number of channels for the straw signal + Int_t Nchann; // number of channels for the straw signal // ---------------------------------------------------------------------- // dummy diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx index 820ab6f978..b72c53e057 100644 --- a/core/detectors/must/CbmMustStation.cxx +++ b/core/detectors/must/CbmMustStation.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustStation.cxx *@author R.Karabowicz <r.karabowicz@gsi.de> @@ -13,7 +13,7 @@ **/ #include "CbmMustStation.h" -#include "CbmMustLayer.h" // for CbmMustLayer +#include "CbmMustLayer.h" // for CbmMustLayer #include <Logger.h> // for LOG @@ -21,68 +21,56 @@ #include <TObjArray.h> // for TObjArray // ----- Default constructor ------------------------------------------- -CbmMustStation::CbmMustStation() - : TObject() - , fDetectorId(0) - , fZ(0.) - , fLayers() -{ -} +CbmMustStation::CbmMustStation() : TObject(), fDetectorId(0), fZ(0.), fLayers() {} // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ -CbmMustStation::CbmMustStation(int iStation, double z) - : TObject() - , fDetectorId(iStation*1e7) - , fZ(z) - , fLayers() -{ -} +CbmMustStation::CbmMustStation(int iStation, double z) : TObject(), fDetectorId(iStation * 1e7), fZ(z), fLayers() {} // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmMustStation::~CbmMustStation() {} // ------------------------------------------------------------------------- -CbmMustTube* CbmMustStation::GetTube(int detid) { - int layerid = detid / 1e5 - 1; - CbmMustLayer* tempLay = GetLayer(layerid); - // LOG(info) << "trying to get tube " << detid % 100000 << " from layer " << layerid; - return tempLay ? tempLay->GetTube(detid % 100000) : nullptr; +CbmMustTube* CbmMustStation::GetTube(int detid) +{ + int layerid = detid / 1e5 - 1; + CbmMustLayer* tempLay = GetLayer(layerid); + // LOG(info) << "trying to get tube " << detid % 100000 << " from layer " << layerid; + return tempLay ? tempLay->GetTube(detid % 100000) : nullptr; } // ----- Public method AddSector --------------------------------------- CbmMustLayer* CbmMustStation::FindLayer(int detid) { - for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { - CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj)); - if ( tempLayer->GetDetectorId() == detid ) - return tempLayer; - } - return nullptr; + for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { + CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj)); + if (tempLayer->GetDetectorId() == detid) return tempLayer; + } + return nullptr; } // ------------------------------------------------------------------------- // ----- Public method AddSector --------------------------------------- bool CbmMustStation::AddLayer(CbmMustLayer* layer) { - for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { - CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj)); - if ( tempLayer->GetDetectorId() == layer->GetDetectorId() ) - return false; - } + for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { + CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj)); + if (tempLayer->GetDetectorId() == layer->GetDetectorId()) return false; + } - fLayers.Add(layer); - return true; + fLayers.Add(layer); + return true; } // ------------------------------------------------------------------------- -void CbmMustStation::Show() { - LOG(info) << " Station " << fDetectorId << " (@ z = " << fZ << "):"; - for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { - CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj)); - tempLayer->Show(); - } +void CbmMustStation::Show() +{ + LOG(info) << " Station " << fDetectorId << " (@ z = " << fZ << "):"; + for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) { + CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj)); + tempLayer->Show(); + } } ClassImp(CbmMustStation) diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h index c9a6d8fa08..9f9ad649b3 100644 --- a/core/detectors/must/CbmMustStation.h +++ b/core/detectors/must/CbmMustStation.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ /** CbmMustStation.h *@author R.Karabowicz <r.karabowicz@gsi.de> @@ -18,15 +18,14 @@ #define CBMMUSTSTATION_H 1 #include "CbmMustLayer.h" // for CbmMustLayer - #include "CbmMustTube.h" -#include <Rtypes.h> // for THashConsistencyHolder, ClassDef -#include <TObjArray.h> // for TObjArray -#include <TObject.h> // for TObject +#include <Rtypes.h> // for THashConsistencyHolder, ClassDef +#include <TObjArray.h> // for TObjArray +#include <TObject.h> // for TObject class CbmMustStation : public TObject { -public: + public: /** Default constructor **/ CbmMustStation(); @@ -47,18 +46,18 @@ public: int GetNLayers() const { return fLayers.GetEntriesFast(); } CbmMustTube* GetTube(int detid); - + CbmMustLayer* GetLayer(int iLayer) const { return (CbmMustLayer*) fLayers.At(iLayer); } /** Add one sector to the array **/ - CbmMustLayer* FindLayer(int detid); - bool AddLayer(CbmMustLayer* layer); - void Show(); - -protected: - int fDetectorId; // Unique detector ID - double fZ; // z position of station center (midplane) [cm] in global cs - TObjArray fLayers; // Array of CbmMustLayers + CbmMustLayer* FindLayer(int detid); + bool AddLayer(CbmMustLayer* layer); + void Show(); + + protected: + int fDetectorId; // Unique detector ID + double fZ; // z position of station center (midplane) [cm] in global cs + TObjArray fLayers; // Array of CbmMustLayers ClassDef(CbmMustStation, 1); }; #endif diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx index 2e02d66f4e..0481e23ccd 100644 --- a/core/detectors/must/CbmMustTube.cxx +++ b/core/detectors/must/CbmMustTube.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmMustTube header file @@ -14,7 +14,12 @@ // standard #include <iostream> -CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(0), fRadOut(0), fHalfLength(0) +CbmMustTube::CbmMustTube() + : fCenPosition(TVector3(0, 0, 0)) + , fRotationMatrix(TMatrixT<double>(3, 3)) + , fRadIn(0) + , fRadOut(0) + , fHalfLength(0) { fRotationMatrix[0][0] = -1.; fRotationMatrix[0][1] = -1.; @@ -29,16 +34,29 @@ CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TM fRotationMatrix[2][2] = -1.; } -CbmMustTube::CbmMustTube(CbmMustTube &tube) - : TObject(tube), fTubeNumber(tube.GetTubeNumber()), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength()) +CbmMustTube::CbmMustTube(CbmMustTube& tube) + : TObject(tube) + , fTubeNumber(tube.GetTubeNumber()) + , fCenPosition(tube.GetPosition()) + , fRotationMatrix(TMatrixT<double>(3, 3)) + , fRadIn(tube.GetRadIn()) + , fRadOut(tube.GetRadOut()) + , fHalfLength(tube.GetHalfLength()) { fRotationMatrix.ResizeTo(3, 3); fRotationMatrix = tube.GetRotationMatrix(); } -CbmMustTube::CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, - Double_t r33, Double_t radin, Double_t radout, Double_t hl) - : fDetectorId(detectorId), fTubeNumber(tubeNumber), fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl) +CbmMustTube::CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, + Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, + Double_t r33, Double_t radin, Double_t radout, Double_t hl) + : fDetectorId(detectorId) + , fTubeNumber(tubeNumber) + , fCenPosition(TVector3(x, y, z)) + , fRotationMatrix(TMatrixT<double>(3, 3)) + , fRadIn(radin) + , fRadOut(radout) + , fHalfLength(hl) { fRotationMatrix[0][0] = r11; @@ -60,42 +78,26 @@ CbmMustTube::~CbmMustTube() // fRotationMatrix.Delete(); } -TVector3 CbmMustTube::GetPosition() const -{ - return fCenPosition; -} +TVector3 CbmMustTube::GetPosition() const { return fCenPosition; } -TMatrixT<Double_t> CbmMustTube::GetRotationMatrix() const -{ - return fRotationMatrix; -} +TMatrixT<Double_t> CbmMustTube::GetRotationMatrix() const { return fRotationMatrix; } -Double_t CbmMustTube::GetRadIn() const -{ - return fRadIn; -} +Double_t CbmMustTube::GetRadIn() const { return fRadIn; } -Double_t CbmMustTube::GetRadOut() const -{ - return fRadOut; -} +Double_t CbmMustTube::GetRadOut() const { return fRadOut; } -Double_t CbmMustTube::GetHalfLength() const -{ - return fHalfLength; -} +Double_t CbmMustTube::GetHalfLength() const { return fHalfLength; } TVector3 CbmMustTube::GetWireDirection() const { return TVector3(-fRotationMatrix[0][1], fRotationMatrix[1][1], fRotationMatrix[2][1]); } -Int_t CbmMustTube::Compare(const TObject *obj) const { - if ( ((CbmMustTube*)obj)->GetTubeNumber() == this->GetTubeNumber() ) - return 0; - if ( ((CbmMustTube*)obj)->GetTubeNumber() < this->GetTubeNumber() ) - return 1; - return -1; +Int_t CbmMustTube::Compare(const TObject* obj) const +{ + if (((CbmMustTube*) obj)->GetTubeNumber() == this->GetTubeNumber()) return 0; + if (((CbmMustTube*) obj)->GetTubeNumber() < this->GetTubeNumber()) return 1; + return -1; } ClassImp(CbmMustTube) diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h index 71f189c3a8..ae5d3bf291 100644 --- a/core/detectors/must/CbmMustTube.h +++ b/core/detectors/must/CbmMustTube.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmMustTube header file @@ -14,43 +14,44 @@ #define CBMMUSTTUBE_H 1 // from ROOT -#include "TVector3.h" #include "TMatrixT.h" #include "TObject.h" +#include "TVector3.h" class CbmMustTube : public TObject { -public: - /** Default constructor **/ - CbmMustTube(); - CbmMustTube(CbmMustTube &tube); - - ~CbmMustTube(); - CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33, - Double_t radin, Double_t radout, Double_t hl); - - int GetDetectorId() const {return fDetectorId;} - int GetTubeNumber() const {return fTubeNumber;} - TVector3 GetPosition() const; - TMatrixT<Double_t> GetRotationMatrix() const; - Double_t GetRadIn() const; - Double_t GetRadOut() const; - Double_t GetHalfLength() const; - TVector3 GetWireDirection() const; - - bool IsSkew() const { return (0. != GetWireDirection().X()); } - - Int_t Compare(const TObject *obj) const override; - Bool_t IsSortable() const override {return kTRUE;} - -private: - int fDetectorId {0}; - int fTubeNumber {0}; - TVector3 fCenPosition; - TMatrixT<double> fRotationMatrix; - Double_t fRadIn, fRadOut, fHalfLength; - - ClassDef(CbmMustTube, 1); + public: + /** Default constructor **/ + CbmMustTube(); + CbmMustTube(CbmMustTube& tube); + + ~CbmMustTube(); + CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, + Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33, + Double_t radin, Double_t radout, Double_t hl); + + int GetDetectorId() const { return fDetectorId; } + int GetTubeNumber() const { return fTubeNumber; } + TVector3 GetPosition() const; + TMatrixT<Double_t> GetRotationMatrix() const; + Double_t GetRadIn() const; + Double_t GetRadOut() const; + Double_t GetHalfLength() const; + TVector3 GetWireDirection() const; + + bool IsSkew() const { return (0. != GetWireDirection().X()); } + + Int_t Compare(const TObject* obj) const override; + Bool_t IsSortable() const override { return kTRUE; } + + private: + int fDetectorId{0}; + int fTubeNumber{0}; + TVector3 fCenPosition; + TMatrixT<double> fRotationMatrix; + Double_t fRadIn, fRadOut, fHalfLength; + + ClassDef(CbmMustTube, 1); }; #endif diff --git a/macro/must/run_digi.C b/macro/must/run_digi.C index 08b194da79..81a01e16f4 100644 --- a/macro/must/run_digi.C +++ b/macro/must/run_digi.C @@ -1,5 +1,10 @@ +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radosław Karabowicz [committer] */ + #include <TStopwatch.h> #include <TString.h> + #include <iostream> #include <memory> @@ -8,79 +13,79 @@ using std::endl; void run_digi() { - FairLogger* logger = FairLogger::GetLogger(); - // logger->SetLogFileName("MyLog.log"); - // logger->SetLogToScreen(kTRUE); - // logger->SetLogToFile(kTRUE); - logger->SetLogVerbosityLevel("LOW"); - // logger->SetLogFileLevel("DEBUG4"); - // logger->SetLogScreenLevel("DEBUG"); - - // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) - Int_t iVerbose = 0; // just forget about it, for the moment - - // Input file (MC events) - TString inFile = "points.root"; - - // Parameter file - TString parFile = "params.root"; - - // Output file - TString outFile = "digis.root"; - - // ----- Timer -------------------------------------------------------- - TStopwatch timer; - - // ----- Reconstruction run ------------------------------------------- - FairRunAna run{}; - FairFileSource* fFileSource = new FairFileSource(inFile); - run.SetSource(fFileSource); - run.SetSink(std::make_unique<FairRootFileSink>(outFile)); - run.SetUseFairLinks(kTRUE); - FairLinkManager::Instance()->AddIncludeType(0); - // FairLinkManager::Instance()->AddIncludeType(1); - run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file - - FairRuntimeDb* rtdb = run.GetRuntimeDb(); - FairParRootFileIo* parInput1 = new FairParRootFileIo(); - parInput1->open(parFile.Data()); - rtdb->setFirstInput(parInput1); - - // ----- TorinoDetector hit producers --------------------------------- - CbmMustDigitize* digiTask = new CbmMustDigitize(); - run.AddTask(digiTask); - - run.Init(); - - timer.Start(); - run.Run(); - - // ----- Finish ------------------------------------------------------- - - cout << endl << endl; - - // Extract the maximal used memory an add is as Dart measurement - // This line is filtered by CTest and the value send to CDash - FairSystemInfo sysInfo; - Float_t maxMemory = sysInfo.GetMaxMemory(); - cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; - cout << maxMemory; - cout << "</DartMeasurement>" << endl; - - timer.Stop(); - Double_t rtime = timer.RealTime(); - Double_t ctime = timer.CpuTime(); - - Float_t cpuUsage = ctime / rtime; - cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; - cout << cpuUsage; - cout << "</DartMeasurement>" << endl; - - cout << endl << endl; - cout << "Output file is " << outFile << endl; - cout << "Parameter file is " << parFile << endl; - cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; - cout << "Macro finished successfully." << endl; - - // ------------------------------------------------------------------------ + FairLogger* logger = FairLogger::GetLogger(); + // logger->SetLogFileName("MyLog.log"); + // logger->SetLogToScreen(kTRUE); + // logger->SetLogToFile(kTRUE); + logger->SetLogVerbosityLevel("LOW"); + // logger->SetLogFileLevel("DEBUG4"); + // logger->SetLogScreenLevel("DEBUG"); + + // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) + Int_t iVerbose = 0; // just forget about it, for the moment + + // Input file (MC events) + TString inFile = "points.root"; + + // Parameter file + TString parFile = "params.root"; + + // Output file + TString outFile = "digis.root"; + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + + // ----- Reconstruction run ------------------------------------------- + FairRunAna run{}; + FairFileSource* fFileSource = new FairFileSource(inFile); + run.SetSource(fFileSource); + run.SetSink(std::make_unique<FairRootFileSink>(outFile)); + run.SetUseFairLinks(kTRUE); + FairLinkManager::Instance()->AddIncludeType(0); + // FairLinkManager::Instance()->AddIncludeType(1); + run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + + FairRuntimeDb* rtdb = run.GetRuntimeDb(); + FairParRootFileIo* parInput1 = new FairParRootFileIo(); + parInput1->open(parFile.Data()); + rtdb->setFirstInput(parInput1); + + // ----- TorinoDetector hit producers --------------------------------- + CbmMustDigitize* digiTask = new CbmMustDigitize(); + run.AddTask(digiTask); + + run.Init(); + + timer.Start(); + run.Run(); + + // ----- Finish ------------------------------------------------------- + + cout << endl << endl; + + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + cout << maxMemory; + cout << "</DartMeasurement>" << endl; + + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + + Float_t cpuUsage = ctime / rtime; + cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + cout << cpuUsage; + cout << "</DartMeasurement>" << endl; + + cout << endl << endl; + cout << "Output file is " << outFile << endl; + cout << "Parameter file is " << parFile << endl; + cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; + cout << "Macro finished successfully." << endl; + + // ------------------------------------------------------------------------ } diff --git a/macro/must/run_hit.C b/macro/must/run_hit.C index 3d192fb5dd..de6a780034 100644 --- a/macro/must/run_hit.C +++ b/macro/must/run_hit.C @@ -1,5 +1,10 @@ +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Radosław Karabowicz [committer] */ + #include <TStopwatch.h> #include <TString.h> + #include <iostream> #include <memory> @@ -8,79 +13,79 @@ using std::endl; void run_hit() { - FairLogger* logger = FairLogger::GetLogger(); - // logger->SetLogFileName("MyLog.log"); - // logger->SetLogToScreen(kTRUE); - // logger->SetLogToFile(kTRUE); - logger->SetLogVerbosityLevel("LOW"); - // logger->SetLogFileLevel("DEBUG4"); - // logger->SetLogScreenLevel("DEBUG"); - - // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) - Int_t iVerbose = 0; // just forget about it, for the moment - - // Input file (MC events) - TString inFile = "digis.root"; - - // Parameter file - TString parFile = "params.root"; - - // Output file - TString outFile = "hits.root"; - - // ----- Timer -------------------------------------------------------- - TStopwatch timer; - - // ----- Reconstruction run ------------------------------------------- - FairRunAna run{}; - FairFileSource* fFileSource = new FairFileSource(inFile); - run.SetSource(fFileSource); - run.SetSink(std::make_unique<FairRootFileSink>(outFile)); - run.SetUseFairLinks(kTRUE); - FairLinkManager::Instance()->AddIncludeType(0); - // FairLinkManager::Instance()->AddIncludeType(1); - run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file - - FairRuntimeDb* rtdb = run.GetRuntimeDb(); - FairParRootFileIo* parInput1 = new FairParRootFileIo(); - parInput1->open(parFile.Data()); - rtdb->setFirstInput(parInput1); - - // ----- TorinoDetector hit producers --------------------------------- - CbmMustFindHits* hitTask = new CbmMustFindHits(); - run.AddTask(hitTask); - - run.Init(); - - timer.Start(); - run.Run(); - - // ----- Finish ------------------------------------------------------- - - cout << endl << endl; - - // Extract the maximal used memory an add is as Dart measurement - // This line is filtered by CTest and the value send to CDash - FairSystemInfo sysInfo; - Float_t maxMemory = sysInfo.GetMaxMemory(); - cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; - cout << maxMemory; - cout << "</DartMeasurement>" << endl; - - timer.Stop(); - Double_t rtime = timer.RealTime(); - Double_t ctime = timer.CpuTime(); - - Float_t cpuUsage = ctime / rtime; - cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; - cout << cpuUsage; - cout << "</DartMeasurement>" << endl; - - cout << endl << endl; - cout << "Output file is " << outFile << endl; - cout << "Parameter file is " << parFile << endl; - cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; - cout << "Macro finished successfully." << endl; - - // ------------------------------------------------------------------------ + FairLogger* logger = FairLogger::GetLogger(); + // logger->SetLogFileName("MyLog.log"); + // logger->SetLogToScreen(kTRUE); + // logger->SetLogToFile(kTRUE); + logger->SetLogVerbosityLevel("LOW"); + // logger->SetLogFileLevel("DEBUG4"); + // logger->SetLogScreenLevel("DEBUG"); + + // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) + Int_t iVerbose = 0; // just forget about it, for the moment + + // Input file (MC events) + TString inFile = "digis.root"; + + // Parameter file + TString parFile = "params.root"; + + // Output file + TString outFile = "hits.root"; + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + + // ----- Reconstruction run ------------------------------------------- + FairRunAna run{}; + FairFileSource* fFileSource = new FairFileSource(inFile); + run.SetSource(fFileSource); + run.SetSink(std::make_unique<FairRootFileSink>(outFile)); + run.SetUseFairLinks(kTRUE); + FairLinkManager::Instance()->AddIncludeType(0); + // FairLinkManager::Instance()->AddIncludeType(1); + run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + + FairRuntimeDb* rtdb = run.GetRuntimeDb(); + FairParRootFileIo* parInput1 = new FairParRootFileIo(); + parInput1->open(parFile.Data()); + rtdb->setFirstInput(parInput1); + + // ----- TorinoDetector hit producers --------------------------------- + CbmMustFindHits* hitTask = new CbmMustFindHits(); + run.AddTask(hitTask); + + run.Init(); + + timer.Start(); + run.Run(); + + // ----- Finish ------------------------------------------------------- + + cout << endl << endl; + + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + cout << maxMemory; + cout << "</DartMeasurement>" << endl; + + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + + Float_t cpuUsage = ctime / rtime; + cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + cout << cpuUsage; + cout << "</DartMeasurement>" << endl; + + cout << endl << endl; + cout << "Output file is " << outFile << endl; + cout << "Parameter file is " << parFile << endl; + cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; + cout << "Macro finished successfully." << endl; + + // ------------------------------------------------------------------------ } diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C index 9364eb3224..07233784a2 100644 --- a/macro/must/run_sim.C +++ b/macro/must/run_sim.C @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0) { @@ -14,7 +14,7 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = TString tut_configdir = dir + "/sim/transport/gconfig/"; gSystem->Setenv("CONFIG_DIR", tut_configdir.Data()); - FairRunSim *fRun = new FairRunSim(); + FairRunSim* fRun = new FairRunSim(); // set the MC version used fRun->SetName("TGeant4"); @@ -39,9 +39,9 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = // Fill the Parameter containers for this run //------------------------------------------- - FairRuntimeDb *rtdb = fRun->GetRuntimeDb(); - Bool_t kParameterMerged = kTRUE; - FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged); + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + Bool_t kParameterMerged = kTRUE; + FairParRootFileIo* output = new FairParRootFileIo(kParameterMerged); output->open(parFile.c_str()); rtdb->setOutput(output); @@ -65,24 +65,23 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = FairModule* magnet = new CbmMagnet("MAGNET"); magnet->SetGeometryFileName(magnetGeom); fRun->AddModule(magnet); - - FairDetector *must = new CbmMust("MUST", kTRUE); + + FairDetector* must = new CbmMust("MUST", kTRUE); must->SetGeometryFileName("must/must_v24a_mcbm.geo.root"); fRun->AddModule(must); // Create and Set Event Generator //------------------------------- - FairPrimaryGenerator *primGen = new FairPrimaryGenerator(); + FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); // Box Generator - FairBoxGenerator *boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl. - if (p2 < 0.) - p2 = p1; - boxGen->SetPRange(p1, p2); // GeV/c //setPRange vs setPtRange + FairBoxGenerator* boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl. + if (p2 < 0.) p2 = p1; + boxGen->SetPRange(p1, p2); // GeV/c //setPRange vs setPtRange boxGen->SetPhiRange(270, 450); // Azimuth angle range [degree] - boxGen->SetThetaRange(6, 22); // Polar angle in lab system range [degree] + boxGen->SetThetaRange(6, 22); // Polar angle in lab system range [degree] boxGen->SetCosTheta(); boxGen->SetXYZ(0., 0., 0.); primGen->AddGenerator(boxGen); @@ -95,7 +94,7 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = magField->SetPosition(0., 0., fieldZ); magField->SetScale(fieldScale); fRun->SetField(magField); - + fRun->Init(); // Transport nEvents diff --git a/reco/detectors/must/CbmMustFindHits.cxx b/reco/detectors/must/CbmMustFindHits.cxx index 8ea5d929eb..8c86fb4e3a 100644 --- a/reco/detectors/must/CbmMustFindHits.cxx +++ b/reco/detectors/must/CbmMustFindHits.cxx @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ - + Authors: Radosław Karabowicz [committer] */ + // ------------------------------------------------------------------------- // ----- CbmMustFindHits source file ----- // ----- Created 2025-01-30 by R. Karabowicz ----- @@ -16,9 +16,7 @@ #include "CbmMustDigi.h" #include "CbmMustHit.h" #include "CbmMustTube.h" - #include "FairRootManager.h" - #include "TFile.h" #include "TMath.h" #include "TStopwatch.h" @@ -37,10 +35,7 @@ using std::setw; using std::vector; // ------------------------------------------------------------------------- -CbmMustFindHits::CbmMustFindHits() - : FairTask("MustFindHits", 1) -{ -} +CbmMustFindHits::CbmMustFindHits() : FairTask("MustFindHits", 1) {} // ----- Destructor ---------------------------------------------------- CbmMustFindHits::~CbmMustFindHits() {} @@ -49,30 +44,30 @@ CbmMustFindHits::~CbmMustFindHits() {} // ----- Task execution ------------------------------------------------ void CbmMustFindHits::Exec(Option_t* /*opt*/) { - assert(fDigiArray); - fHitArray->Delete(); - - // LOG(info) << "got " << fDigiArray->GetEntriesFast() << " points"; - for (Int_t iDigi = 0; iDigi < fDigiArray->GetEntriesFast(); iDigi++) { - const CbmMustDigi* digi = (const CbmMustDigi*) fDigiArray->At(iDigi); - if ( !digi ) LOG(info) << "no digi"; - auto isochrone = GetIsochrone(digi); - - // LOG(info) << "trying to get tube number " << digi->GetDetectorId(); - CbmMustTube* tube = fGeoScheme->GetTube(digi->GetDetectorId()); - if ( !tube ) LOG(info) << "no tube"; - - CbmMustHit* hit = new ((*fHitArray)[iDigi]) CbmMustHit(7,digi->GetDetectorId(), digi->GetSkewed(), 0, - tube->GetPosition(), {0.,0.,0.}, tube->GetWireDirection(), - digi->GetSignalTime(), isochrone.first, isochrone.second, digi->GetDepCharge()); - } + assert(fDigiArray); + fHitArray->Delete(); + + // LOG(info) << "got " << fDigiArray->GetEntriesFast() << " points"; + for (Int_t iDigi = 0; iDigi < fDigiArray->GetEntriesFast(); iDigi++) { + const CbmMustDigi* digi = (const CbmMustDigi*) fDigiArray->At(iDigi); + if (!digi) LOG(info) << "no digi"; + auto isochrone = GetIsochrone(digi); + + // LOG(info) << "trying to get tube number " << digi->GetDetectorId(); + CbmMustTube* tube = fGeoScheme->GetTube(digi->GetDetectorId()); + if (!tube) LOG(info) << "no tube"; + + CbmMustHit* hit = new ((*fHitArray)[iDigi]) CbmMustHit( + 7, digi->GetDetectorId(), digi->GetSkewed(), 0, tube->GetPosition(), {0., 0., 0.}, tube->GetWireDirection(), + digi->GetSignalTime(), isochrone.first, isochrone.second, digi->GetDepCharge()); + } } // ------------------------------------------------------------------------- // ----- Private function to get isochronoe ---------------------------- -std::pair<double,double> CbmMustFindHits::GetIsochrone(const CbmMustDigi* digi) +std::pair<double, double> CbmMustFindHits::GetIsochrone(const CbmMustDigi* digi) { - return std::pair<double,double> (digi->GetSignalTime()/400.,digi->GetSignalError()/400.); + return std::pair<double, double>(digi->GetSignalTime() / 400., digi->GetSignalError() / 400.); } // ------------------------------------------------------------------------- @@ -80,30 +75,30 @@ std::pair<double,double> CbmMustFindHits::GetIsochrone(const CbmMustDigi* digi) // ----- Initialisation ----------------------------------------------- InitStatus CbmMustFindHits::Init() { - FairRootManager* ioman = FairRootManager::Instance(); - if (!ioman) { - std::cout << "-E- CbmMustFindHits::Init: " /// todo replace with logger! - << "RootManager not instantiated!" << std::endl; - return kFATAL; - } - - fDigiArray = static_cast<TClonesArray*>(ioman->GetObject("MUSTDigi")); - if (!fDigiArray) { - std::cout << "-W- CbmMustFindHits::Init: " - << "No Digi array!" << std::endl; - return kERROR; - } - - // Create and register output array - fHitArray = new TClonesArray("CbmMustHit"); - ioman->Register("MUSTHit", "MUST", fHitArray, kTRUE); - - fGeoScheme = CbmMustGeoScheme::Instance(); - fGeoScheme->Init("$VMCWORKDIR/parameters/must/must_geoScheme.root"); - - fGeoScheme->Show(); - - return kSUCCESS; + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) { + std::cout << "-E- CbmMustFindHits::Init: " /// todo replace with logger! + << "RootManager not instantiated!" << std::endl; + return kFATAL; + } + + fDigiArray = static_cast<TClonesArray*>(ioman->GetObject("MUSTDigi")); + if (!fDigiArray) { + std::cout << "-W- CbmMustFindHits::Init: " + << "No Digi array!" << std::endl; + return kERROR; + } + + // Create and register output array + fHitArray = new TClonesArray("CbmMustHit"); + ioman->Register("MUSTHit", "MUST", fHitArray, kTRUE); + + fGeoScheme = CbmMustGeoScheme::Instance(); + fGeoScheme->Init("$VMCWORKDIR/parameters/must/must_geoScheme.root"); + + fGeoScheme->Show(); + + return kSUCCESS; } // ------------------------------------------------------------------------- diff --git a/reco/detectors/must/CbmMustFindHits.h b/reco/detectors/must/CbmMustFindHits.h index 5c2016730b..ce883f2a72 100644 --- a/reco/detectors/must/CbmMustFindHits.h +++ b/reco/detectors/must/CbmMustFindHits.h @@ -1,7 +1,7 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ - + Authors: Radosław Karabowicz [committer] */ + // ------------------------------------------------------------------------- // ----- CbmMustFindHits header file ----- // ----- Created 2025-01-30 by R. Karabowicz ----- @@ -17,29 +17,27 @@ #include "CbmMustDigi.h" #include "CbmMustGeoScheme.h" - #include "FairTask.h" - -#include "TString.h" #include "TClonesArray.h" +#include "TString.h" #include <vector> class CbmMustFindHits : public FairTask { public: CbmMustFindHits(); - virtual ~CbmMustFindHits(); + virtual ~CbmMustFindHits(); virtual void Exec(Option_t* opt); private: virtual InitStatus Init(); TString fDigiFile = "must_geoScheme.root"; // Digitization file - TClonesArray* fDigiArray {nullptr}; - TClonesArray* fHitArray {nullptr}; - CbmMustGeoScheme* fGeoScheme {nullptr}; // Geometry scheme + TClonesArray* fDigiArray{nullptr}; + TClonesArray* fHitArray{nullptr}; + CbmMustGeoScheme* fGeoScheme{nullptr}; // Geometry scheme - std::pair<double,double> GetIsochrone(const CbmMustDigi* digi); + std::pair<double, double> GetIsochrone(const CbmMustDigi* digi); CbmMustFindHits(const CbmMustFindHits&); CbmMustFindHits operator=(const CbmMustFindHits&); diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx index df2be2ed66..a82f025c17 100644 --- a/sim/detectors/must/CbmMust.cxx +++ b/sim/detectors/must/CbmMust.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmMust source file @@ -15,36 +15,36 @@ #include "CbmMust.h" // from CbmRoot, this library #include "CbmDefs.h" -#include "CbmGeoMustPar.h" #include "CbmGeoMust.h" +#include "CbmGeoMustPar.h" #include "CbmMustGeoScheme.h" -#include "CbmMustStation.h" #include "CbmMustLayer.h" #include "CbmMustModule.h" +#include "CbmMustStation.h" #include "CbmMustTube.h" #include "CbmStack.h" // from CbmRoot #include "CbmGeometryUtils.h" // from FairRoot -#include <FairRun.h> #include <FairGeoInterface.h> #include <FairGeoLoader.h> #include <FairGeoNode.h> #include <FairGeoRootBuilder.h> +#include <FairLogger.h> #include <FairRootManager.h> +#include <FairRun.h> #include <FairRuntimeDb.h> #include <FairVolume.h> -#include <FairLogger.h> // from ROOT #include <TClonesArray.h> -#include <TLorentzVector.h> -#include <TParticle.h> -#include <TVirtualMC.h> #include <TGeoMatrix.h> -#include <TObjArray.h> -#include <TGeoTube.h> #include <TGeoMedium.h> +#include <TGeoTube.h> #include <TGeoVolume.h> +#include <TLorentzVector.h> +#include <TObjArray.h> +#include <TParticle.h> +#include <TVirtualMC.h> // standard #include <iostream> @@ -56,24 +56,63 @@ using std::string; // ----- Default constructor ------------------------------------------- CbmMust::CbmMust() - : fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0), fMomIn(0, 0, 0, 0), - fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0), fpostotin(0, 0, 0, 0), - fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0) + : fTrackID(0) + , fVolumeID(0) + , fPos(0, 0, 0, 0) + , fPosIn(0, 0, 0, 0) + , fPosOut(0, 0, 0, 0) + , fPosInLocal(0, 0, 0, 0) + , fPosOutLocal(0, 0, 0, 0) + , fMomIn(0, 0, 0, 0) + , fMomOut(0, 0, 0, 0) + , fTime(0) + , fLength(0) + , fELoss(0) + , fMass(0) + , fIsInitialized(kFALSE) + , fPosIndex(0) + , fMustCollection(nullptr) + , fpostot(0, 0, 0, 0) + , fpostotin(0, 0, 0, 0) + , fpostotout(0, 0, 0, 0) + , fPassNodes() + , valid(kFALSE) + , fGeoType(0) { fMustCollection = new TClonesArray("CbmMustPoint"); - fVerboseLevel = 0; + fVerboseLevel = 0; } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ -CbmMust::CbmMust(const char *name, Bool_t active) - : FairDetector(name, active), fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0), - fMomIn(0, 0, 0, 0), fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0), - fpostotin(0, 0, 0, 0), fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0) +CbmMust::CbmMust(const char* name, Bool_t active) + : FairDetector(name, active) + , fTrackID(0) + , fVolumeID(0) + , fPos(0, 0, 0, 0) + , fPosIn(0, 0, 0, 0) + , fPosOut(0, 0, 0, 0) + , fPosInLocal(0, 0, 0, 0) + , fPosOutLocal(0, 0, 0, 0) + , fMomIn(0, 0, 0, 0) + , fMomOut(0, 0, 0, 0) + , fTime(0) + , fLength(0) + , fELoss(0) + , fMass(0) + , fIsInitialized(kFALSE) + , fPosIndex(0) + , fMustCollection(nullptr) + , fpostot(0, 0, 0, 0) + , fpostotin(0, 0, 0, 0) + , fpostotout(0, 0, 0, 0) + , fPassNodes() + , valid(kFALSE) + , fGeoType(0) { fMustCollection = new TClonesArray("CbmMustPoint"); - fVerboseLevel = 0; - fGeoType = 1; // CHECK + fVerboseLevel = 0; + fGeoType = 1; // CHECK } // ------------------------------------------------------------------------- @@ -105,9 +144,9 @@ float CbmMust::GetSquaredDistanceFromWire() // ------------------------------------------------------------------------- // ----- Public method ProcessHits -------------------------------------- -Bool_t CbmMust::ProcessHits(FairVolume *vol) +Bool_t CbmMust::ProcessHits(FairVolume* vol) { - // LOG(info) << "ProcessHits called!"; + // LOG(info) << "ProcessHits called!"; // TParticle* particle = gMC->GetStack()->GetCurrentTrack(); //[R.K. 01/2017] unused variable? // TGeoMedium *medium = (TGeoMedium*) vol->getGeoNode()->getRootVolume()->GetMedium(); //[R.K. 01/2017] unused variable? // Double_t epsil = medium->GetParam(6); //[R.K. 01/2017] unused variable? @@ -123,14 +162,14 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) valid = kTRUE; // Set parameters at entrance of volume. Reset ELoss. - fELoss = 0.; - fTime = gMC->TrackTime() * 1.0e09; + fELoss = 0.; + fTime = gMC->TrackTime() * 1.0e09; fLength = gMC->TrackLength(); gMC->TrackPosition(fPos); gMC->TrackMomentum(fMomIn); - gMC->TrackPosition(fpostotin); // da cancellare - Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified - Double_t localPos[3] = {0., 0., 0.}; // stt1 modified + gMC->TrackPosition(fpostotin); // da cancellare + Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified + Double_t localPos[3] = {0., 0., 0.}; // stt1 modified globalPos[0] = fPos.X(); globalPos[1] = fPos.Y(); @@ -145,23 +184,21 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) // Create CbmMustPoint at exit of active volume -- but not into the wire if (gMC->IsTrackExiting() && valid == kTRUE) { - valid = kFALSE; - fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); - fVolumeID = static_cast<int>(ECbmModuleId::kEcal); // vol->getMCid(); + valid = kFALSE; + fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); + fVolumeID = static_cast<int>(ECbmModuleId::kEcal); // vol->getMCid(); if (fTrackID != 0) { - if (fVerboseLevel > 2) - LOG(info) << "[MUST] test Vol----------" << vol->getMCid(); - if (fVerboseLevel > 2) - LOG(info) << "fTrackID-----" << fTrackID; + if (fVerboseLevel > 2) LOG(info) << "[MUST] test Vol----------" << vol->getMCid(); + if (fVerboseLevel > 2) LOG(info) << "fTrackID-----" << fTrackID; } - fMass = gMC->TrackMass(); // mass (GeV) + fMass = gMC->TrackMass(); // mass (GeV) gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); - gMC->TrackPosition(fpostotout); // da cancellare - Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified - Double_t localPos[3] = {0., 0., 0.}; // stt1 modified + gMC->TrackPosition(fpostotout); // da cancellare + Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified + Double_t localPos[3] = {0., 0., 0.}; // stt1 modified gMC->Gdtom(localPos, globalPos, 1); @@ -176,86 +213,85 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) string volPath(gMC->CurrentVolPath()); - fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0); + fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., + (fpostotin.Z() + fpostotout.Z()) / 2., 0.0); LOG(debug) << " --> " << volPath; - string strawName = volPath.substr(volPath.find("strawAssembly_")+14,8); - int statId = 1; - int layerId = atoi(strawName.substr(1,2).c_str()); - int moduleId = atoi(strawName.substr(3,2).c_str()); - int strawId = atoi(strawName.substr(5,3).c_str()); - - if ( 1 == 0 ) { - CbmMustGeoScheme* mustGeoScheme = CbmMustGeoScheme::Instance(); - // add station - int detId = statId*1e7; - CbmMustStation* mustStation = mustGeoScheme->FindStation(detId); - if ( !mustStation ) { - LOG(info) << "STATION --> " << volPath; - string statPath = volPath.substr(0,volPath.find("/layer")); - LOG(info) << "STATION --> " << statPath; - mustGeoScheme->NavigateTo(statPath); - TVector3 globPos = mustGeoScheme->GetGlobal(); - mustStation = new CbmMustStation(statId,globPos[2]); // change z! - } - mustGeoScheme->AddStation(mustStation); - // add layer - detId = detId + layerId*1e5; - CbmMustLayer* mustLayer = mustStation->FindLayer(detId); - if ( !mustLayer ) { - LOG(info) << "LAYER --> " << volPath; - string layerPath = volPath.substr(0,volPath.find("/module")); - LOG(info) << "LAYER --> " << layerPath; - mustGeoScheme->NavigateTo(volPath); - TVector3 globPos = mustGeoScheme->GetGlobal(); - mustLayer = new CbmMustLayer(statId,layerId,globPos[2],globPos[2]-mustStation->GetZ()); - } - mustStation->AddLayer(mustLayer); - // add module - detId = detId + moduleId*1e3; - CbmMustModule* mustModule = mustLayer->FindModule(detId); - TVector3 directionVector(0.,1.,0.); - if ( layerId == 2 || layerId == 3 ) { - double angle = 5.*TMath::DegToRad(); - if ( layerId == 3 ) angle = -angle; - directionVector[0] = TMath::Sin(angle); - directionVector[1] = TMath::Cos(angle); - } - if ( !mustModule ) { - mustGeoScheme->NavigateTo(volPath); - TVector3 globPos = mustGeoScheme->GetGlobal(); - mustModule = new CbmMustModule(statId,layerId,moduleId,globPos,directionVector); - } - mustLayer->AddModule(mustModule); - // add tube - detId = detId + strawId; - CbmMustTube* mustTube = mustModule->FindTube(detId); - if ( !mustTube ) { - mustGeoScheme->NavigateTo(volPath); - TVector3 globPos = mustGeoScheme->GetGlobal(); - mustTube = new CbmMustTube(detId,strawId, - globPos[0],globPos[1],globPos[2], - directionVector[1],-directionVector[0],0., - directionVector[0], directionVector[1],0., - 0.,0.,1., - 0.0127,0.49,110.); - } - mustModule->AddTube(mustTube); + string strawName = volPath.substr(volPath.find("strawAssembly_") + 14, 8); + int statId = 1; + int layerId = atoi(strawName.substr(1, 2).c_str()); + int moduleId = atoi(strawName.substr(3, 2).c_str()); + int strawId = atoi(strawName.substr(5, 3).c_str()); + + if (1 == 0) { + CbmMustGeoScheme* mustGeoScheme = CbmMustGeoScheme::Instance(); + // add station + int detId = statId * 1e7; + CbmMustStation* mustStation = mustGeoScheme->FindStation(detId); + if (!mustStation) { + LOG(info) << "STATION --> " << volPath; + string statPath = volPath.substr(0, volPath.find("/layer")); + LOG(info) << "STATION --> " << statPath; + mustGeoScheme->NavigateTo(statPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustStation = new CbmMustStation(statId, globPos[2]); // change z! + } + mustGeoScheme->AddStation(mustStation); + // add layer + detId = detId + layerId * 1e5; + CbmMustLayer* mustLayer = mustStation->FindLayer(detId); + if (!mustLayer) { + LOG(info) << "LAYER --> " << volPath; + string layerPath = volPath.substr(0, volPath.find("/module")); + LOG(info) << "LAYER --> " << layerPath; + mustGeoScheme->NavigateTo(volPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustLayer = new CbmMustLayer(statId, layerId, globPos[2], globPos[2] - mustStation->GetZ()); + } + mustStation->AddLayer(mustLayer); + // add module + detId = detId + moduleId * 1e3; + CbmMustModule* mustModule = mustLayer->FindModule(detId); + TVector3 directionVector(0., 1., 0.); + if (layerId == 2 || layerId == 3) { + double angle = 5. * TMath::DegToRad(); + if (layerId == 3) angle = -angle; + directionVector[0] = TMath::Sin(angle); + directionVector[1] = TMath::Cos(angle); + } + if (!mustModule) { + mustGeoScheme->NavigateTo(volPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustModule = new CbmMustModule(statId, layerId, moduleId, globPos, directionVector); + } + mustLayer->AddModule(mustModule); + // add tube + detId = detId + strawId; + CbmMustTube* mustTube = mustModule->FindTube(detId); + if (!mustTube) { + mustGeoScheme->NavigateTo(volPath); + TVector3 globPos = mustGeoScheme->GetGlobal(); + mustTube = + new CbmMustTube(detId, strawId, globPos[0], globPos[1], globPos[2], directionVector[1], -directionVector[0], + 0., directionVector[0], directionVector[1], 0., 0., 0., 1., 0.0127, 0.49, 110.); + } + mustModule->AddTube(mustTube); } - LOG(debug) << " l/m/t = " << layerId << "/" << moduleId << "/" << strawId; + LOG(debug) << " l/m/t = " << layerId << "/" << moduleId << "/" << strawId; - AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()), - TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), - fTime, fLength, fELoss, fMass); + AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), + TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()), + TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), + TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, + fLength, fELoss, fMass); if (fTrackID != 0) { - if (fVerboseLevel > 2) - LOG(info) << "AddHit CbmMust.cxx= " << fTrackID; + if (fVerboseLevel > 2) LOG(info) << "AddHit CbmMust.cxx= " << fTrackID; } // Increment number of stt points for TParticle - CbmStack *stack = (CbmStack *)gMC->GetStack(); + CbmStack* stack = (CbmStack*) gMC->GetStack(); stack->AddPoint(ECbmModuleId::kEcal); ResetParameters(); } @@ -268,45 +304,41 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol) // ----- Public method EndOfEvent -------------------------------------- void CbmMust::EndOfEvent() { - if (fVerboseLevel) - Print(); + if (fVerboseLevel) Print(); fMustCollection->Delete(); fPosIndex = 0; - if ( 1 == 0 ) { - int nofTubes = 0; - TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations(); - for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) { - CbmMustStation* tempStation = (CbmMustStation*)(stations->At(iobj)); - for ( int ilay = 0 ; ilay < tempStation->GetNLayers() ; ilay++ ) { - CbmMustLayer* tempLayer = tempStation->GetLayer(ilay); - for ( int imod = 0 ; imod < tempLayer->GetNModules() ; imod++ ) { - CbmMustModule* tempModule = tempLayer->GetModule(imod); - tempModule->SortTubes(); - nofTubes += tempModule->GetNTubes(); - } - } + if (1 == 0) { + int nofTubes = 0; + TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations(); + for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) { + CbmMustStation* tempStation = (CbmMustStation*) (stations->At(iobj)); + for (int ilay = 0; ilay < tempStation->GetNLayers(); ilay++) { + CbmMustLayer* tempLayer = tempStation->GetLayer(ilay); + for (int imod = 0; imod < tempLayer->GetNModules(); imod++) { + CbmMustModule* tempModule = tempLayer->GetModule(imod); + tempModule->SortTubes(); + nofTubes += tempModule->GetNTubes(); + } } + } - LOG(info) << "got " << nofTubes << " tubes"; - if ( nofTubes == 256 && !fGeoSchemeSaved ) { - CbmMustGeoScheme::Instance()->Show(); - CbmMustGeoScheme::Instance()->StoreGeoScheme(); - fGeoSchemeSaved = true; - } + LOG(info) << "got " << nofTubes << " tubes"; + if (nofTubes == 256 && !fGeoSchemeSaved) { + CbmMustGeoScheme::Instance()->Show(); + CbmMustGeoScheme::Instance()->StoreGeoScheme(); + fGeoSchemeSaved = true; + } } } // ------------------------------------------------------------------------- // ----- Public method Register ---------------------------------------- -void CbmMust::Register() -{ - FairRootManager::Instance()->Register("MUSTPoint", "Must", fMustCollection, kTRUE); -} +void CbmMust::Register() { FairRootManager::Instance()->Register("MUSTPoint", "Must", fMustCollection, kTRUE); } // ------------------------------------------------------------------------- // ----- Public method GetCollection ----------------------------------- -TClonesArray *CbmMust::GetCollection(Int_t iColl) const +TClonesArray* CbmMust::GetCollection(Int_t iColl) const { if (iColl == 0) return fMustCollection; @@ -316,7 +348,7 @@ TClonesArray *CbmMust::GetCollection(Int_t iColl) const // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- -void CbmMust::Print(Option_t *) const +void CbmMust::Print(Option_t*) const { Int_t nHits = fMustCollection->GetEntriesFast(); @@ -337,17 +369,17 @@ void CbmMust::Reset() // ------------------------------------------------------------------------- // ----- Public method CopyClones -------------------------------------- -void CbmMust::CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) +void CbmMust::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) { Int_t nEntries = cl1->GetEntriesFast(); LOG(info) << " CbmMust: " << nEntries << " entries to add."; - TClonesArray &clref = *cl2; + TClonesArray& clref = *cl2; - CbmMustPoint *oldpoint = nullptr; + CbmMustPoint* oldpoint = nullptr; for (Int_t i = 0; i < nEntries; i++) { - oldpoint = (CbmMustPoint *)cl1->At(i); + oldpoint = (CbmMustPoint*) cl1->At(i); Int_t index = oldpoint->GetTrackID() + offset; @@ -373,73 +405,75 @@ void CbmMust::ConstructGeometry() // --- Only ROOT geometries are supported if (fileName.EndsWith(".root")) { - LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data(); - TGeoCombiTrans* fCombiTrans = NULL; - Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans); - return; + LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data(); + TGeoCombiTrans* fCombiTrans = NULL; + Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans); + return; } LOG(info) << "Constructing Must geometry from text file " << fileName.Data(); - FairGeoLoader *geoLoad = FairGeoLoader::Instance(); - FairGeoInterface *geoFace = geoLoad->getGeoInterface(); - CbmGeoMust *Geo = new CbmGeoMust(); + FairGeoLoader* geoLoad = FairGeoLoader::Instance(); + FairGeoInterface* geoFace = geoLoad->getGeoInterface(); + CbmGeoMust* Geo = new CbmGeoMust(); Geo->setGeomFile(GetGeometryFileName()); geoFace->addGeoModule(Geo); Bool_t rc = geoFace->readSet(Geo); - if (rc) - Geo->create(geoLoad->getGeoBuilder()); + if (rc) Geo->create(geoLoad->getGeoBuilder()); - TList *volList = Geo->getListOfVolumes(); + TList* volList = Geo->getListOfVolumes(); // store geo parameter - FairRun *fRun = FairRun::Instance(); - FairRuntimeDb *rtdb = FairRun::Instance()->GetRuntimeDb(); - CbmGeoMustPar *par; - par = (CbmGeoMustPar *)(rtdb->getContainer("CbmGeoMustPar")); + FairRun* fRun = FairRun::Instance(); + FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb(); + CbmGeoMustPar* par; + par = (CbmGeoMustPar*) (rtdb->getContainer("CbmGeoMustPar")); rtdb->getListOfContainers()->Print(); - TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); - fPassNodes = par->GetGeoPassiveNodes(); + TObjArray* fSensNodes = par->GetGeoSensitiveNodes(); + fPassNodes = par->GetGeoPassiveNodes(); TListIter iter(volList); - FairGeoNode *node = nullptr; - FairGeoVolume *aVol = nullptr; + FairGeoNode* node = nullptr; + FairGeoVolume* aVol = nullptr; - while ((node = (FairGeoNode *)iter.Next())) { - aVol = dynamic_cast<FairGeoVolume *>(node); + while ((node = (FairGeoNode*) iter.Next())) { + aVol = dynamic_cast<FairGeoVolume*>(node); // if (fGeoType == 2) // LOG(info) << "Volume " << aVol->GetName() << " is" << (node->isSensitive() ? "" : " not") << " sensitive"; if (node->isSensitive()) { fSensNodes->AddLast(aVol); - } else { + } + else { fPassNodes->AddLast(aVol); } } par->SetGeometryType(fGeoType); if (fGeoType == 1) { - par->SetTubeInRad(0.4903 / 2.); // cm - par->SetTubeOutRad(0.00127); // cm - } else { + par->SetTubeInRad(0.4903 / 2.); // cm + par->SetTubeOutRad(0.00127); // cm + } + else { LOG(fatal) << "[MUST] GeoType " << fGeoType << " not supported"; } par->setChanged(); par->setInputVersion(fRun->GetRunId(), 1); ProcessNodes(volList); - } // ------------------------------------------------------------------------- // ----- Private method AddHit ----------------------------------------- -CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, - TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass) +CbmMustPoint* CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, + TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t time, + Double_t length, Double_t eLoss, Double_t mass) { - TClonesArray &clref = *fMustCollection; + TClonesArray& clref = *fMustCollection; Int_t size = clref.GetEntriesFast(); - CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, layID, modID, strID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass); + CbmMustPoint* pointnew = new (clref[size]) CbmMustPoint(trackID, detID, layID, modID, strID, pos, posInLocal, + posOutLocal, momIn, momOut, time, length, eLoss, mass); return pointnew; } diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h index 03b6269e2e..dcc47e3046 100644 --- a/sim/detectors/must/CbmMust.h +++ b/sim/detectors/must/CbmMust.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ //////////////////////////////////////////////////////////////////////////// // CbmMust header file @@ -27,8 +27,8 @@ #include <TLorentzVector.h> #include <TVector3.h> // standard -#include <string> #include <sstream> +#include <string> class TClonesArray; class FairVolume; @@ -43,7 +43,7 @@ class CbmMust : public FairDetector { *@param name detetcor name *@param active sensitivity flag **/ - CbmMust(const char *name, Bool_t active); + CbmMust(const char* name, Bool_t active); /** Destructor **/ virtual ~CbmMust(); @@ -55,7 +55,7 @@ class CbmMust : public FairDetector { ** collection. *@param vol Pointer to the active volume **/ - virtual Bool_t ProcessHits(FairVolume *vol = 0) override; + virtual Bool_t ProcessHits(FairVolume* vol = 0) override; /** Virtual method EndOfEvent ** @@ -72,7 +72,10 @@ class CbmMust : public FairDetector { ** The decision is based on the volume name (has to contain "Sensor"). ** Virtual from FairModule. **/ - virtual Bool_t IsSensitive(const std::string& name) override { return (TString(name).Contains("active") ? kTRUE : kFALSE); } + virtual Bool_t IsSensitive(const std::string& name) override + { + return (TString(name).Contains("active") ? kTRUE : kFALSE); + } /** Virtual method Register ** @@ -81,13 +84,13 @@ class CbmMust : public FairDetector { virtual void Register() override; /** Accessor to the hit collection **/ - virtual TClonesArray *GetCollection(Int_t iColl) const override; + virtual TClonesArray* GetCollection(Int_t iColl) const override; /** Virtual method Print ** ** Screen output of hit collection. **/ - virtual void Print(Option_t * /*option*/ = "") const override; + virtual void Print(Option_t* /*option*/ = "") const override; /** Virtual method Reset ** @@ -104,7 +107,7 @@ class CbmMust : public FairDetector { *@param cl2 Target *@param offset Index offset **/ - virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override; + virtual void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override; /** Virtual method Construct geometry ** @@ -115,39 +118,40 @@ class CbmMust : public FairDetector { private: /** GFTrack information to be stored until the track leaves the active volume. **/ - Int_t fTrackID; //! track index - Int_t fVolumeID; //! volume id - TLorentzVector fPos; //! wire position in global frame - TLorentzVector fPosIn; //! entry position in global frame - TLorentzVector fPosOut; //! exit position in global frame - TLorentzVector fPosInLocal; //! entry position in straw frame - TLorentzVector fPosOutLocal; //! exit position in straw frame - TLorentzVector fMomIn; //! momentum - TLorentzVector fMomOut; //! momentum - Double_t fTime; //! time - Double_t fLength; //! length - Double_t fELoss; //! energy loss - Double_t fMass; //! particle mass + Int_t fTrackID; //! track index + Int_t fVolumeID; //! volume id + TLorentzVector fPos; //! wire position in global frame + TLorentzVector fPosIn; //! entry position in global frame + TLorentzVector fPosOut; //! exit position in global frame + TLorentzVector fPosInLocal; //! entry position in straw frame + TLorentzVector fPosOutLocal; //! exit position in straw frame + TLorentzVector fMomIn; //! momentum + TLorentzVector fMomOut; //! momentum + Double_t fTime; //! time + Double_t fLength; //! length + Double_t fELoss; //! energy loss + Double_t fMass; //! particle mass Bool_t fIsInitialized; - Int_t fPosIndex; //! - TClonesArray *fMustCollection; //! Hit collection - TLorentzVector fpostot; // global frame hit position (in)// da cancellare - TLorentzVector fpostotin; // global frame hit position (in)// da cancellare - TLorentzVector fpostotout; // global frame hit position (in)// da cancellare + Int_t fPosIndex; //! + TClonesArray* fMustCollection; //! Hit collection + TLorentzVector fpostot; // global frame hit position (in)// da cancellare + TLorentzVector fpostotin; // global frame hit position (in)// da cancellare + TLorentzVector fpostotout; // global frame hit position (in)// da cancellare - TObjArray *fPassNodes; //! + TObjArray* fPassNodes; //! // geometry type Bool_t valid; Int_t fGeoType; - bool fGeoSchemeSaved{false}; + bool fGeoSchemeSaved{false}; /** Private method AddHit ** ** Adds a CbmTrdPoint to the HitCollection **/ - CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, - TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass); + CbmMustPoint* AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, + TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t time, + Double_t length, Double_t eLoss, Double_t mass); /** Private method ResetParameters ** @@ -162,8 +166,8 @@ class CbmMust : public FairDetector { **/ float GetSquaredDistanceFromWire(); - CbmMust(const CbmMust &L); - CbmMust &operator=(const CbmMust &) { return *this; } + CbmMust(const CbmMust& L); + CbmMust& operator=(const CbmMust&) { return *this; } ClassDef(CbmMust, 1) }; @@ -177,15 +181,15 @@ inline void CbmMust::ResetParameters() fMomIn.SetXYZM(0.0, 0.0, 0.0, 0.0); fMomOut.SetXYZM(0.0, 0.0, 0.0, 0.0); fTime = fLength = fELoss = 0; - fPosIndex = 0; - fpostot.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare - fpostotin.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare - fpostotout.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare + fPosIndex = 0; + fpostot.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare + fpostotin.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare + fpostotout.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare fPosIn.SetXYZM(0.0, 0.0, 0.0, 0.0); fPosOut.SetXYZM(0.0, 0.0, 0.0, 0.0); - fMass = 0; + fMass = 0; fIsInitialized = kFALSE; - valid = kFALSE; + valid = kFALSE; } -#endif // CBMMUST_H +#endif // CBMMUST_H diff --git a/sim/detectors/must/CbmMustDigitize.cxx b/sim/detectors/must/CbmMustDigitize.cxx index 29739a03ca..9e3c402723 100644 --- a/sim/detectors/must/CbmMustDigitize.cxx +++ b/sim/detectors/must/CbmMustDigitize.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustDigitize source file ----- @@ -27,6 +27,7 @@ #include "FairRunAna.h" #include "FairRunSim.h" #include "FairRuntimeDb.h" + #include <Logger.h> // Includes from CbmRoot @@ -35,10 +36,7 @@ #include "CbmMustPoint.h" // ----- Standard constructor ------------------------------------------ -CbmMustDigitize::CbmMustDigitize() - : FairTask("MustDigitizer") -{ -} +CbmMustDigitize::CbmMustDigitize() : FairTask("MustDigitizer") {} // ------------------------------------------------------------------------- @@ -49,76 +47,72 @@ CbmMustDigitize::~CbmMustDigitize() {} // ----- Task execution ------------------------------------------------ void CbmMustDigitize::Exec(Option_t* /*opt*/) { - assert(fPointArray); - fDigiArray->Delete(); - - // LOG(info) << "got " << fPointArray->GetEntriesFast() << " points"; - for (Int_t iPoint = 0; iPoint < fPointArray->GetEntriesFast(); iPoint++) { - const CbmMustPoint* point = (const CbmMustPoint*) fPointArray->At(iPoint); - // LOG(info) << "point from " << point->GetXInLocal() << "," << point->GetYInLocal() << "," << point->GetZInLocal() - // << " to " << point->GetXOutLocal() << "," << point->GetYOutLocal() << "," << point->GetZOutLocal(); - int detectorId = 1e7 + point->GetLayerID()*1e5 + point->GetModuleID()*1e3 + point->GetStrawID(); - int skew = 0; - if ( point->GetLayerID() == 2 ) skew = 1; - if ( point->GetLayerID() == 3 ) skew = -11; - - double driftTime = GetDriftTime(point); - - // ideal output... - CbmMustDigi* digi = new ((*fDigiArray)[iPoint]) CbmMustDigi(detectorId, skew, driftTime, 5, 1); - } + assert(fPointArray); + fDigiArray->Delete(); + + // LOG(info) << "got " << fPointArray->GetEntriesFast() << " points"; + for (Int_t iPoint = 0; iPoint < fPointArray->GetEntriesFast(); iPoint++) { + const CbmMustPoint* point = (const CbmMustPoint*) fPointArray->At(iPoint); + // LOG(info) << "point from " << point->GetXInLocal() << "," << point->GetYInLocal() << "," << point->GetZInLocal() + // << " to " << point->GetXOutLocal() << "," << point->GetYOutLocal() << "," << point->GetZOutLocal(); + int detectorId = 1e7 + point->GetLayerID() * 1e5 + point->GetModuleID() * 1e3 + point->GetStrawID(); + int skew = 0; + if (point->GetLayerID() == 2) skew = 1; + if (point->GetLayerID() == 3) skew = -11; + + double driftTime = GetDriftTime(point); + + // ideal output... + CbmMustDigi* digi = new ((*fDigiArray)[iPoint]) CbmMustDigi(detectorId, skew, driftTime, 5, 1); + } } // ------------------------------------------------------------------------- // ----- Private function to get drift time ---------------------------- -double CbmMustDigitize::GetDriftTime(const CbmMustPoint* point) { - double closestDist = TMath::Sqrt((point->GetXInLocal()+point->GetXOutLocal())*(point->GetXInLocal()+point->GetXOutLocal())+ - (point->GetYInLocal()+point->GetYOutLocal())*(point->GetYInLocal()+point->GetYOutLocal())); - // LOG(info) << "closest distance = " << closestDist << " cm ---> " << closestDist*400. << " ns"; - return closestDist * 400.; +double CbmMustDigitize::GetDriftTime(const CbmMustPoint* point) +{ + double closestDist = + TMath::Sqrt((point->GetXInLocal() + point->GetXOutLocal()) * (point->GetXInLocal() + point->GetXOutLocal()) + + (point->GetYInLocal() + point->GetYOutLocal()) * (point->GetYInLocal() + point->GetYOutLocal())); + // LOG(info) << "closest distance = " << closestDist << " cm ---> " << closestDist*400. << " ns"; + return closestDist * 400.; } // ------------------------------------------------------------------------- // ----- Finish run --------------------------------------------------- -void CbmMustDigitize::Finish() -{ -} +void CbmMustDigitize::Finish() {} // ------------------------------------------------------------------------- // ----- Initialisation ----------------------------------------------- InitStatus CbmMustDigitize::Init() { - FairRootManager* ioman = FairRootManager::Instance(); - if (!ioman) { - std::cout << "-E- CbmMustDigitize::Init: " /// todo replace with logger! - << "RootManager not instantiated!" << std::endl; - return kFATAL; - } - - fPointArray = static_cast<TClonesArray*>(ioman->GetObject("MUSTPoint")); - if (!fPointArray) { - std::cout << "-W- CbmMustDigitize::Init: " - << "No Point array!" << std::endl; - return kERROR; - } - - // Create and register output array - fDigiArray = new TClonesArray("CbmMustDigi"); - ioman->Register("MUSTDigi", "MUST", fDigiArray, kTRUE); - - // Set static initialisation flag - fIsInitialised = kTRUE; - - return kSUCCESS; + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) { + std::cout << "-E- CbmMustDigitize::Init: " /// todo replace with logger! + << "RootManager not instantiated!" << std::endl; + return kFATAL; + } + + fPointArray = static_cast<TClonesArray*>(ioman->GetObject("MUSTPoint")); + if (!fPointArray) { + std::cout << "-W- CbmMustDigitize::Init: " + << "No Point array!" << std::endl; + return kERROR; + } + + // Create and register output array + fDigiArray = new TClonesArray("CbmMustDigi"); + ioman->Register("MUSTDigi", "MUST", fDigiArray, kTRUE); + + // Set static initialisation flag + fIsInitialised = kTRUE; + + return kSUCCESS; } // ------------------------------------------------------------------------- // ----- Private method ReInit ----------------------------------------- -InitStatus CbmMustDigitize::ReInit() -{ - - return kSUCCESS; -} +InitStatus CbmMustDigitize::ReInit() { return kSUCCESS; } // ------------------------------------------------------------------------- ClassImp(CbmMustDigitize) diff --git a/sim/detectors/must/CbmMustDigitize.h b/sim/detectors/must/CbmMustDigitize.h index 1d93491669..8a28b69f2d 100644 --- a/sim/detectors/must/CbmMustDigitize.h +++ b/sim/detectors/must/CbmMustDigitize.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ + Authors: Radosław Karabowicz [committer] */ // ------------------------------------------------------------------------- // ----- CbmMustDigitize header file ----- @@ -24,38 +24,38 @@ **/ class CbmMustDigitize : public FairTask { -public: - /** Constructor **/ - CbmMustDigitize(); - - /** Destructor **/ - virtual ~CbmMustDigitize(); + public: + /** Constructor **/ + CbmMustDigitize(); - /** Virtual method Exec **/ - void Exec(Option_t* opt) override; + /** Destructor **/ + virtual ~CbmMustDigitize(); - /** Re-initialisation **/ - virtual InitStatus ReInit(); + /** Virtual method Exec **/ + void Exec(Option_t* opt) override; -private: - Bool_t fIsInitialised; ///< kTRUE if Init() was called - - TClonesArray* fPointArray {nullptr}; ///< Input array of CbmMustPoint - TClonesArray* fDigiArray {nullptr}; + /** Re-initialisation **/ + virtual InitStatus ReInit(); - double GetDriftTime(const CbmMustPoint* point); + private: + Bool_t fIsInitialised; ///< kTRUE if Init() was called - /** End-of-run action **/ - void Finish() override; + TClonesArray* fPointArray{nullptr}; ///< Input array of CbmMustPoint + TClonesArray* fDigiArray{nullptr}; - /** Initialisation **/ - InitStatus Init() override; + double GetDriftTime(const CbmMustPoint* point); - /** Prevent usage of copy constructor and assignment operator **/ - CbmMustDigitize(const CbmMustDigitize&); - CbmMustDigitize operator=(const CbmMustDigitize&); + /** End-of-run action **/ + void Finish() override; - ClassDef(CbmMustDigitize, 1); + /** Initialisation **/ + InitStatus Init() override; + + /** Prevent usage of copy constructor and assignment operator **/ + CbmMustDigitize(const CbmMustDigitize&); + CbmMustDigitize operator=(const CbmMustDigitize&); + + ClassDef(CbmMustDigitize, 1); }; #endif -- GitLab From 783fa029f035db708d1fcce3edbabe7750706409 Mon Sep 17 00:00:00 2001 From: Radoslaw Karabowicz <r.karabowicz@gsi.de> Date: Fri, 7 Feb 2025 09:50:43 +0100 Subject: [PATCH 12/12] del(must): Remove obsolete classes MapCreator and SingleStraw --- core/detectors/must/CbmMustMapCreator.cxx | 442 ------ core/detectors/must/CbmMustMapCreator.h | 82 -- core/detectors/must/CbmMustSingleStraw.cxx | 1415 -------------------- core/detectors/must/CbmMustSingleStraw.h | 281 ---- 4 files changed, 2220 deletions(-) delete mode 100644 core/detectors/must/CbmMustMapCreator.cxx delete mode 100644 core/detectors/must/CbmMustMapCreator.h delete mode 100644 core/detectors/must/CbmMustSingleStraw.cxx delete mode 100644 core/detectors/must/CbmMustSingleStraw.h diff --git a/core/detectors/must/CbmMustMapCreator.cxx b/core/detectors/must/CbmMustMapCreator.cxx deleted file mode 100644 index e538e6dfbb..0000000000 --- a/core/detectors/must/CbmMustMapCreator.cxx +++ /dev/null @@ -1,442 +0,0 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ - -//////////////////////////////////////////////////////////////////////////// -// CbmMustMapCreator source file -// -// Mapper for MUST -// -// authors: Radoslaw Karabowicz, GSI, 2024 -// -// modified from CbmGeoFts by Nafija Ibrišimović in 2023 -//////////////////////////////////////////////////////////////////////////// - -// from CbmRoot, this library -#include "CbmMustMapCreator.h" - -#include "CbmGeoMustPar.h" -#include "CbmMustTube.h" -// from FairRoot -#include <FairGeoNode.h> -#include <FairGeoRotation.h> -#include <FairGeoTransform.h> -#include <FairGeoTube.h> -#include <FairGeoVector.h> -#include <FairGeoVolume.h> -// from ROOT -#include <FairRootManager.h> - -#include <TClonesArray.h> -#include <TGeoTube.h> -#include <TGeoVolume.h> -#include <TObjArray.h> -#include <TString.h> -#include <TVector3.h> -// standard -#include <fstream> -#include <iostream> - -using namespace std; - -CbmMustMapCreator::CbmMustMapCreator() - : fGeoType(0) - , fTubeInRad(0) - , fTubeOutRad(0) - , fMustParameters(new CbmGeoMustPar()) -{ -} - -// CbmMustMapCreator::CbmMustMapCreator(){} -// to use in CbmMust -CbmMustMapCreator::CbmMustMapCreator(Int_t geoType) - : fGeoType(geoType) - , fTubeInRad(0) - , fTubeOutRad(0) - , fMustParameters(new CbmGeoMustPar("CbmGeoMustPar", "MUST Geometry Parameters")) -{ - if (fGeoType != 1) LOG(fatal) << "[MUST] CbmMustMapCreator. Geometry " << fGeoType << " not supported by map"; - // cout << "Creating mapper with geotype = " << fGeoType << endl; - // cout << "fMustParameters name is " << fMustParameters->GetName() << endl; -} - -CbmMustMapCreator::CbmMustMapCreator(CbmGeoMustPar* mustPar) : fMustParameters(mustPar) -{ - fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius - fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius - // choose geometry type - fGeoType = mustPar->GetGeometryType(); // classic, optimized, average, detailed, CAD - // cout << "Creating map with geoType = " << fGeoType << ", radius = " << fTubeInRad << " / " << fTubeOutRad << endl; -} - -CbmMustMapCreator::~CbmMustMapCreator() {} - -void CbmMustMapCreator::SetGeneralParameters() -{ // CHECK whether it depends on geometry or not - fTubeInRad = fMustParameters->GetTubeInRad(); // tube inner radius - fTubeOutRad = fMustParameters->GetTubeOutRad(); // tube outer radius -} - -Int_t CbmMustMapCreator::GetTubeIDFromPath(TString path) -{ - TString tmpstring = GetNameFromPath(path); - return GetTubeIDFromName(tmpstring); -} - -// ===== GEO TYPE 1 ===== -// sensitive volume is gas -// when reading the parameters we use must01tube to retrieve geometrical information -// OK -// during simulation - -Int_t CbmMustMapCreator::GetTubeIDFromName(TString name) -{ - - TString tmpstring = name; - tmpstring.ReplaceAll('_', '#'); - - if (tmpstring.Contains("#")) { - int start = tmpstring.Index("#") + 1; - tmpstring = tmpstring(start, tmpstring.Sizeof()); - } - else { - int start = tmpstring.Index("e") + 1; - tmpstring = tmpstring(start, tmpstring.Sizeof()); - } - - // cout << "GetTubeIDFromName(" << name.Data() << ") = " << tmpstring.Data() << " = " << tmpstring.Atoi() << endl; - - return tmpstring.Atoi(); -} - -// name as in geo file: from path "_" to name "#" -TString CbmMustMapCreator::GetNameFromPath(TString path) -{ - TString tmpstring = path; - tmpstring.Remove(tmpstring.Last('/'), tmpstring.Length()); - - tmpstring.Remove(0, tmpstring.Last('/')); - - return tmpstring; -} - -int CbmMustMapCreator::GetTypeNumTube(TString path, int& module_type, int& module_number, int& tube_in_module) -{ - - if (path.Contains("cave") && path.Contains("assembly")) path.Replace(0, 34, ""); - path.Replace(0, path.First("M") - 1, ""); - module_type = path.Atoi(); - path.Replace(0, path.First("M") + 1, ""); - module_number = path.Atoi(); - path.Replace(0, path.First("M") + 1, ""); - path.Replace(0, path.First("_") + 1, ""); - tube_in_module = path.Atoi(); - // cout << "GetTypeNumTube will return " << module_type << ", " << module_number << ", " << tube_in_module << endl; - return 0; -} - -Int_t CbmMustMapCreator::GetLayerID(Int_t chamberid, TString path) -{ - - int module_type{0}; - int module_number{0}; - int tube_in_module{0}; - GetTypeNumTube(path, module_type, module_number, tube_in_module); - // cout << "Point detected in module S" << module_type << " number " << module_number << " in the tube " << tube_in_module << " of the module." << endl; - - int layerid = 0; - if (chamberid % 2 == 1) { - if (module_type == 1) { - if (tube_in_module <= 64 && module_number <= 5) - layerid = 1; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 5) - layerid = 2; - else if (tube_in_module <= 64 && 5 < module_number && module_number <= 10) - layerid = 3; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 5 < module_number && module_number <= 10) - layerid = 4; - else if (tube_in_module <= 64 && 10 < module_number && module_number <= 15) - layerid = 5; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 10 < module_number && module_number <= 15) - layerid = 6; - else if (tube_in_module <= 64 && 15 < module_number && module_number <= 20) - layerid = 7; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 15 < module_number && module_number <= 20) - layerid = 8; - } - if (module_type == 2) { - if (tube_in_module <= 64 && module_number <= 4) - layerid = 1; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 4) - layerid = 2; - else if (tube_in_module <= 64 && 4 < module_number && module_number <= 8) - layerid = 3; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 4 < module_number && module_number <= 8) - layerid = 4; - else if (tube_in_module <= 64 && 8 < module_number && module_number <= 12) - layerid = 5; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 8 < module_number && module_number <= 12) - layerid = 6; - else if (tube_in_module <= 64 && 12 < module_number && module_number <= 16) - layerid = 7; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 12 < module_number && module_number <= 16) - layerid = 8; - } - if (module_type == 3) { - if (tube_in_module <= 32 && module_number <= 3) - layerid = 1; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && module_number <= 3) - layerid = 2; - else if (tube_in_module <= 32 && 3 < module_number && module_number <= 6) - layerid = 3; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 3 < module_number && module_number <= 6) - layerid = 4; - else if (tube_in_module <= 32 && 6 < module_number && module_number <= 9) - layerid = 5; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 6 < module_number && module_number <= 9) - layerid = 6; - else if (tube_in_module <= 32 && 9 < module_number && module_number <= 12) - layerid = 7; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 9 < module_number && module_number <= 12) - layerid = 8; - } - } - else if (chamberid % 2 == 0) { - if (module_type == 1) { - if (tube_in_module <= 64 && module_number <= 7) - layerid = 1; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 7) - layerid = 2; - else if (tube_in_module <= 64 && 7 < module_number && module_number <= 14) - layerid = 3; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 7 < module_number && module_number <= 14) - layerid = 4; - else if (tube_in_module <= 64 && 14 < module_number && module_number <= 21) - layerid = 5; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 14 < module_number && module_number <= 21) - layerid = 6; - else if (tube_in_module <= 64 && 21 < module_number && module_number <= 28) - layerid = 7; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 21 < module_number && module_number <= 28) - layerid = 8; - } - if (module_type == 2) { - if (tube_in_module <= 64 && module_number <= 2) - layerid = 1; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && module_number <= 2) - layerid = 2; - else if (tube_in_module <= 64 && 2 < module_number && module_number <= 4) - layerid = 3; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 2 < module_number && module_number <= 4) - layerid = 4; - else if (tube_in_module <= 64 && 4 < module_number && module_number <= 6) - layerid = 5; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 4 < module_number && module_number <= 6) - layerid = 6; - else if (tube_in_module <= 64 && 6 < module_number && module_number <= 8) - layerid = 7; - else if (64 < tube_in_module && tube_in_module <= 2 * 64 && 6 < module_number && module_number <= 8) - layerid = 8; - } - if (module_type == 3) { - if (tube_in_module <= 32 && module_number <= 3) - layerid = 1; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && module_number <= 3) - layerid = 2; - else if (tube_in_module <= 32 && 3 < module_number && module_number <= 6) - layerid = 3; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 3 < module_number && module_number <= 6) - layerid = 4; - else if (tube_in_module <= 32 && 6 < module_number && module_number <= 9) - layerid = 5; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 6 < module_number && module_number <= 9) - layerid = 6; - else if (tube_in_module <= 32 && 9 < module_number && module_number <= 12) - layerid = 7; - else if (32 < tube_in_module && tube_in_module <= 2 * 32 && 9 < module_number && module_number <= 12) - layerid = 8; - } - layerid = layerid + 8; - } - // cout << "will return layer id = " << layerid << endl; - return layerid; -} - -Int_t CbmMustMapCreator::IsSkew(Int_t layerid) -{ - Int_t skew = 0; - // inclination of +5deg: skew=+1 - if (layerid == 3 || layerid == 4 || layerid == 11 || layerid == 12 || layerid == 19 || layerid == 20 || layerid == 27 - || layerid == 28 || layerid == 35 || layerid == 36 || layerid == 43 || layerid == 44) { - skew = 1; - } - // inclination of -5deg: skew=-1 - if (layerid == 5 || layerid == 6 || layerid == 13 || layerid == 14 || layerid == 21 || layerid == 22 || layerid == 29 - || layerid == 30 || layerid == 37 || layerid == 38 || layerid == 45 || layerid == 46) { - skew = -1; - } - - return skew; -} - -Int_t CbmMustMapCreator::GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, - Int_t tube_in_module, Int_t strawCh12) -{ - int tubeidtot = 0; - int modStraws[3] = {64, 64, 32}; - if (chamberid % 2 == 1) { - tubeidtot = tube_in_module + fModShiftMUST1[module_type - 1][module_number - 1] - + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); - } - else if (chamberid % 2 == 0) { - tubeidtot = tube_in_module + fModShiftMUST2[module_type - 1][module_number - 1] - + (layerid % 2 == 1 ? 0 : strawCh12 - modStraws[module_type - 1]); - } - return tubeidtot; -} - -Int_t CbmMustMapCreator::GetTubeIDTot(Int_t chamberid, Int_t layerid, TString path) -{ - - TString tmpstring = path; - Int_t tube = 0; - Int_t totTubeID = 0; - Int_t strawCh12 = 672; - int module_type{0}; - int module_number{0}; - int tube_in_module{0}; - GetTypeNumTube(path, module_type, module_number, tube_in_module); - tube = GetMUSTTubeIDTot(chamberid, layerid, module_type, module_number, tube_in_module, strawCh12); - // cout << path << " : " << chamberid << " / " << layerid << " / " << module_type << " / " << module_number << " / " << tube_in_module << " -> " << tube << endl; - if (chamberid % 2 == 1) { - totTubeID = tube; - } - if (chamberid % 2 == 0) { - totTubeID = tube + strawCh12 * 8; - } - return totTubeID; -} - -///////////////////////////////////////////////////////////// -/// this function will be used in CbmMustHitProducesRealFast -//////////////////////////////////////////////////////////// - -CbmMustTube* CbmMustMapCreator::GetTubeFromNameToFill(TString tubename, Int_t, Int_t) -{ // tubeid layerid //[R.K.03/2017] unused variable(s) - - TObjArray* geoPassNodes = fMustParameters->GetGeoPassiveNodes(); - // Bool_t isCopy = kTRUE; //[R.K. 01/2017] unused variable - // try as if it was a copy stt01tube#XXX - - FairGeoNode* pnode = (FairGeoNode*) geoPassNodes->FindObject(tubename); - if (!pnode) { // try as if it was a solo stt01tubeXXX - // isCopy = kFALSE; //[R.K. 01/2017] unused variable - // tubename = GetNameFromTubeID(tubeid, isCopy); - // pnode = (FairGeoNode*) geoPassNodes->FindObject(tubename); - } - - if (!pnode) { - cout << "CbmMustMapCreator::GetTubeFromNameToFill: tube " << tubename << " not found (nor as a copy)" << endl; - return nullptr; - } - - FairGeoTransform* lab = pnode->getLabTransform(); - FairGeoVector tra = lab->getTransVector(); - FairGeoRotation rot = lab->getRotMatrix(); - - // geometrical info - double x = tra.getX() / 10.; // in cm - double y = tra.getY() / 10.; // in cm - double z = tra.getZ() / 10.; // in cm - - // std::cout<<"tubename="<<tubename<<" tubeid="<<tubeid<<" x="<<x<<" z="<<z<<std::endl; - // Int_t skew=IsSkew(layerid); //[R.K. 01/2017] unused variable? - // double angle=5*3.14159/180; - // x=(x+skew*(tra.getY()*sin(angle))/10.1); - // std::cout<<"tubename="<<tubename<<" tubeid="<<tubeid<<" skew="<<skew<<" newx="<<x<<std::endl; - - double r[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - r[i][j] = rot.getElement(i, j); - - TGeoVolume* rootvol = pnode->getRootVolume(); - TGeoTube* tube = (TGeoTube*) rootvol->GetShape(); - Double_t halflength = tube->GetDz(); // in cm - // sets up the correspondence int (tubeID) <--> int (1 = copy/0 = solo) - // copy_map[key] = alloc - // fCopy_Map[tubeid] = isCopy; - - return new CbmMustTube((float) x, (float) y, (float) z, r[0][0], r[0][1], r[0][2], r[1][0], r[1][1], r[1][2], r[2][0], - r[2][1], r[2][2], fTubeInRad, fTubeOutRad, halflength); -} - -TClonesArray* CbmMustMapCreator::FillTubeArray() -{ - // ofstream myfile("testNumber.txt"); - TObjArray* geoPassNodes = fMustParameters->GetGeoPassiveNodes(); - TClonesArray* tubeArray = new TClonesArray("CbmMustTube"); - // tubeArray->Delete(); - // int mytest=0; //[R.K. 01/2017] unused variable? - // cout << "TA: entries: " << geoPassNodes->GetEntriesFast() << endl; - for (int i = 0; i < geoPassNodes->GetEntriesFast(); i++) { - FairGeoNode* pnode = (FairGeoNode*) geoPassNodes->At(i); - if (!pnode) { - cout << "CbmMustMapCreator::FillTubeArray : tubename=" << pnode->GetName() << " not existing!!!" << endl; - continue; - } - TString tubename = pnode->GetName(); - - // cout<<"CbmMustMapCreator::FillTubeArray : tubename="<<tubename<< endl; - if ((!tubename.Contains("tube")) || (!tubename.Contains("must"))) { - // myfile<<"CbmMustMapCreator::FillTubeArray : skipping tubename="<<tubename<<endl; - continue; - } - - tubename.ReplaceAll("#", "_"); - Int_t tempChamber = GetChamberIDFromName(tubename); - Int_t tempLayer = GetLayerID(tempChamber, tubename); - Int_t totTubeID = GetTubeIDTot(tempChamber, tempLayer, tubename); - - // cout<<"CbmMustMapCreator::FillTubeArray : totTubeID="<<totTubeID<< endl; - tubename = pnode->GetName(); - - // cout << "TUBE " << tempChamber << " / " << tubeID << " / " << tempLayer << " / " << totTubeID << endl; - - CbmMustTube* musttube = GetTubeFromNameToFill(tubename, totTubeID, tempLayer); - new ((*tubeArray)[totTubeID]) CbmMustTube(*musttube); - - delete (musttube); - // myfile << tubename << " " << totTubeID << " "<<tempLayer<<endl; - } - // cout << "end: " << tubeArray->GetEntriesFast() << endl; - return tubeArray; -} - -Int_t CbmMustMapCreator::GetChamberIDFromName(TString name) -{ - TString pathstring = name; - if (pathstring.Contains("must01")) { - return 1; - } - if (pathstring.Contains("must02")) { - return 2; - } - LOG(fatal) << "[MUST] GetChamberIDFromName failed (" << name.Data() << ")"; - return -1; -} - -Int_t CbmMustMapCreator::GetChamberIDFromPath(TString path) -{ - TString pathstring = path; - if (pathstring.Contains("must01tube")) { - return 1; - } - if (pathstring.Contains("must02tube")) { - return 2; - } - LOG(fatal) << "[MUST] GetChamberIDFromPath failed (" << path.Data() << ")"; - return -1; -} - -ClassImp(CbmMustMapCreator) diff --git a/core/detectors/must/CbmMustMapCreator.h b/core/detectors/must/CbmMustMapCreator.h deleted file mode 100644 index 33b0addf3d..0000000000 --- a/core/detectors/must/CbmMustMapCreator.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ - -//////////////////////////////////////////////////////////////////////////// -// CbmMustMapCreator source file -// -// Mapper for MUST -// -// authors: Radoslaw Karabowicz, GSI, 2024 -// -// modified from CbmGeoFts by Nafija Ibrišimović in 2023 -//////////////////////////////////////////////////////////////////////////// - -#ifndef CBMMUSTMAPCREATOR_H -#define CBMMUSTMAPCREATOR_H - -// from ROOT -#include <TObject.h> -// standard -#include <iostream> -#include <map> - -class CbmMustTube; -class CbmGeoMustPar; -class CbmGeoMustPar; - -class TClonesArray; - -class CbmMustMapCreator : public TObject { - public: - CbmMustMapCreator(); - CbmMustMapCreator(Int_t geoType); - CbmMustMapCreator(CbmGeoMustPar* par); - ~CbmMustMapCreator(); - - // general functions - void SetGeneralParameters(); - - // general functions, to be specified depending on geo type - Int_t GetTubeIDFromPath(TString path); - CbmMustTube* GetTubeFromTubeID(Int_t tubeid); - TClonesArray* FillTubeArray(); - Int_t GetChamberIDFromPath(TString path); - Int_t GetChamberIDFromName(TString name); - Int_t GetLayerID(Int_t chamberid, TString path); - Int_t IsSkew(Int_t layerid); - Int_t GetTubeIDTot(Int_t chamberid, Int_t layerid, TString path); - Int_t GetMUSTTubeIDTot(Int_t chamberid, Int_t layerid, Int_t module_type, Int_t module_number, Int_t tube_in_module, - Int_t strawCh12); - - private: - Int_t GetTubeIDFromName(TString name); - TString GetNameFromPath(TString path); - TString GetNameFromTubeID(Int_t tubeid, Bool_t isCopy); - CbmMustTube* GetTubeFromNameToFill(TString tubename, Int_t tubeid, Int_t layerid); - int GetTypeNumTube(TString path, int& module_type, int& module_number, int& tube_in_module); - - Int_t fGeoType{0}; - Double_t fTubeInRad{0.}, fTubeOutRad{0.}; - CbmGeoMustPar* fMustParameters{nullptr}; - int fModShiftMUST1[3][20] = { - {192, 256, 320, 384, 448, 1536, 1600, 1664, 1728, 1792, 2880, 2944, 3008, 3072, 3136, 4224, 4288, 4352, 4416, 4480}, - {64, 128, 512, 576, 1408, 1472, 1856, 1920, 2752, 2816, 3200, 3264, 4096, 4160, 4544, 4608, 0, 0, 0, 0}, - {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0}}; - int fModShiftMUST2[3][28] = { - {128, 192, 256, 320, 384, 448, 512, 1472, 1536, 1600, 1664, 1728, 1792, 1856, - 2816, 2880, 2944, 3008, 3072, 3136, 3200, 4160, 4224, 4288, 4352, 4416, 4480, 4544}, - {64, 576, 1408, 1920, 2752, 3264, 4096, 4608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 32, 640, 1344, 1376, 1984, 2688, 2720, 3328, 4032, 4064, 4672, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; - - // fGeoType1 - // std::map<int, int> fCopy_Map; - - CbmMustMapCreator(const CbmMustMapCreator& L); - CbmMustMapCreator& operator=(const CbmMustMapCreator&) { return *this; } - - protected: - ClassDef(CbmMustMapCreator, 1) -}; - -#endif diff --git a/core/detectors/must/CbmMustSingleStraw.cxx b/core/detectors/must/CbmMustSingleStraw.cxx deleted file mode 100644 index d1ccd9a173..0000000000 --- a/core/detectors/must/CbmMustSingleStraw.cxx +++ /dev/null @@ -1,1415 +0,0 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ - -//////////////////////////////////////////////////////////////////////////// -// CbmMustSingleStraw source file -// -// Copied from CbmFtsSingleStraw -// -// authors: Radoslaw Karabowicz, GSI, 2024 -//////////////////////////////////////////////////////////////////////////// - -// -// ============================================================================ -// -// Straw tube response simulation -// Corrections to StrawCharge and Eject for delta electrons (dec 2007) -// -// version with one threshold only Julich signal -// -// mandatory call at the beginning -// once to set constants -// -// void TConst(Double_t Radius, Double_t pSTP, Double_t ArP, Double_t CO2P); -// -// Pysical (Garfield) values: -// Radius Press (pSTP) % Ar (ArP) % CO2 (CO2P) -// 0.4 1 0.9 0.1 -// 0.5 1 0.9 0.1 -// 0.5 2 0.8 0.2 -// -// ------------------------------------------------------------------------------ -// -// Full simulation: calls at each track for MC applications -// -// define particle and its in-out hits -// -// void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, -// Double_t w4, Double_t w5, Double_t w6); define the wire -// -// Double_t PartToTime(Double_t Mass, Double_t Momentum, -// Double_t InOut[] ); straw time -// -// -// Double_t TimnsToDiscm(Double_t time); from time (ns) -// to the reconstructed distance (cm) -// -// Double_t PartToADC(); ADC charge -// signal corresponding to the energy loss of StrawCharge -// for energy loss simulation -// -// -//----------------------------------------------------------------------------- -// -// Fast simulation: calls at each track for MC applications -// -// define particle and its in-out hits -// -// void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, -// Double_t w4, Double_t w5, Double_t w6); define the wire -// -// Double_t FastRec(Double_t TrueDcm, Int_t Flag); fast approximation: -// from the true distance (cm) -// to the reconstructed one (cm) -// Flag=0 standard -// Flag=1 Julich expt. curve -// (active with press =2 in TCo -// -// void TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[]); constant initialization -// -// Double_t FastPartToADC(); ADC charge -// signal corresponding to the energy loss of StrawCharge -// with the Urban model for energy loss simulation -// -// ---------------------------------------------------------------------------- -// where: -// -// time: measured drift time in ns -// -// pSTP = pressure in bar -// Radius = tube radius -// ArP and CO2P percentages of Argon and CO2 -// w1:w6 = coordinates of the extremes of the straw wire (straw axis) -// Mass, Momentm = mass and momentum of the MC particle -// InOut[0:5] = straw input and output coordinates traversed from the MC particle -// -// -// -// For other applications see the routines listed in CbmMustSingleStraw.h -// -// Author: A. Rotondi (november 2005, revised and extended in August 2006) -// -// ================================================================================ -// - -#include "CbmMustSingleStraw.h" - -// from CbmRoot, CbmData -#include <CbmMustHit.h> -// from ROOT -#include <TImage.h> -#include <TMath.h> -#include <TMatrixD.h> -#include <TMatrixDEigen.h> -#include <TRandom.h> -#include <TVector3.h> -#include <TVectorD.h> -// standard -#include <iostream> -#include <string> - -using namespace std; - -ClassImp(CbmMustSingleStraw); - -// ============================================================ -CbmMustSingleStraw::CbmMustSingleStraw() - : CDist() - , CDistC() - , CNele() - , CNeleT() - , TeleTime() - , AmplSig() - , Pulse() - , PulseT() - , WDist() - , Wi(0) - , ArPerc(0) - , CO2Perc(0) - , CH4Perc(0) - , ArWPerc(0) - , CO2WPerc(0) - , CH4WPerc(0) - , pSTP(0) - , Radius(0) - , AAr(0) - , ZAr(0) - , RhoAr(0) - , NclAr(0) - , EmedAr(0) - , EminAr(0) - , EmpAr(0) - , CsiAr(0) - , IAr(0) - , WiAr(0) - , Ncl(0) - , Ecl(0) - , Lcl(0) - , Ntote(0) - , GasGain(0) - , Cutoff(0) - , EmedCO2(0) - , EminCO2(0) - , EmpCO2(0) - , CsiCO2(0) - , ACO2(0) - , ZCO2(0) - , RhoCO2(0) - , ICO2(0) - , WiCO2(0) - , NclCO2(0) - , EmedCH4(0) - , EmpCH4(0) - , CsiCH4(0) - , EminCH4(0) - , ACH4(0) - , ZCH4(0) - , RhoCH4(0) - , ICH4(0) - , WiCH4(0) - , NclCH4(0) - , RhoMixCO2(0) - , RhoMixCH4(0) - , PZeta(0) - , piMass(0) - , PMass(0) - , PMom(0) - , Dx(0) - , eMass(0) - , prMass(0) - , Delta(0) - , CNumb(0) - , PEn(0) - , beta(0) - , gamma(0) - , Emed(0) - , Emin(0) - , Csi(0) - , Emax(0) - , Emp(0) - , NNClus(0) - , Xin(0) - , Yin(0) - , Zin(0) - , Xout(0) - , Yout(0) - , Zout(0) - , Rpath(0) - , NPolya(0) - , Xmax(0) - , bPolya(0) - , Calpha(0) - , Cbeta(0) - , Cgamma(0) - , NUrban(0) - , SigUrb(0) - , Eup(0) - , AvUrb(0) - , Wx1(0) - , Wy1(0) - , Wz1(0) - , Wx2(0) - , Wy2(0) - , Wz2(0) - , Wp(0) - , Wq(0) - , Wr(0) - , PulseMax(0) - , PulseTime(0) - , Thresh1(0) - , Thresh2(0) - , Nchann(0) - , Out1(0) - , Out2(0) - , Out3(0) -{ - // class constructor - - // clear - memset(CumClus, 0, sizeof(CumClus)); - memset(CH4Clus, 0, sizeof(CH4Clus)); - memset(PolyaCum, 0, sizeof(PolyaCum)); - memset(Xs, 0, sizeof(Xs)); - - CDist.clear(); - CDistC.clear(); - CNele.clear(); - CNeleT.clear(); - TeleTime.clear(); - AmplSig.clear(); - Pulse.clear(); - PulseT.clear(); - WDist.clear(); -} - -// ---------------------------------------------------------------------- -void CbmMustSingleStraw::TConst(Double_t R1, Double_t P1, Double_t A1, Double_t C1) -{ - - // set constants for the simulation - // Input - // P1 = tube absolute pressure pSTP - // R1 = tube radius Radius - // A1 = argon percentage ArPerc - // C1 = C=2 percentage C=2Perc - // - - Radius = R1; - pSTP = P1; - // Input for the media (volume percentages) - ArPerc = A1; - CO2Perc = C1; - - // cluster dimensions in Ar and CO2 (experimantal values) - - // Double_t PClus[20] = - // {0., .656, .150, .064, .035, .0225, .0155, .0105, .0081, - // .0061, .0049, .0039, .0030, .0025, .0020, .0016, .0012, - // .00095, .00075, .00063}; // Fischle fit - - Double_t PClus[20] = {0., .802, .0707, .020, .013, .008, .006, .005, .006, .008, - .009, .007, .0050, .0040, .0033, .0029, .0025, .0023, .0022, .002}; // Lapique 1st calculation - - // Double_t PClus[20] = - // {0., .841, .0340, .021, .013, .008, .006, .004, .003, - // .008, .013, .008, .0050, .004, .0030, .0028, .0025, - // .0023, .0022, .002}; // Lapique 2nd calculation - - // Double_t PClus[20] = - // {0., .656, .150, .064, .035, .0225, .0155, .0105, .0081, - // .0061, .0049, .0039, .0030, .0025, .0020, .0016, .0012, - // .00080, .00059, .00045}; // Fischle empirical - - // PDouble_t Clus[20] = - // {0., .656, .148, .0649, .0337, .0244, .0141, .0078, .0095, - // .0063, .0062, .0042, .0028, .0018, .0023, .0017, .0014, - // .00060, .00050, .00063}; // Fischle exp - - Double_t CO2Clus[20] = {0., .730, .162, .038, .020, .0110, .0147, .0060, .0084, .0052, - .0020, .0042, .0021, .0025, .0038, .0021, .0009, .00013, .00064, .00048}; // Fischle exp - - // Double_t CH4Clus[20] = - // {0., .786, .120, .032, .013, .0098, .0055, .0057, .0027, - // .0029, .0020, .0016, .0013, .0010, .0012, .0006, .0005, - // .00042, .00037, .00033}; // Fischle exp - - CH4Perc = 0.07; - - // ----------------------------------------------------- - // gain of the avalanche - // Ar/CO2 90/10 1 bar (NTP) MAGY GARFIELD 20-7-2006 - GasGain = 100000.; - - // argon ---------------------------------------------------- - AAr = 39.948; // Argon (39.948) - ZAr = 18.0; // Argon (18) - RhoAr = pSTP * 1.78 * 1.e-03; // g/cm3 (1.78 mg/cm3) - IAr = 188 * 1.e-09; // ionization potential (GeV) (188 eV) - WiAr = 27.0; // energy to create an ion pair (standard 26.7 eV) - NclAr = 25.; // cluster/cm in Argon - // CO2 ----------------------------------------------------- - ACO2 = 44; // CO2 - ZCO2 = 22.; // CO2 - RhoCO2 = pSTP * 1.98 * 1.e-03; // g/cm3 CO2 (1.98 mg/cm3) - ICO2 = 95.8 * 1.e-09; // ionization potential (GeV) (96 eV) - WiCO2 = 33.0; // energy to create an ion pair (33 eV) - NclCO2 = 35.5; // clusters/cm CO2 35.5 - // Methane CH4 --------------------------------------------------------- - ACH4 = 16; // CO2 (39.948) - ZCH4 = 10.; // CO2 (18) - RhoCH4 = pSTP * 0.71 * 1.e-03; // g/cm3 CO2 (0.71 mg/cm3) - ICH4 = 40.6 * 1.e-09; // ionization potential (GeV) (45 eV) - WiCH4 = 28.0; // energy to create an ion pair - NclCH4 = 25.0; - // Input for the media (weight percentages) ---------------------------- - ArWPerc = ArPerc * AAr / (ArPerc * AAr + CO2Perc * ACO2); - CO2WPerc = CO2Perc * ACO2 / (ArPerc * AAr + CO2Perc * ACO2); - - // mixture densiies ---------------------------------------------------- - RhoMixCO2 = 1. / ((ArWPerc / RhoAr) + (CO2WPerc / RhoCO2)); - RhoMixCH4 = 1. / ((ArWPerc / RhoAr) + (CH4WPerc / RhoCH4)); - - //---------------------------------------------------------------------- - // particles (Gev, energy losses in Kev) - - PZeta = 1; // projectile charge - piMass = 0.139; // particle mass (GeV) - eMass = 0.511 / 1000.; // electron mass (GeV) (0.511 MeV) - prMass = 0.93827; // proton mass (GeV) - - // --------------------------------------------------------------------- - // thresholds for the straw tubes (default values) see TInit for current values - Thresh1 = 10; - Thresh2 = 30; - // channels for the signal - Nchann = 500; - - // ---------------------------------------------Emin------------------------ - - NPolya = 100; // steps for the calculation of the Polya distributions - Xmax = 0.; // Polya istribution is calculated between o and Xmax (see Polya) - bPolya = 0.5; - Polya(bPolya); // cumulative of the Polya distribution - // ----------------------------------------------------------------------- - - // cumulative for the number of electron per cluster - - Double_t Wnorm = (ArPerc * NclAr + CO2Perc * NclCO2); - CumClus[0] = (ArPerc * NclAr * PClus[0] + CO2Perc * NclCO2 * CO2Clus[0]) / Wnorm; - - for (Int_t i = 1; i < 20; i++) { - CumClus[i] = (ArPerc * NclAr * PClus[i] + CO2Perc * NclCO2 * CO2Clus[i]) / Wnorm + CumClus[i - 1]; - } - CumClus[20] = 1.; - - /* - Double_t sum = 0.; - for (Int_t i = 0; i < 20; i++) { - sum += PClus[i]; - // cout<<" PClus["<<i<<"] = "<<PClus[i]<<endl; - } - // for (Int_t i = 0; i <= 20; i++) { // cout<<"CumClus["<<i<<"] = "<<CumClus[i]<<endl; - // } - // cout<<" Sum of Probabilities = "<<sum<<endl; - */ -} - -// ============================================================== -void CbmMustSingleStraw::PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, Double_t w4, Double_t w5, Double_t w6) -{ - // get wire coordinates - - Wx1 = w1; - Wy1 = w2; - Wz1 = w3; - - Wx2 = w4; - Wy2 = w5; - Wz2 = w6; -} -// ============================================================= - -void CbmMustSingleStraw::TInit(Double_t xPMass, Double_t xPMom, Double_t InOut[]) -{ - - // initialization of the constants for each track and each straw - - // transfer of data - // track geometrical quantities - Xin = InOut[0]; - Yin = InOut[1]; - Zin = InOut[2]; - Xout = InOut[3]; - Yout = InOut[4]; - Zout = InOut[5]; - PMass = xPMass; - PMom = xPMom; - - // path into the straw - Dx = sqrt((Xout - Xin) * (Xout - Xin) + (Yout - Yin) * (Yout - Yin) + (Zout - Zin) * (Zout - Zin)); - - // clear - CNumb = 0; - PulseMax = 0; - PulseTime = 0; - CDist.clear(); - CDistC.clear(); - CNele.clear(); - CNeleT.clear(); - WDist.clear(); - TeleTime.clear(); - AmplSig.clear(); - Pulse.clear(); - PulseT.clear(); - - // --------------------------------------------------------------------- - - // initialization of the constants - // maximum energy transfer Emax (GeV) and related quantities - - PEn = sqrt(PMom * PMom + PMass * PMass); // particle energy GeV - beta = PMom / PEn; - gamma = 1 / sqrt(1. - beta * beta); - Double_t begam = beta * gamma; // local - Double_t mratio = eMass / PMass; // local - - // calculation of the polarization Sternheimer factor for Argon - Double_t ms = 2.80; - Double_t Xst = log10(begam * sqrt(pSTP)); - Double_t Cs = -11.92; - Double_t X1 = 4; - Double_t Xo = 1.96; - Double_t as = 0.389; - Delta = 0; - if (Xo <= Xst && Xst <= X1) - Delta = 4.6051702 * Xst + Cs + as * pow(X1 - Xst, ms); - else if (X1 < Xst) - Delta = 4.6051702 * Xst + Cs; - if (Delta < 0) Delta = 0; - - // calculation of other typical quantites - - Emax = (1.022 * begam * begam / (1. + 2. * gamma * mratio + mratio * mratio)) / 1000.; // GeV - - CsiAr = 0.5 * 0.3071 * PZeta * PZeta * ZAr * RhoAr / (beta * beta * AAr) * 1e-03; // GeV - Double_t fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (IAr * IAr); - EmedAr = 2. * CsiAr * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm - EminAr = pSTP * 2.70 * 1.e-06; // GeV/cm (2.5 keV) - // most prob energy (GeV) - EmpAr = EmedAr + CsiAr * (0.422784 + beta * beta + log(CsiAr / Emax)); - - CsiCO2 = 0.5 * 0.3071 * PZeta * PZeta * ZCO2 * RhoCO2 / (beta * beta * ACO2) * 1e-03; // GeV - fact = 2. * eMass * beta * beta * gamma * gamma * Emax / (ICO2 * ICO2); - EmedCO2 = 2. * CsiCO2 * (0.5 * TMath::Log(fact) - beta * beta - 0.5 * Delta); // GeV/cm - EminCO2 = pSTP * 3.60 * 1.e-06; // GeV/cm (2.5 keV) - // most prob energy (GeV) - EmpCO2 = EmedCO2 + CsiCO2 * (0.422784 + beta * beta + log(CsiCO2 / Emax)); - - Csi = RhoMixCO2 * ((ArWPerc * CsiAr / RhoAr) + (CO2WPerc * CsiCO2 / RhoCO2)); - ; - Emed = RhoMixCO2 * ((ArWPerc * EmedAr / RhoAr) + (CO2WPerc * EmedCO2 / RhoCO2)); - Emin = RhoMixCO2 * ((ArWPerc * EminAr / RhoAr) + (CO2WPerc * EminCO2 / RhoCO2)); - Emp = RhoMixCO2 * ((ArWPerc * EmpAr / RhoAr) + (CO2WPerc * EmpCO2 / RhoCO2)); - - // mean weighted interaction - Wi = (ArPerc * NclAr * WiAr + CO2Perc * NclCO2 * WiCO2) / (ArPerc * NclAr + CO2Perc * NclCO2); - // number of clusters - Double_t nAr = ArWPerc * RhoMixCO2 / AAr; - Double_t nCO2 = CO2WPerc * RhoMixCO2 / ACO2; - // Ncl=pSTP*((ArPerc*NclAr)+(CO2Perc*NclCO2))*Emed/Emin; // <--- Cluster/cm - Ncl = pSTP * ((nAr * NclAr + nCO2 * NclCO2) / (nAr + nCO2)) * Emed / Emin; // <--- Cluster/cm - - Lcl = 1. / Ncl; // mean free path between clusters (cm) - Ecl = 2.8; // mean number of electrons per clusters (def 2.8) - Cutoff = Ncl * Ecl * 25; // limit to the number of primary electrons (*20) - Ntote = Ecl * Ncl; // total mean number of electrons per cm - - // --------------------------------------------------------------------- - // thresholds for the straw tubes (current values) - // total number of electrons * scaling factor (max of signal x electron=1) - - Thresh1 = Ncl * Ecl * 0.10; - Thresh2 = Ncl * Ecl * 0.15; - - // ----------------------------------------------------------------------- - - TDirCos(); // director cosine of the track - - // control prints - - // cout<<" Dx "<<Dx<<" Csi "<<Csi*1.e+09<<" Emax MeV "<< - // Emax*1.e+03<<" PMass "<<PMass<<" gamma "<< - // gamma<<endl; - // cout<<" RRise "<<RRise(gamma)<<endl; - // cout<<" Thresh1 = "<<Thresh1<<" Thresh2 = "<<Thresh2<<endl; -} - -// ============================================================= - -// energy loss in GeV -Double_t CbmMustSingleStraw::STEloss() -{ - - return gRandom->Landau(Emp * Dx, Csi * Dx); // in GeV -} -// ============================================================= - -Double_t CbmMustSingleStraw::STUrban() -{ - - // - // energy loss in GeV from the Urbam distribution NIM A 362(1995)416 - // Author: A. Rotondi December 2007 - // - - Double_t Sig1Ar, Sig2Ar, Sig3Ar; - Double_t Sig1Mix, Sig2Mix, Sig3Mix; - Double_t Sig1CO2, Sig2CO2, Sig3CO2, IMix, nAr, nCO2; - Double_t f1, f2, e1, e2, e2f, ru, Cu, Cuc; - Double_t N1Mix, N2Mix, N3Mix, E1Mix, E2Mix, E3Mix, ZMix; - Double_t Sig21, Sig22, Sig23, Medd; - - Double_t eVGeV = 1.e-09; - - // ru= 0.6; - ru = 0.55; - - Cuc = 2. * PMass * beta * beta * gamma * gamma; - - // calculation for Argon - - Cu = EmedAr; - f2 = 2. / ZAr; - f1 = 1. - f2; - e2 = 10. * ZAr * ZAr * eVGeV; - e2f = TMath::Power(e2, f2); - e1 = TMath::Power(IAr / e2f, 1. / f1); - Sig1Ar = (1. - ru) * Cu * (f1 / e1) * (TMath::Log(Cuc / e1) - beta * beta) / (TMath::Log(Cuc / IAr) - beta * beta); - Sig2Ar = (1. - ru) * Cu * (f2 / e2) * (TMath::Log(Cuc / e2) - beta * beta) / (TMath::Log(Cuc / IAr) - beta * beta); - Sig3Ar = Cu * Emax * ru / (IAr * (Emax + IAr) * TMath::Log((Emax + IAr) / IAr)); - - // Calculation for CO2 - - Cu = EmedCO2; - f2 = 2. / ZCO2; - f1 = 1. - f2; - e2 = 10. * ZCO2 * ZCO2 * eVGeV; - e2f = TMath::Power(e2, f2); - e1 = TMath::Power(ICO2 / e2f, 1. / f1); - - Sig1CO2 = (1. - ru) * Cu * (f1 / e1) * (TMath::Log(Cuc / e1) - beta * beta) / (TMath::Log(Cuc / ICO2) - beta * beta); - Sig2CO2 = (1. - ru) * Cu * (f2 / e2) * (TMath::Log(Cuc / e2) - beta * beta) / (TMath::Log(Cuc / ICO2) - beta * beta); - Sig3CO2 = Cu * Emax * ru / (ICO2 * (Emax + ICO2) * TMath::Log((Emax + ICO2) / ICO2)); - - // calculation for the mixture - - nAr = ArWPerc * RhoMixCO2 / AAr; - nCO2 = CO2WPerc * RhoMixCO2 / ACO2; - IMix = TMath::Exp((nAr * ZAr * TMath::Log(IAr) + nCO2 * ZCO2 * TMath::Log(ICO2)) / (nAr * ZAr + nCO2 * ZCO2)); - - ZMix = ArWPerc * ZAr + CO2WPerc * ZCO2; - f2 = 2. / ZMix; - f1 = 1. - f2; - E2Mix = 10. * ZMix * ZMix * eVGeV; - e2f = TMath::Power(E2Mix, f2); - E1Mix = TMath::Power(IMix / e2f, 1. / f1); - - Sig1Mix = Dx * RhoMixCO2 * (ArWPerc * Sig1Ar / RhoAr + CO2WPerc * Sig1CO2 / RhoCO2); - Sig2Mix = Dx * RhoMixCO2 * (ArWPerc * Sig2Ar / RhoAr + CO2WPerc * Sig2CO2 / RhoCO2); - Sig3Mix = Dx * RhoMixCO2 * (ArWPerc * Sig3Ar / RhoAr + CO2WPerc * Sig3CO2 / RhoCO2); - - NUrban = Sig1Mix + Sig2Mix + Sig3Mix; // total number of collisions (mean value) - - // Urban distribution calculation - - N1Mix = gRandom->Poisson(Sig1Mix); - N2Mix = gRandom->Poisson(Sig2Mix); - N3Mix = gRandom->Poisson(Sig3Mix); - - Int_t N3 = TMath::Nint(N3Mix + gRandom->Uniform()); - - E3Mix = 0.; - for (Int_t j = 1; j <= N3; j++) { - E3Mix += ((Emax + IMix) * IMix) / (IMix + Emax * (1. - gRandom->Uniform())); - } - - // variance calculation - - Eup = IMix / (1. - 0.98 * Emax / (Emax + IMix)); // 98% of the delta electron area (GeV) - Sig21 = IMix * (Emax + IMix) / Emax; - Medd = Sig21 * TMath::Log(Eup / IMix); - Sig22 = Sig21 * Eup - Medd * Medd; - Sig23 = Sig1Mix * E1Mix * E1Mix + Sig2Mix * E2Mix * E2Mix + Sig3Mix * Medd * Medd + Sig3Mix * Sig22; - - AvUrb = Sig1Mix * E1Mix + Sig2Mix * E2Mix + Sig3Mix * Medd; - - SigUrb = TMath::Sqrt(Sig23); - - // return the energy lost in keV - - return N1Mix * E1Mix + N2Mix * E2Mix + E3Mix; // in GeV -} -// ============================================================= - -Double_t CbmMustSingleStraw::StrawCharge() -{ - - // sampling of the ionization energy loss, number of - // primary electrons and their wire distances for each track - // energy loss in GeV - - // clear - Double_t TotEnEle = 0., ClusEner = 0., Ecurr; - CNeleT.clear(); - WDist.clear(); - - // threshold for delta rays (>1.5 KeV from NIM A301(1991)202) - // total energy released by the electrons - // Number of cluster in the length - NNClus = Cluster(); // set vectors CDist CDistC e CNele - // calculation of total energy released by the electrons - for (Int_t j = 1; j <= NNClus; j++) { - ClusEner = 0.; - for (Int_t jj = 1; jj <= (Int_t) (CNele.at(j - 1)); jj++) { - Ecurr = Wi; - TotEnEle += Ecurr; - ClusEner += Ecurr; - } - - // effective number of electrons per cluster - - CNeleT.push_back(int(ClusEner / Wi)); - } - - // record the distance from the wire of any electron - // adding the diffusion effects - Int_t owfl = 0; - for (Int_t k = 1; k <= NNClus; k++) { - for (Int_t kk = 0; kk < (Int_t) CNeleT.at(k - 1); kk++) { - if (owfl > (Int_t) Cutoff) break; - owfl++; - WDist.push_back(WDistCalc(CDistC.at(k - 1))); - } - } - - return TotEnEle * 1.e-09; // in Gev -} - -// ============================================================= - -Int_t CbmMustSingleStraw::Cluster() -{ - - // calculate the number of clusters CNumb - // their distance CDist and - // their number of electrons CNele - - CNumb = 0; - CDist.clear(); - CDistC.clear(); - CNele.clear(); - - Double_t DisTot = 0; - - for (Int_t k = 1; k <= 1000; k++) { - // distance - - Double_t path = -Lcl * log(1 - gRandom->Uniform() + 0.000001); - DisTot += path; - if (DisTot > Dx) break; - CNumb = k; - CDist.push_back(path); - CDistC.push_back(DisTot); - CNele.push_back((Double_t) Eject()); - } - - return CNumb; -} - -// ============================================================= - -Int_t CbmMustSingleStraw::Eject() -{ - // find the number of electrons in a cluster - Int_t Inelect; - Double_t nelect = 0.; - - nelect = TMath::BinarySearch(21, CumClus, gRandom->Uniform()); - if (nelect < 19) { - return Inelect = (Int_t) (nelect) + 1; - } - else { - // long delta electron tail - return Inelect = (Int_t) (20. / (1.03 - gRandom->Uniform())); - } -} - -// ============================================================= - -Double_t CbmMustSingleStraw::RRise(Double_t gamma2) -{ - - // interpolate the relativisic rise of the - // number of cluster per cm, starting from the one - // measured at the ionization minimum - - Double_t Rise; - Double_t lg = log10(gamma2); - - if (1. <= gamma2 && gamma2 <= 2.2) { - Rise = -2.159 * lg + 1.7; - } - else if (2.2 <= gamma2 && gamma2 <= 6.) { - Rise = 1.; - } - else if (6. <= gamma2 && gamma2 <= 200.) { - Rise = 0.302 * lg + 0.765; - } - else if (200. <= gamma2 && gamma2 <= 1000.) { - Rise = 0.1431 * lg + 1.131; - } - else if (1000. <= gamma2) { - Rise = 1.54; - } - else { - Rise = 1.7; - } - - return Rise; -} - -// ========================================================================== - -void CbmMustSingleStraw::Polya(Double_t bpar) -{ - - // calculate the cumulative of the Polya distribution - // for samplig the gain fluctuations - - Double_t eps = 0.0001; - Double_t Dxx = 0.05, xx = 0., x1, x2; - Double_t PMax; - - Double_t k = 1. / bpar - 1.; - - // find Xmax - - PMax = eps * pow(k, k) * exp(-k); - Double_t value = 1.e+06; - Xmax = 2 * k; - while (value > PMax) { - Xmax += Dxx; - value = pow(Xmax, k) * exp(-Xmax); - } - Xmax += -0.5 * Dxx; - - // calculate the cumulative - - Double_t dx = Xmax / NPolya; - Xs[0] = 0; - for (Int_t i = 1; i < NPolya; i++) { - x1 = xx; - xx += dx; - x2 = xx; - Xs[i] = x2; - if (i > 1) - PolyaCum[i] = PolyaCum[i - 1] + 0.5 * dx * (pow(x1, k) * exp(-x1) + pow(x2, k) * exp(-x2)) / TMath::Gamma(k + 1); - else - PolyaCum[i] = PolyaCum[i - 1] + 0.5 * dx * pow(x2, k) * exp(-x2) / TMath::Gamma(k + 1); - } - - // adjust the normalization - - for (Int_t ii = 0; ii < NPolya; ii++) - PolyaCum[ii] /= PolyaCum[NPolya - 1]; -} - -// ===================================================================== - -Double_t CbmMustSingleStraw::PolyaSamp() -{ - - // sampling a wire gain fluctuation in the gas - - Double_t xr = gRandom->Uniform(); - Int_t n = TMath::BinarySearch(NPolya, PolyaCum, xr); - Double_t xsamp = Xmax; - if (n < NPolya - 1) { - xsamp = Xs[n] + ((xr - PolyaCum[n]) / (PolyaCum[n + 1] - PolyaCum[n])) * (Xs[n + 1] - Xs[n]); - } - return xsamp; -} - -// ===================================================================== - -TVector3 CbmMustSingleStraw::WDistCalc(Double_t DisTot) -{ - - // calculation of the distance of the cluster from the wire - // DisTot is the cluster distance from the track entrance - // diffusion effects are considered - - // wire director cosines - - Double_t Wlength = sqrt((Wx2 - Wx1) * (Wx2 - Wx1) + (Wy2 - Wy1) * (Wy2 - Wy1) + (Wz2 - Wz1) * (Wz2 - Wz1)); - Wp = (Wx2 - Wx1) / Wlength; - Wq = (Wy2 - Wy1) / Wlength; - Wr = (Wz2 - Wz1) / Wlength; - - // current track coordinates - Double_t xcor = Calpha * DisTot + Xin; - Double_t ycor = Cbeta * DisTot + Yin; - Double_t zcor = Cgamma * DisTot + Zin; - - // cross product VV1= (wire x track) for the distance - Double_t XX1 = Wr * (ycor - Wy1) - Wq * (zcor - Wz1); - Double_t YY1 = Wp * (zcor - Wz1) - Wr * (xcor - Wx1); - Double_t ZZ1 = Wq * (xcor - Wx1) - Wp * (ycor - Wy1); - - // vector for the 3-D distance from the wire (from wire x VV1) - Double_t XX = Wq * ZZ1 - Wr * YY1; - Double_t YY = Wr * XX1 - Wp * ZZ1; - Double_t ZZ = Wp * YY1 - Wq * XX1; - // cout<<" XYZ "<<XX<<" "<<YY<<" "<<ZZ<<endl; - Double_t DDistcm = sqrt(XX * XX + YY * YY + ZZ * ZZ); - - // director cosines of the distance vector - Double_t cosx = XX / DDistcm; - Double_t cosy = YY / DDistcm; - Double_t cosz = ZZ / DDistcm; - - // sampling of the diffusion - // Double_t DDist = DDistcm*10.; // distance in mm - - // longitudinal coefficient of diffusion (GARFIELD) cm --> micron - // MAGY Ar/CO2 90/10 20-7-2006 GARFIELD - Double_t SigL = DiffLong(DDistcm); - // ... in cm - SigL *= 1.e-04; // in cm - - // tranverse coefficient (GARFIELD) cm--> micron - // MAGY Ar/CO2 90/10 20-7-2006 GARFIELD - Double_t SigT = DiffTran(DDistcm); - SigT *= 1.e-04; // in cm - - // sampling of Longitudinal and Transverse diffusion - Double_t difL = gRandom->Gaus(0., SigL); - Double_t difT = gRandom->Gaus(0., SigT); - - // vector addition to the distance - // the transverse component has the same dir cos of the wire - XX += difL * cosx + difT * Wp; - YY += difL * cosy + difT * Wq; - ZZ += difL * cosz + difT * Wr; - // cout<<" XYZ+ dif "<<XX<<" "<<YY<<" "<<ZZ<<endl; - // cout<<" --------------------------------------------------- "<<endl; - TVector3 TDist(XX, YY, ZZ); - - return TDist; -} - -// ===================================================================== - -void CbmMustSingleStraw::TDirCos() -{ - - // director cosines of the track (called for each track) - - // path into the straw - Rpath = sqrt((Xout - Xin) * (Xout - Xin) + (Yout - Yin) * (Yout - Yin) + (Zout - Zin) * (Zout - Zin)); - - // director cosines - Calpha = (Xout - Xin) / Rpath; - Cbeta = (Yout - Yin) / Rpath; - Cgamma = (Zout - Zin) / Rpath; -} - -// ===================================================================== - -Int_t CbmMustSingleStraw::TimeEle() -{ - - TeleTime.clear(); - - // calculate the arrival times (ns) for each electron in TeleTime - // from cm to ns <--------------------------------- - // return the number of electrons - // Author:A. Rotondi 20-7-2006 - - Int_t ido = WDist.size(); - Double_t etime; - - // cutoff the total charge to 20 times the average - if (ido > (Int_t) Cutoff) ido = (Int_t) Cutoff; - - for (Int_t k = 0; k < ido; k++) { - Double_t dst = WDist.at(k).Mag(); // distance in cm - - // space to time calculation from GARFIELD - - if (pSTP < 1.9) { - if (Radius < 0.5) { - // V=1600V diameter 4 mm 90/10 - etime = -1.624e-05 + 0.1258 * dst + 0.8079 * pow(dst, 2) - 2.918 * pow(dst, 3) + 10.33 * pow(dst, 4) - - 10.84 * pow(dst, 5); - } - else { - // V=1600V diameter 5 mm 90/10 - etime = -6.763e-05 + 0.1471 * dst + 0.3625 * pow(dst, 2) + 0.3876 * pow(dst, 3) + 1.04 * pow(dst, 4) - - 1.693 * pow(dst, 5); - } - } - else { - // 2 bar 2000V, 5 mm, 80/20 - etime = -0.0001014 + 0.1463 * dst - 0.1694 * pow(dst, 2) + 2.4248 * pow(dst, 3) - 1.793 * pow(dst, 4); - } - - etime *= 1000.; // nano seconds - TeleTime.push_back(etime); - } - - return TeleTime.size(); -} - -// ===================================================================== - -Double_t CbmMustSingleStraw::Signal(Double_t t, Double_t t0) -{ - - // electric signal at time t of a cluster arriving at t0 - Double_t elesig; - // Double_t A = 1.03e-03; //[R.K. 01/2017] unused variable? - // Double_t B = 3.95; //[R.K. 01/2017] unused variable? - // Double_t C = 0.228; //[R.K. 01/2017] unused variable? - // Double_t D = -3.839e-02; //[R.K. 01/2017] unused variable? - // Double_t E = 1.148e-03; //[R.K. 01/2017] unused variable? - - Double_t x = t - t0; - // if(x>0) elesig = A*exp(B*log(x)-C*x)*(1+D*x+E*x*x); // Sokolov Signal - if (x > 0) - elesig = pow(2. * x / 10., 2) * exp(-2. * x / 10.); // Wirtz signal - else - elesig = 0.; - - return elesig; -} - -// ===================================================================== - -Int_t CbmMustSingleStraw::StrawSignal(Int_t nsteps) -{ - - // creation of nstep values of - // the straw global Pulse (sum on all clusters) - // return the number of primary electrons - - PulseMax = 0; - Pulse.clear(); - PulseT.clear(); - AmplSig.clear(); - - Int_t neltot = TimeEle(); // creation and size of TeleTime (electron times) - - Double_t Tmax = 1.e-25; - for (Int_t k = 0; k < neltot; k++) - if (Tmax < TeleTime.at(k)) Tmax = TeleTime.at(k); - Tmax += 100.; - - Double_t Dt = Tmax / nsteps; // number of steps of the signal - - // AmplSig is the amplitude of each electron - - for (Int_t j = 0; j < neltot; j++) { - AmplSig.push_back(bPolya * PolyaSamp()); - } - - // creation of the signal Pulse(PulseT) time in ns - for (Int_t j = 0; j < nsteps; j++) { - Double_t te = j * Dt; - Double_t sumele = 0.; - for (Int_t jj = 0; jj < neltot; jj++) { - Double_t te0 = TeleTime.at(jj); - sumele += AmplSig.at(jj) * Signal(te, te0); - } - - Pulse.push_back(sumele); - PulseT.push_back(te); - } - - // add a random noise (3% of maximum) plus - // a 1% of 200 ns periodic signal - - Double_t Pmax = 1.e-25; - for (Int_t k = 0; k < (Int_t) Pulse.size(); k++) - if (Pmax < Pulse.at(k)) Pmax = Pulse.at(k); - - for (Int_t k = 0; k < (Int_t) Pulse.size(); k++) { - Pulse.at(k) += 0.03 * Pmax * gRandom->Uniform() + 0.01 * Pmax * (sin(6.28 * PulseT.at(k) / 120.)); - // if(Pulse[k]<0) Pulse[k] *= -1.; - } - - PulseMax = Pmax; - - // set variable threshold for the signals (constant fraction) - // Thresh1=0.05*Pmax; - // Thresh2=0.15*Pmax; - - return neltot; -} - -// ===================================================================== - -Int_t CbmMustSingleStraw::StrawTime() -{ - - // simulate the discrimination of the straw signal - // and give the time - // discriminator technique: set 2 threshold, select the first one - // (the low one) only if the second one is fired (FINUDA system) - - PulseTime = 0.; - - Int_t ind = 0; - Int_t flag1 = 0; - Int_t flag2 = 1; - - for (Int_t k = 0; k < (Int_t) Pulse.size(); k++) { - if (flag1 == 0 && Pulse[k] > Thresh1) { - flag1 = 1; - ind = k; - } - - // if(Pulse[k]<Thresh1) {flag1=0; ind=0;} // reset if signal decreases - - // if(flag1==1 && Pulse[k]>Thresh2) { - // flag2=1; - // break; - // } - } - if (flag1 == 1 && flag2 == 1) PulseTime = PulseT.at(ind); - - return ind; -} - -// ===================================================================== - -Double_t CbmMustSingleStraw::TrueDist(Double_t Point[]) -{ - // service routine that finds the distance in cm from the wire - // by knowing the wire coordinates (class variables) - // and the input-output points Point[6] - - Double_t truedist = 0; - - // wire director cosines - Double_t Wlength = sqrt((Wx2 - Wx1) * (Wx2 - Wx1) + (Wy2 - Wy1) * (Wy2 - Wy1) + (Wz2 - Wz1) * (Wz2 - Wz1)); - Wp = (Wx2 - Wx1) / Wlength; - Wq = (Wy2 - Wy1) / Wlength; - Wr = (Wz2 - Wz1) / Wlength; - - // director cosines of the given track - Double_t Modu = sqrt((Point[3] * Point[0]) * (Point[3] * Point[0]) + (Point[4] * Point[1]) * (Point[4] * Point[1]) - + (Point[5] * Point[2]) * (Point[5] * Point[2])); - Double_t dcx = (Point[3] - Point[0]) / Modu; - Double_t dcy = (Point[4] - Point[1]) / Modu; - Double_t dcz = (Point[5] - Point[2]) / Modu; - - // distance formula - Double_t p1 = (Point[0] - Wx1) * (dcy * Wr - dcz * Wq); - Double_t p2 = -(Point[1] - Wy1) * (dcx * Wr - dcz * Wp); - Double_t p3 = (Point[2] - Wz1) * (dcx * Wq - dcy * Wp); - Double_t Det = p1 + p2 + p3; - Double_t Disc = sqrt((dcy * Wr - dcz * Wq) * (dcy * Wr - dcz * Wq) + (dcz * Wp - dcx * Wr) * (dcz * Wp - dcx * Wr) - + (dcx * Wq - dcy * Wp) * (dcx * Wq - dcy * Wp)); - if (Disc > 0) truedist = TMath::Abs(Det / Disc); - - return truedist; // distance in cm -} - -// ===================================================================== - -Double_t CbmMustSingleStraw::TimnsToDiscm(Double_t time) -{ - - // distance in cm from time in ns for pSTP =1 and pSTP=2 atm - // utility routine for the track reconstruction - // last update: A. Rotondi 3-3-2007 - - Double_t drift; - - // 1 absolute atm (NTP) 20-7-2006 GARFIELd Ar/CO2 90/10 MAGY - // ns --> mm - - if (pSTP < 1.9) { - if (Radius < 0.5) { - - drift = -0.0140 - 1.37281e-01 + 5.13978e-02 * time + 7.65443e-05 * pow(time, 2) - 9.53479e-06 * pow(time, 3) - + 1.19432e-07 * pow(time, 4) - 6.19861e-10 * pow(time, 5) + 1.35458e-12 * pow(time, 6) - - 1.10933e-15 * pow(time, 7); - } - - else { - // 1600 V 5 mm - if (time < 120.) { - - drift = 0.0300 - 1.07377e-01 + 3.65134e-02 * time + 1.20909e-03 * pow(time, 2) - 4.56678e-05 * pow(time, 3) - + 6.70207e-07 * pow(time, 4) - 4.99204e-09 * pow(time, 5) + 2.19079e-11 * pow(time, 6) - - 8.01791e-14 * pow(time, 7) + 2.16778e-16 * pow(time, 8); - } - else { - - drift = 0.0300 - 8.91701e-01 + 4.68487e-02 * time + 1.00902e-03 * pow(time, 2) - 4.00359e-05 * pow(time, 3) - + 6.23768e-07 * pow(time, 4) - 5.20556e-09 * pow(time, 5) + 2.41502e-11 * pow(time, 6) - - 5.85450e-14 * pow(time, 7) + 5.77250e-17 * pow(time, 8); - } - } - } - - else { - // 2 absolute atm 5 mm 80/20 (1 bar overpressure) - if (time <= 50.) { - - // on thresh static 10% - - drift = -0.0300 + 1.28551e-02 + 1.44029e-02 * time - 3.67834e-03 * pow(time, 2) + 3.32034e-04 * pow(time, 3) - - 6.36592e-06 * pow(time, 4) - 7.82907e-08 * pow(time, 5) + 3.58931e-09 * pow(time, 6) - - 2.93491e-11 * pow(time, 7); - - // one thresh static 3% - // drift = +5.35238e-02 - // -4.25959e-02 *time - // +7.59448e-03 *pow(time,2) - // -1.44009e-04 *pow(time,3) - // -1.76365e-06 *pow(time,4) - // +3.29531e-08 *pow(time,5) - // +1.12115e-09 *pow(time,6) - // -1.72919e-11 *pow(time,7) ; - } - else if (50. < time && time < 130.) { - - // on thresh static 10% - - drift = -0.0190 + 4.40993e-01 - 2.91442e-02 * time + 3.06237e-03 * pow(time, 2) - 6.07870e-05 * pow(time, 3) - + 5.97431e-07 * pow(time, 4) - 3.09238e-09 * pow(time, 5) + 7.70537e-12 * pow(time, 6) - - 6.49086e-15 * pow(time, 7); - - // one thresh static 3% - // drift = +2.25702e-02 - // +5.17806e-02 *time - // +2.53060e-04 *pow(time,2) - // -1.60338e-05 *pow(time,3) - // +2.14805e-07 *pow(time,4) - // -1.30249e-09 *pow(time,5) - // +3.38791e-12 *pow(time,6) - // -2.10503e-15 *pow(time,7) ; - } - - else { - - // on thresh static 10% - drift = -0.0100 + 4.28757e-01 - 1.95413e-02 * time + 3.02333e-03 * pow(time, 2) - 6.13920e-05 * pow(time, 3) - + 5.93656e-07 * pow(time, 4) - 3.05271e-09 * pow(time, 5) + 8.05446e-12 * pow(time, 6) - - 8.59626e-15 * pow(time, 7); - - // one thresh static 3% - // drift = +1.57217e-01 - // +5.79365e-02*time - // +2.15636e-04*pow(time,2) - // -1.66405e-05*pow(time,3) - // +2.13726e-07*pow(time,4) - // -1.26888e-09 *pow(time,5) - // +3.68533e-12 *pow(time,6) - // -4.24032e-15 *pow(time,7) ; - } - } - - drift = 0.1 * drift; - if (drift < 0.) drift = 0.; - return drift; -} - -// -------------------------------------------------------------------------------- - -Double_t CbmMustSingleStraw::PartToTime(Double_t xPMass, Double_t xPMom, Double_t InOut[]) -{ - - // find the time of a particle of mass xPmass, momentum xPMom, with - // input-output coordinate InOut[6] - // Useful for MC pplication after a call to PutWireXYZ - - TInit(xPMass, xPMom, InOut); // start the event - Out1 = StrawCharge(); // energy loss (GeV) to generate charge - Out2 = StrawSignal(Nchann); // generate the straw signal - Out3 = StrawTime(); // find the straw drift time PulseTime - - return PulseTime; -} - -// -------------------------------------------------------------------------------- -Double_t CbmMustSingleStraw::PartToADC() -{ - - // return the energy loss in the tube as charge signal - // taking into account the Polya fluctuations - Double_t ADCsignal = 0.; - - for (Int_t j = 1; j <= NNClus; j++) { - - for (Int_t jc = 1; jc <= (Int_t) CNeleT[j - 1]; jc++) - ADCsignal += bPolya * GasGain * PolyaSamp(); - } - - return ADCsignal; -} - -// -------------------------------------------------------------------------------- - -Double_t CbmMustSingleStraw::FastPartToADC() -{ - - // return the energy loss (from the Urban distribution) - // in the tube as charge signal - // taking into account the Polya fluctuations - - Double_t ADCsignal = 0.; - - // number of elecrons. Wi is the mean energy lost per free - // electrn in eV - Int_t NtotEle = (Int_t) (1.e+09 * STUrban() / Wi); - - for (Int_t j = 1; j <= NtotEle; j++) { - - ADCsignal += bPolya * GasGain * PolyaSamp(); - } - - return ADCsignal; -} - -// ---------------------------------------------------------------------------------- -Double_t CbmMustSingleStraw::FastRec(Double_t TrueDcm, Int_t Flag) -{ - - // having the true distance TrueDcm (cm) as input, - // return the reconstructed distance (cm), in a fast - // and approximated way - // by sampling on the simulated reconstruction curve - // When Press =2 and Flag=1 one uses the julich experimental data - // A. Rotondi March 2007 - - Double_t resmic; - - // 1 atm pressure - if (pSTP < 1.9) { - if (Radius < 0.45) { - if (TrueDcm < 0.38) { - resmic = 1.24506e+02 - 1.80117e+02 * TrueDcm + 3.76905e+03 * pow(TrueDcm, 2) - 4.63251e+04 * pow(TrueDcm, 3) - + 1.80068e+05 * pow(TrueDcm, 4) - 2.21094e+05 * pow(TrueDcm, 5); - } - else - resmic = 57.; - } - // radius > 0.4 cm - else { - if (TrueDcm < 0.48) { - resmic = 1.53656e+02 - 5.07749e+03 * TrueDcm + 1.73707e+05 * pow(TrueDcm, 2) - 2.72285e+06 * pow(TrueDcm, 3) - + 2.28719e+07 * pow(TrueDcm, 4) - 1.12921e+08 * pow(TrueDcm, 5) + 3.39427e+08 * pow(TrueDcm, 6) - - 6.12741e+08 * pow(TrueDcm, 7) + 6.12041e+08 * pow(TrueDcm, 8) - 2.60444e+08 * pow(TrueDcm, 9); - } - else - resmic = 72.; - } - } - // 2 atm pressure radius 5 cm - - else { - if (Flag == 0) { - if (TrueDcm < 0.48) { - resmic = +1.06966e+02 - 4.03073e+03 * TrueDcm + 1.60851e+05 * pow(TrueDcm, 2) - 2.87722e+06 * pow(TrueDcm, 3) - + 2.67581e+07 * pow(TrueDcm, 4) - 1.43397e+08 * pow(TrueDcm, 5) + 4.61046e+08 * pow(TrueDcm, 6) - - 8.79170e+08 * pow(TrueDcm, 7) + 9.17095e+08 * pow(TrueDcm, 8) - 4.03253e+08 * pow(TrueDcm, 9); - } - else - resmic = 30.; - } - else { - // data from julich - if (TrueDcm < 0.48) { - resmic = 20. + 1.48048e+02 - 3.35951e+02 * TrueDcm - 1.87575e+03 * pow(TrueDcm, 2) - + 1.92910e+04 * pow(TrueDcm, 3) - 6.90036e+04 * pow(TrueDcm, 4) + 1.07960e+05 * pow(TrueDcm, 5) - - 5.90064e+04 * pow(TrueDcm, 6); - } - else - resmic = 65.; - } - } - - // real distance in cm - Double_t rsim = gRandom->Gaus(TrueDcm, resmic * 0.0001); - if (rsim < 0.) - rsim = TrueDcm - TrueDcm * gRandom->Uniform(0., 1.); - else if (rsim > 0.5) - rsim = TrueDcm + (0.5 - TrueDcm) * gRandom->Uniform(0., 1.); - - return rsim; -} -// -------------------------------------------------------------------------------- -Double_t CbmMustSingleStraw::DiffLong(Double_t Distcm) -{ - - // return the longitudinal diffusion - // from cm to microns - // MAGY GARFIELD Ar/CO2 90/10 1 bar (NTP) 20-7-2006 - // - Double_t DiffMic; - - if (pSTP < 1.9) { - if (Radius < 0.5) { - // 4 mm 1600 V 90/10 - DiffMic = 0.896 + 1387. * Distcm - 1.888e+04 * pow(Distcm, 2) + 1.799e+05 * pow(Distcm, 3) - - 9.848e+05 * pow(Distcm, 4) + 3.009e+06 * pow(Distcm, 5) - 4.777e+06 * pow(Distcm, 6) - + 3.074e+06 * pow(Distcm, 7); - } - else { - // 5 mm 1600 V - DiffMic = 1.537 + 1246. * Distcm - 1.357e+04 * pow(Distcm, 2) + 1.049e+05 * pow(Distcm, 3) - - 4.755e+05 * pow(Distcm, 4) + 1.211e+06 * pow(Distcm, 5) - 1.6e+06 * pow(Distcm, 6) - + 8.533e+05 * pow(Distcm, 7); - } - } - - else { - // 2000V 5 mm 2 bar 80/20 - DiffMic = 2.135 + 818. * Distcm - 1.044e+04 * pow(Distcm, 2) + 8.31e+04 * pow(Distcm, 3) - - 3.492e+05 * pow(Distcm, 4) + 7.959e+05 * pow(Distcm, 5) - 9.378e+05 * pow(Distcm, 6) - + 4.492e+05 * pow(Distcm, 7); - } - return DiffMic; -} -// -------------------------------------------------------------------------------- -Double_t CbmMustSingleStraw::DiffTran(Double_t Distcm) -{ - - // return the transverse diffusion in microns - // from cm to microns - // MAGY GARFIELD Ar/CO2 90/10 1 bar (NTP) 20-7-2006 - // - Double_t DiffMic; - - if (pSTP < 1.9) { - if (Radius < 0.5) { - // 4 mm 1600 V 90/10 - // DiffMic = + 0.8513 + 1648.*Distcm - 1.085e+04*pow(Distcm,2) - // + 7.38e+04*pow(Distcm,3) - 3.025e+05*pow(Distcm,4) - // + 6.067e+05*pow(Distcm,5) - 4.643e+04*pow(Distcm,6); - DiffMic = +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) - - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); - } - else { - // 5 mm 1600 V 90/10 - DiffMic = +1.482 + 1529. * Distcm - 6755. * pow(Distcm, 2) + 2.924e+04 * pow(Distcm, 3) - - 0.9246e+05 * pow(Distcm, 4) + 1.548e+05 * pow(Distcm, 5) - 1.002e+05 * pow(Distcm, 6); - } - } - else { - - // 5 mm 2000 V 2 bar 80/20 - DiffMic = +2.094 + 1138. * Distcm - 7557. * pow(Distcm, 2) + 2.968e+04 * pow(Distcm, 3) - 6.577e+04 * pow(Distcm, 4) - + 7.581e+04 * pow(Distcm, 5) - 3.497e+04 * pow(Distcm, 6); - } - return DiffMic; -} -// -------------------------------------------------------- -Double_t CbmMustSingleStraw::DistEle(Double_t time) -{ - - // dist in cm from time in ns for pSTP =1 and pSTP=2 - // utility routine for the >SINGLE< electron reconstruction - // last update: A. Rotondi 20-7-2006 - - Double_t drift; - - // 1 absolute atm (NTP) 20-7-2006 GARFIELd Ar/CO2 90/10 MAGY - // ns --> cm - - time *= 0.001; // time in micro s - - if (pSTP < 2.) { - if (Radius < 0.5) { - // 1600 V 4 mm 90/10 - drift = 0.001629 + 6.194 * time - 56.55 * pow(time, 2) + 355.8 * pow(time, 3) - 903.2 * pow(time, 4); - } - else { - // 1600 V 5 mm 90/10 - drift = 0.003365 + 5.734 * time - 41.88 * pow(time, 2) + 191.2 * pow(time, 3) - 333.4 * pow(time, 4); - } - } - - else { - - // 2 absolute atm 2000 V 5 mm 80/20 (1 bar overpressure) - - drift = 0.003365 + 7.056 * time - 62.28 * pow(time, 2) + 306.1 * pow(time, 3) - 558.7 * pow(time, 4); - } - return drift; // in cm -} diff --git a/core/detectors/must/CbmMustSingleStraw.h b/core/detectors/must/CbmMustSingleStraw.h deleted file mode 100644 index 1114d8d1fa..0000000000 --- a/core/detectors/must/CbmMustSingleStraw.h +++ /dev/null @@ -1,281 +0,0 @@ -/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Radoslaw Karabowicz */ - -//////////////////////////////////////////////////////////////////////////// -// CbmMustSingleStraw header file -// -// Copied from CbmFtsSingleStraw -// -// authors: Radoslaw Karabowicz, GSI, 2024 -//////////////////////////////////////////////////////////////////////////// - -#ifndef CBMMUSTSINGLESTRAW_H -#define CBMMUSTSINGLESTRAW_H 1 -// from ROOT -#include <TH2.h> -#include <TMatrix.h> -#include <TMatrixD.h> -#include <TNamed.h> -#include <TVector3.h> -// standard -#include <vector> - -// ClassImp(TMatrixDBase) -// class TMatrixD;; - -class TH2F; - -class CbmMustSingleStraw : public TNamed { - - // -------------------------------------------------------------------- - public: - CbmMustSingleStraw(); - virtual ~CbmMustSingleStraw(){}; - ClassDef(CbmMustSingleStraw, 1); - - // Get methods - - Double_t GetCDist(Int_t k) { return CDist[k]; }; - Double_t GetCNele(Int_t k) { return CNele[k]; }; - Double_t GetCNeleT(Int_t k) { return CNeleT[k]; }; - Double_t GetTeleTime(Int_t k) { return TeleTime[k]; }; - Double_t GetPulse(Int_t k) { return Pulse[k]; }; - Double_t GetPulseT(Int_t k) { return PulseT[k]; }; - Double_t GetWi() { return Wi * 1.e-09; }; // in GeV - Double_t GetGasGain() { return GasGain; }; - Double_t GetXmax() { return Xmax; }; - Double_t GetDx() { return Dx; }; - Double_t GetEmed() { return Emed; }; - Double_t GetEmin() { return Emin; }; - Double_t GetNcl() { return Ncl; }; - Double_t GetCsi() { return Csi; }; - Double_t GetDelta() { return Delta; }; - Double_t GetEmax() { return Emax; }; - Double_t GetIAr() { return IAr; }; - Int_t GetNNClus() { return NNClus; }; - Int_t GetNchann() { return Nchann; }; - Double_t GetPulseMax() { return PulseMax; }; - Double_t GetGamma() { return gamma; }; - Double_t GetBeta() { return beta; }; - Double_t GetpSTP() { return pSTP; }; - Double_t GetPulseTime() { return PulseTime; }; - Double_t GetbPolya() { return bPolya; }; - Double_t GetSigUrb() { return SigUrb; }; - Double_t GetNUrban() { return NUrban; }; - Double_t GetEup() { return Eup; }; - Double_t GetAvUrb() { return AvUrb; }; - - // coordinates - Double_t GetXin() { return Xin; }; - Double_t GetYin() { return Yin; }; - Double_t GetZin() { return Zin; }; - Double_t GetXout() { return Xout; }; - Double_t GetYout() { return Yout; }; - Double_t GetZout() { return Zout; }; - Double_t GetRpath() { return Rpath; }; - - TVector3 GetWDist(Int_t k) { return WDist[k]; }; - - // put methods - void PutTrackXYZ(Double_t v1, Double_t v2, Double_t v3, Double_t v4, Double_t v5, Double_t v6) - { - Xin = v1; - Yin = v2; - Zin = v3; - Xout = v4; - Yout = v5; - Zout = v6; - }; - void PutRpath(Double_t value) { Rpath = value; }; - - void PutPolya(Double_t par) { bPolya = par; }; - - void PutRadius(Double_t value) { Radius = value; }; - void PutPress(Double_t value) { pSTP = value; }; - - // ---------------------------------------------------------------------------- - // calls at each track for MC applications - - // define the wire - void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, Double_t w4, Double_t w5, Double_t w6); - // straw time - Double_t PartToTime(Double_t Mass, Double_t Momentum, Double_t InOut[]); - // ADC signal corresponding to the energy loss of StrawCharge - Double_t PartToADC(); - - // fast reconstructed distance in cm - Double_t FastRec(Double_t TrueDcm, Int_t Flag); - - // ADC signal charge fast simulation - Double_t FastPartToADC(); - - // ---------------------------------------------------------------------------- - // standard calls - - // once to set constants - - void TConst(Double_t Radius, Double_t pSTP, Double_t ArP, Double_t CO2P); - - // to define the track - void TInit(Double_t Mass, Double_t Momentum, Double_t InOut[]); // for each track - - // other possible calls - - Double_t StrawCharge(); // total discharge electron calculation - - Int_t StrawSignal(Int_t nsteps); // oscilloscope signal generation (ns) - // Pulse[PulseT] in ns - // return number of primary electrons - Int_t StrawTime(); // output time of the straw (ns) & - // PulseTime[Int_t] in ns - // Int_t StrawTot(); // Time over threshold time of the straw (ns) not implemented - - Double_t TimnsToDiscm(Double_t time); // from time (ns) to radius in cm - - //----------------------------------------------------------------------------- - // utility methods - - void TDirCos(); // track director cosines - Double_t TrueDist(Double_t Point[]); // true distance wire-track - Double_t DiffLong(Double_t distcm); // longituinal diffusion in microns - Double_t DiffTran(Double_t distcm); // transverse diffusion in microns - void Polya(Double_t bpar); // Polya cumulative calculation - Double_t PolyaSamp(); // sampling from Polya distribution - Double_t RRise(Double_t gamma); // relativistic rise calculation - Int_t Cluster(); // cluster generation - Int_t Eject(); // primary electron generation - TVector3 WDistCalc(Double_t d); // distance electron-wire - Double_t Signal(Double_t t, Double_t t0); // signal functional form - Double_t STEloss(); // Landau energy loss - Double_t STUrban(); // Urban energy loss - Int_t TimeEle(); // arrivals times of all the electrons - Double_t DistEle(Double_t tns); // distance of all the electrons - - //------------------------------------------------------------------------------ - - private: - //----------------------------------------------------------------- - - // distance, number of electrons (with delta rays), - // distance from wire of the cluster - std::vector<Double_t> CDist, CDistC, CNele, CNeleT, TeleTime, AmplSig; - std::vector<Double_t> Pulse, PulseT; - std::vector<TVector3> WDist; - - // set constants - // masses in GeV, energies in GeV, cgs system - - // Input for the medium - - // Double_t PClus[20], CO2Clus[20], CumClus[21], CH4Clus[20]; - Double_t CumClus[21], CH4Clus[20]; // shadows deleted - - Double_t Wi; - Double_t ArPerc, CO2Perc, CH4Perc; // volume percentages - Double_t ArWPerc, CO2WPerc, CH4WPerc; // weight percentages - Double_t pSTP; // pressure (STP reference) - Double_t Radius; // straw radius - Double_t AAr; // Argon - Double_t ZAr; // Argon - Double_t RhoAr; // g/cm3 (1.78 mg/cm3) - Double_t NclAr; // clusters/cm - - Double_t EmedAr; - Double_t EminAr; - Double_t EmpAr; - Double_t CsiAr; - Double_t IAr; // ionization potential (188 eV) - Double_t WiAr; // energy to reate an ion pair in Argon - Double_t Ncl; // mean number of cluster in the mixture - Double_t Ecl; // electron per cluster - Double_t Lcl; // mean free path between clusters - Double_t Ntote; // mean total number of eletrons - Double_t GasGain; // gain of the gas - Double_t Cutoff; // limit the number of primry electrons - // CO2 - Double_t EmedCO2; - Double_t EminCO2; - Double_t EmpCO2; - Double_t CsiCO2; - Double_t ACO2; // CO2 (39.948) - Double_t ZCO2; // CO2 (18) - Double_t RhoCO2; // g/cm3 CO2 (1.98 mg/cm3) - Double_t ICO2; // ionization potential (GeV) (188 eV) - Double_t WiCO2; // energy to create an ion pair - Double_t NclCO2; // clusters/cm - - // Methane CH4 ------------------------------------------------ - Double_t EmedCH4; - Double_t EmpCH4; - Double_t CsiCH4; - Double_t EminCH4; - Double_t ACH4; // CO2 (39.948) - Double_t ZCH4; // CO2 (18) - Double_t RhoCH4; // g/cm3 CO2 (0.71 mg/cm3) - Double_t ICH4; // ionization potential (GeV) (188 eV) - Double_t WiCH4; // energy to create an ion pair - Double_t NclCH4; // clusters/cm - - Double_t RhoMixCO2; - Double_t RhoMixCH4; - //---------------------------------------------------------------------- - // Input for the particle (Gev, energy loses in Kev - - Double_t PZeta; // charge - Double_t piMass; // particle mass (GeV) - Double_t PMass; // incident particle mass - Double_t PMom; // particle momentum (GeV) - Double_t Dx; // distance travelled in gas (cm) - Double_t eMass; // electron mass (GeV) (0.511 MeV) - Double_t prMass; // proton mass - Double_t Delta; // polarization Sternheimer parameter - Int_t CNumb; // current number of clusters - - // ------------------------------------------------------ - // quantities for each track - // calculated in TInit - - Double_t PEn; // particle energy GeV - Double_t beta; - Double_t gamma; - Double_t Emed; // GeV - Double_t Emin; // GeV/cm (2.7 keV) - Double_t Csi; - Double_t Emax; - Double_t Emp; // most probable energy - Int_t NNClus; // number of clusters - - // --------------------------------------------------------------------- - // mathematical and statistical parameters - - Double_t PolyaCum[100], Xs[100]; - Double_t Xin, Yin, Zin, Xout, Yout, Zout, Rpath; - Int_t NPolya; - Double_t Xmax; - Double_t bPolya; - Double_t Calpha, Cbeta, Cgamma; - Double_t NUrban; // total number of collision in the Urban model - Double_t SigUrb; // std dev of the Urban distribution (routine STUrban) - Double_t Eup; // upper limit of the Urban distribution (routine STUrban) - Double_t AvUrb; // average of the Urban distribution (routine STUrban) - - // -------------------------------------------------------------- - // for the straws - - Double_t Wx1, Wy1, Wz1, Wx2, Wy2, Wz2; // wire coordinates - Double_t Wp, Wq, Wr; // director cosine of the wire - Double_t PulseMax; - Double_t PulseTime; - Double_t Thresh1; // first threshold - Double_t Thresh2; - Int_t Nchann; // number of channels for the straw signal - - // ---------------------------------------------------------------------- - // dummy - - Double_t Out1; - Int_t Out2, Out3; -}; - -#endif -- GitLab