CMS 3D CMS Logo

MeasurementDiffEntry.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 // Id: Measurement.C
3 // CAT: Model
4 // ---------------------------------------------------------------------------
5 // History: v1.0
6 // Authors:
7 // Pedro Arce
8 
14 #include <iostream>
15 #include <iomanip>
16 #include <cstdlib>
17 #include <cmath> // include floating-point std::abs functions
18 #ifdef COCOA_VIS
19 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
20 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
21 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
22 #endif
23 
24 
25 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
26 void MeasurementDiffEntry::buildOptONamesList( const std::vector<ALIstring>& wl )
27 {
28 
29  int NPairs = (wl.size()+1)/2; // Number of OptO names ( pair of name and '&' )
30 
31  //--------- Fill list with names
32  for ( int ii=0; ii<NPairs; ii++ ) {
33  //--- take out Entry names from object names
34  int isl = wl[ii*2].rfind("/");
35  AddOptONameListItem( wl[ii*2].substr(0,isl) );
36  // Check for separating '&'
37  if (ii != NPairs-1 && wl[2*ii+1] != ALIstring("&") ) {
39  std::cerr << "!!! Measured Optical Objects should be separated by '&', not by"
40  << wl[2*ii+1] << std::endl;
41  exit(2);
42  }
43  //---- Fill entry names
44  if( ii == 0 ){
45  theEntryNameFirst = wl[ii*2].substr(isl+1,999);
46  }else if( ii == 1 ){
47  theEntryNameSecond = wl[ii*2].substr(isl+1,999);
48  }
49 
50  }
51 
52 }
53 
54 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
55 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
56 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
58 {
59 
60  if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this ); // important for Examples/FakeMeas
61 
62  //---------- Loop list of OptO that take part in measurement
63  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
64  if( ALIUtils::debug >= 5) std::cout << "OptOList size" <<OptOList().size() << std::endl;
65 
66  //----- Check that there are only two objects
67  if( OptOList().size() == !2 ) {
68  std::cerr << "!!! ERROR in MeasurementDiffEntry: " << name() << " There should only be two objects " << std::endl;
69  std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite+1)->name() << std::endl;
72  }
73 
74 #ifdef COCOA_VIS
75  ALIVisLightPath* vispath = 0;
76  if( ALIUtils::getFirstTime() ) {
78  if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
79  vispath = IgCocoaFileMgr::getInstance().newLightPath( name() );
80  }
81  }
82 #endif
83 
84  //--- This is a special 'measurement': it represents the fact that you have measured two entries one relative to the other (e.g. relative angle of two objects)
85  Entry* entry1 = Model::getEntryByName( (*(OptOList().begin()))->longName(), theEntryNameFirst );
86  Entry* entry2 = Model::getEntryByName( (*(OptOList().begin()+1))->longName(), theEntryNameSecond );
87  if( ALIUtils::debug >= 5) std::cout << " entry1 " << (*(OptOList().begin()))->longName() << "/" << entry1->name() << " ->valueDisplaced() " << entry1->valueDisplaced() << " entry2 " << (*(OptOList().begin()+1))->longName() << "/" << entry2->name() << " ->valueDisplaced() " << entry2->valueDisplaced() << std::endl;
88  setValueSimulated( 0, entry1->valueDisplaced() - entry2->valueDisplaced() );
89 
90  if (ALIUtils::debug >= 2) {
91  ALIdouble detD = 1000*valueSimulated(0); if(std::abs(detD) <= 1.e-9 ) detD = 0.;
92  std::cout << "REAL value: " <<"D: " << 1000.*value()[0] << " (mm) " << (this)->name()
93  << " DIFF= " << detD-1000*value()[0] << std::endl;
94  std::cout << "SIMU value: " << "D: " << detD << " (mm) " << (this)->name() << std::endl;
95  }
96 
97  if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl;
98 
99 }
100 
size
Write out results.
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:23
Definition: Entry.h:18
virtual void buildOptONamesList(const std::vector< ALIstring > &wl)
static ALIint debug
Definition: ALIUtils.h:36
static ALIstring & SDFName()
the name of the System Description File
Definition: Model.h:86
static GlobalOptionMgr * getInstance()
static Entry * getEntryByName(const ALIstring &opto_name, const ALIstring &entry_name)
--— Search an Entry name in the Entry* list and return a pointer to it
Definition: Model.cc:633
void AddOptONameListItem(ALIstring optos)
Definition: Measurement.h:184
void DumpBadOrderOptOs()
Definition: Measurement.cc:488
bool ALIbool
Definition: CocoaGlobals.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setValueSimulated(ALIint coor, ALIdouble value)
Definition: Measurement.h:196
ii
Definition: cuy.py:588
const ALIstring & name() const
Definition: Entry.h:52
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:109
void ErrorInLine()
Definition: ALIFileIn.cc:204
static ALIbool getFirstTime()
Definition: ALIUtils.h:101
const ALIdouble * value() const
Definition: Measurement.h:125
#define begin
Definition: vmac.h:30
std::string ALIstring
Definition: CocoaGlobals.h:9
void printStartCalculateSimulatedValue(const Measurement *meas)
Definition: Measurement.cc:445
const ALIstring & name() const
Definition: Measurement.h:90
const ALIdouble valueSimulated(ALIuint ii) const
Definition: Measurement.h:117
virtual void calculateSimulatedValue(ALIbool firstTime)
virtual ALIdouble valueDisplaced() const
Definition: Entry.cc:342
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()