CMS 3D CMS Logo

Public Member Functions | Protected Attributes

MuonResidualsTwoBin Class Reference

#include <MuonResidualsTwoBin.h>

List of all members.

Public Member Functions

double antisym (int parNum)
void correctBField ()
void eraseNotSelectedResiduals ()
double errorerror (int parNum)
void fill (char charge, double *residual)
bool fit (Alignable *ali)
void fix (int parNum, bool value=true)
bool fixed (int parNum)
double loglikelihood ()
double mean (int which, double truncate)
double median (int which)
 MuonResidualsTwoBin (bool twoBin, MuonResidualsFitter *pos, MuonResidualsFitter *neg)
int ndata ()
int npar ()
long numResidualsNeg () const
long numResidualsPos () const
double numsegments ()
double plot (std::string name, TFileDirectory *dir, Alignable *ali)
void plotsimple (std::string name, TFileDirectory *dir, int which, double multiplier)
void plotweighted (std::string name, TFileDirectory *dir, int which, int whichredchi2, double multiplier)
void read (FILE *file, int which=0)
int residualsModel () const
std::vector< double * >
::const_iterator 
residualsNeg_begin () const
std::vector< double * >
::const_iterator 
residualsNeg_end () const
std::vector< bool >::const_iterator residualsNeg_ok_begin () const
std::vector< bool >::const_iterator residualsNeg_ok_end () const
std::vector< double * >
::const_iterator 
residualsPos_begin () const
std::vector< double * >
::const_iterator 
residualsPos_end () const
std::vector< bool >::const_iterator residualsPos_ok_begin () const
std::vector< bool >::const_iterator residualsPos_ok_end () const
void selectPeakResiduals (double nsigma, int nvar, int *vars)
void setPrintLevel (int printLevel) const
void setStrategy (int strategy) const
double stdev (int which, double truncate)
double sumofweights ()
int type () const
int useRes () const
double value (int parNum)
double wmean (int which, int whichredchi2, double truncate)
void write (FILE *file, int which=0)
 ~MuonResidualsTwoBin ()

Protected Attributes

MuonResidualsFitterm_neg
MuonResidualsFitterm_pos
bool m_twoBin

Detailed Description

Date:
2011/10/12 23:45:21
Revision:
1.11
Author:
J. Pivarski - Texas A&M University <pivarski@physics.tamu.edu>

Definition at line 15 of file MuonResidualsTwoBin.h.


Constructor & Destructor Documentation

MuonResidualsTwoBin::MuonResidualsTwoBin ( bool  twoBin,
MuonResidualsFitter pos,
MuonResidualsFitter neg 
) [inline]

Definition at line 17 of file MuonResidualsTwoBin.h.

: m_twoBin(twoBin), m_pos(pos), m_neg(neg) {};
MuonResidualsTwoBin::~MuonResidualsTwoBin ( ) [inline]

Definition at line 18 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, and NULL.

                         {
    if (m_pos != NULL) delete m_pos;
    if (m_neg != NULL) delete m_neg;
  };

Member Function Documentation

double MuonResidualsTwoBin::antisym ( int  parNum) [inline]

Definition at line 64 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::value().

                             {
    return (m_twoBin ? ((m_pos->value(parNum) - m_neg->value(parNum)) / 2.) : 0.);
  };
void MuonResidualsTwoBin::correctBField ( ) [inline]

Definition at line 237 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::correctBField(), and m_pos.

Referenced by MuonAlignmentFromReference::correctBField().

  {
    m_pos->correctBField();
    //if (m_twoBin) m_neg->correctBField();
  };
void MuonResidualsTwoBin::eraseNotSelectedResiduals ( ) [inline]
double MuonResidualsTwoBin::errorerror ( int  parNum) [inline]

Definition at line 61 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::errorerror(), m_neg, m_pos, m_twoBin, funct::pow(), and mathSSE::sqrt().

                                {
    return (m_twoBin ? (sqrt(pow(m_pos->errorerror(parNum), 2.) + pow(m_neg->errorerror(parNum), 2.)) / 2.) : m_pos->errorerror(parNum));
  };
void MuonResidualsTwoBin::fill ( char  charge,
double *  residual 
) [inline]

Definition at line 50 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::fill(), m_neg, m_pos, and m_twoBin.

                                           {
    if (!m_twoBin  ||  charge > 0) m_pos->fill(residual);
    else m_neg->fill(residual);
  };
bool MuonResidualsTwoBin::fit ( Alignable ali) [inline]

