#ifndef TStrawTrkGeom_hxx_seen #define TStrawTrkGeom_hxx_seen #include #include #include #include #include #include #include #include #include #include "IGeomBase.hxx" #include #include namespace COMET { OA_EXCEPTION(ENoStrawTrk,EoaGeomInfo); class IStrawTrkGeom; class IStrawTrkGeomVisitor; class IGeomInfo; } /// Summary of the StrawTrk Geometry. /** * This contains useful * information about the StrawTrk geometry which is derived from the ROOT * TGeoManager geometry description of the CyDet. This must be * accessed through IGeomInfo::StrawTrk(). IStrawTrkGeom is a "singleton" object * that is managed by the IGeomInfo class which really is a singleton. */ class COMET::IStrawTrkGeom : public COMET::IGeomBase { friend class IStrawTrkGeomVisitor; private: COMET::IStrawTrkWireManager *fStrawTrkWireManager; double fStrawDiameter; double fStrawWireDiameter; int fNumberOfStations; int fNumberOfManifolds; int fNumberOfStraws; std::vector fNodeId; COMET::IStrawTrkWireManager::INodeIdMap fNodeIdMap; public: IStrawTrkGeom(); ~IStrawTrkGeom(); /// Fill StrawTrk geometry information void Fill(); /// Clear StrawTrk geometry information void Clear(); /// Printout geometry information void ls(const char* opt); double GetStrawDiameter() const {return fStrawDiameter;} double GetStrawWireDiameter() const {return fStrawWireDiameter;} int GetNumberOfChannels() const {return fStrawTrkWireManager->GetNumberOfChannels();} int GetNumberOfStations() const {return fStrawTrkWireManager->GetNumberOfStations();} int GetNumberOfManifolds() const {return fStrawTrkWireManager->GetNumberOfManifolds();} int GetNumberOfStraws() const {return fStrawTrkWireManager->GetNumberOfStraws();} int GetNumberOfGlobalLayers() const {return fStrawTrkWireManager->GetNumberOfGlobalLayers();} int GetNumberOfGlobalSubLayers() const {return fStrawTrkWireManager->GetNumberOfGlobalSubLayers();} /// Get Geometry information from oaEvent/src/IStrawTrkWireManager.[hxx, cxx] in which wire information are stored int GetSequenceIdFromStrawTrk(const int& station, const int& manifold, const int& straw) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) && (straw >=0 && straw < GetNumberOfStraws()) ) return fStrawTrkWireManager->GetSequenceIdFromStrawTrk(station, manifold, straw); else return -1; } int GetSequenceIdFromGlobalPosition(const TVector3& global) const { return fStrawTrkWireManager->GetSequenceIdFromGlobalPosition(global); } int GetSequenceIdFromGlobalPosition(const double* global) const { double tglob[3] = {global[0], global[1], global[2]}; return fStrawTrkWireManager->GetSequenceIdFromGlobalPosition(tglob); } int GetSequenceIdClosestToGlobalPosition(const TVector3& global, bool findOnSubLayer = false) const; int GetSequenceIdClosestToGlobalPosition(const double* global, bool findOnSubLayer = false) const { TVector3 vglob(global[0], global[1], global[2]); return GetSequenceIdClosestToGlobalPosition(vglob, findOnSubLayer); } int GetSequenceIdClosestToGlobalPositionOnSameSubLayer(const TVector3& global) const { return GetSequenceIdClosestToGlobalPosition(global, true); } int GetSequenceIdClosestToGlobalPositionOnSameSubLayer(const double* global) const { return GetSequenceIdClosestToGlobalPosition(global, true); } int GetSequenceIdFromNodeId(const int& nodeId) const { return fStrawTrkWireManager->GetSequenceIdFromNodeId(nodeId); } int GetSequenceIdFromChannelId(const COMET::IChannelId& chanId) const { return fStrawTrkWireManager->GetSequenceIdFromChannelId(chanId); } int GetSequenceIdFromGeomId(const COMET::IGeometryId& geomId) const { return fStrawTrkWireManager->GetSequenceIdFromGeomId(geomId); } int GetStationIdFromSequenceId(const int& sequenceId) const { return fStrawTrkWireManager->GetStationIdFromSequenceId(sequenceId); } int GetManifoldIdFromSequenceId(const int& sequenceId) const { return fStrawTrkWireManager->GetManifoldIdFromSequenceId(sequenceId); } int GetStrawIdFromSequenceId(const int& sequenceId) const { return fStrawTrkWireManager->GetStrawIdFromSequenceId(sequenceId); } /// The layer number ordered from -Z side in the Detector Solenoid local coordinate. int GetGlobalLayerIdFromSequenceId(const int& sequenceId) const { return fStrawTrkWireManager->GetGlobalLayerIdFromSequenceId(sequenceId); } /// The sublayer number ordered from -Z side in the Detector Solenoid local coordinate. int GetGlobalSubLayerIdFromSequenceId(const int& sequenceId) const { return fStrawTrkWireManager->GetGlobalSubLayerIdFromSequenceId(sequenceId); } int GetStationIdFromGlobalLayerId(const int glayerId) const { return fStrawTrkWireManager->GetStationIdFromGlobalLayerId(glayerId); } int GetStationIdFromGlobalSubLayerId(const int gsublayerId) const { return fStrawTrkWireManager->GetStationIdFromGlobalSubLayerId(gsublayerId); } int GetGlobalLayerIdFromGlobalSubLayerId(int gsublayerId) const { return fStrawTrkWireManager->GetGlobalLayerIdFromGlobalSubLayerId(gsublayerId); } TVector3 GetWirePosition (int sequenceId) const { return fStrawTrkWireManager->GetWirePosition(sequenceId); } TVector3 GetWireEnd0 (int sequenceId) const { return fStrawTrkWireManager->GetWireEnd0(sequenceId); } TVector3 GetWireEnd1 (int sequenceId) const { return fStrawTrkWireManager->GetWireEnd1(sequenceId); } /// Unit vector of the straw direction. This always faces to +X(Y) side in the detector solenoid coordinate. TVector3 GetWireDirection (int sequenceId) const {return (GetWireEnd1(sequenceId)-GetWireEnd0(sequenceId)).Unit(); } bool GetWireDirectionIsY (int sequenceId) const {return fStrawTrkWireManager->GetWireDirectionIsY(sequenceId);} Double_t GetStationPositionZInDS(int sequenceId) const { return fStrawTrkWireManager->GetStationPositionZInDS(sequenceId); } Double_t GetGlobalLayerPositionZInDS(int sequenceId) const { return fStrawTrkWireManager->GetGlobalLayerPositionZInDS(sequenceId); } Double_t GetGlobalSubLayerPositionZInDS(int sequenceId) const { return fStrawTrkWireManager->GetGlobalSubLayerPositionZInDS(sequenceId); } TVector3 GetWirePosition(const int& station, const int& manifold, const int& straw) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) && (straw >=0 && straw < GetNumberOfStraws()) ) return fStrawTrkWireManager->GetWirePosition(station, manifold, straw); else return TVector3(1e10,1e10,1e10); } TVector3 GetWireEnd0(const int& station, const int& manifold, const int& straw) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) && (straw >=0 && straw < GetNumberOfStraws()) ) return fStrawTrkWireManager->GetWireEnd0(station, manifold, straw); else return TVector3(1e10,1e10,1e10); } TVector3 GetWireEnd1(const int& station, const int& manifold, const int& straw) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) && (straw >=0 && straw < GetNumberOfStraws()) ) return fStrawTrkWireManager->GetWireEnd1(station, manifold, straw); else return TVector3(1e10,1e10,1e10); } /// Unit vector of the straw direction. This always faces to +X(Y) side in the detector solenoid coordinate. TVector3 GetWireDirection(const int& station, const int& manifold, const int& straw) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) && (straw >=0 && straw < GetNumberOfStraws()) ) return (fStrawTrkWireManager->GetWireEnd1(station, manifold, straw) - fStrawTrkWireManager->GetWireEnd0(station, manifold, straw)).Unit(); else return TVector3(); } Double_t GetGlobalLayerPositionZInDS(const int& station, const int& manifold) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) ) return fStrawTrkWireManager->GetGlobalLayerPositionZInDS(station, manifold); else return -1e30; } Double_t GetGlobalSubLayerPositionZInDS(const int& station, const int& manifold, const int& straw) const { if ( (station >=0 && station < GetNumberOfStations() ) && (manifold >=0 && manifold < GetNumberOfManifolds()) && (straw >=0 && straw < GetNumberOfStraws() )) return fStrawTrkWireManager->GetGlobalSubLayerPositionZInDS(station, manifold, straw); else return -1e30; } Double_t GetStationPositionZInDSFromStationId(int stationId) const { return fStrawTrkWireManager->GetStationPositionZInDSFromStationId(stationId); } Double_t GetGlobalLayerPositionZInDSFromGlobalLayerId(int glayerId) const { return fStrawTrkWireManager->GetGlobalLayerPositionZInDSFromGlobalLayerId(glayerId); } bool GetGlobalLayerDirectionIsYFromGlobalLayerId(int glayerId) const { return fStrawTrkWireManager->GetGlobalLayerDirectionIsYFromGlobalLayerId(glayerId); } Double_t GetGlobalSubLayerPositionZInDSFromGlobalSubLayerId(int gsublayerId) const { return fStrawTrkWireManager->GetGlobalSubLayerPositionZInDSFromGlobalSubLayerId(gsublayerId); } bool GetGlobalSubLayerDirectionIsYFromGlobalSubLayerId(int gsublayerId) const { return fStrawTrkWireManager->GetGlobalSubLayerDirectionIsYFromGlobalSubLayerId(gsublayerId); } bool GetWireDirectionIsY(const int& station, const int& manifold, const int& straw) const { return fStrawTrkWireManager->GetWireDirectionIsY(station, manifold, straw); } double GetDistanceFromWire(const TVector3& global) const { return fStrawTrkWireManager->GetDistanceFromWire(global); } double GetDistanceFromWire(int sequenceId, const TVector3& global) const { return fStrawTrkWireManager->GetDistanceFromWire(sequenceId, global); } TVector3 GetLocalPosition(int sequenceId, const TVector3& global) const { return fStrawTrkWireManager->GetLocalPosition(sequenceId, global); } TVector3 GetLocalVector(int sequenceId, const TVector3& globalvec) const { return fStrawTrkWireManager->GetLocalVector(sequenceId, globalvec); } int GetStationIdFromGeomId(const COMET::IGeometryId& id) const { return fStrawTrkWireManager->GetStationIdFromGeomId(id); } int GetManifoldIdFromGeomId(const COMET::IGeometryId& id) const { return fStrawTrkWireManager->GetManifoldIdFromGeomId(id); } int GetStrawIdFromGeomId(const COMET::IGeometryId& id) const { return fStrawTrkWireManager->GetStrawIdFromGeomId(id); } /// The layer number ordered from -Z side in the Detector Solenoid local coordinate. int GetGlobalLayerIdFromGeomId(const COMET::IGeometryId& id) const { return fStrawTrkWireManager->GetGlobalLayerIdFromGeomId(id); } /// The sublayer number ordered from -Z side in the Detector Solenoid local coordinate. int GetGlobalSubLayerIdFromGeomId(const COMET::IGeometryId& id) const { return fStrawTrkWireManager->GetGlobalSubLayerIdFromGeomId(id); } /// Estimate a DCA (Distance of closest approach) of the given track for the wire of the given sequenceId, /// if needed, with the left(-1)-right(+1) sign. /** * The signLR of is defined as (-1)=left or (+1)=right. * Here 'right' is the positive side on the measurement axis. * The measurement axis is defined as (wire direction) x (momentum direction), * which is regarded X-axis when Y-axis and Z-axis are wire and beam direction, respectively. * Then 'right' is the right hand side of the wire when seen from the +side of the beam axis * * This definition is based on GENFIT's state vector coordinates: w(plane dir) = u(meas. dir) x v(wire dir) */ double EstimateDCA(int sequenceId, const TVector3& pos, const TVector3& mom, int* signLR = NULL, TVector3* dcaPoint = NULL) const; /// Estimate a DCA (Distance of closest approach) of the given track for the wire of the given geometryId, /// if needed, with the left(-1)-right(+1) sign. /** * The signLR of is defined as (-1)=left or (+1)=right. * Here 'right' is the positive side on the measurement axis. * The measurement axis is defined as (wire direction) x (momentum direction), * which is regarded X-axis when Y-axis and Z-axis are wire and beam direction, respectively. * Then 'right' is the right hand side of the wire when seen from the +side of the beam axis * * This definition is based on GENFIT's state vector coordinates: w(plane dir) = u(meas. dir) x v(wire dir) */ double EstimateDCA(const COMET::IGeometryId& id, const TVector3& pos, const TVector3& mom, int* signLR = NULL, TVector3* dcaPoint = NULL) const; void BuildNodeIdMap(); }; // ------------------------------------------------------------------------------------- /// For information see the discription of the base class 'IGeomVisitor' class COMET::IStrawTrkGeomVisitor : public COMET::IGeomVisitor { public: explicit IStrawTrkGeomVisitor(COMET::IStrawTrkGeom* geom) { fStrawTrkGeom = geom; } bool VisitNode(int depth, const std::string& name, const TGeoNode* node); private: COMET::IStrawTrkGeom* fStrawTrkGeom; }; #endif