Commit 1e150694 authored by Frank Gaede's avatar Frank Gaede
Browse files

add SimpleCaloConfig w/ config parameters

parent 6b740228
......@@ -51,6 +51,7 @@
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv)
......
#ifndef SimpleCaloConfig_hh
#define SimpleCaloConfig_hh
// G4 Classes
#include "G4NistManager.hh"
#include "G4Material.hh"
#include "G4SystemOfUnits.hh"
/** Global Configuration parameters for SimpleCalo example
* Define all relevant parameters here.
* Access parameters with `SimpleCaloConfig::get().parameterName`
*/
class SimpleCaloConfig{
public:
SimpleCaloConfig(){
airMat = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
absMat = G4NistManager::Instance()->FindOrBuildMaterial("G4_W");
sensMat = G4NistManager::Instance()->FindOrBuildMaterial("G4_Si");
// absMat = G4NistManager::Instance()->FindOrBuildMaterial("G4_PbWO4");
// sensMat = G4NistManager::Instance()->FindOrBuildMaterial("G4_PbWO4");
}
bool useSamplingParameterisation = true ;
/// size of the experimental hall (cube)
G4double hallSide = 1000.*cm ;
/// number of calorimeter layers
G4int nLayers = 100 ;
/// width (in x-y) of the calorimter
G4double width = 100.*cm ;
/// absorber thickness
G4double absThickness = 2.1*mm ;
/// sensitive thickness
G4double sensThickness = 0.5*mm ;
/// z position of the face of the calorimeter
G4double zStart = 10.*cm ;
// material pointers
G4Material* airMat={} ;
G4Material* absMat={} ;
G4Material* sensMat={} ;
/// get singleton instance
static SimpleCaloConfig& get() {
static SimpleCaloConfig me ;
return me ;
}
} ;
#endif
......@@ -58,14 +58,12 @@ public:
private:
G4LogicalVolume* fLayerLogCalo;
G4LogicalVolume* fLayerLogA;
G4LogicalVolume* fLayerLogS;
G4VPhysicalVolume* fLayerPhys[100];
G4Region* fRegion;
static G4ThreadLocal GFlashShowerModel* fFastShowerModel;
// static G4ThreadLocal GFlashHomoShowerParameterisation* fParameterisation;
static G4ThreadLocal GVFlashShowerParameterisation* fParameterisation;
static G4ThreadLocal GFlashParticleBounds* fParticleBounds;
......
......@@ -36,6 +36,8 @@
#include "SimpleCaloDetectorConstruction.hh"
#include "SimpleCaloSensitiveDetector.hh"
#include "SimpleCaloConfig.hh"
// G4 Classes
#include "G4NistManager.hh"
#include "G4Material.hh"
......@@ -71,7 +73,7 @@ G4ThreadLocal GFlashHitMaker* SimpleCaloDetectorConstruction::fHitMaker = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SimpleCaloDetectorConstruction::SimpleCaloDetectorConstruction()
:G4VUserDetectorConstruction(), fLayerLogCalo{}, fLayerLogA{}, fLayerLogS{}, fLayerPhys{}, fRegion(nullptr)
:G4VUserDetectorConstruction(), fLayerLogA{}, fLayerLogS{}, fLayerPhys{}, fRegion(nullptr)
{
G4cout<<"SimpleCaloDetectorConstruction::Detector constructor"<<G4endl;
}
......@@ -91,22 +93,13 @@ SimpleCaloDetectorConstruction::~SimpleCaloDetectorConstruction()
G4VPhysicalVolume* SimpleCaloDetectorConstruction::Construct()
{
//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
G4cout << "Defining the materials" << G4endl;
// Get nist material manager
G4NistManager* nistManager = G4NistManager::Instance();
// Build materials
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
G4Material* tungsten = nistManager->FindOrBuildMaterial("G4_W");
G4Material* silicon = nistManager->FindOrBuildMaterial("G4_Si");
/*******************************
* The Experimental Hall *
*******************************/
G4double experimentalHall_x=1000.*cm;
G4double experimentalHall_y=1000.*cm;
G4double experimentalHall_z=1000.*cm;
G4double experimentalHall_x=SimpleCaloConfig::get().hallSide;
G4double experimentalHall_y=SimpleCaloConfig::get().hallSide;
G4double experimentalHall_z=SimpleCaloConfig::get().hallSide;
G4VSolid* experimentalHall_box
= new G4Box("expHall_box", // World Volume
......@@ -116,7 +109,7 @@ G4VPhysicalVolume* SimpleCaloDetectorConstruction::Construct()
G4LogicalVolume* experimentalHallLog
= new G4LogicalVolume(experimentalHall_box,
air,
SimpleCaloConfig::get().airMat,
"expHallLog",
0, //opt: fieldManager
0, //opt: SensitiveDetector
......@@ -136,15 +129,13 @@ G4VPhysicalVolume* SimpleCaloDetectorConstruction::Construct()
//------------------------------
// Simplified layered sandwich calorimeter
G4int nbOfLayers = 100; // don't change it @the moment, since
// the readout in event action assumes this
// dimensions and is not automatically adapted
// in this version of the example :-(
G4int nbOfLayers = SimpleCaloConfig::get().nLayers;
G4double calo_xside = 100*cm;
G4double calo_yside = 100*cm;
G4double calo_zAbs = 2*mm;
G4double calo_zSens = 0.5*mm;
G4double calo_xside = SimpleCaloConfig::get().width;
G4double calo_yside = SimpleCaloConfig::get().width;
G4double calo_zAbs = SimpleCaloConfig::get().absThickness;
G4double calo_zSens = SimpleCaloConfig::get().sensThickness;
G4double calo_zside = nbOfLayers * ( calo_zAbs + calo_zSens ) ;
......@@ -157,53 +148,48 @@ G4VPhysicalVolume* SimpleCaloDetectorConstruction::Construct()
G4LogicalVolume* caloLog
= new G4LogicalVolume(calo_box, // its solid
air, // its material
SimpleCaloConfig::get().airMat, // its material
"calo log", // its name
0, // opt: fieldManager
0, // opt: SensitiveDetector
0); // opt: UserLimit
G4double xpos = 0.0;
G4double ypos = 0.0;
G4double zpos = 100.0*cm;
new G4PVPlacement(0,
G4ThreeVector(xpos, ypos, zpos),
G4ThreeVector( 0.0, 0.0, SimpleCaloConfig::get().zStart ),
caloLog,
"calorimeter",
experimentalHallLog,
false,
1);
// Layers
// absorber
G4VSolid* layer_boxA
= new G4Box("LayerA", // its name
calo_xside/2,
calo_yside/2,
calo_zAbs/2);
fLayerLogA
= new G4LogicalVolume(layer_boxA, // its solid
// pbWO4, // its material
tungsten, // its material
"LayerLogA"); // its name
// sensitive
G4VSolid* layer_boxS
= new G4Box("LayerS", // its name
calo_xside/2,
calo_yside/2,
calo_zSens/2);
// Calo Layers
// absorber layer
G4VSolid* layer_boxA = new G4Box("LayerA",
calo_xside/2,
calo_yside/2,
calo_zAbs/2);
fLayerLogA = new G4LogicalVolume(layer_boxA, // its solid
SimpleCaloConfig::get().absMat,// its material
"LayerLogA"); // its name
// sensitive layer
G4VSolid* layer_boxS = new G4Box("LayerS",
calo_xside/2,
calo_yside/2,
calo_zSens/2);
fLayerLogS
= new G4LogicalVolume(layer_boxS, // its solid
// pbWO4, // its material
silicon, // its material
"LayerLogS"); // its name
fLayerLogS = new G4LogicalVolume(layer_boxS, // its solid
SimpleCaloConfig::get().sensMat, // its material
"LayerLogS"); // its name
for (G4int j=0; j<nbOfLayers; j++)
{
G4int n = j;
// place the layers, alternating absorber and sensitve starting at the face of the calorimeter
G4ThreeVector layerPosA( 0,0, ( j - nbOfLayers / 2 ) * (calo_zAbs + calo_zSens ) + calo_zAbs/2 ) ;
G4ThreeVector layerPosS( 0,0, ( j - nbOfLayers / 2 ) * (calo_zAbs + calo_zSens ) + calo_zAbs + calo_zSens/2 ) ;
......@@ -223,10 +209,9 @@ G4VPhysicalVolume* SimpleCaloDetectorConstruction::Construct()
caloLog,
false,
j);
}
}
G4cout << "There are " << nbOfLayers <<
" layers per row in the calorimeter " << G4endl;
......@@ -260,14 +245,9 @@ void SimpleCaloDetectorConstruction::ConstructSDandField()
SimpleCaloSensitiveDetector* CaloSD
= new SimpleCaloSensitiveDetector("Calorimeter",this);
SDman->AddNewDetector(CaloSD);
fLayerLogS->SetSensitiveDetector(CaloSD);
// fLayerLogCalo->SetSensitiveDetector(CaloSD);
// Get nist material manager
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
G4Material* tungsten = nistManager->FindOrBuildMaterial("G4_W");
G4Material* silicon = nistManager->FindOrBuildMaterial("G4_Si");
// -- fast simulation models:
// **********************************************
// * Initializing shower modell
......@@ -275,11 +255,16 @@ void SimpleCaloDetectorConstruction::ConstructSDandField()
G4cout << "Creating shower parameterization models" << G4endl;
fFastShowerModel = new GFlashShowerModel("fFastShowerModel", fRegion);
#if 0
fParameterisation = new GFlashHomoShowerParameterisation(pbWO4);
#else
fParameterisation = new GFlashSamplingShowerParameterisation( tungsten, silicon, 2*mm, 0.5*mm );
#endif
if( SimpleCaloConfig::get().useSamplingParameterisation ){
fParameterisation = new GFlashSamplingShowerParameterisation( SimpleCaloConfig::get().absMat, SimpleCaloConfig::get().sensMat,
SimpleCaloConfig::get().absThickness, SimpleCaloConfig::get().sensThickness );
} else {
fParameterisation = new GFlashHomoShowerParameterisation( SimpleCaloConfig::get().absMat );
}
fFastShowerModel->SetParameterisation(*fParameterisation);
// Energy Cuts to kill particles:
......
......@@ -27,7 +27,6 @@
/// \file SimpleCaloEDM4hepEventAction.cc
/// \brief Implementation of the SimpleCaloEDM4hepEventAction class
//
// Created by Joanna Weng 26.11.2004
#include "SimpleCaloEDM4hepEventAction.hh"
......@@ -148,7 +147,8 @@ void SimpleCaloEDM4hepEventAction::EndOfEventAction(const G4Event *evt)
hit.setCellID( (*THC)[i]->GetLayerNum() ) ; // fixme: add x/y coordinates ....
hit.setEnergy( (*THC)[i]->GetEdep()/GeV ) ;
totE += estep ;
hit.setEnergy( estep ) ;
G4ThreeVector hitpos=(*THC)[i]->GetPos();
G4ThreeVector l (hitpos.x(), hitpos.y(), hitpos.z());
......
......@@ -30,6 +30,7 @@
// Created by Joanna Weng 26.11.2004
#include "SimpleCaloSensitiveDetector.hh"
#include "SimpleCaloHit.hh"
#include "SimpleCaloConfig.hh"
#include "G4GFlashSpot.hh"
#include "SimpleCaloDetectorConstruction.hh"
#include "G4VPhysicalVolume.hh"
......@@ -90,17 +91,17 @@ G4bool SimpleCaloSensitiveDetector::ProcessHits(G4Step* aStep,G4TouchableHistory
if (ROhist){;}
G4VPhysicalVolume* physVol = theTouchable->GetVolume();
G4int layernum=0;
for(int i=0;i<100;i++) //@@@@@@@ SimpleCaloSensitiveDetector:vorsichty
for(int i=0;i<SimpleCaloConfig::get().nLayers;i++)
{
if(physVol == fDetector->GetLayer(i)) layernum= i;
}
caloHit->SetLayerNum(layernum);
std::cout << " ### processhit: - G4 " << caloHit->GetEdep() << " "
<< caloHit->GetPos()[0] << " "
<< caloHit->GetPos()[1] << " "
<< caloHit->GetPos()[2] << " "
<< std::endl ;
// std::cout << " ### processhit: - G4 " << caloHit->GetEdep() << " "
// << caloHit->GetPos()[0] << " "
// << caloHit->GetPos()[1] << " "
// << caloHit->GetPos()[2] << " "
// << std::endl ;
return true;
}
......@@ -122,18 +123,18 @@ G4bool SimpleCaloSensitiveDetector::ProcessHits(G4GFlashSpot*aSpot ,G4TouchableH
if (ROhist){;}
//cout <<pCurrentVolume->GetName() << endl;
G4int layernum=0;
for(int i=0;i<100;i++) //@@@@@@@ SimpleCaloSensitiveDetector:vorsichty
for(int i=0;i<SimpleCaloConfig::get().nLayers;i++)
{
if(pCurrentVolume == fDetector->GetLayer(i)) layernum= i;
}
caloHit->SetLayerNum(layernum);
std::cout << " ### processhit: - GFlash " << caloHit->GetEdep() << " "
<< caloHit->GetPos()[0] << " "
<< caloHit->GetPos()[1] << " "
<< caloHit->GetPos()[2] << " "
<< caloHit->GetLayerNum()
<< std::endl ;
// std::cout << " ### processhit: - GFlash " << caloHit->GetEdep() << " "
// << caloHit->GetPos()[0] << " "
// << caloHit->GetPos()[1] << " "
// << caloHit->GetPos()[2] << " "
// << caloHit->GetLayerNum()
// << std::endl ;
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment