CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/SimCalorimetry/HcalSimAlgos/src/HcalSimParameterMap.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h"
00002 #include "DataFormats/DetId/interface/DetId.h"
00003 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00005 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"  
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 HcalSimParameterMap::HcalSimParameterMap() :
00009   theHBParameters(2000., std::vector<double>(16, 0.3305),
00010                   117, 5, 
00011                   10, 5, true, true,
00012                   1, std::vector<double>(16, 117.)),
00013   theHEParameters(2000., std::vector<double>(16, 0.3305),
00014                   178, 5,
00015                   10, 5, true, true,
00016                   16, std::vector<double>(16, 178.)),
00017   theHOParameters( 4000., std::vector<double>(16, 0.3065), 
00018                    217., 5, 
00019                    10, 5, true, true,
00020                    1, std::vector<double>(16, 217.)),
00021   theHOZecotekSiPMParameters( 4000., std::vector<double>(16, 3.0), // 1 mip = 15 pe = 45 fC
00022                    217., 5,
00023                    10, 5, true, true,
00024                    1, std::vector<double>(16, 217.)),
00025   theHOHamamatsuSiPMParameters( 4000., std::vector<double>(16, 3.0),
00026                    217., 5,
00027                    10, 5, true, true,
00028                    1, std::vector<double>(16, 217.)),
00029   theHFParameters1(6., 2.79,
00030                    1/0.278 , -4,
00031                    true),
00032   theHFParameters2(6., 2.06,
00033                    1/0.267 , -4,
00034                    true),
00035   theZDCParameters(1., 4.3333,
00036                    2.09 , -4,
00037                    false),
00038   theHOZecotekDetIds(),
00039   theHOHamamatsuDetIds()
00040 {
00041   theHOZecotekSiPMParameters.thePixels = 36000;
00042   theHOHamamatsuSiPMParameters.thePixels = 960;
00043 }
00044 /*
00045   CaloSimParameters(double simHitToPhotoelectrons, double photoelectronsToAnalog,
00046                  double samplingFactor, double timePhase,
00047                  int readoutFrameSize, int binOfMaximum,
00048                  bool doPhotostatistics, bool syncPhase=true);
00049 
00050 */
00051 
00052 HcalSimParameterMap::HcalSimParameterMap(const edm::ParameterSet & p)
00053 : theHBParameters(  p.getParameter<edm::ParameterSet>("hb") ),
00054   theHEParameters(  p.getParameter<edm::ParameterSet>("he") ),
00055   theHOParameters(  p.getParameter<edm::ParameterSet>("ho") ),
00056   theHOZecotekSiPMParameters(  p.getParameter<edm::ParameterSet>("hoZecotek") ),
00057   theHOHamamatsuSiPMParameters(  p.getParameter<edm::ParameterSet>("hoHamamatsu") ),
00058   theHFParameters1( p.getParameter<edm::ParameterSet>("hf1") ),
00059   theHFParameters2( p.getParameter<edm::ParameterSet>("hf2") ),
00060   theZDCParameters( p.getParameter<edm::ParameterSet>("zdc") )
00061 {
00062 }
00063 
00064 const CaloSimParameters & HcalSimParameterMap::simParameters(const DetId & detId) const {
00065   HcalGenericDetId genericId(detId);
00066   if(genericId.isHcalZDCDetId())
00067     return theZDCParameters;
00068   HcalDetId hcalDetId(detId);
00069   if(hcalDetId.subdet() == HcalBarrel) {
00070      return theHBParameters;
00071   } else if(hcalDetId.subdet() == HcalEndcap) {
00072      return theHEParameters;
00073   } else if(hcalDetId.subdet() == HcalOuter) {
00074      if(std::find(theHOZecotekDetIds.begin(),
00075         theHOZecotekDetIds.end(), hcalDetId) != theHOZecotekDetIds.end())
00076      {
00077        return theHOZecotekSiPMParameters;
00078      }
00079      if(std::find(theHOHamamatsuDetIds.begin(),
00080         theHOHamamatsuDetIds.end(), hcalDetId) != theHOHamamatsuDetIds.end())
00081      {
00082        return theHOHamamatsuSiPMParameters;
00083      }
00084      else
00085      {
00086        return theHOParameters;
00087      }
00088   } else { // HF
00089     if(hcalDetId.depth() == 1) {
00090       return theHFParameters1;
00091     } else {
00092       return theHFParameters2;
00093     }
00094   }
00095 }
00096 
00097 void HcalSimParameterMap::setDbService(const HcalDbService * dbService)
00098 {
00099   theHBParameters.setDbService(dbService);
00100   theHEParameters.setDbService(dbService);
00101   theHOParameters.setDbService(dbService);
00102   theHOZecotekSiPMParameters.setDbService(dbService);
00103   theHOHamamatsuSiPMParameters.setDbService(dbService);
00104   theHFParameters1.setDbService(dbService);
00105   theHFParameters2.setDbService(dbService);
00106   theZDCParameters.setDbService(dbService);
00107 }
00108 
00109 void HcalSimParameterMap::setFrameSize(const DetId & detId, int frameSize)
00110 {
00111   HcalGenericDetId genericId(detId);
00112   if(genericId.isHcalZDCDetId())
00113     setFrameSize(theZDCParameters, frameSize);
00114   else
00115   {
00116     HcalDetId hcalDetId(detId);
00117     if(hcalDetId.subdet() == HcalForward) {
00118       // do both depths
00119       setFrameSize(theHFParameters1,frameSize);
00120       setFrameSize(theHFParameters2,frameSize);
00121     }
00122     else
00123     {
00124       CaloSimParameters & parameters = const_cast<CaloSimParameters &>(simParameters(detId));
00125       setFrameSize(parameters, frameSize);
00126     }
00127   }
00128 }
00129 
00130 
00131 void HcalSimParameterMap::setFrameSize(CaloSimParameters & parameters, int frameSize)
00132 {
00133   int binOfMaximum = 5;
00134   if(frameSize == 10) {}
00135   else if(frameSize == 6) binOfMaximum = 4;
00136   else {
00137     edm::LogError("HcalSimParameterMap")<< "Bad HCAL frame size " << frameSize;
00138   }
00139   if(parameters.readoutFrameSize() != frameSize)
00140   {
00141     edm::LogWarning("HcalSignalGenerator")<< "Mismatch in frame sizes.  Setting to " << frameSize;
00142     parameters.setReadoutFrameSize(frameSize);
00143     parameters.setBinOfMaximum(binOfMaximum);
00144   }
00145 }
00146