CMS 3D CMS Logo

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

Analysis for timing run using APV tick marks. More...

#include <ApvTimingAnalysis.h>

Inheritance diagram for ApvTimingAnalysis:
CommissioningAnalysis

Public Member Functions

void addErrorCode (const std::string &error) override
 
 ApvTimingAnalysis ()
 
 ApvTimingAnalysis (const uint32_t &key)
 
const float & base () const
 
const float & delay () const
 
const float & error () const
 
bool foundTickMark () const
 
uint16_t frameFindingThreshold () const
 
const float & height () const
 
bool isValid () const override
 
const float & optimumSamplingPoint () const
 
const float & peak () const
 
void print (std::stringstream &, uint32_t not_used=0) override
 
const float & refTime () const
 
void refTime (const float &time, const float &targetDelay=-1)
 
void reset () override
 
const float & time () const
 
 ~ApvTimingAnalysis () override
 
- Public Member Functions inherited from CommissioningAnalysis
 CommissioningAnalysis (const std::string &my_name)
 
 CommissioningAnalysis (const uint32_t &key, const std::string &my_name)
 
const uint32_t & dcuId () const
 
void dcuId (const uint32_t &)
 
const uint32_t & detId () const
 
void detId (const uint32_t &)
 
const uint32_t & fecKey () const
 
void fecKey (const uint32_t &)
 
const uint32_t & fedKey () const
 
void fedKey (const uint32_t &)
 
const VStringgetErrorCodes () const
 
virtual void header (std::stringstream &) const
 
const std::string & myName () const
 
void setErrorCodes (const VString &errors)
 
virtual void summary (std::stringstream &) const
 
virtual ~CommissioningAnalysis ()
 

Static Public Attributes

static const float frameFindingThreshold_ = (2. / 3.)
 
static const float optimumSamplingPoint_ = 15.
 
static const float tickMarkHeightThreshold_ = 50.
 

Private Attributes

float base_
 
float delay_
 
float error_
 
float height_
 
float peak_
 
bool synchronized_
 
float time_
 

Static Private Attributes

static float refTime_ = 1. * sistrip::invalid_
 

Friends

class ApvTimingAlgorithm
 

Additional Inherited Members

- Public Types inherited from CommissioningAnalysis
typedef std::vector< bool > VBool
 
typedef std::vector< float > VFloat
 
typedef std::vector< uint16_t > VInt
 
typedef std::vector< std::string > VString
 
typedef std::vector< VBoolVVBool
 
typedef std::vector< VFloatVVFloat
 
typedef std::vector< VIntVVInt
 

Detailed Description

Analysis for timing run using APV tick marks.

Author
M. Wingham, R.Bainbridge

Definition at line 15 of file ApvTimingAnalysis.h.

Constructor & Destructor Documentation

◆ ApvTimingAnalysis() [1/2]

ApvTimingAnalysis::ApvTimingAnalysis ( const uint32_t &  key)

Definition at line 30 of file ApvTimingAnalysis.cc.

◆ ApvTimingAnalysis() [2/2]

ApvTimingAnalysis::ApvTimingAnalysis ( )

Definition at line 44 of file ApvTimingAnalysis.cc.

◆ ~ApvTimingAnalysis()

ApvTimingAnalysis::~ApvTimingAnalysis ( )
inlineoverride

Definition at line 23 of file ApvTimingAnalysis.h.

23 { ; }

Member Function Documentation

◆ addErrorCode()

void ApvTimingAnalysis::addErrorCode ( const std::string &  error)
inlineoverridevirtual

Adds error codes for analysis (overrides private base).

Reimplemented from CommissioningAnalysis.

Definition at line 125 of file ApvTimingAnalysis.h.

References CommissioningAnalysis::addErrorCode(), and error().

Referenced by refTime().

◆ base()

const float & ApvTimingAnalysis::base ( ) const
inline

Baseline level of tick mark [ADC].

Definition at line 123 of file ApvTimingAnalysis.h.

123 { return base_; }

References base_.

◆ delay()

const float & ApvTimingAnalysis::delay ( ) const
inline

Delay required to sync w.r.t. reference tick mark [ns].

Definition at line 121 of file ApvTimingAnalysis.h.

121 { return delay_; }

References delay_.

◆ error()

const float & ApvTimingAnalysis::error ( ) const
inline

Error on time of tick mark rising edge [ns].

Definition at line 118 of file ApvTimingAnalysis.h.

118 { return error_; }

References error_.

Referenced by addErrorCode(), and Page1Parser.Page1Parser::check_for_whole_start_tag().

◆ foundTickMark()

bool ApvTimingAnalysis::foundTickMark ( ) const

Identifies if tick mark is found or not.

Definition at line 133 of file ApvTimingAnalysis.cc.

133  {
134  return ((getErrorCodes().empty() || getErrorCodes()[0] == "TickMarkRecovered") && time_ < sistrip::valid_ &&
137 }

References base_, relativeConstraints::empty, frameFindingThreshold(), CommissioningAnalysis::getErrorCodes(), height_, peak_, time_, and sistrip::valid_.

Referenced by print().

◆ frameFindingThreshold()

uint16_t ApvTimingAnalysis::frameFindingThreshold ( ) const

FED frame-finding threshold [ADC] (returns 65535 if invalid).

Definition at line 121 of file ApvTimingAnalysis.cc.

121  {
122  if ((getErrorCodes().empty() || getErrorCodes()[0] == "TickMarkRecovered") && time_ < sistrip::valid_ &&
125  return ((static_cast<uint16_t>(base_ + height_ * ApvTimingAnalysis::frameFindingThreshold_) / 32) * 32);
126  } else {
127  return sistrip::invalid_;
128  }
129 }

References base_, relativeConstraints::empty, frameFindingThreshold_, CommissioningAnalysis::getErrorCodes(), height_, sistrip::invalid_, peak_, tickMarkHeightThreshold_, time_, and sistrip::valid_.

Referenced by foundTickMark(), isValid(), and print().

◆ height()

const float & ApvTimingAnalysis::height ( ) const
inline

Height of tick mark [ADC].

Definition at line 122 of file ApvTimingAnalysis.h.

122 { return height_; }

References height_.

◆ isValid()

bool ApvTimingAnalysis::isValid ( void  ) const
overridevirtual

◆ optimumSamplingPoint()

const float & ApvTimingAnalysis::optimumSamplingPoint ( ) const
inline

Optimum sampling point, defined w.r.t. rising edge [ns].

Definition at line 119 of file ApvTimingAnalysis.h.

119 { return optimumSamplingPoint_; }

References optimumSamplingPoint_.

◆ peak()

const float & ApvTimingAnalysis::peak ( ) const
inline

Level of tick mark top [ADC].

Definition at line 124 of file ApvTimingAnalysis.h.

124 { return peak_; }

References peak_.

◆ print()

void ApvTimingAnalysis::print ( std::stringstream &  ss,
uint32_t  not_used = 0 
)
overridevirtual

Prints analysis results.

Implements CommissioningAnalysis.

Definition at line 150 of file ApvTimingAnalysis.cc.

150  {
151  header(ss);
152 
153  float sampling1 = sistrip::invalid_;
154  if (time_ <= sistrip::valid_) {
155  sampling1 = time_ + optimumSamplingPoint_;
156  }
157 
158  float sampling2 = sistrip::invalid_;
159  if (refTime_ <= sistrip::valid_) {
160  sampling2 = refTime_ + optimumSamplingPoint_;
161  }
162 
163  float adjust = sistrip::invalid_;
164  if (sampling1 <= sistrip::valid_ && delay_ <= sistrip::valid_) {
165  adjust = sampling1 + delay_;
166  }
167 
168  ss << std::fixed << std::setprecision(2) << " Tick mark: time of rising edge [ns] : " << time_
169  << std::endl
170  //<< " Error on time of rising edge [ns] : " << error_ << std::endl
171  << " Tick mark: time of sampling point [ns] : " << sampling1 << std::endl
172  << " Ref tick: time of rising edge [ns] : " << refTime_ << std::endl
173  << " Ref tick: time of sampling point [ns] : " << sampling2 << std::endl
174  << " Ref tick: adjusted sampling point [ns] : " << adjust << std::endl
175  << " Delay required to synchronise [ns] : " << delay_ << std::endl
176  << " Tick mark bottom (baseline) [ADC] : " << base_ << std::endl
177  << " Tick mark top [ADC] : " << peak_ << std::endl
178  << " Tick mark height [ADC] : " << height_ << std::endl
179  << " Frame finding threshold [ADC] : " << frameFindingThreshold() << std::endl
180  << std::boolalpha << " Tick mark found : " << foundTickMark() << std::endl
181  << " isValid : " << isValid() << std::endl
182  << std::noboolalpha << " Error codes (found " << std::setw(3) << std::setfill(' ') << getErrorCodes().size()
183  << ") : ";
184  if (getErrorCodes().empty()) {
185  ss << "(none)";
186  } else {
187  VString::const_iterator istr = getErrorCodes().begin();
188  VString::const_iterator jstr = getErrorCodes().end();
189  for (; istr != jstr; ++istr) {
190  ss << *istr << " ";
191  }
192  }
193  ss << std::endl;
194 }

References base_, delay_, relativeConstraints::empty, alignBH_cfg::fixed, foundTickMark(), frameFindingThreshold(), CommissioningAnalysis::getErrorCodes(), CommissioningAnalysis::header(), height_, sistrip::invalid_, isValid(), optimumSamplingPoint_, peak_, refTime_, contentValuesCheck::ss, time_, and sistrip::valid_.

◆ refTime() [1/2]

const float & ApvTimingAnalysis::refTime ( ) const
inline

Sampling point of "reference" tick mark [ns].

Definition at line 120 of file ApvTimingAnalysis.h.

120 { return refTime_; }

References refTime_.

◆ refTime() [2/2]

void ApvTimingAnalysis::refTime ( const float &  time,
const float &  targetDelay = -1 
)

Static method to set global reference time [ns].

Definition at line 70 of file ApvTimingAnalysis.cc.

70  {
71  // Checks synchronization to reference time is done only once
72  if (synchronized_) {
73  edm::LogWarning(mlCommissioning_) << "[" << myName() << "::" << __func__ << "]"
74  << " Attempting to re-synchronize with reference time!"
75  << " Not allowed!";
76  return;
77  }
78  synchronized_ = true;
79 
80  // Set reference time and check if tick mark time is valid
81  refTime_ = time;
82  if (time_ > sistrip::valid_) {
83  return;
84  }
85 
86  // Calculate position of "sampling point" of last tick;
87  int32_t position;
88  if (targetDelay == -1) { // by default use latest tick
89  position = static_cast<int32_t>(rint(refTime_ + optimumSamplingPoint_));
90  } else {
91  position = static_cast<int32_t>(rint(targetDelay + optimumSamplingPoint_));
92  }
93 
94  // Calculate adjustment so that sampling point is multiple of 25 (ie, synched with FED sampling)
95  float adjustment = 25 - position % 25;
96 
97  // Calculate delay required to synchronise with this adjusted sampling position
98  if (targetDelay == -1) { // by default align forward to the latest tick
99  delay_ = (refTime_ + adjustment) - time_;
100  } else { // otherwise use the supplied target delay
101  if (adjustment > 25 / 2)
102  adjustment -= 25; // go as close as possible to desired target
103  delay_ = (targetDelay + adjustment) - time_;
104  }
105 
106  // Check reference time
107  if (refTime_ < 0. || refTime_ > sistrip::valid_) {
110  }
111 
112  // Check delay is valid
113  if (delay_ < -sistrip::valid_ || delay_ > sistrip::valid_) {
116  }
117 }

References addErrorCode(), delay_, sistrip::invalid_, sistrip::invalidDelayTime_, sistrip::invalidRefTime_, sistrip::mlCommissioning_, CommissioningAnalysis::myName(), optimumSamplingPoint_, position, refTime_, synchronized_, time(), time_, and sistrip::valid_.

◆ reset()

void ApvTimingAnalysis::reset ( void  )
overridevirtual

Resets analysis member data.

Implements CommissioningAnalysis.

Definition at line 58 of file ApvTimingAnalysis.cc.

58  {
59  time_ = 1. * sistrip::invalid_;
63  base_ = 1. * sistrip::invalid_;
64  peak_ = 1. * sistrip::invalid_;
65  synchronized_ = false;
66 }

References base_, delay_, error_, height_, sistrip::invalid_, peak_, synchronized_, and time_.

Referenced by MatrixReader.MatrixReader::__init__(), and MatrixReader.MatrixReader::showRaw().

◆ time()

const float & ApvTimingAnalysis::time ( ) const
inline

Time of tick mark rising edge [ns].

Definition at line 117 of file ApvTimingAnalysis.h.

117 { return time_; }

References time_.

Referenced by refTime().

Friends And Related Function Documentation

◆ ApvTimingAlgorithm

friend class ApvTimingAlgorithm
friend

Definition at line 25 of file ApvTimingAnalysis.h.

Member Data Documentation

◆ base_

float ApvTimingAnalysis::base_
private

Baseline level of tick mark [ADC].

Definition at line 106 of file ApvTimingAnalysis.h.

Referenced by base(), foundTickMark(), frameFindingThreshold(), isValid(), print(), and reset().

◆ delay_

float ApvTimingAnalysis::delay_
private

Delay required to sync w.r.t. reference tick mark [ns].

Definition at line 100 of file ApvTimingAnalysis.h.

Referenced by delay(), isValid(), print(), refTime(), and reset().

◆ error_

float ApvTimingAnalysis::error_
private

Error on time of tick mark rising edge [ns].

Definition at line 94 of file ApvTimingAnalysis.h.

Referenced by error(), and reset().

◆ frameFindingThreshold_

const float ApvTimingAnalysis::frameFindingThreshold_ = (2. / 3.)
static

Threshold for FED frame finding (fraction of tick height).

Definition at line 85 of file ApvTimingAnalysis.h.

Referenced by frameFindingThreshold().

◆ height_

float ApvTimingAnalysis::height_
private

Height of tick mark [ADC].

Definition at line 103 of file ApvTimingAnalysis.h.

Referenced by foundTickMark(), frameFindingThreshold(), height(), isValid(), print(), and reset().

◆ optimumSamplingPoint_

const float ApvTimingAnalysis::optimumSamplingPoint_ = 15.
static

Optimum sampling point, defined w.r.t. rising edge [ns].

Definition at line 79 of file ApvTimingAnalysis.h.

Referenced by optimumSamplingPoint(), print(), and refTime().

◆ peak_

float ApvTimingAnalysis::peak_
private

Level of tick mark top [ADC].

Definition at line 109 of file ApvTimingAnalysis.h.

Referenced by foundTickMark(), frameFindingThreshold(), isValid(), peak(), print(), and reset().

◆ refTime_

float ApvTimingAnalysis::refTime_ = 1. * sistrip::invalid_
staticprivate

Sampling point of "reference" tick mark [ns].

Definition at line 97 of file ApvTimingAnalysis.h.

Referenced by isValid(), print(), and refTime().

◆ synchronized_

bool ApvTimingAnalysis::synchronized_
private

Checks synchronization to ref time is done only once.

Definition at line 112 of file ApvTimingAnalysis.h.

Referenced by isValid(), refTime(), and reset().

◆ tickMarkHeightThreshold_

const float ApvTimingAnalysis::tickMarkHeightThreshold_ = 50.
static

Threshold defining minimum tick mark height [ADC].

Definition at line 82 of file ApvTimingAnalysis.h.

Referenced by ApvTimingAlgorithm::analyse(), ApvTimingHistosUsingDb::create(), and frameFindingThreshold().

◆ time_

float ApvTimingAnalysis::time_
private

Time of tick mark rising edge [ns].

Definition at line 91 of file ApvTimingAnalysis.h.

Referenced by foundTickMark(), frameFindingThreshold(), isValid(), print(), refTime(), reset(), and time().

CommissioningAnalysis::getErrorCodes
const VString & getErrorCodes() const
Definition: CommissioningAnalysis.h:131
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
sistrip::invalidDelayTime_
static const char invalidDelayTime_[]
Definition: ConstantsForCommissioningAnalysis.h:46
ApvTimingAnalysis::foundTickMark
bool foundTickMark() const
Definition: ApvTimingAnalysis.cc:133
ApvTimingAnalysis::time_
float time_
Definition: ApvTimingAnalysis.h:91
CommissioningAnalysis::addErrorCode
virtual void addErrorCode(const std::string &error)
Definition: CommissioningAnalysis.h:148
ApvTimingAnalysis::peak_
float peak_
Definition: ApvTimingAnalysis.h:109
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ApvTimingAnalysis::tickMarkHeightThreshold_
static const float tickMarkHeightThreshold_
Definition: ApvTimingAnalysis.h:82
ApvTimingAnalysis::error
const float & error() const
Definition: ApvTimingAnalysis.h:118
ApvTimingAnalysis::base_
float base_
Definition: ApvTimingAnalysis.h:106
sistrip::valid_
static const uint16_t valid_
Definition: Constants.h:17
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
sistrip::mlCommissioning_
static const char mlCommissioning_[]
Definition: ConstantsForLogger.h:15
sistrip::apvTimingAnalysis_
static const char apvTimingAnalysis_[]
Definition: ConstantsForCommissioningAnalysis.h:37
CommissioningAnalysis::header
virtual void header(std::stringstream &) const
Definition: CommissioningAnalysis.cc:33
ApvTimingAnalysis::isValid
bool isValid() const override
Definition: ApvTimingAnalysis.cc:141
ApvTimingAnalysis::time
const float & time() const
Definition: ApvTimingAnalysis.h:117
ApvTimingAnalysis::addErrorCode
void addErrorCode(const std::string &error) override
Definition: ApvTimingAnalysis.h:125
ApvTimingAnalysis::synchronized_
bool synchronized_
Definition: ApvTimingAnalysis.h:112
CommissioningAnalysis::CommissioningAnalysis
CommissioningAnalysis()
Definition: CommissioningAnalysis.h:105
sistrip::invalidRefTime_
static const char invalidRefTime_[]
Definition: ConstantsForCommissioningAnalysis.h:45
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
ApvTimingAnalysis::optimumSamplingPoint_
static const float optimumSamplingPoint_
Definition: ApvTimingAnalysis.h:79
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
CommissioningAnalysis::myName
const std::string & myName() const
Definition: CommissioningAnalysis.h:139
ApvTimingAnalysis::refTime_
static float refTime_
Definition: ApvTimingAnalysis.h:97
ApvTimingAnalysis::frameFindingThreshold
uint16_t frameFindingThreshold() const
Definition: ApvTimingAnalysis.cc:121
ApvTimingAnalysis::error_
float error_
Definition: ApvTimingAnalysis.h:94
ApvTimingAnalysis::delay_
float delay_
Definition: ApvTimingAnalysis.h:100
ApvTimingAnalysis::height_
float height_
Definition: ApvTimingAnalysis.h:103
crabWrapper.key
key
Definition: crabWrapper.py:19
ApvTimingAnalysis::frameFindingThreshold_
static const float frameFindingThreshold_
Definition: ApvTimingAnalysis.h:85