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/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00026 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00027 #include "Geometry/CaloTopology/interface/EcalEndcapTopology.h"
00028 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
00029 #include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.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
00037 #include "RecoCaloTools/EcalChannelKiller/interface/EcalChannelKiller.h"
00038
00039 #include <string>
00040 #include <cstdio>
00041 using namespace cms;
00042 using namespace std;
00043
00044
00045
00046
00047
00048 EcalChannelKiller::EcalChannelKiller(const edm::ParameterSet& ps)
00049 {
00050
00051 hitProducer_ = ps.getParameter<std::string>("hitProducer");
00052 hitCollection_ = ps.getParameter<std::string>("hitCollection");
00053 reducedHitCollection_ = ps.getParameter<std::string>("reducedHitCollection");
00054 DeadChannelFileName_ = ps.getParameter<std::string>("DeadChannelsFile");
00055
00056 produces< EcalRecHitCollection >(reducedHitCollection_);
00057
00058
00059 }
00060
00061
00062 EcalChannelKiller::~EcalChannelKiller()
00063 {
00064
00065
00066
00067
00068 }
00069
00070
00071
00072
00073
00074
00075
00076 void
00077 EcalChannelKiller::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00078 {
00079 using namespace edm;
00080
00081
00082 edm::Handle<EcalRecHitCollection> rhcHandle;
00083 iEvent.getByLabel(hitProducer_, hitCollection_, rhcHandle);
00084 if (!(rhcHandle.isValid()))
00085 {
00086
00087 return;
00088 }
00089 const EcalRecHitCollection* hit_collection = rhcHandle.product();
00090
00091 int nRed = 0;
00092
00093
00094 std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection);
00095
00096
00097 for(EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) {
00098
00099 double NewEnergy =it->energy();
00100 bool ItIsDead=false;
00101
00102 std::vector<EBDetId>::const_iterator DeadCell;
00103 for(DeadCell=ChannelsDeadID.begin();DeadCell<ChannelsDeadID.end();DeadCell++){
00104 if(it->detid()==*DeadCell){
00105 DetId itID = it->id();
00106
00107 ItIsDead=true;
00108 NewEnergy =0.;
00109 nRed++;
00110
00111 }
00112 }
00113
00114
00115
00116
00117
00118
00119 if(!ItIsDead){
00120 EcalRecHit NewHit(it->id(),NewEnergy,it->time());
00121 redCollection->push_back( NewHit );
00122 }
00123 }
00124
00125
00126 iEvent.put(redCollection, reducedHitCollection_);
00127
00128 }
00129
00130
00131
00132
00133
00134 void
00135 EcalChannelKiller::beginJob()
00136 {
00137
00138
00139 FILE* DeadCha;
00140 printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str());
00141 DeadCha = fopen(DeadChannelFileName_.c_str(),"r");
00142
00143 int fileStatus=0;
00144 int ieta=-10000;
00145 int iphi=-10000;
00146 while(fileStatus != EOF) {
00147 fileStatus = fscanf(DeadCha,"%d %d\n",&ieta,&iphi);
00148
00149 if(ieta==-10000||iphi==-10000){break;}
00150 EBDetId cell(ieta,iphi);
00151 ChannelsDeadID.push_back(cell);
00152 }
00153 fclose(DeadCha);
00154
00155
00156 }
00157
00158
00159
00160
00161 void
00162 EcalChannelKiller::endJob() {
00163 }
00164
00165
00166 DEFINE_FWK_MODULE(EcalChannelKiller);