Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Millepede Class Reference

#include <AlignmentTools/Millepede.h>

List of all members.

Public Member Functions

bool ConstF (double dercs[], double rhs)
bool ConstF (double dercs[], double rhs)
bool EquLoc (double dergb[], double derlc[], double dernl[], double rmeas, double sigma)
bool EquLoc (double dergb[], double derlc[], double dernl[], double rmeas, double sigma)
bool FitLoc (int n, double track_params[], int single_fit)
bool FitLoc (int n, double track_params[], int single_fit)
int GetTrackNumber ()
int GetTrackNumber ()
bool initialize ()
 Initialization.
bool initialize ()
 Initialization.
bool InitMille (bool DOF[], double Sigm[], int nglo, int nloc, double startfact, int nstd, double res_cut, double res_cut_init)
bool InitMille (bool DOF[], double Sigm[], int nglo, int nloc, double startfact, int nstd, double res_cut, double res_cut_init)
bool MakeGlobalFit (double par[], double error[], double pull[])
bool MakeGlobalFit (double par[], double error[], double pull[])
 Millepede ()
 Standard constructor.
 Millepede ()
 Standard constructor.
bool ParGlo (int index, double param)
bool ParGlo (int index, double param)
bool ParSig (int index, double sigma)
bool ParSig (int index, double sigma)
void SetTrackNumber (int value)
void SetTrackNumber (int value)
bool ZerLoc (double dergb[], double derlc[], double dernl[])
bool ZerLoc (double dergb[], double derlc[], double dernl[])
 ~Millepede ()
 Destructor.
 ~Millepede ()
 Destructor.

Private Member Functions

double chindl (int n, int nd)
double chindl (int n, int nd)
double CorPar (int i, int j)
double CorPar (int i, int j)
double ErrPar (int i)
double ErrPar (int i)
bool InitUn (double cutfac)
bool InitUn (double cutfac)
bool PrtGlo ()
bool PrtGlo ()
bool SpAVAt (double v[][mlocal], double a[][mlocal], double w[][mglobl], int n, int m)
bool SpAVAt (double v[][mlocal], double a[][mlocal], double w[][mglobl], int n, int m)
bool SpAX (double a[][mlocal], double x[], double y[], int n, int m)
bool SpAX (double a[][mlocal], double x[], double y[], int n, int m)
int SpmInv (double v[][mlocal], double b[], int n, double diag[], bool flag[])
int SpmInv (double v[][mgl], double b[], int n, double diag[], bool flag[])
int SpmInv (double v[][mlocal], double b[], int n, double diag[], bool flag[])
int SpmInv (double v[][mgl], double b[], int n, double diag[], bool flag[])

Private Attributes

double adercs [mcs][mglobl]
std::vector< double > arenl
std::vector< double > arenl
std::vector< double > arest
std::vector< double > arest
double arhs [mcs]
double bgvec [mgl]
double blvec [mlocal]
double cfactr
double cfactref
double cgmat [mgl][mgl]
double clcmat [mglobl][mlocal]
double clmat [mlocal][mlocal]
double corrm [mglobl][mglobl]
double corrv [mglobl]
double diag [mgl]
double dparm [mglobl]
int indbk [mglobl]
int indgb [mglobl]
int indlc [mlocal]
int indnz [mglobl]
std::vector< int > indst
std::vector< int > indst
int itert
int locrej
int loctot
double m_residual_cut
double m_residual_cut_init
int m_track_number
int nagb
int nalc
int ncs
int nfl
int nlnpa [mglobl]
int nrank
int nst
int nstdev
double pparm [mglobl]
double psigm [mglobl]
double scdiag [mglobl]
bool scflag [mglobl]
int store_row_size
std::vector< double > storeare
std::vector< double > storeare
std::vector< int > storeind
std::vector< int > storeind
std::vector< double > storenl
std::vector< double > storenl
std::vector< int > storeplace
std::vector< int > storeplace

Static Private Attributes

const int mcs = 10
const int mgl = 410
const int mglobl = 400
const int mlocal = 20


Detailed Description

Author:
Sebastien Viret
Date:
2005-07-29


Constructor & Destructor Documentation

Millepede::Millepede  ) 
 

Standard constructor.

00024 {}

Millepede::~Millepede  ) 
 

Destructor.

00028 {} 

Millepede::Millepede  ) 
 

Standard constructor.

Millepede::~Millepede  ) 
 

Destructor.


Member Function Documentation

double Millepede::chindl int  n,
int  nd
[private]
 

double Millepede::chindl int  n,
int  nd
[private]
 

01478 {
01479      int m;
01480      double sn[3]        =      {0.47523, 1.690140, 2.782170};
01481      double table[3][30] = {{1.0000, 1.1479, 1.1753, 1.1798, 1.1775, 1.1730, 1.1680, 1.1630,
01482                              1.1581, 1.1536, 1.1493, 1.1454, 1.1417, 1.1383, 1.1351, 1.1321,
01483                              1.1293, 1.1266, 1.1242, 1.1218, 1.1196, 1.1175, 1.1155, 1.1136,
01484                              1.1119, 1.1101, 1.1085, 1.1070, 1.1055, 1.1040},
01485                             {4.0000, 3.0900, 2.6750, 2.4290, 2.2628, 2.1415, 2.0481, 1.9736,
01486                              1.9124, 1.8610, 1.8171, 1.7791, 1.7457, 1.7161, 1.6897, 1.6658,
01487                              1.6442, 1.6246, 1.6065, 1.5899, 1.5745, 1.5603, 1.5470, 1.5346,
01488                              1.5230, 1.5120, 1.5017, 1.4920, 1.4829, 1.4742},
01489                             {9.0000, 5.9146, 4.7184, 4.0628, 3.6410, 3.3436, 3.1209, 2.9468,
01490                              2.8063, 2.6902, 2.5922, 2.5082, 2.4352, 2.3711, 2.3143, 2.2635,
01491                              2.2178, 2.1764, 2.1386, 2.1040, 2.0722, 2.0428, 2.0155, 1.9901,
01492                              1.9665, 1.9443, 1.9235, 1.9040, 1.8855, 1.8681}};
01493 
01494      if (nd < 1)
01495      {
01496           return 0.0;
01497      }
01498      else
01499      {
01500           m = std::max(1,std::min(n,3));
01501 
01502           if (nd <= 30)
01503           {
01504                return table[m-1][nd-1];
01505           }
01506           else // approximation
01507           {
01508                return ((sn[m-1]+sqrt(float(2*nd-3)))*(sn[m-1]+sqrt(float(2*nd-3))))/float(2*nd-2);
01509           }
01510      }
01511 }

bool Millepede::ConstF double  dercs[],
double  rhs
 

bool Millepede::ConstF double  dercs[],
double  rhs
 

00263 {  
00264      if (ncs>=mcs) // mcs is defined in Millepede.h
00265      {
00266           cout << "Too many constraints !!!" << endl;
00267           return false;
00268      }
00269 
00270      for (int i=0; i<nagb; i++) {adercs[ncs][i] = dercs[i];}
00271 
00272      arhs[ncs] = rhs;
00273      ncs++ ;
00274      cout << "Number of constraints increased to " << ncs << endl;
00275      return true;
00276 }

