Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New DRC sensitive detector using RegEx #367

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions FCCee/IDEA/compact/IDEA_o1_v03/DectDimensions_IDEA_o1_v03.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<define>
<constant name="world_side" value="6100*mm"/> <!-- Used in LumiCal and HOMAbsorber, != world_size -->
<constant name="CrossingAngle" value="0.030*rad"/>
<constant name="CrossingAngle" value="0.030*rad"/>

<constant name="GlobalTrackerReadoutID_DCH" type="string" value="system:1,layer:16,phi:16"/>
<constant name="GlobalTrackerReadoutID" type="string" value="system:5,layer:3,stave:6,module:5,sensor:2"/>
Expand All @@ -25,9 +25,9 @@
<constant name="GlobalTrackerReadoutID_SiWrapperB" type="string" value="system:5,layer:1,stave:9,module:6,sensor:1"/>
<constant name="GlobalTrackerReadoutID_SiWrapperD" type="string" value="system:5,side:1,layer:1,module:6,sensor:1"/>
<constant name="SolenoidField" value="2*tesla"/>

<constant name="DetID_NOTUSED" value=" 0"/>

<constant name="DetID_VXD_IB" value=" 1"/>
<constant name="DetID_VXD_Disks" value=" 2"/>
<constant name="DetID_DCH" value=" 3"/>
Expand All @@ -39,17 +39,17 @@
<constant name="DetID_HCAL_Barrel" value=" 10"/>
<constant name="DetID_HCAL_Endcap" value=" 11"/>
<constant name="DetID_HCAL_Ring" value=" 12"/>

<constant name="DetID_Yoke_Barrel" value=" 13"/>
<constant name="DetID_Yoke_Endcap" value=" 14"/>

<constant name="DetID_LumiCal" value=" 15"/>
<constant name="DetID_LumiCalInstrumentation" value=" 16"/>
<constant name="DetID_LumiCalCooling" value=" 17"/>
<constant name="DetID_LumiCalBackShield" value=" 18"/>
<constant name="DetID_HOMAbsorber" value=" 19"/>
<constant name="DetID_LumiCalNoseShield" value=" 22"/>

<constant name="DetID_SiWrapper_Barrel" value=" 23"/>
<constant name="DetID_SiWrapper_Disks" value=" 24"/>

Expand All @@ -68,7 +68,7 @@
<constant name="SeparatedBeamPipe_z" value="1190.0*mm"/> <!-- was 1159.97*mm in FCCDetectors/> -->
<constant name="CentralBeamPipe_rmax" value="10.0*mm"/>
<constant name="ConeBeamPipe_Rmax" value="28.9*mm" />
<constant name="BeamPipeGoldWidth" value="0.005*mm" />
<constant name="BeamPipeGoldWidth" value="0.005*mm" />
<constant name="BeamPipeGoldTolerance" value="0.001*mm" /> <!-- dummy tolerance, some small non zero value -->
<constant name="BeamPipeConeHalfAngle" value="(ConeBeamPipe_Rmax + BeamPipeWidthFirstCone - CentralBeamPipe_rmax ) / (SeparatedBeamPipe_z - CentralBeamPipe_zmax)" />

Expand All @@ -82,7 +82,7 @@
<constant name="MiddleOfSRMask_z" value="2.1*m" />
<constant name="SynchRadMaskSize" value="5*mm" /> <!-- mask tip is at 10 mm from the beamline -->
<constant name="mask_epsilon" value="0.001*mm" />

