Go to the documentation of this file.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, std::string algo_, double Sum8Cut)
00074 {
00075 double NewEnergy=0.0;
00076
00077 double MNxN[121];
00078 int IndDeadChannel[1]={-1};
00079
00080 double sum8 = MakeNxNMatrice(Id,hit_collection,IndDeadChannel,MNxN);
00081
00082 if(algo_=="Spline"){
00083
00084 if(sum8>Sum8Cut){
00085 if(IndDeadChannel[0]>0)NewEnergy = CorrectDeadChannelsClassic(MNxN,Id.ieta());
00086 }
00087 }else if(algo_=="NeuralNetworks"){
00088 if(sum8>Sum8Cut){
00089 if(IndDeadChannel[0]>0)NewEnergy = CorrectDeadChannelsNN(MNxN);
00090 }
00091 }
00092
00093
00094
00095
00096
00097 uint32_t flag = 0;
00098 if ( NewEnergy > 5. * sum8 ) {
00099 NewEnergy = 0;
00100
00101 }
00102
00103 EcalRecHit NewHit(Id,NewEnergy,0, flag);
00104 return NewHit;
00105
00106 }
00107
00108
00109 EcalRecHit EcalDeadChannelRecoveryAlgos::Correct(const EBDetId Id, const EcalRecHitCollection* hit_collection, std::string algo_, double Sum8Cut)
00110 {
00111 return correct(Id, hit_collection, algo_, Sum8Cut);
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121 double EcalDeadChannelRecoveryAlgos::MakeNxNMatrice(EBDetId itID,const EcalRecHitCollection* hit_collection, int *IndDeadChannel, double *MNxN){
00122
00123
00124
00125
00126 for(int i=0; i<121;i++)MNxN[i]=0.0;
00127
00128
00129
00130
00131 const CaloSubdetectorTopology* topology=calotopo->getSubdetectorTopology(DetId::Ecal,EcalBarrel);
00132 int size =5;
00133 std::vector<DetId> NxNaroundDC = topology->getWindow(itID,size,size);
00134
00135
00136
00137
00138 std::vector<DetId>::const_iterator theCells;
00139
00140 EBDetId EBCellMax = itID;
00141 double EnergyMax = 0.0;
00142
00143 for(theCells=NxNaroundDC.begin();theCells<NxNaroundDC.end();theCells++){
00144 EBDetId EBCell = EBDetId(*theCells);
00145
00146
00147 if(!EBCell.null()){
00148 EcalRecHitCollection::const_iterator goS_it = hit_collection->find(EBCell);
00149 if( goS_it != hit_collection->end() && goS_it->energy()>=EnergyMax){EnergyMax=goS_it->energy(); EBCellMax = EBCell;}
00150 }else{
00151 continue;
00152 }
00153 }
00154 if(EBCellMax.null()){return 0;}
00155
00156
00157
00158
00159
00160
00162
00163
00164 int FixedSize =11;
00165 std::vector<DetId> NxNaroundMaxCont = topology->getWindow(EBCellMax,FixedSize,FixedSize);
00166
00167 double ESUMis=0.0;
00168 int theIndex=0;
00169
00170 std::vector<DetId>::const_iterator itCells;
00171 for(itCells=NxNaroundMaxCont.begin();itCells<NxNaroundMaxCont.end();itCells++){
00172 EBDetId EBitCell = EBDetId(*itCells);
00173 int CReta = EBitCell.ieta();
00174 int CRphi = EBitCell.iphi();
00175
00176 double Energy = 0.0;
00177 if(!EBitCell.null()){
00178 EcalRecHitCollection::const_iterator goS_it = hit_collection->find(EBitCell);
00179 if( goS_it != hit_collection->end() ) Energy=goS_it->energy();
00180 }
00181
00182
00183
00184
00185 int ietaCorr = 0;
00186 if((CReta * EBCellMax.ieta()) < 0 && EBCellMax.ieta()>0 )ietaCorr= -1;
00187 if((CReta * EBCellMax.ieta()) < 0 && EBCellMax.ieta()<0 )ietaCorr= 1;
00188 if((CReta * EBCellMax.ieta()) > 0 )ietaCorr= 0;
00189 int ieta = -( (CReta -ietaCorr) - EBCellMax.ieta() ) + int((FixedSize - 1)/2);
00190
00191 int iphiCorr = 0;
00192 if((CRphi - EBCellMax.iphi())> 50)iphiCorr= 360;
00193 if((CRphi - EBCellMax.iphi())<-50)iphiCorr=-360;
00194 int iphi = CRphi - EBCellMax.iphi() - iphiCorr + int((FixedSize - 1)/2);
00195
00196 int MIndex = ieta+iphi*FixedSize;
00197 if(abs(CReta)<=85)
00198 MNxN[MIndex]=Energy;
00199 if(EBitCell == itID)IndDeadChannel[0]= MIndex;
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 if(theIndex>=48 && theIndex<=50)ESUMis += Energy;
00211 if(theIndex>=59 && theIndex<=61)ESUMis += Energy;
00212 if(theIndex>=70 && theIndex<=72)ESUMis += Energy;
00213
00214 theIndex++;
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00233
00234
00235
00236
00237
00238 return ESUMis;
00239 }
00240