00001
00002
00003
00004
00005 #include "DDDividedPolycone.h"
00006 #include "DDXMLElement.h"
00007
00008 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00009 #include "DetectorDescription/Core/interface/DDName.h"
00010 #include "DetectorDescription/Core/interface/DDPosPart.h"
00011 #include "DetectorDescription/Core/interface/DDAxes.h"
00012 #include "DetectorDescription/Core/interface/DDSolid.h"
00013 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00014 #include "DetectorDescription/Core/interface/DDMaterial.h"
00015
00016 #include "DetectorDescription/Base/interface/DDdebug.h"
00017 #include "DetectorDescription/Base/interface/DDException.h"
00018 #include "DetectorDescription/Base/interface/DDRotationMatrix.h"
00019 #include "DetectorDescription/Base/interface/DDTranslation.h"
00020
00021
00022 #include "CLHEP/Units/SystemOfUnits.h"
00023
00024
00025
00026 DDDividedPolyconeRho::DDDividedPolyconeRho( const DDDivision & div )
00027 : DDDividedGeometryObject::DDDividedGeometryObject (div)
00028 {
00029 checkParametersValidity();
00030 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00031 std::vector<double> localrMaxVec = msol.rMaxVec();
00032 std::vector<double> localrMinVec = msol.rMinVec();
00033
00034 setType( "DivisionPolyconeRho" );
00035
00036
00037
00038
00039
00040
00041 if( divisionType_ == DivWIDTH )
00042 {
00043 compNDiv_ = calculateNDiv( localrMaxVec[0]
00044 - localrMinVec[0], div_.width(), div_.offset() );
00045 }
00046 else if( divisionType_ == DivNDIV )
00047 {
00048 compWidth_ = calculateWidth( localrMaxVec[0]
00049 - localrMinVec[0], div_.nReplicas(), div_.offset() );
00050 }
00051
00052
00053 DCOUT_V ('P', " DDDividedPolyconeRho - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
00054
00055 }
00056
00057
00058 DDDividedPolyconeRho::~DDDividedPolyconeRho()
00059 {
00060 }
00061
00062
00063 void DDDividedPolyconeRho::checkParametersValidity()
00064 {
00065 DDDividedGeometryObject::checkParametersValidity();
00066
00067 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00068
00069 if( divisionType_ == DivNDIVandWIDTH || divisionType_ == DivWIDTH )
00070 {
00071 std::cout << "WARNING - "
00072 << "DDDividedPolyconeRho::checkParametersValidity()"
00073 << std::endl
00074 << " Solid " << msol << std::endl
00075 << " Division along r will be done with a width "
00076 << "different for each solid section." << std::endl
00077 << " WIDTH will not be used !" << std::endl;
00078 }
00079 if( div_.offset() != 0. )
00080 {
00081 std::cout << "WARNING - "
00082 << "DDDividedPolyconeRho::checkParametersValidity()"
00083 << std::endl
00084 << " Solid " << msol << std::endl
00085 << " Division along R will be done with a width "
00086 << "different for each solid section." << std::endl
00087 << " OFFSET will not be used !" << std::endl;
00088 }
00089
00090 }
00091
00092
00093 double DDDividedPolyconeRho::getMaxParameter() const
00094 {
00095 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00096 std::vector<double> localrMaxVec = msol.rMaxVec();
00097 std::vector<double> localrMinVec = msol.rMinVec();
00098
00099 return localrMaxVec[0] - localrMinVec[0];
00100
00101 }
00102
00103
00104 DDRotation DDDividedPolyconeRho::makeDDRotation(const int copyNo) const
00105 {
00106 DDRotation myddrot;
00107 DCOUT_V ('P', "DDDividedPolyconeRho::makeDDRotation : " << myddrot);
00108 return myddrot;
00109 }
00110
00111
00112 DDTranslation DDDividedPolyconeRho::makeDDTranslation( const int copyNo ) const
00113 {
00114 DDTranslation translation;
00115 return translation;
00116 }
00117
00118
00119 DDLogicalPart DDDividedPolyconeRho::makeDDLogicalPart( const int copyNo ) const
00120 {
00121 DDName solname;
00122 DDSolid ddpolycone;
00123 DDMaterial usemat(div_.parent().material());
00124
00125 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00126 std::vector<double> localrMaxVec = msol.rMaxVec();
00127 std::vector<double> localrMinVec = msol.rMinVec();
00128 std::vector<double> localzVec = msol.zVec();
00129
00130
00131
00132 int nZplanes = localzVec.size();
00133
00134 std::vector<double> newrMinVec;
00135 std::vector<double> newrMaxVec;
00136
00137 double width = 0.;
00138 for(int ii = 0; ii < nZplanes; ++ii)
00139 {
00140 width = calculateWidth( localrMaxVec[ii]
00141 - localrMinVec[ii], compNDiv_, div_.offset() );
00142
00143
00144
00145
00146 newrMinVec.push_back(localrMinVec[ii]+div_.offset()+width*copyNo);
00147 newrMaxVec.push_back(localrMinVec[ii]+div_.offset()+width*(copyNo+1));
00148 }
00149 solname = DDName(div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo)
00150 , div_.parent().ddname().ns());
00151
00152 ddpolycone = DDSolidFactory::polycone(solname
00153 , msol.startPhi()
00154 , msol.deltaPhi()
00155 , localzVec
00156 , newrMinVec
00157 , newrMaxVec);
00158
00159
00160
00161 DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddpolycone);
00162 DCOUT_V ('P', " DDDividedPolyconeRho::makeDDLogicalPart() lp:" << ddlp);
00163 return ddlp;
00164 }
00165
00166
00167
00168 DDDividedPolyconePhi::DDDividedPolyconePhi( const DDDivision & div )
00169 : DDDividedGeometryObject::DDDividedGeometryObject (div)
00170 {
00171 checkParametersValidity();
00172 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00173 setType( "DivisionPolyconePhi" );
00174
00175
00176 if( divisionType_ == DivWIDTH )
00177 {
00178
00179 if( msol.deltaPhi() == 360.*deg ) {
00180 compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
00181 }else {
00182 compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), div_.offset() );
00183 }
00184 }
00185 else if( divisionType_ == DivNDIV )
00186 {
00187 if( msol.deltaPhi() == 360.*deg ) {
00188 compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
00189 }else {
00190 compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), div_.offset() );
00191 }
00192 }
00193
00194 DCOUT_V ('P', " DDDividedPolyconePhi - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
00195
00196 }
00197
00198
00199 DDDividedPolyconePhi::~DDDividedPolyconePhi()
00200 {
00201 }
00202
00203
00204 void DDDividedPolyconePhi::checkParametersValidity()
00205 {
00206 DDDividedGeometryObject::checkParametersValidity();
00207 }
00208
00209
00210 double DDDividedPolyconePhi::getMaxParameter() const
00211 {
00212 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00213
00214 return msol.deltaPhi();
00215 }
00216
00217
00218 DDRotation DDDividedPolyconePhi::makeDDRotation(const int copyNo) const
00219 {
00220 DDRotation myddrot;
00221 double posi = ( copyNo - 1 ) * compWidth_;
00222 DDRotationMatrix* rotMat = changeRotMatrix( posi );
00223
00224
00225 DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + DDXMLElement::itostr(copyNo)
00226 , div_.parent().ddname().ns());
00227 myddrot = DDrot(ddrotname, rotMat);
00228
00229 DCOUT_V ('P', "DDDividedPolyconePhi::makeDDRotation : " << myddrot);
00230 return myddrot;
00231 }
00232
00233
00234 DDTranslation DDDividedPolyconePhi::makeDDTranslation( const int copyNo ) const
00235 {
00236 DDTranslation translation;
00237 return translation;
00238 }
00239
00240
00241 DDLogicalPart DDDividedPolyconePhi::makeDDLogicalPart( const int copyNo ) const
00242 {
00243 DDName solname;
00244 DDSolid ddpolycone;
00245 DDMaterial usemat(div_.parent().material());
00246
00247 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00248 std::vector<double> localrMaxVec = msol.rMaxVec();
00249 std::vector<double> localrMinVec = msol.rMinVec();
00250 std::vector<double> localzVec = msol.zVec();
00251
00252
00253
00254
00255
00256 solname = DDName(div_.parent().ddname().name() + "_DIVCHILD"
00257 , div_.parent().ddname().ns());
00258 DDSolid sol(solname);
00259 if (!sol.isDefined().second) {
00260 ddpolycone = DDSolidFactory::polycone(solname
00261 , msol.startPhi()+div_.offset()
00262 , compWidth_
00263 , localzVec
00264 , localrMinVec
00265 , localrMaxVec);
00266 }
00267 DDLogicalPart ddlp(solname);
00268 if (!ddlp.isDefined().second) {
00269 ddlp = DDLogicalPart(solname, usemat, ddpolycone);
00270 }
00271 DCOUT_V ('P', " DDDividedPolyconePhi::makeDDLogicalPart() lp:" << ddlp);
00272 return ddlp;
00273 }
00274
00275
00276
00277 DDDividedPolyconeZ::DDDividedPolyconeZ( const DDDivision & div )
00278 : DDDividedGeometryObject::DDDividedGeometryObject (div)
00279 {
00280 checkParametersValidity();
00281 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00282 std::vector<double> localrMaxVec = msol.rMaxVec();
00283 std::vector<double> localrMinVec = msol.rMinVec();
00284 std::vector<double> localzVec = msol.zVec();
00285
00286 if( divisionType_ == DivWIDTH )
00287 {
00288 compNDiv_ =
00289 calculateNDiv( localzVec[localzVec.size() - 1]
00290 - localzVec[0] , div_.width(), div_.offset() );
00291 }
00292 else if( divisionType_ == DivNDIV )
00293 {
00294 compWidth_ =
00295 calculateNDiv( localzVec[localzVec.size()-1]
00296 - localzVec[0] , div_.nReplicas(), div_.offset() );
00297 }
00298
00299
00300 DCOUT_V ('P', " DDDividedPolyconeZ - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
00301
00302 }
00303
00304
00305 DDDividedPolyconeZ::~DDDividedPolyconeZ()
00306 {
00307 }
00308
00309
00310 void DDDividedPolyconeZ::checkParametersValidity()
00311 {
00312 DDDividedGeometryObject::checkParametersValidity();
00313
00314 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00315 std::vector<double> localzVec = msol.zVec();
00316
00317
00318
00319 size_t tempNDiv = div_.nReplicas();
00320 if (tempNDiv == 0)
00321 tempNDiv = calculateNDiv( localzVec[localzVec.size() - 1] - localzVec[0]
00322 , div_.width()
00323 , div_.offset() );
00324 if ((msol.zVec().size() - 1) != tempNDiv)
00325 {
00326 std::string s = "ERROR - DDDividedPolyconeZ::checkParametersValidity()";
00327 s += "\n\tDivision along Z will be done splitting in the defined";
00328 s += "\n\tz_planes, i.e, the number of division would be :";
00329 s += "\n\t" + DDXMLElement::itostr( msol.zVec().size() - 1 );
00330 s += "\n\tinstead of " + DDXMLElement::itostr(tempNDiv) + " !\n";
00331
00332 throw DDException(s);
00333 }
00334 }
00335
00336
00337 double DDDividedPolyconeZ::getMaxParameter() const
00338 {
00339 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00340 std::vector<double> localzVec = msol.zVec();
00341
00342
00343 return (localzVec[ localzVec.size() - 1] - localzVec[0]);
00344 }
00345
00346
00347 DDRotation DDDividedPolyconeZ::makeDDRotation(const int copyNo) const
00348 {
00349 DDRotation myddrot;
00350 DCOUT_V ('P', "DDDividedPolyconeZ::makeDDRotation : " << myddrot);
00351 return myddrot;
00352 }
00353
00354
00355 DDTranslation DDDividedPolyconeZ::makeDDTranslation( const int copyNo ) const
00356 {
00357 DDTranslation translation;
00358 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00359 std::vector<double> localzVec = msol.zVec();
00360
00361
00362 double posi = (localzVec[copyNo] + localzVec[copyNo+1]) / 2;
00363 translation.SetZ(posi);
00364 return translation;
00365
00366 }
00367
00368
00369 DDLogicalPart DDDividedPolyconeZ::makeDDLogicalPart( const int copyNo ) const
00370 {
00371 DDName solname;
00372 DDSolid ddpolycone;
00373 DDMaterial usemat(div_.parent().material());
00374
00375 DDPolycone msol = (DDPolycone)(div_.parent().solid());
00376 std::vector<double> localrMaxVec = msol.rMaxVec();
00377 std::vector<double> localrMinVec = msol.rMinVec();
00378 std::vector<double> localzVec = msol.zVec();
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395 solname = DDName(div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo)
00396 , div_.parent().ddname().ns());
00397 ddpolycone = DDSolidFactory::cons(solname
00398 , compWidth_ / 2
00399 , localrMinVec[copyNo]
00400 , localrMaxVec[copyNo]
00401 , localrMinVec[copyNo+1]
00402 , localrMaxVec[copyNo+1]
00403 , msol.startPhi()
00404 , msol.deltaPhi()
00405 );
00406
00407 DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddpolycone);
00408 DCOUT_V ('P', " DDDividedPolyconeZ::makeDDLogicalPart() lp:" << ddlp);
00409 return ddlp;
00410 }