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

Alphas example #122

Merged
merged 14 commits into from
Jan 29, 2022
64 changes: 64 additions & 0 deletions examples/01.alphaTrack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
This example shows how to include the detector response and the reconstruction of tracks from rawsignal detector data. The processes included have been adapted to facilitate the reconstruction of short energetic alpha tracks. Before using the example it is necessary to generate the Geant4 event MC data. You may use the following restG4 [example](https://github.com/rest-for-physics/restG4/examples/08.Alphas).

A quick recipe to generate the necessary data.

Copy this example at your working directory. Then copy the restG4 generator example.

```
cd myWorkDir
cp -r $REST_PATH/examples/01.alphaTrack .
cd 01.alphaTrack
cp -r $REST_PATH/examples/restG4/08.Alphas .
export REST_FOIL=1
export REST_ENERGY=5
mkdir data
restG4 08.Alphas/alphas.rml
```

This will produce an initial ROOT file that contains the simulated Geant4 event data.

In order to further process the data we need to execute:

```
restManager --c processing --f data/Run_5MeV_1um.root
```

The processing includes the electron diffusion, the readout segmentation, and shaping and noise signal effects.
The full data processing is disabled by default, there are a few variables that control the depth of the data processing.

* **RAW_PROCESSING**: It will extend the processing to get detector electronics like signals.
* **HIT_PROCESSING**: It will extend the processing to reconstruct the detector raw data using the readout definition (See also readout [README.md](readout/README.md)).
* **TRACK_PROCESSING**: It will extend the processing to reduce the hits and identify the physical track (Few processes are missing yet).

Those variables are dependent between them, and if one of them is enabled, all the previous ones must be enabled too. For example, if `TRACK_PROCESSING` is enabled, then `RAW_PROCESSING` and `HIT_PROCESSING` should be enabled too.

Additionaly, one may enable electronics shaping in the raw detector signal production by enabling an additional variable `SHAPING=ON`.

Those variables may be defined externally at the command shell executing

```
export RAW_PROCESSING=ON
```

or they might be modified inside the corresponding RML file.

Events may be visualized using:

```
restRoot data/Response_5MeV_1um.root
run0->GetEventWithId(9893);
TCanvas c;
ev0->DrawEvent("hist(Cont0,col)[1]");
```

Those commands were used to generate the following plots. That correspond with different levels of processing by enabling `RAW_PROCESSING`, `HIT_PROCESSING` and `TRACK_PROCESSING`, with `SHAPING` disabled/enabled.

![rawSignal](images/rawSignal.png)
![rawSignalShaping](images/rawSignalShaping.png)

![reconstruction](images/reconstruction.png)
![reconstructionShape](images/reconstructionShaping.png)

![trackReduction](images/trackReduction.png)
![trackReductionShaping](images/trackReductionShaping.png)

Binary file added examples/01.alphaTrack/images/rawSignal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions examples/01.alphaTrack/processing.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?xml version="1.0" ?>
<TRestManager name="RESTManagerSim" title="Template manager to process a simulation generated by restG4.">

<globals>
<variable name="EXPERIMENT" value="Fluorescence" overwrite="false"/>
<variable name="RAW_PROCESSING" value="OFF" />
<variable name="HIT_PROCESSING" value="OFF" />
<variable name="TRACK_PROCESSING" value="OFF" />
<variable name="SHAPING" value="OFF" />
<parameter name="mainDataPath" value="."/>
<parameter name="verboseLevel" value="warning"/>
%options are : essential silent, warning, info, debug

<parameter name="sampling" value="10ns" />
<parameter name="driftVelocity" value="" />
<parameter name="electricField" value="100" units="V/cm" />
<parameter name="gasPressure" value="1" />
</globals>

<TRestRun name="Process" title="Alpha simulations.">
<parameter name="experimentName" value="${EXPERIMENT}"/>
<parameter name="readOnly" value="false"/>
<parameter name="runNumber" value="preserve"/>
<parameter name="runTag" value="preserve"/>
<parameter name="runType" value="g4Analysis"/>
<parameter name="runDescription" value=""/>
<parameter name="user" value="${USER}"/>
<parameter name="verboseLevel" value="1"/>
<parameter name="overwrite" value="off"/>
<parameter name="outputFileName" value="data/Response_[fRunTag].root" />

<addMetadata type="TRestDetectorReadout" name="cathode" file="readout/readouts.root" store="false" />
<TRestDetectorGas name="Argon-Isobutane 1Pct 10-10E3Vcm" pressure="1" file="server" />
</TRestRun>


<TRestProcessRunner name="TemplateEventProcess" verboseLevel="info">
<parameter name="eventsToProcess" value="0"/>
<parameter name="threadNumber" value="1"/>

<parameter name="inputAnalysisStorage" value="on"/>
<parameter name="inputEventStorage" value="off"/>
<parameter name="outputEventStorage" value="on"/>

// observable = all will add all NON `custom` observables
<addProcess type="TRestGeant4AnalysisProcess" name="g4Ana" value="ON">
<observable name="thetaPrimary" value="ON" />
<observable name="phiPrimary" value="ON" />
<observable name="xOriginPrimary" value="ON" />
<observable name="yOriginPrimary" value="ON" />
<observable name="zOriginPrimary" value="ON" />
<observable name="xDirectionPrimary" value="ON" />
<observable name="yDirectionPrimary" value="ON" />
<observable name="zDirectionPrimary" value="ON" />
<observable name="totalEdep" value="ON" />
</addProcess>

<addProcess type="TRestGeant4ToDetectorHitsProcess" name="G4ToHits" value="ON" />

<addProcess type="TRestDetectorElectronDiffusionProcess" name="eDiff" value="ON" >
<parameter name="attachment" value="0" />
<parameter name="Wvalue" value="" units="eV" />
<parameter name="maxHits" value="2000" />
</addProcess>

<addProcess type="TRestDetectorHitsSmearingProcess" name="smear" title="Smearing template">
<parameter name="energyReference" value="6keV" />
<parameter name="resolutionReference" value="13" />
</addProcess>

<addProcess type="TRestDetectorFiducializationProcess" name="fidutialization" title="Readout fiducialization"/>

<addProcess type="TRestDetectorHitsAnalysisProcess" name="hitsAnaDiff" title="A hits analysis process">
<observable name="energy" value="ON" />
<observable name="xMean" value="ON" />
<observable name="yMean" value="ON" />
<observable name="zMean" value="ON" />
</addProcess>

<addProcess type="TRestDetectorHitsToSignalProcess" name="hitsToSignal" title="A hits to signal template" value="${RAW_PROCESSING}" >
<parameter name="driftVelocity" value="" />
</addProcess>

<addProcess type="TRestDetectorSignalToRawSignalProcess" name="signalToRaw" title="Physical signal to raw signal" value="${RAW_PROCESSING}">
<parameter name="Npoints" value="512" />
<parameter name="triggerMode" value="firstDeposit" />
<parameter name="triggerDelay" value="120" />
<parameter name="gain" value="10" />
</addProcess>

<addProcess type="TRestRawSignalShapingProcess" name="shaping" title="Signal shaping" value="${SHAPING}">
<parameter name="shapingType" value="shaperSin" />
<parameter name="shapingTime" value="10" />
<parameter name="gain" value="1" />
</addProcess>

<addProcess type="TRestRawSignalAddNoiseProcess" name="noise" title="Signal noise" value="${RAW_PROCESSING}">
<parameter name="noiseLevel" value="2" />
</addProcess>

<addProcess type="TRestRawSignalAnalysisProcess" name="rawAna" title="Signal noise" value="${RAW_PROCESSING}" observable="all">
</addProcess>

<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="${HIT_PROCESSING}"
baseLineRange="(5,55)"
integralRange="(10,500)"
pointThreshold="2"
pointsOverThreshold="5"
signalThreshold="3" />

<!-- Requires a bit of debugging
<addProcess type="TRestDetectorSignalChannelActivityProcess" name="chActivity" value="${RAW_PROCESSING}" verboseLevel="info" observable="all" >
<parameter name="daqChannels" value="240" />
<parameter name="readoutChannels" value="240" />
</addProcess>
-->

<addProcess type="TRestDetectorSignalToHitsProcess" name="signalToHits" value="${HIT_PROCESSING}"
observable="all" method="all" />

<addProcess type="TRestDetectorHitsToTrackProcess" name="hitsToTrack" title="" value="${TRACK_PROCESSING}">
<parameter name="clusterDistance" value="2.5" units="mm" />
</addProcess>

<addProcess type="TRestTrackReductionProcess" name="reduction" title="" value="${TRACK_PROCESSING}">
<parameter name="startingDistance" value="0.15mm" />
<parameter name="minimumDistance" value="0.5mm" />
<parameter name="distanceStepFactor" value="1.15" />
<parameter name="maxNodes" value="3" />
</addProcess>

</TRestProcessRunner>

<addTask type="processEvents" value="ON"/>

</TRestManager>

24 changes: 24 additions & 0 deletions examples/01.alphaTrack/readout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Minimal script to generate the readouts file:

```
TRestReadout *r1 = new TRestReadout("readouts.rml", "readout" );
TRestReadout *r2 = new TRestReadout("readouts.rml", "cathode" );

TFile *f = new TFile( "readouts.root", "RECREATE" );
r1->Write("readout");
r2->Write("cathode");

f->Close();
```


Minimal script to visualize the readout:


```
restRootMacros
REST_Detector_ViewReadout("readouts.root", "cathode")
```

![readout](readout.png)
61 changes: 61 additions & 0 deletions examples/01.alphaTrack/readout/microbulkModule.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<readoutModule name="module" size="((nChannels+1)*pitch-1*pitch/2,(nChannels+1)*pitch-pitch/2-pitch/4)" tolerance="1.e-1" >

// Y-strips
<for variable="nCh" from="1" to="nChannels-2" step="1" >
<readoutChannel id="${nCh}" >
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}" origin="((1+${nCh})*pitch,pitch/4+${nPix}*pitch)" size="(pixelSize,pixelSize)" rotation="45" />
</for>
<addPixel id="nChannels" origin="((1+${nCh})*pitch-pitch/2,pitch/4+(nChannels-1)*pitch+pitch/2)" size="(pitch,pitch/2)" rotation="0" />
</readoutChannel>
</for>

