Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:08

0001 #ifndef CondFormats_EcalGlobalShowerContainmentCorrectionsVsEta_h
0002 #define CondFormats_EcalGlobalShowerContainmentCorrectionsVsEta_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     CondFormats
0006 // Class  :     EcalGlobalShowerContainmentCorrectionsVsEta
0007 //
0008 /**\class EcalGlobalShowerContainmentCorrectionsVsEta EcalGlobalShowerContainmentCorrectionsVsEta.h src/CondFormats/interface/EcalGlobalShowerContainmentCorrectionsVsEta.h
0009 
0010  * Description: Holds the coefficients of a polynomial that describes variation of the global containment effect as afunction of eta
0011  *
0012  * Usage example(for real code see 
0013  * CalibCalorimetry/EcalCorrectionModules/test) : 
0014  * \code
0015 
0016  ESHandle<EcalGlobalShowerContainmentCorrectionsVsEta> pGapCorr;
0017  iESetup.get<EcalGlobalShowerContainmentCorrectionsVsEtaRcd>().get(pGapCorr);
0018   
0019  double correction3x3 = pGapCorr->correction3x3(centerXtal,mathpoint);
0020  double correction5x5 = pGapCorr->correction5x5(centerXtal,mathpoint);
0021 
0022 
0023  * \endcode
0024  * \author       Paolo Meridiani
0025  * \id           $Id: EcalGlobalShowerContainmentCorrectionsVsEta.h,v 1.1 2007/07/13 17:37:06 meridian Exp $
0026 */
0027 
0028 #include "CondFormats/Serialization/interface/Serializable.h"
0029 
0030 #include <vector>
0031 #include <algorithm>
0032 #include <map>
0033 
0034 class DetId;
0035 
0036 class EcalGlobalShowerContainmentCorrectionsVsEta {
0037 public:
0038   /// Structure defining the container for correction coefficients
0039   /**  data[0-2]    : 3x3
0040    *   data[3-5]    : 5x5
0041    */
0042 
0043   struct Coefficients {
0044     Coefficients() {
0045       for (unsigned int i = 0; i < Coefficients::kSize; ++i)
0046         data[i] = 0;
0047     }
0048     Coefficients(const Coefficients& coeff) { std::copy(coeff.data, coeff.data + Coefficients::kSize, data); }
0049 
0050     Coefficients& operator=(const Coefficients& coeff) {
0051       if (this == &coeff)
0052         return *this;
0053       std::copy(coeff.data, coeff.data + Coefficients::kSize, data);
0054       return *this;
0055     }
0056 
0057     ///The degree of the polynomial used as correction function plus one
0058     static const int kCoefficients = 3;
0059 
0060     ///Number of types of correction:  3x3, 5x5
0061     static const int kNTypes = 2;
0062     static const unsigned int kSize = kCoefficients * kNTypes;
0063 
0064     double data[kSize];
0065 
0066     COND_SERIALIZABLE;
0067   };
0068 
0069   /// The correction factor for 3x3 matrix
0070   /** @param pos is the distance in cm from the center of the xtal
0071    *  as calculated in RecoEcal/EgammaCoreTools/interface/PositionCalc.h 
0072    *  The valid return value is in the range (0,1] (divide by this
0073    *  value to apply the correction)
0074    *  Returns -1 if correction is not avaiable for that xtal*/
0075   const double correction3x3(const DetId& xtal) const;
0076 
0077   /// The correction factor for 5x5 matrix
0078   /** @param pos is the distance in cm from the center of the xtal
0079    *  as calculated in RecoEcal/EgammaCoreTools/interface/PositionCalc.h 
0080    *  The return value is in the range (0,1] (divide by this
0081    *  value to apply the correction)
0082    *  Returns -1 if correction is not avaiable for that xtal*/
0083   const double correction5x5(const DetId& xtal) const;
0084 
0085   /// Get the correction coefficients for the given xtal
0086   const Coefficients correctionCoefficients() const;
0087 
0088   /// Fill the correction coefficients
0089   void fillCorrectionCoefficients(const Coefficients& coefficients);
0090 
0091 private:
0092   enum Type { e3x3, e5x5 };
0093 
0094   /** Calculate the correction for the given direction and type  */
0095   const double correction(const DetId& xtal, Type type) const;
0096 
0097   /// Holds the coeffiecients. The index corresponds to the group
0098   Coefficients coefficients_;
0099 
0100   COND_SERIALIZABLE;
0101 };
0102 
0103 #endif