Definition at line 55 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::fit(), m_neg, m_pos, and m_twoBin.

                           {
    return (m_twoBin ? (m_pos->fit(ali)  &&  m_neg->fit(ali)) : m_pos->fit(ali));
  };
void MuonResidualsTwoBin::fix ( int  parNum,
bool  value = true 
) [inline]

Definition at line 31 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::fix(), m_neg, m_pos, and value().

                                        {
    m_pos->fix(parNum, value);
    m_neg->fix(parNum, value);
  };
bool MuonResidualsTwoBin::fixed ( int  parNum) [inline]

Definition at line 36 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::fixed(), m_neg, and m_pos.

                         {
    return m_pos->fixed(parNum)  &&  m_neg->fixed(parNum);
  };
double MuonResidualsTwoBin::loglikelihood ( ) [inline]

Definition at line 67 of file MuonResidualsTwoBin.h.

References MuonResidualsFitter::loglikelihood(), m_neg, m_pos, and m_twoBin.

double MuonResidualsTwoBin::mean ( int  which,
double  truncate 
) [inline]

Definition at line 127 of file MuonResidualsTwoBin.h.

References m_twoBin, n, alignCSCRings::r, residualsNeg_begin(), residualsNeg_end(), residualsPos_begin(), residualsPos_end(), and value().

                                          {
    double sum = 0.;
    double n = 0.;
    for (std::vector<double*>::const_iterator r = residualsPos_begin();  r != residualsPos_end();  ++r) {
      double value = (*r)[which];
      if (fabs(value) < truncate) {
        sum += value;
        n += 1.;
      }
    }
    if (m_twoBin) {
      for (std::vector<double*>::const_iterator r = residualsNeg_begin();  r != residualsNeg_end();  ++r) {
        double value = (*r)[which];
        if (fabs(value) < truncate) {
          sum += value;
          n += 1.;
        }
      }
    }
    return sum/n;
  };
double MuonResidualsTwoBin::median ( int  which) [inline]

Definition at line 112 of file MuonResidualsTwoBin.h.

References m_twoBin, alignCSCRings::r, residualsNeg_begin(), residualsNeg_end(), residualsPos_begin(), residualsPos_end(), and python::multivaluedict::sort().

                           {
    std::vector<double> residuals;
    for (std::vector<double*>::const_iterator r = residualsPos_begin();  r != residualsPos_end();  ++r) {
      residuals.push_back((*r)[which]);
    }
    if (m_twoBin) {
      for (std::vector<double*>::const_iterator r = residualsNeg_begin();  r != residualsNeg_end();  ++r) {
        residuals.push_back((*r)[which]);
      }
    }
    std::sort(residuals.begin(), residuals.end());
    int length = residuals.size();
    return residuals[length/2];
  };
int MuonResidualsTwoBin::ndata ( ) [inline]

Definition at line 27 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, and MuonResidualsFitter::ndata().

{ assert(m_pos->ndata() == m_neg->ndata());  return m_pos->ndata(); };
int MuonResidualsTwoBin::npar ( ) [inline]

Definition at line 26 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, and MuonResidualsFitter::npar().

{ assert(m_pos->npar() == m_neg->npar());  return m_pos->npar(); };
long MuonResidualsTwoBin::numResidualsNeg ( ) const [inline]

Definition at line 25 of file MuonResidualsTwoBin.h.

References m_neg, and MuonResidualsFitter::numResiduals().

{ return m_neg->numResiduals(); };
long MuonResidualsTwoBin::numResidualsPos ( ) const [inline]

Definition at line 24 of file MuonResidualsTwoBin.h.

References m_pos, and MuonResidualsFitter::numResiduals().

{ return m_pos->numResiduals(); };
double MuonResidualsTwoBin::numsegments ( ) [inline]

Definition at line 70 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::numsegments().

                       {
    return (m_twoBin ? (m_pos->numsegments() + m_neg->numsegments()) : m_pos->numsegments());
  };
double MuonResidualsTwoBin::plot ( std::string  name,
TFileDirectory dir,
Alignable ali 
) [inline]

Definition at line 78 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, convertSQLitetoXML_cfg::output, and MuonResidualsFitter::plot().

                                                                   {
    if (m_twoBin) {
      std::string namePos = name + std::string("Pos");
      std::string nameNeg = name + std::string("Neg");
      double output = 0.;
      output += m_pos->plot(namePos, dir, ali);
      output += m_neg->plot(nameNeg, dir, ali);
      return output;
    }
    else {
      return m_pos->plot(name, dir, ali);
    }
  };