<constant name="VertexClearanceTheta" value="0.110"/> <!-- Clearance of vertex detector in mrad-->
<constant name="VTXIB_r_clearance" value="1*mm"/> <!-- Clearance of vertex detector in radius, used for definiton of vertex DD4hep_SubdetectorAssembly -->
<constant name="VTXIB_r_min" value="13.7*mm"/> <!-- Start of inner vertex detector layers. To keep distance of 1.3 mm from outer beam pipe end (10+0.35+1+0.35 mm = 11.7 mm). This changes to 13.7 mm due to cooling issues (see https://indico.cern.ch/event/1176398/contributions/5207171/attachments/2581129/4451907/Krakow%202023_v23_final.pdf) -->
Expand All @@ -98,7 +98,7 @@
<constant name="DCH_inner_cyl_R_total" value=" 349.8 * mm " />
<constant name="DCH_outer_cyl_R_total" value=" 2015 * mm " />
<constant name="DCH_half_length_total" value=" 2250 * mm " />

<constant name="Solenoid_inner_radius" value="2100*mm"/>
<constant name="Solenoid_outer_radius" value="2400*mm"/>
<constant name="Solenoid_half_length" value="2500*mm"/>
Expand All @@ -110,71 +110,71 @@
<constant name="EndPlateAbsorber_outer_radius" value="2090*mm"/>
<constant name="EndPlateAbsorber_z_min" value="2490*mm"/>
<constant name="EndPlateAbsorber_z_half_length" value="4.209/2.0*mm"/>

<constant name="YokeBarrel_inner_radius" value="4479*mm"/>
<constant name="YokeBarrel_outer_radius" value="6000*mm"/>
<constant name="YokeBarrel_half_length" value="3755*mm"/>
<constant name="YokeBarrel_symmetry" value="12"/>

<constant name="YokeEndcap_inner_radius" value="400*mm"/>
<constant name="YokeEndcap_outer_radius" value="6000*mm"/>
<constant name="YokeEndcap_min_z" value="3755*mm"/>
<constant name="YokeEndcap_max_z" value="5300*mm"/>
<constant name="YokeEndcap_outer_symmetry" value="12"/>
<constant name="YokeEndcap_inner_symmetry" value="0"/>

<constant name="CompSol_min_z" value="1230*mm"/>

<constant name="env_safety" value="0.1*mm"/>

<constant name="LumiCal_max_z" value="1186.5*mm" />
<constant name="LumiCal_min_z" value="1074*mm"/>

<constant name="LumiCal_dz" value="(LumiCal_max_z-LumiCal_min_z)/2.0"/>

<constant name="LumiCal_inner_radius" value="55.0*mm"/>
<constant name="LumiCal_outer_radius" value="112.0*mm- env_safety"/>

<constant name="LumiCal_Instr_thickness" value="20*mm"/>
<constant name="LumiCal_Instr_inner_radius" value="LumiCal_outer_radius"/>
<constant name="LumiCal_Instr_outer_radius" value="LumiCal_outer_radius+LumiCal_Instr_thickness - env_safety"/>

<constant name="LumiCal_Cool_thickness" value="9.75*mm"/>
<constant name="LumiCal_Cool_inner_radius" value="LumiCal_Instr_outer_radius"/>
<constant name="LumiCal_Cool_outer_radius" value="LumiCal_Instr_outer_radius+LumiCal_Cool_thickness"/>

<constant name="Lcal_services_rmax" value="LumiCal_outer_radius+30*mm"/>
<constant name="Lcal_offset_phi" value=" 0."/>
<!--preliminary LumiCal shielding-->
<!--back shielding-->
<constant name="LumiCal_Shield_inner_radius" value="LumiCal_inner_radius"/>
<constant name="LumiCal_Shield_outer_radius" value="LumiCal_outer_radius+LumiCal_Instr_thickness+LumiCal_Cool_thickness"/>
<constant name="LumiCal_shield_dz" value="1.75*mm"/>
<constant name="LumiCal_shield_dz" value="1.75*mm"/>
<!--nose-->
<constant name="LumiCal_NoseShield_inner_radius" value="LumiCal_inner_radius-5*mm"/>
<constant name="LumiCal_NoseShield_outer_radius" value="LumiCal_inner_radius+10*mm"/>
<constant name="LumiCal_nose_shield_dz" value="12*mm"/>

<constant name="BeamCal_inner_radius" value="32*mm"/>
<constant name="BeamCal_outer_radius" value="150*mm"/>
<constant name="BeamCal_min_z" value="3181*mm"/>
<constant name="BeamCal_max_z" value="3441*mm"/>
<constant name="BeamCal_dz" value="(BeamCal_max_z-BeamCal_min_z)/2.0"/>

<constant name="Kicker_inner_radius" value="4*mm"/>
<constant name="Kicker_outer_radius" value="25*mm"/>
<constant name="Kicker_min_z" value="3480*mm"/>
<constant name="Kicker_max_z" value="3780*mm"/>

<constant name="BPM_inner_radius" value="36*mm"/>
<constant name="BPM_outer_radius" value="55*mm"/>
<constant name="BPM_min_z" value="3790*mm"/>
<constant name="BPM_max_z" value="3880*mm"/>
<constant name="BPM_max_z" value="3880*mm"/>

<constant name="QD0_min_z" value="2000*mm"/>
<constant name="QD0_max_z" value="5200*mm"/>
<constant name="QD0Coil_outer_radius" value="30*mm"/>
<constant name="CollimatorInFrontOfQD0_dz" value="20*cm"/>
<constant name="CollimatorInFrontOfQD0_dz" value="20*cm"/>
<constant name="CollimatorInFrontOfQD0_radius" value="10*mm"/>
<constant name="CollimatorInFrontOfQD0_dr" value="16*mm"/>

Expand All @@ -197,22 +197,22 @@

<!-- Muon System Parameters-->

<constant name = "numberOfSides" value = "8"/> <!-- The number of sides of the muon system e.g (Octagon, Hexagon, ...)-->
<constant name = "numberOfSides" value = "8"/> <!-- The number of sides of the muon system e.g (Octagon, Hexagon, ...)-->

<!-- Barrel -->
<constant name = "BarrelFirstLayerRadius" value = "4500*mm"/> <!-- 1st Barrel microRWELL detector inner radius-> its the start point of thicknesses of the microRWELL material. In our case the shape is Polygon, so the radius is in the middle of the polygon side. -->
<constant name = "BarrelLength" value = "9000*mm"/> <!--Barrel detector length, in the description of the detctor we always use the half-length -->
<constant name = "BarrelLength" value = "9000*mm"/> <!--Barrel detector length, in the description of the detctor we always use the half-length -->
<!-- Endcap -->
<constant name = "EndcapFirstLayerZOffset" value = "4500*mm"/> <!-- 1st Endcap microRWELL detector inner ZOffset-> its the start point of thicknesses of the microRWELL volume -->
<constant name = "EndcapLayersInnerRadius" value = "700*mm"/> <!--Endcap detector inner radius, its the start point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<constant name = "EndcapLayersOuterRadius" value = "5320*mm"/> <!--Endcap detector outer radius, its the end point of thicknesses of the detector material ** it applies for both detector layers and yoke-->

<!-- End of Muon system Parameters-->


</define>


<limits>
<limitset name="cal_limits">
<limit name="step_length_max" particles="*" value="5.0" unit="mm" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
The compact format for the dual-readout calorimeter (for FCCee IDEA)
</comment>
</info>

<!-- For optics -->
<properties>
<matrix name="RI_Air" coldim="2" values="
Expand Down Expand Up @@ -589,7 +589,7 @@
<sensitive type="DRcaloSiPMSD"/>
<sipmDim height="0.3*mm" material="PolyvinylChloride" vis="DRCGenericVis">
<sipmGlass material="DR_PyrexGlass" vis="DRCGlassVis"/>
<sipmWafer height="0.3*mm" material="Silicon" vis="DRCWaferVis" sensitive="true"/> <!-- Original height : 0.01 mm, change to 0.3 mm, same as sipmDim (to reduce memory)-->
<sipmWafer height="0.3*mm" material="Silicon" vis="DRCWaferVis" sensitive="false"/> <!-- Original height : 0.01 mm, change to 0.3 mm, same as sipmDim (to reduce memory)-->
</sipmDim>
<structure>
<dim distance="1.5*mm" dx="1.0*mm"/>
Expand Down
6 changes: 3 additions & 3 deletions FCCee/IDEA/compact/IDEA_o1_v03/IDEA_o1_v03.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
url="no"
status="development"
version="o1_v03">
<comment>
<comment>
Version o1_v03 of the IDEA detector
</comment>
</info>
Expand All @@ -37,9 +37,9 @@
<!-- shape based model of the beam pipe -->
<include ref="../../../MDI/compact/MDI_o1_v00/Beampipe_o4_v05.xml" />
<include ref="../../../MDI/compact/MDI_o1_v00/BeamInstrumentation_o1_v01.xml" />

<!-- engineered CAD model of the beam pipe -->
<!-- In order to use the CAD beampipe, build k4geo with the following CMake option:
<!-- In order to use the CAD beampipe, build k4geo with the following CMake option:
cmake -D INSTALL_BEAMPIPE_STL_FILES=ON which will download the files needed -->
<!-- <include ref="../../../MDI/compact/MDI_o1_v01/Beampipe_CADimport_o1_v02.xml" /> -->
<!-- <include ref="../../../MDI/compact/MDI_o1_v01/BeamInstrumentation_o1_v01.xml"/> -->
Expand Down
11 changes: 9 additions & 2 deletions detector/calorimeter/dual-readout/src/DRconstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ddDRcalo::DRconstructor::implementTowers(xml_comp_t& x_theta, dd4hep::DDSeg

dd4hep::Volume towerVol( "tower", tower, fDescription->material(x_theta.materialStr()) );
towerVol.setVisAttributes(*fDescription, x_theta.visStr());

implementFibers(x_theta, towerVol, tower, param);

xml_comp_t x_wafer ( fX_sipmDim.child( _Unicode(sipmWafer) ) );
Expand Down Expand Up @@ -123,7 +123,10 @@ void ddDRcalo::DRconstructor::placeAssembly(dd4hep::DDSegmentation::DRparamBase_
int towerId32 = fSegmentation->getFirst32bits(towerId64);

dd4hep::Position towerPos = param->GetTowerPos(nPhi) + dd4hep::Position(0, 0, -(fX_worldTube.height()/2.));
AssemblyBoxVol.placeVolume( towerVol, towerId32, dd4hep::Transform3D( param->GetRotationZYX(nPhi), towerPos ) );
dd4hep::PlacedVolume towerPhys = AssemblyBoxVol.placeVolume( towerVol, towerId32, dd4hep::Transform3D( param->GetRotationZYX(nPhi), towerPos ) );
towerPhys.addPhysVolID("eta", towerNoLR);
towerPhys.addPhysVolID("phi", nPhi);
towerPhys.addPhysVolID("module", 2);

// Remove sipmLayer
dd4hep::Position sipmPos = param->GetSipmLayerPos(nPhi) + dd4hep::Position(0, 0, -(fX_worldTube.height()/2.));
Expand Down Expand Up @@ -250,6 +253,8 @@ void ddDRcalo::DRconstructor::implementFiber(dd4hep::Volume& towerVol, dd4hep::P
if (fVis) coreVol.setVisAttributes(*fDescription, fX_coreC.visStr());
cladVol.placeVolume( coreVol );

// we use the region for the sensitive elements for
// manipulating optical photons (DRCaloFastSimModel)
coreVol.setRegion(*fDescription, fX_det.regionStr());
cladVol.setRegion(*fDescription, fX_det.regionStr());
} else { // s fiber
Expand All @@ -261,6 +266,8 @@ void ddDRcalo::DRconstructor::implementFiber(dd4hep::Volume& towerVol, dd4hep::P
if (fVis) coreVol.setVisAttributes(*fDescription, fX_coreS.visStr());
cladVol.placeVolume( coreVol );

// we use the region for the sensitive elements for
// manipulating optical photons (DRCaloFastSimModel)
coreVol.setRegion(*fDescription, fX_det.regionStr());
cladVol.setRegion(*fDescription, fX_det.regionStr());
}
Expand Down
105 changes: 105 additions & 0 deletions example/DRCfastSDsteer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# ==========================================================================
# AIDA Detector description implementation
# --------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
# ==========================================================================

from __future__ import absolute_import, unicode_literals
import os
import time
import DDG4
from DDG4 import OutputLevel as Output
from g4units import GeV, MeV, m

def run():
args = DDG4.CommandLine()
kernel = DDG4.Kernel()
logger = DDG4.Logger('DRCfastSD')

kernel.loadGeometry(str("./IDEA_o1_v03/IDEA_o1_v03.xml"))

detectorDescription = kernel.detectorDescription()

DDG4.importConstants(detectorDescription, debug=False)

geant4 = DDG4.Geant4(kernel)
geant4.printDetectors()

# Configure UI
ui = geant4.setupCshUI()
ui.Commands = ['/run/beamOn ' + str("10"), '/ddg4/UI/terminate']
#
# Configure field
geant4.setupTrackingField()
#
# Configure G4 geometry setup
seq, act = geant4.addDetectorConstruction('Geant4DetectorGeometryConstruction/ConstructGeo')
#
# Assign sensitive detectors according to the declarations 'tracker' or 'calorimeter', etc
# seq, act = geant4.addDetectorConstruction('Geant4DetectorSensitivesConstruction/ConstructSD')
# Assign sensitive detectors in Geant4 by matching a regular expression in the detector sub-tree
seq, act = geant4.addDetectorConstruction('Geant4RegexSensitivesConstruction/ConstructSDRegEx')
act.Detector = 'DRcalo'
act.OutputLevel = Output.ALWAYS
act.Match = ['(.*)(core|clad)(.*)'] # regex is expensive, always try to avoid complex match
SanghyunKo marked this conversation as resolved.
Show resolved Hide resolved
# overhead time corresponds to the O(n) of the list size
#
# Configure I/O
evt_root = DDG4.EventAction(kernel, 'Geant4Output2EDM4hep_DRC/fastSDtest.root', True)
evt_root.Control = True
output = "fastSDtest.root"
evt_root.Output = output
evt_root.enableUI()
kernel.eventAction().add(evt_root)
#
# Setup particle gun
gun = geant4.setupGun('Gun', particle='e-', energy=20 * GeV, multiplicity=1)
gun.direction = (0.02, 1, 0.009)
gun.OutputLevel = Output.INFO
gun.enableUI()
#
# And handle the simulation particles.
part = DDG4.GeneratorAction(kernel, 'Geant4ParticleHandler/ParticleHandler')
part.SaveProcesses = ['Decay']
part.MinimalKineticEnergy = 50 * MeV
kernel.generatorAction().adopt(part)
#
# Map sensitive detectors
sd = geant4.description.sensitiveDetector(str('DRcalo'))
logger.info(f'+++ DRcalo: SD type: {str(sd.type())}')
seq, act = geant4.setupCalorimeter('DRcalo','DRCaloSDAction')
act.skipScint = True # we skip the optical photon propagation for scint channels
#
# Now build the physics list:
phys = geant4.setupPhysics(str('FTFP_BERT'))
phys.dump()

seq = kernel.physicsList()
cerenkov = DDG4.PhysicsList(kernel, 'Geant4CerenkovPhysics/CerenkovPhys')
cerenkov.TrackSecondariesFirst = True
cerenkov.VerboseLevel = 1
cerenkov.enableUI()
seq.adopt(cerenkov)

opt = DDG4.PhysicsList(kernel, 'Geant4OpticalPhotonPhysics/OpticalGammaPhys')
opt.addParticleConstructor('G4OpticalPhoton')
opt.VerboseLevel = 1
opt.BoundaryInvokeSD = True
opt.enableUI()
seq.adopt(opt)

geant4.execute()

#kernel.configure()
#kernel.initialize()
#kernel.run()
#kernel.terminate()


if __name__ == "__main__":
run()
Loading
Loading