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