CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Fit.cc
Go to the documentation of this file.
2 // COCOA class implementation file
3 //Id: Fit.cc
4 //CAT: Fit
5 //
6 // History: v1.0
7 // Pedro Arce
8 
9 #include <cstdlib>
10 #include <iomanip>
11 #include <cmath>
12 #include <ctime>
13 #include <set>
14 
15 
19 
29 #ifdef COCOA_VIS
30 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
31 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
32 #endif
39 
40 
41 Fit* Fit::instance = 0;
42 
47 //op ALIMatrix* Fit::VaMatrix;
49 //op ALIMatrix* Fit::PDMatrix;
50 //-ALIMatrix* Fit::VyMatrix;
52 //ALIMatrix* Fit::fMatrix;
53 
56 //op ALIMatrix* Fit::thePropagationMatrix;
57 
65 
67 
68 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
69 //@@ Gets the only instance of Model
70 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
72 {
73  if(!instance) {
74  instance = new Fit;
75  ALIdouble go;
77 
78  gomgr->getGlobalOptionValue("maxDeviDerivative", go );
80  if( ALIUtils::debug >= 3 ) std::cout << " Fit::maximum_deviation_derivative " << ALIUtils::getMaximumDeviationDerivative() << std::endl;
81 
82  gomgr->getGlobalOptionValue("maxNoFitIterations", go );
83  MaxNoFitIterations = int(go);
84 
85  gomgr->getGlobalOptionValue("fitQualityCut", go );
86  theFitQualityCut = go;
87  if( ALIUtils::debug >= 3 ) std::cout << " theFitQualityCut " << theFitQualityCut << std::endl;
88 
89  gomgr->getGlobalOptionValue("RelativeFitQualityCut", go );
91  if( ALIUtils::debug >= 3 ) std::cout << " theRelativeFitQualityCut " << theRelativeFitQualityCut << std::endl;
92 
93  gomgr->getGlobalOptionValue("minDaFactor", go );
94  theMinDaFactor = go;
95 
96  }
97 
98  return *instance;
99 }
100 
101 
102 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
103 //@@ startFit: steering method to make the fit
104 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
106 {
107  // Model::setCocoaStatus( COCOA_InitFit );
109  if(GlobalOptionMgr::getInstance()->GlobalOptions()["rootResults"] > 0) {
110  NTmgr->BookNtuple();
111  }
112 
114 
116 
118  for(;;) {
119 
120  bool bend = fitNextEvent( nEvent );
121  if(gomgr->GlobalOptions()["writeDBOptAlign"] > 0 || gomgr->GlobalOptions()["writeDBAlign"] > 0) {
123  }
124 
125  if( !bend ){
126  if ( ALIUtils::debug >= 1) std::cout << "@@@ Fit::startFit ended n events = " << nEvent << std::endl;
127  break;
128  }
129 
130  //- if ( ALIUtils::debug >= 0) std::cout << " FIT STATUS " << Model::printCocoaStatus( Model::getCocoaStatus() ) << std::endl;
131 
132  nEvent++;
133 
134  }
135 
136  //---------- Program ended, fill histograms of fitted entries
137  if(gomgr->GlobalOptions()["histograms"] > 0) {
139  FEmgr->MakeHistos();
140  }
141 
142  if(GlobalOptionMgr::getInstance()->GlobalOptions()["rootResults"] > 0) {
143  NTmgr->WriteNtuple();
144  }
145 }
146 
147 
148 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
150 {
152 
153  //----- Reset coordinates to those read at the start
154  std::vector< OpticalObject* >::iterator voite;
155  for( voite = Model::OptOList().begin(); voite != Model::OptOList().end(); ++voite ) {
156  (*voite)->resetOriginalOriginalCoordinates();
157  }
158 
159  //----- Reset entries displacements to 0.
160  std::vector< Entry* >::iterator veite;
161  for( veite = Model::EntryList().begin(); veite != Model::EntryList().end(); ++veite ) {
162  (*veite)->resetValueDisplacementByFitting();
163  }
164 
165 
166  ALIbool lastEvent = 0;
167 
168  //- DeviationsFromFileSensor2D::setApply( 1 );
169 
170  //m ALIbool moreDataSets = Model::readMeasurementsFromFile( Measurement::only1Date, Measurement::only1Time );
171 
172  //----- Check if there are more data sets
173  ALIbool moreDataSets = 1;
175 
176  if(ALIUtils::debug >= 5) std::cout << CocoaDaqReader::GetDaqReader() << "$$$$$$$$$$$$$$$ More Data Sets to be processed: " << moreDataSets << std::endl;
177 
178  if( moreDataSets ) {
179  if( ALIUtils::debug >= 2 ) std::cout << std::endl << "@@@@@@@@@@@@@@@@@@ Starting data set fit : " << nEvent << std::endl;
180 
181  //----- Count entries to be fitted, and set their order in theFitPos
183 
184  //----- Dump dimensions of output in 'report.out' file
186  fileout << std::endl << "@@@@@@@ NEW MEASUREMENT SET " << nEvent << std::endl;
187  if( ALIUtils::report >= 1 ) ALIUtils::dumpDimensions( fileout );
188 
189  //----- reset Number of iterations of non linear fit
190  theNoFitIterations = 0;
191 
193  ALIdouble dumpMat;
194  gomgr->getGlobalOptionValue("save_matrices", dumpMat );
195 
196  //----- Fit parameters
197  double daFactor = 1.;
199  for(;; ){
200  if(ALIUtils::debug >= 2) {
201  std::cout << std::endl << "Fit iteration " << theNoFitIterations << " ..." << std::endl;
202  }
203 
204  //---------- Calculate the original simulated values of each Measurement (when all entries have their read in values)
205  calculateSimulatedMeasurementsWithOriginalValues(); //?? original changed atfer each iteration
206 
207  FitQuality fq = fitParameters( daFactor );
208  if( dumpMat > 1 ) dumpMatrices();
209 
210  //- evaluateFitQuality( fq, daFactor );
211 
212  if(ALIUtils::debug >= 2) {
213  std::cout << std::endl << "@@@@ Check fit quality for iteration " << theNoFitIterations << std::endl;
214  }
215 
216  //----- Check if new iteration must be done
217  if( fq == FQsmallDistanceToMinimum ) {
218  if(ALIUtils::debug >= 2) std::cout << std::endl << "@@@@ Fit quality: distance SMALLER than mininum " << std::endl;
221  //--- Print entries in all ancestor frames
222  ALIdouble go;
223  gomgr->getGlobalOptionValue("dumpInAllFrames", go );
225 
226  break; // No more iterations
227  } else if( fq == FQbigDistanceToMinimum ) {
228  if(ALIUtils::debug >= 2) std::cout << std::endl << "@@@@ Fit quality: distance BIGGER than mininum " << std::endl;
231 
232  //----- Next iteration (if not too many already)
234  daFactor = 1.;
235 
236  //----- Too many iterations: end event here
238  if(ALIUtils::debug >= 1) std::cerr << "!!!! WARNING: Too many iterations " << theNoFitIterations << " and fit DOES NOT CONVERGE " << std::endl;
239 
240  if(ALIUtils::report >= 2) {
242  fileout << "!!!! WARNING: Too many iterations " << theNoFitIterations << " and fit DOES NOT CONVERGE " << std::endl;
243  }
244  // Model::setCocoaStatus( COCOA_FitCannotImprove );
245  break; // No more iterations
246  }
247 
248  } else if( fq == FQchiSquareWorsened ) {
249  if(ALIUtils::debug >= 1) {
250  //----- Recalculate fit quality with decreasing values of Da
251  std::cerr << "!! WARNING: fit quality has worsened, Recalculate fit quality with decreasing values of Da " << std::endl;
252  std::cout << " quality daFactor= " << daFactor << " minimum= " << theMinDaFactor << std::endl;
253  }
254  daFactor *= 0.5;
255  if( daFactor > theMinDaFactor ){
257 
258  if(ALIUtils::report >= 2) {
260  fileout << " Redoing iteration with Da factor " << daFactor << std::endl;
261  }
262  } else {
263  daFactor *= 2.;
264  std::cerr << " !!!ERROR: not possible to get good fit quality even multiplying Da by " << daFactor << std::endl;
265  if(ALIUtils::report >= 2) {
267  fileout << " !!!ERROR: not possible to get good fit quality even multiplying Da by " << daFactor << std::endl;
268  }
269  // Model::setCocoaStatus( COCOA_FitCannotImprove );
270  //- std::cout << "fdsaf FIT STATUS " << Model::printCocoaStatus( Model::getCocoaStatus() ) << std::endl;
271  break; // No more iterations
272  }
273  }
275 
276  }
277 
278  //----- Iteration is finished: dump fitted entries
280  if(gomgr->GlobalOptions()["histograms"] > 0) {
282  }
283 
284  if(GlobalOptionMgr::getInstance()->GlobalOptions()["rootResults"] > 0) {
286  ntupleMgr->InitNtuple();
287  ntupleMgr->FillChi2();
288  ntupleMgr->FillOptObjects(AtWAMatrix);
289  ntupleMgr->FillMeasurements();
290  ntupleMgr->FillFitParameters(AtWAMatrix);
291  ntupleMgr->FillNtupleTree();
292  }
293 
294  //- only if not stopped in worsening quality state if(ALIUtils::report >= 0) dumpFittedValues( ALIFileOut::getInstance( Model::ReportFName() ));
295 
296  /*- std::vector< OpticalObject* >::iterator voite;
297  for( voite = Model::OptOList().begin(); voite != Model::OptOList().end(); voite++ ) {
298  //-?? (*voite)->resetOriginalOriginalCoordinates();
299  }*/
300 
301  //---- If no measurement file, break after looping once
302  //- std::cout << " Measurement::measurementsFileName() " << Measurement::measurementsFileName() << " Measurement::measurementsFileName()" <<std::endl;
303  if( CocoaDaqReader::GetDaqReader() == 0 ) {
304  //m if( Measurement::measurementsFileName() == "" ) {
305  if( ALIUtils::debug >= 1 ) std::cout << std::endl << "@@@@@@@@@@@@@@@@@@ Fit has ended : only one measurement " << nEvent << std::endl;
306  lastEvent = 1;
307  return !lastEvent;
308  }
309 
310  //- std::cout << " Measurement::only1" << Measurement::only1 << std::endl;
311  if( Measurement::only1 ) {
312  if( ALIUtils::debug >= 1 ) std::cout << std::endl << "@@@@@@@@@@@@@@@@@@ Fit has ended : 'Measurement::only1' is set" << std::endl;
313 
314  lastEvent = 1;
315  return !lastEvent;
316  }
317 
318  if(GlobalOptionMgr::getInstance()->GlobalOptions()["maxEvents"] <= nEvent ){
319  if( ALIUtils::debug >= 1 ) std::cout << std::endl << "@@@@@@@@@@@@@@@@@@ Fit has ended : 'Number of events exhausted " << nEvent << std::endl;
320 
321  lastEvent = 1;
322  return !lastEvent;
323  }
324 
325  } else {
326  lastEvent = 1;
327  if( ALIUtils::debug >= 1 ) std::cout << std::endl << "@@@@@@@@@@@@@@@@@@ Fit has ended : ??no more data sets' " << nEvent << std::endl;
328  return !lastEvent;
329  }
330 
331  if( ALIUtils::debug >= 1 ) std::cout << std::endl << "@@@@@@@@@@@@@@@@@@ Fit has ended : " << nEvent << std::endl;
332 
333  return !lastEvent;
334 }
335 
336 
337 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
339 {
340 #ifdef COCOA_VIS
341  if(gomgr->GlobalOptions()["VisOnly"] == 1) {
342  calculateSimulatedMeasurementsWithOriginalValues(); //?? original changed atfer each iteration
343  }
344 
346  if(gomgr->GlobalOptions()["VisWriteVRML"] > 0) {
347  if(ALIUtils::getFirstTime()) ALIVRMLMgr::getInstance().writeFile();
348  }
349  if(gomgr->GlobalOptions()["VisWriteIguana"] > 0) {
350  if(ALIUtils::getFirstTime()) IgCocoaFileMgr::getInstance().writeFile();
351  }
352 
353  if(gomgr->GlobalOptions()["VisOnly"] == 1) {
354  if(ALIUtils::debug >= 1 )std::cout << " Visualiation file(s) succesfully written. Ending.... " << std::endl;
355  exit(1);
356  }
357 #endif
358 }
359 
360 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
361 //@@ Count how many entries are going to be fitted (have quality >= theMinimumEntryQuality)
362 //@@ Set for this entries the value of theFitPos
363 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
365 {
366 
367  std::vector< Entry* >::const_iterator vecite;
368 
370  theMinimumEntryQuality = int(gomgr->GlobalOptions()[ALIstring("calcul_type")]) + 1;
371  if ( ALIUtils::debug >= 3) std::cout << "@@@ Fit::setFittableEntries: total Entry List size= " << Model::EntryList().size() << std::endl;
372 
373  int No_entry_to_fit = 0;
374  for ( vecite = Model::EntryList().begin();
375  vecite != Model::EntryList().end(); ++vecite ) {
376 
377  // Number the parameters that are going to be fitted
378  if ( (*vecite)->quality() >= theMinimumEntryQuality ) {
379  (*vecite)->setFitPos( No_entry_to_fit );
380  if( ALIUtils::debug >= 4 ) std::cout << " Entry To Fit= " << No_entry_to_fit << " " << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() << " with quality= " << (*vecite)->quality() << std::endl;
381  No_entry_to_fit++;
382  }
383  }
384 
385 }
386 
387 
388 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
389 //@@ Main method in class Fit
390 //@@ fitParameters: get the parameters through the chi square fit
391 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
392 FitQuality Fit::fitParameters( const double daFactor )
393 {
394  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::fitParameters: Fit quality daFactor " << daFactor << std::endl;
395 
396  redoMatrices();
397 
398 
399  //---- Get chi2 of first iteration
402 
404  if (gomgr->GlobalOptions()[ ALIstring("stopAfter1stIteration") ] == 1) {
405  std::cout << "@!! STOPPED by user after 1st iteration " << std::endl;
406  exit(1);
407  }
408  }
409 
410  /* //---------- Open output file
411  if( ALIUtils::report >= 1 ) {
412  ALIFileOut& fileout = ALIFileOut::getInstance( Model::ReportFName() );
413  //t fileout << " REPORT.OUT " << std::endl;
414  //t ALIUtils::dumpDimensions( fileout );
415  fileout << std::endl << "Fit iteration " << theNoFitIterations << " ..." << std::endl;
416  }*/
417 
418  //- std::cout << "2 FIT STATUS " << Model::printCocoaStatus( Model::getCocoaStatus() ) << std::endl;
419 
420  if(ALIUtils::debug >= 10) {
421  std::cout << std::endl << " End fitParameters " << theNoFitIterations << " ..." << std::endl;
422  }
423 
424  return getFitQuality();
425 
426 }
427 
428 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
430 {
431  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::redoMatrices" << std::endl;
432 
433  deleteMatrices();
434 
436 
437  PropagateErrors();
438 
439 }
440 
441 
442 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
443 //@@ Propagate the Errors from the entries to the measurements
444 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
445 //cocoaStatus
447 {
448  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::PropagateErrors" << std::endl;
449 
450  //----- Create empty matrices of appropiate size
451  CreateMatrices();
452 
453  //---- count running time
454  time_t now;
455  now = clock();
456  if(ALIUtils::debug >= 2) std::cout << "TIME:CREATE_MAT : " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
458 
459  //----- Fill the A, W & y matrices with the measurements
461 
462  //---- count running time
463  now = clock();
464  if(ALIUtils::debug >= 2) std::cout << "TIME:MAT_MEAS_FILLED: " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
466 
467  //----- Fill the A, W & y matrices with the calibrated parameters
469  if (gomgr->GlobalOptions()[ ALIstring("calcul_type") ] == 0) {
471 
472  //---- count running time
473  now = clock();
474  if(ALIUtils::debug >= 0) std::cout << "TIME:MAT_CAL_FILLED : " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
476 
477  }
478 
479  //----- Put by hand some correlations if known previously
481 
482  if(ALIUtils::debug >= 3) WMatrix->Dump("WMatrix before inverse");
483 
484  //----- Check first that matrix can be inverted
485  if( m_norm1( WMatrix->MatNonConst() ) == 0 ) {
486  // Model::setCocoaStatus( COCOA_FitMatrixNonInversable );
487  return; // Model::getCocoaStatus();
488  } else {
489  WMatrix->inverse();
490  }
491 
492  if(ALIUtils::debug >= 3) AMatrix->Dump("AMatrix");
493  if(ALIUtils::debug >= 3) WMatrix->Dump("WMatrix");
494  if(ALIUtils::debug >= 3) yfMatrix->Dump("yfMatrix");
495 
496  if(gomgr->GlobalOptions()["onlyDeriv"] >= 1) {
497  std::cout << "ENDING after derivatives are calculated ('onlyDeriv' option set)" << std::endl;
498  exit(1);
499  }
500 
502 
503  now = clock();
504  if(ALIUtils::debug >= 0) std::cout << "TIME:MAT_MULTIPLIED : " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
506 
508 
509 }
510 
511 
512 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
513 //@@ Calculate the simulated value of each Measurement propagating the LightRay when all the entries have their original values
514 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
516 {
517  // if( ALIUtils::debug >= 4) OpticalObjectMgr::getInstance()->dumpOptOs();
518 
519  //---------- Set DeviationsFromFileSensor2D::apply true
521 
522  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::calculateSimulatedMeasurementsWithOriginalValues" <<std::endl;
523  //---------- Loop Measurements
524  std::vector< Measurement* >::const_iterator vmcite;
525  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
526  //----- Calculate Simulated Value Original
527  (*vmcite)->calculateOriginalSimulatedValue();
528  }
529 
530  //---------- Set DeviationsFromFileSensor2D::apply false
531  // It cannot be applied when calculating derivatives, because after a displacement the laser could hit another square in matrix and then cause a big step in the derivative
533 
534 }
535 
536 
537 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
539 {
540  //delete matrices created in previous iteration
541  delete DaMatrix;
542  delete AMatrix;
543  delete WMatrix;
544  delete yfMatrix;
545  //op delete fMatrix;
546  delete AtMatrix;
547  delete AtWAMatrix;
548  //op delete VaMatrix;
549  //- delete VyMatrix;
550  //op delete PDMatrix;
551 
552 }
553 
554 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
555 //@@ Calculate the NoLines & NoColumns and create matrices
556 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
558 {
559 
560  //---------- Count number of measurements
561  ALIint NoMeas = 0;
562  std::vector< Measurement* >::const_iterator vmcite;
563  for ( vmcite = Model::MeasurementList().begin();
564  vmcite != Model::MeasurementList().end(); ++vmcite ) {
565  NoMeas += (*vmcite)->dim();
566  }
567  if( ALIUtils::debug >= 9) std::cout << "NOMEAS" << NoMeas << std::endl;
568 
569  //-------- Count number of 'cal'ibrated parameters
570  ALIint nEnt_cal = 0;
571  ALIint noent = 0;
572  //- std::cout << Model::EntryList().size() << std::endl;
574  if ( gomgr->GlobalOptions()[ "calcul_type" ] == 0) { // fit also 'cal' parameters
575  //- if( ALIUtils::debug >= 9) std::cout << "NOENTCALLL " << nEnt_cal << std::endl;
576  if( ALIUtils::debug >= 5 ) std::cout << " Count number of 'cal'ibrated parameters " << std::endl;
577  std::vector< Entry* >::iterator veite;
578  for ( veite = Model::EntryList().begin();
579  veite != Model::EntryList().end(); ++veite ) {
580  if ( (*veite)->quality() == 1 ) nEnt_cal++;
581  noent++;
582  if( ALIUtils::debug >= 6) {
583  std::cout <<(*veite)->quality() << " " << (*veite)->OptOCurrent()->name() << " "
584  << (*veite)->name() << " # ENT CAL " << nEnt_cal << " # ENT " << noent << std::endl;
585  }
586  }
587  }
588 
589  //---------- Count number parameters to be fitted ('cal' + 'unk')
590  ALIint NoParamFit = 0;
591  std::vector<Entry*>::const_iterator vecite;
592  for ( vecite = Model::EntryList().begin();
593  vecite != Model::EntryList().end(); ++vecite) {
594  if ( (*vecite)->quality() >= theMinimumEntryQuality ) {
595  NoParamFit++;
596  if( ALIUtils::debug >= 99) std::cout <<(*vecite)->quality() << (*vecite)->OptOCurrent()->name() << (*vecite)->name() << "NoParamFit" << NoParamFit << std::endl;
597  // break;
598  }
599  }
600 
601  //---------- Create Matrices
602  ALIint NoLinesA = NoMeas + nEnt_cal;
603  ALIint NoColumnsA = NoParamFit;
604  AMatrix = new ALIMatrix( NoLinesA, NoColumnsA );
605 
606  ALIint NoLinesW = NoLinesA;
607  ALIint NoColumnsW = NoLinesA;
608  WMatrix = new ALIMatrix( NoLinesW, NoColumnsW );
609 
610  ALIint NoLinesY = NoLinesA;
611  //op yMatrix = new ALIMatrix( NoLinesY, 1 );
612  yfMatrix = new ALIMatrix( NoLinesY, 1 );
613 
614  //op fMatrix = new ALIMatrix( NoLinesY, 1 );
615 
616  if ( ALIUtils::debug >= 4 ) std::cout << "CreateMatrices: NoLinesA = " << NoLinesA <<
617  " NoColumnsA = " << NoColumnsA << std::endl;
618 }
619 
620 
621 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
622 //@@ Loop Measurements:
623 //@@ Fill Matrix A with derivatives respect to affecting entries
624 //@@ Fill Matrix W, y & f with values and sigmas of measurement coordinate
625 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
627 {
628  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::FillMatricesWithMeasurements" << std::endl;
629 
630  int Aline = 0;
631 
632  //---------- Loop Measurements
633  std::vector<Measurement*>::const_iterator vmcite;
634  std::vector<Entry*>::const_iterator vecite;
635  for ( vmcite = Model::MeasurementList().begin();
636  vmcite != Model::MeasurementList().end(); ++vmcite) {
637  if( ALIUtils::debug >= 5 ) std::cout << "FillMatricesWithMeasurements: measurement " << (*vmcite)->name() << " # entries affecting " <<(*vmcite)->affectingEntryList().size() << std::endl;
638 
639  //-------- Array of derivatives with respect to entries
640  ALIint measdim = (*vmcite)->dim();
641  std::vector<ALIdouble> derivRE;
642  // derivRE = new ALIdouble[measdim];
643 
644  //-------- Fill matrix A:
645  //------ Loop only Entries affecting this Measurement
646  //-std::cout << "number affecting entries: " << (*vmcite)->affectingEntryList().size() << std::endl;
647  for ( vecite = (*vmcite)->affectingEntryList().begin();
648  vecite != (*vmcite)->affectingEntryList().end(); ++vecite) {
649  //-------- If good quality, get derivative of measurement with respect to this Entry
650  if ( (*vecite)->quality() >= theMinimumEntryQuality ) {
651  if ( ALIUtils::debug >= 4) {
652  // std::cout << "FillMatricesWithMeasurements: filling element ( " << Aline << " - " << Aline+measdim-1 << " , " << (*vecite)->fitPos() << std::endl;
653  std::cout <<"entry affecting: " << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() <<std::endl;
654  }
655  derivRE = (*vmcite)->DerivativeRespectEntry(*vecite);
656  //---------- Fill matrix A with derivatives
657  for ( ALIuint jj = 0; jj < ALIuint(measdim); jj++) {
658  AMatrix->AddData( Aline+jj, (*vecite)->fitPos(), derivRE[jj] );
659  if( ALIUtils::debug >= 5) std::cout << "FillMatricesWithMeasurements: AMATRIX (" << Aline+jj << "," << (*vecite)->fitPos() << " = " << derivRE[jj] << std::endl;
660  //---------- Reset Measurement simulated_value
661  (*vmcite)->setValueSimulated( jj, (*vmcite)->valueSimulated_orig(jj) );
662  }
663  }
664  }
665  // delete[] derivRE;
666 
667  //---------- Fill matrices W, y and f:
668  //------ Loop Measurement coordinates
669  for ( ALIuint jj=0; jj < ALIuint((*vmcite)->dim()); jj++) {
670  ALIdouble sigma = (*vmcite)->sigma()[jj];
671  if ( sigma == 0. ) {
672  std::cerr << "EXITING: Measurement number " <<
673  vmcite - Model::MeasurementList().begin() <<
674  "has 0 error!!" << std::endl;
675  } else {
676  //----- Fill W Matrix with inverse of sigma squared
677  // multiply error by cameraScaleFactor
678  ALIdouble sigmanew = sigma * Measurement::cameraScaleFactor;
679  // std::cout << Aline+jj << " WMATRIX FILLING " << sigmanew << " * " << Measurement::cameraScaleFactor << std::endl;
680  WMatrix->AddData( Aline+jj, Aline+jj, (sigmanew*sigmanew) );
681  }
682  //op //----- Fill Matrices y with measurement value
683  //op yMatrix->AddData( Aline+jj, 0, (*vmcite)->value()[jj] );
684  //op //----- Fill f Matrix with simulated_value
685  //op fMatrix->AddData( Aline+jj, 0, (*vmcite)->valueSimulated_orig(jj) );
686  //----- Fill Matrix y - f with measurement value - simulated value
687  yfMatrix->AddData( Aline+jj, 0, (*vmcite)->value()[jj] - (*vmcite)->valueSimulated_orig(jj) );
688  // std::cout << " yfMatrix FILLING " << Aline+jj << " + " << (*vmcite)->value()[jj] - (*vmcite)->valueSimulated_orig(jj) << " meas " << (*vmcite)->name() << " val " << (*vmcite)->value()[jj] << " simu val " << (*vmcite)->valueSimulated_orig(jj) << std::endl;
689  }
690  if ( ALIUtils::debug >= 99) std::cout << "change line" << Aline << std::endl;
691  Aline += measdim;
692  if ( ALIUtils::debug >= 99) std::cout << "change line" << Aline << std::endl;
693 
694  }
695 
696  if ( ALIUtils::debug >= 4) AMatrix->Dump("Matrix A with meas");
697  if ( ALIUtils::debug >= 4) WMatrix->Dump("Matrix W with meas");
698  if ( ALIUtils::debug >= 4) yfMatrix->Dump("Matrix y with meas");
699 
700 }
701 
702 
703 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
704 //@@ Loop Measurements:
705 //@@ Fill Matrix A with derivatives respect to affecting entries
706 //@@ Fill Matrix W, y & f with values and sigmas of measurement coordinate
707 //@@
708 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
710 {
711  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::FillMatricesWithCalibratedParameters" << std::endl;
712 
713  //---------- Count how many measurements
714  ALIint NolinMes = 0;
715  std::vector<Measurement*>::const_iterator vmcite;
716  for ( vmcite = Model::MeasurementList().begin();
717  vmcite != Model::MeasurementList().end(); ++vmcite) {
718  NolinMes += (*vmcite)->dim();
719  }
720  if(ALIUtils::debug>=4) std::cout << "@@FillMatricesWithCalibratedParameters" << std::endl;
721 
722  std::vector< Entry* >::const_iterator vecite;
723  ALIint nEntcal = 0;
724  //---------- Loop entries
725  for ( vecite = Model::EntryList().begin();
726  vecite != Model::EntryList().end(); ++vecite ) {
727 // (= No parameters to be fitted - No parameters 'unk' )
728  //- std::cout << "entry" << (*veite) << std::endl;
729  //----- Take entries of quality = 'cal'
730  if ( (*vecite)->quality() == 1 ){
731  //--- Matrix A: fill diagonals with 1. (derivatives of entry w.r.t itself)
732  ALIint lineNo = NolinMes + nEntcal;
733  ALIint columnNo = (*vecite)->fitPos(); //=? nEntcal
734  AMatrix->AddData( lineNo, columnNo, 1. );
735  if(ALIUtils::debug >= 4) std::cout << "Fit::FillMatricesWithCalibratedParameters: AMatrix ( " << lineNo << " , " << columnNo << ") = " << 1. << std::endl;
736 
737  //--- Matrix W: sigma*sigma
738  ALIdouble entsig = (*vecite)->sigma();
739  if(ALIUtils::debug >= 4) std::cout << "Fit::FillMatricesWithCalibratedParameters: WMatrix ( " << lineNo << " , " << columnNo << ") = " << entsig*entsig << std::endl;
740  WMatrix->AddData( lineNo, lineNo, entsig*entsig );
741 
742  //--- Matrix y & f: fill it with 0.
743  //op yMatrix->AddData( lineNo, 0, (*vecite)->value());
744  //op yfMatrix->AddData( lineNo, 0, (*vecite)->value());
745  ALIdouble calFit;
747  gomgr->getGlobalOptionValue("calParamInyfMatrix", calFit );
748  if( calFit ) {
749  yfMatrix->AddData( lineNo, 0, -(*vecite)->valueDisplacementByFitting() );
750  //- yfMatrix->AddData( lineNo, 0, (*vecite)->value() );
751  //- yfMatrix->AddData( lineNo, 0, (*vecite)->lastAdditionToValueDisplacementByFitting() );
752  //- ALIFileOut& fileout = ALIFileOut::getInstance( Model::ReportFName() );
753  // fileout << "cal to yf " << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() << " " << (*vecite)->valueDisplacementByFitting() << endl;
754  // std::cout << "call to yf " << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() << " " << (*vecite)->valueDisplacementByFitting() << std::endl;
755 
756  } else {
757  yfMatrix->AddData( lineNo, 0, 0. );
758  }
759  //t if(ALIUtils::debug >= 5) std::cout << "Fit::FillMatricesWithCalibratedParameters: yfMatrix ( " << lineNo << " , " << columnNo << ") = " << (*yfMatrix)(lineNo)(0) << std::endl;
760  nEntcal++;
761  }
762  }
763 
764 }
765 
766 
767 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
768 //@@ Gets the only instance of Model
769 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
771 {
772  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::setCorrelationsInWMatrix" << std::endl;
773 
774  //----- Check if there are correlations to input
776  ALIint siz = corrMgr->getNumberOfCorrelations();
777  if( siz == 0 ) return;
778 
779  //----- Set correlations
780  ALIuint ii;
781  for( ii = 0; ii < ALIuint(siz); ii++ ){
782  //t if(ALIUtils::debug >= 5) std::cout << "globaloption cmslink fit" << Model::GlobalOptions()["cms_link"] << std::endl;
783  ErrorCorrelation* corr = corrMgr->getCorrelation( ii );
785  }
786 
787 }
788 
789 
790 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
791 //@@ set correlation between two entries of two OptOs
792 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
793 void Fit::setCorrelationFromParamFitted( const pss& entry1, const pss& entry2,
794  ALIdouble correl )
795 {
796 
797  ALIint pmsize = WMatrix->NoLines();
798  ALIint fit_pos1 = Model::getEntryByName(entry1.first, entry1.second)->fitPos();
799  ALIint fit_pos2 = Model::getEntryByName(entry2.first, entry2.second)->fitPos();
800  std::cout << "CHECKsetCorrelatiFPF " << fit_pos1 << " " << fit_pos2 << std::endl;
801 
802  if( fit_pos1 >= 0 && fit_pos1 < pmsize && fit_pos2 >= 0 && fit_pos2 < pmsize ) {
803  setCorrelationFromParamFitted( fit_pos1, fit_pos2, correl );
804  }
805 }
806 
807 
808 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
809 void Fit::setCorrelationFromParamFitted( const ALIint fit_pos1, const ALIint fit_pos2, ALIdouble correl )
810 {
811  // ALIdouble error1 = sqrt( (*WMatrix)(fit_pos1, fit_pos1) );
812  // ALIdouble error2 = sqrt( (*WMatrix)(fit_pos2, fit_pos2) );
813  WMatrix->SetCorrelation( fit_pos1, fit_pos2, correl );
814  std::cout << "setCorrelatiFPF " << fit_pos1 << " " << fit_pos2 << " " << correl << std::endl;
815 }
816 
817 
818 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
819 //@@ multiply matrices needed for fit
820 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
822 {
823  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::multiplyMatrices " << std::endl;
824  //---------- Calculate transpose of A
825  AtMatrix = new ALIMatrix( *AMatrix );
826  if(ALIUtils::debug >= 5) AtMatrix->Dump("AtMatrix=A");
827  //- std::cout << "call transpose";
828  AtMatrix->transpose();
829  if(ALIUtils::debug >= 4) AtMatrix->Dump("AtMatrix");
830 
831  //---------- Calculate At * W * A
832  AtWAMatrix = new ALIMatrix(0, 0);
833  // if(ALIUtils::debug >= 5) AtWAMatrix->Dump("AtWAMatrix=0");
834  *AtWAMatrix = *AtMatrix * *WMatrix * *AMatrix;
835  if(ALIUtils::debug >= 5) AtWAMatrix->Dump("AtWAMatrix");
836 
838 
839  //t AtWAMatrix->EliminateLines(0,48);
840  //t AtWAMatrix->EliminateColumns(0,48);
841  time_t now;
842  now = clock();
843  if(ALIUtils::debug >= 0) std::cout << "TIME:BEFORE_INVERSE : " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
845 
846  /* std::cout << " DETERMINANT W " << m_norm1( AtWAMatrix->MatNonConst() ) << std::endl;
847  if( m_norm1( AtWAMatrix->MatNonConst() ) == 0 ) {
848  std::cout << " DETERMINANT W " << m_norm1( AtWAMatrix->MatNonConst() ) << std::endl;
849  std::exception();
850  } */
851 
852  AtWAMatrix->inverse();
853  if(ALIUtils::debug >= 4) AtWAMatrix->Dump("inverse AtWAmatrix");
854  now = clock();
855  if(ALIUtils::debug >= 0) std::cout << "TIME:AFTER_INVERSE : " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
857 
858  //op thePropagationMatrix = AtWAMatrix;
859 
860  //op VaMatrix = new ALIMatrix( *AtWAMatrix );
861 
862  //----- Print out propagated errors of parameters (=AtWA diagonal elements)
863  std::vector< Entry* >::const_iterator vecite;
864 
865  if( ALIUtils::debug >= 4 ) {
866  std::cout << "PARAM" << " Optical Object " << " entry name " << " Param.Value "
867  << " Prog.Error" << " Orig.Error" << std::endl;
868  }
869 
870  ALIint nEnt = 0;
871  ALIint nEntUnk = 0;
872  for ( vecite = Model::EntryList().begin();
873  vecite != Model::EntryList().end(); ++vecite ) {
874 //------------------ Number of parameters 'cal'
875 // (= No parameters to be fitted - No parameters 'unk' )
876  if( (*vecite)->quality() >= theMinimumEntryQuality ){
877  if( ALIUtils::debug >= 4) {
878  std::cout << nEnt << "PARAM" << std::setw(26)
879  << (*vecite)->OptOCurrent()->name().c_str()
880  << std::setw(8) << " " << (*vecite)->name().c_str() << " "
881  << std::setw(8) << " " << (*vecite)->value() << " "
882  << std::setw(8) << sqrt(AtWAMatrix->Mat()->me[nEnt][nEnt]) /
883  (*vecite)->OutputSigmaDimensionFactor()
884  << " " << (*vecite)->sigma() / (*vecite)->OutputSigmaDimensionFactor()
885  << " Q" << (*vecite)->quality() << std::endl;
886  }
887  nEnt++;
888  }
889  if ( (*vecite)->quality() == 2 ) nEntUnk++;
890  }
891 
892  if(ALIUtils::debug >= 5) yfMatrix->Dump("PD(y-f)Matrix final");
893 
894 }
895 
896 
897 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
898 //@@ check also that the fit_quality = SMat(0,0) is smaller for each new iteration
899 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
901 {
902  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::getFitQuality" << std::endl;
903 
904  double fit_quality = GetSChi2(1);
905 
906  //---------- Calculate DS = Variable to recognize convergence (distance to minimum)
907  ALIMatrix* DatMatrix = new ALIMatrix( *DaMatrix );
908  // delete DaMatrix; //op
909  DatMatrix->transpose();
910  if(ALIUtils::debug >= 5) DatMatrix->Dump("DatMatrix");
911  //op ALIMatrix* DSMat = new ALIMatrix(*DatMatrix * *AtMatrix * *WMatrix * *PDMatrix);
912  ALIMatrix* DSMat = new ALIMatrix(*DatMatrix * *AtMatrix * *WMatrix * *yfMatrix);
913  if(ALIUtils::debug >= 5) {
914  ALIMatrix* DSMattemp = new ALIMatrix(*DatMatrix * *AtMatrix * *WMatrix);
915  DSMattemp->Dump("DSMattempMatrix=Dat*At*W");
916  ALIMatrix* DSMattemp2 = new ALIMatrix(*AtMatrix * *WMatrix * *yfMatrix);
917  DSMattemp2->Dump("DSMattempMatrix2=At*W*yf");
918  ALIMatrix* DSMattemp3 = new ALIMatrix(*AtMatrix * *WMatrix);
919  DSMattemp3->Dump("DSMattempMatrix3=At*W");
920  AtMatrix->Dump("AtMatrix");
921  }
922 
923  /* for( int ii = 0; ii < DatMatrix->NoColumns(); ii++ ){
924  std::cout << ii << " DS term " << (*DatMatrix)(0,ii) * (*DSMattemp2)(ii,0) << std::endl;
925  }*/
926  // delete AtMatrix; //op
927  // delete WMatrix; //op
928 
929  //op if(ALIUtils::debug >= 5) (*PDMatrix).Dump("PDMatrix");
930  if(ALIUtils::debug >= 5) (*yfMatrix).Dump("yfMatrix");
931  if(ALIUtils::debug >= 5) DSMat->Dump("DSMatrix final");
932  // delete yfMatrix; //op
933 
934  ALIdouble fit_quality_cut = (*DSMat)(0,0);
935  //- ALIdouble fit_quality_cut =fabs( (*DSMat)(0,0) );
936  delete DSMat;
937  if(ALIUtils::debug >= 0) std::cout << theNoFitIterations << " Fit quality predicted improvement in distance to minimum is = " << fit_quality_cut << std::endl;
938  if( ALIUtils::report >= 2 ) {
940  fileout << theNoFitIterations << " Fit quality predicted improvement in distance to minimum is = " << fit_quality_cut << std::endl;
941  }
942 
943  //- double fit_quality_cut = thePreviousIterationFitQuality - fit_quality;
944  //- double fit_quality_cut = fit_quality;
945  //- std::cout << " fit_quality_cut " << fit_quality_cut << " fit_quality " << fit_quality << std::endl;
946 
947  //----- Check quality
948  time_t now;
949  now = clock();
950  if(ALIUtils::debug >= 0) std::cout << "TIME:QUALITY_CHECKED: " << now << " " << difftime(now, ALIUtils::time_now())/1.E6 << std::endl;
952 
953  FitQuality fitQuality;
954 
955  //----- Chi2 is bigger, bad
956  // if( theNoFitIterations != 0 && fit_quality_cut > 0. ) {
957  if( fit_quality_cut < 0. ) {
958  fitQuality = FQchiSquareWorsened;
959  if(ALIUtils::debug >= 1) std::cerr << "!!WARNING: Fit quality has worsened: Fit Quality now = " << fit_quality
960  << " before " << thePreviousIterationFitQuality << " diff " << fit_quality - thePreviousIterationFitQuality << std::endl;
961 
962  //----- Chi2 is smaller, check if we make another iteration
963  } else {
964  ALIdouble rel_fit_quality = fabs(thePreviousIterationFitQuality - fit_quality)/fit_quality;
965  //----- Small chi2 change: end
966  if( (fit_quality_cut < theFitQualityCut || rel_fit_quality < theRelativeFitQualityCut ) && canBeGood ) {
967  if(ALIUtils::debug >= 2) std::cout << "$$ Fit::getFitQuality good " << fit_quality_cut << " <? " << theFitQualityCut
968  << " || " << rel_fit_quality << " <? " << theRelativeFitQualityCut << " GOOD " << canBeGood << std::endl;
969  fitQuality = FQsmallDistanceToMinimum;
970  if(ALIUtils::report >= 1) {
972  fileout << "STOP: SMALL IMPROVEMENT IN ITERATION " << theNoFitIterations << " = " << fit_quality_cut << " < " << theFitQualityCut << " OR (RELATIVE) " << rel_fit_quality << " < " << theRelativeFitQualityCut << std::endl;
973  }
974  if(ALIUtils::debug >= 4) {
975  std::cout << "STOP: SMALL IMPROVEMENT IN ITERATION " << theNoFitIterations << " = " << fit_quality_cut << " < " << theFitQualityCut << " OR (RELATIVE) " << rel_fit_quality << " < " << theRelativeFitQualityCut << std::endl;
976  }
977 
978  //----- Big chi2 change: go to next iteration
979  } else {
980  if(ALIUtils::debug >= 2) std::cout << "$$ Fit::getFitQuality bad " << fit_quality_cut << " <? " << theFitQualityCut << " || " << rel_fit_quality << " <? " << theRelativeFitQualityCut << " GOOD " << canBeGood << std::endl;
981  fitQuality = FQbigDistanceToMinimum;
982  //----- set thePreviousIterationFitQuality for next iteration
983  thePreviousIterationFitQuality = fit_quality;
984 
985  if(ALIUtils::report >= 2) {
987  fileout << "CONTINUE: BIG IMPROVEMENT IN ITERATION " << theNoFitIterations << " = " << fit_quality_cut << " >= " << theFitQualityCut << " AND (RELATIVE) " << rel_fit_quality << " >= " << theRelativeFitQualityCut << std::endl;
988  }
989  if(ALIUtils::debug >= 4) {
990  std::cout << "CONTINUE: BIG IMPROVEMENT IN ITERATION " << theNoFitIterations << " = " << fit_quality_cut << " >= " << theFitQualityCut << " AND (RELATIVE) " << rel_fit_quality << " >= " << theRelativeFitQualityCut << std::endl;
991  }
992  }
993  }
994 
995  return fitQuality;
996 
997 }
998 
999 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1001 {
1002  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::GetSChi2 useDa= " << useDa << std::endl;
1003 
1004  ALIMatrix* SMat = 0;
1005  if( useDa ){
1006  //----- Calculate variables to check quality of this set of parameters
1007 
1008  //----- Calculate Da = (At * W * A)-1 * At * W * (y-f)
1009  /*t DaMatrix = new ALIMatrix( *AtWAMatrix );
1010  *DaMatrix *= *AtMatrix * *WMatrix;
1011  if(ALIUtils::debug >= 5) DaMatrix->Dump("DaMatrix before yf ");
1012  *DaMatrix *= *yfMatrix;
1013  if(ALIUtils::debug >= 5) DaMatrix->Dump("DaMatrix");
1014  */
1015 
1016  DaMatrix = new ALIMatrix(0, 0);
1017  // if(ALIUtils::debug >= 5) AtWAMatrix->Dump("AtWAMatrix=0");
1018  *DaMatrix = ( *AtWAMatrix * *AtMatrix * *WMatrix * *yfMatrix);
1019  if(ALIUtils::debug >= 5) DaMatrix->Dump("DaMatrix");
1020 
1021  //----- Calculate S = chi2 = Fit quality = r^T W r (r = residual = f + A*Da - y )
1022  //op ALIMatrix* tmpM = new ALIMatrix( *AMatrix * *DaMatrix + *PDMatrix );
1023  // ALIMatrix* tmpM = new ALIMatrix( *AMatrix * *DaMatrix + *yfMatrix );
1024 
1025  ALIMatrix* tmpM = new ALIMatrix( 0,0 );
1026  *tmpM = *AMatrix * *DaMatrix - *yfMatrix;
1027  if(ALIUtils::debug >= 5) tmpM->Dump("A*Da + f - y Matrix ");
1028 
1029  ALIMatrix* tmptM = new ALIMatrix( *tmpM );
1030  tmptM->transpose();
1031  if(ALIUtils::debug >= 5) tmptM->Dump("tmptM after transpose");
1032  if(ALIUtils::debug >= 5) WMatrix->Dump("WMatrix");
1033 
1034  // std::cout << "smat " << std::endl;
1035  //o ALIMatrix* SMat = new ALIMatrix(*tmptM * *WMatrix * *tmpM);
1036  ALIMatrix* SMat1 = MatrixByMatrix(*tmptM,*WMatrix);
1037  // ALIMatrix* SMat1 = MatrixByMatrix(*AMatrix,*WMatrix);
1038  if(ALIUtils::debug >= 5) SMat1->Dump("(A*Da + f - y)^T * W Matrix");
1039  SMat = MatrixByMatrix(*SMat1,*tmpM);
1040  // std::cout << "smatc " << std::endl;
1041  delete tmpM;
1042  delete tmptM;
1043  if(ALIUtils::debug >= 5) SMat->Dump("SMatrix with Da");
1044  } else {
1045  ALIMatrix* yftMat = new ALIMatrix(*yfMatrix);
1046  yftMat->transpose();
1047  SMat = new ALIMatrix(*yftMat * *WMatrix * *yfMatrix);
1048  delete yftMat;
1049  if(ALIUtils::debug >= 5) SMat->Dump("SMatrix no Da");
1050  }
1051  ALIdouble fit_quality = (*SMat)(0,0);
1052  delete SMat;
1053  if(ALIUtils::debug >= 5) std::cout << " GetSChi2 = " << fit_quality << std::endl;
1054 
1055  PrintChi2( fit_quality, !useDa );
1056 
1057  return fit_quality;
1058 
1059 }
1060 
1061 
1062 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1063 //@@ Correct entries with fitted values
1064 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1066 {
1067 
1068  if(ALIUtils::debug >= 4) {
1069  std::cout << "@@ Adding correction (DaMatrix) to Entries " << std::endl;
1070  DaMatrix->Dump("DaMatrix =");
1071  }
1072 
1073  /*- Now there are other places where entries are changed
1074  if( ALIUtils::report >= 3 ) {
1075  ALIFileOut& fileout = ALIFileOut::getInstance( Model::ReportFName() );
1076  fileout << std::endl << " CHANGE IN ENTRIES" << std::endl
1077  << " Optical Object Parameter xxxxxx " << std::endl;
1078  }*/
1079 
1080  ALIint nEnt = 0;
1081  std::vector<Entry*>::const_iterator vecite;
1082  for ( vecite = Model::EntryList().begin();
1083  vecite != Model::EntryList().end(); ++vecite ) {
1084 //------------------ Number of parameters 'cal'
1085 // (= No parameters to be fitted - No parameters 'unk' )
1086  //- std::cout << "qual" << (*vecite)->quality() << theMinimumEntryQuality << std::endl;
1087  if ( (*vecite)->quality() >= theMinimumEntryQuality ){
1088  if ( ALIUtils::debug >= 5) {
1089  std::cout << std::endl << " @@@ PENTRY change "
1090  << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() << " "
1091  << " change= " << (*DaMatrix)(nEnt,0)
1092  << " value= " << (*vecite)->valueDisplacementByFitting()
1093  << std::endl;
1094  }
1095  /* if( ALIUtils::report >=3 ) {
1096  ALIFileOut& fileout = ALIFileOut::getInstance( Model::ReportFName() );
1097  fileout << "dd" << std::setw(30) << (*vecite)->OptOCurrent()->name()
1098  << std::setw(8) << " " << (*vecite)->name() << " "
1099  << std::setw(8) << " " << (*DaMatrix)(nEnt,0) / (*vecite)->OutputValueDimensionFactor()
1100  << " " << (*vecite)->valueDisplacementByFitting() / (*vecite)->OutputValueDimensionFactor() << " fitpos " << (*vecite)->fitPos()
1101  << std::endl;
1102  }*/
1103 
1104  //----- Store this displacement
1105  if(ALIUtils::debug >= 4) std::cout << " old valueDisplacementByFitting " << (*vecite)->name() << " " << (*vecite)->valueDisplacementByFitting() << " original value " << (*vecite)->value() <<std::endl;
1106 
1107  (*vecite)->addFittedDisplacementToValue( (*DaMatrix)(nEnt,0) );
1108 
1109  if(ALIUtils::debug >= 4) std::cout << nEnt << " new valueDisplacementByFitting " << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() << " = " << (*vecite)->valueDisplacementByFitting() << " " << (*DaMatrix)(nEnt,0) << std::endl ;
1110  nEnt++;
1111  }
1112  }
1113 
1114 }
1115 
1116 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1117 //@@ Delete the previous addition of fitted values (to try a new one daFactor times smaller )
1118 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1120 {
1121 
1122  if(ALIUtils::debug >= 4) {
1123  std::cout << "@@ Fit::substractToHalfDaMatrixToEntries " << std::endl;
1124  }
1125 
1126  std::vector<Entry*>::const_iterator vecite;
1127  for ( vecite = Model::EntryList().begin(); vecite != Model::EntryList().end(); ++vecite ) {
1128  if ( (*vecite)->quality() >= theMinimumEntryQuality ){
1129  //-- (*vecite)->addFittedDisplacementToValue( -(*DaMatrix)(nEnt,0) );!!! it is not substracting the new value of DaMatrix, but substracting the value that was added last iteration, with which the new value of DaMatrix has been calculated for this iteration
1130 
1131  ALIdouble lastadd = (*vecite)->lastAdditionToValueDisplacementByFitting() * factor;
1132  //- if( lastadd < 0 ) lastadd *= -1;
1133  (*vecite)->addFittedDisplacementToValue( -lastadd );
1134  (*vecite)->setLastAdditionToValueDisplacementByFitting( - (*vecite)->lastAdditionToValueDisplacementByFitting() );
1135  // (*vecite)->substractToHalfFittedDisplacementToValue();
1136 
1137  if(ALIUtils::debug >= 4) std::cout << " new valueDisplacementByFitting " << (*vecite)->OptOCurrent()->name() << " " << (*vecite)->name() << " = " << (*vecite)->valueDisplacementByFitting() << " " << std::endl ;
1138  }
1139  }
1140 
1141 }
1142 
1143 
1144 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1145 //@@ Dump all the entries that have been fitted (those that were 'cal' or 'unk'
1146 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1147 void Fit::dumpFittedValues( ALIFileOut& fileout, ALIbool printErrors, ALIbool printOrig )
1148 {
1149  //---------- print
1150  if(ALIUtils::debug >= 0) {
1151  std::cout << "SRPRPOS " << " Optical Object "
1152  << " Parameter" << " Fit.Value " << " Orig.Value" << std::endl;
1153  }
1154  //---------- Dump header
1155  if(ALIUtils::debug >= 0) std::cout << std::endl << "FITTED VALUES " << std::endl;
1156  fileout << std::endl << "FITTED VALUES " << std::endl
1157  << "nEnt_unk"
1158  << " Optical Object"
1159  << " Parameter ";
1160  if( printErrors ) {
1161  fileout << " value (+-error)"
1162  << " orig.val (+-error)";
1163  } else {
1164  fileout << " value "
1165  << " orig.val ";
1166  }
1167  fileout << " quality"
1168  << std::endl;
1169 
1170  //---------- Iterate over OptO list
1171  std::vector< Entry* > entries;
1172  // const Entry* entry;
1173  int ii, siz;
1174  std::vector< OpticalObject* >::const_iterator vocite;
1175  for( vocite = Model::OptOList().begin(); vocite != Model::OptOList().end(); ++vocite ) {
1176  if( (*vocite)->type() == ALIstring("system") ) continue;
1177 
1178  fileout << " %%%% Optical Object: " << (*vocite)->longName() << std::endl;
1179 
1180  entries = (*vocite)->CoordinateEntryList();
1181  siz = entries.size();
1182  if( siz != 6 ) {
1183  std::cerr << "!!! FATAL ERROR: strange number of coordinates = " << siz << std::endl;
1184  abort();
1185  }
1186 
1187  //----- Dump entry centre coordinates (centre in current coordinates of parent frame <> summ of displacements, as each displacement is done with a different rotation of parent frame)
1188  OpticalObject* opto = entries[0]->OptOCurrent();
1189  const OpticalObject* optoParent = opto->parent();
1190  printCentreInOptOFrame( opto, optoParent, fileout, printErrors, printOrig );
1191 
1192  //----- Dump entry angles coordinates
1193  printRotationAnglesInOptOFrame( opto, optoParent, fileout, printErrors, printOrig );
1194 
1195  //----- Dump extra entries
1196  entries = (*vocite)->ExtraEntryList();
1197  siz = entries.size();
1198  for( ii = 0; ii < siz; ii++ ){
1199  double entryvalue = getEntryValue( entries[ii] );
1200  dumpEntryAfterFit( fileout, entries[ii], entryvalue, printErrors, printOrig );
1201  }
1202  }
1203 
1204  dumpEntryCorrelations( fileout );
1205 
1206 }
1207 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1208 //@@ Dump all the entries that have been fitted in reference frames of all ancestors
1209 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1210 void Fit::dumpFittedValuesInAllAncestorFrames( ALIFileOut& fileout, ALIbool printErrors, ALIbool printOrig )
1211 {
1212  //---------- print
1213  fileout << std::endl << "@@@@ FITTED VALUES IN ALL ANCESTORS " << std::endl
1214  << "nEnt_unk"
1215  << " Optical Object"
1216  << " Parameter ";
1217  if( printErrors ) {
1218  fileout << " value (+-error)";
1219  if( printOrig ){
1220  fileout << " orig.val (+-error)";
1221  }
1222  } else {
1223  fileout << " value ";
1224  if( printOrig ){
1225  fileout << " orig.val ";
1226  }
1227  }
1228  fileout << " quality"
1229  << std::endl;
1230 
1231  //---------- Iterate over OptO list
1232  std::vector< Entry* > entries;
1233  std::vector< OpticalObject* >::const_iterator vocite;
1234  for( vocite = Model::OptOList().begin(); vocite != Model::OptOList().end(); ++vocite ) {
1235  if( (*vocite)->type() == ALIstring("system") ) continue;
1236 
1237  fileout << " %%%% Optical Object: " << (*vocite)->longName() << std::endl;
1238 
1239  entries = (*vocite)->CoordinateEntryList();
1240 
1241  //----- Dump entry centre coordinates (centre in current coordinates of parent frame <> summ of displacements, as each displacement is done with a different rotation of parent frame)
1242  OpticalObject* opto = *vocite;
1243  const OpticalObject* optoParent = opto->parent();
1244  do {
1245  fileout << " %% IN FRAME : " << optoParent->longName() << std::endl;
1246  printCentreInOptOFrame( opto, optoParent, fileout, printErrors, printOrig );
1247 
1248  //----- Dump entry angles coordinates
1249  printRotationAnglesInOptOFrame( opto, optoParent, fileout, printErrors, printOrig );
1250  optoParent = optoParent->parent();
1251  }while( optoParent );
1252  }
1253 
1254 }
1255 
1256 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1257 void Fit::printCentreInOptOFrame( const OpticalObject* opto, const OpticalObject* optoAncestor, ALIFileOut& fileout, ALIbool printErrors, ALIbool printOrig )
1258 {
1259  CLHEP::Hep3Vector centreLocal;
1260  if( optoAncestor->type() == "system" ) {
1261  centreLocal = opto->centreGlob();
1262  } else {
1263  centreLocal = opto->centreGlob() - optoAncestor->centreGlob();
1264  CLHEP::HepRotation parentRmGlobInv = inverseOf( optoAncestor->rmGlob() );
1265  centreLocal = parentRmGlobInv * centreLocal;
1266  }
1267  if(ALIUtils::debug >= 2 ) {
1268  std::cout << "CENTRE LOCAL "<< opto->name() << " " << centreLocal << " GLOBL " << opto->centreGlob() << " parent GLOB " << optoAncestor->centreGlob() << std::endl;
1269  ALIUtils::dumprm( optoAncestor->rmGlob(), " parent rm " );
1270  }
1271  std::vector< Entry* > entries = opto->CoordinateEntryList();
1272  for( ALIuint ii = 0; ii < 3; ii++ ){
1273  /* double entryvalue = getEntryValue( entries[ii] );
1274  ALIdouble entryvalue;
1275  if( ii == 0 ) {
1276  entryvalue = centreLocal.x();
1277  }else if( ii == 1 ) {
1278  entryvalue = centreLocal.y();
1279  }else if( ii == 2 ) {
1280  entryvalue = centreLocal.z();
1281  }*/
1282  dumpEntryAfterFit( fileout, entries[ii], centreLocal[ii] / entries[ii]->OutputValueDimensionFactor(), printErrors, printOrig );
1283  }
1284 
1285 }
1286 
1287 
1288 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1289 void Fit::printRotationAnglesInOptOFrame( const OpticalObject* opto, const OpticalObject* optoAncestor, ALIFileOut& fileout, ALIbool printErrors, ALIbool printOrig )
1290 {
1291  std::vector< Entry* > entries = opto->CoordinateEntryList();
1292  std::vector<double> entryvalues = opto->getRotationAnglesInOptOFrame( optoAncestor, entries );
1293  //- std::cout << " after return entryvalues[0] " << entryvalues[0] << " entryvalues[1] " << entryvalues[1] << " entryvalues[2] " << entryvalues[2] << std::endl;
1294  for( ALIuint ii = 3; ii < entries.size(); ii++ ){
1295  dumpEntryAfterFit( fileout, entries[ii], entryvalues[ii-3]/entries[ii]->OutputValueDimensionFactor(), printErrors, printOrig );
1296  }
1297 
1298 }
1299 
1300 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1302 {
1303  double entryvalue;
1304  if( entry->type() == "angles") {
1305  if(ALIUtils::debug >= 2 ) std::cout << "WARNING valueDisplacementByFitting has no sense for angles " << std::endl;
1306  entryvalue = -999;
1307  }
1308  entryvalue = ( entry->value() + entry->valueDisplacementByFitting() ) / entry->OutputValueDimensionFactor();
1309  return entryvalue;
1310 }
1311 
1312 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1313 void Fit::dumpEntryAfterFit( ALIFileOut& fileout, const Entry* entry, double entryvalue, ALIbool printErrors, ALIbool printOrig )
1314 {
1315  //- std::cout << " Fit::dumpEntryAfterFit " << entryvalue << std::endl;
1316  ALIdouble dimv = entry->OutputValueDimensionFactor();
1317  ALIdouble dims = entry->OutputSigmaDimensionFactor();
1318  //----- Dump to std::cout
1319  if(ALIUtils::debug >= 3) {
1320  std::cout << "ENTRY: "
1321  << std::setw(30) << entry->OptOCurrent()->name()
1322  << std::setw(8) << " " << entry->name() << " "
1323  << std::setw(8) << ( entry->value() + entry->valueDisplacementByFitting() )
1324  <<" " << entry->value()
1325  << " Q" << entry->quality() << std::endl;
1326  }
1327 
1328  if ( entry->quality() == 2 ) {
1329  fileout << "UNK: " << entry->fitPos() << " ";
1330  } else if ( entry->quality() == 1 ) {
1331  fileout << "CAL: " << entry->fitPos() << " ";
1332  // fileout << "CAL: -1 ";
1333  } else {
1334  fileout << "FIX: -1 ";
1335  }
1336 
1337  fileout << std::setw(30) << entry->OptOCurrent()->name()
1338  << std::setw(8) << " " << entry->name() << " "
1339  << std::setw(8) << std::setprecision(8) << entryvalue;
1340  if ( entry->quality() >= theMinimumEntryQuality ) {
1341  if( printErrors ) fileout << " +- " << std::setw(8) << sqrt(AtWAMatrix->Mat()->me[entry->fitPos()][entry->fitPos()]) / dims;
1342  } else {
1343  if( printErrors ) fileout << " +- " << std::setw(8) << 0.;
1344  }
1345  if( printOrig ) {
1346  fileout << std::setw(8) << " " << entry->value() / dimv;
1347  if( printErrors ) fileout << " +- " << std::setw(8) << entry->sigma() /dims << " Q" << entry->quality();
1348 
1349  if( ALIUtils::report >= 2) {
1350  float dif = ( entry->value() + entry->valueDisplacementByFitting() ) / dimv - entry->value() / dimv;
1351  if( fabs(dif) < 1.E-9 ) dif = 0.;
1352  fileout << " DIFF= " << dif;
1353  // << " == " << ( entry->value() + entry->valueDisplacementByFitting() ) / dimv - entryvalue << " @@ " << ( entry->value() + entry->valueDisplacementByFitting() ) / dimv << " @@ " << entryvalue;
1354  } else {
1355  // fileout << std::endl;
1356  }
1357  }
1358 
1359  fileout << std::endl;
1360 
1361 }
1362 
1363 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1365 {
1366  //----- Only dump correlations bigger than a factor
1367  ALIdouble minCorrel = 1.E-6;
1368  //----- Dump correlations
1369  fileout << std::endl << "CORRELATION BETWEEN 'unk' ENTRIES: (>= " << minCorrel<< " )" << std::endl
1370  << "No_1 No_2 correlation " << std::endl;
1371 
1372  ALIuint i1,i2;
1373  std::vector< Entry* >::iterator veite1, veite2;
1374  std::string E1, E2;
1375  for ( veite1 = Model::EntryList().begin();
1376  veite1 != Model::EntryList().end(); ++veite1 ) {
1377  if( (*veite1)->quality() == 0 ) {
1378  continue;
1379  } else if( (*veite1)->quality() == 1 ) {
1380  E1 = "C";
1381  } else if( (*veite1)->quality() == 2 ) {
1382  E1 = "U";
1383  }
1384  i1 = (*veite1)->fitPos();
1385 
1386  for ( veite2 = veite1+1;
1387  veite2 != Model::EntryList().end(); ++veite2 ) {
1388  i2 = (*veite2)->fitPos();
1389  if( (*veite2)->quality() == 0 ) {
1390  continue;
1391  } else if( (*veite2)->quality() == 1 ) {
1392  E2 = "C";
1393  } else if( (*veite2)->quality() == 2 ) {
1394  E2 = "U";
1395  }
1396  ALIdouble corr = AtWAMatrix->Mat()->me[i1][i2];
1397  ALIdouble corrf = corr / sqrt(AtWAMatrix->Mat()->me[i1][i1])
1398  / sqrt(AtWAMatrix->Mat()->me[i2][i2]);
1399  if (fabs(corrf) >= minCorrel ) {
1400  if(ALIUtils::debug >= 0) {
1401  std::cout << "CORR:" << E1 << "" << E2 << " (" << i1 << ")" << " (" << i2 << ")" << " " << corrf << std::endl;
1402  }
1403  fileout << "CORR:" << E1 << "" << E2 << " (" << i1 << ")" << " (" << i2 << ")" << " " << corrf << std::endl;
1404  }
1405  }
1406  }
1407  //------- Dump optical object list
1409 
1410 }
1411 
1412 
1413 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1414 //@@ Dump matrices used for the fit
1415 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1417 {
1418  //----- Dump matrices for this iteration
1420  // ofstream matout("matrices.out");
1421  matout << std::endl << " @@@@@@@@@@@@@@@ Iteration No : " << theNoFitIterations << std::endl;
1422  AMatrix->ostrDump( matout, "Matrix A" );
1423  AtMatrix->ostrDump( matout, "Matrix At" );
1424  WMatrix->ostrDump( matout, "Matrix W" );
1425  AtWAMatrix->ostrDump( matout, "Matrix AtWA" );
1426  //op VaMatrix->ostrDump( matout, "Matrix Va" );
1427  DaMatrix->ostrDump( matout, "Matrix Da" );
1428  yfMatrix->ostrDump( matout, "Matrix y" );
1429  //op fMatrix->ostrDump( matout, "Matrix f" );
1430  //op thePropagationMatrix->ostrDump( matout, "propagation Matrix " );
1431  matout.close();
1432 
1433 }
1434 
1435 
1436 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1437 //@@ findEntryFitPosition
1438 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1439 ALIint Fit::findEntryFitPosition( const ALIstring& opto_name, const ALIstring& entry_name )
1440 {
1441  ALIint fitposi = -99;
1442 
1443  OpticalObject* opto = Model::getOptOByName( opto_name );
1444  //- std::cout << "OPTO = " << opto->name() << std::endl;
1445  std::vector<Entry*>::const_iterator vecite;
1446  for (vecite = opto->CoordinateEntryList().begin();
1447  vecite < opto->CoordinateEntryList().end(); ++vecite) {
1448  //- std::cout << "ENTRYLIST" << (*vecite)->name() << std::endl;
1449  if ((*vecite)->name() == entry_name ) {
1450  //- std::cout << "FOUND " << std::endl;
1451  fitposi = (*vecite)->fitPos();
1452  }
1453  }
1454  for (vecite = opto->ExtraEntryList().begin();
1455  vecite < opto->ExtraEntryList().end(); ++vecite) {
1456  //- std::cout << "ENTRYLIST" << (*vecite)->name() << std::endl;
1457  if ((*vecite)->name() == entry_name ) {
1458  //- std::cout << "FOUND " << std::endl;
1459  fitposi = (*vecite)->fitPos();
1460  }
1461  }
1462 
1463  if(fitposi == -99) {
1464  std::cerr << "!!EXITING: entry name not found: " << entry_name << std::endl;
1465  exit(2);
1466  } else {
1467  return fitposi;
1468  }
1469 }
1470 
1471 
1472 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1474 {
1475  double chi2meas = 0;
1476  double chi2cal = 0;
1477  ALIint nMeas = 0, nUnk = 0;
1478 
1479  //----- Calculate the chi2 of measurements
1480  std::vector< Measurement* >::const_iterator vmcite;
1481  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
1482  //--- Calculate Simulated Value Original
1483  for ( ALIuint ii = 0; ii < ALIuint((*vmcite)->dim()); ii++ ){
1484  nMeas++;
1485  double c2 = ( (*vmcite)->value(ii) - (*vmcite)->valueSimulated(ii) ) / (*vmcite)->sigma(ii);
1486  chi2meas += c2*c2;
1487  if( ALIUtils::debug >= 2) {
1488  std::cout << c2 << " adding chi2meas " << chi2meas << " " << (*vmcite)->name() << ": " << ii << " (mm)R: " << (*vmcite)->value(ii)*1000. << " S: " << (*vmcite)->valueSimulated(ii)*1000. << " Diff= " << ((*vmcite)->value(ii) - (*vmcite)->valueSimulated(ii))*1000. << std::endl;
1489  }
1490  }
1491  }
1492 
1493  //----- Calculate the chi2 of calibrated parameters
1494  std::vector< Entry* >::iterator veite;
1495  for ( veite = Model::EntryList().begin();
1496  veite != Model::EntryList().end(); ++veite ) {
1497  if ( (*veite)->quality() == 2 ) nUnk++;
1498  if ( (*veite)->quality() == 1 ) {
1499  double c2 = (*veite)->valueDisplacementByFitting() / (*veite)->sigma();
1500  //double c2 = (*veite)->value() / (*veite)->sigma();
1501  chi2cal += c2*c2;
1502  if( ALIUtils::debug >= 2) std::cout << c2 << " adding chi2cal " << chi2cal << " " << (*veite)->OptOCurrent()->name() << " " << (*veite)->name() << std::endl;
1503  //- std::cout << " valueDisplacementByFitting " << (*veite)->valueDisplacementByFitting() << " sigma " << (*veite)->sigma() << std::endl;
1504  }
1505  }
1506 
1507  if( ALIUtils::report >= 1) {
1509  fileout << " Chi2= " << chi2meas+chi2cal << " / " << nMeas-nUnk << " dof " << " From measurements= " << chi2meas << " from calibrated parameters= " << chi2cal << std::endl;
1510  }
1511  if( ALIUtils::debug >= 3) std::cout << " quality Chi2 (no correlations) " << chi2meas+chi2cal << " " << chi2meas << " " << chi2cal << std::endl;
1512 
1513 
1514  if( !isFirst ) {
1515  // double fit_quality_change = thePreviousIterationFitQuality - fit_quality;
1516 
1517  if(ALIUtils::debug >= 0) {
1518  std::cout << std::endl << "@@@@ Fit iteration " << theNoFitIterations << " ..." << std::endl;
1519  // std::cout << theNoFitIterations << " Chi2 improvement in this iteration = " << fit_quality_change << std::endl;
1520  }
1521  if( ALIUtils::report >= 1 ) {
1523  fileout << std::endl << "Fit iteration " << theNoFitIterations << " ..." << std::endl;
1524  // fileout << theNoFitIterations << " Chi2 improvement in this iteration = " << fit_quality_change << std::endl;
1525  }
1526  }
1527 
1528  //---- Print chi2
1529  if(ALIUtils::debug >= 0) std::cout << theNoFitIterations << " Chi2 after iteration = " << fit_quality << std::endl;
1530  if( ALIUtils::report >= 1 ) {
1531  //--------- Get report file handler
1533  fileout << theNoFitIterations << " Chi2 after iteration = " << fit_quality << std::endl;
1534  }
1535 
1536 }
1537 
1538 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1540 {
1541  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::CheckIfFitPossible" << std::endl;
1542 
1543  //----- Check if there is an unknown parameter that is not affecting any measurement
1544  ALIint NolinMes = 0;
1545  std::vector<Measurement*>::const_iterator vmcite;
1546  for ( vmcite = Model::MeasurementList().begin();
1547  vmcite != Model::MeasurementList().end(); ++vmcite) {
1548  NolinMes += (*vmcite)->dim();
1549  }
1550 
1551  std::vector< Entry* >::const_iterator vecite;
1552  for ( vecite = Model::EntryList().begin(); vecite != Model::EntryList().end(); ++vecite ) {
1553  if( ALIUtils::debug >= 4 ) std::cout << "Fit::CheckIfFitPossible looping for entry " << (*vecite)->longName() << std::endl;
1554  if ( (*vecite)->quality() == 2 ) {
1555  ALIint nCol = (*vecite)->fitPos();
1556  //--- Check all measurements
1557  ALIbool noDepend = TRUE;
1558  if( ALIUtils::debug >= 4 ) std::cout << "Fit::CheckIfFitPossible looping for entry " << nCol << std::endl;
1559  for( ALIint ii = 0; ii < NolinMes; ii++ ) {
1560  if( ALIUtils::debug >= 5 ) std::cout << " Derivative= (" << ii << "," << nCol << ") = " << (*AMatrix)(ii,nCol) << std::endl;
1561 
1562  if( fabs((*AMatrix)(ii,nCol)) > ALI_DBL_MIN ) {
1563  if( ALIUtils::debug >= 5 ) std::cout << "Fit::CheckIfFitIsPossible " << nCol << " " << ii << " = " << (*AMatrix)(ii,nCol) << std::endl;
1564  noDepend = FALSE;
1565  break;
1566  }
1567  }
1568  if( noDepend ){
1569  throw cms::Exception("SDFError") << "!!!FATAL ERROR: Fit::CheckIfFitPossible() no measurement depends on unknown entry " << (*vecite)->OptOCurrent()->name() << "/" << (*vecite)->name() << std::endl
1570  << "!!! Fit will not be possible! " << std::endl;
1571  }
1572  }
1573  }
1574 
1575  //------ Check if there are two unknown entries that have the derivatives of all measurements w.r.t. then equal (or 100% proportional). In this case any value of the first entry can be fully compensated by another value in the second entry without change in any measurement ---> the two entries cannot be fitted!
1576 
1577  std::vector< Entry* >::const_iterator vecite1,vecite2;
1578  ALIint nLin = AMatrix->NoLines();
1579  ALIdouble derivPrec = ALI_DBL_MIN;
1580  //---------- Loop entries
1581  for ( vecite1 = Model::EntryList().begin();
1582  vecite1 != Model::EntryList().end(); ++vecite1 ) {
1583  if( (*vecite1)->quality() == 2 ) {
1584  vecite2 = vecite1; ++vecite2;
1585  for ( ;vecite2 != Model::EntryList().end(); ++vecite2 ) {
1586  if( (*vecite2)->quality() == 2 ) {
1587  ALIint fitpos1 = (*vecite1)->fitPos();
1588  ALIint fitpos2 = (*vecite2)->fitPos();
1589  if( ALIUtils::debug >= 5 ) std::cout << "Fit::CheckIfFitIsPossible checking " << (*vecite1)->longName() << " ( " << fitpos1 << " ) & " << (*vecite2)->longName() << " ( " << fitpos2 << " ) "<< std::endl;
1590  ALIdouble prop = DBL_MAX;
1591  ALIbool isProp = TRUE;
1592  for( ALIint ii = 0; ii < nLin; ii++ ) {
1593  if( ALIUtils::debug >= 5 ) std::cout << "Fit::CheckIfFitIsPossible " << ii << " : " << (*AMatrix)(ii,fitpos1) << " ?= " << (*AMatrix)(ii,fitpos2) << std::endl;
1594  if( fabs((*AMatrix)(ii,fitpos1)) < derivPrec ) {
1595  if( fabs((*AMatrix)(ii,fitpos2)) > derivPrec ) {
1596  isProp = FALSE;
1597  break;
1598  }
1599  } else {
1600  ALIdouble propn = (*AMatrix)(ii,fitpos2) / (*AMatrix)(ii,fitpos1);
1601  if( prop != DBL_MAX && prop != propn ) {
1602  isProp = FALSE;
1603  break;
1604  }
1605  prop = propn;
1606  }
1607  }
1608  if( isProp ) {
1609  std::cerr << "!!!FATAL ERROR: Fit::CheckIfFitPossible() two entries for which the measurements have the same dependency (or 100% proportional) " << (*vecite1)->longName() << " & " << (*vecite2)->longName() << std::endl
1610  << "!!! Fit will not be possible! " << std::endl;
1611  throw cms::Exception("SDFError");
1612  }
1613  }
1614  }
1615  }
1616  }
1617 }
1618 
1619 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1621 {
1622  int measProp = -1;
1623 
1624  std::set<ALIuint> columnsEqual;
1625  std::set<ALIuint> columnsEqualSave;
1626  ALIuint biggestColumn = 0;
1627  ALIdouble biggest = 0.;
1628  for (int ii = 0; ii < AMatrix->NoColumns(); ii++ ){
1629  if( fabs((*AMatrix)(measNo,ii)) > biggest ) {
1630  biggest = fabs((*AMatrix)(measNo,ii));
1631  biggestColumn = ii;
1632  }
1633  columnsEqualSave.insert(ii);
1634  }
1635 
1636  ALIdouble div;
1637 
1638  for( int jj = 0; jj < AMatrix->NoLines(); jj++ ){
1639  if( jj == int(measNo) ) continue;
1640  columnsEqual = columnsEqualSave;
1641  // check if ratio of each column to 'biggestColumn' is the same as for the N measurement
1642  for (int ii = 0; ii < AMatrix->NoColumns(); ii++ ){
1643  div = (*AMatrix)(measNo,ii)/(*AMatrix)(measNo,biggestColumn);
1644  if( fabs((*AMatrix)(jj,ii)) > ALI_DBL_MIN && fabs(div - (*AMatrix)(jj,ii)/(*AMatrix)(jj,biggestColumn) ) > ALI_DBL_MIN ) {
1645  if( ALIUtils::debug >= 3 ) std::cout << "CheckIfMeasIsProportionalToAnother 2 columns = " << ii << " in " << measNo << " & " << jj << std::endl;
1646  } else {
1647  if( ALIUtils::debug >= 3 ) std::cout << "CheckIfMeasIsProportionalToAnother 2 columns != " << ii << " in " << measNo << " & " << jj << std::endl;
1648  // if it is not equal delete this column
1649  std::set<ALIuint>::iterator ite = columnsEqual.find( ii );
1650  if( ite != columnsEqual.end() ){
1651  columnsEqual.erase(ite);
1652  }
1653  }
1654  }
1655  // check if not all columns have been deleted from columnsEqual
1656  if( columnsEqual.size() != 0 ) {
1657  if( ALIUtils::debug >= 3 ) std::cout << "CheckIfMeasIsProportionalToAnother " << measNo << " = " << jj << std::endl;
1658  measProp = jj;
1659  break;
1660  }
1661  }
1662 
1663  return measProp;
1664 }
1665 
1666 
1667 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1669 {
1670  std::string measname = " ";
1671 
1672  std::cout << " imeas " << imeas << std::endl;
1673  int Aline = 0;
1674  std::vector< Measurement* >::const_iterator vmcite;
1675  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
1676  for ( ALIuint jj = 0; jj < ALIuint((*vmcite)->dim()); jj++) {
1677  if( Aline == imeas ) {
1678  char ctmp[20];
1679  gcvt( jj, 10, ctmp );
1680  return ((*vmcite)->name()) + ":" + std::string(ctmp);
1681  }
1682  Aline++;
1683  }
1684  }
1685 
1686  std::cout << " return measname " << measname << std::endl;
1687  return measname;
1688 }
1689 
static void set_time_now(time_t now)
Definition: ALIUtils.h:47
static ALIbool only1
Definition: Measurement.h:267
static void multiplyMatrices()
Definition: Fit.cc:821
static ALIdouble theMinDaFactor
Definition: Fit.h:201
ALIint NoLines() const
long double ALIdouble
Definition: CocoaGlobals.h:11
void AddFittedEntriesSet(FittedEntriesSet *fents)
static ALIMatrix * AMatrix
Definition: Fit.h:160
virtual ALIdouble OutputValueDimensionFactor() const
Definition: Entry.h:39
#define TRUE
Definition: scimark2.h:12
static void setCorrelationFromParamFitted(const pss &entry1, const pss &entry2, ALIdouble correl)
Definition: Fit.cc:793
static CocoaDaqReader * GetDaqReader()
static void dumpFittedValuesInAllAncestorFrames(ALIFileOut &fileout, ALIbool printErrors=1, ALIbool printOrig=1)
Definition: Fit.cc:1210
static void setCorrelationsInWMatrix()
Definition: Fit.cc:770
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
const ALIstring & type() const
Definition: Entry.h:54
const double ALI_DBL_MIN
Definition: CocoaGlobals.h:25
static cocoaStatus getCocoaStatus()
Definition: Model.h:48
Definition: Entry.h:18
static void setCocoaStatus(const cocoaStatus cs)
Definition: Model.h:49
ALIdouble valueDisplacementByFitting() const
Definition: Entry.h:63
const std::vector< Entry * > & ExtraEntryList() const
Definition: OpticalObject.h:69
ErrorCorrelation * getCorrelation(ALIint ii)
virtual ALIdouble OutputSigmaDimensionFactor() const
Definition: Entry.h:40
static ALIint theMinimumEntryQuality
Definition: Fit.h:184
static void printCentreInOptOFrame(const OpticalObject *opto, const OpticalObject *optoAncestor, ALIFileOut &fileout, ALIbool printErrors=1, ALIbool printOrig=1)
Definition: Fit.cc:1257
bool DumpCocoaResults()
Definition: CocoaDBMgr.cc:53
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
Definition: ALIUtils.cc:77
isFirst
Definition: cuy.py:417
ALIdouble value() const
Definition: Entry.h:55
MatrixMeschach * MatrixByMatrix(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
static ALIdouble getMaximumDeviationDerivative()
Definition: ALIUtils.h:106
const std::vector< Entry * > & CoordinateEntryList() const
Definition: OpticalObject.h:65
int ALIint
Definition: CocoaGlobals.h:15
static OpticalObject * getOptOByName(const ALIstring &opto_name)
--— Find an OptO name in theOptOList and return a pointer to it
Definition: Model.cc:578
static ALIint debug
Definition: ALIUtils.h:35
static ALIMatrix * AtMatrix
Definition: Fit.h:161
static ALIstring & ReportFName()
the name of the report File
Definition: Model.h:96
static void setMaximumDeviationDerivative(ALIdouble val)
Definition: ALIUtils.h:108
static ErrorCorrelationMgr * getInstance()
static Fit & getInstance()
Definition: Fit.cc:71
static GlobalOptionMgr * getInstance()
static void setFittableEntries()
Definition: Fit.cc:364
void FillMeasurements()
int ii
Definition: cuy.py:588
static std::vector< Entry * > & EntryList()
Definition: Model.h:75
static Entry * getEntryByName(const ALIstring &opto_name, const ALIstring &entry_name)
--— Search an Entry name in the Entry* list and return a pointer to it
Definition: Model.cc:633
static double getEntryValue(const Entry *entry)
Definition: Fit.cc:1301
int nEvent
Definition: myFastSimVal.cc:49
static FittedEntriesReader * getFittedEntriesReader()
Definition: Model.h:267
std::vector< double > getRotationAnglesInOptOFrame(const OpticalObject *optoAncestor, const std::vector< Entry * > &entries) const
static ALIint _NoLinesA
Definition: Fit.h:173
static OpticalObjectMgr * getInstance()
Get the only instance.
static void dumpEntryAfterFit(ALIFileOut &fileout, const Entry *entry, double entryvalue, ALIbool printErrors=1, ALIbool printOrig=1)
Definition: Fit.cc:1313
const CLHEP::HepRotation & rmGlob() const
static ALIMatrix * AtWAMatrix
Definition: Fit.h:163
static ALIdouble theFitQualityCut
Definition: Fit.h:190
int getGlobalOptionValue(const ALIstring &sstr, ALIdouble &val)
--— Search a string in theGlobalOptions and return 1 if found
bool ALIbool
Definition: CocoaGlobals.h:19
static FitQuality getFitQuality(const ALIbool canBeGood=TRUE)
Definition: Fit.cc:900
static void substractLastDisplacementToEntries(const ALIdouble factor)
Definition: Fit.cc:1119
Definition: Fit.h:34
ALIint NoColumns() const
static ALIint MaxNoFitIterations
Definition: Fit.h:198
static void dumpFittedValues(ALIFileOut &fileout, ALIbool printErrors=1, ALIbool printOrig=1)
Definition: Fit.cc:1147
T sqrt(T t)
Definition: SSEVec.h:18
static ALIint findEntryFitPosition(const ALIstring &opto_name, const ALIstring &entry_name)
Definition: Fit.cc:1439
const OpticalObject * parent() const
Definition: OpticalObject.h:62
const pss & getEntry1() const
static ALIMatrix * WMatrix
Definition: Fit.h:162
static std::string GetMeasurementName(int meas)
Definition: Fit.cc:1668
const ALIdouble getCorrelation() const
static void setFirstTime(ALIbool val)
Definition: ALIUtils.h:103
static ALIdouble thePreviousIterationFitQuality
Definition: Fit.h:187
static ALIMatrix * DaMatrix
Definition: Fit.h:165
static void PropagateErrors()
Definition: Fit.cc:446
virtual bool ReadNextEvent()=0
static ALIbool fitNextEvent(ALIuint &nEvent)
Definition: Fit.cc:149
static ALIMatrix * yfMatrix
Definition: Fit.h:170
static Fit * instance
Definition: Fit.h:158
static FittedEntriesManager * getInstance()
const MAT * Mat() const
static ALIuint nEvent
Definition: Fit.h:204
void SetCorrelation(ALIint i1, ALIint i2, ALIdouble corr)
const ALIstring longName() const
static void WriteVisualisationFiles()
Definition: Fit.cc:338
JetCorrectorParameters corr
Definition: classes.h:5
static ALIint _NoColumnsA
Definition: Fit.h:174
ALIint fitPos() const
Definition: Entry.h:60
MatrixMeschach ALIMatrix
void dumpOptOs(std::ostream &out=std::cout) const
static std::vector< OpticalObject * > & OptOList()
Definition: Model.h:71
MAT * MatNonConst() const
static void setApply(ALIbool val)
const ALIstring & name() const
Definition: Entry.h:52
static void FillMatricesWithMeasurements()
Definition: Fit.cc:626
void ostrDump(std::ostream &fout, const ALIstring &mtext)
static void CreateMatrices()
Definition: Fit.cc:557
static void redoMatrices()
Definition: Fit.cc:429
static NtupleManager * getInstance()
static void dumpMatrices()
Definition: Fit.cc:1416
const pss & getEntry2() const
static void dumpEntryCorrelations(ALIFileOut &file)
Definition: Fit.cc:1364
static CocoaDBMgr * getInstance()
Definition: CocoaDBMgr.cc:39
void AddData(ALIuint col, ALIuint lin, ALIdouble data)
static void startFit()
Definition: Fit.cc:105
static ALIint report
Definition: ALIUtils.h:34
static ALIdouble cameraScaleFactor
Definition: Measurement.h:209
static ALIbool getFirstTime()
Definition: ALIUtils.h:100
static void deleteMatrices()
Definition: Fit.cc:538
static void CheckIfFitPossible()
Definition: Fit.cc:1539
const CLHEP::Hep3Vector & centreGlob() const
Definition: OpticalObject.h:85
void FillOptObjects(MatrixMeschach *AtWAMatrix)
static int CheckIfMeasIsProportionalToAnother(ALIuint measNo)
Definition: Fit.cc:1620
#define begin
Definition: vmac.h:30
ALIint quality() const
Definition: Entry.h:59
Fit()
Definition: Fit.h:38
std::string ALIstring
Definition: CocoaGlobals.h:9
void FillFitParameters(MatrixMeschach *AtWAMatrix)
list entry
Definition: mps_splice.py:62
static ALIdouble theRelativeFitQualityCut
Definition: Fit.h:193
static void calculateSimulatedMeasurementsWithOriginalValues()
Definition: Fit.cc:515
static ALIstring & MatricesFName()
the name of the File for storing the matrices
Definition: Model.h:101
tuple cout
Definition: gather_cfg.py:145
const ALIstring & name() const
Definition: OpticalObject.h:60
static void PrintChi2(ALIdouble fit_quality, ALIbool isFirst)
Definition: Fit.cc:1473
static FitQuality fitParameters(const double daFactor)
Definition: Fit.cc:392
OpticalObject * OptOCurrent() const
Definition: Entry.h:61
FitQuality
Definition: Fit.h:32
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of FALSE
static ALIFileOut & getInstance(const ALIstring &filename)
Definition: ALIFileOut.cc:19
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
void Dump(const ALIstring &mtext)
static void addDaMatrixToEntries()
Definition: Fit.cc:1065
static ALIdouble GetSChi2(ALIbool useDa)
Definition: Fit.cc:1000
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:79
static ALIint theNoFitIterations
Definition: Fit.h:196
static void dumpDimensions(std::ofstream &fout)
Definition: ALIUtils.cc:337
static void printRotationAnglesInOptOFrame(const OpticalObject *opto, const OpticalObject *optoAncestor, ALIFileOut &fileout, ALIbool printErrors=1, ALIbool printOrig=1)
Definition: Fit.cc:1289
void FillNtupleTree()
unsigned int ALIuint
Definition: CocoaGlobals.h:17
const ALIstring & type() const
Definition: OpticalObject.h:61
static void FillMatricesWithCalibratedParameters()
Definition: Fit.cc:709
ALIdouble sigma() const
Definition: Entry.h:57
static time_t time_now()
Definition: ALIUtils.h:44