From 64dcc5c351314822a1a31968ca49868df94ffb76 Mon Sep 17 00:00:00 2001 From: Stilianos Kesisoglou Date: Wed, 20 Feb 2013 22:49:16 +0000 Subject: [PATCH] --- yaml --- r: 121795 b: "refs/heads/CMSSW_7_6_X" c: 8509068a3004a394c5d37046ec499e96c9d0a2b0 h: "refs/heads/CMSSW_7_6_X" i: 121793: 7cfda145100e049171681975436514330e041adc 121791: 9231c9908bf0ed4f27db14c7bbb0f615d7d249b2 v: v3 --- [refs] | 2 +- .../EBDeadChannelRecoveryProducers.h | 54 ++++++ .../EEDeadChannelRecoveryProducers.h | 54 ++++++ .../src/EBDeadChannelRecoveryProducers.cc | 169 ++++++++++++++++++ .../src/EEDeadChannelRecoveryProducers.cc | 169 ++++++++++++++++++ 5 files changed, 447 insertions(+), 1 deletion(-) create mode 100644 trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EBDeadChannelRecoveryProducers.h create mode 100644 trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EEDeadChannelRecoveryProducers.h create mode 100644 trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EBDeadChannelRecoveryProducers.cc create mode 100644 trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EEDeadChannelRecoveryProducers.cc diff --git a/[refs] b/[refs] index 8b52efb03b176..ee8b127bf1a65 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -"refs/heads/CMSSW_7_6_X": ef22c71add178795494a5ab3b20536bf5b737d4f +"refs/heads/CMSSW_7_6_X": 8509068a3004a394c5d37046ec499e96c9d0a2b0 diff --git a/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EBDeadChannelRecoveryProducers.h b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EBDeadChannelRecoveryProducers.h new file mode 100644 index 0000000000000..59ba9e805f735 --- /dev/null +++ b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EBDeadChannelRecoveryProducers.h @@ -0,0 +1,54 @@ +#ifndef RecoLocalCalo_EcalDeadChannelRecoveryProducers_EBDeadChannelRecoveryProducers_HH +#define RecoLocalCalo_EcalDeadChannelRecoveryProducers_EBDeadChannelRecoveryProducers_HH + +/** \class EBDeadChannelRecoveryProducers + * + * $Date: 2012/11/21 13:08:40 $ + * $Revision: 1.0 $ + * \author Stilianos Kesisoglou - Institute of Nuclear and Particle Physics NCSR Demokritos (Stilianos.Kesisoglou@cern.ch) + */ + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include + +// +// class decleration +// + +class EBDeadChannelRecoveryProducers : public edm::EDProducer { + public: + explicit EBDeadChannelRecoveryProducers(const edm::ParameterSet&); + ~EBDeadChannelRecoveryProducers(); + + private: + virtual void beginJob() ; + virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + // ----------member data --------------------------- + + double Sum8GeVThreshold_; + std::string hitProducer_; + std::string hitCollection_; + std::string reducedHitCollection_; + std::string DeadChannelFileName_; + std::vector ChannelsDeadID; + bool CorrectDeadCells_; + std::string CorrectionMethod_; + +}; + + +#endif diff --git a/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EEDeadChannelRecoveryProducers.h b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EEDeadChannelRecoveryProducers.h new file mode 100644 index 0000000000000..b56c8fc4ad4af --- /dev/null +++ b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EEDeadChannelRecoveryProducers.h @@ -0,0 +1,54 @@ +#ifndef RecoLocalCalo_EcalDeadChannelRecoveryProducers_EEDeadChannelRecoveryProducers_HH +#define RecoLocalCalo_EcalDeadChannelRecoveryProducers_EEDeadChannelRecoveryProducers_HH + +/** \class EEDeadChannelRecoveryProducers + * + * $Date: 2012/11/21 13:08:40 $ + * $Revision: 1.0 $ + * \author Stilianos Kesisoglou - Institute of Nuclear and Particle Physics NCSR Demokritos (Stilianos.Kesisoglou@cern.ch) + */ + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include + +// +// class decleration +// + +class EEDeadChannelRecoveryProducers : public edm::EDProducer { + public: + explicit EEDeadChannelRecoveryProducers(const edm::ParameterSet&); + ~EEDeadChannelRecoveryProducers(); + + private: + virtual void beginJob() ; + virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + // ----------member data --------------------------- + + double Sum8GeVThreshold_; + std::string hitProducer_; + std::string hitCollection_; + std::string reducedHitCollection_; + std::string DeadChannelFileName_; + std::vector ChannelsDeadID; + bool CorrectDeadCells_; + std::string CorrectionMethod_; + +}; + + +#endif diff --git a/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EBDeadChannelRecoveryProducers.cc b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EBDeadChannelRecoveryProducers.cc new file mode 100644 index 0000000000000..3222dd2378974 --- /dev/null +++ b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EBDeadChannelRecoveryProducers.cc @@ -0,0 +1,169 @@ +// -*- C++ -*- +// +// Package: EcalDeadChannelRecoveryProducers +// Class: EBDeadChannelRecoveryProducers +// +/**\class EBDeadChannelRecoveryProducers EBDeadChannelRecoveryProducers.cc RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EBDeadChannelRecoveryProducers.cc + + Description: + + Implementation: + +*/ +// +// Original Author: Stilianos Kesisoglou - Institute of Nuclear and Particle Physics NCSR Demokritos (Stilianos.Kesisoglou@cern.ch) +// Created: Wed Nov 21 11:24:39 EET 2012 +// +// Nov 21 2012: First version of the code. Based on the old "EcalDeadChannelRecoveryProducers.cc" code +// + + +// system include files +#include + + +// Geometry +#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloTopology/interface/CaloTopology.h" + +// Reconstruction Classes +#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/EcalDetId/interface/EBDetId.h" + +#include "RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EBDeadChannelRecoveryProducers.h" +#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EBDeadChannelRecoveryAlgos.h" + +#include +#include + +using namespace cms; +using namespace std; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +EBDeadChannelRecoveryProducers::EBDeadChannelRecoveryProducers(const edm::ParameterSet& ps) +{ + //now do what ever other initialization is needed + CorrectDeadCells_ = ps.getParameter("CorrectDeadCells"); + CorrectionMethod_ = ps.getParameter("CorrectionMethod"); + hitProducer_ = ps.getParameter("hitProducer"); + hitCollection_ = ps.getParameter("hitCollection"); + reducedHitCollection_ = ps.getParameter("reducedHitCollection"); + DeadChannelFileName_ = ps.getParameter("DeadChannelsFile"); + Sum8GeVThreshold_= ps.getParameter("Sum8GeVThreshold"); + + produces< EcalRecHitCollection >(reducedHitCollection_); +} + + +EBDeadChannelRecoveryProducers::~EBDeadChannelRecoveryProducers() +{ + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void +EBDeadChannelRecoveryProducers::produce(edm::Event& evt, const edm::EventSetup& iSetup) +{ + using namespace edm; + + edm::ESHandle theCaloTopology; + iSetup.get().get(theCaloTopology); + + // get the hit collection from the event: + edm::Handle rhcHandle; + evt.getByLabel(hitProducer_, hitCollection_, rhcHandle); + if (!(rhcHandle.isValid())) + { + // std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; + return; + } + const EcalRecHitCollection* hit_collection = rhcHandle.product(); + + // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and put it in the Event: + std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection); + + EBDeadChannelRecoveryAlgos *DeadChannelCorrector = new EBDeadChannelRecoveryAlgos(theCaloTopology.product()); + + // + // Double loop over EcalRecHit collection and "dead" cell RecHits. + // If we step into a "dead" cell call "DeadChannelCorrector::Correct()" + // + for (EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) { + std::vector::const_iterator CheckDead = ChannelsDeadID.begin(); + bool OverADeadRecHit=false; + while ( CheckDead != ChannelsDeadID.end() ) { + if (it->detid()==*CheckDead) { + OverADeadRecHit=true; + bool AcceptRecHit=true; + EcalRecHit NewRecHit = DeadChannelCorrector->Correct(it->detid(),hit_collection,CorrectionMethod_,Sum8GeVThreshold_, &AcceptRecHit); + // Accept the new rec hit if the flag is true. + if( AcceptRecHit ) { redCollection->push_back( NewRecHit ); } + else { redCollection->push_back( *it );} + break; + } + CheckDead++; + } + if (!OverADeadRecHit) { redCollection->push_back( *it ) ; } + } + + delete DeadChannelCorrector ; + + evt.put(redCollection, reducedHitCollection_); +} + + +// ------------ method called once each job just before starting event loop ------------ +void +EBDeadChannelRecoveryProducers::beginJob() +{ + //Open the DeadChannel file, read it. + FILE* DeadCha; + printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str()); + DeadCha = fopen(DeadChannelFileName_.c_str(),"r"); + + int fileStatus=0; + int ieta=-10000; + int iphi=-10000; + + while (fileStatus != EOF) { + + fileStatus = fscanf(DeadCha,"%d %d\n",&ieta,&iphi); + + // Problem reading Dead Channels file + if (ieta==-10000||iphi==-10000) { break; } + + if( EBDetId::validDetId(ieta,iphi) ) { + EBDetId cell(ieta,iphi); + ChannelsDeadID.push_back(cell); + } + + } //end while + + fclose(DeadCha); +} + +// ------------ method called once each job just after ending the event loop ------------ +void +EBDeadChannelRecoveryProducers::endJob() { +} + +//define this as a plug-in +DEFINE_FWK_MODULE(EBDeadChannelRecoveryProducers); diff --git a/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EEDeadChannelRecoveryProducers.cc b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EEDeadChannelRecoveryProducers.cc new file mode 100644 index 0000000000000..d1c9c83133392 --- /dev/null +++ b/trunk/RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EEDeadChannelRecoveryProducers.cc @@ -0,0 +1,169 @@ +// -*- C++ -*- +// +// Package: EcalDeadChannelRecoveryProducers +// Class: EEDeadChannelRecoveryProducers +// +/**\class EEDeadChannelRecoveryProducers EEDeadChannelRecoveryProducers.cc RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EEDeadChannelRecoveryProducers.cc + + Description: + + Implementation: + +*/ +// +// Original Author: Stilianos Kesisoglou - Institute of Nuclear and Particle Physics NCSR Demokritos (Stilianos.Kesisoglou@cern.ch) +// Created: Wed Nov 21 11:24:39 EET 2012 +// +// Nov 21 2012: First version of the code. Based on the old "EcalDeadChannelRecoveryProducers.cc" code +// + + +// system include files +#include + + +// Geometry +#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloTopology/interface/CaloTopology.h" + +// Reconstruction Classes +#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/EcalDetId/interface/EEDetId.h" + +#include "RecoLocalCalo/EcalDeadChannelRecoveryProducers/interface/EEDeadChannelRecoveryProducers.h" +#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EEDeadChannelRecoveryAlgos.h" + +#include +#include + +using namespace cms; +using namespace std; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +EEDeadChannelRecoveryProducers::EEDeadChannelRecoveryProducers(const edm::ParameterSet& ps) +{ + //now do what ever other initialization is needed + CorrectDeadCells_ = ps.getParameter("CorrectDeadCells"); + CorrectionMethod_ = ps.getParameter("CorrectionMethod"); + hitProducer_ = ps.getParameter("hitProducer"); + hitCollection_ = ps.getParameter("hitCollection"); + reducedHitCollection_ = ps.getParameter("reducedHitCollection"); + DeadChannelFileName_ = ps.getParameter("DeadChannelsFile"); + Sum8GeVThreshold_= ps.getParameter("Sum8GeVThreshold"); + + produces< EcalRecHitCollection >(reducedHitCollection_); +} + + +EEDeadChannelRecoveryProducers::~EEDeadChannelRecoveryProducers() +{ + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void +EEDeadChannelRecoveryProducers::produce(edm::Event& evt, const edm::EventSetup& iSetup) +{ + using namespace edm; + + edm::ESHandle theCaloTopology; + iSetup.get().get(theCaloTopology); + + // get the hit collection from the event: + edm::Handle rhcHandle; + evt.getByLabel(hitProducer_, hitCollection_, rhcHandle); + if (!(rhcHandle.isValid())) + { + // std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; + return; + } + const EcalRecHitCollection* hit_collection = rhcHandle.product(); + + // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and put it in the Event: + std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection); + + EEDeadChannelRecoveryAlgos *DeadChannelCorrector = new EEDeadChannelRecoveryAlgos(theCaloTopology.product()); + + // + // Double loop over EcalRecHit collection and "dead" cell RecHits. + // If we step into a "dead" cell call "DeadChannelCorrector::Correct()" + // + for (EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) { + std::vector::const_iterator CheckDead = ChannelsDeadID.begin(); + bool OverADeadRecHit=false; + while ( CheckDead != ChannelsDeadID.end() ) { + if (it->detid()==*CheckDead) { + OverADeadRecHit=true; + bool AcceptRecHit=true; + EcalRecHit NewRecHit = DeadChannelCorrector->Correct(it->detid(),hit_collection,CorrectionMethod_,Sum8GeVThreshold_, &AcceptRecHit); + // Accept the new rec hit if the flag is true. + if( AcceptRecHit ) { redCollection->push_back( NewRecHit ); } + else { redCollection->push_back( *it );} + break; + } + CheckDead++; + } + if (!OverADeadRecHit) { redCollection->push_back( *it ) ; } + } + + delete DeadChannelCorrector ; + + evt.put(redCollection, reducedHitCollection_); +} + + +// ------------ method called once each job just before starting event loop ------------ +void +EEDeadChannelRecoveryProducers::beginJob() +{ + //Open the DeadChannel file, read it. + FILE* DeadCha; + printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str()); + DeadCha = fopen(DeadChannelFileName_.c_str(),"r"); + + int fileStatus=0; + int ix=-10000; + int iy=-10000; + int iz=-10000; + while (fileStatus != EOF) { + + fileStatus = fscanf(DeadCha,"%d %d %d\n",&ix,&iy,&iz); + + // Problem reading Dead Channels file + if (ix==-10000||iy==-10000||iz==-10000) { break; } + + if ( EEDetId::validDetId(ix,iy,iz) ) { + EEDetId cell(ix,iy,iz); + ChannelsDeadID.push_back(cell); + } + + } //end while + + fclose(DeadCha); +} + +// ------------ method called once each job just after ending the event loop ------------ +void +EEDeadChannelRecoveryProducers::endJob() { +} + +//define this as a plug-in +DEFINE_FWK_MODULE(EEDeadChannelRecoveryProducers);