]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
copy constructor changed with usage of = operator
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 May 2001 10:08:08 +0000 (10:08 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 May 2001 10:08:08 +0000 (10:08 +0000)
13 files changed:
AliGeant4/AliColour.cxx
AliGeant4/AliDetSwitch.cxx
AliGeant4/AliGunParticle.cxx
AliGeant4/AliLVStructure.cxx
AliGeant4/AliLegoSensitiveDetector.cxx
AliGeant4/AliModuleConstruction.cxx
AliGeant4/AliMoreModulesConstruction.cxx
AliGeant4/AliParticleGun.cxx
AliGeant4/AliSensitiveDetector.cxx
AliGeant4/AliSingleModuleConstruction.cxx
TGeant4/TG4G3ControlVector.cxx
TGeant4/TG4G3CutVector.cxx
TGeant4/TG4Limits.cxx

index 3f33a8abf0b6176d1e03b3401de9997ce5f3746d..eeeddc1415498b6d7981692e90049289c816fda7 100644 (file)
@@ -26,10 +26,8 @@ AliColour::AliColour(G4String name, G4double red, G4double blue, G4double green)
 
 AliColour::AliColour(const AliColour& right) {
 //
-  fName = right.fName;
-  fRed = right.fRed;
-  fBlue = right.fBlue;
-  fGreen = right.fGreen;
+  // copy stuff
+  *this = right;
 }
 
 AliColour::~AliColour() {
index 7525dac0539276e3d2aa9fa8192516b6ddf4aba6..4bff2ee1cdb578d5fa3975b3893a4de48a7cfa04 100644 (file)
@@ -22,13 +22,8 @@ AliDetSwitch::AliDetSwitch(G4String detName, G4int nofVersions,
 
 AliDetSwitch::AliDetSwitch(const AliDetSwitch& right) {
 //
-  fDetName = right.fDetName;
-  fNofVersions = right.fNofVersions;
-  fDefaultVersion = right.fDefaultVersion;
-  fPPRVersion = right.fPPRVersion;
-  fIsStandalone = right.fIsStandalone;
-  fType = right.fType;
-  fSwitchedVersion = right.fSwitchedVersion;
+  // copy stuff
+  *this = right;
 }
 
 AliDetSwitch::~AliDetSwitch(){
index f47bce889e631dd18ef6a86b7071f61cbc257728..113997b7cdbdab01e181ae7a879d9b36bf6ab3df 100644 (file)
@@ -47,11 +47,8 @@ AliGunParticle::AliGunParticle( G4ParticleDefinition* particleDef,
 
 AliGunParticle::AliGunParticle(const AliGunParticle& right) {
 //
-  fParticleDefinition = right.fParticleDefinition;
-  fParticleMomentum = right.fParticleMomentum;
-  fPosition = right.fPosition; 
-  fTime = right.fTime;
-  fPolarization = right.fPolarization; 
+  // copy stuff
+  *this = right;
 }
 
 AliGunParticle::~AliGunParticle() {
index 4a4a138e27f185a29c884ceeb77dcd7d88c57e51..d9ac1ba81d6e44de39ff4bf2e54d85882033cb5d 100644 (file)
@@ -31,25 +31,8 @@ AliLVStructure::AliLVStructure(G4String path)
 
 AliLVStructure::AliLVStructure(const AliLVStructure& right)
 {
-  // copy vector of structures
-  fStructures.clearAndDestroy();
-  G4int i;
-  for (i=0; i<right.fStructures.entries(); i++) {
-    // new full structure tree has to be created
-    AliLVStructure* rhsStructure = right.fStructures[i];
-    fStructures.insert(new AliLVStructure(*rhsStructure)); 
-  }  
-  
-  // copy vector of logical volumes
-  fLogicalVolumes.clear();
-  for (i=0; i<right.fLogicalVolumes.entries(); i++) {
-    G4LogicalVolume* rhsLV = right.fLogicalVolumes[i];
-    fLogicalVolumes.insert(rhsLV); 
-  }  
-  
-  fPathName = right.fPathName;
-  fDirName = right.fPathName;
-  fVerboseLevel = right.fVerboseLevel;
+  // copy stuff
+  *this = right;
 }
 
 AliLVStructure::AliLVStructure() {
index e188729072132d2e2f7e6b88d3fde5896e06484f..5d950b1c4d6ef94a53bc2866043085325c820417 100644 (file)
@@ -21,8 +21,8 @@ AliLegoSensitiveDetector::AliLegoSensitiveDetector(
   : TG4VSensitiveDetector(right)                            
 {
 //
-  fLego = right.fLego;
-  fStandardSD = right.fStandardSD;
+  // copy stuff
+  *this = right;
 }
 
 AliLegoSensitiveDetector::AliLegoSensitiveDetector() {
index eb7685b09fef7978d2b9700c4113f8072ef8d354..4a8c8b96782c10d96c72c18492f6251883fe9fdf 100644 (file)
@@ -35,18 +35,11 @@ AliModuleConstruction::AliModuleConstruction(G4String moduleName)
 AliModuleConstruction::AliModuleConstruction(const AliModuleConstruction& right)
 {
 //
-  fModuleName = right.fModuleName; 
-  fModuleFrameName = right.fModuleFrameName;
-  fModuleFrameLV = right.fModuleFrameLV;
-  fAliModule = right.fAliModule;
-  fReadGeometry = right.fReadGeometry;
-  fWriteGeometry = right.fWriteGeometry;
-  fDataFilePath = right.fDataFilePath;
-
-  // new messenger
-  G4String moduleName = fModuleName;
-  moduleName.toLower();
-  fMessenger = new AliModuleConstructionMessenger(this, moduleName);
+  // allocation in assignement operator
+  fMessenger = 0;
+  
+  // copy stuff
+  *this = right;
 }
 
 AliModuleConstruction::AliModuleConstruction()
@@ -85,6 +78,12 @@ AliModuleConstruction::operator=(const AliModuleConstruction& right)
   fWriteGeometry = right.fWriteGeometry;
   fDataFilePath = right.fDataFilePath;
 
+  // new messenger
+  if (fMessenger) delete fMessenger;
+  G4String moduleName = fModuleName;
+  moduleName.toLower();
+  fMessenger = new AliModuleConstructionMessenger(this, moduleName);
+
   return *this;
 }
 
index 60a7195647913f6bbf3daee07b84fd10b941b9df..147e91d405239235d1fa3c4b6cc8b6c7d5827c58 100644 (file)
@@ -24,20 +24,8 @@ AliMoreModulesConstruction::AliMoreModulesConstruction() {
 AliMoreModulesConstruction::AliMoreModulesConstruction(
                                const AliMoreModulesConstruction& right)
 {
-  // delete current module constructions
-  fModuleConstructionVector.erase(
-    fModuleConstructionVector.begin(), fModuleConstructionVector.end());
-    
-  // create new module constructions   
-  G4int nofModules = right.fModuleConstructionVector.size();
-  for (G4int i=0; i<nofModules; i++) {
-    G4String name = right.fModuleConstructionVector[i]->GetDetName();
-    G4int version = right.fModuleConstructionVector[i]->GetVersion();
-    AliModuleType type = right.fModuleConstructionVector[i]->GetType();
-    AddModule(name, version, type);
-  }  
-  
-  fSDManager = right.fSDManager;
+  // copy stuff
+  *this = right;
 }  
                               
 
@@ -68,7 +56,7 @@ AliMoreModulesConstruction::operator=(const AliMoreModulesConstruction& right)
     AliModuleType type = right.fModuleConstructionVector[i]->GetType();
     AddModule(name, version, type);
   }  
-  
+
   fSDManager = right.fSDManager;
 
   return *this;  
index b27be2618b15083aafb42900fd63a8bd3cadd88c..b3fd5b57e6d2a74efef53efebca1519b8451076a 100644 (file)
@@ -19,16 +19,13 @@ AliParticleGun::AliParticleGun() {
 }
 
 AliParticleGun::AliParticleGun(const AliParticleGun& right)
+  : G4VPrimaryGenerator(right)
 {
-  // particles vector
-  fGunParticlesVector.clearAndDestroy();
-  for (G4int i=0; i<right.fGunParticlesVector.entries(); i++) {
-    AliGunParticle* rhsParticle = right.fGunParticlesVector[i];
-    AliGunParticle* newParticle = new AliGunParticle(*rhsParticle);
-    fGunParticlesVector.insert(newParticle);
-  }  
-
+  // allocation
   fMessenger = new AliParticleGunMessenger(this);
+
+  // copy stuff
+  *this = right;
 }
 
 AliParticleGun::~AliParticleGun() {
@@ -44,6 +41,9 @@ AliParticleGun& AliParticleGun::operator=(const AliParticleGun& right)
   // check assignement to self
   if (this == &right) return *this;
 
+  // base class assignment
+  this->G4VPrimaryGenerator::operator=(right);
+
   // particles vector
   fGunParticlesVector.clearAndDestroy();
   for (G4int i=0; i<right.fGunParticlesVector.entries(); i++) {
@@ -51,7 +51,7 @@ AliParticleGun& AliParticleGun::operator=(const AliParticleGun& right)
     AliGunParticle* newParticle = new AliGunParticle(*rhsParticle);
     fGunParticlesVector.insert(newParticle);
   }
-  
+
   return *this;  
 }
   
index 30a167cc46fe85a1221a78f97f73df52aa18d9ab..b250ef47bb5a29e7a6eea31986c75d659e27c09c 100644 (file)
@@ -33,7 +33,8 @@ AliSensitiveDetector::AliSensitiveDetector(const AliSensitiveDetector& right)
   : TG4VSensitiveDetector(right)
 {
 //
-  fModule = right.fModule;
+  // copy stuff
+  *this = right;
 }  
   
 AliSensitiveDetector::AliSensitiveDetector(){
index 69cb80761f250dc2579165bfa2c4fa70981b8605..108a75409f9729581287c18d29631ec61fdaa4c2 100644 (file)
@@ -45,15 +45,11 @@ AliSingleModuleConstruction::AliSingleModuleConstruction(
   : AliModuleConstruction(right)                               
 {
 //
-  fVersion = right.fVersion;
-  fType = right.fType;
-  fProcessConfig = right.fProcessConfig;
-  fAllLVSensitive = right.fAllLVSensitive;
-  fSDManager = right.fSDManager;
-
-  G4String moduleName = right.fModuleName;
-  moduleName.toLower();
-  fMessenger = new AliSingleModuleConstructionMessenger(this, moduleName);
+  // allocation in assignement operator
+  fMessenger = 0;
+  
+  // copy stuff
+  *this = right;
 }
 
 AliSingleModuleConstruction::AliSingleModuleConstruction() {
@@ -81,7 +77,13 @@ AliSingleModuleConstruction::operator=(const AliSingleModuleConstruction& right)
   fProcessConfig = right.fProcessConfig;
   fAllLVSensitive = right.fAllLVSensitive;
   fSDManager = right.fSDManager;
-  
+  // messenger is protected from copying  
+  if (fMessenger) delete fMessenger;
+  G4String moduleName = right.fModuleName;
+  moduleName.toLower();
+  fMessenger = new AliSingleModuleConstructionMessenger(this, moduleName);
   return *this;
 }
 
@@ -161,6 +163,7 @@ void AliSingleModuleConstruction::Configure(const AliFiles& files)
   if (fProcessConfig) {
     gROOT->LoadMacro(rootFilePath);
     G4String macroName = files.GetDefaultMacroName();
+    //macroName = macroName + "_" + fModuleName;
     macroName = macroName + "(";
     AliGlobals::AppendNumberToString(macroName, fVersion);
     macroName = macroName + ")";
index 59c8bd3d942e89fd5a3d73c01140bb1918f446a5..eccce75a5728186b59280d01fc07643141363e86 100644 (file)
@@ -20,11 +20,11 @@ TG4G3ControlVector::TG4G3ControlVector()
 
 TG4G3ControlVector::TG4G3ControlVector(const TG4G3ControlVector& right)
 {
-  // copy fControlVector 
+  // allocation
   fControlVector = new TG4ControlValueVector;
-  for (G4int i=0; i<kNoG3Controls; i++) {
-    fControlVector->insert((*right.fControlVector)[i]);
-  }   
+  
+  // copy stuff
+  *this = right;  
 }
 
 TG4G3ControlVector::~TG4G3ControlVector() {
@@ -41,7 +41,7 @@ TG4G3ControlVector& TG4G3ControlVector::operator=(
   if (this == &right) return *this;
 
   // initialize fControlVector 
-  fControlVector->clear();
+  fControlVector->clear();;
   for (G4int i=0; i<kNoG3Controls; i++) {
     fControlVector->insert((*right.fControlVector)[i]);
   }
index f5d1a3187cf51f846c295a0d9f8a864f327e8db8..7073a18344f6ad9ab7680fa5810766685925bce3 100644 (file)
 TG4G3CutVector::TG4G3CutVector()
 {
   // initialize fCutVector 
-  fCutVector = new TG4doubleVector;
+  fCutVector = new TG4doubleVector();
   for (G4int i=0; i<kNoG3Cuts; i++) fCutVector->insert(0.); 
 }
 
 TG4G3CutVector::TG4G3CutVector(const TG4G3CutVector& right)
 {
-  // copy fCutVector 
-  fCutVector = new TG4doubleVector;
-  for (G4int i=0; i<kNoG3Cuts; i++) {
-    fCutVector->insert((*right.fCutVector)[i]);
-  }   
+ // allocation
+  fCutVector = new TG4doubleVector();
+
+  // copy stuff
+  *this = right;
 }
 
 TG4G3CutVector::~TG4G3CutVector() {
index 2cd09c7fa7399edb0b396a097fc9130f5228552b..b5c486d43e49d97a31accbef3ff8729dd318279c 100644 (file)
@@ -24,8 +24,12 @@ TG4Limits::TG4Limits(const TG4Limits& right)
   : G4UserLimits(right) 
 {
 //    
-  fCutVector = new TG4G3CutVector(*right.fCutVector);
-  fControlVector = new TG4G3ControlVector(*right.fControlVector);
+  // allocation
+  fCutVector = new TG4G3CutVector();
+  fControlVector = new TG4G3ControlVector();
+
+  // copy stuff
+  *this = right;
 }  
 
 TG4Limits::~TG4Limits() {