Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025
00026
00027 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00028 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00029 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00030
00031
00032 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00033 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00034 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00035
00036 #include "RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EcalDeadChannelRecoveryProducers.h"
00037 #include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EcalDeadChannelRecoveryAlgos.h"
00038
00039
00040 #include <string>
00041 using namespace cms;
00042 using namespace std;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 EcalDeadChannelRecoveryProducers::EcalDeadChannelRecoveryProducers(const edm::ParameterSet& ps)
00058 {
00059
00060
00061 CorrectDeadCells_ = ps.getParameter<bool>("CorrectDeadCells");
00062 CorrectionMethod_ = ps.getParameter<std::string>("CorrectionMethod");
00063 hitProducer_ = ps.getParameter<std::string>("hitProducer");
00064 hitCollection_ = ps.getParameter<std::string>("hitCollection");
00065 reducedHitCollection_ = ps.getParameter<std::string>("reducedHitCollection");
00066 DeadChannelFileName_ = ps.getParameter<std::string>("DeadChannelsFile");
00067 Sum8GeVThreshold_= ps.getParameter<double>("Sum8GeVThreshold");
00068
00069 produces< EcalRecHitCollection >(reducedHitCollection_);
00070 }
00071
00072
00073 EcalDeadChannelRecoveryProducers::~EcalDeadChannelRecoveryProducers()
00074 {
00075
00076
00077
00078
00079 }
00080
00081
00082
00083
00084
00085
00086
00087 void
00088 EcalDeadChannelRecoveryProducers::produce(edm::Event& evt, const edm::EventSetup& iSetup)
00089 {
00090 using namespace edm;
00091
00092 edm::ESHandle<CaloTopology> theCaloTopology;
00093 iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
00094
00095
00096 edm::Handle<EcalRecHitCollection> rhcHandle;
00097 evt.getByLabel(hitProducer_, hitCollection_, rhcHandle);
00098 if (!(rhcHandle.isValid()))
00099 {
00100 std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
00101 return;
00102 }
00103 const EcalRecHitCollection* hit_collection = rhcHandle.product();
00104
00105
00106 std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection);
00107
00108 EcalDeadChannelRecoveryAlgos *DeadChannelCorrector = new EcalDeadChannelRecoveryAlgos(theCaloTopology.product());
00109
00110
00111 std::vector<EBDetId>::const_iterator DeadCell;
00112
00113
00114
00115
00116 for(EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) {
00117 std::vector<EBDetId>::const_iterator CheckDead = ChannelsDeadID.begin();
00118 bool OverADeadRecHit=false;
00119 while(CheckDead<ChannelsDeadID.end()){
00120 if(it->detid()==*CheckDead){OverADeadRecHit=true;break;}
00121 CheckDead++;
00122 }
00123 if(!OverADeadRecHit)redCollection->push_back( *it );
00124 }
00125 for(DeadCell=ChannelsDeadID.begin();DeadCell<ChannelsDeadID.end();DeadCell++){
00126 EcalRecHit NewRecHit = DeadChannelCorrector->Correct(*DeadCell,hit_collection,CorrectionMethod_,Sum8GeVThreshold_);
00127 redCollection->push_back( NewRecHit );
00128 }
00129
00130
00131
00132
00133 delete DeadChannelCorrector ;
00134
00135 evt.put(redCollection, reducedHitCollection_);
00136
00137 }
00138
00139
00140
00141
00142 void
00143 EcalDeadChannelRecoveryProducers::beginJob()
00144 {
00145 FILE* DeadCha;
00146 printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str());
00147 DeadCha = fopen(DeadChannelFileName_.c_str(),"r");
00148
00149 int fileStatus=0;
00150 int ieta=-10000;
00151 int iphi=-10000;
00152 while(fileStatus != EOF) {
00153 fileStatus = fscanf(DeadCha,"%d %d\n",&ieta,&iphi);
00154
00155 if(ieta==-10000||iphi==-10000){std::cout << "Problem reading Dead Channels file "<<std::endl;break;}
00156 EBDetId cell(ieta,iphi);
00157 ChannelsDeadID.push_back(cell);
00158 }
00159 fclose(DeadCha);
00160
00161
00162 }
00163
00164
00165 void
00166 EcalDeadChannelRecoveryProducers::endJob() {
00167 }
00168
00169
00170 DEFINE_FWK_MODULE(EcalDeadChannelRecoveryProducers);