Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
RadioBio::RBE Class Reference

#include <Doxymodules_medical.h>

Inheritance diagram for RadioBio::RBE:
RadioBio::VRadiobiologicalQuantity

Public Member Functions

 RBE ()
 
 ~RBE ()
 
void LoadLEMTable (G4String path)
 
void SetCellLine (G4String name)
 
std::tuple< G4double, G4double > GetHitAlphaAndBeta (G4double E, G4int Z)
 
void AddFromAccumulable (G4VAccumulable *) override
 
void Initialize () override
 
void Compute () override
 
void Reset () override
 
void Store () override
 
void PrintParameters () override
 
- Public Member Functions inherited from RadioBio::VRadiobiologicalQuantity
 VRadiobiologicalQuantity ()
 
virtual ~VRadiobiologicalQuantity ()
 
G4bool IsCalculationEnabled () const
 
G4bool HasBeenCalculated () const
 
void SetCalculationEnabled (G4bool enabled)
 
void SetVerboseLevel (G4int level)
 
G4int GetVerboseLevel () const
 
void SetPath (G4String fN)
 
void PrintVirtualParameters ()
 

Private Types

using vector_type = std::map< G4int, std::vector< G4double > >
 

Private Member Functions

void ComputeAlphaAndBeta ()
 
void ComputeRBE ()
 
void StoreAlphaAndBeta ()
 
void StoreRBE ()
 
void SetAlphaNumerator (const array_type alpha)
 
void SetBetaNumerator (const array_type beta)
 
void SetDenominator (const array_type denom)
 
void AddAlphaNumerator (const array_type alpha)
 
void AddBetaNumerator (const array_type beta)
 
void AddDenominator (const array_type denom)
 
void GetDose ()
 

Private Attributes

G4double fAlphaX = 0.
 
G4double fBetaX = 0.
 
G4double fDoseCut = 0.
 
array_type fAlpha = {}
 
array_type fBeta = {}
 
array_type fDose = {}
 
array_type fAlphaNumerator = {}
 
array_type fBetaNumerator = {}
 
array_type fDenominator = {}
 
array_type fLnS = {}
 
array_type fSurvival = {}
 
array_type fDoseX = {}
 
array_type fRBE = {}
 
std::map< G4String, vector_typefTablesEnergy = {}
 
std::map< G4String, vector_typefTablesAlpha = {}
 
std::map< G4String, vector_typefTablesBeta = {}
 
std::map< G4String, G4double > fTablesAlphaX = {}
 
std::map< G4String, G4double > fTablesBetaX = {}
 
std::map< G4String, G4double > fTablesDoseCut = {}
 
G4String fActiveCellLine
 
vector_typefActiveTableEnergy = nullptr
 
vector_typefActiveTableAlpha = nullptr
 
vector_typefActiveTableBeta = nullptr
 
std::map< G4int, G4double > fMaxEnergies = {}
 
std::map< G4int, G4double > fMinEnergies = {}
 
G4int fMinZ = -1
 
G4int fMaxZ = -1
 

Additional Inherited Members

- Public Types inherited from RadioBio::VRadiobiologicalQuantity
using array_type = std::valarray< G4double >
 
- Protected Attributes inherited from RadioBio::VRadiobiologicalQuantity
G4UImessengerfMessenger = nullptr
 
G4int fVerboseLevel = 1
 
G4bool fInitialized = false
 
G4bool fSaved = false
 
G4bool fCalculated = false
 
G4String fPath
 
G4bool fCalculationEnabled = false
 

Detailed Description

Definition at line 141 of file Doxymodules_medical.h.

Member Typedef Documentation

◆ vector_type

using RadioBio::RBE::vector_type = std::map<G4int, std::vector<G4double> >
private

Definition at line 116 of file RBE.hh.

Constructor & Destructor Documentation

◆ RBE()

RadioBio::RBE::RBE ( )

Definition at line 62 of file RBE.cc.

63{
64 fPath = "RadioBio";
65
66 // CreateMessenger
67 fMessenger = new RBEMessenger(this);
68
69 Initialize();
70}
void Initialize() override
Definition RBE.cc:81

◆ ~RBE()

RadioBio::RBE::~RBE ( )

Definition at line 74 of file RBE.cc.

75{
76 delete fMessenger;
77}

Member Function Documentation

◆ LoadLEMTable()

void RadioBio::RBE::LoadLEMTable ( G4String  path)

