#include #include #include #include #include #include "COMETGeomId.hxx" #include "COMETGeomIdDef.hxx" #include "IECALGeomId.hxx" #include "IECALIdFinder.hxx" #include "IGeomIdFinder.hxx" #include "ICOMETLog.hxx" COMET::IECALIdFinder::IECALIdFinder() {} COMET::IECALIdFinder::~IECALIdFinder() {} //========================================================================= // Search //========================================================================= bool COMET::IECALIdFinder::Search(const std::vector& names, COMET::IGeometryId& id) { // ECAL geometry ids that might be removed in the future... Int_t blockWrapper = 0, crystalOuterWrapper = 0, crystalInnerWrapper = 0, crystal = 0, apdModule = 0, apdSensor = 0, apdWindow = 0; // ECAL the most important geometry ids that must be found (be > 0). Int_t blockModule = -1, crystalModule = -1; // Verbose output if this node path includes "ECAL". if(ICOMETLog::GetLogLevel("IECALIdFinder") >= ICOMETLog::VerboseLevel){ std::string path = GetFullNodePath(names); if(path.find("ECAL") != std::string::npos) COMETNamedVerbose("IECALIdFinder", "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 IEIF_CONTAINS(name, str) ( (*(name)).find(str) != (std::string::npos) ) if (IEIF_CONTAINS(name, "BlockModule" )) blockModule = ModuleNo(*name); else if(IEIF_CONTAINS(name, "BlockWrapper" )) blockWrapper = 1; else if(IEIF_CONTAINS(name, "CrystalModule" )) crystalModule = ModuleNo(*name); else if(IEIF_CONTAINS(name, "CrystalOuterWrapper")) crystalOuterWrapper = 1; else if(IEIF_CONTAINS(name, "CrystalInnerWrapper")) crystalInnerWrapper = 1; else if(IEIF_CONTAINS(name, "Crystal" )) crystal = 1; else if(IEIF_CONTAINS(name, "APDModule" )) apdModule = 1; else if(IEIF_CONTAINS(name, "APDSensor" )) apdSensor = 1; else if(IEIF_CONTAINS(name, "APDWindow" )) apdWindow = 1; // Skip the following strings else if(IEIF_CONTAINS(name, "comet" ) || IEIF_CONTAINS(name, "DetectorSolenoid") || IEIF_CONTAINS(name, "ECAL" ) || IEIF_CONTAINS(name, "Array" ) ); // No any string above matched, this doesn't belong to ECAL else return false; #undef IEIF_CONTAINS } // Abort when both block and crystal module id were not found if(blockModule < 0 || crystalModule < 0) return false; // Translate into GeomId id = COMET::GeomId::ECAL::Module(blockModule, blockWrapper, crystalModule, crystalOuterWrapper, crystalInnerWrapper, crystal, apdModule, apdSensor, apdWindow); // Verbose output COMETNamedVerbose("IECALIdFinder", "Got ECALGeomId: " << "BlkMod(" << blockModule << "):" << "BlkWrap(" << blockWrapper << "):" << "CryMod(" << crystalModule << "):" << "CryWrp(" << crystalOuterWrapper << "):" << "CryWrp(" << crystalInnerWrapper << "):" << "Cry(" << crystal << "):" << "APDMod(" << apdModule << "):" << "APDSen(" << apdSensor << "):" << "APDWin(" << apdWindow << ")"); return true; }