CMS 3D CMS Logo

Public Member Functions

ApvTimingHistograms Class Reference

#include <ApvTimingHistograms.h>

Inheritance diagram for ApvTimingHistograms:
CommissioningHistograms ApvTimingHistosUsingDb

List of all members.

Public Member Functions

 ApvTimingHistograms (const edm::ParameterSet &pset, DQMStore *)
void histoAnalysis (bool debug)
virtual ~ApvTimingHistograms ()

Detailed Description

Definition at line 8 of file ApvTimingHistograms.h.


Constructor & Destructor Documentation

ApvTimingHistograms::ApvTimingHistograms ( const edm::ParameterSet pset,
DQMStore bei 
)

Definition at line 18 of file ApvTimingHistograms.cc.

References CommissioningHistograms::factory_, LogTrace, and sistrip::mlDqmClient_.

  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("ApvTimingParameters"),
                             bei,
                             sistrip::APV_TIMING )
{
  factory_ = auto_ptr<ApvTimingSummaryFactory>( new ApvTimingSummaryFactory );
  LogTrace(mlDqmClient_) 
    << "[ApvTimingHistograms::" << __func__ << "]"
    << " Constructing object...";
}
ApvTimingHistograms::~ApvTimingHistograms ( ) [virtual]

Definition at line 32 of file ApvTimingHistograms.cc.

References LogTrace, and sistrip::mlDqmClient_.

                                          {
  LogTrace(mlDqmClient_) 
    << "[ApvTimingHistograms::" << __func__ << "]"
    << " Destructing object...";
}

Member Function Documentation

void ApvTimingHistograms::histoAnalysis ( bool  debug) [virtual]

Reimplemented from CommissioningHistograms.

Definition at line 40 of file ApvTimingHistograms.cc.