double Millepede::CorPar int  i,
int  j
[private]
 

double Millepede::CorPar int  i,
int  j
[private]
 

bool Millepede::EquLoc double  dergb[],
double  derlc[],
double  dernl[],
double  rmeas,
double  sigma
 

bool Millepede::EquLoc double  dergb[],
double  derlc[],
double  dernl[],
double  rmeas,
double  sigma
 

00293 {       
00294 
00295      if (sigma<=0.0) // If parameter is fixed, then no equation
00296      {
00297           for (int i=0; i<nalc; i++)
00298           {
00299                derlc[i] = 0.0;
00300           }
00301           for (int i=0; i<nagb; i++)
00302           {
00303                dergb[i] = 0.0;
00304           }
00305           return true;
00306      }
00307 
00308      // Serious equation, initialize parameters
00309 
00310      double wght =  1.0/(sigma*sigma);
00311      int nonzer  =  0;
00312      int ialc    = -1;
00313      int iblc    = -1;
00314      int iagb    = -1;
00315      int ibgb    = -1;
00316 
00317      for (int i=0; i<nalc; i++) // Retrieve local param interesting indices
00318      {
00319           if (derlc[i]!=0.0)
00320           {
00321                nonzer++;
00322                if (ialc == -1) ialc=i;  // first index
00323                iblc = i;                // last index
00324           }
00325      }
00326 
00327      if (verbose_mode) cout << ialc << " / " << iblc << endl;
00328 
00329      for (int i=0; i<nagb; i++)  // Idem for global parameters
00330      {
00331           if (dergb[i]!=0.0)
00332           {
00333                nonzer++;
00334                if (iagb == -1) iagb=i;  // first index
00335                ibgb = i;                // last index
00336           }
00337      }
00338 
00339      if (verbose_mode) cout << iagb << " / " << ibgb << endl;
00340 
00341      indst.push_back(-1);
00342      arest.push_back(rmeas);
00343      arenl.push_back(0.);
00344 
00345      for (int i=ialc; i<=iblc; i++)
00346      {
00347           if (derlc[i]!=0.0)
00348           {
00349                indst.push_back(i);
00350                arest.push_back(derlc[i]);
00351                arenl.push_back(0.0);
00352                derlc[i]   = 0.0;
00353           }
00354      }
00355 
00356      indst.push_back(-1);
00357      arest.push_back(wght);
00358      arenl.push_back(0.0);
00359 
00360      for (int i=iagb; i<=ibgb; i++)
00361      {
00362           if (dergb[i]!=0.0)
00363           {
00364                indst.push_back(i);
00365                arest.push_back(dergb[i]);
00366                arenl.push_back(dernl[i]);
00367                dergb[i]   = 0.0;
00368           }
00369      }  
00370 
00371      if (verbose_mode) cout << "Out Equloc --  NST = " << arest.size() << endl;
00372 
00373      return true;       
00374 }

double Millepede::ErrPar int  i  )  [private]
 

double Millepede::ErrPar int  i  )  [private]
 

bool Millepede::FitLoc int  n,
double  track_params[],
int  single_fit
 

bool Millepede::FitLoc int  n,
double  track_params[],
int  single_fit
 

