CMS 3D CMS Logo

Fit.h
Go to the documentation of this file.
1 // COCOA class header file
2 //Id: Fit.h
3 //CAT: Model
4 //
5 // Utility class that starts reading the system description file
6 // and contains the static data
7 //
8 // History: v1.0
9 // Pedro Arce
10 #ifndef FIT_H
11 #define FIT_H
12 
13 #define MAT_MESCHACH
14 #ifdef MAT_MESCHACH
16 #endif
17 
18 #include <vector>
19 
21 class Entry;
22 class OpticalObject;
23 #include "CLHEP/Vector/Rotation.h"
24 class FittedEntriesSet;
25 class ALIFileOut;
27 
28 typedef std::pair<ALIstring, ALIstring> pss;
29 
31 
32 class Fit {
33 public:
34  //----- Constructor / Destructor
35  Fit(){};
36  ~Fit(){};
37 
38  //----- Gets the only instance of this class
39  static Fit& getInstance();
40 
41  //----- Steering method to make the fit
42  static void startFit();
43 
44  //----- Dump all the entries that have been fitted (those that were 'cal' or 'unk'
45  //deprecated static void dumpFittedEntries();
46 
47  //----- Dump all the entries of all the objects
48  static void dumpFittedValues(ALIFileOut& fileout, ALIbool printErrors = true, ALIbool printOrig = true);
50  ALIbool printErrors = true,
51  ALIbool printOrig = true);
52  static void dumpEntryAfterFit(
53  ALIFileOut& fileout, const Entry* entry, double entryvalue, ALIbool printErrors = true, ALIbool printOrig = true);
55  static void printCentreInOptOFrame(const OpticalObject* opto,
56  const OpticalObject* optoAncestor,
57  ALIFileOut& fileout,
58  ALIbool printErrors = true,
59  ALIbool printOrig = true);
60  static void printRotationAnglesInOptOFrame(const OpticalObject* opto,
61  const OpticalObject* optoAncestor,
62  ALIFileOut& fileout,
63  ALIbool printErrors = true,
64  ALIbool printOrig = true);
65 
66  //----- Dump matrices used for the fit
67  static void dumpMatrices();
68 
69  //@@@@ Access static data members
70 
71  //----- Search an Entry name in of OpticalObject 'opto_name' and return its fitpos
72  static ALIint findEntryFitPosition(const ALIstring& opto_name, const ALIstring& entry_name);
73 
74  //----- returns propagation matrix
75  //op static ALIMatrix& propagationMatrix(){
76  //op return *thePropagationMatrix;
77  //op }
78 
79  //@@@@@ private METHODS
80 public:
81  //------ Count how many entries are going to be fitted (have quality >= theMinimumEntryQuality). Set for this entries the value of theFitPos
82  static void setFittableEntries();
83 
85 
86 private:
87  static void WriteVisualisationFiles();
88 
89  //----- Calculate the parameters (position, angles,...) with the chi square fit
90  //---- daFactor is the factor by which it is multiplied the matrix Da
91  static FitQuality fitParameters(const double daFactor);
92 
93  static void redoMatrices();
94 
95  //----- Propagate the error of every Entry to every Measurement
96  static void PropagateErrors();
97 
98 public:
99  //----- Calculate the simulated value of each Measurement propagating the LightRay when all the entries have their original values
101 
103 
104 private:
105  //----- Calculate the NoLines & NoColumns and create matrices
106  static void CreateMatrices();
107 
108  //----- Loop Measurements:
109  //--- Fill Matrix A with derivatives respect to affecting entries
110  //--- Fill Matrix W, y & f with values and sigmas of measurement coordinateFill matrices
111  static void FillMatricesWithMeasurements();
112 
113  //----- Loop Measurements:
114  //--- Fill Matrix A with derivatives respect to affecting entries
115  //--- Fill Matrix W, y & f with values and sigmas of measurement coordinate
117 
118  //----- set Correlations In W Matrix
119  static void setCorrelationsInWMatrix();
120 
121  //---------- set correlation between two entries of two OptOs
122  static void setCorrelationFromParamFitted(const pss& entry1, const pss& entry2, ALIdouble correl);
123  static void setCorrelationFromParamFitted(const ALIint fit_pos1, const ALIint fit_pos2, ALIdouble correl);
124 
125  //----- multiply matrices needed for fit
126  static void multiplyMatrices();
127 
128  //----- Get Smatrix to calculate chi2
129  static ALIdouble GetSChi2(ALIbool useDa);
130 
131  //----- check if the quality of the fit for this iteration is good enough
132  static FitQuality getFitQuality(const ALIbool canBeGood = TRUE);
133  static void evaluateFitQuality(const FitQuality fq, const double daFactor);
134 
135  //----- Correct entries with fitted values
136  static void addDaMatrixToEntries();
137 
138  //----- Substract Da of previous iteration (to try with a new Correct entries with fitted values
140 
141  static void deleteMatrices();
142 
143  static double getEntryValue(const Entry* entry);
144 
145 public:
146  static void PrintChi2(ALIdouble fit_quality, ALIbool isFirst);
147 
148  // public static DATA MEMBERS
149 public:
150  // maximum deviation in a Measurent when a parameter is displaced to get derivative
151 
152  static ALIMatrix* GetAtWAMatrix() { return AtWAMatrix; }
153 
154 private:
155  static void CheckIfFitPossible();
156  static int CheckIfMeasIsProportionalToAnother(ALIuint measNo);
157  static std::string GetMeasurementName(int meas);
158 
159  // private DATA MEMBERS
160 private:
161  // Only instance of Fit
162  static Fit* instance;
163 
168  //op static ALIMatrix* VaMatrix;
170  //op static ALIMatrix* PDMatrix;
171  //- static ALIMatrix* VyMatrix;
172  //op static ALIMatrix* yMatrix;
173  //op static ALIMatrix* fMatrix;
175  //op static ALIMatrix* thePropagationMatrix;
176  //----- The number of lines and columns of matrix A
179 
180  //FOR LINK..................
181 private:
182  //
183  //- void AddSigma( CLHEP::Hep3Vector& vori, CLHEP::Hep3Vector& vadd );
184  //- CLHEP::Hep3Vector atanVectorSigma( CLHEP::Hep3Vector& tanvs, const CLHEP::Hep3Vector& tanv );
185  //- CLHEP::Hep3Vector atanVector( CLHEP::Hep3Vector& tanv );
186 
187  //----- The minimum quality an entry must have to be inhcluded in the fit
189 
190  //----- Quality of fit in previous iteration
192 
193  //----- Minimum quality (chi square) the fit has to have to be good
195 
196  //----- Minimum change in quality (chi square) w.r.t previous iteration the fit has to have to be good
198 
199  //----- Number of fit iterations made up to a certain moment
201  //----- Maximum number of fit iterations for the fit to reach good quality
203 
204  //----- Minimum value of the factor to multiply Da to test if an smaller chi2 can be obtained (chapter 5.2 of LeastSquareMethods)
206 
207 public:
208  static ALIuint nEvent;
209 };
210 
211 #endif
Fit::DaMatrix
static ALIMatrix * DaMatrix
Definition: Fit.h:169
Fit::dumpFittedValuesInAllAncestorFrames
static void dumpFittedValuesInAllAncestorFrames(ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1251
Fit::PropagateErrors
static void PropagateErrors()
Definition: Fit.cc:457
Fit::dumpEntryAfterFit
static void dumpEntryAfterFit(ALIFileOut &fileout, const Entry *entry, double entryvalue, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1365
ALIbool
bool ALIbool
Definition: CocoaGlobals.h:19
Fit::theMinDaFactor
static ALIdouble theMinDaFactor
Definition: Fit.h:205
Model.h
Fit::GetMeasurementName
static std::string GetMeasurementName(int meas)
Definition: Fit.cc:1734
Fit::thePreviousIterationFitQuality
static ALIdouble thePreviousIterationFitQuality
Definition: Fit.h:191
pss
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
mps_splice.entry
entry
Definition: mps_splice.py:68
Fit::calculateSimulatedMeasurementsWithOriginalValues
static void calculateSimulatedMeasurementsWithOriginalValues()
Definition: Fit.cc:532
Fit::theMinimumEntryQuality
static ALIint theMinimumEntryQuality
Definition: Fit.h:188
FQsmallDistanceToMinimum
Definition: Fit.h:30
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
Fit::~Fit
~Fit()
Definition: Fit.h:36
Fit::AtWAMatrix
static ALIMatrix * AtWAMatrix
Definition: Fit.h:167
Fit::addDaMatrixToEntries
static void addDaMatrixToEntries()
Definition: Fit.cc:1105
OpticalObject
Definition: OpticalObject.h:35
FittedEntriesSet
Definition: FittedEntriesSet.h:22
Fit::theRelativeFitQualityCut
static ALIdouble theRelativeFitQualityCut
Definition: Fit.h:197
ALIFileOut
Definition: ALIFileOut.h:21
cuy.isFirst
isFirst
Definition: cuy.py:419
Fit::noFitIterations
static ALIint noFitIterations()
Definition: Fit.h:102
Fit::CheckIfFitPossible
static void CheckIfFitPossible()
Definition: Fit.cc:1588
Fit::dumpMatrices
static void dumpMatrices()
Definition: Fit.cc:1467
Fit::fitParameters
static FitQuality fitParameters(const double daFactor)
Definition: Fit.cc:407
Fit::dumpFittedValues
static void dumpFittedValues(ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1185
TRUE
#define TRUE
Definition: scimark2.h:12
Fit::theNoFitIterations
static ALIint theNoFitIterations
Definition: Fit.h:200
Fit::findEntryFitPosition
static ALIint findEntryFitPosition(const ALIstring &opto_name, const ALIstring &entry_name)
Definition: Fit.cc:1487
Fit::fitNextEvent
static ALIbool fitNextEvent(ALIuint &nEvent)
Definition: Fit.cc:144
Fit::dumpEntryCorrelations
static void dumpEntryCorrelations(ALIFileOut &file)
Definition: Fit.cc:1415
Fit
Definition: Fit.h:32
Fit::theFitQualityCut
static ALIdouble theFitQualityCut
Definition: Fit.h:194
Fit::Fit
Fit()
Definition: Fit.h:35
Fit::setFittableEntries
static void setFittableEntries()
Definition: Fit.cc:382
Fit::deleteMatrices
static void deleteMatrices()
Definition: Fit.cc:553
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
Fit::instance
static Fit * instance
Definition: Fit.h:162
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Fit::redoMatrices
static void redoMatrices()
Definition: Fit.cc:442
Fit::PrintChi2
static void PrintChi2(ALIdouble fit_quality, ALIbool isFirst)
Definition: Fit.cc:1517
FitQuality
FitQuality
Definition: Fit.h:30
Fit::getFitQuality
static FitQuality getFitQuality(const ALIbool canBeGood=TRUE)
Definition: Fit.cc:915
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
Fit::evaluateFitQuality
static void evaluateFitQuality(const FitQuality fq, const double daFactor)
Fit::multiplyMatrices
static void multiplyMatrices()
Definition: Fit.cc:830
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
ALIuint
unsigned int ALIuint
Definition: CocoaGlobals.h:17
Fit::getEntryValue
static double getEntryValue(const Entry *entry)
Definition: Fit.cc:1347
Fit::CreateMatrices
static void CreateMatrices()
Definition: Fit.cc:570
Fit::AtMatrix
static ALIMatrix * AtMatrix
Definition: Fit.h:165
Entry
Definition: Entry.h:18
Fit::getInstance
static Fit & getInstance()
Definition: Fit.cc:69
Fit::GetAtWAMatrix
static ALIMatrix * GetAtWAMatrix()
Definition: Fit.h:152
Fit::printRotationAnglesInOptOFrame
static void printRotationAnglesInOptOFrame(const OpticalObject *opto, const OpticalObject *optoAncestor, ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1332
Fit::nEvent
static ALIuint nEvent
Definition: Fit.h:208
Fit::setCorrelationFromParamFitted
static void setCorrelationFromParamFitted(const pss &entry1, const pss &entry2, ALIdouble correl)
Definition: Fit.cc:808
FQchiSquareWorsened
Definition: Fit.h:30
Fit::FillMatricesWithMeasurements
static void FillMatricesWithMeasurements()
Definition: Fit.cc:638
MatrixMeschach.h
MatrixMeschach
Definition: MatrixMeschach.h:30
Fit::yfMatrix
static ALIMatrix * yfMatrix
Definition: Fit.h:174
Fit::_NoLinesA
static ALIint _NoLinesA
Definition: Fit.h:177
Fit::CheckIfMeasIsProportionalToAnother
static int CheckIfMeasIsProportionalToAnother(ALIuint measNo)
Definition: Fit.cc:1681
Fit::printCentreInOptOFrame
static void printCentreInOptOFrame(const OpticalObject *opto, const OpticalObject *optoAncestor, ALIFileOut &fileout, ALIbool printErrors=true, ALIbool printOrig=true)
Definition: Fit.cc:1297
ALIint
int ALIint
Definition: CocoaGlobals.h:15
Fit::GetSChi2
static ALIdouble GetSChi2(ALIbool useDa)
Definition: Fit.cc:1034
CocoaGlobals.h
Fit::_NoColumnsA
static ALIint _NoColumnsA
Definition: Fit.h:178
Fit::setCorrelationsInWMatrix
static void setCorrelationsInWMatrix()
Definition: Fit.cc:786
Fit::MaxNoFitIterations
static ALIint MaxNoFitIterations
Definition: Fit.h:202
Fit::FillMatricesWithCalibratedParameters
static void FillMatricesWithCalibratedParameters()
Definition: Fit.cc:724
Fit::substractLastDisplacementToEntries
static void substractLastDisplacementToEntries(const ALIdouble factor)
Definition: Fit.cc:1159
Fit::WMatrix
static ALIMatrix * WMatrix
Definition: Fit.h:166
Fit::AMatrix
static ALIMatrix * AMatrix
Definition: Fit.h:164
FQbigDistanceToMinimum
Definition: Fit.h:30
Fit::WriteVisualisationFiles
static void WriteVisualisationFiles()
Definition: Fit.cc:354
Fit::startFit
static void startFit()
Definition: Fit.cc:103