File indexing completed on 2024-04-06 12:29:21
0001 #include "CLHEP/Random/RandGaussQ.h"
0002 #include "CondFormats/CastorObjects/interface/CastorGain.h"
0003 #include "CondFormats/CastorObjects/interface/CastorGainWidth.h"
0004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0005 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0006 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "SimCalorimetry/CastorSim/interface/CastorSimParameters.h"
0009 #include <cassert>
0010
0011 CastorSimParameters::CastorSimParameters(double simHitToPhotoelectrons,
0012 double photoelectronsToAnalog,
0013 double samplingFactor,
0014 double timePhase,
0015 bool syncPhase)
0016 : CaloSimParameters(
0017 simHitToPhotoelectrons, photoelectronsToAnalog, samplingFactor, timePhase, 6, 4, false, syncPhase),
0018 theDbService(nullptr),
0019 theSamplingFactor(samplingFactor),
0020 nominalfCperPE(1) {}
0021
0022 CastorSimParameters::CastorSimParameters(const edm::ParameterSet &p)
0023 : CaloSimParameters(p),
0024 theDbService(nullptr),
0025 theSamplingFactor(p.getParameter<double>("samplingFactor")),
0026 nominalfCperPE(p.getParameter<double>("photoelectronsToAnalog")) {}
0027
0028 double CastorSimParameters::getNominalfCperPE() const {
0029
0030 return nominalfCperPE;
0031 }
0032
0033 double CastorSimParameters::photoelectronsToAnalog(const DetId &detId) const {
0034
0035
0036 return theSamplingFactor / fCtoGeV(detId);
0037 }
0038
0039 double CastorSimParameters::fCtoGeV(const DetId &detId) const {
0040 assert(theDbService != nullptr);
0041 HcalGenericDetId hcalGenDetId(detId);
0042 const CastorGain *gains = theDbService->getGain(hcalGenDetId);
0043 const CastorGainWidth *gwidths = theDbService->getGainWidth(hcalGenDetId);
0044 double result = 0.0;
0045 if (!gains || !gwidths) {
0046 edm::LogError("CastorAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
0047 } else {
0048
0049 result = gains->getValue(0);
0050 }
0051 return result;
0052 }