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

Implementation of TRestAxionOpticsMirror to get reflectivity from Henke database #22

Merged
merged 40 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8a878a9
TRestAxionMirrorReflectivity adding skeleton
jgalan Mar 31, 2022
e6b7ac0
TRestAxionMirrorReflectivity. Implemented loading and exporting tables
jgalan Apr 2, 2022
59c5f6a
TRestAxionMirrorReflectivity renamed to TRestAxionOpticsMirror
jgalan Apr 2, 2022
f8473cb
TRestAxionOpticsMirror. Fixing Npts=90 for angles
jgalan Apr 2, 2022
468ed67
TRestAxionOpticsMirror. Implemented GetReflectivity and GetTransmission
jgalan Apr 2, 2022
c67c8b3
TRestAxionOpticsMirror::ExportTables is private now
jgalan Apr 2, 2022
3acf8a8
TRestAxionOpticsMirror. Tables are now in binary format
jgalan Apr 2, 2022
1504490
TRestAxionOpticsMirror::DrawOpticsProperties method added
jgalan Apr 3, 2022
65c64ca
TRestAxionOpticsMirror. Adding documentation
jgalan Apr 3, 2022
76c6f03
Adding images/reflectivity.png
jgalan Apr 3, 2022
8994254
TRestAxionOpticsMirror::GetReflectivity/GetTransmission. Loading tabl…
jgalan Apr 3, 2022
efdcb4c
TRestAxionOpticsMirror. Additional documentation
jgalan Apr 3, 2022
ccba2bc
TRestAxionOpticsMirror. Adding new validation pipeline
jgalan Apr 3, 2022
1c98199
Updating data submodule that contains new reflectivity data
jgalan Apr 4, 2022
afd3a49
TRestAxionOpticsMirror::DrawOpticsProperties adds now a title
jgalan Apr 4, 2022
5dd501c
TRestAxionOpticsMirror. Replacing TGraph::AddPoint by SetPoint
jgalan Apr 4, 2022
2134431
TRestAxionOpticsMirror. Fixing documentation typos
jgalan Apr 4, 2022
1dc18d5
TRestAxionOpticsMirror::DrawOpticsProperties changed to a more intuit…
jgalan Apr 4, 2022
91c3814
TRestAxionOpticsMirror. Adding more details in documentation
jgalan Apr 4, 2022
c0ec2e8
TRestAxionOpticsMirror. Chaging table range to 0 to 9 degrees
jgalan Apr 4, 2022
ba587e0
TRestAxionOpticsMirror. Fixing documentation typos
jgalan Apr 4, 2022
5d16ce0
TRestAxionOpticsMirror. Fixed further documentation typos
jgalan Apr 4, 2022
5a7c5ce
TRestAxionOpticsMirror. Reducing number of downloaded files to 1000
jgalan Apr 5, 2022
80fde74
TRestAxionOpticsMirror::GetReflectivity fixing a bug
jgalan Apr 5, 2022
a42a933
TRestAxionOpticsMirror. Fixed initialization mirror
jgalan Apr 5, 2022
8e16403
TRestAxionOpticsMirror::LoadTables. Now file is read using Double_t
jgalan Apr 5, 2022
5025ac6
TRestAxionOpticsMirror::DrawOpticsProperties. Now we may redefine the…
jgalan Apr 5, 2022
d073e69
Updating reflectivity.png
jgalan Apr 5, 2022
fbdc788
TRestAxionOpticsMirror. Updating headers
jgalan Apr 5, 2022
f66e188
Adding XMM to pipeline/metadata/optics/mirrors.rml
jgalan Apr 5, 2022
77f0544
TRestAxionOpticsMirror::DrawOpticsProperties. Added linear scale plots
jgalan Apr 7, 2022
2d080ae
TRestAxionOpticsMirror. Replaced documentation image
jgalan Apr 7, 2022
dd96cab
TRestAxionOpticsMirror. New filename format with N901f extension
jgalan Apr 7, 2022
2980241
TRestAxionOpticsMirror. Fixing a bug
jgalan Apr 7, 2022
637fb2c
Updating data submodule
jgalan Apr 7, 2022
9e3dee0
Updating validation pipeline
jgalan Apr 7, 2022
422073e
TRestAxionOpticsMirror. Adding support for Bilayer mirror types
jgalan Apr 7, 2022
ecc605c
Updating mirrors.rml to the new metadata members. And adding bilayer …
jgalan Apr 7, 2022
69da8cf
Updating data submodule
jgalan Apr 7, 2022
6fddcd8
TRestAxionOpticsMirror. Updating default drawing plots
jgalan Apr 7, 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
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ optics:
script:
- . ${CI_PROJECT_DIR}/install/thisREST.sh
- cd ${CI_PROJECT_DIR}/pipeline/metadata/optics/
- python mirrors.py
- python optics.py
- python basic.py
except:
Expand Down
Binary file added images/reflectivity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions inc/TRestAxionOpticsMirror.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*************************************************************************
* This file is part of the REST software framework. *
* *
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
* For more information see http://gifna.unizar.es/trex *
* *
* REST is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* REST is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have a copy of the GNU General Public License along with *
* REST in $REST_PATH/LICENSE. *
* If not, see http://www.gnu.org/licenses/. *
* For the list of contributors see $REST_PATH/CREDITS. *
*************************************************************************/

