CMS 3D CMS Logo

HGCalSciNoiseMap.cc
Go to the documentation of this file.
3 #include <fstream>
4 
5 //
7 
8 //
10 
11 //
12 std::unordered_map<int, float> HGCalSciNoiseMap::readSipmPars(const std::string& fullpath) {
13  std::unordered_map<int, float> result;
14  //no file means default sipm size
15  if (fullpath.empty())
16  return result;
17 
18  edm::FileInPath fp(fullpath);
19  std::ifstream infile(fp.fullPath());
20  if (!infile.is_open()) {
21  throw cms::Exception("FileNotFound") << "Unable to open '" << fullpath << "'" << std::endl;
22  }
24  while (getline(infile, line)) {
25  int layer;
26  float boundary;
27 
28  //space-separated
29  std::stringstream linestream(line);
30  linestream >> layer >> boundary;
31 
32  result[layer] = boundary;
33  }
34  return result;
35 }
36 
37 //
38 std::pair<double, double> HGCalSciNoiseMap::scaleByDose(const HGCScintillatorDetId& cellId, const radiiVec& radius) {
39  if (getDoseMap().empty())
40  return std::make_pair(1., 0.);
41 
42  //formula is: A = A0 * exp( -D^0.65 / 199.6)
43  //where A0 is the response of the undamaged detector, D is the dose
44  int layer = cellId.layer();
45  double cellDose = getDoseValue(DetId::HGCalHSc, layer, radius); //in kRad
46  constexpr double expofactor = 1. / 199.6;
47  const double dosespower = 0.65;
48  double scaleFactor = std::exp(-std::pow(cellDose, dosespower) * expofactor);
49 
50  //formula is: N = 2.18 * sqrt(F * A / 2e13)
51  //where F is the fluence and A is the SiPM area
52  double cellFluence = getFluenceValue(DetId::HGCalHSc, layer, radius); //in 1-Mev-equivalent neutrons per cm2
53 
54  constexpr double fluencefactor = 2. / (2 * 1e13); //SiPM area = 2mm^2
55  const double normfactor = 2.18;
56  double noise = normfactor * sqrt(cellFluence * fluencefactor);
57 
58  return std::make_pair(scaleFactor, noise);
59 }
60 
62  double edge;
63  if (cellId.type() == 0) {
64  constexpr double factor = 2 * M_PI * 1. / 360.;
65  edge = radius[0] * factor; //1 degree
66  } else {
67  constexpr double factor = 2 * M_PI * 1. / 288.;
68  edge = radius[0] * factor; //1.25 degrees
69  }
70 
71  double scaleFactor = refEdge_ / edge; //assume reference 3cm of edge
72 
73  return scaleFactor;
74 }
75 
76 double HGCalSciNoiseMap::scaleBySipmArea(const HGCScintillatorDetId& cellId, const double& radius) {
77  if (sipmMap_.empty())
78  return 1.;
79 
80  int layer = cellId.layer();
81  if (radius < sipmMap_[layer])
82  return 2.;
83  else
84  return 1.;
85 }
86 
88  GlobalPoint global = geom()->getPosition(cellId);
89 
90  double radius2 = std::pow(global.x(), 2) + std::pow(global.y(), 2); //in cm
91  double radius4 = std::pow(radius2, 2);
92  double radius = sqrt(radius2);
93  double radius3 = radius2 * radius;
94 
95  double radius_m100 = radius - 100;
96  double radius_m100_2 = std::pow(radius_m100, 2);
97  double radius_m100_3 = radius_m100_2 * radius_m100;
98  double radius_m100_4 = std::pow(radius_m100_2, 2);
99 
100  radiiVec radii{{radius, radius2, radius3, radius4, radius_m100, radius_m100_2, radius_m100_3, radius_m100_4}};
101  return radii;
102 }
double getFluenceValue(const int, const int, const radiiVec &, bool logVal=false)
std::unordered_map< int, float > readSipmPars(const std::string &)
std::array< double, 8 > radiiVec
void setSipmMap(const std::string &)
T y() const
Definition: PV3DBase.h:60
int type() const
get the type
GlobalPoint getPosition(const DetId &id) const
radiiVec computeRadius(const HGCScintillatorDetId &)
double scaleByTileArea(const HGCScintillatorDetId &, const radiiVec &)
returns the signal scaling and the noise
std::unordered_map< int, float > sipmMap_
double scaleBySipmArea(const HGCScintillatorDetId &, const double &)
T sqrt(T t)
Definition: SSEVec.h:19
double getDoseValue(const int, const int, const radiiVec &, bool logVal=false)
#define M_PI
const double refEdge_
int layer() const
get the layer #
std::pair< double, double > scaleByDose(const HGCScintillatorDetId &, const radiiVec &)
std::string fullPath() const
Definition: FileInPath.cc:163
const doseParametersMap & getDoseMap()
T x() const
Definition: PV3DBase.h:59
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
#define constexpr
const HGCalGeometry * geom()