diff --git a/inc/LauBlind.hh b/inc/LauBlind.hh index 8298c2a..60e5849 100644 --- a/inc/LauBlind.hh +++ b/inc/LauBlind.hh @@ -1,113 +1,114 @@ /* Copyright 2015 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauBlind.hh \brief File containing declaration of LauBlind class. */ /*! \class LauBlind \brief Class for blinding and unblinding a number based on a blinding string. Numbers are blinded by applying an offset. The blinding string is converted to an integer using TMath::Hash and this integer is used to seed a TRandom3. The offset is sampled from a Gaussian of defined width using the seeded TRandom3. */ #ifndef LAU_BLIND #define LAU_BLIND #include "TString.h" +#include class LauBlind final { public: //! Default constructor /*! This is purely to allow I/O to succeed, should not generally be used */ LauBlind() = default; //! Constructor /*! \param [in] blindingStr the blinding string \param [in] width the width of the Gaussian for sampling the offset \param [in] flipSign activate possible random sign flip (off by default) */ LauBlind(const TString& blindingStr, const Double_t width, const Bool_t flipSign = kFALSE); //! Obtain the blinded value /*! \param [in] val the unblinded value \return the blinded value */ inline Double_t blind(const Double_t val) const { return flipFactor_[flip_] * val + offset_; } //! Obtain the unblinded value /*! \param [in] val the blinded value \return the unblinded value */ inline Double_t unblind(const Double_t val) const { return flipFactor_[flip_] * (val - offset_); } //! Obtain the blinding string /*! \return the blinding string */ inline const TString& blindingString() const { return blindingString_; } //! Obtain the Gaussian width /*! \return the Gaussian width */ inline Double_t blindingWidth() const { return blindingWidth_; } //! Obtain the sign-flip setting /*! \return the sign-flip setting */ inline Double_t flipSign() const { return flipSign_; } private: //! The blinding string const TString blindingString_; //! The Gaussian width const Double_t blindingWidth_{0.0}; //! The flip sign setting const Bool_t flipSign_{kFALSE}; //! Array to hold +1/-1 factors for efficient implementation of sign flip const std::array flipFactor_{1.0,-1.0}; //! The offset used to blind the value Double_t offset_{0.0}; //! Whether to flip sign in blinding Bool_t flip_{kFALSE}; ClassDef(LauBlind, 1) }; #endif