//First strip is special (upper left corner)
<readoutChannel id="0">
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}" origin="((1)*pitch,pitch/4+${nPix}*pitch)" size="(pixelSize,pixelSize)" rotation="45" />
</for>
<addPixel id="nChannels" origin="((1)*pitch-pitch/2,pitch/4+(nChannels-1)*pitch+pitch/2)" size="(pitch,pitch/2)" rotation="0" />
<addPixel id="nChannels+1" origin="(pitch/2,pitch/4+(nChannels-1)*pitch+pitch)" size="(pitch/2,pitch/2)" rotation="180" triangle="true"/>
</readoutChannel>

// Last strip is special
<readoutChannel id="nChannels-1" >
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}" origin="(nChannels*pitch,pitch/4+${nPix}*pitch)" size="(pixelSize,pixelSize)" rotation="45" />
<addPixel id="nChannels+${nPix}" origin="(nChannels*pitch,pitch/4+${nPix}*pitch)" size="(pitch/2,pitch)" rotation="0" />
</for>
<addPixel id="2*nChannels" origin="(nChannels*pitch-pitch/2,pitch/4+(nChannels-1)*pitch+pitch/2)" size="(pitch,pitch/2)" rotation="0" />
</readoutChannel>

// X-strips

// First strip is special
<readoutChannel id="nChannels" >
<addPixel id="0" origin="(0,0)" size="(pitch/2,3*pitch/4)" rotation="0" />
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}+1" origin="((0.5+${nPix})*pitch,pitch-pitch/4)" size="(pixelSize,pixelSize)" rotation="-135" triangle="true"/>
</for>
<addPixel id="nChannels+1" origin="(0,0)" size="(nChannels*pitch+pitch/2,pitch/4)" rotation="0" />
</readoutChannel>

