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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalChannelKiller (const edm::ParameterSet &)
 
 ~EcalChannelKiller ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 28 of file EcalChannelKiller.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file EcalChannelKiller.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 61 of file EcalChannelKiller.cc.

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

Member Function Documentation

void EcalChannelKiller::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 132 of file EcalChannelKiller.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 159 of file EcalChannelKiller.cc.

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

Implements edm::EDProducer.

Definition at line 76 of file EcalChannelKiller.cc.

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

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

Member Data Documentation

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

Definition at line 43 of file EcalChannelKiller.h.

std::string EcalChannelKiller::DeadChannelFileName_
private

Definition at line 42 of file EcalChannelKiller.h.

std::string EcalChannelKiller::hitCollection_
private

Definition at line 40 of file EcalChannelKiller.h.

std::string EcalChannelKiller::hitProducer_
private

Definition at line 39 of file EcalChannelKiller.h.

std::string EcalChannelKiller::reducedHitCollection_
private

Definition at line 41 of file EcalChannelKiller.h.