00418 {
00419      // Few initializations
00420 
00421      int i, j, k, ik, ij, ist, nderlc, ndergl, ndf;
00422      int ja      = -1;
00423      int jb      = 0;
00424      int nagbn   = 0;
00425 
00426      double rmeas, wght, rms, cutval;
00427 
00428      double summ  = 0.0;
00429      int    nsum  = 0;
00430      nst   = 0; 
00431      nst   = arest.size();
00432 
00433 
00434      // Fill the track store at first pass
00435 
00436      if (itert < 2 && single_fit != 1)  // Do it only once 
00437      {
00438           if (debug_mode) cout << "Store equation no: " << n << endl; 
00439 
00440           for (i=0; i<nst; i++)    // Store the track parameters
00441           {
00442                storeind.push_back(indst[i]);
00443                storeare.push_back(arest[i]);
00444                storenl.push_back(arenl[i]);
00445 
00446                if (arenl[i] != 0.) arest[i] = 0.0; // Reset global derivatives if non linear and first iteration
00447           }
00448 
00449           arenl.clear();
00450 
00451           storeplace.push_back(storeind.size());
00452 
00453           if (verbose_mode) cout << "StorePlace size = " << storeplace[n] << endl; 
00454           if (verbose_mode) cout << "StoreInd size   = " << storeind.size() << endl; 
00455      }  
00456 
00457 
00458      for (i=0; i<nalc; i++) // reset local params
00459      {
00460           blvec[i] = 0.0;
00461 
00462           for (j=0; j<nalc; j++) {clmat[i][j] = 0.0;}
00463      }
00464 
00465      for (i=0; i<nagb; i++) {indnz[i] = -1;} // reset mixed params
00466 
00467 
00468      /*
00469 
00470      LOOPS : HOW DOES IT WORKS ?        
00471 
00472      Now start by reading the informations stored with EquLoc.
00473      Those informations are in vector INDST and AREST.
00474      Each -1 in INDST delimits the equation parameters:
00475 
00476      First -1  ---> rmeas in AREST 
00477      Then we have indices of local eq in INDST, and derivatives in AREST
00478      Second -1 ---> weight in AREST
00479      Then follows indices and derivatives of global eq.
00480      ....
00481 
00482      We took them and store them into matrices.
00483 
00484      As we want ONLY local params, we substract the part of the estimated value
00485      due to global params. Indeed we could have already an idea of these params,
00486      with previous alignment constants for example (set with PARGLO). Also if there
00487      are more than one iteration (FITLOC could be called by FITGLO)
00488 
00489      */
00490 
00491 
00492      //
00493      // FIRST LOOP : local track fit
00494      //
00495 
00496      ist = 0;
00497      indst.push_back(-1);
00498 
00499      while (ist <= nst)
00500      {
00501           if (indst[ist] == -1)
00502           {
00503                if (ja == -1)     {ja = ist;}  // First  0 : rmeas
00504                else if (jb == 0) {jb = ist;}  // Second 0 : weight 
00505                else                           // Third  0 : end of equation  
00506                {
00507                     rmeas       = arest[ja];
00508                     wght        = arest[jb];
00509                     if (verbose_mode) cout << "rmeas = " << rmeas << endl ;
00510                     if (verbose_mode) cout << "wght = " << wght << endl ;
00511 
00512                     for (i=(jb+1); i<ist; i++)   // Now suppress the global part   
00513                          // (only relevant with iterations)
00514                     {
00515                          j = indst[i];              // Global param indice
00516                          if (verbose_mode) cout << "dparm[" << j << "] = " << dparm[j] << endl;        
00517                          if (verbose_mode) cout << "Starting misalignment = " << pparm[j] << endl;        
00518                          rmeas -= arest[i]*(pparm[j]+dparm[j]);
00519                     }
00520 
00521                     if (verbose_mode) cout << "rmeas after global stuff removal = " << rmeas << endl ;
00522 
00523                     for (i=(ja+1); i<jb; i++)    // Finally fill local matrix and vector
00524                     {
00525                          j = indst[i];   // Local param indice (the matrix line) 
00526                          blvec[j] += wght*rmeas*arest[i];  // See note for precisions
00527 
00528                          if (verbose_mode) cout << "blvec[" << j << "] = " << blvec[j] << endl ;
00529 
00530                          for (k=(ja+1); k<=i ; k++) // Symmetric matrix, don't bother k>j coeffs
00531                          {
00532                               ik = indst[k];                                            
00533                               clmat[j][ik] += wght*arest[i]*arest[k];
00534 
00535                               if (verbose_mode) cout << "clmat[" << j << "][" << ik << "] = " << clmat[j][ik] << endl;
00536                          } 
00537                     }  
00538                     ja = -1;
00539                     jb = 0;
00540                     ist--;
00541                } // End of "end of equation" operations
00542           } // End of loop on equation
00543           ist++;
00544      } // End of loop on all equations used in the fit
00545 
00546 
00547      //
00548      // Local params matrix is completed, now invert to solve...
00549      //
00550 
00551      nrank = 0;  // Rank is the number of nonzero diagonal elements 
00552      nrank = Millepede::SpmInv(clmat, blvec, nalc, scdiag, scflag);
00553 
00554      if (debug_mode) cout << "" << endl;
00555      if (debug_mode) cout << " __________________________________________________" << endl;
00556      if (debug_mode) cout << " Printout of local fit  (FITLOC)  with rank= "<< nrank << endl;
00557      if (debug_mode) cout << " Result of local fit :      (index/parameter/error)" << endl;
00558 
00559      for (i=0; i<nalc; i++)
00560      {
00561           if (debug_mode) cout << std::setprecision(4) << std::fixed;
00562           if (debug_mode) cout << std::setw(20) << i << "   /   " << std::setw(10) 
00563                                << blvec[i] << "   /   " << sqrt(clmat[i][i]) << endl;   
00564      }
00565 
00566 
00567      // Store the track params and errors
00568 
00569      for (i=0; i<nalc; i++)
00570      {
00571           track_params[2*i] = blvec[i];
00572           track_params[2*i+1] = sqrt(fabs(clmat[i][i]));
00573      }
00574 
00575 
00576      //
00577      // SECOND LOOP : residual calculation
00578      //
00579 
00580      ist = 0;
00581      ja = -1;
00582      jb = 0;
00583 
00584      while (ist <= nst)
00585      {
00586           if (indst[ist] == -1)
00587           {
00588                if (ja == -1)     {ja = ist;}  // First  0 : rmeas
00589                else if (jb == 0) {jb = ist;}  // Second 0 : weight 
00590                else                           // Third  0 : end of equation  
00591                {        
00592                     rmeas       = arest[ja];
00593                     wght        = arest[jb];
00594 
00595                     nderlc = jb-ja-1;    // Number of local derivatives involved
00596                     ndergl = ist-jb-1;   // Number of global derivatives involved
00597 
00598                     // Print all (for debugging purposes)
00599 
00600                     if (verbose_mode) cout << "" << endl;
00601                     if (verbose_mode) cout << std::setprecision(4) << std::fixed;
00602                     if (verbose_mode) cout << ". equation:  measured value " << std::setw(13) 
00603                                            << rmeas << " +/- " << std::setw(13) << 1.0/sqrt(wght) << endl;
00604                     if (verbose_mode) cout << "Number of derivatives (global, local): " 
00605                                            << ndergl << ", " << nderlc << endl;
00606                     if (verbose_mode) cout << "Global derivatives are: (index/derivative/parvalue) " << endl;
00607 
00608                     for (i=(jb+1); i<ist; i++)
00609                     {if (verbose_mode) cout << indst[i] << " / " << arest[i] 
00610                                             << " / " << pparm[indst[i]] << endl;} 
00611 
00612                     if (verbose_mode) cout << "Local derivatives are: (index/derivative) " << endl;
00613 
00614                     for (i=(ja+1); i<jb; i++) {if (verbose_mode) cout << indst[i] << " / " << arest[i] << endl;}          
00615 
00616                     // Now suppress local and global parts to RMEAS;
00617 
00618                     for (i=(ja+1); i<jb; i++) // First the local part 
00619                     {
00620                          j = indst[i];
00621                          rmeas -= arest[i]*blvec[j];
00622                     }
00623 
00624                     for (i=(jb+1); i<ist; i++) // Then the global part
00625                     {
00626                          j = indst[i];
00627                          rmeas -= arest[i]*(pparm[j]+dparm[j]);
00628                     }
00629 
00630                     // rmeas contains now the residual value
00631                     //  if (verbose_mode) cout << "Residual value : "<< rmeas << endl;
00632                     if (verbose_reject) cout << "Residual value : "<< rmeas << endl;
00633 
00634                     // reject the track if rmeas is too important (outlier)
00635                     if (fabs(rmeas) >= m_residual_cut_init && itert <= 1)  
00636                     {
00637                          //       if (verbose_mode) cout << "Rejected track !!!!!" << endl;
00638                          if (verbose_reject) cout << "Rejected track !!!!!" << endl;
00639                          locrej++;      
00640                          indst.clear(); // reset stores and go to the next track 
00641                          arest.clear();   
00642                          return false;
00643                     }
00644 
00645                     if (fabs(rmeas) >= m_residual_cut && itert > 1)   
00646                     {
00647                          //       if (verbose_mode) cout << "Rejected track !!!!!" << endl;
00648                          if (verbose_reject) cout << "Rejected track !!!!!" << endl;
00649                          locrej++;      
00650                          indst.clear(); // reset stores and go to the next track 
00651                          arest.clear();   
00652                          return false;
00653                     }
00654 
00655                     summ += wght*rmeas*rmeas ; // total chi^2
00656                     nsum++;                    // number of equations                   
00657                     ja = -1;
00658                     jb = 0;
00659                     ist--;
00660                } // End of "end of equation" operations
00661           }   // End of loop on equation
00662           ist++;
00663      } // End of loop on all equations used in the fit
00664 
00665      ndf = nsum-nrank;  
00666      rms = 0.0;
00667 
00668      if (debug_mode) cout << "Final chi square / degrees of freedom "<< summ << " / " << ndf << endl;
00669 
00670      if (ndf > 0) rms = summ/float(ndf);  // Chi^2/dof
00671 
00672      if (single_fit == 0) loctot++;
00673 
00674      if (nstdev != 0 && ndf > 0 && single_fit != 1) // Chisquare cut
00675      {
00676           cutval = Millepede::chindl(nstdev, ndf)*cfactr;
00677 
00678           if (debug_mode) cout << "Reject if Chisq/Ndf = " << rms << "  >  " << cutval << endl;
00679 
00680           if (rms > cutval) // Reject the track if too much...
00681           {
00682                if (verbose_mode) cout << "Rejected track !!!!!" << endl;
00683                if (single_fit == 0) locrej++;      
00684                indst.clear(); // reset stores and go to the next track 
00685                arest.clear();
00686                return false;
00687           }
00688      }
00689 
00690      if (single_fit == 1) // Stop here if just updating the track parameters
00691      {
00692           indst.clear(); // Reset store for the next track 
00693           arest.clear();
00694           return true;
00695      }
00696 
00697      //  
00698      // THIRD LOOP: local operations are finished, track is accepted 
00699      // We now update the global parameters (other matrices)
00700      //
00701 
00702      ist = 0;
00703      ja = -1;
00704      jb = 0;
00705 
00706      while (ist <= nst)
00707      {
00708           if (indst[ist] == -1)
00709           {
00710                if (ja == -1)     {ja = ist;}  // First  0 : rmeas
00711                else if (jb == 0) {jb = ist;}  // Second 0 : weight 
00712                else                           // Third  0 : end of equation  
00713                {        
00714                     rmeas       = arest[ja];
00715                     wght        = arest[jb];
00716 
00717                     for (i=(jb+1); i<ist; i++) // Now suppress the global part
00718                     {
00719                          j = indst[i];   // Global param indice
00720                          rmeas -= arest[i]*(pparm[j]+dparm[j]);
00721                     }
00722 
00723                     // First of all, the global/global terms (exactly like local matrix)
00724 
00725                     for (i=(jb+1); i<ist; i++)  
00726                     {
00727                          j = indst[i];   // Global param indice (the matrix line)          
00728 
00729                          bgvec[j] += wght*rmeas*arest[i];  // See note for precisions
00730                          if (verbose_mode) cout << "bgvec[" << j << "] = " << bgvec[j] << endl ;
00731 
00732                          for (k=(jb+1); k<ist ; k++)
00733                          {
00734                               ik = indst[k];                                            
00735                               cgmat[j][ik] += wght*arest[i]*arest[k];
00736                               if (verbose_mode) cout << "cgmat[" << j << "][" << ik << "] = " << cgmat[j][ik] << endl;
00737                          } 
00738                     }
00739 
00740                     // Now we have also rectangular matrices containing global/local terms.
00741 
00742                     for (i=(jb+1); i<ist; i++) 
00743                     {
00744                          j  = indst[i];  // Global param indice (the matrix line)
00745                          ik = indnz[j];  // Index of index
00746 
00747                          if (ik == -1)    // New global variable
00748                          {
00749                               for (k=0; k<nalc; k++) {clcmat[nagbn][k] = 0.0;} // Initialize the row
00750 
00751                               indnz[j] = nagbn;
00752                               indbk[nagbn] = j;
00753                               ik = nagbn;
00754                               nagbn++;
00755                          }
00756 
00757                          for (k=(ja+1); k<jb ; k++) // Now fill the rectangular matrix
00758                          {
00759                               ij = indst[k];                                            
00760                               clcmat[ik][ij] += wght*arest[i]*arest[k];
00761                               if (verbose_mode) cout << "clcmat[" << ik << "][" << ij << "] = " << clcmat[ik][ij] << endl;
00762                          } 
00763                     }
00764                     ja = -1;
00765                     jb = 0;
00766                     ist--;
00767                } // End of "end of equation" operations
00768           }   // End of loop on equation
00769           ist++;
00770      } // End of loop on all equations used in the fit
00771 
00772      // Third loop is finished, now we update the correction matrices (see notes)
00773 
00774      Millepede::SpAVAt(clmat, clcmat, corrm, nalc, nagbn);
00775      Millepede::SpAX(clcmat, blvec, corrv, nalc, nagbn);
00776 
00777      for (i=0; i<nagbn; i++)
00778      {
00779           j = indbk[i];
00780           bgvec[j] -= corrv[i];
00781 
00782           for (k=0; k<nagbn; k++)
00783           {
00784                ik = indbk[k];
00785                cgmat[j][ik] -= corrm[i][k];
00786           }
00787      }
00788 
00789      indst.clear(); // Reset store for the next track 
00790      arest.clear();
00791 
00792      return true;
00793 }

int Millepede::GetTrackNumber  ) 
 

int Millepede::GetTrackNumber  ) 
 

01514 {return m_track_number;}

bool Millepede::initialize  ) 
 

Initialization.

bool Millepede::initialize  ) 
 

Initialization.

bool Millepede::InitMille bool  DOF[],
double  Sigm[],
int  nglo,
int  nloc,
double  startfact,
int  nstd,
double  res_cut,
double  res_cut_init
 

bool Millepede::InitMille bool  DOF[],
double  Sigm[],
int  nglo,
int  nloc,
double  startfact,
int  nstd,
double  res_cut,
double  res_cut_init
 

00048 {
00049 
00050      cout << "                                           " << endl;
00051      cout << "            * o o                   o      " << endl;
00052      cout << "              o o                   o      " << endl;
00053      cout << "   o ooooo  o o o  oo  ooo   oo   ooo  oo  " << endl;
00054      cout << "    o  o  o o o o o  o o  o o  o o  o o  o " << endl;
00055      cout << "    o  o  o o o o oooo o  o oooo o  o oooo " << endl;
00056      cout << "    o  o  o o o o o    ooo  o    o  o o    " << endl;
00057      cout << "    o  o  o o o o  oo  o     oo   ooo  oo  ++ starts" << endl;       
00058      cout << "                                           " << endl;
00059 
00060      if (debug_mode) cout << "" << endl;
00061      if (debug_mode) cout << "----------------------------------------------------" << endl;
00062      if (debug_mode) cout << "" << endl;
00063      if (debug_mode) cout << "    Entering InitMille" << endl;
00064      if (debug_mode) cout << "" << endl;
00065      if (debug_mode) cout << "-----------------------------------------------------" << endl;
00066      if (debug_mode) cout << "" << endl;
00067 
00068      ncs = 0;
00069      loctot  = 0;                        // Total number of local fits
00070      locrej  = 0;                        // Total number of local fits rejected
00071      cfactref  = 1.0;                    // Reference value for Chi^2/ndof cut
00072 
00073      Millepede::SetTrackNumber(0);       // Number of local fits (starts at 0)
00074 
00075      m_residual_cut = res_cut;
00076      m_residual_cut_init = res_cut_init; 
00077 
00078      //   nagb    = 6*nglo;    // Number of global derivatives
00079      nagb    = 3*nglo;          // modified by wulh
00080      nalc         = nloc;       // Number of local derivatives
00081      nstdev  = nstd;     // Number of StDev for local fit chisquare cut
00082 
00083      if (debug_mode) cout << "Number of global parameters   : " << nagb << endl;
00084      if (debug_mode) cout << "Number of local parameters    : " << nalc << endl;
00085      if (debug_mode) cout << "Number of standard deviations : " << nstdev << endl;
00086 
00087      if (nagb>mglobl || nalc>mlocal)
00088      {
00089           if (debug_mode) cout << "Two many parameters !!!!!" << endl;
00090           return false;
00091      }
00092 
00093      // Global parameters initializations
00094 
00095      for (int i=0; i<nagb; i++)
00096      {
00097           bgvec[i]=0.;
00098           pparm[i]=0.;
00099           dparm[i]=0.;
00100           psigm[i]=-1.;
00101           indnz[i]=-1;
00102           indbk[i]=-1;
00103           nlnpa[i]=0;
00104 
00105           for (int j=0; j<nagb;j++)
00106           {
00107                cgmat[i][j]=0.;
00108           }
00109      }
00110 
00111      // Local parameters initializations
00112 
00113      for (int i=0; i<nalc; i++)
00114      {
00115           blvec[i]=0.;
00116 
00117           for (int j=0; j<nalc;j++)
00118           {
00119                clmat[i][j]=0.;
00120           }
00121      }
00122 
00123      // Then we fix all parameters...
00124 
00125      for (int j=0; j<nagb; j++)  {Millepede::ParSig(j,0.0);}
00126 
00127      // ...and we allow them to move if requested
00128 
00129      //   for (int i=0; i<3; i++)
00130      for (int i=0; i<3; i++)    // modified by wulh on 06/08/27
00131      {
00132           if (verbose_mode) cout << "GetDOF(" << i << ")= " << DOF[i] << endl;
00133 
00134           if (DOF[i]) 
00135           {
00136                for (int j=i*nglo; j<(i+1)*nglo; j++) 
00137                {Millepede::ParSig(j,Sigm[i]);}
00138           }
00139      }
00140 
00141      // Activate iterations (if requested)
00142 
00143      itert   = 0;       // By default iterations are turned off
00144      cfactr = 500.0;
00145      if (m_iteration) Millepede::InitUn(startfact);          
00146 
00147      arest.clear();  // Number of stored parameters when doing local fit
00148      arenl.clear();  // Is it linear or not?
00149      indst.clear(); 
00150 
00151      storeind.clear();
00152      storeare.clear();
00153      storenl.clear();
00154      storeplace.clear();
00155 
00156      if (debug_mode) cout << "" << endl;
00157      if (debug_mode) cout << "----------------------------------------------------" << endl;
00158      if (debug_mode) cout << "" << endl;
00159      if (debug_mode) cout << "    InitMille has been successfully called!" << endl;
00160      if (debug_mode) cout << "" << endl;
00161      if (debug_mode) cout << "-----------------------------------------------------" << endl;
00162      if (debug_mode) cout << "" << endl;
00163 
00164      return true;
00165 }

