CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
OptOCOPS Class Reference

#include <OptOCOPS.h>

Inheritance diagram for OptOCOPS:
OpticalObject

Public Member Functions

void constructSolidShape ()
 
ALIdoubleconvertPointToLocalCoordinates (const CLHEP::Hep3Vector &point)
 
virtual void defaultBehaviour (LightRay &lightray, Measurement &meas)
 
virtual void fastTraversesLightRay (LightRay &lightray)
 
virtual void makeMeasurement (LightRay &lightray, Measurement &meas)
 
 OptOCOPS ()
 
 OptOCOPS (OpticalObject *parent, const ALIstring &type, const ALIstring &name, const ALIbool copy_data)
 
 ~OptOCOPS ()
 
- Public Member Functions inherited from OpticalObject
void addCoordinateEntryToList (Entry *entry)
 
void addExtraEntryToList (Entry *entry)
 
void addExtraEntryValueOriginalOriginalToList (ALIdouble entry_value)
 
void addExtraEntryValueOriginalToList (ALIdouble entry_value)
 
void addExtraEntryValueToList (ALIdouble entry_value)
 
double addPii (double val)
 
double approxTo0 (double val)
 
CLHEP::HepRotation buildRmFromEntryValuesOriginalOriginal ()
 
const CLHEP::Hep3Vector & centreGlob () const
 
const CLHEP::Hep3Vector & centreGlobal () const
 
const CLHEP::Hep3Vector & centreGlobOriginal () const
 
const CLHEP::Hep3Vector & centreGlobOriginalOriginal () const
 
const CLHEP::Hep3Vector centreLocal () const
 
int checkMatrixEquations (double angleX, double angleY, double angleZ, CLHEP::HepRotation *rot=0)
 
void construct ()
 
void constructFromOptAligInfo (const OpticalAlignInfo &oaInfo)
 
virtual void constructMaterial ()
 
const std::vector< Entry * > & CoordinateEntryList () const
 
void createComponentOptOsFromOptAlignInfo ()
 
virtual void detailedDeviatesLightRay (LightRay &lightray)
 
virtual void detailedTraversesLightRay (LightRay &lightray)
 
double diff2pi (double ang1, double ang2)
 
void displaceCentreGlob (const XYZcoor coor, const ALIdouble disp)
 
void displaceCentreGlob (const CLHEP::Hep3Vector &dispVec)
 
void displaceCentreGlobOriginal (const XYZcoor coor, const ALIdouble disp)
 
void displaceCentreGlobOriginal (const CLHEP::Hep3Vector &dispVec)
 
void displaceCentreGlobOriginalOriginal (const XYZcoor coor, const ALIdouble disp)
 
void displaceCentreGlobOriginalOriginal (const CLHEP::Hep3Vector &dispVec)
 
void displaceExtraEntry (const ALIuint entryNo, const ALIdouble disp)
 
void displaceExtraEntryOriginal (const ALIuint entryNo, const ALIdouble disp)
 
void displaceExtraEntryOriginalOriginal (const ALIuint entryNo, const ALIdouble disp)
 
void displaceRmGlobAroundGlobal (OpticalObject *opto1stRotated, const XYZcoor coor, const ALIdouble disp)
 
void displaceRmGlobAroundLocal (OpticalObject *opto1stRotated, const XYZcoor coor, const ALIdouble disp)
 
void displaceRmGlobOriginal (const OpticalObject *opto1stRotated, const XYZcoor coor, const ALIdouble disp)
 
void displaceRmGlobOriginalOriginal (const OpticalObject *opto1stRotated, const XYZcoor coor, const ALIdouble disp)
 
bool eq2ang (double ang1, double ang2)
 
const std::vector< Entry * > & ExtraEntryList () const
 
const ALIint extraEntryNo (const ALIstring &entry_name) const
 
std::vector< ALIdouble > & ExtraEntryValueList ()
 
const std::vector< ALIdouble > & ExtraEntryValueOriginalList ()
 
const std::vector< ALIdouble > & ExtraEntryValueOriginalOriginalList ()
 
virtual void fastDeviatesLightRay (LightRay &lightray)
 
virtual void fillIguana ()
 
virtual void fillVRML ()
 
const ALIdouble findExtraEntryValue (const ALIstring &eename) const
 
const ALIbool findExtraEntryValueIfExists (const ALIstring &eename, ALIdouble &value) const
 
const ALIdouble findExtraEntryValueMustExist (const ALIstring &eename) const
 
const ALIuint getCmsswID () const
 
std::vector< ALIstringgetCoordinateFromOptAlignParam (const OpticalAlignParam &oaParam)
 
CLHEP::Hep3Vector getDisplacementInLocalCoordinates (const XYZcoor coor, const ALIdouble disp)
 
const double getEntryCentre (const XYZcoor coor) const
 
const double getEntryCentre (const ALIstring &coor) const
 
const double getEntryRMangle (const XYZcoor coor) const
 
const double getEntryRMangle (const ALIstring &coor) const
 
std::vector< double > getLocalRotationAngles (std::vector< Entry * > entries) const
 
CocoaMaterialElementarygetMaterial () const
 
ALIPlane getPlate (const ALIbool forwardPlate, const ALIbool applyWedge)
 
std::vector< double > getRotationAnglesFromMatrix (CLHEP::HepRotation &rmLocal, std::vector< Entry * > entries) const
 
std::vector< double > getRotationAnglesInOptOFrame (const OpticalObject *optoAncestor, std::vector< Entry * > entries) const
 
CocoaSolidShapegetSolidShape () const
 
CLHEP::Hep3Vector getZAxis ()
 
const ALIuint ID () const
 
const ALIstring longName () const
 
Measurementmeas ()
 
const ALIstringname () const
 
 OpticalObject ()
 
 OpticalObject (OpticalObject *parent, const ALIstring &type, const ALIstring &name, const ALIbool copy_data)
 
const OpticalObjectparent () const
 
virtual void participateInMeasurement (LightRay &lightray, Measurement &meas, const ALIstring &behav)
 
void propagateGlobalRMOriginalOriginalChangeToChildren (const CLHEP::HepRotation &rmorioriold, const CLHEP::HepRotation &rmoriorinew)
 
void resetGlobalCoordinates ()
 
void resetOriginalOriginalCoordinates ()
 
const CLHEP::HepRotation & rmGlob () const
 
const CLHEP::HepRotation & rmGlobOriginal () const
 
const CLHEP::HepRotation & rmGlobOriginalOriginal () const
 
const CLHEP::HepRotation rmLocal () const
 
void setCmsswID (ALIuint id)
 
void setExtraEntryValue (const ALIuint entryNo, const ALIdouble disp)
 
void setGlobalCoordinates ()
 
void setGlobalRMOriginalOriginal (const CLHEP::HepRotation &rmoriori)
 
void setID (ALIuint id)
 
void setMeas (Measurement *meas)
 set current measurement More...
 
void setOriginalEntryValues ()
 
void setRmGlobal (const CLHEP::HepRotation &rm)
 
void setRmGlobalOriginal (const CLHEP::HepRotation &rm)
 
void setType (const ALIstring &type)
 
const ALIstring shortName () const
 
const ALIstringtype () const
 
virtual void userDefinedBehaviour (LightRay &lightray, Measurement &meas, const ALIstring &behav)
 
virtual ~OpticalObject ()
 

Private Member Functions

ALIdouble getMeasFromInters (ALILine &line_xhair, ALILine &ccd, CLHEP::Hep3Vector &cops_line)
 

Private Attributes

ALILine ccds [4]
 
DeviationsFromFileSensor2DdeviFromFile
 
ALIbool fdevi_from_file
 

Additional Inherited Members

- Protected Member Functions inherited from OpticalObject
virtual void fillExtraEntry (std::vector< ALIstring > &wordlist)
 
- Protected Attributes inherited from OpticalObject
CocoaMaterialElementarytheMaterial
 
CocoaSolidShapetheSolidShape
 
ALIint verbose
 

Detailed Description

Definition at line 20 of file OptOCOPS.h.

Constructor & Destructor Documentation

OptOCOPS::OptOCOPS ( )
inline

Definition at line 25 of file OptOCOPS.h.

25 { };
OptOCOPS::OptOCOPS ( OpticalObject parent,
const ALIstring type,
const ALIstring name,
const ALIbool  copy_data 
)
inline

Definition at line 26 of file OptOCOPS.h.

26  :
27  OpticalObject( parent, type, name, copy_data), fdevi_from_file(0){ };
type
Definition: HCALResponse.h:22
ALIbool fdevi_from_file
Definition: OptOCOPS.h:50
const ALIstring & name() const
Definition: OpticalObject.h:60
OptOCOPS::~OptOCOPS ( )
inline

Definition at line 28 of file OptOCOPS.h.

28 { };

Member Function Documentation

void OptOCOPS::constructSolidShape ( )
virtual