Definition at line 146 of file RBE.cc.

147{
148 std::ifstream in(path);
149 if (!in) {
150 std::stringstream ss;
151 ss << "Cannot open LEM table input file: " << path;
152 G4Exception("RBE::LoadData", "WrongTable", FatalException, ss.str().c_str());
153 }
154
155 // Start with the first line
156 G4String line;
157 if (!getline(in, line)) {
158 std::stringstream ss;
159 ss << "Cannot read header from the LEM table file: " << path;
160 G4Exception("RBE::LoadLEMTable", "CannotReadHeader", FatalException, ss.str().c_str());
161 }
162 std::vector<G4String> header = split(line, ",");
163
164 // Find the order of columns
165 std::vector<G4String> columns = {"alpha_x", "beta_x", "D_t", "specific_energy",
166 "alpha", "beta", "cell", "particle"};
167 std::map<G4String, int> columnIndices;
168 for (auto columnName : columns) {
169 auto pos = find(header.begin(), header.end(), columnName);
170 if (pos == header.end()) {
171 std::stringstream ss;
172 ss << "Column " << columnName << " not present in the LEM table file.";
173 G4Exception("RBE::LoadLEMTable", "ColumnNotPresent", FatalException, ss.str().c_str());
174 }
175 else {
176 columnIndices[columnName] = distance(header.begin(), pos);
177 }
178 }
179
180 // Continue line by line
181 while (getline(in, line)) {
182 std::vector<G4String> lineParts = split(line, ",");
183 G4String cellLine = lineParts[columnIndices["cell"]];
184 // G4int element = elements.at(lineParts[columnIndices["particle"]]);
185 G4NistManager* man = G4NistManager::Instance();
186 G4int element = man->FindOrBuildElement(lineParts[columnIndices["particle"]])->GetZasInt();
187
188 fTablesEnergy[cellLine][element].push_back(
189 std::stod(lineParts[columnIndices["specific_energy"]]) * MeV);
190 fTablesAlpha[cellLine][element].push_back(stod(lineParts[columnIndices["alpha"]]));
191 /* fTablesLet[cellLine][element].push_back(
192 stod(lineParts[columnIndices["let"]])
193 ); */
194 fTablesBeta[cellLine][element].push_back(stod(lineParts[columnIndices["beta"]]));
195
196 fTablesAlphaX[cellLine] = stod(lineParts[columnIndices["alpha_x"]]) / gray;
197 fTablesBetaX[cellLine] = stod(lineParts[columnIndices["beta_x"]]) / (gray * gray);
198 fTablesDoseCut[cellLine] = stod(lineParts[columnIndices["D_t"]]) * gray;
199 }
200
201 // Sort the tables by energy
202 // (https://stackoverflow.com/a/12399290/2692780)
203 for (auto aPair : fTablesEnergy) {
204 for (auto ePair : aPair.second) {
205 std::vector<G4double>& tableEnergy = fTablesEnergy[aPair.first][ePair.first];
206 std::vector<G4double>& tableAlpha = fTablesAlpha[aPair.first][ePair.first];
207 std::vector<G4double>& tableBeta = fTablesBeta[aPair.first][ePair.first];
208
209 std::vector<size_t> idx(tableEnergy.size());
210 iota(idx.begin(), idx.end(), 0);
211 std::sort(idx.begin(), idx.end(),
212 [&tableEnergy](size_t i1, size_t i2) { return tableEnergy[i1] < tableEnergy[i2]; });
213
214 std::vector<std::vector<G4double>*> tables = {&tableEnergy, &tableAlpha, &tableBeta};
215 for (std::vector<G4double>* table : tables) {
216 std::vector<G4double> copy = *table;
217 for (size_t i = 0; i < copy.size(); ++i) {
218 (*table)[i] = copy[idx[i]];
219 }
220 // G4cout << (*table)[0];
221 // reorder(*table, idx);
222 // G4cout << (*table)[0] << G4endl;
223 }
224 }
225 }
226
227 if (fVerboseLevel > 0) {
228 G4cout << "RBE: read LEM data for the following cell lines and elements [number of points]:"
229 << G4endl;
230 for (auto aPair : fTablesEnergy) {
231 G4cout << "- " << aPair.first << ": ";
232 for (auto ePair : aPair.second) {
233 G4cout << ePair.first << "[" << ePair.second.size() << "] ";
234 }
235 G4cout << G4endl;
236 }
237 }
238}
std::map< G4String, vector_type > fTablesEnergy
Definition RBE.hh:117
std::map< G4String, G4double > fTablesAlphaX
Definition RBE.hh:120
std::map< G4String, G4double > fTablesDoseCut
Definition RBE.hh:122
std::map< G4String, vector_type > fTablesAlpha
Definition RBE.hh:118
std::map< G4String, vector_type > fTablesBeta
Definition RBE.hh:119
std::map< G4String, G4double > fTablesBetaX
Definition RBE.hh:121
std::vector< G4String > split(const G4String &line, const G4String &delimiter)
Split string into parts using a delimiter.
Definition RBE.cc:124

