Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:32:55

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 /// \file G04DetectorConstruction.cc
0027 /// \brief Implementation of the G04DetectorConstruction class
0028 
0029 #include "G04DetectorConstruction.hh"
0030 
0031 #include "G04SensitiveDetector.hh"
0032 
0033 #include "G4GDMLParser.hh"
0034 #include "G4SDManager.hh"
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 G04DetectorConstruction::G04DetectorConstruction(const G4GDMLParser& parser)
0039   : G4VUserDetectorConstruction(), fParser(parser)
0040 {}
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 G4VPhysicalVolume* G04DetectorConstruction::Construct()
0045 {
0046   return fParser.GetWorldVolume();
0047 }
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 void G04DetectorConstruction::ConstructSDandField()
0052 {
0053   //------------------------------------------------
0054   // Sensitive detectors
0055   //------------------------------------------------
0056 
0057   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0058 
0059   G4String trackerChamberSDname = "Tracker";
0060   G04SensitiveDetector* aTrackerSD = new G04SensitiveDetector(trackerChamberSDname);
0061   SDman->AddNewDetector(aTrackerSD);
0062 
0063   ///////////////////////////////////////////////////////////////////////
0064   //
0065   // Example how to retrieve Auxiliary Information for sensitive detector
0066   //
0067   const G4GDMLAuxMapType* auxmap = fParser.GetAuxMap();
0068   G4cout << "Found " << auxmap->size() << " volume(s) with auxiliary information." << G4endl
0069          << G4endl;
0070   for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0071     G4cout << "Volume " << ((*iter).first)->GetName()
0072            << " has the following list of auxiliary information: " << G4endl << G4endl;
0073     for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0074          vit != (*iter).second.end(); vit++)
0075     {
0076       G4cout << "--> Type: " << (*vit).type << " Value: " << (*vit).value << G4endl;
0077     }
0078   }
0079   G4cout << G4endl;
0080 
0081   // The same as above, but now we are looking for
0082   // sensitive detectors setting them for the volumes
0083 
0084   for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) {
0085     G4cout << "Volume " << ((*iter).first)->GetName()
0086            << " has the following list of auxiliary information: " << G4endl << G4endl;
0087     for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
0088          vit != (*iter).second.end(); vit++)
0089     {
0090       if ((*vit).type == "SensDet") {
0091         G4cout << "Attaching sensitive detector " << (*vit).value << " to volume "
0092                << ((*iter).first)->GetName() << G4endl << G4endl;
0093 
0094         G4VSensitiveDetector* mydet = SDman->FindSensitiveDetector((*vit).value);
0095         if (mydet) {
0096           G4LogicalVolume* myvol = (*iter).first;
0097           myvol->SetSensitiveDetector(mydet);
0098         }
0099         else {
0100           G4cout << (*vit).value << " detector not found" << G4endl;
0101         }
0102       }
0103     }
0104   }
0105 }