META TOPICPARENT |
name="GlaSiDGettingStarted" |
Tweaking the drivers
This is a very brief description of how one can tweaking the DD4hep drivers to change for example the way various detector sensors are placed, or simply to print detector id's and coordinates.
Model components
The DD4hep model of each SiD sub-detector contains two important components:
- geometry description, in an XML file, e.g.
SiD/compact/SiD_o2_v01/SiTrackerBarrel_o2_v01_00.xml
- the driver, in a C++ file, e.g.
detector/tracker/TrackerBarrel_o1_v03_geo.cpp
Note that the file paths above assume you are located in lcgeo/ .
Identifying the driver
To find which driver is used, have a look in the XML file, in the example above
In the example above, we use a custom driver which is normally located in the detector/ subdirectory. In other cases, a generic driver can be used, e.g.
Generic DD4hep drivers have names like DD4hep_... . A custom driver is very often a modified generic driver.
Note that in the case below, a custom driver located in detector/calorimeter is used, even though it's named Generic_...
Customising a driver
Let us say we want to customise our ECalBarrel driver, which in the example above was GenericCalBarrel_o1_v01_geo.cpp . We make a copy:
cd detector/calorimeter/
cp GenericCalBarrel_o1_v01_geo.cpp MyECalBarrel_o1_v01_geo.cpp
cd ../../
and then we edit SiD/compact/SiD_o2_v01/ECalBarrel_o2_v01_00.xml to say
... detector id="5" name="ECalBarrel" type="MyECalBarrel_o1_v01" ...
Now let's edit the driver MyECalBarrel_o1_v01_geo.cpp and make it print out the module info, e.g. in function placeStaves() add the line
std:cout << "Module: " << module << " X: " << posX << " Y: " << posY << " rotY: " << rotY << std:endl;
and also change
DECLARE_DETELEMENT(MyECalBarrel_o1_v01, create_detector)
And now we must recompile the drivers as described in here, and watch for a message like
[ 59%] Building CXX object CMakeFiles/lcgeo.dir/detector/calorimeter/MyECalBarrel_o1_v01_geo.cpp.o
Running with the new driver
Now if you run for example geoDisplay , or ddsim
ddsim --compactFile=SiD/compact/SiD_o2_v01/SiD_o2_v01.xml --runType=batch --inputFile mcparticles.slcio -N=1 --outputFile=testSiD_o2_v01.slcio
you will notice that when the ECalBarrel is built, the following will be printed to the screen
Module: 0 X: 34.5329 Y: 128.879 rotY: -0.261799
Module: 1 X: 94.3457 Y: 94.3457 rotY: -0.785398
Module: 2 X: 128.879 Y: 34.5329 rotY: -1.309
Module: 3 X: 128.879 Y: -34.5329 rotY: -1.8326
Module: 4 X: 94.3457 Y: -94.3457 rotY: -2.35619
Module: 5 X: 34.5329 Y: -128.879 rotY: -2.87979
Module: 6 X: -34.5329 Y: -128.879 rotY: -3.40339
Module: 7 X: -94.3457 Y: -94.3457 rotY: -3.92699
Module: 8 X: -128.879 Y: -34.5329 rotY: -4.45059
Module: 9 X: -128.879 Y: 34.5329 rotY: -4.97419
Module: 10 X: -94.3457 Y: 94.3457 rotY: -5.49779
Module: 11 X: -34.5329 Y: 128.879 rotY: -6.02139
Follow this example to modify the drivers as needed.
META FILEATTACHMENT |
attachment="whichdriver.png" attr="" comment="Identifying the C++ driver" date="1477357055" name="whichdriver.png" path="whichdriver.png" size="87220" user="DanProtopopescu" version="3" |
META FILEATTACHMENT |
attachment="genericdriver.png" attr="" comment="A generic DD4hep driver is used here" date="1477358085" name="genericdriver.png" path="genericdriver.png" size="72591" user="DanProtopopescu" version="1" |
META FILEATTACHMENT |
attachment="genericecal.png" attr="" comment="Another example of a custom driver" date="1477358498" name="genericecal.png" path="genericecal.png" size="84337" user="DanProtopopescu" version="1" |
|