CMS 3D CMS Logo

Public Member Functions

OptOMirror Class Reference

#include <OptOMirror.h>

Inheritance diagram for OptOMirror:
OpticalObject

List of all members.

Public Member Functions

void constructSolidShape ()
void defaultBehaviour (LightRay &lightray, Measurement &meas)
virtual void detailedDeviatesLightRay (LightRay &lightray)
virtual void detailedTraversesLightRay (LightRay &lightray)
virtual void fastDeviatesLightRay (LightRay &lightray)
virtual void fastTraversesLightRay (LightRay &lightray)
 OptOMirror (OpticalObject *parent, const ALIstring &type, const ALIstring &name, const ALIbool copy_data)
 OptOMirror ()
 ~OptOMirror ()

Detailed Description

Definition at line 18 of file OptOMirror.h.


Constructor & Destructor Documentation

OptOMirror::OptOMirror ( ) [inline]

Definition at line 23 of file OptOMirror.h.

{ };
OptOMirror::OptOMirror ( OpticalObject parent,
const ALIstring type,
const ALIstring name,
const ALIbool  copy_data 
) [inline]

Definition at line 24 of file OptOMirror.h.

                                                                                                           : 
  OpticalObject( parent, type, name, copy_data){ };
OptOMirror::~OptOMirror ( ) [inline]

Definition at line 26 of file OptOMirror.h.

{ };

Member Function Documentation

void OptOMirror::constructSolidShape ( ) [virtual]

Reimplemented from OpticalObject.

Definition at line 213 of file OptOMirror.cc.

References GlobalOptionMgr::getGlobalOptionValue(), GlobalOptionMgr::getInstance(), and m.

{
  ALIdouble go;
  GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
  gomgr->getGlobalOptionValue("VisScale", go );

  theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*1.*cm/m ); //COCOA internal units are meters
}
void OptOMirror::defaultBehaviour ( LightRay lightray,
Measurement meas 
) [virtual]

Reimplemented from OpticalObject.

Definition at line 24 of file OptOMirror.cc.

{
  detailedDeviatesLightRay( lightray );
}
void OptOMirror::detailedDeviatesLightRay ( LightRay lightray) [virtual]

Reimplemented from OpticalObject.

Definition at line 33 of file OptOMirror.cc.

References ALI_DBL_MAX, gather_cfg::cout, ALIUtils::debug, LightRay::direction(), ALIUtils::dump3v(), LightRay::dumpData(), LightRay::intersect(), mag(), mergeVDriftHistosByStation::name, LightRay::point(), LightRay::setDirection(), and tablePrinter::width.

{
  if (ALIUtils::debug >= 2) std::cout << "LR: DETAILED REFLECTION IN MIRROR " << name() << std::endl;
  if (ALIUtils::debug >= 3) ALIUtils::dump3v( centreGlob(), " centre Global ");

  //---------- Get forward plate and intersect lightray with it
  ALIPlane plate = getPlate(1, 0);
  lightray.intersect( plate );
  CLHEP::Hep3Vector inters = lightray.point( );

  //---------- Get centre of forward plate
  //----- Get Z axis
  CLHEP::Hep3Vector ZAxis = getZAxis();
  CLHEP::HepRotation rmt = rmGlob();
  ZAxis = rmt * ZAxis;
  //----- Get centre
  ALIdouble width = findExtraEntryValue("width");
  CLHEP::Hep3Vector plate_centre = centreGlob() - 0.5 * width * ZAxis; 
  //-  if(ALIUtils::debug >= 4) std::cout << " mirror width " << width << std::endl;

  //---------- Get the distance between the intersection point and the centre of the forward plate
  ALIdouble distance = ( plate_centre - inters ).mag();

  //---------- Get normal to mirror at intersection point 
  //------- Get angle of mirror surface (angle between plate centre and intersection)
  ALIdouble flatness = findExtraEntryValue("flatness");
  //-- flatness is defined as number of 632 nm wavelengths
  flatness *= 632.E-9;
  ALIdouble length = 0.;

  ALIdouble curvature_radius;
  ALIdouble angFlatness;
  if( flatness != 0) {
    length = findExtraEntryValueMustExist("length");
    curvature_radius = (flatness*flatness + length*length) / (2*flatness);
    angFlatness = asin( distance / curvature_radius);
  } else {
    curvature_radius = ALI_DBL_MAX;
    angFlatness = 0;
  }

  if (ALIUtils::debug >= 3) {
    std::cout << " intersection with plate " << inters << std::endl;
    std::cout << " plate_centre " << plate_centre << std::endl;
    std::cout << " distance plate_centre - intersection " << distance << std::endl;
    std::cout << " flatness " << flatness << ", length " << length;
    std::cout << ", curvature radius " << curvature_radius << " angle of flatness " << angFlatness << std::endl;
  }

  //----- Axis of rotation is perpendicular to Z Axis and to line plate_centre - intersection
  CLHEP::Hep3Vector ipcV = inters - plate_centre;
  if( ipcV.mag() != 0) ipcV *= 1./ipcV.mag();
  CLHEP::HepRotation rtm = rmGlob();
  ipcV = rtm*ipcV;
  CLHEP::Hep3Vector rotationAxis = ipcV.cross(ZAxis);
  //----- normal is object normal rotated around this axis
  CLHEP::Hep3Vector inters_normal = CLHEP::Hep3Vector(0.,0.,1.);
  inters_normal.rotate( angFlatness, rotationAxis );  
  inters_normal = rmt * inters_normal;

  if (ALIUtils::debug >= 2) {
     ALIUtils::dump3v( ipcV, " intersection -  plate_centre std::vector ");
     std::cout << "rotation Axis " << rotationAxis << std::endl;
     std::cout << " plate normal at intersection point " << inters_normal << std::endl;
}
  //---------- Reflect in plate 
  ALIdouble cosang = -( inters_normal * lightray.direction() ) / 
           inters_normal.mag() / lightray.direction().mag();
  CLHEP::Hep3Vector lrold = lightray.direction();
  lightray.setDirection( lightray.direction() + inters_normal*2*cosang );

  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Reflected in mirror"); 
  }

}
void OptOMirror::detailedTraversesLightRay ( LightRay lightray) [virtual]

