CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:23:40 2009 for CMSSW by  doxygen 1.5.4