CMS 3D CMS Logo

TDistrib Class Reference

#include <CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TDistrib.h>

List of all members.

Public Member Functions

Double_t Covariance (TDistrib &)
Double_t * DeviationValues ()
Double_t ExpectationValue ()
void HistoDistrib (const Int_t &, Double_t &, Double_t &, Double_t *, Int_t &, Int_t &, Int_t &)
void Init ()
Int_t NumberOfEvents ()
TDistriboperator= (const TDistrib &)
Bool_t Refill (const Int_t &, const TVectorD)
Bool_t Resize (const Int_t &)
Double_t StandardDeviation (TString)
Double_t StandardDeviation ()
 TDistrib (const Int_t &, const TVectorD)
 TDistrib (const Int_t &, const Double_t *)
 TDistrib ()
Double_t * VariableValues ()
Double_t VarianceValue ()
virtual ~TDistrib ()

Private Member Functions

void fCopy (const TDistrib &)

Private Attributes

Int_t fCdelete
Int_t fCnew
Int_t fCodeErrMax
Int_t fMemoErrCovar
Int_t fMemoErrEv
Int_t fMemoErrSdev
Int_t fMemoErrVar
Int_t fNbEvents
Double_t * fValues


Detailed Description

Definition at line 34 of file TDistrib.h.


Constructor & Destructor Documentation

TDistrib::TDistrib (  ) 

TDistrib::TDistrib ( const Int_t &  nbv,
const Double_t *  val 
)

Definition at line 140 of file TDistrib.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fCnew, fNbEvents, fValues, i, and Init().

00141 {
00142 //constructors with arguments
00143 //Genuine initialization of a distribution from
00144 //a given positive number of events (nbv) and
00145 //from an array of values.
00146 // THE DIMENSION OF val MUST BE GREATER THAN OR EQUAL TO nbv 
00147 //
00148 
00149   Init();
00150 
00151   fNbEvents = nbv;
00152 
00153   if ( fNbEvents > 0 ) 
00154     {
00155       fValues =  new Double_t[fNbEvents];         fCnew++;
00156       
00157       //  cout << "*Constructor TDistrib::TDistrib(const Int_t&  nbv"
00158       //       << " , const  Double_t *val)*> " << endl
00159       //       << " allocation of " << fNbEvents
00160       //       << " 'Double_t' for array member at memory adress:"
00161       //       << " &fValues = " << &fValues << endl;
00162       
00163       for(Int_t i = 0 ; i < fNbEvents ; i++)
00164         {
00165           fValues[i] = val[i];
00166         }
00167     }
00168   else
00169     {
00170       cerr << endl
00171            << "*Constructor TDistrib::TDistrib(const Int_t&  nbv"
00172            << " , const  Double_t *val) *** ERROR ***> " << endl
00173            << " ------------------------------------------------"
00174            << "--------------------------------------" << endl
00175            << " You try to fill a distribution with"
00176            << " NULL or NEGATIVE number of events:" << endl
00177            << " fNbEvents = " << fNbEvents 
00178            << endl << endl;
00179       
00180       fValues = 0;    // Null pointer. No allocation
00181       
00182       cout << "*Constructor TDistrib::TDistrib(const Int_t&  nbv"
00183            << " , const  Double_t *val)> " << endl
00184            << "  no memory allocation for array member" << endl;
00185     }
00186 }

TDistrib::TDistrib ( const Int_t &  nbv,
const   TVectorD 
)

Definition at line 190 of file TDistrib.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fCnew, fNbEvents, fValues, i, and Init().

