CMS 3D CMS Logo

HGCalRadiationMap.cc
Go to the documentation of this file.
3 #include <fstream>
4 
5 //
6 void HGCalRadiationMap::setDoseMap(const std::string& fullpath, const unsigned int algo) {
7  doseMap_ = readDosePars(fullpath);
8  algo_ = algo;
9 }
10 
11 //
13  hgcalGeom_ = static_cast<const HGCalGeometry*>(geom);
16 }
17 
18 //
19 double HGCalRadiationMap::getDoseValue(const int subdet, const int layer, const radiiVec& radius, bool logVal) {
20  std::pair<int, int> key(subdet, layer);
21  double cellDoseLog10 = doseMap_[key].a_ + doseMap_[key].b_ * radius[4] + doseMap_[key].c_ * radius[5] +
22  doseMap_[key].d_ * radius[6] + doseMap_[key].e_ * radius[7];
23  return logVal ? cellDoseLog10 * M_LN10 + log(grayToKrad_) : std::pow(10, cellDoseLog10) * grayToKrad_;
24 }
25 
26 //
27 double HGCalRadiationMap::getFluenceValue(const int subdet, const int layer, const radiiVec& radius, bool logVal) {
28  std::pair<int, int> key(subdet, layer);
29  double cellFluenceLog10 = doseMap_[key].f_ + doseMap_[key].g_ * radius[0] + doseMap_[key].h_ * radius[1] +
30  doseMap_[key].i_ * radius[2] + doseMap_[key].j_ * radius[3];
31  return logVal ? cellFluenceLog10 * M_LN10 : std::pow(10, cellFluenceLog10);
32 }
33 
34 //
36  const std::string& fullpath) {
38 
39  //no dose file means no aging
40  if (fullpath.empty())
41  return result;
42 
43  edm::FileInPath fp(fullpath);
44  std::ifstream infile(fp.fullPath());
45  if (!infile.is_open()) {
46  throw cms::Exception("FileNotFound") << "Unable to open '" << fullpath << "'" << std::endl;
47  }
49  while (getline(infile, line)) {
50  int subdet;
51  int layer;
52  DoseParameters dosePars;
53 
54  //space-separated
55  std::stringstream linestream(line);
56  linestream >> subdet >> layer >> dosePars.a_ >> dosePars.b_ >> dosePars.c_ >> dosePars.d_ >> dosePars.e_ >>
57  dosePars.f_ >> dosePars.g_ >> dosePars.h_ >> dosePars.i_ >> dosePars.j_;
58 
59  std::pair<int, int> key(subdet, layer);
60  result[key] = dosePars;
61  }
62  return result;
63 }
doseParametersMap readDosePars(const std::string &)
double getFluenceValue(const int, const int, const radiiVec &, bool logVal=false)
const HGCalGeometry * hgcalGeom_
std::array< double, 8 > radiiVec
std::map< std::pair< int, int >, DoseParameters > doseParametersMap
const unsigned int & algo()
void setGeometry(const CaloSubdetectorGeometry *)
const HGCalTopology & topology() const
const HGCalDDDConstants * hgcalDDD_
const double grayToKrad_
double getDoseValue(const int, const int, const radiiVec &, bool logVal=false)
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:96
void setDoseMap(const std::string &, const unsigned int)
std::string fullPath() const
Definition: FileInPath.cc:163
const HGCalTopology * hgcalTopology_
doseParametersMap doseMap_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const HGCalGeometry * geom()