When creating a new detector with the nptool-wizard, a folder with the name of your detector is created in NPSimulation/Detectors including two files (.hh and .cc) handling the necessary methods to describe the detector geometry and readout of input parameters in the case of an unsegmented plastic scintillator. This third tutorial will guide you to modify this class to handle segmentation and obtain a single sided silicon striped detector.
The private data members declared in NPSimulation/MSX25/MSX25.hh are the following:
The m_Event object, from the data class modified in the previous tutorial, will be used here to store the raw physical information of a simulated event. The detector coordinate provided by the user as an input in the file (/Inputs/DetectorConfiguration/MSX25.txt) will be read and stored temporarily in the vectors m_R, m_Theta, m_Phi. The m_Shape attribute defines if the detector is cylindrical or square and is also initialized when reading the input detector file.
Nothing needs to be change here to handle a stripped detector since the format changes in m_Event were made in the previous tutorial.
At the beginning of the MSX25.cc a namespace is defined to handle the physical dimensions and properties of the detector:
These properties are the one that are defined once for all (hard-coded) but not the one that you want to vary frequently and use as a parameter. Here for the turorial we want adapt these properties for a thin single-sided silicon stripped detector:
Most of the methods in the generated class inherits form the abstract base class NPS :VDetector whose file are located in NPSimulation/Core/NPSVDetector.hh. All these particular methods are generic and called either by the DetectorConstruction or the EventAction class necessary to perform Geant4 simulation. We now have to implement some of these methods inherrited from NPS::VDetector.
This method reads the geometry input file provided by the user. It mainly includes reading the position of the detector with respect to the frame origin . Two ways of postionning the detector are available by default : using the center of the detector and spherical coordinates (r,theta,phi) or giving particular position of the detector as input such as the corners of the front face of a telescope (x,y,z). A token based approach is used similarly to the one used in the NPLib classes. For some simple and standard detectors, other options can be provided and read using this method (ex : detector thickness, simple shape).
If all necessary informations are read, the AddnewDet() method is called and add the coordinate of the detector to a vector (m_R ,m_Theta, m_Phi). If several detectors of this kind are read, the size of this vector indicates the number of detectors that were created successfully.
The method does not need any change.
This method takes the world logical volume as an argument and is used to create the detector (material, logical volume) and initialize its sensitive part. It is called in the DetectorConstruction class (mandatory for Geant4). It includes the important call to G4PVPlacementthat creates the physical volume:
where the BuildSquareDetector() method returns the logical volume built from a given solid geometry:
Remark: The scorer “m_MSX25Scorer” used in the SetSensitiveDetector() method is defined in the two following methods.
This method declares and initialize the scorer that will be used to store the properties of the simulated event that are of interest for the user (deposited energy, time, detectorID, position, etc.). It also attaches this scorer to the Geant4 sensitive detector manager. For this tutorial, here is the declaration that has to be used for a silicon stripped detector scorer:
Different kind of generic scorer classes are available in NPSimulation/Core and can be used :
- CalorimeterScorers: this class handles scorers for unsegmented detectors mainly used to obtain energy deposit, time and detector number information. This is the kind of scorer used in the example build from the nptool-wizard.
- SiliconScorers : this class handles scorers for stripped silicon detectors of different kind (Rectangle, Annular, Resistive) but are quite generic and could be used for other kind of segmented detector.
- PhotoDiodeScorers : this class handles scorer for photon detectors.
To illustrate how hit informaions are stored in a scorer, below is displayed a part of the function ProcessHits() from the SiliconScorer class for a rectangle detector. The longitudinal strip number (m_StripLengthNumber) is calculated using the position of the hit (m_Position) in the sensitive detector, the strip pitch and the size of the detector plane. It is the stored in the eight element of the scorer Info array.
This method reads the hit map of the sensitive part of the detector using the chosen scorer (initialized previously) to access the necessary information for a given event and attach it to the event object from the corresponding NPLib data class. As you can see, the eight element of the scorer Info array is accessed and stored to be attached to the event object:
This method access the output tree via the RootOutput singleton and connect the data class to a new branch named after the detector.
The methods does not need any change.
Once all the changes are made in this simulation class, you can compile your work
or if you are using ninja-build
Execution and test
To test all the changes you made are working fine, simulate and analyze again some events with an alpha source: