00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00025 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00026 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00027 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00028 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00029 #include "Geometry/CaloTopology/interface/EcalEndcapTopology.h"
00030 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
00031 #include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h"
00032 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00033 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00034 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
00035
00036
00037
00038 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00039 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00040 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00041
00042 #include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EcalDeadChannelRecoveryAlgos.h"
00043 #include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/CorrectDeadChannelsClassic.cc"
00044 #include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/CorrectDeadChannelsNN.cc"
00045
00046 #include <string>
00047 using namespace cms;
00048 using namespace std;
00049
00050
00051 EcalDeadChannelRecoveryAlgos::EcalDeadChannelRecoveryAlgos(const CaloTopology theCaloTopology)
00052
00053 {
00054
00055 calotopo = theCaloTopology;
00056 }
00057
00058
00059 EcalDeadChannelRecoveryAlgos::~EcalDeadChannelRecoveryAlgos()
00060 {
00061
00062
00063
00064
00065 }
00066
00067
00068
00069
00070
00071
00072
00073 EcalRecHit EcalDeadChannelRecoveryAlgos::Correct(const EBDetId Id, const EcalRecHitCollection* hit_collection, string algo_, double Sum8Cut)
00074 {
00075 double NewEnergy=0.0;
00076
00077 double MNxN[121];
00078
00079 if(algo_=="Spline"){
00080
00081 if(MakeNxNMatrice(Id,hit_collection,MNxN)>Sum8Cut){
00082 NewEnergy = CorrectDeadChannelsClassic(MNxN,Id.ieta());
00083 }
00084 }else if(algo_=="NeuralNetworks"){
00085
00086 if(MakeNxNMatrice(Id,hit_collection,MNxN)>Sum8Cut){
00087 NewEnergy = CorrectDeadChannelsNN(MNxN);
00088 }
00089 }
00090
00091
00092 EcalRecHit NewHit(Id,NewEnergy,0);
00093 return NewHit;
00094
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 double EcalDeadChannelRecoveryAlgos::MakeNxNMatrice(EBDetId itID,const EcalRecHitCollection* hit_collection, double *MNxN){
00106
00107
00108
00109
00110 for(int i=0; i<121;i++)MNxN[i]=0.0;
00111
00112
00113
00114
00115 const CaloSubdetectorTopology* topology=calotopo.getSubdetectorTopology(DetId::Ecal,EcalBarrel);
00116 int size =5;
00117 std::vector<DetId> NxNaroundDC = topology->getWindow(itID,size,size);
00118
00119
00120
00121 vector<DetId>::const_iterator theCells;
00122
00123 EBDetId EBCellMax = itID;
00124 double EnergyMax = 0.0;
00125
00126 for(theCells=NxNaroundDC.begin();theCells<NxNaroundDC.end();theCells++){
00127 EBDetId EBCell = EBDetId(*theCells);
00128
00129
00130 if(!EBCell.null()){
00131 EcalRecHitCollection::const_iterator goS_it = hit_collection->find(EBCell);
00132 if( goS_it != hit_collection->end() && goS_it->energy()>=EnergyMax){EnergyMax=goS_it->energy(); EBCellMax = EBCell;}
00133 }else{
00134 continue;
00135 }
00136 }
00137 if(EBCellMax.null()){cout<<" Error No maximum found around dead channel, no corrections applied"<<endl;return 0;}
00138
00139
00140
00141
00142
00143
00145
00146
00147 int FixedSize =11;
00148 std::vector<DetId> NxNaroundMaxCont = topology->getWindow(EBCellMax,FixedSize,FixedSize);
00149
00150 double ESUMis=0.0;
00151 int theIndex=0;
00152
00153 vector<DetId>::const_iterator itCells;
00154 for(itCells=NxNaroundMaxCont.begin();itCells<NxNaroundMaxCont.end();itCells++){
00155 EBDetId EBitCell = EBDetId(*itCells);
00156 int CReta = EBitCell.ieta();
00157 int CRphi = EBitCell.iphi();
00158
00159 double Energy = 0.0;
00160 if(!EBitCell.null()){
00161 EcalRecHitCollection::const_iterator goS_it = hit_collection->find(EBitCell);
00162 if( goS_it != hit_collection->end() ) Energy=goS_it->energy();
00163 }
00164
00165
00166
00167
00168 int ietaCorr = 0;
00169 if((CReta * EBCellMax.ieta()) < 0 && EBCellMax.ieta()>0 )ietaCorr= -1;
00170 if((CReta * EBCellMax.ieta()) < 0 && EBCellMax.ieta()<0 )ietaCorr= 1;
00171 if((CReta * EBCellMax.ieta()) > 0 )ietaCorr= 0;
00172 int ieta = -( (CReta -ietaCorr) - EBCellMax.ieta() ) + int((FixedSize - 1)/2);
00173
00174 int iphiCorr = 0;
00175 if((CRphi - EBCellMax.iphi())> 50)iphiCorr= 360;
00176 if((CRphi - EBCellMax.iphi())<-50)iphiCorr=-360;
00177 int iphi = CRphi - EBCellMax.iphi() - iphiCorr + int((FixedSize - 1)/2);
00178
00179 int MIndex = ieta+iphi*FixedSize;
00180 if(abs(CReta)<=85)
00181 MNxN[MIndex]=Energy;
00182
00183
00184
00185
00186
00187
00188
00189
00190 if(theIndex>=36 && theIndex<=40)ESUMis += Energy;
00191 if(theIndex>=47 && theIndex<=51)ESUMis += Energy;
00192 if(theIndex>=58 && theIndex<=62)ESUMis += Energy;
00193 if(theIndex>=69 && theIndex<=73)ESUMis += Energy;
00194 if(theIndex>=80 && theIndex<=84)ESUMis += Energy;
00195 theIndex++;
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00214
00215
00216
00217
00218
00219 return ESUMis;
00220 }
00221