00191 {
00192 //constructors with arguments
00193 //Genuine initialization of a distribution from
00194 //a given positive number of events (nbv) and
00195 //from an array of values.
00196 // THE DIMENSION OF val MUST BE GREATER THAN OR EQUAL TO nbv 
00197 
00198   Init();
00199 
00200   fNbEvents = nbv;
00201 
00202   if ( fNbEvents > 0 ) 
00203     {
00204       fValues =  new Double_t[fNbEvents];         fCnew++;
00205       
00206       //  cout << "*Constructor TDistrib::TDistrib(const Int_t&  nbv"
00207       //       << " , const  Double_t *val)*> " << endl
00208       //       << " allocation of " << fNbEvents
00209       //       << " 'Double_t' for array member at memory adress:"
00210       //       << " &fValues = " << &fValues << endl;
00211       
00212       for(Int_t i = 0 ; i < fNbEvents ; i++)
00213         {
00214           fValues[i] = (Double_t)val(i);
00215         }
00216     }
00217   else
00218     {
00219       cerr << endl
00220            << "*Constructor TDistrib::TDistrib(const Int_t&  nbv"
00221            << " , const  TVectorD val) *** ERROR ***> " << endl
00222            << " ------------------------------------------------"
00223            << "--------------------------------------" << endl
00224            << " You try to fill a distribution with"
00225            << " NULL or NEGATIVE number of events:" << endl
00226            << " fNbEvents = " << fNbEvents 
00227            << endl << endl;
00228       
00229       fValues = 0;    // Null pointer. No allocation
00230       
00231       cout << "*Constructor TDistrib::TDistrib(const Int_t&  nbv"
00232            << " , const  TVectorD val)> " << endl
00233            << "  no memory allocation for array member" << endl;
00234     }
00235 }

TDistrib::~TDistrib (  )  [virtual]

Definition at line 243 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fCdelete, fCnew, fNbEvents, and fValues.

00244 {
00245 //destructor
00246 
00247   fNbEvents = 0;
00248   
00249   if ( fValues != 0)
00250     {
00251       // cout << "*Destructor TDistrib::~TDistrib()*> " << endl
00252       //      << " release memory for array member allocated at adress:"
00253       //      << " &fValues = " << &fValues
00254       //      << endl;
00255 
00256       delete [] fValues;      fCdelete++;      // release memory
00257     }
00258   else
00259     {
00260       // cout << "*Destructor TDistrib::~TDistrib()*> " << endl
00261       //      << " no release memory for array member"
00262       //      << " since no allocation was done (fValues = " << fValues
00263       //      << ") " << endl;            
00264     } 
00265 
00266   if ( fCnew != fCdelete )
00267     {
00268       cout << "*TDistrib> WRONG MANAGEMENT OF ALLOCATIONS: fCnew = "
00269            << fCnew << ", fCdelete = " << fCdelete << endl;
00270     }
00271   else
00272     {
00273       //  cout << "*TDistrib> BRAVO! GOOD MANAGEMENT OF ALLOCATIONS: fCnew = "
00274       //           << fCnew << ", fCdelete = " << fCdelete << endl;
00275     }
00276 
00277 }


Member Function Documentation

Double_t TDistrib::Covariance ( TDistrib X_j  ) 

Definition at line 622 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), ExpectationValue(), fCdelete, fCnew, fCodeErrMax, fMemoErrCovar, n, NumberOfEvents(), and VariableValues().

00623 {
00624 //Calculation and return of the covariance with another distribution
00625 
00626   Double_t  covar = (Double_t)0.;
00627   Int_t     n_i   = (*this).fNbEvents;
00628   Int_t     n_j   = X_j.NumberOfEvents();
00629 
00630   //..... determination of the lowest number of events
00631 
00632   Int_t      n_min = 0;
00633   if (n_i <= n_j){n_min = n_i;}
00634   if (n_i >  n_j){n_min = n_j;}
00635 
00636   //................. Calculation of the covariance
00637   if(n_min > 0)
00638     {
00639       Double_t *prod_ecarts = new Double_t[n_min];        fCnew++;
00640       
00641       Double_t* fValues_i = (*this).VariableValues();
00642       Double_t* fValues_j = X_j.VariableValues();
00643       
00644       Double_t  v_moy_i = (*this).ExpectationValue();      
00645       Double_t  v_moy_j = X_j.ExpectationValue();  
00646       
00647       for (Int_t n = 0 ; n < n_min ; n++)
00648         {
00649           prod_ecarts[n] = (fValues_i[n] - v_moy_i)*(fValues_j[n] - v_moy_j);
00650         }
00651       
00652       TDistrib  d_cov(n_min,  prod_ecarts);
00653       covar = d_cov.ExpectationValue();
00654 
00655       delete [] prod_ecarts;                              fCdelete++;
00656     }
00657   else
00658     {
00659       if ( fMemoErrCovar < fCodeErrMax )
00660         {
00661           cout << "*TDistrib::Covariance(TDistrib& X_j)> *** ERROR ***"
00662                << " Calculation of covariance with NON POSITIVE numbers of events"
00663                << " Distribution i: n_i = " << n_i << ", distribution j: n_j = " << n_j
00664                << '\007' << endl;
00665           fMemoErrCovar++;
00666         }
00667       
00668       if ( fMemoErrCovar == fCodeErrMax )
00669         {
00670           cout << "*TDistrib::Covariance(TDistrib& X_j)> This message has been issued "
00671                << fMemoErrCovar <<" times. It will be suppressed from now" << endl
00672                << "                               BUT THE PROBLEM WHICH CAUSES"
00673                << " THIS MESSAGE CAN STILL BE PRESENT." << endl;
00674           fMemoErrCovar++;
00675         }
00676     }
00677   return covar;
00678 } 

