CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalDeadChannelRecoveryProducers Class Reference

#include <RecoLocalCalo/EcalDeadChannelRecoveryProducers/src/EcalDeadChannelRecoveryProducers.cc>

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

List of all members.

Public Member Functions

 EcalDeadChannelRecoveryProducers (const edm::ParameterSet &)
 ~EcalDeadChannelRecoveryProducers ()

Private Member Functions

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

Private Attributes

std::vector< EBDetIdChannelsDeadID
bool CorrectDeadCells_
std::string CorrectionMethod_
std::string DeadChannelFileName_
std::string hitCollection_
std::string hitProducer_
std::string reducedHitCollection_
double Sum8GeVThreshold_

Detailed Description

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

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

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

Definition at line 30 of file EcalDeadChannelRecoveryProducers.h.


Constructor & Destructor Documentation

EcalDeadChannelRecoveryProducers::EcalDeadChannelRecoveryProducers ( const edm::ParameterSet ps) [explicit]

Definition at line 57 of file EcalDeadChannelRecoveryProducers.cc.

References edm::ParameterSet::getParameter().

{

   //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_);
}
EcalDeadChannelRecoveryProducers::~EcalDeadChannelRecoveryProducers ( )

Definition at line 73 of file EcalDeadChannelRecoveryProducers.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void EcalDeadChannelRecoveryProducers::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 143 of file EcalDeadChannelRecoveryProducers.cc.

References gather_cfg::cout.

{
    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);
    //    std::cout<<" ieta "<<ieta<<" iphi "<<iphi<<std::endl;
    if(ieta==-10000||iphi==-10000){std::cout << "Problem reading Dead Channels file "<<std::endl;break;}
    EBDetId cell(ieta,iphi);
    ChannelsDeadID.push_back(cell);
    } //end while           
    fclose(DeadCha);
    //  std::cout<<" Read "<<ChannelsDeadID.size()<<" dead channels "<<std::endl;
  
}
void EcalDeadChannelRecoveryProducers::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 166 of file EcalDeadChannelRecoveryProducers.cc.

                                         {
}
void EcalDeadChannelRecoveryProducers::produce ( edm::Event evt,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 88 of file EcalDeadChannelRecoveryProducers.cc.

References gather_cfg::cout, edm::EventSetup::get(), edm::Event::getByLabel(), and edm::Event::put().

{
  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);
  
  EcalDeadChannelRecoveryAlgos *DeadChannelCorrector = new EcalDeadChannelRecoveryAlgos(theCaloTopology.product());
  
  //Dead Cells are read from a text file
  std::vector<EBDetId>::const_iterator DeadCell;

  //
  //This should work only if we REMOVE the DC RecHit from the reduced RecHit collection 
  //
  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;break;}
      CheckDead++;
    }
    if(!OverADeadRecHit)redCollection->push_back( *it );
  }
  for(DeadCell=ChannelsDeadID.begin();DeadCell<ChannelsDeadID.end();DeadCell++){
    EcalRecHit NewRecHit = DeadChannelCorrector->Correct(*DeadCell,hit_collection,CorrectionMethod_,Sum8GeVThreshold_);
    redCollection->push_back( NewRecHit );
  }



  
  delete DeadChannelCorrector ;
  
  evt.put(redCollection, reducedHitCollection_);
  
}

Member Data Documentation

Definition at line 47 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 48 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 49 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 46 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 44 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 43 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 45 of file EcalDeadChannelRecoveryProducers.h.

Definition at line 42 of file EcalDeadChannelRecoveryProducers.h.