<for variable="nCh" from="1" to="nChannels-2" step="1" >
<readoutChannel id="nChannels+${nCh}" >
<addPixel id="0" origin="(0,${nCh}*pitch-pitch/4)" size="(pitch/2,pitch)" rotation="0" />
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}+1" origin="((0.5+${nPix})*pitch,${nCh}*pitch-pitch/4)" size="(pixelSize,pixelSize)" rotation="45" />
</for>
</readoutChannel>
</for>

//Last strip is special (upper left corner)
<readoutChannel id="nChannels+nChannels-1" >
<addPixel id="0" origin="(0,pitch/4+(nChannels-1)*pitch+pitch/2)" size="(pitch/2,pitch/2)" rotation="0" triangle="true"/>
<addPixel id="1" origin="(0,(nChannels-1)*pitch-pitch/4)" size="(pitch/2,pitch)" rotation="0" />
<for variable="nPix" from="0" to="nChannels-1" step="1" >
<addPixel id="${nPix}+2" origin="((0.5+${nPix})*pitch,(nChannels-1)*pitch-pitch/4)" size="(pixelSize,pixelSize)" rotation="45" />
</for>
</readoutChannel>

</readoutModule>

Binary file added examples/01.alphaTrack/readout/readout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions examples/01.alphaTrack/readout/readouts.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" ?>
<readouts>
<globals>
<!-- The pitch value in mm -->
<variable name="PITCH" value="1" overwrite="false" />
<!-- The number of modules per axis MxM -->
<variable name="N_MODULES" value="1" overwrite="false" />
<!-- The number of pixels per side PxP -->
<variable name="N_CHANNELS" value="120" overwrite="false" />
</globals>