Double_t * TDistrib::DeviationValues (  ) 

Definition at line 448 of file TDistrib.cc.

References ExpectationValue(), fCdelete, fCnew, fNbEvents, fValues, and n.

00449 {
00450 //Calculation and return of the deviation values
00451 
00452   Int_t nmax = fNbEvents;
00453 
00454   Double_t  vmoy   = ExpectationValue();
00455 
00456   Double_t* ecarts = new Double_t[nmax];      fCnew++;
00457   
00458   for (Int_t n = 0 ; n < nmax ; n++)
00459     {
00460       ecarts[n] = fValues[n] - vmoy;
00461     }
00462   
00463   TDistrib  deviat( nmax, ecarts);
00464   
00465   delete [] ecarts;                                 fCdelete++;
00466   
00467   return deviat.fValues;
00468 }

Double_t TDistrib::ExpectationValue (  ) 

Definition at line 393 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fCodeErrMax, fMemoErrEv, fNbEvents, fValues, and n.

Referenced by TCnaRunEB::ComputeExpectationValuesOfCorrelationsBetweenSamples(), TCnaRunEB::ComputeExpectationValuesOfExpectationValuesOfSamples(), TCnaRunEB::ComputeExpectationValuesOfSigmasOfSamples(), Covariance(), DeviationValues(), and VarianceValue().

00394 {
00395 //Calculation and return of the expectation value for nmax events
00396 
00397   Int_t nmax = fNbEvents;
00398   
00399   Double_t vmoy = (Double_t)0.;
00400   
00401   for (Int_t n = 0 ; n < nmax ; n++)
00402     {
00403       //vmoy = vmoy + fValues[n];
00404       vmoy += fValues[n];
00405     }
00406 
00407   if(nmax > 0)
00408     {  
00409       vmoy = vmoy/(Double_t)nmax;
00410     }
00411   else
00412     {
00413       cout << "*TDistrib::ExpectationValue() *** ERROR ***> " << endl
00414            << " Calculation of expectation value for a Distribution"
00415            << endl << " with a non-positive number of events."
00416            << " nmax = " << nmax << endl;
00417       //      {Int_t cintoto; cin >> cintoto;}
00418     }
00419 
00420   if( !(vmoy >= 0 || vmoy < 0) )
00421     {
00422       if ( fMemoErrEv < fCodeErrMax )
00423         {
00424           cout << "*TDistrib::ExpectationValue() *** ERROR ***>"
00425                << " EXTRA expectation value! vmoy = "
00426                << vmoy << " *==> MAY BE SOMETHING WRONG IN MEMORY (?)..." 
00427                << '\007' << endl;
00428           fMemoErrEv++;
00429         }
00430       if ( fMemoErrEv == fCodeErrMax )
00431         {
00432           cout << "*TDistrib::ExpectationValue()> This message has been issued "
00433                << fMemoErrEv <<" times. It will be suppressed from now" << endl
00434                << "                               BUT THE PROBLEM WHICH CAUSES"
00435                << " THIS MESSAGE CAN STILL BE PRESENT." << endl;
00436           fMemoErrEv++;
00437         }
00438     }
00439   return vmoy;
00440 }

void TDistrib::fCopy ( const TDistrib dis  )  [private]

Definition at line 49 of file TDistrib.cc.

References fNbEvents, fValues, and i.

Referenced by operator=().

00050 {
00051 //private copy
00052 
00053   fNbEvents = dis.fNbEvents;
00054   
00055   for(Int_t i = 0 ; i < fNbEvents ; i++)
00056     {
00057       fValues[i] = dis.fValues[i];
00058     }  
00059 }

void TDistrib::HistoDistrib ( const Int_t &  nb_bins,
Double_t &  xmin,
Double_t &  xmax,
Double_t *  dist_histo,
Int_t &  range_null,
Int_t &  n_underflow,
Int_t &  n_overflow 
)

Definition at line 695 of file TDistrib.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), fNbEvents, and fValues.

00699 {
00700 //Histogram making of the distribution.
00701 //A small difference can be observed between the values
00702 //of the histogram X axis and the values of the variable
00703 //distribution (because of the binning).
00704 //The difference is given by:
00705 //
00706 // | mean(histogram) - mean(distribution) | = delta_X_for_1_bin/sqrt{12} 
00707 //
00708 //It is small if the number of bins is at least greater than 100
00709 
00710   Int_t nb_events = fNbEvents;
00711 
00712   if ( nb_events > 0 )
00713     {  
00714       //........... Search for xmin and xmax 
00715 
00716       xmin = fValues[0];
00717       xmax = fValues[0];
00718 
00719       for (Int_t i_evt = 0 ; i_evt < nb_events ; i_evt++)
00720         {
00721           if ( xmin >= fValues[i_evt] ){xmin = fValues[i_evt];}
00722           if ( xmax <= fValues[i_evt] ){xmax = fValues[i_evt];}
00723         }
00724 
00725       //.......................................... histo building
00726       
00727       Int_t i_bin;
00728       
00729       //..................... reset histo
00730       
00731       for (i_bin = 0 ; i_bin < nb_bins ; i_bin++)
00732         {
00733           dist_histo[i_bin] = (Double_t)0.;
00734         }
00735       
00736       //..................... binning a la ROOT
00737       
00738       Double_t range_x = xmax - xmin;
00739       range_null = 0;
00740       
00741       n_underflow = 0;
00742       n_overflow  = 0;
00743       
00744       if ( range_x > 0 )
00745         {
00746           for (Int_t i_evt = 0 ; i_evt < nb_events ; i_evt++)
00747             {
00748               // i_bin = (Int_t)( ( ( fValues[i_evt] - xmin )/range_x )*( (Double_t)(nb_bins - 1) ) );
00749               i_bin = (Int_t)( ( ( fValues[i_evt] - xmin )/range_x )*(Double_t)nb_bins);
00750               //i_bin = floor( ( ( fValues[i_evt] - xmin )/range_x )*(Double_t)(nb_bins-1)+(Double_t)(0.5) );
00751 
00752               if( i_bin < 0 )
00753                 {
00754                   i_bin = 0;
00755                   //n_underflow = n_underflow + 1;
00756                   n_underflow++;
00757                 }
00758 
00759               if( i_bin >= nb_bins )
00760                 {
00761                   i_bin = nb_bins - 1;
00762                   //n_overflow = n_overflow + 1;
00763                   n_overflow++;
00764                 }
00765               
00766               //dist_histo[i_bin] = dist_histo[i_bin] + (Double_t)1.;
00767               dist_histo[i_bin]++; 
00768             }
00769         }
00770       else
00771         {
00772           //range_null = range_null + 1;
00773           range_null++;
00774         }
00775     }
00776   else
00777     {
00778       cerr << "*TDistrib::HistoDistrib() *** ERROR ***> " << endl
00779            << " You are trying to make an histogram for a distribution"
00780            << endl << " with a non-positive number of events."
00781            << " nb_events = " << nb_events << '\007' << endl;
00782     }
00783 }

