Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:04

0001 //   COCOA class implementation file
0002 //Id:  OptOUserDefined.cc
0003 //CAT: Model
0004 //
0005 //   History: v1.0
0006 //   Pedro Arce
0007 
0008 #include "Alignment/CocoaModel/interface/OptOUserDefined.h"
0009 #include "Alignment/CocoaModel/interface/LightRay.h"
0010 #include "Alignment/CocoaModel/interface/ALIPlane.h"
0011 #include "Alignment/CocoaModel/interface/Measurement.h"
0012 #include <iostream>
0013 #include <iomanip>
0014 #include <cstdlib>
0015 #ifdef COCOA_VIS
0016 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
0017 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
0018 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
0019 #endif
0020 
0021 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
0022 //@@  Default behaviour: make measurement
0023 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
0024 void OptOUserDefined::userDefinedBehaviour(LightRay& lightray, Measurement& meas, const ALIstring& behav) {
0025 #ifdef COCOA_VIS
0026   ALIVisLightPath* vispath = 0;
0027   if (ALIUtils::getFirstTime()) {
0028     GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0029     if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0030       vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
0031     }
0032   }
0033 #endif
0034 
0035   if (ALIUtils::debug >= 5)
0036     ALIUtils::dump3v(centreGlob(), " user Defined centre ");
0037   //---- Object is not a basic one
0038   if (ExtraEntryList().empty()) {
0039     std::cerr << "OpticalObject: !!! EXITING at Measurement: " << meas.name() << " in OptO: " << name()
0040               << " behaviour ':" << behav << "' is not adequate " << std::endl;
0041     std::cerr << "an OptO has to indicate if detailed simulation traverses (:T) or deviates (:D) or Fast Simulation "
0042                  "traverses (:FT) or deviates  (:FD) or default behaviour () "
0043               << std::endl;
0044     exit(4);
0045   } else {
0046     ALIint behavSize = behav.size();
0047     //     if( !(nSet[0]).isNumber() ) nSet = "";
0048     ALIstring nSet;
0049     if (behavSize != 2 || behav[0] != 'D') {  //|| !behav[1]).isNumber() )
0050       std::cerr << "OpticalObject: !!! EXITING at Measurement: " << meas.name() << " in OptO: " << name()
0051                 << " behaviour ':" << behav << "' is not adequate " << std::endl;
0052       std::cerr << "an OptO has to indicate detailed simulation by (:Dn) where n is an integer number " << std::endl;
0053       exit(4);
0054     } else {
0055       nSet = behav.substr(behavSize - 1, behavSize);
0056     }
0057     //-    std::cout << behavSize << " nSet " << nSet << std::endl;
0058     ALIdouble shiftZ = findExtraEntryValue("shiftZ" + nSet);
0059     ALIdouble shiftX = findExtraEntryValue("shiftX" + nSet);
0060     ALIdouble shiftY = findExtraEntryValue("shiftY" + nSet);
0061     ALIdouble deviX = findExtraEntryValue("deviX" + nSet);
0062     ALIdouble deviY = findExtraEntryValue("deviY" + nSet);
0063     ALIdouble deviZ = findExtraEntryValue("deviZ" + nSet);
0064     CLHEP::Hep3Vector shift3D(shiftX, shiftY, shiftZ);
0065     CLHEP::HepRotation rmt = rmGlob();
0066     shift3D = rmt * shift3D;
0067     if (ALIUtils::debug >= 5) {
0068       lightray.dumpData("OptOUserDefined: lightray incoming");
0069       ALIUtils::dump3v(shift3D, " shift 3D ");
0070       //-std::cout << " shift " << shiftX << " shiftY " << shiftY << " shiftZ " << shiftZ
0071       //-    << " deviX " << deviX << " deviY " << deviY << std::endl;
0072     }
0073 
0074     ALIPlane plate = getPlate(false, false);
0075     lightray.intersect(plate);
0076 
0077 #ifdef COCOA_VIS
0078     //--- draw a point at intersection
0079     GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0080     if (ALIUtils::getFirstTime()) {
0081       if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
0082         ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
0083         if (ALIUtils::debug >= 5)
0084           std::cout << "ALIVRMLMgr addLightPoint " << lightray.point() << name() << std::endl;
0085       }
0086       if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0087         vispath->addLightPoint(lightray.point(), this);
0088       }
0089     }
0090 #endif
0091 
0092     lightray.setPoint(lightray.point() + shift3D);
0093     if (ALIUtils::debug >= 5) {
0094       lightray.dumpData("OptOUserDefined: lightray after shift");
0095     }
0096     CLHEP::Hep3Vector direc = lightray.direction();
0097     CLHEP::Hep3Vector XAxis(1., 0., 0.);
0098     XAxis = rmt * XAxis;
0099     direc.rotate(deviX, XAxis);
0100     if (ALIUtils::debug >= 5) {
0101       std::cout << "Direction after deviX " << direc << std::endl;
0102       std::cout << " deviX " << deviX << std::endl;
0103     }
0104     CLHEP::Hep3Vector YAxis(0., 1., 0.);
0105     YAxis = rmt * YAxis;
0106     direc.rotate(deviY, YAxis);
0107     lightray.setDirection(direc);
0108     if (ALIUtils::debug >= 5) {
0109       std::cout << "Direction after deviY " << direc << std::endl;
0110       std::cout << " deviY " << deviY << std::endl;
0111     }
0112     CLHEP::Hep3Vector ZAxis(0., 0., 1.);
0113     ZAxis = rmt * ZAxis;
0114     direc.rotate(deviZ, ZAxis);
0115     lightray.setDirection(direc);
0116     if (ALIUtils::debug >= 5) {
0117       std::cout << "Direction after deviZ " << direc << std::endl;
0118       std::cout << " deviZ " << deviZ << std::endl;
0119     }
0120     if (ALIUtils::debug >= 4) {
0121       lightray.dumpData("OptOUserDefined: lightray at exiting");
0122     }
0123   }
0124 
0125 #ifdef COCOA_VIS
0126   //--- draw a point at exiting
0127   if (ALIUtils::getFirstTime()) {
0128     GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0129     if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
0130       ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
0131       if (ALIUtils::debug >= 5)
0132         std::cout << "ALIVRMLMg  addLightPoint " << lightray.point() << name() << std::endl;
0133     }
0134     if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
0135       vispath->addLightPoint(lightray.point(), this);
0136     }
0137   }
0138 #endif
0139 }
0140 
0141 #ifdef COCOA_VIS
0142 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
0143 void OptOUserDefined::fillVRML() {
0144   /*  ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
0145   ALIColour* col = new ALIColour( 1., 0.7, 0.8, 0. );
0146   vrmlmgr.AddBox( *this, 100, 100, 0.1, col);
0147   vrmlmgr.SendReferenceFrame( *this, 0.1);
0148   vrmlmgr.SendName( *this, 0.01 );
0149   */
0150 }
0151 
0152 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
0153 void OptOUserDefined::fillIguana() {
0154   ALIColour* col = new ALIColour(0., 0., 0., 0.);
0155   std::vector<ALIdouble> spar;
0156   spar.push_back(1.);
0157   spar.push_back(1.);
0158   spar.push_back(1.);
0159   IgCocoaFileMgr::getInstance().addSolid(*this, "BOX", spar, col);
0160 }
0161 #endif