diff --git a/Detector/DetCEPCv4/CMakeLists.txt b/Detector/DetCEPCv4/CMakeLists.txt
index c7520576b7cf22687029a68535d817e7c4938423..db9c990820b99641b399e1edd621a5f7ad228750 100644
--- a/Detector/DetCEPCv4/CMakeLists.txt
+++ b/Detector/DetCEPCv4/CMakeLists.txt
@@ -22,6 +22,7 @@ gaudi_add_module(DetCEPCv4
                          src/calorimeter/SHcalRpc01_EndcapRing.cpp
                          src/calorimeter/SHcalSc04_Barrel_v04.cpp
                          src/calorimeter/SHcalSc04_Endcaps_v01.cpp
+                         src/calorimeter/SHcalSc04_Endcaps_v02.cpp
                          src/calorimeter/Yoke05_Barrel.cpp
                          src/calorimeter/Yoke05_Endcaps.cpp
                          src/other/BoxSupport_o1_v01_geo.cpp
diff --git a/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Barrel_v04.cpp b/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Barrel_v04.cpp
index d72739195fd9e32cd13594aa5f7d94581977331e..52396b76273fa67f61c95079d7d0177dc6bc9658 100644
--- a/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Barrel_v04.cpp
+++ b/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Barrel_v04.cpp
@@ -22,10 +22,11 @@
 
 using namespace std;
 
-using dd4hep::BUILD_ENVELOPE;
+using dd4hep::_toString;
 using dd4hep::Box;
-using dd4hep::DetElement;
+using dd4hep::BUILD_ENVELOPE;
 using dd4hep::Detector;
+using dd4hep::DetElement;
 using dd4hep::IntersectionSolid;
 using dd4hep::Material;
 using dd4hep::PlacedVolume;
@@ -40,679 +41,607 @@ using dd4hep::Transform3D;
 using dd4hep::Trapezoid;
 using dd4hep::Tube;
 using dd4hep::Volume;
-using dd4hep::_toString;
 
 using dd4hep::rec::LayeredCalorimeterData;
 
 // After reading in all the necessary parameters.
 // To check the radius range and the space for placing the total layers
-static bool validateEnvelope(double rInner, double rOuter, double radiatorThickness, double layerThickness, int layerNumber, int nsymmetry){
-  
+static bool validateEnvelope(double rInner, double rOuter, double radiatorThickness, double layerThickness, int layerNumber, int nsymmetry)
+{
+
   bool Error = false;
   bool Warning = false;
-  double spaceAllowed = rOuter*cos(M_PI/nsymmetry) - rInner;
-  double spaceNeeded  = (radiatorThickness + layerThickness)* layerNumber;
-  double spaceToleranted  = (radiatorThickness + layerThickness)* (layerNumber+1);
-  double rOuterRecommaned = ( rInner + spaceNeeded )/cos(M_PI/16.);
-  int layerNumberRecommaned = floor( ( spaceAllowed ) / (radiatorThickness + layerThickness) );
-  
-  
-  if( spaceNeeded > spaceAllowed )
-    {
-      printout( dd4hep::ERROR,  "SHcalSc04_Barrel_v04", " Layer number is more than it can be built! "  ) ;
-      Error = true;
-    }
-  else if ( spaceToleranted < spaceAllowed )
-    {
-      printout( dd4hep::WARNING,  "SHcalSc04_Barrel_v04", " Layer number is less than it is able to build!" ) ;
-      Warning = true;
-    }
+  double spaceAllowed = rOuter * cos(M_PI / nsymmetry) - rInner;
+  double spaceNeeded = (radiatorThickness + layerThickness) * layerNumber;
+  double spaceToleranted = (radiatorThickness + layerThickness) * (layerNumber + 1);
+  double rOuterRecommaned = (rInner + spaceNeeded) / cos(M_PI / 16.);
+  int layerNumberRecommaned = floor((spaceAllowed) / (radiatorThickness + layerThickness));
+
+  if (spaceNeeded > spaceAllowed)
+  {
+    printout(dd4hep::ERROR, "SHcalSc04_Barrel_v04", " Layer number is more than it can be built! ");
+    Error = true;
+  }
+  else if (spaceToleranted < spaceAllowed)
+  {
+    printout(dd4hep::WARNING, "SHcalSc04_Barrel_v04", " Layer number is less than it is able to build!");
+    Warning = true;
+  }
   else
-    {
-      printout( dd4hep::DEBUG,  "SHcalSc04_Barrel_v04"," has been validated and start to build it." ) ;
-      Error = false;
-      Warning = false;
-    }
-
-  if( Error )
-    {
-      cout<<"\n ============> First Help Documentation <=============== \n"
-	  <<" When you see this message, that means you are crashing the module. \n"
-	  <<" Please take a cup of cafe, and think about what you want to do! \n"
-	  <<" Here are few FirstAid# for you. Please read them carefully. \n"
-	  <<" \n"
-	  <<" ###  FirstAid 1: ###\n"
-	  <<" If you want to build HCAL within the rInner and rOuter range, \n"
-	  <<" please reduce the layer number to " << layerNumberRecommaned <<" \n"
-	  <<" with the current layer thickness structure. \n"
-	  <<" \n"
-	  <<" You may redisgn the layer structure and thickness, too. \n"
-	  <<" \n"
-	  <<" ###  FirstAid 2: ###\n"
-	  <<" If you want to build HCAL with this layer number and the layer thickness, \n"
-	  <<" you have to update rOuter to "<< rOuterRecommaned*10. <<"*mm \n"
-	  <<" and to inform other subdetector, you need this space for building your design. \n"
-	  <<" \n"
-	  <<" ###  FirstAid 3: ###\n"
-	  <<" Do you think that you are looking for another type of HCAL driver? \n"
-	  <<" \n"
-	  <<endl; 
-      throw lcgeo::GeometryException(  "SHcalSc04_Barrel: Error: Layer number is more than it can be built!"   ) ;
-    } 
-  else if( Warning )
-    {
-      cout<<"\n ============> First Help Documentation <=============== \n"
-	  <<" When you see this warning message, that means you are changing the module. \n"
-	  <<" Please take a cup of cafe, and think about what you want to do! \n"
-	  <<" Here are few FirstAid# for you. Please read them carefully. \n"
-	  <<" \n"
-	  <<" ###  FirstAid 1: ###\n"
-	  <<" If you want to build HCAL within the rInner and rOuter range, \n"
-	  <<" You could build the layer number up to " << layerNumberRecommaned <<" \n"
-	  <<" with the current layer thickness structure. \n"
-	  <<" \n"
-	  <<" You may redisgn the layer structure and thickness, too. \n"
-	  <<" \n"
-	  <<" ###  FirstAid 2: ###\n"
-	  <<" If you want to build HCAL with this layer number and the layer thickness, \n"
-	  <<" you could reduce rOuter to "<< rOuterRecommaned*10. <<"*mm \n"
-	  <<" and to reduce the back plate thickness, which you may not need for placing layer. \n"
-	  <<" \n"
-	  <<" ###  FirstAid 3: ###\n"
-	  <<" Do you think that you are looking for another type of HCAL driver? \n"
-	  <<" \n"
-	  <<endl; 
-      return Warning;
-    }
-  else { return true; }
+  {
+    printout(dd4hep::DEBUG, "SHcalSc04_Barrel_v04", " has been validated and start to build it.");
+    Error = false;
+    Warning = false;
+  }
 
+  if (Error)
+  {
+    cout << "\n ============> First Help Documentation <=============== \n"
+         << " When you see this message, that means you are crashing the module. \n"
+         << " Please take a cup of cafe, and think about what you want to do! \n"
+         << " Here are few FirstAid# for you. Please read them carefully. \n"
+         << " \n"
+         << " ###  FirstAid 1: ###\n"
+         << " If you want to build HCAL within the rInner and rOuter range, \n"
+         << " please reduce the layer number to " << layerNumberRecommaned << " \n"
+         << " with the current layer thickness structure. \n"
+         << " \n"
+         << " You may redisgn the layer structure and thickness, too. \n"
+         << " \n"
+         << " ###  FirstAid 2: ###\n"
+         << " If you want to build HCAL with this layer number and the layer thickness, \n"
+         << " you have to update rOuter to " << rOuterRecommaned * 10. << "*mm \n"
+         << " and to inform other subdetector, you need this space for building your design. \n"
+         << " \n"
+         << " ###  FirstAid 3: ###\n"
+         << " Do you think that you are looking for another type of HCAL driver? \n"
+         << " \n"
+         << endl;
+    throw lcgeo::GeometryException("SHcalSc04_Barrel: Error: Layer number is more than it can be built!");
+  }
+  else if (Warning)
+  {
+    cout << "\n ============> First Help Documentation <=============== \n"
+         << " When you see this warning message, that means you are changing the module. \n"
+         << " Please take a cup of cafe, and think about what you want to do! \n"
+         << " Here are few FirstAid# for you. Please read them carefully. \n"
+         << " \n"
+         << " ###  FirstAid 1: ###\n"
+         << " If you want to build HCAL within the rInner and rOuter range, \n"
+         << " You could build the layer number up to " << layerNumberRecommaned << " \n"
+         << " with the current layer thickness structure. \n"
+         << " \n"
+         << " You may redisgn the layer structure and thickness, too. \n"
+         << " \n"
+         << " ###  FirstAid 2: ###\n"
+         << " If you want to build HCAL with this layer number and the layer thickness, \n"
+         << " you could reduce rOuter to " << rOuterRecommaned * 10. << "*mm \n"
+         << " and to reduce the back plate thickness, which you may not need for placing layer. \n"
+         << " \n"
+         << " ###  FirstAid 3: ###\n"
+         << " Do you think that you are looking for another type of HCAL driver? \n"
+         << " \n"
+         << endl;
+    return Warning;
+  }
+  else
+  {
+    return true;
+  }
 }
 
-static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDetector sens)  {
+static Ref_t create_detector(Detector &theDetector, xml_h element, SensitiveDetector sens)
+{
 
   double boundarySafety = 0.0001;
 
-  xml_det_t   x_det       = element;
-  string      det_name    = x_det.nameStr();
-  int           det_id    = x_det.id();
-  DetElement  sdet( det_name, det_id );
+  xml_det_t x_det = element;
+  string det_name = x_det.nameStr();
+  int det_id = x_det.id();
+  DetElement sdet(det_name, det_id);
 
   // --- create an envelope volume and position it into the world ---------------------
-  
-  Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector,  element , sdet ) ;
-  
-  dd4hep::xml::setDetectorTypeFlag( element, sdet ) ;
-  
-  if( theDetector.buildType() == BUILD_ENVELOPE ) return sdet ;
+
+  Volume envelope = dd4hep::xml::createPlacedEnvelope(theDetector, element, sdet);
+
+  dd4hep::xml::setDetectorTypeFlag(element, sdet);
+
+  if (theDetector.buildType() == BUILD_ENVELOPE)
+    return sdet;
 
   //-----------------------------------------------------------------------------------
 
-  xml_comp_t    x_staves          = x_det.staves();
-  Material      stavesMaterial    = theDetector.material(x_staves.materialStr());
-  Material      air               = theDetector.air();
+  xml_comp_t x_staves = x_det.staves(); // absorber
+  Material stavesMaterial = theDetector.material(x_staves.materialStr());
+  Material air = theDetector.air();
 
   PlacedVolume pv;
 
   sens.setType("calorimeter");
 
-//====================================================================
-//
-// Read all the constant from ILD_o1_v05.xml
-// Use them to build HcalBarrel
-//
-//====================================================================
-  double      Hcal_inner_radius   = theDetector.constant<double>("Hcal_inner_radius");
-  double      Hcal_outer_radius   = theDetector.constant<double>("Hcal_outer_radius");
-  double      Hcal_half_length    = theDetector.constant<double>("Hcal_half_length");
-  int         Hcal_inner_symmetry = theDetector.constant<int>("Hcal_inner_symmetry");
-  int         Hcal_outer_symmetry = 0; // Fixed shape for Tube, and not allow to modify from compact xml.
-
-  double      Hcal_radiator_thickness          = theDetector.constant<double>("Hcal_radiator_thickness");
-  double      Hcal_chamber_thickness           = theDetector.constant<double>("Hcal_chamber_thickness");
-  double      Hcal_back_plate_thickness        = theDetector.constant<double>("Hcal_back_plate_thickness");
-  double      Hcal_lateral_plate_thickness     = theDetector.constant<double>("Hcal_lateral_structure_thickness");
-  double      Hcal_stave_gaps                  = theDetector.constant<double>("Hcal_stave_gaps");
-  double      Hcal_modules_gap                 = theDetector.constant<double>("Hcal_modules_gap"); 
-  double      Hcal_middle_stave_gaps           = theDetector.constant<double>("Hcal_middle_stave_gaps");
-  double      Hcal_layer_air_gap               = theDetector.constant<double>("Hcal_layer_air_gap");
-  //double      Hcal_cells_size                  = theDetector.constant<double>("Hcal_cells_size");
-
-  int         Hcal_nlayers                     = theDetector.constant<int>("Hcal_nlayers");
-
-  printout( dd4hep::INFO, "SHcalSc04_Barrel_v04", "Hcal_inner_radius : %e   - Hcal_outer_radius %e ", Hcal_inner_radius , Hcal_outer_radius);
+  //====================================================================
+  //
+  // Read all the constant from ILD_o1_v05.xml
+  // Use them to build HcalBarrel
+  //
+  //====================================================================
+  double Hcal_inner_radius = theDetector.constant<double>("Hcal_inner_radius");
+  double Hcal_outer_radius = theDetector.constant<double>("Hcal_outer_radius");
+  double Hcal_half_length = theDetector.constant<double>("Hcal_half_length");
+  int Hcal_inner_symmetry = theDetector.constant<int>("Hcal_inner_symmetry");
+  int Hcal_outer_symmetry = 0; // Fixed shape for Tube, and not allow to modify from compact xml
+  double Hcal_cell_size = theDetector.constant<double>("Hcal_cell_size");
+  double Hcal_cell_size_abnormal = theDetector.constant<double>("Hcal_cell_size_abnormal");
+  double Hcal_scintillator_air_gap = theDetector.constant<double>("Hcal_scintillator_air_gap");
+  double Hcal_scintillator_ESR_thickness = theDetector.constant<double>("Hcal_scintillator_ESR_thickness");
+  double Hcal_scintillator_thickness = theDetector.constant<double>("Hcal_scintillator_thickness");
+  double Hcal_radiator_thickness = theDetector.constant<double>("Hcal_radiator_thickness");
+  double Hcal_chamber_thickness = theDetector.constant<double>("Hcal_chamber_thickness");
+  double Hcal_back_plate_thickness = theDetector.constant<double>("Hcal_back_plate_thickness");
+  double Hcal_lateral_plate_thickness = theDetector.constant<double>("Hcal_lateral_structure_thickness");
+  double Hcal_stave_gaps = theDetector.constant<double>("Hcal_stave_gaps");
+  // double Hcal_modules_gap = theDetector.constant<double>("Hcal_modules_gap");
+  double Hcal_middle_stave_gaps = theDetector.constant<double>("Hcal_middle_stave_gaps");
+  double Hcal_layer_air_gap = theDetector.constant<double>("Hcal_layer_air_gap");
+  // double      Hcal_cells_size                  = theDetector.constant<double>("Hcal_cells_size");
+
+  int Hcal_nlayers = theDetector.constant<int>("Hcal_nlayers");
+
+  //=================================================================================
+  //  if Hcal_outer_radius stands for the radius of circumcircle, comment next line 
+  Hcal_outer_radius /= cos(M_PI / Hcal_inner_symmetry);
+  //=================================================================================
+  printout(dd4hep::INFO, "SHcalSc04_Barrel_v04", "Hcal_inner_radius : %e   - Hcal_outer_radius %e ", Hcal_inner_radius, Hcal_outer_radius);
   validateEnvelope(Hcal_inner_radius, Hcal_outer_radius, Hcal_radiator_thickness, Hcal_chamber_thickness, Hcal_nlayers, Hcal_inner_symmetry);
 
-  Readout readout = sens.readout();
-  dd4hep::Segmentation seg = readout.segmentation();
-  
-  dd4hep::DDSegmentation::BitField64 encoder = seg.decoder();
-  encoder.setValue(0) ;
-  
-
-  //fg: this is a bit tricky: we first have to check whether a multi segmentation is used and then, if so, we
-  //    will check the <subsegmentation key="" value=""/> element, for which subsegmentation to use for filling the 
-  //    DDRec:LayeredCalorimeterData information.
-  //    Additionally, we need to figure out if there is a TiledLayerGridXY instance defined -
-  //    and in case, there is more than one defined, we need to pick the correct one specified via the
-  //    <subsegmentation key="" value=""/> element.
-  //    This involves a lot of casting:  review the API in DD4hep !!
+  // fg: this is a bit tricky: we first have to check whether a multi segmentation is used and then, if so, we
+  //     will check the <subsegmentation key="" value=""/> element, for which subsegmentation to use for filling the
+  //     DDRec:LayeredCalorimeterData information.
+  //     Additionally, we need to figure out if there is a TiledLayerGridXY instance defined -
+  //     and in case, there is more than one defined, we need to pick the correct one specified via the
+  //     <subsegmentation key="" value=""/> element.
+  //     This involves a lot of casting:  review the API in DD4hep !!
 
   // check if we have a multi segmentation :
 
-  dd4hep::DDSegmentation::MultiSegmentation* multiSeg = 
-    dynamic_cast< dd4hep::DDSegmentation::MultiSegmentation*>( seg.segmentation() ) ;
-  
-  dd4hep::DDSegmentation::TiledLayerGridXY* tileSeg = 0 ;
-    
-  int sensitive_slice_number = -1 ;
-
-  if( multiSeg ){
-
-    try{ 
-      // check if we have an entry for the subsegmentation to be used 
-      xml_comp_t segxml = x_det.child( _Unicode( subsegmentation ) ) ;
-
-      std::string keyStr = segxml.attr<std::string>( _Unicode(key) ) ;
-      int keyVal = segxml.attr<int>( _Unicode(value) )  ;
-
-      encoder[ keyStr ] =  keyVal ;
-
-      // if we have a multisegmentation that uses the slice as key, we need to know for the
-      // computation of the layer parameters in LayeredCalorimeterData::Layer below
-      if( keyStr == "slice" ){
-	sensitive_slice_number = keyVal ;
-      }
-
-
-    } catch(const std::runtime_error &) {
-      throw lcgeo::GeometryException(  "SHcalSc04_Barrel: Error: MultiSegmentation specified but no "
-                                       " <subsegmentation key="" value=""/> element defined for detector ! " ) ;
-    }
-    
-    // check if we have a TiledLayerGridXY segmentation :
-    const dd4hep::DDSegmentation::TiledLayerGridXY* ts0 =
-      dynamic_cast<const dd4hep::DDSegmentation::TiledLayerGridXY*>(  &multiSeg->subsegmentation( encoder.getValue() ) ) ;
-    
-    tileSeg = const_cast<dd4hep::DDSegmentation::TiledLayerGridXY*>( ts0 ) ;
-    
-    if( ! tileSeg ){ // if the current segmentation is not a tileSeg, we see if there is another one
-      
-      for( auto s : multiSeg->subSegmentations() ){
-	const dd4hep::DDSegmentation::TiledLayerGridXY* ts =
-	  dynamic_cast<const dd4hep::DDSegmentation::TiledLayerGridXY*>( s.segmentation ) ;
-	
-	if( ts ) {
-	  tileSeg = const_cast<dd4hep::DDSegmentation::TiledLayerGridXY*>( ts ) ;
-	  break ;
-	}
-      }
-    }
-    
-  } else {
-    
-    tileSeg = 
-      dynamic_cast< dd4hep::DDSegmentation::TiledLayerGridXY*>( seg.segmentation() ) ;
-  }
-  
-  
-
-  std::vector<double> cellSizeVector = seg.cellDimensions( encoder.getValue() ); //Assume uniform cell sizes, provide dummy cellID
-  double cell_sizeX      = cellSizeVector[0];
-  double cell_sizeY      = cellSizeVector[1];
-
-
   //========== fill data for reconstruction ============================
-  LayeredCalorimeterData* caloData = new LayeredCalorimeterData ;
-  caloData->layoutType = LayeredCalorimeterData::BarrelLayout ;
-  caloData->inner_symmetry = Hcal_inner_symmetry  ;
-  caloData->outer_symmetry = Hcal_outer_symmetry  ;
-  caloData->phi0 = 0 ; // fg: also hardcoded below 
+  LayeredCalorimeterData *caloData = new LayeredCalorimeterData;
+  caloData->layoutType = LayeredCalorimeterData::BarrelLayout;
+  caloData->inner_symmetry = Hcal_inner_symmetry;
+  caloData->outer_symmetry = Hcal_outer_symmetry;
+  caloData->phi0 = 0; // fg: also hardcoded below
 
   /// extent of the calorimeter in the r-z-plane [ rmin, rmax, zmin, zmax ] in mm.
-  caloData->extent[0] = Hcal_inner_radius ;
-  caloData->extent[1] = Hcal_outer_radius ;
-  caloData->extent[2] = 0. ; // Barrel zmin is "0" by default.
-  caloData->extent[3] = Hcal_half_length ;
+  caloData->extent[0] = Hcal_inner_radius;
+  caloData->extent[1] = Hcal_outer_radius;
+  caloData->extent[2] = 0.; // Barrel zmin is "0" by default.
+  caloData->extent[3] = Hcal_half_length;
 
-//====================================================================
-//
-// general calculated parameters
-//
-//====================================================================
+  //====================================================================
+  //
+  // general calculated parameters
+  //
+  //====================================================================
 
-  double Hcal_total_dim_y   = Hcal_nlayers * (Hcal_radiator_thickness + Hcal_chamber_thickness) 
-                            + Hcal_back_plate_thickness;
+  double Hcal_total_dim_y = Hcal_nlayers * (Hcal_radiator_thickness + Hcal_chamber_thickness) + Hcal_back_plate_thickness;
 
-  double Hcal_y_dim1_for_x  = Hcal_outer_radius*cos(M_PI/Hcal_inner_symmetry) - Hcal_inner_radius;
-  double Hcal_bottom_dim_x  = 2.*Hcal_inner_radius*tan(M_PI/Hcal_inner_symmetry)- Hcal_stave_gaps;
-  double Hcal_normal_dim_z  = (2 * Hcal_half_length - Hcal_modules_gap)/2.;
+  // double Hcal_y_dim1_for_x = Hcal_outer_radius * cos(M_PI / Hcal_inner_symmetry) - Hcal_inner_radius;
+  double Hcal_bottom_dim_x = 2. * Hcal_inner_radius * tan(M_PI / Hcal_inner_symmetry) - Hcal_lateral_plate_thickness * 2 - Hcal_stave_gaps;
+  // double Hcal_normal_dim_z = (2 * Hcal_half_length - Hcal_modules_gap) / 2.;
+  double Hcal_normal_dim_z = Hcal_half_length;
 
- //only the middle has the steel plate.
-  double Hcal_regular_chamber_dim_z = Hcal_normal_dim_z - Hcal_lateral_plate_thickness;
+  // only the middle has the steel plate.
+  // double Hcal_regular_chamber_dim_z = Hcal_normal_dim_z - Hcal_lateral_plate_thickness;
+  double Hcal_regular_chamber_dim_z = Hcal_normal_dim_z;
 
-  //double Hcal_cell_dim_x            = Hcal_cells_size;
-  //double Hcal_cell_dim_z            = Hcal_regular_chamber_dim_z / floor (Hcal_regular_chamber_dim_z/Hcal_cell_dim_x);
+  // double Hcal_cell_dim_x            = Hcal_cells_size;
+  // double Hcal_cell_dim_z            = Hcal_regular_chamber_dim_z / floor (Hcal_regular_chamber_dim_z/Hcal_cell_dim_x);
+
+  // ========= Create Hcal Barrel stave   ====================================
+  //  It will be the volume for palcing the Hcal Barrel Chamber(i.e. Layers).
+  //  Itself will be placed into the world volume.
+  // ==========================================================================
 
- 
-// ========= Create Hcal Barrel stave   ====================================
-//  It will be the volume for palcing the Hcal Barrel Chamber(i.e. Layers).
-//  Itself will be placed into the world volume.
-// ==========================================================================
- 
-  double chambers_y_off_correction = 0.;
- 
   // stave modules shaper parameters
-  double BHX  = (Hcal_bottom_dim_x + Hcal_stave_gaps)/2.;
-  double THX  = (Hcal_total_dim_y + Hcal_inner_radius)*tan(M_PI/Hcal_inner_symmetry);
-  double YXH  = Hcal_total_dim_y / 2.;
-  double DHZ  = (Hcal_normal_dim_z - Hcal_lateral_plate_thickness) / 2.;
+  double BHX = (Hcal_bottom_dim_x + Hcal_lateral_plate_thickness * 2 + Hcal_stave_gaps) / 2.;
+  double THX = (Hcal_total_dim_y + Hcal_inner_radius) * tan(M_PI / Hcal_inner_symmetry);
+  double YXH = Hcal_total_dim_y / 2.;
+  // double DHZ = (Hcal_normal_dim_z - Hcal_lateral_plate_thickness) / 2.;
+  double DHZ = Hcal_normal_dim_z;
+
+  Trapezoid stave_shaper(THX, BHX, DHZ, DHZ, YXH);
 
-  Trapezoid stave_shaper(  THX, BHX, DHZ, DHZ, YXH);
+  Tube solidCaloTube(0, Hcal_outer_radius, DHZ + boundarySafety);
 
-  Tube solidCaloTube(0, Hcal_outer_radius, DHZ+boundarySafety);
-  
-  RotationZYX mrot(0,0,M_PI/2.);
+  RotationZYX mrot(0, 0, M_PI / 2.);
 
   Rotation3D mrot3D(mrot);
-  Position mxyzVec(0,0,(Hcal_inner_radius + Hcal_total_dim_y / 2.));
-  Transform3D mtran3D(mrot3D,mxyzVec);
+  Position mxyzVec(0, 0, (Hcal_inner_radius + Hcal_total_dim_y / 2.));
+  Transform3D mtran3D(mrot3D, mxyzVec);
 
   IntersectionSolid barrelModuleSolid(stave_shaper, solidCaloTube, mtran3D);
 
-  Volume  EnvLogHcalModuleBarrel(det_name+"_module",barrelModuleSolid,stavesMaterial);
-
-  EnvLogHcalModuleBarrel.setAttributes(theDetector,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
-
-
-
-
-
-  //stave modules lateral plate shaper parameters
-  double BHX_LP  = BHX;
-  double THX_LP  = THX;
-  double YXH_LP  = YXH;
+  Volume EnvLogHcalModuleBarrel(det_name + "_module", barrelModuleSolid, stavesMaterial);
 
-  //build lateral palte here to simulate lateral plate in the middle of barrel.
-  double DHZ_LP  = Hcal_lateral_plate_thickness/2.0; 
+  EnvLogHcalModuleBarrel.setAttributes(theDetector, x_staves.regionStr(), x_staves.limitsStr(), x_staves.visStr());
 
-  Trapezoid stave_shaper_LP(THX_LP, BHX_LP, DHZ_LP, DHZ_LP, YXH_LP);
+  // stave modules lateral plate shaper parameters
+  // double BHX_LP = BHX;
+  // double THX_LP = THX;
+  // double YXH_LP = YXH;
 
-  Tube solidCaloTube_LP(0, Hcal_outer_radius, DHZ_LP+boundarySafety);
+  // // build lateral palte here to simulate lateral plate in the middle of barrel.
+  // double DHZ_LP = Hcal_lateral_plate_thickness / 2.0;
 
-  IntersectionSolid Module_lateral_plate(stave_shaper_LP, solidCaloTube_LP, mtran3D);
+  // Trapezoid stave_shaper_LP(THX_LP, BHX_LP, DHZ_LP, DHZ_LP, YXH_LP);
 
-  Volume  EnvLogHcalModuleBarrel_LP(det_name+"_Module_lateral_plate",Module_lateral_plate,stavesMaterial);
+  // Tube solidCaloTube_LP(0, Hcal_outer_radius, DHZ_LP + boundarySafety);
 
-  EnvLogHcalModuleBarrel_LP.setAttributes(theDetector,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
+  // IntersectionSolid Module_lateral_plate(stave_shaper_LP, solidCaloTube_LP, mtran3D);
 
+  // Volume EnvLogHcalModuleBarrel_LP(det_name + "_Module_lateral_plate", Module_lateral_plate, stavesMaterial);
 
+  // EnvLogHcalModuleBarrel_LP.setAttributes(theDetector, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
 
 #ifdef SHCALSC04_DEBUG
-  std::cout<< " ==> Hcal_outer_radius: "<<Hcal_outer_radius <<std::endl;
+  std::cout << " ==> Hcal_outer_radius: " << Hcal_outer_radius << std::endl;
 #endif
 
-
-
-
-
-//====================================================================
-//
-// Chambers in the HCAL BARREL
-//
-//====================================================================
+  //====================================================================
+  //
+  // Chambers in the HCAL BARREL
+  //
+  //====================================================================
   // Build Layer Chamber fill with air, which include the tolarance space at the two side
   // place the slice into the Layer Chamber
   // Place the Layer Chamber into the Stave module
   // place the Stave module into the asembly Volume
   // place the module middle lateral plate into asembly Volume
 
-  double x_length; //dimension of an Hcal barrel layer on the x-axis
-  double y_height; //dimension of an Hcal barrel layer on the y-axis
-  double z_width;  //dimension of an Hcal barrel layer on the z-axis
-  x_length = 0.; // Each Layer the x_length has new value.
-  y_height = Hcal_chamber_thickness / 2.;
-  z_width  = Hcal_regular_chamber_dim_z/2.;
+  double x_halflength; // dimension of an Hcal barrel layer on the x-axis
+  double y_halfheight; // dimension of an Hcal barrel layer on the y-axis
+  double z_halfwidth;  // dimension of an Hcal barrel layer on the z-axis
+  x_halflength = 0.;   // Each Layer the x_halflength has new value.
+  y_halfheight = Hcal_chamber_thickness / 2.;
+  z_halfwidth = Hcal_regular_chamber_dim_z;
 
-  double xOffset = 0.;//the x_length of a barrel layer is calculated as a
-  //barrel x-dimension plus (bottom barrel) or minus
+  double xOffset = 0.; // the x_halflength of a barrel layer is calculated as a
+  // barrel x-dimension plus (bottom barrel) or minus
   //(top barrel) an x-offset, which depends on the angle M_PI/Hcal_inner_symmetry
 
-  double xShift = 0.;//Geant4 draws everything in the barrel related to the 
-  //center of the bottom barrel, so we need to shift the layers to
-  //the left (or to the right) with the quantity xShift
+  double xShift = 0.; // Geant4 draws everything in the barrel related to the
+  // center of the bottom barrel, so we need to shift the layers to
+  // the left (or to the right) with the quantity xShift
+
+  // read sensitive cell parameters and create it
+
+  // xml_comp_t x_scintillator = x_det.solid();
+  // Material sensitiveMaterial = theDetector.material(x_scintillator.materialStr());
+  // xml_comp_t x_ESR = x_det.shape();
+  // Material ladderMaterial = theDetector.material(x_ESR.materialStr());
+
+  Volume cell_vol;
+  Volume scintillator_vol;
+  Volume cell_vol_abnormal;
+  Volume scintillator_vol_abnormal;
+  xml_comp_t x_layer_tmp(x_det.child(_U(layer)));
+  for (xml_coll_t k(x_layer_tmp, _U(slice)); k; ++k)
+  {
+    xml_comp_t x_slice = k;
+    if (x_slice.isSensitive())
+    {
+      // child elements: ladder and sensitive
+      xml_comp_t x_sensitive(x_slice.child(_U(sensitive)));
+      xml_comp_t x_ladder(x_slice.child(_U(ladder)));
+      Material sensitiveMaterial = theDetector.material(x_sensitive.materialStr());
+      Material ladderMaterial = theDetector.material(x_ladder.materialStr());
+
+      // Store scintillator thickness
+      double cell_thickness = Hcal_scintillator_thickness + 2 * Hcal_scintillator_ESR_thickness;
+
+      double cell_size = 2 * Hcal_scintillator_ESR_thickness + Hcal_cell_size;
+      // place sensitive cell into ESR cell
+      string cell_name = "cell";
+      string scintillator_name = cell_name + "_scintillator";
+      // create sensitive cell with ESR
+      Box cell_box(cell_size / 2., cell_size / 2., cell_thickness / 2.);
+      // string cell_name=
+      // Volume cell_vol_tmp(cell_name, cell_box, ladderMaterial);
+      cell_vol = Volume(cell_name, cell_box, ladderMaterial);
+      cell_vol.setAttributes(theDetector, x_ladder.regionStr(), x_ladder.limitsStr(), x_ladder.visStr());
+      Box scintillator_box(Hcal_cell_size / 2., Hcal_cell_size / 2., Hcal_scintillator_thickness / 2.);
+      // Volume scintillator_vol_tmp(scintillator_name, scintillator_box, sensitiveMaterial);
+      scintillator_vol = Volume(scintillator_name, scintillator_box, sensitiveMaterial);
+      scintillator_vol.setAttributes(theDetector, x_sensitive.regionStr(), x_sensitive.limitsStr(), x_sensitive.visStr());
+      scintillator_vol.setSensitiveDetector(sens);
+      cell_vol.placeVolume(scintillator_vol, Position(0., 0., 0.));
+      // cout << x_ladder.visStr() << "   " << x_sensitive.visStr() << endl;
+      ///////////////////////////////
+      // abnormal cell             //
+      ///////////////////////////////
+      double cell_size_abnormal = 2 * Hcal_scintillator_ESR_thickness + Hcal_cell_size_abnormal;
+      // place sensitive cell into ESR cell
+      string cell_name_abnormal = "cell_abnormal";
+      string scintillator_name_abnormal = cell_name_abnormal + "_scintillator_abnormal";
+      // create sensitive cell with ESR
+      Box cell_box_abnormal(cell_size_abnormal / 2., cell_size / 2., cell_thickness / 2.);
+      // string cell_name=
+      // Volume cell_vol_tmp_abnormal(cell_name_abnormal, cell_box_abnormal, ladderMaterial);
+      cell_vol_abnormal = Volume(cell_name_abnormal, cell_box_abnormal, ladderMaterial);
+      cell_vol_abnormal.setAttributes(theDetector, x_ladder.regionStr(), x_ladder.limitsStr(), x_ladder.visStr());
+      Box scintillator_box_abnormal(Hcal_cell_size_abnormal / 2., Hcal_cell_size / 2., Hcal_scintillator_thickness / 2.);
+      // Volume scintillator_vol_tmp_abnormal(scintillator_name_abnormal, scintillator_box_abnormal, sensitiveMaterial);
+      scintillator_vol_abnormal = Volume(scintillator_name_abnormal, scintillator_box_abnormal, sensitiveMaterial);
+      scintillator_vol_abnormal.setAttributes(theDetector, x_sensitive.regionStr(), x_sensitive.limitsStr(), x_sensitive.visStr());
+      scintillator_vol_abnormal.setSensitiveDetector(sens);
+      cell_vol_abnormal.placeVolume(scintillator_vol_abnormal, Position(0., 0., 0.));
+    }
+  }
 
+  // sensitive cell creating done
 
   //-------------------- start loop over HCAL layers ----------------------
+  // int n_x_layer_1 = 0;
+  for (int layer_id = 1; layer_id <= (Hcal_nlayers); layer_id++)
+  {
 
-  for (int layer_id = 1; layer_id <= (2*Hcal_nlayers); layer_id++)
-    {
- 
-      double TanPiDiv8 = tan(M_PI/Hcal_inner_symmetry);
-      double x_total   = 0.;
-      double x_halfLength;
-      x_length  = 0.;
-
-      int logical_layer_id = 0;
-
-      if ( (layer_id < Hcal_nlayers)
-	   || (layer_id > Hcal_nlayers && layer_id < (2*Hcal_nlayers)) )
-	logical_layer_id = layer_id % Hcal_nlayers;
-      else if ( (layer_id == Hcal_nlayers) 
-		|| (layer_id == 2*Hcal_nlayers) ) logical_layer_id = Hcal_nlayers;
-
-      //---- bottom barrel------------------------------------------------------------
-      if( logical_layer_id *(Hcal_radiator_thickness + Hcal_chamber_thickness)
-	  < (Hcal_outer_radius * cos(M_PI/Hcal_inner_symmetry) - Hcal_inner_radius ) ) {
-	xOffset = (logical_layer_id * Hcal_radiator_thickness 
-		   + (logical_layer_id -1) * Hcal_chamber_thickness) * TanPiDiv8;
-
-	x_total  = Hcal_bottom_dim_x/2 - Hcal_middle_stave_gaps/2 + xOffset;
-	x_length = x_total - 2*Hcal_layer_air_gap;
-	x_halfLength = x_length/2.;
-
-      } else {//----- top barrel -------------------------------------------------
-	double y_layerID = logical_layer_id * (Hcal_radiator_thickness + Hcal_chamber_thickness) + Hcal_inner_radius;
-	double ro_layer = Hcal_outer_radius - Hcal_radiator_thickness;
-	
-	x_total = sqrt( ro_layer * ro_layer - y_layerID * y_layerID);
-	
-	x_length = x_total - Hcal_middle_stave_gaps;
-	
-	x_halfLength = x_length/2.;
-	
-	xOffset = (logical_layer_id * Hcal_radiator_thickness 
-		   + (logical_layer_id - 1) * Hcal_chamber_thickness - Hcal_y_dim1_for_x) / TanPiDiv8
-	  + Hcal_chamber_thickness / TanPiDiv8;
-	
-      }
+    double TanPiDiv8 = tan(M_PI / Hcal_inner_symmetry);
+    double x_total = 0.;
+    // double x_halfLength;
+    x_halflength = 0.;
 
-      double xAbsShift = (Hcal_middle_stave_gaps/2 + Hcal_layer_air_gap + x_halfLength);
-      
-      if (layer_id <= Hcal_nlayers)     xShift = - xAbsShift;
-      else if (layer_id > Hcal_nlayers) xShift = xAbsShift;
-
-      x_length = x_length/2.;
-
-      
-      //calculate the size of a fractional tile
-      //-> this sets fract_cell_dim_x
-      
-      //double fract_cell_dim_x = 0.;
-      //this->CalculateFractTileSize(2*x_length, Hcal_cell_dim_x, fract_cell_dim_x);
-      
-      //Vector newFractCellDim(fract_cell_dim_x, Hcal_chamber_thickness, Hcal_cell_dim_z);
-      //theBarrilRegSD->SetFractCellDimPerLayer(layer_id, newFractCellDim);
-
-      encoder["layer"] = logical_layer_id ;
-      cellSizeVector = seg.segmentation()->cellDimensions( encoder.getValue() ); 
-      cell_sizeX      = cellSizeVector[0];
-      cell_sizeY      = cellSizeVector[1];
-
-      LayeredCalorimeterData::Layer caloLayer ;
-      caloLayer.cellSize0 = cell_sizeX;
-      caloLayer.cellSize1 = cell_sizeY;
-
-
-      //--------------------------------------------------------------------------------
-      //  build chamber box, with the calculated dimensions 
-      //-------------------------------------------------------------------------------
-      printout( dd4hep::DEBUG,  "SHcalSc04_Barrel_v04", " \n Start to build layer chamber - layer_id: %d", layer_id ) ;
-      printout( dd4hep::DEBUG,  "SHcalSc04_Barrel_v04"," chamber x:y:z:  %e:%e:%e", x_length*2., z_width*2. , y_height*2. );
-
-      //check if x_length (scintillator length) is divisible with x_integerTileSize
-      if( layer_id <= Hcal_nlayers) {
-	double fracPart, intPart;
-	double temp = x_length*2./cell_sizeX;
-	fracPart = modf(temp, &intPart);
-	int noOfIntCells = int(temp);
-
-
-	if( tileSeg !=0 ){
-
-	  tileSeg->setBoundaryLayerX(x_length);
-	  
-	  if (fracPart == 0){ //divisible
-	    if ( noOfIntCells%2 ) {
-	      if( tileSeg !=0 ) tileSeg->setLayerOffsetX(0);
-	    }
-	    else {
-	      if( tileSeg !=0 ) tileSeg->setLayerOffsetX(1);
-	    }
-	    tileSeg->setFractCellSizeXPerLayer(0);
-	  }
-	  else if (fracPart>0){
-	    if ( noOfIntCells%2 ) {
-	      if( tileSeg !=0 ) tileSeg->setLayerOffsetX(1);
-	    }
-	    else {
-	      if( tileSeg !=0 ) tileSeg->setLayerOffsetX(0);
-	    }
-	    tileSeg->setFractCellSizeXPerLayer( (fracPart+1.0)/2.0*cell_sizeX );
-	  }
-	  
-	  if ( (int)( (z_width*2.) / cell_sizeX)%2 ){
-	    if( tileSeg !=0 ) tileSeg->setLayerOffsetY(0);
-	  }
-	  else {
-	    if( tileSeg !=0 ) tileSeg->setLayerOffsetY(1);
-	  }
-
-	}
-      }
-      Box ChamberSolid((x_length + Hcal_layer_air_gap),  //x + air gaps at two side, do not need to build air gaps individualy.
-			 z_width,   //z attention!
-			 y_height); //y attention!
+    // int layer_id = 0;
 
-      string ChamberLogical_name      = det_name+_toString(layer_id,"_layer%d");
+    // if ((layer_id < Hcal_nlayers) || (layer_id > Hcal_nlayers && layer_id < (2 * Hcal_nlayers)))
+    //   layer_id = layer_id % Hcal_nlayers;
+    // else if ((layer_id == Hcal_nlayers) || (layer_id == 2 * Hcal_nlayers))
+    //   layer_id = Hcal_nlayers;
 
-      Volume ChamberLogical(ChamberLogical_name, ChamberSolid, air);   
+    //---- bottom barrel------------------------------------------------------------
+    // if (layer_id * (Hcal_radiator_thickness + Hcal_chamber_thickness) < (Hcal_outer_radius * cos(M_PI / Hcal_inner_symmetry) - Hcal_inner_radius))
+    // {
+    xOffset = (layer_id * Hcal_radiator_thickness + (layer_id - 1) * Hcal_chamber_thickness) * TanPiDiv8;
 
+    x_total = Hcal_bottom_dim_x - Hcal_middle_stave_gaps + xOffset * 2;
+    x_halflength = x_total - 2 * Hcal_layer_air_gap;
+    // x_halfLength = x_halflength / 2.;
+    // }
+    // else
+    // { //----- top barrel -------------------------------------------------
+    //   double y_layerID = layer_id * (Hcal_radiator_thickness + Hcal_chamber_thickness) + Hcal_inner_radius;
+    //   double ro_layer = Hcal_outer_radius - Hcal_radiator_thickness;
 
+    //   x_total = sqrt(ro_layer * ro_layer - y_layerID * y_layerID);
 
-      double layer_thickness = y_height*2.;
+    //   x_halflength = x_total - Hcal_middle_stave_gaps;
 
-      double nRadiationLengths=0.;
-      double nInteractionLengths=0.;
-      double thickness_sum=0;
+    //   x_halfLength = x_halflength / 2.;
 
-      nRadiationLengths   = Hcal_radiator_thickness/(stavesMaterial.radLength());
-      nInteractionLengths = Hcal_radiator_thickness/(stavesMaterial.intLength());
-      thickness_sum       = Hcal_radiator_thickness;
+    //   xOffset = (layer_id * Hcal_radiator_thickness + (layer_id - 1) * Hcal_chamber_thickness - Hcal_y_dim1_for_x) / TanPiDiv8 + Hcal_chamber_thickness / TanPiDiv8;
+    // }
 
-//====================================================================
-// Create Hcal Barrel Chamber without radiator
-// Place into the Hcal Barrel stave, after each radiator 
-//====================================================================
-      xml_coll_t c(x_det,_U(layer));
-      xml_comp_t   x_layer = c;
-      string layer_name      = det_name+_toString(layer_id,"_layer%d");
-      
-      // Create the slices (sublayers) within the Hcal Barrel Chamber.
-      double slice_pos_z = layer_thickness/2.;
-      int slice_number = 0;
-
-      for(xml_coll_t k(x_layer,_U(slice)); k; ++k)  {
-	xml_comp_t x_slice = k;
-	string   slice_name      = layer_name + _toString(slice_number,"_slice%d");
-	double   slice_thickness = x_slice.thickness();
-	Material slice_material  = theDetector.material(x_slice.materialStr());
-	DetElement slice(layer_name,_toString(slice_number,"slice%d"),x_det.id());
-	
-	slice_pos_z -= slice_thickness/2.;
-	
-	// Slice volume & box
-	Volume slice_vol(slice_name,Box(x_length,z_width,slice_thickness/2.),slice_material);
-
-	nRadiationLengths   += slice_thickness/(2.*slice_material.radLength());
-	nInteractionLengths += slice_thickness/(2.*slice_material.intLength());
-	thickness_sum       += slice_thickness/2;
-	
-	if ( x_slice.isSensitive() ) {
-
-	  slice_vol.setSensitiveDetector(sens);
-
-	  // if we have a multisegmentation based on slices, we need to use the correct slice here
-	  if ( sensitive_slice_number<0  || sensitive_slice_number == slice_number ) {
-	
-	    //Store "inner" quantities
-	    caloLayer.inner_nRadiationLengths   = nRadiationLengths;
-	    caloLayer.inner_nInteractionLengths = nInteractionLengths;
-	    caloLayer.inner_thickness = thickness_sum;
-	    //Store scintillator thickness
-	    caloLayer.sensitive_thickness = slice_thickness;
-	    
-	    //Reset counters to measure "outside" quantitites
-	    nRadiationLengths=0.;
-	    nInteractionLengths=0.;
-	    thickness_sum = 0.;
-	  }
-	}
-
-	nRadiationLengths   += slice_thickness/(2.*slice_material.radLength());
-	nInteractionLengths += slice_thickness/(2.*slice_material.intLength());
-	thickness_sum       += slice_thickness/2;
-
-
-	// Set region, limitset, and vis.
-	slice_vol.setAttributes(theDetector,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
-	// slice PlacedVolume
-	PlacedVolume slice_phv = ChamberLogical.placeVolume(slice_vol,Position(0.,0.,slice_pos_z));
-
-	slice_phv.addPhysVolID("layer",logical_layer_id).addPhysVolID("slice", slice_number );
-
-	
-	if ( x_slice.isSensitive() ) {
-	  int tower_id  = (layer_id > Hcal_nlayers)? 1:-1;
-	  slice_phv.addPhysVolID("tower",tower_id);
-	  printout( dd4hep::DEBUG,  "SHcalSc04_Barrel_v04", "  logical_layer_id:  %d  tower_id:  %d", logical_layer_id, tower_id  ) ;
-	}
-	
-	slice.setPlacement(slice_phv);
-	// Increment x position for next slice.
-	slice_pos_z -= slice_thickness/2.;
-	// Increment slice number.
-	++slice_number;             
-      }
+    x_halflength = x_halflength / 2.;
 
-      //Store "outer" quantities
-      caloLayer.outer_nRadiationLengths = nRadiationLengths;
-      caloLayer.outer_nInteractionLengths = nInteractionLengths;
-      caloLayer.outer_thickness = thickness_sum;
+    LayeredCalorimeterData::Layer caloLayer;
+    caloLayer.cellSize0 = Hcal_cell_size;
+    caloLayer.cellSize1 = Hcal_cell_size;
 
+    //--------------------------------------------------------------------------------
+    //  build chamber box, with the calculated dimensions
+    //-------------------------------------------------------------------------------
+    printout(dd4hep::DEBUG, "SHcalSc04_Barrel_v04", " \n Start to build layer chamber - layer_id: %d", layer_id);
+    printout(dd4hep::DEBUG, "SHcalSc04_Barrel_v04", " chamber x:y:z:  %e:%e:%e", x_halflength * 2., z_halfwidth * 2., y_halfheight * 2.);
 
-//---------------------------  Chamber Placements -----------------------------------------
+    // check if x_halflength (scintillator length) is divisible with x_integerTileSize
 
-      double chamber_x_offset, chamber_y_offset, chamber_z_offset;
-      chamber_x_offset = xShift;
+    Box ChamberSolid((x_halflength + Hcal_layer_air_gap), // x + air gaps at two side, do not need to build air gaps individualy.
+                     z_halfwidth,                         // z attention!
+                     y_halfheight);                       // y attention!
 
-      chamber_z_offset = 0;
+    string ChamberLogical_name = det_name + _toString(layer_id, "_layer%d");
 
+    Volume ChamberLogical(ChamberLogical_name, ChamberSolid, air);
+    ChamberLogical.setAttributes(theDetector, x_layer_tmp.regionStr(), x_layer_tmp.limitsStr(), x_layer_tmp.visStr());
 
-      chamber_y_offset = -(-Hcal_total_dim_y/2. 
-			   + (logical_layer_id-1) *(Hcal_chamber_thickness + Hcal_radiator_thickness)
-			   + Hcal_radiator_thickness + Hcal_chamber_thickness/2.);
+    double layer_thickness = y_halfheight * 2.;
 
+    double nRadiationLengths = 0.;
+    double nInteractionLengths = 0.;
+    double thickness_sum = 0;
 
-      pv =  EnvLogHcalModuleBarrel.placeVolume(ChamberLogical,
-					       Position(chamber_x_offset,
-							chamber_z_offset,
-							chamber_y_offset + chambers_y_off_correction));
-      
+    nRadiationLengths = Hcal_radiator_thickness / (stavesMaterial.radLength());
+    nInteractionLengths = Hcal_radiator_thickness / (stavesMaterial.intLength());
+    thickness_sum = Hcal_radiator_thickness;
 
+    //====================================================================
+    // Create Hcal Barrel Chamber without radiator
+    // Place into the Hcal Barrel stave, after each radiator
+    //====================================================================
+    xml_coll_t c(x_det, _U(layer));
+    xml_comp_t x_layer = c;
+    string layer_name = det_name + _toString(layer_id, "_layer%d");
 
-      //-----------------------------------------------------------------------------------------
-      if( layer_id <= Hcal_nlayers ){ // add the first set of layers to the reconstruction data
-	
-	caloLayer.distance = Hcal_inner_radius + Hcal_total_dim_y/2.0 - (chamber_y_offset + chambers_y_off_correction)
-	  - caloLayer.inner_thickness ; // Will be added later at "DDMarlinPandora/DDGeometryCreator.cc:226" to get center of sensitive element
+    // Create the slices (sublayers) within the Hcal Barrel Chamber.
+    double slice_pos_z = layer_thickness / 2.;
+    int slice_number = 0;
 
-	caloLayer.absorberThickness = Hcal_radiator_thickness ;
-	
-	caloData->layers.push_back( caloLayer ) ;
+    for (xml_coll_t k(x_layer, _U(slice)); k; ++k)
+    {
+      xml_comp_t x_slice = k;
+      string slice_name = layer_name + _toString(slice_number, "_slice%d");
+      double slice_thickness = x_slice.thickness();
+      Material slice_material = theDetector.material(x_slice.materialStr());
+      DetElement slice(layer_name, _toString(slice_number, "slice%d"), x_det.id());
+
+      slice_pos_z -= slice_thickness / 2.;
+
+      // Slice volume & box
+      Volume slice_vol(slice_name, Box(x_halflength, z_halfwidth, slice_thickness / 2.), slice_material);
+      slice_vol.setAttributes(theDetector, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());
+
+      nRadiationLengths += slice_thickness / (2. * slice_material.radLength());
+      nInteractionLengths += slice_thickness / (2. * slice_material.intLength());
+      thickness_sum += slice_thickness / 2;
+      if (x_slice.isSensitive())
+      {
+        // Store "inner" quantities
+        caloLayer.inner_nRadiationLengths = nRadiationLengths;
+        caloLayer.inner_nInteractionLengths = nInteractionLengths;
+        caloLayer.inner_thickness = thickness_sum;
+        // Store scintillator thickness
+        caloLayer.sensitive_thickness = Hcal_scintillator_thickness;
+
+        double cell_size = 2 * Hcal_scintillator_ESR_thickness + Hcal_cell_size;
+        double cell_size_abnormal = 2 * Hcal_scintillator_ESR_thickness + Hcal_cell_size_abnormal;
+        double cell_x_offset = 0, cell_z_offset = 0, cell_y_offset = 0;
+        // place cell into slice one by one
+        double total_cell_size = cell_size + Hcal_scintillator_air_gap;                   // include air gap
+        double total_cell_size_abnormal = cell_size_abnormal + Hcal_scintillator_air_gap; // include air gap
+        int n_x = (2 * x_halflength) / total_cell_size;
+        int n_z = (2 * z_halfwidth) / total_cell_size;
+        int nx_abnormal = (2 * x_halflength - n_x * total_cell_size) / (total_cell_size_abnormal - total_cell_size);
+        n_x -= nx_abnormal;
+        // if(layer_id==1){n_x_layer_1=n_x;}
+        // else{
+        //   n_x=(n_x-n_x_layer_1)/2;
+        //   n_x=n_x*2+n_x_layer_1;
+        // }
+        for (int index_cell_z = 0; index_cell_z < n_z; index_cell_z++)
+        {
+          cell_x_offset = (n_x * total_cell_size + nx_abnormal * total_cell_size_abnormal) / 2.;
+          cell_z_offset = (n_z / 2. - index_cell_z - 0.5) * total_cell_size;
+          for (int index_cell_x = 0; index_cell_x < n_x; index_cell_x++)
+          {
+            cell_x_offset -= total_cell_size / 2.;
+            int cell_number = index_cell_x + 100 * index_cell_z;
+            string cell_name = slice_name + _toString(cell_number, "_cell%d");
+            string scintillator_name = cell_name + "_scintillator";
+            // cell_y_offset = slice_thickness / 2.;
+            PlacedVolume cell_phv = slice_vol.placeVolume(cell_vol, Position(cell_x_offset, cell_z_offset, cell_y_offset));
+            cell_phv.addPhysVolID("tile", cell_number);
+
+            DetElement cell(cell_name, _toString(cell_number, "cell%d"), cell_number);
+            cell.setPlacement(cell_phv);
+            cell_x_offset -= total_cell_size / 2.;
+          }
+          for (int index_cell_x = 0; index_cell_x < nx_abnormal; index_cell_x++)
+          {
+            cell_x_offset -= total_cell_size_abnormal / 2.;
+            int cell_number = index_cell_x + n_x + 100 * index_cell_z;
+            string cell_name = slice_name + _toString(cell_number, "_cell%d");
+            string scintillator_name = cell_name + "_scintillator";
+            // cell_y_offset = slice_thickness / 2.;
+            PlacedVolume cell_phv = slice_vol.placeVolume(cell_vol_abnormal, Position(cell_x_offset, cell_z_offset, cell_y_offset));
+            cell_phv.addPhysVolID("tile", cell_number);
+
+            DetElement cell(cell_name, _toString(cell_number, "cell%d"), cell_number);
+            cell.setPlacement(cell_phv);
+            cell_x_offset -= total_cell_size_abnormal / 2.;
+          }
+        }
+        printf("layerID: %2d, x_length: %3.3lf, x_cell: %3.3lf, x_cell_abnormal: %3.3lf, x_dead: %3.3lf, z_length: %3.3lf,z_cell: %3.3lf, z_dead: %3.3lf,\n", layer_id,  2 * x_halflength,  n_x * total_cell_size,  nx_abnormal * total_cell_size_abnormal,  2 * x_halflength - n_x * total_cell_size - nx_abnormal * total_cell_size_abnormal,  2 * z_halfwidth,  n_z * total_cell_size,  2 * z_halfwidth - n_z * total_cell_size);
+        // Reset counters to measure "outside" quantitites
+        nRadiationLengths = 0.;
+        nInteractionLengths = 0.;
+        thickness_sum = 0.;
+        // }
       }
-      //-----------------------------------------------------------------------------------------
-
-      
-    }//end loop over HCAL nlayers;
-
-  if( tileSeg !=0 ){
-    // check the offsets directly in the TileSeg ...
-    std::vector<double> LOX = tileSeg->layerOffsetX();
-    std::vector<double> LOY = tileSeg->layerOffsetY();
-
-    std::stringstream sts ;
-    sts <<" layerOffsetX(): ";
-    for (std::vector<double>::const_iterator ix = LOX.begin(); ix != LOX.end(); ++ix)
-      sts << *ix << ' ';
-    printout( dd4hep::DEBUG,  "SHcalSc04_Barrel_v04", "%s" , sts.str().c_str() ) ;
-    sts.clear() ; sts.str("") ;
-    sts <<" layerOffsetY(): ";
-    for (std::vector<double>::const_iterator iy = LOY.begin(); iy != LOY.end(); ++iy)
-      sts << *iy << ' ';
-    printout( dd4hep::DEBUG,  "SHcalSc04_Barrel_v04", "%s" , sts.str().c_str() ) ;
+      nRadiationLengths += slice_thickness / (2. * slice_material.radLength());
+      nInteractionLengths += slice_thickness / (2. * slice_material.intLength());
+      thickness_sum += slice_thickness / 2;
+
+      // Set region, limitset, and vis.
+      // slice_vol.setAttributes(theDetector, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());
+      // slice PlacedVolume
+      PlacedVolume slice_phv = ChamberLogical.placeVolume(slice_vol, Position(0., 0., slice_pos_z));
+
+      slice_phv.addPhysVolID("layer", layer_id);
+      slice.setPlacement(slice_phv);
+      // Increment z position for next slice.
+      slice_pos_z -= slice_thickness / 2.;
+      // Increment slice number.
+      ++slice_number;
+    }
 
-  }
+    // Store "outer" quantities
+    caloLayer.outer_nRadiationLengths = nRadiationLengths;
+    caloLayer.outer_nInteractionLengths = nInteractionLengths;
+    caloLayer.outer_thickness = thickness_sum;
 
+    //---------------------------  Chamber Placements -----------------------------------------
 
+    double chamber_x_offset, chamber_y_offset, chamber_z_offset;
+    chamber_x_offset = xShift;
 
-//====================================================================
-// Place HCAL Barrel stave module into the envelope
-//====================================================================
-  double stave_phi_offset,  module_z_offset,  lateral_plate_z_offset;
+    chamber_z_offset = 0;
 
-  double Y = Hcal_inner_radius + Hcal_total_dim_y / 2.;
+    chamber_y_offset = -(-Hcal_total_dim_y / 2. + (layer_id - 1) * (Hcal_chamber_thickness + Hcal_radiator_thickness) + Hcal_radiator_thickness + Hcal_chamber_thickness / 2.);
 
-  stave_phi_offset = M_PI/Hcal_inner_symmetry -M_PI/2.;
+    pv = EnvLogHcalModuleBarrel.placeVolume(ChamberLogical,
+                                            Position(chamber_x_offset, chamber_z_offset, chamber_y_offset));
 
+    //-----------------------------------------------------------------------------------------
+    if (layer_id <= Hcal_nlayers)
+    { // add the first set of layers to the reconstruction data
 
-  //-------- start loop over HCAL BARREL staves ----------------------------
+      caloLayer.distance = Hcal_inner_radius + Hcal_total_dim_y / 2.0 - chamber_y_offset - caloLayer.inner_thickness;
+      // Will be added later at "DDMarlinPandora/DDGeometryCreator.cc:226" to get center of sensitive element
 
-  for (int stave_id = 1;
-       stave_id <=Hcal_inner_symmetry;
-       stave_id++)
-    {
-      module_z_offset = - (Hcal_normal_dim_z + Hcal_modules_gap + Hcal_lateral_plate_thickness)/2.;
-      lateral_plate_z_offset = - (Hcal_lateral_plate_thickness + Hcal_modules_gap)/2.;
+      caloLayer.absorberThickness = Hcal_radiator_thickness;
 
-      double phirot = stave_phi_offset;
-      RotationZYX srot(0,phirot,M_PI*0.5);
-      Rotation3D srot3D(srot);
+      caloData->layers.push_back(caloLayer);
+    }
+    //-----------------------------------------------------------------------------------------
 
-      for (int module_id = 1;
-         module_id <=2;
-         module_id++)
-	{
-	  Position sxyzVec(-Y*sin(phirot), Y*cos(phirot), module_z_offset);
-	  Transform3D stran3D(srot3D,sxyzVec);
-	  
-	  // Place Hcal Barrel volume into the envelope volume
-	  pv = envelope.placeVolume(EnvLogHcalModuleBarrel,stran3D);
-	  pv.addPhysVolID("stave",stave_id);
-	  pv.addPhysVolID("module",module_id);
-	  pv.addPhysVolID("system",det_id);
+  } // end loop over HCAL nlayers;
 
-	  const int staveCounter = (stave_id-1)*2+module_id-1;
-	  DetElement stave(sdet, _toString(staveCounter,"stave%d"), staveCounter );
-	  stave.setPlacement(pv);
+  //====================================================================
+  // Place HCAL Barrel stave module into the envelope
+  //====================================================================
+  double stave_phi_offset, module_z_offset = 0;
 
-	  Position xyzVec_LP(-Y*sin(phirot), Y*cos(phirot),lateral_plate_z_offset);
-	  Transform3D tran3D_LP(srot3D,xyzVec_LP);
-	  pv = envelope.placeVolume(EnvLogHcalModuleBarrel_LP,tran3D_LP);
+  double Y = Hcal_inner_radius + Hcal_total_dim_y / 2.;
 
-	  module_z_offset = - module_z_offset;
-	  lateral_plate_z_offset = - lateral_plate_z_offset;
-	}
+  stave_phi_offset = M_PI / Hcal_inner_symmetry - M_PI / 2.;
 
+  //-------- start loop over HCAL BARREL staves ----------------------------
 
-      stave_phi_offset -=  M_PI*2.0/Hcal_inner_symmetry;
-    }  //-------- end loop over HCAL BARREL staves ----------------------------
+  for (int stave_id = 1; stave_id <= Hcal_inner_symmetry; stave_id++)
+  {
+    double phirot = stave_phi_offset;
+    RotationZYX srot(0, phirot, M_PI * 0.5);
+    Rotation3D srot3D(srot);
 
+    // for (int module_id = 1; module_id <= 2; module_id++)
+    // {
+    Position sxyzVec(-Y * sin(phirot), Y * cos(phirot), module_z_offset);
+    Transform3D stran3D(srot3D, sxyzVec);
 
-  sdet.addExtension< LayeredCalorimeterData >( caloData ) ;
+    // Place Hcal Barrel volume into the envelope volume
+    pv = envelope.placeVolume(EnvLogHcalModuleBarrel, stran3D);
+    pv.addPhysVolID("stave", stave_id);
+    // pv.addPhysVolID("module", module_id);
+    pv.addPhysVolID("system", det_id);
 
- 
-  return sdet;
+    // const int staveCounter = (stave_id - 1) * 2 + module_id - 1;
+    const int staveCounter = stave_id - 1;
+    DetElement stave(sdet, _toString(staveCounter, "stave%d"), staveCounter);
+    stave.setPlacement(pv);
 
+    // Position xyzVec_LP(-Y * sin(phirot), Y * cos(phirot), lateral_plate_z_offset);
+    // Transform3D tran3D_LP(srot3D, xyzVec_LP);
+    // pv = envelope.placeVolume(EnvLogHcalModuleBarrel_LP, tran3D_LP);
+
+    // module_z_offset = -module_z_offset;
+    // lateral_plate_z_offset = -lateral_plate_z_offset;
+    // }
+
+    stave_phi_offset -= M_PI * 2.0 / Hcal_inner_symmetry;
+  } //-------- end loop over HCAL BARREL staves ----------------------------
+
+  sdet.addExtension<LayeredCalorimeterData>(caloData);
+
+  return sdet;
 }
 
 DECLARE_DETELEMENT(SHcalSc04_Barrel_v04, create_detector)
diff --git a/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Endcaps_v02.cpp b/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Endcaps_v02.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..06db6d6b24c1962dfdca06a2ca2bf5b184717fc2
--- /dev/null
+++ b/Detector/DetCEPCv4/src/calorimeter/SHcalSc04_Endcaps_v02.cpp
@@ -0,0 +1,411 @@
+//================================================================================
+// Description 鈥� End-Cap AHCAL
+//--------------------------------------------------------------------------------
+// Author: Ji-Yuan CHEN (SJTU; jy_chen@sjtu.edu.cn)
+//--------------------------------------------------------------------------------
+//
+// End-cap AHCAL with 40脳40脳3 mm鲁 scintillator tiles.
+// Adding the dead materials (cassette, PCB and electronic components, ESR wrapper and steel absorber) and including the air gaps, the size of each cell becomes 40.3脳40.3脳27.2 mm鲁.
+//
+// The inner radius, end-cap thickness, unit size, etc. are directly read from XML file.
+//
+// Structure in a layer: Cassette 鈫� ESR 鈫� scintillator 鈫� ESR 鈫� PCB (including electronic components) 鈫� cassette 鈫� steel absorber.
+//
+// Default layout: The absorber is designed as a whole with some space left for the sensitive units (the cross-section is not a polygon); steel frame on the edges of each module; 16 modules (called 'staves' in this program), 48 layers; 72 rows in r direction, with uniform granularity.  For a schematic diagram, see Page 3 of  <https://indico.ihep.ac.cn/event/22010/contributions/153187/attachments/77666/96430/2024_0324_Calorimeter_Endcaps.pdf>  (the design on the left; the numbers have been modified).
+//================================================================================
+
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/Shapes.h"
+#include "DD4hep/DetType.h"
+#include "XML/Layering.h"
+#include "XML/Utilities.h"
+#include "DDRec/DetectorData.h"
+#include "DDSegmentation/Segmentation.h"
+#include <sstream>
+#include <cassert>
+
+using std::cout;
+using std::endl;
+using std::string;
+using std::vector;
+using std::to_string;
+
+#define MYDEBUG(x) cout << __FILE__ << ":" << __LINE__ << ": " << x << endl;
+#define MYDEBUGVAL(x) cout << __FILE__ << ":" << __LINE__ << ": "<< #x << ": " << x << endl;
+
+using dd4hep::Ref_t;
+using dd4hep::Detector;
+using dd4hep::SensitiveDetector;
+using dd4hep::pi;
+using dd4hep::mm;
+using dd4hep::Material;
+using dd4hep::DetElement;
+using dd4hep::Volume;
+using dd4hep::PolyhedraRegular;
+using dd4hep::Tube;
+using dd4hep::UnionSolid;
+using dd4hep::Trapezoid;
+using dd4hep::Box;
+using dd4hep::SubtractionSolid;
+using dd4hep::PlacedVolume;
+using dd4hep::Position;
+using dd4hep::RotationX;
+using dd4hep::_toString;
+using dd4hep::Transform3D;
+using dd4hep::RotationZ;
+using dd4hep::RotationY;
+
+static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector sens)
+{
+    xml_det_t x_det = e;
+
+    const string det_name = x_det.nameStr();
+    const string det_type = x_det.typeStr();
+    const int det_id = x_det.id();
+    MYDEBUGVAL(det_name)
+    MYDEBUGVAL(det_type)
+    MYDEBUGVAL(det_id)
+
+    // To prevent overlapping
+    const double boundary_safety = theDetector.constant<double>("boundary_safety");
+
+    // Global geometry
+    const double r_in = theDetector.constant<double>("hcalendcap_inner_radius");
+    const double r_out = theDetector.constant<double>("hcalendcap_outer_radius");
+    const double module_thickness = theDetector.constant<double>("hcalendcap_thickness");
+    const double pos_z = theDetector.constant<double>("hcalendcap_z");
+    const int Nmodules = theDetector.constant<int>("Nmodules");
+    const double angle = 2 * pi / Nmodules;
+
+    // Unit size
+    const double scintillator_xy = theDetector.constant<double>("scintillator_xy");
+    const double scintillator_z = theDetector.constant<double>("scintillator_z");
+    const double wrapped_scintillator_xy = theDetector.constant<double>("wrapped_scintillator_xy");
+    const double wrapped_scintillator_z = theDetector.constant<double>("wrapped_scintillator_z");
+
+    // Dead materials
+    const double cassette_thickness = theDetector.constant<double>("cassette_thickness"); 
+    const double esr_thickness = theDetector.constant<double>("esr_thickness");    // Wrapper
+    [[maybe_unused]] const double sipm_xy = theDetector.constant<double>("sipm_xy");
+    [[maybe_unused]] const double sipm_z = theDetector.constant<double>("sipm_z");
+    const double pcb_thickness = theDetector.constant<double>("pcb_thickness"); 
+    const double absorber_thickness = theDetector.constant<double>("absorber_thickness"); 
+    const double air_gap_xy = 0.5 * (wrapped_scintillator_xy - scintillator_xy) - esr_thickness;
+    [[maybe_unused]] const double air_gap_z = 0.5 * (wrapped_scintillator_z - scintillator_z) - esr_thickness;
+
+    // Odd-shaped cells
+    const int Nodd = theDetector.constant<int>("Nodd");
+    const double short_elongation_1 = theDetector.constant<double>("short_elongation_1");
+    const double short_elongation_2 = theDetector.constant<double>("short_elongation_2");
+    const double short_elongation_3 = theDetector.constant<double>("short_elongation_3");
+    const double short_elongation_4 = theDetector.constant<double>("short_elongation_4");
+    const double short_elongation_5 = theDetector.constant<double>("short_elongation_5");
+
+    const double elongation_angle_esr_out = wrapped_scintillator_xy * tan(0.5 * angle);    // Elongation of the outer edge of ESR: long side - short side
+    const double elongation_angle_esr_in = (wrapped_scintillator_xy - esr_thickness / cos(0.5 * angle)) * tan(0.5 * angle);    // Elongation of the inner edge of ESR: long side - short side
+    const double elongation_angle_sc = scintillator_xy * tan(0.5 * angle);    // Elongation of the scintillator: long side - short side
+    const vector<double> short_elongation_esr_out = { short_elongation_1, short_elongation_2, short_elongation_3, short_elongation_4, short_elongation_5 };
+    assert(Nodd == short_elongation_esr_out.size());
+
+    vector<double> short_elongation_sc(short_elongation_esr_out.size()), long_elongation_sc(short_elongation_esr_out.size()), short_elongation_esr_in(short_elongation_esr_out.size()), long_elongation_esr_in(short_elongation_esr_out.size()), long_elongation_esr_out(short_elongation_esr_out.size());
+    for (int i = 0; i < Nodd; ++i)
+    {
+        short_elongation_sc.at(i) = short_elongation_esr_out.at(i) - (air_gap_xy + esr_thickness) / cos(0.5 * angle);
+        long_elongation_sc.at(i) = short_elongation_sc.at(i) + elongation_angle_sc;
+        short_elongation_esr_in.at(i) = short_elongation_esr_out.at(i) - esr_thickness / cos(0.5 * angle);
+        long_elongation_esr_in.at(i) = short_elongation_esr_in.at(i) + elongation_angle_esr_in;
+        long_elongation_esr_out.at(i) = short_elongation_esr_out.at(i) + elongation_angle_esr_out;
+    }
+
+    // Mechanical structure
+    const double inner_structure_thickness = theDetector.constant<double>("inner_structure_thickness");
+    [[maybe_unused]] const double outer_structure_width = theDetector.constant<double>("outer_structure_width");
+    [[maybe_unused]] const double outer_structure_thickness = theDetector.constant<double>("outer_structure_thickness");
+    const double frame_thickness = theDetector.constant<double>("frame_thickness");
+
+    const double layer_thickness = wrapped_scintillator_z + pcb_thickness + 2 * cassette_thickness + absorber_thickness + 5 * boundary_safety;
+    const double non_absorber_thickness = wrapped_scintillator_z + pcb_thickness + 3 * boundary_safety;
+
+    MYDEBUGVAL(layer_thickness)
+
+    // Module size
+    const double dim_in_frame = (r_in + inner_structure_thickness + frame_thickness) * tan(0.5 * angle);
+    const double dim_out_frame = r_out * sin(0.5 * angle);
+    const double dim_in = dim_in_frame - frame_thickness / cos(0.5 * angle);
+    const double dim_out = dim_out_frame - frame_thickness / cos(0.5 * angle);
+    const double height = r_out * cos(0.5 * angle) - r_in - inner_structure_thickness;
+    const double r0 = r_in + inner_structure_thickness + 0.5 * height;    // Rotation radius for placing the modules
+
+    const int Nrows = (int) (height / (wrapped_scintillator_xy + boundary_safety));
+    const int Nlayers = (int) (module_thickness / layer_thickness);
+    int Ncells_phi;
+
+    MYDEBUGVAL(Nrows)
+    MYDEBUGVAL(Nlayers)
+
+    // Materials
+    Material mat_air(theDetector.material("Air"));
+    Material mat_PCB(theDetector.material("PCB"));
+    [[maybe_unused]] Material mat_SiPM(theDetector.material("G4_Si"));
+    Material mat_sensitive(theDetector.material( x_det.materialStr() ));
+    Material mat_ESR(theDetector.material("G4_ESR"));
+    Material mat_steel(theDetector.material("Steel235"));
+
+    // The detector and mother volumes (world)
+    DetElement AHCAL(det_name, det_id);
+    Volume motherVol = theDetector.pickMotherVolume(AHCAL);
+
+    // Create two tube-like envelopes to represent the end-cap volumes
+//    PolyhedraRegular envelope_side(Nmodules, 0.5 * angle, r_in + inner_structure_thickness, r_out, module_thickness);
+    Tube envelope_side(r_in, r_out, 0.5 * module_thickness);
+    UnionSolid envelope(envelope_side, envelope_side, Position(0, 0, 2 * pos_z));
+    Volume envelopeVol(det_name, envelope, mat_steel);
+    PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, Position(0, 0, -pos_z));
+    envelopePlv.addPhysVolID("system", det_id);
+    envelopeVol.setVisAttributes(theDetector, "SeeThrough");
+    AHCAL.setPlacement(envelopePlv);
+    DetElement stave_det(AHCAL, "sector", det_id);
+
+    // Module (stave)
+    Trapezoid stave(dim_in, dim_out, 0.5 * module_thickness, 0.5 * module_thickness, 0.5 * height);
+    Volume stave_vol("stave_vol", stave, mat_steel);
+    stave_vol.setVisAttributes(theDetector, "BlueVis");
+
+    // Layer with only wrapped scintillators, electronic components and PCB
+    Trapezoid layer(dim_in, dim_out, 0.5 * non_absorber_thickness, 0.5 * non_absorber_thickness, 0.5 * height);
+    Volume layer_vol("layer_vol", layer, mat_steel);
+    layer_vol.setVisAttributes(theDetector, "SeeThrough");
+
+    // Scintillator, ESR, SiPM, PCB, cassette, and absorber
+    Box normal_scintillator(0.5 * scintillator_xy, 0.5 * scintillator_z, 0.5 * scintillator_xy);
+    Volume scintillator("scintillator", normal_scintillator, mat_sensitive);    // Order: phi 鈫� z 鈫� r
+    scintillator.setVisAttributes(theDetector, "SeeThrough");
+    scintillator.setSensitiveDetector(sens);
+
+    [[maybe_unused]] Volume sipm("SiPM", Box(0.5 * sipm_xy, 0.5 * sipm_xy, 0.5 * sipm_z), mat_SiPM);
+    sipm.setVisAttributes(theDetector, "CyanVis");
+
+    Box esr_out(0.5 * wrapped_scintillator_xy, 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_xy);
+    Box esr_in(0.5 * wrapped_scintillator_xy - esr_thickness, 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+    Volume esr("esr", SubtractionSolid(esr_out, esr_in, Position(0, 0, 0)), mat_ESR);
+    esr.setVisAttributes(theDetector, "SeeThrough");
+
+    // Odd-shaped scintillators
+    Trapezoid odd_add_0_scintillator(0, long_elongation_sc.at(0) - short_elongation_sc.at(0), 0.5 * scintillator_z, 0.5 * scintillator_z, 0.5 * scintillator_xy);
+    Trapezoid odd_add_45_scintillator(short_elongation_sc.at(1), long_elongation_sc.at(1), 0.5 * scintillator_z, 0.5 * scintillator_z, 0.5 * scintillator_xy);
+    Trapezoid odd_add_9_scintillator(short_elongation_sc.at(2), long_elongation_sc.at(2), 0.5 * scintillator_z, 0.5 * scintillator_z, 0.5 * scintillator_xy);
+    Trapezoid odd_add_14_scintillator(short_elongation_sc.at(3), long_elongation_sc.at(3), 0.5 * scintillator_z, 0.5 * scintillator_z, 0.5 * scintillator_xy);
+    Trapezoid odd_add_17_scintillator(short_elongation_sc.at(4), long_elongation_sc.at(4), 0.5 * scintillator_z, 0.5 * scintillator_z, 0.5 * scintillator_xy);
+
+    Box odd_scintillator_0_rect(0.5 * (scintillator_xy + short_elongation_sc.at(0)), 0.5 * scintillator_z, 0.5 * scintillator_xy);
+
+    Volume odd_0_scintillator("odd_0_scintillator", UnionSolid(odd_scintillator_0_rect, odd_add_0_scintillator, Position(0.5 * (scintillator_xy + short_elongation_sc.at(0)), 0, 0)), mat_sensitive);
+    odd_0_scintillator.setVisAttributes(theDetector, "SeeThrough");
+    odd_0_scintillator.setSensitiveDetector(sens);
+
+    Volume odd_45_scintillator("odd_45_scintillator", UnionSolid(normal_scintillator, odd_add_45_scintillator, Position(0.5 * scintillator_xy, 0, 0)), mat_sensitive);
+    odd_45_scintillator.setVisAttributes(theDetector, "SeeThrough");
+    odd_45_scintillator.setSensitiveDetector(sens);
+
+    Volume odd_9_scintillator("odd_9_scintillator", UnionSolid(normal_scintillator, odd_add_9_scintillator, Position(0.5 * scintillator_xy, 0, 0)), mat_sensitive);
+    odd_9_scintillator.setVisAttributes(theDetector, "SeeThrough");
+    odd_9_scintillator.setSensitiveDetector(sens);
+
+    Volume odd_14_scintillator("odd_14_scintillator", UnionSolid(normal_scintillator, odd_add_14_scintillator, Position(0.5 * scintillator_xy, 0, 0)), mat_sensitive);
+    odd_14_scintillator.setVisAttributes(theDetector, "SeeThrough");
+    odd_14_scintillator.setSensitiveDetector(sens);
+
+    Volume odd_17_scintillator("odd_17_scintillator", UnionSolid(normal_scintillator, odd_add_17_scintillator, Position(0.5 * scintillator_xy, 0, 0)), mat_sensitive);
+    odd_17_scintillator.setVisAttributes(theDetector, "SeeThrough");
+    odd_17_scintillator.setSensitiveDetector(sens);
+
+    // Odd-shaped ESR
+    // Outer edge
+    Trapezoid odd_add_0_esr_out(short_elongation_esr_out.at(0), long_elongation_esr_out.at(0), 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_xy);
+    Trapezoid odd_add_45_esr_out(short_elongation_esr_out.at(1), long_elongation_esr_out.at(1), 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_xy);
+    Trapezoid odd_add_9_esr_out(short_elongation_esr_out.at(2), long_elongation_esr_out.at(2), 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_xy);
+    Trapezoid odd_add_14_esr_out(short_elongation_esr_out.at(3), long_elongation_esr_out.at(3), 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_xy);
+    Trapezoid odd_add_17_esr_out(short_elongation_esr_out.at(4), long_elongation_esr_out.at(4), 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_z, 0.5 * wrapped_scintillator_xy);
+
+    UnionSolid odd_0_esr_out(esr_out, odd_add_0_esr_out, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_45_esr_out(esr_out, odd_add_45_esr_out, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_9_esr_out(esr_out, odd_add_9_esr_out, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_14_esr_out(esr_out, odd_add_14_esr_out, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_17_esr_out(esr_out, odd_add_17_esr_out, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+
+    // Inner edge
+    Trapezoid odd_add_0_esr_in(0, long_elongation_esr_in.at(0) - short_elongation_esr_in.at(0), 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+    Trapezoid odd_add_45_esr_in(short_elongation_esr_in.at(1), long_elongation_esr_in.at(1), 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+    Trapezoid odd_add_9_esr_in(short_elongation_esr_in.at(2), long_elongation_esr_in.at(2), 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+    Trapezoid odd_add_14_esr_in(short_elongation_esr_in.at(3), long_elongation_esr_in.at(3), 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+    Trapezoid odd_add_17_esr_in(short_elongation_esr_in.at(4), long_elongation_esr_in.at(4), 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+
+    Box odd_esr_in_0_rect(0.5 * (wrapped_scintillator_xy - 2 * esr_thickness + short_elongation_esr_in.at(0)), 0.5 * wrapped_scintillator_z - esr_thickness, 0.5 * wrapped_scintillator_xy - esr_thickness);
+
+    UnionSolid odd_0_esr_in(odd_esr_in_0_rect, odd_add_0_esr_in, Position(0.5 * (wrapped_scintillator_xy + short_elongation_esr_in.at(0)), 0, 0));
+    UnionSolid odd_45_esr_in(esr_in, odd_add_45_esr_in, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_9_esr_in(esr_in, odd_add_9_esr_in, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_14_esr_in(esr_in, odd_add_14_esr_in, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+    UnionSolid odd_17_esr_in(esr_in, odd_add_17_esr_in, Position(0.5 * wrapped_scintillator_xy, 0, 0));
+
+    // Odd-shaped ESR, from the subtraction of outer and inner frames
+    Volume odd_0_esr("odd_0_esr", SubtractionSolid(odd_0_esr_out, odd_0_esr_in, Position(0, 0, 0)), mat_ESR);
+    Volume odd_45_esr("odd_45_esr", SubtractionSolid(odd_45_esr_out, odd_45_esr_in, Position(0, 0, 0)), mat_ESR);
+    Volume odd_9_esr("odd_9_esr", SubtractionSolid(odd_9_esr_out, odd_9_esr_in, Position(0, 0, 0)), mat_ESR);
+    Volume odd_14_esr("odd_14_esr", SubtractionSolid(odd_14_esr_out, odd_14_esr_in, Position(0, 0, 0)), mat_ESR);
+    Volume odd_17_esr("odd_17_esr", SubtractionSolid(odd_17_esr_out, odd_17_esr_in, Position(0, 0, 0)), mat_ESR);
+
+    // Positions
+    const double scintillator_pos_z = -0.5 * non_absorber_thickness + boundary_safety + 0.5 * wrapped_scintillator_z;
+    const double esr_pos_z = scintillator_pos_z;
+    const double pcb_pos_z = esr_pos_z + 0.5 * wrapped_scintillator_z + boundary_safety + 0.5 * pcb_thickness;
+
+    // Loop for placing the units in a layer
+    for (int ir = 1; ir <= Nrows; ++ir)
+    {
+        const double layer_length = dim_in + (ir - 1) * wrapped_scintillator_xy * tan(0.5 * angle);
+        Ncells_phi = (int) (2 * layer_length / wrapped_scintillator_xy);
+        const double layer_phi = Ncells_phi * wrapped_scintillator_xy;
+        const double single_elongation = layer_length - 0.5 * layer_phi;
+
+        Volume slice("slice", Trapezoid(layer_length, layer_length + elongation_angle_esr_out, 0.5 * non_absorber_thickness, 0.5 * non_absorber_thickness, 0.5 * (wrapped_scintillator_xy + boundary_safety)), mat_air);
+        slice.setVisAttributes(theDetector, "SeeThrough");
+        string slicename = "Slice_" + to_string(ir);
+        DetElement sd(stave_det, slicename, det_id);
+
+        Volume slice_pcb("slice_pcb", Box(0.5 * layer_phi, 0.5 * pcb_thickness, 0.5 * wrapped_scintillator_xy), mat_PCB);
+        slice_pcb.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit = slice.placeVolume(slice_pcb, Position(0, pcb_pos_z, 0));
+        pcb_unit.addPhysVolID("row", ir);
+
+        for (int iphi = 1; iphi <= Ncells_phi; ++iphi)
+        {
+            PlacedVolume scintillator_unit;
+            PlacedVolume esr_unit;
+
+            Position position_scintillator((-0.5 * (Ncells_phi + 1) + iphi) * wrapped_scintillator_xy, scintillator_pos_z, 0);
+            Position position_esr((-0.5 * (Ncells_phi + 1) + iphi) * wrapped_scintillator_xy, esr_pos_z, 0);
+
+            Transform3D transform_scintillator(RotationZ(pi), position_scintillator);
+            Transform3D transform_esr(RotationZ(pi), position_esr);
+
+            if (iphi == 1)
+            {
+                if (single_elongation >= short_elongation_esr_out.at(4))
+                {
+                    scintillator_unit = slice.placeVolume(odd_17_scintillator, transform_scintillator);
+                    esr_unit = slice.placeVolume(odd_17_esr, transform_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(3))
+                {
+                    scintillator_unit = slice.placeVolume(odd_14_scintillator, transform_scintillator);
+                    esr_unit = slice.placeVolume(odd_14_esr, transform_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(2))
+                {
+                    scintillator_unit = slice.placeVolume(odd_9_scintillator, transform_scintillator);
+                    esr_unit = slice.placeVolume(odd_9_esr, transform_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(1))
+                {
+                    scintillator_unit = slice.placeVolume(odd_45_scintillator, transform_scintillator);
+                    esr_unit = slice.placeVolume(odd_45_esr, transform_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(0))
+                {
+//                    scintillator_unit = slice.placeVolume(odd_0_scintillator, transform_scintillator);
+                    scintillator_unit = slice.placeVolume(odd_0_scintillator, Transform3D(RotationZ(pi),
+                                Position((-0.5 * (Ncells_phi + 1) + iphi) * wrapped_scintillator_xy - 0.5 * short_elongation_esr_in.at(0),
+                                         scintillator_pos_z,
+                                         0)));
+                    esr_unit = slice.placeVolume(odd_0_esr, transform_esr);
+                }
+            }
+            else if (iphi == Ncells_phi)
+            {
+                if (single_elongation >= short_elongation_esr_out.at(4))
+                {
+                    scintillator_unit = slice.placeVolume(odd_17_scintillator, position_scintillator);
+                    esr_unit = slice.placeVolume(odd_17_esr, position_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(3))
+                {
+                    scintillator_unit = slice.placeVolume(odd_14_scintillator, position_scintillator);
+                    esr_unit = slice.placeVolume(odd_14_esr, position_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(2))
+                {
+                    scintillator_unit = slice.placeVolume(odd_9_scintillator, position_scintillator);
+                    esr_unit = slice.placeVolume(odd_9_esr, position_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(1))
+                {
+                    scintillator_unit = slice.placeVolume(odd_45_scintillator, position_scintillator);
+                    esr_unit = slice.placeVolume(odd_45_esr, position_esr);
+                }
+                else if (single_elongation >= short_elongation_esr_out.at(0))
+                {
+//                    scintillator_unit = slice.placeVolume(odd_0_scintillator, position_scintillator);
+                    scintillator_unit = slice.placeVolume(odd_0_scintillator,
+                                Position((-0.5 * (Ncells_phi + 1) + iphi) * wrapped_scintillator_xy + 0.5 * short_elongation_esr_in.at(0),
+                                         scintillator_pos_z,
+                                         0));
+                    esr_unit = slice.placeVolume(odd_0_esr, position_esr);
+                }
+            }
+            else
+            {
+                scintillator_unit = slice.placeVolume(scintillator, position_scintillator);
+                esr_unit = slice.placeVolume(esr, position_esr);
+            }
+
+            scintillator_unit.addPhysVolID("row", ir).addPhysVolID("phi", iphi);
+            esr_unit.addPhysVolID("row", ir).addPhysVolID("phi", iphi);
+
+            string scintillator_name = "Scintillator_" + to_string(ir) + "_" + to_string(iphi);
+            DetElement unit(sd, scintillator_name, det_id);
+            unit.setPlacement(scintillator_unit);
+        }
+
+        PlacedVolume plv = layer_vol.placeVolume(slice, Position(0, 0, (-0.5 * (Nrows + 1) + ir) * (wrapped_scintillator_xy + boundary_safety)));
+        plv.addPhysVolID("row", ir);
+        sd.setPlacement(plv);
+    }
+
+    // Loop for placing the layers in a module
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        PlacedVolume plv = stave_vol.placeVolume(layer_vol, Position(0, (ilayer - 1) * layer_thickness + cassette_thickness + 0.5 * non_absorber_thickness - 0.5 * module_thickness, 0));
+        plv.addPhysVolID("layer", ilayer);
+        DetElement sd(stave_det, _toString(ilayer, "layer_%3d"), det_id);
+        sd.setPlacement(plv);
+    }
+
+    // Loop for placing the modules
+    for (int i = 0; i < Nmodules; ++i)
+    {
+        const double m_rot = i * angle;
+        const double posx = -r0 * sin(m_rot);
+        const double posy = r0 * cos(m_rot);
+
+        Transform3D transform_neg(RotationZ(m_rot) * RotationX(-0.5 * pi), Position(posx, posy, 0));
+        Transform3D transform_pos(RotationZ(m_rot) * RotationY(pi) * RotationX(-0.5 * pi), Position(posx, posy, 2 * pos_z));
+        PlacedVolume plv_neg = envelopeVol.placeVolume(stave_vol, transform_neg);
+        PlacedVolume plv_pos = envelopeVol.placeVolume(stave_vol, transform_pos);
+        plv_neg.addPhysVolID("stave", i);
+        plv_pos.addPhysVolID("stave", i + Nmodules);
+        DetElement sd_neg(AHCAL, _toString(i, "sector%3d"), det_id);
+        DetElement sd_pos(AHCAL, _toString(i + Nmodules, "sector%3d"), det_id);
+        sd_neg.setPlacement(plv_neg);
+        sd_pos.setPlacement(plv_pos);
+    }
+
+    sens.setType("calorimeter");
+
+    MYDEBUG("create_detector FINISHED.");
+    return AHCAL;
+}
+
+DECLARE_DETELEMENT(SHcalSc04_Endcaps_v02, create_detector)
diff --git a/Detector/DetCRD/CMakeLists.txt b/Detector/DetCRD/CMakeLists.txt
index 0ee51f932889b69a51028e6531fa10b3ad9d7507..61f203fac711cca0aca1185b27f40ea0f3245caf 100644
--- a/Detector/DetCRD/CMakeLists.txt
+++ b/Detector/DetCRD/CMakeLists.txt
@@ -6,6 +6,9 @@
 gaudi_add_module(DetCRD
                  SOURCES src/Calorimeter/CRDEcal_v01.cpp
                          src/Calorimeter/LongCrystalBarBarrelCalorimeter32Polygon_v01.cpp
+                         src/Calorimeter/LongCrystalBarEndcapCalorimeter_v01.cpp
+                         src/Calorimeter/CRDEcal_Short_v02.cpp
+                         src/Calorimeter/CRDEcal_Endcap_Short_v01.cpp
                          src/Calorimeter/RotatedPolyhedraBarrelCalorimeter_v01_geo.cpp
                          src/Calorimeter/RotatedCrystalCalorimeter_v01_geo.cpp
                          src/Calorimeter/Lumical_v01_geo.cpp
diff --git a/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml
new file mode 100644
index 0000000000000000000000000000000000000000..30f14a456930df770ce3fa98c9cbbf2d93278d3b
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+    <define>
+        <constant name="ecalbarrel_inner_radius" value="Ecal_barrel_inner_radius"/>
+        <constant name="ecalbarrel_outer_radius" value="Ecal_barrel_outer_radius"/>
+        <!--<constant name="ecalbarrel_thickness" value="Ecal_barrel_thickness"/>-->
+        <constant name="ecalbarrel_thickness" value="28.5*cm"/>
+        <constant name="ecalbarrel_zlength" value="Ecal_barrel_half_length*2"/>
+        <constant name="Nmodule" value="32"/>
+        <constant name="Nblock_z" value="15"/>
+        <constant name="module_rotation" value="12*degree"/>
+
+        <constant name="crystal_r" value="4.1*cm"/>
+        <constant name="crystal_phi" value="1*cm"/>
+        <constant name="crystal_z" value="1*cm"/>
+
+        <constant name="esr_thickness" value="0.1*mm"/>
+        <constant name="sipm_r" value="0.8*mm"/>
+        <constant name="sipm_phi" value="3*mm"/>
+        <constant name="sipm_z" value="3*mm"/>
+        <constant name="pcb_thickness" value="2.2*mm"/>
+        <constant name="cu_thickness" value="1*mm"/>
+        <constant name="fibre_thickness" value="0.1*mm"/>
+
+        <constant name="collection_width" value="300*mm"/>
+        <constant name="collection_thickness" value="10*mm"/>
+
+        <constant name="boundary_safety" value="1*nm"/>
+    </define>
+
+    <regions>
+        <region name="EcalBarrelRegion">
+        </region>
+    </regions>
+
+    <detectors>
+        <detector id="DetID_ECAL"
+                  name="EcalBarrel"
+                  type="CRDEcalBarrel_Short_v02"
+                  readout="EcalBarrelCollection"
+                  vis="Invisible"
+                  sensitive="true"
+                  region="EcalBarrelRegion">
+            <!-- Use cm as unit if you want to use Pandora for reconstruction -->
+        <material name="G4_BGO"/>
+        </detector>
+    </detectors>
+
+    <readouts>
+        <readout name="EcalBarrelCollection">
+            <segmentation type="NoSegmentation"/>
+            <!--segmentation type="CartesianGridXYZ"
+                          grid_size_x="1*cm"
+                          grid_size_y="1*cm"
+                          grid_size_z="1*cm"/-->
+            <id>system:5,module:5,stave:4,layer:5,phi:6,z:6</id>
+        </readout>
+    </readouts>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..73c5c6e7838c5df6e7f9adee4ac724f461b1c6fe
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+    <define>
+        <constant name="ecalendcap_inner_radius" value="Ecal_endcap_inner_radius"/>
+        <constant name="ecalendcap_outer_radius" value="Ecal_endcap_outer_radius"/>
+        <constant name="ecalendcap_block_xy" value="350*mm"/>
+        <constant name="ecalendcap_thickness" value="Ecal_endcap_zmax-Ecal_endcap_zmin"/>
+        <constant name="ecalendcap_z" value="0.5*(Ecal_endcap_zmin+Ecal_endcap_zmax)"/>
+        <constant name="Nblock_xy" value="6"/>
+        <constant name="Nsectors" value="4"/>
+
+        <!-- Fill in the space at the corner-->
+        <constant name="ecalendcap_block_fill_rect_short" value="260*mm"/>
+        <constant name="ecalendcap_block_fill_sq1" value="180*mm"/>
+        <constant name="ecalendcap_block_fill_sq2" value="270*mm"/>
+
+        <constant name="Ncell_rect_short" value="26"/>
+        <constant name="Ncell_sq1_xy" value="18"/>
+        <constant name="Ncell_sq2_xy" value="27"/>
+
+        <constant name="gap_narrow" value="2*mm"/>
+        <constant name="gap_wide" value="10*mm"/>
+
+        <!-- CrystalXY = CellXY - 2 * BoundarySafety - 2 * ESRThickness-->
+        <!-- CrystalZ = CellZ - 2 * BoundarySafety - 2 * ESRThickness-->
+        <constant name="Ncell_xy" value="35"/>
+        <constant name="crystal_z" value="4.1*cm"/>
+
+        <constant name="esr_thickness" value="0.1*mm"/>
+        <constant name="sipm_x" value="3*mm"/>
+        <constant name="sipm_y" value="3*mm"/>
+        <constant name="sipm_z" value="0.8*mm"/>
+        <constant name="pcb_thickness" value="2.2*mm"/>
+        <constant name="cu_thickness" value="1*mm"/>
+        <constant name="fibre_thickness" value="0.1*mm"/>
+        <constant name="boundary_safety" value="1*nm"/>
+    </define>
+
+    <regions>
+        <region name="EcalEndcapsRegion">
+        </region>
+    </regions>
+
+    <detectors>
+        <detector id="DetID_ECAL_ENDCAP"
+                  name="EcalEndcaps"
+                  type="CRDEcalEndcap_Short_v01"
+                  readout="EcalEndcapsCollection"
+                  vis="Invisible"
+                  sensitive="true"
+                  region="EcalEndcapsRegion">
+            <!-- Use cm as unit if you want to use Pandora for reconstruction -->
+        <material name="G4_BGO"/>
+        </detector>
+    </detectors>
+
+    <readouts>
+        <readout name="EcalEndcapsCollection">
+            <segmentation type="NoSegmentation"/>
+            <!--segmentation type="CartesianGridXYZ"
+                          grid_size_x="1*cm"
+                          grid_size_y="1*cm"
+                          grid_size_z="1*cm"/-->
+            <id>system:5,module:3,stave:5,layer:5,x:6,y:6</id>
+        </readout>
+    </readouts>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Endcap_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Endcap_v01_01.xml
new file mode 100755
index 0000000000000000000000000000000000000000..a9ab8c907ac719b3b3241d4a4d7a459e1601ff10
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Endcap_v01_01.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+<lccdd> 
+  <define>
+    <constant name="ecalendcap_inner_radius"        value="Ecal_endcap_inner_radius"/>
+    <constant name="ecalendcap_outer_radius"        value="Ecal_endcap_outer_radius"/>
+    <constant name="ecalendcap_zmin"             value="Ecal_endcap_zmin"/>
+    <constant name="ecalendcap_depth"             value="Ecal_endcap_thickness"/>
+
+    <constant name="ecalendcap_layer"               value="28" />
+    <constant name="ecalendcap_x_width"               value="350*mm" />
+    <constant name="ecalendcap_y_width"               value="350*mm" />
+    <constant name="ecalendcap_width_crystal"    value="10.2*mm"/>
+
+    <constant name="ecalendcap_crystal_wrapping"    value="0.1*mm"/>
+    <constant name="ecalendcap_length_photoelectronic"    value="0.7*mm"/> 
+    <constant name="ecalendcap_width_photoelectronic"    value="3*mm"/> 
+
+    <constant name="ecalendcap_length_carbon"    value="2.5*mm"/> 
+    <constant name="ecalendcap_length_cable"    value="0.*mm"/> 
+    <constant name="ecalendcap_length_cooling"    value="1.*mm"/> 
+    <constant name="ecalendcap_length_pcb"    value="1.2*mm"/> 
+    <constant name="ecalendcap_length_asic"    value="1.*mm"/>
+    <constant name="ecalendcap_length_back"    value="10.*mm"/>
+
+  </define> 
+
+  <regions>
+    <region name="EcalendcapRegion">
+    </region>
+  </regions>
+
+  <detectors>
+    <detector id="DetID_ECAL_ENDCAP" name="CaloDetectorEndcap" type="LongCrystalBarEndcapCalorimeter_v01" readout="EcalEndcapsCollection" vis="Invisible" sensitive="true" region="EcalendcapRegion">
+      <!-- Use cm as unit if you want to use Pandora for reconstruction -->
+    </detector>
+  </detectors>
+  
+  <readouts>
+    <readout name="EcalEndcapsCollection">
+      <segmentation type="NoSegmentation"/>
+      <!--segmentation type="CartesianGridXYZ"
+                    grid_size_x="1*cm"
+                    grid_size_y="1*cm"
+                    grid_size_z="1*cm"/-->
+      <id>system:5,module:1,stave:15,dlayer:5,slayer:1,bar:15</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml
index be7ef3f18f86766d19a2b415119563846479ce59..117d30237ec3c27ca2ad7e6ede75c07c476b9efe 100644
--- a/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml
+++ b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml
@@ -38,7 +38,7 @@
 
       <envelope vis="CyanVis">
         <shape type="BooleanShape" operation="Subtraction" material="Air" >
-          <shape type="Cone" rmin1="0.0" rmax1="Hcal_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_outer_radius + env_safety" z="Hcal_half_length + env_safety/2.0"/>
+          <shape type="Cone" rmin1="0.0" rmax1="Hcal_barrel_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_barrel_outer_radius + env_safety" z="Hcal_half_length + env_safety/2.0"/>
           <shape type="PolyhedraRegular"  numsides="Hcal_inner_symmetry" rmin="0.0"
                  rmax="Hcal_inner_radius - env_safety" dz="2*(Hcal_half_length + env_safety)"/>
         </shape>
diff --git a/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v05.xml b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v05.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d0770876d9a30bbcf3a9a50dd2ff681c48a0edc5
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v05.xml
@@ -0,0 +1,65 @@
+<!-- comment> Glass scintillator HCAL barrel modified from SHcalSc04_Barrel_v04_01.xml</comment -->
+
+<lccdd>
+  <define>
+    <constant name="Hcal_cell_size" value="40*mm"/>
+    <constant name="Hcal_cell_size_abnormal" value="50*mm"/>
+    <constant name="Hcal_inner_radius" value="Hcal_barrel_inner_radius"/>
+    <constant name="Hcal_outer_radius" value="Hcal_barrel_outer_radius"/>
+    <constant name="Hcal_half_length" value="Hcal_barrel_half_length"/>
+    <constant name="Hcal_inner_symmetry" value="Hcal_barrel_symmetry"/>
+    <constant name="Hcal_nlayers" value="48"/>
+    <constant name="Hcal_radiator_thickness" value="9.9*mm"/>
+    <constant name="Hcal_chamber_thickness" value="17.3*mm"/>
+    <constant name="Hcal_scintillator_ESR_thickness" value="0.065*mm"/>
+    <constant name="Hcal_scintillator_air_gap" value="0.17*mm"/>
+    <constant name="Hcal_scintillator_thickness" value="10*mm"/>
+    <constant name="Hcal_back_plate_thickness" value="15*mm"/>
+    <constant name="Hcal_lateral_structure_thickness" value="24*mm"/>
+    <constant name="Hcal_stave_gaps" value="0*mm"/>
+    <constant name="Hcal_middle_stave_gaps" value="0*mm"/>
+    <constant name="Hcal_modules_gap" value="2*mm"/>
+    <constant name="Hcal_layer_air_gap" value="0*mm"/>
+    <constant name="HcalSD_glass_anode_thickness" value="0.7*mm"/>
+    <constant name="HcalSD_sensitive_gas_gap" value="1.2*mm"/>
+    <constant name="HcalSD_glass_cathode_thickness" value="1.1*mm"/>
+    <constant name="Hcal_PCB_thickness" value="3.1*mm"/>
+    <constant name="Hcal_scintillator_ESR_air_thickness" value="10.2*mm"/>
+    <constant name="Ecal_outer_radius" value="Ecal_barrel_outer_radius"/>
+  </define>
+  <detectors>
+    <detector name="HcalBarrel" type="SHcalSc04_Barrel_v04" id="DetID_HCAL" readout="HcalBarrelCollection" insideTrackingVolume="false" vis="seeThrough">
+      <comment>Hadron Calorimeter Barrel</comment>
+
+      <envelope vis="SeeThrough">
+        <shape type="BooleanShape" operation="Subtraction" material="Air" >
+          <shape type="Cone" rmin1="0.0" rmax1="Hcal_barrel_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_barrel_outer_radius + env_safety" z="Hcal_half_length + env_safety/2.0"/>
+          <shape type="PolyhedraRegular"  numsides="Hcal_inner_symmetry" rmin="0.0" rmax="Hcal_inner_radius - env_safety" dz="2*(Hcal_half_length + env_safety)"/>
+        </shape>
+        <rotation x="0" y="0" z="90*deg-180*deg/Hcal_inner_symmetry"/>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_BARREL + DetType_HADRONIC " />
+
+      <staves  material = "Steel235"  vis="SeeThrough"/>
+
+      <layer repeat="Hcal_nlayers" vis="seeThrough">
+        <slice material="Steel235" thickness = "2*mm"   vis="seeThrough"   />
+        <slice material="PCB" thickness = "Hcal_PCB_thickness"   vis="GreenVis"   />
+        <slice material="Air" thickness = "Hcal_scintillator_ESR_air_thickness" sensitive = "yes"   limits="cal_limits"  vis="SeeThrough" >
+          <sensitive material = "G4_GlassHCAL"  sensitive = "yes" limits="cal_limits"   vis="CyanVis"/>
+          <ladder material = "G4_ESR"  limits="cal_limits" vis="RedVis" />
+        </slice>
+        <slice material="Steel235" thickness = "2*mm"   vis="seeThrough"   />
+      </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="HcalBarrelCollection">
+      <id>system:5,stave:4,layer:6,tile:16,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Endcaps_v01.xml b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Endcaps_v01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..857363c28564fafa3d38d8119a54708fdc54ba69
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Endcaps_v01.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+  <comment>Glass Scintillator tile HCAL endcap, modified from Jiyuan's SHcalSc04_Endcaps_v02.xml</comment>
+
+    <define>
+        <constant name="hcalendcap_inner_radius" value="Hcal_endcap_inner_radius"/>
+        <constant name="hcalendcap_outer_radius" value="Hcal_endcap_outer_radius"/>
+        <constant name="hcalendcap_thickness" value="Hcal_endcap_zmax-Hcal_endcap_zmin"/>
+        <constant name="hcalendcap_z" value="0.5*(Hcal_endcap_zmin+Hcal_endcap_zmax)"/>
+        <constant name="Nmodules" value="Hcal_endcap_symmetry"/>
+
+        <constant name="scintillator_xy" value="40.0*mm"/>
+        <constant name="scintillator_z" value="10.0*mm"/>
+        <constant name="wrapped_scintillator_xy" value="40.3*mm"/>
+        <constant name="wrapped_scintillator_z" value="10.2*mm"/>
+
+        <!-- Odd-shaped cells -->
+        <constant name="Nodd" value="5"/>
+        <constant name="short_elongation_1" value="0*mm"/>
+        <constant name="short_elongation_2" value="4.5*mm"/>
+        <constant name="short_elongation_3" value="9*mm"/>
+        <constant name="short_elongation_4" value="14*mm"/>
+        <constant name="short_elongation_5" value="17*mm"/>
+
+        <constant name="cassette_thickness" value="2.0*mm"/>
+        <constant name="esr_thickness" value="65.0*um"/>
+        <constant name="sipm_xy" value="3.0*mm"/>
+        <constant name="sipm_z" value="0.8*mm"/>
+        <constant name="pcb_thickness" value="3.1*mm"/>
+        <constant name="absorber_thickness" value="9.9*mm"/>
+
+        <constant name="inner_structure_thickness" value="50*mm"/>
+        <constant name="outer_structure_width" value="120*mm"/>
+        <constant name="outer_structure_thickness" value="50*mm"/>
+        <constant name="frame_thickness" value="3*mm"/>
+
+        <constant name="boundary_safety" value="1*nm"/>
+    </define>
+
+    <regions>
+        <region name="HcalEndcapsRegion">
+        </region>
+    </regions>
+
+    <detectors>
+        <detector id="DetID_HCAL_ENDCAP"
+                  name="HcalEndcaps"
+                  type="SHcalSc04_Endcaps_v02"
+                  readout="HcalEndcapsCollection"
+                  vis="Invisible"
+                  sensitive="true"
+                  region="HcalEndcapsRegion">
+            <!-- Use cm as unit if you want to use Pandora for reconstruction -->
+        <material name="G4_GlassHCAL"/>
+        </detector>
+    </detectors>
+
+    <readouts>
+        <readout name="HcalEndcapsCollection">
+            <segmentation type="NoSegmentation"/>
+            <!--segmentation type="CartesianGridXYZ"
+                          grid_size_x="1*cm"
+                          grid_size_y="1*cm"
+                          grid_size_z="1*cm"/-->
+            <id>system:5,stave:5,layer:6,row:7,phi:6</id>
+        </readout>
+    </readouts>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Barrel_v04_01.xml b/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Barrel_v04_01.xml
index 32810ce1c0da9fdf6f602daa770d2815778ddb37..424b3edbe009fb326fdb1ba57cc64792aef49d6d 100644
--- a/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Barrel_v04_01.xml
+++ b/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Barrel_v04_01.xml
@@ -1,16 +1,21 @@
-<!-- comment>Calorimeters</comment -->
+<!-- comment> Plastic scintillator HCAL barrel by Hongbin Diao (diaohb@mail.ustc.edu.cn)</comment -->
 
 <lccdd>
   <define>
-    <constant name="Hcal_cell_size" value="10*mm"/>
+    <constant name="Hcal_cell_size" value="40*mm"/>
+    <constant name="Hcal_cell_size_abnormal" value="50*mm"/>
     <constant name="Hcal_inner_radius" value="Hcal_barrel_inner_radius"/>
+    <constant name="Hcal_outer_radius" value="Hcal_barrel_outer_radius"/>
     <constant name="Hcal_half_length" value="Hcal_barrel_half_length"/>
     <constant name="Hcal_inner_symmetry" value="Hcal_barrel_symmetry"/>
-    <constant name="Hcal_nlayers" value="38"/>
-    <constant name="Hcal_radiator_thickness" value="20.0*mm"/>
-    <constant name="Hcal_chamber_thickness" value="6.5*mm"/>
+    <constant name="Hcal_nlayers" value="48"/>
+    <constant name="Hcal_radiator_thickness" value="16.8*mm"/>
+    <constant name="Hcal_chamber_thickness" value="10.4*mm"/>
+    <constant name="Hcal_scintillator_ESR_thickness" value="0.065*mm"/>
+    <constant name="Hcal_scintillator_air_gap" value="0.17*mm"/>
+    <constant name="Hcal_scintillator_thickness" value="3*mm"/>
     <constant name="Hcal_back_plate_thickness" value="15*mm"/>
-    <constant name="Hcal_lateral_structure_thickness" value="10*mm"/>
+    <constant name="Hcal_lateral_structure_thickness" value="24*mm"/>
     <constant name="Hcal_stave_gaps" value="0*mm"/>
     <constant name="Hcal_middle_stave_gaps" value="0*mm"/>
     <constant name="Hcal_modules_gap" value="2*mm"/>
@@ -18,52 +23,41 @@
     <constant name="HcalSD_glass_anode_thickness" value="0.7*mm"/>
     <constant name="HcalSD_sensitive_gas_gap" value="1.2*mm"/>
     <constant name="HcalSD_glass_cathode_thickness" value="1.1*mm"/>
-    <constant name="Hcal_scintillator_thickness" value="3.0*mm"/>
+    <constant name="Hcal_PCB_thickness" value="3.2*mm"/>
+    <constant name="Hcal_scintillator_ESR_air_thickness" value="3.2*mm"/>
     <constant name="Ecal_outer_radius" value="Ecal_barrel_outer_radius"/>
-    <constant name="Hcal_readout_segmentation_slice" value="3"/>
   </define>
   <detectors>
-    <detector name="HcalBarrel" type="SHcalSc04_Barrel_v04" id="DetID_HCAL" readout="HcalBarrelCollection" vis="GreenVis" insideTrackingVolume="false" >
+    <detector name="HcalBarrel" type="SHcalSc04_Barrel_v04" id="DetID_HCAL" readout="HcalBarrelCollection" insideTrackingVolume="false" vis="seeThrough">
       <comment>Hadron Calorimeter Barrel</comment>
 
-      <envelope vis="ILD_HCALVis">
+      <envelope vis="SeeThrough">
         <shape type="BooleanShape" operation="Subtraction" material="Air" >
-          <shape type="Cone" rmin1="0.0" rmax1="Hcal_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_outer_radius + env_safety" z="Hcal_half_length + env_safety/2.0"/>
-          <shape type="PolyhedraRegular"  numsides="Hcal_inner_symmetry" rmin="0.0"
-                 rmax="Hcal_inner_radius - env_safety" dz="2*(Hcal_half_length + env_safety)"/>
+          <shape type="Cone" rmin1="0.0" rmax1="Hcal_barrel_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_barrel_outer_radius + env_safety" z="Hcal_half_length + env_safety/2.0"/>
+          <shape type="PolyhedraRegular"  numsides="Hcal_inner_symmetry" rmin="0.0" rmax="Hcal_inner_radius - env_safety" dz="2*(Hcal_half_length + env_safety)"/>
         </shape>
         <rotation x="0" y="0" z="90*deg-180*deg/Hcal_inner_symmetry"/>
       </envelope>
 
       <type_flags type=" DetType_CALORIMETER + DetType_BARREL + DetType_HADRONIC " />
 
-      <staves  material = "Steel235"  vis="BlueVis"/>
+      <staves  material = "Steel235"  vis="SeeThrough"/>
 
-
-      <!--  select which subsegmentation will be used to fill the DDRec:LayeredCalorimeterData cell dimensions -->
-      <subsegmentation key="slice" value="Hcal_readout_segmentation_slice"/>
-
-      <layer repeat="Hcal_nlayers" vis="SeeThrough">
-        <slice material="FloatGlass" thickness="HcalSD_glass_anode_thickness" vis="Invisible"/>
-        <slice material="RPCGAS2"    thickness="HcalSD_sensitive_gas_gap" sensitive="yes" limits="cal_limits" vis="YellowVis"/>
-        <slice material="FloatGlass" thickness="HcalSD_glass_cathode_thickness" vis="Invisible"/>
-        <slice material="G4_POLYSTYRENE" thickness = "Hcal_scintillator_thickness" sensitive = "yes"   limits="cal_limits"  vis="CyanVis"   />
-        <slice material="Air"      thickness="Hcal_chamber_thickness - ( HcalSD_glass_anode_thickness + HcalSD_sensitive_gas_gap + HcalSD_glass_cathode_thickness + Hcal_scintillator_thickness)" vis="Invisible" />
+      <layer repeat="Hcal_nlayers" vis="seeThrough">
+        <slice material="Steel235" thickness = "2*mm"   vis="seeThrough"   />
+        <slice material="PCB" thickness = "Hcal_PCB_thickness"   vis="GreenVis"   />
+        <slice material="Air" thickness = "Hcal_scintillator_ESR_air_thickness" sensitive = "yes"   limits="cal_limits"  vis="SeeThrough" >
+          <sensitive material = "G4_POLYSTYRENE"  sensitive = "yes" limits="cal_limits"   vis="CyanVis"/>
+          <ladder material = "G4_ESR"  limits="cal_limits" vis="RedVis" />
+        </slice>
+        <slice material="Steel235" thickness = "2*mm"   vis="seeThrough"   />
       </layer>
     </detector>
   </detectors>
 
   <readouts>
     <readout name="HcalBarrelCollection">
-      <segmentation   type="MultiSegmentation"  key="slice">
-        <segmentation name="RPCgrid" type="CartesianGridXY"   key_value="1"  grid_size_x="Hcal_cell_size" grid_size_y="Hcal_cell_size" />
-        <segmentation name="Scigrid" type="TiledLayerGridXY"  key_value="3"  grid_size_x="3" grid_size_y="3.03248"/>
-      </segmentation>
-      <hits_collections>
-        <hits_collection name="HCalBarrelRPCHits"  key="slice" key_value="1"/>
-        <hits_collection name="HcalBarrelRegCollection"  key="slice" key_value="3"/>
-      </hits_collections>
-      <id>system:5,module:3,stave:4,tower:5,layer:6,slice:4,x:32:-16,y:-16</id>
+      <id>system:5,stave:4,layer:6,tile:16,x:32:-16,y:-16</id>
     </readout>
   </readouts>
 
diff --git a/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Endcaps_v02.xml b/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Endcaps_v02.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ccfb77b3f374b7821675f9c6d12b471ec06a16ba
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/SHcalSc04_Endcaps_v02.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+  <comment>Plastic Scintillator tile HCAL endcap by Jiyuan Chen</comment>
+
+    <define>
+        <constant name="hcalendcap_inner_radius" value="Hcal_endcap_inner_radius"/>
+        <constant name="hcalendcap_outer_radius" value="Hcal_endcap_outer_radius"/>
+        <constant name="hcalendcap_thickness" value="Hcal_endcap_zmax-Hcal_endcap_zmin"/>
+        <constant name="hcalendcap_z" value="0.5*(Hcal_endcap_zmin+Hcal_endcap_zmax)"/>
+        <constant name="Nmodules" value="Hcal_endcap_symmetry"/>
+
+        <constant name="scintillator_xy" value="40.0*mm"/>
+        <constant name="scintillator_z" value="3.0*mm"/>
+        <constant name="wrapped_scintillator_xy" value="40.3*mm"/>
+        <constant name="wrapped_scintillator_z" value="3.2*mm"/>
+
+        <!-- Odd-shaped cells -->
+        <constant name="Nodd" value="5"/>
+        <constant name="short_elongation_1" value="0*mm"/>
+        <constant name="short_elongation_2" value="4.5*mm"/>
+        <constant name="short_elongation_3" value="9*mm"/>
+        <constant name="short_elongation_4" value="14*mm"/>
+        <constant name="short_elongation_5" value="17*mm"/>
+
+        <constant name="cassette_thickness" value="2.0*mm"/>
+        <constant name="esr_thickness" value="65.0*um"/>
+        <constant name="sipm_xy" value="3.0*mm"/>
+        <constant name="sipm_z" value="0.8*mm"/>
+        <constant name="pcb_thickness" value="3.2*mm"/>
+        <constant name="absorber_thickness" value="16.8*mm"/>
+
+        <constant name="inner_structure_thickness" value="50*mm"/>
+        <constant name="outer_structure_width" value="120*mm"/>
+        <constant name="outer_structure_thickness" value="50*mm"/>
+        <constant name="frame_thickness" value="3*mm"/>
+
+        <constant name="boundary_safety" value="1*nm"/>
+    </define>
+
+    <regions>
+        <region name="HcalEndcapsRegion">
+        </region>
+    </regions>
+
+    <detectors>
+        <detector id="DetID_HCAL_ENDCAP"
+                  name="HcalEndcaps"
+                  type="SHcalSc04_Endcaps_v02"
+                  readout="HcalEndcapsCollection"
+                  vis="Invisible"
+                  sensitive="true"
+                  region="HcalEndcapsRegion">
+            <!-- Use cm as unit if you want to use Pandora for reconstruction -->
+        <material name="G4_POLYSTYRENE"/>
+        </detector>
+    </detectors>
+
+    <readouts>
+        <readout name="HcalEndcapsCollection">
+            <segmentation type="NoSegmentation"/>
+            <!--segmentation type="CartesianGridXYZ"
+                          grid_size_x="1*cm"
+                          grid_size_y="1*cm"
+                          grid_size_z="1*cm"/-->
+            <id>system:5,stave:5,layer:6,row:7,phi:6</id>
+        </readout>
+    </readouts>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_CaloTest/TDR_Dimensions_v01_01.xml b/Detector/DetCRD/compact/TDR_CaloTest/TDR_Dimensions_v01_01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7b37c14e5aa3d3c48bd377d4937d5482b31ff374
--- /dev/null
+++ b/Detector/DetCRD/compact/TDR_CaloTest/TDR_Dimensions_v01_01.xml
@@ -0,0 +1,369 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <info name="CRDDimensions"
+       title="master file with includes and world dimension"
+       author=""
+       url="no"
+       status="development"
+       version="1.0">
+    <comment>
+      undeterminded parameters
+    </comment>
+  </info>
+
+  <define>
+    <constant name="CrossingAngle" value="0.033*rad"/>  
+
+    <constant name="Global_endcap_costheta" value="0.99"/>
+
+    <constant name="GlobalTrackerReadoutID_DCH" type="string" value="system:8,chamber:1,layer:7,phi:16"/>
+    <constant name="GlobalTrackerReadoutID" type="string" value="system:5,side:-2,layer:9,module:8,sensor:8,barrelside:-2"/>
+
+    <constant name="Field_nominal_value" value="3*tesla"/>
+    <constant name="Field_outer_nominal_value" value="-1.3*tesla"/>
+
+    <constant name="env_safety" value="0.1*mm"/>
+
+    <constant name="DetID_NOTUSED"      value="  0"/>
+    <constant name="DetID_VXD"          value="  1"/>
+    <constant name="DetID_SIT"          value="  2"/>
+    <constant name="DetID_FTD"          value="  3"/>
+    <constant name="DetID_TPC"          value="  4"/>
+    <constant name="DetID_SET"          value="  5"/>
+    <constant name="DetID_ETD"          value="  6"/>
+    
+    <constant name="DetID_ECAL"         value=" 20"/>
+    <constant name="DetID_ECAL_PLUG"    value=" 21"/>
+    <constant name="DetID_HCAL"         value=" 22"/>
+    <constant name="DetID_HCAL_RING"    value=" 23"/>
+    <constant name="DetID_LCAL"         value=" 24"/>
+    <constant name="DetID_BCAL"         value=" 25"/>
+    <constant name="DetID_LHCAL"        value=" 26"/>
+    <constant name="DetID_YOKE"         value=" 27"/>
+    <constant name="DetID_COIL"         value=" 28"/>
+    <constant name="DetID_ECAL_ENDCAP"  value=" 29"/>
+    <constant name="DetID_HCAL_ENDCAP"  value=" 30"/>
+    <constant name="DetID_YOKE_ENDCAP"  value=" 31"/>
+    
+    <constant name="DetID_bwd"       value="-1"/>
+    <constant name="DetID_barrel"    value=" 0"/>
+    <constant name="DetID_fwd"       value="+1"/>
+
+    <!-- FIXME:need to check/-->
+    <constant name="BeamPipe_Be_inner_thickness"   value="0.2*mm"/>
+    <constant name="BeamPipe_Cooling_thickness"    value="0.3*mm"/>
+    <constant name="BeamPipe_Be_outer_thickness"   value="0.15*mm"/>
+    <constant name="BeamPipe_Be_total_thickness"   value="BeamPipe_Be_inner_thickness+BeamPipe_Cooling_thickness+BeamPipe_Be_outer_thickness"/>
+    <constant name="BeamPipe_Al_thickness"         value="BeamPipe_Be_total_thickness"/>
+    <constant name="BeamPipe_ThinCu_thickness"     value="2.0*mm"/>
+    <constant name="BeamPipe_Cu_thickness"         value="3.0*mm"/>
+
+    <constant name="BeamPipe_CentralBe_zmax"       value="85*mm"/>
+    <constant name="BeamPipe_CentralAl_zmax"       value="180*mm"/>
+    <constant name="BeamPipe_ExpandAl_zmax"        value="655*mm"/>
+    <constant name="BeamPipe_Linker_zmin"          value="700*mm"/>
+    <constant name="BeamPipe_Linker_zmax"          value="780*mm"/>
+    <constant name="BeamPipe_Waist_zmax"           value="805*mm"/>
+    <constant name="BeamPipe_Crotch_zmax"          value="855*mm"/>
+    <constant name="BeamPipe_FirstSeparated_zmax"  value="1110*mm"/>
+    <constant name="BeamPipe_Mask_zmin"            value="1210*mm"/>
+    <constant name="BeamPipe_Mask_zmax"            value="1230*mm"/>
+    <constant name="BeamPipe_Q1a_zmin"             value="1900*mm"/>
+    <constant name="BeamPipe_Q1a_zmax"             value="3110*mm"/>
+    <constant name="BeamPipe_Q1b_zmin"             value="3190*mm"/>
+    <constant name="BeamPipe_Q1b_zmax"             value="4400*mm"/>
+    <constant name="BeamPipe_QF1_zmin"             value="4700*mm"/>
+    <constant name="BeamPipe_QF1_zmax"             value="6200*mm"/>
+    <constant name="BeamPipe_end_z"                value="7050*mm"/>
+
+    <constant name="BeamPipe_Central_inner_radius"  value="10*mm"/>
+    <constant name="BeamPipe_Fork_inner_radius"     value="10*mm"/>
+    <constant name="BeamPipe_FirstExpand_width"     value="35*mm"/>
+    <constant name="BeamPipe_SecondExpand_width"    value="39*mm"/>
+    <constant name="BeamPipe_Mask_inner_radius"     value="6*mm"/>
+    <constant name="BeamPipe_Q1a_inner_radius"      value="BeamPipe_Fork_inner_radius"/>
+    <constant name="BeamPipe_Q1b_inner_radius"      value="11.5*mm"/>
+    <constant name="BeamPipe_QF1_inner_radius"      value="16*mm"/>
+
+    <constant name="BeamPipe_FrontLinker_rmax"      value="BeamPipe_FirstExpand_width/2+BeamPipe_Al_thickness"/>
+    <constant name="BeamPipe_ForwardRegion_rmax"    value="BeamPipe_SecondExpand_width/2+BeamPipe_Cu_thickness"/>
+
+    <constant name="Vertex_inner_radius" value="BeamPipe_Central_inner_radius+BeamPipe_Be_total_thickness"/>
+    <constant name="Vertex_outer_radius" value="72.5*mm"/>
+    <constant name="Vertex_half_length"  value="750*mm"/>
+
+    <!--constant name="BeamPipe_VertexRegion_rmax"     value="BeamPipe_Central_inner_radius+BeamPipe_Al_thickness
+	   +(BeamPipe_FirstExpand_width/2-BeamPipe_Central_inner_radius)/(BeamPipe_ExpandAl_zmax-BeamPipe_CentralAl_zmax)*(Vertex_half_length-BeamPipe_CentralAl_zmax)"/-->
+    <constant name="BeamPipe_VertexRegion_rmax"     value="BeamPipe_FirstExpand_width
+							   +(BeamPipe_SecondExpand_width-BeamPipe_FirstExpand_width)/(BeamPipe_Linker_zmax-BeamPipe_Linker_zmin)*(Vertex_half_length-BeamPipe_Linker_zmin)"/>
+    <constant name="Vertex_Side_rmin"    value="BeamPipe_VertexRegion_rmax"/>
+
+    <constant name="TPC_inner_radius" value="600*mm"/>
+    <constant name="TPC_outer_radius" value="1800*mm"/>
+    <constant name="TPC_half_length"  value="2900*mm"/>
+    <constant name="OuterTracker_half_length" value="TPC_half_length"/>
+
+    <constant name="SIT1_inner_radius"   value="150*mm"/>
+    <constant name="SIT2_inner_radius"   value="250*mm"/>
+    <constant name="SIT3_inner_radius"   value="500*mm"/>
+    <constant name="SIT1_half_length"    value="243*mm"/>
+    <constant name="SIT2_half_length"    value="405*mm"/>
+    <constant name="SIT3_half_length"    value="810*mm"/>
+
+    <constant name="SET_inner_radius"    value="1800*mm"/>
+
+    <constant name="SiTracker_region1_costheta"   value="0.85"/>
+    <constant name="SiTracker_region2_costheta"   value="0.9"/>
+    <constant name="SiTracker_region3_costheta"   value="0.95"/>
+    <constant name="SiTracker_endcap_barrel_zgap" value="5*mm"/>
+    <constant name="SiTracker_endcap_barrel_rgap" value="10*mm"/>
+    <constant name="SiTracker_endcap_gas_zgap"    value="3*mm"/>
+    <constant name="SiTracker_endcap_gas_rgap"    value="20*mm"/>
+    <constant name="SiTracker_endcap_z1" value="Vertex_half_length"/>
+    <constant name="SiTracker_endcap_z2" value="SIT3_half_length+SiTracker_endcap_barrel_zgap"/>
+    <constant name="SiTracker_endcap_z3" value="TPC_inner_radius/tan(acos(SiTracker_region2_costheta))"/>
+    <constant name="SiTracker_endcap_z4" value="TPC_inner_radius/tan(acos(SiTracker_region3_costheta))"/>
+    <constant name="SiTracker_endcap_z5" value="TPC_half_length+SiTracker_endcap_gas_zgap"/>
+    <constant name="SiTracker_endcap_outer_radius1" value="SiTracker_endcap_z1*tan(acos(SiTracker_region1_costheta))"/>
+    <constant name="SiTracker_endcap_outer_radius2" value="SIT3_inner_radius"/>
+    <constant name="SiTracker_endcap_outer_radius3" value="TPC_inner_radius-SiTracker_endcap_gas_rgap"/>
+    <constant name="SiTracker_endcap_outer_radius4" value="TPC_inner_radius-SiTracker_endcap_gas_rgap"/>
+    <constant name="SiTracker_endcap_outer_radius5" value="TPC_outer_radius+SiTracker_endcap_barrel_rgap"/>
+
+    <!--obseleted constance, used by old construct, should be removed while creating new constrcut-->
+    <constant name="TPC_Ecal_Hcal_barrel_halfZ"   value="TPC_half_length"/>
+
+    <constant name="Ecal_barrel_inner_radius" value="1830*mm"/>
+    <constant name="Ecal_barrel_thickness"    value="300*mm"/>
+    <constant name="Ecal_barrel_outer_radius" value="Ecal_barrel_inner_radius+Ecal_barrel_thickness"/>
+    <constant name="Ecal_barrel_half_length"  value="2900*mm"/>
+    <constant name="Ecal_barrel_symmetry"     value="32"/>
+    <constant name="Ecal_Tpc_gap"             value="Ecal_barrel_inner_radius-TPC_outer_radius"/>
+
+    <constant name="Ecal_endcap_inner_radius" value="350*mm"/>
+    <constant name="Ecal_endcap_outer_radius" value="Ecal_barrel_outer_radius"/>
+    <constant name="Ecal_endcap_zmin"         value="2930*mm"/>
+    <constant name="Ecal_endcap_thickness"    value="Ecal_barrel_thickness"/>
+    <constant name="Ecal_endcap_zmax"         value="Ecal_endcap_zmin+Ecal_endcap_thickness"/>
+    <constant name="Ecal_endcap_symmetry"     value="32"/>
+
+    <constant name="Hcal_barrel_inner_radius" value="2140*mm"/>
+    <constant name="Hcal_barrel_outer_radius" value="3455*mm"/>
+    <constant name="Hcal_barrel_half_length"  value="3230*mm"/>
+    <constant name="Hcal_barrel_symmetry"    value="16"/>
+    
+    <constant name="Hcal_endcap_inner_radius" value="450*mm"/>
+    <constant name="Hcal_endcap_outer_radius" value="Hcal_barrel_outer_radius"/>
+    <constant name="Hcal_endcap_zmin" value="3260*mm"/>
+    <constant name="Hcal_endcap_thickness" value="Hcal_barrel_outer_radius-Hcal_barrel_inner_radius"/>
+    <constant name="Hcal_endcap_zmax" value="Hcal_endcap_zmin+Hcal_endcap_thickness"/>
+    <constant name="Hcal_endcap_symmetry" value="16"/>
+
+    <constant name="Solenoid_inner_radius" value="3535*mm"/>
+    <constant name="Solenoid_outer_radius" value="4235*mm"/>
+    <constant name="Solenoid_half_length" value="4575*mm"/>
+    <constant name="SolenoidCoil_half_length" value="4075*mm"/>
+    <constant name="SolenoidCoil_radius" value="3650*mm"/>
+    <constant name="SolenoidCoil_center_radius" value="(Solenoid_inner_radius+Solenoid_outer_radius)/2"/>
+        
+    <constant name="Yoke_barrel_inner_radius" value="4235*mm"/>
+    <constant name="Yoke_barrel_outer_radius" value="5485*mm"/>
+    <constant name="Yoke_barrel_half_length" value="4525*mm"/>
+    <constant name="Yoke_barrel_symmetry" value="12"/>
+    
+    <constant name="Yoke_endcap_inner_radius" value="650*mm"/>
+    <constant name="Yoke_endcap_outer_radius" value="Yoke_barrel_outer_radius"/>
+    <constant name="Yoke_endcap_zmin" value="4635*mm"/>
+    <constant name="Yoke_endcap_zmax" value="5875*mm"/>
+    <constant name="Yoke_endcap_outer_symmetry" value="Yoke_barrel_symmetry"/>
+    <constant name="Yoke_endcap_inner_symmetry" value="0"/>
+
+    <!-- FIXME:need to check/--> 
+    <constant name="Lumical_inner_radius" value="BeamPipe_Fork_inner_radius+BeamPipe_ThinCu_thickness"/>
+    <constant name="Lumical_outer_radius" value="100.0*mm"/>
+    <constant name="Lumical_zmax" value="BeamPipe_FirstSeparated_zmax" />
+    <constant name="Lumical_zmin" value="700*mm"/>
+    <constant name="Lumical_thickness" value="(Lumical_zmax-Lumical_zmin)/2.0"/>
+        
+    <constant name="tracker_region_zmax" value="Ecal_endcap_zmin"/>
+    <constant name="tracker_region_rmax" value="Ecal_barrel_inner_radius"/>
+
+    <!--Muon Detector-->
+    <!--strip & fiber dimensions-->
+    <constant name="Muon_strip_x" value="4*cm"/>
+    <constant name="Muon_strip_y" value="1*cm"/>
+    <constant name="Muon_strip_z" value="4*m"/>
+    <constant name="Muon_strip_surf" value="1*mm"/>
+
+    <constant name="Muon_strip_surface_x" value="Muon_strip_x"/>
+    <constant name="Muon_strip_surface_y" value="Muon_strip_y"/>
+    <constant name="Muon_strip_surface_z" value="Muon_strip_z"/>
+
+    <constant name="Muon_strip_scintillator_x" value="Muon_strip_x-2*Muon_strip_surf"/>
+    <constant name="Muon_strip_scintillator_y" value="Muon_strip_y-2*Muon_strip_surf"/>
+    <constant name="Muon_strip_scintillator_z" value="Muon_strip_z"/>
+
+    <constant name="Muon_strip_SiPM_x" value="6*mm"/>
+    <constant name="Muon_strip_SiPM_y" value="6*mm"/>
+    <constant name="Muon_strip_SiPM_z" value="Muon_strip_surf"/>
+    <constant name="Muon_strip_SiPM_posx" value="0"/>
+    <constant name="Muon_strip_SiPM_posy" value="0"/>
+    <constant name="Muon_strip_SiPM_posz" value="0.5*Muon_strip_z+0.5*Muon_strip_SiPM_z"/>
+
+    <constant name="Muon_fiber_core_rmax" value="0.95*mm"/>
+    <constant name="Muon_fiber_core_z" value="Muon_strip_z"/>
+
+    <constant name="Muon_fiber_cladding_rmin" value="Muon_fiber_core_rmax"/>
+    <constant name="Muon_fiber_cladding_rmax" value="1*mm"/>
+    <constant name="Muon_fiber_cladding_z" value="Muon_strip_z"/>
+
+    <constant name="Muon_strip_cut_gap" value="0.1*mm"/>
+    <constant name="Muon_strip_cut3_rmax" value="Muon_fiber_cladding_rmax+Muon_strip_cut_gap"/>
+    <constant name="Muon_strip_cut3_z" value="Muon_strip_z"/>
+    <constant name="Muon_strip_cut3_posx" value="0"/>
+    <constant name="Muon_strip_cut3_posy" value="Muon_strip_cut3_rmax-Muon_fiber_cladding_rmax"/>
+    <constant name="Muon_strip_cut3_posz" value="0"/>
+
+    <constant name="Muon_strip_cut1_x" value="2*Muon_strip_cut3_rmax"/>
+    <constant name="Muon_strip_cut1_y" value="Muon_strip_surf"/>
+    <constant name="Muon_strip_cut1_z" value="Muon_strip_z"/>
+    <constant name="Muon_strip_cut1_posx" value="0"/>
+    <constant name="Muon_strip_cut1_posy" value="0.5*Muon_strip_y-0.5*Muon_strip_cut1_y"/>
+    <constant name="Muon_strip_cut1_posz" value="0"/>
+
+    <constant name="Muon_strip_cut2_x" value="Muon_strip_cut1_x"/>
+    <constant name="Muon_strip_cut2_y" value="0.5*Muon_strip_scintillator_y-Muon_strip_cut3_rmax+Muon_fiber_cladding_rmax"/>
+    <constant name="Muon_strip_cut2_z" value="Muon_strip_z"/>
+    <constant name="Muon_strip_cut2_posx" value="0"/>
+    <constant name="Muon_strip_cut2_posy" value="0.5*Muon_strip_scintillator_y-0.5*Muon_strip_cut2_y"/>
+    <constant name="Muon_strip_cut2_posz" value="0"/>
+
+    <!--standard scale-->
+    <constant name="Muon_standard_scale" value="105*cm"/>    
+    <constant name="Muon_Iron_gap_z" value="100*cm"/>
+
+    <!--Muon Barrel>
+    <constant name="Muon_barrel_barrel_num" value="2"/>
+    <constant name="Muon_barrel_iron_part_num" value="12"/>
+    <constant name="Muon_barrel_superlayer_num" value="6"/>
+    <constant name="Muon_barrel_strip_num_0" value="40"/>
+    <constant name="Muon_barrel_strip_num_1" value="48"/>
+    <constant name="Muon_barrel_strip_num_2" value="62"/>
+    <constant name="Muon_barrel_strip_num_3" value="74"/>
+    <constant name="Muon_barrel_strip_num_4" value="84"/>
+    <constant name="Muon_barrel_strip_num_5" value="96"/>
+    <constant name="Muon_barrel_strip_num" value="100"/>
+
+    <constant name="Muon_barrel_iron_x1" value="Muon_standard_scale"/>
+    <constant name="Muon_barrel_iron_y" value="Muon_strip_z+2*Muon_strip_surf+Muon_Iron_gap_z"/>
+    <constant name="Muon_barrel_iron_z" value="Muon_standard_scale"/>
+    <constant name="Muon_barrel_iron_posx" value="-1*Muon_standard_scale"/>
+
+    <constant name="Muon_barrel_barrel_y" value="Muon_barrel_iron_y"/>
+    <constant name="Muon_barrel_barrel_posy" value="0.5*Muon_barrel_barrel_y"/>
+
+    <constant name="Muon_barrel_superlayer_init" value="-21.5*cm"/>
+    <constant name="Muon_barrel_superlayer_gap" value="12.5*cm"/>
+    <constant name="Muon_barrel_superlayer_air_gap" value="0.1*cm"/>
+    <constant name="Muon_barrel_superlayer_aluminum_gap" value="0.5*Muon_barrel_superlayer_air_gap"/>
+
+    <constant name="Muon_barrel_superlayer_y" value="2*Muon_strip_y+2*Muon_barrel_superlayer_air_gap"/>
+    <constant name="Muon_barrel_superlayer_z" value="Muon_strip_z+2*Muon_strip_surf+2*Muon_barrel_superlayer_air_gap"/> 
+
+    <Muon Endcap>
+    <constant name="Muon_endcap_part_num" value="4"/>
+    <constant name="Muon_endcap_superlayer_num" value="6"/>
+    <constant name="Muon_endcap_iron_gap_num" value="Muon_endcap_superlayer_num+1"/>
+    <constant name="Muon_endcap_layer_num" value="2"/>
+    <constant name="Muon_endcap_strip_num" value="146"/>
+    <constant name="Muon_endcap_strip_num_cut" value="13"/>
+    <constant name="Muon_endcap_endcap_rmin" value="52*cm"/>
+    <constant name="Muon_endcap_magnification" value="1.02"/>
+
+    <constant name="Muon_endcap_iron_gap" value="12.5*cm"/>
+    <constant name="Muon_endcap_endcap_z" value="Muon_endcap_iron_gap_num*Muon_endcap_iron_gap+2*Muon_endcap_superlayer_num*Muon_strip_y"/>
+    <constant name="Muon_endcap_endcap_posy" value="Muon_strip_z+2*Muon_strip_surf+Muon_Iron_gap_z+0.5*Muon_endcap_endcap_z"/-->
+
+  </define>
+  
+  <limits>
+    <limitset name="cal_limits">
+      <limit name="step_length_max" particles="*" value="5.0" unit="mm" />
+    </limitset>
+    <limitset name="tpc_limits">
+      <limit name="step_length_max" particles="*" value="10.0" unit="mm" />
+    </limitset>
+    <limitset name="tracker_limits">
+      <limit name="step_length_max" particles="*" value="5.0" unit="mm" />
+    </limitset>
+    <limitset name="detail_limits">
+      <limit name="step_length_max" particles="*" value="1.0" unit="mm" />
+    </limitset>
+    <limitset name="support_limits">
+      <limit name="step_length_max" particles="*" value="10.0" unit="mm" />
+    </limitset>
+    <limitset name="yoke_limits">
+      <limit name="step_length_max" particles="*" value="10.0" unit="mm" />
+      <!--limit name="track_length_max" particles="*" value="5.0" unit="mm" /-->
+      <!--limit name="time_max" particles="*" value="5.0" unit="ns" /-->
+      <limit name="ekin_min" particles="*" value="10" unit="MeV" />
+      <limit name="range_min" particles="*" value="10.0" unit="mm" />
+    </limitset>
+  </limits>
+
+  <regions>
+    <region name="BeampipeRegion"/>
+    <region name="VertexRegion"/>
+    <region name="ForwardRegion"/>
+  </regions>
+
+  <display>
+    <vis name="VXDVis"           alpha="0.1" r="0.1"   g=".5"      b=".5"    showDaughters="true"  visible="true"/>
+    <vis name="VXDLayerVis"      alpha="1.0" r="0.1"   g=".5"      b=".5"    showDaughters="true"  visible="true"/>
+    <vis name="VXDSupportVis"    alpha="1.0" r="0.0"   g="1.0"     b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="FTDVis"           alpha="1.0" r="0.5"   g="0.87"    b="0.11"  showDaughters="true"  visible="true"/>
+    <vis name="FTDSupportVis"    alpha="1.0" r="0.3"   g="0.3"     b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="FTDSensitiveVis"  alpha="1.0" r="0.3"   g="0.5"     b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="DCVis"            alpha="1.0" r="0.96"  g="0.64"    b="0.90"  showDaughters="true"  visible="true"/>
+    <vis name="DCLayerVis"       alpha="1.0" r="0.96"  g="0.64"    b="0.90"  showDaughters="false" visible="true"/>
+    <vis name="TPCVis"           alpha="1.0" r="0.96"  g="0.64"    b="0.90"  showDaughters="true"  visible="true"/>
+    <vis name="TPCMotherVis"     alpha="1.0" r="0.96"  g="0.64"    b="0.90"  showDaughters="true"  visible="true"/>
+    <vis name="TPCGasVis"        alpha="1.0" r="0.96"  g="0.64"    b="0.90"  showDaughters="true"  visible="false"/>
+    <vis name="TPCCathodeVis"    alpha="1.0" r="0.6"   g="1.0"     b="0.80"  showDaughters="true"  visible="true"/>
+    <vis name="TPCCathodeGripVis" alpha="1." r="0.7"   g="0.7"     b="0.70"  showDaughters="true"  visible="true"/>
+    <vis name="TPCShellVis"      alpha="1.0" r="0.5"   g="0.5"     b="0.5"   showDaughters="true"  visible="true"/>
+    <vis name="SITVis"           alpha="0.0" r="0.54"  g="0.59"    b="0.93"  showDaughters="true"  visible="false"/>
+    <vis name="SITSupportVis"    alpha="1.0" r="0.0"   g="0.0"     b="1.0"   showDaughters="false" visible="true"/>
+    <vis name="SITSensitiveVis"  alpha="1.0" r="0.67"  g="0.99"    b="0.78"  showDaughters="false" visible="true"/>
+    <vis name="SETVis"           alpha="0.0" r="0.8"   g="0.8"     b="0.4"   showDaughters="true"  visible="false"/>
+    <vis name="SETSupportVis"    alpha="1.0" r="0.5"   g="0.3"     b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="SETSensitiveVis"  alpha="1.0" r="0.0"   g="0.60"    b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="ECALVis"          alpha="1.0" r="0.2"   g="0.6"     b="0"     showDaughters="true"  visible="true"/>
+    <vis name="HCALVis"          alpha="1.0" r="0.95"  g="0.78"    b="0.69"  showDaughters="true"  visible="true"/>
+    <vis name="SOLVis"           alpha="1.0" r="0.0"   g="0.0"     b="0.8"   showDaughters="true"  visible="true"/>
+    <vis name="YOKEVis"          alpha="1.0" r="0.64"  g="0.75"    b="0.99"  showDaughters="true" visible="true"/>
+    <vis name="LCALVis"          alpha="1.0" r="0.25"  g="0.88"    b="0.81"  showDaughters="true"  visible="true"/>
+    <vis name="SupportVis"       alpha="1.0" r="0.2"   g="0.2"     b="0.2"   showDaughters="true"  visible="true"/>
+    <vis name="ShellVis"         alpha="1.0" r="1.0"   g="1.0"     b="0.8"   showDaughters="false" visible="true"/>
+
+    <vis name="WhiteVis"         alpha="0.0" r=".96" g=".96"  b=".96"   showDaughters="true"  visible="true"/>
+    <vis name="LightGrayVis"     alpha="0.0" r=".75" g=".75"  b=".75"   showDaughters="true"  visible="true"/>
+    <vis name="Invisible"        alpha="0.0" r="0.0" g="0.0"  b="0.0"   showDaughters="false" visible="false"/>
+    <vis name="SeeThrough"       alpha="0.0" r="0.0" g="0.0"  b="0.0"   showDaughters="true"  visible="false"/>
+    <vis name="RedVis"           alpha="1.0" r="1.0" g="0.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="GreenVis"         alpha="1.0" r="0.0" g="1.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="BlueVis"          alpha="1.0" r="0.0" g="0.0"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="CyanVis"          alpha="1.0" r="0.0" g="1.0"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="MagentaVis"       alpha="1.0" r="1.0" g="0.0"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="VioletVis"        alpha="1.0" r=".83" g=".55"  b=".89"   showDaughters="true" visible="true"/>
+    <vis name="BlueVioletVis"    alpha="1.0" r=".55" g=".36"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="OrangeVis"        alpha="1.0" r="1.0" g="0.6"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="YellowVis"        alpha="1.0" r="1.0" g="1.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="BlackVis"         alpha="1.0" r="0.0" g="0.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="GrayVis"          alpha="1.0" r="0.5" g="0.5"  b="0.5"   showDaughters="true"  visible="true"/>
+  </display>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_CaloTest/TDR_longEcal_GSHcal.xml b/Detector/DetCRD/compact/TDR_CaloTest/TDR_longEcal_GSHcal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..99e88de6e7b8aa7cb3a8278127b02f6965468a64
--- /dev/null
+++ b/Detector/DetCRD/compact/TDR_CaloTest/TDR_longEcal_GSHcal.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+  <info name="TDR_o1_v01"
+        title="CepC reference detctor for TDR"
+        author=""
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <comment>CepC reference detector simulation models used for TDR </comment>
+  </info>
+  
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="../CRD_common_v02/materials.xml"/>
+  </includes>
+  
+  <define>
+    <constant name="world_size" value="10*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+
+    <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
+  </define>
+
+  <include ref="./TDR_Dimensions_v01_01.xml"/>
+
+  <!--TODO: vertex cooling-->
+  <include ref="../CRD_common_v02/Beampipe_v01_03.xml"/>
+  <!--preliminary vertex and tracker, to update/-->
+  <include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/>
+  <include ref="../CRD_common_v02/FTD_SkewRing_v01_05.xml"/>
+  <include ref="../CRD_common_v02/SIT_SimplePixel_v01_03.xml"/>
+  <!--include ref="../CRD_common_v01/TPC_Simple_v10_02.xml"/-->
+  <!--use 10 rows clustering version/-->
+  <include ref="../CRD_common_v02/TPC_ModularEndcap_o1_v02.xml"/>
+  <include ref="../CRD_common_v01/SET_SimplePixel_v01_01.xml"/>
+
+  <include ref="../CRD_common_v01/Ecal_Crystal_Barrel_v01_02.xml"/>
+  <include ref="../CRD_common_v01/Ecal_Crystal_Endcap_v01_01.xml"/>
+  <include ref="../CRD_common_v01/SHcalGlass_Barrel_v05.xml"/>
+  <include ref="../CRD_common_v01/SHcalGlass_Endcaps_v01.xml"/>
+
+  <!--Lumical to update-->
+  <include ref="../CRD_common_v01/Lumical_o1_v01.xml"/>
+  <!--preliminary Magnet, to update/-->
+  <include ref="../CRD_common_v02/Coil_Simple_v01_02.xml"/>
+  <!--preliminary Muon, obselete/-->
+  <!--include ref="../CRD_common_v02/Yoke_Polyhedra_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v02/Yoke_Polyhedra_Endcaps_v01_01.xml"/-->
+ 
+  <!--muon detector-->
+  <include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/>
+ 
+  <fields>
+    <field name="InnerSolenoid" type="solenoid"
+           inner_field="Field_nominal_value"
+           outer_field="0"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="SolenoidCoil_center_radius"
+           outer_radius="Solenoid_outer_radius">
+    </field>
+    <field name="OuterSolenoid" type="solenoid"
+           inner_field="0"
+           outer_field="Field_outer_nominal_value"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="Solenoid_outer_radius"
+           outer_radius="Yoke_barrel_inner_radius">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyGSHcal.xml b/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyGSHcal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ac7ada59909f9405f2cd5d98ec993b2fdcce2b77
--- /dev/null
+++ b/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyGSHcal.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+  <info name="TDR_o1_v01"
+        title="CepC reference detctor for TDR"
+        author=""
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <comment>CepC reference detector simulation models used for TDR </comment>
+  </info>
+  
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="../CRD_common_v02/materials.xml"/>
+  </includes>
+  
+  <define>
+    <constant name="world_size" value="10*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+
+    <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
+  </define>
+
+  <include ref="./TDR_Dimensions_v01_01.xml"/>
+
+  <!--TODO: vertex cooling-->
+  <!--include ref="../CRD_common_v02/Beampipe_v01_03.xml"/-->
+  <!--preliminary vertex and tracker, to update/-->
+  <!--include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/>
+  <include ref="../CRD_common_v02/FTD_SkewRing_v01_05.xml"/>
+  <include ref="../CRD_common_v02/SIT_SimplePixel_v01_03.xml"/-->
+  <!--include ref="../CRD_common_v01/TPC_Simple_v10_02.xml"/-->
+  <!--use 10 rows clustering version/-->
+  <!--include ref="../CRD_common_v02/TPC_ModularEndcap_o1_v02.xml"/>
+  <include ref="../CRD_common_v01/SET_SimplePixel_v01_01.xml"/-->
+
+  <!--include ref="../CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml"/-->
+  <!--include ref="../CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml"/-->
+  <include ref="../CRD_common_v01/SHcalGlass_Barrel_v05.xml"/>
+  <include ref="../CRD_common_v01/SHcalGlass_Endcaps_v01.xml"/>
+
+  <!--Lumical to update-->
+  <!--include ref="../CRD_common_v01/Lumical_o1_v01.xml"/-->
+  <!--preliminary Magnet, to update/-->
+  <!--include ref="../CRD_common_v02/Coil_Simple_v01_02.xml"/-->
+  <!--preliminary Muon, obselete/-->
+  <!--include ref="../CRD_common_v02/Yoke_Polyhedra_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v02/Yoke_Polyhedra_Endcaps_v01_01.xml"/-->
+ 
+  <!--muon detector-->
+  <!--include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/-->
+  <!--include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/-->
+ 
+  <fields>
+    <field name="InnerSolenoid" type="solenoid"
+           inner_field="Field_nominal_value"
+           outer_field="0"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="SolenoidCoil_center_radius"
+           outer_radius="Solenoid_outer_radius">
+    </field>
+    <field name="OuterSolenoid" type="solenoid"
+           inner_field="0"
+           outer_field="Field_outer_nominal_value"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="Solenoid_outer_radius"
+           outer_radius="Yoke_barrel_inner_radius">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyPSHcal.xml b/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyPSHcal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3d56ee8194196b26cc2f5109af29fe3e8d7db83d
--- /dev/null
+++ b/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyPSHcal.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+  <info name="TDR_o1_v01"
+        title="CepC reference detctor for TDR"
+        author=""
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <comment>CepC reference detector simulation models used for TDR </comment>
+  </info>
+  
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="../CRD_common_v02/materials.xml"/>
+  </includes>
+  
+  <define>
+    <constant name="world_size" value="10*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+
+    <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
+  </define>
+
+  <include ref="./TDR_Dimensions_v01_01.xml"/>
+
+  <!--TODO: vertex cooling-->
+  <!--include ref="../CRD_common_v02/Beampipe_v01_03.xml"/-->
+  <!--preliminary vertex and tracker, to update/-->
+  <!--include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/>
+  <include ref="../CRD_common_v02/FTD_SkewRing_v01_05.xml"/>
+  <include ref="../CRD_common_v02/SIT_SimplePixel_v01_03.xml"/-->
+  <!--include ref="../CRD_common_v01/TPC_Simple_v10_02.xml"/-->
+  <!--use 10 rows clustering version/-->
+  <!--include ref="../CRD_common_v02/TPC_ModularEndcap_o1_v02.xml"/>
+  <include ref="../CRD_common_v01/SET_SimplePixel_v01_01.xml"/-->
+
+  <!--include ref="../CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml"/-->
+  <!--include ref="../CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml"/-->
+  <include ref="../CRD_common_v01/SHcalSc04_Barrel_v04_01.xml"/>
+  <include ref="../CRD_common_v01/SHcalSc04_Endcaps_v02.xml"/>
+
+  <!--Lumical to update-->
+  <!--include ref="../CRD_common_v01/Lumical_o1_v01.xml"/-->
+  <!--preliminary Magnet, to update/-->
+  <!--include ref="../CRD_common_v02/Coil_Simple_v01_02.xml"/-->
+  <!--preliminary Muon, obselete/-->
+  <!--include ref="../CRD_common_v02/Yoke_Polyhedra_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v02/Yoke_Polyhedra_Endcaps_v01_01.xml"/-->
+ 
+  <!--muon detector-->
+  <!--include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/-->
+  <!--include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/-->
+ 
+  <fields>
+    <field name="InnerSolenoid" type="solenoid"
+           inner_field="Field_nominal_value"
+           outer_field="0"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="SolenoidCoil_center_radius"
+           outer_radius="Solenoid_outer_radius">
+    </field>
+    <field name="OuterSolenoid" type="solenoid"
+           inner_field="0"
+           outer_field="Field_outer_nominal_value"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="Solenoid_outer_radius"
+           outer_radius="Yoke_barrel_inner_radius">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyshortEcal.xml b/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyshortEcal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..48d39b447613510feb636ac0eabe5f7f8147946e
--- /dev/null
+++ b/Detector/DetCRD/compact/TDR_CaloTest/TDR_onlyshortEcal.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+  <info name="TDR_o1_v01"
+        title="CepC reference detctor for TDR"
+        author=""
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <comment>CepC reference detector simulation models used for TDR </comment>
+  </info>
+  
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="../CRD_common_v02/materials.xml"/>
+  </includes>
+  
+  <define>
+    <constant name="world_size" value="10*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+
+    <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
+  </define>
+
+  <include ref="./TDR_Dimensions_v01_01.xml"/>
+
+  <!--TODO: vertex cooling-->
+  <!--include ref="../CRD_common_v02/Beampipe_v01_03.xml"/-->
+  <!--preliminary vertex and tracker, to update/-->
+  <!--include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/>
+  <include ref="../CRD_common_v02/FTD_SkewRing_v01_05.xml"/>
+  <include ref="../CRD_common_v02/SIT_SimplePixel_v01_03.xml"/-->
+  <!--include ref="../CRD_common_v01/TPC_Simple_v10_02.xml"/-->
+  <!--use 10 rows clustering version/-->
+  <!--include ref="../CRD_common_v02/TPC_ModularEndcap_o1_v02.xml"/>
+  <include ref="../CRD_common_v01/SET_SimplePixel_v01_01.xml"/-->
+
+  <include ref="../CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml"/>
+  <include ref="../CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml"/>
+  <!--include ref="../CRD_common_v01/SHcalSc04_Barrel_v04_01.xml"/-->
+  <!--include ref="../CRD_common_v01/SHcalSc04_Endcaps_v02.xml"/-->
+
+  <!--Lumical to update-->
+  <!--include ref="../CRD_common_v01/Lumical_o1_v01.xml"/-->
+  <!--preliminary Magnet, to update/-->
+  <!--include ref="../CRD_common_v02/Coil_Simple_v01_02.xml"/-->
+  <!--preliminary Muon, obselete/-->
+  <!--include ref="../CRD_common_v02/Yoke_Polyhedra_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v02/Yoke_Polyhedra_Endcaps_v01_01.xml"/-->
+ 
+  <!--muon detector-->
+  <!--include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/-->
+  <!--include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/-->
+ 
+  <fields>
+    <field name="InnerSolenoid" type="solenoid"
+           inner_field="Field_nominal_value"
+           outer_field="0"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="SolenoidCoil_center_radius"
+           outer_radius="Solenoid_outer_radius">
+    </field>
+    <field name="OuterSolenoid" type="solenoid"
+           inner_field="0"
+           outer_field="Field_outer_nominal_value"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="Solenoid_outer_radius"
+           outer_radius="Yoke_barrel_inner_radius">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_CaloTest/TDR_shortEcal_PSHcal.xml b/Detector/DetCRD/compact/TDR_CaloTest/TDR_shortEcal_PSHcal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..07ecdec044314a2cb7507e7daee91dd632f7e8ee
--- /dev/null
+++ b/Detector/DetCRD/compact/TDR_CaloTest/TDR_shortEcal_PSHcal.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+       xmlns:xs="http://www.w3.org/2001/XMLSchema"
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+  <info name="TDR_o1_v01"
+        title="CepC reference detctor for TDR"
+        author=""
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <comment>CepC reference detector simulation models used for TDR </comment>
+  </info>
+  
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="../CRD_common_v02/materials.xml"/>
+  </includes>
+  
+  <define>
+    <constant name="world_size" value="10*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+
+    <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
+  </define>
+
+  <include ref="./TDR_Dimensions_v01_01.xml"/>
+
+  <!--TODO: vertex cooling-->
+  <include ref="../CRD_common_v02/Beampipe_v01_03.xml"/>
+  <!--preliminary vertex and tracker, to update/-->
+  <include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/>
+  <include ref="../CRD_common_v02/FTD_SkewRing_v01_05.xml"/>
+  <include ref="../CRD_common_v02/SIT_SimplePixel_v01_03.xml"/>
+  <!--include ref="../CRD_common_v01/TPC_Simple_v10_02.xml"/-->
+  <!--use 10 rows clustering version/-->
+  <include ref="../CRD_common_v02/TPC_ModularEndcap_o1_v02.xml"/>
+  <include ref="../CRD_common_v01/SET_SimplePixel_v01_01.xml"/>
+
+  <include ref="../CRD_common_v01/Ecal_Crystal_Barrel_Short_v02.xml"/>
+  <include ref="../CRD_common_v01/Ecal_Crystal_Endcap_Short_v01.xml"/>
+  <include ref="../CRD_common_v01/SHcalSc04_Barrel_v04_01.xml"/>
+  <include ref="../CRD_common_v01/SHcalSc04_Endcaps_v02.xml"/>
+
+  <!--Lumical to update-->
+  <include ref="../CRD_common_v01/Lumical_o1_v01.xml"/>
+  <!--preliminary Magnet, to update/-->
+  <include ref="../CRD_common_v02/Coil_Simple_v01_02.xml"/>
+  <!--preliminary Muon, obselete/-->
+  <!--include ref="../CRD_common_v02/Yoke_Polyhedra_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v02/Yoke_Polyhedra_Endcaps_v01_01.xml"/-->
+ 
+  <!--muon detector-->
+  <include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/>
+  <include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/>
+ 
+  <fields>
+    <field name="InnerSolenoid" type="solenoid"
+           inner_field="Field_nominal_value"
+           outer_field="0"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="SolenoidCoil_center_radius"
+           outer_radius="Solenoid_outer_radius">
+    </field>
+    <field name="OuterSolenoid" type="solenoid"
+           inner_field="0"
+           outer_field="Field_outer_nominal_value"
+           zmax="SolenoidCoil_half_length"
+           inner_radius="Solenoid_outer_radius"
+           outer_radius="Yoke_barrel_inner_radius">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml
index 1782fa6da80e4de455bb1621ff843aa7ca33e2f7..48b9e4567c27c0c75dcb805aae02a2f857f0d4e5 100644
--- a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml
+++ b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml
@@ -41,7 +41,7 @@
   <include ref="../CRD_common_v01/Ecal_Crystal_Barrel_v01_02.xml"/>
   <!--preliminary EcalEndcaps/-->
   <include ref="../CRD_common_v02/EcalEndcaps_Polyhedra_v01_01.xml"/>
-  <include ref="../CRD_common_v02/SHcalGlass_Barrel_v04_02.xml"/>
+  <include ref="../CRD_common_v01/SHcalGlass_Barrel_v05.xml"/>
   <!--preliminary HcalEndcaps/-->
   <include ref="../CRD_common_v02/HcalEndcaps_Polyhedra_v01_01.xml"/>
 
diff --git a/Detector/DetCRD/src/Calorimeter/CRDEcal_Endcap_Short_v01.cpp b/Detector/DetCRD/src/Calorimeter/CRDEcal_Endcap_Short_v01.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ca728e5f6e75ac041b28172f38a6d3ed59c3ac25
--- /dev/null
+++ b/Detector/DetCRD/src/Calorimeter/CRDEcal_Endcap_Short_v01.cpp
@@ -0,0 +1,520 @@
+//================================================================================
+// Description 鈥� Short-Crystal End-Cap ECAL
+//--------------------------------------------------------------------------------
+// Author: Ji-Yuan CHEN (SJTU; jy_chen@sjtu.edu.cn)
+//--------------------------------------------------------------------------------
+//
+// End-cap ECAL with short-bar crystals, 1脳1脳1 cm鲁 each.
+// Each block is of size 35脳35脳30 cm鲁.  Some blocks on the edges are truncated.
+// For placing more crystals, the gaps have been 'absorbed' in the blocks, and the actual size of each crystal is slightly smaller than (but still very close to) 1脳1脳1 cm鲁.
+//
+// The inner radius, number of modules in x or y direction, end-cap thickness, etc. are directly read from XML file.
+// Dead material: ESR (wrapper), SiPM, PCB, Cu (cooling material).
+//
+// Structure in a layer: ESR 鈫� crystal 鈫� ESR 鈫� SiPM 鈫� PCB 鈫� Cu.
+//
+// Default layout: 12 blocks in x and y directions; for filling up spaces, add some smaller blocks.  For a schematic diagram, see Page 1 of  <https://indico.ihep.ac.cn/event/22010/contributions/153187/attachments/77666/96430/2024_0324_Calorimeter_Endcaps.pdf>  (the structure on the left; the numbers and detailed block structures have been modified).
+//================================================================================
+
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/Shapes.h"
+#include "DD4hep/DetType.h"
+#include "XML/Layering.h"
+#include "XML/Utilities.h"
+#include "DDRec/DetectorData.h"
+#include "DDSegmentation/Segmentation.h"
+#include <sstream>
+
+using std::cout;
+using std::endl;
+using std::string;
+using std::to_string;
+
+#define MYDEBUG(x) cout << __FILE__ << ":" << __LINE__ << ": " << x << endl;
+#define MYDEBUGVAL(x) cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << endl;
+
+using dd4hep::Ref_t;
+using dd4hep::Detector;
+using dd4hep::SensitiveDetector;
+using dd4hep::pi;
+using dd4hep::degree;
+using dd4hep::DetElement;
+using dd4hep::Volume;
+using dd4hep::Tube;
+using dd4hep::Box;
+using dd4hep::SubtractionSolid;
+using dd4hep::UnionSolid;
+using dd4hep::Material;
+using dd4hep::PlacedVolume;
+using dd4hep::Position;
+using dd4hep::Transform3D;
+using dd4hep::RotationZ;
+using dd4hep::_toString;
+using dd4hep::RotationY;
+
+static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector sens)
+{
+    xml_det_t x_det = e;
+
+    const string det_name = x_det.nameStr();
+    const string det_type = x_det.typeStr();
+    const int det_id = x_det.id();
+    MYDEBUGVAL(det_name)
+    MYDEBUGVAL(det_type)
+    MYDEBUGVAL(det_id)
+
+    // To prevent overlapping
+    const double boundary_safety = theDetector.constant<double>("boundary_safety");
+
+    // Global geometry
+    const double r_in = theDetector.constant<double>("ecalendcap_inner_radius");
+    const double r_out = theDetector.constant<double>("ecalendcap_outer_radius");
+    const double block_xy_out = theDetector.constant<double>("ecalendcap_block_xy");
+    const double block_z = theDetector.constant<double>("ecalendcap_thickness");
+    const double pos_z = theDetector.constant<double>("ecalendcap_z");
+    const int Nblock_xy = theDetector.constant<double>("Nblock_xy");    // In a sector
+    const int Nsectors = theDetector.constant<double>("Nsectors");
+    const double gap_narrow = theDetector.constant<double>("gap_narrow");
+    const double gap_wide = theDetector.constant<double>("gap_wide");
+    const double block_xy_in = block_xy_out - gap_narrow;
+    const double angle = 2 * pi / Nsectors;
+
+    // Filling the gaps
+    const double block_rect_short_out = theDetector.constant<double>("ecalendcap_block_fill_rect_short");
+    const double block_sq1_width = theDetector.constant<double>("ecalendcap_block_fill_sq1");
+    const double block_sq2_width = theDetector.constant<double>("ecalendcap_block_fill_sq2");
+
+    const double block_rect_short_in = block_rect_short_out - gap_narrow;
+    const double block_sq1_width_in = block_sq1_width - gap_narrow;
+    const double block_sq2_width_in = block_sq2_width - gap_narrow;
+
+    const int Ncell_rect_short = theDetector.constant<double>("Ncell_rect_short");
+    const int Ncell_sq1_xy = theDetector.constant<double>("Ncell_sq1_xy");
+    const int Ncell_sq2_xy = theDetector.constant<double>("Ncell_sq2_xy");
+
+    // Unit size
+    const int Ncell_xy = theDetector.constant<int>("Ncell_xy");
+    const double crystal_z = theDetector.constant<double>("crystal_z");
+    const double cell_xy = block_xy_in / Ncell_xy;
+
+    const double esr_thickness = theDetector.constant<double>("esr_thickness");    // Wrapper
+    const double sipm_x = theDetector.constant<double>("sipm_x");
+    const double sipm_y = theDetector.constant<double>("sipm_y");
+    const double sipm_z = theDetector.constant<double>("sipm_z");
+    const double pcb_thickness = theDetector.constant<double>("pcb_thickness");
+    const double cu_thickness = theDetector.constant<double>("cu_thickness");    // Cooling material: Cu
+    const double fibre_thickness = theDetector.constant<double>("fibre_thickness");    // Mechanical structure: carbon fibre
+
+    const double crystal_xy = cell_xy - 4 * boundary_safety - 2 * esr_thickness - fibre_thickness;
+    const double cell_z = crystal_z + 4 * boundary_safety + 2 * esr_thickness + fibre_thickness;
+
+    const double layer_thickness = cell_z + sipm_z + pcb_thickness + cu_thickness + 4 * boundary_safety;
+    const int Nlayers = (int) (block_z / layer_thickness);
+
+    MYDEBUGVAL(layer_thickness)
+    MYDEBUGVAL(Nlayers)
+
+    // Materials
+    Material mat_air(theDetector.material("Air"));
+    Material mat_sensitive(theDetector.material( x_det.materialStr() ));
+    Material mat_ESR(theDetector.material("G4_ESR"));
+    Material mat_SiPM(theDetector.material("G4_Si"));
+    Material mat_PCB(theDetector.material("PCB"));
+    Material mat_Cu(theDetector.material("G4_Cu"));
+    Material mat_CF(theDetector.material("CarbonFiber"));
+
+    // Define the detector and mother volumes (world)
+    DetElement ECAL(det_name, det_id);
+    Volume motherVol = theDetector.pickMotherVolume(ECAL);
+
+    // Create two tube-like envelopes to represent the end-cap volumes
+    Tube envelope_tube(0, r_out, 0.5 * block_z + boundary_safety);
+    Box envelope_box(r_in, r_in, block_z);
+    SubtractionSolid envelope_side(envelope_tube, envelope_box, Position(0, 0, 0));
+    UnionSolid envelope(envelope_side, envelope_side, Position(0, 0, 2 * pos_z));
+    Volume envelopeVol(det_name, envelope, mat_air);
+    PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, Position(0, 0, -pos_z));
+    envelopePlv.addPhysVolID("system", det_id);
+    envelopeVol.setVisAttributes(theDetector, "SeeThrough");
+    ECAL.setPlacement(envelopePlv);
+    DetElement blockdet(ECAL, "box", det_id);
+
+    // Sector
+    Tube sector_tube(0, r_out, 0.5 * block_z + boundary_safety, 0, 0.5 * pi);
+    SubtractionSolid sector(sector_tube, envelope_box, Position(0, 0, 0));
+    Volume sector_vol("sector_vol", sector, mat_air);
+    sector_vol.setVisAttributes(theDetector, "GreenVis");
+
+    // Main block
+    Box block(0.5 * block_xy_out, 0.5 * block_xy_out, 0.5 * block_z + boundary_safety);
+    Volume block_vol("block_vol", block, mat_air);
+    block_vol.setVisAttributes(theDetector, "GreenVis");
+
+    Box block_cf_in(0.5 * block_xy_in, 0.5 * block_xy_in, 0.5 * block_z);
+    Volume block_cf("block_cf", SubtractionSolid(block, block_cf_in, Position(0, 0, 0)), mat_CF);
+    block_cf.setVisAttributes(theDetector, "GreenVis");
+
+    // Rectangle block for filling the space
+    Box block_rect(0.5 * block_xy_out, 0.5 * block_rect_short_out, 0.5 * block_z + boundary_safety);
+    Volume block_rect_vol("block_rect_vol", block_rect, mat_air);
+    block_rect_vol.setVisAttributes(theDetector, "GreenVis");
+
+    Box block_cf_rect_in(0.5 * block_xy_in, 0.5 * block_rect_short_out - gap_narrow, 0.5 * block_z);
+    Volume block_cf_rect("block_cf_rect", SubtractionSolid(block_rect, block_cf_rect_in, Position(0, 0, 0)), mat_CF);
+    block_cf_rect.setVisAttributes(theDetector, "GreenVis");
+
+    // Square blocks for filling the space
+    // Square 1
+    Box block_sq1(0.5 * block_sq1_width, 0.5 * block_sq1_width, 0.5 * block_z + boundary_safety);
+    Volume block_sq1_vol("block_sq1_vol", block_sq1, mat_air);
+    block_sq1_vol.setVisAttributes(theDetector, "GreenVis");
+
+    Box block_cf_sq1_in(0.5 * block_sq1_width_in, 0.5 * block_sq1_width_in, 0.5 * block_z);
+    Volume block_cf_sq1("block_cf_sq1", SubtractionSolid(block_sq1, block_cf_sq1_in, Position(0, 0, 0)), mat_CF);
+    block_cf_sq1.setVisAttributes(theDetector, "GreenVis");
+
+    // Square 2
+    Box block_sq2(0.5 * block_sq2_width, 0.5 * block_sq2_width, 0.5 * block_z + boundary_safety);
+    Volume block_sq2_vol("block_sq2_vol", block_sq2, mat_air);
+    block_sq2_vol.setVisAttributes(theDetector, "GreenVis");
+
+    Box block_cf_sq2_in(0.5 * block_sq2_width_in, 0.5 * block_sq2_width_in, 0.5 * block_z);
+    Volume block_cf_sq2("block_cf_sq2", SubtractionSolid(block_sq2, block_cf_sq2_in, Position(0, 0, 0)), mat_CF);
+    block_cf_sq2.setVisAttributes(theDetector, "GreenVis");
+
+    // Crystal, SiPM, ESR, and carbon fibre
+    Volume crystal("crystal", Box(0.5 * crystal_xy, 0.5 * crystal_xy, 0.5 * crystal_z), mat_sensitive);
+    crystal.setVisAttributes(theDetector, "SeeThrough");
+    crystal.setSensitiveDetector(sens);
+
+    Volume sipm("SiPM", Box(0.5 * sipm_x, 0.5 * sipm_y, 0.5 * sipm_z), mat_SiPM);
+    sipm.setVisAttributes(theDetector, "SeeThrough");
+
+    Box esr_out(0.5 * crystal_xy + esr_thickness + boundary_safety, 0.5 * crystal_xy + esr_thickness + boundary_safety, 0.5 * crystal_z + esr_thickness + boundary_safety);
+    Box esr_in(0.5 * crystal_xy + boundary_safety, 0.5 * crystal_xy + boundary_safety, 0.5 * crystal_z + boundary_safety);
+    Volume esr("esr", SubtractionSolid(esr_out, esr_in, Position(0, 0, 0)), mat_ESR);
+    esr.setVisAttributes(theDetector, "SeeThrough");
+
+    Box cf_out(0.5 * cell_xy, 0.5 * cell_xy, 0.5 * cell_z);
+    Box cf_in(0.5 * (cell_xy - fibre_thickness), 0.5 * (cell_xy - fibre_thickness), 0.5 * (cell_z - fibre_thickness));
+    Volume cf("cf", SubtractionSolid(cf_out, cf_in, Position(0, 0, 0)), mat_CF);
+    cf.setVisAttributes(theDetector, "SeeThrough");
+
+    // Positions
+    const double crystal_pos_z = -0.5 * layer_thickness + 0.5 * cell_z;
+    const double esr_pos_z = crystal_pos_z;
+    const double cf_pos_z = esr_pos_z;
+    const double sipm_pos_z = cf_pos_z + 0.5 * cell_z + boundary_safety + 0.5 * sipm_z;
+    const double pcb_pos_z = sipm_pos_z + 0.5 * sipm_z + boundary_safety + 0.5 * pcb_thickness;
+    const double cu_pos_z = pcb_pos_z + 0.5 * (pcb_thickness + cu_thickness);
+
+    // Loop for placing the units in a block
+    // Normal block
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        Volume slice("slice", Box(0.5 * block_xy_in, 0.5 * block_xy_in, 0.5 * layer_thickness), mat_air);
+        slice.setVisAttributes(theDetector, "SeeThrough");
+        string slicename = "Slice_" + to_string(ilayer);
+        DetElement sd(blockdet, slicename, det_id);
+
+        Volume slice_pcb("slice_pcb", Box(0.5 * block_xy_in, 0.5 * block_xy_in, 0.5 * pcb_thickness), mat_PCB);
+        slice_pcb.setVisAttributes(theDetector, "SeeThrough");
+
+        Volume slice_cu("slice_cu", Box(0.5 * block_xy_in, 0.5 * block_xy_in, 0.5 * cu_thickness), mat_Cu);
+        slice_cu.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit = slice.placeVolume(slice_pcb, Position(0, 0, pcb_pos_z));
+        pcb_unit.addPhysVolID("layer", ilayer);
+
+        PlacedVolume cu_unit = slice.placeVolume(slice_cu, Position(0, 0, cu_pos_z));
+        cu_unit.addPhysVolID("layer", ilayer);
+
+        for (int ix = 1; ix <= Ncell_xy; ++ix)
+            for (int iy = 1; iy <= Ncell_xy; ++iy)
+            {
+                PlacedVolume crystal_unit = slice.placeVolume(crystal,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_xy_in + iy * cell_xy,
+                                 crystal_pos_z));
+                PlacedVolume esr_unit = slice.placeVolume(esr,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_xy_in + iy * cell_xy,
+                                 esr_pos_z));
+                PlacedVolume cf_unit = slice.placeVolume(cf,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_xy_in + iy * cell_xy,
+                                 cf_pos_z));
+                PlacedVolume sipm_unit = slice.placeVolume(sipm,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_xy_in + iy * cell_xy,
+                                 sipm_pos_z));
+
+                crystal_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                esr_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                cf_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                sipm_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+
+                string crystal_name = "Crystal_" + to_string(ilayer) + "_" + to_string(ix) + "_" + to_string(iy);
+                DetElement unit(sd, crystal_name, det_id);
+                unit.setPlacement(crystal_unit);
+            }
+
+        PlacedVolume plv = block_vol.placeVolume(slice, Position(0, 0, (ilayer - 0.5) * layer_thickness - 0.5 * block_z + boundary_safety));
+        plv.addPhysVolID("layer", ilayer);
+        sd.setPlacement(plv);
+    }
+
+    // Rectangle block
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        Volume slice("slice", Box(0.5 * block_xy_in, 0.5 * block_rect_short_in, 0.5 * layer_thickness), mat_air);
+        slice.setVisAttributes(theDetector, "SeeThrough");
+        string slicename = "Rect_Slice_" + to_string(ilayer);
+        DetElement sd(blockdet, slicename, det_id);
+
+        Volume slice_pcb("slice_pcb", Box(0.5 * block_xy_in, 0.5 * block_rect_short_in, 0.5 * pcb_thickness), mat_PCB);
+        slice_pcb.setVisAttributes(theDetector, "SeeThrough");
+
+        Volume slice_cu("slice_cu", Box(0.5 * block_xy_in, 0.5 * block_rect_short_in, 0.5 * cu_thickness), mat_Cu);
+        slice_cu.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit = slice.placeVolume(slice_pcb, Position(0, 0, pcb_pos_z));
+        pcb_unit.addPhysVolID("layer", ilayer);
+
+        PlacedVolume cu_unit = slice.placeVolume(slice_cu, Position(0, 0, cu_pos_z));
+        cu_unit.addPhysVolID("layer", ilayer);
+
+        for (int ix = 1; ix <= Ncell_xy; ++ix)
+            for (int iy = 1; iy <= Ncell_rect_short; ++iy)
+            {
+                PlacedVolume crystal_unit = slice.placeVolume(crystal,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_rect_short_in + iy * cell_xy,
+                                 crystal_pos_z));
+                PlacedVolume esr_unit = slice.placeVolume(esr,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_rect_short_in + iy * cell_xy,
+                                 esr_pos_z));
+                PlacedVolume cf_unit = slice.placeVolume(cf,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_rect_short_in + iy * cell_xy,
+                                 cf_pos_z));
+                PlacedVolume sipm_unit = slice.placeVolume(sipm,
+                        Position(-0.5 * block_xy_in + ix * cell_xy,
+                                 -0.5 * block_rect_short_in + iy * cell_xy,
+                                 sipm_pos_z));
+
+                crystal_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                esr_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                cf_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                sipm_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+
+                string crystal_name = "Crystal_" + to_string(ilayer) + "_" + to_string(ix) + "_" + to_string(iy);
+                DetElement unit(sd, crystal_name, det_id);
+                unit.setPlacement(crystal_unit);
+            }
+
+        PlacedVolume plv = block_rect_vol.placeVolume(slice, Position(0, 0, (ilayer - 0.5) * layer_thickness - 0.5 * block_z + boundary_safety));
+        plv.addPhysVolID("layer", ilayer);
+        sd.setPlacement(plv);
+    }
+
+    // Square block 1
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        Volume slice("slice", Box(0.5 * block_sq1_width, 0.5 * block_sq1_width, 0.5 * layer_thickness), mat_air);
+        slice.setVisAttributes(theDetector, "SeeThrough");
+        string slicename = "Sq1_Slice_" + to_string(ilayer);
+        DetElement sd(blockdet, slicename, det_id);
+
+        Volume slice_pcb("slice_pcb", Box(0.5 * block_sq1_width, 0.5 * block_sq1_width, 0.5 * pcb_thickness), mat_PCB);
+        slice_pcb.setVisAttributes(theDetector, "SeeThrough");
+
+        Volume slice_cu("slice_cu", Box(0.5 * block_sq1_width, 0.5 * block_sq1_width, 0.5 * cu_thickness), mat_Cu);
+        slice_cu.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit = slice.placeVolume(slice_pcb, Position(0, 0, pcb_pos_z));
+        pcb_unit.addPhysVolID("layer", ilayer);
+
+        PlacedVolume cu_unit = slice.placeVolume(slice_cu, Position(0, 0, cu_pos_z));
+        cu_unit.addPhysVolID("layer", ilayer);
+
+        for (int ix = 1; ix <= Ncell_sq1_xy; ++ix)
+            for (int iy = 1; iy <= Ncell_sq1_xy; ++iy)
+            {
+                PlacedVolume crystal_unit = slice.placeVolume(crystal,
+                        Position(-0.5 * block_sq1_width + ix * cell_xy,
+                                 -0.5 * block_sq1_width + iy * cell_xy,
+                                 crystal_pos_z));
+                PlacedVolume esr_unit = slice.placeVolume(esr,
+                        Position(-0.5 * block_sq1_width + ix * cell_xy,
+                                 -0.5 * block_sq1_width + iy * cell_xy,
+                                 esr_pos_z));
+                PlacedVolume cf_unit = slice.placeVolume(cf,
+                        Position(-0.5 * block_sq1_width + ix * cell_xy,
+                                 -0.5 * block_sq1_width + iy * cell_xy,
+                                 cf_pos_z));
+                PlacedVolume sipm_unit = slice.placeVolume(sipm,
+                        Position(-0.5 * block_sq1_width + ix * cell_xy,
+                                 -0.5 * block_sq1_width + iy * cell_xy,
+                                 sipm_pos_z));
+
+                crystal_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                esr_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                cf_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                sipm_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+
+                string crystal_name = "Crystal_" + to_string(ilayer) + "_" + to_string(ix) + "_" + to_string(iy);
+                DetElement unit(sd, crystal_name, det_id);
+                unit.setPlacement(crystal_unit);
+            }
+
+        PlacedVolume plv = block_sq1_vol.placeVolume(slice, Position(0, 0, (ilayer - 0.5) * layer_thickness - 0.5 * block_z + boundary_safety));
+        plv.addPhysVolID("layer", ilayer);
+        sd.setPlacement(plv);
+    }
+
+    // Square block 2
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        Volume slice("slice", Box(0.5 * block_sq2_width, 0.5 * block_sq2_width, 0.5 * layer_thickness), mat_air);
+        slice.setVisAttributes(theDetector, "SeeThrough");
+        string slicename = "Sq2_Slice_" + to_string(ilayer);
+        DetElement sd(blockdet, slicename, det_id);
+
+        Volume slice_pcb("slice_pcb", Box(0.5 * block_sq2_width, 0.5 * block_sq2_width, 0.5 * pcb_thickness), mat_PCB);
+        slice_pcb.setVisAttributes(theDetector, "SeeThrough");
+
+        Volume slice_cu("slice_cu", Box(0.5 * block_sq2_width, 0.5 * block_sq2_width, 0.5 * cu_thickness), mat_Cu);
+        slice_cu.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit = slice.placeVolume(slice_pcb, Position(0, 0, pcb_pos_z));
+        pcb_unit.addPhysVolID("layer", ilayer);
+
+        PlacedVolume cu_unit = slice.placeVolume(slice_cu, Position(0, 0, cu_pos_z));
+        cu_unit.addPhysVolID("layer", ilayer);
+
+        for (int ix = 1; ix <= Ncell_sq2_xy; ++ix)
+            for (int iy = 1; iy <= Ncell_sq2_xy; ++iy)
+            {
+                PlacedVolume crystal_unit = slice.placeVolume(crystal,
+                        Position(-0.5 * block_sq2_width + ix * cell_xy,
+                                 -0.5 * block_sq2_width + iy * cell_xy,
+                                 crystal_pos_z));
+                PlacedVolume esr_unit = slice.placeVolume(esr,
+                        Position(-0.5 * block_sq2_width + ix * cell_xy,
+                                 -0.5 * block_sq2_width + iy * cell_xy,
+                                 esr_pos_z));
+                PlacedVolume cf_unit = slice.placeVolume(cf,
+                        Position(-0.5 * block_sq2_width + ix * cell_xy,
+                                 -0.5 * block_sq2_width + iy * cell_xy,
+                                 cf_pos_z));
+                PlacedVolume sipm_unit = slice.placeVolume(sipm,
+                        Position(-0.5 * block_sq2_width + ix * cell_xy,
+                                 -0.5 * block_sq2_width + iy * cell_xy,
+                                 sipm_pos_z));
+
+                crystal_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                esr_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                cf_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+                sipm_unit.addPhysVolID("layer", ilayer).addPhysVolID("x", ix).addPhysVolID("y", iy);
+
+                string crystal_name = "Crystal_" + to_string(ilayer) + "_" + to_string(ix) + "_" + to_string(iy);
+                DetElement unit(sd, crystal_name, det_id);
+                unit.setPlacement(crystal_unit);
+            }
+
+        PlacedVolume plv = block_sq2_vol.placeVolume(slice, Position(0, 0, (ilayer - 0.5) * layer_thickness - 0.5 * block_z + boundary_safety));
+        plv.addPhysVolID("layer", ilayer);
+        sd.setPlacement(plv);
+    }
+
+    int istave = 0;
+
+    // Loop for placing the blocks in a module
+    // This session is not flexible enough...
+    for (int ix = 1; ix <= Nblock_xy; ++ix)
+        for (int iy = 1; iy <= Nblock_xy; ++iy)
+        {
+            const double distance = sqrt(pow((ix - 0.5) * block_xy_out, 2) + pow((iy - 0.5) * block_xy_out, 2));
+            if (distance < r_in || distance > r_out)
+                continue;
+
+            ++istave;
+
+            PlacedVolume plv_block_cf;
+            PlacedVolume plv_block;
+
+            if (ix == 2 && iy == Nblock_xy)
+            {
+                plv_block_cf = block_rect_vol.placeVolume(block_cf_rect, Position(0, 0, 0));
+                plv_block = sector_vol.placeVolume(block_rect_vol,
+                        Position(0.5 * gap_wide - gap_narrow + (ix - 0.5) * block_xy_out,
+                                 0.5 * gap_wide - gap_narrow + (iy - 1) * block_xy_out + 0.5 * block_rect_short_out,
+                                 0));
+            }
+            else if ((ix == 3 && iy == Nblock_xy) || (ix == Nblock_xy && iy == 3))
+            {
+                plv_block_cf = block_sq1_vol.placeVolume(block_cf_sq1, Position(0, 0, 0));
+                plv_block = sector_vol.placeVolume(block_sq1_vol,
+                        Position(0.5 * gap_wide - gap_narrow + (ix - 1) * block_xy_out + 0.5 * block_sq1_width,
+                                 0.5 * gap_wide - gap_narrow + (iy - 1) * block_xy_out + 0.5 * block_sq1_width,
+                                 0));
+            }
+            else if ((ix == 4 && iy == 5) || (ix == 5 && iy == 4))
+            {
+                plv_block_cf = block_sq2_vol.placeVolume(block_cf_sq2, Position(0, 0, 0));
+                plv_block = sector_vol.placeVolume(block_sq2_vol,
+                        Position(0.5 * gap_wide - gap_narrow + (ix - 1) * block_xy_out + 0.5 * block_sq2_width,
+                                 0.5 * gap_wide - gap_narrow + (iy - 1) * block_xy_out + 0.5 * block_sq2_width,
+                                 0));
+            }
+            else if (ix == Nblock_xy && iy == 2)
+            {
+                plv_block_cf = block_rect_vol.placeVolume(block_cf_rect, Position(0, 0, 0));
+                Transform3D transform(RotationZ(0.5 * pi),
+                        Position(0.5 * gap_wide - gap_narrow + (ix - 1) * block_xy_out + 0.5 * block_rect_short_out,
+                                 0.5 * gap_wide - gap_narrow + (iy - 0.5) * block_xy_out,
+                                 0));
+                plv_block = sector_vol.placeVolume(block_rect_vol, transform);
+            }
+            else
+            {
+                plv_block_cf = block_vol.placeVolume(block_cf, Position(0, 0, 0));
+                plv_block = sector_vol.placeVolume(block_vol,
+                        Position(0.5 * gap_wide - gap_narrow + (ix - 0.5) * block_xy_out,
+                                 0.5 * gap_wide - gap_narrow + (iy - 0.5) * block_xy_out,
+                                 0));
+            }
+            plv_block_cf.addPhysVolID("stave", istave);
+            plv_block.addPhysVolID("stave", istave);
+            DetElement sd(blockdet, _toString(istave, "block_%3d"), det_id);
+            sd.setPlacement(plv_block);
+        }
+
+    MYDEBUGVAL(istave)
+
+    // Loop for placing the modules
+    for (int i = 0; i < Nsectors; ++i)
+    {
+        const double s_rot = i * angle;
+        Transform3D transform_neg(RotationZ(s_rot) * RotationY(pi), Position(0, 0, 0));
+        Transform3D transform_pos(RotationZ(s_rot + angle), Position(0, 0, 2 * pos_z));
+        PlacedVolume plv_neg = envelopeVol.placeVolume(sector_vol, transform_neg);
+        PlacedVolume plv_pos = envelopeVol.placeVolume(sector_vol, transform_pos);
+        plv_neg.addPhysVolID("module", i);
+        plv_pos.addPhysVolID("module", i + Nsectors);
+        DetElement sd_neg(ECAL, _toString(i, "sector%3d"), det_id);
+        DetElement sd_pos(ECAL, _toString(i + Nsectors, "sector%3d"), det_id);
+        sd_neg.setPlacement(plv_neg);
+        sd_pos.setPlacement(plv_pos);
+    }
+
+    sens.setType("calorimeter");
+
+    MYDEBUG("create_detector FINISHED.")
+    return ECAL;
+}
+
+DECLARE_DETELEMENT(CRDEcalEndcap_Short_v01, create_detector)
diff --git a/Detector/DetCRD/src/Calorimeter/CRDEcal_Short_v02.cpp b/Detector/DetCRD/src/Calorimeter/CRDEcal_Short_v02.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dd3ac9a57d5a9ea3d2c73c9914f6310084594f7f
--- /dev/null
+++ b/Detector/DetCRD/src/Calorimeter/CRDEcal_Short_v02.cpp
@@ -0,0 +1,374 @@
+//================================================================================
+// Description 鈥� 32-Sided Polygon Barrel ECAL
+//--------------------------------------------------------------------------------
+// Author: Ji-Yuan CHEN (SJTU; jy_chen@sjtu.edu.cn)
+//--------------------------------------------------------------------------------
+//
+// ECAL with short crystals.  Not crossed-bar structure.
+// 32 modules cover a phi range of 2pi.
+//
+// 鈥楶ositive鈥� and 鈥榥egative鈥� trapezia:
+//       ______________             __________
+//       \            /            /          \        鈫� R (pointing outwards)
+//        \__________/            /____________\       鈹�
+//          Positive                 Negative        z 鈯� 鈥斺€斺啋 蠁
+// (Inner base < outer base)     (Inner > outer)
+//
+// The inner radius, module thickness, barrel length, etc. are directly read from XML file.
+// Dead material: ESR (wrapper), carbon fibre (mechanical structure), SiPM, PCB, Cu (cooling material).
+//
+// Layout: 32 modules in phi direction
+//         鈫� 15 blocks in z direction;
+//           鈫� 24 (?) layers in R direction.
+// For a schematic diagram, see  <https://indico.ihep.ac.cn/event/22331/contributions/155518/attachments/77650/96399/Polygon32-CrossSection.pdf>  (the numbers have been modified).
+//================================================================================
+
+#include "DD4hep/DetFactoryHelper.h"
+#include "XML/Layering.h"
+#include "XML/Utilities.h"
+#include "DDRec/DetectorData.h"
+#include "DDSegmentation/Segmentation.h"
+
+using std::cout;
+using std::endl;
+using std::string;
+using std::to_string;
+
+#define MYDEBUG(x) cout << __FILE__ << ":" << __LINE__ << ": " << x << endl;
+#define MYDEBUGVAL(x) cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << endl;
+
+using dd4hep::Ref_t;
+using dd4hep::Detector;
+using dd4hep::SensitiveDetector;
+using dd4hep::pi;
+using dd4hep::degree;
+using dd4hep::DetElement;
+using dd4hep::Volume;
+using dd4hep::PolyhedraRegular;
+using dd4hep::Material;
+using dd4hep::PlacedVolume;
+using dd4hep::Position;
+using dd4hep::Trapezoid;
+using dd4hep::Box;
+using dd4hep::SubtractionSolid;
+using dd4hep::Transform3D;
+using dd4hep::RotationZ;
+using dd4hep::RotationX;
+using dd4hep::_toString;
+
+static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector sens)
+{
+    xml_det_t x_det = e;
+
+    string det_name = x_det.nameStr();
+    string det_type = x_det.typeStr();
+    const int detid = x_det.id();
+    MYDEBUGVAL(det_name)
+    MYDEBUGVAL(det_type)
+    MYDEBUGVAL(detid)
+
+    // To prevent overlapping
+    const double boundary_safety = theDetector.constant<double>("boundary_safety");
+
+    // Global geometry
+    const double r_in = theDetector.constant<double>("ecalbarrel_inner_radius");
+    const double r_out_max = theDetector.constant<double>("ecalbarrel_outer_radius");
+    const double h0 = theDetector.constant<double>("ecalbarrel_thickness");
+    const double Z0 = theDetector.constant<double>("ecalbarrel_zlength");
+    const int Nmodule = theDetector.constant<int>("Nmodule");    // 32 modules
+    const int Nblock_z = theDetector.constant<int>("Nblock_z");    // Block number in z direction
+    const double rotation_angle = theDetector.constant<double>("module_rotation");    // Angle between the leg and the radius through its mid-point.
+    const double angle = 2 * pi / Nmodule;
+
+    // Unit size
+    const double crystal_r = theDetector.constant<double>("crystal_r");
+    const double crystal_phi = theDetector.constant<double>("crystal_phi");
+    const double crystal_z = theDetector.constant<double>("crystal_z");
+    const double block_z = Z0 / Nblock_z;    // Length of a block in z direction
+
+    MYDEBUGVAL(block_z)
+
+    const double esr_thickness = theDetector.constant<double>("esr_thickness");    // Wrapper
+    const double sipm_r = theDetector.constant<double>("sipm_r");
+    const double sipm_phi = theDetector.constant<double>("sipm_phi");
+    const double sipm_z = theDetector.constant<double>("sipm_z");
+    const double pcb_thickness = theDetector.constant<double>("pcb_thickness");
+    const double cu_thickness = theDetector.constant<double>("cu_thickness");    // Cooling material: Cu
+    const double fibre_thickness = theDetector.constant<double>("fibre_thickness");    // Mechanical structure: carbon fibre
+    const double collection_width = theDetector.constant<double>("collection_width");
+    const double collection_thickness = theDetector.constant<double>("collection_thickness");
+
+    const double cell_r = crystal_r + 4 * boundary_safety + 2 * esr_thickness + fibre_thickness;
+    const double cell_phi = crystal_phi + 4 * boundary_safety + 2 * esr_thickness + fibre_thickness;
+    const double cell_z = crystal_z + 4 * boundary_safety + 2 * esr_thickness + fibre_thickness;
+
+    const double layer_thickness = cell_r + sipm_r + pcb_thickness + cu_thickness + 4 * boundary_safety;
+    MYDEBUGVAL(layer_thickness)
+
+    // Adjustments for the positive trapezia
+    const double height_leg_angle_pos = rotation_angle + 0.5 * angle;    // Angle between <height> and <leg> of the positive trapezia
+    const double height_leg_deviation_pos = 0.5 * h0 * tan(height_leg_angle_pos);    // Deviation because of the angle between <height> and <leg> (about the mid-point of the leg)
+    const double height_rad_deviation = 0.5 * h0 * tan(0.5 * angle);    // Deviation because of the angle between <height> and <radius through the mid-point of the leg> (about the mid-point of the leg)
+    const double leg_rad_deviation_pos = height_leg_deviation_pos - height_rad_deviation;    // Deviation because of the angle between <leg> and <radius through the mid-point of the leg> (about the mid-point of the leg). Or equivalently, deviation of the inner base due to rotation.
+
+    // Adjustments for the negative trapezia
+    const double height_leg_angle_neg = rotation_angle - 0.5 * angle;    // Angle between <height> and <leg> of the negative trapezia
+    const double height_leg_deviation_neg = 0.5 * h0 * tan(height_leg_angle_neg);    // Deviation because of the angle between <height> and <leg> (about the mid-point of the leg)
+    const double leg_rad_deviation_neg = height_leg_deviation_neg + height_rad_deviation;    // Deviation because of the angle between <leg> and <radius through the mid-point of the leg> (about the mid-point of the leg)
+
+    const double dim_in_pos = r_in * tan(0.5 * angle) - leg_rad_deviation_pos;
+    const double dim_out_pos = dim_in_pos + h0 * tan(height_leg_angle_pos);
+    const double dim_in_neg = r_in * tan(0.5 * angle) + leg_rad_deviation_neg;
+    const double dim_out_neg = dim_in_neg - h0 * tan(height_leg_angle_neg);
+    const double dim_y = 0.5 * Z0;
+    const double dim_z = 0.5 * h0;
+    const double r0 = r_in + 0.5 * h0;    // Rotation radius
+    const double r_out = sqrt(pow(r_in + h0, 2) + pow(dim_out_pos, 2));
+
+    if (r_out > r_out_max)
+        throw "Outer radius of barrel ECAL exceeds assigned maximum value!";
+
+    MYDEBUGVAL(dim_in_pos)
+    MYDEBUGVAL(dim_out_pos)
+    MYDEBUGVAL(dim_in_neg)
+    MYDEBUGVAL(dim_out_neg)
+
+    const int Nlayers = ((int) (h0 / layer_thickness) * layer_thickness + collection_thickness <= h0) ? (int) (h0 / layer_thickness) : (int) (h0 / layer_thickness) - 1;
+    const int Ncell_z = (int) (block_z / cell_z);    // Crystal number along z direction in each block
+    int Ncell_phi_pos;    // Crystal number along phi direction in each positive trapezium block
+    int Ncell_phi_neg;    // Crystal number along phi direction in each negative trapezium block
+
+    MYDEBUGVAL(Nlayers)
+    MYDEBUGVAL(Ncell_z)
+
+    // Materials
+    Material mat_air(theDetector.material("Air"));
+    Material mat_sensitive(theDetector.material( x_det.materialStr() ));
+    Material mat_ESR(theDetector.material("G4_ESR"));
+    Material mat_SiPM(theDetector.material("G4_Si"));
+    Material mat_PCB(theDetector.material("PCB"));
+    Material mat_Cu(theDetector.material("G4_Cu"));
+    Material mat_CF(theDetector.material("CarbonFiber"));
+
+    // Define the detector and mother volumes (world)
+    DetElement ECAL(det_name, detid);
+    Volume motherVol = theDetector.pickMotherVolume(ECAL);
+
+    // Create a tube-like envelope to represent the whole detector volume
+    PolyhedraRegular envelope(Nmodule, 0.5 * angle, r_in, r_out, Z0);
+    Volume envelopeVol(det_name, envelope, mat_air);
+    PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, Position(0, 0, 0));
+    envelopePlv.addPhysVolID("system", detid);
+    envelopeVol.setVisAttributes(theDetector, "SeeThrough");
+    ECAL.setPlacement(envelopePlv);
+    DetElement blockdet(ECAL, "module", detid);
+
+    // Positive trapezium module
+    Trapezoid module_pos(dim_in_pos, dim_out_pos, dim_y, dim_y, dim_z);
+    Volume module_pos_vol("module_pos_vol", module_pos, mat_air);
+    module_pos_vol.setVisAttributes(theDetector, "CyanVis");
+
+    // Negative trapezium module
+    Trapezoid module_neg(dim_in_neg, dim_out_neg, dim_y, dim_y, dim_z);
+    Volume module_neg_vol("module_neg_vol", module_neg, mat_air);
+    module_neg_vol.setVisAttributes(theDetector, "CyanVis");
+
+    // Positive block
+    Trapezoid block_pos(dim_in_pos, dim_out_pos, 0.5 * block_z, 0.5 * block_z, dim_z);
+    Volume block_pos_vol("block_pos_vol", block_pos, mat_CF);
+    block_pos_vol.setVisAttributes(theDetector, "CyanVis");
+
+    // Negative block
+    Trapezoid block_neg(dim_in_neg, dim_out_neg, 0.5 * block_z, 0.5 * block_z, dim_z);
+    Volume block_neg_vol("block_neg_vol", block_neg, mat_CF);
+    block_neg_vol.setVisAttributes(theDetector, "CyanVis");
+
+    // Crystal, ESR, SiPM, carbon fibre and collection board
+    Volume crystal("crystal", Box(0.5 * crystal_phi, 0.5 * crystal_z, 0.5 * crystal_r), mat_sensitive);    // Order: phi 鈫� z 鈫� R.
+    crystal.setVisAttributes(theDetector, "SeeThrough");
+    crystal.setSensitiveDetector(sens);
+
+    Box esr_out(0.5 * crystal_phi + esr_thickness + boundary_safety, 0.5 * crystal_z + esr_thickness + boundary_safety, 0.5 * crystal_r + esr_thickness + boundary_safety);
+    Box esr_in(0.5 * crystal_phi + boundary_safety, 0.5 * crystal_z + boundary_safety, 0.5 * crystal_r + boundary_safety);
+    Volume esr("esr", SubtractionSolid(esr_out, esr_in, Position(0, 0, 0)), mat_ESR);
+    esr.setVisAttributes(theDetector, "SeeThrough");
+
+    Volume SiPM("SiPM", Box(0.5 * sipm_phi, 0.5 * sipm_z, 0.5 * sipm_r), mat_SiPM);
+    SiPM.setVisAttributes(theDetector, "SeeThrough");
+
+    Box cf_out(0.5 * cell_phi, 0.5 * cell_z, 0.5 * cell_r);
+    Box cf_in(0.5 * (cell_phi - fibre_thickness), 0.5 * (cell_z - fibre_thickness), 0.5 * (cell_r - fibre_thickness));
+    Volume cf("cf", SubtractionSolid(cf_out, cf_in, Position(0, 0, 0)), mat_CF);
+    cf.setVisAttributes(theDetector, "SeeThrough");
+
+    Volume collection("collection", Box(0.5 * collection_width, 0.5 * collection_thickness, 0.5 * collection_width), mat_PCB);
+    collection.setVisAttributes(theDetector, "SeeThrough");
+
+    // Positions
+    const double crystal_pos_r = -0.5 * layer_thickness + 0.5 * cell_r;
+    const double esr_pos_r = crystal_pos_r;
+    const double cf_pos_r = esr_pos_r;
+    const double sipm_pos_r = cf_pos_r + 0.5 * cell_r + boundary_safety + 0.5 * sipm_r;
+    const double pcb_pos_r = sipm_pos_r + 0.5 * sipm_r + boundary_safety + 0.5 * pcb_thickness;
+    const double cu_pos_r = pcb_pos_r + 0.5 * (pcb_thickness + cu_thickness);
+
+    // Loop for placing the crystals in one positive trapezium block
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        const double layer_length_pos = dim_in_pos + (ilayer - 1) * layer_thickness * tan(height_leg_angle_pos);
+        Ncell_phi_pos = (int) (2 * layer_length_pos / cell_phi);
+        const double layer_phi_pos = Ncell_phi_pos * cell_phi;
+
+        Volume slice_pos("slice_pos", Box(0.5 * layer_phi_pos, 0.5 * block_z, 0.5 * layer_thickness), mat_air);
+        slice_pos.setVisAttributes(theDetector, "SeeThrough");
+        string slicename_pos = "Slice_pos_" + to_string(ilayer);
+        DetElement sd_pos(blockdet, slicename_pos, detid);
+
+        Volume slice_pcb_pos("slice_pcb_pos", Box(0.5 * layer_phi_pos, 0.5 * block_z, 0.5 * pcb_thickness), mat_PCB);
+        slice_pcb_pos.setVisAttributes(theDetector, "SeeThrough");
+
+        Volume slice_cu_pos("slice_cu_pos", Box(0.5 * layer_phi_pos, 0.5 * block_z, 0.5 * cu_thickness), mat_Cu);
+        slice_cu_pos.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit_pos = slice_pos.placeVolume(slice_pcb_pos, Position(0, 0, pcb_pos_r));
+        pcb_unit_pos.addPhysVolID("layer", ilayer);
+
+        PlacedVolume cu_unit = slice_pos.placeVolume(slice_cu_pos, Position(0, 0, cu_pos_r));
+        cu_unit.addPhysVolID("layer", ilayer);
+
+        for (int iz = 1; iz <= Ncell_z; ++iz)
+            for (int iphi = 1; iphi <= Ncell_phi_pos; ++iphi)
+            {
+                PlacedVolume crystal_unit_pos = slice_pos.placeVolume(crystal,
+                        Position((-0.5 * (Ncell_phi_pos + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 crystal_pos_r));
+                PlacedVolume esr_unit_pos = slice_pos.placeVolume(esr,
+                        Position((-0.5 * (Ncell_phi_pos + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 esr_pos_r));
+                PlacedVolume cf_unit_pos = slice_pos.placeVolume(cf,
+                        Position((-0.5 * (Ncell_phi_pos + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 cf_pos_r));
+                PlacedVolume sipm_unit_pos = slice_pos.placeVolume(SiPM,
+                        Position((-0.5 * (Ncell_phi_pos + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 sipm_pos_r));
+
+                crystal_unit_pos.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+                esr_unit_pos.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+                cf_unit_pos.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+                sipm_unit_pos.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+
+                string crystal_name_pos = "Crystal_pos_" + to_string(ilayer) + "_" + to_string(iphi) + "_" + to_string(iz);
+                DetElement unit_pos(sd_pos, crystal_name_pos, detid);
+                unit_pos.setPlacement(crystal_unit_pos);
+            }
+
+        PlacedVolume plv = block_pos_vol.placeVolume(slice_pos, Position(0, 0, (ilayer - 0.5) * layer_thickness - dim_z));
+        plv.addPhysVolID("layer", ilayer);
+        sd_pos.setPlacement(plv);
+    }
+
+    // Loop for placing the crystals in one negative trapezium block
+    for (int ilayer = 1; ilayer <= Nlayers; ++ilayer)
+    {
+        const double layer_length_neg = dim_in_neg - ilayer * layer_thickness * tan(height_leg_angle_neg);
+        Ncell_phi_neg = (int) (2 * layer_length_neg / cell_phi);
+        const double layer_phi_neg = Ncell_phi_neg * cell_phi;
+
+        Volume slice_neg("slice_neg", Box(0.5 * layer_phi_neg, 0.5 * block_z, 0.5 * layer_thickness), mat_air);
+        slice_neg.setVisAttributes(theDetector, "SeeThrough");
+        string slicename_neg = "Slice_neg_" + to_string(ilayer);
+        DetElement sd_neg(blockdet, slicename_neg, detid);
+
+        Volume slice_pcb_neg("slice_pcb_neg", Box(0.5 * layer_phi_neg, 0.5 * block_z, 0.5 * pcb_thickness), mat_PCB);
+        slice_pcb_neg.setVisAttributes(theDetector, "SeeThrough");
+
+        Volume slice_cu_neg("slice_cu_neg", Box(0.5 * layer_phi_neg, 0.5 * block_z, 0.5 * cu_thickness), mat_Cu);
+        slice_cu_neg.setVisAttributes(theDetector, "SeeThrough");
+
+        PlacedVolume pcb_unit_neg = slice_neg.placeVolume(slice_pcb_neg, Position(0, 0, pcb_pos_r));
+        pcb_unit_neg.addPhysVolID("layer", ilayer);
+
+        PlacedVolume cu_unit = slice_neg.placeVolume(slice_cu_neg, Position(0, 0, cu_pos_r));
+        cu_unit.addPhysVolID("layer", ilayer);
+
+        for (int iz = 1; iz <= Ncell_z; ++iz)
+            for (int iphi = 1; iphi <= Ncell_phi_neg; ++iphi)
+            {
+                PlacedVolume crystal_unit_neg = slice_neg.placeVolume(crystal,
+                        Position((-0.5 * (Ncell_phi_neg + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 crystal_pos_r));
+                PlacedVolume esr_unit_neg = slice_neg.placeVolume(esr,
+                        Position((-0.5 * (Ncell_phi_neg + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 esr_pos_r));
+                PlacedVolume cf_unit_neg = slice_neg.placeVolume(cf,
+                        Position((-0.5 * (Ncell_phi_neg + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 cf_pos_r));
+                PlacedVolume sipm_unit_neg = slice_neg.placeVolume(SiPM,
+                        Position((-0.5 * (Ncell_phi_neg + 1) + iphi) * cell_phi,
+                                 (-0.5 * (Ncell_z + 1) + iz) * cell_z,
+                                 sipm_pos_r));
+
+                crystal_unit_neg.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+                esr_unit_neg.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+                cf_unit_neg.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+                sipm_unit_neg.addPhysVolID("layer", ilayer).addPhysVolID("phi", iphi).addPhysVolID("z", iz);
+
+                string crystal_name_neg = "Crystal_neg_" + to_string(ilayer) + "_" + to_string(iphi) + "_" + to_string(iz);
+                DetElement unit_neg(sd_neg, crystal_name_neg, detid);
+                unit_neg.setPlacement(crystal_unit_neg);
+            }
+
+        PlacedVolume plv = block_neg_vol.placeVolume(slice_neg, Position(0, 0, (ilayer - 0.5) * layer_thickness - dim_z));
+        plv.addPhysVolID("layer", ilayer);
+        sd_neg.setPlacement(plv);
+    }
+
+    // Loop for placing the blocks in a module
+    for (int iz = 1; iz <= Nblock_z; ++iz)
+    {
+        PlacedVolume plv_collection_pos = block_pos_vol.placeVolume(collection, Position(0, 0, -0.5 * dim_z + Nlayers * layer_thickness + collection_thickness));
+        plv_collection_pos.addPhysVolID("stave", iz);
+
+        PlacedVolume plv_pos = module_pos_vol.placeVolume(block_pos_vol, Position(0, dim_y - (iz - 0.5) * block_z, 0));
+        plv_pos.addPhysVolID("stave", iz);
+        DetElement sd_pos(blockdet, _toString(iz, "block_pos_%3d"), detid);
+        sd_pos.setPlacement(plv_pos);
+
+        PlacedVolume plv_collection_neg = block_neg_vol.placeVolume(collection, Position(0, 0, -0.5 * dim_z + Nlayers * layer_thickness + collection_thickness));
+        plv_collection_neg.addPhysVolID("stave", iz);
+
+        PlacedVolume plv_neg = module_neg_vol.placeVolume(block_neg_vol, Position(0, dim_y - (iz - 0.5) * block_z, 0));
+        plv_neg.addPhysVolID("stave", iz);
+        DetElement sd_neg(blockdet, _toString(iz, "block_neg_%3d"), detid);
+        sd_neg.setPlacement(plv_neg);
+    }
+
+    // Loop for placing the modules
+    for (int i = 0; i < Nmodule; ++i)
+    {
+        const double m_rot = i * angle;
+        const double posx = -r0 * sin(m_rot);
+        const double posy = r0 * cos(m_rot);
+
+        Transform3D transform(RotationZ(m_rot) * RotationX(-0.5 * pi), Position(posx, posy, 0.0));
+        PlacedVolume plv = (i % 2 == 0) ? envelopeVol.placeVolume(module_pos_vol, transform) : envelopeVol.placeVolume(module_neg_vol, transform);
+        plv.addPhysVolID("module", i);
+
+        DetElement sd(ECAL, _toString(i, "module%3d"), detid);
+        sd.setPlacement(plv);
+    }
+
+    sens.setType("calorimeter");
+
+    MYDEBUG("create_detector FINISHED.");
+    return ECAL;
+}
+
+DECLARE_DETELEMENT(CRDEcalBarrel_Short_v02, create_detector)
diff --git a/Detector/DetCRD/src/Calorimeter/LongCrystalBarEndcapCalorimeter_v01.cpp b/Detector/DetCRD/src/Calorimeter/LongCrystalBarEndcapCalorimeter_v01.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..5fba0ab7d99b9f2967cd45dc1f7c59aad1b9138d
--- /dev/null
+++ b/Detector/DetCRD/src/Calorimeter/LongCrystalBarEndcapCalorimeter_v01.cpp
@@ -0,0 +1,464 @@
+//==========================================================================
+// LongCrystalBarEndcapCalorimeter_v01 implementation 
+//--------------------------------------------------------------------------
+// Author: Song Weizheng, IHEP
+//--------------------------------------------------------------------------
+// Data: 2024.6
+//==========================================================================
+
+#include "DD4hep/DetFactoryHelper.h" 
+#include "XML/Layering.h"
+#include "XML/Utilities.h"
+#include "DDRec/DetectorData.h"
+#include "DDSegmentation/Segmentation.h"
+
+#define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl;
+#define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl;
+
+using dd4hep::rec::LayeredCalorimeterData;
+using namespace dd4hep;
+using namespace std;
+
+static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
+                                     xml_h e,
+                                     dd4hep::SensitiveDetector sens) {
+
+    xml_det_t x_det = e;
+    std::string det_name = x_det.nameStr();
+    std::string det_type = x_det.typeStr();
+    MYDEBUGVAL(det_name);
+    MYDEBUGVAL(det_type);
+    int detid = x_det.id();
+
+    // ######################################
+    // ### detector description parameter ###
+    // ######################################
+
+    double radius_inner = theDetector.constant<double>("ecalendcap_inner_radius");
+    double radius_outer = theDetector.constant<double>("ecalendcap_outer_radius");
+    double z_min = theDetector.constant<double>("ecalendcap_zmin");
+    double z_depth = theDetector.constant<double>("ecalendcap_depth");
+
+    double x_width = theDetector.constant<double>("ecalendcap_x_width");
+    double y_width = theDetector.constant<double>("ecalendcap_y_width");
+    int Nlayers = theDetector.constant<double>("ecalendcap_layer");
+
+    double width_crystal = theDetector.constant<double>("ecalendcap_width_crystal");
+    double crystal_wrapping = theDetector.constant<double>("ecalendcap_crystal_wrapping");
+    double photoelectronic = theDetector.constant<double>("ecalendcap_length_photoelectronic");
+    double photoelectronic_width = theDetector.constant<double>("ecalendcap_width_photoelectronic");
+
+    double carbon = theDetector.constant<double>("ecalendcap_length_carbon");
+    double cable = theDetector.constant<double>("ecalendcap_length_cable");
+    double pcb = theDetector.constant<double>("ecalendcap_length_pcb");
+    double asic = theDetector.constant<double>("ecalendcap_length_asic");
+    double cooling = theDetector.constant<double>("ecalendcap_length_cooling");
+    double back_plate = theDetector.constant<double>("ecalendcap_length_back");
+    
+    // ###########################
+    // ### general measurement ###
+    // ###########################
+
+    double length_crystal = x_width - 2*carbon - 2*cable - 2*pcb - 2*asic - 2*cooling; // length of crystal wrap sipm
+    int Nbar = floor(length_crystal/width_crystal); // number of crystal
+
+    std::cout << "length_crystal" << " : " << length_crystal << std::endl;
+    std::cout << "Nbar" << " : " << Nbar << std::endl;
+
+    // // ####################
+    // // ### World Volume ###
+    // // ####################
+    dd4hep::Material air(theDetector.material("Air"));
+    dd4hep::Material vacuum(theDetector.material("Vacuum"));
+    dd4hep::Material mat_BGO(theDetector.material("G4_BGO")); 
+    dd4hep::Material mat_CF(theDetector.material("CarbonFiber"));
+    dd4hep::Material mat_Cu(theDetector.material("G4_Cu"));
+    dd4hep::Material mat_ESR(theDetector.material("G4_ESR"));
+    dd4hep::Material mat_Si(theDetector.material("G4_Si"));
+    dd4hep::Material mat_PCB(theDetector.material("PCB"));
+    
+    dd4hep::DetElement ECAL(det_name, detid);
+    dd4hep::Volume motherVol = theDetector.pickMotherVolume(ECAL);
+
+    dd4hep::Tube tube_shape(0, radius_outer, z_depth/2);
+    dd4hep::Box box_shape(x_width, y_width, z_depth);
+    dd4hep::SubtractionSolid booleanZplus(tube_shape, box_shape, Position(0.0, 0.0, 0.0));
+    dd4hep::SubtractionSolid booleanZminus(tube_shape, box_shape, Position(0.0, 0.0, 0.0));
+    dd4hep::UnionSolid unionean(booleanZplus, booleanZminus, Position(0.0, 0.0, 2*z_min+z_depth));
+    
+    // dd4hep::Volume envelopeVolZplus("envelopeVolZplus", boolean, vacuum); 
+    // dd4hep::Volume envelopeVolZminus("envelopeVolZminus", boolean, vacuum); 
+
+    
+    dd4hep::Volume envelopeVol("envelopeVol", unionean, vacuum); 
+    dd4hep::Transform3D transform(dd4hep::RotationZ(90*degree), dd4hep::Position(0.0, 0.0, -z_min-z_depth/2)); 
+    dd4hep::PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, transform);
+
+    
+    // dd4hep::Transform3D transform2(dd4hep::RotationZ(90*degree),  dd4hep::Position(0,0,-z_min-z_depth/2));
+    // dd4hep::PlacedVolume	envelopePlvZplus = motherVol.placeVolume(envelopeVolZplus, transform1);
+    // dd4hep::PlacedVolume	envelopePlvZminus = motherVol.placeVolume(envelopeVolZminus, transform2);
+    // envelopePlvZplus.addPhysVolID("system",x_det.id()).addPhysVolID("module", 0);
+    envelopePlv.addPhysVolID("system",x_det.id());
+    // envelopeVolZplus.setVisAttributes(theDetector, "BlueVis");
+    envelopeVol.setVisAttributes(theDetector, "BlueVis");
+    ECAL.setPlacement(envelopePlv);
+    // moduleEle.setPlacement(envelopePlvZminus);
+
+    dd4hep::DetElement moduleEle(ECAL, "moduleEle", detid);
+    // dd4hep::DetElement towerEle(moduleEle, "towerEle", detid);
+    dd4hep::DetElement stavedet(moduleEle, "staveEle", detid);
+    
+    
+    // // ####################
+    // // ### Print Volume ###
+    // // ####################
+
+
+    // // ###############################
+    // // ### module inside placement ###
+    // // ###############################
+    
+    dd4hep::Box module_box(x_width/2, y_width/2, z_depth/2);
+    dd4hep::Volume module_volume("module_volume", module_box, air);
+    module_volume.setVisAttributes(theDetector, "GreenVis");
+
+    //Carbon fiber supporting
+
+    dd4hep::Volume CarbonFiber0("CarbonFiber0", dd4hep::Box(x_width/2, carbon/2, z_depth/2), mat_CF); 
+    CarbonFiber0.setVisAttributes(theDetector, "GrayVis");
+
+    dd4hep::Volume CarbonFiber1("CarbonFiber1", dd4hep::Box(carbon/2, (y_width-2*carbon)/2, z_depth/2), mat_CF); 
+    CarbonFiber1.setVisAttributes(theDetector, "GrayVis");
+
+    dd4hep::PlacedVolume plv_cf0 = module_volume.placeVolume(CarbonFiber0, Position(0, y_width/2-carbon/2, 0));
+    std::string cfname0 = "carbonfiber_s0";	
+    dd4hep::DetElement cfdet0(stavedet, cfname0, detid);
+    cfdet0.setPlacement(plv_cf0);
+
+    dd4hep::PlacedVolume plv_cf1 = module_volume.placeVolume(CarbonFiber0, Position(0, -y_width/2+carbon/2, 0));
+    std::string cfname1 = "carbonfiber_s1";	
+    dd4hep::DetElement cfdet1(stavedet, cfname1, detid);
+    cfdet1.setPlacement(plv_cf1);
+
+    dd4hep::PlacedVolume plv_bar2 = module_volume.placeVolume(CarbonFiber1, Position(x_width/2-carbon/2, 0, 0));
+    std::string barname2 = "carbonfiber_s2";
+    dd4hep::DetElement bardet2(stavedet, barname2, detid);
+    bardet2.setPlacement(plv_bar2);
+
+    dd4hep::PlacedVolume plv_bar3= module_volume.placeVolume(CarbonFiber1, Position(-x_width/2+carbon/2, 0, 0));
+    std::string barname3 = "carbonfiber_s3";
+    dd4hep::DetElement bardet3(stavedet, barname3, detid);
+    bardet3.setPlacement(plv_bar3);
+
+    //Cooling copper
+
+    dd4hep::Volume copper0("copper0", dd4hep::Box((x_width-2*carbon)/2, cooling/2, z_depth/2), mat_Cu); 
+    copper0.setVisAttributes(theDetector, "RedVis");
+
+    dd4hep::Volume copper1("copper1", dd4hep::Box(cooling/2, (x_width-2*carbon-2*cooling)/2, z_depth/2), mat_Cu); 
+    copper1.setVisAttributes(theDetector, "RedVis");
+
+    dd4hep::PlacedVolume plv_copper0 = module_volume.placeVolume(copper0, Position(0, y_width/2-carbon-cooling/2, 0));
+    std::string coppername0 = "copper_s0";
+    dd4hep::DetElement copperdet0(stavedet, coppername0, detid);
+    copperdet0.setPlacement(plv_copper0);
+
+    dd4hep::PlacedVolume plv_copper1 = module_volume.placeVolume(copper0, Position(0, -y_width/2+carbon+cooling/2, 0));
+    std::string coppername1 = "copper_s1";
+    dd4hep::DetElement copperdet1(stavedet, coppername1, detid);
+    copperdet1.setPlacement(plv_copper1);
+
+    dd4hep::PlacedVolume plv_copper2 = module_volume.placeVolume(copper1, Position(x_width/2-carbon-cooling/2, 0, 0));
+    std::string coppername2 = "copper_s2";
+    dd4hep::DetElement copperdet2(stavedet, coppername2, detid);
+    copperdet2.setPlacement(plv_copper2);
+
+    dd4hep::PlacedVolume plv_copper3 = module_volume.placeVolume(copper1, Position(-x_width/2+carbon+cooling/2, 0, 0));
+    std::string coppername3 = "copper_s3";
+    dd4hep::DetElement copperdet3(stavedet, coppername3, detid);
+    copperdet3.setPlacement(plv_copper3);
+
+    // Electronics
+
+    double electronics = cable + pcb + asic;
+
+    dd4hep::Volume electronics0("electronics0", dd4hep::Box((x_width-2*carbon-2*cooling)/2, electronics/2, z_depth/2), mat_PCB);
+    electronics0.setVisAttributes(theDetector, "YellowVis");
+
+    dd4hep::Volume electronics1("electronics1", dd4hep::Box(electronics/2, (y_width-2*carbon-2*cooling-2*electronics)/2, z_depth/2), mat_PCB);
+    electronics1.setVisAttributes(theDetector, "YellowVis");
+
+    dd4hep::PlacedVolume plv_elec0 = module_volume.placeVolume(electronics0, Position(0, y_width/2-carbon-cooling-electronics/2, 0));
+    std::string elecname0 = "electronics_s0";	
+    dd4hep::DetElement elecdet0(stavedet, elecname0, detid);
+    elecdet0.setPlacement(plv_elec0);
+
+    dd4hep::PlacedVolume plv_elec1 = module_volume.placeVolume(electronics0, Position(0, -y_width/2+carbon+cooling+electronics/2, 0));
+    std::string elecname1 = "electronics_s1";
+    dd4hep::DetElement elecdet1(stavedet, elecname1, detid);
+    elecdet1.setPlacement(plv_elec1);
+
+    dd4hep::PlacedVolume plv_elec2 = module_volume.placeVolume(electronics1, Position(x_width/2-carbon-cooling-electronics/2, 0, 0));
+    std::string elecname2 = "electronics_s2";
+    dd4hep::DetElement elecdet2(stavedet, elecname2, detid);
+    elecdet2.setPlacement(plv_elec2);
+
+    dd4hep::PlacedVolume plv_elec3 = module_volume.placeVolume(electronics1, Position(-x_width/2+carbon+cooling+electronics/2, 0, 0));
+    std::string elecname3 = "electronics_s3";
+    dd4hep::DetElement elecdet3(stavedet, elecname3, detid);
+    elecdet3.setPlacement(plv_elec3);
+
+    //Back Plate
+
+    // dd4hep::Volume backPlate("back_plate", dd4hep::Box(back_plate*15, back_plate*15, back_plate/2), mat_PCB);
+    // backPlate.setVisAttributes(theDetector, "GrayVis");
+    // std::string blockname = "back_plate_positive";
+    // dd4hep::PlacedVolume plv = subtrap_positive_vol.placeVolume(backPlate, Position(0, 0, dim_z_p-back_plate/2));
+    // sd.setPlacement(plv);
+
+    // single layer
+    dd4hep::Volume block("block", dd4hep::Box((x_width-2*carbon-2*cooling-2*electronics)/2, (y_width-2*carbon-2*cooling-2*electronics)/2, width_crystal/2), air);
+    block.setVisAttributes(theDetector, "SeeThrough");
+    std::string blockname = "Block";
+    dd4hep::DetElement sd(stavedet, blockname, detid);
+
+    dd4hep::Volume sipm_s0("sipm_s0", dd4hep::Box(photoelectronic/2, photoelectronic_width/2, photoelectronic_width/2), mat_Si); 
+    sipm_s0.setVisAttributes(theDetector, "BlueVis");
+
+    dd4hep::Volume sipm_s1("sipm_s1", dd4hep::Box(crystal_wrapping/2, photoelectronic_width/2, photoelectronic_width/2), mat_Si); 
+    sipm_s1.setVisAttributes(theDetector, "BlueVis");
+
+    double last_bar = length_crystal - (Nbar-1)*width_crystal;
+
+    dd4hep::Volume bar_s0("bar_s0", dd4hep::Box(length_crystal/2, width_crystal/2-crystal_wrapping, width_crystal/2-crystal_wrapping), mat_BGO); 
+    bar_s0.setVisAttributes(theDetector, "EcalBarrelVis");
+    bar_s0.setSensitiveDetector(sens);
+
+    dd4hep::Volume bar_s1("bar_s1", dd4hep::Box(length_crystal/2, last_bar/2-crystal_wrapping, width_crystal/2-crystal_wrapping), mat_BGO); 
+    bar_s1.setVisAttributes(theDetector, "EcalBarrelVis");
+    bar_s1.setSensitiveDetector(sens);
+
+    for(int ibar0=0;ibar0<Nbar;ibar0++){
+        if(ibar0 == Nbar-1){
+            dd4hep::Volume hardware_s1("hardware_s1", dd4hep::Box((x_width-2*carbon-2*cooling-2*electronics)/2, last_bar/2, width_crystal/2), air); 
+            hardware_s1.setVisAttributes(theDetector, "SeeThrough");
+
+            dd4hep::Volume crystal_s1("crystal_s1", dd4hep::Box((x_width-2*carbon-2*cooling-2*electronics-2*photoelectronic)/2, last_bar/2, width_crystal/2), mat_ESR); 
+            crystal_s1.setVisAttributes(theDetector, "EcalBarrelVis");
+
+            dd4hep::PlacedVolume plv_bar0 = crystal_s1.placeVolume(bar_s1, Position(0, 0, 0));
+            std::string barname0 = "CrystalBar_positive_s0_"+std::to_string(ibar0);	
+            dd4hep::DetElement bardet0(sd, barname0, detid);
+            bardet0.setPlacement(plv_bar0);
+
+            dd4hep::PlacedVolume plv_sipm4 = crystal_s1.placeVolume(sipm_s1, Position(-(x_width-2*carbon-2*cooling-2*electronics)/2+photoelectronic+crystal_wrapping/2, 0, -photoelectronic_width/2));
+            std::string sipmname4 = "SiPM_positive_s8_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet4(sd, sipmname4, detid);
+            sipmdet4.setPlacement(plv_sipm4);
+
+            dd4hep::PlacedVolume plv_sipm5 = crystal_s1.placeVolume(sipm_s1, Position((x_width-2*carbon-2*cooling-2*electronics)/2-photoelectronic-crystal_wrapping/2, 0, photoelectronic_width/2));
+            std::string sipmname5 = "SiPM_positive_s9_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet5(sd, sipmname5, detid);
+            sipmdet5.setPlacement(plv_sipm5);
+
+            dd4hep::PlacedVolume plv_sipm6 = crystal_s1.placeVolume(sipm_s1, Position(-(x_width-2*carbon-2*cooling-2*electronics)/2+photoelectronic+crystal_wrapping/2, 0, photoelectronic_width/2));
+            std::string sipmname6 = "SiPM_positive_s10_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet6(sd, sipmname6, detid);
+            sipmdet6.setPlacement(plv_sipm6);
+
+            dd4hep::PlacedVolume plv_sipm7 = crystal_s1.placeVolume(sipm_s1, Position((x_width-2*carbon-2*cooling-2*electronics)/2-photoelectronic-crystal_wrapping/2, 0, -photoelectronic_width/2));
+            std::string sipmname7 = "SiPM_positive_s11_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet7(sd, sipmname7, detid);
+            sipmdet7.setPlacement(plv_sipm7);
+
+            dd4hep::PlacedVolume plv_sipm0 = hardware_s1.placeVolume(sipm_s0, Position(-(x_width-2*carbon-2*cooling-2*electronics)/2+photoelectronic/2, 0, -photoelectronic_width/2));
+            std::string sipmname0 = "SiPM_positive_s0_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet0(sd, sipmname0, detid);
+            sipmdet0.setPlacement(plv_sipm0);
+
+            dd4hep::PlacedVolume plv_sipm1 = hardware_s1.placeVolume(sipm_s0, Position((x_width-2*carbon-2*cooling-2*electronics)/2-photoelectronic/2, 0, photoelectronic_width/2));
+            std::string sipmname1 = "SiPM_positive_s1_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet1(sd, sipmname1, detid);
+            sipmdet1.setPlacement(plv_sipm1);
+
+            dd4hep::PlacedVolume plv_sipm2 = hardware_s1.placeVolume(sipm_s0, Position(-(x_width-2*carbon-2*cooling-2*electronics)/2+photoelectronic/2, 0, photoelectronic_width/2));
+            std::string sipmname2 = "SiPM_positive_s2_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet2(sd, sipmname2, detid);
+            sipmdet2.setPlacement(plv_sipm2);
+
+            dd4hep::PlacedVolume plv_sipm3 = hardware_s1.placeVolume(sipm_s0, Position((x_width-2*carbon-2*cooling-2*electronics)/2-photoelectronic/2, 0, -photoelectronic_width/2));
+            std::string sipmname3 = "SiPM_positive_s3_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet3(sd, sipmname3, detid);
+            sipmdet3.setPlacement(plv_sipm3);
+
+            dd4hep::PlacedVolume plv_cry0 = hardware_s1.placeVolume(crystal_s1, Position(0, 0, 0));
+            std::string cryname0 = "Crystal_positive_s0_"+std::to_string(ibar0);
+            dd4hep::DetElement crydet0(sd, cryname0, detid);
+            crydet0.setPlacement(plv_cry0);
+
+            dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s1, Position(0, -length_crystal/2+last_bar/2, 0));
+            plv_hard0.addPhysVolID("bar",ibar0);
+            std::string hardname0 = "Hardware_positive_s0_"+std::to_string(ibar0);
+            dd4hep::DetElement harddet0(sd, hardname0, detid);
+            harddet0.setPlacement(plv_hard0);
+        }
+        else{
+
+            dd4hep::Volume hardware_s0("hardware_s0", dd4hep::Box((x_width-2*carbon-2*cooling-2*electronics)/2, width_crystal/2, width_crystal/2), air); 
+            hardware_s0.setVisAttributes(theDetector, "SeeThrough");
+
+            dd4hep::Volume crystal_s0("crystal_s0", dd4hep::Box((x_width-2*carbon-2*cooling-2*electronics-2*photoelectronic)/2, width_crystal/2, width_crystal/2), mat_ESR); 
+            crystal_s0.setVisAttributes(theDetector, "EcalBarrelVis");
+
+            dd4hep::PlacedVolume plv_bar0 = crystal_s0.placeVolume(bar_s0, Position(0, 0, 0));
+            std::string barname0 = "CrystalBar_s0_"+std::to_string(ibar0);	
+            dd4hep::DetElement bardet0(sd, barname0, detid);
+            bardet0.setPlacement(plv_bar0);
+
+            dd4hep::PlacedVolume plv_sipm4 = crystal_s0.placeVolume(sipm_s1, Position(-(x_width-2*carbon-2*cooling-2*electronics-2*photoelectronic)/2+crystal_wrapping/2, 0, -photoelectronic_width/2));
+            std::string sipmname4 = "SiPM_positive_s8_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet4(sd, sipmname4, detid);
+            sipmdet4.setPlacement(plv_sipm4);
+
+            dd4hep::PlacedVolume plv_sipm5 = crystal_s0.placeVolume(sipm_s1, Position((x_width-2*carbon-2*cooling-2*electronics-2*photoelectronic)/2-crystal_wrapping/2, 0, photoelectronic_width/2));
+            std::string sipmname5 = "SiPM_positive_s9_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet5(sd, sipmname5, detid);
+            sipmdet5.setPlacement(plv_sipm5);
+
+            dd4hep::PlacedVolume plv_sipm6 = crystal_s0.placeVolume(sipm_s1, Position(-(x_width-2*carbon-2*cooling-2*electronics-2*photoelectronic)/2+crystal_wrapping/2, 0, photoelectronic_width/2));
+            std::string sipmname6 = "SiPM_positive_s10_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet6(sd, sipmname6, detid);
+            sipmdet6.setPlacement(plv_sipm6);
+
+            dd4hep::PlacedVolume plv_sipm7 = crystal_s0.placeVolume(sipm_s1, Position((x_width-2*carbon-2*cooling-2*electronics-2*photoelectronic)/2-crystal_wrapping/2, 0, -photoelectronic_width/2));
+            std::string sipmname7 = "SiPM_positive_s11_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet7(sd, sipmname7, detid);
+            sipmdet7.setPlacement(plv_sipm7);
+
+            dd4hep::PlacedVolume plv_sipm0 = hardware_s0.placeVolume(sipm_s0, Position(-(x_width-2*carbon-2*cooling-2*electronics)/2+photoelectronic/2, 0, -photoelectronic_width/2));
+            std::string sipmname0 = "SiPM_positive_s0_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet0(sd, sipmname0, detid);
+            sipmdet0.setPlacement(plv_sipm0);
+
+            dd4hep::PlacedVolume plv_sipm1 = hardware_s0.placeVolume(sipm_s0, Position((x_width-2*carbon-2*cooling-2*electronics)/2-photoelectronic/2, 0, photoelectronic_width/2));
+            std::string sipmname1 = "SiPM_positive_s1_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet1(sd, sipmname1, detid);
+            sipmdet1.setPlacement(plv_sipm1);
+
+            dd4hep::PlacedVolume plv_sipm2 = hardware_s0.placeVolume(sipm_s0, Position(-(x_width-2*carbon-2*cooling-2*electronics)/2+photoelectronic/2, 0, photoelectronic_width/2));
+            std::string sipmname2 = "SiPM_positive_s2_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet2(sd, sipmname2, detid);
+            sipmdet2.setPlacement(plv_sipm2);
+
+            dd4hep::PlacedVolume plv_sipm3 = hardware_s0.placeVolume(sipm_s0, Position((x_width-2*carbon-2*cooling-2*electronics)/2-photoelectronic/2, 0, -photoelectronic_width/2));
+            std::string sipmname3 = "SiPM_positive_s3_"+std::to_string(ibar0);
+            dd4hep::DetElement sipmdet3(sd, sipmname3, detid);
+            sipmdet3.setPlacement(plv_sipm3);
+
+            dd4hep::PlacedVolume plv_cry0 = hardware_s0.placeVolume(crystal_s0, Position(0, 0, 0));
+            std::string cryname0 = "Crystal_positive_s0_"+std::to_string(ibar0);
+            dd4hep::DetElement crydet0(sd, cryname0, detid);
+            crydet0.setPlacement(plv_cry0);
+
+            dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s0, Position(0, length_crystal/2-(2*ibar0+1)*width_crystal/2, 0));
+            std::string hardname0 = "Hardware_positive_s0_"+std::to_string(ibar0);
+            dd4hep::DetElement harddet0(sd, hardname0, detid);
+            plv_hard0.addPhysVolID("bar",ibar0);
+            harddet0.setPlacement(plv_hard0);
+        }
+    }
+
+    // // #########################
+    // // ### modules placement ###
+    // // #########################
+
+    for(int ilayer=0; ilayer<Nlayers; ilayer=ilayer+1){
+        if(ilayer%2==0){
+            dd4hep::PlacedVolume plv = module_volume.placeVolume(block, Position(0, 0, 0.5*width_crystal+ilayer*width_crystal-z_depth/2));
+            plv.addPhysVolID("slayer", 0).addPhysVolID("dlayer", floor(ilayer/2+1));
+            stavedet.setPlacement(plv); 
+        }
+        else{
+            dd4hep::Transform3D transform(dd4hep::RotationZ(90*degree),  dd4hep::Position(0, 0, 0.5*width_crystal+ilayer*width_crystal-z_depth/2)); 
+            dd4hep::PlacedVolume plv = module_volume.placeVolume(block, transform);
+            plv.addPhysVolID("slayer", 1).addPhysVolID("dlayer", floor(ilayer/2+1));
+            stavedet.setPlacement(plv); 
+            
+        }             
+    }
+
+    // several smaller module
+    // dd4hep::Box module_box1(x_width/2, 260/2, z_depth/2);
+    // dd4hep::Volume module_volume1("module_volume1", module_box1, air);
+    // module_volume1.setVisAttributes(theDetector, "GreenVis");
+
+    // dd4hep::Volume block1("block1", dd4hep::Box(x_width/2, 260/2, width_crystal/2), air);
+    // block1.setVisAttributes(theDetector, "SeeThrough");
+    // std::string blockname = "Block1";
+    // dd4hep::DetElement sd1(stavedet, blockname1, detid);
+
+    // dd4hep::Volume bar_s0("bar_s0", dd4hep::Box(length_crystal/2, width_crystal/2-crystal_wrapping, width_crystal/2-crystal_wrapping), mat_BGO); 
+    // bar_s0.setVisAttributes(theDetector, "EcalBarrelVis");
+    // bar_s0.setSensitiveDetector(sens);
+
+    // // #########################
+    // // ### modules placement ###
+    // // #########################
+
+    int number = 0;
+    for(int i=-6; i<7; i=i+1){
+        for(int j=-6; j<7; j=j+1){
+            // if((i==2 && j==2) || (i==2 && j==3) || (i==3 && j==2) || (i==3 && j==3)){
+                if(i==0 || j==0) continue; 
+                if(sqrt(abs(i)*abs(i) + abs(j)*abs(j))<2 || sqrt(abs(i)*abs(i) + abs(j)*abs(j))>6.1) continue;
+                else{
+                    dd4hep::PlacedVolume plvPlus, plvMinus;
+                    // cout<<"i: "<<i<<" j: "<<j<<endl;
+                    if(i>0 && j>0){
+                        plvPlus = envelopeVol.placeVolume(module_volume, Position(x_width*i - x_width/2, y_width*j - y_width/2, 2*z_min+z_depth));
+                        dd4hep::Transform3D transform(dd4hep::RotationY(-180*degree),  Position(x_width*i - x_width/2, y_width*j - y_width/2, 0)); 
+                        plvMinus = envelopeVol.placeVolume(module_volume, transform);
+
+                        
+                    } 
+                    else if (i>0 && j<0){
+                        plvPlus = envelopeVol.placeVolume(module_volume, Position(x_width*i - x_width/2, y_width*j + y_width/2, 2*z_min+z_depth));
+                        dd4hep::Transform3D transform(dd4hep::RotationY(-180*degree),  Position(x_width*i - x_width/2, y_width*j + y_width/2, 0));
+                        plvMinus = envelopeVol.placeVolume(module_volume, transform);
+                    }  
+
+                    else if (i<0 && j>0) {
+                        plvPlus = envelopeVol.placeVolume(module_volume, Position(x_width*i + x_width/2, y_width*j - y_width/2, 2*z_min+z_depth));
+                        dd4hep::Transform3D transform(dd4hep::RotationY(-180*degree),  Position(x_width*i + x_width/2, y_width*j - y_width/2, 0));
+                        plvMinus = envelopeVol.placeVolume(module_volume, transform);
+                    } 
+                    else  {
+                        plvPlus = envelopeVol.placeVolume(module_volume, Position(x_width*i + x_width/2, y_width*j + y_width/2, 2*z_min+z_depth));
+                        dd4hep::Transform3D transform(dd4hep::RotationY(-180*degree),  Position(x_width*i + x_width/2, y_width*j + y_width/2, 0));
+                        plvMinus = envelopeVol.placeVolume(module_volume, transform);
+                    }
+
+                    plvPlus.addPhysVolID("module", 0).addPhysVolID("stave", 100*(i+6)+(j+6));
+                    plvMinus.addPhysVolID("module", 1).addPhysVolID("stave", 100*(i+6)+(j+6));
+                    // DetElement sd1(towerEle, "stave1_"+std::to_string(100*(i+6)+(j+6)), detid);
+                    // DetElement sd2(towerEle, "stave2_"+std::to_string(100*(i+6)+(j+6)), detid);
+                    moduleEle.setPlacement(plvPlus);
+                    moduleEle.setPlacement(plvMinus);
+                    number++; 
+                }
+            // }
+        }   
+    }
+
+    cout<<"number: "<<number<<endl;
+
+  
+     
+
+    sens.setType("calorimeter");
+    MYDEBUG("create_detector DONE. ");
+    return ECAL;
+} 
+
+DECLARE_DETELEMENT(LongCrystalBarEndcapCalorimeter_v01, create_detector)
diff --git a/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp b/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp
index 9e6abc73eb7242667b5481f0af2829370c7166e6..6515e9769b8a5c39d98955a3012950b11528cecc 100644
--- a/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp
+++ b/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp
@@ -320,6 +320,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
     }
     dd4hep::Transform3D pv(dd4hep::Rotation3D(dd4hep::RotationX(90*dd4hep::degree)),dd4hep::Position(0,0,0));
     dd4hep::PlacedVolume phv = motherVol.placeVolume(envelope,pv);
+    phv.addPhysVolID("system",x_det.id());
     sdet.setPlacement(phv);
 
     MYDEBUG("create_detector DONE. ");
diff --git a/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp b/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp
index acb54e5b03a44ad347acd085f0e66338d0e9ecc0..7631b5377206d63f0570a6ddb41702b224791eb7 100644
--- a/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp
+++ b/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp
@@ -294,7 +294,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
     sdetB.setPlacement(pv);
 
     pv = motherVol.placeVolume(assembly);
-//    pv.addPhysVolID("system",x_det.id());
+    pv.addPhysVolID("system",x_det.id());
     both_endcaps.setPlacement(pv);
     both_endcaps.add(sdetA);
     both_endcaps.add(sdetB);