◆ SetCellLine()

void RadioBio::RBE::SetCellLine ( G4String  name)

Definition at line 242 of file RBE.cc.

243{
244 G4cout << "*************************" << G4endl << "*******SetCellLine*******" << G4endl
245 << "*************************" << G4endl;
246 if (fTablesEnergy.size() == 0) {
247 G4Exception("RBE::SetCellLine", "NoCellLine", FatalException,
248 "Cannot select cell line, probably LEM table not loaded yet?");
249 }
250 if (fTablesEnergy.find(name) == fTablesEnergy.end()) {
251 std::stringstream str;
252 str << "Cell line " << name << " not found in the LEM table.";
253 G4Exception("RBE::SetCellLine", "", FatalException, str.str().c_str());
254 }
255 else {
256 fAlphaX = fTablesAlphaX[name];
257 fBetaX = fTablesBetaX[name];
258 fDoseCut = fTablesDoseCut[name];
259
263
264 fMinZ = 0;
265 fMaxZ = 0;
266 fMinEnergies.clear();
267 fMaxEnergies.clear();
268
269 for (auto energyPair : *fActiveTableEnergy) {
270 if (!fMinZ || (energyPair.first < fMinZ)) fMinZ = energyPair.first;
271 if (energyPair.first > fMaxZ) fMaxZ = energyPair.first;
272
273 fMinEnergies[energyPair.first] = energyPair.second[0];
274 fMaxEnergies[energyPair.first] = energyPair.second[energyPair.second.size() - 1];
275 }
276 }
277
278 fActiveCellLine = name;
279
280 if (fVerboseLevel > 0) {
281 G4cout << "RBE: cell line " << name << " selected." << G4endl;
282 }
283}
vector_type * fActiveTableAlpha
Definition RBE.hh:128
G4int fMinZ
Definition RBE.hh:132
vector_type * fActiveTableEnergy
Definition RBE.hh:127
vector_type * fActiveTableBeta
Definition RBE.hh:129
std::map< G4int, G4double > fMaxEnergies
Definition RBE.hh:130
G4double fDoseCut
Definition RBE.hh:98
G4String fActiveCellLine
Definition RBE.hh:126
std::map< G4int, G4double > fMinEnergies
Definition RBE.hh:131
G4double fAlphaX
Definition RBE.hh:96
G4double fBetaX
Definition RBE.hh:97
G4int fMaxZ
Definition RBE.hh:133

◆ GetHitAlphaAndBeta()

std::tuple< G4double, G4double > RadioBio::RBE::GetHitAlphaAndBeta ( G4double  E,
G4int  Z 
)

Definition at line 287 of file RBE.cc.

