Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121795
b: "refs/heads/CMSSW_7_6_X"
c: 8509068
h: "refs/heads/CMSSW_7_6_X"
i:
  121793: 7cfda14
  121791: 9231c99
v: v3
  • Loading branch information
Stilianos Kesisoglou committed Feb 20, 2013
1 parent cf7a07d commit 64dcc5c
Show file tree
Hide file tree
Showing 5 changed files with 447 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
"refs/heads/CMSSW_7_6_X": ef22c71add178795494a5ab3b20536bf5b737d4f
"refs/heads/CMSSW_7_6_X": 8509068a3004a394c5d37046ec499e96c9d0a2b0
Original file line number Diff line number Diff line change
@@ -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 <memory>

// 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 <string>

//
// 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<EBDetId> ChannelsDeadID;
bool CorrectDeadCells_;
std::string CorrectionMethod_;

};


#endif
Original file line number Diff line number Diff line change
@@ -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 <memory>

// 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 <string>

//
// 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<EEDetId> ChannelsDeadID;
bool CorrectDeadCells_;
std::string CorrectionMethod_;

};


#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// -*- C++ -*-
//
// Package: EcalDeadChannelRecoveryProducers
// Class: EBDeadChannelRecoveryProducers
//
/**\class EBDeadChannelRecoveryProducers EBDeadChannelRecoveryProducers.cc RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EBDeadChannelRecoveryProducers.cc
Description: <one line class summary>
Implementation:
<Notes on 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 <memory>


// 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 <string>
#include <cstdio>

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<bool>("CorrectDeadCells");
CorrectionMethod_ = ps.getParameter<std::string>("CorrectionMethod");
hitProducer_ = ps.getParameter<std::string>("hitProducer");
hitCollection_ = ps.getParameter<std::string>("hitCollection");
reducedHitCollection_ = ps.getParameter<std::string>("reducedHitCollection");
DeadChannelFileName_ = ps.getParameter<std::string>("DeadChannelsFile");
Sum8GeVThreshold_= ps.getParameter<double>("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<CaloTopology> theCaloTopology;
iSetup.get<CaloTopologyRecord>().get(theCaloTopology);

// get the hit collection from the event:
edm::Handle<EcalRecHitCollection> 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<EBDetId>::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);
Loading

0 comments on commit 64dcc5c

Please sign in to comment.