CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Alignment/CocoaModel/src/OptOUserDefined.cc

Go to the documentation of this file.
00001 //   COCOA class implementation file
00002 //Id:  OptOUserDefined.cc
00003 //CAT: Model
00004 //
00005 //   History: v1.0 
00006 //   Pedro Arce
00007 
00008 #include "Alignment/CocoaModel/interface/OptOUserDefined.h"
00009 #include "Alignment/CocoaModel/interface/LightRay.h"
00010 #include "Alignment/CocoaModel/interface/ALIPlane.h" 
00011 #include "Alignment/CocoaModel/interface/Measurement.h"
00012 #include <iostream>
00013 #include <iomanip>
00014 #include <cstdlib>
00015 #ifdef COCOA_VIS
00016 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
00017 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
00018 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
00019 #endif
00020 
00021 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00022 //@@  Default behaviour: make measurement
00023 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00024 void OptOUserDefined::userDefinedBehaviour( LightRay& lightray, Measurement& meas, ALIstring& behav ) 
00025 {
00026 #ifdef COCOA_VIS
00027   ALIVisLightPath* vispath = 0;
00028   if( ALIUtils::getFirstTime() ) {
00029     GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00030     if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
00031       vispath = IgCocoaFileMgr::getInstance().newLightPath( name() );
00032     } 
00033   }
00034 #endif
00035 
00036   if(ALIUtils::debug >= 5)ALIUtils::dump3v( centreGlob(), " user Defined centre " ); 
00037   //---- Object is not a basic one
00038   if(ExtraEntryList().size() == 0) {
00039     std::cerr << "OpticalObject: !!! EXITING at Measurement: " << meas.name() << " in OptO: "  << name() << " behaviour ':" << behav << "' is not adequate " << std::endl;
00040     std::cerr <<  "an OptO has to indicate if detailed simulation traverses (:T) or deviates (:D) or Fast Simulation traverses (:FT) or deviates  (:FD) or default behaviour () "<< std::endl;
00041     exit(4);
00042   } else {
00043     ALIint behavSize = behav.size();
00044     //     if( !(nSet[0]).isNumber() ) nSet = "";
00045     ALIstring nSet;
00046     if( behavSize != 2 || behav[0] != 'D' ){  //|| !behav[1]).isNumber() )
00047       std::cerr << "OpticalObject: !!! EXITING at Measurement: " << meas.name() << " in OptO: "  << name() << " behaviour ':" << behav << "' is not adequate " << std::endl;
00048       std::cerr <<  "an OptO has to indicate detailed simulation by (:Dn) where n is an integer number " << std::endl;
00049       exit(4);      
00050     } else {
00051       nSet = behav.substr( behavSize-1, behavSize);
00052     }
00053     //-    std::cout << behavSize << " nSet " << nSet << std::endl;
00054     ALIdouble shiftZ = findExtraEntryValue("shiftZ"+nSet);
00055     ALIdouble shiftX = findExtraEntryValue("shiftX"+nSet);
00056     ALIdouble shiftY = findExtraEntryValue("shiftY"+nSet);
00057     ALIdouble deviX = findExtraEntryValue("deviX"+nSet);
00058     ALIdouble deviY = findExtraEntryValue("deviY"+nSet);
00059     ALIdouble deviZ = findExtraEntryValue("deviZ"+nSet);
00060     CLHEP::Hep3Vector shift3D( shiftX, shiftY, shiftZ ); 
00061     CLHEP::HepRotation rmt = rmGlob();
00062     shift3D = rmt*shift3D;
00063     if(ALIUtils::debug >= 5) {
00064       lightray.dumpData("OptOUserDefined: lightray incoming");
00065       ALIUtils::dump3v( shift3D, " shift 3D " );
00066                     //-std::cout << " shift " << shiftX << " shiftY " << shiftY << " shiftZ " << shiftZ
00067                     //-    << " deviX " << deviX << " deviY " << deviY << std::endl;
00068     }
00069 
00070     ALIPlane plate = getPlate(0, 0);
00071     lightray.intersect( plate );
00072 
00073 #ifdef COCOA_VIS
00074     //--- draw a point at intersection
00075     GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00076     if( ALIUtils::getFirstTime() ) {
00077       if(gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
00078         ALIVRMLMgr::getInstance().addLightPoint( lightray.point() );
00079         if(ALIUtils::debug>=5)std::cout << "ALIVRMLMgr addLightPoint " << lightray.point() << name() << std::endl;
00080       }
00081       if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
00082         vispath->addLightPoint( lightray.point(), this );
00083       }
00084     }
00085 #endif
00086 
00087     lightray.setPoint( lightray.point() + shift3D );
00088     if(ALIUtils::debug >= 5) {
00089       lightray.dumpData("OptOUserDefined: lightray after shift");
00090     }
00091     CLHEP::Hep3Vector direc = lightray.direction();
00092     CLHEP::Hep3Vector XAxis(1.,0.,0.);
00093     XAxis = rmt*XAxis;
00094     direc.rotate(deviX, XAxis);
00095     if(ALIUtils::debug >= 5) {
00096       std::cout << "Direction after deviX " << direc << std::endl;
00097       std::cout << " deviX " << deviX << std::endl; 
00098     }
00099     CLHEP::Hep3Vector YAxis(0.,1.,0.);
00100     YAxis = rmt*YAxis;
00101     direc.rotate(deviY, YAxis);
00102     lightray.setDirection( direc ); 
00103     if(ALIUtils::debug >= 5) {
00104       std::cout << "Direction after deviY " << direc << std::endl;
00105       std::cout << " deviY " << deviY << std::endl;
00106     }
00107     CLHEP::Hep3Vector ZAxis(0.,0.,1.);
00108     ZAxis = rmt*ZAxis;
00109     direc.rotate(deviZ, ZAxis);
00110     lightray.setDirection( direc ); 
00111     if(ALIUtils::debug >= 5) {
00112       std::cout << "Direction after deviZ " << direc << std::endl;
00113       std::cout << " deviZ " << deviZ << std::endl;
00114     }
00115     if(ALIUtils::debug >= 4) {
00116       lightray.dumpData("OptOUserDefined: lightray at exiting");
00117     }
00118   }
00119 
00120 #ifdef COCOA_VIS
00121   //--- draw a point at exiting
00122   if( ALIUtils::getFirstTime() ) {
00123     GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00124     if(gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
00125       ALIVRMLMgr::getInstance().addLightPoint( lightray.point() );
00126       if(ALIUtils::debug>=5)std::cout << "ALIVRMLMg  addLightPoint " << lightray.point() << name() << std::endl;
00127     }
00128     if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
00129       vispath->addLightPoint( lightray.point(), this );
00130     }
00131   }
00132 #endif
00133     
00134 }
00135 
00136 #ifdef COCOA_VIS
00137 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00138 void OptOUserDefined::fillVRML()
00139 {
00140   /*  ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
00141   ALIColour* col = new ALIColour( 1., 0.7, 0.8, 0. );
00142   vrmlmgr.AddBox( *this, 100, 100, 0.1, col);
00143   vrmlmgr.SendReferenceFrame( *this, 0.1); 
00144   vrmlmgr.SendName( *this, 0.01 );
00145   */
00146 }
00147 
00148 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00149 void OptOUserDefined::fillIguana()
00150 {
00151   ALIColour* col = new ALIColour( 0., 0., 0., 0. );
00152   std::vector<ALIdouble> spar;
00153   spar.push_back(1.);
00154   spar.push_back(1.);
00155   spar.push_back(1.);
00156   IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar, col);
00157 }
00158 #endif
00159