CMS 3D CMS Logo

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> // among others include also floating-point std::abs functions
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 = nullptr;
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 
113  ALIUtils::setFirstTime( true );
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 = false;
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 = true;
174  if(CocoaDaqReader::GetDaqReader() != nullptr) moreDataSets = CocoaDaqReader::GetDaqReader()->ReadNextEvent();
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() == nullptr ) {
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 = true;
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 = true;
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 = true;
322  return !lastEvent;
323  }
324 
325  } else {
326  lastEvent = true;
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 
507  if( ALIUtils::getFirstTime() == 1) ALIUtils::setFirstTime( false );
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(true);
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 =std::abs( (*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 = std::abs(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 = nullptr;
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 
1307  // commenting out the following line as it is a dead assignment due to the
1308  // subsequent assignment below
1309  // -> silence static analyzer warnings, but leaving the commented line in
1310  // case someone wants to actively use this code again
1311 
1312  // entryvalue = -999;
1313  }
1314  entryvalue = ( entry->value() + entry->valueDisplacementByFitting() ) / entry->OutputValueDimensionFactor();
1315  return entryvalue;
1316 }
1317 
1318 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1319 void Fit::dumpEntryAfterFit( ALIFileOut& fileout, const Entry* entry, double entryvalue, ALIbool printErrors, ALIbool printOrig )
1320 {
1321  //- std::cout << " Fit::dumpEntryAfterFit " << entryvalue << std::endl;
1322  ALIdouble dimv = entry->OutputValueDimensionFactor();
1323  ALIdouble dims = entry->OutputSigmaDimensionFactor();
1324  //----- Dump to std::cout
1325  if(ALIUtils::debug >= 3) {
1326  std::cout << "ENTRY: "
1327  << std::setw(30) << entry->OptOCurrent()->name()
1328  << std::setw(8) << " " << entry->name() << " "
1329  << std::setw(8) << ( entry->value() + entry->valueDisplacementByFitting() )
1330  <<" " << entry->value()
1331  << " Q" << entry->quality() << std::endl;
1332  }
1333 
1334  if ( entry->quality() == 2 ) {
1335  fileout << "UNK: " << entry->fitPos() << " ";
1336  } else if ( entry->quality() == 1 ) {
1337  fileout << "CAL: " << entry->fitPos() << " ";
1338  // fileout << "CAL: -1 ";
1339  } else {
1340  fileout << "FIX: -1 ";
1341  }
1342 
1343  fileout << std::setw(30) << entry->OptOCurrent()->name()
1344  << std::setw(8) << " " << entry->name() << " "
1345  << std::setw(8) << std::setprecision(8) << entryvalue;
1346  if ( entry->quality() >= theMinimumEntryQuality ) {
1347  if( printErrors ) fileout << " +- " << std::setw(8) << sqrt(AtWAMatrix->Mat()->me[entry->fitPos()][entry->fitPos()]) / dims;
1348  } else {
1349  if( printErrors ) fileout << " +- " << std::setw(8) << 0.;
1350  }
1351  if( printOrig ) {
1352  fileout << std::setw(8) << " " << entry->value() / dimv;
1353  if( printErrors ) fileout << " +- " << std::setw(8) << entry->sigma() /dims << " Q" << entry->quality();
1354 
1355  if( ALIUtils::report >= 2) {
1356  float dif = ( entry->value() + entry->valueDisplacementByFitting() ) / dimv - entry->value() / dimv;
1357  if( std::abs(dif) < 1.E-9 ) dif = 0.;
1358  fileout << " DIFF= " << dif;
1359  // << " == " << ( entry->value() + entry->valueDisplacementByFitting() ) / dimv - entryvalue << " @@ " << ( entry->value() + entry->valueDisplacementByFitting() ) / dimv << " @@ " << entryvalue;
1360  } else {
1361  // fileout << std::endl;
1362  }
1363  }
1364 
1365  fileout << std::endl;
1366 
1367 }
1368 
1369 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1371 {
1372  //----- Only dump correlations bigger than a factor
1373  ALIdouble minCorrel = 1.E-6;
1374  //----- Dump correlations
1375  fileout << std::endl << "CORRELATION BETWEEN 'unk' ENTRIES: (>= " << minCorrel<< " )" << std::endl
1376  << "No_1 No_2 correlation " << std::endl;
1377 
1378  ALIuint i1,i2;
1379  std::vector< Entry* >::iterator veite1, veite2;
1380  std::string E1, E2;
1381  for ( veite1 = Model::EntryList().begin();
1382  veite1 != Model::EntryList().end(); ++veite1 ) {
1383  if( (*veite1)->quality() == 0 ) {
1384  continue;
1385  } else if( (*veite1)->quality() == 1 ) {
1386  E1 = "C";
1387  } else if( (*veite1)->quality() == 2 ) {
1388  E1 = "U";
1389  }
1390  i1 = (*veite1)->fitPos();
1391 
1392  for ( veite2 = veite1+1;
1393  veite2 != Model::EntryList().end(); ++veite2 ) {
1394  i2 = (*veite2)->fitPos();
1395  if( (*veite2)->quality() == 0 ) {
1396  continue;
1397  } else if( (*veite2)->quality() == 1 ) {
1398  E2 = "C";
1399  } else if( (*veite2)->quality() == 2 ) {
1400  E2 = "U";
1401  }
1402  ALIdouble corr = AtWAMatrix->Mat()->me[i1][i2];
1403  ALIdouble corrf = corr / sqrt(AtWAMatrix->Mat()->me[i1][i1])
1404  / sqrt(AtWAMatrix->Mat()->me[i2][i2]);
1405  if (std::abs(corrf) >= minCorrel ) {
1406  if(ALIUtils::debug >= 0) {
1407  std::cout << "CORR:" << E1 << "" << E2 << " (" << i1 << ")" << " (" << i2 << ")" << " " << corrf << std::endl;
1408  }
1409  fileout << "CORR:" << E1 << "" << E2 << " (" << i1 << ")" << " (" << i2 << ")" << " " << corrf << std::endl;
1410  }
1411  }
1412  }
1413  //------- Dump optical object list
1415 
1416 }
1417 
1418 
1419 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1420 //@@ Dump matrices used for the fit
1421 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1423 {
1424  //----- Dump matrices for this iteration
1426  // ofstream matout("matrices.out");
1427  matout << std::endl << " @@@@@@@@@@@@@@@ Iteration No : " << theNoFitIterations << std::endl;
1428  AMatrix->ostrDump( matout, "Matrix A" );
1429  AtMatrix->ostrDump( matout, "Matrix At" );
1430  WMatrix->ostrDump( matout, "Matrix W" );
1431  AtWAMatrix->ostrDump( matout, "Matrix AtWA" );
1432  //op VaMatrix->ostrDump( matout, "Matrix Va" );
1433  DaMatrix->ostrDump( matout, "Matrix Da" );
1434  yfMatrix->ostrDump( matout, "Matrix y" );
1435  //op fMatrix->ostrDump( matout, "Matrix f" );
1436  //op thePropagationMatrix->ostrDump( matout, "propagation Matrix " );
1437  matout.close();
1438 
1439 }
1440 
1441 
1442 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1443 //@@ findEntryFitPosition
1444 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1445 ALIint Fit::findEntryFitPosition( const ALIstring& opto_name, const ALIstring& entry_name )
1446 {
1447  ALIint fitposi = -99;
1448 
1449  OpticalObject* opto = Model::getOptOByName( opto_name );
1450  //- std::cout << "OPTO = " << opto->name() << std::endl;
1451  std::vector<Entry*>::const_iterator vecite;
1452  for (vecite = opto->CoordinateEntryList().begin();
1453  vecite < opto->CoordinateEntryList().end(); ++vecite) {
1454  //- std::cout << "ENTRYLIST" << (*vecite)->name() << std::endl;
1455  if ((*vecite)->name() == entry_name ) {
1456  //- std::cout << "FOUND " << std::endl;
1457  fitposi = (*vecite)->fitPos();
1458  }
1459  }
1460  for (vecite = opto->ExtraEntryList().begin();
1461  vecite < opto->ExtraEntryList().end(); ++vecite) {
1462  //- std::cout << "ENTRYLIST" << (*vecite)->name() << std::endl;
1463  if ((*vecite)->name() == entry_name ) {
1464  //- std::cout << "FOUND " << std::endl;
1465  fitposi = (*vecite)->fitPos();
1466  }
1467  }
1468 
1469  if(fitposi == -99) {
1470  std::cerr << "!!EXITING: entry name not found: " << entry_name << std::endl;
1471  exit(2);
1472  } else {
1473  return fitposi;
1474  }
1475 }
1476 
1477 
1478 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1480 {
1481  double chi2meas = 0;
1482  double chi2cal = 0;
1483  ALIint nMeas = 0, nUnk = 0;
1484 
1485  //----- Calculate the chi2 of measurements
1486  std::vector< Measurement* >::const_iterator vmcite;
1487  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
1488  //--- Calculate Simulated Value Original
1489  for ( ALIuint ii = 0; ii < ALIuint((*vmcite)->dim()); ii++ ){
1490  nMeas++;
1491  double c2 = ( (*vmcite)->value(ii) - (*vmcite)->valueSimulated(ii) ) / (*vmcite)->sigma(ii);
1492  chi2meas += c2*c2;
1493  if( ALIUtils::debug >= 2) {
1494  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;
1495  }
1496  }
1497  }
1498 
1499  //----- Calculate the chi2 of calibrated parameters
1500  std::vector< Entry* >::iterator veite;
1501  for ( veite = Model::EntryList().begin();
1502  veite != Model::EntryList().end(); ++veite ) {
1503  if ( (*veite)->quality() == 2 ) nUnk++;
1504  if ( (*veite)->quality() == 1 ) {
1505  double c2 = (*veite)->valueDisplacementByFitting() / (*veite)->sigma();
1506  //double c2 = (*veite)->value() / (*veite)->sigma();
1507  chi2cal += c2*c2;
1508  if( ALIUtils::debug >= 2) std::cout << c2 << " adding chi2cal " << chi2cal << " " << (*veite)->OptOCurrent()->name() << " " << (*veite)->name() << std::endl;
1509  //- std::cout << " valueDisplacementByFitting " << (*veite)->valueDisplacementByFitting() << " sigma " << (*veite)->sigma() << std::endl;
1510  }
1511  }
1512 
1513  if( ALIUtils::report >= 1) {
1515  fileout << " Chi2= " << chi2meas+chi2cal << " / " << nMeas-nUnk << " dof " << " From measurements= " << chi2meas << " from calibrated parameters= " << chi2cal << std::endl;
1516  }
1517  if( ALIUtils::debug >= 3) std::cout << " quality Chi2 (no correlations) " << chi2meas+chi2cal << " " << chi2meas << " " << chi2cal << std::endl;
1518 
1519 
1520  if( !isFirst ) {
1521  // double fit_quality_change = thePreviousIterationFitQuality - fit_quality;
1522 
1523  if(ALIUtils::debug >= 0) {
1524  std::cout << std::endl << "@@@@ Fit iteration " << theNoFitIterations << " ..." << std::endl;
1525  // std::cout << theNoFitIterations << " Chi2 improvement in this iteration = " << fit_quality_change << std::endl;
1526  }
1527  if( ALIUtils::report >= 1 ) {
1529  fileout << std::endl << "Fit iteration " << theNoFitIterations << " ..." << std::endl;
1530  // fileout << theNoFitIterations << " Chi2 improvement in this iteration = " << fit_quality_change << std::endl;
1531  }
1532  }
1533 
1534  //---- Print chi2
1535  if(ALIUtils::debug >= 0) std::cout << theNoFitIterations << " Chi2 after iteration = " << fit_quality << std::endl;
1536  if( ALIUtils::report >= 1 ) {
1537  //--------- Get report file handler
1539  fileout << theNoFitIterations << " Chi2 after iteration = " << fit_quality << std::endl;
1540  }
1541 
1542 }
1543 
1544 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1546 {
1547  if(ALIUtils::debug >= 3) std::cout << "@@@ Fit::CheckIfFitPossible" << std::endl;
1548 
1549  //----- Check if there is an unknown parameter that is not affecting any measurement
1550  ALIint NolinMes = 0;
1551  std::vector<Measurement*>::const_iterator vmcite;
1552  for ( vmcite = Model::MeasurementList().begin();
1553  vmcite != Model::MeasurementList().end(); ++vmcite) {
1554  NolinMes += (*vmcite)->dim();
1555  }
1556 
1557  std::vector< Entry* >::const_iterator vecite;
1558  for ( vecite = Model::EntryList().begin(); vecite != Model::EntryList().end(); ++vecite ) {
1559  if( ALIUtils::debug >= 4 ) std::cout << "Fit::CheckIfFitPossible looping for entry " << (*vecite)->longName() << std::endl;
1560  if ( (*vecite)->quality() == 2 ) {
1561  ALIint nCol = (*vecite)->fitPos();
1562  //--- Check all measurements
1563  ALIbool noDepend = TRUE;
1564  if( ALIUtils::debug >= 4 ) std::cout << "Fit::CheckIfFitPossible looping for entry " << nCol << std::endl;
1565  for( ALIint ii = 0; ii < NolinMes; ii++ ) {
1566  if( ALIUtils::debug >= 5 ) std::cout << " Derivative= (" << ii << "," << nCol << ") = " << (*AMatrix)(ii,nCol) << std::endl;
1567 
1568  if( std::abs((*AMatrix)(ii,nCol)) > ALI_DBL_MIN ) {
1569  if( ALIUtils::debug >= 5 ) std::cout << "Fit::CheckIfFitIsPossible " << nCol << " " << ii << " = " << (*AMatrix)(ii,nCol) << std::endl;
1570  noDepend = FALSE;
1571  break;
1572  }
1573  }
1574  if( noDepend ){
1575  throw cms::Exception("SDFError") << "!!!FATAL ERROR: Fit::CheckIfFitPossible() no measurement depends on unknown entry " << (*vecite)->OptOCurrent()->name() << "/" << (*vecite)->name() << std::endl
1576  << "!!! Fit will not be possible! " << std::endl;
1577  }
1578  }
1579  }
1580 
1581  //------ 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!
1582 
1583  std::vector< Entry* >::const_iterator vecite1,vecite2;
1584  ALIint nLin = AMatrix->NoLines();
1585  ALIdouble derivPrec = ALI_DBL_MIN;
1586  //---------- Loop entries
1587  for ( vecite1 = Model::EntryList().begin();
1588  vecite1 != Model::EntryList().end(); ++vecite1 ) {
1589  if( (*vecite1)->quality() == 2 ) {
1590  vecite2 = vecite1; ++vecite2;
1591  for ( ;vecite2 != Model::EntryList().end(); ++vecite2 ) {
1592  if( (*vecite2)->quality() == 2 ) {
1593  ALIint fitpos1 = (*vecite1)->fitPos();
1594  ALIint fitpos2 = (*vecite2)->fitPos();
1595  if( ALIUtils::debug >= 5 ) std::cout << "Fit::CheckIfFitIsPossible checking " << (*vecite1)->longName() << " ( " << fitpos1 << " ) & " << (*vecite2)->longName() << " ( " << fitpos2 << " ) "<< std::endl;
1596  ALIdouble prop = DBL_MAX;
1597  ALIbool isProp = TRUE;
1598  for( ALIint ii = 0; ii < nLin; ii++ ) {
1599  if( ALIUtils::debug >= 5 ) std::cout << "Fit::CheckIfFitIsPossible " << ii << " : " << (*AMatrix)(ii,fitpos1) << " ?= " << (*AMatrix)(ii,fitpos2) << std::endl;
1600  if( std::abs((*AMatrix)(ii,fitpos1)) < derivPrec ) {
1601  if( std::abs((*AMatrix)(ii,fitpos2)) > derivPrec ) {
1602  isProp = FALSE;
1603  break;
1604  }
1605  } else {
1606  ALIdouble propn = (*AMatrix)(ii,fitpos2) / (*AMatrix)(ii,fitpos1);
1607  if( prop != DBL_MAX && prop != propn ) {
1608  isProp = FALSE;
1609  break;
1610  }
1611  prop = propn;
1612  }
1613  }
1614  if( isProp ) {
1615  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
1616  << "!!! Fit will not be possible! " << std::endl;
1617  throw cms::Exception("SDFError");
1618  }
1619  }
1620  }
1621  }
1622  }
1623 }
1624 
1625 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1627 {
1628  int measProp = -1;
1629 
1630  std::set<ALIuint> columnsEqual;
1631  std::set<ALIuint> columnsEqualSave;
1632  ALIuint biggestColumn = 0;
1633  ALIdouble biggest = 0.;
1634  for (int ii = 0; ii < AMatrix->NoColumns(); ii++ ){
1635  if( std::abs((*AMatrix)(measNo,ii)) > biggest ) {
1636  biggest = std::abs((*AMatrix)(measNo,ii));
1637  biggestColumn = ii;
1638  }
1639  columnsEqualSave.insert(ii);
1640  }
1641 
1642  ALIdouble div;
1643 
1644  for( int jj = 0; jj < AMatrix->NoLines(); jj++ ){
1645  if( jj == int(measNo) ) continue;
1646  columnsEqual = columnsEqualSave;
1647  // check if ratio of each column to 'biggestColumn' is the same as for the N measurement
1648  for (int ii = 0; ii < AMatrix->NoColumns(); ii++ ){
1649  div = (*AMatrix)(measNo,ii)/(*AMatrix)(measNo,biggestColumn);
1650  if( std::abs((*AMatrix)(jj,ii)) > ALI_DBL_MIN && std::abs(div - (*AMatrix)(jj,ii)/(*AMatrix)(jj,biggestColumn) ) > ALI_DBL_MIN ) {
1651  if( ALIUtils::debug >= 3 ) std::cout << "CheckIfMeasIsProportionalToAnother 2 columns = " << ii << " in " << measNo << " & " << jj << std::endl;
1652  } else {
1653  if( ALIUtils::debug >= 3 ) std::cout << "CheckIfMeasIsProportionalToAnother 2 columns != " << ii << " in " << measNo << " & " << jj << std::endl;
1654  // if it is not equal delete this column
1655  std::set<ALIuint>::iterator ite = columnsEqual.find( ii );
1656  if( ite != columnsEqual.end() ){
1657  columnsEqual.erase(ite);
1658  }
1659  }
1660  }
1661  // check if not all columns have been deleted from columnsEqual
1662  if( !columnsEqual.empty() ) {
1663  if( ALIUtils::debug >= 3 ) std::cout << "CheckIfMeasIsProportionalToAnother " << measNo << " = " << jj << std::endl;
1664  measProp = jj;
1665  break;
1666  }
1667  }
1668 
1669  return measProp;
1670 }
1671 
1672 
1673 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1675 {
1676  std::string measname = " ";
1677 
1678  std::cout << " imeas " << imeas << std::endl;
1679  int Aline = 0;
1680  std::vector< Measurement* >::const_iterator vmcite;
1681  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
1682  for ( ALIuint jj = 0; jj < ALIuint((*vmcite)->dim()); jj++) {
1683  if( Aline == imeas ) {
1684  char ctmp[20];
1685  gcvt( jj, 10, ctmp );
1686  return ((*vmcite)->name()) + ":" + std::string(ctmp);
1687  }
1688  Aline++;
1689  }
1690  }
1691 
1692  std::cout << " return measname " << measname << std::endl;
1693  return measname;
1694 }
1695 
static void set_time_now(time_t now)
Definition: ALIUtils.h:48
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 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
static void printCentreInOptOFrame(const OpticalObject *opto, const OpticalObject *optoAncestor, ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1257
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 dumpEntryAfterFit(ALIFileOut &fileout, const Entry *entry, double entryvalue, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1319
bool DumpCocoaResults()
Definition: CocoaDBMgr.cc:51
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
Definition: ALIUtils.cc:77
ALIdouble value() const
Definition: Entry.h:55
MatrixMeschach * MatrixByMatrix(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
static ALIdouble getMaximumDeviationDerivative()
Definition: ALIUtils.h:107
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:580
static ALIint debug
Definition: ALIUtils.h:36
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:109
static ErrorCorrelationMgr * getInstance()
static Fit & getInstance()
Definition: Fit.cc:71
static GlobalOptionMgr * getInstance()
static void setFittableEntries()
Definition: Fit.cc:364
void FillMeasurements()
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:635
static double getEntryValue(const Entry *entry)
Definition: Fit.cc:1301
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.
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 void dumpFittedValuesInAllAncestorFrames(ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1210
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
T sqrt(T t)
Definition: SSEVec.h:18
static ALIint findEntryFitPosition(const ALIstring &opto_name, const ALIstring &entry_name)
Definition: Fit.cc:1445
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:1674
const ALIdouble getCorrelation() const
static void setFirstTime(ALIbool val)
Definition: ALIUtils.h:104
static ALIdouble thePreviousIterationFitQuality
Definition: Fit.h:187
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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
isFirst
Definition: cuy.py:418
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
ii
Definition: cuy.py:589
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:1422
static void dumpFittedValues(ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1147
const pss & getEntry2() const
static void dumpEntryCorrelations(ALIFileOut &file)
Definition: Fit.cc:1370
static CocoaDBMgr * getInstance()
Definition: CocoaDBMgr.cc:37
void AddData(ALIuint col, ALIuint lin, ALIdouble data)
static void startFit()
Definition: Fit.cc:105
static ALIint report
Definition: ALIUtils.h:35
static ALIdouble cameraScaleFactor
Definition: Measurement.h:209
static ALIbool getFirstTime()
Definition: ALIUtils.h:101
static void deleteMatrices()
Definition: Fit.cc:538
static void CheckIfFitPossible()
Definition: Fit.cc:1545
const CLHEP::Hep3Vector & centreGlob() const
Definition: OpticalObject.h:85
static void printRotationAnglesInOptOFrame(const OpticalObject *opto, const OpticalObject *optoAncestor, ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1289
void FillOptObjects(MatrixMeschach *AtWAMatrix)
static int CheckIfMeasIsProportionalToAnother(ALIuint measNo)
Definition: Fit.cc:1626
#define begin
Definition: vmac.h:32
ALIint quality() const
Definition: Entry.h:59
Fit()
Definition: Fit.h:38
std::string ALIstring
Definition: CocoaGlobals.h:9
void FillFitParameters(MatrixMeschach *AtWAMatrix)
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
const ALIstring & name() const
Definition: OpticalObject.h:60
static void PrintChi2(ALIdouble fit_quality, ALIbool isFirst)
Definition: Fit.cc:1479
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
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:45