Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:37

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file G04DetectorConstruction.cc
0028 /// \brief Implementation of the G04DetectorConstruction class
0029 
0030 #include "G04DetectorConstruction.hh"
0031 
0032 #include "G04SensitiveDetector.hh"
0033 
0034 #include "G4GDMLParser.hh"
0035 #include "G4SDManager.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 G04DetectorConstruction::G04DetectorConstruction(const G4GDMLParser& parser)
0040   : G4VUserDetectorConstruction(), fParser(parser)
0041 {}
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 G4VPhysicalVolume* G04DetectorConstruction::Construct()
0046 {
0047   return fParser.GetWorldVolume();
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 void G04DetectorConstruction::ConstructSDandField()
0053 {
0054   //------------------------------------------------
0055   // Sensitive detectors
0056   //------------------------------------------------
0057 
0058   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0059 
0060   G4String trackerChamberSDname = "Tracker";
0061   G04SensitiveDetector* aTrackerSD = new G04SensitiveDetector(trackerChamberSDname);
0062   SDman->AddNewDetector(aTrackerSD);
0063 
0064   ///////////////////////////////////////////////////////////////////////
0065   //
0066   // Example how to retrieve Auxiliary Information for sensitive detector
0067   //
0068   const G4GDMLAuxMapType* auxmap = fParser.GetAuxMap();
0069   G4cout << "Found " << auxmap->size() << " volume(s) with auxiliary information." << G4endl
0070          << G4endl;
0071   for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0072     G4cout << "Volume " << ((*iter).first)->GetName()
0073            << " has the following list of auxiliary information: " << G4endl << G4endl;
0074     for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0075          vit != (*iter).second.end(); vit++)
0076     {
0077       G4cout << "--> Type: " << (*vit).type << " Value: " << (*vit).value << G4endl;
0078     }
0079   }
0080   G4cout << G4endl;
0081 
0082   // The same as above, but now we are looking for
0083   // sensitive detectors setting them for the volumes
0084 
0085   for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0086     G4cout << "Volume " << ((*iter).first)->GetName()
0087            << " has the following list of auxiliary information: " << G4endl << G4endl;
0088     for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0089          vit != (*iter).second.end(); vit++)
0090     {
0091       if ((*vit).type == "SensDet") {
0092         G4cout << "Attaching sensitive detector " << (*vit).value << " to volume "
0093                << ((*iter).first)->GetName() << G4endl << G4endl;
0094 
0095         G4VSensitiveDetector* mydet = SDman->FindSensitiveDetector((*vit).value);
0096         if (mydet) {
0097           G4LogicalVolume* myvol = (*iter).first;
0098           myvol->SetSensitiveDetector(mydet);
0099         }
0100         else {
0101           G4cout << (*vit).value << " detector not found" << G4endl;
0102         }
0103       }
0104     }
0105   }
0106 }