CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HBHEDarkening Class Reference

#include <HBHEDarkening.h>

Classes

struct  LumiYear
 
struct  LumiYearComp
 

Public Member Functions

float degradation (float intlumi, int ieta, int lay) const
 
int get_ieta_shift () const
 
 HBHEDarkening (int ieta_shift, float drdA, float drdB, std::map< int, std::vector< std::vector< float >>> dosemaps, std::vector< LumiYear > years)
 
 ~HBHEDarkening ()
 

Static Public Member Functions

static std::vector< std::vector< float > > readDoseMap (const std::string &fullpath)
 

Private Member Functions

float degradationYear (const LumiYear &year, float intlumi, int ieta, int lay) const
 
float dose (int ieta, int lay, int energy) const
 
std::string getYearForLumi (float intlumi) const
 

Private Attributes

std::map< int, std::vector< std::vector< float > > > dosemaps_
 
float drdA_
 
float drdB_
 
int ieta_shift_
 
std::vector< LumiYearyears_
 

Detailed Description

Definition at line 17 of file HBHEDarkening.h.

Constructor & Destructor Documentation

◆ HBHEDarkening()

HBHEDarkening::HBHEDarkening ( int  ieta_shift,
float  drdA,
float  drdB,
std::map< int, std::vector< std::vector< float >>>  dosemaps,
std::vector< LumiYear years 
)

Definition at line 16 of file HBHEDarkening.cc.

References jetUpdater_cfi::sort, HLT_2023v12_cff::year, and years_.

21  : ieta_shift_(ieta_shift), drdA_(drdA), drdB_(drdB), dosemaps_(std::move(dosemaps)), years_(std::move(years)) {
22  //finish initializing years
23  std::sort(years_.begin(), years_.end());
24  //sum up int lumi
25  float sumlumi = 0.0;
26  for (auto& year : years_) {
27  sumlumi += year.intlumi_;
28  year.sumlumi_ = sumlumi;
29  }
30 }
std::map< int, std::vector< std::vector< float > > > dosemaps_
Definition: HBHEDarkening.h:63
std::vector< LumiYear > years_
Definition: HBHEDarkening.h:64
def move(src, dest)
Definition: eostools.py:511

◆ ~HBHEDarkening()

HBHEDarkening::~HBHEDarkening ( )
inline

Definition at line 45 of file HBHEDarkening.h.

45 {}

Member Function Documentation

◆ degradation()

float HBHEDarkening::degradation ( float  intlumi,
int  ieta,
int  lay 
) const

Definition at line 98 of file HBHEDarkening.cc.

References funct::abs(), cms::cuda::assert(), degradationYear(), getYearForLumi(), hcalRecHitTable_cff::ieta, ieta_shift_, submitPVValidationJobs::intlumi, AlCaHLTBitMon_QueryRunRegistry::string, HLT_2023v12_cff::year, and years_.

Referenced by HcalDigitizer::darkening(), HCalSD::getEnergyDeposit(), and HBHERecalibration::initialize().

98  {
99  ieta = abs(ieta);
100  //shift ieta tower index to act as array index
101  ieta -= ieta_shift_;
102  //shift layer index by 1 to act as array index
103  lay -= 1;
104 
105  //accumulate degradation over years
106  float response = 1.0;
107  std::string yearForLumi = getYearForLumi(intlumi);
108  assert(!yearForLumi.empty());
109 
110  for (const auto& year : years_) {
111  response *= degradationYear(year, intlumi, ieta, lay);
112  if (year.year_ == yearForLumi)
113  break;
114  }
115 
116  return response;
117 }
std::string getYearForLumi(float intlumi) const
assert(be >=bs)
float degradationYear(const LumiYear &year, float intlumi, int ieta, int lay) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< LumiYear > years_
Definition: HBHEDarkening.h:64

◆ degradationYear()

float HBHEDarkening::degradationYear ( const LumiYear year,
float  intlumi,
int  ieta,
int  lay 
) const
private

Definition at line 80 of file HBHEDarkening.cc.

References dose(), drdA_, drdB_, JetChargeProducer_cfi::exp, hcalRecHitTable_cff::ieta, submitPVValidationJobs::intlumi, funct::pow(), and HLT_2023v12_cff::year.

Referenced by degradation().

