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

Alpha ana #124

Merged
merged 37 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
db03914
Adding 01.alphaTrack validation routine
jgalan Jan 31, 2022
dd4e374
Pipeline/trexdm Removing forking feature from pipeline
jgalan Jan 31, 2022
18bd869
Fixing pipeline
jgalan Jan 31, 2022
e9b5649
examples/01.alphaTrack adapting to new ZeroSuppresion scheme
jgalan Jan 31, 2022
4f1239d
Updating 01.alphaTrack Validate.C
jgalan Jan 31, 2022
e6e34c0
examples/01.alphaTrack. Minor README update
jgalan Jan 31, 2022
dc1ba5b
examples/01.alphaTrack increasing validation range
jgalan Jan 31, 2022
b10865c
pipeline/trexdm fixing chain connectivity
jgalan Jan 31, 2022
bbe7181
pipeline/trexdm fixing pipeline
jgalan Jan 31, 2022
03f8328
Trying do address trex pipeline
juanangp Feb 2, 2022
96d7bc5
Updating alphaTrack example with current code changes
juanangp Feb 2, 2022
accaae9
Adding static function TRestHits::GetBoundaries as a generic method t…
juanangp Mar 16, 2022
85e0232
Adding new static function to perform kMeansClustering of volume hits
juanangp Mar 16, 2022
8e42db6
Adding scaling option to TRestAnalysisPlot that can be used to plot t…
juanangp Mar 16, 2022
019fba6
Adding AlphaCAMM project as a submodule to the repository
juanangp Mar 16, 2022
a4cb6a3
Merge branch 'master' into alphaAna
juanangp Mar 16, 2022
ffe3759
Trying to fix pipeline error
juanangp Mar 17, 2022
29ca945
Making FindGarfieldOlf more generic including Heed inc dirs
juanangp Mar 17, 2022
bcfab03
Fixing typo
juanangp Mar 17, 2022
8217039
Removing duplicated HitsToTrackProcess, trying to fix pipeline...
juanangp Mar 17, 2022
6b969ad
Trying to fix pandaX pipeline after removal of TRestRawZeroSuppresion…
juanangp Mar 17, 2022
83a3f71
Trying to fix pandax pipeline with new code changes
juanangp Mar 17, 2022
86042ad
Fixing trex pipeline
juanangp Mar 17, 2022
ac040aa
Removing TRestRawZeroSuppresionProcess from rml examples
juanangp Mar 17, 2022
0abfa40
Fixing bug in FindGarfieldOld
juanangp Mar 22, 2022
afee1ce
Merge branch 'master' into alphaAna
juanangp Mar 30, 2022
69fb878
Trying to fix pipeline after merging with master
juanangp Mar 30, 2022
15e69c2
Merge branch 'master' into alphaAna
juanangp Apr 5, 2022
3c031f9
Merge branch 'master' of github.com:rest-for-physics/framework into a…
juanangp Apr 8, 2022
46d6a36
Merge branch 'master' into alphaAna
jgalan Apr 20, 2022
ff37137
Fixing compilation error after merge with master
juanangp Apr 20, 2022
ccd048a
Increasing tracklib submodule to 1.3
jgalan Apr 25, 2022
e138c59
Increasing rawlib submodule to 1.6
juanangp Apr 25, 2022
5e0610f
Increasing connectorslib submodule to 1.2
juanangp Apr 25, 2022
8a33774
Increasing detectorlib submodule to 1.7
juanangp Apr 25, 2022
792df26
Updated TRestVersion.h to v2.3.12
juanangp Apr 25, 2022
0cf8f3c
Merge branch 'master' of github.com:rest-for-physics/framework into a…
juanangp Apr 25, 2022
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
29 changes: 29 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ stages:
# Stage to validate restG4 package examples
- restG4

# Stage to validate framework examples
- examples

# Stage to validate data chain processing constructions (TREX-DM data, PandaX-III topology, etc).
- restManager_process

Expand Down Expand Up @@ -148,6 +151,32 @@ List REST Macros:
- ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/Xe136bb0n_n2E06.root
expire_in: 1 day

08_alphas:
type: restG4
script:
- source ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/restG4/08.Alphas/
- mkdir data
- export REST_ENERGY=5
- export REST_FOIL=1
- restG4 alphas.rml
artifacts:
paths:
- ${CI_PROJECT_DIR}/install/examples/restG4/08.Alphas/data/Run_5MeV_1um.root
expire_in: 1 day

01_alphaTrack:
type: examples
script:
- source ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/install/examples/01.alphaTrack/
- mkdir data
- export RAW_PROCESSING=ON
- export HIT_PROCESSING=ON
- export TRACK_PROCESSING=ON
- restManager --c processing.rml --f ${CI_PROJECT_DIR}/install/examples/restG4/08.Alphas/data/Run_5MeV_1um.root
- restRoot -b -q Validate.C'("data/Response_5MeV_1um.root")'