#ifndef _TRestAxionOpticsMirror
#define _TRestAxionOpticsMirror

#include <TRestMetadata.h>
#include <iostream>

#include <TCanvas.h>

/// A metadata class accessing the Henke database to load reflectivity data
class TRestAxionOpticsMirror : public TRestMetadata {
private:
/// The mirror type (Thick, Single, Bilayer, Multilayer). Only `Single/Bilayer` is supported now.
std::string fMirrorType = "Single"; //<

/// The mirror layer material (chemical formula).
std::string fLayerTop = "C"; //<

/// The layer thickness in nm
std::string fLayerThicknessTop = "30"; //<

/// Layer surface roughness in nm
std::string fSigmaTop = "0"; //<

/// The mirror bottom layer material (chemical formula). Only used for "Bilayer" mirror type.
std::string fLayerBottom = ""; //<

/// The bottom layer thickness in nm. Only used for "Bilayer" mirror type.
std::string fLayerThicknessBottom = ""; //<

/// Bottom layer surface roughness in nm. Only used for "Bilayer" mirror type.
std::string fSigmaBottom = ""; //<

/// The substrate material
std::string fSubstrate = "SiO2"; //<

/// A set of key-value pairs sent to the Henke website for data request
std::map<std::string, std::string> fHenkeKeys; //!

/// The reflectivity loaded as a table with angle versus energy
std::vector<std::vector<Float_t> > fReflectivityTable; //!

/// The transmission loaded as a table with angle versus energy
std::vector<std::vector<Float_t> > fTransmissionTable; //!

/// A canvas to insert the optic properties drawing
TCanvas* fCanvas = nullptr; //!

std::string DownloadHenkeFile();

Int_t ExportTables();

std::string GetReflectivityFilename();
std::string GetTransmissionFilename();

public:
void Initialize();

void SetMirrorType(const std::string& type) { fMirrorType = type; }
void SetLayerMaterial(const std::string& layer) { fLayerTop = layer; }
void SetLayerThickness(const std::string& thickness) { fLayerThicknessTop = thickness; }
void SetLayerRoughness(const std::string& roughness) { fSigmaTop = roughness; }
void SetTopLayerMaterial(const std::string& layer) { fLayerTop = layer; }
void SetTopLayerThickness(const std::string& thickness) { fLayerThicknessTop = thickness; }
void SetTopLayerRoughness(const std::string& roughness) { fSigmaTop = roughness; }
void SetBottomLayerMaterial(const std::string& layer) { fLayerBottom = layer; }
void SetBottomLayerThickness(const std::string& thickness) { fLayerThicknessBottom = thickness; }
void SetBottomLayerRoughness(const std::string& roughness) { fSigmaBottom = roughness; }
void SetSubstrateMaterial(const std::string& substrate) { fSubstrate = substrate; }

void LoadTables();

Double_t GetReflectivity(const Double_t angle, const Double_t energy);

Double_t GetTransmission(const Double_t angle, const Double_t energy);

void PrintMetadata();

TCanvas* DrawOpticsProperties(std::string options = "", Double_t lowRange = 1.e-9,
Double_t lowRange2 = 1.e-3);

TRestAxionOpticsMirror();
TRestAxionOpticsMirror(const char* cfgFileName, std::string name = "");
~TRestAxionOpticsMirror();

ClassDef(TRestAxionOpticsMirror, 1);
};
#endif
87 changes: 87 additions & 0 deletions pipeline/metadata/optics/mirrors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/python3

import ROOT

ROOT.gSystem.Load("libRestFramework.so")
ROOT.gSystem.Load("libRestAxion.so")

print( "Loading default dummy mirror" )
mirror = ROOT.TRestAxionOpticsMirror("mirrors.rml", "default")
mirror.PrintMetadata()

ref1 = mirror.GetReflectivity( 0.25, 1 )
ref2 = mirror.GetReflectivity( 0.5, 3 )
ref3 = mirror.GetReflectivity( 0.75, 5 )
ref4 = mirror.GetReflectivity( 1., 7 )

ref1int = int(10000. * ref1 )
ref2int = int(10000. * ref2 )
ref3int = int(10000. * ref3 )
ref4int = int(10000. * ref4 )

print( "Reflectivity: " + str(ref1int), end ="" )
if( ref1int != 9721 ):
print( "\nError! Reflectivity should be 0.9721!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print( "Reflectivity: " + str(ref2int), end ="" )
if( ref2int != 9563 ):
print( "\nError! Reflectivity should be 0.9563!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print( "Reflectivity: " + str(ref3int), end ="" )
if( ref3int != 34 ):
print( "\nError! Reflectivity should be 0.0037!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print( "Reflectivity: " + str(ref4int), end ="" )
if( ref4int != 2 ):
print( "\nError! Reflectivity should be 0.0005!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")


print( "Loading XMM mirror" )
mirror = ROOT.TRestAxionOpticsMirror("mirrors.rml", "XMM")
mirror.PrintMetadata()

ref1 = mirror.GetReflectivity( 0.25, 1 )
ref2 = mirror.GetReflectivity( 0.5, 3 )
ref3 = mirror.GetReflectivity( 0.75, 5 )
ref4 = mirror.GetReflectivity( 1., 7 )

ref1int = int(10000. * ref1 )
ref2int = int(10000. * ref2 )
ref3int = int(10000. * ref3 )
ref4int = int(10000. * ref4 )

print( "Reflectivity: " + str(ref1int), end ="" )
if( ref1int != 9428 ):
print( "\nError! Reflectivity should be 0.9429!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print( "Reflectivity: " + str(ref2int), end ="" )
if( ref2int != 7099 ):
print( "\nError! Reflectivity should be 0.7090!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print( "Reflectivity: " + str(ref3int), end ="" )
if( ref3int != 5357 ):
print( "\nError! Reflectivity should be 0.5357!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print( "Reflectivity: " + str(ref4int), end ="" )
if( ref4int != 145 ):
print( "\nError! Reflectivity should be 0.0145!" )
exit(1)
print (" [\033[92m OK \x1b[0m]")

print ("All tests passed!")

exit(0)
35 changes: 35 additions & 0 deletions pipeline/metadata/optics/mirrors.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<mirrors>
<TRestAxionOpticsMirror name="default">
<parameter name="mirrorType" value="Single" />

<parameter name="layerTop" value="C" />
<parameter name="layerThicknessTop" value="30" />
<parameter name="sigmaTop" value="0" />

<parameter name="substrate" value="SiO2" />
</TRestAxionOpticsMirror>

<TRestAxionOpticsMirror name="XMM">
<parameter name="mirrorType" value="Single" />

<parameter name="layerTop" value="Au" />
<parameter name="layerThicknessTop" value="250" />
<parameter name="sigmaTop" value="0.4" />

<parameter name="substrate" value="Ni" />
</TRestAxionOpticsMirror>

<TRestAxionOpticsMirror name="XMM_C5H8O2_0.4nm">
<parameter name="mirrorType" value="Bilayer" />

<parameter name="layerTop" value="C5H8O2" />
<parameter name="layerThicknessTop" value="0.4" />
<parameter name="sigmaTop" value="0" />

<parameter name="layerBottom" value="Au" />
<parameter name="layerThicknessBottom" value="250" />
<parameter name="sigmaBottom" value="0.4" />

<parameter name="substrate" value="Ni" />
</TRestAxionOpticsMirror>
</mirrors>
Loading