CMS 3D CMS Logo

HcalPulseContainmentAlgo.cc
Go to the documentation of this file.
4 #include <cmath>
5 #include <iostream>
6 
7 // Function generates a lookup map for a passed-in function (via templated object algoObject,
8 // which must contain method "calcpair" that spits out (x,y) pair from a type float seed.
9 // Each map y-value is separated from the previous value by a programmable fractional error
10 // relative to the previous value.
11 //
13  double fixedphase_ns,
14  const HcalTimeSlew* hcalTimeSlew_delay)
15  : fixedphasens_(fixedphase_ns),
16  integrator_(&(HcalPulseShapes().hbShape())),
17  hcalTimeSlew_delay_(hcalTimeSlew_delay) {
18  init(num_samples);
19 }
20 
22  int num_samples,
23  double fixedphase_ns,
24  const HcalTimeSlew* hcalTimeSlew_delay)
25  : fixedphasens_(fixedphase_ns), integrator_(shape), hcalTimeSlew_delay_(hcalTimeSlew_delay) {
26  init(num_samples);
27 }
28 
29 void HcalPulseContainmentAlgo::init(int num_samples) {
30  const int binsize_ns = 25;
31 
32  // First set up controlling parameters for calculating the correction factor:
33  // Integration window size...
34  //
35  integrationwindowns_ = (double)(binsize_ns * num_samples);
36 
37  // First find the point at which time bin "1" exceeds time bin "0",
38  // and call that point "time 0".
39  //
40  for (int shift_ns = 0; shift_ns < binsize_ns; shift_ns++) {
41  // Digitize by integrating to find all time sample
42  // bin values for this shift.
43  //
44  double tmin = -(double)shift_ns;
45  double bin0val = (double)integrator_(tmin, tmin + binsize_ns);
46  double bin1val = (double)integrator_(tmin + binsize_ns, tmin + 2 * binsize_ns);
47 
48 #if 0
49  char s[80];
50  sprintf (s, "%7.3f %8.5f %8.5f\n", tmin, bin0val, bin1val);
51  cout << s;
52 #endif
53 
54  if (bin1val > bin0val) {
55  time0shiftns_ = shift_ns;
56  break;
57  }
58  }
59 
60 #if 0
61  cout << "time0shiftns_ = " << time0shiftns_ << endl;
62 #endif
63 }
64 
65 std::pair<double, double> HcalPulseContainmentAlgo::calcpair(double truefc) {
66  double timeslew_ns = hcalTimeSlew_delay_->delay(std::max(0.0, (double)truefc), HcalTimeSlew::Medium);
67 
68  double shift_ns = fixedphasens_ - time0shiftns_ + timeslew_ns;
69  //std::cout << "SHIFT " << fixedphasens_ << " " << time0shiftns_ << " " << timeslew_ns << std::endl;
70  double tmin = -shift_ns;
71  double tmax = tmin + integrationwindowns_;
72 
73  //double integral = shape_.integrate( tmin, tmax );
74  double integral = integrator_(tmin, tmax);
75  //std::cout << "INTEGRAL " << integral << " " << truefc << " " << tmin << " " << tmax << std::endl;
76  double corfactor = 1.0 / integral;
77  double recofc = (double)truefc * integral;
78 
79 #if 0
80  char s[80];
81  sprintf (s, "%8.2f %8.4f %8.4f %8.5f %8.5f %8.5f ",
82  truefc, tmin, tmax, integral, corfactor, recofc);
83  cout << s;
84 #endif
85 
86  std::pair<double, double> thepair(recofc, corfactor);
87  return thepair;
88 }
HcalPulseContainmentAlgo.h
HcalPulseContainmentAlgo::calcpair
std::pair< double, double > calcpair(double)
Definition: HcalPulseContainmentAlgo.cc:65
muonTiming_cfi.tmin
tmin
Definition: muonTiming_cfi.py:24
HcalTimeSlew::Medium
Definition: HcalTimeSlew.h:71
HcalPulseShapes
Definition: HcalPulseShapes.h:22
HcalPulseShapes.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalPulseContainmentAlgo::time0shiftns_
double time0shiftns_
Definition: HcalPulseContainmentAlgo.h:22
HcalTimeSlew.h
HcalTimeSlew
Definition: HcalTimeSlew.h:19
HcalTimeSlew::delay
float delay(float fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:20
tmax
static const double tmax[3]
Definition: CastorTimeSlew.cc:7
HcalPulseContainmentAlgo::integrationwindowns_
double integrationwindowns_
Definition: HcalPulseContainmentAlgo.h:21
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HcalPulseContainmentAlgo::HcalPulseContainmentAlgo
HcalPulseContainmentAlgo(const HcalPulseShape *shape, int num_samples, double fixedphase_ns, const HcalTimeSlew *hcalTimeSlew_delay)
Definition: HcalPulseContainmentAlgo.cc:21
funct::integral
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:70
HcalPulseContainmentAlgo::hcalTimeSlew_delay_
const HcalTimeSlew * hcalTimeSlew_delay_
Definition: HcalPulseContainmentAlgo.h:24
HcalPulseContainmentAlgo::integrator_
HcalShapeIntegrator integrator_
Definition: HcalPulseContainmentAlgo.h:23
HcalPulseContainmentAlgo::fixedphasens_
double fixedphasens_
Definition: HcalPulseContainmentAlgo.h:20
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HcalPulseContainmentAlgo::init
void init(int num_samples)
Definition: HcalPulseContainmentAlgo.cc:29
HcalPulseShape
Definition: HcalPulseShape.h:6