Load Gas:
stage: metadata
script:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@
[submodule "doc/userguide"]
path = doc/userguide
url = https://github.com/rest-for-physics/rest-docs.github.io.git
[submodule "projects/alphacamm"]
path = projects/alphacamm
url = git@lfna.unizar.es:gifna/alphacamm.git
2 changes: 1 addition & 1 deletion examples/01.alphaTrack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This example shows how to include the detector response and the reconstruction o

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.
A quick recipe to generate the necessary data follows.

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

Expand Down
12 changes: 12 additions & 0 deletions examples/01.alphaTrack/Validate.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Int_t Validate(string fname) {
TRestRun* run = new TRestRun(fname);
cout << "Run entries : " << run->GetEntries() << endl;
if (run->GetEntries() < 4350 || run->GetEntries() > 4500) {
cout << "The number of entries is not in the range (4350,4500)!" << endl;
return 1;
}
delete run;

cout << "[\033[92m OK \x1b[0m]" << endl;
return 0;
}
22 changes: 16 additions & 6 deletions examples/01.alphaTrack/processing.rml
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@
<addProcess type="TRestRawSignalAnalysisProcess" name="rawAna" title="Signal noise" value="${RAW_PROCESSING}" observable="all">
</addProcess>

<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="${RAW_PROCESSING}"
baseLineRange="(5,55)"
integralRange="(10,500)"
pointThreshold="2"
pointsOverThreshold="5"
signalThreshold="3" />
<addProcess type="TRestRawToDetectorSignalProcess" name="zS" value="${RAW_PROCESSING}"
triggerStarts="0us"
gain="1"
threshold="0.01"
zeroSuppression="true"
baseLineRange="(5,55)"
integralRange="(10,500)"
pointThreshold="2"
nPointsOverThreshold="5"
signalThreshold="3" />

<!-- Requires a bit of debugging
<addProcess type="TRestDetectorSignalChannelActivityProcess" name="chActivity" value="${RAW_PROCESSING}" verboseLevel="info" observable="all" >
Expand All @@ -118,6 +122,12 @@
<addProcess type="TRestDetectorSignalToHitsProcess" name="signalToHits" value="${HIT_PROCESSING}"
observable="all" method="all" />

<addProcess type="TRestDetectorHitsToTrackFastProcess" name="hitsToTrackFast" title="" value="OFF">
<parameter name="netOrigin" value="(-100,-100,-100)" units="mm" />
<parameter name="netSize" value="200" units="mm" />
<parameter name="cellResolution" value="2" units="mm" />
</addProcess>

<addProcess type="TRestDetectorHitsToTrackProcess" name="hitsToTrack" title="" value="${TRACK_PROCESSING}">
<parameter name="clusterDistance" value="1" units="cm" />
</addProcess>
Expand Down
2 changes: 1 addition & 1 deletion examples/multiFeminos.rml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<parameter name="pointThreshold" value="3" />
<parameter name="pointsOverThreshold" value="3" />
</addProcess>
<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="ON" file="processes.rml"/>
<addProcess type="TRestRawToDetectorSignalProcess" name="zS" value="ON" file="processes.rml"/>

</TRestProcessRunner>

Expand Down
13 changes: 7 additions & 6 deletions pipeline/pandaxiii_MC/processes_2D.rml
Original file line number Diff line number Diff line change
Expand Up @@ -439,18 +439,19 @@
<observable name="Qratio_Y_R30" value="ON" />
<parameter name="hitsToCheckFraction" value="0.25" />
</TRestTrackBlobAnalysisProcess>
<TRestRawZeroSuppresionProcess name="zS" title="" verboseLevel="silent">
<!-- This parameter is used to define the baseline calculation -->
<parameter name="baseLineRange" value="(50,120)" />
<TRestRawToDetectorSignalProcess name="zS" title="" verboseLevel="silent">
<!-- These parameters define the integral with threshold.
threshold : number of baseline noise sigmas to consider a point for integration.
pointsOverThreshold : Number of consecutive points over threshold to be considered for integration.
minPeakAmplitude : Minimum peak signal amplitude to be considered at all.
-->
<!-- This parameter is used to define the baseline calculation -->
<parameter name="baseLineRange" value="(50,120)" />
<parameter name="zeroSuppression" value="true" />
<parameter name="pointThreshold" value="1.9" />
<parameter name="pointsOverThreshold" value="10" />
<parameter name="nPointsOverThreshold" value="10" />
<parameter name="signalThreshold" value="2.8" />
</TRestRawZeroSuppresionProcess>
</TRestRawToDetectorSignalProcess>
<TRestRawSignalAnalysisProcess name="sAna" title="" verboseLevel="silent">
<!-- This parameter defines every how many seconds a signal will be drawn.
In case the value is zero. There will not be any drawing. -->
Expand All @@ -465,7 +466,7 @@
minPeakAmplitude : Minimum peak signal amplitude to be considered at all.
-->
<parameter name="pointThreshold" value="1.9" />
<parameter name="pointsOverThreshold" value="10" />
<parameter name="nPointsOverThreshold" value="10" />
<parameter name="signalThreshold" value="2.8" />
<!-- ++++++++++++++++++++++
Observable definitions
Expand Down
11 changes: 7 additions & 4 deletions pipeline/pandaxiii_data/P3AutoChain.rml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<addProcess type="TRestRawMultiCoBoAsAdToSignalProcess" name="virtualDAQ" value="ON"/>
<addProcess type="TRestRawSignalAnalysisProcess" name="sAna" value="ON">

