CMS 3D CMS Logo

OptOUserDefined.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 //Id: OptOUserDefined.cc
3 //CAT: Model
4 //
5 // History: v1.0
6 // Pedro Arce
7 
12 #include <iostream>
13 #include <iomanip>
14 #include <cstdlib>
15 #ifdef COCOA_VIS
16 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
17 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
18 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
19 #endif
20 
21 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
22 //@@ Default behaviour: make measurement
23 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
25 #ifdef COCOA_VIS
26  ALIVisLightPath* vispath = 0;
27  if (ALIUtils::getFirstTime()) {
29  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
30  vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
31  }
32  }
33 #endif
34 
35  if (ALIUtils::debug >= 5)
36  ALIUtils::dump3v(centreGlob(), " user Defined centre ");
37  //---- Object is not a basic one
38  if (ExtraEntryList().empty()) {
39  std::cerr << "OpticalObject: !!! EXITING at Measurement: " << meas.name() << " in OptO: " << name()
40  << " behaviour ':" << behav << "' is not adequate " << std::endl;
41  std::cerr << "an OptO has to indicate if detailed simulation traverses (:T) or deviates (:D) or Fast Simulation "
42  "traverses (:FT) or deviates (:FD) or default behaviour () "
43  << std::endl;
44  exit(4);
45  } else {
46  ALIint behavSize = behav.size();
47  // if( !(nSet[0]).isNumber() ) nSet = "";
48  ALIstring nSet;
49  if (behavSize != 2 || behav[0] != 'D') { //|| !behav[1]).isNumber() )
50  std::cerr << "OpticalObject: !!! EXITING at Measurement: " << meas.name() << " in OptO: " << name()
51  << " behaviour ':" << behav << "' is not adequate " << std::endl;
52  std::cerr << "an OptO has to indicate detailed simulation by (:Dn) where n is an integer number " << std::endl;
53  exit(4);
54  } else {
55  nSet = behav.substr(behavSize - 1, behavSize);
56  }
57  //- std::cout << behavSize << " nSet " << nSet << std::endl;
58  ALIdouble shiftZ = findExtraEntryValue("shiftZ" + nSet);
59  ALIdouble shiftX = findExtraEntryValue("shiftX" + nSet);
60  ALIdouble shiftY = findExtraEntryValue("shiftY" + nSet);
61  ALIdouble deviX = findExtraEntryValue("deviX" + nSet);
62  ALIdouble deviY = findExtraEntryValue("deviY" + nSet);
63  ALIdouble deviZ = findExtraEntryValue("deviZ" + nSet);
64  CLHEP::Hep3Vector shift3D(shiftX, shiftY, shiftZ);
65  CLHEP::HepRotation rmt = rmGlob();
66  shift3D = rmt * shift3D;
67  if (ALIUtils::debug >= 5) {
68  lightray.dumpData("OptOUserDefined: lightray incoming");
69  ALIUtils::dump3v(shift3D, " shift 3D ");
70  //-std::cout << " shift " << shiftX << " shiftY " << shiftY << " shiftZ " << shiftZ
71  //- << " deviX " << deviX << " deviY " << deviY << std::endl;
72  }
73 
74  ALIPlane plate = getPlate(false, false);
75  lightray.intersect(plate);
76 
77 #ifdef COCOA_VIS
78  //--- draw a point at intersection
80  if (ALIUtils::getFirstTime()) {
81  if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
82  ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
83  if (ALIUtils::debug >= 5)
84  std::cout << "ALIVRMLMgr addLightPoint " << lightray.point() << name() << std::endl;
85  }
86  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
87  vispath->addLightPoint(lightray.point(), this);
88  }
89  }
90 #endif
91 
92  lightray.setPoint(lightray.point() + shift3D);
93  if (ALIUtils::debug >= 5) {
94  lightray.dumpData("OptOUserDefined: lightray after shift");
95  }
96  CLHEP::Hep3Vector direc = lightray.direction();
97  CLHEP::Hep3Vector XAxis(1., 0., 0.);
98  XAxis = rmt * XAxis;
99  direc.rotate(deviX, XAxis);
100  if (ALIUtils::debug >= 5) {
101  std::cout << "Direction after deviX " << direc << std::endl;
102  std::cout << " deviX " << deviX << std::endl;
103  }
104  CLHEP::Hep3Vector YAxis(0., 1., 0.);
105  YAxis = rmt * YAxis;
106  direc.rotate(deviY, YAxis);
107  lightray.setDirection(direc);
108  if (ALIUtils::debug >= 5) {
109  std::cout << "Direction after deviY " << direc << std::endl;
110  std::cout << " deviY " << deviY << std::endl;
111  }
112  CLHEP::Hep3Vector ZAxis(0., 0., 1.);
113  ZAxis = rmt * ZAxis;
114  direc.rotate(deviZ, ZAxis);
115  lightray.setDirection(direc);
116  if (ALIUtils::debug >= 5) {
117  std::cout << "Direction after deviZ " << direc << std::endl;
118  std::cout << " deviZ " << deviZ << std::endl;
119  }
120  if (ALIUtils::debug >= 4) {
121  lightray.dumpData("OptOUserDefined: lightray at exiting");
122  }
123  }
124 
125 #ifdef COCOA_VIS
126  //--- draw a point at exiting
127  if (ALIUtils::getFirstTime()) {
129  if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
130  ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
131  if (ALIUtils::debug >= 5)
132  std::cout << "ALIVRMLMg addLightPoint " << lightray.point() << name() << std::endl;
133  }
134  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
135  vispath->addLightPoint(lightray.point(), this);
136  }
137  }
138 #endif
139 }
140 
141 #ifdef COCOA_VIS
142 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
144  /* ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
145  ALIColour* col = new ALIColour( 1., 0.7, 0.8, 0. );
146  vrmlmgr.AddBox( *this, 100, 100, 0.1, col);
147  vrmlmgr.SendReferenceFrame( *this, 0.1);
148  vrmlmgr.SendName( *this, 0.01 );
149  */
150 }
151 
152 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
154  ALIColour* col = new ALIColour(0., 0., 0., 0.);
155  std::vector<ALIdouble> spar;
156  spar.push_back(1.);
157  spar.push_back(1.);
158  spar.push_back(1.);
159  IgCocoaFileMgr::getInstance().addSolid(*this, "BOX", spar, col);
160 }
161 #endif
LightRay::dumpData
void dumpData(const ALIstring &str) const
Definition: LightRay.cc:374
OpticalObject::meas
Measurement * meas()
Definition: OpticalObject.h:200
OpticalObject::findExtraEntryValue
const ALIdouble findExtraEntryValue(const ALIstring &eename) const
Definition: OpticalObject.cc:1519
GlobalOptionMgr::GlobalOptions
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
Definition: GlobalOptionMgr.h:31
GlobalOptionMgr
Definition: GlobalOptionMgr.h:18
OpticalObject::name
const ALIstring & name() const
Definition: OpticalObject.h:58
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
cuy.col
col
Definition: cuy.py:1010
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
LightRay.h
OpticalObject::centreGlob
const CLHEP::Hep3Vector & centreGlob() const
Definition: OpticalObject.h:75
OpticalObject::rmGlob
const CLHEP::HepRotation & rmGlob() const
Definition: OpticalObject.h:83
LightRay::intersect
void intersect(const ALIPlane &plane)
Definition: LightRay.cc:93
LightRay::point
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:57
ALIUtils::getFirstTime
static ALIbool getFirstTime()
Definition: ALIUtils.h:87
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
Measurement
Definition: Measurement.h:27
ALIPlane.h
OpticalObject::fillIguana
virtual void fillIguana()
Definition: OpticalObject.h:55
Measurement.h
OpticalObject::ExtraEntryList
const std::vector< Entry * > & ExtraEntryList() const
Definition: OpticalObject.h:65
LightRay
Definition: LightRay.h:20
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
LightRay::setPoint
void setPoint(const CLHEP::Hep3Vector &point)
Definition: LightRay.h:63
ALIPlane
Definition: ALIPlane.h:15
LightRay::direction
const CLHEP::Hep3Vector & direction() const
Definition: LightRay.h:58
OptOUserDefined.h
LightRay::setDirection
void setDirection(const CLHEP::Hep3Vector &direc)
Definition: LightRay.h:62
ALIUtils::dump3v
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:58
Measurement::name
const ALIstring & name() const
Definition: Measurement.h:86
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
OpticalObject::fillVRML
virtual void fillVRML()
Definition: OpticalObject.h:54
ALIint
int ALIint
Definition: CocoaGlobals.h:15
OpticalObject::getPlate
ALIPlane getPlate(const ALIbool forwardPlate, const ALIbool applyWedge)
Definition: OpticalObject.cc:946
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
OptOUserDefined::userDefinedBehaviour
void userDefinedBehaviour(LightRay &lightray, Measurement &meas, const ALIstring &behav) override
Definition: OptOUserDefined.cc:24