bool Millepede::InitUn double  cutfac  )  [private]
 

bool Millepede::InitUn double  cutfac  )  [private]
 

00241 {
00242      cfactr = std::max(1.0, cutfac);
00243 
00244      cout << "Initial cut factor is  " << cfactr << endl;
00245      itert = 1; // Initializes the iteration process
00246      return true;
00247 }

bool Millepede::MakeGlobalFit double  par[],
double  error[],
double  pull[]
 

bool Millepede::MakeGlobalFit double  par[],
double  error[],
double  pull[]
 

00814 {
00815      int i, j, nf, nvar;
00816      int itelim = 0;
00817 
00818      int nstillgood;
00819 
00820      double sum;
00821 
00822      double step[150];
00823 
00824      double trackpars[2*mlocal];
00825 
00826      int ntotal_start, ntotal;
00827 
00828      cout << "..... Making global fit ....." << endl;
00829 
00830      ntotal_start = Millepede::GetTrackNumber();
00831 
00832      std::vector<double> track_slopes;
00833 
00834      track_slopes.resize(2*ntotal_start);
00835 
00836      for (i=0; i<2*ntotal_start; i++) track_slopes[i] = 0.;
00837 
00838      if (itert <= 1) itelim=10;    // Max number of iterations
00839 
00840      while (itert < itelim)  // Iteration for the final loop
00841      {
00842           if (debug_mode) cout << "ITERATION --> " << itert << endl;
00843 
00844           ntotal = Millepede::GetTrackNumber();
00845           cout << "...using " << ntotal << " tracks..." << endl;
00846 
00847           // Start by saving the diagonal elements
00848 
00849           for (i=0; i<nagb; i++) {diag[i] = cgmat[i][i];}
00850 
00851           //  Then we retrieve the different constraints: fixed parameter or global equation
00852 
00853           nf = 0; // First look at the fixed global params
00854 
00855           for (i=0; i<nagb; i++)
00856           {
00857                if (psigm[i] <= 0.0)   // fixed global param
00858                {
00859                     nf++;
00860 
00861                     for (j=0; j<nagb; j++)
00862                     {
00863                          cgmat[i][j] = 0.0;  // Reset row and column
00864                          cgmat[j][i] = 0.0;
00865                     }                   
00866                }
00867                else if (psigm[i] > 0.0) 
00868                {
00869                     cgmat[i][i] += 1.0/(psigm[i]*psigm[i]);
00870                }
00871           }
00872 
00873           nvar = nagb;  // Current number of equations  
00874           if (debug_mode) cout << "Number of constraint equations : " << ncs << endl;
00875 
00876           if (ncs > 0) // Then the constraint equation
00877           {
00878                for (i=0; i<ncs; i++)
00879                {
00880                     sum = arhs[i];
00881                     for (j=0; j<nagb; j++)
00882                     {
00883                          cgmat[nvar][j] = float(ntotal)*adercs[i][j];
00884                          cgmat[j][nvar] = float(ntotal)*adercs[i][j];          
00885                          sum -= adercs[i][j]*(pparm[j]+dparm[j]);
00886                     }
00887 
00888                     cgmat[nvar][nvar] = 0.0;
00889                     bgvec[nvar] = float(ntotal)*sum;
00890                     nvar++;
00891                }
00892           }
00893 
00894 
00895           // Intended to compute the final global chisquare
00896 
00897           double final_cor = 0.0;
00898 
00899           if (itert > 1)
00900           {
00901                for (j=0; j<nagb; j++)
00902                {
00903                     for (i=0; i<nagb; i++)
00904                     {
00905                          if (psigm[i] > 0.0)
00906                          {
00907                               final_cor += step[j]*cgmat[j][i]*step[i]; 
00908                               if (i == j) final_cor -= step[i]*step[i]/(psigm[i]*psigm[i]);
00909                          }
00910                     }
00911                }
00912           }
00913 
00914           cout << " Final coeff is " << final_cor << endl;              
00915           cout << " Final NDOFs =  " << nagb << endl;
00916 
00917           //  The final matrix inversion
00918 
00919           nrank = Millepede::SpmInv(cgmat, bgvec, nvar, scdiag, scflag);
00920 
00921           for (i=0; i<nagb; i++)
00922           {
00923                dparm[i] += bgvec[i];    // Update global parameters values (for iterations)
00924                if (verbose_mode) cout << "dparm[" << i << "] = " << dparm[i] << endl;
00925                if (verbose_mode) cout << "cgmat[" << i << "][" << i << "] = " << cgmat[i][i] << endl;
00926                if (verbose_mode) cout << "err = " << sqrt(fabs(cgmat[i][i])) << endl;
00927 
00928                step[i] = bgvec[i];
00929 
00930                if (itert == 1) error[i] = cgmat[i][i]; // Unfitted error
00931           }
00932 
00933           cout << "" << endl;
00934           cout << "The rank defect of the symmetric " << nvar << " by " << nvar 
00935                << " matrix is " << nvar-nf-nrank << " (bad if non 0)" << endl;
00936 
00937           if (itert == 0)  break;       
00938           itert++;
00939 
00940           cout << "" << endl;
00941           cout << "Total : " << loctot << " local fits, " 
00942                << locrej << " rejected." << endl;
00943 
00944           // Reinitialize parameters for iteration
00945 
00946           loctot = 0;
00947           locrej = 0;
00948 
00949           if (cfactr != cfactref && sqrt(cfactr) > 1.2*cfactref)
00950           {
00951                cfactr = sqrt(cfactr);
00952           }
00953           else
00954           {
00955                cfactr = cfactref;
00956                //      itert = itelim;
00957           }
00958 
00959           if (itert == itelim)  break;  // End of story         
00960 
00961           cout << "Iteration " << itert << " with cut factor " << cfactr << endl;
00962 
00963           // Reset global variables
00964 
00965           for (i=0; i<nvar; i++)
00966           {
00967                bgvec[i] = 0.0;
00968                for (j=0; j<nvar; j++)
00969                {
00970                     cgmat[i][j] = 0.0;
00971                }
00972           }
00973 
00974           //
00975           // We start a new iteration
00976           //
00977 
00978           // First we read the stores for retrieving the local params
00979 
00980           nstillgood = 0;       
00981 
00982           for (i=0; i<ntotal_start; i++)
00983           {
00984                int rank_i = 0;
00985                int rank_f = 0;
00986 
00987                (i>0) ? rank_i = abs(storeplace[i-1]) : rank_i = 0;
00988                rank_f = storeplace[i];
00989 
00990                if (verbose_mode) cout << "Track " << i << " : " << endl;
00991                if (verbose_mode) cout << "Starts at " << rank_i << endl;
00992                if (verbose_mode) cout << "Ends at " << rank_f << endl;
00993 
00994                if (rank_f >= 0) // Fit is still OK
00995                {
00996 
00997                     if (itert > 3)
00998                     {
00999                          indst.clear();
01000                          arest.clear();
01001 
01002                          for (j=rank_i; j<rank_f; j++)
01003                          {
01004                               indst.push_back(storeind[j]);
01005 
01006                               if (storenl[j] == 0) arest.push_back(storeare[j]);
01007                               if (storenl[j] == 1) arest.push_back(track_slopes[2*i]*storeare[j]);
01008                               if (storenl[j] == 2) arest.push_back(track_slopes[2*i+1]*storeare[j]);
01009                          }
01010 
01011                          for (j=0; j<2*nalc; j++) {trackpars[j] = 0.;}  
01012 
01013                          Millepede::FitLoc(i,trackpars,1);
01014 
01015                          track_slopes[2*i] = trackpars[2];
01016                          track_slopes[2*i+1] = trackpars[6];
01017                     }
01018 
01019                     indst.clear();
01020                     arest.clear();
01021 
01022                     for (j=rank_i; j<rank_f; j++)
01023                     {
01024                          indst.push_back(storeind[j]);
01025 
01026                          if (storenl[j] == 0) arest.push_back(storeare[j]);
01027                          if (storenl[j] == 1) arest.push_back(track_slopes[2*i]*storeare[j]);
01028                          if (storenl[j] == 2) arest.push_back(track_slopes[2*i+1]*storeare[j]);
01029                     }
01030 
01031                     for (j=0; j<2*nalc; j++) {trackpars[j] = 0.;}       
01032 
01033                     bool sc = Millepede::FitLoc(i,trackpars,0);
01034 
01035                     (sc) 
01036                          ? nstillgood++
01037                          : storeplace[i] = -rank_f;     
01038                }
01039           } // End of loop on fits
01040 
01041           Millepede::SetTrackNumber(nstillgood);
01042 
01043      } // End of iteration loop
01044 
01045      Millepede::PrtGlo(); // Print the final results
01046 
01047      for (j=0; j<nagb; j++)
01048      {
01049           par[j]   = dparm[j];
01050           dparm[j] = 0.;
01051           pull[j]  = par[j]/sqrt(psigm[j]*psigm[j]-cgmat[j][j]);
01052           error[j] = sqrt(fabs(cgmat[j][j]));
01053      }
01054 
01055      cout << std::setw(10) << " " << endl;
01056      cout << std::setw(10) << "            * o o                   o      " << endl;
01057      cout << std::setw(10) << "              o o                   o      " << endl;
01058      cout << std::setw(10) << "   o ooooo  o o o  oo  ooo   oo   ooo  oo  " << endl;
01059      cout << std::setw(10) << "    o  o  o o o o o  o o  o o  o o  o o  o " << endl;
01060      cout << std::setw(10) << "    o  o  o o o o oooo o  o oooo o  o oooo " << endl;
01061      cout << std::setw(10) << "    o  o  o o o o o    ooo  o    o  o o    " << endl;
01062      cout << std::setw(10) << "    o  o  o o o o  oo  o     oo   ooo  oo ++ ends." << endl;
01063      cout << std::setw(10) << "                       o                   " << endl;      
01064 
01065      return true;
01066 }

bool Millepede::ParGlo int  index,
double  param
 

bool Millepede::ParGlo int  index,
double  param
 

00182 {
00183      if (index<0 || index>=nagb)
00184      {return false;}
00185      else
00186      {pparm[index] = param;}
00187 
00188      return true;
00189 }

bool Millepede::ParSig int  index,
double  sigma
 

bool Millepede::ParSig int  index,
double  sigma
 

00209 {
00210      if (index>=nagb) 
00211      {return false;}
00212      else
00213      {psigm[index] = sigma;}
00214 
00215      return true;
00216 }

bool Millepede::PrtGlo  )  [private]
 

bool Millepede::PrtGlo  )  [private]
 

01419 {
01420      double err, gcor;
01421 
01422      cout << "" << endl;
01423      cout << "   Result of fit for global parameters" << endl;
01424      cout << "   ===================================" << endl;
01425      cout << "    I       initial       final       differ   " 
01426           << "     lastcor        Error       gcor" << endl;
01427      cout << "-----------------------------------------" 
01428           << "------------------------------------------" << endl;
01429 
01430      for (int i=0; i<nagb; i++)
01431      {
01432           err = sqrt(fabs(cgmat[i][i]));
01433           if (cgmat[i][i] < 0.0) err = -err;
01434           gcor = 0.0;
01435 
01436           if (i%(nagb/6) == 0)
01437           {
01438                cout << "-----------------------------------------" 
01439                     << "------------------------------------------" << endl;
01440           }
01441 
01442 //         cout << "cgmat[" << i << "][" << i << "] = " << cgmat[i][i]; 
01443 //         cout << "        diag[" << i << "] = " << diag[i] << endl;
01444           if (fabs(cgmat[i][i]*diag[i]) > 0)
01445           {
01446                cout << std::setprecision(4) << std::fixed;
01447                gcor = sqrt(fabs(1.0-1.0/(cgmat[i][i]*diag[i])));
01448                cout << std::setw(4) << i << "  / " << std::setw(10) << pparm[i] 
01449                     << "  / " << std::setw(10) << pparm[i]+ dparm[i] 
01450                     << "  / " << std::setw(13) << dparm[i] 
01451                     << "  / " << std::setw(13) << bgvec[i] << "  / " << std::setw(10) 
01452                     << std::setprecision(5) << err << "  / " << std::setw(10) << gcor << endl;
01453           }
01454           else
01455           {
01456                cout << std::setw(4) << i << "  / " << std::setw(10) << "OFF" 
01457                     << "  / " << std::setw(10) << "OFF" 
01458                     << "  / " << std::setw(13) << "OFF" 
01459                     << "  / " << std::setw(13) << "OFF" 
01460                     << "  / " << std::setw(10) << "OFF" 
01461                     << "  / " << std::setw(10) << "OFF" << endl;
01462           }
01463      }
01464      return true;
01465 }

void Millepede::SetTrackNumber int  value  ) 
 

void Millepede::SetTrackNumber int  value  ) 
 

01515 {m_track_number = value;}

bool Millepede::SpAVAt double  v[][mlocal],
double  a[][mlocal],
double  w[][mglobl],
int  n,
int  m
[private]
 

bool Millepede::SpAVAt double  v[][mlocal],
double  a[][mlocal],
double  w[][mglobl],
int  n,
int  m
[private]
 

01350 {
01351      int i,j, k, l; 
01352 
01353      for (i=0; i<m; i++)
01354      {
01355           for (j=0; j<m; j++)   // Could be improved as matrix symmetric
01356           {
01357                w[i][j] = 0.0;      // Reset final matrix
01358 
01359                for (k=0; k<n; k++)
01360                {
01361                     for (l=0; l<n; l++)
01362                     {
01363                          w[i][j] += a[i][k]*v[k][l]*a[j][l];  // fill the matrix
01364                     }
01365                }
01366           }
01367      }
01368 
01369      return true;
01370 }

bool Millepede::SpAX double  a[][mlocal],
double  x[],
double  y[],
int  n,
int  m
[private]
 

bool Millepede::SpAX double  a[][mlocal],
double  x[],
double  y[],
int  n,
int  m
[private]
 

01390 {
01391      int i,j; 
01392 
01393      for (i=0; i<m; i++)
01394      {
01395           y[i] = 0.0;       // Reset final vector
01396 
01397           for (j=0; j<n; j++)
01398           {
01399                y[i] += a[i][j]*x[j];  // fill the vector
01400           }
01401      }
01402 
01403      return true;
01404 }

int Millepede::SpmInv double  v[][mlocal],
double  b[],
int  n,
double  diag[],
bool  flag[]
[private]
 

int Millepede::SpmInv double  v[][mgl],
double  b[],
int  n,
double  diag[],
bool  flag[]
[private]
 

int Millepede::SpmInv double  v[][mlocal],
double  b[],
int  n,
double  diag[],
bool  flag[]
[private]
 

01227 {
01228      int i, j, jj, k;
01229      double vkk, *temp;
01230      double eps = 0.0000000000001;
01231 
01232      temp = new double[n];
01233 
01234      for (i=0; i<n; i++)
01235      {
01236           flag[i] = true;
01237           diag[i] = fabs(v[i][i]);     // save diagonal elem absolute values    
01238 
01239           for (j=0; j<=i; j++)
01240           {
01241                v[j][i] = v[i][j] ;
01242           }
01243      }
01244 
01245      nrank = 0;
01246 
01247      for (i=0; i<n; i++)
01248      {
01249           vkk = 0.0;
01250           k = -1;
01251 
01252           for (j=0; j<n; j++) // First look for the pivot, ie max unused diagonal element 
01253           {
01254                if (flag[j] && (fabs(v[j][j])>std::max(fabs(vkk),eps*diag[j])))
01255                {
01256                     vkk = v[j][j];
01257                     k = j;
01258                }
01259           }
01260 
01261           if (k >= 0)    // pivot found
01262           {
01263                nrank++;
01264                flag[k] = false;
01265                vkk = 1.0/vkk;
01266                v[k][k] = -vkk; // Replace pivot by its inverse
01267 
01268                for (j=0; j<n; j++)
01269                {
01270                     for (jj=0; jj<n; jj++)  
01271                     {
01272                          if (j != k && jj != k) // Other elements (!!! do them first as you use old v[k][j]'s !!!)
01273                          {
01274                               v[j][jj] = v[j][jj] - vkk*v[j][k]*v[k][jj];
01275                          }                                      
01276                     }                                   
01277                }
01278 
01279                for (j=0; j<n; j++)
01280                {
01281                     if (j != k) // Pivot row or column elements 
01282                     {
01283                          v[j][k] = (v[j][k])*vkk; // Column
01284                          v[k][j] = (v[k][j])*vkk; // Line
01285                     }
01286                }                                        
01287           }
01288           else  // No more pivot value (clear those elements)
01289           {
01290                for (j=0; j<n; j++)
01291                {
01292                     if (flag[j])
01293                     {
01294                          b[j] = 0.0;
01295 
01296                          for (k=0; k<n; k++)
01297                          {
01298                               v[j][k] = 0.0;
01299                          }
01300                     }                           
01301                }
01302 
01303                break;  // No more pivots anyway, stop here
01304           }
01305      }
01306 
01307      for (j=0; j<n; j++)
01308      {
01309           temp[j] = 0.0;
01310 
01311           for (jj=0; jj<n; jj++)  // Reverse matrix elements
01312           {
01313                v[j][jj] = -v[j][jj];
01314                temp[j] += v[j][jj]*b[jj];
01315           }                                     
01316      }
01317 
01318      for (j=0; j<n; j++)
01319      {  
01320           b[j] = temp[j];
01321      }                                  
01322 
01323      delete temp;
01324 
01325      return nrank;
01326 }

int Millepede::SpmInv double  v[][mgl],
double  b[],
int  n,
double  diag[],
bool  flag[]
[private]
 

01084 {
01085      int i, j, jj, k;
01086      double vkk, *temp;
01087      double  *r, *c;
01088      double eps = 0.00000000000001;
01089 
01090      r = new double[n];
01091      c = new double[n];
01092 
01093      temp = new double[n];
01094 
01095      for (i=0; i<n; i++)
01096      {
01097           r[i] = 0.0;
01098           c[i] = 0.0;
01099           flag[i] = true;
01100 
01101           for (j=0; j<=i; j++) {if (v[j][i] == 0) {v[j][i] = v[i][j];}}
01102      }
01103 
01104      // Small loop for matrix equilibration (gives a better conditioning) 
01105 
01106      for (i=0; i<n; i++)
01107      {
01108           for (j=0; j<n; j++)
01109           { 
01110                if (fabs(v[i][j]) >= r[i]) r[i] = fabs(v[i][j]); // Max elemt of row i
01111                if (fabs(v[j][i]) >= c[i]) c[i] = fabs(v[j][i]); // Max elemt of column i
01112           }
01113      }
01114 
01115      for (i=0; i<n; i++)
01116      {
01117           if (0.0 != r[i]) r[i] = 1./r[i]; // Max elemt of row i
01118           if (0.0 != c[i]) c[i] = 1./c[i]; // Max elemt of column i
01119 
01120           //    if (eps >= r[i]) r[i] = 0.0; // Max elemt of row i
01121           //    if (eps >= c[i]) c[i] = 0.0; // Max elemt of column i
01122      }
01123 
01124      for (i=0; i<n; i++) // Equilibrate the V matrix
01125      {
01126           for (j=0; j<n; j++) {v[i][j] = sqrt(r[i])*v[i][j]*sqrt(c[j]);}
01127      }
01128 
01129      nrank = 0;
01130 
01131      // save diagonal elem absolute values      
01132      for (i=0; i<n; i++) {diag[i] = fabs(v[i][i]);} 
01133 
01134      for (i=0; i<n; i++)
01135      {
01136           vkk = 0.0;
01137           k = -1;
01138 
01139           for (j=0; j<n; j++) // First look for the pivot, ie max unused diagonal element 
01140           {
01141                if (flag[j] && (fabs(v[j][j])>std::max(fabs(vkk),eps*diag[j])))
01142                {
01143                     vkk = v[j][j];
01144                     k = j;
01145                }
01146           }
01147 
01148           if (k >= 0)    // pivot found
01149           {      
01150                if (verbose_mode) cout << "Pivot value :" << vkk << endl;
01151                nrank++;
01152                flag[k] = false; // This value is used
01153                vkk = 1.0/vkk;
01154                v[k][k] = -vkk; // Replace pivot by its inverse
01155 
01156                for (j=0; j<n; j++)
01157                {
01158                     for (jj=0; jj<n; jj++)  
01159                     {
01160                          if (j != k && jj != k) // Other elements (!!! do them first as you use old v[k][j]'s !!!)
01161                          {
01162                               v[j][jj] = v[j][jj] - vkk*v[j][k]*v[k][jj];
01163                          }                                      
01164                     }                                   
01165                }
01166 
01167                for (j=0; j<n; j++)
01168                {
01169                     if (j != k) // Pivot row or column elements 
01170                     {
01171                          v[j][k] = (v[j][k])*vkk;       // Column
01172                          v[k][j] = (v[k][j])*vkk;       // Line
01173                     }
01174                }        
01175           }
01176           else   // No more pivot value (clear those elements)
01177           {
01178                for (j=0; j<n; j++)
01179                {
01180                     if (flag[j])
01181                     {
01182                          b[j] = 0.0;
01183 
01184                          for (k=0; k<n; k++)
01185                          {
01186                               v[j][k] = 0.0;
01187                               v[k][j] = 0.0;
01188                          }
01189                     }                           
01190                }
01191 
01192                break;  // No more pivots anyway, stop here
01193           }
01194      }
01195 
01196      for (i=0; i<n; i++) // Correct matrix V
01197      {
01198           for (j=0; j<n; j++) {v[i][j] = sqrt(c[i])*v[i][j]*sqrt(r[j]);}
01199      }
01200 
01201      for (j=0; j<n; j++)
01202      {
01203           temp[j] = 0.0;
01204 
01205           for (jj=0; jj<n; jj++)  // Reverse matrix elements
01206           {
01207                v[j][jj] = -v[j][jj];
01208                temp[j] += v[j][jj]*b[jj];
01209           }                                     
01210      }
01211 
01212      for (j=0; j<n; j++) {b[j] = temp[j];}      // The final result                             
01213 
01214      delete temp;
01215      delete r;
01216      delete c;
01217 
01218      return nrank;
01219 }

bool Millepede::ZerLoc double  dergb[],
double  derlc[],
double  dernl[]
 

bool Millepede::ZerLoc double  dergb[],
double  derlc[],
double  dernl[]
 

00388 {
00389      for(int i=0; i<nalc; i++) {derlc[i] = 0.0;}
00390      for(int i=0; i<nagb; i++) {dergb[i] = 0.0;}
00391      for(int i=0; i<nagb; i++) {dernl[i] = 0.0;}
00392 
00393      return true;
00394 }


Member Data Documentation

double Millepede::adercs [private]
 

std::vector<double> Millepede::arenl [private]
 

std::vector<double> Millepede::arenl [private]
 

std::vector<double> Millepede::arest [private]
 

std::vector<double> Millepede::arest [private]
 

double Millepede::arhs [private]
 

double Millepede::bgvec [private]
 

double Millepede::blvec [private]
 

double Millepede::cfactr [private]
 

double Millepede::cfactref [private]
 

double Millepede::cgmat [private]
 

double Millepede::clcmat [private]
 

double Millepede::clmat [private]
 

double Millepede::corrm [private]
 

double Millepede::corrv [private]
 

double Millepede::diag [private]
 

double Millepede::dparm [private]
 

int Millepede::indbk [private]
 

int Millepede::indgb [private]
 

int Millepede::indlc [private]
 

int Millepede::indnz [private]
 

std::vector<int> Millepede::indst [private]
 

std::vector<int> Millepede::indst [private]
 

int Millepede::itert [private]
 

int Millepede::locrej [private]
 

int Millepede::loctot [private]
 

double Millepede::m_residual_cut [private]
 

double Millepede::m_residual_cut_init [private]
 

int Millepede::m_track_number [private]
 

const int Millepede::mcs = 10 [static, private]
 

const int Millepede::mgl = 410 [static, private]
 

const int Millepede::mglobl = 400 [static, private]
 

const int Millepede::mlocal = 20 [static, private]
 

int Millepede::nagb [private]
 

int Millepede::nalc [private]
 

int Millepede::ncs [private]
 

int Millepede::nfl [private]
 

int Millepede::nlnpa [private]
 

int Millepede::nrank [private]
 

int Millepede::nst [private]
 

int Millepede::nstdev [private]
 

double Millepede::pparm [private]
 

double Millepede::psigm [private]
 

double Millepede::scdiag [private]
 

bool Millepede::scflag [private]
 

int Millepede::store_row_size [private]
 

std::vector<double> Millepede::storeare [private]
 

std::vector<double> Millepede::storeare [private]
 

std::vector<int> Millepede::storeind [private]
 

std::vector<int> Millepede::storeind [private]
 

std::vector<double> Millepede::storenl [private]
 

std::vector<double> Millepede::storenl [private]
 

std::vector<int> Millepede::storeplace [private]
 

std::vector<int> Millepede::storeplace [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:32:13 2011 for BOSS6.5.5 by  doxygen 1.3.9.1