<parameter name="pointsOverThreshold" value="3" />
/// We define all observables except MinValue because it is not yet in validation chain
<observable name="BaseLineMean" value="ON" />
<observable name="BaseLineSigmaMean" value="ON" />
Expand All @@ -56,8 +56,12 @@

</addProcess>
<addProcess type="TRestEventRateAnalysisProcess" name="rateAna" value="ON" observable="all"/>
<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="ON" sampling="0.2us"/> 5MHz sampling

<addProcess type="TRestRawToDetectorSignalProcess" name="rawSignalToSignal" value="ON">
<parameter name="sampling" value="0.2us"/>
<parameter name="zeroSuppression" value="true"/>
<parameter name="nPointsOverThreshold" value="3" />
</addProcess>

<addProcess type="TRestRealTimeDrawingProcess" name="rD" value="ON" drawInterval="1000" >
<TRestAnalysisPlot name="TriggerRatePlot" previewPlot="false">
<canvas size="(1000,800)" save="TriggerRate.png"/>
Expand All @@ -78,7 +82,6 @@
<parameter name="mainDataPath" value="" />

<parameter name="pointThreshold" value="3" />
<parameter name="pointsOverThreshold" value="3" />
</globals>

</TRestManager>
Expand Down
20 changes: 12 additions & 8 deletions pipeline/trex/02_signal.rml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@

<parameter name="eventsToProcess" value="0" />

<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="ON"
baseLineRange="(${BL_MIN},${BL_MAX})"
integralRange="(${INT_MIN},${INT_MAX})"
pointThreshold="${POINT_TH}"
pointsOverThreshold="${NPOINTS}"
sampling="${SAMPLING}"
signalThreshold="${SGNL_TH}"
verboseLevel="silent" />
<addProcess type="TRestRawToDetectorSignalProcess" name="detSignal" value="ON"
threshold="0.01"
triggerStarts="0us"
gain="1"
zeroSuppression="true"
baseLineRange="(${BL_MIN},${BL_MAX})"
integralRange="(${INT_MIN},${INT_MAX})"
pointThreshold="${POINT_TH}"
nPointsOverThreshold="${NPOINTS}"
sampling="${SAMPLING}"
signalThreshold="${SGNL_TH}"
verboseLevel="silent" />

