43std::vector<std::vector<const G4LogicalVolume*>* >* G4GeneralCerenkov::fLV =
nullptr;
44std::vector<G4VXRayModel*>* G4GeneralCerenkov::fSharedModels =
nullptr;
54 fSharedModels =
new std::vector<G4VXRayModel*>;
55 fLV =
new std::vector<std::vector<const G4LogicalVolume*>* >;
56 fLVNames =
new std::vector<G4String>;
67 fSharedModels =
nullptr;
69 for (
auto const & p : *fLV) {
87 if (isPrepared || !isInitializer ||
nullptr == model) {
90 if (model !=
nullptr) { nam = model->
GetName(); }
91 ed <<
" Attempt to add Cerenkov model <" << nam <<
"> for LogicalVolume "
92 << nameLogVolume <<
" is failed!\n isPrepared:" << isPrepared
93 <<
" isInitilizer:" << isInitializer;
94 G4Exception(
"G4GeneralCerenkov::AddModelForVolume",
"em0304",
98 fSharedModels->push_back(model);
99 fLVNames->push_back(nameLogVolume);
106 if (isPrepared) {
return; }
116 auto nmod = fSharedModels->size();
120 fSharedModels->push_back(mod);
124 fSecondaries.reserve(fMaxPhotons);
125 nModels = (
G4int)nmod;
134 for (
G4int i=0; i<nModels; ++i) {
135 auto v =
new std::vector<const G4LogicalVolume*>;
139 for (
auto const & lv : *lvs) {
141 auto const MPT = lv->GetMaterial()->GetMaterialPropertiesTable();
142 if (
nullptr == MPT) {
continue; }
144 const G4String& lvname = lv->GetName();
147 if (!modAndVol.empty()) {
148 for (
auto const & it : modAndVol) {
149 if (it.second == lvname) {
151 (*fLV)[0]->push_back(lv);
152 fLVNames->push_back(lvname);
159 if (ok) {
continue; }
162 for (
G4int i=0; i<nModels; ++i) {
163 if (lvname == (*fLVNames)[i]) {
164 (*fLV)[i]->push_back(lv);
169 if (ok) {
continue; }
172 if (
nullptr != MPT->GetProperty(
kRINDEX)) {
173 (*fLV)[0]->push_back(lv);
174 fLVNames->push_back(lvname);
184 if (isBuilt) {
return; }
186 if (nModels == 0) {
return; }
189 if (!isInitializer) {
191 fModels.reserve(nModels);
192 for (
G4int i=0; i<nModels; ++i) {
194 fModels.push_back(newmod);
195 G4double b = newmod->Initialise((*fLV)[i]);
196 fBetaMin = std::min(fBetaMin, b);
201 for (
G4int i=0; i<nModels; ++i) {
202 G4double b = (*fSharedModels)[i]->Initialise((*fLV)[i]);
203 fBetaMin = std::min(fBetaMin, b);
204 nn += ((*fLV)[i])->size();
209 <<
" fMaxBetaChange=" << fMaxBetaChange <<
G4endl;
210 G4cout << std::setw(20) <<
"fMaxNphot=" << fMaxPhotons
211 <<
" Nlv=" << nn <<
" fStackingFlag:" << fStackingFlag
212 <<
" fTrackSecondariesFirst:" << fTrackSecondariesFirst
214 for (
G4int i=0; i<nModels; ++i) {
216 G4cout << std::setw(10) << (*fSharedModels)[i]->GetName()
217 << std::setw(30) <<
"Nvolumes=" << n <<
" Volumes:" <<
G4endl;
219 for (
G4int j=0; j<n; ++j) {
220 G4cout << (*((*fLV)[i]))[j]->GetName() <<
" ";
221 if (0 != j && (j/5)*5 == j) {
240 if (dp->GetCharge() == 0.0) {
return limit; }
241 fCurrentModel =
nullptr;
243 if (fPreStepBeta <= fBetaMin) {
return limit; }
246 if (
nullptr == volume) {
return limit; }
250 if (
nullptr == MPT) {
return limit; }
253 for (
G4int i=0; i<nModels; ++i) {
254 auto const v = (*fLV)[i];
255 std::size_t nn = v->size();
256 for (std::size_t j = 0; j < nn; ++j) {
257 if ((*v)[j] == fCurrentLV) {
258 fCurrentModel = fModels[i];
259 if (fCurrentModel->StepLimit(j, aTrack, fPreStepBeta, limit)) {
277 fCurrentModel->SampleXRays(fSecondaries, aStep);
278 if (!fSecondaries.empty()) {
283 for (
auto & t : fSecondaries) {
284 t->SetTouchableHandle(touch);
285 t->SetParentID(parent);
286 t->SetCreatorModelID(secID);
289 fSecondaries.clear();
302 out <<
"The Cerenkov effect simulates optical photons created by the\n";
303 out <<
"passage of charged particles through matter. Materials need\n";
304 out <<
"to have the property RINDEX (refractive index) defined." <<
G4endl;
310 fTrackSecondariesFirst = state;
312 fTrackSecondariesFirst);
318 fMaxBetaChange = value;
325 fMaxPhotons = NumPhotons;
332 fStackingFlag = stackingFlag;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void PreparePhysicsTable(const G4ParticleDefinition &part) override
G4GeneralCerenkov(const G4String &processName="Cerenkov", G4ProcessType type=fElectromagnetic)
~G4GeneralCerenkov() override
void SetTrackSecondariesFirst(const G4bool state)
void AddModelForVolume(G4VXRayModel *, const G4String &nameLogVolume)
void SetMaxBetaChangePerStep(const G4double d)
void SetStackPhotons(const G4bool)
G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
void SetMaxNumPhotonsPerStep(const G4int NumPhotons)
void SetVerboseLevel(G4int)
void BuildPhysicsTable(const G4ParticleDefinition &aParticleType) override
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *) override
void ProcessDescription(std::ostream &out) const override
G4double PostStepGetPhysicalInteractionLength(const G4Track &aTrack, G4double, G4ForceCondition *) override
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override
G4LogicalVolumeStore is a singleton class, acting as container for all logical volumes,...
static G4LogicalVolumeStore * GetInstance()
G4Material * GetMaterial() const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
void SetCerenkovMaxBetaChange(G4double)
void SetCerenkovMaxPhotonsPerStep(G4int)
G4int GetCerenkovVerboseLevel() const
const std::vector< std::pair< G4XRayModelType, const G4String > > & ActiveVolumes() const
G4int GetCerenkovMaxPhotonsPerStep() const
static G4OpticalParameters * Instance()
G4double GetCerenkovMaxBetaChange() const
void SetCerenkovStackPhotons(G4bool)
void SetCerenkovTrackSecondariesFirst(G4bool)
void SetCerenkovVerboseLevel(G4int)
G4bool GetCerenkovTrackSecondariesFirst() const
G4bool GetCerenkovStackPhotons() const
static G4int GetModelID(const G4int modelIndex)
const G4TouchableHandle & GetTouchableHandle() const
G4StepPoint * GetPreStepPoint() const
G4TrackStatus GetTrackStatus() const
G4VPhysicalVolume * GetVolume() const
const G4DynamicParticle * GetDynamicParticle() const
G4VDiscreteProcess(const G4String &aName, G4ProcessType aType=fNotDefined)
G4LogicalVolume * GetLogicalVolume() const
G4ParticleChange aParticleChange
void SetProcessSubType(G4int)
const G4String & GetProcessName() const
const G4String & GetName() const