void TDistrib::Init ( void   ) 

Definition at line 285 of file TDistrib.cc.

References fCdelete, fCnew, fCodeErrMax, fMemoErrCovar, fMemoErrEv, fMemoErrSdev, and fMemoErrVar.

Referenced by TDistrib().

00286 {
00287 //Miscellaneous initializations
00288 
00289   //................... Init counters new/delete
00290   fCnew    = 0;
00291   fCdelete = 0;
00292   //................init memo error tags
00293 
00294   fCodeErrMax = 10;
00295 
00296   fMemoErrEv    = 0;
00297   fMemoErrVar   = 0;
00298   fMemoErrSdev  = 0;
00299   fMemoErrCovar = 0;
00300 }

Int_t TDistrib::NumberOfEvents (  ) 

Definition at line 369 of file TDistrib.cc.

References fNbEvents.

Referenced by Covariance().

00370 {
00371 //Return of the number of events
00372   return fNbEvents;
00373 }

TDistrib & TDistrib::operator= ( const TDistrib dis  ) 

Definition at line 105 of file TDistrib.cc.

References fCdelete, fCnew, fCopy(), fNbEvents, and fValues.

00106 {
00107 //overloading of the operator=
00108 
00109   if ( fValues != dis.fValues )
00110     {
00111       if (fNbEvents != dis.fNbEvents )
00112         {
00113           if ( fValues != 0 ) {delete [] fValues;  fCdelete++;}
00114           fNbEvents = dis.fNbEvents;
00115           fValues = new Double_t[fNbEvents];   fCnew++;     // allocation
00116           
00117           // cout << "*Overloading TDistrib::operator=(const TDistrib& dis)*> "
00118           //      << endl << " allocation of " << fNbEvents
00119           //      << " 'Double_t' for array member at memory adress:"
00120           //      << " &fValues = " << &fValues << endl;          
00121         }
00122       fCopy(dis);        // call to the private copy
00123     }
00124   return *this;
00125 }

Bool_t TDistrib::Refill ( const Int_t &  nmax,
const   TVectorD 
)

Definition at line 308 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fNbEvents, fValues, and i.

Referenced by TCnaRunEB::ComputeExpectationValuesOfCorrelationsBetweenSamples(), TCnaRunEB::ComputeExpectationValuesOfExpectationValuesOfSamples(), TCnaRunEB::ComputeExpectationValuesOfSigmasOfSamples(), TCnaRunEB::ComputeSigmasOfCorrelationsBetweenSamples(), TCnaRunEB::ComputeSigmasOfExpectationValuesOfSamples(), and TCnaRunEB::ComputeSigmasOfSigmasOfSamples().

00309 {
00310 //Refill: change the values
00311 
00312   Bool_t ok_refill = kFALSE;
00313 
00314   if (nmax == fNbEvents)
00315     {
00316       for(Int_t i = 0 ; i < fNbEvents ; i++)
00317         {
00318           fValues[i] = (Double_t)val(i);
00319         }
00320       ok_refill = kTRUE;
00321     }
00322   else
00323     {
00324       cout << "!TDistib::Refill(...)> nmax = " << nmax << ". Not equal to fNbEvents ( = "
00325            << fNbEvents << "). No Refill" << endl; 
00326     }
00327   return ok_refill;
00328 }

Bool_t TDistrib::Resize ( const Int_t &  nmax  ) 

Definition at line 343 of file TDistrib.cc.

References fNbEvents.

Referenced by TCnaRunEB::GetReadyToCompute().

00344 {  
00345 //Resize:change the number of events if lower than before
00346 
00347   Bool_t ok_resize = kFALSE;
00348 
00349   if( nmax > 0 && nmax < fNbEvents )
00350     {
00351       fNbEvents = nmax;
00352       ok_resize = kTRUE;
00353     }
00354   else
00355     {
00356       // if( nmax > fNbEvents ){cout << "!TDistib::Resize(...)> new nmax > old nmax. No Resize" << endl;}
00357       // if( nmax < 0         ){cout << "!TDistib::Resize(...)> new nmax < 0. No Resize" << endl;}
00358       // if( nmax == 0        ){cout << "!TDistib::Resize(...)> new nmax = 0. No Resize" << endl;}
00359     }
00360   return ok_resize;
00361 }

