#include #include #include #include //#define DEBUG_StrawTrkFinder #include #include "COMETGeomId.hxx" #include "COMETGeomIdDef.hxx" #include "IStrawTrkGeomId.hxx" #include "IStrawTrkIdFinder.hxx" #include "IGeomIdFinder.hxx" #include "ICOMETLog.hxx" COMET::IStrawTrkIdFinder::IStrawTrkIdFinder() {} COMET::IStrawTrkIdFinder::~IStrawTrkIdFinder() {} bool COMET::IStrawTrkIdFinder::Search(const std::vector& names, COMET::IGeometryId& id) { // StrawTrk geometry ids that might be removed in the future... Int_t layer = 0, strawGas = 0, strawWire = 0; // StrawTrk the most important geometry ids that must be found (be > 0). Int_t station = -1, manifoldXY = -1, strawTube = -1; // Verbose output if this node path includes "StrawTrk". if(ICOMETLog::GetLogLevel("IStrawTrkIdFinder") >= ICOMETLog::VerboseLevel){ std::string path = GetFullNodePath(names); if(path.find("StrawTrk") != std::string::npos) COMETNamedVerbose("IStrawTrkIdFinder", "Path: " << path); } // Check every string in names... for(std::vector::const_reverse_iterator name = names.rbegin(); name != names.rend(); name++){ // Useful macro to check if name contains str. #define ISTIF_CONTAINS(name, str) ( (*(name)).find(str) != (std::string::npos) ) if (ISTIF_CONTAINS(name, "Station" )) station = ModuleNo(*name); else if(ISTIF_CONTAINS(name, "ManifoldX" )) manifoldXY = 0; // means X else if(ISTIF_CONTAINS(name, "ManifoldY" )) manifoldXY = 1; // means Y else if(ISTIF_CONTAINS(name, "Layer" )) layer = 1; else if(ISTIF_CONTAINS(name, "StrawTube" )) strawTube = ModuleNo(*name); else if(ISTIF_CONTAINS(name, "StrawGas" )) strawGas = 1; else if(ISTIF_CONTAINS(name, "StrawWire" )) strawWire = 1; //else if(ISTIF_CONTAINS(name, "ROESTI" )) roesti = ModuleNo(*name); // Skip the following strings else if(ISTIF_CONTAINS(name, "comet" ) || ISTIF_CONTAINS(name, "DetectorSolenoid") || ISTIF_CONTAINS(name, "StrawTrk" ) ); // No any string above matched, this doesn't belong to StrawTrk else return false; #undef ISTIF_CONTAINS } // Abort when anyone in Station, ManifoldX/Y, and StrawTube ids was not found if(station < 0 || manifoldXY < 0 || strawTube < 0) return false; // Translate into GeomId id = COMET::GeomId::StrawTrk::Module(station, manifoldXY, layer, strawTube, strawGas, strawWire); // Verbose output COMETNamedVerbose("IStrawTrkIdFinder", "Got StrawTrkGeomId: " << "Station(" << station << "):" << "X/Y(" << (manifoldXY? "Y":"X") << "):" << "Layer(" << layer << "):" << "Tube(" << strawTube << "):" << "Gas(" << strawGas << "):" << "Wire(" << strawWire << ")" ); return true; }