#include "ICOMETLog.hxx" #include "IGeometryId.hxx" #include "COMETGeomId.hxx" #include "COMETGeomIdDef.hxx" #include "ICDCGeomId.hxx" COMET::IGeometryId COMET::GeomId::CDC::Detector() { ISettableGeometryId id; id.SetField(COMET::GeomId::Def::kCDC, COMET::GeomId::Def::kDetectorIdMSB, COMET::GeomId::Def::kDetectorIdLSB); return id; } COMET::IGeometryId COMET::GeomId::CDC::LayerId(int isLayer, int layer) { ISettableGeometryId id; id.SetField(COMET::GeomId::Def::kCDC, COMET::GeomId::Def::kDetectorIdMSB, COMET::GeomId::Def::kDetectorIdLSB); id.SetField(isLayer, COMET::GeomId::Def::CDC::kIsCDCLayerMSB, COMET::GeomId::Def::CDC::kIsCDCLayerLSB); id.SetField(layer, COMET::GeomId::Def::CDC::kCDCLayerIdMSB, COMET::GeomId::Def::CDC::kCDCLayerIdLSB); return id; } COMET::IGeometryId COMET::GeomId::CDC::WireId(int isLayer, int layer, int wire) { ISettableGeometryId id; id.SetField(COMET::GeomId::Def::kCDC, COMET::GeomId::Def::kDetectorIdMSB, COMET::GeomId::Def::kDetectorIdLSB); id.SetField(isLayer, COMET::GeomId::Def::CDC::kIsCDCLayerMSB, COMET::GeomId::Def::CDC::kIsCDCLayerLSB); id.SetField(layer, COMET::GeomId::Def::CDC::kCDCLayerIdMSB, COMET::GeomId::Def::CDC::kCDCLayerIdLSB); id.SetField(wire, COMET::GeomId::Def::CDC::kCDCWireIdMSB, COMET::GeomId::Def::CDC::kCDCWireIdLSB); id.SetField(0, COMET::GeomId::Def::CDC::kCDCSenseFlagMSB, COMET::GeomId::Def::CDC::kCDCSenseFlagLSB); return id; } COMET::IGeometryId COMET::GeomId::CDC::SenseWireId(int isLayer, int layer, int wire, int active) { ISettableGeometryId id; id.SetField(COMET::GeomId::Def::kCDC, COMET::GeomId::Def::kDetectorIdMSB, COMET::GeomId::Def::kDetectorIdLSB); id.SetField(isLayer, COMET::GeomId::Def::CDC::kIsCDCLayerMSB, COMET::GeomId::Def::CDC::kIsCDCLayerLSB); id.SetField(layer, COMET::GeomId::Def::CDC::kCDCLayerIdMSB, COMET::GeomId::Def::CDC::kCDCLayerIdLSB); id.SetField(wire, COMET::GeomId::Def::CDC::kCDCWireIdMSB, COMET::GeomId::Def::CDC::kCDCWireIdLSB); id.SetField(1, COMET::GeomId::Def::CDC::kCDCSenseFlagMSB, COMET::GeomId::Def::CDC::kCDCSenseFlagLSB); id.SetField(active, COMET::GeomId::Def::CDC::kCDCActiveWireFlagMSB, COMET::GeomId::Def::CDC::kCDCActiveWireFlagLSB); return id; } bool COMET::GeomId::CDC::IsCDC(IGeometryId inputId) { // Construct a dummy geometry ID ISettableGeometryId id(inputId); // Check that it is a CDC geometry ID int detector = id.GetField(COMET::GeomId::Def::kDetectorIdMSB, COMET::GeomId::Def::kDetectorIdLSB); return detector == COMET::GeomId::Def::kCDC; } bool COMET::GeomId::CDC::IsLayer(COMET::IGeometryId inputId) { // Check it is in the CDC if (!IsCDC(inputId)) return false; // Construct a dummy geometry ID ISettableGeometryId id(inputId); // Check if it is a layer geometry ID return id.GetField(COMET::GeomId::Def::CDC::kIsCDCLayerMSB, COMET::GeomId::Def::CDC::kIsCDCLayerLSB); } bool COMET::GeomId::CDC::IsWire(COMET::IGeometryId inputId) { // Check that it is in the CDC and not a layer return IsCDC(inputId) && !IsLayer(inputId); } bool COMET::GeomId::CDC::IsSense(COMET::IGeometryId inputId) { // If it is not a wire, then we're not interested if (!IsWire(inputId)) return false; // Construct a dummy geometry ID ISettableGeometryId id(inputId); // Check if it is a sense wire return id.GetField(COMET::GeomId::Def::CDC::kCDCSenseFlagMSB, COMET::GeomId::Def::CDC::kCDCSenseFlagLSB); } bool COMET::GeomId::CDC::IsActiveSenseWire(COMET::IGeometryId inputId) { // If it is not a sense wire, then we're not interested if (!IsSense(inputId)) return false; // Construct a dummy geometry ID ISettableGeometryId id(inputId); // Check if it is an active wire return id.GetField(COMET::GeomId::Def::CDC::kCDCActiveWireFlagMSB, COMET::GeomId::Def::CDC::kCDCActiveWireFlagLSB); } int COMET::GeomId::CDC::GetLayerId(COMET::IGeometryId inputId) { // If its not in the CDC, return -1 if (!IsCDC(inputId)) return -1; // Construct a dummy geometry ID ISettableGeometryId id(inputId); // Return the layer ID return id.GetField(COMET::GeomId::Def::CDC::kCDCLayerIdMSB, COMET::GeomId::Def::CDC::kCDCLayerIdLSB); } int COMET::GeomId::CDC::GetWireId(COMET::IGeometryId inputId) { // Check that it is in the CDC and is not a layer ID if (!IsWire(inputId)) return -1; // Build a dummy ID ISettableGeometryId id(inputId); // Return the wire index return id.GetField(COMET::GeomId::Def::CDC::kCDCWireIdMSB, COMET::GeomId::Def::CDC::kCDCWireIdLSB); };