Double_t TDistrib::StandardDeviation ( TString  calling_prog  ) 

Definition at line 578 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and funct::sqrt().

00579 {
00580 //Calculation and return of the standard deviation
00581 //Return the argument in message in case of error
00582 
00583   Double_t sigma;
00584   Double_t var = (*this).VarianceValue();
00585   
00586   if( var >= (Double_t)0. )
00587     {
00588       sigma = sqrt(var);
00589     }
00590   else
00591     {
00592       if ( var < (Double_t)0. )
00593         {
00594           cout << "*TDistrib::StandardDeviation() *** ERROR ***>"
00595                << " detection of NEGATIVE variance! var = " << var
00596                << ", standard deviation value forced to -1" << endl
00597                << " The calling program has transmited the following TString argument: "
00598                << calling_prog << '\007' << endl;
00599           sigma = -1;
00600         }
00601       else
00602         {
00603           cout << "*TDistrib::StandardDeviation() *** ERROR ***>"
00604                << " detection of EXTRA variance! var = " << var
00605                << ", standard deviation value forced to -1" << endl
00606                << " The calling program has transmited the following TString argument: "
00607                << calling_prog << " *===> MAY BE SOMETHING WRONG IN MEMORY (?)..." 
00608                << '\007' << endl;
00609           sigma = -1;
00610         }
00611     }
00612   return sigma;
00613 }

Double_t TDistrib::StandardDeviation (  ) 

Definition at line 533 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fCodeErrMax, fMemoErrSdev, funct::sqrt(), and VarianceValue().

Referenced by TCnaRunEB::ComputeCorrelationsBetweenSamples(), TCnaRunEB::ComputeSigmasOfCorrelationsBetweenSamples(), TCnaRunEB::ComputeSigmasOfExpectationValuesOfSamples(), and TCnaRunEB::ComputeSigmasOfSigmasOfSamples().

00534 {
00535 //Calculation and return of the standard deviation
00536 
00537   Double_t sigma = (Double_t)0.;
00538   Double_t var = VarianceValue();
00539 
00540   if( var >= (Double_t)0. )
00541     {
00542       sigma = (Double_t)sqrt(var);
00543     }
00544   else
00545     {
00546       if( var < (Double_t)0.)
00547         {
00548           cout << "*TDistrib::StandardDeviation() *** ERROR ***>"
00549                << " detection of NEGATIVE variance! var = " << var
00550                << ", standard deviation value forced to -1"
00551                << '\007' << endl;
00552           sigma = -1;
00553         }
00554       else
00555         {
00556           if ( fMemoErrSdev < fCodeErrMax )
00557             {
00558               cout << "*TDistrib::StandardDeviation() *** ERROR ***>"
00559                    << " detection of EXTRA variance! var = " << var
00560                    << ", standard deviation value forced to -1" << endl
00561                    << " *===> MAY BE SOMETHING WRONG IN MEMORY (?)..." 
00562                    << '\007' << endl;
00563               sigma = -1;
00564               fMemoErrSdev++;
00565             }
00566           if ( fMemoErrSdev == fCodeErrMax )
00567             {
00568               cout << "*TDistrib::StandardDeviation()> This message has been issued "
00569                    << fMemoErrSdev <<" times. It will be suppressed from now" << endl
00570                    << "BUT THE PROBLEM WHICH CAUSES THIS MESSAGE CAN STILL BE PRESENT" << endl; 
00571               fMemoErrSdev++; 
00572             }
00573         }
00574     }
00575   return sigma;
00576 }

Double_t * TDistrib::VariableValues (  ) 

Definition at line 381 of file TDistrib.cc.

References fValues.

Referenced by Covariance().

00382 {
00383 //Return of the pointer to the values
00384   return fValues;
00385 }

Double_t TDistrib::VarianceValue (  ) 

