source: trunk/source/geometry/volumes/src/G4ReflectionFactory.cc@ 892

Last change on this file since 892 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

File size: 26.2 KB
RevLine 
[831]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// $Id: G4ReflectionFactory.cc,v 1.6 2007/05/11 13:58:35 gcosmo Exp $
[850]28// GEANT4 tag $Name: HEAD $
[831]29//
30//
31// Class G4ReflectionFactory Implementation
32//
33// Decomposition of a general transformation
34// that can include reflection in a "reflection-free" transformation:
35//
36// x(inM') = TG*x(inM) TG - general transformation
37// = T*(R*x(inM)) T - "reflection-free" transformation
38// = T* x(inReflM)
39//
40// Daughters transformation:
41// When a volume V containing daughter D with transformation TD
42// is placed in mother M with a general tranformation TGV,
43// the TGV is decomposed,
44// new reflected volume ReflV containing a new daughter ReflD
45// with reflected transformation ReflTD is created:
46//
47// x(inV) = TD * x(inD);
48// x(inM) = TGV * x(inV)
49// = TV * R * x(inV)
50// = TV * R * TD * x(inD)
51// = TV * R*TD*R-1 * R*x(inD)
52// = TV * ReflTD * x(inReflD)
53
54// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
55// --------------------------------------------------------------------
56
57#include "G4ReflectionFactory.hh"
58#include "G4ReflectedSolid.hh"
59#include "G4Region.hh"
60#include "G4LogicalVolume.hh"
61#include "G4PVPlacement.hh"
62#include "G4PVReplica.hh"
63#include "G4VPVDivisionFactory.hh"
64#include "G4GeometryTolerance.hh"
65
66G4ReflectionFactory* G4ReflectionFactory::fInstance = 0;
67const G4String G4ReflectionFactory::fDefaultNameExtension = "_refl";
68const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0);
69
70//_____________________________________________________________________________
71
72G4ReflectionFactory* G4ReflectionFactory::Instance()
73{
74 // Static singleton access method.
75 // ---
76
77 if (!fInstance) new G4ReflectionFactory();
78
79 return fInstance;
80}
81
82//_____________________________________________________________________________
83
84G4ReflectionFactory::G4ReflectionFactory()
85 : fVerboseLevel(0),
86 fNameExtension(fDefaultNameExtension)
87{
88 // Protected singleton constructor.
89 // ---
90
91 fScalePrecision = 10.
92 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
93 fInstance = this;
94}
95
96//_____________________________________________________________________________
97
98G4ReflectionFactory::~G4ReflectionFactory()
99{
100}
101
102//
103// public methods
104//
105
106//_____________________________________________________________________________
107
108G4PhysicalVolumesPair
109G4ReflectionFactory::Place( const G4Transform3D& transform3D,
110 const G4String& name,
111 G4LogicalVolume* LV,
112 G4LogicalVolume* motherLV,
113 G4bool isMany,
114 G4int copyNo,
115 G4bool surfCheck)
116{
117 // Evaluates the passed transformation; if it contains reflection
118 // it performs its decomposition, creates new reflected solid and
119 // logical volume (or retrieves them from a map if the reflected
120 // objects were already created), transforms the daughters (if present)
121 // and place it in the given mother.
122 // The result is a pair of physical volumes;
123 // the second physical volume is a placement in a reflected mother
124 // - or 0 if mother LV was not reflected.
125 // ---
126
127 if (fVerboseLevel>0)
128 {
129 G4cout << "Place " << name << " lv " << LV << " "
130 << LV->GetName() << G4endl;
131 }
132
133 // decompose transformation
134 G4Scale3D scale;
135 G4Rotate3D rotation;
136 G4Translate3D translation;
137
138 transform3D.getDecomposition(scale, rotation, translation);
139 G4Transform3D pureTransform3D = translation * rotation;
140
141 //PrintTransform(transform3D);
142 //PrintTransform(pureTransform3D);
143
144 // check that scale correspond to fScale
145 //
146 CheckScale(scale);
147
148 //
149 // reflection IS NOT present in transform3D
150 //
151
152 if (! IsReflection(scale))
153 {
154 if (fVerboseLevel>0)
155 G4cout << "Scale positive" << G4endl;
156
157 G4VPhysicalVolume* pv1
158 = new G4PVPlacement(pureTransform3D, LV, name,
159 motherLV, isMany, copyNo, surfCheck);
160
161 G4VPhysicalVolume* pv2 = 0;
162 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
163 {
164 // if mother was reflected
165 // reflect this LV and place it in reflected mother
166
167 pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
168 ReflectLV(LV, surfCheck), name, reflMotherLV,
169 isMany, copyNo, surfCheck);
170 }
171
172 return G4PhysicalVolumesPair(pv1, pv2);
173 }
174
175 //
176 // reflection IS present in transform3D
177 //
178
179 if (fVerboseLevel>0)
180 G4cout << "scale negative" << G4endl;
181
182 G4VPhysicalVolume* pv1
183 = new G4PVPlacement(pureTransform3D, ReflectLV(LV, surfCheck), name,
184 motherLV, isMany, copyNo, surfCheck);
185
186 G4VPhysicalVolume* pv2 = 0;
187 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
188 {
189
190 // if mother was reflected
191 // place the refLV consituent in reflected mother
192
193 pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
194 LV, name, reflMotherLV, isMany, copyNo, surfCheck);
195 }
196
197 return G4PhysicalVolumesPair(pv1, pv2);
198}
199
200
201//_____________________________________________________________________________
202
203G4PhysicalVolumesPair
204G4ReflectionFactory::Replicate(const G4String& name,
205 G4LogicalVolume* LV,
206 G4LogicalVolume* motherLV,
207 EAxis axis,
208 G4int nofReplicas,
209 G4double width,
210 G4double offset)
211{
212 // Creates replica in given mother.
213 // The result is a pair of physical volumes;
214 // the second physical volume is a replica in a reflected mother
215 // - or 0 if mother LV was not reflected.
216 // ---
217
218 if (fVerboseLevel>0)
219 {
220 G4cout << "Replicate " << name << " lv " << LV << " "
221 << LV->GetName() << G4endl;
222 }
223
224 G4VPhysicalVolume* pv1
225 = new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
226
227 G4VPhysicalVolume* pv2 = 0;
228 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
229 {
230 // if mother was reflected
231 // reflect the LV and replicate it in reflected mother
232
233 pv2 = new G4PVReplica(name, ReflectLV(LV), reflMotherLV,
234 axis, nofReplicas, width, offset);
235 }
236
237 return G4PhysicalVolumesPair(pv1, pv2);
238}
239
240//_____________________________________________________________________________
241
242G4PhysicalVolumesPair
243G4ReflectionFactory::Divide(const G4String& name,
244 G4LogicalVolume* LV,
245 G4LogicalVolume* motherLV,
246 EAxis axis,
247 G4int nofDivisions,
248 G4double width,
249 G4double offset)
250{
251 // Creates division in the given mother.
252 // The result is a pair of physical volumes;
253 // the second physical volume is a division in a reflected mother
254 // or 0 if mother LV was not reflected.
255 // ---
256
257 if (fVerboseLevel>0)
258 {
259 G4cout << "Divide " << name << " lv " << LV << " "
260 << LV->GetName() << G4endl;
261 }
262
263 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
264
265 G4VPhysicalVolume* pv1 = divisionFactory
266 ->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, width, offset);
267
268 G4VPhysicalVolume* pv2 = 0;
269 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
270 {
271 // if mother was reflected
272 // reflect the LV and replicate it in reflected mother
273
274 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
275 axis, nofDivisions, width, offset);
276 }
277
278 return G4PhysicalVolumesPair(pv1, pv2);
279}
280
281
282//_____________________________________________________________________________
283
284G4PhysicalVolumesPair
285G4ReflectionFactory::Divide(const G4String& name,
286 G4LogicalVolume* LV,
287 G4LogicalVolume* motherLV,
288 EAxis axis,
289 G4int nofDivisions,
290 G4double offset)
291{
292 // Creates division in the given mother.
293 // The result is a pair of physical volumes;
294 // the second physical volume is a division in a reflected mother
295 // or 0 if mother LV was not reflected.
296 // ---
297
298 if (fVerboseLevel>0)
299 {
300 G4cout << "Divide " << name << " lv " << LV << " "
301 << LV->GetName() << G4endl;
302 }
303
304 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
305
306 G4VPhysicalVolume* pv1 = divisionFactory
307 ->CreatePVDivision(name, LV, motherLV, axis, nofDivisions, offset);
308
309 G4VPhysicalVolume* pv2 = 0;
310 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
311 {
312 // if mother was reflected
313 // reflect the LV and replicate it in reflected mother
314
315 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
316 axis, nofDivisions, offset);
317 }
318
319 return G4PhysicalVolumesPair(pv1, pv2);
320}
321
322
323//_____________________________________________________________________________
324
325G4PhysicalVolumesPair
326G4ReflectionFactory::Divide(const G4String& name,
327 G4LogicalVolume* LV,
328 G4LogicalVolume* motherLV,
329 EAxis axis,
330 G4double width,
331 G4double offset)
332{
333 // Creates division in the given mother.
334 // The result is a pair of physical volumes;
335 // the second physical volume is a division in a reflected mother
336 // or 0 if mother LV was not reflected.
337 // ---
338
339 if (fVerboseLevel>0)
340 {
341 G4cout << "Divide " << name << " lv " << LV << " "
342 << LV->GetName() << G4endl;
343 }
344
345 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
346
347 G4VPhysicalVolume* pv1 = divisionFactory
348 -> CreatePVDivision(name, LV, motherLV, axis, width, offset);
349
350 G4VPhysicalVolume* pv2 = 0;
351 if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV))
352 {
353 // if mother was reflected
354 // reflect the LV and replicate it in reflected mother
355
356 pv2 = divisionFactory->CreatePVDivision(name, ReflectLV(LV), reflMotherLV,
357 axis, width, offset);
358 }
359
360 return G4PhysicalVolumesPair(pv1, pv2);
361}
362
363
364//
365// private methods
366//
367
368//_____________________________________________________________________________
369
370G4LogicalVolume* G4ReflectionFactory::ReflectLV(G4LogicalVolume* LV,
371 G4bool surfCheck)
372{
373 // Gets/creates the reflected solid and logical volume
374 // and copies + transforms LV daughters.
375 // ---
376
377 G4LogicalVolume* refLV = GetReflectedLV(LV);
378
379 if (!refLV)
380 {
381
382 // create new (reflected) objects
383 //
384 refLV = CreateReflectedLV(LV);
385
386 // process daughters
387 //
388 ReflectDaughters(LV, refLV, surfCheck);
389
390 // check if to be set as root region
391 //
392 if (LV->IsRootRegion())
393 {
394 LV->GetRegion()->AddRootLogicalVolume(refLV);
395 }
396 }
397
398 return refLV;
399}
400
401//_____________________________________________________________________________
402
403G4LogicalVolume* G4ReflectionFactory::CreateReflectedLV(G4LogicalVolume* LV)
404{
405 // Creates the reflected solid and logical volume
406 // and add the logical volumes pair in the maps.
407 // ---
408
409 // consistency check
410 //
411 if (fReflectedLVMap.find(LV) != fReflectedLVMap.end())
412 {
413 G4cerr << "ERROR - G4ReflectionFactory::CreateReflectedLV(..): "
414 << LV->GetName() << G4endl
415 << " Cannot be applied to an already reflected volume !"
416 << G4endl;
417 G4Exception("G4ReflectionFactory::CreateReflectedLV(..)",
418 "NotApplicable", FatalException,
419 "Cannot be applied to a volume already reflected.");
420 }
421
422 G4VSolid* refSolid
423 = new G4ReflectedSolid(LV->GetSolid()->GetName() + fNameExtension,
424 LV->GetSolid(), fScale);
425
426 G4LogicalVolume* refLV
427 = new G4LogicalVolume(refSolid,
428 LV->GetMaterial(),
429 LV->GetName() + fNameExtension,
430 LV->GetFieldManager(),
431 LV->GetSensitiveDetector(),
432 LV->GetUserLimits());
433 refLV->SetVisAttributes(LV->GetVisAttributes()); // vis-attributes
434 refLV->SetBiasWeight(LV->GetBiasWeight()); // biasing weight
435 if (LV->IsRegion())
436 {
437 refLV->SetRegion(LV->GetRegion()); // set a region in case
438 }
439
440 fConstituentLVMap[LV] = refLV;
441 fReflectedLVMap[refLV] = LV;
442
443 return refLV;
444}
445
446//_____________________________________________________________________________
447
448void G4ReflectionFactory::ReflectDaughters(G4LogicalVolume* LV,
449 G4LogicalVolume* refLV,
450 G4bool surfCheck)
451{
452 // Reflects daughters recursively.
453 // ---
454
455 if (fVerboseLevel>0)
456 {
457 G4cout << "G4ReflectionFactory::ReflectDaughters(): "
458 << LV->GetNoDaughters() << " of " << LV->GetName() << G4endl;
459 }
460
461 for (G4int i=0; i<LV->GetNoDaughters(); i++)
462 {
463 G4VPhysicalVolume* dPV = LV->GetDaughter(i);
464
465 if (! dPV->IsReplicated())
466 {
467 ReflectPVPlacement(dPV, refLV, surfCheck);
468 }
469 else if (! dPV->GetParameterisation())
470 {
471 ReflectPVReplica(dPV, refLV);
472 }
473 else if (G4VPVDivisionFactory::Instance() &&
474 G4VPVDivisionFactory::Instance()->IsPVDivision(dPV))
475 {
476 ReflectPVDivision(dPV, refLV);
477 }
478 else
479 {
480 ReflectPVParameterised(dPV, refLV, surfCheck);
481 }
482 }
483}
484
485//_____________________________________________________________________________
486
487void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
488 G4LogicalVolume* refLV,
489 G4bool surfCheck)
490{
491 // Copies and transforms daughter of PVPlacement type of
492 // a constituent volume into a reflected volume.
493 // ---
494
495 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
496
497 // update daughter transformation
498 //
499 G4Transform3D dt(dPV->GetObjectRotationValue(), dPV->GetObjectTranslation());
500 dt = fScale * (dt * fScale.inverse());
501
502 G4LogicalVolume* refDLV;
503
504 if (fVerboseLevel>0)
505 G4cout << "Daughter: " << dPV << " " << dLV->GetName();
506
507 if (!IsReflected(dLV))
508 {
509
510 if (fVerboseLevel>0)
511 G4cout << " will be reflected." << G4endl;
512
513 // get reflected volume if already created //
514 refDLV = GetReflectedLV(dLV);
515
516 if (!refDLV)
517 {
518 // create new daughter solid and logical volume
519 //
520 refDLV = CreateReflectedLV(dLV);
521
522 // recursive call
523 //
524 ReflectDaughters(dLV, refDLV, surfCheck);
525 }
526
527 // create new daughter physical volume
528 // with updated transformation
529
530 new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
531 dPV->IsMany(), dPV->GetCopyNo(), surfCheck);
532
533 }
534 else
535 {
536 if (fVerboseLevel>0)
537 G4cout << " will be reconstitued." << G4endl;
538
539 refDLV = GetConstituentLV(dLV);
540
541 new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
542 dPV->IsMany(), dPV->GetCopyNo(), surfCheck);
543 }
544}
545
546//_____________________________________________________________________________
547
548void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
549 G4LogicalVolume* refLV)
550{
551 // Copies and transforms daughter of PVReplica type of
552 // a constituent volume into a reflected volume.
553 // ---
554
555 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
556
557 // get replication data
558 //
559 EAxis axis;
560 G4int nofReplicas;
561 G4double width;
562 G4double offset;
563 G4bool consuming;
564
565 dPV->GetReplicationData(axis, nofReplicas, width, offset, consuming);
566
567 G4LogicalVolume* refDLV;
568
569 if (fVerboseLevel>0)
570 G4cout << "Daughter: " << dPV << " " << dLV->GetName();
571
572 if (!IsReflected(dLV))
573 {
574 if (fVerboseLevel>0)
575 G4cout << " will be reflected." << G4endl;
576
577 // get reflected volume if already created
578 //
579 refDLV = GetReflectedLV(dLV);
580
581 if (!refDLV)
582 {
583 // create new daughter solid and logical volume
584 //
585 refDLV = CreateReflectedLV(dLV);
586
587 // recursive call
588 //
589 ReflectDaughters(dLV, refDLV);
590 }
591
592 // create new daughter replica
593 //
594 new G4PVReplica(dPV->GetName(), refDLV, refLV,
595 axis, nofReplicas, width, offset);
596 }
597 else
598 {
599 if (fVerboseLevel>0)
600 G4cout << " will be reconstitued." << G4endl;
601
602 refDLV = GetConstituentLV(dLV);
603
604 new G4PVReplica(dPV->GetName(), refDLV, refLV,
605 axis, nofReplicas, width, offset);
606 }
607}
608
609//_____________________________________________________________________________
610
611void G4ReflectionFactory::ReflectPVDivision(G4VPhysicalVolume* dPV,
612 G4LogicalVolume* refLV)
613{
614 // Copies and transforms daughter of PVDivision type of
615 // a constituent volume into a reflected volume.
616 // ---
617
618 G4VPVDivisionFactory* divisionFactory = GetPVDivisionFactory();
619
620 G4LogicalVolume* dLV = dPV->GetLogicalVolume();
621
622 // get parameterisation data
623 //
624 G4VPVParameterisation* param = dPV->GetParameterisation();
625
626 G4LogicalVolume* refDLV;
627
628 if (fVerboseLevel>0)
629 G4cout << "Daughter: " << dPV << " " << dLV->GetName();
630
631 if (!IsReflected(dLV))
632 {
633 if (fVerboseLevel>0)
634 G4cout << " will be reflected." << G4endl;
635
636 // get reflected volume if already created
637 //
638 refDLV = GetReflectedLV(dLV);
639
640 if (!refDLV)
641 {
642 // create new daughter solid and logical volume
643 //
644 refDLV = CreateReflectedLV(dLV);
645
646 // recursive call
647 //
648 ReflectDaughters(dLV, refDLV);
649 }
650
651 // create new daughter replica
652 //
653 divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
654 }
655 else
656 {
657 if (fVerboseLevel>0)
658 G4cout << " will be reconstitued." << G4endl;
659
660 refDLV = GetConstituentLV(dLV);
661
662 divisionFactory->CreatePVDivision(dPV->GetName(), refDLV, refLV, param);
663 }
664}
665
666//_____________________________________________________________________________
667
668void G4ReflectionFactory::ReflectPVParameterised(G4VPhysicalVolume* dPV,
669 G4LogicalVolume*, G4bool)
670{
671 // Not implemented.
672 // Should copy and transform daughter of PVReplica type of
673 // a constituent volume into a reflected volume.
674 // ---
675
676 G4cerr << "ERROR - G4ReflectionFactory::ReflectPVParameterised(...): "
677 << dPV->GetName() << G4endl
678 << " Reflection of parameterised volumes "
679 << "is not yet implemented." << G4endl;
680 G4Exception("G4ReflectionFactory::ReflectPVParameterised(...)",
681 "NotImplemented", FatalException,
682 "Sorry, not yet implemented.");
683}
684
685//_____________________________________________________________________________
686
687G4LogicalVolume*
688G4ReflectionFactory::GetConstituentLV(G4LogicalVolume* reflLV) const
689{
690 // Returns the consituent volume of the given reflected volume,
691 // 0 if the given reflected volume was not found.
692 // ---
693
694 LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
695
696 if (it == fReflectedLVMap.end()) return 0;
697
698 return (*it).second;
699}
700
701//_____________________________________________________________________________
702
703G4LogicalVolume*
704G4ReflectionFactory::GetReflectedLV(G4LogicalVolume* lv) const
705{
706 // Returns the reflected volume of the given consituent volume,
707 // 0 if the given volume was not reflected.
708 // ---
709
710 LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
711
712 if (it == fConstituentLVMap.end()) return 0;
713
714 return (*it).second;
715}
716
717//_____________________________________________________________________________
718
719G4bool G4ReflectionFactory::IsConstituent(G4LogicalVolume* lv) const
720{
721 // Returns true if the given volume has been already reflected
722 // (is in the map of constituent volumes).
723 // ---
724
725 return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
726}
727
728//_____________________________________________________________________________
729
730G4bool G4ReflectionFactory::IsReflected(G4LogicalVolume* lv) const
731{
732 // Returns true if the given volume is a reflected volume
733 // (is in the map reflected volumes).
734 // ---
735
736 return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
737}
738
739//_____________________________________________________________________________
740
741G4bool G4ReflectionFactory::IsReflection(const G4Scale3D& scale) const
742{
743 // Returns true if the scale is negative, false otherwise.
744 // ---
745
746 if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
747 return true;
748 else
749 return false;
750}
751
752//_____________________________________________________________________________
753
754const G4ReflectedVolumesMap&
755G4ReflectionFactory::GetReflectedVolumesMap() const
756{
757 return fReflectedLVMap;
758}
759
760//_____________________________________________________________________________
761
762void G4ReflectionFactory::PrintConstituentLVMap()
763{
764 // temporary - for debugging purpose
765 // ---
766
767 LogicalVolumesMapIterator it;
768 for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); it++)
769 {
770 G4cout << "lv: " << (*it).first << " lv_refl: " << (*it).second << G4endl;
771 }
772 G4cout << G4endl;
773}
774
775//_____________________________________________________________________________
776
777void G4ReflectionFactory::CheckScale(const G4Scale3D& scale) const
778{
779 // Check if scale correspond to fScale,
780 // if not give exception.
781 // ---
782
783 if (!IsReflection(scale)) return;
784
785 G4double diff = 0.;
786 for (G4int i=0; i<4; i++)
787 for (G4int j=0; j<4; j++)
788 diff += std::abs(scale(i,j) - fScale(i,j));
789
790 if (diff > fScalePrecision)
791 {
792 G4cerr << "ERROR - G4ReflectionFactory::CheckScale(..)" << G4endl
793 << " Unexpected scale. Difference: " << diff << G4endl;
794 G4Exception("G4ReflectionFactory::CheckScale(..)",
795 "WrongArgumentValue", FatalException,
796 "Unexpected scale in input !");
797 }
798}
799
800//_____________________________________________________________________________
801
802G4VPVDivisionFactory* G4ReflectionFactory::GetPVDivisionFactory() const
803{
804 // Returns the G4PVDivisionFactory instance if it exists,
805 // otherwise gives exception
806 // ---
807
808 G4VPVDivisionFactory* divisionFactory = G4VPVDivisionFactory::Instance();
809 if (!divisionFactory)
810 {
811 G4cerr << "ERROR - G4ReflectionFactory::GetPVDivisionFactory()" << G4endl
812 << " It has been requested to reflect divided volumes."
813 << G4endl
814 << " In this case, it is required to instantiate a concrete"
815 << G4endl
816 << " factory G4PVDivisionFactory in your program -before-"
817 << G4endl
818 << " executing the reflection !" << G4endl;
819 G4Exception("G4ReflectionFactory::GetPVDivisionFactory()",
820 "WrongSetup", FatalException,
821 "A concrete G4PVDivisionFactory instantiated is required !");
822 }
823
824 return divisionFactory;
825}
826
827//_____________________________________________________________________________
828
829void G4ReflectionFactory::SetScalePrecision(G4double scaleValue)
830{
831 fScalePrecision = scaleValue;
832}
833
834//_____________________________________________________________________________
835
836G4double G4ReflectionFactory::GetScalePrecision() const
837{
838 return fScalePrecision;
839}
840
841//_____________________________________________________________________________
842
843void G4ReflectionFactory::SetVerboseLevel(G4int verboseLevel)
844{
845 fVerboseLevel = verboseLevel;
846}
847
848//_____________________________________________________________________________
849
850G4int G4ReflectionFactory::GetVerboseLevel() const
851{
852 return fVerboseLevel;
853}
854
855//_____________________________________________________________________________
856
857void G4ReflectionFactory::SetVolumesNameExtension(const G4String& nameExtension)
858{
859 fNameExtension = nameExtension;
860}
861
862//_____________________________________________________________________________
863
864G4String G4ReflectionFactory::GetVolumesNameExtension() const
865{
866 return fNameExtension;
867}
868
869/*
870 // placement with decomposed transformation
871
872 G4VPhysicalVolume* pv1
873 = new G4PVPlacement(new G4RotationMatrix(rotation.getRotation().inverse()),
874 translation.getTranslation(),
875 refLV, name, motherLV, isMany, copyNo);
876*/
Note: See TracBrowser for help on using the repository browser.