CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
CTPPSDiamondRecHitProducerAlgorithm Class Reference

#include <CTPPSDiamondRecHitProducerAlgorithm.h>

Public Member Functions

void build (const CTPPSGeometry &, const edm::DetSetVector< CTPPSDiamondDigi > &, edm::DetSetVector< CTPPSDiamondRecHit > &)
 
 CTPPSDiamondRecHitProducerAlgorithm (const edm::ParameterSet &conf)
 
void setCalibration (const PPSTimingCalibration &, const PPSTimingCalibrationLUT &)
 

Private Attributes

bool apply_calib_
 Switch on/off the timing calibration. More...
 
PPSTimingCalibration calib_
 
std::unique_ptr< reco::FormulaEvaluatorcalib_fct_
 
PPSTimingCalibrationLUT calibLUT_
 
double ts_to_ns_
 Conversion constant between HPTDC time slice and absolute time (in ns) More...
 

Static Private Attributes

static constexpr unsigned short MAX_CHANNEL = 20
 

Detailed Description

Definition at line 27 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Constructor & Destructor Documentation

◆ CTPPSDiamondRecHitProducerAlgorithm()

CTPPSDiamondRecHitProducerAlgorithm::CTPPSDiamondRecHitProducerAlgorithm ( const edm::ParameterSet conf)

Definition at line 15 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

16  : ts_to_ns_(iConfig.getParameter<double>("timeSliceNs")),
17  apply_calib_(iConfig.getParameter<bool>("applyCalibration")) {}
bool apply_calib_
Switch on/off the timing calibration.
double ts_to_ns_
Conversion constant between HPTDC time slice and absolute time (in ns)

Member Function Documentation

◆ build()

void CTPPSDiamondRecHitProducerAlgorithm::build ( const CTPPSGeometry geom,
const edm::DetSetVector< CTPPSDiamondDigi > &  input,
edm::DetSetVector< CTPPSDiamondRecHit > &  output 
)

Definition at line 26 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

References apply_calib_, PPSTimingCalibrationLUT::bins(), calib_, calib_fct_, calibLUT_, edm::DetSet< T >::emplace_back(), relativeConstraints::geom, DetGeomDesc::getDiamondDimensions(), input, edm::isNotFinite(), MAX_CHANNEL, convertSQLitetoXML_cfg::output, PPSTimingCalibration::parameters(), DetGeomDesc::parentZPosition(), relativeConstraints::station, FrontierCondition_GT_autoExpress_cfi::t0, PPSTimingCalibration::timeOffset(), PPSTimingCalibration::timePrecision(), CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING, compareTotals::tot, DetGeomDesc::translation(), ts_to_ns_, and DiamondDimensions::xHalfWidth.

Referenced by CTPPSDiamondRecHitProducer::produce().

28  {
29  for (const auto& vec : input) {
30  const CTPPSDiamondDetId detid(vec.detId());
31 
32  if (detid.channel() > MAX_CHANNEL) // VFAT-like information, to be ignored
33  continue;
34 
35  // retrieve the geometry element associated to this DetID
36  const DetGeomDesc* det = geom.sensor(detid);
37 
38  const float x_pos = det->translation().x(), y_pos = det->translation().y();
39  float z_pos = 0.;
40  z_pos = det->parentZPosition(); // retrieve the plane position;
41 
42  // parameters stand for half the size
43  const auto& diamondDimensions = det->getDiamondDimensions();
44  const float x_width = 2.0 * diamondDimensions.xHalfWidth;
45  const float y_width = 2.0 * diamondDimensions.yHalfWidth;
46  const float z_width = 2.0 * diamondDimensions.zHalfWidth;
47 
48  const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel();
49  //LUT calibration
50  std::vector<double> lut;
51  if (apply_calib_) {
52  lut = calibLUT_.bins(sector, station, plane, channel);
53  if (lut.size() != 1024)
54  lut = std::vector<double>(1024, 0.0);
55  } else
56  lut = std::vector<double>(1024, 0.0);
57 
58  // retrieve the timing calibration part for this channel
59  const auto& ch_params = (apply_calib_) ? calib_.parameters(sector, station, plane, channel) : std::vector<double>{};
60  // default values for offset + time precision if calibration object not found
61  const double ch_t_offset = (apply_calib_) ? calib_.timeOffset(sector, station, plane, channel) : 0.;
62  const double ch_t_precis = (apply_calib_) ? calib_.timePrecision(sector, station, plane, channel) : 0.;
63 
64  edm::DetSet<CTPPSDiamondRecHit>& rec_hits = output.find_or_insert(detid);
65 
66  for (const auto& digi : vec) {
67  const int t_lead = digi.leadingEdge(), t_trail = digi.trailingEdge();
68  // skip invalid digis
69  if (t_lead == 0 && t_trail == 0)
70  continue;
71 
72  double tot = -1., ch_t_twc = 0.;
73  if (t_lead != 0 && t_trail != 0) {
74  tot = (t_trail - t_lead) * ts_to_ns_; // in ns
75  if (calib_fct_ && apply_calib_) {
76  // compute the time-walk correction
77  ch_t_twc = calib_fct_->evaluate(std::vector<double>{tot}, ch_params);
78  if (edm::isNotFinite(ch_t_twc))
79  ch_t_twc = 0.;
80  }
81  }
82 
83  const int time_slice =
84  (t_lead != 0) ? (t_lead - ch_t_offset / ts_to_ns_) / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING;
85 
86  // calibrated time of arrival
87  const double t0 = (t_lead % 1024) * ts_to_ns_ + lut[t_lead % 1024] - ch_t_twc;
88  rec_hits.emplace_back(
89  // spatial information
90  x_pos,
91  x_width,
92  y_pos,
93  y_width,
94  z_pos,
95  z_width,
96  // timing information
97  t0,
98  tot,
99  ch_t_precis,
100  time_slice,
101  // readout information
102  digi.hptdcErrorFlags(),
103  digi.multipleHit());
104  }
105  }
106 }
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
bool apply_calib_
Switch on/off the timing calibration.
static std::string const input
Definition: EdmProvDump.cc:47
float parentZPosition() const
Definition: DetGeomDesc.h:106
double ts_to_ns_
Conversion constant between HPTDC time slice and absolute time (in ns)
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
std::unique_ptr< reco::FormulaEvaluator > calib_fct_
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...

◆ setCalibration()

void CTPPSDiamondRecHitProducerAlgorithm::setCalibration ( const PPSTimingCalibration calib,
const PPSTimingCalibrationLUT calibLUT 
)

Member Data Documentation

◆ apply_calib_

bool CTPPSDiamondRecHitProducerAlgorithm::apply_calib_
private

Switch on/off the timing calibration.

Definition at line 39 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().

◆ calib_

PPSTimingCalibration CTPPSDiamondRecHitProducerAlgorithm::calib_
private

Definition at line 40 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

◆ calib_fct_

std::unique_ptr<reco::FormulaEvaluator> CTPPSDiamondRecHitProducerAlgorithm::calib_fct_
private

Definition at line 42 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

◆ calibLUT_

PPSTimingCalibrationLUT CTPPSDiamondRecHitProducerAlgorithm::calibLUT_
private

Definition at line 41 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

◆ MAX_CHANNEL

constexpr unsigned short CTPPSDiamondRecHitProducerAlgorithm::MAX_CHANNEL = 20
staticprivate

Definition at line 35 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().

◆ ts_to_ns_

double CTPPSDiamondRecHitProducerAlgorithm::ts_to_ns_
private

Conversion constant between HPTDC time slice and absolute time (in ns)

Definition at line 37 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().