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 &)
 

Private Attributes

PPSTimingCalibration calib_
 
std::unique_ptr< reco::FormulaEvaluatorcalib_fct_
 
double ts_to_ns_
 Conversion constant between HPTDC time slice and absolute time (in ns) More...
 

Static Private Attributes

static 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 14 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

14  :
15  ts_to_ns_( iConfig.getParameter<double>( "timeSliceNs" ) )
16 {}
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 26 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

References calib_, calib_fct_, edm::DetSet< T >::emplace_back(), edm::DetSetVector< T >::find_or_insert(), CTPPSGeometry::getSensor(), edm::isNotFinite(), MAX_CHANNEL, PPSTimingCalibration::parameters(), DetGeomDesc::params(), DetGeomDesc::parentZPosition(), relativeConstraints::station, cscNeutronWriter_cfi::t0, PPSTimingCalibration::timeOffset(), PPSTimingCalibration::timePrecision(), CTPPSDiamondRecHit::TIMESLICE_WITHOUT_LEADING, DetGeomDesc::translation(), and ts_to_ns_.

Referenced by CTPPSDiamondRecHitProducer::produce().

29 {
30  for ( const auto& vec : input ) {
31  const CTPPSDiamondDetId detid( vec.detId() );
32 
33  if ( detid.channel() > MAX_CHANNEL ) // VFAT-like information, to be ignored
34  continue;
35 
36  // retrieve the geometry element associated to this DetID
37  const DetGeomDesc* det = geom.getSensor( detid );
38 
39  const float x_pos = det->translation().x(),
40  y_pos = det->translation().y();
41  float z_pos = 0.;
42  z_pos = det->parentZPosition(); // retrieve the plane position;
43 
44  const float x_width = 2.0 * det->params().at( 0 ), // parameters stand for half the size
45  y_width = 2.0 * det->params().at( 1 ),
46  z_width = 2.0 * det->params().at( 2 );
47 
48  // retrieve the timing calibration part for this channel
49  const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel();
50  const auto& ch_params = calib_.parameters( sector, station, plane, channel );
51  // offset + time precision set to 0 if not found
52  const double ch_t_offset = calib_.timeOffset( sector, station, plane, channel );
53  const double ch_t_precis = calib_.timePrecision( sector, station, plane, channel );
54 
55  edm::DetSet<CTPPSDiamondRecHit>& rec_hits = output.find_or_insert( detid );
56 
57  for ( const auto& digi : vec ) {
58  const int t_lead = digi.getLeadingEdge(), t_trail = digi.getTrailingEdge();
59  // skip invalid digis
60  if ( t_lead == 0 && t_trail == 0 )
61  continue;
62 
63  double tot = -1., ch_t_twc = 0.;
64  if ( t_lead != 0 && t_trail != 0 ) {
65  tot = ( t_trail-t_lead )*ts_to_ns_; // in ns
66  if ( calib_fct_ ) {
67  // compute the time-walk correction
68  ch_t_twc = calib_fct_->evaluate( std::vector<double>{ tot }, ch_params );
69  if ( edm::isNotFinite( ch_t_twc ) )
70  ch_t_twc = 0.;
71  }
72  }
73 
74  const int time_slice = ( t_lead != 0 )
75  ? ( t_lead-ch_t_offset/ts_to_ns_ ) / 1024
77 
78  // calibrated time of arrival
79  const double t0 = ( t_lead % 1024 )*ts_to_ns_-ch_t_twc;
80 
81  rec_hits.emplace_back(
82  // spatial information
83  x_pos, x_width, y_pos, y_width, z_pos, z_width,
84  // timing information
85  t0, tot, ch_t_precis, time_slice,
86  // readout information
87  digi.getHPTDCErrorFlags(),
88  digi.getMultipleHit()
89  );
90  }
91  }
92 }
Translation translation() const
Definition: DetGeomDesc.h:66
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
double timeOffset(int key1, int key2, int key3, int key4=-1) const
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:254
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
decltype(auto) emplace_back(Args &&...args)
Definition: DetSet.h:70
double ts_to_ns_
Conversion constant between HPTDC time slice and absolute time (in ns)
Geometrical description of a sensor.
Definition: DetGeomDesc.h:35
std::unique_ptr< reco::FormulaEvaluator > calib_fct_
float parentZPosition() const
Definition: DetGeomDesc.h:58
static constexpr int TIMESLICE_WITHOUT_LEADING
std::vector< double > params() const
Definition: DetGeomDesc.h:68
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 19 of file CTPPSDiamondRecHitProducerAlgorithm.cc.

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

Referenced by CTPPSDiamondRecHitProducer::produce().

20 {
21  calib_ = calib;
23 }
const std::string & formula() const
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
std::unique_ptr< reco::FormulaEvaluator > calib_fct_

Member Data Documentation

PPSTimingCalibration CTPPSDiamondRecHitProducerAlgorithm::calib_
private

Definition at line 38 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

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

Definition at line 39 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build(), and setCalibration().

unsigned short CTPPSDiamondRecHitProducerAlgorithm::MAX_CHANNEL = 20
staticprivate

Definition at line 35 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 37 of file CTPPSDiamondRecHitProducerAlgorithm.h.

Referenced by build().