ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DicomPhantomZSliceMerged.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DicomPhantomZSliceMerged.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
29 //
30 //
31 // The code was written by :
32 // * Jonathan Madsen : jonathan.madsen@cern.ch (12/18/2012)
33 //
34 // Texas A&M University
35 // 3133 TAMU, Zachry Building
36 // College Station, TX 77843, USA
37 //
38 //*******************************************************
39 
41 #include "G4UnitsTable.hh"
42 #include "G4SystemOfUnits.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 {
48 
49 }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {
55  fSlices.clear();
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  G4cout << "\nDicomPhantomZSliceMerged::Checking "
63  << fSlices.size() << " fSlices..." << G4endl;
64 
65  G4bool uniformSliceThickness = true;
66 
67  if(fSlices.size() > 1) {
68  if(fSlices.size() == 2) {
69  DicomPhantomZSliceHeader* one = fSlices.begin()->second;
70  DicomPhantomZSliceHeader* two = fSlices.end()->second;
71 
72  G4double real_distance = (two->GetSliceLocation()-one->GetSliceLocation())/2.;
73 
74  if(one->GetMaxZ() != two->GetMinZ()) {
75  one->SetMaxZ(one->GetSliceLocation()+real_distance);
76  two->SetMinZ(two->GetSliceLocation()-real_distance);
77  //one->SetMinZ(one->GetSliceLocation()-real_distance);
78  //two->SetMaxZ(two->GetSliceLocation()+real_distance);
79  if(uniformSliceThickness) {
80  one->SetMinZ(one->GetSliceLocation()-real_distance);
81  two->SetMaxZ(two->GetSliceLocation()+real_distance);
82  }
83  }
84  } else {
85  auto ite0 = fSlices.begin();
86  auto ite1 = fSlices.begin();
87  auto ite2 = fSlices.begin();
88  ++ite1;
89  ++ite2; ++ite2;
90 
91  for(; ite2 != fSlices.end(); ++ite0, ++ite1, ++ite2)
92  {
93  DicomPhantomZSliceHeader* prev = ite0->second;
94  DicomPhantomZSliceHeader* slice = ite1->second;
95  DicomPhantomZSliceHeader* next = ite2->second;
96  G4double real_max_distance = (next->GetSliceLocation() -
97  slice->GetSliceLocation())/2.;
98  G4double real_min_distance = (slice->GetSliceLocation() -
99  prev->GetSliceLocation())/2.;
100  G4double real_distance = real_max_distance + real_min_distance;
101  G4double stated_distance = slice->GetMaxZ()-slice->GetMinZ();
102  if(real_distance != stated_distance) {
103  uintmax_t sliceNum = std::distance(fSlices.begin(),ite1);
104  G4cout << "\tDicomPhantomZSliceMerged::CheckSlices - \
105  Slice Distance Error in slice [" << sliceNum
106  << "]: Real Distance = "
107  << real_distance/mm
108  << " mm, Stated Distance = " << stated_distance/mm << G4endl;
109  slice->SetMinZ(slice->GetSliceLocation()-real_min_distance);
110  slice->SetMaxZ(slice->GetSliceLocation()+real_max_distance);
111 
112  if(ite0 == fSlices.begin()) {
113  prev->SetMaxZ(slice->GetMinZ());
114  // Using below would make all slice same thickness
115  //prev->SetMinZ(prev->GetSliceLocation()-real_min_distance);
116  if(uniformSliceThickness) {
117  prev->SetMinZ(prev->GetSliceLocation()-real_min_distance); }
118 
119  }
120  if(static_cast<unsigned int>(std::distance(fSlices.begin(),ite2)+1)==
121  fSlices.size()) {
122  next->SetMinZ(slice->GetMaxZ());
123  // Using below would make all slice same thickness
124  //next->SetMaxZ(next->GetSliceLocation()+real_max_distance);
125  if(uniformSliceThickness) {
126  next->SetMaxZ(next->GetSliceLocation()+real_max_distance); }
127  }
128  }
129  }
130  }
131  }
132  G4cout << G4endl;
133 
134  for(auto ite = fSlices.cbegin(); ite != fSlices.cend(); ++ite) {
135  ite->second->DumpToFile();
136  }
137 
138 }
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......