diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_001_cfg.py b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_001_cfg.py deleted file mode 100644 index 47d74ab37f874..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_001_cfg.py +++ /dev/null @@ -1,96 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("DCRec") - -process.load("Configuration.StandardSequences.MagneticField_cff") -#process.load("Configuration.StandardSequences.Geometry_cff") # Depreciated -process.load("Configuration.Geometry.GeometryIdeal_cff") - -process.load("Configuration.EventContent.EventContent_cff") -process.load("Geometry.CaloEventSetup.CaloGeometry_cfi") -process.load("Geometry.CaloEventSetup.CaloTopology_cfi") - -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -process.GlobalTag.globaltag = cms.string('START53_V10::All') - -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) - -process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) - - -# ***************************************************************** -# Input Source -# ***************************************************************** -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( -# '/store/relval/CMSSW_2_2_4/RelValTTbar/GEN-SIM-RECO/STARTUP_V8_v1/0000/200EB7E3-90F3-DD11-B1B0-001D09F2432B.root', -# '/eos/cms/store/relval/CMSSW_5_3_4_cand1/RelValZEE/GEN-SIM-RECO/PU_START53_V10-v1/0003/22521942-41F7-E111-A383-003048D375AA.root', -# '/store/relval/CMSSW_5_3_4_cand1/RelValZEE/GEN-SIM-RECO/PU_START53_V10-v1/0003/22521942-41F7-E111-A383-003048D375AA.root', -# 'root://eoscms//eos/cms/store/relval/CMSSW_5_3_4_cand1/RelValZEE/GEN-SIM-RECO/PU_START53_V10-v1/0003/22521942-41F7-E111-A383-003048D375AA.root', - 'rfio:/afs/cern.ch/work/i/ikesisog/public/TestFiles/22521942-41F7-E111-A383-003048D375AA.root', - ) -) - - -# ***************************************************************** -# Output Target -# ***************************************************************** -process.out = cms.OutputModule("PoolOutputModule", - fileName = cms.untracked.string('Results.root'), - outputCommands = cms.untracked.vstring('keep *_*_*_DCRec','keep *_*_*_VALIDATION'), - #SelectEvents = cms.untracked.PSet( SelectEvents = cms.vstring("p") ), -) - - -# ***************************************************************** -# RecHitsKiller and RecHitRecoveryProducer module for Barrel -# ***************************************************************** -process.CreateEBDeadCells = cms.EDProducer("EBChannelKiller", - hitProducer = cms.string("ecalRecHit"), - hitCollection = cms.string("EcalRecHitsEB"), - reducedHitCollection = cms.string("EcalRecHitsEB"), - KilledHitCollection = cms.string("KilledEcalRecHitsEB"), - DeadChannelsFile = cms.string("EBDeadCellsEach5.txt"), - KillDeadCells = cms.bool(True), -) - -process.ModCorrectEBDeadCells = cms.EDProducer("EBDeadChannelRecoveryProducers", - hitProducer = cms.string("CreateEBDeadCells"), - hitCollection = cms.string("EcalRecHitsEB"), - reducedHitCollection = cms.string("EcalRecHitsEB"), - DeadChannelsFile = cms.string("EBDeadCellsEach5.txt"), - Sum8GeVThreshold = cms.double(8.0), - CorrectionMethod = cms.string("NeuralNetworks"), - CorrectDeadCells = cms.bool(True), -) - - -# ***************************************************************** -# RecHitsKiller and RecHitRecoveryProducer module for EndCap -# ***************************************************************** -process.CreateEEDeadCells = cms.EDProducer("EEChannelKiller", - hitProducer = cms.string("ecalRecHit"), - hitCollection = cms.string("EcalRecHitsEE"), - reducedHitCollection = cms.string("EcalRecHitsEE"), - KilledHitCollection = cms.string("KilledEcalRecHitsEE"), - DeadChannelsFile = cms.string("EEDeadCellsEach5.txt"), - KillDeadCells = cms.bool(True), -) - -process.ModCorrectEEDeadCells = cms.EDProducer("EEDeadChannelRecoveryProducers", - hitProducer = cms.string("CreateEEDeadCells"), - hitCollection = cms.string("EcalRecHitsEE"), - reducedHitCollection = cms.string("EcalRecHitsEE"), - DeadChannelsFile = cms.string("EEDeadCellsEach5.txt"), - Sum8GeVThreshold = cms.double(8.0), - CorrectionMethod = cms.string("NeuralNetworks"), - CorrectDeadCells = cms.bool(True), -) - - -# ***************************************************************** -# Execution Path -# ***************************************************************** -process.p = cms.Path(process.CreateEBDeadCells * process.ModCorrectEBDeadCells + process.CreateEEDeadCells * process.ModCorrectEEDeadCells ) -process.outpath = cms.EndPath(process.out) - diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_002_cfg.py b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_002_cfg.py index 391c9001d8148..7d63b67b013d8 100644 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_002_cfg.py +++ b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/RecoAllKilledAndCorrected_002_cfg.py @@ -54,8 +54,7 @@ # RecHitsKiller and RecHitRecoveryProducer module for Barrel # ***************************************************************** process.CreateEBDeadCells = cms.EDProducer("EBChannelKiller", - hitProducer = cms.string("reducedEcalRecHitsEB"), - hitCollection = cms.string(""), + hitTag = cms.InputTag("reducedEcalRecHitsEB", ""), reducedHitCollection = cms.string("CreateEB"), KilledHitCollection = cms.string("KilledEcalRecHitsEB"), DeadChannelsFile = cms.string("EBDeadCellsEach5.txt"), @@ -63,8 +62,7 @@ ) process.ModCorrectEBDeadCells = cms.EDProducer("EBDeadChannelRecoveryProducers", - hitProducer = cms.string("CreateEBDeadCells"), - hitCollection = cms.string("CreateEB"), + hitTag = cms.InputTag("CreateEBDeadCells", "CreateEB"), reducedHitCollection = cms.string("ModifyEB"), DeadChannelsFile = cms.string("EBDeadCellsEach5.txt"), Sum8GeVThreshold = cms.double(8.0), @@ -77,8 +75,7 @@ # RecHitsKiller and RecHitRecoveryProducer module for EndCap # ***************************************************************** process.CreateEEDeadCells = cms.EDProducer("EEChannelKiller", - hitProducer = cms.string("reducedEcalRecHitsEE"), - hitCollection = cms.string(""), + hitTag = cms.InputTag("reducedEcalRecHitsEE", ""), reducedHitCollection = cms.string("CreateEE"), KilledHitCollection = cms.string("KilledEcalRecHitsEE"), DeadChannelsFile = cms.string("EEDeadCellsEach5.txt"), @@ -86,8 +83,7 @@ ) process.ModCorrectEEDeadCells = cms.EDProducer("EEDeadChannelRecoveryProducers", - hitProducer = cms.string("CreateEEDeadCells"), - hitCollection = cms.string("CreateEE"), + hitTag = cms.InputTag("CreateEEDeadCells", "CreateEE"), reducedHitCollection = cms.string("ModifyEE"), DeadChannelsFile = cms.string("EEDeadCellsEach5.txt"), Sum8GeVThreshold = cms.double(8.0), @@ -111,8 +107,6 @@ titlePrefix = cms.string("(EE) "), ) - - process.dump = cms.EDAnalyzer("EcalRecHitDump", EBRecHitCollection = cms.InputTag("ModCorrectEBDeadCells", "ModifyEB"), EERecHitCollection = cms.InputTag("ModCorrectEEDeadCells", "ModifyEE"), diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.cc b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.cc deleted file mode 100644 index 008babac72e30..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.cc +++ /dev/null @@ -1,160 +0,0 @@ -// -*- C++ -*- -// -// Package: EcalChannelKiller -// Class: EBChannelKiller -// -/**\class EBChannelKiller EBChannelKiller.cc RecoCaloTools/EcalChannelKiller/src/EBChannelKiller.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 "EcalChannelKiller.cc" code -// - - -// Geometry -#include "Geometry/Records/interface/IdealGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" -#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" -#include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" -#include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" -#include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h" -#include "Geometry/CaloTopology/interface/EcalEndcapHardcodedTopology.h" - -// Reconstruction Classes -#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" -#include "DataFormats/EcalDetId/interface/EBDetId.h" - -#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.h" - -#include -#include -using namespace cms; -using namespace std; - -// -// constructors and destructor -// -EBChannelKiller::EBChannelKiller(const edm::ParameterSet& ps) -{ - hitProducer_ = ps.getParameter("hitProducer"); - hitCollection_ = ps.getParameter("hitCollection"); - reducedHitCollection_ = ps.getParameter("reducedHitCollection"); - DeadChannelFileName_ = ps.getParameter("DeadChannelsFile"); - - produces< EcalRecHitCollection >(reducedHitCollection_); -} - - -EBChannelKiller::~EBChannelKiller() -{ - // 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 -EBChannelKiller::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - - // get the hit collection from the event: - edm::Handle rhcHandle; - iEvent.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(); - - int nRed = 0; - - // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and put in the Event: - std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection); - - for (EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) { - - double NewEnergy = it->energy(); - bool ItIsDead = false; - - //Dead Cells are read from text files - std::vector::const_iterator DeadCell; - for (DeadCell = ChannelsDeadID.begin(); DeadCell != ChannelsDeadID.end(); ++DeadCell) { - if ( it->detid() == *DeadCell ) { - ItIsDead=true; - NewEnergy =0.; - nRed++; - // If a "dead" cell is detected add a corresponding recHit with zero energy. - // It perserves the total number of recHits and simulates the true "dead" cell situation. - EcalRecHit NewDeadHit(it->id(),NewEnergy,it->time()); - redCollection->push_back( NewDeadHit ); - } - }//End looping on vector of Dead Cells - - // Make a new RecHit - // - // TODO what will be the it->time() for D.C. ? - // Could we use it for "correction" identification? - // - if ( !ItIsDead ) { redCollection->push_back( *it ); } - } - - iEvent.put(redCollection, reducedHitCollection_); - -} - - - - -// ------------ method called once each job just before starting event loop ------------ -void -EBChannelKiller::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 -EBChannelKiller::endJob() { -} - -//define this as a plug-in -DEFINE_FWK_MODULE(EBChannelKiller); diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.h b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.h deleted file mode 100644 index 0b1b5939fc53a..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBChannelKiller.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef RecoCaloTools_EcalChannelKiller_EBChannelKiller_HH -#define RecoCaloTools_EcalChannelKiller_EBChannelKiller_HH - -/** \class EBChannelKiller - * - * $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 EBChannelKiller : public edm::EDProducer { - public: - explicit EBChannelKiller(const edm::ParameterSet&); - ~EBChannelKiller(); - - private: - virtual void beginJob() ; - virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - // ----------member data --------------------------- - std::string hitProducer_; - std::string hitCollection_; - std::string reducedHitCollection_; - std::string DeadChannelFileName_; - std::vector ChannelsDeadID; -}; - - -#endif diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.cc b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.cc deleted file mode 100644 index de26858c59f81..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.cc +++ /dev/null @@ -1,170 +0,0 @@ -// -*- 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/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.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); - ebDeadChannelCorrector.setCaloTopology(theCaloTopology.product()); - - // - // Double loop over EcalRecHit collection and "dead" cell RecHits. - // If we step into a "dead" cell call "ebDeadChannelCorrector::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 hit = ebDeadChannelCorrector.correct(it->detid(),*hit_collection,CorrectionMethod_,Sum8GeVThreshold_, &AcceptRecHit); - - if ( hit.energy() != 0 and AcceptRecHit == true ) { - hit.setFlag(EcalRecHit::kNeighboursRecovered) ; - } else { - // recovery failed - hit.setFlag(EcalRecHit::kDead) ; - } - - redCollection->push_back(hit); - break; - } - CheckDead++; - } - if (!OverADeadRecHit) { redCollection->push_back( *it ) ; } - } - - 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/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.h b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.h deleted file mode 100644 index d8370badf5d39..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EBDeadChannelRecoveryProducers.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef RecoLocalCalo_EcalDeadChannelRecoveryProducers_EBDeadChannelRecoveryProducers_HH -#define RecoLocalCalo_EcalDeadChannelRecoveryProducers_EBDeadChannelRecoveryProducers_HH - -/** \class EBDeadChannelRecoveryProducers - * - * \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 - -#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EcalDeadChannelRecoveryAlgos.h" - -// -// 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_; - - EcalDeadChannelRecoveryAlgos ebDeadChannelCorrector; -}; - - -#endif diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.cc b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.cc deleted file mode 100644 index 4c83763cc97e0..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.cc +++ /dev/null @@ -1,160 +0,0 @@ -// -*- C++ -*- -// -// Package: EcalChannelKiller -// Class: EEChannelKiller -// -/**\class EEChannelKiller EEChannelKiller.cc RecoCaloTools/EcalChannelKiller/src/EEChannelKiller.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 "EcalChannelKiller.cc" code -// - - -// Geometry -#include "Geometry/Records/interface/IdealGeometryRecord.h" -#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" -#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" -#include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" -#include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" -#include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h" -#include "Geometry/CaloTopology/interface/EcalEndcapHardcodedTopology.h" - -// Reconstruction Classes -#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" -#include "DataFormats/EcalDetId/interface/EEDetId.h" - -#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.h" - -#include -#include -using namespace cms; -using namespace std; - -// -// constructors and destructor -// -EEChannelKiller::EEChannelKiller(const edm::ParameterSet& ps) -{ - hitProducer_ = ps.getParameter("hitProducer"); - hitCollection_ = ps.getParameter("hitCollection"); - reducedHitCollection_ = ps.getParameter("reducedHitCollection"); - DeadChannelFileName_ = ps.getParameter("DeadChannelsFile"); - - produces< EcalRecHitCollection >(reducedHitCollection_); -} - - -EEChannelKiller::~EEChannelKiller() -{ - // 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 -EEChannelKiller::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - - // get the hit collection from the event: - edm::Handle rhcHandle; - iEvent.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(); - - int nRed = 0; - - // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and put in the Event: - std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection); - - for (EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) { - - double NewEnergy = it->energy(); - bool ItIsDead = false; - - //Dead Cells are read from text files - std::vector::const_iterator DeadCell; - for (DeadCell = ChannelsDeadID.begin(); DeadCell != ChannelsDeadID.end(); ++DeadCell) { - if ( it->detid() == *DeadCell ) { - ItIsDead=true; - NewEnergy =0.; - nRed++; - // If a "dead" cell is detected add a corresponding recHit with zero energy. - // It perserves the total number of recHits and simulates the true "dead" cell situation. - EcalRecHit NewDeadHit(it->id(),NewEnergy,it->time()); - redCollection->push_back( NewDeadHit ); - } - }//End looping on vector of Dead Cells - - // Make a new RecHit - // - // TODO what will be the it->time() for D.C. ? - // Could we use it for "correction" identification? - // - if ( !ItIsDead ) { redCollection->push_back( *it ); } - } - - iEvent.put(redCollection, reducedHitCollection_); - -} - - - - -// ------------ method called once each job just before starting event loop ------------ -void -EEChannelKiller::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 -EEChannelKiller::endJob() { -} - -//define this as a plug-in -DEFINE_FWK_MODULE(EEChannelKiller); diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.h b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.h deleted file mode 100644 index 9c6aaab7293d3..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEChannelKiller.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef RecoCaloTools_EcalChannelKiller_EEChannelKiller_HH -#define RecoCaloTools_EcalChannelKiller_EEChannelKiller_HH - -/** \class EEChannelKiller - * - * $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 EEChannelKiller : public edm::EDProducer { - public: - explicit EEChannelKiller(const edm::ParameterSet&); - ~EEChannelKiller(); - - private: - virtual void beginJob() ; - virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - // ----------member data --------------------------- - std::string hitProducer_; - std::string hitCollection_; - std::string reducedHitCollection_; - std::string DeadChannelFileName_; - std::vector ChannelsDeadID; -}; - - -#endif diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.cc b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.cc deleted file mode 100644 index 21966b8ba062b..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.cc +++ /dev/null @@ -1,170 +0,0 @@ -// -*- 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/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.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); - eeDeadChannelCorrector.setCaloTopology(theCaloTopology.product()); - - // - // Double loop over EcalRecHit collection and "dead" cell RecHits. - // If we step into a "dead" cell call "eeDeadChannelCorrector::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 hit = eeDeadChannelCorrector.correct(it->detid(),*hit_collection,CorrectionMethod_,Sum8GeVThreshold_, &AcceptRecHit); - - if ( hit.energy() != 0 and AcceptRecHit == true ) { - hit.setFlag(EcalRecHit::kNeighboursRecovered) ; - } else { - // recovery failed - hit.setFlag(EcalRecHit::kDead) ; - } - - redCollection->push_back(hit); - break; - } - CheckDead++; - } - if (!OverADeadRecHit) { redCollection->push_back( *it ) ; } - } - - 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); diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.h b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.h deleted file mode 100644 index 33eed2ee2f08e..0000000000000 --- a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EEDeadChannelRecoveryProducers.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef RecoLocalCalo_EcalDeadChannelRecoveryProducers_EEDeadChannelRecoveryProducers_HH -#define RecoLocalCalo_EcalDeadChannelRecoveryProducers_EEDeadChannelRecoveryProducers_HH - -/** \class EEDeadChannelRecoveryProducers - * - * $Date: 2013/02/20 22:49:13 $ - * $Revision: 1.1 $ - * \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 - -#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EcalDeadChannelRecoveryAlgos.h" -// -// 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_; - - EcalDeadChannelRecoveryAlgos eeDeadChannelCorrector; -}; - - -#endif diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.cc b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.cc new file mode 100644 index 0000000000000..2c6ac2305bb6a --- /dev/null +++ b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.cc @@ -0,0 +1,191 @@ +// -*- C++ -*- +// +// Package: EcalChannelKiller +// Class: EBChannelKiller +// +/**\class EBChannelKiller EBChannelKiller.cc + RecoCaloTools/EcalChannelKiller/src/EBChannelKiller.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 +// "EcalChannelKiller.cc" code +// + +// Geometry +#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" +#include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" +#include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" +#include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h" +#include "Geometry/CaloTopology/interface/EcalEndcapHardcodedTopology.h" + +// Reconstruction Classes +#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/EcalDetId/interface/EBDetId.h" +#include "DataFormats/EcalDetId/interface/EEDetId.h" + +#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.h" + +#include +#include + +using namespace cms; +using namespace std; + +// +// constructors and destructor +// +template +EcalChannelKiller::EcalChannelKiller(const edm::ParameterSet& ps) { + hitToken_ = + consumes(ps.getParameter("hitTag")); + + reducedHitCollection_ = ps.getParameter("reducedHitCollection"); + DeadChannelFileName_ = ps.getParameter("DeadChannelsFile"); + + produces(reducedHitCollection_); +} + +template EcalChannelKiller::~EcalChannelKiller() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + +// ------------ method called to produce the data ------------ +template +void EcalChannelKiller::produce(edm::Event& iEvent, + const edm::EventSetup& iSetup) { + using namespace edm; + + // get the hit collection from the event: + edm::Handle rhcHandle; + iEvent.getByToken(hitToken_, rhcHandle); + if (!(rhcHandle.isValid())) { + // std::cout << "could not get a handle on the EcalRecHitCollection!" << + // std::endl; + return; + } + const EcalRecHitCollection* hit_collection = rhcHandle.product(); + + int nRed = 0; + + // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and + // put in the Event: + std::auto_ptr redCollection(new EcalRecHitCollection); + + for (EcalRecHitCollection::const_iterator it = hit_collection->begin(); + it != hit_collection->end(); ++it) { + + double NewEnergy = it->energy(); + bool ItIsDead = false; + + //Dead Cells are read from text files + typename std::vector::const_iterator DeadCell; + for (DeadCell = ChannelsDeadID.begin(); DeadCell != ChannelsDeadID.end(); + ++DeadCell) { + if (it->detid() == *DeadCell) { + ItIsDead = true; + NewEnergy = 0.; + nRed++; + // If a "dead" cell is detected add a corresponding recHit with zero + // energy. + // It perserves the total number of recHits and simulates the true + // "dead" cell situation. + EcalRecHit NewDeadHit(it->id(), NewEnergy, it->time()); + redCollection->push_back(NewDeadHit); + } + } //End looping on vector of Dead Cells + + // Make a new RecHit + // + // TODO what will be the it->time() for D.C. ? + // Could we use it for "correction" identification? + // + if (!ItIsDead) { + redCollection->push_back(*it); + } + } + + iEvent.put(redCollection, reducedHitCollection_); + +} + +// ------------ method called once each job just before starting event loop +// ------------ +template <> void EcalChannelKiller::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); +} + +template <> void EcalChannelKiller::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 +template void EcalChannelKiller::endJob() {} + +typedef class EcalChannelKiller EBChannelKiller; +typedef class EcalChannelKiller EEChannelKiller; + +DEFINE_FWK_MODULE(EBChannelKiller); +DEFINE_FWK_MODULE(EEChannelKiller); diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.h b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.h new file mode 100644 index 0000000000000..d7aa298f6b1f0 --- /dev/null +++ b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalChannelKiller.h @@ -0,0 +1,40 @@ +#ifndef RecoLocalCalo_EcalDeadChannelRecoveryAlgos_test_EcalChannelKiller_h +#define RecoLocalCalo_EcalDeadChannelRecoveryAlgos_test_EcalChannelKiller_h + +/** + * \author Stilianos Kesisoglou - Institute of Nuclear and Particle Physics + * NCSR Demokritos (Stilianos.Kesisoglou@cern.ch) + */ + +#include +#include + +#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 "DataFormats/EcalRecHit/interface/EcalRecHit.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" + +template class EcalChannelKiller : public edm::EDProducer { + public: + explicit EcalChannelKiller(const edm::ParameterSet&); + ~EcalChannelKiller(); + + private: + virtual void beginJob(); + virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void endJob(); + + // ----------member data --------------------------- + std::string reducedHitCollection_; + std::string DeadChannelFileName_; + std::vector ChannelsDeadID; + + edm::EDGetTokenT hitToken_; +}; + +#endif diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.cc b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.cc new file mode 100644 index 0000000000000..c4d337100f8f9 --- /dev/null +++ b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.cc @@ -0,0 +1,181 @@ +// 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 +#include +#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 "DataFormats/EcalDetId/interface/EEDetId.h" + +#include "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.h" + +using namespace cms; +using namespace std; + +template +EcalDeadChannelRecoveryProducers::EcalDeadChannelRecoveryProducers( + const edm::ParameterSet& ps) { + //now do what ever other initialization is needed + CorrectDeadCells_ = ps.getParameter("CorrectDeadCells"); + CorrectionMethod_ = ps.getParameter("CorrectionMethod"); + reducedHitCollection_ = ps.getParameter("reducedHitCollection"); + DeadChannelFileName_ = ps.getParameter("DeadChannelsFile"); + Sum8GeVThreshold_ = ps.getParameter("Sum8GeVThreshold"); + + hitToken_ = + consumes(ps.getParameter("hitTag")); + produces(reducedHitCollection_); +} + +template +EcalDeadChannelRecoveryProducers::~EcalDeadChannelRecoveryProducers() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + +// ------------ method called to produce the data ------------ +template +void EcalDeadChannelRecoveryProducers::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.getByToken(hitToken_, 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 redCollection(new EcalRecHitCollection); + deadChannelCorrector.setCaloTopology(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 hit = deadChannelCorrector.correct( + it->detid(), *hit_collection, CorrectionMethod_, Sum8GeVThreshold_, + &AcceptRecHit); + + if (hit.energy() != 0 and AcceptRecHit == true) { + hit.setFlag(EcalRecHit::kNeighboursRecovered); + } else { + // recovery failed + hit.setFlag(EcalRecHit::kDead); + } + + redCollection->push_back(hit); + break; + } + CheckDead++; + } + if (!OverADeadRecHit) { + redCollection->push_back(*it); + } + } + + evt.put(redCollection, reducedHitCollection_); +} + +// method called once each job just before starting event loop ------------ +template <> void EcalDeadChannelRecoveryProducers::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); +} + +template <> void EcalDeadChannelRecoveryProducers::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 +// ------------ +template +void EcalDeadChannelRecoveryProducers::endJob() {} + +typedef class EcalDeadChannelRecoveryProducers + EBDeadChannelRecoveryProducers; +typedef class EcalDeadChannelRecoveryProducers + EEDeadChannelRecoveryProducers; + +DEFINE_FWK_MODULE(EBDeadChannelRecoveryProducers); +DEFINE_FWK_MODULE(EEDeadChannelRecoveryProducers); diff --git a/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.h b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.h new file mode 100644 index 0000000000000..14c86a4c79573 --- /dev/null +++ b/RecoLocalCalo/EcalDeadChannelRecoveryAlgos/test/plugins/EcalDeadChannelRecoveryProducers.h @@ -0,0 +1,48 @@ +#ifndef RecoLocalCalo_EcalDeadChannelRecoveryProducers_test_EcalDeadChannelRecoveryProducers_HH +#define RecoLocalCalo_EcalDeadChannelRecoveryProducers_test_EcalDeadChannelRecoveryProducers_HH + +/** + * \author Stilianos Kesisoglou - Institute of Nuclear and Particle Physics + * NCSR Demokritos (Stilianos.Kesisoglou@cern.ch) + */ + +// system include files +#include +#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 "RecoLocalCalo/EcalDeadChannelRecoveryAlgos/interface/EcalDeadChannelRecoveryAlgos.h" + +template +class EcalDeadChannelRecoveryProducers : public edm::EDProducer { + public: + explicit EcalDeadChannelRecoveryProducers(const edm::ParameterSet&); + ~EcalDeadChannelRecoveryProducers(); + + private: + virtual void beginJob(); + virtual void produce(edm::Event&, const edm::EventSetup&); + virtual void endJob(); + + // ----------member data --------------------------- + edm::EDGetTokenT hitToken_; + + double Sum8GeVThreshold_; + std::string reducedHitCollection_; + std::string DeadChannelFileName_; + std::vector ChannelsDeadID; + bool CorrectDeadCells_; + std::string CorrectionMethod_; + + EcalDeadChannelRecoveryAlgos deadChannelCorrector; +}; + +#endif