![]() |
![]() |
#include <RecoCaloTools/EcalChannelKiller/src/EcalChannelKiller.cc>
Public Member Functions | |
EcalChannelKiller (const edm::ParameterSet &) | |
~EcalChannelKiller () | |
Private Member Functions | |
virtual void | beginJob (const edm::EventSetup &) |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
vector< EBDetId > | ChannelsDeadID |
string | DeadChannelFileName_ |
string | hitCollection_ |
string | hitProducer_ |
string | reducedHitCollection_ |
Description: <one line="" class="" summary>="">.
Implementation: <Notes on="" implementation>="">
Definition at line 31 of file EcalChannelKiller.h.
EcalChannelKiller::EcalChannelKiller | ( | const edm::ParameterSet & | ps | ) | [explicit] |
Definition at line 47 of file EcalChannelKiller.cc.
References DeadChannelFileName_, edm::ParameterSet::getParameter(), hitCollection_, hitProducer_, and reducedHitCollection_.
00048 { 00049 00050 hitProducer_ = ps.getParameter<std::string>("hitProducer"); 00051 hitCollection_ = ps.getParameter<std::string>("hitCollection"); 00052 reducedHitCollection_ = ps.getParameter<std::string>("reducedHitCollection"); 00053 DeadChannelFileName_ = ps.getParameter<std::string>("DeadChannelsFile"); 00054 00055 produces< EcalRecHitCollection >(reducedHitCollection_); 00056 00057 00058 }
EcalChannelKiller::~EcalChannelKiller | ( | ) |
Definition at line 61 of file EcalChannelKiller.cc.
00062 { 00063 00064 // do anything here that needs to be done at desctruction time 00065 // (e.g. close files, deallocate resources etc.) 00066 00067 }
void EcalChannelKiller::beginJob | ( | const edm::EventSetup & | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 135 of file EcalChannelKiller.cc.
References ChannelsDeadID, GenMuonPlsPt100GeV_cfg::cout, DeadChannelFileName_, and lat::endl().
00136 { 00137 00138 //Open the DeadChannel file, read it. 00139 FILE* DeadCha; 00140 printf("Dead Channels FILE: %s\n",DeadChannelFileName_.c_str()); 00141 DeadCha = fopen(DeadChannelFileName_.c_str(),"r"); 00142 00143 int fileStatus=0; 00144 int ieta=-10000; 00145 int iphi=-10000; 00146 while(fileStatus != EOF) { 00147 fileStatus = fscanf(DeadCha,"%d %d\n",&ieta,&iphi); 00148 cout<<" ieta "<<ieta<<" iphi "<<iphi<<endl; 00149 if(ieta==-10000||iphi==-10000){std::cout << "Problem reading Dead Channels file "<<std::endl;break;} 00150 EBDetId cell(ieta,iphi); 00151 ChannelsDeadID.push_back(cell); 00152 } //end while 00153 fclose(DeadCha); 00154 std::cout<<" Read "<<ChannelsDeadID.size()<<" dead channels "<<std::endl; 00155 00156 }
void EcalChannelKiller::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 76 of file EcalChannelKiller.cc.
References edm::SortedCollection< T, SORT >::begin(), ChannelsDeadID, GenMuonPlsPt100GeV_cfg::cout, edm::SortedCollection< T, SORT >::end(), lat::endl(), edm::Event::getByLabel(), hitCollection_, hitProducer_, edm::Handle< T >::isValid(), it, edm::Handle< T >::product(), edm::Event::put(), DetId::rawId(), reducedHitCollection_, and edm::SortedCollection< T, SORT >::size().
00077 { 00078 using namespace edm; 00079 00080 // get the hit collection from the event: 00081 edm::Handle<EcalRecHitCollection> rhcHandle; 00082 iEvent.getByLabel(hitProducer_, hitCollection_, rhcHandle); 00083 if (!(rhcHandle.isValid())) 00084 { 00085 std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl; 00086 return; 00087 } 00088 const EcalRecHitCollection* hit_collection = rhcHandle.product(); 00089 00090 int nTot = hit_collection->size(); 00091 int nRed = 0; 00092 00093 // create an auto_ptr to a EcalRecHitCollection, copy the RecHits into it and put in the Event: 00094 std::auto_ptr< EcalRecHitCollection > redCollection(new EcalRecHitCollection); 00095 00096 00097 for(EcalRecHitCollection::const_iterator it = hit_collection->begin(); it != hit_collection->end(); ++it) { 00098 00099 double NewEnergy =it->energy(); 00100 bool ItIsDead=false; 00101 //Dead Cells are read from text files 00102 vector<EBDetId>::const_iterator DeadCell; 00103 for(DeadCell=ChannelsDeadID.begin();DeadCell<ChannelsDeadID.end();DeadCell++){ 00104 if(it->detid()==*DeadCell){ 00105 DetId itID = it->id(); 00106 cout<<" +++++++++++ Old Energy "<<it->energy()<<" eta "<< itID.rawId()<<endl; 00107 ItIsDead=true; 00108 NewEnergy =0.; 00109 nRed++; 00110 00111 } 00112 }//End looping on vector of Dead Cells 00113 00114 // Make a new RecHit 00115 // 00116 // TODO what will be the it->time() for D.C. ? 00117 // Could we use it for "correction" identification? 00118 // 00119 if(!ItIsDead){ 00120 EcalRecHit NewHit(it->id(),NewEnergy,it->time()); 00121 redCollection->push_back( NewHit ); 00122 } 00123 } 00124 std::cout << "total # hits: " << nTot << " #hits with E = " << 0 << " GeV : " << nRed << std::endl; 00125 00126 iEvent.put(redCollection, reducedHitCollection_); 00127 00128 }
vector<EBDetId> EcalChannelKiller::ChannelsDeadID [private] |
string EcalChannelKiller::DeadChannelFileName_ [private] |
Definition at line 45 of file EcalChannelKiller.h.
Referenced by beginJob(), and EcalChannelKiller().
string EcalChannelKiller::hitCollection_ [private] |
Definition at line 43 of file EcalChannelKiller.h.
Referenced by EcalChannelKiller(), and produce().
string EcalChannelKiller::hitProducer_ [private] |
Definition at line 42 of file EcalChannelKiller.h.
Referenced by EcalChannelKiller(), and produce().
string EcalChannelKiller::reducedHitCollection_ [private] |
Definition at line 44 of file EcalChannelKiller.h.
Referenced by EcalChannelKiller(), and produce().