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 19 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 @@ -26,6 +26,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 @@ -201,6 +204,32 @@ listRESTMacros:
- ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC/Xe136bb0n_n2E06.root
expire_in: 1 day

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

01_alphaTrack:
type: examples
script:
- . ${CI_PROJECT_DIR}/install_latest/thisREST.sh
- cd ${CI_PROJECT_DIR}/install_latest/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_latest/examples/restG4/08.Alphas/data/Run_5MeV_1um.root
- restRoot -b -q Validate.C'("data/Response_5MeV_1um.root")'

LoadGas:
type: 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
9 changes: 6 additions & 3 deletions cmake/FindGarfieldOld.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
set(Garfield_DIR $ENV{GARFIELD_HOME})

find_path(Garfield_INCLUDE_DIRS Sensor.hh
HINTS ${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield ${Garfield_INC_DIR}
${Garfield_DIR}/Include)
HINTS ${Garfield_DIR}/Include/ ${Garfield_DIR}/Include/Garfield
${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield)

find_path(Garfield_INCLUDE_Heed_DIRS HeedChamber.hh
HINTS ${Garfield_DIR}/Heed/)

#message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS})

find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield
HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR}
$ENV{GARFIELD_HOME}/lib)
$ENV{GARFIELD_DIR}/lib)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://cmake.org/cmake/help/latest/command/find_library.html
If I understand this correctly, this change should be equivalent to removing $ENV{GARFIELD_HOME}/lib) from the macro. Why is this needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line is not needed and it was actually removed, I don't understand how it end up in this PR.

As fas as I remember some commits were cherry-pick from this PR to master. Perhaps something when wrong in between.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is behind master, perhaps it will be fixed once master is merged in this branch. Highly recommended.

Screenshot 2022-04-20 at 21 35 51

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess thats why "outdated" appears next to the file name

#message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES})

#if (${Garfield_LIBRARY_DIR})
Expand Down
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;
}
19 changes: 13 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 @@ -122,6 +126,9 @@
<parameter name="clusterDistance" value="1" units="cm" />
</addProcess>

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

<addProcess type="TRestTrackReductionProcess" name="reduction" title="" value="${TRACK_PROCESSING}">
<parameter name="startingDistance" value="0.15mm" />
<parameter name="minimumDistance" value="0.5mm" />
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}"
pointsOverThreshold="${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 @@ -70,6 +70,7 @@ class TRestAnalysisPlot : public TRestMetadata {
string title;

Double_t normalize;
string scale;
juanangp marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -194,6 +194,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);

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 @@ -67,6 +67,8 @@ class TRestVolumeHits : public TRestHits {
}
Double_t GetXYSize(int n) { 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 @@ -558,6 +558,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 @@ -163,3 +163,54 @@ void TRestVolumeHits::PrintHits() {
<< " 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);
}

}