CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/Alignment/CocoaAnalysis/src/FittedEntry.cc

Go to the documentation of this file.
00001 //  COCOA class implementation file
00002 //Id:  FittedEntry.cc
00003 //CAT: Model
00004 //
00005 //   History: v1.0 
00006 //   Pedro Arce
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 #include <cstdlib>
00016 
00017 
00018 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
00019 FittedEntry::FittedEntry( Entry* entry, ALIint order, ALIdouble sigma)
00020 {
00021   theEntry = entry;
00022   theOrder = order;
00023   theOptOName = entry->OptOCurrent()->longName();
00024   if(ALIUtils::debug >= 5) std::cout << " creating FittedEntry " << theOptOName << std::endl;
00025   theEntryName = entry->name();
00026   BuildName();
00027 
00028   //------ store values and sigmas in dimensions indicated by global options
00029   ALIdouble dimv = entry->OutputValueDimensionFactor();
00030   ALIdouble dims = entry->OutputSigmaDimensionFactor();
00031   theValue = ( entry->value() + entry->valueDisplacementByFitting() ) / dimv;
00032   theSigma = sigma / dims;
00033   theOrigValue = entry->value() / dimv;
00034   theOrigSigma = entry->sigma() / dims;
00035   theQuality = entry->quality();
00036 
00037   //-std::cout << this << " FE value" << this->theValue << "sigma" << this->theSigma << std::endl;
00038 }
00039 
00040 
00041 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
00042 FittedEntry::FittedEntry( ALIstring name, float value, float sigma)
00043 { 
00044   //ar.lass1.laser.centre_X
00045   theOrder = 0;
00046   theOptOName = "s";
00047   ALIint point = -1;
00048   ALIint pointold = 0;
00049   for( ;; ){
00050     point = name.find( ".", point+1 );
00051     if( point == -1 ) break;
00052     theOptOName += "/" + name.substr( pointold, point-pointold);
00053     pointold = point+1;
00054   }
00055   theEntryName = name.substr( pointold, name.size() );
00056 
00057   //  std::cout << " building theEntryName " << theEntryName << " " << pointold << " " << name << std::endl;
00058   Entry* entry = Model::getEntryByName( theOptOName, theEntryName ); 
00059 
00060   theEntry = 0;
00061 
00062   //------ store values and sigmas in dimensions indicated by global options
00063   ALIdouble dimv = entry->OutputValueDimensionFactor();
00064   ALIdouble dims = entry->OutputSigmaDimensionFactor();
00065   theValue = value * dimv;
00066   theSigma = sigma * dims;
00067   theOrigValue = value * dimv;
00068   theOrigSigma = sigma * dims;
00069   theQuality = 2;
00070 
00071   //-std::cout << this << " FE value" << this->theValue << "sigma" << this->theSigma << std::endl;
00072 }
00073 
00074 
00075 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
00076 FittedEntry::FittedEntry( std::vector<FittedEntry*> vFEntry )
00077 {
00078   //----- Average the entries
00079 
00080   std::vector<FittedEntry*>::iterator ite;
00081   //--- First check that all entries are from the same OptO and Entry
00082   theOptOName = (vFEntry[0]->getOptOName() );
00083   theEntryName = (vFEntry[0]->getEntryName() );
00084   theOrder = (vFEntry[0]->getOrder() );
00085   theEntry = (vFEntry[0]->getEntry() );
00086   theQuality = (vFEntry[0]->getQuality() );
00087 
00088   theValue = 0.;
00089   theSigma = 0.;
00090   theOrigValue = 0.;
00091   theOrigSigma = 0.;
00092   for( ite = vFEntry.begin(); ite != vFEntry.end(); ite++) {
00093     if( (*ite)->getOptOName() != theOptOName || (*ite)->getEntryName() != theEntryName ){
00094       std::cerr << "!!! FATAL ERROR FittedEntry::FittedEntry  one entry in list has different opto or entry names : " << (*ite)->getOptOName() << " !=  " << theOptOName << " " << (*ite)->getEntryName() << " != " << theEntryName << std::endl;
00095       exit(1);
00096     }
00097 
00098     theValue += (*ite)->getValue();
00099     theSigma += (*ite)->getSigma();
00100     theOrigValue += (*ite)->getOrigValue();
00101     theOrigSigma += (*ite)->getOrigSigma();
00102   }
00103 
00104   ALIint siz = vFEntry.size();
00105   theValue /= siz;
00106   theSigma /= siz;
00107   theOrigValue /= siz;
00108   theOrigSigma /= siz;
00109 
00110 }
00111 
00112 
00113 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
00114 void FittedEntry::BuildName()
00115 {
00116   //----- substitute '/' by '.' in opto name
00117   theName = theOptOName.substr( 2, theOptOName.size() );  // skip the first 's/'
00118   ALIint slash = -1;
00119   for(;;){
00120     slash =  theName.find('/', slash+1);
00121     if( slash == -1 ) break;
00122     theName[slash] = '.';
00123   }
00124 
00125   //----- Check if there is a ' ' in entry (should not happen now)
00126   ALIint space = theEntryName.rfind(' ');
00127   theName.append(".");
00128   ALIstring en = theEntryName;
00129   if( space != -1) en[space] = '_';
00130 
00131   //----- Merge opto and entry names
00132   // now it is not used as theName   theName.append( en + ".out");
00133   theName.append( en);
00134 
00135 }
00136