CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/SimCalorimetry/CastorSim/src/CastorSimParameters.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/CastorSim/src/CastorSimParameters.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/CastorObjects/interface/CastorGain.h"
00007 #include "CondFormats/CastorObjects/interface/CastorGainWidth.h"
00008 #include "CLHEP/Random/RandGaussQ.h"
00009 
00010 
00011 CastorSimParameters::CastorSimParameters(double simHitToPhotoelectrons, double photoelectronsToAnalog,double samplingFactor, double timePhase, bool syncPhase)
00012 : CaloSimParameters(simHitToPhotoelectrons, photoelectronsToAnalog, samplingFactor, timePhase, 6, 4, false, syncPhase),
00013   theDbService(0),
00014   theSamplingFactor( samplingFactor )
00015 {
00016 }
00017 
00018 /* 
00019 CastorSimParameters::CastorSimParameters(double simHitToPhotoelectrons, double photoelectronsToAnalog,
00020                 double samplingFactor, double timePhase,
00021                 int readoutFrameSize, int binOfMaximum,
00022                 bool doPhotostatistics, bool syncPhase,
00023                 int firstRing, const std::vector<double> & samplingFactors)
00024  : CaloSimParameters(simHitToPhotoelectrons, photoelectronsToAnalog, samplingFactor, timePhase,
00025                    readoutFrameSize, binOfMaximum, doPhotostatistics, syncPhase),
00026  theDbService(0),
00027  theFirstRing(firstRing),
00028  theSamplingFactors(samplingFactors)
00029 {
00030 }
00031 */
00032 
00033 CastorSimParameters::CastorSimParameters(const edm::ParameterSet & p)
00034 :  CaloSimParameters(p),
00035    theDbService(0),
00036    theSamplingFactor( p.getParameter<double>("samplingFactor") )
00037 {
00038 }
00039 /*
00040 : CaloSimParameters(p),
00041   theDbService(0),
00042   theFirstRing( p.getParameter<int>("firstRing") ),
00043   theSamplingFactors( p.getParameter<std::vector<double> >("samplingFactors") )
00044 {
00045 }
00046 */
00047 
00048 /*
00049 double CastorSimParameters::simHitToPhotoelectrons(const DetId & detId) const 
00050 {
00051   // the gain is in units of GeV/fC.  We want a constant with pe/dGeV
00052   // pe/dGeV = (GeV/dGeV) / (GeV/fC) / (fC/pe) 
00053   double result = CaloSimParameters::simHitToPhotoelectrons(detId);
00054   if(HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenForward
00055      || HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenCastor)
00056     { 
00057       result = samplingFactor(detId) / fCtoGeV(detId) / photoelectronsToAnalog();
00058     }
00059   return result;
00060 }
00061 */
00062 
00063 double CastorSimParameters::photoelectronsToAnalog(const DetId & detId) const
00064 {
00065   // pe/fC = pe/GeV * GeV/fC  = (0.24 pe/GeV * 6 for photomult * 0.2146GeV/fC)
00066   return 1./(theSamplingFactor * simHitToPhotoelectrons(detId) * fCtoGeV(detId));
00067 }
00068 
00069 
00070 
00071 double CastorSimParameters::fCtoGeV(const DetId & detId) const
00072 {
00073   assert(theDbService != 0);
00074   HcalGenericDetId hcalGenDetId(detId);
00075   const CastorGain* gains = theDbService->getGain(hcalGenDetId);
00076   const CastorGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
00077   if (!gains || !gwidths )
00078   {
00079     edm::LogError("CastorAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
00080   }
00081   // only one gain will be recorded per channel, so just use capID 0 for now
00082   
00083   double result = gains->getValue(0);
00084 //  if(doNoise_)
00086 //    result += CLHEP::RandGaussQ::shoot(0.,  gwidths->getValue(0));
00087 //  }
00088   return result;
00089 }
00090 /*
00091 double CastorSimParameters::samplingFactor(const DetId & detId) const {  
00092 HcalDetId hcalDetId(detId); 
00093 return theSamplingFactors[hcalDetId.ietaAbs()-theFirstRing];
00094 }
00095 */