Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:39

0001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h"
0002 #include "DataFormats/DetId/interface/DetId.h"
0003 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0005 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 HcalSimParameterMap::HcalSimParameterMap()
0009     : theHBParameters(2000., 117, 5, 10, 5, true, true, 1, std::vector<double>(16, 117.), 10.),
0010       theHEParameters(2000., 178, 5, 10, 5, true, true, 16, std::vector<double>(16, 178.), 10.),
0011       theHOParameters(4000., 217., 5, 10, 5, true, true, 1, std::vector<double>(16, 217.), 5.),
0012       theHOZecotekSiPMParameters(4000., 217., 5, 10, 5, true, true, 1, std::vector<double>(16, 217.), 5.),
0013       theHOHamamatsuSiPMParameters(4000., 217., 5, 10, 5, true, true, 1, std::vector<double>(16, 217.), 5.),
0014       theHFParameters1(6., 2.79, 1 / 0.278, -4, true),
0015       theHFParameters2(6., 2.06, 1 / 0.267, -4, true),
0016       theZDCParameters(1., 4.3333, 2.09, -4, false),
0017       theHOZecotekDetIds(),
0018       theHOHamamatsuDetIds() {}
0019 
0020 HcalSimParameterMap::HcalSimParameterMap(const edm::ParameterSet &p)
0021     : theHBParameters(p.getParameter<edm::ParameterSet>("hb")),
0022       theHEParameters(p.getParameter<edm::ParameterSet>("he")),
0023       theHOParameters(p.getParameter<edm::ParameterSet>("ho")),
0024       theHOZecotekSiPMParameters(p.getParameter<edm::ParameterSet>("hoZecotek")),
0025       theHOHamamatsuSiPMParameters(p.getParameter<edm::ParameterSet>("hoHamamatsu")),
0026       theHFParameters1(p.getParameter<edm::ParameterSet>("hf1")),
0027       theHFParameters2(p.getParameter<edm::ParameterSet>("hf2")),
0028       theZDCParameters(p.getParameter<edm::ParameterSet>("zdc")) {}
0029 
0030 const CaloSimParameters &HcalSimParameterMap::simParameters(const DetId &detId) const {
0031   HcalGenericDetId genericId(detId);
0032   if (genericId.isHcalZDCDetId())
0033     return theZDCParameters;
0034   HcalDetId hcalDetId(detId);
0035   if (hcalDetId.subdet() == HcalBarrel) {
0036     return theHBParameters;
0037   } else if (hcalDetId.subdet() == HcalEndcap) {
0038     return theHEParameters;
0039   } else if (hcalDetId.subdet() == HcalOuter) {
0040     if (std::find(theHOZecotekDetIds.begin(), theHOZecotekDetIds.end(), hcalDetId) != theHOZecotekDetIds.end()) {
0041       return theHOZecotekSiPMParameters;
0042     }
0043     if (std::find(theHOHamamatsuDetIds.begin(), theHOHamamatsuDetIds.end(), hcalDetId) != theHOHamamatsuDetIds.end()) {
0044       return theHOHamamatsuSiPMParameters;
0045     } else {
0046       return theHOParameters;
0047     }
0048   } else {  // HF
0049     if (hcalDetId.depth() == 1 || hcalDetId.depth() == 3) {
0050       return theHFParameters1;
0051     } else {
0052       return theHFParameters2;
0053     }
0054   }
0055 }
0056 
0057 void HcalSimParameterMap::setDbService(const HcalDbService *dbService) {
0058   theHBParameters.setDbService(dbService);
0059   theHEParameters.setDbService(dbService);
0060   theHOParameters.setDbService(dbService);
0061   theHOZecotekSiPMParameters.setDbService(dbService);
0062   theHOHamamatsuSiPMParameters.setDbService(dbService);
0063   theHFParameters1.setDbService(dbService);
0064   theHFParameters2.setDbService(dbService);
0065   theZDCParameters.setDbService(dbService);
0066 }
0067 
0068 void HcalSimParameterMap::setFrameSize(const DetId &detId, int frameSize) {
0069   HcalGenericDetId genericId(detId);
0070   if (genericId.isHcalZDCDetId())
0071     setFrameSize(theZDCParameters, frameSize);
0072   else {
0073     HcalDetId hcalDetId(detId);
0074     if (hcalDetId.subdet() == HcalForward) {
0075       // do both depths
0076       setFrameSize(theHFParameters1, frameSize);
0077       setFrameSize(theHFParameters2, frameSize);
0078     } else {
0079       CaloSimParameters &parameters = const_cast<CaloSimParameters &>(simParameters(detId));
0080       setFrameSize(parameters, frameSize);
0081     }
0082   }
0083 }
0084 
0085 void HcalSimParameterMap::setFrameSize(CaloSimParameters &parameters, int frameSize) {
0086   int binOfMaximum = 5;
0087   if (frameSize == 10) {
0088   } else if (frameSize == 6)
0089     binOfMaximum = 4;
0090   else {
0091     edm::LogError("HcalSimParameterMap") << "Bad HCAL frame size " << frameSize;
0092   }
0093   if (parameters.readoutFrameSize() != frameSize) {
0094     edm::LogWarning("HcalSignalGenerator") << "Mismatch in frame sizes.  Setting to " << frameSize;
0095     parameters.setReadoutFrameSize(frameSize);
0096     parameters.setBinOfMaximum(binOfMaximum);
0097   }
0098 }