9 #include "TGeoPhysicalNode.h"
31 const std::string &volume_path)
const {
33 std::stringstream reg_exp;
35 reg_exp <<
"/" << nav_path.first <<
"_(\\d+)";
40 if (std::regex_search(volume_path, match, std::regex(reg_exp.str()))) {
41 hit_info.
detector_half = (
unsigned char) std::stoul(match[2]);
42 hit_info.
plane = (
unsigned char) std::stoul(match[3]);
43 hit_info.
module = (
unsigned char) std::stoul(match[4]);
44 unsigned char sensor_id((
unsigned char) std::stoul(match[5]));
49 "general.sensors_per_module_side");
51 if (sensor_id > sensors_per_module_side - 1) {
53 sensor_id = sensor_id % (sensors_per_module_side - 1);
63 if (actPath !=
"" && actPath !=
" ")
fGeoManager->cd(actPath);
67 throw std::runtime_error(
"PndLmdGeometryHelper::translateVolumePathToHitLocationInfo: geometry "
68 "navigation paths mismatch!"
69 " Seems like you used a different lmd geo config file to create a lmd "
70 "root geometry which was use in your simulations...");
79 std::string vol_path(geo_handling->
GetPath(sensor_id).Data());
91 int sensor_id(geo_handling->
GetShortID(volume_path.c_str()));
103 return result->second;
113 return result->second;
121 std::vector<int> result;
123 for (
int iHalf = 0; iHalf < 2; iHalf++) {
124 for (
int iPlane = 0; iPlane < 4; iPlane++) {
125 for (
int iModule = 0; iModule < 5; iModule++) {
126 for (
int iOverlap = 0; iOverlap < 9; iOverlap++) {
127 overlapID = 1000 * iHalf + 100 * iPlane + 10 * iModule + iOverlap;
128 result.push_back(overlapID);
143 matrix.MasterToLocal(temp, result);
145 return TVector3(result);
155 matrix.MasterToLocal(temp, result);
157 return TVector3(result);
162 std::string vol_path(geo_handling->
GetPath(
int(sensorId)));
170 TGeoHMatrix matrix = *
fGeoManager->GetCurrentMatrix();
171 if (actPath !=
"" && actPath !=
" ")
fGeoManager->cd(actPath);
178 return TGeoHMatrix(result.Inverse());
183 int fhalf, fplane, fmodule, fside, fsensor;
184 int bhalf, bplane, bmodule, bside, bsensor;
189 int smalloverlap = -1;
191 fhalf = infoOne.detector_half;
192 bhalf = infoTwo.detector_half;
194 if (bhalf != fhalf) {
198 fside = infoOne.module_side;
199 bside = infoTwo.module_side;
201 fplane = infoOne.plane;
202 bplane = infoTwo.plane;
204 fmodule = infoOne.module;
205 bmodule = infoTwo.module;
207 fsensor = infoOne.module_sensor_id;
208 bsensor = infoTwo.module_sensor_id;
210 if (fside == bside) {
214 if (bplane != fplane) {
217 if (bmodule != fmodule) {
222 if (fsensor == 0 && bsensor == 5) {
226 else if (fsensor == 3 && bsensor == 8) {
230 else if (fsensor == 4 && bsensor == 9) {
234 else if (fsensor == 3 && bsensor == 6) {
238 else if (fsensor == 1 && bsensor == 8) {
242 else if (fsensor == 2 && bsensor == 8) {
246 else if (fsensor == 2 && bsensor == 9) {
250 else if (fsensor == 3 && bsensor == 7) {
254 else if (fsensor == 4 && bsensor == 7) {
257 return 1000 * fhalf + 100 * fplane + 10 * fmodule + smalloverlap;
265 TGeoHMatrix *matrix = (TGeoHMatrix *) (
fGeoManager->GetCurrentNode()->GetMatrix());
267 if (actPath !=
"" && actPath !=
" ")
fGeoManager->cd(actPath);
278 int fhalf, fplane, fmodule, fside, fsensor;
279 int bhalf, bplane, bmodule, bside, bsensor;
284 fhalf = infoOne.detector_half;
285 bhalf = infoTwo.detector_half;
288 if (bhalf != fhalf) {
292 fside = infoOne.module_side;
293 bside = infoTwo.module_side;
295 fplane = infoOne.plane;
296 bplane = infoTwo.plane;
298 fmodule = infoOne.module;
299 bmodule = infoTwo.module;
301 fsensor = infoOne.module_sensor_id;
302 bsensor = infoTwo.module_sensor_id;
304 if (bplane != fplane) {
307 if (bmodule != fmodule) {
310 if (bside == fside) {
315 if (fsensor == 0 && bsensor == 5) {
319 if (fsensor == 3 && bsensor == 8) {
323 if (fsensor == 4 && bsensor == 9) {
327 if (fsensor == 3 && bsensor == 6) {
331 if (fsensor == 1 && bsensor == 8) {
335 if (fsensor == 2 && bsensor == 8) {
339 if (fsensor == 2 && bsensor == 9) {
343 if (fsensor == 3 && bsensor == 7) {
347 if (fsensor == 4 && bsensor == 7) {
355 bool halfs,
bool detector) {
357 std::vector<std::string> result;
360 std::vector<std::string> filter_strings;
368 std::cout <<
"total number of alignable volumes: " << all_volume_paths.size() << std::endl;
370 for (
auto filter_string : filter_strings) {
371 auto found(all_volume_paths.begin());
372 while (found != all_volume_paths.end()) {
373 found = std::find_if(found, all_volume_paths.end(), [&](
const std::string&
s) {
374 std::stringstream reg_exp;
375 reg_exp<<
"^.*/" << filter_string <<
"_(\\d+)/*$";
377 return std::regex_search(
s, match, std::regex(reg_exp.str()));
380 if (found != all_volume_paths.end()) {
381 result.push_back(*found);
388 std::sort(result.begin(), result.end());
396 std::vector<std::string> alignable_volumes;
401 if (entry) alignable_volumes.push_back(entry->GetPath());
405 std::vector<std::pair<TGeoNode*, std::string> > current_paths;
406 current_paths.push_back(std::make_pair(node,
fGeoManager->GetPath()));
408 while (current_paths.size() > 0) {
409 auto temp_current_paths = current_paths;
410 current_paths.clear();
411 for (
auto const curpath : temp_current_paths) {
412 std::stringstream reg_exp;
414 reg_exp <<
"/" + nav_path.first <<
"_(\\d+)";
416 if (std::regex_search(curpath.second, match, std::regex(reg_exp.str() +
"/*$"))) {
417 if (nav_path.second) alignable_volumes.push_back(curpath.second);
421 for (
int i = 0;
i < curpath.first->GetNdaughters(); ++
i) {
422 node = curpath.first->GetDaughter(
i);
423 std::stringstream full_path;
424 full_path << curpath.second <<
"/" << node->GetName();
425 current_paths.push_back(std::make_pair(node, full_path.str()));
430 return alignable_volumes;
TVector3 transformPndGlobalToSensor(const TVector3 &vec, int sensorId)
PndLmdHitLocationInfo translateVolumePathToHitLocationInfo(const std::string &volume_path) const
static std::vector< int > getAvailableOverlapIDs()
const PndLmdHitLocationInfo & createMappingEntry(int sensor_id)
std::vector< std::pair< std::string, bool > > navigation_paths
TString GetPath(Int_t shortID)
for a given shortID the path is returned
const TGeoHMatrix getMatrixSensorToPndGlobal(const int sensorId)
std::vector< std::string > getAllAlignPaths(bool sensors=true, bool modules=false, bool planes=false, bool halfs=false, bool detector=false)
unsigned char module_side
std::vector< std::string > getAllAlignableVolumePaths() const
std::map< std::string, PndLmdHitLocationInfo > volume_path_to_hit_info_mapping
TGeoManager * fGeoManager
Class to access the naming information of the MVD.
const TGeoHMatrix getMatrixPndGlobalToLmdLocal()
const TGeoHMatrix getMatrixPndGlobalToSensor(const int sensorId)
const PndLmdHitLocationInfo & getHitLocationInfo(const std::string &volume_path)
Bool_t cd(Int_t id)
as the cd command of TGeoManager just with the ID
Int_t GetShortID(TString path)
for a given path the (unique) position of the sensor path in the fSensorNamePar-List is given...
static PndGeoHandling * Instance()
std::map< int, PndLmdHitLocationInfo > sensor_id_to_hit_info_mapping
unsigned char module_sensor_id
const TGeoHMatrix getMatrixLmdLocalToPndGlobal()
boost::property_tree::ptree geometry_properties
TVector3 transformPndGlobalToLmdLocal(const TVector3 &vec)
std::string lmd_root_path
int getOverlapIdFromSensorIDs(int id1, int id2)
bool isOverlappingArea(const int id1, const int id2)
unsigned char detector_half
virtual ~PndLmdGeometryHelper()