CMS 3D CMS Logo

UpdateTProfile Class Reference

#include <DQM/SiStripCommon/interface/UpdateTProfile.h>

List of all members.

Public Member Functions

 UpdateTProfile ()
 ~UpdateTProfile ()

Static Public Member Functions

static void setBinContent (TProfile *const profile, const uint32_t &bin, const double &entries, const double &mean, const double &spread)
 Error option "s" means that the error returned using the GetBinError() method is the spread for that bin.
static void setBinContents (TProfile *const profile, const uint32_t &bin, const double &num_of_entries, const double &sum_of_contents, const double &sum_of_squares)


Detailed Description

Definition at line 9 of file UpdateTProfile.h.


Constructor & Destructor Documentation

UpdateTProfile::UpdateTProfile (  ) 

Definition at line 10 of file UpdateTProfile.cc.

00010 {;}

UpdateTProfile::~UpdateTProfile (  ) 

Definition at line 14 of file UpdateTProfile.cc.

00014 {;}


Member Function Documentation

void UpdateTProfile::setBinContent ( TProfile *const   prof,
const uint32_t &  bin,
const double &  num_of_entries,
const double &  mean,
const double &  spread 
) [static]

Error option "s" means that the error returned using the GetBinError() method is the spread for that bin.

(If the default error option is used, the error returned is spread / sqrt(N), where N is the number of entries for that bin). The commissioning procedures use option "s" throughout.

In order that the profile histo correctly displays the "bin_mean" and "bin_spread" (an example being: peds +/- strip noise), we have to manipulate the "contents" and "error" data as follows:

TProfile::SetBinEntries( bin_number, bin_entries ) TProfile::SetBinContents( bin_number, bin_mean * bin_entries ) TProfile::SetBinError( bin_number, weight )

"weight" is calculated based on the GetBinError() method, which returns an error ("err" below) based on the following equation:

1) if error option is set to "s": err = sqrt( wei^2 / num - ( sum / num )^2 ) => err = sqrt( wei^2 / num - sum^2 / num^2 ) => wei = sqrt( err^2 * num + sum^2 / num ) => wei = sqrt( err^2 * num + mean^2 * num )

2) else if error option is set to "" (ie, default): err = ( 1 / sqrt( num ) ) * sqrt( wei^2 / num - ( sum / num )^2 ) => err = sqrt( wei^2 / num^2 - sum^2 / num^3 ) => wei = sqrt( err^2 * num^2 + cont^2 / num ) => wei = sqrt( err^2 * num^2 + mean^2 * num )

where: "num" is the bin entries, as set by the method SetBinEntries() "sum" is the bin content, as set by the method SetBinContent() "wei" is the bin error, as set by the method SetBinError() and "mean" = sum / num

Definition at line 83 of file UpdateTProfile.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), python::tagInventory::entries, funct::sqrt(), and weight.

Referenced by setBinContents(), PedestalsTask::update(), PedsOnlyTask::update(), and NoiseTask::update().

00087                                                            {
00088   //   cout << "[UpdateTProfile::setBinContents]" << endl;
00089 
00090   // Check histo exists
00091   if ( !prof ) {
00092     cerr << "[UpdateTProfile::setBinContents]"
00093          << " NULL pointer to TProfile object!" << endl;
00094     return;
00095   }
00096 
00097   // Check bin number is valid
00098   if ( bin == 0 || bin > static_cast<uint32_t>(prof->GetNbinsX()) ) {
00099     cerr << "[UpdateTProfile::setBinContents]"
00100          << " Unexpected bin number!" << endl;
00101     return;
00102   }
00103 
00104   // Check entries are present
00105   if ( num_of_entries <= 0. ) { return; } //@@ what about negative weights???
00106   double entries = num_of_entries;
00107   
00108   // Check error option
00109   const char* spread_option = "s";
00110   const char* default_option = "";
00111   //   const char* option = prof->GetErrorOption();
00112   //   if ( option[0] != spread_option[0] ) {
00113   //     cout << "[UpdateTProfile::setBinContents]"
00114   //     << " Setting error option for TProfile to 's'!" << endl;
00115   //     prof->SetErrorOption( "s" );
00116   //   }
00117   const char* error_option = prof->GetErrorOption();
00118 
00119   // Calculate "weight" used for SetBinError() method
00120   double weight;
00121   if ( error_option[0] == spread_option[0] ) {
00122     weight = sqrt( mean*mean*entries + spread*spread*entries  );
00123   } else if (error_option[0] == default_option[0] ) {
00124     weight = sqrt( mean*mean*entries + spread*spread*entries*entries );
00125   } else { 
00126     cerr << "[UpdateTProfile::setBinContents]"
00127          << " Unexpected error option for TProfile!" << endl;
00128     weight = 0.; 
00129   }
00130   
00131   // Set bin entries, contents and error
00132   prof->SetBinEntries( bin, entries );
00133   prof->SetBinContent( bin, mean * entries );
00134   prof->SetBinError( bin, weight );
00135  
00136 //   LogTrace("TEST")
00137 //     << "[UpdateTProfile::" << __func__ << "]"
00138 //     << " bin/entries/mean/content/error: " 
00139 //     << bin << "/"
00140 //     << entries << "/"
00141 //     << mean << "/"
00142 //     << mean*entries << "/"
00143 //     << weight;
00144 
00145   // Set total number of entries 
00146   if ( bin == 1 ) { prof->SetEntries( entries ); }
00147   else { prof->SetEntries( prof->GetEntries() + entries ); }
00148   
00149 }

void UpdateTProfile::setBinContents ( TProfile *const   profile,
const uint32_t &  bin,
const double &  num_of_entries,
const double &  sum_of_contents,
const double &  sum_of_squares 
) [static]

Definition at line 18 of file UpdateTProfile.cc.

References mean(), setBinContent(), and funct::sqrt().

00022                                                                     {
00023   //   cout << "[UpdateTProfile::setBinContents]" << endl;
00024   
00025   double mean = 0.;
00026   double spread = 0.;
00027   if ( num_of_entries ) { 
00028     mean = sum_of_contents / num_of_entries;
00029     spread = sqrt( sum_of_squares/ num_of_entries - mean * mean ); 
00030   }
00031    
00032 //   LogTrace("TEST")
00033 //     << "[UpdateTProfile::setBinContents]"
00034 //     << " bin: " << bin
00035 //     << " entries: " << num_of_entries
00036 //     << " contents: " << sum_of_contents
00037 //     << " squared: " << sum_of_squares
00038 //     << " mean: " << mean
00039 //     << " spread: " << spread;
00040   
00041   UpdateTProfile::setBinContent( prof, bin, num_of_entries, mean, spread );
00042   
00043 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:51 2009 for CMSSW by  doxygen 1.5.4