CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

OptOOpticalSquare Class Reference

#include <OptOOpticalSquare.h>

Inheritance diagram for OptOOpticalSquare:
OpticalObject

List of all members.

Public Member Functions

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

Private Member Functions

void calculateFaces (ALIbool isDetailed)

Private Attributes

CLHEP::Hep3Vector faceP [5]
CLHEP::Hep3Vector faceV [5]

Detailed Description

Definition at line 18 of file OptOOpticalSquare.h.


Constructor & Destructor Documentation

OptOOpticalSquare::OptOOpticalSquare ( ) [inline]

Definition at line 23 of file OptOOpticalSquare.h.

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

Definition at line 24 of file OptOOpticalSquare.h.

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

Definition at line 26 of file OptOOpticalSquare.h.

{ };

Member Function Documentation

void OptOOpticalSquare::calculateFaces ( ALIbool  isDetailed) [private]

Definition at line 154 of file OptOOpticalSquare.cc.

References funct::cos(), gather_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), and funct::sin().

{

  ALIint numberOfFaces = 5;

  //----- useful variables
  CLHEP::Hep3Vector opto_centre = centreGlob();
  if(ALIUtils::debug >= 3) std::cout << "opto_centre " << opto_centre << std::endl;
  const ALIdouble hlen1 = findExtraEntryValueMustExist("length1") / 2.;
  const ALIdouble hlen2 = findExtraEntryValueMustExist("length2") / 2.;
  ALIdouble ang = 67.5*acos(0.)/90.;

  //-  if( ALIUtils::debug >= 3) std::cout << "length 1 " << 2*hlen1 << " length 2 " << hlen2 * 2 << std::endl;
  faceP[0] = CLHEP::Hep3Vector( 0, 0 , -hlen1 );
  faceV[0] = CLHEP::Hep3Vector( 0, 0, -1 );
  faceP[1] = CLHEP::Hep3Vector( 0, hlen1 - hlen2*sin(ang), hlen1 + hlen2*cos(ang) );
  faceV[1] = CLHEP::Hep3Vector( 0, cos(ang), sin(ang) );

  faceP[2] = CLHEP::Hep3Vector( 0, -hlen1 - hlen2*cos(ang), -hlen1 + hlen2*sin(ang) );
  faceV[2] = CLHEP::Hep3Vector( 0, -sin(ang), -cos(ang) );
  faceP[3] = CLHEP::Hep3Vector( 0, hlen1, 0 );
  faceV[3] = CLHEP::Hep3Vector( 0, 1, 0 );

  // face of added piece (so that light when traversing finds parallel surfaces at entry and exit)
  faceP[4] = CLHEP::Hep3Vector( 0, 0, hlen1 + 2*hlen2*cos(ang) );
  faceV[4] = CLHEP::Hep3Vector( 0, 0, 1 );

  //--------- Put faces in global reference frame
  CLHEP::HepRotation rmt = rmGlob();
  ALIint ii;
  if (ALIUtils::debug >= 3) { 
    std::cout << " optical_square centre" << opto_centre << std::endl;
  }
  for( ii = 0; ii < numberOfFaces; ii++ ) {
    faceP[ii] = rmt * faceP[ii];
    faceP[ii] += opto_centre;
    faceV[ii] = rmt * faceV[ii];
    if (ALIUtils::debug >= 3) { 
      std::cout << "point at face " << ii << ": " << faceP[ii] << std::endl;
      std::cout << "normal at face " << ii << ": " << faceV[ii] << std::endl;
    }
  }

  //----------- Correct faces 1 & 2 by wedge: rotate each face normal 1/2 of the wedge around two axis perpendicular to normal 
  if( isDetailed ) {
    ALIdouble wedge, wedgeX, wedgeY;
    const ALIbool wxy = findExtraEntryValueIfExists("wedge", wedge);
    if( !wxy ) {
      wedgeX = findExtraEntryValue("wedgeX");
      wedgeY = findExtraEntryValue("wedgeY");
    } else {
      wedgeX = wedge;
      wedgeY = wedge;
    }

    //----- One axis is along X axis for the two faces (X belong to both faces)
    if(ALIUtils::debug >= 4) std::cout << "OptOOpticalSquare calculateFaces: wedgeX  " << wedgeX << " wedgeY  " << wedgeY << std::endl;
    CLHEP::Hep3Vector Axis1(1.,0.,0.);
    Axis1 = rmt * Axis1; 
    if( ALIUtils::debug >= 4) {
      ALIUtils::dump3v(faceV[1], "faceV[1] before wedge"); 
      ALIUtils::dump3v(faceV[2], "faceV[2] before wedge"); 
    }
    faceV[1].rotate(0.5* wedgeX, Axis1);
    if( ALIUtils::debug >= 4) ALIUtils::dump3v( Axis1, " Axis1 in faceV[1] ");
    faceV[2].rotate(-0.5* wedgeX, Axis1);
    if( ALIUtils::debug >= 4) {
      ALIUtils::dump3v( Axis1, " Axis1 in faceV[2] ");
      ALIUtils::dump3v(faceV[1], "faceV[1] after wedge X"); 
      ALIUtils::dump3v(faceV[2], "faceV[2] after wedge X"); 
    }

    //----- Other axis perpendicular to first and to normal of each face
    CLHEP::Hep3Vector Axis2 = Axis1;
    Axis2 = Axis2.cross( faceV[1] );
    faceV[1].rotate(0.5* wedgeY, Axis2);
    if( ALIUtils::debug >= 4) ALIUtils::dump3v( Axis2, " Axis2 in faceV[1] ");
    Axis2 = Axis1;
    Axis2 = Axis2.cross( faceV[2] );
    faceV[2].rotate(-0.5* wedgeY, Axis2);
    if( ALIUtils::debug >= 4) {
      ALIUtils::dump3v( Axis2, " Axis2 in faceV[2] ");
      ALIUtils::dump3v(faceV[1], "faceV[1] after wedge Y"); 
      ALIUtils::dump3v(faceV[2], "faceV[2] after wedge Y"); 
    }
    
  }

}
void OptOOpticalSquare::constructSolidShape ( ) [virtual]

