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 return *(myDDRotation.rotation());
00277 }
00278 else
00279 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
00280 << name << " therefore could not look up the rotation." << std::endl;
00281
00282 return DDRotationMatrix();
00283 }
00284 else
00285 {
00286 return DDRotationMatrix();
00287 }
00288 }
00289
00290
00291
00292
00293
00294
00295 void global_simpleAngular_1::checkTermination()
00296 {
00297
00298
00299 if (count_ > ParE_["number"][0])
00300 terminate();
00301 }
00302
00303
00304 void global_simpleAngular_1::stream(std::ostream & os) const
00305 {
00306 os << "global_simpleAngular_0::stream(): not implemented.";
00307 }
00308
00309
00310
00311
00312
00313 global_simpleAngular_2::global_simpleAngular_2(AlgoPos * a,std::string label)
00314 : AlgoImpl(a,label)
00315 { }
00316
00317 global_simpleAngular_2::~global_simpleAngular_2()
00318 { }
00319
00320 bool global_simpleAngular_2::checkParameters()
00321 {
00322 bool result = true;
00323
00324
00325 if (ParE_["number"].size() == 0) {
00326 result = false;
00327 }
00328 else {
00329
00330 if (ParE_["number"][0] == 0.) {
00331 err_ += "\tnumber must not be 0\n";
00332 result = false;
00333 }
00334 }
00335
00336
00337 if (ParE_["delta"].size() == 0) {
00338 result = false;
00339 }
00340 else {
00341
00342 if (ParE_["delta"][0] == 0.) {
00343 err_ += "\tdelta must not be 0\n";
00344 result = false;
00345 }
00346 }
00347
00348 double delta = ParE_["delta"][0];
00349 double number = ParE_["number"][0];
00350 if (delta * number > 360. * deg) {
00351 err_ += "\tat this time delta * number can not be greater than 360 degrees\n";
00352 result = false;
00353 }
00354 return result;
00355 }
00356
00357
00358 DDTranslation global_simpleAngular_2::translation()
00359 {
00360
00361
00362 double offset = ParE_["offset"][0];
00363
00364 double delta = ParE_["delta"][0];
00365 double radius = ParE_["radius"][0];
00366
00367 DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00368 radius * sin(offset + delta * (count_ - 1)),
00369 0. );
00370
00371 return trans;
00372 }
00373
00374
00375 DDRotationMatrix global_simpleAngular_2::rotation()
00376 {
00377
00378
00379 double delta = ParE_["delta"][0];
00380 if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00381 || ParS_["rotate"][0] == "True")
00382 {
00383 double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
00384 DDRotationMatrix rm1;
00385 if (ParS_["orientation"].size() != 0)
00386 {
00387 std::string name=ParS_["orientation"][0];
00388 size_t foundColon = 0;
00389 std::string rn = "";
00390 std::string ns = "";
00391 while (foundColon < name.size() && name[foundColon] != ':')
00392 ++foundColon;
00393 if (foundColon != name.size())
00394 {
00395 for (size_t j = foundColon + 1; j < name.size(); ++j)
00396 rn = rn + name[j];
00397 for (size_t i = 0; i < foundColon; ++i)
00398 ns = ns + name[i];
00399 }
00400 if (rn != "" && ns != "")
00401 {
00402 DDRotation myDDRotation(DDName(rn, ns));
00403 rm1 = *(myDDRotation.rotation());
00404 }
00405 else
00406 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :"
00407 << name << std::endl;
00408 }
00409 ROOT::Math::RotationZ rm(angle);
00410 rm1.Invert();
00411 rm.Invert();
00412 return rm * rm1;
00413 }
00414 else if (ParS_["orientation"].size() != 0)
00415 {
00416
00417 std::string name=ParS_["orientation"][0];
00418 size_t foundColon = 0;
00419 std::string rn = "";
00420 std::string ns = "";
00421 while (foundColon < name.size() && name[foundColon] != ':')
00422 ++foundColon;
00423 if (foundColon != name.size())
00424 {
00425 for (size_t j = foundColon + 1; j < name.size(); ++j)
00426 rn = rn + name[j];
00427 for (size_t i = 0; i < foundColon; ++i)
00428 ns = ns + name[i];
00429 }
00430 if (rn != "" && ns != "")
00431 {
00432
00433 DDRotation myDDRotation(DDName(rn, ns));
00434 return *(myDDRotation.rotation());
00435 }
00436 else
00437 std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got "
00438 << name << " therefore could not look up the rotation." << std::endl;
00439 return DDRotationMatrix();
00440 }
00441 else
00442 {
00443 return DDRotationMatrix();
00444 }
00445 }
00446
00447
00448
00449
00450
00451
00452 void global_simpleAngular_2::checkTermination()
00453 {
00454
00455
00456 if (count_ > ParE_["number"][0])
00457 terminate();
00458 }
00459
00460
00461 void global_simpleAngular_2::stream(std::ostream & os) const
00462 {
00463 os << "global_simpleAngular_0::stream(): not implemented.";
00464 }
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486 global_simpleAngular_Check::global_simpleAngular_Check()
00487 {
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 constraintsE_["radius"] = ConstraintE( 1,
00499 1,
00500 -MAX_DOUBLE,
00501 +MAX_DOUBLE,
00502 false,
00503 true,
00504 0.0
00505 );
00506
00507 constraintsE_["offset"] = ConstraintE( 1,
00508 1,
00509 0.0*deg,
00510 360.0*deg,
00511 false,
00512 true,
00513 0.0
00514 );
00515
00516 constraintsE_["delta"] = ConstraintE( 1,
00517 1,
00518 0.0*deg,
00519 360.0*deg,
00520 false,
00521 false,
00522 0.
00523 );
00524
00525 constraintsE_["number"] = ConstraintE( 1,
00526 1,
00527 -MAX_DOUBLE,
00528 +MAX_DOUBLE,
00529 false,
00530 false,
00531 0.
00532 );
00533
00534 constraintsE_["radius"] = ConstraintE( 1,
00535 1,
00536 -MAX_DOUBLE,
00537 +MAX_DOUBLE,
00538 true,
00539 true,
00540 0.0
00541 );
00542
00543 constraintsS_["rotate"] = ConstraintS( 1,
00544 1,
00545
00546
00547 false,
00548 true,
00549 "1"
00550 );
00551
00552 constraintsS_["orientation"] = ConstraintS( 1,
00553 1,
00554
00555
00556 false,
00557 false,
00558 ""
00559 );
00560
00561 }
00562
00563