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.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/exoticphysics/monopole/src/G4MonopoleFieldSetup.cc (Version 11.3.0) and /examples/extended/exoticphysics/monopole/src/G4MonopoleFieldSetup.cc (Version 11.1.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /// \file exoticphysics/monopole/src/G4Monopol     26 /// \file exoticphysics/monopole/src/G4MonopoleFieldSetup.cc
 27 /// \brief Implementation of the G4MonopoleFie     27 /// \brief Implementation of the G4MonopoleFieldSetup class
 28 //                                                 28 //
 29 //                                                 29 //
 30 //....oooOO0OOooo........oooOO0OOooo........oo     30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //                                                 32 //
 33 //                                                 33 //
 34 // G4MonopoleFieldSetup is responsible for set     34 // G4MonopoleFieldSetup is responsible for setting up a magnetic field
 35 // and the ability to use it with two differen <<  35 // and the ability to use it with two different equation of motions, 
 36 // one for monopoles and another for the rest  <<  36 // one for monopoles and another for the rest of the particles. 
 37 //                                             <<  37 // 
 38 //                                             <<  38 // 
 39                                                    39 
 40 // ===========================================     40 // =======================================================================
 41 // Created:  13 May 2010, B. Bozsogi               41 // Created:  13 May 2010, B. Bozsogi
 42 // ===========================================     42 // =======================================================================
 43                                                    43 
 44 #include "G4MonopoleFieldSetup.hh"                 44 #include "G4MonopoleFieldSetup.hh"
                                                   >>  45 #include "G4MonopoleFieldMessenger.hh"
 45                                                    46 
 46 #include "G4ChordFinder.hh"                    <<  47 #include "G4MagneticField.hh"
                                                   >>  48 #include "G4UniformMagField.hh"
 47 #include "G4FieldManager.hh"                       49 #include "G4FieldManager.hh"
 48 #include "G4MagIntegratorStepper.hh"           <<  50 #include "G4TransportationManager.hh"
 49 #include "G4Mag_UsualEqRhs.hh"                     51 #include "G4Mag_UsualEqRhs.hh"
 50 #include "G4MagneticField.hh"                  << 
 51 #include "G4MonopoleEquation.hh"                   52 #include "G4MonopoleEquation.hh"
 52 #include "G4MonopoleFieldMessenger.hh"         <<  53 #include "G4MagIntegratorStepper.hh"
 53 #include "G4TransportationManager.hh"          <<  54 #include "G4ChordFinder.hh"
 54 #include "G4UniformMagField.hh"                << 
 55                                                    55 
 56 // #include "G4ExplicitEuler.hh"                   56 // #include "G4ExplicitEuler.hh"
 57 // #include "G4ImplicitEuler.hh"                   57 // #include "G4ImplicitEuler.hh"
 58 // #include "G4SimpleRunge.hh"                     58 // #include "G4SimpleRunge.hh"
 59 // #include "G4SimpleHeum.hh"                      59 // #include "G4SimpleHeum.hh"
 60 #include "G4ClassicalRK4.hh"                       60 #include "G4ClassicalRK4.hh"
 61 // #include "G4HelixExplicitEuler.hh"              61 // #include "G4HelixExplicitEuler.hh"
 62 // #include "G4HelixImplicitEuler.hh"              62 // #include "G4HelixImplicitEuler.hh"
 63 // #include "G4HelixSimpleRunge.hh"                63 // #include "G4HelixSimpleRunge.hh"
 64 // #include "G4CashKarpRKF45.hh"                   64 // #include "G4CashKarpRKF45.hh"
 65 // #include "G4RKG3_Stepper.hh"                    65 // #include "G4RKG3_Stepper.hh"
 66                                                    66 
 67 #include "G4SystemOfUnits.hh"                      67 #include "G4SystemOfUnits.hh"
 68                                                    68 
 69 // G4MonopoleFieldSetup* G4MonopoleFieldSetup: <<  69 //G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0;
 70                                                    70 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 72                                                    72 
 73 G4MonopoleFieldSetup::G4MonopoleFieldSetup()       73 G4MonopoleFieldSetup::G4MonopoleFieldSetup()
 74   : fFieldManager(0),                          <<  74  : fFieldManager(0),
 75     fChordFinder(0),                           <<  75    fChordFinder(0),
 76     fUsualChordFinder(0),                      <<  76    fUsualChordFinder(0),
 77     fMonopoleChordFinder(0),                   <<  77    fMonopoleChordFinder(0),
 78     fEquation(0),                              <<  78    fEquation(0),
 79     fMonopoleEquation(0),                      <<  79    fMonopoleEquation(0),
 80     fMagneticField(0),                         <<  80    fMagneticField(0),
 81     fStepper(0),                               <<  81    fStepper(0),
 82     fMonopoleStepper(0),                       <<  82    fMonopoleStepper(0),
 83     fMinStep(0.0),                             <<  83    fMinStep(0.0),
 84     fZmagFieldValue(0.2 * tesla),              <<  84    fZmagFieldValue(0.2*tesla),
 85     fMonopoleFieldMessenger(0)                 <<  85    fMonopoleFieldMessenger(0)
 86 {                                                  86 {
                                                   >>  87 
 87   fMonopoleFieldMessenger = new G4MonopoleFiel     88   fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this);
 88   fFieldManager = GetGlobalFieldManager();         89   fFieldManager = GetGlobalFieldManager();
 89 }                                                  90 }
 90                                                    91 
 91 //....oooOO0OOooo........oooOO0OOooo........oo     92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 92                                                    93 
 93 // G4MonopoleFieldSetup* G4MonopoleFieldSetup:     94 // G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup()
 94 // {                                               95 // {
 95 //    if (0 == fMonopoleFieldSetup)                96 //    if (0 == fMonopoleFieldSetup)
 96 //    {                                            97 //    {
 97 //      static G4ThreadLocal G4MonopoleFieldSe     98 //      static G4ThreadLocal G4MonopoleFieldSetup theInstance;
 98 //      fMonopoleFieldSetup = &theInstance;        99 //      fMonopoleFieldSetup = &theInstance;
 99 //    }                                           100 //    }
100                                                << 101    
101 //    return fMonopoleFieldSetup;                 102 //    return fMonopoleFieldSetup;
102 // }                                              103 // }
103                                                   104 
104 //....oooOO0OOooo........oooOO0OOooo........oo    105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105                                                   106 
106 G4MonopoleFieldSetup::~G4MonopoleFieldSetup()     107 G4MonopoleFieldSetup::~G4MonopoleFieldSetup()
107 {                                                 108 {
108   delete fMonopoleFieldMessenger;                 109   delete fMonopoleFieldMessenger;
109   if (fMagneticField) delete fMagneticField;   << 110   if(fMagneticField) delete fMagneticField;
110   //  if(fChordFinder)   delete fChordFinder;     111   //  if(fChordFinder)   delete fChordFinder;
111   if (fUsualChordFinder) delete fUsualChordFin << 112   if(fUsualChordFinder)   delete fUsualChordFinder;
112   if (fMonopoleChordFinder) delete fMonopoleCh << 113   if(fMonopoleChordFinder)   delete fMonopoleChordFinder;
113   if (fStepper) delete fStepper;               << 114   if(fStepper)       delete fStepper;
114   if (fMonopoleStepper) delete fMonopoleSteppe << 115   if(fMonopoleStepper)  delete fMonopoleStepper;
115 }                                                 116 }
116                                                   117 
117 //....oooOO0OOooo........oooOO0OOooo........oo    118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118                                                   119 
119 void G4MonopoleFieldSetup::SetZMagFieldValue(G << 120 void G4MonopoleFieldSetup::SetZMagFieldValue (G4double val)
120 {                                                 121 {
121   // set new magnetic field value and rebuild  << 122   //set new magnetic field value and rebuild the field
122   fZmagFieldValue = val;                          123   fZmagFieldValue = val;
123                                                   124 
124   ConstructMagField();                            125   ConstructMagField();
125 }                                                 126 }
126                                                   127 
127 //....oooOO0OOooo........oooOO0OOooo........oo    128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128                                                   129 
129 void G4MonopoleFieldSetup::ConstructMagField()    130 void G4MonopoleFieldSetup::ConstructMagField()
130 {                                                 131 {
131   // apply a global uniform magnetic field alo << 132   //apply a global uniform magnetic field along Z axis  
132   if (fMagneticField) {                        << 133   if (fMagneticField) { delete fMagneticField; }  //delete the existing magn field
133     delete fMagneticField;                     << 
134   }  // delete the existing magn field         << 
135                                                   134 
136   if (fZmagFieldValue != 0.)  // create a new  << 135   if (fZmagFieldValue != 0.)     // create a new one if non nul
137   {                                            << 136     {
138     // G4cout << "Go to create new field ..."  << 137       // G4cout << "Go to create new field ..." << G4endl;
139     fMagneticField = new G4UniformMagField(G4T << 138       fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0., 
140     InitialiseAll();                           << 139                                                            fZmagFieldValue));        
141   }                                            << 140       InitialiseAll();
142   else {                                       << 141     }
143     // G4cout << "Set field = 0 ..." << G4endl << 142    else
144     fMagneticField = 0;                        << 143     {
145   }                                            << 144       // G4cout << "Set field = 0 ..." << G4endl;
                                                   >> 145       fMagneticField = 0;
                                                   >> 146     }
146                                                   147 
147   fFieldManager->SetDetectorField(fMagneticFie    148   fFieldManager->SetDetectorField(fMagneticField);
                                                   >> 149   
148 }                                                 150 }
149                                                   151 
150 //....oooOO0OOooo........oooOO0OOooo........oo    152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151                                                   153 
152 void G4MonopoleFieldSetup::InitialiseAll()        154 void G4MonopoleFieldSetup::InitialiseAll()
153 {                                                 155 {
154   fEquation = new G4Mag_UsualEqRhs(fMagneticFi << 156   fEquation = new G4Mag_UsualEqRhs(fMagneticField); 
155   fMonopoleEquation = new G4MonopoleEquation(f    157   fMonopoleEquation = new G4MonopoleEquation(fMagneticField);
156                                                << 158  
157   fMinStep = 0.01 * mm;  // minimal step of 1  << 159   fMinStep     = 0.01*mm ; // minimal step of 1 mm is default
158                                                << 160                                         
159   fMonopoleStepper = new G4ClassicalRK4(fMonop << 161   fMonopoleStepper = new G4ClassicalRK4( fMonopoleEquation, 8 ); 
160   fStepper = new G4ClassicalRK4(fEquation);    << 162   fStepper = new G4ClassicalRK4( fEquation );                                         
161                                                << 163                                          
162   fUsualChordFinder = new G4ChordFinder(fMagne << 164   fUsualChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);      
163   fMonopoleChordFinder = new G4ChordFinder(fMa << 165   fMonopoleChordFinder = new G4ChordFinder( fMagneticField, fMinStep, 
                                                   >> 166                                             fMonopoleStepper);
164                                                   167 
165   SetStepperAndChordFinder(0);                    168   SetStepperAndChordFinder(0);
166 }                                                 169 }
167                                                   170 
168 //....oooOO0OOooo........oooOO0OOooo........oo    171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169                                                   172 
170 void G4MonopoleFieldSetup::SetStepperAndChordF    173 void G4MonopoleFieldSetup::SetStepperAndChordFinder(G4int val)
171 {                                                 174 {
172   if (fMagneticField) {                        << 175 
173     fFieldManager->SetDetectorField(fMagneticF << 176   if (fMagneticField)
                                                   >> 177   {
                                                   >> 178     fFieldManager->SetDetectorField(fMagneticField );
174     //    if(fChordFinder) delete fChordFinder    179     //    if(fChordFinder) delete fChordFinder;
175                                                   180 
176     switch (val) {                             << 181     switch (val)
177         //       case 0:                       << 182     {
178         //         fChordFinder = new G4ChordF << 183 //       case 0:
179         //         break;                      << 184 //         fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);      
180         //       case 1:                       << 185 //         break;
181         //         fChordFinder = new G4ChordF << 186 //       case 1: 
182         //                                     << 187 //         fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, 
183         //         break;                      << 188 //                                             fMonopoleStepper);
                                                   >> 189 //         break;
184       case 0:                                     190       case 0:
185         fChordFinder = fUsualChordFinder;         191         fChordFinder = fUsualChordFinder;
186         break;                                    192         break;
187       case 1:                                  << 193       case 1: 
188         fChordFinder = fMonopoleChordFinder;      194         fChordFinder = fMonopoleChordFinder;
189         break;                                    195         break;
190     }                                          << 196     }   
191                                                << 197   
192     fFieldManager->SetChordFinder(fChordFinder << 198     fFieldManager->SetChordFinder( fChordFinder );
193   }                                               199   }
                                                   >> 200 
194 }                                                 201 }
195                                                   202 
196 //....oooOO0OOooo........oooOO0OOooo........oo    203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197                                                   204 
198 G4FieldManager* G4MonopoleFieldSetup::GetGloba << 205 G4FieldManager*  G4MonopoleFieldSetup::GetGlobalFieldManager()
199 {                                                 206 {
200   return G4TransportationManager::GetTransport << 207   return G4TransportationManager::GetTransportationManager()
                                                   >> 208                           ->GetFieldManager();
201 }                                                 209 }
202                                                   210 
203 //....oooOO0OOooo........oooOO0OOooo........oo    211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204                                                   212