288{
289 if (!fActiveTableEnergy) {
290 G4Exception("RBE::GetHitAlphaAndBeta", "NoCellLine", FatalException,
291 "No cell line selected. Please, do it using the /rbe/cellLine command.");
292 }
293
294 // Check we are in the tables
295 if ((Z < fMinZ) || (Z > fMaxZ)) {
296 if (fVerboseLevel > 2) {
297 std::stringstream str;
298 str << "Alpha & beta calculation supported only for ";
299 str << fMinZ << " <= Z <= " << fMaxZ << ", but " << Z << " requested.";
300 G4Exception("RBE::GetHitAlphaAndBeta", "", JustWarning, str.str().c_str());
301 }
302 return std::make_tuple<G4double, G4double>(0.0, 0.0); // out of table!
303 }
304 if ((E < fMinEnergies[Z]) || (E >= fMaxEnergies[Z])) {
305 if (fVerboseLevel > 2) {
306 G4cout << "RBE hit: Z=" << Z << ", E=" << E << " => out of LEM table";
307 if (fVerboseLevel > 3) {
308 G4cout << " (" << fMinEnergies[Z] << " to " << fMaxEnergies[Z] << " MeV)";
309 }
310 G4cout << G4endl;
311 }
312 return std::make_tuple<G4double, G4double>(0.0, 0.0); // out of table!
313 }
314
315 std::vector<G4double>& vecEnergy = (*fActiveTableEnergy)[Z];
316 std::vector<G4double>& vecAlpha = (*fActiveTableAlpha)[Z];
317 std::vector<G4double>& vecBeta = (*fActiveTableBeta)[Z];
318
319 // Find the row in energy tables
320 const auto eLarger = upper_bound(begin(vecEnergy), end(vecEnergy), E);
321 const G4int lower = distance(begin(vecEnergy), eLarger) - 1;
322 const G4int upper = lower + 1;
323
324 // Interpolation
325 const G4double energyLower = vecEnergy[lower];
326 const G4double energyUpper = vecEnergy[upper];
327 const G4double energyFraction = (E - energyLower) / (energyUpper - energyLower);
328
329 // linear interpolation along E
330 const G4double alpha =
331 ((1 - energyFraction) * vecAlpha[lower] + energyFraction * vecAlpha[upper]);
332 const G4double beta = ((1 - energyFraction) * vecBeta[lower] + energyFraction * vecBeta[upper]);
333 if (fVerboseLevel > 2) {
334 G4cout << "RBE hit: Z=" << Z << ", E=" << E << " => alpha=" << alpha << ", beta=" << beta
335 << G4endl;
336 }
337
338 return std::make_tuple(alpha, beta);
339}

◆ AddFromAccumulable()

void RadioBio::RBE::AddFromAccumulable ( G4VAccumulable GenAcc)
overridevirtual

Implements RadioBio::VRadiobiologicalQuantity.

Definition at line 653 of file RBE.cc.

654{
655 RBEAccumulable* acc = (RBEAccumulable*)GenAcc;
656 AddAlphaNumerator(acc->GetAlphaNumerator());
657 AddBetaNumerator(acc->GetBetaNumerator());
658 AddDenominator(acc->GetDenominator());
659
660 fCalculated = false;
661}
void AddDenominator(const array_type denom)
Definition RBE.cc:470
void AddAlphaNumerator(const array_type alpha)
Definition RBE.cc:509
void AddBetaNumerator(const array_type beta)
Definition RBE.cc:528

◆ Initialize()

void RadioBio::RBE::Initialize ( )
overridevirtual

Implements RadioBio::VRadiobiologicalQuantity.

Definition at line 81 of file RBE.cc.

82{
83 fLnS.resize(VoxelizedSensitiveDetector::GetInstance()->GetTotalVoxelNumber());
84 fDoseX.resize(VoxelizedSensitiveDetector::GetInstance()->GetTotalVoxelNumber());
85
86 fInitialized = true;
87}
array_type fLnS
Definition RBE.hh:110
array_type fDoseX
Definition RBE.hh:112
static VoxelizedSensitiveDetector * GetInstance()
Static method to retrieve a pointer to the only object existing in the simulation.

◆ Compute()

void RadioBio::RBE::Compute ( )
overridevirtual

Implements RadioBio::VRadiobiologicalQuantity.

Definition at line 416 of file RBE.cc.

417{
418 // Skip RBE computation if calculation not enabled.
419 if (!fCalculationEnabled) {
420 if (fVerboseLevel > 0) {
421 G4cout << "RBE::Compute() called but skipped as calculation not enabled" << G4endl;
422 }
423 return;
424 }
425
426 if (fCalculated == true) return;
427
428 GetDose();
429
431 ComputeRBE();
432
433 // If this method reached the bottom, set calculated to true
434 fCalculated = true;
435}
void ComputeAlphaAndBeta()
Definition RBE.cc:344
void GetDose()
Definition RBE.cc:439
void ComputeRBE()
Definition RBE.cc:378

◆ Reset()

void RadioBio::RBE::Reset ( )
overridevirtual

Implements RadioBio::VRadiobiologicalQuantity.

Definition at line 636 of file RBE.cc.

