CMS 3D CMS Logo

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>
12 
18 namespace CLHEP {
19  class HepRandomEngine;
20 }
21 
23 public:
25  // Default constructor is for callers that do not call beginRun(EventSetup)
29  // only needed if you'll be getting shapes by DetId
30  void beginRun(edm::EventSetup const& es);
31  void beginRun(const HcalDbService* conditions);
32 
33  const Shape& hbShape() const { return hpdShape_; }
34  const Shape& heShape() const { return hpdShape_; }
35  const Shape& hfShape() const { return hfShape_; }
36  const Shape& hoShape(bool sipm = false) const { return sipm ? siPMShapeHO_ : hpdShape_; }
37  // return Shape for given shapeType.
38  const Shape& getShape(int shapeType) const;
40  const Shape& shape(const HcalDetId& detId) const;
41  const Shape& shapeForReco(const HcalDetId& detId) const;
43  const Shape& defaultShape(const HcalDetId& detId) const;
44  //public static helpers
45  static const int nBinsSiPM_ = 250;
46  static constexpr float deltaTSiPM_ = 0.5;
47  static constexpr float invDeltaTSiPM_ = 2.0;
48  static double analyticPulseShapeSiPMHO(double t);
49  static double analyticPulseShapeSiPMHE(double t);
50  static constexpr float Y11RANGE_ = nBinsSiPM_;
51  static constexpr float Y11MAX203_ = 0.04;
52  static constexpr float Y11MAX206_ = 0.08;
53  static double Y11203(double t);
54  static double Y11206(double t);
55  static double generatePhotonTime(CLHEP::HepRandomEngine* engine, unsigned int signalShape);
56  static double generatePhotonTime203(CLHEP::HepRandomEngine* engine);
57  static double generatePhotonTime206(CLHEP::HepRandomEngine* engine);
58  //this function can take function pointers *or* functors!
59  template <class F1, class F2>
60  static std::vector<double> convolve(unsigned nbin, F1 f1, F2 f2) {
61  std::vector<double> result(2 * nbin - 1, 0.);
62  for (unsigned i = 0; i < 2 * nbin - 1; ++i) {
63  for (unsigned j = 0; j < std::min(i + 1, nbin); ++j) {
64  double tmp = f1(j) * f2(i - j);
65  if (std::isnan(tmp) or std::isinf(tmp))
66  continue;
67  result[i] += tmp;
68  }
69  }
70  return result;
71  }
72  static std::vector<double> normalize(std::vector<double> nt, unsigned nbin) {
73  //skip first bin, always 0
74  double norm = 0.;
75  for (unsigned int j = 1; j <= nbin; ++j) {
76  norm += (nt[j] > 0) ? nt[j] : 0.;
77  }
78 
79  double normInv = 1. / norm;
80  for (unsigned int j = 1; j <= nbin; ++j) {
81  nt[j] *= normInv;
82  }
83 
84  return nt;
85  }
86  static std::vector<double> normalizeShift(std::vector<double> nt, unsigned nbin, int shift) {
87  //skip first bin, always 0
88  double norm = 0.;
89  for (unsigned int j = std::max(1, -1 * shift); j <= nbin; j++) {
90  norm += std::max(0., nt[j - shift]);
91  }
92  double normInv = 1. / norm;
93  std::vector<double> nt2(nt.size(), 0);
94  for (int j = 1; j <= (int)nbin; j++) {
95  if (j - shift >= 0) {
96  nt2[j] = nt[j - shift] * normInv;
97  }
98  }
99  return nt2;
100  }
101 
102  std::map<int, Shape const*> const& get_all_shapes() const { return theShapes; }
103 
104 private:
105  void computeHPDShape(float, float, float, float, float, float, float, float, Shape&);
106  void computeHFShape();
107  void computeSiPMShapeHO();
120  typedef std::map<int, const Shape*> ShapeMap;
122 };
123 #endif
HcalPulseShapes::invDeltaTSiPM_
static constexpr float invDeltaTSiPM_
Definition: HcalPulseShapes.h:47
mps_fire.i
i
Definition: mps_fire.py:428
HcalPulseShapes::theDbServiceToken
edm::ESGetToken< HcalDbService, HcalDbRecord > theDbServiceToken
Definition: HcalPulseShapes.h:118
HcalPulseShapes::heShape
const Shape & heShape() const
Definition: HcalPulseShapes.h:34
HcalPulseShapes::defaultShape
const Shape & defaultShape(const HcalDetId &detId) const
in case of conditions problems
Definition: HcalPulseShapes.cc:538
HcalPulseShapes::theShapes
ShapeMap theShapes
Definition: HcalPulseShapes.h:121
HcalPulseShapes::~HcalPulseShapes
~HcalPulseShapes()
Definition: HcalPulseShapes.cc:144
nt
int nt
Definition: AMPTWrapper.h:42
min
T min(T a, T b)
Definition: MathUtil.h:58
HcalPulseShapes
Definition: HcalPulseShapes.h:22
HcalPulseShapes::hpdShapeMC_v3
Shape hpdShapeMC_v3
Definition: HcalPulseShapes.h:116
HcalPulseShapes::nBinsSiPM_
static const int nBinsSiPM_
Definition: HcalPulseShapes.h:45
HcalPulseShapes::shapeForReco
const Shape & shapeForReco(const HcalDetId &detId) const
Definition: HcalPulseShapes.cc:524
HcalPulseShapes::computeHFShape
void computeHFShape()
Definition: HcalPulseShapes.cc:247
HcalPulseShapes::computeSiPMShapeData2017
void computeSiPMShapeData2017()
Definition: HcalPulseShapes.cc:380
HcalPulseShapes::computeSiPMShapeHE206
const HcalPulseShape & computeSiPMShapeHE206()
Definition: HcalPulseShapes.cc:492
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
HcalPulseShapes::deltaTSiPM_
static constexpr float deltaTSiPM_
Definition: HcalPulseShapes.h:46
Shape
Abstract Class of shape.
Definition: Shape.h:14
HcalPulseShapes::get_all_shapes
std::map< int, Shape const * > const & get_all_shapes() const
Definition: HcalPulseShapes.h:102
HcalPulseShapes::hpdShape_
Shape hpdShape_
Definition: HcalPulseShapes.h:113
HcalPulseShapes::generatePhotonTime203
static double generatePhotonTime203(CLHEP::HepRandomEngine *engine)
Definition: HcalPulseShapes.cc:589
HcalPulseShapes::computeSiPMShapeHO
void computeSiPMShapeHO()
Definition: HcalPulseShapes.cc:434
HcalPulseShapes::Y11206
static double Y11206(double t)
Definition: HcalPulseShapes.cc:611
HcalPulseShapes::getShape
const Shape & getShape(int shapeType) const
Definition: HcalPulseShapes.cc:500
HcalPulseShape.h
CommonMethods.isnan
def isnan(num)
Definition: CommonMethods.py:98
HcalPulseShapes::convolve
static std::vector< double > convolve(unsigned nbin, F1 f1, F2 f2)
Definition: HcalPulseShapes.h:60
HcalPulseShapes::hbShape
const Shape & hbShape() const
Definition: HcalPulseShapes.h:33
HcalDbRecord.h
HcalPulseShapes::Y11203
static double Y11203(double t)
Definition: HcalPulseShapes.cc:608
HcalPulseShapes::Y11RANGE_
static constexpr float Y11RANGE_
Definition: HcalPulseShapes.h:50
HcalPulseShapes::HcalPulseShapes
HcalPulseShapes()
Definition: HcalPulseShapes.cc:14
HcalPulseShapes::siPMShapeData2018_
Shape siPMShapeData2018_
Definition: HcalPulseShapes.h:114
CLHEP
Definition: CocoaGlobals.h:27
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HcalPulseShapes::hpdBV30Shape_v2
Shape hpdBV30Shape_v2
Definition: HcalPulseShapes.h:117
DeadROC_duringRun.f2
f2
Definition: DeadROC_duringRun.py:220
HcalPulseShapes::normalize
static std::vector< double > normalize(std::vector< double > nt, unsigned nbin)
Definition: HcalPulseShapes.h:72
HcalDetId.h
HcalPulseShapes::hpdBV30ShapeMC_v2
Shape hpdBV30ShapeMC_v2
Definition: HcalPulseShapes.h:117
HcalPulseShapes::analyticPulseShapeSiPMHE
static double analyticPulseShapeSiPMHE(double t)
Definition: HcalPulseShapes.cc:575
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
HcalPulseShapes::beginRun
void beginRun(edm::EventSetup const &es)
Definition: HcalPulseShapes.cc:146
HcalPulseShapes::computeSiPMShapeData2018
void computeSiPMShapeData2018()
Definition: HcalPulseShapes.cc:327
edm::EventSetup
Definition: EventSetup.h:57
HcalPulseShapes::Y11MAX203_
static constexpr float Y11MAX203_
Definition: HcalPulseShapes.h:51
HcalPulseShapes::siPMShapeMCRecoRun3_
Shape siPMShapeMCRecoRun3_
Definition: HcalPulseShapes.h:114
edm::ESGetToken< HcalDbService, HcalDbRecord >
HcalPulseShape
Definition: HcalPulseShape.h:6
HcalPulseShapes::hoShape
const Shape & hoShape(bool sipm=false) const
Definition: HcalPulseShapes.h:36
HcalPulseShapes::normalizeShift
static std::vector< double > normalizeShift(std::vector< double > nt, unsigned nbin, int shift)
Definition: HcalPulseShapes.h:86
HcalPulseShapes::generatePhotonTime
static double generatePhotonTime(CLHEP::HepRandomEngine *engine, unsigned int signalShape)
Definition: HcalPulseShapes.cc:582
HcalPulseShapes::hfShape
const Shape & hfShape() const
Definition: HcalPulseShapes.h:35
HcalPulseShapes::hpdShape_v2
Shape hpdShape_v2
Definition: HcalPulseShapes.h:115
HcalDbService
Definition: HcalDbService.h:26
HcalPulseShapes::shape
const Shape & shape(const HcalDetId &detId) const
automatically figures out which shape to return
Definition: HcalPulseShapes.cc:510
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
HcalPulseShapes::computeHPDShape
void computeHPDShape(float, float, float, float, float, float, float, float, Shape &)
Definition: HcalPulseShapes.cc:151
HcalPulseShapes::siPMShapeHO_
Shape siPMShapeHO_
Definition: HcalPulseShapes.h:113
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
HcalPulseShapes::hpdShapeMC_v2
Shape hpdShapeMC_v2
Definition: HcalPulseShapes.h:115
Frameworkfwd.h
HcalPulseShapes::theDbService
const HcalDbService * theDbService
Definition: HcalPulseShapes.h:119
ZMuMuCategoriesSequences_cff.nbin
nbin
Definition: ZMuMuCategoriesSequences_cff.py:25
HcalPulseShapes::computeSiPMShapeMCRecoRun3
void computeSiPMShapeMCRecoRun3()
Definition: HcalPulseShapes.cc:276
or
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
HcalPulseShapes::Shape
HcalPulseShape Shape
Definition: HcalPulseShapes.h:24
HcalPulseShapes::Y11MAX206_
static constexpr float Y11MAX206_
Definition: HcalPulseShapes.h:52
HcalPulseShapes::generatePhotonTime206
static double generatePhotonTime206(CLHEP::HepRandomEngine *engine)
Definition: HcalPulseShapes.cc:598
HcalDbService.h
HcalPulseShapes::computeSiPMShapeHE203
const HcalPulseShape & computeSiPMShapeHE203()
Definition: HcalPulseShapes.cc:485
HcalPulseShapes::hpdShape_v3
Shape hpdShape_v3
Definition: HcalPulseShapes.h:116
mps_fire.result
result
Definition: mps_fire.py:311
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
DeadROC_duringRun.f1
f1
Definition: DeadROC_duringRun.py:219
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HcalPulseShapes::siPMShapeData2017_
Shape siPMShapeData2017_
Definition: HcalPulseShapes.h:114
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
HcalPulseShapes::ShapeMap
std::map< int, const Shape * > ShapeMap
Definition: HcalPulseShapes.h:120
HcalPulseShapes::analyticPulseShapeSiPMHO
static double analyticPulseShapeSiPMHO(double t)
Definition: HcalPulseShapes.cc:568
HcalPulseShapes::hfShape_
Shape hfShape_
Definition: HcalPulseShapes.h:113