CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalChannelKiller Class Reference

#include <RecoCaloTools/EcalChannelKiller/src/EcalChannelKiller.cc>

Inheritance diagram for EcalChannelKiller:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 EcalChannelKiller (const edm::ParameterSet &)
 
 ~EcalChannelKiller ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::vector< EBDetIdChannelsDeadID
 
std::string DeadChannelFileName_
 
std::string hitCollection_
 
std::string hitProducer_
 
std::string reducedHitCollection_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Date:
2010/08/06 20:24:49
Revision:
1.3

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 30 of file EcalChannelKiller.h.

Constructor & Destructor Documentation

EcalChannelKiller::EcalChannelKiller ( const edm::ParameterSet ps)
explicit

Definition at line 48 of file EcalChannelKiller.cc.

References edm::ParameterSet::getParameter().

49 {
50 
51  hitProducer_ = ps.getParameter<std::string>("hitProducer");
52  hitCollection_ = ps.getParameter<std::string>("hitCollection");
53  reducedHitCollection_ = ps.getParameter<std::string>("reducedHitCollection");
54  DeadChannelFileName_ = ps.getParameter<std::string>("DeadChannelsFile");
55 
56  produces< EcalRecHitCollection >(reducedHitCollection_);
57 
58 
59 }
T getParameter(std::string const &) const
std::string DeadChannelFileName_
std::string hitCollection_
std::string hitProducer_
std::string reducedHitCollection_
EcalChannelKiller::~EcalChannelKiller ( )

Definition at line 62 of file EcalChannelKiller.cc.

63 {
64 
65  // do anything here that needs to be done at desctruction time
66  // (e.g. close files, deallocate resources etc.)
67 
68 }

Member Function Documentation

void EcalChannelKiller::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 133 of file EcalChannelKiller.cc.

134 {
135 
136  //Open the DeadChannel file, read it.
137  FILE* DeadCha;
138  printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str());
139  DeadCha = fopen(DeadChannelFileName_.c_str(),"r");
140 
141  int fileStatus=0;
142  int ieta=-10000;
143  int iphi=-10000;
144  while(fileStatus != EOF) {
145  fileStatus = fscanf(DeadCha,"%d %d\n",&ieta,&iphi);
146  // std::cout<<" ieta "<<ieta<<" iphi "<<iphi<<std::endl;
147  if(ieta==-10000||iphi==-10000){/*std::cout << "Problem reading Dead Channels file "<<std::endl;*/break;}
148  EBDetId cell(ieta,iphi);
149  ChannelsDeadID.push_back(cell);
150  } //end while
151  fclose(DeadCha);
152  // std::cout<<" Read "<<ChannelsDeadID.size()<<" dead channels "<<std::endl;
153 
154 }
std::vector< EBDetId > ChannelsDeadID
std::string DeadChannelFileName_
void EcalChannelKiller::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 160 of file EcalChannelKiller.cc.

160  {
161 }
void EcalChannelKiller::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 77 of file EcalChannelKiller.cc.

References edm::Event::getByLabel(), and edm::Event::put().

78 {
79  using namespace edm;
80 
81  // get the hit collection from the event:
83  iEvent.getByLabel(hitProducer_, hitCollection_, rhcHandle);
84  if (!(rhcHandle.isValid()))
85  {
86  // std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
87  return;
88  }
89  const EcalRecHitCollection* hit_collection = rhcHandle.product();
90 
91  int nRed = 0;
92 
93  // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and put in the Event:
94  std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection);
95 
96 
97  for(EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) {
98 
99  double NewEnergy =it->energy();
100  bool ItIsDead=false;
101  //Dead Cells are read from text files
102  std::vector<EBDetId>::const_iterator DeadCell;
103  for(DeadCell=ChannelsDeadID.begin();DeadCell<ChannelsDeadID.end();DeadCell++){
104  if(it->detid()==*DeadCell){
105  ItIsDead=true;
106  NewEnergy =0.;
107  nRed++;
108 
109  }
110  }//End looping on vector of Dead Cells
111 
112  // Make a new RecHit
113  //
114  // TODO what will be the it->time() for D.C. ?
115  // Could we use it for "correction" identification?
116  //
117  if(!ItIsDead){
118  EcalRecHit NewHit(it->id(),NewEnergy,it->time());
119  redCollection->push_back( NewHit );
120  }
121  }
122  // std::cout << "total # hits: " << nTot << " #hits with E = " << 0 << " GeV : " << nRed << std::endl;
123 
124  iEvent.put(redCollection, reducedHitCollection_);
125 
126 }
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< EBDetId > ChannelsDeadID
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::string hitCollection_
std::string hitProducer_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string reducedHitCollection_

Member Data Documentation

std::vector<EBDetId> EcalChannelKiller::ChannelsDeadID
private

Definition at line 45 of file EcalChannelKiller.h.

std::string EcalChannelKiller::DeadChannelFileName_
private

Definition at line 44 of file EcalChannelKiller.h.

std::string EcalChannelKiller::hitCollection_
private

Definition at line 42 of file EcalChannelKiller.h.

std::string EcalChannelKiller::hitProducer_
private

Definition at line 41 of file EcalChannelKiller.h.

std::string EcalChannelKiller::reducedHitCollection_
private

Definition at line 43 of file EcalChannelKiller.h.