CMS 3D CMS Logo

CTPPSDiamondRecHitProducerAlgorithm.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of PPS offline software.
4 * Authors:
5 * Laurent Forthomme (laurent.forthomme@cern.ch)
6 *
7 ****************************************************************************/
8 
10 
13 
14 //----------------------------------------------------------------------------------------------------
15 
19  for (const auto& vec : input) {
20  const CTPPSDiamondDetId detid(vec.detId());
21 
22  if (detid.channel() > MAX_CHANNEL) // VFAT-like information, to be ignored
23  continue;
24 
25  // retrieve the geometry element associated to this DetID
26  const DetGeomDesc* det = geom.sensor(detid);
27 
28  const float x_pos = det->translation().x(), y_pos = det->translation().y();
29  float z_pos = 0.;
30  z_pos = det->parentZPosition(); // retrieve the plane position;
31 
32  // parameters stand for half the size
33  const auto& diamondDimensions = det->getDiamondDimensions();
34  const float x_width = 2.0 * diamondDimensions.xHalfWidth;
35  const float y_width = 2.0 * diamondDimensions.yHalfWidth;
36  const float z_width = 2.0 * diamondDimensions.zHalfWidth;
37 
38  const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel();
39  //LUT calibration
40  std::vector<double> lut;
41  if (apply_calib_)
42  lut = calibLUT_->bins(sector, station, plane, channel);
43  if (lut.size() != 1024)
44  lut = std::vector<double>(1024, 0.0);
45 
46  // retrieve the timing calibration part for this channel
47  const auto& ch_params =
48  (apply_calib_) ? calib_->parameters(sector, station, plane, channel) : std::vector<double>{};
49  // default values for offset + time precision if calibration object not found
50  const double ch_t_offset = (apply_calib_) ? calib_->timeOffset(sector, station, plane, channel) : 0.;
51  const double ch_t_precis = (apply_calib_) ? calib_->timePrecision(sector, station, plane, channel) : 0.;
52 
53  edm::DetSet<CTPPSDiamondRecHit>& rec_hits = output.find_or_insert(detid);
54 
55  for (const auto& digi : vec) {
56  const int t_lead = digi.leadingEdge(), t_trail = digi.trailingEdge();
57  // skip invalid digis
58  if (t_lead == 0 && t_trail == 0)
59  continue;
60 
61  double tot = -1., ch_t_twc = 0.;
62  if (t_lead != 0 && t_trail != 0) {
63  tot = (t_trail - t_lead) * ts_to_ns_; // in ns
64  if (calib_fct_ && apply_calib_ && !ch_params.empty()) {
65  // compute the time-walk correction
66  ch_t_twc = calib_fct_->evaluate(std::vector<double>{tot}, ch_params);
67  if (edm::isNotFinite(ch_t_twc))
68  ch_t_twc = 0.;
69  }
70  }
71 
72  const int time_slice =
73  (t_lead != 0) ? (t_lead - ch_t_offset / ts_to_ns_) / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING;
74 
75  // calibrated time of arrival
76  const double t0 = (t_lead % 1024) * ts_to_ns_ + lut[t_lead % 1024] - ch_t_twc;
77  rec_hits.emplace_back(
78  // spatial information
79  x_pos,
80  x_width,
81  y_pos,
82  y_width,
83  z_pos,
84  z_width,
85  // timing information
86  t0,
87  tot,
88  ch_t_precis,
89  time_slice,
90  // readout information
91  digi.hptdcErrorFlags(),
92  digi.multipleHit());
93  }
94  }
95 }
void build(const CTPPSGeometry &, const edm::DetSetVector< CTPPSDiamondDigi > &, edm::DetSetVector< CTPPSDiamondRecHit > &) override
const Translation & translation() const
Definition: DetGeomDesc.h:80
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
double timeOffset(int key1, int key2, int key3, int key4=-1) const
static std::string const input
Definition: EdmProvDump.cc:50
float parentZPosition() const
Definition: DetGeomDesc.h:106
decltype(auto) emplace_back(Args &&... args)
Definition: DetSet.h:68
std::vector< double > bins(int key1, int key2, int key3, int key4) const
double timePrecision(int key1, int key2, int key3, int key4=-1) const
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
The manager class for TOTEM RP geometry.
Definition: CTPPSGeometry.h:30
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
static constexpr int TIMESLICE_WITHOUT_LEADING
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...