Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:25

0001 //  COCOA class implementation file

0002 //Id:  FittedEntry.cc

0003 //CAT: Model

0004 //

0005 //   History: v1.0

0006 //   Pedro Arce

0007 
0008 #include "Alignment/CocoaFit/interface/FittedEntry.h"
0009 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0010 #include "Alignment/CocoaModel/interface/Entry.h"
0011 #include "Alignment/CocoaModel/interface/Model.h"
0012 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
0013 #include <iostream>
0014 #include <iomanip>
0015 #include <cstdlib>
0016 
0017 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2

0018 FittedEntry::FittedEntry(Entry* entry, ALIint order, ALIdouble sigma) {
0019   theEntry = entry;
0020   theOrder = order;
0021   theOptOName = entry->OptOCurrent()->longName();
0022   if (ALIUtils::debug >= 5)
0023     std::cout << " creating FittedEntry " << theOptOName << std::endl;
0024   theEntryName = entry->name();
0025   BuildName();
0026 
0027   //------ store values and sigmas in dimensions indicated by global options

0028   ALIdouble dimv = entry->OutputValueDimensionFactor();
0029   ALIdouble dims = entry->OutputSigmaDimensionFactor();
0030   theValue = (entry->value() + entry->valueDisplacementByFitting()) / dimv;
0031   theSigma = sigma / dims;
0032   theOrigValue = entry->value() / dimv;
0033   theOrigSigma = entry->sigma() / dims;
0034   theQuality = entry->quality();
0035 
0036   //-std::cout << this << " FE value" << this->theValue << "sigma" << this->theSigma << std::endl;

0037 }
0038 
0039 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2

0040 FittedEntry::FittedEntry(ALIstring name, float value, float sigma) {
0041   //ar.lass1.laser.centre_X

0042   theOrder = 0;
0043   theOptOName = "s";
0044   ALIint point = -1;
0045   ALIint pointold = 0;
0046   for (;;) {
0047     point = name.find('.', point + 1);
0048     if (point == -1)
0049       break;
0050     theOptOName += "/" + name.substr(pointold, point - pointold);
0051     pointold = point + 1;
0052   }
0053   theEntryName = name.substr(pointold, name.size());
0054 
0055   //  std::cout << " building theEntryName " << theEntryName << " " << pointold << " " << name << std::endl;

0056   Entry* entry = Model::getEntryByName(theOptOName, theEntryName);
0057 
0058   theEntry = nullptr;
0059 
0060   //------ store values and sigmas in dimensions indicated by global options

0061   ALIdouble dimv = entry->OutputValueDimensionFactor();
0062   ALIdouble dims = entry->OutputSigmaDimensionFactor();
0063   theValue = value * dimv;
0064   theSigma = sigma * dims;
0065   theOrigValue = value * dimv;
0066   theOrigSigma = sigma * dims;
0067   theQuality = 2;
0068 
0069   //-std::cout << this << " FE value" << this->theValue << "sigma" << this->theSigma << std::endl;

0070 }
0071 
0072 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2

0073 FittedEntry::FittedEntry(const std::vector<FittedEntry*>& _vFEntry) {
0074   //----- Average the entries

0075   std::vector<FittedEntry*> vFEntry = _vFEntry;
0076   std::vector<FittedEntry*>::iterator ite;
0077   //--- First check that all entries are from the same OptO and Entry

0078   theOptOName = (vFEntry[0]->getOptOName());
0079   theEntryName = (vFEntry[0]->getEntryName());
0080   theOrder = (vFEntry[0]->getOrder());
0081   theEntry = (vFEntry[0]->getEntry());
0082   theQuality = (vFEntry[0]->getQuality());
0083 
0084   theValue = 0.;
0085   theSigma = 0.;
0086   theOrigValue = 0.;
0087   theOrigSigma = 0.;
0088   for (ite = vFEntry.begin(); ite != vFEntry.end(); ++ite) {
0089     if ((*ite)->getOptOName() != theOptOName || (*ite)->getEntryName() != theEntryName) {
0090       std::cerr << "!!! FATAL ERROR FittedEntry::FittedEntry  one entry in list has different opto or entry names : "
0091                 << (*ite)->getOptOName() << " !=  " << theOptOName << " " << (*ite)->getEntryName()
0092                 << " != " << theEntryName << std::endl;
0093       exit(1);
0094     }
0095 
0096     theValue += (*ite)->getValue();
0097     theSigma += (*ite)->getSigma();
0098     theOrigValue += (*ite)->getOrigValue();
0099     theOrigSigma += (*ite)->getOrigSigma();
0100   }
0101 
0102   ALIint siz = vFEntry.size();
0103   theValue /= siz;
0104   theSigma /= siz;
0105   theOrigValue /= siz;
0106   theOrigSigma /= siz;
0107 }
0108 
0109 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2

0110 void FittedEntry::BuildName() {
0111   //----- substitute '/' by '.' in opto name

0112   theName = theOptOName.substr(2, theOptOName.size());  // skip the first 's/'

0113   ALIint slash = -1;
0114   for (;;) {
0115     slash = theName.find('/', slash + 1);
0116     if (slash == -1)
0117       break;
0118     theName[slash] = '.';
0119   }
0120 
0121   //----- Check if there is a ' ' in entry (should not happen now)

0122   ALIint space = theEntryName.rfind(' ');
0123   theName.append(".");
0124   ALIstring en = theEntryName;
0125   if (space != -1)
0126     en[space] = '_';
0127 
0128   //----- Merge opto and entry names

0129   // now it is not used as theName   theName.append( en + ".out");

0130   theName.append(en);
0131 }