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

Add segmentation and get cellIDD

parent 7a542a93
No related branches found
Tags v1.3.0
No related merge requests found
......@@ -4,7 +4,8 @@
################################################################################
gaudi_subdir(DetDriftChamber v0r0)
gaudi_depends_on_subdirs(GaudiKernel)
gaudi_depends_on_subdirs(Detector/DetSegmentation)
#gaudi_depends_on_subdirs(GaudiKernel)
find_package(DD4hep COMPONENTS DDRec DDG4 DDParsers REQUIRED)
......
......@@ -57,9 +57,9 @@
<readouts>
<readout name="DriftChamberHitsCollection">
<segmentation type="NoSegmentation"/>
<segmentation type="GridDriftChamber" delta_phi="8*deg" identifier_phi="phi"/>
<id>system:8,chamber:1,layer:8</id>
<id>system:8,chamber:1,layer:8,phi:16</id>
</readout>
</readouts>
......
......@@ -12,6 +12,7 @@
#include "XML/Utilities.h"
#include "DDRec/DetectorData.h"
#include "DDSegmentation/Segmentation.h"
#include "DetSegmentation/GridDriftChamber.h"
using namespace dd4hep;
using namespace dd4hep::detail;
......@@ -74,6 +75,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
dd4hep::Tube det_outer_chamber_solid(outer_chamber_radius_min, outer_chamber_radius_max, outer_chamber_length*0.5);
dd4hep::Volume det_outer_chamber_vol(det_name+"_outer_chamber_vol", det_outer_chamber_solid, det_mat);
// - layer
for(int layer_id=0; layer_id<(inner_chamber_layer_number+outer_chamber_layer_number-1);layer_id++) {
double rmin,rmax;
......
File added
#################################################################################
##Package : DetSegmentation
#################################################################################
gaudi_subdir(DetSegmentation v1r0)
gaudi_depends_on_subdirs(GaudiKernel)
find_package(DD4hep COMPONENTS DDRec DDG4 DDParsers REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake )
include(DD4hep)
find_package(ROOT COMPONENTS MathCore Physics GenVector Geom REQUIRED)
gaudi_add_library(DetSegmentation
src/*.cpp
INCLUDE_DIRS DD4hep ROOT
LINK_LIBRARIES GaudiKernel DD4hep ROOT ${DD4hep_COMPONENT_LIBRARIES}
PUBLIC_HEADERS DetSegmentation)
gaudi_add_module(DetSegmentationPlugin
src/plugins/*.cpp
INCLUDE_DIRS DD4hep ROOT
LINK_LIBRARIES GaudiKernel DD4hep ROOT ${DD4hep_COMPONENT_LIBRARIES} DetSegmentation)
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}")
dd4hep_generate_rootmap(DetSegmentationPlugin)
include(CTest)
gaudi_add_test(TestSegmentationPhiEta
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
FRAMEWORK tests/options/phiEtaSegmentation.py)
#ifndef DETSEGMENTATION_GRIDDRIFTCHAMBER_H
#define DETSEGMENTATION_GRIDDRIFTCHAMBER_H
#include "DDSegmentation/Segmentation.h"
#include "TVector3.h"
#include <cmath>
#include <iostream>
/** GridDriftChamber Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h GridDriftChamber.h
*
* Segmentation for drift chamber.
*
* @author nalipour
*/
namespace dd4hep {
namespace DDSegmentation {
class GridDriftChamber : public Segmentation {
public:
/// default constructor using an arbitrary type
GridDriftChamber(const std::string& aCellEncoding);
/// Default constructor used by derived classes passing an existing decoder
GridDriftChamber(const BitFieldCoder* decoder);
/// destructor
virtual ~GridDriftChamber() = default;
virtual Vector3D position(const CellID& aCellID) const;
virtual CellID cellID(const Vector3D& aLocalPosition, const Vector3D& aGlobalPosition,
const VolumeID& aVolumeID) const;
// inline double innerRadius() const { return m_innerRadius; }
// inline double detectorLength() const { return m_detectorLength; }
inline double offsetPhi() const { return m_offsetPhi; }
inline double delta_phi() const{ return m_delta_phi; }
inline const std::string& fieldNamePhi() const { return m_phiID; }
// Setters
// inline void setGeomParams(int layer, double sizePhi) {
// layer_params[layer] = {sizePhi};
// }
// void updateParams(int layer) const {
// auto it_end = layer_params.cend();
// --it_end;
// double size = it_end->second[0];
// double radius = it_end->second[1];
// double eps = it_end->second[2];
//
// auto map_it = layer_params.find(layer);
// if (map_it != layer_params.cend()) {
// size = map_it->second[0];
// radius = map_it->second[1];
// eps = map_it->second[2];
// }
//
// _currentGridSizePhi = size;
// _currentRadius = radius;
// m_epsilon = eps;
// }
inline double phiFromXY(const Vector3D& aposition) const {
return std::atan2(aposition.Y, aposition.X) + M_PI ;
}
// inline int returnLayer(double x, double y) const {
// // Hit R position
// double R = std::sqrt(x * x + y * y);
// // Layer
// int layer = int((R - m_innerRadius) / m_cellSize);
// return layer;
// }
protected:
/* *** nalipour *** */
double phi(const CellID& cID) const;
double m_offsetPhi;
double m_delta_phi;
std::string m_phiID;
// Current parameters of the layer: sizePhi
// mutable double _currentGridSizePhi; // current size Phi
// mutable double _currentRadius; // current size radius
// mutable double m_epsilon;
};
}
}
#endif /* DETSEGMENTATION_GRIDDRIFTCHAMBER_H */
#include "DetSegmentation/GridDriftChamber.h"
namespace dd4hep {
namespace DDSegmentation {
/// default constructor using an encoding string
GridDriftChamber::GridDriftChamber(const std::string& cellEncoding) : Segmentation(cellEncoding) {
// define type and description
_type = "GridDriftChamber";
_description = "Drift chamber segmentation in the global coordinates";
registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi");
registerParameter("delta_phi", "delta phi", m_delta_phi, 0., SegmentationParameter::LengthUnit);
}
GridDriftChamber::GridDriftChamber(const BitFieldCoder* decoder) : Segmentation(decoder) {
// define type and description
_type = "GridDriftChamber";
_description = "Drift chamber segmentation in the global coordinates";
registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "phi");
registerParameter("delta_phi", "delta phi", m_delta_phi, 0., SegmentationParameter::LengthUnit);
}
Vector3D GridDriftChamber::position(const CellID& /*cID*/) const {
Vector3D cellPosition = {0, 0, 0};
return cellPosition;
}
CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3D& globalPosition,
const VolumeID& vID) const {
CellID cID = vID;
double phi_hit = phiFromXY(globalPosition);
double posx = globalPosition.X;
double posy = globalPosition.Y;
int lphi = (int) (phi_hit/m_delta_phi);
_decoder->set(cID, m_phiID, lphi);
// std::cout << " myliu: "
// << " x: " << posx
// << " y: " << posy
//// << " pre: " << phi_pre
// << " phi_hit: " << phi_hit
// << " lphi: " << lphi
// << std::endl;
return cID;
}
REGISTER_SEGMENTATION(GridDriftChamber)
}
}
#include "DD4hep/Factories.h"
#include "DD4hep/detail/SegmentationsInterna.h"
namespace {
template <typename T>
dd4hep::SegmentationObject* create_segmentation(const dd4hep::BitFieldCoder* decoder) {
return new dd4hep::SegmentationWrapper<T>(decoder);
}
}
//#include "DetSegmentation/GridEta.h"
//DECLARE_SEGMENTATION(GridEta, create_segmentation<dd4hep::DDSegmentation::GridEta>)
//#include "DetSegmentation/FCCSWGridPhiEta.h"
//DECLARE_SEGMENTATION(FCCSWGridPhiEta, create_segmentation<dd4hep::DDSegmentation::FCCSWGridPhiEta>)
//#include "DetSegmentation/GridRPhiEta.h"
//DECLARE_SEGMENTATION(GridRPhiEta, create_segmentation<dd4hep::DDSegmentation::GridRPhiEta>)
#include "DetSegmentation/GridDriftChamber.h"
DECLARE_SEGMENTATION(GridDriftChamber, create_segmentation<dd4hep::DDSegmentation::GridDriftChamber>)
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