Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-23 03:25:35

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   // return the nominal PMT gain value of CASTOR from the config file.
0030   return nominalfCperPE;
0031 }
0032 
0033 double CastorSimParameters::photoelectronsToAnalog(const DetId &detId) const {
0034   // calculate factor (PMT gain) using sampling factor value & available
0035   // electron gain
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     // only one gain will be recorded per channel, so just use capID 0 for now
0049     result = gains->getValue(0);
0050   }
0051   return result;
0052 }