#include <HcalAmplifier.h>
Public Member Functions | |
virtual void | amplify (CaloSamples &linearFrame) const |
HcalAmplifier (const CaloVSimParameterMap *parameters, bool addNoise) | |
void | setADCPeds (const HcalPedestals *ADCPeds) |
void | setCholesky (const HcalCholeskyMatrices *Cholesky) |
void | setDbService (const HcalDbService *service) |
the Producer will probably update this every event | |
void | setHBtuningParameter (double tp) |
void | setHEtuningParameter (double tp) |
void | setHFtuningParameter (double tp) |
void | setHOtuningParameter (double tp) |
void | setIonFeedbackSim (HPDIonFeedbackSim *feedbackSim) |
void | setNoiseSignalGenerator (const CaloVNoiseSignalGenerator *noiseSignalGenerator) |
void | setRandomEngine (CLHEP::HepRandomEngine &engine) |
void | setStartingCapId (int capId) |
void | setTimeSlewSim (const HcalTimeSlewSim *timeSlewSim) |
void | setUseOldHB (bool useOld) |
void | setUseOldHE (bool useOld) |
void | setUseOldHF (bool useOld) |
void | setUseOldHO (bool useOld) |
virtual | ~HcalAmplifier () |
Private Member Functions | |
void | addPedestals (CaloSamples &frame) const |
void | makeNoise (const HcalCholeskyMatrix &thisChanCholesky, int fFrames, double *fGauss, double *fNoise, int m) const |
void | makeNoiseOld (HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const |
void | pe2fC (CaloSamples &frame) const |
Private Attributes | |
bool | addNoise_ |
double | HB_ff |
double | HE_ff |
double | HF_ff |
double | HO_ff |
const HcalPedestals * | myADCPeds |
const HcalCholeskyMatrices * | myCholeskys |
const HcalDbService * | theDbService |
HPDIonFeedbackSim * | theIonFeedbackSim |
const CaloVNoiseSignalGenerator * | theNoiseSignalGenerator |
const CaloVSimParameterMap * | theParameterMap |
CLHEP::RandFlat * | theRandFlat |
CLHEP::RandGaussQ * | theRandGaussQ |
unsigned | theStartingCapId |
const HcalTimeSlewSim * | theTimeSlewSim |
bool | useOldHB |
bool | useOldHE |
bool | useOldHF |
bool | useOldHO |
Definition at line 21 of file HcalAmplifier.h.
HcalAmplifier::HcalAmplifier | ( | const CaloVSimParameterMap * | parameters, |
bool | addNoise | ||
) |
Definition at line 22 of file HcalAmplifier.cc.
: theDbService(0), theRandGaussQ(0), theRandFlat(0), theParameterMap(parameters), theNoiseSignalGenerator(0), theIonFeedbackSim(0), theTimeSlewSim(0), theStartingCapId(0), addNoise_(addNoise), useOldHB(false), useOldHE(false), useOldHF(false), useOldHO(false) { }
virtual HcalAmplifier::~HcalAmplifier | ( | ) | [inline, virtual] |
void HcalAmplifier::addPedestals | ( | CaloSamples & | frame | ) | const [private] |
Definition at line 88 of file HcalAmplifier.cc.
References addNoise_, HcalQIECoder::charge(), HcalGenericDetId::genericSubdet(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCalibrationWidths(), HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalPedestal::getValue(), HcalCholeskyMatrices::getValues(), HcalCondObjectContainer< Item >::getValues(), HB_ff, HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, HE_ff, HF_ff, HO_ff, i, CaloSamples::id(), makeNoise(), makeNoiseOld(), myADCPeds, myCholeskys, HcalCalibrations::pedestal(), CaloSamples::size(), theDbService, theRandFlat, theRandGaussQ, theStartingCapId, useOldHB, useOldHE, useOldHF, useOldHO, and x.
Referenced by amplify().
{ assert(theDbService != 0); HcalGenericDetId hcalGenDetId(frame.id()); HcalGenericDetId::HcalGenericSubdetector hcalSubDet = hcalGenDetId.genericSubdet(); bool useOld=false; if(hcalSubDet==HcalGenericDetId::HcalGenBarrel) useOld = useOldHB; if(hcalSubDet==HcalGenericDetId::HcalGenEndcap) useOld = useOldHE; if(hcalSubDet==HcalGenericDetId::HcalGenForward) useOld = useOldHF; if(hcalSubDet==HcalGenericDetId::HcalGenOuter) useOld = useOldHO; if(useOld) { const HcalCalibrationWidths & calibWidths = theDbService->getHcalCalibrationWidths(hcalGenDetId); const HcalCalibrations& calibs = theDbService->getHcalCalibrations(hcalGenDetId); double noise [32] = {0.}; //big enough if(addNoise_) { double gauss [32]; //big enough for (int i = 0; i < frame.size(); i++) gauss[i] = theRandGaussQ->fire(0., 1.); makeNoiseOld(hcalSubDet, calibWidths, frame.size(), gauss, noise); } for (int tbin = 0; tbin < frame.size(); ++tbin) { int capId = (theStartingCapId + tbin)%4; double pedestal = calibs.pedestal(capId) + noise[tbin]; frame[tbin] += pedestal; } return; } double fudgefactor = 1; if(hcalSubDet==HcalGenericDetId::HcalGenBarrel) fudgefactor = HB_ff; if(hcalSubDet==HcalGenericDetId::HcalGenEndcap) fudgefactor = HE_ff; if(hcalSubDet==HcalGenericDetId::HcalGenForward) fudgefactor = HF_ff; if(hcalSubDet==HcalGenericDetId::HcalGenOuter) fudgefactor = HO_ff; if(hcalGenDetId.isHcalCastorDetId()) return; if(hcalGenDetId.isHcalZDCDetId()) return; const HcalCholeskyMatrix * thisChanCholesky = myCholeskys->getValues(hcalGenDetId); const HcalPedestal * thisChanADCPeds = myADCPeds->getValues(hcalGenDetId); int theStartingCapId_2 = (int)floor(theRandFlat->fire(0.,4.)); double noise [32] = {0.}; //big enough if(addNoise_) { double gauss [32]; //big enough for (int i = 0; i < frame.size(); i++) gauss[i] = theRandGaussQ->fire(0., 1.); makeNoise(*thisChanCholesky, frame.size(), gauss, noise, (int)theStartingCapId_2); } const HcalQIECoder* coder = theDbService->getHcalCoder(hcalGenDetId); const HcalQIEShape* shape = theDbService->getHcalShape(); for (int tbin = 0; tbin < frame.size(); ++tbin) { int capId = (theStartingCapId_2 + tbin)%4; double x = noise[tbin] * fudgefactor + thisChanADCPeds->getValue(capId);//*(values+capId); //*.70 goes here! int x1=(int)std::floor(x); int x2=(int)std::floor(x+1); float y2=coder->charge(*shape,x2,capId); float y1=coder->charge(*shape,x1,capId); frame[tbin] = (y2-y1)*(x-x1)+y1; } }
void HcalAmplifier::amplify | ( | CaloSamples & | linearFrame | ) | const [virtual] |
Definition at line 54 of file HcalAmplifier.cc.
References addPedestals(), HPDIonFeedbackSim::addThermalNoise(), CaloVNoiseSignalGenerator::contains(), HcalTimeSlewSim::delay(), CaloSamples::id(), LogDebug, pe2fC(), theIonFeedbackSim, theNoiseSignalGenerator, and theTimeSlewSim.
Referenced by HcalElectronicsSim::convert().
{ if(theIonFeedbackSim) { theIonFeedbackSim->addThermalNoise(frame); } pe2fC(frame); // don't bother for blank signals if(theTimeSlewSim && frame[4] > 1.e-6) { theTimeSlewSim->delay(frame); } if(theNoiseSignalGenerator==0 || !theNoiseSignalGenerator->contains(frame.id())) { addPedestals(frame); } LogDebug("HcalAmplifier") << frame; }
void HcalAmplifier::makeNoise | ( | const HcalCholeskyMatrix & | thisChanCholesky, |
int | fFrames, | ||
double * | fGauss, | ||
double * | fNoise, | ||
int | m | ||
) | const [private] |
Definition at line 157 of file HcalAmplifier.cc.
References HcalCholeskyMatrix::getValue(), i, and j.
Referenced by addPedestals().
void HcalAmplifier::makeNoiseOld | ( | HcalGenericDetId::HcalGenericSubdetector | hcalSubDet, |
const HcalCalibrationWidths & | width, | ||
int | fFrames, | ||
double * | fGauss, | ||
double * | fNoise | ||
) | const [private] |
Definition at line 167 of file HcalAmplifier.cc.
References corr, HcalGenericDetId::HcalGenForward, i, HcalCalibrationWidths::pedestal(), and mathSSE::sqrt().
Referenced by addPedestals().
{ // This is a simplified noise generation scheme using only the diagonal elements // (proposed by Salavat Abduline). // This is direct adaptation of the code in HcalPedestalWidth.cc // average over capId's double s_xx_mean = 0.25 * (width.pedestal(0)*width.pedestal(0) + width.pedestal(1)*width.pedestal(1) + width.pedestal(2)*width.pedestal(2) + width.pedestal(3)*width.pedestal(3)); // Off-diagonal element approximation // In principle should come from averaging the values of elements (0.1), (1,2), (2,3), (3,0) // For now use the definition below (but keep structure of the code structure for development) double s_xy_mean = -0.5 * s_xx_mean; // Use different parameter for HF to reproduce the noise rate after zero suppression. // Steven Won/Jim Hirschauer/Radek Ofierzynski 18.03.2010 if (hcalSubDet == HcalGenericDetId::HcalGenForward) s_xy_mean = 0.08 * s_xx_mean; double term = s_xx_mean*s_xx_mean - 2.*s_xy_mean*s_xy_mean; if (term < 0.) term = 1.e-50 ; double sigma = sqrt (0.5 * (s_xx_mean + sqrt(term))); double corr = sigma == 0. ? 0. : 0.5*s_xy_mean / sigma; for (int i = 0; i < fFrames; i++) { fNoise [i] = fGauss[i]*sigma; if (i > 0) fNoise [i] += fGauss[i-1]*corr; if (i < fFrames-1) fNoise [i] += fGauss[i+1]*corr; } }
void HcalAmplifier::pe2fC | ( | CaloSamples & | frame | ) | const [private] |
Definition at line 73 of file HcalAmplifier.cc.
References CaloSamples::id(), Parameters::parameters, CaloSimParameters::photoelectronsToAnalog(), CaloVSimParameterMap::simParameters(), and theParameterMap.
Referenced by amplify().
{ const CaloSimParameters & parameters = theParameterMap->simParameters(frame.id()); frame *= parameters.photoelectronsToAnalog(frame.id()); }
void HcalAmplifier::setADCPeds | ( | const HcalPedestals * | ADCPeds | ) | [inline] |
Definition at line 52 of file HcalAmplifier.h.
References myADCPeds.
Referenced by HcalDigitizer::produce().
{ myADCPeds = ADCPeds; }
void HcalAmplifier::setCholesky | ( | const HcalCholeskyMatrices * | Cholesky | ) | [inline] |
Definition at line 51 of file HcalAmplifier.h.
References myCholeskys.
Referenced by HcalDigitizer::produce().
{ myCholeskys = Cholesky; }
void HcalAmplifier::setDbService | ( | const HcalDbService * | service | ) |
the Producer will probably update this every event
Definition at line 40 of file HcalAmplifier.cc.
References HPDIonFeedbackSim::setDbService(), theDbService, and theIonFeedbackSim.
Referenced by HcalDigitizer::produce(), and HcalTBDigiProducer::produce().
{ theDbService = service; if(theIonFeedbackSim) theIonFeedbackSim->setDbService(service); }
void HcalAmplifier::setHBtuningParameter | ( | double | tp | ) |
void HcalAmplifier::setHEtuningParameter | ( | double | tp | ) |
void HcalAmplifier::setHFtuningParameter | ( | double | tp | ) |
Definition at line 81 of file HcalAmplifier.cc.
References HF_ff.
Referenced by HcalDigitizer::HcalDigitizer().
{ HF_ff = tp; }
void HcalAmplifier::setHOtuningParameter | ( | double | tp | ) |
Definition at line 82 of file HcalAmplifier.cc.
References HO_ff.
Referenced by HcalDigitizer::HcalDigitizer().
{ HO_ff = tp; }
void HcalAmplifier::setIonFeedbackSim | ( | HPDIonFeedbackSim * | feedbackSim | ) | [inline] |
Definition at line 29 of file HcalAmplifier.h.
References theIonFeedbackSim.
{theIonFeedbackSim = feedbackSim;}
void HcalAmplifier::setNoiseSignalGenerator | ( | const CaloVNoiseSignalGenerator * | noiseSignalGenerator | ) | [inline] |
if it's set, the amplifier will only use it to check if it has already added noise
Definition at line 33 of file HcalAmplifier.h.
References theNoiseSignalGenerator.
Referenced by HcalDigitizer::setHBHENoiseSignalGenerator(), HcalDigitizer::setHFNoiseSignalGenerator(), HcalDigitizer::setHONoiseSignalGenerator(), and HcalDigitizer::setZDCNoiseSignalGenerator().
{ theNoiseSignalGenerator = noiseSignalGenerator; }
void HcalAmplifier::setRandomEngine | ( | CLHEP::HepRandomEngine & | engine | ) |
Definition at line 46 of file HcalAmplifier.cc.
References HPDIonFeedbackSim::setRandomEngine(), theIonFeedbackSim, theRandFlat, and theRandGaussQ.
Referenced by HcalElectronicsSim::setRandomEngine().
{ theRandGaussQ = new CLHEP::RandGaussQ(engine); theRandFlat = new CLHEP::RandFlat(engine); if(theIonFeedbackSim) theIonFeedbackSim->setRandomEngine(engine); }
void HcalAmplifier::setStartingCapId | ( | int | capId | ) | [inline] |
Definition at line 42 of file HcalAmplifier.h.
References theStartingCapId.
Referenced by HcalElectronicsSim::newEvent(), and HcalElectronicsSim::setStartingCapId().
{theStartingCapId = capId;}
void HcalAmplifier::setTimeSlewSim | ( | const HcalTimeSlewSim * | timeSlewSim | ) | [inline] |
Definition at line 36 of file HcalAmplifier.h.
References theTimeSlewSim.
Referenced by HcalDigitizer::HcalDigitizer().
{ theTimeSlewSim = timeSlewSim; }
void HcalAmplifier::setUseOldHB | ( | bool | useOld | ) |
void HcalAmplifier::setUseOldHE | ( | bool | useOld | ) |
void HcalAmplifier::setUseOldHF | ( | bool | useOld | ) |
Definition at line 85 of file HcalAmplifier.cc.
References useOldHF.
Referenced by HcalDigitizer::HcalDigitizer().
{ useOldHF = useOld; }
void HcalAmplifier::setUseOldHO | ( | bool | useOld | ) |
Definition at line 86 of file HcalAmplifier.cc.
References useOldHO.
Referenced by HcalDigitizer::HcalDigitizer().
{ useOldHO = useOld; }
bool HcalAmplifier::addNoise_ [private] |
Definition at line 69 of file HcalAmplifier.h.
Referenced by addPedestals().
double HcalAmplifier::HB_ff [private] |
Definition at line 75 of file HcalAmplifier.h.
Referenced by addPedestals(), and setHBtuningParameter().
double HcalAmplifier::HE_ff [private] |
Definition at line 76 of file HcalAmplifier.h.
Referenced by addPedestals(), and setHEtuningParameter().
double HcalAmplifier::HF_ff [private] |
Definition at line 77 of file HcalAmplifier.h.
Referenced by addPedestals(), and setHFtuningParameter().
double HcalAmplifier::HO_ff [private] |
Definition at line 78 of file HcalAmplifier.h.
Referenced by addPedestals(), and setHOtuningParameter().
const HcalPedestals* HcalAmplifier::myADCPeds [private] |
Definition at line 80 of file HcalAmplifier.h.
Referenced by addPedestals(), and setADCPeds().
const HcalCholeskyMatrices* HcalAmplifier::myCholeskys [private] |
Definition at line 79 of file HcalAmplifier.h.
Referenced by addPedestals(), and setCholesky().
const HcalDbService* HcalAmplifier::theDbService [private] |
Definition at line 61 of file HcalAmplifier.h.
Referenced by addPedestals(), and setDbService().
Definition at line 66 of file HcalAmplifier.h.
Referenced by amplify(), setDbService(), setIonFeedbackSim(), and setRandomEngine().
const CaloVNoiseSignalGenerator* HcalAmplifier::theNoiseSignalGenerator [private] |
Definition at line 65 of file HcalAmplifier.h.
Referenced by amplify(), and setNoiseSignalGenerator().
const CaloVSimParameterMap* HcalAmplifier::theParameterMap [private] |
Definition at line 64 of file HcalAmplifier.h.
Referenced by pe2fC().
CLHEP::RandFlat* HcalAmplifier::theRandFlat [private] |
Definition at line 63 of file HcalAmplifier.h.
Referenced by addPedestals(), and setRandomEngine().
CLHEP::RandGaussQ* HcalAmplifier::theRandGaussQ [private] |
Definition at line 62 of file HcalAmplifier.h.
Referenced by addPedestals(), setRandomEngine(), and ~HcalAmplifier().
unsigned HcalAmplifier::theStartingCapId [private] |
Definition at line 68 of file HcalAmplifier.h.
Referenced by addPedestals(), and setStartingCapId().
const HcalTimeSlewSim* HcalAmplifier::theTimeSlewSim [private] |
Definition at line 67 of file HcalAmplifier.h.
Referenced by amplify(), and setTimeSlewSim().
bool HcalAmplifier::useOldHB [private] |
Definition at line 70 of file HcalAmplifier.h.
Referenced by addPedestals(), and setUseOldHB().
bool HcalAmplifier::useOldHE [private] |
Definition at line 71 of file HcalAmplifier.h.
Referenced by addPedestals(), and setUseOldHE().
bool HcalAmplifier::useOldHF [private] |
Definition at line 72 of file HcalAmplifier.h.
Referenced by addPedestals(), and setUseOldHF().
bool HcalAmplifier::useOldHO [private] |
Definition at line 73 of file HcalAmplifier.h.
Referenced by addPedestals(), and setUseOldHO().