00001
00002
00003
00004
00005
00006
00007
00008 #include "Alignment/CocoaModel/interface/EntryAngleAffAngles.h"
00009 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00010 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00011
00012
00013 EntryAngleAffAngles::EntryAngleAffAngles( const ALIstring& type )
00014 : EntryAngle( type )
00015 {
00016 }
00017
00018
00019
00020 void EntryAngleAffAngles::FillName( const ALIstring& name )
00021 {
00022 ALIstring nn = "Angles ";
00023 nn += name;
00024 setName( nn );
00025 }
00026
00027
00028
00029
00030
00031 void EntryAngleAffAngles::displace( ALIdouble disp )
00032 {
00033 XYZcoor coor = XCoor;
00034 ALIint namelength = name().length()-1;
00035
00036 if ( name_[namelength] == 'X' ) {
00037 coor = XCoor;
00038 } else if ( name_[namelength] == 'Y' ) {
00039 coor = YCoor;
00040 } else if ( name_[namelength] == 'Z' ) {
00041 coor = ZCoor;
00042 }
00043
00044 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00045 if(gomgr->GlobalOptions()["rotateAroundLocal"] == 0) {
00046 OptOCurrent()->displaceRmGlobAroundGlobal( OptOCurrent(), coor, disp );
00047 }else {
00048 OptOCurrent()->displaceRmGlobAroundLocal( OptOCurrent(), coor, disp );
00049 }
00050
00051 }
00052
00053
00054
00055 void EntryAngleAffAngles::displaceOriginal( ALIdouble disp )
00056 {
00057 ALIint namelength = name().length()-1;
00058
00059 if ( name_[namelength] == 'X' ) {
00060
00061 OptOCurrent()->displaceRmGlobOriginal( OptOCurrent(), XCoor, disp );
00062 } else if ( name_[namelength] == 'Y' ) {
00063
00064 OptOCurrent()->displaceRmGlobOriginal( OptOCurrent(), YCoor, disp );
00065 } else if ( name_[namelength] == 'Z' ) {
00066 OptOCurrent()->displaceRmGlobOriginal( OptOCurrent(), ZCoor, disp );
00067 }
00068
00069 }
00070
00071
00072 void EntryAngleAffAngles::displaceOriginalOriginal( ALIdouble disp )
00073 {
00074 ALIint namelength = name().length()-1;
00075 if(ALIUtils::debug >= 5) std::cout << this << "ENtryAnglesAffAngle displaceOriginalOriginal" << name_ <<std::endl;
00076 if ( name_[namelength] == 'X' ) {
00077
00078 OptOCurrent()->displaceRmGlobOriginalOriginal( OptOCurrent(), XCoor, disp );
00079 } else if ( name_[namelength] == 'Y' ) {
00080
00081 OptOCurrent()->displaceRmGlobOriginalOriginal( OptOCurrent(), YCoor, disp );
00082 } else if ( name_[namelength] == 'Z' ) {
00083 OptOCurrent()->displaceRmGlobOriginalOriginal( OptOCurrent(), ZCoor, disp );
00084 }
00085
00086 }
00087
00088
00089
00090
00091 ALIdouble EntryAngleAffAngles::valueDisplaced() const
00092 {
00093
00094
00095
00096 if(ALIUtils::debug >= 5) {
00097 std::cout << " EntryAngleAffAngles::valueDisplaced() parent opto " << OptOCurrent()->parent()->name() << std::endl;
00098 ALIUtils::dumprm( OptOCurrent()->rmGlob() , " RmGlob ");
00099 ALIUtils::dumprm( OptOCurrent()->rmGlobOriginal() , " RmGlobOriginal ");
00100 ALIUtils::dumprm( OptOCurrent()->parent()->rmGlobOriginal() , " parent RmGlobOriginal ");
00101 }
00102
00103 CLHEP::HepRotation diffRm = OptOCurrent()->rmGlob() * OptOCurrent()->rmGlobOriginal().inverse();
00104 CLHEP::HepRotation rmLocal = diffRm * OptOCurrent()->parent()->rmGlobOriginal().inverse();
00105 std::vector<double> localrot = OptOCurrent()->getRotationAnglesFromMatrix( rmLocal, OptOCurrent()->CoordinateEntryList() );
00106 if(ALIUtils::debug >= 5) {
00107 ALIUtils::dumprm( diffRm , " diffRm ");
00108 ALIUtils::dumprm( rmLocal , " rmLocal ");
00109 std::cout << " localrot " << localrot[0] << " " << localrot[1] << " " << localrot[2] << std::endl;
00110 }
00111
00112 if( name() == "angles_X" ) {
00113 return localrot[0];
00114 }else if( name() == "angles_Y" ) {
00115 return localrot[1];
00116 }else if( name() == "angles_Z" ) {
00117 return localrot[2];
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 }
00149
00150
00151
00152 ALIdouble EntryAngleAffAngles::checkDiff( Hep3Vector axis, Hep3Vector axisOrig, std::vector<double> localrot, std::vector<double> localrotorig ) const
00153 {
00154 int inam = 0;
00155 if( name() == "angles_X" ) {
00156 inam = 1;
00157 }else if( name() == "angles_Y" ) {
00158 inam = 2;
00159 }else if( name() == "angles_Z" ) {
00160 inam = 3;
00161 }
00162 switch( inam ){
00163 case 1:
00164 axis.rotateX( localrot[0] );
00165 axisOrig.rotateX( localrotorig[0] );
00166 case 2:
00167 axis.rotateY( localrot[1] );
00168 axisOrig.rotateY( localrotorig[1] );
00169 case 3:
00170 axis.rotateZ( localrot[2] );
00171 axisOrig.rotateZ( localrotorig[2] );
00172 break;
00173 }
00174
00175 ALIdouble ang = axis.angle( axisOrig );
00176
00177
00178
00179
00180
00181
00182
00183 return ang;
00184 }
00185
00186