<TRestDetectorReadout name="cathode" title="Cathode ${PITCH} mm-Pitch ${N_CHANNELS}+${N_CHANNELS} channels">

<constant name="pitch" value="${PITCH}" overwrite="false" />
<!-- The number of modules per axis MxM -->
<constant name="nModules" value="${N_MODULES}" overwrite="false" />

<!-- The number of pixels per side PxP -->
<constant name="nChannels" value="${N_CHANNELS}" overwrite="false" />
<constant name="pixelSize" value="${PITCH}/sqrt(2.)" />

<parameter name="mappingNodes" value="400" />
<include file="microbulkModule.rml" />
<readoutPlane position="(0,0,0)mm" planeVector="(0,0,1)" chargeCollection="1" cathodePosition="(0,0,50)mm">
<addReadoutModule id="0" name="module" origin="(-0.5*nChannels*pitch,-0.5*nChannels*pitch)" rotation="0" decodingFile="" firstDaqChannel="0" />
</readoutPlane>
</TRestDetectorReadout>

<TRestDetectorReadout name="readout" title="Readout ${PITCH} mm-Pitch ${N_CHANNELS}+${N_CHANNELS} channels">

<constant name="pitch" value="${PITCH}" overwrite="false" />
<!-- The number of modules per axis MxM -->
<constant name="nModules" value="${N_MODULES}" overwrite="false" />

<!-- The number of pixels per side PxP -->
<constant name="nChannels" value="${N_CHANNELS}" overwrite="false" />
<constant name="pixelSize" value="${PITCH}/sqrt(2.)" />

<parameter name="mappingNodes" value="400" />
<include file="microbulkModule.rml" />
<readoutPlane position="(0,0,50)mm" planeVector="(0,0,-1)" chargeCollection="1" cathodePosition="(0,0,0)mm">
<addReadoutModule id="0" name="module" origin="(-0.5*nChannels*pitch,-0.5*nChannels*pitch)" rotation="0" decodingFile="" firstDaqChannel="0" />
</readoutPlane>
</TRestDetectorReadout>
</readouts>
Binary file added examples/01.alphaTrack/readout/readouts.root
Binary file not shown.
24 changes: 24 additions & 0 deletions pipeline/alphaTrack/readout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Minimal script to generate the readouts file:

```
TRestReadout *r1 = new TRestReadout("readouts.rml", "readout" );
TRestReadout *r2 = new TRestReadout("readouts.rml", "cathode" );

TFile *f = new TFile( "readouts.root", "RECREATE" );
r1->Write("readout");
r2->Write("cathode");

f->Close();
```


Minimal script to visualize the readout:


```
restRootMacros
REST_Detector_ViewReadout("readouts.root", "cathode")
```

![readout](readout.png)
Loading