Commit 8c17aa1c authored by Administrator's avatar Administrator
Browse files

Allow to pass matrices to detector classes

Adapt the detecor classes of STS, RICH, MUCH, TRD, TOF and PSD such that it
becomes possible to overwrite the default translation and rotation matrices
read from the geometry file with values from the setup files.
Adapt CbmGeoSetupProvider such that the values read from the setup is properly
passed to the detector classes.
parent b0e24b4c
......@@ -89,7 +89,7 @@ ClassImp(CbmMuch)
// ----- Standard constructor ------------------------------------------
CbmMuch::CbmMuch(const char* name, Bool_t active)
CbmMuch::CbmMuch(const char* name, Bool_t active, TGeoCombiTrans* matrix)
: FairDetector(name, active)
, fTrackID(-1)
, fVolumeID(-1)
......@@ -107,7 +107,7 @@ CbmMuch::CbmMuch(const char* name, Bool_t active)
, flGeoPar(new TList())
, fPar(NULL)
, fVolumeName("")
, fCombiTrans()
, fCombiTrans(matrix)
{
ResetParameters();
......@@ -322,10 +322,14 @@ void CbmMuch::ConstructRootGeometry(TGeoMatrix*)
fGeoScheme->Init(stations, fFlagID);
TGeoMatrix* tempMatrix {nullptr};
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName, fVolumeName, &tempMatrix)) {
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName)) {
LOG(info) << "Importing MUCH geometry from ROOT file " << fgeoName.Data();
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this);
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
if (fCombiTrans) {
LOG(info) << "Overwrite default matrix from the geometry file";
LOG(info) << "Placement of the MUCH detector is explicitely defined from the setup";
fCombiTrans->Print();
}
}
else {
LOG(info) << "Constructing MUCH geometry from ROOT file " << fgeoName.Data();
......
......@@ -18,8 +18,9 @@
#include "FairDetector.h"
#include "TLorentzVector.h"
#include "TVector3.h"
#include <TGeoMatrix.h>
#include <TLorentzVector.h>
#include <TVector3.h>
#include <string>
......@@ -28,7 +29,6 @@ class CbmMuchPoint;
class FairVolume;
class CbmGeoMuchPar;
class TGeoMedium;
class TGeoCombiTrans;
class CbmMuch : public FairDetector {
......@@ -40,8 +40,9 @@ public:
/** Standard constructor.
*@param name detector name
*@param active sensitivity flag
*@param matrix detector placement in the cave, overwrites matrix from geometry file
**/
CbmMuch(const char* name, Bool_t active);
CbmMuch(const char* name, Bool_t active, TGeoCombiTrans* = nullptr);
/** Destructor **/
virtual ~CbmMuch();
......
......@@ -28,7 +28,7 @@
// ----- Default constructor -------------------------------------------
CbmPsdMC::CbmPsdMC(Bool_t active, const char* name)
CbmPsdMC::CbmPsdMC(Bool_t active, const char* name, TGeoCombiTrans* matrix)
: FairDetector(name, active, ToIntegralType(ECbmModuleId::kPsd))
, fPosX(0.)
, fPosZ(0.)
......@@ -44,6 +44,7 @@ CbmPsdMC::CbmPsdMC(Bool_t active, const char* name)
, fEloss(-1.)
, fLayerID(-1)
, fModuleID(-1)
, fCombiTrans(matrix)
{
}
// -------------------------------------------------------------------------
......@@ -66,6 +67,7 @@ void CbmPsdMC::ConstructGeometry()
/*
LOG(info) << GetName() << ": Constructing geometry from file "
<< fgeoName;
......@@ -146,8 +148,18 @@ void CbmPsdMC::ConstructGeometry()
geoFile->Close();
*/
LOG(info) << "Importing PSD geometry from ROOT file " << fgeoName.Data();
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this);
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName)) {
LOG(info) << "Importing PSD geometry from ROOT file " << fgeoName.Data();
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
if (fCombiTrans) {
LOG(info) << "Overwrite default matrix from the geometry file";
LOG(info) << "Placement of the STS detector is explicitely defined from the setup";
fCombiTrans->Print();
}
}
else {
LOG(fatal) << "Geometry format of PSD file " << fgeoName.Data() << " not supported.";
}
}
// -------------------------------------------------------------------------
......
......@@ -37,8 +37,9 @@ public:
/** @brief Constructor
** @param active If set true, ProcessHits will be called
** @param name Name of detector object
** @param matrix detector placement in the cave, overwrites matrix from geometry file
**/
CbmPsdMC(Bool_t active = kTRUE, const char* name = "PSDMC");
CbmPsdMC(Bool_t active = kTRUE, const char* name = "PSDMC", TGeoCombiTrans* = nullptr);
/** Destructor **/
......@@ -152,15 +153,16 @@ private:
TClonesArray* fPsdPoints; //! Output array
/** Track information to be temporarily stored **/
Int_t fTrackID; //! track index
Int_t fAddress; //! address (module and layer)
TLorentzVector fPos; //! position
TLorentzVector fMom; //! momentum
Double_t fTime; //! time
Double_t fLength; //! length
Double_t fEloss; //! energy loss
Int_t fLayerID; //! layer ID
Int_t fModuleID; //! module ID
Int_t fTrackID; //! track index
Int_t fAddress; //! address (module and layer)
TLorentzVector fPos; //! position
TLorentzVector fMom; //! momentum
Double_t fTime; //! time
Double_t fLength; //! length
Double_t fEloss; //! energy loss
Int_t fLayerID; //! layer ID
Int_t fModuleID; //! module ID
TGeoCombiTrans* fCombiTrans; //! Transformation matrix for geometry positioning
/** @brief Register all sensitive volumes
** @param node Pointer to start node
......@@ -177,7 +179,7 @@ private:
CbmPsdMC operator=(const CbmPsdMC&) = delete;
ClassDef(CbmPsdMC, 1)
ClassDef(CbmPsdMC, 2)
};
......
......@@ -55,6 +55,19 @@ CbmRich::CbmRich()
fVerboseLevel = 1;
}
CbmRich::CbmRich(const char* name, Bool_t active, TGeoCombiTrans* matrix)
: FairDetector(name, active, ToIntegralType(ECbmModuleId::kRich))
, fPosIndex(0)
, fRegisterPhotonsOnSensitivePlane(true)
, fRichPoints(new TClonesArray("CbmRichPoint"))
, fRichRefPlanePoints(new TClonesArray("CbmRichPoint"))
, fRichMirrorPoints(new TClonesArray("CbmRichPoint"))
, fRotation(NULL)
, fPositionRotation(matrix)
{
fVerboseLevel = 1;
}
CbmRich::CbmRich(const char* name, Bool_t active, Double_t px, Double_t py, Double_t pz, Double_t rx, Double_t ry,
Double_t rz)
: FairDetector(name, active, ToIntegralType(ECbmModuleId::kRich))
......@@ -278,8 +291,12 @@ void CbmRich::ConstructGeometry()
if (fileName.EndsWith(".root")) {
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName)) {
LOG(info) << "Importing RICH geometry from ROOT file " << fgeoName.Data();
TGeoCombiTrans* fCombiTrans {}; //! Transformation matrix for geometry positioning
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fPositionRotation);
if (fPositionRotation) {
LOG(info) << "Overwrite default matrix from the geometry file";
LOG(info) << "Placement of the RICH detector is explicitely defined from the setup";
fPositionRotation->Print();
}
}
else {
LOG(info) << "Constructing RICH geometry from ROOT file " << fgeoName.Data();
......
......@@ -48,6 +48,13 @@ public:
*/
CbmRich();
/** Standard constructor.
*@param name detetcor name
*@param active sensitivity flag
*@param matrix detector placement in the cave, overwrites matrix from geometry file
**/
CbmRich(const char* name, Bool_t active, TGeoCombiTrans* = nullptr);
/**
* \brief Constructor for the GDML geometry.
* \param[in] name Detector name.
......
......@@ -32,7 +32,7 @@ using std::map;
using std::pair;
// ----- Constructor ---------------------------------------------------
CbmStsMC::CbmStsMC(Bool_t active, const char* name)
CbmStsMC::CbmStsMC(Bool_t active, const char* name, TGeoCombiTrans* matrix)
: FairDetector(name, active, ToIntegralType(ECbmModuleId::kSts))
, fStatusIn()
, fStatusOut()
......@@ -40,7 +40,7 @@ CbmStsMC::CbmStsMC(Bool_t active, const char* name)
, fAddressMap()
, fStsPoints(NULL)
, fSetup(NULL)
, fCombiTrans(NULL)
, fCombiTrans(matrix)
, fProcessNeutrals(kFALSE)
{
}
......@@ -311,6 +311,11 @@ void CbmStsMC::ConstructRootGeometry(TGeoMatrix*)
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName)) {
LOG(info) << "Importing STS geometry from ROOT file " << fgeoName.Data();
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
if (fCombiTrans) {
LOG(info) << "Overwrite default matrix from the geometry file";
LOG(info) << "Placement of the STS detector is explicitely defined from the setup";
fCombiTrans->Print();
}
}
else {
LOG(info) << "Constructing STS geometry from ROOT file " << fgeoName.Data();
......
......@@ -15,10 +15,11 @@
#include "CbmStsTrackStatus.h"
#include "FairDetector.h"
#include "FairRootManager.h"
#include <FairDetector.h>
#include <FairRootManager.h>
#include "TClonesArray.h"
#include <TClonesArray.h>
#include <TGeoMatrix.h>
#include <map>
......@@ -26,7 +27,6 @@ class FairVolume;
class CbmStsPoint;
class CbmStsSetup;
class TGeoNode;
class TGeoCombiTrans;
/** @class CbmStsMC
** @brief Class for the MC transport of the CBM-STS
......@@ -43,8 +43,9 @@ public:
** @param active If set true, ProcessHits will be called and
** CbmStsPoints will be created.
** @param name Name of detector object
** @param matrix detector placement in the cave, overwrites matrix from geometry file
**/
CbmStsMC(Bool_t active = kTRUE, const char* name = "STSMC");
CbmStsMC(Bool_t active = kTRUE, const char* name = "STSMC", TGeoCombiTrans* matrix = nullptr);
/** Destructor **/
......
......@@ -74,7 +74,7 @@ CbmTof::CbmTof()
// ----- Standard constructor ------------------------------------------
CbmTof::CbmTof(const char* name, Bool_t active)
CbmTof::CbmTof(const char* name, Bool_t active, TGeoCombiTrans* matrix)
: FairDetector(name, active, ToIntegralType(ECbmModuleId::kTof))
, fTrackID(-1)
, fVolumeID(-1)
......@@ -86,7 +86,7 @@ CbmTof::CbmTof(const char* name, Bool_t active)
, fPosIndex(0)
, fTofCollection(new TClonesArray("CbmTofPoint"))
, fGeoHandler(new CbmTofGeoHandler())
, fCombiTrans()
, fCombiTrans(matrix)
, fVolumeName("")
, fbOnePointPerTrack(kFALSE)
, fbIsNewTrack(kFALSE)
......@@ -501,6 +501,11 @@ void CbmTof::ConstructRootGeometry(TGeoMatrix*)
{
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName)) {
LOG(info) << "Importing TOF geometry from ROOT file " << fgeoName.Data();
if (fCombiTrans) {
LOG(info) << "Overwrite default matrix from the geometry file";
LOG(info) << "Placement of the TOF detector is explicitely defined from the setup";
fCombiTrans->Print();
}
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
}
else {
......
......@@ -19,9 +19,10 @@
#define CBMTOF_H
#include "FairDetector.h"
#include <FairDetector.h>
#include "TLorentzVector.h"
#include <TGeoMatrix.h>
#include <TLorentzVector.h>
#include <tuple>
#include <map>
......@@ -33,7 +34,6 @@ class CbmTofGeoHandler;
class FairVolume;
class TClonesArray;
class TVector3;
class TGeoCombiTrans;
class TGeoPhysicalNode;
class CbmTof : public FairDetector {
......@@ -46,8 +46,9 @@ public:
/** Standard constructor.
*@param name detetcor name
*@param active sensitivity flag
*@param matrix detector placement in the cave, overwrites matrix from geometry file
**/
CbmTof(const char* name, Bool_t active);
CbmTof(const char* name, Bool_t active, TGeoCombiTrans* = nullptr);
/** Destructor **/
......
......@@ -56,7 +56,7 @@ CbmTrd::CbmTrd()
// ----- Standard constructor ---------------------------------------------
CbmTrd::CbmTrd(const char* name, Bool_t active)
CbmTrd::CbmTrd(const char* name, Bool_t active, TGeoCombiTrans* matrix)
: FairDetector(name, active, ToIntegralType(ECbmModuleId::kTrd))
, fPosIn()
, fMomIn()
......@@ -69,7 +69,7 @@ CbmTrd::CbmTrd(const char* name, Bool_t active)
, fTrdPoints(new TClonesArray("CbmTrdPoint"))
, fGeoHandler(new CbmTrdGeoHandler())
, fUseGlobalPhysicsProcesses(kFALSE)
, fCombiTrans(nullptr)
, fCombiTrans(matrix)
{
fVerboseLevel = 1;
}
......@@ -313,6 +313,11 @@ void CbmTrd::ConstructRootGeometry(TGeoMatrix*)
if (Cbm::GeometryUtils::IsNewGeometryFile(fgeoName)) {
LOG(info) << "Importing TRD geometry from ROOT file " << fgeoName.Data();
Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
if (fCombiTrans) {
LOG(info) << "Overwrite default matrix from the geometry file";
LOG(info) << "Placement of the TRD detector is explicitely defined from the setup";
fCombiTrans->Print();
}
}
else {
LOG(info) << "Constructing TRD geometry from ROOT file " << fgeoName.Data();
......
......@@ -12,10 +12,11 @@
#ifndef CBMTRD_H_
#define CBMTRD_H_
#include "FairDetector.h"
#include <FairDetector.h>
#include "TLorentzVector.h"
#include "TVector3.h"
#include <TGeoMatrix.h>
#include <TLorentzVector.h>
#include <TVector3.h>
#include <string>
......@@ -23,7 +24,6 @@ class CbmTrdPoint;
class CbmTrdGeoHandler;
class FairVolume;
class TClonesArray;
class TGeoCombiTrans;
/**
* \class CbmTrd
......@@ -42,8 +42,9 @@ public:
* \brief Standard constructor.
* \param name Detector name.
* \param active Sensitivity flag
* \param matrix detector placement in the cave, overwrites matrix from geometry file
**/
CbmTrd(const char* name, Bool_t active);
CbmTrd(const char* name, Bool_t active, TGeoCombiTrans* = nullptr);
CbmTrd(const CbmTrd&) = delete;
CbmTrd operator=(const CbmTrd&) = delete;
......@@ -58,7 +59,7 @@ public:
* Creates CbmTrdPoints and adds them to the collection.
* \param vol Pointer to the active volume.
**/
virtual Bool_t ProcessHits(FairVolume* vol = NULL);
virtual Bool_t ProcessHits(FairVolume* vol = nullptr);
/**
* \brief If verbosity level is set, print hit collection at the end of the event and resets it afterwards.
......@@ -131,7 +132,7 @@ private:
virtual void Initialize();
virtual void SetSpecialPhysicsCuts();
virtual void ConstructRootGeometry(TGeoMatrix* shift = NULL);
virtual void ConstructRootGeometry(TGeoMatrix* = nullptr);
ClassDef(CbmTrd, 10);
......
......@@ -29,6 +29,8 @@
//#include "CbmShield.h"
#include "CbmPlatform.h"
#include <TGeoMatrix.h> // for TGeoHMatrix, for TGeoCombiTrans
#include <boost/algorithm/string.hpp>
ClassImp(CbmGeoSetupProvider);
......@@ -98,6 +100,8 @@ void CbmGeoSetupProvider::RegisterSetup()
std::string geoTag = geoModule.GetTag();
std::string modulName = geoModule.GetName();
TGeoCombiTrans* combiTrans = CreateCombiTrans(geoModule.GetMatrix());
std::vector<std::string> _geom;
std::vector<std::string> _tag;
boost::split(_geom, fileName, [](char c) { return c == ':'; });
......@@ -123,16 +127,16 @@ void CbmGeoSetupProvider::RegisterSetup()
}
case ECbmModuleId::kTarget: fairModule = new CbmTarget(); break;
case ECbmModuleId::kMvd: fairModule = new CbmMvd("MVD", isActive); break;
case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive); break;
case ECbmModuleId::kRich: fairModule = new CbmRich("RICH", isActive); break;
case ECbmModuleId::kMuch: fairModule = new CbmMuch("MUCH", isActive); break;
case ECbmModuleId::kTrd: fairModule = new CbmTrd("TRD", isActive); break;
case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive, "STSMC", combiTrans); break;
case ECbmModuleId::kRich: fairModule = new CbmRich("RICH", isActive, combiTrans); break;
case ECbmModuleId::kMuch: fairModule = new CbmMuch("MUCH", isActive, combiTrans); break;
case ECbmModuleId::kTrd: fairModule = new CbmTrd("TRD", isActive, combiTrans); break;
case ECbmModuleId::kTof:
fairModule = new CbmTof("TOF", isActive);
fairModule = new CbmTof("TOF", isActive, combiTrans);
break;
// case ECbmModuleId::kEcal: fairModule = new CbmEcal("Ecal", isActive); break;
case ECbmModuleId::kPsd:
fairModule = new CbmPsdMC(isActive);
fairModule = new CbmPsdMC(isActive, "PSDMC", combiTrans);
break;
// case ECbmModuleId::kShield: fairModule = new CbmShield("SHIELD"); break;
case ECbmModuleId::kPlatform: fairModule = new CbmPlatform("PLATFORM"); break;
......@@ -150,6 +154,15 @@ void CbmGeoSetupProvider::RegisterSetup()
}
}
TGeoCombiTrans* CbmGeoSetupProvider::CreateCombiTrans(const TGeoHMatrix matrix)
{
if (matrix.IsIdentity()) { return nullptr; }
else {
LOG(info) << "Create matrix";
return new TGeoCombiTrans(matrix);
}
}
void CbmGeoSetupProvider::Reset() { fSetup = CbmGeoSetup(); }
CbmGeoSetupModule CbmGeoSetupProvider::GetDefaultCaveModule()
......
......@@ -14,7 +14,8 @@
#include "CbmGeoSetup.h"
#include "CbmGeoSetupModule.h"
#include "TObject.h"
#include <TGeoMatrix.h> // for TGeoMatrix, TGeoCombiTrans
#include <TObject.h>
#include <vector>
......@@ -94,6 +95,8 @@ protected:
CbmGeoSetup fSetup {}; /// underlying geometry setup representation.
private:
TGeoCombiTrans* CreateCombiTrans(const TGeoHMatrix);
ClassDef(CbmGeoSetupProvider, 1);
};
......
......@@ -191,8 +191,8 @@ CbmGeoSetup CbmGeoSetupRepoProvider::GetSetupByTag(std::string setupTag, std::st
// Regex to get the translation or rotation parameters parameters if any
// [\w ,.-] means a combunation of any word charcter plus . plus , plus - plus blanks
std::regex transRegex( R"(.*)" + detector.second.translation +R"(\s+=\s+\{([\w ,.-]+)\};)" );
std::regex rotRegex( R"(.*)" + detector.second.rotation +R"(\s+=\s+\{([\w ,.-]+)\};)" );
std::regex transRegex(R"(.*)" + detector.second.translation + R"(\s+=\s+\{([\w ,.-]+)\};)");
std::regex rotRegex(R"(.*)" + detector.second.rotation + R"(\s+=\s+\{([\w ,.-]+)\};)");
std::string tag;
std::string translation;
......@@ -209,35 +209,33 @@ CbmGeoSetup CbmGeoSetupRepoProvider::GetSetupByTag(std::string setupTag, std::st
moduleMap[moduleId] = GetModuleByTag(moduleId, tag);
if (translation.size()) {
LOG(info) << "Found Translation info for " << detector.second.tag
<< " in the setup file: " << translation;
LOG(info) << "Found Translation info for " << detector.second.tag << " in the setup file: " << translation;
std::vector<std::string> vector_elements;
boost::split(vector_elements, translation, [](char c) { return c == ','; });
if (3 != vector_elements.size() ) {
if (3 != vector_elements.size()) {
LOG(error) << "Wrong size of the passed translation matrix. Must be 3 but is " << vector_elements.size();
LOG(fatal) << "Passed matrix: " << translation;
}
int counter = 0;
Double_t _trans[3];
for (auto& elem : vector_elements) {
_trans[counter] = std::stod(elem);
_trans[counter] = std::stod(elem);
counter++;
}
moduleMap[moduleId].GetMatrix().SetTranslation(_trans);
}
if (rotation.size()) {
LOG(info) << "Found Rotation info for " << detector.second.tag
<< " in the setup file: " << rotation;
LOG(info) << "Found Rotation info for " << detector.second.tag << " in the setup file: " << rotation;
std::vector<std::string> matrix_elements;
boost::split(matrix_elements, rotation, [](char c) { return c == ','; });
if (9 != matrix_elements.size() ) {
LOG(error) << "Wrong size of the passed translation matrix. Must be 3 but is " << matrix_elements.size();
if (9 != matrix_elements.size()) {
LOG(error) << "Wrong size of the passed translation matrix. Must be 9 but is " << matrix_elements.size();
LOG(fatal) << "Passed matrix: " << rotation;
}
int counter = 0;
Double_t _rot[9];
for (auto& elem : matrix_elements) {
_rot[counter] = std::stod(elem);
_rot[counter] = std::stod(elem);
counter++;
}
moduleMap[moduleId].GetMatrix().SetRotation(_rot);
......@@ -307,8 +305,6 @@ CbmGeoSetupModule CbmGeoSetupRepoProvider::GetModuleByTag(ECbmModuleId moduleId,
}
full_file_path.pop_back(); // Remove the last ;
CbmGeoSetupModule module;
module.SetName(detector.name);
module.SetFilePath(full_file_path);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment