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 (const uint32_t &key)
 
 ApvTimingAnalysis ()
 
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 uint32_t &key, const std::string &my_name)
 
 CommissioningAnalysis (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::ApvTimingAnalysis ( const uint32_t &  key)
ApvTimingAnalysis::ApvTimingAnalysis ( )
ApvTimingAnalysis::~ApvTimingAnalysis ( )
inlineoverride

Definition at line 25 of file ApvTimingAnalysis.h.

25 {;}

Member Function Documentation

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

Adds error codes for analysis (overrides private base).

Reimplemented from CommissioningAnalysis.

Definition at line 129 of file ApvTimingAnalysis.h.

References CommissioningAnalysis::addErrorCode().

Referenced by ApvTimingAlgorithm::analyse(), and refTime().

const float & error() const
virtual void addErrorCode(const std::string &error)
const float & ApvTimingAnalysis::base ( ) const
inline

Baseline level of tick mark [ADC].

Definition at line 127 of file ApvTimingAnalysis.h.

References base_.

Referenced by ApvTimingHistosUsingDb::create(), ApvTimingSummaryFactory::extract(), and ApvTimingHistosUsingDb::update().

127 { return base_; }
const float & ApvTimingAnalysis::delay ( ) const
inline

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

Definition at line 125 of file ApvTimingAnalysis.h.

References delay_.

Referenced by ApvTimingHistosUsingDb::create(), ApvTimingSummaryFactory::extract(), and ApvTimingHistosUsingDb::update().

125 { return delay_; }
const float & ApvTimingAnalysis::error ( ) const
inline

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

Definition at line 122 of file ApvTimingAnalysis.h.

References error_.

Referenced by Page1Parser.Page1Parser::check_for_whole_start_tag().

122 { return error_; }
bool ApvTimingAnalysis::foundTickMark ( ) const

Identifies if tick mark is found or not.

Definition at line 134 of file ApvTimingAnalysis.cc.

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

Referenced by ApvTimingHistograms::histoAnalysis(), and print().

134  {
135  return ( ( getErrorCodes().empty() || getErrorCodes()[0] == "TickMarkRecovered") &&
141 }
static const uint16_t valid_
Definition: Constants.h:17
uint16_t frameFindingThreshold() const
const VString & getErrorCodes() const
uint16_t ApvTimingAnalysis::frameFindingThreshold ( ) const

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

Definition at line 119 of file ApvTimingAnalysis.cc.

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

Referenced by ApvTimingHistosUsingDb::create(), foundTickMark(), isValid(), print(), and ApvTimingHistosUsingDb::update().

119  {
120  if ( ( getErrorCodes().empty() || getErrorCodes()[0] == "TickMarkRecovered" ) &&
122  base_ < sistrip::valid_ &&
123  peak_ < sistrip::valid_ &&
126  return ( ( static_cast<uint16_t>( base_ +
127  height_ *
129  } else { return sistrip::invalid_; }
130 }
static const float tickMarkHeightThreshold_
static const uint16_t valid_
Definition: Constants.h:17
static const uint16_t invalid_
Definition: Constants.h:16
static const float frameFindingThreshold_
const VString & getErrorCodes() const
const float & ApvTimingAnalysis::height ( ) const
inline
bool ApvTimingAnalysis::isValid ( void  ) const
overridevirtual

Identifies if analysis is valid or not.

Reimplemented from CommissioningAnalysis.

Definition at line 145 of file ApvTimingAnalysis.cc.

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

Referenced by ntupleDataFormat._Object::_checkIsValid(), ApvTimingHistosUsingDb::create(), ApvTimingHistograms::histoAnalysis(), print(), core.AutoHandle.AutoHandle::ReallyLoad(), and ApvTimingHistosUsingDb::update().

145  {
146  return ( ( getErrorCodes().empty() || getErrorCodes()[0] == "TickMarkRecovered" ) &&
152  synchronized_ &&
155 }
static const uint16_t valid_
Definition: Constants.h:17
uint16_t frameFindingThreshold() const
const VString & getErrorCodes() const
const float & ApvTimingAnalysis::optimumSamplingPoint ( ) const
inline

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

Definition at line 123 of file ApvTimingAnalysis.h.

References optimumSamplingPoint_.

Referenced by ApvTimingHistosUsingDb::create().

123 { return optimumSamplingPoint_; }
static const float optimumSamplingPoint_
const float & ApvTimingAnalysis::peak ( ) const
inline

Level of tick mark top [ADC].

Definition at line 128 of file ApvTimingAnalysis.h.

References peak_.

Referenced by ApvTimingHistosUsingDb::create(), ApvTimingSummaryFactory::extract(), and ApvTimingHistosUsingDb::update().

128 { return peak_; }
void ApvTimingAnalysis::print ( std::stringstream &  ss,
uint32_t  not_used = 0 
)
overridevirtual

Prints analysis results.

Implements CommissioningAnalysis.

Definition at line 159 of file ApvTimingAnalysis.cc.

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

Referenced by ApvTimingHistosUsingDb::update().

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

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

Definition at line 124 of file ApvTimingAnalysis.h.

References refTime_.

Referenced by ApvTimingHistosUsingDb::create(), ApvTimingSummaryFactory::extract(), and ApvTimingHistograms::histoAnalysis().

124 { return refTime_; }
void ApvTimingAnalysis::refTime ( const float &  time,
const float &  targetDelay = -1 
)

Static method to set global reference time [ns].

Definition at line 68 of file ApvTimingAnalysis.cc.

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

68  {
69 
70  // Checks synchronization to reference time is done only once
71  if ( synchronized_ ) {
73  << "[" << 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_ ) { return; }
83 
84  // Calculate position of "sampling point" of last tick;
85  int32_t position;
86  if ( targetDelay == -1 ) { // by default use latest tick
87  position = static_cast<int32_t>( rint( refTime_ + optimumSamplingPoint_ ) );
88  } else {
89  position = static_cast<int32_t>( rint( targetDelay + optimumSamplingPoint_ ) );
90  }
91 
92  // Calculate adjustment so that sampling point is multiple of 25 (ie, synched with FED sampling)
93  float adjustment = 25 - position % 25;
94 
95  // Calculate delay required to synchronise with this adjusted sampling position
96  if ( targetDelay == -1 ) { // by default align forward to the latest tick
97  delay_ = ( refTime_ + adjustment ) - time_;
98  } else { // otherwise use the supplied target delay
99  if ( adjustment > 25/2 ) adjustment -= 25; // go as close as possible to desired target
100  delay_ = ( targetDelay + adjustment ) - time_;
101  }
102 
103  // Check reference time
104  if ( refTime_ < 0. || refTime_ > sistrip::valid_ ) {
107  }
108 
109  // Check delay is valid
110  if ( delay_ < -sistrip::valid_ || delay_ > sistrip::valid_ ) {
113  }
114 
115 }
static const uint16_t valid_
Definition: Constants.h:17
static const char mlCommissioning_[]
void addErrorCode(const std::string &error) override
const float & time() const
static const char invalidRefTime_[]
static const float optimumSamplingPoint_
static const uint16_t invalid_
Definition: Constants.h:16
static int position[264][3]
Definition: ReadPGInfo.cc:509
const std::string & myName() const
static const char invalidDelayTime_[]
void ApvTimingAnalysis::reset ( void  )
overridevirtual
const float & ApvTimingAnalysis::time ( ) const
inline

Time of tick mark rising edge [ns].

Definition at line 121 of file ApvTimingAnalysis.h.

References time_.

Referenced by ApvTimingHistosUsingDb::create(), ApvTimingSummaryFactory::extract(), ApvTimingHistograms::histoAnalysis(), and refTime().

121 { return time_; }

Friends And Related Function Documentation

friend class ApvTimingAlgorithm
friend

Definition at line 27 of file ApvTimingAnalysis.h.

Member Data Documentation

float ApvTimingAnalysis::base_
private

Baseline level of tick mark [ADC].

Definition at line 109 of file ApvTimingAnalysis.h.

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

float ApvTimingAnalysis::delay_
private

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

Definition at line 103 of file ApvTimingAnalysis.h.

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

float ApvTimingAnalysis::error_
private

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

Definition at line 97 of file ApvTimingAnalysis.h.

Referenced by error(), and reset().

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

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

Definition at line 87 of file ApvTimingAnalysis.h.

Referenced by frameFindingThreshold().

float ApvTimingAnalysis::height_
private

Height of tick mark [ADC].

Definition at line 106 of file ApvTimingAnalysis.h.

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

const float ApvTimingAnalysis::optimumSamplingPoint_ = 15.
static

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

Definition at line 81 of file ApvTimingAnalysis.h.

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

float ApvTimingAnalysis::peak_
private

Level of tick mark top [ADC].

Definition at line 112 of file ApvTimingAnalysis.h.

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

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

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

Definition at line 100 of file ApvTimingAnalysis.h.

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

bool ApvTimingAnalysis::synchronized_
private

Checks synchronization to ref time is done only once.

Definition at line 115 of file ApvTimingAnalysis.h.

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

const float ApvTimingAnalysis::tickMarkHeightThreshold_ = 50.
static

Threshold defining minimum tick mark height [ADC].

Definition at line 84 of file ApvTimingAnalysis.h.

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

float ApvTimingAnalysis::time_
private

Time of tick mark rising edge [ns].

Definition at line 94 of file ApvTimingAnalysis.h.

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