Reimplemented from OpticalObject.

Definition at line 266 of file OptOOpticalSquare.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*5.*cm/m ); //COCOA internal units are meters
}
void OptOOpticalSquare::detailedDeviatesLightRay ( LightRay lightray) [virtual]

Reimplemented from OpticalObject.

Definition at line 28 of file OptOOpticalSquare.cc.

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

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

  calculateFaces( 1 );

  //---------- Deviate in prism
  //---------- Refract after entering face 0, reflect in face 1, reflect in face 2, refract after face 3
  const ALIdouble refra_ind = findExtraEntryValueMustExist("refra_ind");
  const ALIdouble refra_ind0 = 1.; 

  ALIint ii;
  for( ii = 0; ii < 4; ii++ ) {
    if(ii == 0) { 
      if( ALIUtils::debug >= 3 ) std::cout << "## OPTOOPTICALSQUARE: refract in face " << ii << std::endl;
      lightray.refract( ALIPlane(faceP[ii],faceV[ii]), refra_ind0, refra_ind );
    } else if( ii == 3) { 
    //---- interchange refraction index for exiting instead of entering
      lightray.refract( ALIPlane(faceP[ii],faceV[ii]), refra_ind, refra_ind0 );
    } else { 
      lightray.reflect( ALIPlane(faceP[ii],faceV[ii] ));
    }  
    if (ALIUtils::debug >= 3) { 
      lightray.dumpData( "After face ");
    } 
  }

  //----- checks that it is inside prism and the order of faces hit is the good one
  //   

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

Reimplemented from OpticalObject.

Definition at line 65 of file OptOOpticalSquare.cc.

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

{
  if (ALIUtils::debug >= 2) std::cout << "LR: DETAILED TRAVERSES OPTICAL SQUARE " << name() << std::endl;

  calculateFaces( 1 );
  const ALIdouble refra_ind = findExtraEntryValueMustExist("refra_ind");
  const ALIdouble refra_ind0 = 1.; 

  lightray.refract( ALIPlane(faceP[0],faceV[0]), refra_ind0, refra_ind );
  lightray.refract( ALIPlane(faceP[4],faceV[4]), refra_ind, refra_ind0 );

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

Reimplemented from OpticalObject.

Definition at line 84 of file OptOOpticalSquare.cc.

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

{
  if (ALIUtils::debug >= 2) std::cout << "LR: FAST DEVIATION IN OPTICAL SQUARE " << name() << std::endl;
  
  calculateFaces( 0 );
  
  //---------- Deviate in prism
  lightray.reflect( ALIPlane(faceP[1],faceV[1] ));
  if (ALIUtils::debug >= 3) { 
    lightray.dumpData( "After face 1");
  } 
  lightray.reflect( ALIPlane(faceP[2],faceV[2] ));
  if (ALIUtils::debug >= 3) { 
    lightray.dumpData( "After face 2");
  } 
  lightray.intersect( ALIPlane(faceP[3],faceV[3] ));
  if (ALIUtils::debug >= 3) { 
    lightray.dumpData( "intersected at face 3");
  }

  //----- Deviates by 'devi' X & Y??
  lightray.shiftAndDeviateWhileTraversing( this, 'R');
  /*  ALIdouble deviRX = findExtraEntryValue("deviRX");
  ALIdouble deviRY = findExtraEntryValue("deviRY");
  ALIdouble shiftRX = findExtraEntryValue("shiftRX");
  ALIdouble shiftRY = findExtraEntryValue("shiftRY");
  lightray.shiftAndDeviateWhileTraversing( this, shiftRX, shiftRY, deviRX, deviRY);
  */

  if (ALIUtils::debug >= 2) {
    //  std::cout << " shiftRX " << shiftRX << " shiftRY " << shiftRY << std::endl;
    // std::cout << " deviRX " << deviRX << " deviRY " << deviRY << std::endl;
    lightray.dumpData("Deviated ");
  }


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

Reimplemented from OpticalObject.

Definition at line 129 of file OptOOpticalSquare.cc.

References ALIUtils::debug, LightRay::dumpData(), LightRay::intersect(), and LightRay::shiftAndDeviateWhileTraversing().

{
  //  std::cerr << " WARNING  there should be an extra piece to make entering and exiting surfaces parallel (like in modified_rhomboid_prism) " << std::endl;

  calculateFaces( 0 );

  lightray.intersect( ALIPlane(faceP[1],faceV[1] ));
  //---------- Shift and Deviate
  lightray.shiftAndDeviateWhileTraversing( this, 'T');
  /*  ALIdouble shiftX = findExtraEntryValue("shiftTX");
  ALIdouble shiftY = findExtraEntryValue("shiftTY");
  ALIdouble deviTX = findExtraEntryValue("deviTX");
  ALIdouble deviTY = findExtraEntryValue("deviTY");
  lightray.shiftAndDeviateWhileTraversing( this, shiftX, shiftY, deviTX, deviTY);
  */
  if (ALIUtils::debug >= 2) {
    lightray.dumpData("Shifted and Deviated");
  }
}

Member Data Documentation

CLHEP::Hep3Vector OptOOpticalSquare::faceP[5] [private]

Definition at line 47 of file OptOOpticalSquare.h.

CLHEP::Hep3Vector OptOOpticalSquare::faceV[5] [private]

Definition at line 48 of file OptOOpticalSquare.h.