Go to the documentation of this file.00001
00002
00003
00004
00005 #include "CondFormats/EcalCorrections/interface/EcalShowerContainmentCorrections.h"
00006 #include <DataFormats/EcalDetId/interface/EBDetId.h>
00007 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00008
00009
00010
00011 const EcalShowerContainmentCorrections::Coefficients
00012 EcalShowerContainmentCorrections::correctionCoefficients(const EBDetId& centerxtal) const
00013 {
00014 GroupMap::const_iterator iter = groupmap_.find(centerxtal.rawId());
00015
00016 if (iter!=groupmap_.end()) {
00017 int group =iter->second;
00018 return coefficients_[group-1];
00019 }
00020
00021 edm::LogError("ShowerContaiment Correction not found");
00022 return Coefficients();
00023
00024 }
00025
00026
00027 void
00028 EcalShowerContainmentCorrections::fillCorrectionCoefficients(const EBDetId& xtal, int group,const Coefficients& coefficients){
00029
00030
00031 if (groupmap_.find(xtal)!=groupmap_.end()) return;
00032 groupmap_[xtal]=group;
00033
00034
00035 if (coefficients_.size()<(unsigned int)(group)) {
00036 coefficients_.resize(group);
00037 coefficients_[group-1]=coefficients;
00038 }
00039
00040
00041
00042
00043 }
00044
00045
00046 void
00047 EcalShowerContainmentCorrections::fillCorrectionCoefficients(const int supermodule, const int module,
00048 const Coefficients& coefficients){
00049
00050
00051 if (module>EBDetId::kModulesPerSM) {
00052 edm::LogError("Invalid Module Number");
00053 return;
00054 }
00055
00056
00057
00058 const int kModuleLow[]={1,501,901,1301};
00059 const int kModuleHigh[]={500,900,1300,1700};
00060
00061 for (int xtal =kModuleLow[module-1] ; xtal <= kModuleHigh[module-1];++xtal){
00062 EBDetId detid(supermodule,xtal,EBDetId::SMCRYSTALMODE);
00063 fillCorrectionCoefficients(detid,module,coefficients);
00064 }
00065
00066 }
00067
00069 const double
00070 EcalShowerContainmentCorrections::correctionXY(const EBDetId& xtal,
00071 double position,
00072 EcalShowerContainmentCorrections::Direction dir,
00073 EcalShowerContainmentCorrections::Type type
00074 ) const{
00075
00076 GroupMap::const_iterator iter=groupmap_.find(xtal);
00077 if (iter==groupmap_.end()) return -1;
00078
00079 int group=iter->second;
00080 EcalShowerContainmentCorrections::Coefficients coeff=coefficients_[group-1];
00081
00082 int offset=0;
00083
00084 if (dir==eY) offset+= 2* Coefficients::kPolynomialDegree;
00085 if (position<0) offset+= Coefficients::kPolynomialDegree;
00086 if (type==e5x5) offset+= 4* Coefficients::kPolynomialDegree;
00087
00088 double corr=0;
00089
00090 for ( int i=offset;
00091 i<offset+Coefficients::kPolynomialDegree;
00092 ++i){
00093 corr+= coeff.data[i] * pow( position ,i-offset) ;
00094 }
00095
00096 return corr;
00097 }
00098
00099 const double
00100 EcalShowerContainmentCorrections::correction3x3(const EBDetId& xtal,
00101 const math::XYZPoint& pos) const {
00102
00103 double x= pos.X()*10;
00104 double y= pos.Y()*10;
00105
00106 double corrx = correctionXY(xtal,x,eX,e3x3);
00107 double corry = correctionXY(xtal,y,eY,e3x3);
00108
00109 return corrx*corry;
00110 }
00111
00112
00113
00114
00115 const double
00116 EcalShowerContainmentCorrections::correction5x5(const EBDetId& xtal,
00117 const math::XYZPoint& pos) const {
00118
00119 double x= pos.X()*10;
00120 double y= pos.Y()*10;
00121
00122 double corrx = correctionXY(xtal,x,eX,e5x5);
00123 double corry = correctionXY(xtal,y,eY,e5x5);
00124
00125 return corrx*corry;
00126 }
00127