00001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameters.h"
00002 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00003 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "CondFormats/HcalObjects/interface/HcalGain.h"
00007 #include "CondFormats/HcalObjects/interface/HcalGainWidth.h"
00008 #include "CLHEP/Random/RandGaussQ.h"
00009
00010
00011 HcalSimParameters::HcalSimParameters(double simHitToPhotoelectrons, double photoelectronsToAnalog,
00012 double samplingFactor, double timePhase,
00013 int readoutFrameSize, int binOfMaximum,
00014 bool doPhotostatistics, bool syncPhase,
00015 int firstRing, const std::vector<double> & samplingFactors)
00016 : CaloSimParameters(simHitToPhotoelectrons, photoelectronsToAnalog, samplingFactor, timePhase,
00017 readoutFrameSize, binOfMaximum, doPhotostatistics, syncPhase),
00018 theDbService(0),
00019 theFirstRing(firstRing),
00020 theSamplingFactors(samplingFactors)
00021 {
00022 }
00023
00024 HcalSimParameters::HcalSimParameters(const edm::ParameterSet & p)
00025 : CaloSimParameters(p),
00026 theDbService(0),
00027 theFirstRing( p.getParameter<int>("firstRing") ),
00028 theSamplingFactors( p.getParameter<std::vector<double> >("samplingFactors") )
00029 {
00030 }
00031
00032 double HcalSimParameters::simHitToPhotoelectrons(const DetId & detId) const
00033 {
00034
00035
00036 double result = CaloSimParameters::simHitToPhotoelectrons(detId);
00037 if(HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenForward
00038 || HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenZDC)
00039 {
00040 result = samplingFactor(detId) / fCtoGeV(detId) / photoelectronsToAnalog(detId);
00041 }
00042 return result;
00043 }
00044
00045
00046 double HcalSimParameters::fCtoGeV(const DetId & detId) const
00047 {
00048 assert(theDbService != 0);
00049 HcalGenericDetId hcalGenDetId(detId);
00050 const HcalGain* gains = theDbService->getGain(hcalGenDetId);
00051 const HcalGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
00052 if (!gains || !gwidths )
00053 {
00054 edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
00055 }
00056
00057
00058 double result = gains->getValue(0);
00059
00061
00062
00063 return result;
00064 }
00065
00066 double HcalSimParameters::samplingFactor(const DetId & detId) const
00067 {
00068 HcalDetId hcalDetId(detId);
00069 return theSamplingFactors.at(hcalDetId.ietaAbs()-theFirstRing);
00070 }
00071