CMS 3D CMS Logo

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 () override
 
ALIdoubleconvertPointToLocalCoordinates (const CLHEP::Hep3Vector &point)
 
void defaultBehaviour (LightRay &lightray, Measurement &meas) override
 
void fastTraversesLightRay (LightRay &lightray) override
 
void makeMeasurement (LightRay &lightray, Measurement &meas) override
 
 OptOCOPS ()
 
 OptOCOPS (OpticalObject *parent, const ALIstring &type, const ALIstring &name, const ALIbool copy_data)
 
 ~OptOCOPS () override
 
- 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=nullptr)
 
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 (const std::vector< Entry * > &entries) const
 
CocoaMaterialElementarygetMaterial () const
 
ALIPlane getPlate (const ALIbool forwardPlate, const ALIbool applyWedge)
 
std::vector< double > getRotationAnglesFromMatrix (CLHEP::HepRotation &rmLocal, const std::vector< Entry * > &entries) const
 
std::vector< double > getRotationAnglesInOptOFrame (const OpticalObject *optoAncestor, const 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(false){ };
type
Definition: HCALResponse.h:21
ALIbool fdevi_from_file
Definition: OptOCOPS.h:50
const ALIstring & name() const
Definition: OpticalObject.h:60
OptOCOPS::~OptOCOPS ( )
inlineoverride

Member Function Documentation

void OptOCOPS::constructSolidShape ( )
overridevirtual

Reimplemented from OpticalObject.

Definition at line 502 of file OptOCOPS.cc.

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

Referenced by ~OptOCOPS().

503 {
504  ALIdouble go;
506  gomgr->getGlobalOptionValue("VisScale", go );
507 
508  theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*1.*cm/m ); //COCOA internal units are meters
509 }
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 365 of file OptOCOPS.cc.

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

Referenced by ~OptOCOPS().

366 {
367  if(ALIUtils::debug >= 1) std::cout << "***** OptOCOPS::convertPointToLocalCoordinates" <<std::endl;
368  ALIdouble* interslc = new ALIdouble[2];
369 
370  //----- X value
371  CLHEP::HepRotation rmt = rmGlob();
372  CLHEP::Hep3Vector XAxism(1.,0.,0.);
373  XAxism*=rmt;
374  if( ALIUtils::debug >= 5) ALIUtils::dump3v( (this)->centreGlob(), "centre glob sensor2D" );
375  if( ALIUtils::debug >= 5) ALIUtils::dumprm( rmt, "rotation matrix sensor2D" );
376  //t ALIUtils::dump3v(point - (this)->centreGlob() , "inters - (this)->centreGlob()");
377  //t ALIUtils::dump3v(XAxism , "XAxism");
378  interslc[0] = (point - (this)->centreGlob() ) * XAxism;
379 
380  //----- Y value
381  CLHEP::Hep3Vector YAxism(0.,1.,0.);
382  YAxism*=rmt;
383  //t ALIUtils::dump3v(YAxism , "YAxism");
384  interslc[1] = (point - (this)->centreGlob() ) * YAxism;
385 
386  if( ALIUtils::debug >=5 ) {
387  std::cout << " intersection in local coordinates: X= " << interslc[0] << " Y= " << interslc[1] << std::endl;
388  }
389  return interslc;
390 }
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:36
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
*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 
)
overridevirtual

Reimplemented from OpticalObject.

Definition at line 33 of file OptOCOPS.cc.

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

Referenced by ~OptOCOPS().

34 {
35  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::defaultBehaviour" <<std::endl;
36  makeMeasurement( lightray, meas);
37 }
void makeMeasurement(LightRay &lightray, Measurement &meas) override
Definition: OptOCOPS.cc:43
static ALIint debug
Definition: ALIUtils.h:36
void OptOCOPS::fastTraversesLightRay ( LightRay lightray)
overridevirtual

Reimplemented from OpticalObject.

Definition at line 343 of file OptOCOPS.cc.

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

Referenced by ~OptOCOPS().

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

Definition at line 394 of file OptOCOPS.cc.

References funct::abs(), gather_cfg::cout, ALIUtils::debug, OpticalObject::fillIguana(), OpticalObject::fillVRML(), ALILine::intersect(), ALILine::pt(), EnergyCorrector::pt, Validation_hcalonly_cfi::sign, and ALILine::vec().

Referenced by ~OptOCOPS().

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

Reimplemented from OpticalObject.

Definition at line 43 of file OptOCOPS.cc.

References funct::abs(), MessageLogger_cfi::cerr, gather_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), MillePedeFileConverter_cfg::e, cmsRelvalreport::exit, OpticalObject::findExtraEntryValueIfExists(), cuy::ii, LightRay::intersect(), edm::isNotFinite(), dataset::name, Measurement::OptOList(), PI, LightRay::point(), RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, ALIPlane::project(), OpticalObject::rmGlob(), Measurement::setValueSimulated(), Measurement::setXlaserLine(), Measurement::value(), Measurement::valueSimulated(), and Measurement::xlaserLine().

Referenced by ~OptOCOPS().

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