Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:40

0001 #ifndef _CR_MATERIALEFFECTSUPDATOR_H_
0002 #define _CR_MATERIALEFFECTSUPDATOR_H_
0003 
0004 /** \class MaterialEffectsUpdator
0005  *  Interface for adding material effects during propagation.
0006  *  Updates to TrajectoryStateOnSurface are implemented 
0007  *  in this class.
0008  *  Ported from ORCA.
0009  *
0010  *  Moved "state" into an independent struct "Effect"
0011  *
0012  */
0013 
0014 #include "DataFormats/GeometrySurface/interface/Surface.h"
0015 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0016 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0017 
0018 namespace materialEffect {
0019   enum CovIndex { elos = 0, msxx = 1, msxy = 2, msyy = 3 };
0020   class Covariance {
0021   public:
0022     float operator[](CovIndex i) const { return data[i]; }
0023     float& operator[](CovIndex i) { return data[i]; }
0024     void add(AlgebraicSymMatrix55& cov) const {
0025       cov(0, 0) += data[elos];
0026       cov(1, 1) += data[msxx];
0027       cov(1, 2) += data[msxy];
0028       cov(2, 2) += data[msyy];
0029     }
0030     Covariance& operator+=(Covariance const& cov) {
0031       for (int i = 0; i != 4; ++i)
0032         data[i] += cov.data[i];
0033       return *this;
0034     }
0035 
0036   private:
0037     float data[4] = {0};
0038   };
0039 
0040   struct Effect {
0041     float weight = 1.f;
0042     // Change in |p| from material effects.
0043     float deltaP = 0;
0044     // Contribution to covariance matrix (in local co-ordinates) from material effects.
0045     Covariance deltaCov;
0046     void combine(Effect const& e1, Effect const& e2) {
0047       weight *= e1.weight * e2.weight;
0048       deltaP += e1.deltaP + e2.deltaP;
0049       deltaCov += e1.deltaCov;
0050       deltaCov += e2.deltaCov;
0051     }
0052   };
0053 
0054 }  // namespace materialEffect
0055 
0056 class MaterialEffectsUpdator {
0057 public:
0058   typedef materialEffect::Covariance Covariance;
0059   typedef materialEffect::Effect Effect;
0060   typedef materialEffect::CovIndex CovIndex;
0061 
0062   /** Constructor with explicit mass hypothesis
0063    */
0064   MaterialEffectsUpdator(float mass);
0065   virtual ~MaterialEffectsUpdator();
0066 
0067   /** Updates TrajectoryStateOnSurface with material effects
0068    *    (momentum and covariance matrix are potentially affected.
0069    */
0070   virtual TrajectoryStateOnSurface updateState(const TrajectoryStateOnSurface& TSoS,
0071                                                const PropagationDirection propDir) const;
0072 
0073   /** Updates in place TrajectoryStateOnSurface with material effects
0074    *    (momentum and covariance matrix are potentially affected)
0075    *  Will return 'false' if the 'updateState' would have returned an invalid TSOS
0076    *  Note that the TSoS might be very well unchanged from this method 
0077    *  (just like 'updateState' can return the same TSOS)
0078    */
0079   virtual bool updateStateInPlace(TrajectoryStateOnSurface& TSoS, const PropagationDirection propDir) const;
0080 
0081   /** Particle mass assigned at construction.
0082    */
0083   inline float mass() const { return theMass; }
0084 
0085   virtual MaterialEffectsUpdator* clone() const = 0;
0086 
0087   // here comes the actual computation of the values
0088   virtual void compute(const TrajectoryStateOnSurface&, const PropagationDirection, Effect& effect) const = 0;
0089 
0090 private:
0091   float theMass;
0092 };
0093 
0094 #endif