From 4700e2f62aa0ecf6fe65b857e0c316e5a90e8f70 Mon Sep 17 00:00:00 2001 From: jose-luis-rs Date: Mon, 29 Dec 2025 23:14:21 +0100 Subject: [PATCH] refactor(tofwall):Update TofWall classes and ROOT geometry Minor change --- sofdata/tofwData/R3BSofTofWPoint.cxx | 56 +++---- sofdata/tofwData/R3BSofTofWPoint.h | 97 ++++++------ tofwall/calibration/R3BSofTofWMapped2Tcal.h | 7 +- .../calibration/R3BSofTofWMapped2TcalPar.h | 9 +- .../calibration/R3BSofTofWTcal2SingleTcal.h | 7 +- tofwall/digi/R3BSofTofWDigitizer.cxx | 92 ++++++----- tofwall/digi/R3BSofTofWDigitizer.h | 68 +++++---- tofwall/geobase/create_softofw_geo.C | 143 ++++++++---------- tofwall/sim/R3BSofTofW.cxx | 42 +++-- tofwall/sim/R3BSofTofW.h | 25 ++- tofwall/test/CMakeLists.txt | 6 +- tofwall/test/testSofTofWContainerPar.cxx | 2 +- tofwall/test/testSofTofWSimulation.C | 22 +-- 13 files changed, 295 insertions(+), 281 deletions(-) mode change 100755 => 100644 sofdata/tofwData/R3BSofTofWPoint.h mode change 100755 => 100644 tofwall/geobase/create_softofw_geo.C diff --git a/sofdata/tofwData/R3BSofTofWPoint.cxx b/sofdata/tofwData/R3BSofTofWPoint.cxx index 829f0169..3c4d6161 100644 --- a/sofdata/tofwData/R3BSofTofWPoint.cxx +++ b/sofdata/tofwData/R3BSofTofWPoint.cxx @@ -1,3 +1,16 @@ +/****************************************************************************** + * Copyright (C) 2017 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2017-2026 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + // ------------------------------------------------------------------------- // ----- R3BSofTofWPoint source file ----- // ------------------------------------------------------------------------- @@ -8,31 +21,27 @@ using std::cout; using std::endl; -using std::flush; // ----- Default constructor ------------------------------------------- R3BSofTofWPoint::R3BSofTofWPoint() : FairMCPoint() { - fX_out = fY_out = fZ_out = 0.; - fPx_out = fPy_out = fPz_out = 0.; - fZFF = fAFF = 0.; } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ -R3BSofTofWPoint::R3BSofTofWPoint(Int_t trackID, - Int_t detID, - Int_t detCopyID, - Double_t Z, - Double_t A, +R3BSofTofWPoint::R3BSofTofWPoint(int trackID, + int detID, + int detCopyID, + double Z, + double A, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, - Double_t tof, - Double_t length, - Double_t eLoss) + double tof, + double length, + double eLoss) : FairMCPoint(trackID, detID, posIn, momIn, tof, length, eLoss) { fDetCopyID = detCopyID; @@ -45,16 +54,11 @@ R3BSofTofWPoint::R3BSofTofWPoint(Int_t trackID, fZFF = Z; fAFF = A; } -// ------------------------------------------------------------------------- - -// ----- Destructor ---------------------------------------------------- -R3BSofTofWPoint::~R3BSofTofWPoint() {} -// ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- -void R3BSofTofWPoint::Print(const Option_t* opt) const +void R3BSofTofWPoint::Print(const Option_t*) const { - cout << "-I- R3BSofTofWPoint: STS Point for track " << fTrackID << " in detector " << fDetectorID << endl; + cout << "R3BSofTofWPoint: STS Point for track " << fTrackID << " in detector " << fDetectorID << endl; cout << " Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl; cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl; cout << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" @@ -63,31 +67,29 @@ void R3BSofTofWPoint::Print(const Option_t* opt) const // ------------------------------------------------------------------------- // ----- Point x coordinate from linear extrapolation ------------------ -Double_t R3BSofTofWPoint::GetX(Double_t z) const +double R3BSofTofWPoint::GetX(double z) const { - // cout << fZ << " " << z << " " << fZ_out << endl; if ((fZ_out - z) * (fZ - z) >= 0.) return (fX_out + fX) / 2.; - Double_t dz = fZ_out - fZ; + double dz = fZ_out - fZ; return (fX + (z - fZ) / dz * (fX_out - fX)); } // ------------------------------------------------------------------------- // ----- Point y coordinate from linear extrapolation ------------------ -Double_t R3BSofTofWPoint::GetY(Double_t z) const +double R3BSofTofWPoint::GetY(double z) const { if ((fZ_out - z) * (fZ - z) >= 0.) return (fY_out + fY) / 2.; - Double_t dz = fZ_out - fZ; - // if ( TMath::Abs(dz) < 1.e-3 ) return (fY_out+fY)/2.; + double dz = fZ_out - fZ; return (fY + (z - fZ) / dz * (fY_out - fY)); } // ------------------------------------------------------------------------- // ----- Public method IsUsable ---------------------------------------- -Bool_t R3BSofTofWPoint::IsUsable() const +bool R3BSofTofWPoint::IsUsable() const { - Double_t dz = fZ_out - fZ; + double dz = fZ_out - fZ; if (TMath::Abs(dz) < 1.e-4) return kFALSE; return kTRUE; diff --git a/sofdata/tofwData/R3BSofTofWPoint.h b/sofdata/tofwData/R3BSofTofWPoint.h old mode 100755 new mode 100644 index 9c4acfb5..8eda7ec9 --- a/sofdata/tofwData/R3BSofTofWPoint.h +++ b/sofdata/tofwData/R3BSofTofWPoint.h @@ -1,21 +1,29 @@ +/****************************************************************************** + * Copyright (C) 2017 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2017-2026 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + // ------------------------------------------------------------------------- -// ----- R3BSofTofWPoint header file ----- -// ----- Created 06/12/17 by JL Rodriguez ----- +// ----- R3BSofTofWPoint header file ----- +// ----- Created 06/12/17 by J.L. Rodriguez-Sanchez ----- // ------------------------------------------------------------------------- -/** R3BSofTofWPoint.h - **/ - -#ifndef R3BSofTofWPoint_H -#define R3BSofTofWPoint_H +#pragma once -#include "FairMCPoint.h" -#include "TObject.h" -#include "TVector3.h" +#include +#include +#include class R3BSofTofWPoint : public FairMCPoint { - public: /** Default constructor **/ R3BSofTofWPoint(); @@ -34,65 +42,66 @@ class R3BSofTofWPoint : public FairMCPoint *@param length Track length since creation [cm] *@param eLoss Energy deposit [GeV] **/ - R3BSofTofWPoint(Int_t trackID, - Int_t detID, - Int_t detCopyID, - Double_t Z, - Double_t A, + R3BSofTofWPoint(int trackID, + int detID, + int detCopyID, + double Z, + double A, TVector3 posIn, TVector3 posOut, TVector3 momIn, TVector3 momOut, - Double_t tof, - Double_t length, - Double_t eLoss); + double tof, + double length, + double eLoss); /** Copy constructor **/ R3BSofTofWPoint(const R3BSofTofWPoint& point) { *this = point; }; /** Destructor **/ - virtual ~R3BSofTofWPoint(); + virtual ~R3BSofTofWPoint() = default; /** Accessors **/ - Int_t GetDetCopyID() const { return fDetCopyID; } - Double_t GetXIn() const { return fX; } - Double_t GetYIn() const { return fY; } - Double_t GetZIn() const { return fZ; } - Double_t GetXOut() const { return fX_out; } - Double_t GetYOut() const { return fY_out; } - Double_t GetZOut() const { return fZ_out; } - Double_t GetPxOut() const { return fPx_out; } - Double_t GetPyOut() const { return fPy_out; } - Double_t GetPzOut() const { return fPz_out; } - Double_t GetZFF() const { return fZFF; } - Double_t GetAFF() const { return fAFF; } + int GetDetCopyID() const { return fDetCopyID; } + double GetXIn() const { return fX; } + double GetYIn() const { return fY; } + double GetZIn() const { return fZ; } + double GetXOut() const { return fX_out; } + double GetYOut() const { return fY_out; } + double GetZOut() const { return fZ_out; } + double GetPxOut() const { return fPx_out; } + double GetPyOut() const { return fPy_out; } + double GetPzOut() const { return fPz_out; } + double GetZFF() const { return fZFF; } + double GetAFF() const { return fAFF; } void PositionIn(TVector3& pos) { pos.SetXYZ(fX, fY, fZ); } void PositionOut(TVector3& pos) { pos.SetXYZ(fX_out, fY_out, fZ_out); } void MomentumOut(TVector3& mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); } /** Point coordinates at given z from linear extrapolation **/ - Double_t GetX(Double_t z) const; - Double_t GetY(Double_t z) const; + double GetX(double z) const; + double GetY(double z) const; /** Check for distance between in and out **/ - Bool_t IsUsable() const; + bool IsUsable() const; /** Modifiers **/ void SetPositionOut(TVector3 pos); void SetMomentumOut(TVector3 mom); - void SetDetCopyID(Int_t id) { fDetCopyID = id; }; + void SetDetCopyID(int id) { fDetCopyID = id; }; /** Output to screen **/ - virtual void Print(const Option_t* opt) const; + virtual void Print(const Option_t*) const; - protected: - Double32_t fX_out, fY_out, fZ_out; - Double32_t fPx_out, fPy_out, fPz_out; - Int_t fDetCopyID; - Double32_t fZFF, fAFF; + private: + double fX_out = 0., fY_out = 0., fZ_out = 0.; + double fPx_out = 0., fPy_out = 0., fPz_out = 0.; + int fDetCopyID = 0; + double fZFF = 0., fAFF = 0.; - ClassDef(R3BSofTofWPoint, 1) + public: + ClassDef(R3BSofTofWPoint, 1); }; inline void R3BSofTofWPoint::SetPositionOut(TVector3 pos) @@ -108,5 +117,3 @@ inline void R3BSofTofWPoint::SetMomentumOut(TVector3 mom) fPy_out = mom.Py(); fPz_out = mom.Pz(); } - -#endif diff --git a/tofwall/calibration/R3BSofTofWMapped2Tcal.h b/tofwall/calibration/R3BSofTofWMapped2Tcal.h index 4ccc5e86..26e1639b 100644 --- a/tofwall/calibration/R3BSofTofWMapped2Tcal.h +++ b/tofwall/calibration/R3BSofTofWMapped2Tcal.h @@ -4,8 +4,7 @@ // *** ---> from the fine and coarse times, calculate a raw time in ns *** // // *** *************************************************************** *** // -#ifndef R3BSOFTOFW_MAPPED2TCAL_H -#define R3BSOFTOFW_MAPPED2TCAL_H +#pragma once #include "FairTask.h" #include "R3BSofTofWTcalData.h" @@ -65,7 +64,5 @@ class R3BSofTofWMapped2Tcal : public FairTask R3BSofTofWTcalData* AddTCalData(UShort_t detector, UShort_t pmt, Double_t t); public: - ClassDef(R3BSofTofWMapped2Tcal, 1) + ClassDef(R3BSofTofWMapped2Tcal, 1); }; - -#endif // R3BSOFTOFW_MAPPED2TCAL_H diff --git a/tofwall/calibration/R3BSofTofWMapped2TcalPar.h b/tofwall/calibration/R3BSofTofWMapped2TcalPar.h index 3d223c0a..1216c93a 100644 --- a/tofwall/calibration/R3BSofTofWMapped2TcalPar.h +++ b/tofwall/calibration/R3BSofTofWMapped2TcalPar.h @@ -1,8 +1,7 @@ -#ifndef R3BSOFTOFWMAPPED2TCALPAR_H -#define R3BSOFTOFWMAPPED2TCALPAR_H +#pragma once -#include "FairTask.h" -#include "TH1F.h" +#include +#include class TClonesArray; class R3BSofTcalPar; @@ -72,5 +71,3 @@ class R3BSofTofWMapped2TcalPar : public FairTask public: ClassDef(R3BSofTofWMapped2TcalPar, 0); }; - -#endif // R3BSOFTOFWMAPPED2TCALPAR_H diff --git a/tofwall/calibration/R3BSofTofWTcal2SingleTcal.h b/tofwall/calibration/R3BSofTofWTcal2SingleTcal.h index e12ef67d..f47c3e4a 100644 --- a/tofwall/calibration/R3BSofTofWTcal2SingleTcal.h +++ b/tofwall/calibration/R3BSofTofWTcal2SingleTcal.h @@ -2,8 +2,7 @@ // *** R3BSofTofWTcal2SingleTcal // *** *************************************************************** -#ifndef R3BSOFTOFW_TCAL2SINGLETCAL_H -#define R3BSOFTOFW_TCAL2SINGLETCAL_H 1 +#pragma once #include "FairTask.h" #include "R3BSofSciRawTofPar.h" @@ -65,7 +64,5 @@ class R3BSofTofWTcal2SingleTcal : public FairTask R3BSofTofWSingleTcalData* AddHitData(Int_t plastic, Double_t time, Double_t tof, Double_t pos); public: - ClassDef(R3BSofTofWTcal2SingleTcal, 1) + ClassDef(R3BSofTofWTcal2SingleTcal, 1); }; - -#endif // R3BSOFTOFW_TCAL2SINGLETCAL_H diff --git a/tofwall/digi/R3BSofTofWDigitizer.cxx b/tofwall/digi/R3BSofTofWDigitizer.cxx index d2469dea..024cc3e4 100644 --- a/tofwall/digi/R3BSofTofWDigitizer.cxx +++ b/tofwall/digi/R3BSofTofWDigitizer.cxx @@ -1,44 +1,45 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2026 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + // ---------------------------------------------------------------- // ----- R3BSofTofWDigitizer source file ----- // ----- Created 03/11/19 by J.L. Rodriguez ----- // ---------------------------------------------------------------- #include "R3BSofTofWDigitizer.h" - -#include "FairLogger.h" -#include "FairRootManager.h" -#include "FairRunAna.h" -#include "FairRuntimeDb.h" #include "R3BLogger.h" #include "R3BMCTrack.h" #include "R3BSofTofWPoint.h" #include "R3BTGeoPar.h" -#include "TClonesArray.h" -#include "TMath.h" -#include "TVector3.h" + +#include +#include +#include +#include + +#include +#include +#include // R3BSofTofWDigitizer: Default Constructor -------------------------- R3BSofTofWDigitizer::R3BSofTofWDigitizer() - : FairTask("R3BSofTofWDigitizer", 1) - , fMCTrack(NULL) - , fTofPoints(NULL) - , fTofHits(NULL) - , fsigma_y(1) // sigma=1mm - , fsigma_t(0.017) // sigma=17ps - , fsigma_ELoss(0.) + : R3BSofTofWDigitizer("R3BSofTofWDigitizer", 1) { - rand = new TRandom3(); } // R3BSofTofWDigitizer: Standard Constructor -------------------------- -R3BSofTofWDigitizer::R3BSofTofWDigitizer(const char* name, Int_t iVerbose) - : FairTask(name, iVerbose) - , fMCTrack(NULL) - , fTofPoints(NULL) - , fTofHits(NULL) - , fsigma_y(1) - , fsigma_t(0.017) - , fsigma_ELoss(0.) +R3BSofTofWDigitizer::R3BSofTofWDigitizer(const TString& name, int iVerbose) + : FairTask(name.Data(), iVerbose) { rand = new TRandom3(); } @@ -100,38 +101,37 @@ InitStatus R3BSofTofWDigitizer::Init() } // ----- Public method Execution -------------------------------------------- -void R3BSofTofWDigitizer::Exec(Option_t* opt) +void R3BSofTofWDigitizer::Exec(Option_t*) { Reset(); // Reading the Input -- Point Data -- - Int_t nHits = fTofPoints->GetEntries(); + auto nHits = fTofPoints->GetEntries(); if (nHits == 0) { return; } // Data from Point level - R3BSofTofWPoint** pointData = new R3BSofTofWPoint*[nHits]; - Int_t paddle = 0; - Int_t TrackId = 0, PID = 0, mother = -1; - Double_t x = 0., y = 0., z = 0., time = 0.; + int paddle = 0; + int TrackId = 0, PID = 0, mother = -1; + double x = 0., y = 0., z = 0., time = 0.; TVector3 vpos; for (Int_t i = 0; i < nHits; i++) { - pointData[i] = (R3BSofTofWPoint*)(fTofPoints->At(i)); - TrackId = pointData[i]->GetTrackID(); + auto* pointData = dynamic_cast(fTofPoints->At(i)); + TrackId = pointData->GetTrackID(); - R3BMCTrack* Track = (R3BMCTrack*)fMCTrack->At(TrackId); + auto* Track = dynamic_cast(fMCTrack->At(TrackId)); PID = Track->GetPdgCode(); if (PID > 1000080160) // Z=8 and A=16 { - Double_t fX_in = pointData[i]->GetXIn(); - Double_t fY_in = pointData[i]->GetYIn(); - Double_t fZ_in = pointData[i]->GetZIn(); - Double_t fX_out = pointData[i]->GetXOut(); - Double_t fY_out = pointData[i]->GetYOut(); - Double_t fZ_out = pointData[i]->GetZOut(); - paddle = pointData[i]->GetDetCopyID() + 1; + Double_t fX_in = pointData->GetXIn(); + Double_t fY_in = pointData->GetYIn(); + Double_t fZ_in = pointData->GetZIn(); + Double_t fX_out = pointData->GetXOut(); + Double_t fY_out = pointData->GetYOut(); + Double_t fZ_out = pointData->GetZOut(); + paddle = pointData->GetDetCopyID() + 1; // std::cout<GetTime() + rand->Gaus(0., fsigma_t); + time = pointData->GetTime() + rand->Gaus(0., fsigma_t); // Add hit data AddHitData(paddle, vpos.X() * 10., vpos.Y() * 10. + rand->Gaus(0., fsigma_y), time); } } - if (pointData) - { - delete[] pointData; - } LOG(info) << "R3BSofTofWDigitizer: " << fTofHits->GetEntriesFast() << " points registered in this event"; return; } @@ -173,12 +169,12 @@ void R3BSofTofWDigitizer::Reset() } // ----- Private method AddHitData ------------------------------------------- -R3BSofTofWHitData* R3BSofTofWDigitizer::AddHitData(Int_t paddle, Double_t x, Double_t y, Double_t time) +R3BSofTofWHitData* R3BSofTofWDigitizer::AddHitData(int paddle, double x, double y, double time) { // It fills the R3BSofTofWHitData TClonesArray& clref = *fTofHits; - Int_t size = clref.GetEntriesFast(); + auto size = clref.GetEntriesFast(); return new (clref[size]) R3BSofTofWHitData(paddle, x, y, time); } -ClassImp(R3BSofTofWDigitizer); +ClassImp(R3BSofTofWDigitizer) diff --git a/tofwall/digi/R3BSofTofWDigitizer.h b/tofwall/digi/R3BSofTofWDigitizer.h index a564579b..d0eebe97 100644 --- a/tofwall/digi/R3BSofTofWDigitizer.h +++ b/tofwall/digi/R3BSofTofWDigitizer.h @@ -1,17 +1,30 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2026 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + // ---------------------------------------------------------------- // ----- R3BSofTofWDigitizer source file ----- // ----- Created 03/11/19 by JL Rodriguez ----- // ---------------------------------------------------------------- -#ifndef R3BSofTofWDigitizer_H -#define R3BSofTofWDigitizer_H 1 +#pragma once -#include "FairTask.h" #include "R3BSofTofWHitData.h" -#include "TRandom3.h" -#include "TRotation.h" -#include "TVector3.h" +#include + +#include +#include +#include #include #include @@ -26,52 +39,51 @@ class R3BSofTofWDigitizer : public FairTask R3BSofTofWDigitizer(); /** Standard constructor **/ - R3BSofTofWDigitizer(const char* name, Int_t iVerbose = 1); + R3BSofTofWDigitizer(const TString& name, int iVerbose = 1); /** Destructor **/ ~R3BSofTofWDigitizer(); - /** Virtual method Init **/ - virtual InitStatus Init(); + /** Method Init **/ + InitStatus Init() override; - /** Virtual method ReInit **/ - virtual InitStatus ReInit(); + /** Method ReInit **/ + InitStatus ReInit() override; - /** Virtual method Exec **/ - virtual void Exec(Option_t* opt); + /** Method Exec **/ + void Exec(Option_t*) override; // Fair specific - virtual void SetParContainers(); + void SetParContainers() override; - virtual void Reset(); + void Reset(); /** Setters for sigmas **/ - void SetSigma_t(Float_t sigma_t) { fsigma_t = sigma_t; } - void SetSigma_ELoss(Float_t sigma_ELoss) { fsigma_ELoss = sigma_ELoss; } + void SetSigma_t(double sigma_t) { fsigma_t = sigma_t; } + void SetSigma_ELoss(double sigma_ELoss) { fsigma_ELoss = sigma_ELoss; } private: void SetParameter(); - TClonesArray* fMCTrack; - TClonesArray* fTofPoints; - TClonesArray* fTofHits; - R3BTGeoPar* fTofWGeoPar; + TClonesArray* fMCTrack = nullptr; + TClonesArray* fTofPoints = nullptr; + TClonesArray* fTofHits = nullptr; + R3BTGeoPar* fTofWGeoPar = nullptr; + TRandom3* rand; - Float_t fsigma_y; - Float_t fsigma_t; + double fsigma_y = 1.; // mm + double fsigma_t = 0.017; // ns + double fsigma_ELoss = 0.; - Float_t fsigma_ELoss; TVector3 fTrans; TRotation fRot; /** Private method AddHitData **/ // Adds a R3BSofTofWHitData to the TofWHitCollection - R3BSofTofWHitData* AddHitData(Int_t paddle, Double_t x, Double_t y, Double_t time); + R3BSofTofWHitData* AddHitData(int paddle, double x, double y, double time); public: // Class definition - ClassDef(R3BSofTofWDigitizer, 1); + ClassDefOverride(R3BSofTofWDigitizer, 2); }; - -#endif diff --git a/tofwall/geobase/create_softofw_geo.C b/tofwall/geobase/create_softofw_geo.C old mode 100755 new mode 100644 index 3262f206..f10d0a4c --- a/tofwall/geobase/create_softofw_geo.C +++ b/tofwall/geobase/create_softofw_geo.C @@ -3,15 +3,16 @@ // // Author: Jose Luis // -// Last Update: 18/02/23 +// Last Update: 29/12/25 // // Comments: // -#include "TGeoManager.h" -#include "TMath.h" +#include +#include #include #include +#include void create_softofw_geo(const TString geoTag = "v2021.3") { @@ -120,118 +121,99 @@ void create_softofw_geo(const TString geoTag = "v2021.3") // SHAPES, VOLUMES AND GEOMETRICAL HIERARCHY // Shape: Plastic scintillator type: TGeoBBox dx = 3.15; - dy = 66.0000; - dz = 0.500000; - TGeoShape* pTOFBox = new TGeoBBox("TOFBox", dx / 2., dy / 2., dz / 2.); - // Volume: TOFLog - TGeoVolume* pTOFLog = new TGeoVolume("TOF_FFs", pTOFBox, pMed34); + dy = 66.0; + dz = 0.50; + auto* pTOFBox = new TGeoBBox("TOFBox", dx / 2., dy / 2., dz / 2.); + auto* pTOFLog = new TGeoVolume("TOF_FFs", pTOFBox, pMed34); pTOFLog->SetVisLeaves(kTRUE); - pTOFLog->SetLineColor(kBlue - 8); + pTOFLog->SetLineColor(kAzure + 10); - // SHAPES, VOLUMES AND GEOMETRICAL HIERARCHY - // Shape: PMs type: TGeoTubeSeg - Double_t rmin = 0.0000; - Double_t rmax = 1.35; - dz = 12.00000; - Double_t phi1 = 0.000000; - Double_t phi2 = 360.0000; - TGeoShape* pPM = new TGeoTubeSeg("PM", rmin, rmax, dz / 2., phi1, phi2); - - TGeoRotation* rot_PM = new TGeoRotation("PMrot"); - rot_PM->RotateX(90.0); + // Shape: PMTs + dz = 12.0; + auto* pPM = new TGeoTubeSeg("PMT", 0., 1.35, dz / 2., 0., 360.); - TGeoVolume* pPM_nbu[28]; - TGeoCombiTrans* pGlobalPMsu[28]; - TGeoCombiTrans* pMatrixPMsu[28]; + auto* rot_PM = new TGeoRotation("PMrot"); + rot_PM->RotateX(90.0); - TGeoVolume* pPM_nbd[28]; - TGeoCombiTrans* pGlobalPMsd[28]; - TGeoCombiTrans* pMatrixPMsd[28]; + std::vector pPM_nbu; + std::vector pGlobalPMsu; + std::vector pMatrixPMsu; - TGeoCombiTrans* pGlobalSci[28]; - TGeoCombiTrans* pMatrixSci[28]; + std::vector pPM_nbd; + std::vector pGlobalPMsd; + std::vector pMatrixPMsd; - char buf[126]; + std::vector pGlobalSci; + std::vector pMatrixSci; - for (int i = 0; i < 28; i++) + for (size_t i = 0; i < 28; i++) { - - sprintf(buf, "PM_up_%i", i + 1); + TString name = Form("PM_up_%zu", i + 1); dx = -3.15 * i + 3.15 * 13. + 3.15 / 2.; dy = 66. / 2. + 6.001; dz = 0.00; - pMatrixPMsu[i] = new TGeoCombiTrans("", dx, dy, dz, rot_PM); + pMatrixPMsu.push_back(new TGeoCombiTrans("", dx, dy, dz, rot_PM)); - pPM_nbu[i] = new TGeoVolume(buf, pPM, pMedAl); + pPM_nbu.push_back(new TGeoVolume(name.Data(), pPM, pMedAl)); pPM_nbu[i]->SetVisLeaves(kTRUE); - pPM_nbu[i]->SetLineColor(kGray); + pPM_nbu[i]->SetLineColor(kGray + 3); ptof->AddNode(pPM_nbu[i], i, pMatrixPMsu[i]); - dx = -3.15 * i + 3.15 * 13. + 3.15 / 2.; dy = 0.00; - dz = 0.00; - pMatrixSci[i] = new TGeoCombiTrans("", dx, dy, dz, rotg); + pMatrixSci.push_back(new TGeoCombiTrans("", dx, dy, dz, rotg)); ptof->AddNode(pTOFLog, i, pMatrixSci[i]); - sprintf(buf, "PM_down_%i", i + 1); + name = Form("PM_down_%zu", i + 1); - dx = -3.15 * i + 3.15 * 13. + 3.15 / 2.; dy = -66. / 2. - 6.001; - dz = 0.00; - pMatrixPMsd[i] = new TGeoCombiTrans("", dx, dy, dz, rot_PM); + pMatrixPMsd.push_back(new TGeoCombiTrans("", dx, dy, dz, rot_PM)); - pPM_nbd[i] = new TGeoVolume(buf, pPM, pMedAl); + pPM_nbd.push_back(new TGeoVolume(name.Data(), pPM, pMedAl)); pPM_nbd[i]->SetVisLeaves(kTRUE); - pPM_nbd[i]->SetLineColor(kGray); + pPM_nbd[i]->SetLineColor(kGray + 3); ptof->AddNode(pPM_nbd[i], i, pMatrixPMsd[i]); } // --------------- Supports -------------------------------------- dx = 100.0; - dy = 4.0; - dz = 5.0; - TGeoShape* plane = new TGeoBBox("plane1", dx / 2., dy / 2., dz / 2.); - TGeoVolume* subplane = new TGeoVolume("", plane, pMedAl); - subplane->SetVisLeaves(kTRUE); - subplane->SetLineColor(5); + dy = 6.0; + dz = 6.0; + auto* profile = new TGeoBBox("Profile1", dx / 2., dy / 2., dz / 2.); + auto* profile1vol = new TGeoVolume("", profile, pMedAl); + profile1vol->SetVisLeaves(kTRUE); + profile1vol->SetLineColor(204); dx = 0.00; - dy = 66. / 2. + 12. + 2.; + dy = 66. / 2. + 12. + 3.; dz = 0.00; - TGeoCombiTrans* pMatrix3 = new TGeoCombiTrans("", dx, dy, dz, 0); - ptof->AddNode(subplane, 0, pMatrix3); + auto* pMatrix3 = new TGeoCombiTrans("", dx, dy, dz, 0); + ptof->AddNode(profile1vol, 1, pMatrix3); - dx = 0.00; - dy = -dy; - dz = 0.00; - TGeoCombiTrans* pMatrix4 = new TGeoCombiTrans("", dx, dy, dz, 0); - ptof->AddNode(subplane, 0, pMatrix4); - - dx = 3.99; - dy = 180.0; - dz = 5.0; - TGeoShape* plane2 = new TGeoBBox("plane2", dx / 2., dy / 2., dz / 2.); - TGeoVolume* subplane2 = new TGeoVolume("", plane2, pMedAl); - subplane2->SetVisLeaves(kTRUE); - subplane2->SetLineColor(5); - - dx = 52.00; - dy = -45.00 + 4; - dz = 0.00; - TGeoCombiTrans* pMatrix5 = new TGeoCombiTrans("", dx, dy, dz, 0); - ptof->AddNode(subplane2, 0, pMatrix5); + auto* pMatrix4 = new TGeoCombiTrans("", dx, -dy, dz, 0); + ptof->AddNode(profile1vol, 2, pMatrix4); - dx = -52.00; - dy = -45.00 + 4; - dz = 0.00; - TGeoCombiTrans* pMatrix6 = new TGeoCombiTrans("", dx, dy, dz, 0); - ptof->AddNode(subplane2, 0, pMatrix6); + dx = 6.0; + dy = 102.0; + dz = 6.0; + auto* profile2 = new TGeoBBox("Profile2", dx / 2., dy / 2., dz / 2.); + auto* profile2vol = new TGeoVolume("", profile2, pMedAl); + profile2vol->SetVisLeaves(kTRUE); + profile2vol->SetLineColor(204); + + dx = 53.; + dy = 0.; + dz = 0.; + auto* pMatrix5 = new TGeoCombiTrans("", dx, dy, dz, 0); + ptof->AddNode(profile2vol, 0, pMatrix5); + + auto* pMatrix6 = new TGeoCombiTrans("", -dx, dy, dz, 0); + ptof->AddNode(profile2vol, 0, pMatrix6); pWorld->AddNode(ptof, 0, pMatrix2); @@ -241,10 +223,13 @@ void create_softofw_geo(const TString geoTag = "v2021.3") gGeoMan->PrintOverlaps(); gGeoMan->Test(); - TFile* geoFile = new TFile(geoFileName, "RECREATE"); + TFile geoFile(geoFileName, "RECREATE"); top->Write(); - geoFile->Close(); + // top->Draw("ogl"); + geoFile.Close(); + std::cout << "\033[34m Creating geometry:\033[0m " << "\033[33m" << geoFileName << " \033[0m" << std::endl; std::cout << "Macro finished successfully." << std::endl; + gApplication->Terminate(); } diff --git a/tofwall/sim/R3BSofTofW.cxx b/tofwall/sim/R3BSofTofW.cxx index 6c6b3723..cb21371b 100644 --- a/tofwall/sim/R3BSofTofW.cxx +++ b/tofwall/sim/R3BSofTofW.cxx @@ -1,21 +1,34 @@ +/****************************************************************************** + * Copyright (C) 2017 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2017-2026 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + // ------------------------------------------------------------------------ // ----- R3BSofTofW source file ----- // ----- Created 24/11/17 by H.Alvarez-Pol ----- // ------------------------------------------------------------------------ #include "R3BSofTofW.h" - -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairVolume.h" #include "R3BLogger.h" #include "R3BMCStack.h" #include "R3BSofTofWPoint.h" -#include "TGeoManager.h" -#include "TVirtualMC.h" -#include "TVirtualMCStack.h" + +#include +#include +#include #include +#include +#include +#include R3BSofTofW::R3BSofTofW() : R3BSofTofW("") @@ -28,7 +41,7 @@ R3BSofTofW::R3BSofTofW(const TString& geoFile, const TGeoTranslation& trans, con } R3BSofTofW::R3BSofTofW(const TString& geoFile, const TGeoCombiTrans& combi) - : R3BDetector("R3BSofTofW", kSOFTofWall, geoFile, combi) + : R3BDetector("R3BSofTofW", kSOFTofWall, geoFile.Data(), combi) , fSofTofWallCollection(new TClonesArray("R3BSofTofWPoint")) , fPosIndex(0) { @@ -77,7 +90,6 @@ Bool_t R3BSofTofW::ProcessHits(FairVolume* vol) if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop() || TVirtualMC::GetMC()->IsTrackDisappeared()) { - fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); fVolumeID = vol->getMCid(); fDetCopyID = vol->getCopyNo(); @@ -105,7 +117,7 @@ Bool_t R3BSofTofW::ProcessHits(FairVolume* vol) fELoss); // Increment number of SofTofWallPoints for this track - R3BStack* stack = static_cast(TVirtualMC::GetMC()->GetStack()); + auto* stack = static_cast(TVirtualMC::GetMC()->GetStack()); stack->AddPoint(kSOFTofWall); ResetParameters(); } @@ -143,9 +155,9 @@ TClonesArray* R3BSofTofW::GetCollection(Int_t iColl) const } // ----- Public method Print ---------------------------------------------- -void R3BSofTofW::Print(Option_t* option) const +void R3BSofTofW::Print(Option_t*) const { - Int_t nHits = fSofTofWallCollection->GetEntriesFast(); + auto nHits = fSofTofWallCollection->GetEntriesFast(); R3BLOG(info, nHits << " points registered in this event"); } @@ -171,7 +183,7 @@ R3BSofTofWPoint* R3BSofTofW::AddPoint(Int_t trackID, Double_t eLoss) { TClonesArray& clref = *fSofTofWallCollection; - Int_t size = clref.GetEntriesFast(); + auto size = clref.GetEntriesFast(); if (fVerboseLevel > 1) { R3BLOG(info, @@ -183,7 +195,7 @@ R3BSofTofWPoint* R3BSofTofW::AddPoint(Int_t trackID, } // ----- Public method CheckIfSensitive ---------------------------------- -Bool_t R3BSofTofW::CheckIfSensitive(std::string name) +bool R3BSofTofW::CheckIfSensitive(std::string name) { if (TString(name).Contains("TOF_FFs")) { @@ -193,4 +205,4 @@ Bool_t R3BSofTofW::CheckIfSensitive(std::string name) return kFALSE; } -ClassImp(R3BSofTofW); +ClassImp(R3BSofTofW) diff --git a/tofwall/sim/R3BSofTofW.h b/tofwall/sim/R3BSofTofW.h index 05c19873..fb160491 100644 --- a/tofwall/sim/R3BSofTofW.h +++ b/tofwall/sim/R3BSofTofW.h @@ -1,8 +1,21 @@ -#ifndef R3BSofTofW_H -#define R3BSofTofW_H +/****************************************************************************** + * Copyright (C) 2017 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2017-2026 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#pragma once #include "R3BDetector.h" -#include "TLorentzVector.h" + +#include class TClonesArray; class R3BSofTofWPoint; @@ -65,12 +78,10 @@ class R3BSofTofW : public R3BDetector /** has to be called after each event to reset the containers */ void Reset() override; - Bool_t CheckIfSensitive(std::string name) override; + bool CheckIfSensitive(std::string name) override; void Initialize() override; - void SetSpecialPhysicsCuts() override { ; } - private: /** Track information to be stored until the track leaves the active volume. **/ @@ -129,5 +140,3 @@ inline void R3BSofTofW::ResetParameters() fTime = fLength = fELoss = fZ = fA = 0; fPosIndex = 0; }; - -#endif /* R3BSofTofW_H */ diff --git a/tofwall/test/CMakeLists.txt b/tofwall/test/CMakeLists.txt index 64683e3b..8b3ef386 100644 --- a/tofwall/test/CMakeLists.txt +++ b/tofwall/test/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################## # Copyright (C) 2017 GSI Helmholtzzentrum für Schwerionenforschung GmbH # -# Copyright (C) 2017-2025 Members of R3B Collaboration # +# Copyright (C) 2017-2026 Members of R3B Collaboration # # # # This software is distributed under the terms of the # # GNU General Public Licence (GPL) version 3, # @@ -17,11 +17,11 @@ if(GTEST_FOUND) testSofTofWContainerPar.cxx) target_link_libraries(SofTofWUnitTests PRIVATE GTest::gtest_main GTest::gmock_main R3BSofTofW) - gtest_discover_tests(SofTofWUnitTests DISCOVERY_TIMEOUT 600) + gtest_discover_tests(SofTofWUnitTests DISCOVERY_TIMEOUT 100) endif(GTEST_FOUND) generate_root_test_script(${R3BSOF_SOURCE_DIR}/tofwall/test/testSofTofWSimulation.C) add_test(NAME SofTofWSimulation COMMAND ${R3BROOT_BINARY_DIR}/sofia/tofwall/test/testSofTofWSimulation.sh) -set_tests_properties(SofTofWSimulation PROPERTIES TIMEOUT "2000") +set_tests_properties(SofTofWSimulation PROPERTIES TIMEOUT "300") set_tests_properties(SofTofWSimulation PROPERTIES PASS_REGULAR_EXPRESSION "Macro finished successfully.") diff --git a/tofwall/test/testSofTofWContainerPar.cxx b/tofwall/test/testSofTofWContainerPar.cxx index d1b6b516..24cf344c 100644 --- a/tofwall/test/testSofTofWContainerPar.cxx +++ b/tofwall/test/testSofTofWContainerPar.cxx @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2017 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2017-2025 Members of R3B Collaboration * + * Copyright (C) 2017-2026 Members of R3B Collaboration * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * diff --git a/tofwall/test/testSofTofWSimulation.C b/tofwall/test/testSofTofWSimulation.C index 998f9fc0..7ae0090c 100644 --- a/tofwall/test/testSofTofWSimulation.C +++ b/tofwall/test/testSofTofWSimulation.C @@ -1,6 +1,6 @@ /****************************************************************************** * Copyright (C) 2021 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2021-2023 Members of R3B Collaboration * + * Copyright (C) 2021-2026 Members of R3B Collaboration * * * * This software is distributed under the terms of the * * GNU General Public Licence (GPL) version 3, * @@ -16,7 +16,7 @@ #include #include -void testSofTofWSimulation(int nbevents = 100) +void testSofTofWSimulation(const int nbevents = 100) { // Timer TStopwatch timer; @@ -38,22 +38,22 @@ void testSofTofWSimulation(int nbevents = 100) // const TString parafile = "test.para.root"; // Basic simulation setup - auto run = new FairRunSim(); + auto run = std::make_unique(); run->SetName("TGeant4"); run->SetStoreTraj(false); run->SetMaterials("media_r3b.geo"); - run->SetSink(new FairRootFileSink(simufile)); + run->SetSink(std::make_unique(simufile)); // Primary particle generator - auto boxGen = new FairIonGenerator(82, 208, 82, 1, 0., 0., 1.09, 0., 0., 0.); - auto primGen = new FairPrimaryGenerator(); - primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + auto ionGen = std::make_unique(82, 208, 82, 1, 0., 0., 1.09, 0., 0., 0.); + auto primGen = std::make_unique(); + primGen->AddGenerator(ionGen.release()); + run->SetGenerator(primGen.release()); // Geometry: Cave - auto cave = new R3BCave("CAVE"); - cave->SetGeometryFileName("r3b_cave.geo"); - run->AddModule(cave); + auto cave = std::make_unique("CAVE"); + cave->SetGeometryFileName("r3b_cave_vacuum.geo"); + run->AddModule(cave.release()); // Geometry: SofTofW run->AddModule(new R3BSofTofW("sof_tof_v2021.3.geo.root", { 0., 0., 60. }));