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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 10.0.p4)


  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 // $Id: G4MonopoleFieldSetup.cc 68036 2013-03-13 14:13:45Z gcosmo $
 29 //                                                 30 //
 30 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //                                                 33 //
 33 //                                                 34 //
 34 // G4MonopoleFieldSetup is responsible for set     35 // G4MonopoleFieldSetup is responsible for setting up a magnetic field
 35 // and the ability to use it with two differen <<  36 // and the ability to use it with two different equation of motions, 
 36 // one for monopoles and another for the rest  <<  37 // one for monopoles and another for the rest of the particles. 
 37 //                                             <<  38 // 
 38 //                                             <<  39 // 
 39                                                    40 
 40 // ===========================================     41 // =======================================================================
 41 // Created:  13 May 2010, B. Bozsogi               42 // Created:  13 May 2010, B. Bozsogi
 42 // ===========================================     43 // =======================================================================
 43                                                    44 
 44 #include "G4MonopoleFieldSetup.hh"                 45 #include "G4MonopoleFieldSetup.hh"
                                                   >>  46 #include "G4MonopoleFieldMessenger.hh"
 45                                                    47 
 46 #include "G4ChordFinder.hh"                    <<  48 #include "G4MagneticField.hh"
                                                   >>  49 #include "G4UniformMagField.hh"
 47 #include "G4FieldManager.hh"                       50 #include "G4FieldManager.hh"
 48 #include "G4MagIntegratorStepper.hh"           <<  51 #include "G4TransportationManager.hh"
 49 #include "G4Mag_UsualEqRhs.hh"                     52 #include "G4Mag_UsualEqRhs.hh"
 50 #include "G4MagneticField.hh"                  << 
 51 #include "G4MonopoleEquation.hh"                   53 #include "G4MonopoleEquation.hh"
 52 #include "G4MonopoleFieldMessenger.hh"         <<  54 #include "G4MagIntegratorStepper.hh"
 53 #include "G4TransportationManager.hh"          <<  55 #include "G4ChordFinder.hh"
 54 #include "G4UniformMagField.hh"                << 
 55                                                    56 
 56 // #include "G4ExplicitEuler.hh"                   57 // #include "G4ExplicitEuler.hh"
 57 // #include "G4ImplicitEuler.hh"                   58 // #include "G4ImplicitEuler.hh"
 58 // #include "G4SimpleRunge.hh"                     59 // #include "G4SimpleRunge.hh"
 59 // #include "G4SimpleHeum.hh"                      60 // #include "G4SimpleHeum.hh"
 60 #include "G4ClassicalRK4.hh"                       61 #include "G4ClassicalRK4.hh"
 61 // #include "G4HelixExplicitEuler.hh"              62 // #include "G4HelixExplicitEuler.hh"
 62 // #include "G4HelixImplicitEuler.hh"              63 // #include "G4HelixImplicitEuler.hh"
 63 // #include "G4HelixSimpleRunge.hh"                64 // #include "G4HelixSimpleRunge.hh"
 64 // #include "G4CashKarpRKF45.hh"                   65 // #include "G4CashKarpRKF45.hh"
 65 // #include "G4RKG3_Stepper.hh"                    66 // #include "G4RKG3_Stepper.hh"
 66                                                    67 
 67 #include "G4SystemOfUnits.hh"                      68 #include "G4SystemOfUnits.hh"
 68                                                    69 
 69 // G4MonopoleFieldSetup* G4MonopoleFieldSetup: <<  70 G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0;
 70                                                    71 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 72                                                    73 
 73 G4MonopoleFieldSetup::G4MonopoleFieldSetup()       74 G4MonopoleFieldSetup::G4MonopoleFieldSetup()
 74   : fFieldManager(0),                          <<  75  : fFieldManager(0),
 75     fChordFinder(0),                           <<  76    fChordFinder(0),
 76     fUsualChordFinder(0),                      <<  77    fEquation(0),
 77     fMonopoleChordFinder(0),                   <<  78    fMonopoleEquation(0),
 78     fEquation(0),                              <<  79    fMagneticField(0),
 79     fMonopoleEquation(0),                      <<  80    fStepper(0),
 80     fMagneticField(0),                         <<  81    fMonopoleStepper(0),
 81     fStepper(0),                               <<  82    fMinStep(0.0),
 82     fMonopoleStepper(0),                       <<  83    fMonopoleFieldMessenger(0)
 83     fMinStep(0.0),                             << 
 84     fZmagFieldValue(0.2 * tesla),              << 
 85     fMonopoleFieldMessenger(0)                 << 
 86 {                                                  84 {
 87   fMonopoleFieldMessenger = new G4MonopoleFiel     85   fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this);
 88   fFieldManager = GetGlobalFieldManager();     << 
 89 }                                                  86 }
 90                                                    87 
 91 //....oooOO0OOooo........oooOO0OOooo........oo     88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 92                                                    89 
 93 // G4MonopoleFieldSetup* G4MonopoleFieldSetup: <<  90 G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup()
 94 // {                                           << 
 95 //    if (0 == fMonopoleFieldSetup)            << 
 96 //    {                                        << 
 97 //      static G4ThreadLocal G4MonopoleFieldSe << 
 98 //      fMonopoleFieldSetup = &theInstance;    << 
 99 //    }                                        << 
