Skip to content

Commit

Permalink
Merge pull request #16002 from kpedro88/Phase1-DbHardcode3
Browse files Browse the repository at this point in the history
Configurable SiPM hardcode parameters
  • Loading branch information
cmsbuild committed Sep 30, 2016
2 parents c35f716 + 94965c0 commit 12aa3ff
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 33 deletions.
13 changes: 10 additions & 3 deletions CalibCalorimetry/HcalAlgos/interface/HcalDbHardcode.h
Expand Up @@ -27,8 +27,12 @@
#include "CondFormats/HcalObjects/interface/HcalTPParameters.h"
#include "CondFormats/HcalObjects/interface/HcalTPChannelParameters.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalHardcodeParameters.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"

#include <vector>
#include <map>
#include <utility>

/**
Expand Down Expand Up @@ -58,6 +62,7 @@ class HcalDbHardcode {
void useHOUpgrade(bool b) { useHOUpgrade_ = b; }
void useHFUpgrade(bool b) { useHFUpgrade_ = b; }
void testHFQIE10(bool b) { testHFQIE10_ = b; }
void setSiPMCharacteristics(std::vector<edm::ParameterSet> vps) { theSiPMCharacteristics_ = vps; }

//getters
const bool useHBUpgrade() const { return useHBUpgrade_; }
Expand All @@ -79,20 +84,22 @@ class HcalDbHardcode {
HcalTimingParam makeTimingParam (HcalGenericDetId fId);
void makeHardcodeMap(HcalElectronicsMap& emap, const std::vector<HcalGenericDetId>& cells);
void makeHardcodeDcsMap(HcalDcsMap& dcs_map);
void makeHardcodeFrontEndMap(HcalFrontEndMap& emap,
const std::vector<HcalGenericDetId>& cells);
HcalSiPMParameter makeHardcodeSiPMParameter (HcalGenericDetId fId);
void makeHardcodeFrontEndMap(HcalFrontEndMap& emap, const std::vector<HcalGenericDetId>& cells);
HcalSiPMParameter makeHardcodeSiPMParameter (HcalGenericDetId fId, const HcalTopology* topo);
void makeHardcodeSiPMCharacteristics (HcalSiPMCharacteristics& sipm);
HcalTPChannelParameter makeHardcodeTPChannelParameter (HcalGenericDetId fId);
void makeHardcodeTPParameters (HcalTPParameters& tppar);

private:
int getLayersInDepth(int ieta, int depth, const HcalTopology* topo);
//member variables
HcalHardcodeParameters theDefaultParameters_;
HcalHardcodeParameters theHBParameters_, theHEParameters_, theHFParameters_, theHOParameters_;
HcalHardcodeParameters theHBUpgradeParameters_, theHEUpgradeParameters_, theHFUpgradeParameters_;
bool setHB_, setHE_, setHF_, setHO_, setHBUpgrade_, setHEUpgrade_, setHFUpgrade_;
bool useHBUpgrade_, useHEUpgrade_, useHOUpgrade_, useHFUpgrade_, testHFQIE10_;
std::vector<edm::ParameterSet> theSiPMCharacteristics_;
std::map<std::pair<int,int>,int> theLayersInDepths_;
};

#endif
Expand Up @@ -11,7 +11,8 @@ class HcalHardcodeParameters {
HcalHardcodeParameters() {}
//construct from values
HcalHardcodeParameters(double pedestal, double pedestalWidth, std::vector<double> gain, std::vector<double> gainWidth,
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope, int mcShape, int recoShape);
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope, int mcShape, int recoShape,
double photoelectronsToAnalog, double darkCurrent);
//construct from pset
HcalHardcodeParameters(const edm::ParameterSet & p);

Expand All @@ -29,6 +30,8 @@ class HcalHardcodeParameters {
const double qieSlope(unsigned range) const { return qieSlope_.at(range); }
const int mcShape() const { return mcShape_; }
const int recoShape() const { return recoShape_; }
const double photoelectronsToAnalog() const { return photoelectronsToAnalog_; }
const double darkCurrent() const { return darkCurrent_; }

private:
//member variables
Expand All @@ -37,6 +40,7 @@ class HcalHardcodeParameters {
int qieType_;
std::vector<double> qieOffset_, qieSlope_;
int mcShape_, recoShape_;
double photoelectronsToAnalog_, darkCurrent_;
};

#endif
77 changes: 54 additions & 23 deletions CalibCalorimetry/HcalAlgos/src/HcalDbHardcode.cc
Expand Up @@ -14,7 +14,7 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

HcalDbHardcode::HcalDbHardcode()
: theDefaultParameters_(3.0,0.5,{0.2,0.2},{0.0,0.0},0,{0.0,0.0,0.0,0.0},{0.9,0.9,0.9,0.9},125,105), //"generic" set of conditions
: theDefaultParameters_(3.0,0.5,{0.2,0.2},{0.0,0.0},0,{0.0,0.0,0.0,0.0},{0.9,0.9,0.9,0.9},125,105,0.0,0.0), //"generic" set of conditions
setHB_(false), setHE_(false), setHF_(false), setHO_(false),
setHBUpgrade_(false), setHEUpgrade_(false), setHFUpgrade_(false),
useHBUpgrade_(false), useHEUpgrade_(false), useHOUpgrade_(true),
Expand Down Expand Up @@ -538,40 +538,71 @@ void HcalDbHardcode::makeHardcodeFrontEndMap(HcalFrontEndMap& emap, const std::v
emap.sort();
}

HcalSiPMParameter HcalDbHardcode::makeHardcodeSiPMParameter (HcalGenericDetId fId) {
// SiPMParameter defined for each DetId the following quantities:
// SiPM type, PhotoElectronToAnalog, Dark Current, two auxilairy words
// These numbers come from some measurements done with SiPM's
if (fId.isHcalDetId()) {
if (fId.subdetId() == HcalBarrel) {
if (useHBUpgrade_)
return HcalSiPMParameter(fId.rawId(), HcalHBHamamatsu1, 57.5, 0.055, 0, 0);
} else if (fId.subdetId() == HcalEndcap) {
if (useHEUpgrade_)
return HcalSiPMParameter(fId.rawId(), HcalHEHamamatsu1, 57.5, 0.055, 0, 0);
} else if (fId.subdetId() == HcalOuter) {
if (useHOUpgrade_)
return HcalSiPMParameter(fId.rawId(), HcalHOHamamatsu, 4.0, 0.055, 0, 0);
int HcalDbHardcode::getLayersInDepth(int ieta, int depth, const HcalTopology* topo){
//check for cached value
auto eta_depth_pair = std::make_pair(ieta,depth);
auto nLayers = theLayersInDepths_.find(eta_depth_pair);
if(nLayers != theLayersInDepths_.end()){
return nLayers->second;
}
else {
std::vector<int> segmentation;
topo->getDepthSegmentation(ieta,segmentation);
//assume depth segmentation vector is sorted
int nLayersInDepth = std::distance(std::lower_bound(segmentation.begin(),segmentation.end(),depth),
std::upper_bound(segmentation.begin(),segmentation.end(),depth));
theLayersInDepths_.insert(std::make_pair(eta_depth_pair,nLayersInDepth));
return nLayersInDepth;
}
}
return HcalSiPMParameter(fId.rawId(), HcalNoSiPM, 0, 0, 0, 0);
}

HcalSiPMParameter HcalDbHardcode::makeHardcodeSiPMParameter (HcalGenericDetId fId, const HcalTopology* topo) {
// SiPMParameter defined for each DetId the following quantities:
// SiPM type, PhotoElectronToAnalog, Dark Current, two auxiliary words
// These numbers come from some measurements done with SiPMs
// rule for type: cells with >4 layers use larger device (3.3mm diameter), otherwise 2.8mm
HcalSiPMType theType = HcalNoSiPM;
double thePe2fC = getParameters(fId).photoelectronsToAnalog();
double theDC = getParameters(fId).darkCurrent();
if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel && useHBUpgrade_) {
HcalDetId hid(fId);
int nLayersInDepth = getLayersInDepth(hid.ietaAbs(),hid.depth(),topo);
if(nLayersInDepth > 4) theType = HcalHBHamamatsu2;
else theType = HcalHBHamamatsu1;
} else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap && useHEUpgrade_) {
HcalDetId hid(fId);
int nLayersInDepth = getLayersInDepth(hid.ietaAbs(),hid.depth(),topo);
if(nLayersInDepth > 4) theType = HcalHEHamamatsu2;
else theType = HcalHEHamamatsu1;
} else if (fId.genericSubdet() == HcalGenericDetId::HcalGenOuter && useHOUpgrade_) {
theType = HcalHOHamamatsu;
}

return HcalSiPMParameter(fId.rawId(), theType, thePe2fC, theDC, 0, 0);
}

void HcalDbHardcode::makeHardcodeSiPMCharacteristics (HcalSiPMCharacteristics& sipm) {
// SiPMCharacteristics are constants for each type of SiPM:
// Type, # of pixels, 3 parameters for non-linearity, cross talk parameter, ..
// Obtained from data sheet and measurements
sipm.loadObject(HcalHOZecotek,36000,1,0,0,0.32,0,0);
sipm.loadObject(HcalHOHamamatsu,2500,1,0,0,0.32,0,0);
sipm.loadObject(HcalHEHamamatsu1,27370,1.000669,1.34646E-5,1.57918E-10,0.32,0,0);
sipm.loadObject(HcalHEHamamatsu2,38018,1.000669,1.34646E-5,1.57918E-10,0.32,0,0);
sipm.loadObject(HcalHBHamamatsu1,27370,1.000669,1.34646E-5,1.57918E-10,0.32,0,0);
// types (in order): HcalHOZecotek=1, HcalHOHamamatsu, HcalHEHamamatsu1, HcalHEHamamatsu2, HcalHBHamamatsu1
for(unsigned ip = 0; ip < theSiPMCharacteristics_.size(); ++ip){
auto& ps = theSiPMCharacteristics_[ip];
sipm.loadObject(ip+1,
ps.getParameter<int>("pixels"),
ps.getParameter<double>("nonlin1"),
ps.getParameter<double>("nonlin2"),
ps.getParameter<double>("nonlin3"),
ps.getParameter<double>("crosstalk"),
0,0
);
}
}

HcalTPChannelParameter HcalDbHardcode::makeHardcodeTPChannelParameter (HcalGenericDetId fId) {
// For each detId parameters for trigger primitive
// mask for channel validity and self trigger information, fine grain
// bit information and auxilairy words
// bit information and auxiliary words
uint32_t bitInfo = ((44 << 16) | 30);
return HcalTPChannelParameter(fId.rawId(), 0, bitInfo, 0, 0);
}
Expand Down
11 changes: 8 additions & 3 deletions CalibCalorimetry/HcalAlgos/src/HcalHardcodeParameters.cc
@@ -1,7 +1,8 @@
#include "CalibCalorimetry/HcalAlgos/interface/HcalHardcodeParameters.h"

HcalHardcodeParameters::HcalHardcodeParameters(double pedestal, double pedestalWidth, std::vector<double> gain, std::vector<double> gainWidth,
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope, int mcShape, int recoShape)
int qieType, std::vector<double> qieOffset, std::vector<double> qieSlope, int mcShape, int recoShape,
double photoelectronsToAnalog, double darkCurrent)
: pedestal_(pedestal),
pedestalWidth_(pedestalWidth),
gain_(gain),
Expand All @@ -10,7 +11,9 @@ HcalHardcodeParameters::HcalHardcodeParameters(double pedestal, double pedestalW
qieOffset_(qieOffset),
qieSlope_(qieSlope),
mcShape_(mcShape),
recoShape_(recoShape)
recoShape_(recoShape),
photoelectronsToAnalog_(photoelectronsToAnalog),
darkCurrent_(darkCurrent)
{
}

Expand All @@ -23,6 +26,8 @@ HcalHardcodeParameters::HcalHardcodeParameters(const edm::ParameterSet & p)
qieOffset_(p.getParameter<std::vector<double>>("qieOffset")),
qieSlope_(p.getParameter<std::vector<double>>("qieSlope")),
mcShape_(p.getParameter<int>("mcShape")),
recoShape_(p.getParameter<int>("recoShape"))
recoShape_(p.getParameter<int>("recoShape")),
photoelectronsToAnalog_(p.getParameter<double>("photoelectronsToAnalog")),
darkCurrent_(p.getParameter<double>("darkCurrent"))
{
}
Expand Up @@ -21,6 +21,7 @@
useHBUpgrade = cms.bool(False),
useHEUpgrade = cms.bool(False),
useHFUpgrade = cms.bool(False),
useHOUpgrade = cms.bool(True),
testHFQIE10 = cms.bool(False),
hb = cms.PSet(
pedestal = cms.double(3.0),
Expand All @@ -32,6 +33,8 @@
qieSlope = cms.vdouble(0.912,0.917,0.922,0.923),
mcShape = cms.int32(125),
recoShape = cms.int32(105),
photoelectronsToAnalog = cms.double(0.0),
darkCurrent = cms.double(0.0),
),
he = cms.PSet(
pedestal = cms.double(3.0),
Expand All @@ -43,6 +46,8 @@
qieSlope = cms.vdouble(0.912,0.916,0.920,0.922),
mcShape = cms.int32(125),
recoShape = cms.int32(105),
photoelectronsToAnalog = cms.double(0.0),
darkCurrent = cms.double(0.0),
),
hf = cms.PSet(
pedestal = cms.double(3.0),
Expand All @@ -54,6 +59,8 @@
qieSlope = cms.vdouble(0.359,0.358,0.360,0.367),
mcShape = cms.int32(301),
recoShape = cms.int32(301),
photoelectronsToAnalog = cms.double(0.0),
darkCurrent = cms.double(0.0),
),
ho = cms.PSet(
pedestal = cms.double(11.0),
Expand All @@ -65,6 +72,8 @@
qieSlope = cms.vdouble(0.907,0.915,0.920,0.921),
mcShape = cms.int32(201),
recoShape = cms.int32(201),
photoelectronsToAnalog = cms.double(4.0),
darkCurrent = cms.double(0.055),
),
hbUpgrade = cms.PSet(
pedestal = cms.double(17.3),
Expand All @@ -76,6 +85,8 @@
qieSlope = cms.vdouble(0.333,0.333,0.333,0.333),
mcShape = cms.int32(203),
recoShape = cms.int32(203),
photoelectronsToAnalog = cms.double(57.5),
darkCurrent = cms.double(0.055),
),
heUpgrade = cms.PSet(
pedestal = cms.double(17.3),
Expand All @@ -87,6 +98,8 @@
qieSlope = cms.vdouble(0.333,0.333,0.333,0.333),
mcShape = cms.int32(203),
recoShape = cms.int32(203),
photoelectronsToAnalog = cms.double(57.5),
darkCurrent = cms.double(0.055),
),
hfUpgrade = cms.PSet(
pedestal = cms.double(13.33),
Expand All @@ -98,6 +111,17 @@
qieSlope = cms.vdouble(0.297,0.298,0.298,0.313),
mcShape = cms.int32(301),
recoShape = cms.int32(301),
photoelectronsToAnalog = cms.double(0.0),
darkCurrent = cms.double(0.0),
),
# types (in order): HcalHOZecotek, HcalHOHamamatsu, HcalHEHamamatsu1, HcalHEHamamatsu2, HcalHBHamamatsu1, HcalHBHamamatsu2
SiPMCharacteristics = cms.VPSet(
cms.PSet( pixels = cms.int32(36000), crosstalk = cms.double(0.32), nonlin1 = cms.double(1.0), nonlin2 = cms.double(0.0), nonlin3 = cms.double(0.0) ),
cms.PSet( pixels = cms.int32(2500), crosstalk = cms.double(0.32), nonlin1 = cms.double(1.0), nonlin2 = cms.double(0.0), nonlin3 = cms.double(0.0) ),
cms.PSet( pixels = cms.int32(27370), crosstalk = cms.double(0.32), nonlin1 = cms.double(1.000669), nonlin2 = cms.double(1.34646E-5), nonlin3 = cms.double(1.57918E-10) ),
cms.PSet( pixels = cms.int32(38018), crosstalk = cms.double(0.32), nonlin1 = cms.double(1.000669), nonlin2 = cms.double(1.34646E-5), nonlin3 = cms.double(1.57918E-10) ),
cms.PSet( pixels = cms.int32(27370), crosstalk = cms.double(0.32), nonlin1 = cms.double(1.000669), nonlin2 = cms.double(1.34646E-5), nonlin3 = cms.double(1.57918E-10) ),
cms.PSet( pixels = cms.int32(38018), crosstalk = cms.double(0.32), nonlin1 = cms.double(1.000669), nonlin2 = cms.double(1.34646E-5), nonlin3 = cms.double(1.57918E-10) ),
),
)

Expand Down
29 changes: 27 additions & 2 deletions CalibCalorimetry/HcalPlugins/src/HcalHardcodeCalibrations.cc
Expand Up @@ -115,7 +115,7 @@ namespace {
}

HcalHardcodeCalibrations::HcalHardcodeCalibrations ( const edm::ParameterSet& iConfig ):
he_recalibration(0), hf_recalibration(0), setHEdsegm(false), setHBdsegm(false), testHFQIE10(iConfig.getParameter<bool>("testHFQIE10"))
he_recalibration(0), hf_recalibration(0), setHEdsegm(false), setHBdsegm(false)
{
edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::HcalHardcodeCalibrations->...";

Expand All @@ -134,7 +134,9 @@ HcalHardcodeCalibrations::HcalHardcodeCalibrations ( const edm::ParameterSet& iC
dbHardcode.useHBUpgrade(iConfig.getParameter<bool>("useHBUpgrade"));
dbHardcode.useHEUpgrade(iConfig.getParameter<bool>("useHEUpgrade"));
dbHardcode.useHFUpgrade(iConfig.getParameter<bool>("useHFUpgrade"));
dbHardcode.useHOUpgrade(iConfig.getParameter<bool>("useHOUpgrade"));
dbHardcode.testHFQIE10(iConfig.getParameter<bool>("testHFQIE10"));
dbHardcode.setSiPMCharacteristics(iConfig.getParameter<std::vector<edm::ParameterSet>>("SiPMCharacteristics"));

// HE and HF recalibration preparation
iLumi=iConfig.getParameter<double>("iLumi");
Expand Down Expand Up @@ -769,7 +771,7 @@ std::unique_ptr<HcalSiPMParameters> HcalHardcodeCalibrations::produceSiPMParamet
auto result = std::make_unique<HcalSiPMParameters>(topo);
std::vector <HcalGenericDetId> cells = allCells(*htopo);
for (std::vector <HcalGenericDetId>::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) {
HcalSiPMParameter item = dbHardcode.makeHardcodeSiPMParameter (*cell);
HcalSiPMParameter item = dbHardcode.makeHardcodeSiPMParameter (*cell,topo);
result->addValues(item);
}
return result;
Expand Down Expand Up @@ -817,6 +819,7 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc.add<bool>("useHBUpgrade",false);
desc.add<bool>("useHEUpgrade",false);
desc.add<bool>("useHFUpgrade",false);
desc.add<bool>("useHOUpgrade",true);
desc.add<bool>("testHFQIE10",false);
desc.addUntracked<std::vector<std::string>>("toGet",std::vector<std::string>());
desc.addUntracked<bool>("fromDDD",false);
Expand All @@ -831,6 +834,8 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_hb.add<int>("qieType", 0);
desc_hb.add<int>("mcShape",125);
desc_hb.add<int>("recoShape",105);
desc_hb.add<double>("photoelectronsToAnalog",0.0);
desc_hb.add<double>("darkCurrent",0.0);
desc.add<edm::ParameterSetDescription>("hb", desc_hb);

edm::ParameterSetDescription desc_hbUpgrade;
Expand All @@ -843,6 +848,8 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_hbUpgrade.add<int>("qieType", 2);
desc_hbUpgrade.add<int>("mcShape",203);
desc_hbUpgrade.add<int>("recoShape",203);
desc_hbUpgrade.add<double>("photoelectronsToAnalog",57.5);
desc_hbUpgrade.add<double>("darkCurrent",0.055);
desc.add<edm::ParameterSetDescription>("hbUpgrade", desc_hbUpgrade);

edm::ParameterSetDescription desc_he;
Expand All @@ -855,6 +862,8 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_he.add<int>("qieType", 0);
desc_he.add<int>("mcShape",125);
desc_he.add<int>("recoShape",105);
desc_he.add<double>("photoelectronsToAnalog",0.0);
desc_he.add<double>("darkCurrent",0.0);
desc.add<edm::ParameterSetDescription>("he", desc_he);

edm::ParameterSetDescription desc_heUpgrade;
Expand All @@ -867,6 +876,8 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_heUpgrade.add<int>("qieType", 2);
desc_heUpgrade.add<int>("mcShape",203);
desc_heUpgrade.add<int>("recoShape",203);
desc_heUpgrade.add<double>("photoelectronsToAnalog",57.5);
desc_heUpgrade.add<double>("darkCurrent",0.055);
desc.add<edm::ParameterSetDescription>("heUpgrade", desc_heUpgrade);

edm::ParameterSetDescription desc_hf;
Expand All @@ -879,6 +890,8 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_hf.add<int>("qieType", 0);
desc_hf.add<int>("mcShape",301);
desc_hf.add<int>("recoShape",301);
desc_hf.add<double>("photoelectronsToAnalog",0.0);
desc_hf.add<double>("darkCurrent",0.0);
desc.add<edm::ParameterSetDescription>("hf", desc_hf);

edm::ParameterSetDescription desc_hfUpgrade;
Expand All @@ -891,6 +904,8 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_hfUpgrade.add<int>("qieType", 1);
desc_hfUpgrade.add<int>("mcShape",301);
desc_hfUpgrade.add<int>("recoShape",301);
desc_hfUpgrade.add<double>("photoelectronsToAnalog",0.0);
desc_hfUpgrade.add<double>("darkCurrent",0.0);
desc.add<edm::ParameterSetDescription>("hfUpgrade", desc_hfUpgrade);

edm::ParameterSetDescription desc_hfrecal;
Expand All @@ -910,8 +925,18 @@ void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions &
desc_ho.add<int>("qieType", 0);
desc_ho.add<int>("mcShape",201);
desc_ho.add<int>("recoShape",201);
desc_ho.add<double>("photoelectronsToAnalog",4.0);
desc_ho.add<double>("darkCurrent",0.055);
desc.add<edm::ParameterSetDescription>("ho", desc_ho);

edm::ParameterSetDescription validator_sipm;
validator_sipm.add<int>("pixels",1);
validator_sipm.add<double>("crosstalk",0);
validator_sipm.add<double>("nonlin1",1);
validator_sipm.add<double>("nonlin2",0);
validator_sipm.add<double>("nonlin3",0);
std::vector<edm::ParameterSet> default_sipm(1);
desc.addVPSet("SiPMCharacteristics",validator_sipm,default_sipm);

descriptions.addDefault(desc);
}

0 comments on commit 12aa3ff

Please sign in to comment.