CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalPulseShapes.h
Go to the documentation of this file.
1 #ifndef CALIBCALORIMETRY_HCALALGOS_HCALPULSESHAPES_H
2 #define CALIBCALORIMETRY_HCALALGOS_HCALPULSESHAPES_H 1
3 
4 #include <map>
5 #include <vector>
6 #include <cmath>
13 
19 namespace CLHEP {
20  class HepRandomEngine;
21 }
22 
24 public:
26  // Default constructor is for callers that do not call beginRun(EventSetup)
30  // only needed if you'll be getting shapes by DetId
31  void beginRun(edm::EventSetup const& es);
32  void beginRun(const HcalDbService* conditions);
33 
34  const Shape& hbShape() const { return hpdShape_; }
35  const Shape& heShape() const { return hpdShape_; }
36  const Shape& hfShape() const { return hfShape_; }
37  const Shape& hoShape(bool sipm = false) const { return sipm ? siPMShapeHO_ : hpdShape_; }
38  // return Shape for given shapeType.
39  const Shape& getShape(int shapeType) const;
41  const Shape& shape(const HcalDetId& detId) const;
42  const Shape& shapeForReco(const HcalDetId& detId) const;
44  const Shape& defaultShape(const HcalDetId& detId) const;
45  //public static helpers
46  static const int nBinsSiPM_ = 250;
47  static constexpr float deltaTSiPM_ = 0.5;
48  static constexpr float invDeltaTSiPM_ = 2.0;
49  static double analyticPulseShapeSiPMHO(double t);
50  static double analyticPulseShapeSiPMHE(double t);
51  static constexpr float Y11RANGE_ = nBinsSiPM_;
52  static constexpr float Y11MAX203_ = 0.04;
53  static constexpr float Y11MAX206_ = 0.08;
54  static double Y11203(double t);
55  static double Y11206(double t);
56  static double generatePhotonTime(CLHEP::HepRandomEngine* engine, unsigned int signalShape);
57  static double generatePhotonTime203(CLHEP::HepRandomEngine* engine);
58  static double generatePhotonTime206(CLHEP::HepRandomEngine* engine);
59  //this function can take function pointers *or* functors!
60  template <class F1, class F2>
61  static std::vector<double> convolve(unsigned nbin, F1 f1, F2 f2) {
62  std::vector<double> result(2 * nbin - 1, 0.);
63  for (unsigned i = 0; i < 2 * nbin - 1; ++i) {
64  for (unsigned j = 0; j < std::min(i + 1, nbin); ++j) {
65  double tmp = f1(j) * f2(i - j);
66  if (edm::isNotFinite(tmp))
67  continue;
68  result[i] += tmp;
69  }
70  }
71  return result;
72  }
73  static std::vector<double> normalize(std::vector<double> nt, unsigned nbin) {
74  //skip first bin, always 0
75  double norm = 0.;
76  for (unsigned int j = 1; j <= nbin; ++j) {
77  norm += (nt[j] > 0) ? nt[j] : 0.;
78  }
79 
80  double normInv = 1. / norm;
81  for (unsigned int j = 1; j <= nbin; ++j) {
82  nt[j] *= normInv;
83  }
84 
85  return nt;
86  }
87  static std::vector<double> normalizeShift(std::vector<double> nt, unsigned nbin, int shift) {
88  //skip first bin, always 0
89  double norm = 0.;
90  for (unsigned int j = std::max(1, -1 * shift); j <= nbin; j++) {
91  norm += std::max(0., nt[j - shift]);
92  }
93  double normInv = 1. / norm;
94  std::vector<double> nt2(nt.size(), 0);
95  for (int j = 1; j <= (int)nbin; j++) {
96  if (j - shift >= 0) {
97  nt2[j] = nt[j - shift] * normInv;
98  }
99  }
100  return nt2;
101  }
102 
103  std::map<int, Shape const*> const& get_all_shapes() const { return theShapes; }
104 
105 private:
106  void computeHPDShape(float, float, float, float, float, float, float, float, Shape&);
107  void computeHFShape();
108  void computeSiPMShapeHO();
121  typedef std::map<int, const Shape*> ShapeMap;
123 };
124 #endif
const Shape & getShape(int shapeType) const
const Shape & heShape() const
static std::vector< double > normalizeShift(std::vector< double > nt, unsigned nbin, int shift)
void computeSiPMShapeMCRecoRun3()
const Shape & hoShape(bool sipm=false) const
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void beginRun(edm::EventSetup const &es)
static double generatePhotonTime206(CLHEP::HepRandomEngine *engine)
static const int nBinsSiPM_
const Shape & shapeForReco(const HcalDetId &detId) const
static double analyticPulseShapeSiPMHE(double t)
tuple result
Definition: mps_fire.py:311
static std::vector< double > normalize(std::vector< double > nt, unsigned nbin)
const Shape & shape(const HcalDetId &detId) const
automatically figures out which shape to return
const HcalPulseShape & computeSiPMShapeHE206()
static std::vector< double > convolve(unsigned nbin, F1 f1, F2 f2)
static constexpr float Y11MAX206_
edm::ESGetToken< HcalDbService, HcalDbRecord > theDbServiceToken
static double Y11206(double t)
void computeSiPMShapeData2017()
const HcalPulseShape & computeSiPMShapeHE203()
void computeSiPMShapeData2018()
const HcalDbService * theDbService
int nt
Definition: AMPTWrapper.h:42
static constexpr float invDeltaTSiPM_
const Shape & defaultShape(const HcalDetId &detId) const
in case of conditions problems
static constexpr float deltaTSiPM_
const Shape & hfShape() const
static constexpr float Y11MAX203_
void computeHPDShape(float, float, float, float, float, float, float, float, Shape &)
static double generatePhotonTime(CLHEP::HepRandomEngine *engine, unsigned int signalShape)
std::map< int, Shape const * > const & get_all_shapes() const
std::map< int, const Shape * > ShapeMap
const Shape & hbShape() const
static double Y11203(double t)
HcalPulseShape Shape
static constexpr float Y11RANGE_
static unsigned int const shift
static double generatePhotonTime203(CLHEP::HepRandomEngine *engine)
tmp
align.sh
Definition: createJobs.py:716
static double analyticPulseShapeSiPMHO(double t)
Abstract Class of shape.
Definition: Shape.h:14