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