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 ItIsDead=true;
00106 NewEnergy =0.;
00107 nRed++;
00108
00109 }
00110 }
00111
00112
00113
00114
00115
00116
00117 if(!ItIsDead){
00118 EcalRecHit NewHit(it->id(),NewEnergy,it->time());
00119 redCollection->push_back( NewHit );
00120 }
00121 }
00122
00123
00124 iEvent.put(redCollection, reducedHitCollection_);
00125
00126 }
00127
00128
00129
00130
00131
00132 void
00133 EcalChannelKiller::beginJob()
00134 {
00135
00136
00137 FILE* DeadCha;
00138 printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str());
00139 DeadCha = fopen(DeadChannelFileName_.c_str(),"r");
00140
00141 int fileStatus=0;
00142 int ieta=-10000;
00143 int iphi=-10000;
00144 while(fileStatus != EOF) {
00145 fileStatus = fscanf(DeadCha,"%d %d\n",&ieta,&iphi);
00146
00147 if(ieta==-10000||iphi==-10000){break;}
00148 EBDetId cell(ieta,iphi);
00149 ChannelsDeadID.push_back(cell);
00150 }
00151 fclose(DeadCha);
00152
00153
00154 }
00155
00156
00157
00158
00159 void
00160 EcalChannelKiller::endJob() {
00161 }
00162
00163
00164 DEFINE_FWK_MODULE(EcalChannelKiller);