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