10 #include "TGeoPhysicalNode.h" 
   33     const std::string &volume_path)
 const {
 
   35         std::stringstream reg_exp;
 
   37                 reg_exp << 
"/" << nav_path.first << 
"_(\\d+)";
 
   42         if (std::regex_search(volume_path, match, std::regex(reg_exp.str()))) {
 
   43                 hit_info.
detector_half = (
unsigned char) std::stoul(match[2]);
 
   44                 hit_info.
plane = (
unsigned char) std::stoul(match[3]);
 
   45                 hit_info.
module = (
unsigned char) std::stoul(match[4]);
 
   46                 unsigned char sensor_id((
unsigned char) std::stoul(match[5]));
 
   51                     "general.sensors_per_module_side");
 
   53                 if (sensor_id > sensors_per_module_side - 1) {
 
   55                         sensor_id = sensor_id % (sensors_per_module_side - 1);
 
   65                 if (actPath != 
"" && actPath != 
" ") 
fGeoManager->cd(actPath);
 
   69                 throw std::runtime_error(
"PndLmdGeometryHelper::translateVolumePathToHitLocationInfo: geometry " 
   70                                 "navigation paths mismatch!" 
   71                                 " Seems like you used a different lmd geo config file to create a lmd " 
   72                                 "root geometry which was use in your simulations...");
 
   80         std::vector<PndLmdOverlapInfo> result;
 
   84         if (iHalf < 0 || iPlane < 0 || iModule < 0) {
 
   88         if (iHalf > 2 || iPlane > 4 || iModule > 5) {
 
   89                 std::cerr << 
"ERROR. Invalid module specified.\n";
 
   95                 std::cerr << 
"WARNING! No geoHandling present!\n";
 
  102         for (
int iSensor = 0; iSensor < 400; iSensor++) {
 
  103                 for (
int jSensor = iSensor; jSensor < 400; jSensor++) {
 
  109                                         if (iPlane != hitLoc.
plane) 
continue;
 
  110                                         if (iModule != hitLoc.
module) 
continue;
 
  115                                 std::string path1(geo_handling->
GetPath(
int(iSensor)));
 
  120                                 std::string path2(geo_handling->
GetPath(
int(jSensor)));
 
  136                                 result.push_back(temp);
 
  147         std::string vol_path(geo_handling->
GetPath(sensor_id).Data());
 
  159         int sensor_id(geo_handling->
GetShortID(volume_path.c_str()));
 
  171                 return result->second;
 
  181                 return result->second;
 
  189         std::vector<int> result;
 
  191         for (
auto &info : infos) {
 
  192                 result.push_back(info.overlapID);
 
  204         matrix.MasterToLocal(temp, result);
 
  206         return TVector3(result);
 
  216         matrix.MasterToLocal(temp, result);
 
  218         return TVector3(result);
 
  228         std::string vol_path(geo_handling->
GetPath(
int(sensorId)));
 
  236         TGeoHMatrix matrix = *
fGeoManager->GetCurrentMatrix();
 
  237         if (actPath != 
"" && actPath != 
" ") 
fGeoManager->cd(actPath);
 
  248         int fhalf, fplane, fmodule, fside, fsensor;
 
  249         int bhalf, bplane, bmodule, bside, bsensor;
 
  254         int smalloverlap = -1;
 
  256         fhalf = infoOne.detector_half;
 
  257         bhalf = infoTwo.detector_half;
 
  259         fside = infoOne.module_side;
 
  260         bside = infoTwo.module_side;
 
  262         fplane = infoOne.plane;
 
  263         bplane = infoTwo.plane;
 
  265         fmodule = infoOne.module;
 
  266         bmodule = infoTwo.module;
 
  268         fsensor = infoOne.module_sensor_id;
 
  269         bsensor = infoTwo.module_sensor_id;
 
  271         if (bhalf != fhalf) {
 
  275         if (fside == bside) {
 
  279         if (bplane != fplane) {
 
  282         if (bmodule != fmodule) {
 
  288                 cout << 
"PndLmdGeometryHelper::WARNING: pair with ids (" << id1 << 
", " << id2 << 
") is not sorted.\n";
 
  289                 cout << 
"this shouldn't happen here anymore!\n";
 
  292                 std::swap(fsensor, bsensor);
 
  296         if (fsensor == 0 && bsensor == 5) {
 
  300         else if (fsensor == 3 && bsensor == 8) {
 
  304         else if (fsensor == 4 && bsensor == 9) {
 
  308         else if (fsensor == 3 && bsensor == 6) {
 
  312         else if (fsensor == 1 && bsensor == 8) {
 
  316         else if (fsensor == 2 && bsensor == 8) {
 
  320         else if (fsensor == 2 && bsensor == 9) {
 
  324         else if (fsensor == 3 && bsensor == 7) {
 
  328         else if (fsensor == 4 && bsensor == 7) {
 
  335         return 1000 * fhalf + 100 * fplane + 10 * fmodule + smalloverlap;
 
  346         TGeoHMatrix *matrix = (TGeoHMatrix *) (
fGeoManager->GetCurrentMatrix());
 
  348         if (actPath != 
"" && actPath != 
" ") 
fGeoManager->cd(actPath);
 
  362     bool halfs, 
bool detector) {
 
  364         std::vector<std::string> result;
 
  367         std::vector<std::string> filter_strings;
 
  375         std::cout << 
"total number of alignable volumes: " << all_volume_paths.size() << std::endl;
 
  377         for (
auto filter_string : filter_strings) {
 
  378                 auto found(all_volume_paths.begin());
 
  379                 while (found != all_volume_paths.end()) {
 
  380                         found = std::find_if(found, all_volume_paths.end(), [&](
const std::string& 
s) {
 
  381                                 std::stringstream reg_exp;
 
  382                                 reg_exp<<
"^.*/" << filter_string << 
"_(\\d+)/*$";
 
  384                                 return std::regex_search(
s, match, std::regex(reg_exp.str()));
 
  387                         if (found != all_volume_paths.end()) {
 
  388                                 result.push_back(*found);
 
  395         std::sort(result.begin(), result.end());
 
  402         for (
auto &info : allInfos) {
 
  403                 if (info.overlapID == overlapID) {
 
  412         for (
auto &info : allInfos) {
 
  413                 if (info.overlapID == overlapID) {
 
  423         std::vector<std::string> alignable_volumes;
 
  428                         if (entry) alignable_volumes.push_back(entry->GetPath());
 
  432                 std::vector<std::pair<TGeoNode*, std::string> > current_paths;
 
  433                 current_paths.push_back(std::make_pair(node, 
fGeoManager->GetPath()));
 
  435                 while (current_paths.size() > 0) {
 
  436                         auto temp_current_paths = current_paths;
 
  437                         current_paths.clear();
 
  438                         for (
auto const curpath : temp_current_paths) {
 
  439                                 std::stringstream reg_exp;
 
  441                                         reg_exp << 
"/" + nav_path.first << 
"_(\\d+)";
 
  443                                         if (std::regex_search(curpath.second, match, std::regex(reg_exp.str() + 
"/*$"))) {
 
  444                                                 if (nav_path.second) alignable_volumes.push_back(curpath.second);
 
  448                                 for (
int i = 0; 
i < curpath.first->GetNdaughters(); ++
i) {
 
  449                                         node = curpath.first->GetDaughter(
i);
 
  450                                         std::stringstream full_path;
 
  451                                         full_path << curpath.second << 
"/" << node->GetName();
 
  452                                         current_paths.push_back(std::make_pair(node, full_path.str()));
 
  457         return alignable_volumes;
 
TVector3 transformPndGlobalToSensor(const TVector3 &vec, int sensorId)
PndLmdHitLocationInfo translateVolumePathToHitLocationInfo(const std::string &volume_path) const 
std::vector< int > getAvailableOverlapIDs()
int getSensorTwoFromOverlapID(int overlapID)
const PndLmdHitLocationInfo & createMappingEntry(int sensor_id)
TGeoManager * gGeoManager
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< PndLmdOverlapInfo > getOverlapInfos(int iHalf=-1, int iPlane=-1, int iModule=-1)
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)
int getSensorOneFromOverlapID(int overlapID)
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
PndLmdHitLocationInfo hit1
TVector3 transformPndGlobalToLmdLocal(const TVector3 &vec)
std::string lmd_root_path
int getOverlapIdFromSensorIDs(int id1, int id2)
PndLmdHitLocationInfo hit2
bool isOverlappingArea(const int id1, const int id2)
unsigned char detector_half
virtual ~PndLmdGeometryHelper()