CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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(const edm::ParameterSet & p)
00020 :  CaloSimParameters(p),
00021    theDbService(0),
00022    theSamplingFactor( p.getParameter<double>("samplingFactor") )
00023 {
00024 }
00025 
00026 /*
00027 double CastorSimParameters::simHitToPhotoelectrons(const DetId & detId) const 
00028 {
00029   // the gain is in units of GeV/fC.  We want a constant with pe/dGeV
00030   // pe/dGeV = (GeV/dGeV) / (GeV/fC) / (fC/pe) 
00031   double result = CaloSimParameters::simHitToPhotoelectrons(detId);
00032   if(HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenForward
00033      || HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenCastor)
00034     { 
00035       result = samplingFactor(detId) / fCtoGeV(detId) / photoelectronsToAnalog();
00036     }
00037   return result;
00038 }
00039 */
00040 
00041 double CastorSimParameters::photoelectronsToAnalog(const DetId & detId) const
00042 {
00043   // calculate factor (PMT gain) using sampling factor value & available electron gain
00044   //std::cout << " sampling factor = " << theSamplingFactor << " fCtoGeV = " << fCtoGeV(detId) << " and photoelectronsToAnalog = " << theSamplingFactor/fCtoGeV(detId) << std::endl;
00045   return theSamplingFactor/fCtoGeV(detId);
00046 }
00047 
00048 
00049 
00050 double CastorSimParameters::fCtoGeV(const DetId & detId) const
00051 {
00052   assert(theDbService != 0);
00053   HcalGenericDetId hcalGenDetId(detId);
00054   const CastorGain* gains = theDbService->getGain(hcalGenDetId);
00055   const CastorGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
00056   if (!gains || !gwidths )
00057   {
00058     edm::LogError("CastorAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
00059   }
00060   // only one gain will be recorded per channel, so just use capID 0 for now
00061   
00062   double result = gains->getValue(0);
00063 //  if(doNoise_)
00065 //    result += CLHEP::RandGaussQ::shoot(0.,  gwidths->getValue(0));
00066 //  }
00067   return result;
00068 }
00069 /*
00070 double CastorSimParameters::samplingFactor(const DetId & detId) const {  
00071 HcalDetId hcalDetId(detId); 
00072 return theSamplingFactors[hcalDetId.ietaAbs()-theFirstRing];
00073 }
00074 */