Definition at line 476 of file TDistrib.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), ExpectationValue(), fCdelete, fCnew, fCodeErrMax, fMemoErrVar, fNbEvents, fValues, and n.

Referenced by TCnaRunEB::ComputeVariancesOfSamples(), and StandardDeviation().

00477 {
00478 //Calculation and return of the variance
00479 
00480   Int_t     nmax = fNbEvents;
00481   Double_t  vmoy = ExpectationValue();
00482   
00483   Double_t*   tab_squared_deviat = new Double_t[nmax];      fCnew++;
00484   
00485   for (Int_t n = 0 ; n < nmax ; n++)
00486     {
00487       Double_t deviat = fValues[n] - vmoy;
00488       tab_squared_deviat[n] = deviat*deviat;
00489     }
00490   
00491   TDistrib  sq_deviat( nmax, tab_squared_deviat);
00492    
00493   Double_t var = sq_deviat.ExpectationValue();
00494   
00495   if ( !(var >= 0) )
00496     {
00497       if ( var < 0 )
00498         {
00499           cout << "*TDistrib::VarianceValue() *** ERROR ***>"
00500                << " NEGATIVE result at variance calculation! var = "
00501                << var << '\007' << endl;
00502         }
00503       else
00504         {
00505           if ( fMemoErrVar < fCodeErrMax )
00506             {
00507               cout << "*TDistrib::VarianceValue() *** ERROR ***>"
00508                    << " EXTRA result at variance calculation! var = "
00509                    << var << "*===> MAY BE SOMETHING WRONG IN MEMORY (?)..." 
00510                    << '\007' << endl;
00511               fMemoErrVar++;
00512             }
00513           if ( fMemoErrVar == fCodeErrMax )
00514             {
00515               cout << "*TDistrib::VarianceValue()> This message has been issued "
00516                    << fMemoErrVar <<" times. It will be suppressed from now" << endl
00517                    << "BUT THE PROBLEM WHICH CAUSES THIS MESSAGE CAN STILL BE PRESENT" << endl;
00518               fMemoErrVar++;
00519             }
00520         }
00521     }
00522 
00523   delete [] tab_squared_deviat;                           fCdelete++;
00524   return var;
00525 }


Member Data Documentation

Int_t TDistrib::fCdelete [private]

Definition at line 41 of file TDistrib.h.

Referenced by Covariance(), DeviationValues(), Init(), operator=(), VarianceValue(), and ~TDistrib().

Int_t TDistrib::fCnew [private]

Definition at line 40 of file TDistrib.h.

Referenced by Covariance(), DeviationValues(), Init(), operator=(), TDistrib(), VarianceValue(), and ~TDistrib().

Int_t TDistrib::fCodeErrMax [private]

Definition at line 49 of file TDistrib.h.

Referenced by Covariance(), ExpectationValue(), Init(), StandardDeviation(), and VarianceValue().

Int_t TDistrib::fMemoErrCovar [private]

Definition at line 54 of file TDistrib.h.

Referenced by Covariance(), and Init().

Int_t TDistrib::fMemoErrEv [private]

Definition at line 51 of file TDistrib.h.

Referenced by ExpectationValue(), and Init().

Int_t TDistrib::fMemoErrSdev [private]

Definition at line 53 of file TDistrib.h.

Referenced by Init(), and StandardDeviation().

Int_t TDistrib::fMemoErrVar [private]

Definition at line 52 of file TDistrib.h.

Referenced by Init(), and VarianceValue().

Int_t TDistrib::fNbEvents [private]

Definition at line 43 of file TDistrib.h.

Referenced by DeviationValues(), ExpectationValue(), fCopy(), HistoDistrib(), NumberOfEvents(), operator=(), Refill(), Resize(), TDistrib(), VarianceValue(), and ~TDistrib().

Double_t* TDistrib::fValues [private]

Definition at line 44 of file TDistrib.h.

Referenced by DeviationValues(), ExpectationValue(), fCopy(), HistoDistrib(), operator=(), Refill(), TDistrib(), VariableValues(), VarianceValue(), and ~TDistrib().


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