diff --git a/src/external/DepthProfile/inc/PDepthProfile.h b/src/external/DepthProfile/inc/PDepthProfile.h
index 73b90ce0..693dfc26 100644
--- a/src/external/DepthProfile/inc/PDepthProfile.h
+++ b/src/external/DepthProfile/inc/PDepthProfile.h
@@ -44,8 +44,8 @@ class PDepthProfileGlobal
Bool_t IsValid() { return fValid; }
virtual Int_t GetEnergyIndex(const Double_t energy) { return fRgeHandler->GetEnergyIndex(energy); }
virtual Double_t GetMuonStoppingDensity(const Int_t energyIndex, const Double_t z) const { return fRgeHandler->Get_n(energyIndex, z); }
- virtual double GetStoppingProbability(double a, double b, Double_t energy) const;
- virtual double GetZmax(Double_t energy) const { return fRgeHandler->GetZmax(energy); }
+ virtual Double_t GetStoppingProbability(double a, double b, Double_t energy) const;
+ virtual Double_t GetZmax(const Double_t energy);
private:
Bool_t fValid{true};
diff --git a/src/external/DepthProfile/src/PDepthProfile.cpp b/src/external/DepthProfile/src/PDepthProfile.cpp
index dffd36f8..f11b0847 100644
--- a/src/external/DepthProfile/src/PDepthProfile.cpp
+++ b/src/external/DepthProfile/src/PDepthProfile.cpp
@@ -101,15 +101,15 @@ PDepthProfile::~PDepthProfile() {
}
//--------------------------------------------------------------------------
-// SetGlobalPart (public)
+// SetGlobalPart : public
//--------------------------------------------------------------------------
/**
*
*
- * return:
+ * @param globalPart
+ * @param idx
*
- * \param globalPart
- * \param idx
+ * @return
*/
void PDepthProfile::SetGlobalPart(std::vector &globalPart, UInt_t idx) {
fIdxGlobal = static_cast(idx);
@@ -140,22 +140,23 @@ void PDepthProfile::SetGlobalPart(std::vector &globalPart, UInt_t idx) {
}
//--------------------------------------------------------------------------
-// GlobalPartIsValid (public)
+// GlobalPartIsValid : public
//--------------------------------------------------------------------------
/**
- *
+ *
Returns true if the global part is valid. It is also checking if all
+ * muon stopping profiles have been loaded, if present.
*
- * return:
+ * @return true if the global part is valid, false otherwise.
*/
Bool_t PDepthProfile::GlobalPartIsValid() const {
return (fValid && fDepthProfileGlobal->IsValid());
}
//--------------------------------------------------------------------------
-// GetPosIdx()
+// GetPosIdx() : private
//--------------------------------------------------------------------------
/**
- *
Get the position index for a given distance 'a' and a given implantation
+ *
Get the position index for a given distance 'z' and a given implantation
* energy index.
*
* @param z distance for which the index is requested
@@ -165,7 +166,7 @@ Bool_t PDepthProfile::GlobalPartIsValid() const {
*/
Int_t PDepthProfileGlobal::GetPosIdx(const double z, const Int_t energyIdx) const
{
- Int_t idx=0;
+ Int_t idx=-1;
for (UInt_t i=0; iCalculates the stopping probability from a to b for a given implantation
@@ -188,13 +191,12 @@ Int_t PDepthProfileGlobal::GetPosIdx(const double z, const Int_t energyIdx) cons
*
* @param a starting point in distance
* @param b stopping point in distance
- * @param energy implantation energy in keV
+ * @param energy implantation energy in (eV)
*
* @return stopping probability p.
*/
-double PDepthProfileGlobal::GetStoppingProbability(double a, double b, Double_t energy) const {
+Double_t PDepthProfileGlobal::GetStoppingProbability(double a, double b, Double_t energy) const {
- energy = energy * 1000;
Int_t idx = fRgeHandler->GetEnergyIndex(energy);
if (idx == -1) {
std::cerr << "**WARNING** couldn't find energy " << energy << " (eV) in the rge-files provided." << std::endl;
@@ -205,37 +207,30 @@ double PDepthProfileGlobal::GetStoppingProbability(double a, double b, Double_t
const Int_t idx_b = GetPosIdx(b, idx); // get index for distance b from cfd(z, E)
return fCfd[idx].nn[idx_b] - fCfd[idx].nn[idx_a];
+}
-/* //as35
- double zMax = fRgeHandler->GetZmax(energy);
+//--------------------------------------------------------------------------
+// GetZmax() : public
+//--------------------------------------------------------------------------
+/**
+ * Returns the maximal distance present in an rge-dataset for a given energy.
+ *
+ * @param energy in (eV) of the rge-dataset
+ *
+ * @return maximal distance in the rge-dataset, or 1e4 if energy is not found.
+ */
+Double_t PDepthProfileGlobal::GetZmax(const Double_t energy)
+{
+ const Int_t idx=GetEnergyIndex(energy);
+ if (idx == -1) return 10000.0;
+ const Int_t maxDepthIdx = fCfd[idx].depth.size()-1;
- std::vector z;
- double x = a;
- double xMax = b;
- std::cout << " a: " << x << "xmax: " << xMax<< std::endl;
-
- while (x < xMax) {
- //z[j]=x;
- z.push_back(x);
- x++;
- }
-
- double probability = 0;
- double prob = 0;
- for (int j = a; j < b - 1; j++) {
- prob = fRgeHandler->Get_n(energy, j);
- if ((j == a) || (j == b - 1)) {
- }
- probability = probability + prob;
- }
-
- return probability;
-*/ //as35
+ return fCfd[idx].depth[maxDepthIdx];
}
//--------------------------------------------------------------------------
-// operator()
+// operator() : public
//--------------------------------------------------------------------------
/**
* calculate the stopping fraction amplitude f(E) for the given parameter:
@@ -256,6 +251,8 @@ Double_t PDepthProfile::operator()(Double_t energy, const std::vector
// number of steps: n+1
int n = (param.size() - 1) / 2;
+ energy *= 1000.0; // keV -> eV
+
double fE = param[0]*fDepthProfileGlobal->GetStoppingProbability(0.0, param[n+1], energy); // z=0..x_1
for (int i=n+1; i
double zMax = fDepthProfileGlobal->GetZmax(energy);
fE += param[n]*fDepthProfileGlobal->GetStoppingProbability(param[param.size()-1], zMax, energy); // z=x_(n-1)..infinity
-/* //as35
- std::vector parameters;
-
- if (fPreviousParam.size() == 0) {
- for (int i = 0; i < param.size(); i++) {
- fPreviousParam.push_back(param[i]);
- parameters.push_back(param[i]);
- }
- } else {
- for (int i = 0; i <(n+1); i++) {
- if (param[i]>=0 & param[i] <=1) {
- parameters.push_back(param[i]);
- } else{
- parameters.push_back(fPreviousParam[i]);
- }
- }
- if (n==1) {
- if (param[n + 1]>0) {
- parameters.push_back(param[n+1]);
- } else {
- parameters.push_back(fPreviousParam[n+1]);
- }
- } else {
- for (int i=n+1; i param[i+1]) {
- parameters.push_back(fPreviousParam[i+1]);
- } else {
- //std::cout<<"bem" << std::endl;
- parameters.push_back(param[i]);
- }
- } else {
- if (param[i] < param[i-1]) {
- parameters.push_back(fPreviousParam[i-1]);
- } else {
- //std::cout<<"bem" << std::endl;
- parameters.push_back(param[i]);
- }
- }
- }
- }
- for (int i = 0; i < param.size(); i++) {
- fPreviousParam.push_back(parameters[i]);
- std::cout << "param[i]: " << fPreviousParam[i] << std::endl;
- }
- }
-
- std::vector probability;
-
- // get stopping probability
- //int l=0;
- for (int i=0; iGetStoppingProbability(a, b, energy);
- probability.push_back(probE);
- }
-
- double fit=0;
-
- for (int j=0; j