#include #include #include //#define DEBUG_CTHFinder #ifdef DEBUG_CTHFinder #include #endif #include "COMETGeomId.hxx" #include "COMETGeomIdDef.hxx" #include "ICTHGeomId.hxx" #include "ICTHIdFinder.hxx" COMET::ICTHIdFinder::ICTHIdFinder() {;} COMET::ICTHIdFinder::~ICTHIdFinder() {;} static bool GetIndex(const std::string& name, const std::string& pattern, UInt_t * index) { const size_t pos = name.find(pattern); if (pos == std::string::npos) return false; const char * s = name.c_str() + pos + pattern.size(); *index = std::atoi(s); return true; } bool COMET::ICTHIdFinder::Search(const std::vector& names, COMET::IGeometryId& id){ const std::string& name = names.back(); UInt_t mod=0, cnt=0, scint=0, lightG=0; if (GetIndex(name, "ScintLightGuideUS_pv_1_", &cnt)) { scint = lightG = 1; } else if (GetIndex(name, "ScintLightGuideDS_pv_1_", &cnt)) { mod = scint = lightG = 1; } else if (GetIndex(name, "CherenkovLightGuideUS_pv_1_", &cnt)) { lightG = 1; } else if (GetIndex(name, "CherenkovLightGuideDS_pv_1_", &cnt)) { mod = lightG = 1; } else if (GetIndex(name, "CherenkovUS_pv_0_", &cnt)){ } else if (GetIndex(name, "CherenkovDS_pv_0_", &cnt)){ mod = 1; } else if (GetIndex(name, "ScintillatorUS_pv_0_", &cnt)){ scint = 1; } else if (GetIndex(name, "ScintillatorDS_pv_0_", &cnt)){ mod = scint = 1; } else { /* Below is the old naming scheme */ if (GetIndex(name, "Cherenkov_pv_0_", &cnt)){ } else if (GetIndex(name, "Scintillator_pv_0_", &cnt)){ scint = 1; } else { return false; } const UInt_t numberOfSegments = 64; if (cnt >= numberOfSegments) { mod = 1; cnt -= numberOfSegments; } } #ifdef DEBUG_CTHFinder for (std::vector::const_iterator s = names.begin(); s != names.end(); ++s) std::cout << " " << *s; std::cout << std::endl; #endif id = COMET::GeomId::CTH::Counter(mod,cnt,scint,lightG); return true; }