CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
MuonResidualsFitter Class Referenceabstract

#include <MuonResidualsFitter.h>

Inheritance diagram for MuonResidualsFitter:
MuonResiduals1DOFFitter MuonResiduals5DOFFitter MuonResiduals6DOFFitter MuonResiduals6DOFrphiFitter MuonResidualsAngleFitter MuonResidualsBfieldAngleFitter MuonResidualsPositionFitter

Classes

struct  MuonAlignmentTreeRow
 

Public Types

enum  {
  kPureGaussian, kPowerLawTails, kROOTVoigt, kGaussPowerTails,
  kPureGaussian2D
}
 
enum  {
  k1DOF, k5DOF, k6DOF, k6DOFrphi,
  kPositionFitter, kAngleFitter, kAngleBfieldFitter
}
 
enum  {
  k1111, k1110, k1100, k1010,
  k0010, k1000, k0100
}
 

Public Member Functions

void computeHistogramRangeAndBinning (int which, int &nbins, double &a, double &b)
 
virtual void correctBField ()=0
 
virtual void correctBField (int idx_momentum, int idx_q)
 
TMatrixDSym correlationMatrix ()
 
double covarianceElement (int parNum1, int parNum2)
 
TMatrixDSym covarianceMatrix ()
 
void eraseNotSelectedResiduals ()
 
double errorerror (int parNum)
 
void fiducialCuts (double xMin=-80.0, double xMax=80.0, double yMin=-80.0, double yMax=80.0, bool fidcut1=false)
 
void fill (double *residual)
 
virtual bool fit (Alignable *ali)=0
 
void fix (int parNum, bool dofix=true)
 
bool fixed (int parNum)
 
void histogramChi2GaussianFit (int which, double &fit_mean, double &fit_sigma)
 
double loglikelihood ()
 
 MuonResidualsFitter (int residualsModel, int minHits, int useResiduals, bool weightAlignment=true)
 
virtual int ndata ()=0
 
int nfixed ()
 
virtual int npar ()=0
 
long numResiduals () const
 
long numsegments ()
 
int parNum2parIdx (int parNum)
 
virtual double plot (std::string name, TFileDirectory *dir, Alignable *ali)=0
 
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)
 
std::vector< double * >::const_iterator residuals_begin () const
 
std::vector< double * >::const_iterator residuals_end () const
 
int residualsModel () const
 
std::vector< bool > & selectedResidualsFlags ()
 
void selectPeakResiduals (double nsigma, int nvar, int *vars)
 
void selectPeakResiduals_simple (double nsigma, int nvar, int *vars)
 
void setInitialValue (int parNum, double value)
 
void setPrintLevel (int printLevel)
 
void setStrategy (int strategy)
 
virtual double sumofweights ()=0
 
virtual int type () const =0
 
int useRes (int pattern=-1)
 
double value (int parNum)
 
void write (FILE *file, int which=0)
 
virtual ~MuonResidualsFitter ()
 

Protected Member Functions

bool dofit (void(*fcn)(int &, double *, double &, double *, int), std::vector< int > &parNum, std::vector< std::string > &parName, std::vector< double > &start, std::vector< double > &step, std::vector< double > &low, std::vector< double > &high)
 
virtual void inform (TMinuit *tMinuit)=0
 
void initialize_table ()
 

Protected Attributes

double m_center [20]
 
TMatrixDSym m_cov
 
std::vector< double > m_error
 
std::vector< bool > m_fixed
 
double m_loglikelihood
 
int m_minHits
 
std::map< int, double > m_parNum2InitValue
 
std::map< int, int > m_parNum2parIdx
 
int m_printLevel
 
double m_radii [20]
 
std::vector< double * > m_residuals
 
std::vector< bool > m_residuals_ok
 
int m_residualsModel
 
int m_strategy
 
int m_useResiduals
 
std::vector< double > m_value
 
bool m_weightAlignment
 

Detailed Description

Date
2011/04/15 21:51:13
Revision
1.16
Author
J. Pivarski - Texas A&M University pivar.nosp@m.ski@.nosp@m.physi.nosp@m.cs.t.nosp@m.amu.e.nosp@m.du
Id
MuonResidualsFitter.h,v 1.16 2011/04/15 21:51:13 khotilov Exp

Definition at line 80 of file MuonResidualsFitter.h.

Member Enumeration Documentation

anonymous enum
anonymous enum
anonymous enum

Constructor & Destructor Documentation

MuonResidualsFitter::MuonResidualsFitter ( int  residualsModel,
int  minHits,
int  useResiduals,
bool  weightAlignment = true 
)

Definition at line 165 of file MuonResidualsFitter.cc.

References Exception, kGaussPowerTails, kPowerLawTails, kPureGaussian, kPureGaussian2D, kROOTVoigt, and m_residualsModel.

165  :
170 , m_printLevel(0)
171 , m_strategy(1)
172 , m_cov(1)
173 , m_loglikelihood(0.)
174 {
177  throw cms::Exception("MuonResidualsFitter") << "unrecognized residualsModel";
178 }
tuple weightAlignment
Definition: align_cfg.py:30
MuonResidualsFitter::~MuonResidualsFitter ( )
virtual

Definition at line 181 of file MuonResidualsFitter.cc.

References residuals_begin(), and residuals_end().

182 {
183  for (std::vector<double*>::const_iterator residual = residuals_begin(); residual != residuals_end(); ++residual) {
184  delete [] (*residual);
185  }
186 }
std::vector< double * >::const_iterator residuals_end() const
std::vector< double * >::const_iterator residuals_begin() const

Member Function Documentation

void MuonResidualsFitter::computeHistogramRangeAndBinning ( int  which,
int &  nbins,
double &  a,
double &  b 
)

Definition at line 520 of file MuonResidualsFitter.cc.

References gather_cfg::cout, data, mps_fire::i, createfilelist::int, m_residuals, gen::n, numResiduals(), funct::pow(), alignCSCRings::r, and eostools::which().

Referenced by histogramChi2GaussianFit().

521 {
522  // first, make a numeric array while discarding some crazy outliers
523  double *data = new double[numResiduals()];
524  int n = 0;
525  for (std::vector<double*>::const_iterator r = m_residuals.begin(); r != m_residuals.end(); r++)
526  if (fabs((*r)[which])<50.)
527  {
528  data[n] = (*r)[which];
529  n++;
530  }
531 
532  // compute "3 normal sigma" and regular interquantile ranges
533  const int n_quantiles = 7;
534  double probabilities[n_quantiles] = {0.00135, 0.02275, 0.25, 0.5, 0.75, 0.97725, 0.99865}; // "3 normal sigma"
535  //double probabilities[n_quantiles] = {0.02275, 0.25, 0.75, 0.97725}; // "2 normal sigma"
536  double quantiles[n_quantiles];
537  std::sort(data, data + n);
538  TMath::Quantiles(n, n_quantiles, data, quantiles, probabilities, true, nullptr, 7);
539  delete [] data;
540  double iqr = quantiles[4] - quantiles[2];
541 
542  // estimate optimal bin size according to Freedman-Diaconis rule
543  double hbin = 2 * iqr / pow( n, 1./3);
544 
545  a = quantiles[1];
546  b = quantiles[5];
547  nbins = (int) ( (b - a) / hbin + 3. ); // add extra safety margin of 3
548 
549  std::cout<<" quantiles: "; for (int i=0;i<n_quantiles;i++) std::cout<<quantiles[i]<<" "; std::cout<<std::endl;
550  //cout<<"n="<<select_count<<" quantiles ["<<quantiles[1]<<", "<<quantiles[2]<<"] IQR="<<iqr
551  // <<" full range=["<<minx<<","<<maxx<<"]"<<" 2 normal sigma quantile range = ["<<quantiles[0]<<", "<<quantiles[3]<<"]"<<endl;
552  std::cout<<" optimal h="<<hbin<<" nbins="<<nbins<<std::endl;
553 }
std::vector< double * > m_residuals
double b
Definition: hdecay.h:120
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double a
Definition: hdecay.h:121
def which(cmd)
Definition: eostools.py:335
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual void MuonResidualsFitter::correctBField ( )
pure virtual
void MuonResidualsFitter::correctBField ( int  idx_momentum,
int  idx_q 
)
virtual

Definition at line 810 of file MuonResidualsFitter.cc.

References stringResolutionProvider_cfi::bin, KineDebug3::count(), gather_cfg::cout, MillePedeFileConverter_cfg::e, mps_fire::i, createfilelist::int, m_residuals, m_residuals_ok, cosmictrackSelector_cfi::min_pt, EnergyCorrector::pt, alignCSCRings::r, residuals_begin(), residuals_end(), and findQualityFiles::size.

811 {
812  const int Nbin = 17;
813  // find max 1/pt and bin width
814  double min_pt = 9999.;
815  for (std::vector<double*>::const_iterator r = residuals_begin(); r != residuals_end(); ++r)
816  {
817  double pt = fabs((*r)[idx_momentum]);
818  if (pt < min_pt) min_pt = pt;
819  }
820  min_pt -= 0.01; // to prevent bin # overflow
821  const double bin_width = 1./min_pt/Nbin;
822 
823  // fill indices of positive and negative charge residuals in each bin
824  std::vector<size_t> pos[Nbin], neg[Nbin], to_erase;
825  for (size_t i = 0; i < m_residuals.size(); i++)
826  {
827  if (!m_residuals_ok[i]) continue;
828  int bin = (int)floor(1./fabs(m_residuals[i][idx_momentum])/bin_width);
829  if (m_residuals[i][idx_q] > 0) pos[bin].push_back(i);
830  else neg[bin].push_back(i);
831  }
832 
833  // equalize pos and neg in each bin
834  for (int j = 0; j < Nbin; j++)
835  {
836  size_t psize = pos[j].size();
837  size_t nsize = neg[j].size();
838  if (psize == nsize) continue;
839 
840  std::set<int> idx_set; // use a set to collect certain number of unique random indices to erase
841  if (psize > nsize)
842  {
843  while (idx_set.size() < psize - nsize) idx_set.insert( gRandom->Integer(psize) );
844  for (std::set<int>::iterator it = idx_set.begin() ; it != idx_set.end(); it++ ) to_erase.push_back(pos[j][*it]);
845  }
846  else
847  {
848  while (idx_set.size() < nsize - psize) idx_set.insert( gRandom->Integer(nsize) );
849  for (std::set<int>::iterator it = idx_set.begin() ; it != idx_set.end(); it++ ) to_erase.push_back(neg[j][*it]);
850  }
851  }
852  // sort in descending order, so we safely go from higher to lower indices:
853  std::sort(to_erase.begin(), to_erase.end(), std::greater<int>() );
854  for (std::vector<size_t>::const_iterator e = to_erase.begin(); e != to_erase.end(); ++e)
855  {
856  m_residuals_ok[*e] = false;
857  //delete[] *(m_residuals.begin() + *e);
858  //m_residuals.erase(m_residuals.begin() + *e);
859  }
860 
861  std::vector<size_t> apos[Nbin], aneg[Nbin];
862  for (size_t i = 0; i < m_residuals.size(); i++)
863  {
864  if (!m_residuals_ok[i]) continue;
865  int bin = (int)floor(1./fabs(m_residuals[i][idx_momentum])/bin_width);
866  if (m_residuals[i][idx_q] > 0) apos[bin].push_back(i);
867  else aneg[bin].push_back(i);
868  }
869  for (int j = 0; j < Nbin; j++) std::cout << "bin " << j << ": [pos,neg] sizes before & after: ["
870  << pos[j].size() <<","<< neg[j].size()<<"] -> [" << apos[j].size() <<","<< aneg[j].size() << "]" << std::endl;
871  std::cout<<" N residuals "<<m_residuals.size()<<" -> "<<(size_t) std::count(m_residuals_ok.begin(), m_residuals_ok.end(), true)<<std::endl;
872 }
size
Write out results.
std::vector< double * > m_residuals
std::vector< bool > m_residuals_ok
bin
set the eta bin as selection string.
std::vector< double * >::const_iterator residuals_end() const
std::vector< double * >::const_iterator residuals_begin() const
TMatrixDSym MuonResidualsFitter::correlationMatrix ( )
double MuonResidualsFitter::covarianceElement ( int  parNum1,
int  parNum2 
)

Definition at line 212 of file MuonResidualsFitter.cc.

References m_cov, npar(), and parNum2parIdx().

213 {
214  assert(0 <= parNum1 && parNum1 < npar());
215  assert(0 <= parNum2 && parNum2 < npar());
216  assert(m_cov.GetNcols() == npar()); // m_cov might have not yet been resized to account for proper #parameters
217  return m_cov(parNum2parIdx(parNum1), parNum2parIdx(parNum2));
218 }
int parNum2parIdx(int parNum)
virtual int npar()=0
TMatrixDSym MuonResidualsFitter::covarianceMatrix ( )
inline

Definition at line 168 of file MuonResidualsFitter.h.

168 {return m_cov;}
bool MuonResidualsFitter::dofit ( void(*)(int &, double *, double &, double *, int)  fcn,
std::vector< int > &  parNum,
std::vector< std::string > &  parName,
std::vector< double > &  start,
std::vector< double > &  step,
std::vector< double > &  low,
std::vector< double > &  high 
)
protected

Definition at line 301 of file MuonResidualsFitter.cc.

References MillePedeFileConverter_cfg::e, fcn(), fixed(), mps_fire::i, inform(), m_cov, m_error, m_loglikelihood, m_strategy, m_value, MuonResidualsFitter_TMinuit, npar(), and findQualityFiles::v.

Referenced by MuonResiduals1DOFFitter::fit(), MuonResidualsAngleFitter::fit(), MuonResidualsBfieldAngleFitter::fit(), MuonResidualsPositionFitter::fit(), MuonResiduals5DOFFitter::fit(), MuonResiduals6DOFrphiFitter::fit(), and MuonResiduals6DOFFitter::fit().

303 {
305 
306  MuonResidualsFitter_TMinuit = new TMinuit(npar());
307  // MuonResidualsFitter_TMinuit->SetPrintLevel(m_printLevel);
308  MuonResidualsFitter_TMinuit->SetPrintLevel();
309  MuonResidualsFitter_TMinuit->SetObjectFit(fitinfo);
312 
313  std::vector<int>::const_iterator iNum = parNum.begin();
314  std::vector<std::string>::const_iterator iName = parName.begin();
315  std::vector<double>::const_iterator istart = start.begin();
316  std::vector<double>::const_iterator istep = step.begin();
317  std::vector<double>::const_iterator ilow = low.begin();
318  std::vector<double>::const_iterator ihigh = high.begin();
319 
320  //MuonResidualsFitter_TMinuit->SetPrintLevel(-1);
321 
322  for (; iNum != parNum.end(); ++iNum, ++iName, ++istart, ++istep, ++ilow, ++ihigh)
323  {
324  MuonResidualsFitter_TMinuit->DefineParameter(*iNum, iName->c_str(), *istart, *istep, *ilow, *ihigh);
325  if (fixed(*iNum)) MuonResidualsFitter_TMinuit->FixParameter(*iNum);
326  }
327 
328  double arglist[10];
329  int ierflg;
330  int smierflg; //second MIGRAD ierflg
331 
332  // chi^2 errors should be 1.0, log-likelihood should be 0.5
333  for (int i = 0; i < 10; i++) arglist[i] = 0.;
334  arglist[0] = 0.5;
335  ierflg = 0;
336  smierflg = 0;
337  MuonResidualsFitter_TMinuit->mnexcm("SET ERR", arglist, 1, ierflg);
338  if (ierflg != 0) { delete MuonResidualsFitter_TMinuit; delete fitinfo; return false; }
339 
340  // set strategy = 2 (more refined fits)
341  for (int i = 0; i < 10; i++) arglist[i] = 0.;
342  arglist[0] = m_strategy;
343  ierflg = 0;
344  MuonResidualsFitter_TMinuit->mnexcm("SET STR", arglist, 1, ierflg);
345  if (ierflg != 0) { delete MuonResidualsFitter_TMinuit; delete fitinfo; return false; }
346 
347  bool try_again = false;
348 
349  // minimize
350  for (int i = 0; i < 10; i++) arglist[i] = 0.;
351  arglist[0] = 50000;
352  ierflg = 0;
353  MuonResidualsFitter_TMinuit->mnexcm("MIGRAD", arglist, 1, ierflg);
354  if (ierflg != 0) try_again = true;
355 
356  // just once more, if needed (using the final Minuit parameters from the failed fit; often works)
357  if (try_again)
358  {
359  for (int i = 0; i < 10; i++) arglist[i] = 0.;
360  arglist[0] = 50000;
361  MuonResidualsFitter_TMinuit->mnexcm("MIGRAD", arglist, 1, smierflg);
362  }
363 
364  Double_t fmin, fedm, errdef;
365  Int_t npari, nparx, istat;
366  MuonResidualsFitter_TMinuit->mnstat(fmin, fedm, errdef, npari, nparx, istat);
367 
368  if (istat != 3)
369  {
370  for (int i = 0; i < 10; i++) arglist[i] = 0.;
371  ierflg = 0;
372  MuonResidualsFitter_TMinuit->mnexcm("HESSE", arglist, 0, ierflg);
373  }
374 
375  // read-out the results
376  m_loglikelihood = -fmin;
377 
378  m_value.clear();
379  m_error.clear();
380  for (int i = 0; i < npar(); i++)
381  {
382  double v, e;
383  MuonResidualsFitter_TMinuit->GetParameter(i, v, e);
384  m_value.push_back(v);
385  m_error.push_back(e);
386  }
387  m_cov.ResizeTo(npar(),npar());
388  MuonResidualsFitter_TMinuit->mnemat( m_cov.GetMatrixArray(), npar());
389 
391  delete fitinfo;
392  if (smierflg != 0) return false;
393  return true;
394 }
Definition: start.py:1
virtual void inform(TMinuit *tMinuit)=0
virtual int npar()=0
std::vector< double > m_error
std::vector< double > m_value
static TMinuit * MuonResidualsFitter_TMinuit
void fcn(int &, double *, double &, double *, int)
step
void MuonResidualsFitter::eraseNotSelectedResiduals ( )

Definition at line 875 of file MuonResidualsFitter.cc.

References KineDebug3::count(), gather_cfg::cout, mps_fire::i, m_residuals, m_residuals_ok, and tmp.

Referenced by MuonResidualsTwoBin::eraseNotSelectedResiduals().

876 {
877  // it should probably be faster then doing erase
878  size_t n_ok = (size_t) std::count(m_residuals_ok.begin(), m_residuals_ok.end(), true);
879  std::vector<double*> tmp(n_ok, nullptr);
880  std::cout << "residuals sizes: all=" << m_residuals.size()<<" good="<<n_ok<<std::endl;
881  int iok=0;
882  for (size_t i = 0; i < m_residuals.size(); i++)
883  {
884  if (!m_residuals_ok[i]) continue;
885  tmp[iok++] = m_residuals[i];
886  }
887  m_residuals.swap(tmp);
888 
889  std::vector<bool> tmp_ok(n_ok, true);
890  m_residuals_ok.swap(tmp_ok);
891 
892  std::cout << "residuals size after eraseNotSelectedResiduals =" << m_residuals.size()<<" ok size="<<m_residuals_ok.size()<<std::endl;
893 }
std::vector< double * > m_residuals
std::vector< bool > m_residuals_ok
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double MuonResidualsFitter::errorerror ( int  parNum)
inline

Definition at line 162 of file MuonResidualsFitter.h.

Referenced by MuonResidualsTwoBin::errorerror(), MuonResiduals5DOFFitter::plot(), MuonResiduals6DOFrphiFitter::plot(), and MuonResiduals6DOFFitter::plot().

162 { assert(0 <= parNum && parNum < npar()); return m_error[parNum]; }
virtual int npar()=0
std::vector< double > m_error
void MuonResidualsFitter::fiducialCuts ( double  xMin = -80.0,
double  xMax = 80.0,
double  yMin = -80.0,
double  yMax = 80.0,
bool  fidcut1 = false 
)

Definition at line 728 of file MuonResidualsFitter.cc.

References m_residuals_ok, alignCSCRings::r, residuals_begin(), and residuals_end().

Referenced by MuonResidualsTwoBin::fiducialCuts().

728  {
729 
730  int iResidual = -1;
731 
732  int n_station=9999;
733  int n_wheel=9999;
734  int n_sector=9999;
735 
736  double positionX=9999.;
737  double positionY=9999.;
738 
739  double chambw=9999.;
740  double chambl=9999.;
741 
742  for (std::vector<double*>::const_iterator r = residuals_begin(); r != residuals_end(); ++r) {
743  iResidual++;
744  if (!m_residuals_ok[iResidual]) continue;
745 
746  if( (*r)[15]>0.0001 ) { // this value is greater than zero (chamber width) for 6DOFs stations 1,2,3 better to change for type()!!!
747  n_station = (*r)[12];
748  n_wheel = (*r)[13];
749  n_sector = (*r)[14];
750  positionX = (*r)[4];
751  positionY = (*r)[5];
752  chambw = (*r)[15];
753  chambl = (*r)[16];
754  }
755  else{ // in case of 5DOF residual the residual object index is different
756  n_station = (*r)[10];
757  n_wheel = (*r)[11];
758  n_sector = (*r)[12];
759  positionX = (*r)[2];
760  positionY = (*r)[3];
761  chambw = (*r)[13];
762  chambl = (*r)[14];
763  }
764 
765 
766  if(fidcut1){ // this is the standard fiducial cut used so far 80x80 cm in x,y
767  if (positionX >= xMax || positionX <= xMin) m_residuals_ok[iResidual] = false;
768  if (positionY >= yMax || positionY <= yMin) m_residuals_ok[iResidual] = false;
769  }
770 
771  // Implementation of new fiducial cut
772 
773  double dtrkchamx = (chambw/2.) - positionX; // variables to cut tracks on the edge of the chambers
774  double dtrkchamy = (chambl/2.) - positionY;
775 
776  if(!fidcut1){
777 
778 
779  if(n_station==4){
780  if( (n_wheel==-1 && n_sector==3) || (n_wheel==1 && n_sector==4)){ // FOR SHORT CHAMBER LENGTH IN: WHEEL 1 SECTOR 4 AND WHEEL -1 SECTOR 3
781  if( (n_sector==1 || n_sector==2 || n_sector==3 || n_sector==5 || n_sector==6 || n_sector==7 || n_sector==8 || n_sector==12) && ( (dtrkchamx<40 || dtrkchamx>380) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
782  if( (n_sector==4 || n_sector==13) && ( (dtrkchamx<40 || dtrkchamx>280) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
783  if( (n_sector==9 || n_sector==11) && ( (dtrkchamx<40 || dtrkchamx>180) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
784  if( (n_sector==10 || n_sector==14) && ( (dtrkchamx<40 || dtrkchamx>220) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
785  }
786  else{
787  if( (n_sector==1 || n_sector==2 || n_sector==3 || n_sector==5 || n_sector==6 || n_sector==7 || n_sector==8 || n_sector==12) && ( (dtrkchamx<40 || dtrkchamx>380) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
788  if( (n_sector==4 || n_sector==13) && ( (dtrkchamx<40 || dtrkchamx>280) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
789  if( (n_sector==9 || n_sector==11) && ( (dtrkchamx<40 || dtrkchamx>180) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
790  if( (n_sector==10 || n_sector==14) && ( (dtrkchamx<40 || dtrkchamx>220) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
791  }
792  }
793  else{
794  if( (n_wheel==-1 && n_sector==3) || (n_wheel==1 && n_sector==4)){
795  if(n_station==1 && ( (dtrkchamx<30.0 || dtrkchamx>190.0) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
796  if(n_station==2 && ( (dtrkchamx<30.0 || dtrkchamx>240.0) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
797  if(n_station==3 && ( (dtrkchamx<30.0 || dtrkchamx>280.0) || (dtrkchamy<40.0 || dtrkchamy>170.0)) ) m_residuals_ok[iResidual] = false;
798  }
799  else{
800  if(n_station==1 && ( (dtrkchamx<30.0 || dtrkchamx>190.0) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
801  if(n_station==2 && ( (dtrkchamx<30.0 || dtrkchamx>240.0) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
802  if(n_station==3 && ( (dtrkchamx<30.0 || dtrkchamx>280.0) || (dtrkchamy<40.0 || dtrkchamy>210.0)) ) m_residuals_ok[iResidual] = false;
803  }
804  }
805  }
806  }
807 }
std::vector< bool > m_residuals_ok
std::vector< double * >::const_iterator residuals_end() const
std::vector< double * >::const_iterator residuals_begin() const
void MuonResidualsFitter::fill ( double *  residual)

Definition at line 205 of file MuonResidualsFitter.cc.

References m_residuals, and m_residuals_ok.

Referenced by MuonResidualsTwoBin::fill(), read(), MuonResiduals5DOFFitter::readNtuple(), MuonResiduals6DOFrphiFitter::readNtuple(), and MuonResiduals6DOFFitter::readNtuple().

206 {
207  m_residuals.push_back(residual);
208  m_residuals_ok.push_back(true);
209 }
std::vector< double * > m_residuals
std::vector< bool > m_residuals_ok
virtual bool MuonResidualsFitter::fit ( Alignable ali)
pure virtual
void MuonResidualsFitter::fix ( int  parNum,
bool  dofix = true 
)

Definition at line 189 of file MuonResidualsFitter.cc.

References m_fixed, and npar().

Referenced by MuonResiduals5DOFFitter::fit(), MuonResiduals6DOFrphiFitter::fit(), MuonResiduals6DOFFitter::fit(), and MuonResidualsTwoBin::fix().

190 {
191  assert(0 <= parNum && parNum < npar());
192  if (m_fixed.empty()) m_fixed.resize(npar(), false);
193  m_fixed[parNum] = dofix;
194 }
virtual int npar()=0
std::vector< bool > m_fixed
bool MuonResidualsFitter::fixed ( int  parNum)

Definition at line 197 of file MuonResidualsFitter.cc.

References m_fixed, and npar().

Referenced by dofit(), MuonResiduals1DOFFitter::fit(), and MuonResidualsTwoBin::fixed().

198 {
199  assert(0 <= parNum && parNum < npar());
200  if (m_fixed.empty()) return false;
201  else return m_fixed[parNum];
202 }
virtual int npar()=0
std::vector< bool > m_fixed
void MuonResidualsFitter::histogramChi2GaussianFit ( int  which,
double &  fit_mean,
double &  fit_sigma 
)

Definition at line 556 of file MuonResidualsFitter.cc.

References a, b, computeHistogramRangeAndBinning(), gather_cfg::cout, connectstrParser::f1, create_public_lumi_plots::hist, m_residuals, pileupCalc::nbins, and alignCSCRings::r.

Referenced by selectPeakResiduals().

557 {
558  int nbins;
559  double a, b;
560  computeHistogramRangeAndBinning(which, nbins, a, b);
561  if (a==b || a > b) { fit_mean = a; fit_sigma = 0; return; }
562 
563  TH1D *hist = new TH1D("htmp", "", nbins, a, b);
564  for (std::vector<double*>::const_iterator r = m_residuals.begin(); r != m_residuals.end(); ++r) hist->Fill( (*r)[which] );
565 
566  // do simple chi2 gaussian fit
567  TF1 *f1= new TF1("f1","gaus", a, b);
568  f1->SetParameter(0, hist->GetEntries());
569  f1->SetParameter(1, 0);
570  f1->SetParameter(2, hist->GetRMS());
571  hist->Fit("f1","RQ");
572  // hist->Fit(f1,"RQ");
573 
574  fit_mean = f1->GetParameter(1);
575  fit_sigma = f1->GetParameter(2);
576  std::cout<<" h("<<nbins<<","<<a<<","<<b<<") mu="<<fit_mean<<" sig="<<fit_sigma<<std::endl;
577 
578  delete f1;
579  delete hist;
580 }
void computeHistogramRangeAndBinning(int which, int &nbins, double &a, double &b)
std::vector< double * > m_residuals
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
def which(cmd)
Definition: eostools.py:335
virtual void MuonResidualsFitter::inform ( TMinuit *  tMinuit)
protectedpure virtual
void MuonResidualsFitter::initialize_table ( )
protected

Definition at line 230 of file MuonResidualsFitter.cc.

References gather_cfg::cout, Exception, kPowerLawTails, MuonResidualsFitter_compute_log_convolution(), MuonResidualsFitter_gsbinsize, MuonResidualsFitter_lookup_table, MuonResidualsFitter_numgsbins, MuonResidualsFitter_numtsbins, MuonResidualsFitter_table_initialized, MuonResidualsFitter_tsbinsize, residualsModel(), and heppy_batch::val.

Referenced by MuonResiduals1DOFFitter::fit(), MuonResidualsAngleFitter::fit(), MuonResidualsBfieldAngleFitter::fit(), MuonResidualsPositionFitter::fit(), MuonResiduals5DOFFitter::fit(), MuonResiduals6DOFrphiFitter::fit(), and MuonResiduals6DOFFitter::fit().

231 {
234 
235  std::ifstream convolution_table("convolution_table.txt");
236  if (convolution_table.is_open())
237  {
238  int numgsbins = 0;
239  int numtsbins = 0;
240  double tsbinsize = 0.;
241  double gsbinsize = 0.;
242 
243  convolution_table >> numgsbins >> numtsbins >> tsbinsize >> gsbinsize;
244  if (numgsbins != MuonResidualsFitter_numgsbins || numtsbins != MuonResidualsFitter_numtsbins ||
246  {
247  throw cms::Exception("MuonResidualsFitter") << "convolution_table.txt has the wrong bin width/bin size. Throw it away and let the fitter re-create the file.\n";
248  }
249 
250  for (int gsbin = 0; gsbin < MuonResidualsFitter_numgsbins; gsbin++)
251  {
252  for (int tsbin = 0; tsbin < MuonResidualsFitter_numtsbins; tsbin++)
253  {
254  int read_gsbin = 0;
255  int read_tsbin = 0;
256  double val = 0.;
257 
258  convolution_table >> read_gsbin >> read_tsbin >> val;
259  if (read_gsbin != gsbin || read_tsbin != tsbin)
260  {
261  throw cms::Exception("MuonResidualsFitter") << "convolution_table.txt is out of order. Throw it away and let the fitter re-create the file.\n";
262  }
263  MuonResidualsFitter_lookup_table[gsbin][tsbin] = val;
264  }
265  }
266  convolution_table.close();
267  }
268  else
269  {
270  std::ofstream convolution_table2("convolution_table.txt");
271 
272  if (!convolution_table2.is_open()) throw cms::Exception("MuonResidualsFitter") << "Couldn't write to file convolution_table.txt\n";
273 
274  convolution_table2 << MuonResidualsFitter_numgsbins << " " << MuonResidualsFitter_numtsbins << " " << MuonResidualsFitter_tsbinsize << " " << MuonResidualsFitter_gsbinsize << std::endl;
275 
276  std::cout << "Initializing convolution look-up table (takes a few minutes)..." << std::endl;
277 
278  for (int gsbin = 0; gsbin < MuonResidualsFitter_numgsbins; gsbin++)
279  {
280  double gammaoversigma = double(gsbin) * MuonResidualsFitter_gsbinsize;
281  std::cout << " gsbin " << gsbin << "/" << MuonResidualsFitter_numgsbins << std::endl;
282  for (int tsbin = 0; tsbin < MuonResidualsFitter_numtsbins; tsbin++)
283  {
284  double toversigma = double(tsbin) * MuonResidualsFitter_tsbinsize;
285 
286  // 1e-6 errors (out of a value of ~0.01) with max=100, step=0.001, power=4 (max=1000 does a little better with the tails)
287  MuonResidualsFitter_lookup_table[gsbin][tsbin] = MuonResidualsFitter_compute_log_convolution(toversigma, gammaoversigma);
288 
289  // <10% errors with max=20, step=0.005, power=4 (faster computation for testing)
290  // MuonResidualsFitter_lookup_table[gsbin][tsbin] = MuonResidualsFitter_compute_log_convolution(toversigma, gammaoversigma, 100., 0.005, 4.);
291 
292  convolution_table2 << gsbin << " " << tsbin << " " << MuonResidualsFitter_lookup_table[gsbin][tsbin] << std::endl;
293  }
294  }
295  convolution_table2.close();
296  std::cout << "Initialization done!" << std::endl;
297  }
298 }
const int MuonResidualsFitter_numgsbins
const int MuonResidualsFitter_numtsbins
const double MuonResidualsFitter_gsbinsize
const double MuonResidualsFitter_tsbinsize
double MuonResidualsFitter_compute_log_convolution(double toversigma, double gammaoversigma, double max, double step, double power)
bool MuonResidualsFitter_table_initialized
double MuonResidualsFitter_lookup_table[MuonResidualsFitter_numgsbins][MuonResidualsFitter_numtsbins]
double MuonResidualsFitter::loglikelihood ( )
inline
virtual int MuonResidualsFitter::ndata ( )
pure virtual
int MuonResidualsFitter::nfixed ( )
inline

Definition at line 146 of file MuonResidualsFitter.h.

References KineDebug3::count().

146 { return std::count(m_fixed.begin(), m_fixed.end(), true); }
std::vector< bool > m_fixed
virtual int MuonResidualsFitter::npar ( )
pure virtual
long MuonResidualsFitter::numResiduals ( ) const
inline
long MuonResidualsFitter::numsegments ( )

Definition at line 221 of file MuonResidualsFitter.cc.

References pileupDistInMC::num, residuals_begin(), and residuals_end().

Referenced by MuonResidualsTwoBin::numsegments().

222 {
223  long num = 0;
224  for (std::vector<double*>::const_iterator resiter = residuals_begin(); resiter != residuals_end(); ++resiter) num++;
225  return num;
226 }
std::vector< double * >::const_iterator residuals_end() const
std::vector< double * >::const_iterator residuals_begin() const
int MuonResidualsFitter::parNum2parIdx ( int  parNum)
inline

Definition at line 166 of file MuonResidualsFitter.h.

Referenced by covarianceElement().

166 { return m_parNum2parIdx[parNum];}
std::map< int, int > m_parNum2parIdx
virtual double MuonResidualsFitter::plot ( std::string  name,
TFileDirectory dir,
Alignable ali 
)
pure virtual
void MuonResidualsFitter::plotsimple ( std::string  name,
TFileDirectory dir,
int  which,
double  multiplier 
)

Definition at line 490 of file MuonResidualsFitter.cc.

References create_public_lumi_plots::hist, TFileDirectory::make(), alignCSCRings::r, residuals_begin(), residuals_end(), and svgfig::window().

Referenced by MuonResidualsTwoBin::plotsimple().

491 {
492  double window = 100.;
493  if (which == 0) window = 2.*30.;
494  else if (which == 1) window = 2.*30.;
495  else if (which == 2) window = 2.*20.;
496  else if (which == 3) window = 2.*50.;
497 
498  TH1F *hist = dir->make<TH1F>(name.c_str(), "", 200, -window, window);
499  for (std::vector<double*>::const_iterator r = residuals_begin(); r != residuals_end(); ++r) hist->Fill(multiplier * (*r)[which]);
500 }
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:642
T * make(const Args &...args) const
make new ROOT object
std::vector< double * >::const_iterator residuals_end() const
def which(cmd)
Definition: eostools.py:335
std::vector< double * >::const_iterator residuals_begin() const
void MuonResidualsFitter::plotweighted ( std::string  name,
TFileDirectory dir,
int  which,
int  whichredchi2,
double  multiplier 
)

Definition at line 503 of file MuonResidualsFitter.cc.

References create_public_lumi_plots::hist, TFileDirectory::make(), alignCSCRings::r, residuals_begin(), residuals_end(), and svgfig::window().

Referenced by MuonResidualsTwoBin::plotweighted().

504 {
505  double window = 100.;
506  if (which == 0) window = 2.*30.;
507  else if (which == 1) window = 2.*30.;
508  else if (which == 2) window = 2.*20.;
509  else if (which == 3) window = 2.*50.;
510 
511  TH1F *hist = dir->make<TH1F>(name.c_str(), "", 200, -window, window);
512  for (std::vector<double*>::const_iterator r = residuals_begin(); r != residuals_end(); ++r)
513  {
514  double weight = 1./(*r)[whichredchi2];
515  if (TMath::Prob(1./weight*12, 12) < 0.99) hist->Fill(multiplier * (*r)[which], weight);
516  }
517 }
Definition: weight.py:1
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:642
T * make(const Args &...args) const
make new ROOT object
std::vector< double * >::const_iterator residuals_end() const
def which(cmd)
Definition: eostools.py:335
std::vector< double * >::const_iterator residuals_begin() const
void MuonResidualsFitter::read ( FILE *  file,
int  which = 0 
)

Definition at line 434 of file MuonResidualsFitter.cc.

References MillePedeFileConverter_cfg::e, Exception, fill(), mps_fire::i, m_residuals, m_residuals_ok, ndata(), numResiduals(), and tablePrinter::rows.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), MuonResidualsTwoBin::read(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

435 {
436  long rows = -100;
437  int cols = -100;
438  int readwhich = -100;
439 
440  fread(&rows, sizeof(long), 1, file);
441  fread(&cols, sizeof(int), 1, file);
442  fread(&readwhich, sizeof(int), 1, file);
443 
444  if (cols != ndata() || rows < 0 || readwhich != which)
445  {
446  throw cms::Exception("MuonResidualsFitter") << "temporary file is corrupted (which = " << which << " readwhich = " << readwhich << " rows = " << rows << " cols = " << cols << ")\n";
447  }
448 
449  double *likeAChecksum = new double[cols];
450  double *likeAChecksum2 = new double[cols];
451  for (int i = 0; i < cols; i++)
452  {
453  likeAChecksum[i] = 0.;
454  likeAChecksum2[i] = 0.;
455  }
456 
457  m_residuals.reserve(rows);
458  for (long row = 0; row < rows; row++)
459  {
460  double *residual = new double[cols];
461  fread(residual, sizeof(double), cols, file);
462  fill(residual);
463  for (int i = 0; i < cols; i++)
464  {
465  if (fabs(residual[i]) > likeAChecksum[i]) likeAChecksum[i] = fabs(residual[i]);
466  if (fabs(residual[i]) < likeAChecksum2[i]) likeAChecksum2[i] = fabs(residual[i]);
467  }
468  } // end loop over records in file
469 
470  double *readChecksum = new double[cols];
471  double *readChecksum2 = new double[cols];
472  fread(readChecksum, sizeof(double), cols, file);
473  fread(readChecksum2, sizeof(double), cols, file);
474 
475  for (int i = 0; i < cols; i++)
476  {
477  if (fabs(likeAChecksum[i] - readChecksum[i]) > 1e-10 || fabs(1./likeAChecksum2[i] - 1./readChecksum2[i]) > 1e10)
478  {
479  throw cms::Exception("MuonResidualsFitter") << "temporary file is corrupted (which = " << which << " rows = " << rows << " likeAChecksum " << likeAChecksum[i] << " != readChecksum " << readChecksum[i] << " " << " likeAChecksum2 " << likeAChecksum2[i] << " != readChecksum2 " << readChecksum2[i] << ")\n";
480  }
481  }
482 
483  m_residuals_ok.resize(numResiduals(), true);
484 
485  delete [] likeAChecksum;
486  delete [] likeAChecksum2;
487 }
void fill(double *residual)
std::vector< double * > m_residuals
std::vector< bool > m_residuals_ok
virtual int ndata()=0
def which(cmd)
Definition: eostools.py:335
std::vector<double*>::const_iterator MuonResidualsFitter::residuals_begin ( ) const
inline
std::vector<double*>::const_iterator MuonResidualsFitter::residuals_end ( ) const
inline
int MuonResidualsFitter::residualsModel ( ) const
inline
std::vector<bool>& MuonResidualsFitter::selectedResidualsFlags ( )
inline
void MuonResidualsFitter::selectPeakResiduals ( double  nsigma,
int  nvar,
int *  vars 
)

Definition at line 586 of file MuonResidualsFitter.cc.

References gather_cfg::cout, histogramChi2GaussianFit(), m_center, m_radii, m_residuals, m_residuals_ok, numResiduals(), funct::pow(), alignCSCRings::r, findQualityFiles::v, and eostools::which().

Referenced by MuonResidualsTwoBin::selectPeakResiduals().

587 {
588  // does not make sense for small statistics
589  if (numResiduals()<25) return;
590 
591  int nbefore = numResiduals();
592 
593  //just to be sure (can't see why it might ever be more then 10)
594  assert(nvar<=10);
595 
596  // estimate nvar-D ellipsoid center & axes
597  for (int v = 0; v<nvar; v++)
598  {
599  int which = vars[v];
600  histogramChi2GaussianFit(which, m_center[which], m_radii[which]);
601  m_radii[which] = nsigma * m_radii[which];
602  }
603 
604  // filter out residuals that don't fit into the ellipsoid
605  std::vector<double*>::iterator r = m_residuals.begin();
606  while (r != m_residuals.end())
607  {
608  double ellipsoid_sum = 0;
609  for (int v = 0; v<nvar; v++)
610  {
611  int which = vars[v];
612  if (m_radii[which] == 0.) continue;
613  ellipsoid_sum += pow( ( (*r)[which] - m_center[which]) / m_radii[which] , 2);
614  }
615  if (ellipsoid_sum <= 1.) ++r;
616  else
617  {
618  m_residuals_ok[r - m_residuals.begin()] = false;
619  ++r;
620  // delete [] (*r);
621  // r = m_residuals.erase(r);
622  }
623  }
624  std::cout<<" N residuals "<<nbefore<<" -> "<<numResiduals()<<std::endl;
625 }
void histogramChi2GaussianFit(int which, double &fit_mean, double &fit_sigma)
std::vector< double * > m_residuals
std::vector< bool > m_residuals_ok
def which(cmd)
Definition: eostools.py:335
vars
Definition: DeepTauId.cc:77
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void MuonResidualsFitter::selectPeakResiduals_simple ( double  nsigma,
int  nvar,
int *  vars 
)

Definition at line 630 of file MuonResidualsFitter.cc.

References KineDebug3::count(), gather_cfg::cout, data, SoftLeptonByDistance_cfi::distance, mps_fire::i, m_residuals, m_residuals_ok, numResiduals(), alignCSCRings::r, mathSSE::sqrt(), and findQualityFiles::v.

631 {
632  //std::cout<<"doing selectpeakresiduals: nsig="<<nsigma<<" nvar="<<nvar<<" vars=";
633  for (int i=0; i<nvar; ++i) std::cout<<vars[i]<<" ";
634  std::cout<<std::endl;
635 
636  // does not make sense for small statistics set to 50
637  // YP changed it to 10 for test
638  if (numResiduals()<10) return;
639  // if (numResiduals()<50) return;
640 
641  size_t nbefore = numResiduals();
642  std::cout<<" N residuals "<<nbefore<<" ~ "<<(size_t) std::count(m_residuals_ok.begin(), m_residuals_ok.end(), true)<<std::endl;
643  //just to be sure (can't see why it might ever be more then 10)
644  assert(nvar<=10 && nvar>0);
645 
646  std::vector<double*>::iterator r = m_residuals.begin();
647 
648  // it's awkward, but the 1D case has to be handled separately
649  if (nvar==1)
650  {
651  std::cout << "1D case" << std::endl;
652  // get robust estimates for the peak and sigma
653  double *data = new double[nbefore];
654  for (size_t i = 0; i < nbefore; i++) data[i] = m_residuals[i][ vars[0] ];
655  double peak, sigma;
656  TRobustEstimator re;
657  re.EvaluateUni(nbefore, data, peak, sigma);
658 
659  // filter out residuals that are more then nsigma away from the peak
660  while (r != m_residuals.end())
661  {
662  double distance = fabs( ((*r)[ vars[0] ] - peak)/sigma );
663  if (distance <= nsigma) ++r;
664  else
665  {
666  m_residuals_ok[r - m_residuals.begin()] = false;
667  ++r;
668  //delete [] (*r);
669  //r = m_residuals.erase(r);
670  }
671  }
672  std::cout<<" N residuals "<<nbefore<<" -> "<<numResiduals()<<std::endl;
673  return;
674  } // end 1D case
675 
676  // initialize and run the robust estimator for D>1
677  std::cout << "D>1 case" << std::endl;
678  TRobustEstimator re(nbefore+1, nvar);
679  std::cout << "nbefore " << nbefore << " nvar " << nvar << std::endl;
680  r = m_residuals.begin();
681  std::cout << "+++++ JUST before loop while (r != m_residuals.end())" << std::endl;
682  int counter1 = 0;
683  while (r != m_residuals.end())
684  {
685  double *row = new double[nvar];
686  for (int v = 0; v<nvar; v++) row[v] = (*r)[ vars[v] ];
687  re.AddRow(row);
688  // delete[] row;
689  ++r;
690  counter1++;
691  }
692  std::cout << "counter1 " << counter1 << std::endl;
693  std::cout << "+++++ JUST after loop while (r != m_residuals.end())" << std::endl;
694  re.Evaluate();
695  std::cout << "+++++ JUST after re.Evaluate()" << std::endl;
696 
697  // get nvar-dimensional ellipsoid center & covariance
698  TVectorD M(nvar);
699  re.GetMean(M);
700  TMatrixDSym Cov(nvar);
701  re.GetCovariance(Cov);
702  Cov.Invert();
703 
704  // calculate the normalized radius for this nvar-dimensional ellipsoid from a 1D-Gaussian nsigma equivalent distance
705  double conf_1d = TMath::Erf(nsigma/sqrt(2));
706  double surf_radius = sqrt(TMath::ChisquareQuantile(conf_1d, nvar));
707 
708  // filter out residuals that are outside of the covariance ellipsoid with the above normalized radius
709  r = m_residuals.begin();
710  while (r != m_residuals.end())
711  {
712  TVectorD res(nvar);
713  for (int v = 0; v<nvar; v++) res[v] = (*r)[ vars[v] ];
714  double distance = sqrt( Cov.Similarity(res - M) );
715  if (distance <= surf_radius) ++r;
716  else
717  {
718  m_residuals_ok[r - m_residuals.begin()] = false;
719  ++r;
720  //delete [] (*r);
721  //r = m_residuals.erase(r);
722  }
723  }
724  std::cout<<" N residuals "<<nbefore<<" -> "<<(size_t) std::count(m_residuals_ok.begin(), m_residuals_ok.end(), true)<<std::endl;
725 }
Definition: Electron.h:6
std::vector< double * > m_residuals
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< bool > m_residuals_ok
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
vars
Definition: DeepTauId.cc:77
void MuonResidualsFitter::setInitialValue ( int  parNum,
double  value 
)
inline

Definition at line 151 of file MuonResidualsFitter.h.

References lumiContext::fill, trackingPlots::fit, and relativeConstraints::value.

151 { m_parNum2InitValue[parNum] = value; }
double value(int parNum)
std::map< int, double > m_parNum2InitValue
void MuonResidualsFitter::setPrintLevel ( int  printLevel)
inline

Definition at line 148 of file MuonResidualsFitter.h.

Referenced by MuonResidualsTwoBin::setPrintLevel().

148 { m_printLevel = printLevel; }
void MuonResidualsFitter::setStrategy ( int  strategy)
inline

Definition at line 149 of file MuonResidualsFitter.h.

Referenced by MuonResidualsTwoBin::setStrategy().

149 { m_strategy = strategy; }
virtual double MuonResidualsFitter::sumofweights ( )
pure virtual
virtual int MuonResidualsFitter::type ( ) const
pure virtual
int MuonResidualsFitter::useRes ( int  pattern = -1)
inline
double MuonResidualsFitter::value ( int  parNum)
inline
void MuonResidualsFitter::write ( FILE *  file,
int  which = 0 
)

Definition at line 397 of file MuonResidualsFitter.cc.

References mps_fire::i, ndata(), numResiduals(), residuals_begin(), residuals_end(), tablePrinter::rows, and eostools::which().

Referenced by pkg.AbstractPkg::generate(), MuonResidualsTwoBin::write(), and querying.connection::write_and_commit().

398 {
399  long rows = numResiduals();
400  int cols = ndata();
401  int whichcopy = which;
402 
403  fwrite(&rows, sizeof(long), 1, file);
404  fwrite(&cols, sizeof(int), 1, file);
405  fwrite(&whichcopy, sizeof(int), 1, file);
406 
407  double *likeAChecksum = new double[cols];
408  double *likeAChecksum2 = new double[cols];
409  for (int i = 0; i < cols; i++)
410  {
411  likeAChecksum[i] = 0.;
412  likeAChecksum2[i] = 0.;
413  }
414 
415  for (std::vector<double*>::const_iterator residual = residuals_begin(); residual != residuals_end(); ++residual)
416  {
417  fwrite((*residual), sizeof(double), cols, file);
418  for (int i = 0; i < cols; i++)
419  {
420  if (fabs((*residual)[i]) > likeAChecksum[i]) likeAChecksum[i] = fabs((*residual)[i]);
421  if (fabs((*residual)[i]) < likeAChecksum2[i]) likeAChecksum2[i] = fabs((*residual)[i]);
422  }
423  } // end loop over residuals
424 
425  // the idea is that mal-formed doubles are likely to be huge values (or tiny values)
426  // because the exponent gets screwed up; we want to check for that
427  fwrite(likeAChecksum, sizeof(double), cols, file);
428  fwrite(likeAChecksum2, sizeof(double), cols, file);
429 
430  delete [] likeAChecksum;
431  delete [] likeAChecksum2;
432 }
virtual int ndata()=0
std::vector< double * >::const_iterator residuals_end() const
def which(cmd)
Definition: eostools.py:335
std::vector< double * >::const_iterator residuals_begin() const

Member Data Documentation

double MuonResidualsFitter::m_center[20]
protected

Definition at line 243 of file MuonResidualsFitter.h.

Referenced by selectPeakResiduals().

TMatrixDSym MuonResidualsFitter::m_cov
protected

Definition at line 235 of file MuonResidualsFitter.h.

Referenced by covarianceElement(), and dofit().

std::vector<double> MuonResidualsFitter::m_error
protected

Definition at line 234 of file MuonResidualsFitter.h.

Referenced by dofit().

std::vector<bool> MuonResidualsFitter::m_fixed
protected

Definition at line 226 of file MuonResidualsFitter.h.

Referenced by fix(), and fixed().

double MuonResidualsFitter::m_loglikelihood
protected

Definition at line 236 of file MuonResidualsFitter.h.

Referenced by dofit().

int MuonResidualsFitter::m_minHits
protected
std::map<int, double> MuonResidualsFitter::m_parNum2InitValue
protected

Definition at line 227 of file MuonResidualsFitter.h.

std::map<int,int> MuonResidualsFitter::m_parNum2parIdx
protected

Definition at line 238 of file MuonResidualsFitter.h.

int MuonResidualsFitter::m_printLevel
protected

Definition at line 228 of file MuonResidualsFitter.h.

double MuonResidualsFitter::m_radii[20]
protected

Definition at line 244 of file MuonResidualsFitter.h.

Referenced by selectPeakResiduals().

std::vector<double*> MuonResidualsFitter::m_residuals
protected
std::vector<bool> MuonResidualsFitter::m_residuals_ok
protected
int MuonResidualsFitter::m_residualsModel
protected

Definition at line 222 of file MuonResidualsFitter.h.

Referenced by MuonResidualsFitter().

int MuonResidualsFitter::m_strategy
protected

Definition at line 228 of file MuonResidualsFitter.h.

Referenced by dofit().

int MuonResidualsFitter::m_useResiduals
protected

Definition at line 224 of file MuonResidualsFitter.h.

std::vector<double> MuonResidualsFitter::m_value
protected

Definition at line 233 of file MuonResidualsFitter.h.

Referenced by dofit().

bool MuonResidualsFitter::m_weightAlignment
protected