637{
638 if (fVerboseLevel > 1) {
639 G4cout << "RBE: Reset(): ";
640 }
641 fAlphaNumerator = 0.0;
642 fBetaNumerator = 0.0;
643 fDenominator = 0.0;
644 fDose = 0.0;
645 fCalculated = false;
646 if (fVerboseLevel > 1) {
647 G4cout << fAlphaNumerator.size() << " points." << G4endl;
648 }
649}
array_type fBetaNumerator
Definition RBE.hh:106
array_type fAlphaNumerator
Definition RBE.hh:105
array_type fDose
Definition RBE.hh:103
array_type fDenominator
Definition RBE.hh:107

◆ Store()

void RadioBio::RBE::Store ( )
overridevirtual

Implements RadioBio::VRadiobiologicalQuantity.

Definition at line 91 of file RBE.cc.

92{
94 StoreRBE();
95}
void StoreRBE()
Definition RBE.cc:591
void StoreAlphaAndBeta()
Definition RBE.cc:547

◆ PrintParameters()

void RadioBio::RBE::PrintParameters ( )
overridevirtual

Reimplemented from RadioBio::VRadiobiologicalQuantity.

Definition at line 99 of file RBE.cc.

100{
101 G4cout << "*******************************************" << G4endl
102 << "******* Parameters of the class RBE *******" << G4endl
103 << "*******************************************" << G4endl;
105 G4cout << "** RBE Cell line: " << fActiveCellLine << G4endl;
106 G4cout << "** RBE Dose threshold value: " << fDoseCut / gray << " gray" << G4endl;
107 G4cout << "** RBE Alpha X value: " << fAlphaX * gray << " 1/gray" << G4endl;
108 G4cout << "** RBE Beta X value: " << fBetaX * std::pow(gray, 2.0) << " 1/gray2" << G4endl;
109 G4cout << "*******************************************" << G4endl;
110}

◆ ComputeAlphaAndBeta()

void RadioBio::RBE::ComputeAlphaAndBeta ( )
private

Definition at line 344 of file RBE.cc.

345{
346 // Skip RBE computation if calculation not enabled.
347 if (!fCalculationEnabled) {
348 if (fVerboseLevel > 0) {
349 G4cout << "RBE::ComputeAlphaAndBeta() called but skipped as calculation not enabled"
350 << G4endl;
351 }
352 return;
353 }
354
355 if (fVerboseLevel > 0) {
356 G4cout << "RBE: Computing alpha and beta..." << G4endl;
357 }
358
359 // Re-initialize the number of voxels
360 fAlpha.resize(fAlphaNumerator.size()); // Initialize with the same number of elements
361 fBeta.resize(fBetaNumerator.size()); // Initialize with the same number of elements
362
363 for (size_t ii = 0; ii < fDenominator.size(); ii++) {
364 if (fDenominator[ii] > 0) {
365 fAlpha[ii] = fAlphaNumerator[ii] / (fDenominator[ii] * gray);
366 fBeta[ii] = std::pow(fBetaNumerator[ii] / (fDenominator[ii] * gray), 2.0);
367 }
368
369 else {
370 fAlpha[ii] = 0.;
371 fBeta[ii] = 0.;
372 }
373 }
374}
array_type fBeta
Definition RBE.hh:102
array_type fAlpha
Definition RBE.hh:101

◆ ComputeRBE()

void RadioBio::RBE::ComputeRBE ( )
private

Definition at line 378 of file RBE.cc.

379{
380 // Skip RBE computation if calculation not enabled.
381 if (!fCalculationEnabled) {
382 if (fVerboseLevel > 0) {
383 G4cout << "RBE::ComputeRBE() called but skipped as calculation not enabled" << G4endl;
384 }
385 return;
386 }
387
388 if (fVerboseLevel > 0) {
389 G4cout << "RBE: Computing survival and RBE..." << G4endl;
390 }
391 G4double smax = fAlphaX + 2 * fBetaX * fDoseCut;
392
393 for (G4int i = 0; i < VoxelizedSensitiveDetector::GetInstance()->GetTotalVoxelNumber(); i++) {
394 if (std::isnan(fAlpha[i]) || std::isnan(fBeta[i])) {
395 fLnS[i] = 0.0;
396 fDoseX[i] = 0.0;
397 }
398 else if (fDose[i] <= fDoseCut) {
399 fLnS[i] = -(fAlpha[i] * fDose[i]) - (fBeta[i] * (std::pow(fDose[i], 2.0)));
400 fDoseX[i] =
401 std::sqrt((-fLnS[i] / fBetaX) + std::pow((fAlphaX / (2 * fBetaX)), 2.0)) - (fAlphaX / (2 * fBetaX));
402 }
403 else {
404 G4double ln_Scut = -(fAlpha[i] * fDoseCut) - (fBeta[i] * (std::pow((fDoseCut), 2.0)));
405 fLnS[i] = ln_Scut - ((fDose[i] - fDoseCut) * smax);
406
407 fDoseX[i] = ((-fLnS[i] + ln_Scut) / smax) + fDoseCut;
408 }
409 }
410 fRBE = fDoseX / fDose;
411 fSurvival = std::exp(fLnS);
412}
array_type fSurvival
Definition RBE.hh:111
array_type fRBE
Definition RBE.hh:113
G4int GetTotalVoxelNumber() const
Method to get the total voxel number.

