CMS 3D CMS Logo

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

List of all members.

Public Member Functions

void addErrorCode (const std::string &error)
 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
const float & optimumSamplingPoint () const
const float & peak () const
void print (std::stringstream &, uint32_t not_used=0)
void refTime (const float &time, const float &targetDelay=-1)
const float & refTime () const
void reset ()
const float & time () const
virtual ~ApvTimingAnalysis ()

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

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 ( )
virtual ApvTimingAnalysis::~ApvTimingAnalysis ( ) [inline, virtual]

Definition at line 25 of file ApvTimingAnalysis.h.

{;}

Member Function Documentation

void ApvTimingAnalysis::addErrorCode ( const std::string &  error) [inline, virtual]

Adds error codes for analysis (overrides private base).

Reimplemented from CommissioningAnalysis.

Definition at line 129 of file ApvTimingAnalysis.h.

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

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().

{ 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().

{ 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_.

{ return error_; }
bool ApvTimingAnalysis::foundTickMark ( ) const
uint16_t ApvTimingAnalysis::frameFindingThreshold ( ) const
const float & ApvTimingAnalysis::height ( ) const [inline]

Height of tick mark [ADC].

Definition at line 126 of file ApvTimingAnalysis.h.

References height_.

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

{ return height_; }
bool ApvTimingAnalysis::isValid ( void  ) const [virtual]
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().

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().

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

Prints analysis results.

Implements CommissioningAnalysis.

Definition at line 159 of file ApvTimingAnalysis.cc.

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

Referenced by ApvTimingHistosUsingDb::update().

                                                                      { 
  header( ss );

  float sampling1 = sistrip::invalid_;
  if ( time_ <= sistrip::valid_ ) { sampling1 = time_ + optimumSamplingPoint_; }
  
  float sampling2 = sistrip::invalid_;
  if ( refTime_ <= sistrip::valid_ ) { sampling2 = refTime_ + optimumSamplingPoint_; }
  
  float adjust = sistrip::invalid_;
  if ( sampling1 <= sistrip::valid_ && delay_ <= sistrip::valid_ ) { adjust = sampling1 + delay_; }

  ss <<  std::fixed << std::setprecision(2)
     << " Tick mark: time of rising edge     [ns] : " << time_ << std::endl 
    //<< " Error on time of rising edge     [ns] : " << error_ << std::endl
     << " Tick mark: time of sampling point  [ns] : " << sampling1 << std::endl 
     << " Ref tick: time of rising edge      [ns] : " << refTime_ << std::endl 
     << " Ref tick: time of sampling point   [ns] : " << sampling2 << std::endl 
     << " Ref tick: adjusted sampling point  [ns] : " << adjust << std::endl 
     << " Delay required to synchronise      [ns] : " << delay_ << std::endl 
     << " Tick mark bottom (baseline)       [ADC] : " << base_ << std::endl 
     << " Tick mark top                     [ADC] : " << peak_ << std::endl 
     << " Tick mark height                  [ADC] : " << height_ << std::endl
     << " Frame finding threshold           [ADC] : " << frameFindingThreshold() << std::endl
     << std::boolalpha 
     << " Tick mark found                         : " << foundTickMark()  << std::endl
     << " isValid                                 : " << isValid()  << std::endl
     << std::noboolalpha
     << " Error codes (found "
     << std::setw(3) << std::setfill(' ') << getErrorCodes().size() 
     << ")                 : ";
  if ( getErrorCodes().empty() ) { ss << "(none)"; }
  else { 
    VString::const_iterator istr = getErrorCodes().begin();
    VString::const_iterator jstr = getErrorCodes().end();
    for ( ; istr != jstr; ++istr ) { ss << *istr << " "; }
  }
  ss << std::endl;
}
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().

{ 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_.

                                                                             { 

  // Checks synchronization to reference time is done only once
  if ( synchronized_ ) { 
    edm::LogWarning(mlCommissioning_)
      << "[" << myName() << "::" << __func__ << "]"
      << " Attempting to re-synchronize with reference time!"
      << " Not allowed!";
    return; 
  }
  synchronized_ = true;

  // Set reference time and check if tick mark time is valid
  refTime_ = time;
  if ( time_ > sistrip::valid_ ) { return; }
  
  // Calculate position of "sampling point" of last tick;
  int32_t position;
  if ( targetDelay == -1 ) {   // by default use latest tick
    position = static_cast<int32_t>( rint( refTime_ + optimumSamplingPoint_ ) );
  } else {
    position = static_cast<int32_t>( rint( targetDelay + optimumSamplingPoint_ ) );
  }

  // Calculate adjustment so that sampling point is multiple of 25 (ie, synched with FED sampling)
  float adjustment = 25 - position % 25;

  // Calculate delay required to synchronise with this adjusted sampling position
  if ( targetDelay == -1 ) {   // by default align forward to the latest tick
    delay_ = ( refTime_ + adjustment ) - time_;
  } else {                     // otherwise use the supplied target delay
    if ( adjustment > 25/2 ) adjustment -= 25; // go as close as possible to desired target
    delay_ = ( targetDelay + adjustment ) - time_;
  }

  // Check reference time
  if ( refTime_ < 0. || refTime_ > sistrip::valid_ ) { 
    refTime_ = sistrip::invalid_;
    addErrorCode(sistrip::invalidRefTime_);
  }
  
  // Check delay is valid
  if ( delay_ < -sistrip::valid_ || delay_ > sistrip::valid_ ) { 
    delay_ = sistrip::invalid_;
    addErrorCode(sistrip::invalidDelayTime_);
  }

}
void ApvTimingAnalysis::reset ( void  ) [virtual]
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().

{ 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_ [static, private]

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

Definition at line 100 of file ApvTimingAnalysis.h.

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

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().