]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliDetSwitch.cxx
Add const to SolenoidField() method for correct overwriting from the parent class
[u/mrichter/AliRoot.git] / AliGeant4 / AliDetSwitch.cxx
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliDetSwitch
7 // ------------------
8 // See the class description in the header file.
9
10 #include "AliDetSwitch.h"
11 #include "AliGlobals.h"
12
13 //_____________________________________________________________________________
14 AliDetSwitch::AliDetSwitch(G4String detName, G4int nofVersions, 
15                            G4int defaultVersion, AliModuleType modType)
16   : fDetName(detName),
17     fNofVersions(nofVersions),
18     fDefaultVersion(defaultVersion),
19     fType(modType),
20     fSwitchedVersion(-1)
21 {
22 //
23 }
24
25 //_____________________________________________________________________________
26 AliDetSwitch::AliDetSwitch(const AliDetSwitch& right) {
27 //
28   // copy stuff
29   *this = right;
30 }
31
32 //_____________________________________________________________________________
33 AliDetSwitch::~AliDetSwitch(){
34 //
35 }
36
37 // operators
38
39 //_____________________________________________________________________________
40 AliDetSwitch& AliDetSwitch::operator=(const AliDetSwitch& right)
41 {    
42   // check assignement to self
43   if (this == &right) return *this;
44
45   fDetName = right.fDetName;
46   fNofVersions = right.fNofVersions;
47   fDefaultVersion = right.fDefaultVersion;
48   fSwitchedVersion = right.fSwitchedVersion;
49   fType = right.fType;
50   
51   return *this;
52 }
53
54 //_____________________________________________________________________________
55 G4int AliDetSwitch::operator==(const AliDetSwitch& right) const
56 {    
57 //
58   G4int returnValue = 0;
59   if (fDetName == right.fDetName )
60      returnValue = 1;
61
62   return returnValue;  
63 }
64
65 //_____________________________________________________________________________
66 G4int AliDetSwitch::operator!=(const AliDetSwitch& right) const
67
68 //   
69   G4int returnValue = 1;
70   if (*this == right) returnValue = 0; 
71   
72   return returnValue;
73 }
74   
75 // public methods
76
77 //_____________________________________________________________________________
78 void AliDetSwitch::SwitchOn(G4int iVersion)
79 {
80 // Switchs on the iVersion version.
81 // ---
82
83   if ((iVersion < 0) || (iVersion >= fNofVersions)) {
84     G4String text = "Wrong version number for ";
85     text = text + fDetName + ".";
86     AliGlobals::Exception(text);
87   }  
88    
89   fSwitchedVersion = iVersion;
90 }
91
92 //_____________________________________________________________________________
93 void AliDetSwitch::SwitchOnDefault()
94 {
95 // Switchs on the default version.
96 // ---
97
98   fSwitchedVersion = fDefaultVersion;
99 }
100
101 //_____________________________________________________________________________
102 void AliDetSwitch::SwitchOff()
103 {
104 // No version is switched on.
105 // ---
106
107   fSwitchedVersion = -1;
108 }