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

Generic optics #13

Merged
merged 32 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9d632c5
Add files via upload
jovoy Feb 17, 2022
26e963f
adding optics properies
jovoy Feb 17, 2022
1136cb5
Generic optics file added
jovoy Feb 17, 2022
e17e983
Repaired typo
jovoy Feb 21, 2022
00da28e
TRestAxionOptics. Added new virtual methods
jgalan Feb 21, 2022
455a9d5
TRestAxionGenericOptics. Fixed compilation errors
jgalan Feb 21, 2022
42cbbd6
Merge branch 'generic_optics' of github.com:jgalan/axionlib into gene…
jgalan Feb 21, 2022
6e9fa8b
TRestAxionGenericOptics. Adding missing Initialize method implementation
jgalan Feb 21, 2022
7de5b12
TRestAxionOptics. Implementing spider metadata members, and documenting
jgalan Feb 22, 2022
9323358
pipeline/optics/basic.rml added to define basic TRestAxionOptics tests
jgalan Feb 22, 2022
6fd3c4b
TRestAxionGenericOptics. Recovered documentation examples from editte…
jgalan Feb 22, 2022
876d2c2
TRestAxionOptics::HitsSpider method implemented
jgalan Feb 22, 2022
1a4e0c5
basic.rml updating verbose output level
jgalan Feb 22, 2022
9724737
TRestAxionOptics::InitFromConfigFile. Simplifying basic parameter ret…
jgalan Feb 22, 2022
906028d
TRestAxionOptics. Setting default spider start radius to 20mm
jgalan Feb 22, 2022
291a084
TRestAxionGenericOptics added interaction point method
jovoy Feb 23, 2022
fab9d7b
TRestAxionOptics fLength just length of one mirror
jovoy Feb 23, 2022
b093ab9
TRestAxionOptics added approx of optics length back in
jovoy Feb 23, 2022
68c6639
TRestAxionGenericOptics start method to get interaction point
jovoy Feb 23, 2022
2920f0a
TRestAxionOptics made shell radii protected
jovoy Feb 23, 2022
d2a5827
TRestAxionGenericOptics. Fixed returning value data type.
jgalan Feb 23, 2022
dceda4d
TRestAxionOptics::GetMaxRingRadius method added
jgalan Feb 24, 2022
bb62704
TRestAxionOptics::HitsSpider fixed errors
jgalan Feb 24, 2022
766d3a9
TRestAxionOptics. Systematic replacement of Shell by Ring
jgalan Feb 24, 2022
b8c1daf
TRestAxionOptics. Minor documentation update
jgalan Feb 24, 2022
f5a9d4c
pipeline/optics/basic.rml now defines two optics setups
jgalan Feb 24, 2022
e5bfd42
pipeline/optics/basic.py added
jgalan Feb 24, 2022
1591db1
Adding new optics pipeline script
jgalan Feb 24, 2022
d1aec64
TRestAxionGenericOptics. Updating according to changes at TRestAxionO…
jgalan Feb 24, 2022
6d86d7d
pipeline/optics.py fixing renamed method
jgalan Feb 26, 2022
d899323
setups.rml fixing pipeline
jgalan Feb 26, 2022
2cfeeed
Merge branch 'master' into generic_optics
jgalan Mar 29, 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
63 changes: 63 additions & 0 deletions inc/TRestAxionGenericOptics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*************************************************************************
* 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 _TRestAxionGenericOptics
#define _TRestAxionGenericOptics
#include <TRestAxionOptics.h>
#include <iostream>
/// A class calculate the reflection path and probability of X-rays through a Wolter 1 telescope
class TRestAxionGenericOptics : public TRestAxionOptics {
private:
/// A vector containing the shells seperations between the two stacks. First element is the lowest radius.
std::vector<Double_t> fShellsSep; //<

/// A vector containing the shells angles. First element is the lowest radius. Note that the second stack
/// has the tripple of this angle.
std::vector<Double_t> fShellsAngle; //<

/// coating materials and surface roughness or better yet: direction to a file that gives the reflectivity
std::string fReflectivityFileName; //<

void Initialize();

public:
void PrintMetadata();
void InitFromConfigFile();

/// It returns the position at the optics exit plane for the incoming particle
TVector3 GetPositionAtExit(const TVector3& pos, const TVector3& dir) { return TVector3(0, 0, 0); }

/// It returns the direction at the optics exit plane for the incoming particle
TVector3 GetDirectionAtExit(const TVector3& pos, const TVector3& dir) { return TVector3(0, 0, 0); }

/// It returns the efficiency for particle with position `pos` and direction `dir`.
Double_t GetEfficiency(const TVector3& pos, const TVector3& dir) { return 0.0; }

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

/// get the interaction point of the photon with the mirror
TVector3 GetInteractionPoint(const TVector3& pos, const TVector3& dir);
ClassDef(TRestAxionGenericOptics, 1);
};
#endif
65 changes: 51 additions & 14 deletions inc/TRestAxionOptics.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <TRestMetadata.h>
#include <iostream>

/// A class to load optics response files (WIP). Perhaps we might inherit later TRestAxionMCPLOptics, ...
/// An abstract class to define common optics parameters and methods
class TRestAxionOptics : public TRestMetadata {
private:
/// It is the position of the center of the optics system.
Expand All @@ -36,25 +36,51 @@ class TRestAxionOptics : public TRestMetadata {
TVector3 fAxis = TVector3(0, 0, 1); //<

/// Optics physical mirror length in mm
Double_t fLength = 250; //<
Double_t fLength = 300; //<

/// A vector containing the shells ring radius definitions. First element is the lower radius.
std::vector<std::pair<Double_t, Double_t>> fShellsRadii; //<
/// The angle between two consecutive spider arms measured in radians.
Double_t fSpiderArmsSeparationAngle = 0; //<

/// The position angle at which the spider arm will start
Double_t fSpiderOffsetAngle = 0; //<

/// The width of each specific spider arm. Measured in radians. Default is 2.5 degrees.
Double_t fSpiderWidth = TMath::Pi() / 18. / 4.; //<

/// The spider structure will be effective from this radius, in mm. Default is from 20 mm.
Double_t fSpiderStartRadius = 20.; //<

/// An internal variable to register the maximum shell radius
Double_t fMaxShellRadius = -1; //!

/// An internal variable to register the minimum shell radius
Double_t fMinShellRadius = -1; //!

/// It is the calculated position at the entrance of the optics.
TVector3 fEntrance; //!
/// It is the calculated axis position at the entrance of the optics plane.
TVector3 fEntrance = TVector3(0, 0, 0); //!

/// It is the calculated axis position at the exit of the optics plane.
TVector3 fExit = TVector3(0, 0, 0); //!

/// A vector used to define a reference vector at the optics plane
TVector3 fReference = TVector3(0, 0, 0); //!

/// It defines the forbidden (cosine) angular ranges imposed by the spider structure (0,Pi)
std::vector<std::pair<Double_t, Double_t>> fSpiderPositiveRanges; //!

/// It is the calculated position at the exit of the optics.
TVector3 fExit; //!
/// It defines the forbidden (cosine) angular ranges imposed by the spider structure (Pi,2Pi)
std::vector<std::pair<Double_t, Double_t>> fSpiderNegativeRanges; //!

void SetMaxAndMinShellRadius();
void InitializeSpiderAngles();

Bool_t IsInsideRing(const TVector3& pos, Double_t Rout, Double_t Rin = 0);
Bool_t HitsSpider(const TVector3& pos);

protected:

/// A vector containing the shells ring radius definitions. First element is the lower radius.
std::vector<std::pair<Double_t, Double_t>> fShellsRadii; //<

public:
void Initialize();
Expand All @@ -65,8 +91,12 @@ class TRestAxionOptics : public TRestMetadata {
/// It returns the axis vector of the optics system
TVector3 GetAxis() { return fAxis; }

/// It returns the physical length of the optics system
Double_t GetLength() { return fLength; }
/// It returns the physical length of one mirror stack; the whole optical system would be L=(fLength + 1/2 * xSep) * (cos(angleShell) + cos(angleShell)) which doesn't work here because the angele hasn't been defined
Double_t GetMirrLength() { return fLength; }

/// It returns the physical length of the whole optics approximated
Double_t GetLength() { return fLength * 2; }


/// It returns the number of shells implemented in the optics system
Int_t GetNumberOfShells() { return fShellsRadii.size(); }
Expand All @@ -78,17 +108,24 @@ class TRestAxionOptics : public TRestMetadata {
TVector3 GetExit() { return fExit; }

TVector3 GetPositionAtEntrance(const TVector3& pos, const TVector3& dir);
TVector3 GetPositionAtExit(const TVector3& pos, const TVector3& dir);

/// Pure abstract method to be implemented at inherited class
virtual TVector3 GetPositionAtExit(const TVector3& pos, const TVector3& dir) { return TVector3(0, 0, 0); }

/// Pure abstract method to be implemented at inherited class
virtual TVector3 GetDirectionAtExit(const TVector3& pos, const TVector3& dir) {
return TVector3(0, 0, 0);
}

/// Pure abstract method to be implemented at inherited class
virtual Double_t GetEfficiency(const TVector3& pos, const TVector3& dir) { return 0.0; }

Int_t GetEntranceShell(const TVector3& pos, const TVector3& dir);

void PrintMetadata();

void InitFromConfigFile();

/// Photon propagation method to be implemented at the derived class
virtual TVector3 PropagatePhoton(const TVector3& in) = 0;

TRestAxionOptics();
TRestAxionOptics(const char* cfgFileName, std::string name = "");
~TRestAxionOptics();
Expand Down
23 changes: 23 additions & 0 deletions pipeline/optics/basic.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<xml>

<globals>
<constant name="R0" value="3" />
<constant name="pi" value="3.1415927" />
</globals>

<!-- Turn verbose level to "debug" to see additional output -->
<TRestAxionOptics name="basic1" verboseLevel="info" >
<parameter name="center" value="(0,0,200)mm" />
<parameter name="axis" value="(0,0.02,0.98)" />
<parameter name="length" value="22cm" />

<!-- We build mirror shells with 0.1mm thickness -->
<parameter name="shellMinRadii" value="0,7,10,15,20,25" />
<parameter name="shellMaxRadii" value="R0,9.9,14.9,19.9,24.9,29.9" />

<parameter name="spiderArmsSeparationAngle" value="pi*30./180." />
<parameter name="spiderOffsetAngle" value="0.0" />
<parameter name="spiderWidth" value="pi*2.5/180." />
<parameter name="spiderStartRadius" value="R0" units="cm" />
</TRestAxionOptics>
</xml>
166 changes: 166 additions & 0 deletions src/TRestAxionGenericOptics.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/******************** REST disclaimer ***********************************
* 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. *
*************************************************************************/

//////////////////////////////////////////////////////////////////////////
/// TRestAxionGenericOptics is a class that inherits from TRestAxionOptics.
///
/// ToDO: Write what happens here
///
///
/// ### RML definition
///
/// Example 1:
/// \code
/// <TRestAxionGenericOptics name="dummy">
/// <parameter name="center" value="(0,0,200)mm" />
/// <parameter name="axis" value="(0,0.02,0.98)" />
/// <parameter name="length" value="22cm" />
///
/// <!-- We build mirror shells with 0.1mm thickness -->
/// <parameter name="shellMinRadii" value="5,10,15,20,25" />
/// <parameter name="shellMaxRadii" value="9.9,14.9,19.9,24.9,29.9" />
/// <TRestAxionOptics/>
/// \endcode
///
/// Example 2:
/// \code
/// <TRestAxionGenericOptics center="(0,0,950)mm" axis="(0,0,1)" />
/// \endcode
///
/// Example 3:
/// \code
/// <TRestAxionGenericOptics center="(0,0,95)" units="cm" />
/// \endcode
///
///--------------------------------------------------------------------------
///
/// RESTsoft - Software for Rare Event Searches with TPCs
///
/// History of developments:
///
/// 2022-February: First concept and implementation of TRestAxionGenericOptics class.
/// Johanna von Oy
///
/// \class TRestAxionGenericOptics
/// \author Johanna von Oy <vonoy@physik.uni-bonn.de>
///
/// <hr>
///

#include "TRestAxionGenericOptics.h"

using namespace std;
#include <cmath>
#include "TRestPhysics.h"
using namespace REST_Physics;
ClassImp(TRestAxionGenericOptics);

///////////////////////////////////////////////
/// \brief Default constructor
///
TRestAxionGenericOptics::TRestAxionGenericOptics() : TRestAxionOptics() { Initialize(); }

///////////////////////////////////////////////
/// \brief Default destructor
///
TRestAxionGenericOptics::~TRestAxionGenericOptics() {}

///////////////////////////////////////////////
/// \brief Constructor loading data from a config file
///
/// If no configuration path is defined using TRestMetadata::SetConfigFilePath
/// the path to the config file must be specified using full path, absolute or
/// relative.
///
/// The default behaviour is that the config file must be specified with
/// full path, absolute or relative.
///
/// \param cfgFileName A const char* giving the path to an RML file.
/// \param name The name of the specific metadata. It will be used to find the
/// corresponding TRestAxionMagneticField section inside the RML.
///
TRestAxionGenericOptics::TRestAxionGenericOptics(const char* cfgFileName, string name)
: TRestAxionOptics(cfgFileName) {
debug << "Entering TRestAxionGenericOptics constructor( cfgFileName, name )" << endl;

Initialize();

LoadConfigFromFile(fConfigFileName, name);

if (GetVerboseLevel() >= REST_Info) PrintMetadata();
}

///////////////////////////////////////////////
/// \brief Initialization of TRestAxionGenericOptics members
///
void TRestAxionGenericOptics::Initialize() {
TRestAxionOptics::Initialize();

SetSectionName(this->ClassName());
SetLibraryVersion(LIBRARY_VERSION);

// Call any initialization methods here
}

///////////////////////////////////////////////
/// \brief Initialization of TRestAxionGenericOptics field members through a RML file
///
void TRestAxionGenericOptics::InitFromConfigFile() {
TRestAxionOptics::InitFromConfigFile();

/// TODO Initialize metadata members of this class here

// If we recover the metadata class from ROOT file we will need to call Initialize ourselves
this->Initialize();
}

///////////////////////////////////////////////
/// \brief This calculates the interaction Point between the X-Ray photons path and a mirror in the
/// predetermined layer
///
TVector3 TRestAxionGenericOptics::GetInteractionPoint(const TVector3& pos, const TVector3& dir) {
Int_t layer = TRestAxionOptics::GetEntranceShell(pos, dir);
Copy link
Member

@jgalan jgalan Feb 23, 2022

Choose a reason for hiding this comment

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

Line 141 looks strange. There is no need to call specifying the base class, mainly because the method GetEntranceShell is not virtual, and it is not re-implemented inside TRestAxionGenericOptics. Therefore, just calling GetEntranceShell will have the same effect. When the method might be existing on both, base and inherited, then we need to specify, and therefore, as it is written now, to me it looks as if GetEntranceShell is on both classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay, I understand, thanks!

Double_t r1 = fShellsRadii[layer].second;
Double_t angle = fShellsAngle[layer];
Double_t xSep = fShellsSep[layer];
Double_t fLength = TRestAxionOptics::GetMirrLength();
// Double_t distMirrors = 0 for first stack and (fLength + xSep) * cos(angle) for the second // distance
// of the mirror should be added in for second stack
Double_t r2 = r1 - fLength * sin(angle);
// r1 = sqrt((pos[0] + s * dir[0]) * (pos[0] + s * dir[0]) +
// (pos[1] + s * dir[1]) * (pos[1] + s * dir[1])) -
// ((r2 - r1) * (pos[2] + s * dir[2] - distMirrors) / (cos(angle) * fLength)) //needs to be solved for
// s, maybe by incresing s for some value and comparing this to r1
return TVector3(0, 0, 0);
}

///////////////////////////////////////////////
/// \brief Prints on screen the information about the metadata members of TRestAxionGenericOptics
///
void TRestAxionGenericOptics::PrintMetadata() {
TRestAxionOptics::PrintMetadata();

metadata << "---------" << endl;
/// Print here metadata members
/// metadata << "xxx : " < fXXX << endl;
metadata << "+++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
}
Loading