◆ StoreAlphaAndBeta()

void RadioBio::RBE::StoreAlphaAndBeta ( )
private

Definition at line 547 of file RBE.cc.

548{
549 // Skip RBE storing if calculation not enabled.
550 if (!fCalculationEnabled) {
551 if (fVerboseLevel > 0) {
552 G4cout << "RBE::StoreAlphaAndBeta() called but skipped as calculation not enabled" << G4endl;
553 }
554 return;
555 }
556
557 G4String AlphaBetaPath = fPath + "_AlphaAndBeta.out";
558 if (fVerboseLevel > 1) {
559 G4cout << "RBE: Writing alpha and beta..." << G4endl;
560 }
561 std::ofstream ofs(AlphaBetaPath);
562
563 Compute();
564
565 if (ofs.is_open()) {
566 ofs << std::left << std::setw(width) << "i" << std::setw(width) << "j" << std::setw(width)
567 << "k" << std::setw(width) << "alpha" << std::setw(width) << "beta " << G4endl;
568
569 auto voxSensDet = VoxelizedSensitiveDetector::GetInstance();
570
571 // Alpha and beta are written only if valid. If value is -nan, 0 is written
572 // on the text file
573 for (G4int i = 0; i < voxSensDet->GetVoxelNumberAlongX(); i++)
574 for (G4int j = 0; j < voxSensDet->GetVoxelNumberAlongY(); j++)
575 for (G4int k = 0; k < voxSensDet->GetVoxelNumberAlongZ(); k++) {
576 G4int v = voxSensDet->GetThisVoxelNumber(i, j, k);
577
578 ofs << std::left << std::setw(width) << i << std::setw(width) << j << std::setw(width)
579 << k << std::setw(width) << (std::isnan(fAlpha[v]) ? 0 : (fAlpha[v] * gray))
580 << std::setw(width) << (std::isnan(fBeta[v]) ? 0 : (fBeta[v] * std::pow(gray, 2.0)))
581 << G4endl;
582 }
583 }
584 if (fVerboseLevel > 0) {
585 G4cout << "RBE: Alpha and beta written to " << AlphaBetaPath << G4endl;
586 }
587}
#define width
Definition Dose.cc:44
void Compute() override
Definition RBE.cc:416

◆ StoreRBE()

void RadioBio::RBE::StoreRBE ( )
private

Definition at line 591 of file RBE.cc.

592{
593 // Skip RBE storing if calculation not enabled.
594 if (!fCalculationEnabled) {
595 if (fVerboseLevel > 0) {
596 G4cout << "RBE::StoreRBE() called but skipped as calculation not enabled" << G4endl;
597 }
598 return;
599 }
600
601 G4String RBEPath = fPath + "_RBE.out";
602 if (fSaved == true)
603 G4Exception("RBE::StoreRBE", "RBEOverwrite", JustWarning,
604 "Overwriting RBE file. For multiple runs, change filename.");
605 std::ofstream ofs(RBEPath);
606
607 Compute();
608
609 if (ofs.is_open()) {
610 ofs << std::left << std::setw(width) << "i" << std::setw(width) << "j" << std::setw(width)
611 << "k" << std::setw(width) << "Dose(Gy)" << std::setw(width) << "ln(S) " << std::setw(width)
612 << "Survival" << std::setw(width) << "DoseB(Gy)" << std::setw(width) << "RBE" << G4endl;
613
614 auto voxSensDet = VoxelizedSensitiveDetector::GetInstance();
615
616 for (G4int i = 0; i < voxSensDet->GetVoxelNumberAlongX(); i++)
617 for (G4int j = 0; j < voxSensDet->GetVoxelNumberAlongY(); j++)
618 for (G4int k = 0; k < voxSensDet->GetVoxelNumberAlongZ(); k++) {
619 G4int v = voxSensDet->GetThisVoxelNumber(i, j, k);
620
621 ofs << std::left << std::setw(width) << i << std::setw(width) << j << std::setw(width)
622 << k << std::setw(width) << (fDose[v] / gray) << std::setw(width) << fLnS[v]
623 << std::setw(width) << fSurvival[v] << std::setw(width) << fDoseX[v] / gray
624 << std::setw(width) << (std::isnan(fRBE[v]) ? 0. : fRBE[v]) << G4endl;
625 }
626 }
627 if (fVerboseLevel > 0) {
628 G4cout << "RBE: RBE written to " << RBEPath << G4endl;
629 }
630
631 fSaved = true;
632}