void MuonResidualsTwoBin::plotsimple ( std::string  name,
TFileDirectory dir,
int  which,
double  multiplier 
) [inline]

Definition at line 202 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::plotsimple().

                                                                                     {
    if (m_twoBin) {
      std::string namePos = name + std::string("Pos");
      std::string nameNeg = name + std::string("Neg");
      m_pos->plotsimple(namePos, dir, which, multiplier);
      m_neg->plotsimple(nameNeg, dir, which, multiplier);
    }
    else {
      m_pos->plotsimple(name, dir, which, multiplier);
    }
  };
void MuonResidualsTwoBin::plotweighted ( std::string  name,
TFileDirectory dir,
int  which,
int  whichredchi2,
double  multiplier 
) [inline]

Definition at line 214 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::plotweighted().

                                                                                                         {
    if (m_twoBin) {
      std::string namePos = name + std::string("Pos");
      std::string nameNeg = name + std::string("Neg");
      m_pos->plotweighted(namePos, dir, which, whichredchi2, multiplier);
      m_neg->plotweighted(nameNeg, dir, which, whichredchi2, multiplier);
    }
    else {
      m_pos->plotweighted(name, dir, which, whichredchi2, multiplier);
    }
  };
void MuonResidualsTwoBin::read ( FILE *  file,
int  which = 0 
) [inline]

Definition at line 102 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::read().

Referenced by MuonAlignmentFromReference::readTmpFiles().

                                     {
    if (m_twoBin) {
      m_pos->read(file, 2*which);
      m_neg->read(file, 2*which + 1);
    }
    else {
      m_pos->read(file, which);
    }
  };
int MuonResidualsTwoBin::residualsModel ( ) const [inline]

Definition at line 23 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, and MuonResidualsFitter::residualsModel().

{ assert(m_pos->residualsModel() == m_neg->residualsModel());  return m_pos->residualsModel(); };
std::vector<double*>::const_iterator MuonResidualsTwoBin::residualsNeg_begin ( ) const [inline]

Definition at line 256 of file MuonResidualsTwoBin.h.

References m_neg, and MuonResidualsFitter::residuals_begin().

Referenced by mean(), median(), stdev(), and wmean().

{ return m_neg->residuals_begin(); };
std::vector<double*>::const_iterator MuonResidualsTwoBin::residualsNeg_end ( ) const [inline]

Definition at line 257 of file MuonResidualsTwoBin.h.

References m_neg, and MuonResidualsFitter::residuals_end().

Referenced by mean(), median(), stdev(), and wmean().

{ return m_neg->residuals_end(); };
std::vector<bool>::const_iterator MuonResidualsTwoBin::residualsNeg_ok_begin ( ) const [inline]

Definition at line 261 of file MuonResidualsTwoBin.h.

References m_neg, and MuonResidualsFitter::selectedResidualsFlags().

{ return m_neg->selectedResidualsFlags().begin(); };
std::vector<bool>::const_iterator MuonResidualsTwoBin::residualsNeg_ok_end ( ) const [inline]

Definition at line 262 of file MuonResidualsTwoBin.h.

References m_neg, and MuonResidualsFitter::selectedResidualsFlags().

{ return m_neg->selectedResidualsFlags().end(); };
std::vector<double*>::const_iterator MuonResidualsTwoBin::residualsPos_begin ( ) const [inline]
std::vector<double*>::const_iterator MuonResidualsTwoBin::residualsPos_end ( ) const [inline]
std::vector<bool>::const_iterator MuonResidualsTwoBin::residualsPos_ok_begin ( ) const [inline]
std::vector<bool>::const_iterator MuonResidualsTwoBin::residualsPos_ok_end ( ) const [inline]

Definition at line 260 of file MuonResidualsTwoBin.h.

References m_pos, and MuonResidualsFitter::selectedResidualsFlags().

{ return m_pos->selectedResidualsFlags().end(); };
void MuonResidualsTwoBin::selectPeakResiduals ( double  nsigma,
int  nvar,
int *  vars 
) [inline]

Definition at line 226 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::selectPeakResiduals().

Referenced by MuonAlignmentFromReference::selectResidualsPeaks().

  {
    if (m_twoBin) {
      m_pos->selectPeakResiduals(nsigma, nvar, vars);
      m_neg->selectPeakResiduals(nsigma, nvar, vars);
    }
    else {
      m_pos->selectPeakResiduals(nsigma, nvar, vars);
    }
  }
void MuonResidualsTwoBin::setPrintLevel ( int  printLevel) const [inline]

Definition at line 40 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, and MuonResidualsFitter::setPrintLevel().

                                           {
    m_pos->setPrintLevel(printLevel);
    m_neg->setPrintLevel(printLevel);
  }
void MuonResidualsTwoBin::setStrategy ( int  strategy) const [inline]

Definition at line 45 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, and MuonResidualsFitter::setStrategy().

                                       {
    m_pos->setStrategy(strategy);
    m_neg->setStrategy(strategy);
  }
double MuonResidualsTwoBin::stdev ( int  which,
double  truncate 
) [inline]

Definition at line 177 of file MuonResidualsTwoBin.h.

References m_twoBin, n, funct::pow(), alignCSCRings::r, residualsNeg_begin(), residualsNeg_end(), residualsPos_begin(), residualsPos_end(), mathSSE::sqrt(), and value().

                                           {
    double sum2 = 0.;
    double sum = 0.;
    double n = 0.;
    for (std::vector<double*>::const_iterator r = residualsPos_begin();  r != residualsPos_end();  ++r) {
      double value = (*r)[which];
      if (fabs(value) < truncate) {
        sum2 += value*value;
        sum += value;
        n += 1.;
      }
    }
    if (m_twoBin) {
      for (std::vector<double*>::const_iterator r = residualsNeg_begin();  r != residualsNeg_end();  ++r) {
        double value = (*r)[which];
        if (fabs(value) < truncate) {
          sum2 += value*value;
          sum += value;
          n += 1.;
        }
      }
    }
    return sqrt(sum2/n - pow(sum/n, 2));
  };
double MuonResidualsTwoBin::sumofweights ( ) [inline]

Definition at line 73 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::sumofweights().

                        {
    return (m_twoBin ? (m_pos->sumofweights() + m_neg->sumofweights()) : m_pos->sumofweights());
  };
int MuonResidualsTwoBin::type ( ) const [inline]
int MuonResidualsTwoBin::useRes ( ) const [inline]

Definition at line 29 of file MuonResidualsTwoBin.h.

References m_pos, and MuonResidualsFitter::useRes().

Referenced by MuonAlignmentFromReference::selectResidualsPeaks().

{ return m_pos->useRes(); };
double MuonResidualsTwoBin::value ( int  parNum) [inline]

Definition at line 58 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::value().

Referenced by fix(), mean(), stdev(), and wmean().

                           {
    return (m_twoBin ? ((m_pos->value(parNum) + m_neg->value(parNum)) / 2.) : m_pos->value(parNum));
  };
double MuonResidualsTwoBin::wmean ( int  which,
int  whichredchi2,
double  truncate 
) [inline]

Definition at line 149 of file MuonResidualsTwoBin.h.

References m_twoBin, n, alignCSCRings::r, residualsNeg_begin(), residualsNeg_end(), residualsPos_begin(), residualsPos_end(), value(), and CommonMethods::weight().

                                                             {
    double sum = 0.;
    double n = 0.;
    for (std::vector<double*>::const_iterator r = residualsPos_begin();  r != residualsPos_end();  ++r) {
      double value = (*r)[which];
      if (fabs(value) < truncate) {
        double weight = 1./(*r)[whichredchi2];
        if (TMath::Prob(1./weight*12, 12) < 0.99) {
          sum += weight*value;
          n += weight;
        }
      }
    }
    if (m_twoBin) {
      for (std::vector<double*>::const_iterator r = residualsNeg_begin();  r != residualsNeg_end();  ++r) {
        double value = (*r)[which];
        if (fabs(value) < truncate) {
          double weight = 1./(*r)[whichredchi2];
          if (TMath::Prob(1./weight*12, 12) < 0.99) {
            sum += weight*value;
            n += weight;
          }
        }
      }
    }
    return sum/n;
  };
void MuonResidualsTwoBin::write ( FILE *  file,
int  which = 0 
) [inline]

Definition at line 93 of file MuonResidualsTwoBin.h.

References m_neg, m_pos, m_twoBin, and MuonResidualsFitter::write().

Referenced by MuonAlignmentFromReference::writeTmpFiles().

                                      {
    if (m_twoBin) {
      m_pos->write(file, 2*which);
      m_neg->write(file, 2*which + 1);
    }
    else {
      m_pos->write(file, which);
    }
  };

Member Data Documentation