// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // -------------------------------------------------------------- // GEANT 4 - SoLid // // For information related to this code contact: Mariangela Settimo // e-mail: mariangela.settimo@gmail.com // -------------------------------------------------------------- // Comments // // // by Mariangela Settimo - Subatech // (14th April 2017) // // PVTSD (PVT sensitive detector definition) // -------------------------------------------------------------- #include "SolidPVTSD.hh" #include "SolidPVTHit.hh" #include "Phase1DetectorConstruction.hh" #include "SolidDetectorConstruction.hh" #include "G4VPhysicalVolume.hh" #include "G4HCofThisEvent.hh" #include "G4Step.hh" #include "G4SDManager.hh" #include "G4ParticleDefinition.hh" #include "G4ParticleTypes.hh" #include "G4VProcess.hh" #include "G4ProcessType.hh" #include "G4Ions.hh" #include "G4ios.hh" #include #include "G4OpticalPhoton.hh" #include "SolidUtils.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... SolidPVTSD::SolidPVTSD(G4String name) :G4VSensitiveDetector(name) { G4String HCname; if (name == "/SolidDet/ScintSD") HCname="pvtCollection"; //if (name == "/SolidDet/Li6SD") // HCname="liCollection"; collectionName.insert(HCname); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... SolidPVTSD::~SolidPVTSD(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SolidPVTSD::Initialize(G4HCofThisEvent*) { pvtCollection = new SolidPVTHitsCollection(SensitiveDetectorName,collectionName[0]); // liCollection = new SolidPVTHitsCollection(SensitiveDetectorName,collectionName[1]); HitID = -1; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... G4bool SolidPVTSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // G4cout << " Process Hits for " << aStep->GetTrack()->GetTrackID() << G4endl; //================================== // info for T5 - info cube-wise //================================== G4int trackID = aStep->GetTrack()->GetTrackID(); G4int motherID = aStep->GetTrack()->GetParentID(); G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition(); G4int particlePDG = particle->GetPDGEncoding(); G4double edep = aStep->GetTotalEnergyDeposit(); G4double trkLength = aStep->GetStepLength(); G4StepPoint* thePrePoint = aStep->GetPreStepPoint(); G4double time = thePrePoint->GetGlobalTime(); if (edep<=0) return false; if (aStep->GetPreStepPoint()->GetWeight()>0) { edep *= aStep->GetPreStepPoint()->GetWeight(); trkLength *= aStep->GetPreStepPoint()->GetWeight(); } /**************************************************************** * get the correct cube id ****************************************************************/ G4int cubeID = -100; G4int LiID = 0; G4TouchableHandle thePrePointTouch = thePrePoint->GetTouchableHandle(); G4String endvol = aStep->GetTrack()->GetVolume()->GetName(); G4String layer = ""; G4int moduleID = -1; G4int planeID = -1; G4int detModID = -1; if (endvol == "physPVT" || endvol == "physBacking" || endvol == "physTyvek") layer = "PVT"; else if (endvol == "physLi") layer = "Li"; if( endvol == "physPVT" || endvol == "physLi" || endvol == "physBacking" || endvol == "physTyvek" ) { moduleID = thePrePointTouch->GetCopyNumber(3); // it is zero for NEMENIX & SM1 planeID = thePrePointTouch->GetCopyNumber(2); // it is zero for NEMENIX detModID = thePrePointTouch->GetCopyNumber(1); cubeID = 10000*(10*moduleID + planeID) + detModID; LiID = aStep->GetTrack()->GetVolume()->GetCopyNo(); // 0 for punched LiF:ZnS, 1 for plain LiF:ZnS // printf("%12s, Li: %d, module: %d, plane: %d, detMod: %4d ==> cube: %6d \n", endvol.data(), LiID, moduleID, planeID, detModID, cubeID); } /****************************************************************/ G4int volID = GetVolID(endvol, LiID); G4bool isFibre = IsVolInsideFibre(endvol); G4int cubeIDmod = volID; // initialisation value if (volID == 15) cubeIDmod = cubeID*10; //PVT else if (volID == 20) cubeIDmod = cubeID*10 + 1; //Li X else if (volID == 21) cubeIDmod = cubeID*10 + 2; //Li Z else if (volID == 30) cubeIDmod = cubeID*10 + 3; //LiBack X else if (volID == 31) cubeIDmod = cubeID*10 + 4; //LiBack Z else if (volID == 40) cubeIDmod = cubeID*10 + 5; //tyvek coating else if( isFibre ) cubeIDmod = 5000000 + cubeID; //else G4cout << " test : volID: " << volID << " " << cubeIDmod << G4endl; cubeIDmod += 1e9; // fill in hit SolidPVTHit* newHit = new SolidPVTHit(); G4ThreeVector Pos = thePrePoint->GetPosition(); //This gives the positon of the edep point inside the current volume G4ThreeVector localPosition = thePrePointTouch->GetHistory()->GetTopTransform().TransformPoint(Pos); //Current Volume Translation wrt the mother physDetMod G4ThreeVector EdepVolumePos = thePrePointTouch->GetVolume()->GetTranslation(); //Edep position wrt to the physDetMod reference system G4ThreeVector EdepPos_ref = localPosition + EdepVolumePos; /* //for info : alternative method providing same results : G4ThreeVector origin = aStep->GetTrack()->GetVolume()->GetTranslation(); G4ThreeVector EdepPos1 = localPosition + origin; //show results for the 2 methods, these 6 lines are only for testing, it can be commented or removed G4cout << cubeID << " " << cubeIDmod << " Edep Local Pos: " << localPosition.x() << " " << localPosition.y() << " " << localPosition.z() << G4endl ; G4cout << cubeID << " " << cubeIDmod << " Origin Pos Mary: " << origin.x() << " " << origin.y() << " " << origin.z() << G4endl ; G4cout << cubeID << " " << cubeIDmod << " Edep Pos (Ref 1): " << EdepPos1.x() << " " << EdepPos1.y() << " " << EdepPos1.z() << G4endl ; G4cout << cubeID << " " << cubeIDmod << " Edep Local Pos: " << localPosition.x() << " " << localPosition.y() << " " << localPosition.z() << G4endl ; G4cout << cubeID << " " << cubeIDmod << " Edep Volume Pos: " << EdepVolumePos.x() << " " << EdepVolumePos.y() << " " << EdepVolumePos.z() << G4endl ; G4cout << cubeID << " " << cubeIDmod << " Edep Pos (Ref 2): " << EdepPos_ref.x() << " " << EdepPos_ref.y() << " " << EdepPos_ref.z() << G4endl ; */ newHit->SetTrackID(trackID); newHit->SetEdep(edep); newHit->SetTime(time); newHit->SetLayerName(layer); newHit->SetParticlePDG(particlePDG); newHit->SetCubeID(cubeIDmod); newHit->SetTrackLength(trkLength); newHit->SetMotherID(motherID); newHit->SetPositionX(EdepPos_ref.x()); newHit->SetPositionY(EdepPos_ref.y()); newHit->SetPositionZ(EdepPos_ref.z()); HitID = pvtCollection->insert(newHit); return true; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SolidPVTSD::EndOfEvent(G4HCofThisEvent* HCE) { // G4AnalysisManager* man = G4AnalysisManager::Instance(); G4String HCname = collectionName[0]; static G4int HCID = -1; if(HCID<0) HCID = G4SDManager::GetSDMpointer()->GetCollectionID(HCname); HCE->AddHitsCollection(HCID,pvtCollection); G4int nHits = pvtCollection->entries(); if (verboseLevel>=1) G4cout << " PVT collection: " << nHits << " hits" << G4endl; if (verboseLevel>=2) pvtCollection->PrintAllHits(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SolidPVTSD::clear() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SolidPVTSD::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... void SolidPVTSD::PrintAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....