File indexing completed on 2024-09-07 04:34:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef MODEL_H
0012 #define MODEL_H
0013
0014 #include <vector>
0015 #include <map>
0016
0017
0018 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
0019 class Entry;
0020
0021 class OpticalObject;
0022
0023 class Measurement;
0024 class ALIFileIn;
0025 class FittedEntriesReader;
0026
0027 class OpticalAlignments;
0028 class OpticalAlignMeasurements;
0029
0030 #include "CondFormats/OptAlignObjects/interface/OpticalAlignInfo.h"
0031
0032 enum sectionType {
0033 sectGlobalOptions,
0034 sectParameters,
0035 sectSystemTreeDescription,
0036 sectSystemTreeData,
0037 sectMeasurements,
0038 sectReportOut
0039 };
0040
0041 enum cocoaStatus {
0042 COCOA_Init,
0043 COCOA_ReadingModel,
0044 COCOA_InitFit,
0045 COCOA_FirstIterationInEvent,
0046 COCOA_NextIterationInEvent,
0047 COCOA_FitOK,
0048 COCOA_FitImproving,
0049 COCOA_FitCannotImprove,
0050 COCOA_FitChi2Worsened,
0051 COCOA_FitMatrixNonInversable
0052 };
0053
0054 class Model {
0055 public:
0056
0057 Model();
0058 ~Model() {}
0059
0060
0061 static Model& getInstance();
0062
0063 static cocoaStatus getCocoaStatus() { return theCocoaStatus; }
0064 static void setCocoaStatus(const cocoaStatus cs) { theCocoaStatus = cs; }
0065 static std::string printCocoaStatus(const cocoaStatus cs);
0066
0067
0068 static void readSystemDescription();
0069
0070
0071 void BuildSystemDescriptionFromOA(OpticalAlignments& optAlig);
0072 OpticalAlignInfo FindOptAlignInfoByType(const ALIstring& type);
0073
0074 void BuildMeasurementsFromOA(OpticalAlignMeasurements& measList);
0075
0076
0077
0078
0079
0080
0081
0082 static std::vector<std::vector<ALIstring> >& OptODictionary() { return theOptODictionary; }
0083
0084 static std::vector<OpticalObject*>& OptOList() { return theOptOList; }
0085
0086 static std::vector<Entry*>& EntryList() { return theEntryVector; }
0087
0088 static std::vector<Measurement*>& MeasurementList() { return theMeasurementVector; }
0089
0090 static Measurement* getMeasurementByName(const ALIstring& name, ALIbool exists = true);
0091
0092
0093 static ALIstring& SDFName() { return theSDFName; }
0094
0095
0096 static ALIstring& MeasFName() { return theMeasFName; }
0097
0098
0099 static ALIstring& ReportFName() { return theReportFName; }
0100
0101
0102 static ALIstring& MatricesFName() { return theMatricesFName; }
0103
0104
0105
0106
0107 static int getParameterValue(const ALIstring& sstr, ALIdouble& val);
0108
0109
0110 static OpticalObject* getOptOByName(const ALIstring& opto_name);
0111
0112
0113 static OpticalObject* getOptOByType(const ALIstring& type);
0114
0115
0116 static Entry* getEntryByName(const ALIstring& opto_name, const ALIstring& entry_name);
0117
0118
0119
0120 static Entry* getEntryByName(const ALIstring& opto_entry_name) {
0121 ALIint slash_pos = opto_entry_name.rfind('/');
0122 ALIint length = opto_entry_name.length();
0123 ALIstring opto_name = opto_entry_name.substr(0, slash_pos);
0124 ALIstring entry_name = opto_entry_name.substr(slash_pos + 1, length);
0125 Entry* entry = getEntryByName(opto_name, entry_name);
0126 return entry;
0127 }
0128
0129
0130 static ALIbool getComponentOptOTypes(const ALIstring& opto_type, std::vector<ALIstring>& vcomponents);
0131
0132
0133 static ALIbool getComponentOptOs(const ALIstring& opto_name, std::vector<OpticalObject*>& vcomponents);
0134
0135 static struct tm& MeasurementsTime() { return theMeasurementsTime; }
0136
0137 static std::vector<OpticalAlignInfo> getOpticalAlignments() { return theOpticalAlignments; }
0138
0139
0140 static void addEntryToList(Entry* entry) {
0141 theEntryVector.push_back(entry);
0142
0143 }
0144
0145 static void addMeasurementToList(Measurement* measadd) {
0146 theMeasurementVector.push_back(measadd);
0147
0148 }
0149
0150
0151 static void setSDFName(const ALIstring& name) { theSDFName = name; }
0152
0153 static void setReportFName(const ALIstring& name) { theReportFName = name; }
0154
0155 static void setMatricesFName(const ALIstring& name) { theMatricesFName = name; }
0156
0157 static void setMeasurementsTime(struct tm& tim) { theMeasurementsTime = tim; }
0158
0159 static ALIbool readMeasurementsFromFile(ALIstring only1Date = ALIstring(""), ALIstring only1Time = ALIstring(""));
0160
0161
0162 private:
0163
0164 static void reorderOptODictionary(const ALIstring& ssearch, std::vector<std::vector<ALIstring> >& OptODictionary2);
0165
0166
0167
0168
0169
0170 static void buildMeasurementsLinksToOptOs();
0171
0172 static void SetValueDisplacementsFromReportOut();
0173
0174
0175
0176 static Model* theInstance;
0177
0178
0179
0180
0181
0182 static std::vector<std::vector<ALIstring> > theOptODictionary;
0183
0184
0185
0186
0187
0188 static std::vector<OpticalObject*> theOptOList;
0189
0190
0191 static std::vector<Entry*> theEntryVector;
0192
0193
0194 static std::vector<Measurement*> theMeasurementVector;
0195
0196
0197 static ALIstring theSDFName;
0198
0199 static ALIstring theMeasFName;
0200
0201 static ALIstring theReportFName;
0202
0203 static ALIstring theMatricesFName;
0204
0205
0206 public:
0207
0208 static ALIbool createCopyComponentList(const ALIstring& optoname);
0209
0210 static OpticalObject* nextOptOToCopy();
0211
0212 private:
0213
0214 static ALIbool fillCopyComponentList(const OpticalObject* opto);
0215
0216 static std::vector<OpticalObject*> theOptOsToCopyList;
0217
0218 static std::vector<OpticalObject*>::const_iterator theOptOsToCopyListIterator;
0219
0220
0221 public:
0222 static ALIint Ncmslinkrange;
0223 static std::vector<ALIdouble> CMSLinkRangeDetValue;
0224
0225
0226 public:
0227 void CMSLinkFit(ALIint cmslink);
0228
0229 private:
0230 void CMSLinkCleanModel();
0231 static void CMSLinkDeleteOptOs();
0232 static void CMSLinkSaveParamFittedSigma(ALIint cmslink);
0233 static void CMSLinkSaveParamFittedValueDisplacement(ALIint cmslink);
0234 static void CMSLinkRecoverParamFittedSigma(ALIint cmslink);
0235 static void CMSLinkRecoverParamFittedValueDisplacement(ALIint cmslink);
0236
0237 static ALIint CMSLinkIteration;
0238
0239
0240 static void deleteOptO(const ALIstring& opto_name);
0241 static void deleteOptO(OpticalObject* opto);
0242
0243 static void saveParamFittedSigma(const ALIstring& opto_name, const ALIstring& entry_name);
0244
0245 static void saveParamFittedCorrelation(const ALIstring& opto_name1,
0246 const ALIstring& entry_name1,
0247 const ALIstring& opto_name2,
0248 const ALIstring& entry_name2);
0249
0250 static void recoverParamFittedSigma(const ALIstring& opto_name, const ALIstring& entry_name, const ALIuint position);
0251
0252 public:
0253 static ALIdouble getParamFittedSigmaVectorItem(const ALIuint position);
0254 static FittedEntriesReader* getFittedEntriesReader() { return theFittedEntriesReader; }
0255
0256 private:
0257 static void cleanParamFittedSigmaVector() {
0258 ALIuint pfsv_size = theParamFittedSigmaVector.size();
0259 for (ALIuint ii = 0; ii < pfsv_size; ii++) {
0260 theParamFittedSigmaVector.pop_back();
0261 }
0262 }
0263
0264 static void cleanParamFittedValueDisplacementMap() {
0265 theParamFittedValueDisplacementMap.erase(theParamFittedValueDisplacementMap.begin(),
0266 theParamFittedValueDisplacementMap.end());
0267 }
0268
0269 static void copyMeasurements(const std::vector<ALIstring>& wl);
0270
0271 private:
0272 static cocoaStatus theCocoaStatus;
0273
0274 static std::vector<ALIdouble> theParamFittedSigmaVector;
0275
0276 static std::map<ALIstring, ALIdouble, std::less<ALIstring> > theParamFittedValueDisplacementMap;
0277
0278 static struct tm theMeasurementsTime;
0279
0280 static FittedEntriesReader* theFittedEntriesReader;
0281
0282 static std::vector<OpticalAlignInfo> theOpticalAlignments;
0283 };
0284
0285 #endif