File indexing completed on 2025-01-31 09:21:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "doiPETRun.hh"
0035 #include "doiPETDetectorConstruction.hh"
0036 #include "doiPETPrimaryGeneratorAction.hh"
0037
0038 #include "G4UnitsTable.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4Event.hh"
0041 #include "doiPETAnalysis.hh"
0042
0043
0044 doiPETRun::doiPETRun()
0045 : G4Run()
0046 {
0047
0048 totalTime = 0 * s;
0049 prev_totalTime = 0 * s;
0050 totalEdep = 0*keV;
0051 }
0052
0053
0054
0055 doiPETRun::~doiPETRun()
0056 {}
0057
0058
0059 void doiPETRun::GetIntractionInfomation(InteractionInformation*step)
0060 {
0061
0062
0063 mapBlockInteraction.insert( std::multimap< G4int, InteractionInformation* >::value_type( step->GetBlockNo(), step) );
0064
0065
0066 setBlockInteraction.insert( step->GetBlockNo());
0067 }
0068
0069
0070
0071 void doiPETRun::FindInteractingCrystal()
0072 {
0073 std::multimap< G4int, InteractionInformation* >::iterator mitr;
0074 std::set<G4int>::iterator sitr;
0075 G4int cystalIDTemp;
0076
0077 for(sitr=setBlockInteraction.begin(); sitr!=setBlockInteraction.end(); sitr++){
0078 blockID = (*sitr);
0079 mitr = mapBlockInteraction.find(blockID);
0080 numberofInteractions = mapBlockInteraction.count(blockID);
0081 totalEdep=edepMax=0.;
0082 for(G4int i=0; i<numberofInteractions; i++, mitr++){
0083 edep = (*mitr).second->GetEdep();
0084 cystalIDTemp = (*mitr).second->GetCrystalNo();
0085 edep_AfterCrystalBlurring = doiPETAnalysis::GetInstance()->QuantumEffifciency(edep, blockID, cystalIDTemp);
0086 totalEdep += edep_AfterCrystalBlurring;
0087
0088 crystalID_vec.push_back(cystalIDTemp);
0089 posInter_vec.push_back(((*mitr).second->GetInteractionPositionInCrystal()));
0090 edepInCry_vec.push_back(edep_AfterCrystalBlurring);
0091
0092
0093 if(edepMax<edep_AfterCrystalBlurring){
0094 edepMax=edep_AfterCrystalBlurring;
0095 crystalID = cystalIDTemp;
0096 interactionTime = (*mitr).second->GetGlobalTime();
0097
0098
0099
0100 }
0101 }
0102 if(totalEdep==0)continue;
0103
0104
0105 interactionPos = CenterOfMassInteractionPos(crystalID_vec, edepInCry_vec, totalEdep, posInter_vec);
0106 doiPETAnalysis::GetInstance()->ReadOut(blockID,crystalID,interactionTime,timeOfAnnihil,interactionPos,totalEdep);
0107
0108 crystalID_vec.clear();
0109 posInter_vec.clear();
0110 edepInCry_vec.clear();
0111 }
0112
0113 }
0114
0115
0116 G4ThreeVector doiPETRun::CenterOfMassInteractionPos(const std::vector<G4int> &cryID, const std::vector<G4double> &energyDep, G4double edepTotal, const std::vector<G4ThreeVector> &pos){
0117 posInterInCrystal = G4ThreeVector();
0118 for(std::size_t i=0; i<cryID.size();i++){
0119 posInterInCrystal += pos[i] * energyDep[i];
0120 }
0121 return (posInterInCrystal)/edepTotal;
0122 }
0123
0124
0125 void doiPETRun::SetAnnihilationTime(G4double t){
0126 timeOfAnnihil = t;
0127 }
0128
0129 void doiPETRun::Clear(){
0130
0131 std::multimap< G4int, InteractionInformation* >::iterator mitr2;
0132 for( mitr2= mapBlockInteraction.begin(); mitr2!=mapBlockInteraction.end(); mitr2++){
0133 delete (*mitr2).second;
0134 }
0135
0136 mapBlockInteraction.clear();
0137 setBlockInteraction.clear();
0138
0139 }
0140
0141 void doiPETRun::GetEventIDRun(G4int evt){
0142 eventID = evt;
0143 }
0144
0145
0146
0147 void doiPETRun::Merge(const G4Run* run)
0148 {
0149 G4Run::Merge(run);
0150 }