Skip to content
Snippets Groups Projects
Unverified Commit 2bde2870 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn Committed by GitHub
Browse files

Merge pull request #48 from myliu-hub/master

Layer the  inner and outer drift chambers
parents 089d48db 8ec8871c
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
################################################################################ ################################################################################
gaudi_subdir(DetDriftChamber v0r0) 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) find_package(DD4hep COMPONENTS DDRec DDG4 DDParsers REQUIRED)
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<lccdd> <lccdd>
<info name="DriftChamber" <info name="DriftChamber"
title="Test with Drift Chamber" title="Test with Drift Chamber"
author="Tao Lin" author="Tao Lin"
url="http://github.com/cepc/CEPCSW" url="http://github.com/cepc/CEPCSW"
status="development" status="development"
version="v0"> version="v0">
<comment>Test with Drift Chamber</comment> <comment>Test with Drift Chamber</comment>
</info> </info>
<includes> <includes>
...@@ -34,7 +34,10 @@ ...@@ -34,7 +34,10 @@
<constant name="SDT_outer_chamber_radius_min" value="1085*mm"/> <constant name="SDT_outer_chamber_radius_min" value="1085*mm"/>
<constant name="SDT_outer_chamber_radius_max" value="SDT_radius_max"/> <constant name="SDT_outer_chamber_radius_max" value="SDT_radius_max"/>
<constant name="SDT_outer_chamber_length" value="SDT_length"/> <constant name="SDT_outer_chamber_length" value="SDT_length"/>
<constant name="SDT_inner_chamber_layer_number" value="67"/>
<constant name="SDT_outer_chamber_layer_number" value="63"/>
<constant name="SDT_chamber_layer_width" value="10*mm"/>
</define> </define>
...@@ -49,18 +52,14 @@ ...@@ -49,18 +52,14 @@
<detectors> <detectors>
<detector id="1" name="DriftChamber" type="DriftChamber" readout="DriftChamberHitsCollection" vis="VisibleBlue" sensitive="true"> <detector id="1" name="DriftChamber" type="DriftChamber" readout="DriftChamberHitsCollection" vis="VisibleBlue" sensitive="true">
<!-- Use cm as unit if you want to use Pandora for reconstruction --> <!-- Use cm as unit if you want to use Pandora for reconstruction -->
</detector> </detector>
</detectors> </detectors>
<readouts> <readouts>
<readout name="DriftChamberHitsCollection"> <readout name="DriftChamberHitsCollection">
<!-- <segmentation type="NoSegmentation"/> --> <segmentation type="GridDriftChamber" delta_phi="8*deg" identifier_phi="phi"/>
<segmentation type="CartesianGridXYZ" <id>system:8,chamber:1,layer:8,phi:16</id>
grid_size_x="1*cm"
grid_size_y="1*cm"
grid_size_z="1*cm"/>
<id>system:8,chamber:1,x:-16,y:-16,z:-16</id>
</readout> </readout>
</readouts> </readouts>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// //
// Author: Tao Lin // Author: Tao Lin
// Mengyao Liu
// //
//==================================================================== //====================================================================
...@@ -11,13 +12,18 @@ ...@@ -11,13 +12,18 @@
#include "XML/Utilities.h" #include "XML/Utilities.h"
#include "DDRec/DetectorData.h" #include "DDRec/DetectorData.h"
#include "DDSegmentation/Segmentation.h" #include "DDSegmentation/Segmentation.h"
#include "DetSegmentation/GridDriftChamber.h"
using namespace dd4hep;
using namespace dd4hep::detail;
using namespace dd4hep::rec ;
#define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl; #define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl;
#define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl; #define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl;
static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
xml_h e, xml_h e,
dd4hep::SensitiveDetector sens) { dd4hep::SensitiveDetector sens) {
// ======================================================================= // =======================================================================
// Parameter Definition // Parameter Definition
// ======================================================================= // =======================================================================
...@@ -27,7 +33,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, ...@@ -27,7 +33,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
std::string det_name = x_det.nameStr(); std::string det_name = x_det.nameStr();
std::string det_type = x_det.typeStr(); std::string det_type = x_det.typeStr();
// - global // - global
double chamber_radius_min = theDetector.constant<double>("SDT_radius_min"); double chamber_radius_min = theDetector.constant<double>("SDT_radius_min");
double chamber_radius_max = theDetector.constant<double>("SDT_radius_max"); double chamber_radius_max = theDetector.constant<double>("SDT_radius_max");
double chamber_length = theDetector.constant<double>("SDT_length"); double chamber_length = theDetector.constant<double>("SDT_length");
...@@ -42,6 +48,11 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, ...@@ -42,6 +48,11 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
double outer_chamber_radius_max = theDetector.constant<double>("SDT_outer_chamber_radius_max"); double outer_chamber_radius_max = theDetector.constant<double>("SDT_outer_chamber_radius_max");
double outer_chamber_length = theDetector.constant<double>("SDT_outer_chamber_length"); double outer_chamber_length = theDetector.constant<double>("SDT_outer_chamber_length");
// - layer
int inner_chamber_layer_number = theDetector.constant<int>("SDT_inner_chamber_layer_number");
int outer_chamber_layer_number = theDetector.constant<int>("SDT_outer_chamber_layer_number");
double chamber_layer_width = theDetector.constant<double>("SDT_chamber_layer_width");
// ======================================================================= // =======================================================================
// Detector Construction // Detector Construction
// ======================================================================= // =======================================================================
...@@ -51,8 +62,8 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, ...@@ -51,8 +62,8 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
dd4hep::Volume motherVol = theDetector.pickMotherVolume(sdet); dd4hep::Volume motherVol = theDetector.pickMotherVolume(sdet);
dd4hep::Material det_mat(theDetector.material("Air")); dd4hep::Material det_mat(theDetector.material("Air"));
// - global // - global
dd4hep::Tube det_solid(chamber_radius_min, chamber_radius_max, chamber_length*0.5); dd4hep::Tube det_solid(chamber_radius_min, chamber_radius_max, chamber_length*0.5);
dd4hep::Volume det_vol(det_name+"_vol", det_solid, det_mat); dd4hep::Volume det_vol(det_name+"_vol", det_solid, det_mat);
...@@ -60,39 +71,59 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, ...@@ -60,39 +71,59 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
dd4hep::Tube det_inner_chamber_solid(inner_chamber_radius_min, inner_chamber_radius_max, inner_chamber_length*0.5); dd4hep::Tube det_inner_chamber_solid(inner_chamber_radius_min, inner_chamber_radius_max, inner_chamber_length*0.5);
dd4hep::Volume det_inner_chamber_vol(det_name+"_inner_chamber_vol", det_inner_chamber_solid, det_mat); dd4hep::Volume det_inner_chamber_vol(det_name+"_inner_chamber_vol", det_inner_chamber_solid, det_mat);
dd4hep::Transform3D transform_inner_chamber(dd4hep::Rotation3D(),
dd4hep::Position(0,0,0));
dd4hep::PlacedVolume det_inner_chamber_phy = det_vol.placeVolume(det_inner_chamber_vol,
transform_inner_chamber);
det_inner_chamber_phy.addPhysVolID("chamber", 0);
if ( x_det.isSensitive() ) {
dd4hep::SensitiveDetector sd = sens;
det_inner_chamber_vol.setSensitiveDetector(sens);
sd.setType("tracker");
}
// - outer // - outer
dd4hep::Tube det_outer_chamber_solid(outer_chamber_radius_min, outer_chamber_radius_max, outer_chamber_length*0.5); 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); 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;
std::string layer_name;
dd4hep::Volume* current_vol_ptr = nullptr;
if(layer_id<inner_chamber_layer_number){
current_vol_ptr = &det_inner_chamber_vol;
rmin = inner_chamber_radius_min+(layer_id*chamber_layer_width);
rmax = rmin+chamber_layer_width;
layer_name = det_name+"_inner_chamber_vol"+_toString(layer_id,"_layer%d");
}else{
current_vol_ptr = &det_outer_chamber_vol;
rmin = outer_chamber_radius_min+((layer_id-inner_chamber_layer_number)*chamber_layer_width);
rmax = rmin+chamber_layer_width;
layer_name = det_name+"_outer_chamber_vol"+_toString(layer_id,"_layer%d");
}
/// Construction of drift chamber layers
dd4hep::Tube layer_solid(rmin,rmax,chamber_length*0.5);
dd4hep::Volume layer_vol(layer_name,layer_solid,det_mat);
dd4hep::Transform3D transform_layer(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.));
dd4hep::PlacedVolume layer_phy = (*current_vol_ptr).placeVolume(layer_vol, transform_layer);
layer_phy.addPhysVolID("layer",layer_id);
/// Set drift chamber layers to sensitive detector
dd4hep::SensitiveDetector sd = sens;
layer_vol.setSensitiveDetector(sens);
sd.setType("tracker");
}
// - place in det
// inner
dd4hep::Transform3D transform_inner_chamber(dd4hep::Rotation3D(),
dd4hep::Position(0,0,0));
dd4hep::PlacedVolume det_inner_chamber_phy = det_vol.placeVolume(det_inner_chamber_vol,
transform_inner_chamber);
det_inner_chamber_phy.addPhysVolID("chamber", 0);
// outer
dd4hep::Transform3D transform_outer_chamber(dd4hep::Rotation3D(), dd4hep::Transform3D transform_outer_chamber(dd4hep::Rotation3D(),
dd4hep::Position(0,0,0)); dd4hep::Position(0,0,0));
dd4hep::PlacedVolume det_outer_chamber_phy = det_vol.placeVolume(det_outer_chamber_vol, dd4hep::PlacedVolume det_outer_chamber_phy = det_vol.placeVolume(det_outer_chamber_vol,
transform_outer_chamber); transform_inner_chamber);
det_outer_chamber_phy.addPhysVolID("chamber", 1);
det_inner_chamber_phy.addPhysVolID("chamber", 1);
if ( x_det.isSensitive() ) {
dd4hep::SensitiveDetector sd = sens;
det_outer_chamber_vol.setSensitiveDetector(sens);
sd.setType("tracker");
}
// - place in world // - place in world
dd4hep::Transform3D transform(dd4hep::Rotation3D(), dd4hep::Transform3D transform(dd4hep::Rotation3D(),
dd4hep::Position(0,0,0)); dd4hep::Position(0,0,0));
dd4hep::PlacedVolume phv = motherVol.placeVolume(det_vol,transform); dd4hep::PlacedVolume phv = motherVol.placeVolume(det_vol,transform);
......
#################################################################################
##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