◆ SetAlphaNumerator()

void RadioBio::RBE::SetAlphaNumerator ( const array_type  alpha)
private

Definition at line 489 of file RBE.cc.

490{
491 if (fVerboseLevel > 1) {
492 G4cout << "RBE: Setting alpha numerator..." << G4endl;
493 }
494 fAlphaNumerator = alpha;
495}

◆ SetBetaNumerator()

void RadioBio::RBE::SetBetaNumerator ( const array_type  beta)
private

Definition at line 499 of file RBE.cc.

500{
501 if (fVerboseLevel > 1) {
502 G4cout << "RBE: Setting beta numerator..." << G4endl;
503 }
504 fBetaNumerator = beta;
505}

◆ SetDenominator()

void RadioBio::RBE::SetDenominator ( const array_type  denom)
private

Definition at line 460 of file RBE.cc.

461{
462 if (fVerboseLevel > 1) {
463 G4cout << "RBE: Setting denominator..." << G4endl;
464 }
465 fDenominator = denom;
466}

◆ AddAlphaNumerator()

void RadioBio::RBE::AddAlphaNumerator ( const array_type  alpha)
private

Definition at line 509 of file RBE.cc.

510{
511 if (fVerboseLevel > 1) {
512 G4cout << "RBE: Adding alpha numerator...";
513 }
514 if (fAlphaNumerator.size()) {
515 fAlphaNumerator += alpha;
516 }
517 else {
518 if (fVerboseLevel > 1) {
519 G4cout << " (created empty array)";
520 }
521 fAlphaNumerator = alpha;
522 }
523 G4cout << G4endl;
524}

◆ AddBetaNumerator()

void RadioBio::RBE::AddBetaNumerator ( const array_type  beta)
private

Definition at line 528 of file RBE.cc.

529{
530 if (fVerboseLevel > 1) {
531 G4cout << "RBE: Adding beta numerator...";
532 }
533 if (fBetaNumerator.size()) {
534 fBetaNumerator += beta;
535 }
536 else {
537 if (fVerboseLevel > 1) {
538 G4cout << " (created empty array)";
539 }
540 fBetaNumerator = beta;
541 }
542 G4cout << G4endl;
543}

◆ AddDenominator()

void RadioBio::RBE::AddDenominator ( const array_type  denom)
private

Definition at line 470 of file RBE.cc.

471{
472 if (fVerboseLevel > 1) {
473 G4cout << "RBE: Adding denominator...";
474 }
475 if (fDenominator.size()) {
476 fDenominator += denom;
477 }
478 else {
479 if (fVerboseLevel > 1) {
480 G4cout << " (created empty array)";
481 }
482 fDenominator = denom;
483 }
484 G4cout << G4endl;
485}

◆ GetDose()

void RadioBio::RBE::GetDose ( )
private

Definition at line 439 of file RBE.cc.

440{
441 // Get the pointer to dose. If it does not exist, launch an exception
442 const Dose* dose = dynamic_cast<const Dose*>(Manager::GetInstance()->GetQuantity("Dose"));
443 if (dose == nullptr)
444 G4Exception("RBE::Compute", "RBEMissingDose", FatalException,
445 "Trying to compute RBE without knowing the dose. Please add a valid dose or "
446 "disable RBE calculation");
447
448 // Check whether dose has been calculated.
449 // If not, give a warning
450 if (!dose->HasBeenCalculated())
451 G4Exception("RBE::Compute", "RBEDoseNotCalculated", JustWarning,
452 "Dose has not been calculated yet while computing RBE, that will be wrong."
453 " Please, first calculate dose");
454 // Copy the proper vector from Dose class to RBE class
455 fDose = dose->GetDose();
456}
VRadiobiologicalQuantity * GetQuantity(G4String)
Definition Manager.cc:113
static Manager * GetInstance()
Definition Manager.cc:63

