#include <EcalPreshowerRecHitsMaker.h>
Public Member Functions | |
EcalPreshowerRecHitsMaker (edm::ParameterSet const &p, const RandomEngine *random) | |
void | init (const edm::EventSetup &es) |
void | loadEcalPreshowerRecHits (edm::Event &iEvent, ESRecHitCollection &esRecHits) |
~EcalPreshowerRecHitsMaker () | |
Private Member Functions | |
void | clean () |
unsigned | createVectorsOfCells (const edm::EventSetup &es) |
void | Fill (uint32_t id, float energy, std::map< uint32_t, std::pair< float, bool > > &myHits, bool signal=true) |
void | loadPCaloHits (const edm::Event &iEvent) |
void | noisify () |
void | noisifySignal (std::map< uint32_t, std::pair< float, bool > > &theMap) |
void | noisifySubdet (std::map< uint32_t, std::pair< float, bool > > &theMap, const std::vector< uint32_t > &thecells, unsigned ncells) |
Private Attributes | |
std::map< uint32_t, std::pair < float, bool > > | ecalsRecHits_ |
std::vector< uint32_t > | escells_ |
bool | initialized_ |
edm::InputTag | inputCol_ |
const GaussianTail * | myGaussianTailGenerator_ |
unsigned | ncells_ |
double | noise_ |
double | preshowerHotFraction_ |
const RandomEngine * | random_ |
double | threshold_ |
Definition at line 21 of file EcalPreshowerRecHitsMaker.h.
EcalPreshowerRecHitsMaker::EcalPreshowerRecHitsMaker | ( | edm::ParameterSet const & | p, |
const RandomEngine * | random | ||
) |
Definition at line 19 of file EcalPreshowerRecHitsMaker.cc.
References edm::ParameterSet::getParameter(), initialized_, inputCol_, myGaussianTailGenerator_, noise_, preshowerHotFraction_, random_, mathSSE::sqrt(), and threshold_.
: random_(myrandom), myGaussianTailGenerator_(0) { edm::ParameterSet RecHitsParameters = p.getParameter<edm::ParameterSet>("ECALPreshower"); noise_ = RecHitsParameters.getParameter<double>("Noise"); threshold_ = RecHitsParameters.getParameter<double>("Threshold"); inputCol_=RecHitsParameters.getParameter<edm::InputTag>("MixedSimHits"); initialized_=false; Genfun::Erf myErf; if( noise_>0. ) { preshowerHotFraction_ = 0.5-0.5*myErf(threshold_/noise_/sqrt(2.)); myGaussianTailGenerator_ = new GaussianTail(random_, noise_, threshold_); } else { preshowerHotFraction_ =0.; } }
EcalPreshowerRecHitsMaker::~EcalPreshowerRecHitsMaker | ( | ) |
Definition at line 43 of file EcalPreshowerRecHitsMaker.cc.
References initialized_, and myGaussianTailGenerator_.
{ initialized_=false; delete myGaussianTailGenerator_; }
void EcalPreshowerRecHitsMaker::clean | ( | ) | [private] |
Definition at line 49 of file EcalPreshowerRecHitsMaker.cc.
References ecalsRecHits_.
Referenced by loadPCaloHits().
{ ecalsRecHits_.clear(); }
unsigned EcalPreshowerRecHitsMaker::createVectorsOfCells | ( | const edm::EventSetup & | es | ) | [private] |
Definition at line 107 of file EcalPreshowerRecHitsMaker.cc.
References DetId::Ecal, EcalPreshower, escells_, relativeConstraints::geom, edm::EventSetup::get(), CaloSubdetectorGeometry::getValidDetIds(), i, and pileupDistInMC::total.
Referenced by init().
{ edm::ESHandle<CaloGeometry> pG; es.get<CaloGeometryRecord>().get(pG); unsigned total=0; escells_.reserve(137728); const CaloSubdetectorGeometry* geom=pG->getSubdetectorGeometry(DetId::Ecal,EcalPreshower); if(geom==0) return 0; const std::vector<DetId>& ids(geom->getValidDetIds(DetId::Ecal,EcalPreshower)); for (std::vector<DetId>::const_iterator i=ids.begin(); i!=ids.end(); i++) { escells_.push_back(i->rawId()); ++total; } return escells_.size(); }
void EcalPreshowerRecHitsMaker::Fill | ( | uint32_t | id, |
float | energy, | ||
std::map< uint32_t, std::pair< float, bool > > & | myHits, | ||
bool | signal = true |
||
) | [private] |
Definition at line 169 of file EcalPreshowerRecHitsMaker.cc.
References relval_parameters_module::energy, RandomEngine::gaussShoot(), errorMatrix2Lands_multiChannel::id, noise_, and random_.
Referenced by loadPCaloHits().
{ // The signal hits are singletons (no need to look into a map) if(signal) { // a new hit is created // we can give a hint for the insert // Add the noise at this point. We are sure that it won't be added several times energy += random_->gaussShoot(0.,noise_); std::pair<float,bool> hit(energy,false); // if it is signal, it is already ordered, so we can give a hint for the // insert if(signal) myHits.insert(myHits.end(),std::pair<uint32_t,std::pair<float,bool> >(id,hit)); } else // In this case,there is a risk of duplication. Need to look into the map { std::map<uint32_t,std::pair<float,bool> >::iterator itcheck=myHits.find(id); if(itcheck==myHits.end()) { energy += random_->gaussShoot(0.,noise_); std::pair<float,bool> hit(energy,false); myHits.insert(std::pair<uint32_t,std::pair<float,bool> >(id,hit)); } else { itcheck->second.first += energy; } } }
void EcalPreshowerRecHitsMaker::init | ( | const edm::EventSetup & | es | ) |
Definition at line 99 of file EcalPreshowerRecHitsMaker.cc.
References createVectorsOfCells(), initialized_, and ncells_.
Referenced by CaloRecHitsProducer::beginRun().
{ if(initialized_) return; ncells_=createVectorsOfCells(es); edm::LogInfo("CaloRecHitsProducer") << "Total number of cells in Preshower " << ncells_ << std::endl; initialized_=true; }
void EcalPreshowerRecHitsMaker::loadEcalPreshowerRecHits | ( | edm::Event & | iEvent, |
ESRecHitCollection & | esRecHits | ||
) |
Definition at line 56 of file EcalPreshowerRecHitsMaker.cc.
References cond::rpcobgas::detid, ecalsRecHits_, loadPCaloHits(), myGaussianTailGenerator_, ncells_, noisify(), edm::SortedCollection< T, SORT >::push_back(), and threshold_.
Referenced by CaloRecHitsProducer::produce().
{ // if no preshower, do nothing if(ncells_==0) return; loadPCaloHits(iEvent); if( myGaussianTailGenerator_ ) noisify(); std::map<uint32_t,std::pair<float,bool> >::const_iterator it=ecalsRecHits_.begin(); std::map<uint32_t,std::pair<float,bool> >::const_iterator itend=ecalsRecHits_.end(); for(;it!=itend;++it) { // check if the hit has been killed if(it->second.second) continue; // check if it is above the threshold if(it->second.first<threshold_) continue; ESDetId detid(it->first); // std::cout << detid << " " << it->second.first << std::endl; ecalHits.push_back(EcalRecHit(detid,it->second.first,0.)); } }
void EcalPreshowerRecHitsMaker::loadPCaloHits | ( | const edm::Event & | iEvent | ) | [private] |
Definition at line 81 of file EcalPreshowerRecHitsMaker.cc.
References clean(), ecalsRecHits_, Fill(), edm::Event::getByLabel(), inputCol_, and edm::Handle< T >::product().
Referenced by loadEcalPreshowerRecHits().
{ clean(); edm::Handle<CrossingFrame<PCaloHit> > cf; iEvent.getByLabel(inputCol_,cf); std::auto_ptr<MixCollection<PCaloHit> > colcalo(new MixCollection<PCaloHit>(cf.product(),std::pair<int,int>(0,0) )); MixCollection<PCaloHit>::iterator it=colcalo->begin(); MixCollection<PCaloHit>::iterator itend=colcalo->end(); for(;it!=itend;++it) { Fill(it->id(),it->energy(),ecalsRecHits_,it.getTrigger()); // Fill(it->id(),it->energy(),ecalsRecHits_); } }
void EcalPreshowerRecHitsMaker::noisify | ( | ) | [private] |
Definition at line 126 of file EcalPreshowerRecHitsMaker.cc.
References ecalsRecHits_, escells_, ncells_, and noisifySubdet().
Referenced by loadEcalPreshowerRecHits().
{ if(ecalsRecHits_.size()<ncells_) { // Not needed anymore, the noise is added when loading the PCaloHits // noisifySignal(ecalsRecHits_); noisifySubdet(ecalsRecHits_,escells_,ncells_); } else edm::LogWarning("CaloRecHitsProducer") << "All Preshower cells on ! " << std::endl; }
void EcalPreshowerRecHitsMaker::noisifySignal | ( | std::map< uint32_t, std::pair< float, bool > > & | theMap | ) | [private] |
void EcalPreshowerRecHitsMaker::noisifySubdet | ( | std::map< uint32_t, std::pair< float, bool > > & | theMap, |
const std::vector< uint32_t > & | thecells, | ||
unsigned | ncells | ||
) | [private] |
Definition at line 139 of file EcalPreshowerRecHitsMaker.cc.
References RandomEngine::flatShoot(), timingPdfMaker::mean, myGaussianTailGenerator_, RandomEngine::poissonShoot(), preshowerHotFraction_, random_, and GaussianTail::shoot().
Referenced by noisify().
{ // noise won't be injected in cells that contain signal double mean = (double)(ncells-theMap.size())*preshowerHotFraction_; unsigned nps = random_->poissonShoot(mean); unsigned ncell=0; unsigned cellindex=0; uint32_t cellnumber=0; std::map<uint32_t,std::pair<float,bool> >::const_iterator itcheck; while(ncell < nps) { cellindex = (unsigned)(random_->flatShoot()*ncells); cellnumber = thecells[cellindex]; itcheck=theMap.find(cellnumber); if(itcheck==theMap.end()) // inject only in empty cells { std::pair <float,bool> noisehit(myGaussianTailGenerator_->shoot(), false); theMap.insert(std::pair<uint32_t,std::pair<float,bool> > (cellnumber,noisehit)); ++ncell; } } // edm::LogInfo("CaloRecHitsProducer") << "CaloRecHitsProducer : added noise in "<< ncell << " HCAL cells " << std::endl; }
std::map<uint32_t,std::pair<float,bool> > EcalPreshowerRecHitsMaker::ecalsRecHits_ [private] |
Definition at line 54 of file EcalPreshowerRecHitsMaker.h.
Referenced by clean(), loadEcalPreshowerRecHits(), loadPCaloHits(), and noisify().
std::vector<uint32_t> EcalPreshowerRecHitsMaker::escells_ [private] |
Definition at line 55 of file EcalPreshowerRecHitsMaker.h.
Referenced by createVectorsOfCells(), and noisify().
bool EcalPreshowerRecHitsMaker::initialized_ [private] |
Definition at line 52 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), init(), and ~EcalPreshowerRecHitsMaker().
Definition at line 48 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), and loadPCaloHits().
const GaussianTail* EcalPreshowerRecHitsMaker::myGaussianTailGenerator_ [private] |
Definition at line 57 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), loadEcalPreshowerRecHits(), noisifySubdet(), and ~EcalPreshowerRecHitsMaker().
unsigned EcalPreshowerRecHitsMaker::ncells_ [private] |
Definition at line 53 of file EcalPreshowerRecHitsMaker.h.
Referenced by init(), loadEcalPreshowerRecHits(), and noisify().
double EcalPreshowerRecHitsMaker::noise_ [private] |
Definition at line 50 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), and Fill().
double EcalPreshowerRecHitsMaker::preshowerHotFraction_ [private] |
Definition at line 51 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), and noisifySubdet().
const RandomEngine* EcalPreshowerRecHitsMaker::random_ [private] |
Definition at line 56 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), Fill(), and noisifySubdet().
double EcalPreshowerRecHitsMaker::threshold_ [private] |
Definition at line 49 of file EcalPreshowerRecHitsMaker.h.
Referenced by EcalPreshowerRecHitsMaker(), and loadEcalPreshowerRecHits().