Skip to content
Snippets Groups Projects
Commit 3d95f26d authored by myliu@ihep.ac.cn's avatar myliu@ihep.ac.cn
Browse files

The id of the layer of the out chamber starts from 0

parent 86db28b5
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,20 @@ typedef struct Layer ...@@ -30,6 +30,20 @@ typedef struct Layer
} }
} LAYER; } LAYER;
typedef struct CID
{
int chamberID;
int layerID;
// CID(){}
CID(int i, int j): chamberID(i),layerID(j){}
// the operator < defines the operation used in map
friend bool operator < (const CID &c1, const CID &c2);
} vID;
inline bool operator < (const struct CID &c1, const struct CID &c2) {
return c1.chamberID < c2.chamberID || (c1.chamberID == c2.chamberID && c1.layerID < c2.layerID);
}
namespace dd4hep { namespace dd4hep {
namespace DDSegmentation { namespace DDSegmentation {
class GridDriftChamber : public Segmentation { class GridDriftChamber : public Segmentation {
...@@ -74,13 +88,15 @@ public: ...@@ -74,13 +88,15 @@ public:
return hit_phi; return hit_phi;
} }
inline void setGeomParams(int layer, double layerphi, double R, double eps, double offset) { inline void setGeomParams(int chamberID, int layerID, double layerphi, double R, double eps, double offset) {
layer_params.insert(std::pair<int,LAYER>(layer,LAYER(layerphi,R,eps,offset)));
layer_params.insert(std::pair<vID,LAYER>(vID(chamberID,layerID),LAYER(layerphi,R,eps,offset)));
} }
inline void setWiresInLayer(int layer, int numWires) inline void setWiresInLayer(int chamber, int layer, int numWires)
{ {
updateParams(layer); updateParams(chamber,layer);
for (int i = 0; i<numWires; ++i) { for (int i = 0; i<numWires; ++i) {
auto phi_start = _currentLayerphi * (i+0.5) + m_offset; auto phi_start = _currentLayerphi * (i+0.5) + m_offset;
...@@ -106,31 +122,33 @@ public: ...@@ -106,31 +122,33 @@ public:
// return w; // return w;
// } // }
void updateParams(int layer) const{ void updateParams(int chamber, int layer) const{
auto it_end = layer_params.cend(); auto it_end = layer_params.cend();
--it_end; --it_end;
double layerphi = it_end->second.layerphi; double LayerPhi = it_end->second.layerphi;
double radius = it_end->second.R; double Radius = it_end->second.R;
double eps = it_end->second.eps; double Eps = it_end->second.eps;
double offset = it_end->second.offset; double Offset = it_end->second.offset;
auto map_it = layer_params.find(layer); CID v1(chamber,layer);
auto map_it = layer_params.find(v1);
if (map_it != layer_params.cend()) { if (map_it != layer_params.cend()) {
layerphi = map_it->second.layerphi; LayerPhi = map_it->second.layerphi;
radius = map_it->second.R; Radius = map_it->second.R;
eps = map_it->second.eps; Eps = map_it->second.eps;
offset = map_it->second.offset; Offset = map_it->second.offset;
} } else { std::cout << " Sorry, pair with key " << layer << " not in map" << std::endl; }
_currentLayerphi = layerphi;
_currentRadius = radius; _currentLayerphi = LayerPhi;
m_epsilon = eps; _currentRadius = Radius;
m_offset = offset; m_epsilon = Eps;
m_offset = Offset;
} }
protected: protected:
double phi(const CellID& cID) const; double phi(const CellID& cID) const;
std::map<int,LAYER> layer_params; // <layer, {layerphi, R, eps, offset}> std::map<vID,LAYER> layer_params; // <{chamberID,layerID}, {layerphi, R, eps, offset}>
std::map<int, std::vector<std::pair<TVector3, TVector3> >> m_wiresPositions; // < layer, vec<WireMidpoint, WireDirection> > std::map<int, std::vector<std::pair<TVector3, TVector3> >> m_wiresPositions; // < layer, vec<WireMidpoint, WireDirection> >
inline TVector3 returnWirePosition(double angle, int sign) const { inline TVector3 returnWirePosition(double angle, int sign) const {
......
...@@ -54,6 +54,8 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3 ...@@ -54,6 +54,8 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3
CellID cID = vID; CellID cID = vID;
int chamberID = _decoder->get(cID, "chamber");
double posx = globalPosition.X; double posx = globalPosition.X;
double posy = globalPosition.Y; double posy = globalPosition.Y;
double radius = sqrt(posx*posx+posy*posy); double radius = sqrt(posx*posx+posy*posy);
...@@ -64,18 +66,19 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3 ...@@ -64,18 +66,19 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3
if( radius<= m_DC_inner_rend && radius>= m_DC_inner_rbegin) { if( radius<= m_DC_inner_rend && radius>= m_DC_inner_rbegin) {
layerid = floor((radius - m_DC_inner_rbegin)/DC_layerdelta); layerid = floor((radius - m_DC_inner_rbegin)/DC_layerdelta);
} else if ( radius<= m_DC_outer_rend && radius>= m_DC_outer_rbegin ) { } else if ( radius<= m_DC_outer_rend && radius>= m_DC_outer_rbegin ) {
layerid = floor((radius - m_DC_outer_rbegin)/DC_layerdelta)+m_DC_inner_layer_number; layerid = floor((radius - m_DC_outer_rbegin)/DC_layerdelta);
} else if ( radius>= (m_DC_inner_rmin-m_safe_distance) && radius < m_DC_inner_rbegin) { } else if ( radius>= (m_DC_inner_rmin-m_safe_distance) && radius < m_DC_inner_rbegin) {
layerid = 0; layerid = 0;
} else if ( radius> m_DC_inner_rend && radius <= (m_DC_inner_rmax+m_safe_distance)) { } else if ( radius> m_DC_inner_rend && radius <= (m_DC_inner_rmax+m_safe_distance)) {
layerid = m_DC_inner_layer_number-1; layerid = m_DC_inner_layer_number-1;
} else if ( radius>= (m_DC_outer_rmin-m_safe_distance) && radius < m_DC_outer_rbegin) { } else if ( radius>= (m_DC_outer_rmin-m_safe_distance) && radius < m_DC_outer_rbegin) {
layerid = m_DC_inner_layer_number; layerid = 0;
} else if ( radius> m_DC_outer_rend && radius <= (m_DC_outer_rmax+m_safe_distance)) { } else if ( radius> m_DC_outer_rend && radius <= (m_DC_outer_rmax+m_safe_distance)) {
layerid = m_DC_inner_layer_number+ m_DC_outer_layer_number-1; layerid = m_DC_outer_layer_number-1;
} }
updateParams(layerid);
updateParams(chamberID,layerid);
double phi_hit = phiFromXY(globalPosition); double phi_hit = phiFromXY(globalPosition);
double offsetphi= m_offset; double offsetphi= m_offset;
...@@ -103,8 +106,9 @@ double GridDriftChamber::phi(const CellID& cID) const { ...@@ -103,8 +106,9 @@ double GridDriftChamber::phi(const CellID& cID) const {
void GridDriftChamber::cellposition(const CellID& cID, TVector3& Wstart, void GridDriftChamber::cellposition(const CellID& cID, TVector3& Wstart,
TVector3& Wend) const { TVector3& Wend) const {
auto chamberIndex = _decoder->get(cID, "chamber");
auto layerIndex = _decoder->get(cID, "layer"); auto layerIndex = _decoder->get(cID, "layer");
updateParams(layerIndex); updateParams(chamberIndex,layerIndex);
double phi_start = phi(cID); double phi_start = phi(cID);
double phi_mid = phi_start + _currentLayerphi/2.; double phi_mid = phi_start + _currentLayerphi/2.;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment