CMS 3D CMS Logo

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, const std::map< int, std::vector< std::vector< float >>> &dosemaps, const 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 ( int  ieta_shift,
float  drdA,
float  drdB,
const std::map< int, std::vector< std::vector< float >>> &  dosemaps,
const std::vector< LumiYear > &  years 
)

Definition at line 16 of file HBHEDarkening.cc.

References create_public_lumi_plots::year, and years_.

Referenced by HBHEDarkening::LumiYearComp::operator()().

16  :
17  ieta_shift_(ieta_shift), drdA_(drdA), drdB_(drdB), dosemaps_(dosemaps), years_(years)
18 {
19  //finish initializing years
20  std::sort(years_.begin(),years_.end());
21  //sum up int lumi
22  float sumlumi = 0.0;
23  for(auto& year : years_){
24  sumlumi += year.intlumi_;
25  year.sumlumi_ = sumlumi;
26  }
27 }
std::map< int, std::vector< std::vector< float > > > dosemaps_
Definition: HBHEDarkening.h:64
std::vector< LumiYear > years_
Definition: HBHEDarkening.h:65
HBHEDarkening::~HBHEDarkening ( )
inline

Definition at line 46 of file HBHEDarkening.h.

References degradation().

46 {}

Member Function Documentation

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

Definition at line 88 of file HBHEDarkening.cc.

References funct::abs(), degradationYear(), getYearForLumi(), ieta_shift_, AlCaHLTBitMon_QueryRunRegistry::string, create_public_lumi_plots::year, and years_.

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

88  {
89  ieta = abs(ieta);
90  //shift ieta tower index to act as array index
91  ieta -= ieta_shift_;
92  //shift layer index by 1 to act as array index
93  lay -= 1;
94 
95  //accumulate degradation over years
96  float response = 1.0;
97  std::string yearForLumi = getYearForLumi(intlumi);
98  assert(yearForLumi.size());
99 
100  for(const auto& year : years_){
101  response *= degradationYear(year,intlumi,ieta,lay);
102  if(year.year_==yearForLumi) break;
103  }
104 
105  return response;
106 }
std::string getYearForLumi(float intlumi) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float degradationYear(const LumiYear &year, float intlumi, int ieta, int lay) const
std::vector< LumiYear > years_
Definition: HBHEDarkening.h:65
float HBHEDarkening::degradationYear ( const LumiYear year,
float  intlumi,
int  ieta,
int  lay 
) const
private

Definition at line 72 of file HBHEDarkening.cc.

References dose(), drdA_, drdB_, HBHEDarkening::LumiYear::energy_, JetChargeProducer_cfi::exp, HBHEDarkening::LumiYear::intlumi_, HBHEDarkening::LumiYear::lumirate_, funct::pow(), and HBHEDarkening::LumiYear::sumlumi_.

Referenced by degradation(), and get_ieta_shift().

72  {
73  float doseToUse = dose(ieta,lay,year.energy_);
74  if(doseToUse==0.0) return 1.0;
75 
76  //apply dose rate dependence model to the provided year
77  //get krad/hr from Mrad/fb-1 and fb-1/hr
78  float decayConst = drdA_*std::pow(1000*doseToUse*year.lumirate_,drdB_);
79 
80  //determine if this is a partial year
81  float intlumiToUse = year.intlumi_;
82  if(intlumi < year.sumlumi_) intlumiToUse = year.sumlumi_ - intlumi;
83 
84  //calculate degradation
85  return std::exp(-(intlumiToUse*doseToUse)/decayConst);
86 }
float dose(int ieta, int lay, int energy) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float HBHEDarkening::dose ( int  ieta,
int  lay,
int  energy 
) const
private

Definition at line 47 of file HBHEDarkening.cc.

References dosemaps_.

Referenced by degradationYear(), and get_ieta_shift().

47  {
48  //existence check
49  const auto dosemapIt = dosemaps_.find(energy);
50  if(dosemapIt == dosemaps_.end()) return 0.0;
51 
52  //bounds check
53  const auto& dosemap = dosemapIt->second;
54  if(ieta<0 or ieta>=int(dosemap.size())) return 0.0;
55 
56  //bounds check
57  const auto& doserow = dosemap[ieta];
58  if(lay<0 or lay>=int(doserow.size())) return 0.0;
59 
60  return doserow[lay];
61 }
std::map< int, std::vector< std::vector< float > > > dosemaps_
Definition: HBHEDarkening.h:64
int HBHEDarkening::get_ieta_shift ( ) const
inline
std::string HBHEDarkening::getYearForLumi ( float  intlumi) const
private

Definition at line 63 of file HBHEDarkening.cc.

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

Referenced by degradation(), and get_ieta_shift().

63  {
64  //compare based on sum lumi value
65  auto lb = std::lower_bound(years_.begin(),years_.end(),intlumi,LumiYearComp());
66  if(lb == years_.end() or lb->sumlumi_ < intlumi) {
67  throw cms::Exception("ValueError") << "HBHEDarkening: insufficient LHC run information provided to simulate " << intlumi << "/fb - check the python config" << std::endl;
68  }
69  return lb->year_;
70 }
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:65
std::vector< std::vector< float > > HBHEDarkening::readDoseMap ( const std::string &  fullpath)
static

Definition at line 29 of file HBHEDarkening.cc.

References Exception, mps_splice::line, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by get_ieta_shift(), and HBHEDarkeningEP::produce().

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

Member Data Documentation

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

Definition at line 64 of file HBHEDarkening.h.

Referenced by dose().

float HBHEDarkening::drdA_
private

Definition at line 63 of file HBHEDarkening.h.

Referenced by degradationYear().

float HBHEDarkening::drdB_
private

Definition at line 63 of file HBHEDarkening.h.

Referenced by degradationYear().

int HBHEDarkening::ieta_shift_
private

Definition at line 62 of file HBHEDarkening.h.

Referenced by degradation(), and get_ieta_shift().

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

Definition at line 65 of file HBHEDarkening.h.

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