80  {
81  float doseToUse = dose(ieta, lay, year.energy_);
82  if (doseToUse == 0.0)
83  return 1.0;
84 
85  //apply dose rate dependence model to the provided year
86  //get krad/hr from Mrad/fb-1 and fb-1/hr
87  float decayConst = drdA_ * std::pow(1000 * doseToUse * year.lumirate_, drdB_);
88 
89  //determine if this is a partial year
90  float intlumiToUse = year.intlumi_;
91  if (intlumi < year.sumlumi_)
92  intlumiToUse = intlumi - (year.sumlumi_ - year.intlumi_);
93 
94  //calculate degradation
95  return std::exp(-(intlumiToUse * doseToUse) / decayConst);
96 }
float dose(int ieta, int lay, int energy) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ dose()

float HBHEDarkening::dose ( int  ieta,
int  lay,
int  energy 
) const
private

Definition at line 51 of file HBHEDarkening.cc.

References dosemaps_, hcalRecHitTable_cff::energy, and hcalRecHitTable_cff::ieta.

Referenced by degradationYear().

51  {
52  //existence check
53  const auto dosemapIt = dosemaps_.find(energy);
54  if (dosemapIt == dosemaps_.end())
55  return 0.0;
56 
57  //bounds check
58  const auto& dosemap = dosemapIt->second;
59  if (ieta < 0 or ieta >= int(dosemap.size()))
60  return 0.0;
61 
62  //bounds check
63  const auto& doserow = dosemap[ieta];
64  if (lay < 0 or lay >= int(doserow.size()))
65  return 0.0;
66 
67  return doserow[lay];
68 }
std::map< int, std::vector< std::vector< float > > > dosemaps_
Definition: HBHEDarkening.h:63

◆ get_ieta_shift()

int HBHEDarkening::get_ieta_shift ( ) const
inline

Definition at line 49 of file HBHEDarkening.h.

References ieta_shift_.

Referenced by HBHERecalibration::setup().

49 { return ieta_shift_; }

◆ getYearForLumi()

std::string HBHEDarkening::getYearForLumi ( float  intlumi) const
private

Definition at line 70 of file HBHEDarkening.cc.

References Exception, submitPVValidationJobs::intlumi, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, or, and years_.

Referenced by degradation().

70  {
71  //compare based on sum lumi value
72  auto lb = std::lower_bound(years_.begin(), years_.end(), intlumi, LumiYearComp());
73  if (lb == years_.end() or lb->sumlumi_ < intlumi) {
74  throw cms::Exception("ValueError") << "HBHEDarkening: insufficient LHC run information provided to simulate "
75  << intlumi << "/fb - check the python config" << std::endl;
76  }
77  return lb->year_;
78 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< LumiYear > years_
Definition: HBHEDarkening.h:64

◆ readDoseMap()

std::vector< std::vector< float > > HBHEDarkening::readDoseMap ( const std::string &  fullpath)
static

Definition at line 32 of file HBHEDarkening.cc.

References Exception, reco_skim_cfg_mod::fullpath, timingPdfMaker::infile, mps_splice::line, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HBHEDarkeningEP::produce().

32  {
33  std::ifstream infile(fullpath.c_str());
34  if (!infile.is_open()) {
35  throw cms::Exception("FileNotFound") << "Unable to open '" << fullpath << "'" << std::endl;
36  }
38  std::vector<std::vector<float>> result;
39  while (getline(infile, line)) {
40  //space-separated
41  std::stringstream linestream(line);
42  std::vector<float> lineresult;
43  float doseval;
44  while (linestream >> doseval)
45  lineresult.push_back(doseval);
46  result.push_back(lineresult);
47  }
48  return result;
49 }

Member Data Documentation

◆ dosemaps_

std::map<int, std::vector<std::vector<float> > > HBHEDarkening::dosemaps_
private

Definition at line 63 of file HBHEDarkening.h.

Referenced by dose().

◆ drdA_

float HBHEDarkening::drdA_
private

Definition at line 62 of file HBHEDarkening.h.

Referenced by degradationYear().

◆ drdB_

float HBHEDarkening::drdB_
private

Definition at line 62 of file HBHEDarkening.h.

Referenced by degradationYear().

◆ ieta_shift_

int HBHEDarkening::ieta_shift_
private

Definition at line 61 of file HBHEDarkening.h.

Referenced by degradation(), and get_ieta_shift().

◆ years_

std::vector<LumiYear> HBHEDarkening::years_
private

Definition at line 64 of file HBHEDarkening.h.

Referenced by degradation(), getYearForLumi(), and HBHEDarkening().