#include <ESFastTDigitizer.h>
Public Member Functions | |
void | addNoiseHits () |
void | createNoisyList (std::vector< int > &abThreshCh) |
preparing the list of channels where the noise has to be generated | |
ESFastTDigitizer (CaloHitResponse *hitResponse, ESElectronicsSimFast *electronicsSim, bool addNoise, int numESdetId) | |
void | readHistosFromFile () |
taking reference histos | |
void | run (MixCollection< PCaloHit > &input, ESDigiCollection &output) |
turns hits into digis | |
void | setDetIds (const std::vector< DetId > &detIds) |
tell the digitizer which cells exist | |
void | setGain (const int gain) |
set ES Gain | |
void | setNoiseHitGenerator (CaloVNoiseHitGenerator *generator) |
~ESFastTDigitizer () | |
Private Attributes | |
bool | addNoise_ |
int | ESGain_ |
double | histoBin_ |
CLHEP::RandGeneral * | histoDistribution_ |
double | histoInf_ |
double | histoSup_ |
ifstream * | m_histofile |
int | numESdetId_ |
std::string | refFile_ |
double * | refHistos_ |
bool | setRefFile_ |
const std::vector< DetId > * | theDetIds |
ESElectronicsSimFast * | theElectronicsSim |
CaloHitResponse * | theHitResponse |
CaloVNoiseHitGenerator * | theNoiseHitGenerator |
double | zsThreshold_ |
Definition at line 26 of file ESFastTDigitizer.h.
ESFastTDigitizer::ESFastTDigitizer | ( | CaloHitResponse * | hitResponse, |
ESElectronicsSimFast * | electronicsSim, | ||
bool | addNoise, | ||
int | numESdetId | ||
) | [inline] |
Definition at line 30 of file ESFastTDigitizer.h.
References setRefFile_.
: theHitResponse(hitResponse), theNoiseHitGenerator(0), theElectronicsSim(electronicsSim), theDetIds(0), addNoise_(addNoise), numESdetId_(numESdetId), refHistos_ ( 0 ), histoDistribution_(0) { setRefFile_ = true; }
ESFastTDigitizer::~ESFastTDigitizer | ( | ) | [inline] |
Definition at line 45 of file ESFastTDigitizer.h.
References histoDistribution_, and refHistos_.
{ delete histoDistribution_; delete [] refHistos_; }
void ESFastTDigitizer::addNoiseHits | ( | ) | [inline] |
Definition at line 225 of file ESFastTDigitizer.h.
References CaloHitResponse::add(), CaloVNoiseHitGenerator::getNoiseHits(), theHitResponse, and theNoiseHitGenerator.
Referenced by run().
{ std::vector<PCaloHit> noiseHits; theNoiseHitGenerator->getNoiseHits(noiseHits); for(std::vector<PCaloHit>::const_iterator hitItr = noiseHits.begin(), hitEnd = noiseHits.end(); hitItr != hitEnd; ++hitItr) { theHitResponse->add(*hitItr); } }
void ESFastTDigitizer::createNoisyList | ( | std::vector< int > & | abThreshCh | ) | [inline] |
preparing the list of channels where the noise has to be generated
Definition at line 126 of file ESFastTDigitizer.h.
References benchmark_cfg::cerr, Exception, spr::find(), i, edm::Service< T >::isAvailable(), numESdetId_, query::result, ntuplemaker::status, and zsThreshold_.
Referenced by run().
{ edm::Service<edm::RandomNumberGenerator> rng; if ( ! rng.isAvailable()) { throw cms::Exception("Configuration") << "ESFastTDigitizer requires the RandomNumberGeneratorService\n" "which is not present in the configuration file. You must add the service\n" "in the configuration file or remove the modules that require it."; } CLHEP::RandPoissonQ poissonDistribution_(rng->getEngine()); CLHEP::RandFlat flatDistribution_(rng->getEngine()); gsl_sf_result result; int status = gsl_sf_erf_Q_e(zsThreshold_, &result); if (status != 0) std::cerr<<"ESFastTDigitizer::could not compute gaussian tail probability for the threshold chosen"<<std::endl; double probabilityLeft = result.val; double meanNumberOfNoisyChannels = probabilityLeft * numESdetId_; int numberOfNoisyChannels = poissonDistribution_.fire(meanNumberOfNoisyChannels); abThreshCh.reserve(numberOfNoisyChannels); for (int i = 0; i < numberOfNoisyChannels; i++) { std::vector<int>::iterator theChannel; int theChannelNumber = 0; do { theChannelNumber = (int)flatDistribution_.fire(numESdetId_); theChannel = find(abThreshCh.begin(), abThreshCh.end(), theChannelNumber); } while ( theChannel!=abThreshCh.end() ); abThreshCh.push_back(theChannelNumber); } }
void ESFastTDigitizer::readHistosFromFile | ( | ) | [inline] |
taking reference histos
Definition at line 69 of file ESFastTDigitizer.h.
References Exception, histoBin_, histoDistribution_, histoInf_, histoSup_, edm::errors::InvalidReference, edm::Service< T >::isAvailable(), m_histofile, refFile_, and refHistos_.
Referenced by setGain().
{ m_histofile = new ifstream (edm::FileInPath(refFile_).fullPath().c_str()); if (m_histofile == 0){ throw edm::Exception(edm::errors::InvalidReference,"NullPointer") << "Reference histos file not opened" ; return ; } // number of bins char buffer[200]; int thisLine = 0; while( thisLine==0 ) { m_histofile->getline(buffer,400); if (!strstr(buffer,"#") && !(strspn(buffer," ") == strlen(buffer))){ float histoBin; sscanf(buffer,"%f",&histoBin); histoBin_ = (double)histoBin; thisLine++; } } int histoBin3 = (int)(histoBin_*histoBin_*histoBin_); refHistos_ = new double[histoBin3]; // all info int thisBin = -2; while( !(m_histofile->eof()) ){ m_histofile->getline(buffer,400); if (!strstr(buffer,"#") && !(strspn(buffer," ") == strlen(buffer))){ if(thisBin==-2){ float histoInf; sscanf(buffer,"%f",&histoInf); histoInf_ = (double)histoInf; } if(thisBin==-1){ float histoSup; sscanf(buffer,"%f",&histoSup); histoSup_ = (double)histoSup; } if (thisBin>=0){ float refBin; sscanf(buffer,"%f",&refBin); refHistos_[thisBin] = (double)refBin; } thisBin++; } } // creating the reference distribution to extract random numbers edm::Service<edm::RandomNumberGenerator> rng; if ( ! rng.isAvailable()) { throw cms::Exception("Configuration") << "ESFastTDigitizer requires the RandomNumberGeneratorService\n" "which is not present in the configuration file. You must add the service\n" "in the configuration file or remove the modules that require it."; } CLHEP::HepRandomEngine& engine = rng->getEngine(); histoDistribution_ = new CLHEP::RandGeneral(engine, refHistos_, histoBin3, 0); m_histofile->close(); delete m_histofile; }
void ESFastTDigitizer::run | ( | MixCollection< PCaloHit > & | input, |
ESDigiCollection & | output | ||
) | [inline] |
turns hits into digis
Definition at line 167 of file ESFastTDigitizer.h.
References addNoise_, addNoiseHits(), ESElectronicsSimFast::analogToDigital(), CaloHitResponse::clear(), createNoisyList(), spr::find(), CaloHitResponse::findSignal(), histoBin_, histoDistribution_, histoInf_, histoSup_, CaloHitResponse::makeBlankSignal(), ESElectronicsSimFast::newEvent(), CaloHitResponse::nSignals(), edm::SortedCollection< T, SORT >::push_back(), edm::SortedCollection< T, SORT >::reserve(), CaloHitResponse::run(), theDetIds, theElectronicsSim, theHitResponse, and theNoiseHitGenerator.
Referenced by EcalDigiProducer::produce().
{ assert( 0 != theDetIds && 0 != theDetIds->size() ); theHitResponse->run(input); if(theNoiseHitGenerator != 0) addNoiseHits(); theElectronicsSim->newEvent(); // reserve space for how many digis we expect int nDigisExpected = addNoise_ ? theDetIds->size() : theHitResponse->nSignals(); output.reserve(nDigisExpected); // random generation of channel above threshold std::vector<int> abThreshCh; if (addNoise_) createNoisyList(abThreshCh); // make a raw digi for evey cell where we have noise int idxDetId=0; for(std::vector<DetId>::const_iterator idItr = theDetIds->begin(); idItr != theDetIds->end(); ++idItr,++idxDetId) { bool needToDeleteSignal = false; CaloSamples * analogSignal = theHitResponse->findSignal(*idItr); // signal or just noise? bool wasEmpty = false; if (!analogSignal){ // no signal here wasEmpty = true; if (!addNoise_) continue; else { std::vector<int>::iterator thisChannel; thisChannel = find( abThreshCh.begin(), abThreshCh.end(), idxDetId); if( thisChannel != abThreshCh.end() ) { analogSignal = new CaloSamples(theHitResponse->makeBlankSignal(*idItr)); needToDeleteSignal = true; } } } if (analogSignal != 0){ // either we have a signal or we need to generate noise samples ESDataFrame digi(*idItr); theElectronicsSim->analogToDigital(*analogSignal , digi, wasEmpty, histoDistribution_, histoInf_, histoSup_, histoBin_); output.push_back(digi); if (needToDeleteSignal) delete analogSignal; } } // free up some memory theHitResponse->clear(); }
void ESFastTDigitizer::setDetIds | ( | const std::vector< DetId > & | detIds | ) | [inline] |
tell the digitizer which cells exist
Definition at line 160 of file ESFastTDigitizer.h.
References theDetIds.
Referenced by EcalDigiProducer::updateGeometry().
{theDetIds = &detIds;}
void ESFastTDigitizer::setGain | ( | const int | gain | ) | [inline] |
set ES Gain
Definition at line 50 of file ESFastTDigitizer.h.
References addNoise_, ESGain_, readHistosFromFile(), refFile_, setRefFile_, and zsThreshold_.
Referenced by EcalDigiProducer::checkCalibrations().
{ ESGain_ = gain; if (ESGain_ == 1) { zsThreshold_ = 3; refFile_ = "SimCalorimetry/EcalSimProducers/data/esRefHistosFile_LG.txt"; } else if (ESGain_ == 2) { zsThreshold_ = 4; refFile_ = "SimCalorimetry/EcalSimProducers/data/esRefHistosFile_HG.txt"; } if (addNoise_ && setRefFile_) { readHistosFromFile(); setRefFile_ = false; } }
void ESFastTDigitizer::setNoiseHitGenerator | ( | CaloVNoiseHitGenerator * | generator | ) | [inline] |
Definition at line 162 of file ESFastTDigitizer.h.
References python::IdGenerator::generator, and theNoiseHitGenerator.
{ theNoiseHitGenerator = generator; }
bool ESFastTDigitizer::addNoise_ [private] |
Definition at line 241 of file ESFastTDigitizer.h.
int ESFastTDigitizer::ESGain_ [private] |
Definition at line 244 of file ESFastTDigitizer.h.
Referenced by setGain().
double ESFastTDigitizer::histoBin_ [private] |
Definition at line 250 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), and run().
CLHEP::RandGeneral* ESFastTDigitizer::histoDistribution_ [private] |
Definition at line 254 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), run(), and ~ESFastTDigitizer().
double ESFastTDigitizer::histoInf_ [private] |
Definition at line 251 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), and run().
double ESFastTDigitizer::histoSup_ [private] |
Definition at line 252 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), and run().
ifstream* ESFastTDigitizer::m_histofile [private] |
Definition at line 248 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile().
int ESFastTDigitizer::numESdetId_ [private] |
Definition at line 243 of file ESFastTDigitizer.h.
Referenced by createNoisyList().
std::string ESFastTDigitizer::refFile_ [private] |
Definition at line 247 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), and setGain().
double* ESFastTDigitizer::refHistos_ [private] |
Definition at line 249 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), and ~ESFastTDigitizer().
bool ESFastTDigitizer::setRefFile_ [private] |
Definition at line 242 of file ESFastTDigitizer.h.
Referenced by ESFastTDigitizer(), and setGain().
const std::vector<DetId>* ESFastTDigitizer::theDetIds [private] |
Definition at line 240 of file ESFastTDigitizer.h.
Referenced by run(), and setDetIds().
Definition at line 239 of file ESFastTDigitizer.h.
Referenced by run().
CaloHitResponse* ESFastTDigitizer::theHitResponse [private] |
Definition at line 237 of file ESFastTDigitizer.h.
Referenced by addNoiseHits(), and run().
Definition at line 238 of file ESFastTDigitizer.h.
Referenced by addNoiseHits(), run(), and setNoiseHitGenerator().
double ESFastTDigitizer::zsThreshold_ [private] |
Definition at line 245 of file ESFastTDigitizer.h.
Referenced by createNoisyList(), and setGain().