File indexing completed on 2025-02-25 09:22:34
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
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #include "GRRun.hh"
0045 #include "GRRunAction.hh"
0046
0047 #include "G4AnalysisManager.hh"
0048 #include "G4MultiFunctionalDetector.hh"
0049 #include "G4VPrimitiveScorer.hh"
0050
0051 #include "G4PrimaryVertex.hh"
0052 #include "G4PrimaryParticle.hh"
0053
0054 GRRun::GRRun(GRRunAction* ra) : G4Run(),pRA(ra)
0055 {
0056 ;
0057 }
0058
0059 GRRun::~GRRun()
0060 {
0061 ;
0062 }
0063
0064 void GRRun::RecordEvent(const G4Event* anEvent)
0065 {
0066
0067 numberOfEvent++;
0068
0069 G4HCofThisEvent* pHCE = anEvent->GetHCofThisEvent();
0070
0071 auto analysisManager = G4AnalysisManager::Instance();
0072 auto map = pRA->IDMap;
0073 for(auto itr : map)
0074 {
0075 if(itr.second->pplotter!=nullptr) continue;
0076
0077 auto cID = itr.second->collID;
0078 auto hID = itr.second->histID;
0079 auto hTyp = itr.second->histType;
0080
0081 if(hTyp==1)
0082 {
0083 if(cID>=0)
0084 {
0085 if(!pHCE) continue;
0086 auto score = (G4THitsMap<G4double>*)(pHCE->GetHC(cID));
0087 G4double val = 0.;
0088 for(auto hItr : *score)
0089 {
0090 if(itr.second->idx==-1 || itr.second->idx==hItr.first)
0091 { val += *(hItr.second); }
0092 }
0093 analysisManager->FillH1(hID,val);
0094 }
0095 else
0096 {
0097 auto pv = anEvent->GetPrimaryVertex();
0098 while(pv)
0099 {
0100 auto pp = pv->GetPrimary();
0101 while(pp)
0102 {
0103 auto primE = pp->GetKineticEnergy();
0104 G4double weight = 1.0;
0105 if(itr.second->biasf) weight = pp->GetWeight();
0106 analysisManager->FillH1(hID,primE,weight);
0107 pp = pp->GetNext();
0108 }
0109 pv = pv->GetNext();
0110 }
0111 }
0112 }
0113
0114 else if(hTyp==2)
0115 {
0116 if(!pHCE) continue;
0117 auto score = (G4THitsMap<G4double>*)(pHCE->GetHC(cID));
0118 for(auto hItr : *score)
0119 { analysisManager->FillP1(hID,G4double(hItr.first),*(hItr.second)); }
0120 }
0121
0122 }
0123
0124 auto ntmap = pRA->NTMap;
0125 if(ntmap.size()>0)
0126 {
0127 for(auto ntitr : ntmap)
0128 {
0129 auto colID = ntitr.first;
0130 auto cID = ntitr.second->collID;
0131 G4double val = 0.;
0132 if(cID>=0)
0133 {
0134 if(!pHCE) continue;
0135 auto score = (G4THitsMap<G4double>*)(pHCE->GetHC(cID));
0136 for(auto hItr : *score)
0137 {
0138 if(ntitr.second->idx==-1 || ntitr.second->idx==hItr.first)
0139 { val += *(hItr.second); }
0140 }
0141 }
0142 else
0143 {
0144 auto pv = anEvent->GetPrimaryVertex();
0145 auto pp = pv->GetPrimary();
0146 val = pp->GetKineticEnergy();
0147 }
0148 analysisManager->FillNtupleDColumn(colID,val*(ntitr.second->fuct));
0149 }
0150 analysisManager->AddNtupleRow();
0151 }
0152
0153 }
0154
0155 void GRRun::Merge(const G4Run * aRun)
0156 {
0157 G4Run::Merge(aRun);
0158 }
0159
0160