00001
00002
00003
00004 #include "global_simpleAngular.h"
00005
00006
00007
00008 #define MAX_DOUBLE DBL_MAX
00009
00010
00011
00012 #include "DetectorDescription/Core/interface/DDTransform.h"
00013
00014
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016 #include <Math/RotationZ.h>
00017
00018
00019
00020 global_simpleAngular_0::global_simpleAngular_0(AlgoPos * a,std::string label)
00021 : AlgoImpl(a,label)
00022 { }
00023
00024 global_simpleAngular_0::~global_simpleAngular_0()
00025 { }
00026
00027 bool global_simpleAngular_0::checkParameters()
00028 {
00029
00030
00031
00032
00033
00034 bool result = true;
00035
00036
00037 if (ParE_["delta"].size() == 0) {
00038 result = false;
00039 }
00040 else {
00041
00042 if (ParE_["delta"][0] == 0.) {
00043 err_ += "\tdelta can not be zero\n";
00044 result = false;
00045 }
00046 }
00047
00048
00049 if (ParE_["number"].size() != 0) {
00050
00051 result = false;
00052 }
00053 return result;
00054 }
00055
00056
00057 DDTranslation global_simpleAngular_0::translation()
00058 {
00059 double offset = ParE_["offset"][0]/rad;
00060 double delta = ParE_["delta"][0]/rad;
00061 double radius = ParE_["radius"][0];
00062
00063 DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00064 radius * sin(offset + delta * (count_ - 1)),
00065 0. );
00066
00067 return trans;
00068 }
00069
00070
00071 DDRotationMatrix global_simpleAngular_0::rotation()
00072 {
00073 std::cout << "ParS_[\"rotate\"][0] = " << ParS_["rotate"][0] << std::endl;
00074 if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00075 || ParS_["rotate"][0] == "True")
00076 {
00077 double angle = -(ParE_["offset"][0]/rad + (ParE_["delta"][0]/rad) * (count_ - 1));
00078 DDRotationMatrix rm1;
00079 if (ParS_["orientation"].size() != 0)
00080 {
00081 std::string name=ParS_["orientation"][0];
00082 size_t foundColon = 0;
00083 std::string rn = "";
00084 std::string ns = "";
00085 while (foundColon < name.size() && name[foundColon] != ':')
00086 ++foundColon;
00087 if (foundColon != name.size())
00088 {
00089 for (size_t j = foundColon + 1; j < name.size(); ++j)
00090 rn = rn + name[j];
00091 for (size_t i = 0; i < foundColon; ++i)
00092 ns = ns + name[i];
00093 }
00094 if (rn != "" && ns != "")
00095 {
00096 DDRotation myDDRotation(DDName(rn, ns));
00097 rm1 = *(myDDRotation.rotation());
00098 }
00099 else
00100 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
00101 << name << std::endl;
00102 }
00103 ROOT::Math::RotationZ rm(angle);
00104 rm1.Invert();
00105 rm.Invert();
00106 return rm * rm1;
00107 }
00108 else if (ParS_["orientation"].size() != 0)
00109 {
00110
00111 std::string name=ParS_["orientation"][0];
00112 size_t foundColon = 0;
00113 std::string rn = "";
00114 std::string ns = "";
00115 while (foundColon < name.size() && name[foundColon] != ':')
00116 ++foundColon;
00117 if (foundColon != name.size())
00118 {
00119 for (size_t j = foundColon + 1; j < name.size(); ++j)
00120 rn = rn + name[j];
00121 for (size_t i = 0; i < foundColon; ++i)
00122 ns = ns + name[i];
00123 }
00124 if (rn != "" && ns != "")
00125 {
00126
00127 DDRotation myDDRotation(DDName(rn, ns));
00128 std::cout << "about to return *(myDDRotation.rotation())" << std::endl;
00129 std::cout << *myDDRotation.rotation() << std::endl;
00130 return *(myDDRotation.rotation());
00131 }
00132 else
00133 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
00134 << name << " therefore could not look up the rotation." << std::endl;
00135 return DDRotationMatrix();
00136 }
00137 else
00138 {
00139 return DDRotationMatrix();
00140 }
00141 }
00142
00143
00144
00145
00146
00147
00148 void global_simpleAngular_0::checkTermination()
00149 {
00150
00151
00152
00153 if (ParE_["delta"][0] * count_ / deg > 360.)
00154 terminate();
00155
00156 }
00157
00158
00159 void global_simpleAngular_0::stream(std::ostream & os) const
00160 {
00161 os << "global_simplesimpleAngular_0::stream(): not implemented.";
00162 }
00163
00164
00165
00166
00167
00168 global_simpleAngular_1::global_simpleAngular_1(AlgoPos * a,std::string label)
00169 : AlgoImpl(a,label)
00170 { }
00171
00172 global_simpleAngular_1::~global_simpleAngular_1()
00173 { }
00174
00175 bool global_simpleAngular_1::checkParameters()
00176 {
00177 bool result = true;
00178
00179
00180 if (ParE_["number"].size() == 0) {
00181 result = false;
00182 }
00183 else {
00184
00185 if (ParE_["number"][0] == 0.) {
00186 err_ += "\tnumber must not be 0\n";
00187 result = false;
00188 }
00189 }
00190
00191
00192 if (ParE_["delta"].size() != 0) {
00193
00194 result = false;
00195 }
00196
00197 return result;
00198 }
00199
00200
00201 DDTranslation global_simpleAngular_1::translation()
00202 {
00203
00204
00205 double offset = ParE_["offset"][0];
00206 double number = ParE_["number"][0];
00207 double delta = (360.0 / number) * deg;
00208 double radius = ParE_["radius"][0];
00209
00210 DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00211 radius * sin(offset + delta * (count_ - 1)),
00212 0. );
00213
00214 return trans;
00215 }
00216
00217
00218 DDRotationMatrix global_simpleAngular_1::rotation()
00219 {
00220 double number = ParE_["number"][0];
00221 double delta = (360.0 / number) * deg;
00222 if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00223 || ParS_["rotate"][0] == "True")
00224 {
00225 double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
00226
00227 DDRotationMatrix rm1;
00228 if (ParS_["orientation"].size() != 0)
00229 {
00230 std::string name=ParS_["orientation"][0];
00231 size_t foundColon = 0;
00232 std::string rn = "";
00233 std::string ns = "";
00234 while (foundColon < name.size() && name[foundColon] != ':')
00235 ++foundColon;
00236 if (foundColon != name.size())
00237 {
00238 for (size_t j = foundColon + 1; j < name.size(); ++j)
00239 rn = rn + name[j];
00240 for (size_t i = 0; i < foundColon; ++i)
00241 ns = ns + name[i];
00242 }
00243 if (rn != "" && ns != "")
00244 {
00245 DDRotation myDDRotation(DDName(rn, ns));
00246 rm1 = *(myDDRotation.rotation());
00247 }
00248 else
00249 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
00250 << name << " therefore could not look up the rotation." << std::endl;
00251 }
00252 ROOT::Math::RotationZ rm(angle);
00253 rm1.Invert();
00254 rm.Invert();
00255 return rm * rm1;
00256 }
00257 else if (ParS_["orientation"].size() != 0)
00258 {
00259 std::string name=ParS_["orientation"][0];
00260 size_t foundColon = 0;
00261 std::string rn = "";
00262 std::string ns = "";
00263 while (foundColon < name.size() && name[foundColon] != ':')
00264 ++foundColon;
00265 if (foundColon != name.size())
00266 {
00267 for (size_t j = foundColon + 1; j < name.size(); ++j)
00268 rn = rn + name[j];
00269 for (size_t i = 0; i < foundColon; ++i)
00270 ns = ns + name[i];
00271 }
00272 if (rn != "" && ns != "")
00273 {
00274
00275 DDRotation myDDRotation(DDName(rn, ns));
00276 DDRotationMatrix rm = *(myDDRotation.rotation());
00277 return *(myDDRotation.rotation());
00278 }
00279 else
00280 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
00281 << name << " therefore could not look up the rotation." << std::endl;
00282
00283 return DDRotationMatrix();
00284 }
00285 else
00286 {
00287 return DDRotationMatrix();
00288 }
00289 }
00290
00291
00292
00293
00294
00295
00296 void global_simpleAngular_1::checkTermination()
00297 {
00298
00299
00300 if (count_ > ParE_["number"][0])
00301 terminate();
00302 }
00303
00304
00305 void global_simpleAngular_1::stream(std::ostream & os) const
00306 {
00307 os << "global_simpleAngular_0::stream(): not implemented.";
00308 }
00309
00310
00311
00312
00313
00314 global_simpleAngular_2::global_simpleAngular_2(AlgoPos * a,std::string label)
00315 : AlgoImpl(a,label)
00316 { }
00317
00318 global_simpleAngular_2::~global_simpleAngular_2()
00319 { }
00320
00321 bool global_simpleAngular_2::checkParameters()
00322 {
00323 bool result = true;
00324
00325
00326 if (ParE_["number"].size() == 0) {
00327 result = false;
00328 }
00329 else {
00330
00331 if (ParE_["number"][0] == 0.) {
00332 err_ += "\tnumber must not be 0\n";
00333 result = false;
00334 }
00335 }
00336
00337
00338 if (ParE_["delta"].size() == 0) {
00339 result = false;
00340 }
00341 else {
00342
00343 if (ParE_["delta"][0] == 0.) {
00344 err_ += "\tdelta must not be 0\n";
00345 result = false;
00346 }
00347 }
00348
00349 double delta = ParE_["delta"][0];
00350 double number = ParE_["number"][0];
00351 if (delta * number > 360. * deg) {
00352 err_ += "\tat this time delta * number can not be greater than 360 degrees\n";
00353 result = false;
00354 }
00355 return result;
00356 }
00357
00358
00359 DDTranslation global_simpleAngular_2::translation()
00360 {
00361
00362
00363 double offset = ParE_["offset"][0];
00364
00365 double delta = ParE_["delta"][0];
00366 double radius = ParE_["radius"][0];
00367
00368 DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00369 radius * sin(offset + delta * (count_ - 1)),
00370 0. );
00371
00372 return trans;
00373 }
00374
00375
00376 DDRotationMatrix global_simpleAngular_2::rotation()
00377 {
00378
00379
00380 double delta = ParE_["delta"][0];
00381 if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00382 || ParS_["rotate"][0] == "True")
00383 {
00384 double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
00385 DDRotationMatrix rm1;
00386 if (ParS_["orientation"].size() != 0)
00387 {
00388 std::string name=ParS_["orientation"][0];
00389 size_t foundColon = 0;
00390 std::string rn = "";
00391 std::string ns = "";
00392 while (foundColon < name.size() && name[foundColon] != ':')
00393 ++foundColon;
00394 if (foundColon != name.size())
00395 {
00396 for (size_t j = foundColon + 1; j < name.size(); ++j)
00397 rn = rn + name[j];
00398 for (size_t i = 0; i < foundColon; ++i)
00399 ns = ns + name[i];
00400 }
00401 if (rn != "" && ns != "")
00402 {
00403 DDRotation myDDRotation(DDName(rn, ns));
00404 rm1 = *(myDDRotation.rotation());
00405 }
00406 else
00407 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
00408 << name << std::endl;
00409 }
00410 ROOT::Math::RotationZ rm(angle);
00411 rm1.Invert();
00412 rm.Invert();
00413 return rm * rm1;
00414 }
00415 else if (ParS_["orientation"].size() != 0)
00416 {
00417
00418 std::string name=ParS_["orientation"][0];
00419 size_t foundColon = 0;
00420 std::string rn = "";
00421 std::string ns = "";
00422 while (foundColon < name.size() && name[foundColon] != ':')
00423 ++foundColon;
00424 if (foundColon != name.size())
00425 {
00426 for (size_t j = foundColon + 1; j < name.size(); ++j)
00427 rn = rn + name[j];
00428 for (size_t i = 0; i < foundColon; ++i)
00429 ns = ns + name[i];
00430 }
00431 if (rn != "" && ns != "")
00432 {
00433
00434 DDRotation myDDRotation(DDName(rn, ns));
00435 DDRotationMatrix rm = *(myDDRotation.rotation());
00436 return *(myDDRotation.rotation());
00437 }
00438 else
00439 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
00440 << name << " therefore could not look up the rotation." << std::endl;
00441 return DDRotationMatrix();
00442 }
00443 else
00444 {
00445 return DDRotationMatrix();
00446 }
00447 }
00448
00449
00450
00451
00452
00453
00454 void global_simpleAngular_2::checkTermination()
00455 {
00456
00457
00458 if (count_ > ParE_["number"][0])
00459 terminate();
00460 }
00461
00462
00463 void global_simpleAngular_2::stream(std::ostream & os) const
00464 {
00465 os << "global_simpleAngular_0::stream(): not implemented.";
00466 }
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 global_simpleAngular_Check::global_simpleAngular_Check()
00489 {
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 constraintsE_["radius"] = ConstraintE( 1,
00501 1,
00502 -MAX_DOUBLE,
00503 +MAX_DOUBLE,
00504 false,
00505 true,
00506 0.0
00507 );
00508
00509 constraintsE_["offset"] = ConstraintE( 1,
00510 1,
00511 0.0*deg,
00512 360.0*deg,
00513 false,
00514 true,
00515 0.0
00516 );
00517
00518 constraintsE_["delta"] = ConstraintE( 1,
00519 1,
00520 0.0*deg,
00521 360.0*deg,
00522 false,
00523 false,
00524 0.
00525 );
00526
00527 constraintsE_["number"] = ConstraintE( 1,
00528 1,
00529 -MAX_DOUBLE,
00530 +MAX_DOUBLE,
00531 false,
00532 false,
00533 0.
00534 );
00535
00536 constraintsE_["radius"] = ConstraintE( 1,
00537 1,
00538 -MAX_DOUBLE,
00539 +MAX_DOUBLE,
00540 true,
00541 true,
00542 0.0
00543 );
00544
00545 constraintsS_["rotate"] = ConstraintS( 1,
00546 1,
00547
00548
00549 false,
00550 true,
00551 "1"
00552 );
00553
00554 constraintsS_["orientation"] = ConstraintS( 1,
00555 1,
00556
00557
00558 false,
00559 false,
00560 ""
00561 );
00562
00563 }
00564
00565