Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:32

0001 #include "SimCalorimetry/HcalSimAlgos/interface/HFSimParameters.h"
0002 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0003 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "CondFormats/HcalObjects/interface/HcalGain.h"
0007 #include "CondFormats/HcalObjects/interface/HcalGainWidth.h"
0008 #include "CLHEP/Random/RandGaussQ.h"
0009 
0010 HFSimParameters::HFSimParameters(double simHitToPhotoelectrons,
0011                                  double photoelectronsToAnalog,
0012                                  double samplingFactor,
0013                                  double timePhase,
0014                                  bool syncPhase)
0015     : CaloSimParameters(
0016           simHitToPhotoelectrons, photoelectronsToAnalog, samplingFactor, timePhase, 6, 4, false, syncPhase),
0017       theDbService(nullptr),
0018       theSamplingFactor(samplingFactor) {}
0019 
0020 HFSimParameters::HFSimParameters(const edm::ParameterSet& p)
0021     : CaloSimParameters(p),
0022       theDbService(nullptr),
0023       theSamplingFactor(p.getParameter<double>("samplingFactor")),
0024       threshold_currentTDC_(p.getParameter<double>("threshold_currentTDC")) {}
0025 
0026 double HFSimParameters::photoelectronsToAnalog(const DetId& detId) const {
0027   // pe/fC = pe/GeV * GeV/fC  = (0.24 pe/GeV * 6 for photomult * 0.2146GeV/fC)
0028   return 1. / (theSamplingFactor * simHitToPhotoelectrons(detId) * fCtoGeV(detId));
0029 }
0030 
0031 double HFSimParameters::fCtoGeV(const DetId& detId) const {
0032   assert(theDbService != nullptr);
0033   HcalGenericDetId hcalGenDetId(detId);
0034   const HcalGain* gains = theDbService->getGain(hcalGenDetId);
0035   const HcalGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
0036   double result = 0.0;
0037   if (!gains || !gwidths) {
0038     edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
0039   } else {
0040     // only one gain will be recorded per channel, so just use capID 0 for now
0041     result = gains->getValue(0);
0042     //  if(doNoise_)
0043     ///  {
0044     //    result += CLHEP::RandGaussQ::shoot(0.,  gwidths->getValue(0));
0045     //  }
0046   }
0047   return result;
0048 }
0049 
0050 double HFSimParameters::samplingFactor() const { return theSamplingFactor; }