[807] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // File name: RadmonDetectorLayout.cc |
---|
| 28 | // Creation date: Sep 2005 |
---|
| 29 | // Main author: Riccardo Capra <capra@ge.infn.it> |
---|
| 30 | // |
---|
| 31 | // Id: $Id: RadmonDetectorLayout.cc,v 1.3.2.2 2006/06/29 16:13:59 gunter Exp $ |
---|
| 32 | // Tag: $Name: geant4-09-01-patch-02 $ |
---|
| 33 | // |
---|
| 34 | |
---|
| 35 | // Include files |
---|
| 36 | #include "RadmonDetectorLayout.hh" |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | RadmonDetectorLayout :: RadmonDetectorLayout() |
---|
| 41 | { |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | RadmonDetectorLayout :: ~RadmonDetectorLayout() |
---|
| 47 | { |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | void RadmonDetectorLayout :: EnableEnvironment(void) |
---|
| 55 | { |
---|
| 56 | if (environment.IsEnabled()) |
---|
| 57 | return; |
---|
| 58 | |
---|
| 59 | environment.Enable(); |
---|
| 60 | NotifyChange(); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | void RadmonDetectorLayout :: DisableEnvironment(void) |
---|
| 66 | { |
---|
| 67 | if (!environment.IsEnabled()) |
---|
| 68 | return; |
---|
| 69 | |
---|
| 70 | environment.Disable(); |
---|
| 71 | NotifyChange(); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | G4bool RadmonDetectorLayout :: IsEnabledEnvironment(void) const |
---|
| 77 | { |
---|
| 78 | return environment.IsEnabled(); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | void RadmonDetectorLayout :: SetEnvironmentType(const G4String & type) |
---|
| 86 | { |
---|
| 87 | if (environment.GetType()==type) |
---|
| 88 | return; |
---|
| 89 | |
---|
| 90 | environment.SetType(type); |
---|
| 91 | |
---|
| 92 | if (environment.IsEnabled()) |
---|
| 93 | NotifyChange(); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | const G4String & RadmonDetectorLayout :: GetEnvironmentType() const |
---|
| 99 | { |
---|
| 100 | return environment.GetType(); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | G4int RadmonDetectorLayout :: GetEnvironmentNAttributes(void) const |
---|
| 106 | { |
---|
| 107 | return environment.GetNAttributes(); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | const G4String & RadmonDetectorLayout :: GetEnvironmentAttributeName(G4int index) const |
---|
| 113 | { |
---|
| 114 | return environment.GetAttributeName(index); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | void RadmonDetectorLayout :: SetEnvironmentAttribute(const G4String & attributeName, const G4String & attributeValue) |
---|
| 120 | { |
---|
| 121 | if (attributeName=="") |
---|
| 122 | { |
---|
| 123 | G4cout << "RadmonDetectorLayout::FindPlacement: \"\" is not a valid attribute name." << G4endl; |
---|
| 124 | return; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | if (environment.GetAttribute(attributeName, attributeValue+"#")==attributeValue) |
---|
| 128 | return; |
---|
| 129 | |
---|
| 130 | environment.SetAttribute(attributeName, attributeValue); |
---|
| 131 | |
---|
| 132 | if (environment.IsEnabled()) |
---|
| 133 | NotifyChange(); |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | const G4String RadmonDetectorLayout :: GetEnvironmentAttribute(const G4String & attributeName, const G4String & defaultAttributeValue) const |
---|
| 139 | { |
---|
| 140 | return environment.GetAttribute(attributeName, defaultAttributeValue); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | void RadmonDetectorLayout :: ClearEnvironmentAttribute(const G4String & attributeName) |
---|
| 146 | { |
---|
| 147 | if (!environment.ExistsAttribute(attributeName)) |
---|
| 148 | { |
---|
| 149 | G4cout << "RadmonDetectorLayout::ClearEnvironmentAttribute: Attribute \"" << attributeName << "\" missing in environment." << G4endl; |
---|
| 150 | return; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | environment.ClearAttribute(attributeName); |
---|
| 154 | |
---|
| 155 | if (environment.IsEnabled()) |
---|
| 156 | NotifyChange(); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | void RadmonDetectorLayout :: CreateMultilayer(const G4String & multilayerLabel) |
---|
| 164 | { |
---|
| 165 | if (multilayersCollection.ExistsMultilayerByLabel(multilayerLabel)) |
---|
| 166 | { |
---|
| 167 | G4cout << "RadmonDetectorLayout::CreateMultilayer: Multilayer \"" << multilayerLabel << "\" just exists." << G4endl; |
---|
| 168 | return; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | RadmonDetectorMultilayerLayout & multilayer(multilayersCollection.CreateMultilayer()); |
---|
| 172 | multilayer.SetLabel(multilayerLabel); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | void RadmonDetectorLayout :: RemoveMultilayer(const G4String & multilayerLabel) |
---|
| 178 | { |
---|
| 179 | if (IsPlaced(multilayerLabel)) |
---|
| 180 | { |
---|
| 181 | G4cout << "RadmonDetectorLayout::RemoveMultilayer: Multilayer \"" << multilayerLabel << "\" is placed and cannot be deleted. Remove the placement first." << G4endl; |
---|
| 182 | return; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | if (!multilayersCollection.ExistsMultilayerByLabel(multilayerLabel)) |
---|
| 186 | { |
---|
| 187 | G4cout << "RadmonDetectorLayout::RemoveMultilayer: Multilayer \"" << multilayerLabel << "\" does not exist." << G4endl; |
---|
| 188 | return; |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | multilayersCollection.RemoveMultilayersByLabel(multilayerLabel); |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | void RadmonDetectorLayout :: SetMultilayerWidth(const G4String & multilayerLabel, G4double width) |
---|
| 197 | { |
---|
| 198 | RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 199 | |
---|
| 200 | if (!multilayer) |
---|
| 201 | return; |
---|
| 202 | |
---|
| 203 | if (multilayer->GetWidth()==width) |
---|
| 204 | return; |
---|
| 205 | |
---|
| 206 | multilayer->SetWidth(width); |
---|
| 207 | |
---|
| 208 | if (IsPlaced(multilayerLabel)) |
---|
| 209 | NotifyChange(); |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | |
---|
| 214 | G4double RadmonDetectorLayout :: GetMultilayerWidth(const G4String & multilayerLabel) const |
---|
| 215 | { |
---|
| 216 | const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 217 | |
---|
| 218 | if (!multilayer) |
---|
| 219 | return 0.; |
---|
| 220 | |
---|
| 221 | return multilayer->GetWidth(); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | |
---|
| 226 | void RadmonDetectorLayout :: SetMultilayerHeight(const G4String & multilayerLabel, G4double height) |
---|
| 227 | { |
---|
| 228 | RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 229 | |
---|
| 230 | if (!multilayer) |
---|
| 231 | return; |
---|
| 232 | |
---|
| 233 | if (multilayer->GetHeight()==height) |
---|
| 234 | return; |
---|
| 235 | |
---|
| 236 | multilayer->SetHeight(height); |
---|
| 237 | |
---|
| 238 | if (IsPlaced(multilayerLabel)) |
---|
| 239 | NotifyChange(); |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | G4double RadmonDetectorLayout :: GetMultilayerHeight(const G4String & multilayerLabel) const |
---|
| 245 | { |
---|
| 246 | const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 247 | |
---|
| 248 | if (!multilayer) |
---|
| 249 | return 0.; |
---|
| 250 | |
---|
| 251 | return multilayer->GetHeight(); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | G4double RadmonDetectorLayout :: GetMultilayerTotalThickness(const G4String & multilayerLabel) const |
---|
| 257 | { |
---|
| 258 | const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 259 | |
---|
| 260 | if (!multilayer) |
---|
| 261 | return 0.; |
---|
| 262 | |
---|
| 263 | return multilayer->GetTotalThickness(); |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | void RadmonDetectorLayout :: AppendLayerToMultilayer(const G4String & multilayerLabel, const G4String & layerLabel) |
---|
| 271 | { |
---|
| 272 | RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 273 | |
---|
| 274 | if (!multilayer) |
---|
| 275 | return; |
---|
| 276 | |
---|
| 277 | if (multilayer->ExistsLayerByLabel(layerLabel)) |
---|
| 278 | { |
---|
| 279 | G4cout << "RadmonDetectorLayout::AppendLayerToMultilayer: Layer \"" << layerLabel << "\" just exists in multilayer \"" << multilayerLabel << "\"." << G4endl; |
---|
| 280 | return; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | RadmonDetectorLayerLayout & layer(multilayer->AppendLayer()); |
---|
| 284 | |
---|
| 285 | layer.SetLabel(layerLabel); |
---|
| 286 | |
---|
| 287 | if (IsPlaced(multilayerLabel)) |
---|
| 288 | NotifyChange(); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | void RadmonDetectorLayout :: RemoveLayerFromMultilayer(const G4String & multilayerLabel, const G4String & layerLabel) |
---|
| 294 | { |
---|
| 295 | RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 296 | |
---|
| 297 | if (!multilayer) |
---|
| 298 | return; |
---|
| 299 | |
---|
| 300 | if (!multilayer->ExistsLayerByLabel(layerLabel)) |
---|
| 301 | { |
---|
| 302 | G4cout << "RadmonDetectorLayout::RemoveLayerFromMultilayer: Layer \"" << layerLabel << "\" does not exist in multilayer \"" << multilayerLabel << "\"." << G4endl; |
---|
| 303 | return; |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | multilayer->RemoveLayersByLabel(layerLabel); |
---|
| 307 | |
---|
| 308 | if (IsPlaced(multilayerLabel)) |
---|
| 309 | NotifyChange(); |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | void RadmonDetectorLayout :: RemoveAllLayersFromMultilayer(const G4String & multilayerLabel) |
---|
| 315 | { |
---|
| 316 | RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 317 | |
---|
| 318 | if (!multilayer) |
---|
| 319 | return; |
---|
| 320 | |
---|
| 321 | multilayer->RemoveAllLayers(); |
---|
| 322 | |
---|
| 323 | if (IsPlaced(multilayerLabel)) |
---|
| 324 | NotifyChange(); |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | G4int RadmonDetectorLayout :: GetMultilayerNLayers(const G4String & multilayerLabel) const |
---|
| 330 | { |
---|
| 331 | const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 332 | |
---|
| 333 | if (!multilayer) |
---|
| 334 | return 0; |
---|
| 335 | |
---|
| 336 | return multilayer->GetNLayers(); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | |
---|
| 340 | |
---|
| 341 | const G4String & RadmonDetectorLayout :: GetMultilayerLayerLabel(const G4String & multilayerLabel, G4int index) const |
---|
| 342 | { |
---|
| 343 | const RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 344 | |
---|
| 345 | if (!multilayer) |
---|
| 346 | return GetNullStr(); |
---|
| 347 | |
---|
| 348 | return multilayer->GetLayer(index).GetLabel(); |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | |
---|
| 352 | |
---|
| 353 | |
---|
| 354 | |
---|
| 355 | void RadmonDetectorLayout :: SetLayerThickness(const G4String & multilayerLabel, const G4String & layerLabel, G4double thickness) |
---|
| 356 | { |
---|
| 357 | RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 358 | |
---|
| 359 | if (!layer) |
---|
| 360 | return; |
---|
| 361 | |
---|
| 362 | if (layer->GetThickness()==thickness) |
---|
| 363 | return; |
---|
| 364 | |
---|
| 365 | layer->SetThickness(thickness); |
---|
| 366 | |
---|
| 367 | if (IsPlaced(multilayerLabel)) |
---|
| 368 | NotifyChange(); |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | |
---|
| 372 | |
---|
| 373 | G4double RadmonDetectorLayout :: GetLayerThickness(const G4String & multilayerLabel, const G4String & layerLabel) const |
---|
| 374 | { |
---|
| 375 | const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 376 | |
---|
| 377 | if (!layer) |
---|
| 378 | return 0.; |
---|
| 379 | |
---|
| 380 | return layer->GetThickness(); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | |
---|
| 384 | |
---|
| 385 | void RadmonDetectorLayout :: SetLayerType(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & type) |
---|
| 386 | { |
---|
| 387 | RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 388 | |
---|
| 389 | if (!layer) |
---|
| 390 | return; |
---|
| 391 | |
---|
| 392 | if (layer->GetType()==type) |
---|
| 393 | return; |
---|
| 394 | |
---|
| 395 | layer->SetType(type); |
---|
| 396 | |
---|
| 397 | if (IsPlaced(multilayerLabel)) |
---|
| 398 | NotifyChange(); |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | const G4String & RadmonDetectorLayout :: GetLayerType(const G4String & multilayerLabel, const G4String & layerLabel) const |
---|
| 404 | { |
---|
| 405 | const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 406 | |
---|
| 407 | if (!layer) |
---|
| 408 | return GetNullStr(); |
---|
| 409 | |
---|
| 410 | return layer->GetType(); |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | G4int RadmonDetectorLayout :: GetLayerNAttributes(const G4String & multilayerLabel, const G4String & layerLabel) const |
---|
| 418 | { |
---|
| 419 | const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 420 | |
---|
| 421 | if (!layer) |
---|
| 422 | return 0; |
---|
| 423 | |
---|
| 424 | return layer->GetNAttributes(); |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | |
---|
| 428 | |
---|
| 429 | const G4String & RadmonDetectorLayout :: GetLayerAttributeName(const G4String & multilayerLabel, const G4String & layerLabel, G4int index) const |
---|
| 430 | { |
---|
| 431 | const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 432 | |
---|
| 433 | if (!layer) |
---|
| 434 | return GetNullStr(); |
---|
| 435 | |
---|
| 436 | return layer->GetAttributeName(index); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | void RadmonDetectorLayout :: SetLayerAttribute(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & attributeName, const G4String & attributeValue) |
---|
| 442 | { |
---|
| 443 | if (attributeName=="") |
---|
| 444 | { |
---|
| 445 | G4cout << "RadmonDetectorLayout::FindPlacement: \"\" is not a valid attribute name." << G4endl; |
---|
| 446 | return; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 450 | |
---|
| 451 | if (!layer) |
---|
| 452 | return; |
---|
| 453 | |
---|
| 454 | if (layer->GetAttribute(attributeName, attributeValue+"#")==attributeValue) |
---|
| 455 | return; |
---|
| 456 | |
---|
| 457 | layer->SetAttribute(attributeName, attributeValue); |
---|
| 458 | |
---|
| 459 | if (IsPlaced(multilayerLabel)) |
---|
| 460 | NotifyChange(); |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | |
---|
| 464 | |
---|
| 465 | const G4String RadmonDetectorLayout :: GetLayerAttribute(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & attributeName, const G4String & defaultAttributeValue) const |
---|
| 466 | { |
---|
| 467 | const RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 468 | |
---|
| 469 | if (!layer) |
---|
| 470 | return G4String(""); |
---|
| 471 | |
---|
| 472 | return layer->GetAttribute(attributeName, defaultAttributeValue); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | |
---|
| 476 | |
---|
| 477 | void RadmonDetectorLayout :: ClearLayerAttribute(const G4String & multilayerLabel, const G4String & layerLabel, const G4String & attributeName) |
---|
| 478 | { |
---|
| 479 | RadmonDetectorLayerLayout * layer(FindLayer(multilayerLabel, layerLabel)); |
---|
| 480 | |
---|
| 481 | if (!layer) |
---|
| 482 | return; |
---|
| 483 | |
---|
| 484 | if (!layer->ExistsAttribute(attributeName)) |
---|
| 485 | { |
---|
| 486 | G4cout << "RadmonDetectorLayout::ClearLayerAttribute: Attribute \"" << attributeName << "\" missing in layer \"" << layerLabel << "\" of multilayer \"" << multilayerLabel << "\"." << G4endl; |
---|
| 487 | return; |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | layer->ClearAttribute(attributeName); |
---|
| 491 | |
---|
| 492 | if (IsPlaced(multilayerLabel)) |
---|
| 493 | NotifyChange(); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | |
---|
| 498 | |
---|
| 499 | |
---|
| 500 | void RadmonDetectorLayout :: CreatePlacement(const G4String & placementLabel, const G4String & multilayerName) |
---|
| 501 | { |
---|
| 502 | if (multilayerPlacementsCollection.ExistsPlacementByLabel(placementLabel)) |
---|
| 503 | { |
---|
| 504 | G4cout << "RadmonDetectorLayout::CreateMultilayer: Placement \"" << placementLabel << "\" just exists." << G4endl; |
---|
| 505 | return; |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | RadmonDetectorMultilayerPlacementLayout & placement(multilayerPlacementsCollection.CreatePlacement()); |
---|
| 509 | placement.SetLabel(placementLabel); |
---|
| 510 | placement.SetMultilayerLabel(multilayerName); |
---|
| 511 | |
---|
| 512 | NotifyChange(); |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | |
---|
| 516 | |
---|
| 517 | G4int RadmonDetectorLayout :: GetNPlacements() const |
---|
| 518 | { |
---|
| 519 | return multilayerPlacementsCollection.GetNPlacements(); |
---|
| 520 | } |
---|
| 521 | |
---|
| 522 | |
---|
| 523 | |
---|
| 524 | const G4String & RadmonDetectorLayout :: GetPlacementLabel(G4int index) const |
---|
| 525 | { |
---|
| 526 | return multilayerPlacementsCollection.GetPlacement(index).GetLabel(); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | |
---|
| 531 | void RadmonDetectorLayout :: RemovePlacement(const G4String & placementLabel) |
---|
| 532 | { |
---|
| 533 | if (!multilayerPlacementsCollection.ExistsPlacementByLabel(placementLabel)) |
---|
| 534 | { |
---|
| 535 | G4cout << "RadmonDetectorLayout::CreateMultilayer: Placement \"" << placementLabel << "\" does not exist." << G4endl; |
---|
| 536 | return; |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | multilayerPlacementsCollection.RemovePlacementByLabel(placementLabel); |
---|
| 540 | NotifyChange(); |
---|
| 541 | } |
---|
| 542 | |
---|
| 543 | |
---|
| 544 | |
---|
| 545 | |
---|
| 546 | |
---|
| 547 | const G4String & RadmonDetectorLayout :: GetPlacementMultilayerType(const G4String & placementLabel) const |
---|
| 548 | { |
---|
| 549 | const RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 550 | |
---|
| 551 | if (!placement) |
---|
| 552 | return GetNullStr(); |
---|
| 553 | |
---|
| 554 | return placement->GetMultilayerLabel(); |
---|
| 555 | } |
---|
| 556 | |
---|
| 557 | |
---|
| 558 | |
---|
| 559 | void RadmonDetectorLayout :: SetPlacementPosition(const G4String & placementLabel, const G4ThreeVector & position) |
---|
| 560 | { |
---|
| 561 | RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 562 | |
---|
| 563 | if (!placement) |
---|
| 564 | return; |
---|
| 565 | |
---|
| 566 | placement->SetAbsolutePosition(position); |
---|
| 567 | NotifyChange(); |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | |
---|
| 571 | |
---|
| 572 | const G4ThreeVector & RadmonDetectorLayout :: GetPlacementPosition(const G4String & placementLabel) const |
---|
| 573 | { |
---|
| 574 | const RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 575 | |
---|
| 576 | if (!placement) |
---|
| 577 | return GetNullPosition(); |
---|
| 578 | |
---|
| 579 | return placement->GetAbsolutePosition(); |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | |
---|
| 583 | |
---|
| 584 | void RadmonDetectorLayout :: SetPlacementPosition(const G4String & placementLabel, const G4String & originLabel, const G4ThreeVector & offset) |
---|
| 585 | { |
---|
| 586 | RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 587 | |
---|
| 588 | if (!placement) |
---|
| 589 | return; |
---|
| 590 | |
---|
| 591 | const RadmonDetectorMultilayerPlacementLayout * origin(FindPlacement(originLabel)); |
---|
| 592 | if (!origin) |
---|
| 593 | return; |
---|
| 594 | |
---|
| 595 | placement->SetRelativePosition(*origin, offset); |
---|
| 596 | NotifyChange(); |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | |
---|
| 600 | |
---|
| 601 | void RadmonDetectorLayout :: SetPlacementRotation(const G4String & placementLabel, const G4RotationMatrix & rotation) |
---|
| 602 | { |
---|
| 603 | RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 604 | |
---|
| 605 | if (!placement) |
---|
| 606 | return; |
---|
| 607 | |
---|
| 608 | placement->SetAbsoluteRotation(rotation); |
---|
| 609 | NotifyChange(); |
---|
| 610 | } |
---|
| 611 | |
---|
| 612 | |
---|
| 613 | |
---|
| 614 | const G4RotationMatrix & RadmonDetectorLayout :: GetPlacementRotation(const G4String & placementLabel) const |
---|
| 615 | { |
---|
| 616 | const RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 617 | |
---|
| 618 | if (!placement) |
---|
| 619 | return GetNullRotationMatrix(); |
---|
| 620 | |
---|
| 621 | return placement->GetAbsoluteRotation(); |
---|
| 622 | } |
---|
| 623 | |
---|
| 624 | |
---|
| 625 | |
---|
| 626 | void RadmonDetectorLayout :: SetPlacementRotation(const G4String & placementLabel, const G4String & originLabel, const G4RotationMatrix & relativeRotation) |
---|
| 627 | { |
---|
| 628 | RadmonDetectorMultilayerPlacementLayout * placement(FindPlacement(placementLabel)); |
---|
| 629 | |
---|
| 630 | if (!placement) |
---|
| 631 | return; |
---|
| 632 | |
---|
| 633 | const RadmonDetectorMultilayerPlacementLayout * origin(FindPlacement(originLabel)); |
---|
| 634 | if (!origin) |
---|
| 635 | return; |
---|
| 636 | |
---|
| 637 | placement->SetRelativeRotation(*origin, relativeRotation); |
---|
| 638 | NotifyChange(); |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | |
---|
| 642 | |
---|
| 643 | |
---|
| 644 | |
---|
| 645 | void RadmonDetectorLayout :: DumpLayout(std::ostream & out) const |
---|
| 646 | { |
---|
| 647 | const G4String indent(" - "); |
---|
| 648 | |
---|
| 649 | out << "- Environment\n"; |
---|
| 650 | environment.DumpLayout(out, indent); |
---|
| 651 | |
---|
| 652 | out << "\n- Multilayers\n"; |
---|
| 653 | multilayersCollection.DumpLayout(out, indent); |
---|
| 654 | |
---|
| 655 | out << "\n- Placements\n"; |
---|
| 656 | multilayerPlacementsCollection.DumpLayout(out, indent); |
---|
| 657 | } |
---|
| 658 | |
---|
| 659 | |
---|
| 660 | |
---|
| 661 | |
---|
| 662 | |
---|
| 663 | G4bool RadmonDetectorLayout :: Load(std::istream & /*in*/) |
---|
| 664 | { |
---|
| 665 | // TO BE DONE |
---|
| 666 | G4cout << "RadmonDetectorLayout::Load(): PLEASE CHECK" << G4endl; |
---|
| 667 | |
---|
| 668 | return false; |
---|
| 669 | } |
---|
| 670 | |
---|
| 671 | |
---|
| 672 | |
---|
| 673 | G4bool RadmonDetectorLayout :: Save(std::ostream & /*out*/) const |
---|
| 674 | { |
---|
| 675 | // TO BE DONE |
---|
| 676 | G4cout << "RadmonDetectorLayout::Save(): PLEASE CHECK" << G4endl; |
---|
| 677 | |
---|
| 678 | return false; |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | |
---|
| 682 | |
---|
| 683 | |
---|
| 684 | |
---|
| 685 | inline bool RadmonDetectorLayout :: IsPlaced(const G4String & multilayerLabel) |
---|
| 686 | { |
---|
| 687 | G4int n(multilayerPlacementsCollection.GetNPlacements()); |
---|
| 688 | |
---|
| 689 | while (n>0) |
---|
| 690 | { |
---|
| 691 | n--; |
---|
| 692 | |
---|
| 693 | if (multilayerPlacementsCollection.GetPlacement(n).GetMultilayerLabel()==multilayerLabel) |
---|
| 694 | return true; |
---|
| 695 | } |
---|
| 696 | |
---|
| 697 | return false; |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | |
---|
| 701 | |
---|
| 702 | inline RadmonDetectorMultilayerLayout * RadmonDetectorLayout :: FindMultilayer(const G4String & multilayerLabel) |
---|
| 703 | { |
---|
| 704 | if (!multilayersCollection.ExistsMultilayerByLabel(multilayerLabel)) |
---|
| 705 | { |
---|
| 706 | G4cout << "RadmonDetectorLayout::FindMultilayer: Multilayer \"" << multilayerLabel << "\" does not exist." << G4endl; |
---|
| 707 | return 0; |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | return &multilayersCollection.FindMultilayerByLabel(multilayerLabel); |
---|
| 711 | } |
---|
| 712 | |
---|
| 713 | |
---|
| 714 | |
---|
| 715 | inline const RadmonDetectorMultilayerLayout * RadmonDetectorLayout :: FindMultilayer(const G4String & multilayerLabel) const |
---|
| 716 | { |
---|
| 717 | return const_cast<RadmonDetectorLayout *>(this)->FindMultilayer(multilayerLabel); |
---|
| 718 | } |
---|
| 719 | |
---|
| 720 | |
---|
| 721 | |
---|
| 722 | inline RadmonDetectorMultilayerPlacementLayout * RadmonDetectorLayout :: FindPlacement(const G4String & placementLabel) |
---|
| 723 | { |
---|
| 724 | if (!multilayerPlacementsCollection.ExistsPlacementByLabel(placementLabel)) |
---|
| 725 | { |
---|
| 726 | G4cout << "RadmonDetectorLayout::FindPlacement: Placement \"" << placementLabel << "\" does not exist." << G4endl; |
---|
| 727 | return 0; |
---|
| 728 | } |
---|
| 729 | |
---|
| 730 | return & multilayerPlacementsCollection.FindPlacementByLabel(placementLabel); |
---|
| 731 | } |
---|
| 732 | |
---|
| 733 | |
---|
| 734 | |
---|
| 735 | inline const RadmonDetectorMultilayerPlacementLayout * RadmonDetectorLayout :: FindPlacement(const G4String & placementLabel) const |
---|
| 736 | { |
---|
| 737 | return const_cast<RadmonDetectorLayout *>(this)->FindPlacement(placementLabel); |
---|
| 738 | } |
---|
| 739 | |
---|
| 740 | |
---|
| 741 | |
---|
| 742 | inline RadmonDetectorLayerLayout * RadmonDetectorLayout :: FindLayer(const G4String & multilayerLabel, const G4String & layerLabel) |
---|
| 743 | { |
---|
| 744 | RadmonDetectorMultilayerLayout * multilayer(FindMultilayer(multilayerLabel)); |
---|
| 745 | |
---|
| 746 | if (!multilayer) |
---|
| 747 | return 0; |
---|
| 748 | |
---|
| 749 | if (!multilayer->ExistsLayerByLabel(layerLabel)) |
---|
| 750 | { |
---|
| 751 | G4cout << "RadmonDetectorLayout::FindLayer: Layer \"" << layerLabel << "\" does not exist in multilayer \"" << multilayerLabel << "\"." << G4endl; |
---|
| 752 | return 0; |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | return &multilayer->FindLayerByLabel(layerLabel); |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | |
---|
| 759 | |
---|
| 760 | inline const RadmonDetectorLayerLayout * RadmonDetectorLayout :: FindLayer(const G4String & multilayerLabel, const G4String & layerLabel) const |
---|
| 761 | { |
---|
| 762 | return const_cast<RadmonDetectorLayout *>(this)->FindLayer(multilayerLabel, layerLabel); |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | |
---|
| 766 | |
---|
| 767 | |
---|
| 768 | |
---|
| 769 | inline G4String & RadmonDetectorLayout :: GetNullStr() const |
---|
| 770 | { |
---|
| 771 | static G4String *nullStr(0); |
---|
| 772 | |
---|
| 773 | if (nullStr==0) |
---|
| 774 | nullStr=new G4String(""); |
---|
| 775 | |
---|
| 776 | return *nullStr; |
---|
| 777 | } |
---|
| 778 | |
---|
| 779 | |
---|
| 780 | |
---|
| 781 | inline G4ThreeVector & RadmonDetectorLayout :: GetNullPosition() const |
---|
| 782 | { |
---|
| 783 | static G4ThreeVector *nullPosition(0); |
---|
| 784 | |
---|
| 785 | if (nullPosition==0) |
---|
| 786 | nullPosition=new G4ThreeVector(); |
---|
| 787 | |
---|
| 788 | return *nullPosition; |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | |
---|
| 792 | |
---|
| 793 | inline G4RotationMatrix & RadmonDetectorLayout :: GetNullRotationMatrix() const |
---|
| 794 | { |
---|
| 795 | static G4RotationMatrix * nullRotationMatrix(0); |
---|
| 796 | |
---|
| 797 | if (nullRotationMatrix==0) |
---|
| 798 | nullRotationMatrix=new G4RotationMatrix(); |
---|
| 799 | |
---|
| 800 | return *nullRotationMatrix; |
---|
| 801 | } |
---|