Member Data Documentation

◆ fAlphaX

G4double RadioBio::RBE::fAlphaX = 0.
private

Definition at line 96 of file RBE.hh.

◆ fBetaX

G4double RadioBio::RBE::fBetaX = 0.
private

Definition at line 97 of file RBE.hh.

◆ fDoseCut

G4double RadioBio::RBE::fDoseCut = 0.
private

Definition at line 98 of file RBE.hh.

◆ fAlpha

array_type RadioBio::RBE::fAlpha = {}
private

Definition at line 101 of file RBE.hh.

101{};

◆ fBeta

array_type RadioBio::RBE::fBeta = {}
private

Definition at line 102 of file RBE.hh.

102{};

◆ fDose

array_type RadioBio::RBE::fDose = {}
private

Definition at line 103 of file RBE.hh.

103{}; // Note: this is copied from calculation in Dose

◆ fAlphaNumerator

array_type RadioBio::RBE::fAlphaNumerator = {}
private

Definition at line 105 of file RBE.hh.

105{};

◆ fBetaNumerator

array_type RadioBio::RBE::fBetaNumerator = {}
private

Definition at line 106 of file RBE.hh.

106{};

◆ fDenominator

array_type RadioBio::RBE::fDenominator = {}
private

Definition at line 107 of file RBE.hh.

107{};

◆ fLnS

array_type RadioBio::RBE::fLnS = {}
private

Definition at line 110 of file RBE.hh.

110{};

◆ fSurvival

array_type RadioBio::RBE::fSurvival = {}
private

Definition at line 111 of file RBE.hh.

111{};

◆ fDoseX

array_type RadioBio::RBE::fDoseX = {}
private

Definition at line 112 of file RBE.hh.

112{};

◆ fRBE

array_type RadioBio::RBE::fRBE = {}
private

Definition at line 113 of file RBE.hh.

113{};

◆ fTablesEnergy

std::map<G4String, vector_type> RadioBio::RBE::fTablesEnergy = {}
private

Definition at line 117 of file RBE.hh.

117{};

◆ fTablesAlpha

std::map<G4String, vector_type> RadioBio::RBE::fTablesAlpha = {}
private

Definition at line 118 of file RBE.hh.

118{};

◆ fTablesBeta

std::map<G4String, vector_type> RadioBio::RBE::fTablesBeta = {}
private

Definition at line 119 of file RBE.hh.

119{};

◆ fTablesAlphaX

std::map<G4String, G4double> RadioBio::RBE::fTablesAlphaX = {}
private

Definition at line 120 of file RBE.hh.

120{};

◆ fTablesBetaX

std::map<G4String, G4double> RadioBio::RBE::fTablesBetaX = {}
private

Definition at line 121 of file RBE.hh.

121{};

◆ fTablesDoseCut

std::map<G4String, G4double> RadioBio::RBE::fTablesDoseCut = {}
private

Definition at line 122 of file RBE.hh.

122{};

◆ fActiveCellLine

G4String RadioBio::RBE::fActiveCellLine
private

Definition at line 126 of file RBE.hh.

◆ fActiveTableEnergy

vector_type* RadioBio::RBE::fActiveTableEnergy = nullptr
private

Definition at line 127 of file RBE.hh.

◆ fActiveTableAlpha

vector_type* RadioBio::RBE::fActiveTableAlpha = nullptr
private

Definition at line 128 of file RBE.hh.

◆ fActiveTableBeta

vector_type* RadioBio::RBE::fActiveTableBeta = nullptr
private

Definition at line 129 of file RBE.hh.

◆ fMaxEnergies

std::map<G4int, G4double> RadioBio::RBE::fMaxEnergies = {}
private

Definition at line 130 of file RBE.hh.

130{};

◆ fMinEnergies

std::map<G4int, G4double> RadioBio::RBE::fMinEnergies = {}
private

Definition at line 131 of file RBE.hh.

131{};

◆ fMinZ

G4int RadioBio::RBE::fMinZ = -1
private

Definition at line 132 of file RBE.hh.

◆ fMaxZ

G4int RadioBio::RBE::fMaxZ = -1
private

Definition at line 133 of file RBE.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration