Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:28

0001 /* Copyright 2008-2014, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 /** @addtogroup RKTrackRep
0021  * @{
0022  */
0023 
0024 #ifndef genfit_MaterialEffects_h
0025 #define genfit_MaterialEffects_h
0026 
0027 #include "RKTools.h"
0028 #include "AbsMaterialInterface.h"
0029 
0030 #include <iostream>
0031 #include <vector>
0032 
0033 #include <TVector3.h>
0034 
0035 
0036 namespace genfit {
0037 
0038 /** @brief Stepper and energy loss/noise matrix calculation
0039  *
0040  *  @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
0041  *  @author Sebastian Neubert  (Technische Universit&auml;t M&uuml;nchen, original author)
0042  *  @author Johannes Rauch  (Technische Universit&auml;t M&uuml;nchen, author)
0043  *
0044  *  It provides functionality to limit the stepsize of an extrapolation in order not to
0045  *  exceed a specified maximum momentum loss. After propagation, the energy loss
0046  *  for the given length and (optionally) the noise matrix can be calculated.
0047  *  You have to set which energy-loss and noise mechanisms you want to use.
0048  *  At the moment, per default all energy loss and noise options are ON.
0049  */
0050 class MaterialEffects {
0051 
0052  private:
0053 
0054   MaterialEffects();
0055   virtual ~MaterialEffects();
0056 
0057   static MaterialEffects* instance_;
0058 
0059 
0060 public:
0061 
0062   static MaterialEffects* getInstance();
0063   static void destruct();
0064 
0065   //! set the material interface here. Material interface classes must be derived from AbsMaterialInterface.
0066   void init(AbsMaterialInterface* matIfc);
0067   bool isInitialized() { return materialInterface_ != nullptr; }
0068 
0069   void setNoEffects(bool opt = true) {noEffects_ = opt;}
0070 
0071   void setEnergyLossBetheBloch(bool opt = true) {energyLossBetheBloch_ = opt; noEffects_ = false;}
0072   void setNoiseBetheBloch(bool opt = true) {noiseBetheBloch_ = opt; noEffects_ = false;}
0073   void setNoiseCoulomb(bool opt = true) {noiseCoulomb_ = opt; noEffects_ = false;}
0074   void setEnergyLossBrems(bool opt = true) {energyLossBrems_ = opt; noEffects_ = false;}
0075   void setNoiseBrems(bool opt = true) {noiseBrems_ = opt; noEffects_ = false;}
0076   void ignoreBoundariesBetweenEqualMaterials(bool opt = true) {ignoreBoundariesBetweenEqualMaterials_ = opt;}
0077   void setMagCharge(double magCharge) {mag_charge_ = magCharge;} 
0078 
0079   /** @brief Select the multiple scattering model that will be used during track fit.
0080    *
0081    *  At the moment two model are available GEANE and Highland. GEANE is the model was was present in Genfit first.
0082    *  Note that using this function has no effect if setNoiseCoulomb(false) is set.
0083    */
0084   void setMscModel(const std::string& modelName);
0085 
0086 
0087   //! Calculates energy loss in the traveled path, optional calculation of noise matrix
0088   double effects(const std::vector<RKStep>& steps,
0089                  int materialsFXStart,
0090                  int materialsFXStop,
0091                  const double& mom,
0092                  const int& pdg,
0093                  M7x7* noise = nullptr);
0094 
0095   /**  @brief Returns maximum length so that a specified momentum loss will not be exceeded.
0096    *
0097    * The stepper returns the maximum length that the particle may travel, so that a specified relative momentum loss will not be exceeded,
0098    * or the next material boundary is reached. The material crossed are stored together with their stepsizes.
0099   */
0100   void stepper(const RKTrackRep* rep,
0101                M1x7& state7,
0102                const double& mom, // momentum
0103                double& relMomLoss, // relative momloss for the step will be added
0104                const int& pdg,
0105                Material& currentMaterial,
0106                StepLimits& limits,
0107                bool varField = true);
0108 
0109   void setDebugLvl(unsigned int lvl = 1);
0110 
0111 
0112   void drawdEdx(int pdg = 11);
0113 
0114  private:
0115 
0116   //! sets charge_, mass_
0117   void getParticleParameters();
0118 
0119   void getMomGammaBeta(double Energy,
0120                        double& mom, double& gammaSquare, double& gamma, double& betaSquare) const;
0121 
0122   //! Returns momentum loss
0123   /**
0124    * Also sets dEdx_ and E_.
0125    */
0126   double momentumLoss(double stepSign, double mom, bool linear);
0127 
0128   //! Calculate dEdx for a given energy
0129   double dEdx(double Energy);
0130 
0131 
0132   //! Uses Bethe Bloch formula to calculate dEdx.
0133   double dEdxBetheBloch(double betaSquare, double gamma, double gammasquare) const;
0134 
0135   //! calculation of energy loss straggeling
0136   /**  For the energy loss straggeling, different formulas are used for different regions:
0137     *  - Vavilov-Gaussian regime
0138     *  - Urban/Landau approximation
0139     *  - truncated Landau distribution
0140     *  - Urban model
0141     *
0142     *  Needs dEdx_, which is calculated in momentumLoss, so it has to be called afterwards!
0143     */
0144   void noiseBetheBloch(M7x7& noise, double mom, double betaSquare, double gamma, double gammaSquare) const;
0145 
0146   //! calculation of multiple scattering
0147   /**  This function first calcuates a MSC variance based on the current material and step length
0148    * 2 different formulas for the MSC variance are implemeted. One can select the formula via "setMscModel".
0149    * With the MSC variance and the current direction of the track a full 7D noise matrix is calculated.
0150    * This noise matrix is the additional noise at the end of fStep in the 7D globa cooridnate system
0151    * taking even the (co)variances of the position coordinates into account.
0152    * 
0153     */
0154   void noiseCoulomb(M7x7& noise,
0155                     const M1x3& direction, double momSquare, double betaSquare) const;
0156 
0157   //! Returns dEdx
0158   /** Can be called with any pdg, but only calculates dEdx for electrons and positrons (otherwise returns 0).
0159     * Uses a gaussian approximation (Bethe-Heitler formula with Migdal corrections).
0160     * For positrons, dEdx is weighed with a correction factor.
0161   */
0162   double dEdxBrems(double mom) const;
0163 
0164   //! calculation of energy loss straggeling
0165   /** Can be called with any pdg, but only calculates straggeling for electrons and positrons.
0166    */
0167   void noiseBrems(M7x7& noise, double momSquare, double betaSquare) const;
0168 
0169 
0170 
0171   bool noEffects_;
0172 
0173   bool energyLossBetheBloch_;
0174   bool noiseBetheBloch_;
0175   bool noiseCoulomb_;
0176   bool energyLossBrems_;
0177   bool noiseBrems_;
0178 
0179   bool ignoreBoundariesBetweenEqualMaterials_;
0180 
0181   const double me_; // electron mass (GeV)
0182 
0183   double stepSize_; // stepsize
0184 
0185   // cached values for energy loss and noise calculations
0186   double dEdx_; // Runkge Kutta dEdx
0187   double E_; // Runge Kutta Energy
0188   double matDensity_;
0189   double matZ_;
0190   double matA_;
0191   double radiationLength_;
0192   double mEE_; // mean excitation energy
0193 
0194   int pdg_;
0195   double charge_;
0196   double mag_charge_; // in units of e+
0197   double mass_;
0198 
0199   int mscModelCode_; /// depending on this number a specific msc model is chosen in the noiseCoulomb function.
0200 
0201   AbsMaterialInterface* materialInterface_;
0202 
0203   unsigned int debugLvl_;
0204 
0205   // ClassDef(MaterialEffects, 1);
0206 
0207 };
0208 
0209 } /* End of namespace genfit */
0210 /** @} */
0211 
0212 #endif // genfit_MaterialEffects_h