References CommissioningAlgorithm::analysis(), begin, SiStripFecKey::ccuAddr(), SiStripFecKey::ccuChan(), prof2calltree::count, CommissioningHistograms::data(), relativeConstraints::empty, benchmark_cfg::errors, extract(), SiStripFecKey::fecCrate(), SiStripFecKey::fecRing(), SiStripFecKey::fecSlot(), ApvTimingAnalysis::foundTickMark(), CommissioningAnalysis::getErrorCodes(), CommissioningHistograms::histos(), sistrip::invalid_, ApvTimingAnalysis::isValid(), SiStripFecKey::lldChan(), LogTrace, max(), min, sistrip::mlDqmClient_, CommissioningHistograms::pset(), ApvTimingAnalysis::refTime(), ApvTimingAnalysis::time(), TrackValidation_HighPurity_cff::valid, and sistrip::valid_.

                                                    {
  LogTrace(mlDqmClient_)
    << "[ApvTimingHistograms::" << __func__ << "]";

  // Some initialisation
  uint16_t valid = 0;
  HistosMap::const_iterator iter;
  Analyses::iterator ianal;
  std::map<std::string,uint16_t> errors;
  
  // Clear map holding analysis objects
  for ( ianal = data().begin(); ianal != data().end(); ianal++ ) { 
    if ( ianal->second ) { delete ianal->second; }
  } 
  data().clear();
  
  // Reset minimum / maximum delays
  float time_min =  1. * sistrip::invalid_;
  float time_max = -1. * sistrip::invalid_;
  uint32_t device_min = sistrip::invalid_;
  uint32_t device_max = sistrip::invalid_;
  
  // Iterate through map containing histograms
  for ( iter = histos().begin();
        iter != histos().end(); iter++ ) {
    
    // Check vector of histos is not empty
    if ( iter->second.empty() ) {
      edm::LogWarning(mlDqmClient_) 
        << "[ApvTimingHistograms::" << __func__ << "]"
        << " Zero histograms found!";
      continue;
    }
    
    // Retrieve pointers to histos
    std::vector<TH1*> profs;
    Histos::const_iterator ihis = iter->second.begin(); 
    for ( ; ihis != iter->second.end(); ihis++ ) {
      TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
      if ( prof ) { profs.push_back(prof); }
    } 
    
    // Perform histo analysis
    ApvTimingAnalysis* anal = new ApvTimingAnalysis( iter->first );
    ApvTimingAlgorithm algo( this->pset(), anal );
    algo.analysis( profs );
    data()[iter->first] = anal; 

    // Check if tick mark found
    if ( !anal->foundTickMark() ) { continue; }
    
    // Find maximum time
    if ( anal->time() > time_max ) { 
      time_max = anal->time(); 
      device_max = iter->first;
    }
    
    // Find minimum time
    if ( anal->time() < time_min ) { 
      time_min = anal->time(); 
      device_min = iter->first;
    }
    
  }
  
  // Adjust maximum (and minimum) delay(s) to find optimum sampling point(s)
  if ( time_max > sistrip::valid_ ||
       time_max < -1.*sistrip::valid_ ) { 

    edm::LogWarning(mlDqmClient_)
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " Unable to set maximum time! Found unexpected value: "
      << time_max;
    
  } else {
    
    SiStripFecKey min( device_min );
    edm::LogVerbatim(mlDqmClient_)
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " Crate/FEC/Ring/CCU/module/channel: " 
      << min.fecCrate() << "/" 
      << min.fecSlot() << "/" 
      << min.fecRing() << "/" 
      << min.ccuAddr() << "/"
      << min.ccuChan() << "/"
      << min.lldChan() 
      << " has minimum time for tick mark rising edge [ns]: " << time_min;
    
    SiStripFecKey max( device_max );
    edm::LogVerbatim(mlDqmClient_)
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " Crate/FEC/Ring/CCU/module/channel: " 
      << max.fecCrate() << "/" 
      << max.fecSlot() << "/" 
      << max.fecRing() << "/" 
      << max.ccuAddr() << "/"
      << max.ccuChan() << "/"
      << max.lldChan() 
      << " has maximum time for tick mark rising edge [ns]: " << time_max;

    edm::LogVerbatim(mlDqmClient_)
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " Difference b/w minimum and maximum times"
      << " for tick mark rising edges [ns] is: " << ( time_max - time_min );

  }
  
  // Set reference time for all analysis objects
  for ( ianal = data().begin(); ianal != data().end(); ianal++ ) { 
    ApvTimingAnalysis* anal = dynamic_cast<ApvTimingAnalysis*>(ianal->second);
    if ( !anal ) { continue; }
    anal->refTime( time_max, this->pset().getParameter<int>("TargetDelay") );
    if ( anal->isValid() ) { valid++; }
    if ( !anal->getErrorCodes().empty() ) { 
      errors[anal->getErrorCodes()[0]]++;
    }
  }

  if ( !histos().empty() ) {
    edm::LogVerbatim(mlDqmClient_) 
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " Analyzed histograms for " << histos().size() 
      << " FED channels, of which " << valid 
      << " (" << 100 * valid / histos().size()
      << "%) are valid.";
  } else {
    edm::LogWarning(mlDqmClient_) 
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " No histograms to analyze!";
  }

  if ( !histos().empty() ) {
    edm::LogVerbatim(mlDqmClient_) 
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " Analyzed histograms for " << histos().size() 
      << " FED channels, of which " << valid 
      << " (" << 100 * valid / histos().size()
      << "%) are valid.";
    if ( !errors.empty() ) {
      uint16_t count = 0;
      std::stringstream ss;
      ss << std::endl;
      std::map<std::string,uint16_t>::const_iterator ii;
      for ( ii = errors.begin(); ii != errors.end(); ++ii ) { 
        ss << " " << ii->first << ": " << ii->second << std::endl;
        count += ii->second;
      }
      edm::LogWarning(mlDqmClient_) 
        << "[ApvTimingHistograms::" << __func__ << "]"
        << " Found " << count << " errors ("
        << 100 * count / histos().size() << "%): " 
        << ss.str();
    }
  } else {
    edm::LogWarning(mlDqmClient_) 
      << "[ApvTimingHistograms::" << __func__ << "]"
      << " No histograms to analyze!";
  }
  
}