4 #ifndef LMD_LMDMC_PNDLMDGEOMETRYHELPER_H_ 5 #define LMD_LMDMC_PNDLMDGEOMETRYHELPER_H_ 14 #include <boost/property_tree/json_parser.hpp> 15 #include <boost/property_tree/ptree.hpp> 17 #include <TGeoManager.h> 30 stream <<
"detector half: " << (
unsigned int)hit_info.
detector_half <<
"\n";
31 stream <<
"detector plane: " << (
unsigned int)hit_info.
plane <<
"\n";
32 stream <<
"module on half plane: " << (
unsigned int)hit_info.
module <<
"\n";
33 stream <<
"side of module: " << (
unsigned int)hit_info.
module_side <<
"\n";
64 stream <<
"path 1: " << overlap_info.
path1 <<
"\n";
65 stream <<
"path 2: " << overlap_info.
path2 <<
"\n";
66 stream <<
"module path: " << overlap_info.
pathModule <<
"\n";
67 stream <<
"id 1: " << overlap_info.
id1 <<
"\n";
68 stream <<
"id 2: " << overlap_info.
id2 <<
"\n";
69 stream <<
"overlapID: " << overlap_info.
overlapID <<
"\n";
75 boost::property_tree::ptree geometry_properties;
76 std::vector<std::pair<std::string, bool>> navigation_paths;
78 std::map<std::string, PndLmdHitLocationInfo> volume_path_to_hit_info_mapping;
79 std::map<int, PndLmdHitLocationInfo> sensor_id_to_hit_info_mapping;
81 std::string lmd_root_path;
83 TGeoManager *fGeoManager;
85 std::mutex accessMutex;
86 std::vector<std::string> fAlignableVolumes;
88 PndLmdGeometryHelper(
const std::string &geo_params_config_file_url =
"") : fGeoManager(gGeoManager)
90 std::string file_url(geo_params_config_file_url);
91 if (geo_params_config_file_url ==
"") {
92 file_url = std::getenv(
"VMCWORKDIR");
93 file_url +=
"/macro/detectors/lmd/lmd-geo-params.json";
97 read_json(file_url, geometry_properties);
98 }
catch (std::exception &e) {
99 std::cerr <<
"PndLmdGeometryHelper::PndLmdGeometryHelper(): ERROR! Parameter file not present!\n";
100 std::cerr <<
"Was looking for file: " << file_url <<
"\n";
105 std::cerr <<
"ERROR! gGeoManager is unitialized! Please populate the gGeoManager or initialize a run!\n";
109 auto pt_general = geometry_properties.get_child(
"general");
110 for (boost::property_tree::ptree::value_type &nav_path : pt_general.get_child(
"navigation_paths")) {
111 navigation_paths.push_back(std::make_pair(nav_path.second.get<std::string>(
"name"), nav_path.second.get<
bool>(
"is_alignable")));
114 TString actPath = fGeoManager->GetPath();
115 std::stringstream lmd_path;
116 fGeoManager->CdTop();
117 lmd_path << fGeoManager->GetPath() <<
"/" << navigation_paths[0].first <<
"_0";
118 lmd_root_path = lmd_path.str();
119 if (actPath !=
"" && actPath !=
" ")
120 fGeoManager->cd(actPath);
146 std::vector<int> getAvailableOverlapIDs();
147 int getOverlapIdFromSensorIDs(
int id1,
int id2);
148 int getModuleIDFromSensorID(
int sensorID);
149 int getSectorIDfromSensorID(
int sensorID);
150 std::string getModulePathFromModuleID(
int moduleID);
152 TVector3 transformPndGlobalToLmdLocal(
const TVector3 &vec);
153 TVector3 transformPndGlobalToSensor(
const TVector3 &vec,
int sensorId);
155 bool isOverlappingArea(
const int id1,
const int id2);
157 const std::string getPath(
unsigned char...);
159 const TGeoHMatrix getMatrixPndGlobalToSensor(
const int sensorId);
160 const TGeoHMatrix getMatrixSensorToPndGlobal(
const int sensorId);
162 const TGeoHMatrix getMatrixPndGlobalToLmdLocal();
163 const TGeoHMatrix getMatrixLmdLocalToPndGlobal();
165 std::vector<std::string> getAllAlignPaths(
bool sensors =
true,
bool modules =
false,
bool planes =
false,
bool halfs =
false,
bool detector =
false);
168 std::vector<PndLmdOverlapInfo> getOverlapInfos(
int iHalf = -1,
int iPlane = -1,
int iModule = -1);
170 std::vector<std::string> getAllAlignableVolumePaths();
friend std::ostream & operator<<(std::ostream &stream, const PndLmdOverlapInfo &overlap_info)
static PndLmdGeometryHelper & getInstance()
bool operator<(const PndLmdHitLocationInfo &o)
friend std::ostream & operator<<(std::ostream &stream, const PndLmdHitLocationInfo &hit_info)
unsigned char module_side
unsigned char module_sensor_id
PndLmdHitLocationInfo hit1
PndLmdHitLocationInfo hit2
unsigned char detector_half