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 ] [ 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 ]

  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 // File: CCalDetectorConstruction.cc
 28 // Description: CCalDetectorConstruction user action class to construct 
 29 //              detector geometry
 30 ///////////////////////////////////////////////////////////////////////////////
 31 #include "CCalDetectorConstruction.hh"
 32 
 33 //#define debug
 34 
 35 #ifdef debug
 36 #include "G4Timer.hh"
 37 #endif
 38 
 39 #include "CCalMaterialFactory.hh"
 40 #include "CCalRotationMatrixFactory.hh"
 41 #include "CCalSensAssign.hh"
 42 #include "CCalMagneticField.hh"
 43 #include "CCalG4Hall.hh"
 44 #include "CCalutils.hh"
 45 
 46 #include "CCalSensitiveConfiguration.hh"
 47 #include "CCalEcalOrganization.hh"
 48 #include "CCalHcalOrganization.hh"
 49 
 50 #include "G4SystemOfUnits.hh"
 51 #include "G4SDManager.hh"
 52 #include "G4FieldManager.hh"
 53 #include "G4ChordFinder.hh"
 54 #include "G4Mag_UsualEqRhs.hh"
 55 #include "G4PropagatorInField.hh"
 56 #include "G4TransportationManager.hh"
 57 
 58 #include "G4ClassicalRK4.hh"
 59 #include "G4SimpleRunge.hh"
 60 #include "G4ExplicitEuler.hh"
 61 #include "G4ImplicitEuler.hh"
 62 #include "G4SimpleHeum.hh"
 63 #include "G4HelixExplicitEuler.hh"
 64 #include "G4HelixImplicitEuler.hh"
 65 #include "G4HelixSimpleRunge.hh"
 66 #include "G4CashKarpRKF45.hh"
 67 #include "G4RKG3_Stepper.hh"
 68 
 69 
 70 CCalDetectorConstruction::CCalDetectorConstruction() : testBeamHCal96( nullptr ) {}
 71 
 72 
 73 CCalDetectorConstruction::~CCalDetectorConstruction() {}
 74 
 75 
 76 G4VPhysicalVolume* CCalDetectorConstruction::Construct() {
 77 
 78   /////////
 79   //Instantiate for the first time the materials and rotations
 80 #ifdef debug
 81   G4cout << "Retrieving materials...." << G4endl;
 82 #endif
 83   CCalMaterialFactory::getInstance("material.cms");
 84 
 85 #ifdef debug
 86   G4cout << "Retrieving rotation matrices....." << G4endl;
 87 #endif
 88   CCalRotationMatrixFactory::getInstance("rotation.cms");
 89 
 90 #ifdef debug
 91   G4cout << tab << "CCalDetectorConstruction: Starting timer!!!" 
 92          << G4endl;
 93   G4Timer timer;
 94   timer.Start();
 95 #endif
 96 
 97   //HCAL Test Beam 96
 98   testBeamHCal96 = new CCalG4Hall("HcalTB96");
 99   testBeamHCal96->constructHierarchy();
100 #ifdef debug
101   timer.Stop();
102   G4cout << tab << "CCalDetectorConstruction: Total time to "
103          << "construct the geometry: " << timer << G4endl;
104 #endif //debug
105   G4VPhysicalVolume* volume = testBeamHCal96->PhysicalVolume(0);
106   
107   return volume;
108 }
109 
110 
111 void CCalDetectorConstruction::ConstructSDandField() {
112   // Create global magnetic field messenger.
113 
114   //-------------------------------------------------------------------------
115   // Magnetic field
116   //-------------------------------------------------------------------------
117 
118   static G4bool fieldIsInitialized = false;
119   //And finally that it was not initialized previously
120   if (!fieldIsInitialized) {
121     CCalMagneticField* ccalField=new CCalMagneticField("fmap.tb96");
122     G4double field = ccalField->GetConstantFieldvalue();
123     if (field == 0) {
124       ccalField = NULL;
125       G4cout << "***************************" << G4endl
126              << "*                         *" << G4endl
127              << "*  Magnetic Field is off  *" << G4endl
128              << "*                         *" << G4endl
129              << "***************************" << G4endl;
130     } else {
131       G4cout << "***************************" << G4endl
132              << "*                         *" << G4endl
133              << "*  Magnetic Field is on   *" << G4endl
134              << "*                         *" << G4endl
135              << "***************************" << G4endl << G4endl
136              << " Field Value " << tab << field << G4endl;
137     }
138     G4FieldManager* fieldMgr
139       = G4TransportationManager::GetTransportationManager()->GetFieldManager();
140     fieldMgr->SetDetectorField(ccalField);
141     G4Mag_UsualEqRhs *fEquation = new G4Mag_UsualEqRhs(ccalField); 
142 
143     G4MagIntegratorStepper *pStepper = new G4ClassicalRK4 (fEquation);
144     //pStepper = new G4ExplicitEuler( fEquation );
145     //pStepper = new G4ImplicitEuler( fEquation );      
146     //pStepper = new G4SimpleRunge( fEquation );        
147     //pStepper = new G4SimpleHeum( fEquation );         
148     //pStepper = new G4HelixExplicitEuler( fEquation ); 
149     //pStepper = new G4HelixImplicitEuler( fEquation ); 
150     //pStepper = new G4HelixSimpleRunge( fEquation );   
151     //pStepper = new G4CashKarpRKF45( fEquation );      
152     //pStepper = new G4RKG3_Stepper( fEquation );       
153 
154     G4ChordFinder *pChordFinder = new G4ChordFinder(ccalField,
155                                                     1.e-1*mm, pStepper);
156     pChordFinder->SetDeltaChord(1.0e-3*mm);
157     fieldMgr->SetChordFinder(pChordFinder);
158     fieldMgr->SetDeltaOneStep(1.0e-3*mm);
159     fieldMgr->SetDeltaIntersection(1.0e-4*mm);
160     G4PropagatorInField* fieldPropagator
161       = G4TransportationManager::GetTransportationManager()
162       ->GetPropagatorInField();
163     fieldPropagator->SetMinimumEpsilonStep(1.e-5*mm);
164     fieldPropagator->SetMaximumEpsilonStep(1.e-2*mm);
165     fieldIsInitialized = true;
166   }
167 
168   //Add sensitive detector types
169   testBeamHCal96->sensitiveHandling();  
170   G4int sensitive = CCalSensitiveConfiguration::getInstance()->getSensitiveFlag("HadronCalorimeter");
171   if ( sensitive > 0 ) {
172     CCalSensAssign::getInstance()->addCaloSD("HadronCalorimeter", new CCalHcalOrganization);
173   }
174   sensitive = CCalSensitiveConfiguration::getInstance()->getSensitiveFlag("CrystalMatrixModule");
175   if ( sensitive > 0 ) {
176     CCalSensAssign::getInstance()->addCaloSD("CrystalMatrix", new CCalEcalOrganization);
177   }
178   // Assign the sensitive detectors
179   CCalSensAssign::getInstance()->assign();
180 }
181