Luminosity_Monitor.cc

Go to the documentation of this file.
00001 //! \file
00002 //!
00003 //! Source file for Luminosity_Monitor class.
00004 //!
00005 //! The Luminosity_Monitor class is used to build the Luminosity Monitor
00006 //! for the OLYMPUS detector simulation.
00007 //!
00008 //! \author D.K. Hasell
00009 //! \version 1.0
00010 //! \date 2010-10-31
00011 //!
00012 //! \ingroup detector
00013 
00014 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00015 
00016 // Include the LM header file and the user header files referenced here.
00017 
00018 #include "Luminosity_Monitor.h"
00019 #include "LM_SD.h"
00020 
00021 // Include the GEANT4 header files used here.
00022 
00023 #include "G4VPhysicalVolume.hh"
00024 #include "G4LogicalVolume.hh"
00025 #include "G4PVPlacement.hh"
00026 #include "G4Box.hh"
00027 #include "G4SubtractionSolid.hh"
00028 #include "G4Material.hh"
00029 #include "G4ThreeVector.hh"
00030 #include "G4RotationMatrix.hh"
00031 #include "G4VisAttributes.hh"
00032 #include "G4Colour.hh"
00033 
00034 #include "G4SDManager.hh"
00035 
00036 // Use the standard namespace.
00037 
00038 using namespace std;
00039 
00040 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00041 
00042 // Routines to define the OLYMPUS Luminosity_Monitor class.
00043 
00044 // Constructor.
00045 
00046 Luminosity_Monitor::Luminosity_Monitor() {}
00047 
00048 // Destructor.
00049 
00050 Luminosity_Monitor::~Luminosity_Monitor() {}
00051 
00052 // Member function to build the beamline.
00053 
00054 void Luminosity_Monitor::Build( G4VPhysicalVolume * World_phys ) {
00055 
00056    // Building the LM detector.
00057    
00058    G4cout << "Building the Lumi detectors:\n" << flush;
00059    
00060    // Define the LM position and dimensions.
00061    
00062 //   G4double R[N_LM]      = { 187.0, 237.0, 287.0, 187.0, 237.0, 287.0 };
00063    G4double R[N_LM]      = { 187.0, 222.0, 256.0, 187.0, 222.0, 256.0 };
00064    
00065    G4double Theta[N_LM]  = {  12.0,  12.0,  12.0,  12.0,  12.0,  12.0 };
00066 
00067    G4double Phi[N_LM]    = {   0.0,   0.0,   0.0, 180.0, 180.0, 180.0 };
00068 
00069    G4double Alpha[N_LM]  = { -12.0, -12.0, -12.0,  12.0,  12.0,  12.0 };
00070 
00071    // Set the units properly.
00072    
00073    for( int i = 0; i < N_LM; ++i ) {
00074       R[i]      *= cm;
00075       Theta[i]  *= degree;
00076       Phi[i]    *= degree;
00077       Alpha[i]  *= degree;
00078    }
00079 
00080    G4double Width  = 12.5 * cm;
00081    G4double Height = 12.5 * cm;
00082    G4double Thick  =  1.5 * cm;
00083 
00084    // Create an instance of the LM sensitive detector.
00085 
00086    LM_SD * SD = new LM_SD( "OLYMPUS/LM" );
00087 
00088    G4SDManager::GetSDMpointer()->AddNewDetector( SD );
00089 
00090    // Loop over the detectors.
00091 
00092    for( int i = 0; i < N_LM; ++i ) {
00093 
00094      // Create the LM and place it.
00095    
00096      G4Box * LM_solid = new
00097        G4Box( "LM_solid", Width / 2.0, Height / 2.0, Thick / 2.0 );
00098    
00099      G4LogicalVolume * LM_log = new
00100        G4LogicalVolume( LM_solid, G4Material::GetMaterial( "WC_gas" ),
00101          "LM_log", 0, 0, 0, true );
00102       
00103      LM_log->SetVisAttributes( G4VisAttributes( false, G4Color() ) );
00104       
00105      G4double costheta = cos( Theta[i] );
00106      G4double sintheta = sin( Theta[i] );
00107      G4double cosphi = cos( Phi[i] );
00108      G4double sinphi = sin( Phi[i] );
00109 
00110      // Note these rotations produce the correct local coordinates in the left
00111      // and right sectors assuming the detectors are identical.
00112 
00113      G4RotationMatrix * Rotation = new G4RotationMatrix;
00114      Rotation->rotateY( Alpha[i] );
00115      if( i > 2 ) Rotation->rotateZ( 180.0 * degree );
00116 
00117      new G4PVPlacement( Rotation, G4ThreeVector( R[i] * sintheta * cosphi,
00118                    R[i] * sintheta * sinphi,
00119                    R[i] * costheta ),
00120          "LM_phys", LM_log, World_phys, false, i, false );
00121 
00122      // Create and place the Gas volume.
00123    
00124      G4Box * LM_Gas_solid = new
00125        G4Box( "LM_Gas_solid", ( Width - 2.5 * cm ) / 2.0,
00126              ( Height - 2.5 * cm ) / 2.0, ( Thick + 0.01 * cm ) / 2.0 );
00127    
00128      G4LogicalVolume * LM_Gas_log = new
00129        G4LogicalVolume( LM_Gas_solid, G4Material::GetMaterial( "WC_gas" ),
00130          "LM_Gas_log", 0, 0, 0, true );
00131    
00132      LM_Gas_log->SetVisAttributes( G4VisAttributes( false, G4Color() ) );
00133       
00134      new G4PVPlacement( 0, G4ThreeVector(), 
00135          LM_Gas_log, "LM_Gas_phys", LM_log, false, i, false );
00136       
00137      // Create the Frame volume.
00138       
00139      G4SubtractionSolid * LM_Frame_solid = new
00140        G4SubtractionSolid( "LM_Frame_solid", LM_solid, LM_Gas_solid );
00141       
00142      G4LogicalVolume * LM_Frame_log = new
00143        G4LogicalVolume( LM_Frame_solid, G4Material::GetMaterial( "NemaG10" ),
00144          "LM_Frame_log", 0, 0, 0, true );
00145       
00146      LM_Frame_log->SetVisAttributes( G4VisAttributes( true,
00147                         G4Colour( 0, 0.8, 0 ) ) );
00148       
00149      new G4PVPlacement( 0, G4ThreeVector(),
00150          LM_Frame_log, "LM_Frame_phys", LM_log, false, i, false );
00151       
00152      // Create the Drift volume.
00153    
00154      G4Box * LM_Drift_solid = new
00155        G4Box( "LM_Drift_solid", ( Width - 2.5 * cm ) / 2.0,
00156          ( Height - 2.5 * cm ) / 2.0, ( 0.3 * cm ) / 2.0 );
00157    
00158      G4LogicalVolume * LM_Drift_log = new
00159        G4LogicalVolume( LM_Drift_solid, G4Material::GetMaterial( "WC_gas" ),
00160                        "LM_Drift_log", 0, 0, 0, true );
00161    
00162      LM_Drift_log->SetVisAttributes( G4VisAttributes( false, G4Color() ) );
00163       
00164      new G4PVPlacement( 0, G4ThreeVector( 0.0, 0.0, ( 0.3 * cm - Thick ) / 2.0 ),
00165          LM_Drift_log, "LM_Drift_phys", LM_log, false, i, false );
00166       
00167      // Make the Drift volume sensitive.
00168       
00169      LM_Drift_log->SetSensitiveDetector( SD );
00170    
00171    }
00172 
00173    G4cout << "     Done.\n" << G4endl << flush;
00174 
00175    // That's All Folks !
00176 
00177    return;
00178 
00179 }