<addProcess type="TRestDetectorSignalChannelActivityProcess" name="chActivity" value="ON" verboseLevel="info" observable="all" >
<parameter name="daqChannels" value="72*4*4" />
Expand Down
1 change: 1 addition & 0 deletions source/framework/core/inc/TRestAnalysisPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TRestAnalysisPlot : public TRestMetadata {
std::string title;

Double_t normalize;
std::string scale;
Bool_t logX;
Bool_t logY;
Bool_t logZ;
Expand Down
2 changes: 2 additions & 0 deletions source/framework/core/inc/TRestHits.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ class TRestHits : public TObject {

void WriteHitsToTextFile(TString filename);

static void GetBoundaries(std::vector<double> &val, double &max, double &min, int &nBins, double offset=10);

virtual void PrintHits(Int_t nHits = -1) const;

class TRestHits_Iterator : public std::iterator<std::random_access_iterator_tag, TRestHits_Iterator> {
Expand Down
2 changes: 2 additions & 0 deletions source/framework/core/inc/TRestVolumeHits.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class TRestVolumeHits : public TRestHits {
return TMath::Sqrt(fSigmaX[n] * fSigmaX[n] + fSigmaY[n] * fSigmaY[n]);
}

static void kMeansClustering(TRestVolumeHits *hits, TRestVolumeHits &vHits, int maxIt =100);

// Constructor & Destructor
TRestVolumeHits();
~TRestVolumeHits();
Expand Down
15 changes: 14 additions & 1 deletion source/framework/core/src/TRestAnalysisPlot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ void TRestAnalysisPlot::InitFromConfigFile() {
plot.gridY = StringToBool(GetParameter("gridY", plotele, "false"));
plot.gridX = StringToBool(GetParameter("gridX", plotele, "false"));
plot.normalize = StringToDouble(GetParameter("norm", plotele, ""));
plot.scale = GetParameter("scale", plotele, "");
plot.labelX = GetParameter("xlabel", plotele, "");
plot.labelY = GetParameter("ylabel", plotele, "");
plot.ticksX = StringToInteger(GetParameter("xticks", plotele, "510"));
Expand Down Expand Up @@ -843,7 +844,7 @@ void TRestAnalysisPlot::PlotCombinedCanvas() {
continue;
}

// scale the histograms
// normalize the histograms
if (plot.normalize > 0) {
for (unsigned int i = 0; i < plot.histos.size(); i++) {
if (plot.histos[i].ptr == nullptr) continue;
Expand All @@ -855,6 +856,18 @@ void TRestAnalysisPlot::PlotCombinedCanvas() {
}
}

// scale the histograms
if (plot.scale != "") {
for (unsigned int i = 0; i < plot.histos.size(); i++) {
if (plot.histos[i].ptr == nullptr) continue;
Double_t scale = 1.;
if(plot.scale == "binSize")scale = 1./plot.histos[i].ptr->GetXaxis()->GetBinWidth(1);
else scale=StringToDouble(plot.scale);

plot.histos[i].ptr->Scale(scale);
}
}

// draw to the pad
targetPad = (TPad*)fCombinedCanvas->cd(n + 1 + fPanels.size());
Double_t maxValue_Pad = 0;
Expand Down
20 changes: 20 additions & 0 deletions source/framework/core/src/TRestHits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,26 @@ void TRestHits::WriteHitsToTextFile(TString filename) {
fclose(fff);
}

void TRestHits::GetBoundaries(std::vector<double> &dist, double &max, double &min, int &nBins, double offset){

std::sort(dist.begin(),dist.end());
max=dist.back();
min=dist.front();

double minDiff = 1E6;
double prevVal=1E6;
for (const auto &h : dist){
double diff = std::abs( h - prevVal);
if(diff>0 && diff<minDiff )minDiff=diff;
prevVal=h;
}

max += offset*minDiff + minDiff/2.;
min -= offset*minDiff + minDiff/2.;
nBins = std::round((max-min)/minDiff);

}

Double_t TRestHits::GetGaussSigmaX() {
Double_t gausSigmaX = 0;
Int_t nHits = GetNumberOfHits();
Expand Down
51 changes: 51 additions & 0 deletions source/framework/core/src/TRestVolumeHits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,54 @@ void TRestVolumeHits::PrintHits() const {
<< " Energy: " << GetEnergy(n) << endl;
}
}


//______________________________________________________________________________
void TRestVolumeHits::kMeansClustering(TRestVolumeHits *hits, TRestVolumeHits &vHits, int maxIt){

const int nodes = vHits.GetNumberOfHits();
TRestVolumeHits volHits[nodes];
//std::cout<<"Nhits "<<hits->GetNumberOfHits()<<" Nodes "<<nodes<<std::endl;
TVector3 nullVector = TVector3(0,0,0);
std::vector<TVector3> centroid(nodes);
std::vector<TVector3> centroidOld(nodes,nullVector);

for(int h=0;h<nodes; h++)centroid[h] = vHits.GetPosition(h);

for(int it=0;it<maxIt;it++){
for(int n=0;n<nodes;n++)volHits[n].RemoveHits();
for (int i = 0; i < hits->GetNumberOfHits(); i++){
double minDist=1E9;
int clIndex=-1;
for(int n=0;n<nodes;n++){
TVector3 hitPos =hits->GetPosition(i);
double dist = (centroid[n] - hitPos).Mag();
if(dist < minDist){
minDist=dist;
clIndex=n;
}
}
//cout<<minDist<<" "<<clIndex<<endl;
volHits[clIndex].AddHit(*hits,i);
}
bool converge=true;
for(int n=0;n<nodes;n++){
centroid[n] = volHits[n].GetMeanPosition();
converge &= (centroid[n] == centroidOld[n]);
centroidOld[n] = centroid[n];
}
if(converge){
break;
}
}

vHits.RemoveHits();
const TVector3 sigma(0., 0., 0.);
for(int n=0;n<nodes;n++){
if(volHits[n].GetNumberOfHits()>0)
vHits.AddHit(volHits[n].GetMeanPosition(),volHits[n].GetTotalEnergy(),0,volHits[n].GetType(0),sigma);
}

}