Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hgc sample gain fix cns cmssw 11 0 0 pre9 #9

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SLHCUpgradeSimulations/Configuration/python/aging.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def ageHF(process,turnon):
process.es_hardcode.HFRecalibration = cms.bool(turnon)
return process

def agedHGCal(process):
def agedHGCal(process,algo=0):
from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import HGCal_setEndOfLifeNoise
process = HGCal_setEndOfLifeNoise(process)
process = HGCal_setEndOfLifeNoise(process,byDose=True,byDoseAlgo=algo)
return process

# needs lumi to set proper ZS thresholds (tbd)
Expand Down
8 changes: 5 additions & 3 deletions SimCalorimetry/HGCalSimAlgos/interface/HGCalRadiationMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class HGCalRadiationMap {
typedef std::map<std::pair<int, int>, DoseParameters> doseParametersMap;

void setGeometry(const CaloSubdetectorGeometry *);
void setDoseMap(const std::string &);
void setDoseMap(const std::string &,const unsigned int &);

double getDoseValue(const int, const int, const radiiVec &, bool logVal = false);
double getFluenceValue(const int, const int, const radiiVec &, bool logVal = false);


const unsigned int &algo() { return algo_; }
const HGCalGeometry *geom() { return hgcalGeom_; }
const HGCalTopology *topo() { return hgcalTopology_; }
const HGCalDDDConstants *ddd() { return hgcalDDD_; }
Expand All @@ -39,7 +40,8 @@ class HGCalRadiationMap {

private:
doseParametersMap readDosePars(const std::string &);


unsigned int algo_;
const HGCalGeometry *hgcalGeom_;
const HGCalTopology *hgcalTopology_;
const HGCalDDDConstants *hgcalDDD_;
Expand Down
13 changes: 12 additions & 1 deletion SimCalorimetry/HGCalSimAlgos/interface/HGCalSiNoiseMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
*/
class HGCalSiNoiseMap : public HGCalRadiationMap {
public:

enum GainRange_t { q80fC, q160fC, q320fC, AUTO };
enum NoiseMapAlgoBits_t { FLUENCE, CCE, NOISE };


struct SiCellOpCharacteristics {
SiCellOpCharacteristics()
Expand Down Expand Up @@ -40,13 +43,18 @@ class HGCalSiNoiseMap : public HGCalRadiationMap {
cceParam_.push_back(parsThick); //300
}


/**
@short overrides base class method with specifics for the configuration of the algo
*/
void setDoseMap(const std::string &,const unsigned int &);

/**
@short returns the charge collection efficiency and noise
if gain range is set to auto, it will find the most appropriate gain to put the mip peak close to 10 ADC counts
*/
SiCellOpCharacteristics getSiCellOpCharacteristics(const HGCSiliconDetId &did,
GainRange_t gain = GainRange_t::AUTO,
bool ignoreFluence = false,
int aimMIPtoADC = 10);

std::vector<double> &getMipEqfC() { return mipEqfC_; }
Expand Down Expand Up @@ -83,6 +91,9 @@ class HGCalSiNoiseMap : public HGCalRadiationMap {

//conversions
const double unitToMicro_ = 1e6;

//flags used to disable specific components of the Si operation parameters
bool ignoreFluence_, ignoreCCE_, ignoreNoise_;
};

#endif
5 changes: 4 additions & 1 deletion SimCalorimetry/HGCalSimAlgos/src/HGCalRadiationMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#include <fstream>

//
void HGCalRadiationMap::setDoseMap(const std::string& fullpath) { doseMap_ = readDosePars(fullpath); }
void HGCalRadiationMap::setDoseMap(const std::string& fullpath,const unsigned int &algo) {
doseMap_ = readDosePars(fullpath);
algo_ = algo;
}

//
void HGCalRadiationMap::setGeometry(const CaloSubdetectorGeometry* geom) {
Expand Down
30 changes: 27 additions & 3 deletions SimCalorimetry/HGCalSimAlgos/src/HGCalSiNoiseMap.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#include "SimCalorimetry/HGCalSimAlgos/interface/HGCalSiNoiseMap.h"

//
HGCalSiNoiseMap::HGCalSiNoiseMap() : encpScale_(840.), encCommonNoiseSub_(sqrt(1.25)), qe2fc_(1.60217646E-4) {
HGCalSiNoiseMap::HGCalSiNoiseMap() :
encpScale_(840.),
encCommonNoiseSub_(sqrt(1.25)),
qe2fc_(1.60217646E-4),
ignoreFluence_(false),
ignoreCCE_(false),
ignoreNoise_(false)
{
encsParam_.push_back({636., 15.6, 0.0328}); // q80fC
maxADCPerGain_.push_back(80.); // the num of fC (charge) which corresponds to the max ADC value
encsParam_.push_back({1045., 8.74, 0.0685}); // q160fC
Expand Down Expand Up @@ -37,10 +44,21 @@ HGCalSiNoiseMap::HGCalSiNoiseMap() : encpScale_(840.), encCommonNoiseSub_(sqrt(1
cellVolume_.push_back(cellVolume_300);
}

//
void HGCalSiNoiseMap::setDoseMap(const std::string &fullpath,const unsigned int &algo){

//decode bits in the algo word
ignoreFluence_ = ((algo >> FLUENCE) & 0x1 );
ignoreCCE_ = ((algo >> CCE) & 0x1 );
ignoreNoise_ = ((algo >> NOISE) & 0x1 );

//call base class method
HGCalRadiationMap::setDoseMap(fullpath,algo);
}

//
HGCalSiNoiseMap::SiCellOpCharacteristics HGCalSiNoiseMap::getSiCellOpCharacteristics(const HGCSiliconDetId &cellId,
GainRange_t gain,
bool ignoreFluence,
int aimMIPtoADC) {
SiCellOpCharacteristics siop;

Expand All @@ -55,7 +73,7 @@ HGCalSiNoiseMap::SiCellOpCharacteristics HGCalSiNoiseMap::getSiCellOpCharacteris
return siop;

//leakage current and CCE [muA]
if (ignoreFluence) {
if (ignoreFluence_) {
siop.fluence = 0;
siop.lnfluence = -1;
siop.ileak = exp(ileakParam_[1]) * cellVol * unitToMicro_;
Expand All @@ -82,6 +100,9 @@ HGCalSiNoiseMap::SiCellOpCharacteristics HGCalSiNoiseMap::getSiCellOpCharacteris
siop.cce = std::max(0., siop.cce);
}

//reset if CCE is to be ignored
if(ignoreCCE_) siop.cce=1.0;

//determine the gain to apply accounting for cce
double S(siop.cce * mipEqfC_[cellThick]);
if (gain == GainRange_t::AUTO) {
Expand All @@ -108,6 +129,9 @@ HGCalSiNoiseMap::SiCellOpCharacteristics HGCalSiNoiseMap::getSiCellOpCharacteris
double enc_s(encsParam_[gain][0] + encsParam_[gain][1] * cellCap + encsParam_[gain][2] * pow(cellCap, 2));
double enc_p(encpScale_ * sqrt(siop.ileak));
siop.noise = hypot(enc_p, enc_s* encCommonNoiseSub_ ) * qe2fc_;

//reset if NOISE is to be ignored
if(ignoreNoise_) siop.noise=0.0;

return siop;
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void HGCHEbackSignalScalerAnalyzer::analyze(const edm::Event& iEvent, const edm:

//instantiate scaler
HGCalSciNoiseMap scal;
scal.setDoseMap(doseMap_);
scal.setDoseMap(doseMap_,0);
scal.setSipmMap(sipmMap_);
scal.setGeometry(gHGCal_);

Expand Down
10 changes: 5 additions & 5 deletions SimCalorimetry/HGCalSimAlgos/test/HGCSiNoiseMapAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HGCSiNoiseMapAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResour
std::map<std::pair<DetId::Detector, int>, TProfile *> detCCEVsFluence_;

int aimMIPtoADC_;
bool ignoreFluence_, ignoreGainSettings_;
bool ignoreGainSettings_;

const int plotMargin_ = 20;
};
Expand All @@ -70,6 +70,7 @@ HGCSiNoiseMapAnalyzer::HGCSiNoiseMapAnalyzer(const edm::ParameterSet &iConfig) {

//configure the dose map
std::string doseMapURL(iConfig.getParameter<std::string>("doseMap"));
unsigned int doseMapAlgo(iConfig.getParameter<unsigned int>("doseMapAlgo"));
std::vector<double> ileakParam(
iConfig.getParameter<edm::ParameterSet>("ileakParam").template getParameter<std::vector<double>>("ileakParam"));
std::vector<double> cceParamFine(
Expand All @@ -80,17 +81,16 @@ HGCSiNoiseMapAnalyzer::HGCSiNoiseMapAnalyzer(const edm::ParameterSet &iConfig) {
iConfig.getParameter<edm::ParameterSet>("cceParams").template getParameter<std::vector<double>>("cceParamThick"));

noiseMaps_[DetId::HGCalEE] = std::unique_ptr<HGCalSiNoiseMap>(new HGCalSiNoiseMap);
noiseMaps_[DetId::HGCalEE]->setDoseMap(doseMapURL);
noiseMaps_[DetId::HGCalEE]->setDoseMap(doseMapURL,doseMapAlgo);
noiseMaps_[DetId::HGCalEE]->setIleakParam(ileakParam);
noiseMaps_[DetId::HGCalEE]->setCceParam(cceParamFine, cceParamThin, cceParamThick);

noiseMaps_[DetId::HGCalHSi] = std::unique_ptr<HGCalSiNoiseMap>(new HGCalSiNoiseMap);
noiseMaps_[DetId::HGCalHSi]->setDoseMap(doseMapURL);
noiseMaps_[DetId::HGCalHSi]->setDoseMap(doseMapURL,doseMapAlgo);
noiseMaps_[DetId::HGCalHSi]->setIleakParam(ileakParam);
noiseMaps_[DetId::HGCalHSi]->setCceParam(cceParamFine, cceParamThin, cceParamThick);

aimMIPtoADC_ = iConfig.getParameter<int>("aimMIPtoADC");
ignoreFluence_ = iConfig.getParameter<bool>("ignoreFluence");
ignoreGainSettings_ = iConfig.getParameter<bool>("ignoreGainSettings");
}

Expand Down Expand Up @@ -176,7 +176,7 @@ void HGCSiNoiseMapAnalyzer::analyze(const edm::Event &iEvent, const edm::EventSe
if (ignoreGainSettings_)
gainToSet = HGCalSiNoiseMap::q80fC;
HGCalSiNoiseMap::SiCellOpCharacteristics siop =
noiseMaps_[d]->getSiCellOpCharacteristics(id, gainToSet, ignoreFluence_, aimMIPtoADC_);
noiseMaps_[d]->getSiCellOpCharacteristics(id, gainToSet, aimMIPtoADC_);

//fill histos (layer,radius)
detN_[d]->Fill(layer, r, 1);
Expand Down
6 changes: 3 additions & 3 deletions SimCalorimetry/HGCalSimAlgos/test/hgcsiNoiseMapTester_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import HGCAL_ileakParam_toUse, HGCAL_cceParams_toUse
process.plotter_eol = cms.EDAnalyzer("HGCSiNoiseMapAnalyzer",
doseMap = cms.string( options.doseMap ),
doseMapAlgo = cms.uint32(0),
ileakParam = HGCAL_ileakParam_toUse,
cceParams = HGCAL_cceParams_toUse,
aimMIPtoADC = cms.int32(10),
ignoreGainSettings = cms.bool(False),
ignoreFluence = cms.bool(False)
ignoreGainSettings = cms.bool(False)
)

process.plotter_eol_nogain = process.plotter_eol.clone( ignoreGainSettings = cms.bool(True) )

process.plotter_start = process.plotter_eol.clone( ignoreFluence = cms.bool(True) )
process.plotter_start = process.plotter_eol.clone( doseMapAlgo=cms.uint32(3) )


process.TFileService = cms.Service("TFileService",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@

HGCAL_noise_fC = cms.PSet(
scaleByDose = cms.bool(False),
scaleByDoseAlgo = cms.uint32(0),
doseMap = cms.string(""),
values = cms.vdouble( [x*fC_per_ele for x in nonAgedNoises] ), #100,200,300 um
)

HGCAL_noise_heback = cms.PSet(
scaleByDose = cms.bool(False),
scaleByDoseAlgo = cms.uint32(0),
doseMap = cms.string(""), #empty dose map at begin-of-life
noise_MIP = cms.double(1./100.)
)
Expand Down Expand Up @@ -318,9 +320,10 @@
#function to set noise to aged HGCal
endOfLifeCCEs = [0.5, 0.5, 0.7]
endOfLifeNoises = [2400.0,2250.0,1750.0]
def HGCal_setEndOfLifeNoise(process,byDose=True):
def HGCal_setEndOfLifeNoise(process,byDose=True,byDoseAlgo=0):
process.HGCAL_noise_fC = cms.PSet(
scaleByDose = cms.bool(byDose),
scaleByDoseAlgo = cms.uint32(byDoseAlgo),
doseMap = cms.string("SimCalorimetry/HGCalSimProducers/data/doseParams_3000fb_fluka-3.5.15.9.txt"),
values = cms.vdouble( [x*fC_per_ele for x in endOfLifeNoises] ), #100,200,300 um
)
Expand All @@ -329,6 +332,7 @@ def HGCal_setEndOfLifeNoise(process,byDose=True):
)
process.HGCAL_noise_heback = cms.PSet(
scaleByDose = cms.bool(byDose),
scaleByDoseAlgo = cms.uint32(byDoseAlgo),
doseMap = cms.string("SimCalorimetry/HGCalSimProducers/data/doseParams_3000fb_fluka-3.5.15.9.txt"),
noise_MIP = cms.double(1./5.) #uses noise map
)
Expand All @@ -343,6 +347,7 @@ def HGCal_disableNoise(process):
)
process.HGCAL_noise_heback = cms.PSet(
scaleByDose = cms.bool(False),
scaleByDoseAlgo = cms.uint32(0),
doseMap = cms.string(""),
noise_MIP = cms.double(0.) #zero noise
)
Expand Down
9 changes: 5 additions & 4 deletions SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ HGCDigitizerBase<DFr>::HGCDigitizerBase(const edm::ParameterSet& ps) : scaleByDo
const auto& noises =
myCfg_.getParameter<edm::ParameterSet>("noise_fC").template getParameter<std::vector<double>>("values");
noise_fC_ = std::vector<float>(noises.begin(), noises.end());
scaleByDose_ = myCfg_.getParameter<edm::ParameterSet>("noise_fC").template getParameter<bool>("scaleByDose");
doseMapFile_ = myCfg_.getParameter<edm::ParameterSet>("noise_fC").template getParameter<std::string>("doseMap");
scal_.setDoseMap(doseMapFile_);
scaleByDose_ = myCfg_.getParameter<edm::ParameterSet>("noise_fC").template getParameter<bool>("scaleByDose");
int scaleByDoseAlgo = myCfg_.getParameter<edm::ParameterSet>("noise_fC").template getParameter<uint32_t>("scaleByDoseAlgo");
doseMapFile_ = myCfg_.getParameter<edm::ParameterSet>("noise_fC").template getParameter<std::string>("doseMap");
scal_.setDoseMap(doseMapFile_,scaleByDoseAlgo);
} else {
noise_fC_.resize(1, 1.f);
}
Expand Down Expand Up @@ -96,7 +97,7 @@ void HGCDigitizerBase<DFr>::runSimple(std::unique_ptr<HGCDigitizerBase::DColl>&
if (scaleByDose_) {
HGCSiliconDetId detId(id);
HGCalSiNoiseMap::SiCellOpCharacteristics siop =
scal_.getSiCellOpCharacteristics(detId, HGCalSiNoiseMap::AUTO, false, myFEelectronics_->getTargetMipValue());
scal_.getSiCellOpCharacteristics(detId, HGCalSiNoiseMap::AUTO, myFEelectronics_->getTargetMipValue());
cce = siop.cce;
noiseWidth = siop.noise;
lsbADC = scal_.getLSBPerGain()[(HGCalSiNoiseMap::GainRange_t)siop.gain];
Expand Down
3 changes: 2 additions & 1 deletion SimCalorimetry/HGCalSimProducers/src/HGCHEbackDigitizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ HGCHEbackDigitizer::HGCHEbackDigitizer(const edm::ParameterSet& ps) : HGCDigitiz
scaleBySipmArea_ = cfg.getParameter<bool>("scaleBySipmArea");
sipmMapFile_ = cfg.getParameter<std::string>("sipmMap");
scaleByDose_ = cfg.getParameter<edm::ParameterSet>("noise").getParameter<bool>("scaleByDose");
unsigned int scaleByDoseAlgo=cfg.getParameter<edm::ParameterSet>("noise").getParameter<uint32_t>("scaleByDoseAlgo");
doseMapFile_ = cfg.getParameter<edm::ParameterSet>("noise").getParameter<std::string>("doseMap");
noise_MIP_ = cfg.getParameter<edm::ParameterSet>("noise").getParameter<double>("noise_MIP");
thresholdFollowsMIP_ = cfg.getParameter<bool>("thresholdFollowsMIP");
Expand All @@ -29,7 +30,7 @@ HGCHEbackDigitizer::HGCHEbackDigitizer(const edm::ParameterSet& ps) : HGCDigitiz
xTalk_ = cfg.getParameter<double>("xTalk");
sdPixels_ = cfg.getParameter<double>("sdPixels");

scal_.setDoseMap(doseMapFile_);
scal_.setDoseMap(doseMapFile_,scaleByDoseAlgo);
scal_.setSipmMap(sipmMapFile_);
}

Expand Down