CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 &)
 

Private Attributes

bool apply_calib_
 Switch on/off the timing calibration. More...
 
PPSTimingCalibration calib_
 
std::unique_ptr
< reco::FormulaEvaluator
calib_fct_
 
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 26 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

17  : ts_to_ns_(iConfig.getParameter<double>("timeSliceNs")),
18  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

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

Definition at line 25 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

References apply_calib_, calib_, calib_fct_, edm::DetSet< T >::emplace_back(), edm::DetSetVector< T >::find_or_insert(), DetGeomDesc::getDiamondDimensions(), edm::isNotFinite(), MAX_CHANNEL, PPSTimingCalibration::parameters(), DetGeomDesc::parentZPosition(), CTPPSGeometry::sensor(), relativeConstraints::station, FrontierCondition_GT_autoExpress_cfi::t0, PPSTimingCalibration::timeOffset(), PPSTimingCalibration::timePrecision(), CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING, DetGeomDesc::translation(), ts_to_ns_, and DiamondDimensions::xHalfWidth.

Referenced by CTPPSDiamondRecHitProducer::produce().

27  {
28  for (const auto& vec : input) {
29  const CTPPSDiamondDetId detid(vec.detId());
30 
31  if (detid.channel() > MAX_CHANNEL) // VFAT-like information, to be ignored
32  continue;
33 
34  // retrieve the geometry element associated to this DetID
35  const DetGeomDesc* det = geom.sensor(detid);
36 
37  const float x_pos = det->translation().x(), y_pos = det->translation().y();
38  float z_pos = 0.;
39  z_pos = det->parentZPosition(); // retrieve the plane position;
40 
41  // parameters stand for half the size
42  const auto& diamondDimensions = det->getDiamondDimensions();
43  const float x_width = 2.0 * diamondDimensions.xHalfWidth;
44  const float y_width = 2.0 * diamondDimensions.yHalfWidth;
45  const float z_width = 2.0 * diamondDimensions.zHalfWidth;
46 
47  // retrieve the timing calibration part for this channel
48  const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel();
49  const auto& ch_params = (apply_calib_) ? calib_.parameters(sector, station, plane, channel) : std::vector<double>{};
50  // default values for offset + time precision if calibration object not found
51  const double ch_t_offset = (apply_calib_) ? calib_.timeOffset(sector, station, plane, channel) : 0.;
52  const double ch_t_precis = (apply_calib_) ? calib_.timePrecision(sector, station, plane, channel) : 0.;
53 
54  edm::DetSet<CTPPSDiamondRecHit>& rec_hits = output.find_or_insert(detid);
55 
56  for (const auto& digi : vec) {
57  const int t_lead = digi.leadingEdge(), t_trail = digi.trailingEdge();
58  // skip invalid digis
59  if (t_lead == 0 && t_trail == 0)
60  continue;
61 
62  double tot = -1., ch_t_twc = 0.;
63  if (t_lead != 0 && t_trail != 0) {
64  tot = (t_trail - t_lead) * ts_to_ns_; // in ns
65  if (calib_fct_ && apply_calib_) {
66  // compute the time-walk correction
67  ch_t_twc = calib_fct_->evaluate(std::vector<double>{tot}, ch_params);
68  if (edm::isNotFinite(ch_t_twc))
69  ch_t_twc = 0.;
70  }
71  }
72 
73  const int time_slice =
74  (t_lead != 0) ? (t_lead - ch_t_offset / ts_to_ns_) / 1024 : CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING;
75 
76  // calibrated time of arrival
77  const double t0 = (t_lead % 1024) * ts_to_ns_ - ch_t_twc;
78 
79  rec_hits.emplace_back(
80  // spatial information
81  x_pos,
82  x_width,
83  y_pos,
84  y_width,
85  z_pos,
86  z_width,
87  // timing information
88  t0,
89  tot,
90  ch_t_precis,
91  time_slice,
92  // readout information
93  digi.hptdcErrorFlags(),
94  digi.multipleHit());
95  }
96  }
97 }
const Translation & translation() const
Definition: DetGeomDesc.h:80
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
bool apply_calib_
Switch on/off the timing calibration.
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
double timeOffset(int key1, int key2, int key3, int key4=-1) const
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:234
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
decltype(auto) emplace_back(Args &&...args)
Definition: DetSet.h:68
double ts_to_ns_
Conversion constant between HPTDC time slice and absolute time (in ns)
const DetGeomDesc * sensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
std::unique_ptr< reco::FormulaEvaluator > calib_fct_
float parentZPosition() const
Definition: DetGeomDesc.h:106
static constexpr int TIMESLICE_WITHOUT_LEADING
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
double timePrecision(int key1, int key2, int key3, int key4=-1) const
void CTPPSDiamondRecHitProducerAlgorithm::setCalibration ( const PPSTimingCalibration calib)

Definition at line 20 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

References calib_, calib_fct_, and PPSTimingCalibration::formula().

Referenced by CTPPSDiamondRecHitProducer::produce().

20  {
21  calib_ = calib;
22  calib_fct_ = std::make_unique<reco::FormulaEvaluator>(calib_.formula());
23 }
const std::string & formula() const
std::unique_ptr< reco::FormulaEvaluator > calib_fct_

Member Data Documentation

bool CTPPSDiamondRecHitProducerAlgorithm::apply_calib_
private

Switch on/off the timing calibration.

Definition at line 38 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().

PPSTimingCalibration CTPPSDiamondRecHitProducerAlgorithm::calib_
private

Definition at line 39 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

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

Definition at line 40 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

constexpr unsigned short CTPPSDiamondRecHitProducerAlgorithm::MAX_CHANNEL = 20
staticprivate

Definition at line 34 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().

double CTPPSDiamondRecHitProducerAlgorithm::ts_to_ns_
private

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

Definition at line 36 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().