Reimplemented from OpticalObject.

Definition at line 138 of file OptOMirror.cc.

References gather_cfg::cout, ALIUtils::debug, LightRay::dumpData(), mergeVDriftHistosByStation::name, LightRay::refract(), and tablePrinter::width.

{
  if (ALIUtils::debug >= 2) std::cout << "LR: DETAILED TRAVERSE IN MIRROR " << name() << std::endl;

  //---------- Get forward plate
  ALIPlane plate = getPlate(1, 1);
  //---------- If width is 0, just keep the same point 
  ALIdouble width = findExtraEntryValue("width");
  if( width == 0 ) {
    if(ALIUtils::debug >= 3) lightray.dumpData("Traversed with 0 width"); 
    return;
  }

  //---------- Refract while entering mirror
  ALIdouble refra_ind1 = 1.;
  ALIdouble refra_ind2 = findExtraEntryValue("refra_ind");
  lightray.refract( plate, refra_ind1, refra_ind2 );
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Refracted in first plate"); 
  }

  //---------- Get backward plate
  plate = getPlate(0, 1);
  //---------- Refract while exiting mirror
  lightray.refract( plate, refra_ind2, refra_ind1 );
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Refracted in first plate"); 
  }

}
void OptOMirror::fastDeviatesLightRay ( LightRay lightray) [virtual]

Reimplemented from OpticalObject.

Definition at line 114 of file OptOMirror.cc.

References gather_cfg::cout, ALIUtils::debug, LightRay::dumpData(), mergeVDriftHistosByStation::name, LightRay::reflect(), and LightRay::shiftAndDeviateWhileTraversing().

{
  if (ALIUtils::debug >= 2) std::cout << "LR: FAST REFLECTION IN MIRROR " << name() << std::endl;

  //---------- Get forward plate
  ALIPlane plate = getPlate(1, 0);

  //---------- Reflect in plate (including intersection with it)
  lightray.reflect( plate );
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Reflected in plate"); 
  }
  //---------- Deviate Lightray 
  //  ALIdouble deviX = findExtraEntryValue("deviX");
  // ALIdouble deviY = findExtraEntryValue("deviY");
  //  lightray.shiftAndDeviateWhileTraversing( this, 0., 0., 0., deviX, deviY, 0.);
  lightray.shiftAndDeviateWhileTraversing( this, 'R' );
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Deviated ");
  }

}
void OptOMirror::fastTraversesLightRay ( LightRay lightray) [virtual]

Reimplemented from OpticalObject.

Definition at line 171 of file OptOMirror.cc.

References gather_cfg::cout, ALIUtils::debug, LightRay::dumpData(), LightRay::intersect(), mergeVDriftHistosByStation::name, and LightRay::shiftAndDeviateWhileTraversing().

{
  if (ALIUtils::debug >= 2) std::cout << "LR: TRAVERSE MIRROR  " << name() << std::endl;
  
  //---------- Get backward plate
  ALIPlane plate = getPlate(0, 0);
  lightray.intersect( plate );
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Intersected with plate"); 
  }
  //---------- Shift and Deviate
  lightray.shiftAndDeviateWhileTraversing( this, 'T' );
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Shifted and Deviated");
  }

}