BGO done and working

This commit is contained in:
Peter DeRosa 2022-12-15 14:53:07 -05:00
parent a1c098e50d
commit bfa90c7459
5 changed files with 34 additions and 24 deletions

Binary file not shown.

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.d
*.so
*.swp
*.swo

View File

@ -1,5 +1,6 @@
#include "CloverCrystalSD.hh"
//#include "CloverCrystalSD.hh"
#include "BGOSD.hh"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
@ -10,7 +11,8 @@
///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CloverCrystalSD::CloverCrystalSD(const G4String& name, const G4String& hitsCollectionName, const G4int nCrystal)
//CloverCrystalSD::CloverCrystalSD(const G4String& name, const G4String& hitsCollectionName, const G4int nCrystal)
BGOSD::BGOSD(const G4String& name, const G4String& hitsCollectionName, const G4int nCrystal)
: G4VSensitiveDetector(name),
fHitsCollection(nullptr),
fNDet(nCrystal)
@ -20,23 +22,26 @@ CloverCrystalSD::CloverCrystalSD(const G4String& name, const G4String& hitsColle
///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CloverCrystalSD::~CloverCrystalSD()
//CloverCrystalSD::~CloverCrystalSD()
BGOSD::~BGOSD()
{
}
///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CloverCrystalSD::Initialize(G4HCofThisEvent* hce)
//void CloverCrystalSD::Initialize(G4HCofThisEvent* hce)
void BGOSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection = new CloverCrystalHitsCollection(SensitiveDetectorName, collectionName[0]);
//fHitsCollection = new CloverCrystalHitsCollection(SensitiveDetectorName, collectionName[0]);
fHitsCollection = new BGOHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
for (G4int i=0; i<fNDet; i++ ) {
fHitsCollection->insert(new CloverCrystalHit());
fHitsCollection->insert(new BGOHit());
}
//G4cout << "######### size of fHitCollection : " << fHitsCollection->GetSize() << G4endl;
@ -45,7 +50,8 @@ void CloverCrystalSD::Initialize(G4HCofThisEvent* hce)
///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool CloverCrystalSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
//G4bool CloverCrystalSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
G4bool BGOSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
{
// energy deposit
@ -59,22 +65,23 @@ G4bool CloverCrystalSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*
if ( edep==0. && stepLength == 0. ) return false;
G4int crystalID = step->GetPreStepPoint()->GetTouchableHandle() ->GetCopyNumber();
G4int BGOID = step->GetPreStepPoint()->GetTouchableHandle() ->GetCopyNumber();
//----------- save hit in each crystal
CloverCrystalHit * hit = (*fHitsCollection)[crystalID];
BGOHit * hit = (*fHitsCollection)[BGOID];
hit->SetTrackID (step->GetTrack()->GetTrackID());
hit->SetEdep(edep);
hit->SetPos (step->GetPostStepPoint()->GetPosition());
hit->SetStepLength( stepLength);
hit->SetCrystalID(crystalID);
hit->SetBGOID(BGOID);
//---------- Save indivual hit
CloverCrystalHit* newHit = new CloverCrystalHit();
// CloverCrystalHit* newHit = new CloverCrystalHit();
BGOHit* newHit = new BGOHit();
newHit->SetTrackID (step->GetTrack()->GetTrackID());
newHit->SetCrystalID(crystalID);
newHit->SetBGOID(BGOID);
newHit->SetEdep(edep);
newHit->SetPos (step->GetPostStepPoint()->GetPosition());
newHit->SetStepLength( stepLength);
@ -87,7 +94,8 @@ G4bool CloverCrystalSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*
///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CloverCrystalSD::EndOfEvent(G4HCofThisEvent*)
//void CloverCrystalSD::EndOfEvent(G4HCofThisEvent*)
void BGOSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel > 1 ) {
G4int nofHits = fHitsCollection->GetSize();

View File

@ -44,7 +44,7 @@ G4GlobalMagFieldMessenger* CloverDetectorConstruction::fMagFieldMessenger = 0;
CloverDetectorConstruction::CloverDetectorConstruction()
: G4VUserDetectorConstruction(),
fNumOfCrystal(0),
fLogicBGO(NULL), fLogicCrystal(NULL), fCrystalMaterial(NULL),
fLogicCrystal(NULL), fLogicBGO(NULL), fCrystalMaterial(NULL),
fCheckOverlaps(true)
{
fNumOfCrystal = Crystal_Num; //also need to change the fNDet in CloverEventAction.cc
@ -56,7 +56,7 @@ CloverDetectorConstruction::CloverDetectorConstruction()
CloverDetectorConstruction::~CloverDetectorConstruction()
{
delete [] fLogicCrystal;
delete [] fLogicCrystal;
delete [] fLogicBGO;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@ -327,7 +327,7 @@ G4VPhysicalVolume* CloverDetectorConstruction::DefineVolumes()
if( jCrystal == 0 ) {
caseLV[iClover] = new G4LogicalVolume(casing, G4Material::GetMaterial("G4_Al"), "Case");
fLogicBGO[iClover] = new G4LogicalVolume(bgo , G4Material::GetMaterial("G4_Al"), "BGO ");
fLogicBGO[iClover] = new G4LogicalVolume(bgo , G4Material::GetMaterial("G4_Al"), "BGOLV");
bgowindowLV[iClover] = new G4LogicalVolume(bgowindow, G4Material::GetMaterial("G4_Al"), "BGO WINDOW ");
new G4PVPlacement( rotmat , // case orientation
@ -342,7 +342,7 @@ G4VPhysicalVolume* CloverDetectorConstruction::DefineVolumes()
new G4PVPlacement( bgomat , // bgo orientation
bgo_pos, // bgo location
fLogicBGO[i/4], // its logical volume
"Bgo", // its name
"BGO", // its name
worldLV, // its mother volume
false, // no boolean operation
iClover, // copy number

View File

@ -28,9 +28,9 @@
CloverEventAction::CloverEventAction()
: G4UserEventAction(),
fCrystalHCID(-1),
fNDet(Crystal_Num), // number of crystal
fBGOHCID(-1),
fNBGODet(Crystal_Num/4) // number of bgo
fNBGODet(Crystal_Num/4), // number of bgo
fNDet(Crystal_Num) // number of crystal
{
fdEList.clear();
fdLList.clear();
@ -173,12 +173,12 @@ void CloverEventAction::EndOfEventAction(const G4Event* event)
*/
fdEList[i] = edep * resol * 1000; // to keV
fdLList[i] = crystalHit->GetStepLength();
// std::cout<< "crystalhere "<< i << ", " << fdEList[i] << std::endl;
}
auto BGOHC = GetHitsBGOCollection(fBGOHCID, event); //this is G4VHitsCollection
for( int i = 0 ; i < fNDet ; i++){
for( int i = 0 ; i < fNBGODet ; i++){
BGOHit * bgoHit = (*BGOHC)[i]; //this is CloverCrystalHit :: G4VHit
//add detector resolution of 1%
@ -206,6 +206,7 @@ void CloverEventAction::EndOfEventAction(const G4Event* event)
fBEList[i] = edep * resol * 1000; // to keV
fBLList[i] = bgoHit->GetStepLength();
// std::cout<< "bgohere "<< i << ", " << fBEList[i] << std::endl;
}
// get analysis manager
@ -214,9 +215,9 @@ void CloverEventAction::EndOfEventAction(const G4Event* event)
// fill ntuple
analysisManager->FillNtupleIColumn(0, n_trajectories);
analysisManager->FillNtupleDColumn(3, beamEnergy);
analysisManager->FillNtupleDColumn(4, beamTheta);
analysisManager->FillNtupleDColumn(5, beamPhi);
analysisManager->FillNtupleDColumn(5, beamEnergy);
analysisManager->FillNtupleDColumn(6, beamTheta);
analysisManager->FillNtupleDColumn(7, beamPhi);
analysisManager->AddNtupleRow();