100                                                << 
101 //    return fMonopoleFieldSetup;              << 
102 // }                                           << 
103                                                << 
104 //....oooOO0OOooo........oooOO0OOooo........oo << 
105                                                << 
106 G4MonopoleFieldSetup::~G4MonopoleFieldSetup()  << 
107 {                                                  91 {
108   delete fMonopoleFieldMessenger;              <<  92    if (0 == fMonopoleFieldSetup)
109   if (fMagneticField) delete fMagneticField;   <<  93    {
110   //  if(fChordFinder)   delete fChordFinder;  <<  94      static G4MonopoleFieldSetup theInstance;
111   if (fUsualChordFinder) delete fUsualChordFin <<  95      fMonopoleFieldSetup = &theInstance;
112   if (fMonopoleChordFinder) delete fMonopoleCh <<  96    }
113   if (fStepper) delete fStepper;               <<  97    
114   if (fMonopoleStepper) delete fMonopoleSteppe <<  98    return fMonopoleFieldSetup;
115 }                                                  99 }
116                                                   100 
117 //....oooOO0OOooo........oooOO0OOooo........oo    101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118                                                   102 
119 void G4MonopoleFieldSetup::SetZMagFieldValue(G << 103 G4MonopoleFieldSetup::~G4MonopoleFieldSetup()
120 {                                                 104 {
121   // set new magnetic field value and rebuild  << 105   delete fMonopoleFieldMessenger;
122   fZmagFieldValue = val;                       << 106   if(fMagneticField) delete fMagneticField;
123                                                << 107   if(fChordFinder)   delete fChordFinder;
124   ConstructMagField();                         << 108   if(fStepper)       delete fStepper;
                                                   >> 109   if(fMonopoleStepper)  delete fMonopoleStepper;
125 }                                                 110 }
126                                                   111 
127 //....oooOO0OOooo........oooOO0OOooo........oo    112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128                                                   113 
129 void G4MonopoleFieldSetup::ConstructMagField() << 114 void G4MonopoleFieldSetup::SetMagField(G4double fieldValue)
130 {                                                 115 {
131   // apply a global uniform magnetic field alo << 116   //apply a global uniform magnetic field along Z axis  
132   if (fMagneticField) {                        << 117   if (fMagneticField) { delete fMagneticField; }  //delete the existing magn field
133     delete fMagneticField;                     << 
134   }  // delete the existing magn field         << 
135                                                << 
136   if (fZmagFieldValue != 0.)  // create a new  << 
137   {                                            << 
138     // G4cout << "Go to create new field ..."  << 
139     fMagneticField = new G4UniformMagField(G4T << 
140     InitialiseAll();                           << 
141   }                                            << 
142   else {                                       << 
143     // G4cout << "Set field = 0 ..." << G4endl << 
144     fMagneticField = 0;                        << 
145   }                                            << 
146                                                   118 
147   fFieldManager->SetDetectorField(fMagneticFie << 119   if (fieldValue != 0.)     // create a new one if non nul
                                                   >> 120     {
                                                   >> 121       fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0., fieldValue));        
                                                   >> 122       InitialiseAll();
                                                   >> 123     }
                                                   >> 124    else
                                                   >> 125     {
                                                   >> 126       fMagneticField = 0;
                                                   >> 127       fFieldManager->SetDetectorField(fMagneticField);
                                                   >> 128     }
148 }                                                 129 }
149                                                   130 
150 //....oooOO0OOooo........oooOO0OOooo........oo    131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151                                                   132 
152 void G4MonopoleFieldSetup::InitialiseAll()     << 133 void
                                                   >> 134 G4MonopoleFieldSetup::InitialiseAll()
153 {                                                 135 {
154   fEquation = new G4Mag_UsualEqRhs(fMagneticFi << 136   fFieldManager = G4TransportationManager::GetTransportationManager()
                                                   >> 137                                           ->GetFieldManager();
                                                   >> 138                                           
                                                   >> 139   fEquation = new G4Mag_UsualEqRhs(fMagneticField); 
155   fMonopoleEquation = new G4MonopoleEquation(f    140   fMonopoleEquation = new G4MonopoleEquation(fMagneticField);
156                                                << 141  
157   fMinStep = 0.01 * mm;  // minimal step of 1  << 142   fMinStep     = 0.01*mm ; // minimal step of 1 mm is default
158                                                << 143                                         
159   fMonopoleStepper = new G4ClassicalRK4(fMonop << 144   fMonopoleStepper = new G4ClassicalRK4( fMonopoleEquation, 8 ); // for time information..
160   fStepper = new G4ClassicalRK4(fEquation);    << 145   fStepper = new G4ClassicalRK4( fEquation );                                         
161                                                << 146                                          
162   fUsualChordFinder = new G4ChordFinder(fMagne << 
163   fMonopoleChordFinder = new G4ChordFinder(fMa << 
164                                                << 
165   SetStepperAndChordFinder(0);                    147   SetStepperAndChordFinder(0);
166 }                                                 148 }
167                                                   149 
168 //....oooOO0OOooo........oooOO0OOooo........oo    150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169                                                   151 
170 void G4MonopoleFieldSetup::SetStepperAndChordF    152 void G4MonopoleFieldSetup::SetStepperAndChordFinder(G4int val)
171 {                                                 153 {
172   if (fMagneticField) {                        << 154   if (fMagneticField)
173     fFieldManager->SetDetectorField(fMagneticF << 155   {
174     //    if(fChordFinder) delete fChordFinder << 156     fFieldManager->SetDetectorField(fMagneticField );
175                                                << 157 
176     switch (val) {                             << 158     if(fChordFinder) delete fChordFinder;
177         //       case 0:                       << 159 
178         //         fChordFinder = new G4ChordF << 160     switch (val)
179         //         break;                      << 161     {
180         //       case 1:                       << 
181         //         fChordFinder = new G4ChordF << 
182         //                                     << 
183         //         break;                      << 
184       case 0:                                     162       case 0:
185         fChordFinder = fUsualChordFinder;      << 163         fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);      
186         break;                                    164         break;
187       case 1:                                  << 165       case 1: 
188         fChordFinder = fMonopoleChordFinder;   << 166         fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fMonopoleStepper);
189         break;                                    167         break;
190     }                                          << 168     }   
191                                                << 169   
192     fFieldManager->SetChordFinder(fChordFinder << 170     fFieldManager->SetChordFinder( fChordFinder );
193   }                                               171   }
194 }                                                 172 }
195                                                   173 
196 //....oooOO0OOooo........oooOO0OOooo........oo    174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197                                                   175 
198 G4FieldManager* G4MonopoleFieldSetup::GetGloba << 176 G4FieldManager*  G4MonopoleFieldSetup::GetGlobalFieldManager()
199 {                                                 177 {
200   return G4TransportationManager::GetTransport << 178   return G4TransportationManager::GetTransportationManager()
                                                   >> 179                           ->GetFieldManager();
201 }                                                 180 }
202                                                   181 
203 //....oooOO0OOooo........oooOO0OOooo........oo    182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204                                                   183