Reimplemented from OpticalObject.

Definition at line 501 of file OptOCOPS.cc.

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

502 {
503  ALIdouble go;
505  gomgr->getGlobalOptionValue("VisScale", go );
506 
507  theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*1.*cm/m ); //COCOA internal units are meters
508 }
long double ALIdouble
Definition: CocoaGlobals.h:11
CocoaSolidShape * theSolidShape
static GlobalOptionMgr * getInstance()
int getGlobalOptionValue(const ALIstring &sstr, ALIdouble &val)
--— Search a string in theGlobalOptions and return 1 if found
ALIdouble * OptOCOPS::convertPointToLocalCoordinates ( const CLHEP::Hep3Vector &  point)

Definition at line 364 of file OptOCOPS.cc.

References gather_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), and ALIUtils::dumprm().

365 {
366  if(ALIUtils::debug >= 1) std::cout << "***** OptOCOPS::convertPointToLocalCoordinates" <<std::endl;
367  ALIdouble* interslc = new ALIdouble[2];
368 
369  //----- X value
370  CLHEP::HepRotation rmt = rmGlob();
371  CLHEP::Hep3Vector XAxism(1.,0.,0.);
372  XAxism*=rmt;
373  if( ALIUtils::debug >= 5) ALIUtils::dump3v( (this)->centreGlob(), "centre glob sensor2D" );
374  if( ALIUtils::debug >= 5) ALIUtils::dumprm( rmt, "rotation matrix sensor2D" );
375  //t ALIUtils::dump3v(point - (this)->centreGlob() , "inters - (this)->centreGlob()");
376  //t ALIUtils::dump3v(XAxism , "XAxism");
377  interslc[0] = (point - (this)->centreGlob() ) * XAxism;
378 
379  //----- Y value
380  CLHEP::Hep3Vector YAxism(0.,1.,0.);
381  YAxism*=rmt;
382  //t ALIUtils::dump3v(YAxism , "YAxism");
383  interslc[1] = (point - (this)->centreGlob() ) * YAxism;
384 
385  if( ALIUtils::debug >=5 ) {
386  std::cout << " intersection in local coordinates: X= " << interslc[0] << " Y= " << interslc[1] << std::endl;
387  }
388  return interslc;
389 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
Definition: ALIUtils.cc:77
static ALIint debug
Definition: ALIUtils.h:35
const CLHEP::HepRotation & rmGlob() const
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:61
const CLHEP::Hep3Vector & centreGlob() const
Definition: OpticalObject.h:85
tuple cout
Definition: gather_cfg.py:121
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void OptOCOPS::defaultBehaviour ( LightRay lightray,
Measurement meas 
)
virtual

Reimplemented from OpticalObject.

Definition at line 32 of file OptOCOPS.cc.

References gather_cfg::cout, and ALIUtils::debug.

33 {
34  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::defaultBehaviour" <<std::endl;
35  makeMeasurement( lightray, meas);
36 }
virtual void makeMeasurement(LightRay &lightray, Measurement &meas)
Definition: OptOCOPS.cc:42
static ALIint debug
Definition: ALIUtils.h:35
tuple cout
Definition: gather_cfg.py:121
void OptOCOPS::fastTraversesLightRay ( LightRay lightray)
virtual

Reimplemented from OpticalObject.

Definition at line 342 of file OptOCOPS.cc.

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

343 {
344 
345  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::fastTraversesLightRay" <<std::endl;
346  if (ALIUtils::debug >= 2) std::cout << "LR: FAST TRAVERSES COPS " << name() << std::endl;
347 
348  //---------- Get intersection
349  CLHEP::Hep3Vector ZAxis(0.,0,1.);
350  CLHEP::HepRotation rmt = rmGlob();
351  ZAxis = rmt * ZAxis;
352  lightray.intersect( ALIPlane(centreGlob(), ZAxis) );
353  CLHEP::Hep3Vector inters = lightray.point();
354  lightray.setPoint( inters );
355 
356  if (ALIUtils::debug >= 2) {
357  lightray.dumpData(" after COPS ");
358  }
359 
360 }
static ALIint debug
Definition: ALIUtils.h:35
const CLHEP::HepRotation & rmGlob() const
void setPoint(const CLHEP::Hep3Vector &point)
Definition: LightRay.h:64
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:52
void intersect(const ALIPlane &plane)
Definition: LightRay.cc:100
const CLHEP::Hep3Vector & centreGlob() const
Definition: OpticalObject.h:85
void dumpData(const ALIstring &str) const
Definition: LightRay.cc:381
tuple cout
Definition: gather_cfg.py:121
const ALIstring & name() const
Definition: OpticalObject.h:60
ALIdouble OptOCOPS::getMeasFromInters ( ALILine line_xhair,
ALILine ccd,
CLHEP::Hep3Vector &  cops_line 
)
private

Definition at line 393 of file OptOCOPS.cc.

References gather_cfg::cout, ALIUtils::debug, ALILine::intersect(), ALILine::pt(), and ALILine::vec().

394 {
395 
396  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::getMeasFromInters" <<std::endl;
397  CLHEP::Hep3Vector inters = line_xhair.intersect( ccd, 0 ) - ccd.pt();
398  ALIdouble sign = inters*ccd.vec();
399  if( sign != 0 ){
400  sign = fabs(sign)/sign;
401  // std::cout << " @@@@@@@@@@@@ sign = " << sign << std::endl;
402  // ALIUtils::dump3v(inters, " intersection " );
403  // ALIUtils::dump3v( ccd.vec(), " cops_line ");
404  } //sign can be zero only if inters is 0, because they are parallel
405  return sign*inters.mag();
406 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:35
const CLHEP::Hep3Vector & pt() const
Definition: ALILine.h:27
CLHEP::Hep3Vector intersect(const ALILine &l2, bool notParallel=0)
Definition: ALILine.cc:29
tuple cout
Definition: gather_cfg.py:121
const CLHEP::Hep3Vector & vec() const
Definition: ALILine.h:28
void OptOCOPS::makeMeasurement ( LightRay lightray,
Measurement meas 
)
virtual

Reimplemented from OpticalObject.

Definition at line 42 of file OptOCOPS.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), alignCSCRings::e, cmsRelvalreport::exit, OpticalObject::findExtraEntryValueIfExists(), LightRay::intersect(), edm::detail::isnan(), mergeVDriftHistosByStation::name, Measurement::OptOList(), PI, LightRay::point(), ALIPlane::project(), OpticalObject::rmGlob(), Measurement::setValueSimulated(), Measurement::setXlaserLine(), Measurement::value(), Measurement::valueSimulated(), and Measurement::xlaserLine().

43 {
44 
45  if (ALIUtils::debug >= 4) std::cout << "***** OptOCOPS::makeMeasurement(lightray, meas) " << std::endl;
46  //---------- Centre of COPS is at dowel point 2
47  CLHEP::Hep3Vector dowel2 = centreGlob();
48  //---------- Coordinates of dowel point 1 are given with respect to dowel point 2 (in local reference frame)
49  ALIdouble posx12 = findExtraEntryValue("dowel1X");
50 // Changed default value to .045 from .03
51  if(posx12 == 0. ) posx12 = -0.045; //samir changed sign to correct the dowel 1st pixel
52  CLHEP::Hep3Vector dowel1(posx12,findExtraEntryValue("dowel1Y"), 0.);
53  CLHEP::HepRotation rmt = rmGlob();
54  dowel1 = rmt*dowel1;
55  dowel1 += dowel2;
56  if (ALIUtils::debug >= 3) {
57  ALIUtils::dump3v(dowel2, " dowel2");
58  ALIUtils::dump3v(dowel1, " dowel1");
59  }
60 
61  //---------- Get line joining dowel1-dowel2 and perpendicular to it inside cops
62 // CLHEP::Hep3Vector line_dowel21 = - (dowel1-dowel2 ); //////
63  CLHEP::Hep3Vector line_dowel21 = (dowel1-dowel2 ); // samir changed sign to correct the dowel 1st pixel
64  CLHEP::Hep3Vector ZAxis(0.,0,1.);
65  ZAxis = rmt * ZAxis;
66  CLHEP::Hep3Vector line_dowel21_perp = ZAxis.cross( line_dowel21 );
67  if (ALIUtils::debug >= 3) {
68  ALIUtils::dump3v(line_dowel21," line_dowel21");
69  ALIUtils::dump3v(line_dowel21_perp," line_dowel21_perp");
70  }
71 
72  //---------- Position four CCDs (locally, i.e. with respect to centre)
73  //----- Get first CCD length, that will be used to give a default placement to the CCDs
74  ALIdouble CCDlength = findExtraEntryValue("CCDlength");
75  if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6; // (in meters, the default unit)
76 
77 
78 
79  // global / local output of ccd location in RF was reversed, I am swapping
80 
81 
82  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
83  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** UP CCD *****" << std::endl
84  << "******************" << std::endl << std::endl;
85  ALIdouble posX = findExtraEntryValue("upCCDXtoDowel2");
86  ALIdouble posY;
87  ALIbool eexists = findExtraEntryValueIfExists("upCCDYtoDowel2", posY);
88  if(!eexists) posY = CCDlength + 0.004;
89  //if(!eexists) posY = 0.004;
90  CLHEP::Hep3Vector posxy( posX, posY, 0);
91  if(ALIUtils::debug>= 3) std::cout << " %%%% CCD distances to Dowel2: " << std::endl;
92  if(ALIUtils::debug>= 3) std::cout << " up ccd in local RF " << posxy << std::endl;
93  posxy = rmt * posxy;
94  if(ALIUtils::debug>= 3) std::cout << " up ccd in global RF " << posxy << std::endl;
95  // ALILine upCCD( dowel2 + posxy, -line_dowel21 );
96  // ccds[0] = ALILine( posxy, -line_dowel21 );
97  ALILine upCCD( dowel2 + posxy, line_dowel21 );// Samir changed sign to correct the dowel 1st pixel
98  ccds[0] = ALILine( posxy, line_dowel21 ); // samir changed sign to correct the dowel 1st pixel
99  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
100  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** DOWN CCD *****" << std::endl
101  << "********************" << std::endl << std::endl ;
102  posX = findExtraEntryValue("downCCDXtoDowel2");
103  eexists = findExtraEntryValueIfExists("downCCDYtoDowel2", posY);
104  if(!eexists) posY = 0.002;
105  posxy = CLHEP::Hep3Vector( posX, posY, 0);
106  if(ALIUtils::debug>= 3) std::cout << " down ccd in local RF " << posxy << std::endl;
107  posxy = rmt * posxy;
108  if(ALIUtils::debug>= 3) std::cout << " down ccd in global RF " << posxy << std::endl;
109 // ALILine downCCD( dowel2 + posxy, -line_dowel21 );
110  // ccds[1] = ALILine( posxy, -line_dowel21 );
111 
112 ALILine downCCD( dowel2 + posxy, line_dowel21 );//samir changed signto correct the dowel 1st pixel
113  ccds[1] = ALILine( posxy, line_dowel21 ); // samir changed sign to correct the dowel 1st pixel
114 
115  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
116 
117  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** LEFT CCD *****" << std::endl
118  << "********************" << std::endl << std::endl;
119  eexists = findExtraEntryValueIfExists("leftCCDXtoDowel2", posX);
120 // if(!eexists) posX = -0.002;
121  if(!eexists) posX = -CCDlength - 0.002; // Samir changed sign to correct the dowel 1st pixel
122  posY = findExtraEntryValue("leftCCDYtoDowel2");
123  posxy = CLHEP::Hep3Vector( posX, posY, 0);
124  if(ALIUtils::debug>= 3) std::cout << " left ccd in local RF " << posxy << std::endl;
125  posxy = rmt * posxy;
126  if(ALIUtils::debug>= 3) std::cout << " left ccd in global RF " << posxy << std::endl;
127  // ALILine leftCCD( dowel2 + posxy, line_dowel21_perp );
128  // ccds[2] = ALILine( posxy, line_dowel21_perp );
129 
130  ALILine leftCCD( dowel2 + posxy, -line_dowel21_perp );//samir changed sign to correct the dowel 1st pixel
131  ccds[2] = ALILine( posxy, -line_dowel21_perp );//samir changed sign to correct the dowel 1st pixel
132 
133  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
134  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** RIGHT CCD *****" << std::endl
135  << "*********************" << std::endl<< std::endl ;
136  eexists = findExtraEntryValueIfExists("rightCCDXtoDowel2", posX);
137  // if(!eexists) posX = -CCDlength - 0.004;
138  if(!eexists) posX = - 0.004; // samir tried to change in order to adjust the position of 1 st pixel.
139  posY = findExtraEntryValue("rightCCDYtoDowel2");
140  posxy = CLHEP::Hep3Vector( posX, posY, 0);
141  if(ALIUtils::debug>= 3) std::cout << " right ccd in local RF " << posxy << std::endl;
142  posxy = rmt * posxy;
143  if(ALIUtils::debug>= 3) std::cout << " right ccd in global RF " << posxy << std::endl << std::endl;
144  // ALILine rightCCD( dowel2 + posxy, line_dowel21_perp );
145  // ccds[3] = ALILine( posxy, line_dowel21_perp );
146 
147 ALILine rightCCD( dowel2 + posxy, -line_dowel21_perp ); //samir changed sign to correct the dowel 1st pixel
148  ccds[3] = ALILine( posxy, -line_dowel21_perp ); //samir changed sign to correct the dowel 1st pixel
149 
150  if (ALIUtils::debug >= 3) {
151  std::cout << " %%% Positions of CCDs in global RF: " << std::endl<< std::endl;
152  std::cout << " upCCD: " << upCCD << std::endl;
153  std::cout << " downCCD: " << downCCD << std::endl;
154  std::cout << " leftCCD: " << leftCCD << std::endl;
155  std::cout << " rightCCD: " << rightCCD << std::endl << std::endl;
156  }
157 
158  //---------- Intersect x-hair laser with COPS
159  if (ALIUtils::debug >= 3) std::cout << " %%% Intersecting x-hair laser with COPS: " << std::endl;
160  ALIPlane copsPlane(centreGlob(), ZAxis);
161  lightray.intersect( *this );
162  CLHEP::Hep3Vector inters = lightray.point();
163  if (ALIUtils::debug >= 3) {
164  ALIUtils::dump3v(inters, " Intersection of x-hair laser with COPS ");
165  }
166 
167  //---------- Get cross of x-hair laser:
168  if (ALIUtils::debug >= 5) std::cout << "1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
169 
170  OpticalObject* xhairOptO = *(meas.OptOList().begin());
171 
172  if (ALIUtils::debug >= 35) std::cout << "2. Get the Y of the laser and project it on the COPS" << std::endl;
173  CLHEP::Hep3Vector YAxis_xhair(0.,1.,0.);
174  CLHEP::HepRotation rmtx = xhairOptO->rmGlob();
175  YAxis_xhair = rmtx * YAxis_xhair;
176  ALILine Yline_xhair( inters, copsPlane.project( YAxis_xhair ));
177  if (ALIUtils::debug >= 3) {
178  std::cout << " %%%% Projecting x-hair laser on COPS: " << std::endl;
179  ALIUtils::dump3v(YAxis_xhair, " Y direction of laser ");
180  std::cout << " Y line of laser projected on COPS " << Yline_xhair << std::endl;
181  }
182 
183  if (ALIUtils::debug >= 5) std::cout << " 3. Get the X of the laser (correct it if cross is not 90o) and project it on the COPS" << std::endl;
184 
185  ALIdouble anglebx;
186  eexists = xhairOptO->findExtraEntryValueIfExists("angleBetweenAxis", anglebx);
187  if(!eexists) anglebx = PI/2.;
188  CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
189 
190  // if (ALIUtils::debug >= 3) ALIUtils::dump3v(XAxis_xhair," X of laser1 ");
191  ZAxis = CLHEP::Hep3Vector(0.,0.,1.);
192  ZAxis = rmtx * ZAxis;
193  XAxis_xhair.rotate(anglebx, ZAxis );
194  ALILine Xline_xhair( inters, copsPlane.project( XAxis_xhair ) );
195  if (ALIUtils::debug >= 3) {
196  std::cout << "angleBetweenAxis = " << anglebx << std::endl;
197  ALIUtils::dump3v(XAxis_xhair," X direction of laser ");
198  std::cout << " X line of laser projected on COPS " << Xline_xhair << std::endl;
199  }
200 
201 
202  //---------- Get measurement as intersection with four CCDs
203  if(ALIUtils::debug >= 3) std::cout << " Getting measurements as intersection with four CCDs: " << std::endl;
204 
205  if(ALIUtils::debug >= 4)std::cout << "intersecting with upCCD " << std::endl;
206  ALIdouble measv[4][2];
207 
208 // swap Y and X line_xhair by exchanging second index
209 
210  if(ALIUtils::debug >= 5)std::cout << "$@S@ measv[0][0] upccd " << std::endl;
211  measv[0][0] = getMeasFromInters( Yline_xhair, upCCD, line_dowel21 );
212  if(ALIUtils::debug >= 5)std::cout << "$@$@ measv[0][1] upccd " << std::endl;
213  measv[0][1] = getMeasFromInters( Xline_xhair, upCCD, line_dowel21 );
214 
215  //---- check if postive or negative:
216  if(ALIUtils::debug >= 4) std::cout << "intersecting with downCCD " << std::endl;
217  measv[1][0] = getMeasFromInters(Yline_xhair, downCCD, line_dowel21 );
218  measv[1][1] = getMeasFromInters(Xline_xhair, downCCD, line_dowel21 );
219 
220 //
221 
222  if(ALIUtils::debug >= 4) std::cout << "intersecting with leftCCD " << std::endl;
223  measv[2][0] = getMeasFromInters(Xline_xhair, leftCCD, line_dowel21_perp );
224  measv[2][1] = getMeasFromInters(Yline_xhair, leftCCD, line_dowel21_perp );
225  if(ALIUtils::debug >= 4) std::cout << "intersecting with rightCCD " << std::endl;
226  measv[3][0] = getMeasFromInters(Xline_xhair, rightCCD, line_dowel21_perp );
227  measv[3][1] = getMeasFromInters(Yline_xhair, rightCCD, line_dowel21_perp );
228 
229  /* Both X and Y axis of the x-laser are intersected with each CCD and it checks that one of
230  the two is inside the CCD(less than CCDlength/2). If no one is inside, it will give an
231  exception. If both are inside (a strange case where, for example, the laser centre is very
232  close and forms 45 degrees with the CCD) it will also make an exception (if you prefer, I can
233  put a warning saying that you have two measurements, but I guess this should never happen for
234  you, so I better give an exception and you don't risk to overpass this warning).
235 
236  Then it is mandatory that you put the CCDlength parameter (I could put a default one if
237  you prefer).
238 
239 
240  ALIbool measInCCD[2];
241  ALIuint ii,jj;
242  for( ii = 0; ii < 4; ii++ ) {
243  for( jj = 0; jj < 2; jj++ ) {
244  measInCCD[jj] = fabs( measv[ii][jj] ) < CCDlength/2;
245  }
246  if (ALIUtils::debug >= 2) std::cout << "$@$@ CHECK CCD = " << ii << std::endl;
247  if( measInCCD[0] && measInCCD[1] ){
248  std::cerr << "!!!EXITING: both lasers lines of x-hair laser intersect with same CCD " << measNames[ii] << " one at " << measv[ii][0] << " another one at " << measv[ii][1] << "CCDhalfLegth " << CCDlength/2 << std::endl;
249  exit(1);
250  } else if( !(measInCCD[0] || measInCCD[1]) ){
251  std::cerr << "!!!EXITING: none of the lasers lines of x-hair laser intersect with CCD " << measNames[ii] << ", one at " << measv[ii][0] << " another one at " << measv[ii][1] << "CCDhalfLegth " << CCDlength/2 << std::endl;
252  exit(1);
253  } else {
254  measInCCD[0] ? meas.setValueSimulated( ii, measv[ii][0] ) :
255  meas.setValueSimulated( ii, measv[ii][1] );
256  }
257  }
258  */
259 
260  ALIstring measNames[4] ={"up","down","left","right"};
261  ALIbool laserLine;
262  if (ALIUtils::debug >= 2) std::cout << std::endl << "--> Now comparing measurement in ccds by x and y laser lines (will always choose the smaller one) " <<std::endl;
263 
264  unsigned int ii;
265  for( ii = 0; ii < 4; ii++ ) {
266  if (ALIUtils::debug >= 2) std::cout << "\tmeas CCD " << measNames[ii] << " ii=(" << ii << ") \t Values: "
267  //<< (fabs( measv[ii][0] ) < fabs( measv[ii][1])
268  << " " << fabs( measv[ii][0] ) << " " << fabs( measv[ii][1] ) << " isnan() = " <<
269  std::isnan(measv[ii][1]) << std::endl;
270 
271  if( meas.xlaserLine( ii ) != -1 ) {
272  laserLine = ALIbool( meas.xlaserLine( ii ) );
273  } else {
274 
275  // Problem here !!!
276  //
277  // Somehow measv[][1] can occasionally return value of 'nan'
278  // which is interpretted as less than any real value
279  //
280  if(std::isnan(measv[ii][1]) != 0){
281  measv[ii][1] = 1e99;
282  if (ALIUtils::debug >= 2) std::cout << " --> Swapping for " << measv[ii][1] << "(inf)" << std::endl;
283  }
284 
285  laserLine = fabs( measv[ii][0] ) < fabs( measv[ii][1] );
286 
287  meas.setXlaserLine( ii, int(laserLine) );
288  }
289  laserLine ? meas.setValueSimulated( ii, measv[ii][0] )
290  : meas.setValueSimulated( ii, measv[ii][1] );
291  }
292 
293  if (ALIUtils::debug >= 2) std::cout << std::endl; //Keep format of debug output reasonable
294 
295  // try to identify pathological cases: up and down CCD are intersected by the same
296  // laser line (say X) and the same for the left and right CCD
297 
298  if(ALIUtils::debug >= 2) std::cout << "***** OptOCOPS::makeMeasurement - identify pathological cases U and D intersected by same line" <<std::endl;
299  ALIbool xlaserDir[4];
300  for( ii = 0; ii < 4; ii++ ) {
301  // xlaserDir[ii] = fabs( measv[ii][0] ) < fabs( measv[ii][1] );
302  xlaserDir[ii] = ALIbool( meas.xlaserLine( ii ) );
303  }
304  if( xlaserDir[0] ^ xlaserDir[1] ) {
305  std::cerr << "!!EXITING up and down CCDs intersected by different x-laser line " << xlaserDir[0] << " " << xlaserDir[1] << std::endl;
306  exit(1);
307  }
308  if( xlaserDir[2] ^ xlaserDir[3] ) {
309  std::cerr << "!!EXITING right and left CCDs intersected by different x-laser line " << xlaserDir[0] << " " << xlaserDir[1] << std::endl;
310  exit(1);
311  }
312 
313  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::makeMeasurement - now output sim values" << std::endl;
314 
315  if (ALIUtils::debug >= 1) {
316  ALIstring chrg = "";
317  std::cout << "REAL value: " << chrg <<"U: " << 1000*meas.value()[0] << chrg
318  << " D: " << 1000*meas.value()[1]
319  << " L: " << 1000*meas.value()[2]
320  << " R: " << 1000*meas.value()[3]
321  << " (mm) " << (this)->name() << std::endl;
322  ALIdouble detU = 1000*meas.valueSimulated(0); if(fabs(detU) <= 1.e-9 ) detU = 0.;
323  ALIdouble detD = 1000*meas.valueSimulated(1); if(fabs(detD) <= 1.e-9 ) detD = 0.;
324  ALIdouble detL = 1000*meas.valueSimulated(2); if(fabs(detL) <= 1.e-9 ) detL = 0.;
325  ALIdouble detR = 1000*meas.valueSimulated(3); if(fabs(detR) <= 1.e-9 ) detR = 0.;
326  std::cout << "SIMU value: " << chrg << "U: "
327  // << setprecision(3) << setw(4)
328  << detU
329  << chrg << " D: " << detD
330  << chrg << " L: " << detL
331  << chrg << " R: " << detR
332  << " (mm) " << (this)->name() << std::endl;
333  }
334 
335 
336 }
long double ALIdouble
Definition: CocoaGlobals.h:11
#define PI
std::vector< OpticalObject * > & OptOList()
Definition: Measurement.h:109
const ALIbool findExtraEntryValueIfExists(const ALIstring &eename, ALIdouble &value) const
static ALIint debug
Definition: ALIUtils.h:35
const CLHEP::HepRotation & rmGlob() const
bool ALIbool
Definition: CocoaGlobals.h:19
bool isnan(float x)
Definition: math.h:13
virtual void setXlaserLine(ALIuint ii, int val)
Definition: Measurement.h:209
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:52
ALILine ccds[4]
Definition: OptOCOPS.h:51
void setValueSimulated(ALIint coor, ALIdouble value)
Definition: Measurement.h:196
virtual int xlaserLine(ALIuint ii)
Definition: Measurement.h:199
const ALIdouble findExtraEntryValue(const ALIstring &eename) const
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:61
void intersect(const ALIPlane &plane)
Definition: LightRay.cc:100
const CLHEP::Hep3Vector & centreGlob() const
Definition: OpticalObject.h:85
const ALIdouble * value() const
Definition: Measurement.h:125
std::string ALIstring
Definition: CocoaGlobals.h:9
const ALIdouble valueSimulated(ALIuint ii) const
Definition: Measurement.h:117
ALIdouble getMeasFromInters(ALILine &line_xhair, ALILine &ccd, CLHEP::Hep3Vector &cops_line)
Definition: OptOCOPS.cc:393
tuple cout
Definition: gather_cfg.py:121
const ALIstring & name() const
Definition: OpticalObject.h:60

Member Data Documentation

ALILine OptOCOPS::ccds[4]
private

Definition at line 51 of file OptOCOPS.h.

DeviationsFromFileSensor2D* OptOCOPS::deviFromFile
private

Definition at line 49 of file OptOCOPS.h.

ALIbool OptOCOPS::fdevi_from_file
private

Definition at line 50 of file OptOCOPS.h.