![]() |
![]() |
#include <SimCalorimetry/EcalSimAlgos/interface/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, double zsThreshold, std::string refFile) | |
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 | setNoiseHitGenerator (CaloVNoiseHitGenerator *generator) |
~ESFastTDigitizer () | |
doesn't delete the pointers passed in | |
Private Attributes | |
bool | addNoise_ |
double | histoBin_ |
CLHEP::RandGeneral * | histoDistribution_ |
double | histoInf_ |
double | histoSup_ |
ifstream * | m_histofile |
int | numESdetId_ |
std::string | refFile_ |
double * | refHistos_ |
std::vector< DetId > | theDetIds |
ESElectronicsSimFast * | theElectronicsSim |
CaloHitResponse * | theHitResponse |
CaloVNoiseHitGenerator * | theNoiseHitGenerator |
double | zsThreshold_ |
Definition at line 28 of file ESFastTDigitizer.h.
ESFastTDigitizer::ESFastTDigitizer | ( | CaloHitResponse * | hitResponse, | |
ESElectronicsSimFast * | electronicsSim, | |||
bool | addNoise, | |||
int | numESdetId, | |||
double | zsThreshold, | |||
std::string | refFile | |||
) | [inline] |
Definition at line 32 of file ESFastTDigitizer.h.
References addNoise_, and readHistosFromFile().
00033 : theHitResponse(hitResponse), 00034 theNoiseHitGenerator(0), 00035 theElectronicsSim(electronicsSim), 00036 theDetIds(0), 00037 addNoise_(addNoise), 00038 numESdetId_(numESdetId), 00039 zsThreshold_(zsThreshold), 00040 refFile_(refFile) { 00041 00042 // reference distributions 00043 if (addNoise_) readHistosFromFile () ; 00044 }
ESFastTDigitizer::~ESFastTDigitizer | ( | ) | [inline] |
doesn't delete the pointers passed in
Definition at line 48 of file ESFastTDigitizer.h.
References histoDistribution_.
00048 { delete histoDistribution_; }
void ESFastTDigitizer::addNoiseHits | ( | ) | [inline] |
Definition at line 206 of file ESFastTDigitizer.h.
References CaloHitResponse::add(), CaloVNoiseHitGenerator::getNoiseHits(), theHitResponse, and theNoiseHitGenerator.
Referenced by run().
00206 { 00207 std::vector<PCaloHit> noiseHits; 00208 theNoiseHitGenerator->getNoiseHits(noiseHits); 00209 for(std::vector<PCaloHit>::const_iterator hitItr = noiseHits.begin(), 00210 hitEnd = noiseHits.end(); hitItr != hitEnd; ++hitItr) { 00211 theHitResponse->add(*hitItr); 00212 } 00213 }
preparing the list of channels where the noise has to be generated
Definition at line 108 of file ESFastTDigitizer.h.
References TestMuL1L2Filter_cff::cerr, lat::endl(), Exception, find(), i, int, edm::Service< T >::isAvailable(), numESdetId_, HLT_VtxMuL3::result, StDecayID::status, and zsThreshold_.
Referenced by run().
00108 { 00109 00110 edm::Service<edm::RandomNumberGenerator> rng; 00111 if ( ! rng.isAvailable()) { 00112 throw cms::Exception("Configuration") 00113 << "ESFastTDigitizer requires the RandomNumberGeneratorService\n" 00114 "which is not present in the configuration file. You must add the service\n" 00115 "in the configuration file or remove the modules that require it."; 00116 } 00117 CLHEP::RandPoissonQ poissonDistribution_(rng->getEngine()); 00118 CLHEP::RandFlat flatDistribution_(rng->getEngine()); 00119 00120 gsl_sf_result result; 00121 int status = gsl_sf_erf_Q_e(zsThreshold_, &result); 00122 if (status != 0) std::cerr<<"ESFastTDigitizer::could not compute gaussian tail probability for the threshold chosen"<<std::endl; 00123 double probabilityLeft = result.val; 00124 double meanNumberOfNoisyChannels = probabilityLeft * numESdetId_; 00125 int numberOfNoisyChannels = poissonDistribution_.fire(meanNumberOfNoisyChannels); 00126 abThreshCh.reserve(numberOfNoisyChannels); 00127 for (int i = 0; i < numberOfNoisyChannels; i++) { 00128 std::vector<int>::iterator theChannel; 00129 int theChannelNumber = 0; 00130 do { 00131 theChannelNumber = (int)flatDistribution_.fire(numESdetId_); 00132 theChannel = find(abThreshCh.begin(), abThreshCh.end(), theChannelNumber); 00133 } 00134 while ( theChannel!=abThreshCh.end() ); 00135 00136 abThreshCh.push_back(theChannelNumber); 00137 } 00138 }
void ESFastTDigitizer::readHistosFromFile | ( | ) | [inline] |
taking reference histos
Definition at line 51 of file ESFastTDigitizer.h.
References Exception, histoBin_, histoDistribution_, histoInf_, histoSup_, int, edm::errors::InvalidReference, edm::Service< T >::isAvailable(), m_histofile, refFile_, and refHistos_.
Referenced by ESFastTDigitizer().
00051 { 00052 00053 m_histofile = new ifstream (edm::FileInPath(refFile_).fullPath().c_str()); 00054 if (m_histofile == 0){ 00055 throw edm::Exception(edm::errors::InvalidReference,"NullPointer") 00056 << "Reference histos file not opened" ; 00057 return ; 00058 } 00059 00060 // number of bins 00061 char buffer[200]; 00062 int thisLine = 0; 00063 while( thisLine==0 ) { 00064 m_histofile->getline(buffer,400); 00065 if (!strstr(buffer,"#") && !(strspn(buffer," ") == strlen(buffer))){ 00066 float histoBin; 00067 sscanf(buffer,"%f",&histoBin); 00068 histoBin_ = (double)histoBin; 00069 thisLine++; 00070 } 00071 } 00072 int histoBin3 = (int)(histoBin_*histoBin_*histoBin_); 00073 refHistos_ = new double[histoBin3]; 00074 00075 // all info 00076 int thisBin = -2; 00077 while( !(m_histofile->eof()) ){ 00078 m_histofile->getline(buffer,400); 00079 if (!strstr(buffer,"#") && !(strspn(buffer," ") == strlen(buffer))){ 00080 if(thisBin==-2){ float histoInf; sscanf(buffer,"%f",&histoInf); histoInf_ = (double)histoInf; } 00081 if(thisBin==-1){ float histoSup; sscanf(buffer,"%f",&histoSup); histoSup_ = (double)histoSup; } 00082 00083 if (thisBin>=0){ 00084 float refBin; 00085 sscanf(buffer,"%f",&refBin); 00086 refHistos_[thisBin] = (double)refBin; 00087 } 00088 thisBin++; 00089 } 00090 } 00091 00092 // creating the reference distribution to extract random numbers 00093 edm::Service<edm::RandomNumberGenerator> rng; 00094 if ( ! rng.isAvailable()) { 00095 throw cms::Exception("Configuration") 00096 << "ESFastTDigitizer requires the RandomNumberGeneratorService\n" 00097 "which is not present in the configuration file. You must add the service\n" 00098 "in the configuration file or remove the modules that require it."; 00099 } 00100 CLHEP::HepRandomEngine& engine = rng->getEngine(); 00101 histoDistribution_ = new CLHEP::RandGeneral(engine, refHistos_, histoBin3, 0); 00102 00103 m_histofile->close(); 00104 delete m_histofile; 00105 }
void ESFastTDigitizer::run | ( | MixCollection< PCaloHit > & | input, | |
ESDigiCollection & | output | |||
) | [inline] |
turns hits into digis
Definition at line 149 of file ESFastTDigitizer.h.
References addNoise_, addNoiseHits(), ESElectronicsSimFast::analogToDigital(), CaloHitResponse::clear(), createNoisyList(), 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().
00149 { 00150 00151 assert(theDetIds.size() != 0); 00152 00153 theHitResponse->run(input); 00154 00155 if(theNoiseHitGenerator != 0) addNoiseHits(); 00156 00157 theElectronicsSim->newEvent(); 00158 00159 // reserve space for how many digis we expect 00160 int nDigisExpected = addNoise_ ? theDetIds.size() : theHitResponse->nSignals(); 00161 output.reserve(nDigisExpected); 00162 00163 // random generation of channel above threshold 00164 std::vector<int> abThreshCh; 00165 if (addNoise_) createNoisyList(abThreshCh); 00166 00167 // make a raw digi for evey cell where we have noise 00168 int idxDetId=0; 00169 for(std::vector<DetId>::const_iterator idItr = theDetIds.begin(); 00170 idItr != theDetIds.end(); ++idItr,++idxDetId) { 00171 00172 bool needToDeleteSignal = false; 00173 CaloSamples * analogSignal = theHitResponse->findSignal(*idItr); 00174 00175 // signal or just noise? 00176 bool wasEmpty = false; 00177 00178 if (!analogSignal){ // no signal here 00179 wasEmpty = true; 00180 if (!addNoise_) continue; 00181 else { 00182 std::vector<int>::iterator thisChannel; 00183 thisChannel = find( abThreshCh.begin(), abThreshCh.end(), idxDetId); 00184 if( thisChannel != abThreshCh.end() ) { 00185 analogSignal = new CaloSamples(theHitResponse->makeBlankSignal(*idItr)); 00186 needToDeleteSignal = true; 00187 } 00188 } 00189 } 00190 00191 if (analogSignal != 0){ 00192 // either we have a signal or we need to generate noise samples 00193 00194 ESDataFrame digi(*idItr); 00195 theElectronicsSim->analogToDigital(*analogSignal , digi, wasEmpty, histoDistribution_, histoInf_, histoSup_, histoBin_); 00196 output.push_back(digi); 00197 if (needToDeleteSignal) delete analogSignal; 00198 } 00199 } 00200 00201 // free up some memory 00202 theHitResponse->clear(); 00203 }
tell the digitizer which cells exist
Definition at line 142 of file ESFastTDigitizer.h.
References theDetIds.
Referenced by EcalDigiProducer::updateGeometry().
00142 {theDetIds = detIds;}
void ESFastTDigitizer::setNoiseHitGenerator | ( | CaloVNoiseHitGenerator * | generator | ) | [inline] |
Definition at line 144 of file ESFastTDigitizer.h.
References theNoiseHitGenerator.
00144 { 00145 theNoiseHitGenerator = generator; 00146 }
bool ESFastTDigitizer::addNoise_ [private] |
double ESFastTDigitizer::histoBin_ [private] |
CLHEP::RandGeneral* ESFastTDigitizer::histoDistribution_ [private] |
Definition at line 233 of file ESFastTDigitizer.h.
Referenced by readHistosFromFile(), run(), and ~ESFastTDigitizer().
double ESFastTDigitizer::histoInf_ [private] |
double ESFastTDigitizer::histoSup_ [private] |
ifstream* ESFastTDigitizer::m_histofile [private] |
int ESFastTDigitizer::numESdetId_ [private] |
std::string ESFastTDigitizer::refFile_ [private] |
double* ESFastTDigitizer::refHistos_ [private] |
std::vector<DetId> ESFastTDigitizer::theDetIds [private] |
CaloHitResponse* ESFastTDigitizer::theHitResponse [private] |
Definition at line 219 of file ESFastTDigitizer.h.
Referenced by addNoiseHits(), run(), and setNoiseHitGenerator().
double ESFastTDigitizer::zsThreshold_ [private] |