Detector.cc

Go to the documentation of this file.
00001 //! \file
00002 //!
00003 //! Source file for the Detector class used to build the OLYMPUS detector.
00004 //!
00005 //! Defines the Detector class and the member routines which
00006 //! construct the OLYMPUS detector.
00007 //!
00008 //! \author D.K. Hasell
00009 //! \version 1.0
00010 //! \date 2010-02-27
00011 //!
00012 //! \ingroup detector
00013 
00014 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00015 
00016 // Include user header files referenced in this file.
00017 
00018 #include "Detector.h"
00019 
00020 #include "Materials.h"
00021 
00022 #include "Beam_Pipe.h"
00023 #include "Gem_Tracker.h"
00024 #include "Luminosity_Monitor.h"
00025 #include "Magnetic_Field.h"
00026 #include "MWPC.h"
00027 #include "Symmetric_Moeller.h"
00028 #include "Target_Chamber.h"
00029 #include "Time_of_Flight.h"
00030 #include "Toroid_Magnet.h"
00031 #include "Wire_Chamber.h"
00032 
00033 #include "DET_Messenger.h"
00034 
00035 // Include the GEANT4 header files referenced in this file.
00036 
00037 #include "G4VPhysicalVolume.hh"
00038 #include "G4FieldManager.hh"
00039 #include "G4TransportationManager.hh"
00040 
00041 #include "G4Box.hh"
00042 #include "G4LogicalVolume.hh"
00043 #include "G4Material.hh"
00044 #include "G4VisAttributes.hh"
00045 #include "G4Color.hh"
00046 #include "G4PVPlacement.hh"
00047 #include "G4ThreeVector.hh"
00048 
00049 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00050 
00051 // Define the Detector class.
00052 
00053 // Constructor.
00054 
00055 Detector::Detector() :
00056    pMF(0), pTC(0), pBP(0), pTM(0), pGT(0), pWC(0), pTF(0), pLM(0),
00057    pMW(0), pSM(0) {
00058 
00059    // Pass pointer to this class to Messenger.
00060 
00061    DET_Messenger::Instance()->setDETptr( this );
00062 
00063 }
00064 
00065 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00066 
00067 // Destructor.
00068 
00069 Detector::~Detector() {
00070 
00071    delete pMF;
00072    delete pTC;
00073    delete pBP;
00074    delete pTM;
00075    delete pGT;
00076    delete pWC;
00077    delete pTF;
00078    delete pLM;
00079    delete pMW;
00080    delete pSM;
00081 
00082 }
00083 
00084 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00085 
00086 // Define the detector construction member function Construct().
00087 
00088 G4VPhysicalVolume * Detector::Construct() {
00089 
00090    // Define materials and print table (if argument is true).
00091 
00092    Materials( false );
00093 
00094    // Define the magnetic field for OLYMPUS and set it.
00095 
00096    G4cout << "Initializing the magnetic field.\n" << flush;
00097       
00098    pMF = new Magnetic_Field( "detector/magneticfield/OLYMPUS.grid", 1.0 );
00099 
00100    G4FieldManager * FieldMgr =
00101       G4TransportationManager::GetTransportationManager()->GetFieldManager();
00102 
00103    FieldMgr->SetDetectorField( pMF );
00104    FieldMgr->CreateChordFinder( pMF );
00105 
00106    G4cout << "     done.\n" << G4endl << flush;
00107 
00108    // Define the World volume as a box 10 x 10 x 10 m^3.
00109 
00110    G4cout << "Building the world volume.\n" << flush;
00111 
00112    G4Box * World_solid = new G4Box( "World_solid", 5.0 * m, 5.0 * m, 5.0 * m );
00113    
00114    G4LogicalVolume * World_log = new
00115       G4LogicalVolume( World_solid, G4Material::GetMaterial( "G4_AIR" ),
00116                        "World_log", 0, 0, 0, false );
00117 
00118    World_log->SetVisAttributes( G4VisAttributes( false, G4Color() ) );
00119       
00120    G4PVPlacement * World_phys = new
00121       G4PVPlacement( 0, G4ThreeVector(), "World_phys",
00122                      World_log, 0, false, 0, false );
00123    
00124    G4cout << "     done.\n" << endl << flush;
00125 
00126    // Other components are defined in separate routines and positioned in the 
00127    // World volume. These can be commented out to remove a component from
00128    // consideration and thus simplify the simulation if desired.
00129 
00130    // The routine first checks whether or not the component already exists,
00131    // deletes it if it does and then create an instance of the component and
00132    // builds it.
00133 
00134    // Build the target chamber, collimator and target cell.
00135 
00136    if( pTC ) delete pTC;
00137    pTC = new Target_Chamber();
00138    pTC->Build( World_phys );
00139 
00140    // Build the beampipe.
00141 
00142    if( pBP ) delete pBP;
00143    pBP = new Beam_Pipe();
00144    pBP->Build( World_phys );
00145 
00146    // Build the TOROID magnet.
00147 
00148    if( pTM ) delete pTM;
00149    pTM = new Toroid_Magnet();
00150    pTM->Build( World_phys );
00151 
00152    // Build the GEM Tracker Detector.
00153    
00154    if( pGT ) delete pGT;
00155    pGT = new Gem_Tracker();
00156    pGT->Build( World_phys );
00157 
00158    // Build the Wire Chambers.
00159 
00160    if( pWC ) delete pWC;
00161    pWC = new Wire_Chamber();
00162    pWC->Build( World_phys );
00163    
00164    // Build the Time of Flight Detector.
00165    
00166    if( pTF ) delete pTF;
00167    pTF = new Time_of_Flight();
00168    pTF->Build( World_phys );
00169 
00170    // Build the Luminosity Monitor.
00171    
00172    if( pLM ) delete pLM;
00173    pLM = new Luminosity_Monitor();
00174    pLM->Build( World_phys );
00175    
00176    // Build the MWPC.
00177    
00178    if( pMW ) delete pMW;
00179    pMW = new MWPC();
00180    pMW->Build( World_phys );
00181    
00182    // Build the Symmetric_Moeller detector.
00183    
00184    if( pSM ) delete pSM;
00185    pSM = new Symmetric_Moeller();
00186    pSM->Build( World_phys );
00187    
00188    // Return pointer to the world physical volume.
00189 
00190    return World_phys;
00191 
00192    // That's All Folks !
00193 
00194 }