00001
00002
00003
00004
00005
00006
00007
00008 #include "Alignment/CocoaAnalysis/interface/FittedEntry.h"
00009 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00010 #include "Alignment/CocoaModel/interface/Entry.h"
00011 #include "Alignment/CocoaModel/interface/Model.h"
00012 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
00013 #include <iostream>
00014 #include <iomanip>
00015
00016
00017
00018 FittedEntry::FittedEntry( Entry* entry, ALIint order, ALIdouble sigma)
00019 {
00020 theEntry = entry;
00021 theOrder = order;
00022 theOptOName = entry->OptOCurrent()->longName();
00023 if(ALIUtils::debug >= 5) std::cout << " creating FittedEntry " << theOptOName << std::endl;
00024 theEntryName = entry->name();
00025 BuildName();
00026
00027
00028 ALIdouble dimv = entry->OutputValueDimensionFactor();
00029 ALIdouble dims = entry->OutputSigmaDimensionFactor();
00030 theValue = ( entry->value() + entry->valueDisplacementByFitting() ) / dimv;
00031 theSigma = sigma / dims;
00032 theOrigValue = entry->value() / dimv;
00033 theOrigSigma = entry->sigma() / dims;
00034 theQuality = entry->quality();
00035
00036
00037 }
00038
00039
00040
00041 FittedEntry::FittedEntry( ALIstring name, float value, float sigma)
00042 {
00043
00044 theOrder = 0;
00045 theOptOName = "s";
00046 ALIint point = -1;
00047 ALIint pointold = 0;
00048 for( ;; ){
00049 point = name.find( ".", point+1 );
00050 if( point == -1 ) break;
00051 theOptOName += "/" + name.substr( pointold, point-pointold);
00052 pointold = point+1;
00053 }
00054 theEntryName = name.substr( pointold, name.size() );
00055
00056
00057 Entry* entry = Model::getEntryByName( theOptOName, theEntryName );
00058
00059 theEntry = 0;
00060
00061
00062 ALIdouble dimv = entry->OutputValueDimensionFactor();
00063 ALIdouble dims = entry->OutputSigmaDimensionFactor();
00064 theValue = value * dimv;
00065 theSigma = sigma * dims;
00066 theOrigValue = value * dimv;
00067 theOrigSigma = sigma * dims;
00068 theQuality = 2;
00069
00070
00071 }
00072
00073
00074
00075 FittedEntry::FittedEntry( std::vector<FittedEntry*> vFEntry )
00076 {
00077
00078
00079 std::vector<FittedEntry*>::iterator ite;
00080
00081 theOptOName = (vFEntry[0]->getOptOName() );
00082 theEntryName = (vFEntry[0]->getEntryName() );
00083 theOrder = (vFEntry[0]->getOrder() );
00084 theEntry = (vFEntry[0]->getEntry() );
00085 theQuality = (vFEntry[0]->getQuality() );
00086
00087 theValue = 0.;
00088 theSigma = 0.;
00089 theOrigValue = 0.;
00090 theOrigSigma = 0.;
00091 for( ite = vFEntry.begin(); ite != vFEntry.end(); ite++) {
00092 if( (*ite)->getOptOName() != theOptOName || (*ite)->getEntryName() != theEntryName ){
00093 std::cerr << "!!! FATAL ERROR FittedEntry::FittedEntry one entry in list has different opto or entry names : " << (*ite)->getOptOName() << " != " << theOptOName << " " << (*ite)->getEntryName() << " != " << theEntryName << std::endl;
00094 exit(1);
00095 }
00096
00097 theValue += (*ite)->getValue();
00098 theSigma += (*ite)->getSigma();
00099 theOrigValue += (*ite)->getOrigValue();
00100 theOrigSigma += (*ite)->getOrigSigma();
00101 }
00102
00103 ALIint siz = vFEntry.size();
00104 theValue /= siz;
00105 theSigma /= siz;
00106 theOrigValue /= siz;
00107 theOrigSigma /= siz;
00108
00109 }
00110
00111
00112
00113 void FittedEntry::BuildName()
00114 {
00115
00116 theName = theOptOName.substr( 2, theOptOName.size() );
00117 ALIint slash = -1;
00118 for(;;){
00119 slash = theName.find('/', slash+1);
00120 if( slash == -1 ) break;
00121 theName[slash] = '.';
00122 }
00123
00124
00125 ALIint space = theEntryName.rfind(' ');
00126 theName.append(".");
00127 ALIstring en = theEntryName;
00128 if( space != -1) en[space] = '_';
00129
00130
00131
00132 theName.append( en);
00133
00134 }
00135