CMS 3D CMS Logo

HGCalRadiationMap.cc
Go to the documentation of this file.
3 #include <fstream>
4 
5 //
6 HGCalRadiationMap::HGCalRadiationMap() : fluenceSFlog10_(0.) {}
7 
8 //
9 void HGCalRadiationMap::setDoseMap(const std::string& fullpath, const unsigned int algo) {
11  algo_ = algo;
12 }
13 
14 //
16  hgcalGeom_ = static_cast<const HGCalGeometry*>(geom);
19 }
20 
21 //
23  GlobalPoint global = geom()->getPosition(cellId);
24  return std::sqrt(std::pow(global.x(), 2) + std::pow(global.y(), 2));
25 }
26 
27 //
28 double HGCalRadiationMap::getDoseValue(const int subdet, const int layer, const double radius, bool logVal) {
29  std::pair<int, int> key(subdet, layer);
30 
31  if (doseMap_.find(key) == doseMap_.end()) {
32  return logVal ? -10. : 0.;
33  }
34 
35  double r(radius - doseMap_[key].doff_);
36  double r2(r * r);
37  double r3(r2 * r);
38  double r4(r3 * r);
39 
40  double cellDoseLog10 =
41  doseMap_[key].a_ + doseMap_[key].b_ * r + doseMap_[key].c_ * r2 + doseMap_[key].d_ * r3 + doseMap_[key].e_ * r4;
42 
43  return logVal ? cellDoseLog10 * M_LN10 + log(grayToKrad_) : std::pow(10, cellDoseLog10) * grayToKrad_;
44 }
45 
46 //
47 double HGCalRadiationMap::getFluenceValue(const int subdet, const int layer, const double radius, bool logVal) {
48  std::pair<int, int> key(subdet, layer);
49 
50  double r(radius - doseMap_[key].foff_);
51  double r2(r * r);
52  double r3(r2 * r);
53  double r4(r3 * r);
54 
55  double cellFluenceLog10 =
56  doseMap_[key].f_ + doseMap_[key].g_ * r + doseMap_[key].h_ * r2 + doseMap_[key].i_ * r3 + doseMap_[key].j_ * r4;
57  cellFluenceLog10 += fluenceSFlog10_;
58 
59  return logVal ? cellFluenceLog10 * M_LN10 : std::pow(10, cellFluenceLog10);
60 }
61 
62 //
64  const std::string& fullpath) {
66 
67  //no dose file means no aging
68  if (fullpath.empty())
69  return result;
70 
72  std::ifstream infile(fp.fullPath());
73  if (!infile.is_open()) {
74  throw cms::Exception("FileNotFound") << "Unable to open '" << fullpath << "'" << std::endl;
75  }
77  while (getline(infile, line)) {
78  int subdet;
79  int layer;
80  DoseParameters dosePars;
81 
82  //space-separated
83  std::stringstream linestream(line);
84  linestream >> subdet >> layer >> dosePars.a_ >> dosePars.b_ >> dosePars.c_ >> dosePars.d_ >> dosePars.e_ >>
85  dosePars.doff_ >> dosePars.f_ >> dosePars.g_ >> dosePars.h_ >> dosePars.i_ >> dosePars.j_ >> dosePars.foff_;
86 
87  std::pair<int, int> key(subdet, layer);
88  result[key] = dosePars;
89  }
90  return result;
91 }
doseParametersMap readDosePars(const std::string &)
const HGCalGeometry * hgcalGeom_
std::map< std::pair< int, int >, DoseParameters > doseParametersMap
const unsigned int & algo()
double getDoseValue(const int, const int, const double, bool logVal=false)
void setGeometry(const CaloSubdetectorGeometry *)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
const HGCalDDDConstants * hgcalDDD_
const double grayToKrad_
const HGCalTopology & topology() const
double getFluenceValue(const int, const int, const double, bool logVal=false)
void setDoseMap(const std::string &, const unsigned int)
double computeRadius(const HGCScintillatorDetId &)
GlobalPoint getPosition(const DetId &id, bool debug=false) const
const HGCalTopology * hgcalTopology_
doseParametersMap doseMap_
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
const HGCalGeometry * geom()