Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
DicomRun Class Reference

DicomRun class. More...

#include <Doxymodules_medical.h>

Inheritance diagram for DicomRun:
G4Run Dicom2Run

Public Member Functions

 DicomRun ()
 (Description) DicomRun Class is for accumulating scored quantities which is scored using G4MutiFunctionalDetector and G4VPrimitiveScorer.
 
 DicomRun (const std::vector< G4String > mfdName)
 
virtual ~DicomRun ()
 
virtual void RecordEvent (const G4Event *)
 
size_t GetNumberOfHitsMap () const
 
G4THitsMap< G4double > * GetHitsMap (G4int i) const
 
G4THitsMap< G4double > * GetHitsMap (const G4String &detName, const G4String &colName) const
 
G4THitsMap< G4double > * GetHitsMap (const G4String &fullName) const
 
void ConstructMFD (const std::vector< G4String > &)
 
virtual void Merge (const G4Run *)
 

Private Attributes

std::vector< G4StringfCollName
 
std::vector< G4int > fCollID
 
std::vector< G4THitsMap< G4double > * > fRunMap
 

Detailed Description

DicomRun class.

Example implementation for multi-functional-detector and primitive scorer. This DicomRun class has collections which accumulate a event information into a run information.

Definition at line 32 of file Doxymodules_medical.h.

Constructor & Destructor Documentation

◆ DicomRun() [1/2]

DicomRun::DicomRun ( )

(Description) DicomRun Class is for accumulating scored quantities which is scored using G4MutiFunctionalDetector and G4VPrimitiveScorer.

Accumulation is done using G4THitsMap object.

The constructor DicomRun(const std::vector<G4String> mfdName) needs a vector filled with MultiFunctionalDetector names which was assigned at instantiation of MultiFunctionalDetector(MFD). Then DicomRun constructor automatically scans primitive scorers in the MFD, and obtains collectionIDs of all collections associated to those primitive scorers. Futhermore, the G4THitsMap objects for accumulating during a RUN are automatically created too. (*) Collection Name is same as primitive scorer name.

The resultant information is kept inside DicomRun objects as data members. std::vector<G4String> fCollName; // Collection Name, std::vector<G4int> fCollID; // Collection ID, std::vector<G4THitsMap<G4double>*> fRunMap; // HitsMap for RUN.

The resualtant HitsMap objects are obtain using access method, GetHitsMap(..).

Definition at line 66 of file DicomRun.cc.

67: G4Run()
68{ }

◆ DicomRun() [2/2]

DicomRun::DicomRun ( const std::vector< G4String mfdName)

Definition at line 74 of file DicomRun.cc.

74 : G4Run()
75{
76 ConstructMFD(mfdName);
77}
void ConstructMFD(const std::vector< G4String > &)
Definition DicomRun.cc:100

◆ ~DicomRun()

DicomRun::~DicomRun ( )
virtual

Definition at line 83 of file DicomRun.cc.

84{
85 //--- Clear HitsMap for RUN
86 size_t Nmap = fRunMap.size();
87 for ( size_t i = 0; i < Nmap; ++i)
88 {
89 if(fRunMap[i] ) fRunMap[i]->clear();
90 }
91 fCollName.clear();
92 fCollID.clear();
93 fRunMap.clear();
94}
std::vector< G4String > fCollName
Definition DicomRun.hh:82
std::vector< G4THitsMap< G4double > * > fRunMap
Definition DicomRun.hh:84
std::vector< G4int > fCollID
Definition DicomRun.hh:83

Member Function Documentation

◆ RecordEvent()

void DicomRun::RecordEvent ( const G4Event aEvent)
virtual

Reimplemented in Dicom2Run.

Definition at line 157 of file DicomRun.cc.

158{
159 // disable below because this is done in G4Run::RecordEvent(aEvent);
160 //numberOfEvent++; // This is an original line.
161
162 //G4cout << "Dicom Run :: Recording event " << aEvent->GetEventID()
163 //<< "..." << G4endl;
164 //=============================
165 // HitsCollection of This Event
166 //============================
167 G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
168 if (!HCE) return;
169
170 //=======================================================
171 // Sum up HitsMap of this Event into HitsMap of this RUN
172 //=======================================================
173 size_t Ncol = fCollID.size();
174 for ( size_t i = 0; i < Ncol ; ++i ) // Loop over HitsCollection
175 {
176 G4THitsMap<G4double>* EvtMap = nullptr;
177 if ( fCollID[i] >= 0 ) // Collection is attached to HCE
178 {
179 EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID[i]));
180 }
181 else
182 {
183 G4cout <<" Error EvtMap Not Found "<< i << G4endl;
184 }
185 if ( EvtMap )
186 {
187 //=== Sum up HitsMap of this event to HitsMap of RUN.===
188 *fRunMap[i] += *EvtMap;
189 //G4cout << "Summing EvtMap into RunMap at " << i << "..." << G4endl;
190 //======================================================
191 } //else {
192 //G4cout << "Null pointer to EvtMap at " << i << "..." << G4endl;
193 //}
194 }
195
196 G4Run::RecordEvent(aEvent);
197
198}

◆ GetNumberOfHitsMap()

size_t DicomRun::GetNumberOfHitsMap ( ) const
inline

Definition at line 67 of file DicomRun.hh.

67{return fRunMap.size();}

◆ GetHitsMap() [1/3]

G4THitsMap< G4double > * DicomRun::GetHitsMap ( G4int  i) const
inline

Definition at line 71 of file DicomRun.hh.

71{return fRunMap[i];}

◆ GetHitsMap() [2/3]

G4THitsMap< G4double > * DicomRun::GetHitsMap ( const G4String detName,
const G4String colName 
) const

Definition at line 224 of file DicomRun.cc.

226{
227 G4String fullName = detName+"/"+colName;
228 return GetHitsMap(fullName);
229}
G4THitsMap< G4double > * GetHitsMap(G4int i) const
Definition DicomRun.hh:71

◆ GetHitsMap() [3/3]

G4THitsMap< G4double > * DicomRun::GetHitsMap ( const G4String fullName) const

Definition at line 235 of file DicomRun.cc.

236{
237
238 //G4THitsMap<G4double>* hitsmap = 0;
239
240 size_t Ncol = fCollName.size();
241 for ( size_t i = 0; i < Ncol; ++i)
242 {
243 if ( fCollName[i] == fullName )
244 {
245 return fRunMap[i];
246 //if(hitsmap) { *hitsmap += *fRunMap[i]; }
247 //if(!hitsmap) { hitsmap = fRunMap[i]; }
248 }
249 }
250
251 G4Exception("DicomRun", fullName.c_str(), JustWarning,
252 "GetHitsMap failed to locate the requested HitsMap");
253 return nullptr;
254}

◆ ConstructMFD()

void DicomRun::ConstructMFD ( const std::vector< G4String > &  mfdName)

Definition at line 100 of file DicomRun.cc.

101{
102
103 G4SDManager* SDman = G4SDManager::GetSDMpointer();
104 //=================================================
105 // Initalize RunMaps for accumulation.
106 // Get CollectionIDs for HitCollections.
107 //=================================================
108 size_t Nmfd = mfdName.size();
109 for ( size_t idet = 0; idet < Nmfd ; ++idet) // Loop for all MFD.
110 {
111 G4String detName = mfdName[idet];
112 //--- Seek and Obtain MFD objects from SDmanager.
114 (G4MultiFunctionalDetector*)(SDman->FindSensitiveDetector(detName));
115 //
116 if ( mfd )
117 {
118 //--- Loop over the registered primitive scorers.
119 for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); ++icol)
120 {
121 // Get Primitive Scorer object.
122 G4VPrimitiveScorer* scorer = mfd->GetPrimitive(icol);
123 // collection name and collectionID for HitsCollection,
124 // where type of HitsCollection is G4THitsMap in case
125 // of primitive scorer.
126 // The collection name is given by <MFD name>/<Primitive
127 // Scorer name>.
128 G4String collectionName = scorer->GetName();
129 G4String fullCollectionName = detName+"/"+collectionName;
130 G4int collectionID = SDman->GetCollectionID(fullCollectionName);
131 //
132 if ( collectionID >= 0 )
133 {
134 G4cout << "++ "<<fullCollectionName<< " id " << collectionID
135 << G4endl;
136 // Store obtained HitsCollection information into data members.
137 // And, creates new G4THitsMap for accumulating quantities during RUN.
138 fCollName.push_back(fullCollectionName);
139 fCollID.push_back(collectionID);
140 fRunMap.push_back(new G4THitsMap<G4double>(detName,collectionName));
141 }
142 else
143 {
144 G4cout << "** collection " << fullCollectionName << " not found. "
145 <<G4endl;
146 }
147 }
148 }
149 }
150}

◆ Merge()

void DicomRun::Merge ( const G4Run aRun)
virtual

Reimplemented in Dicom2Run.

Definition at line 202 of file DicomRun.cc.

203{
204 const DicomRun* localRun = static_cast<const DicomRun*>(aRun);
205 Copy(fCollName, localRun->fCollName);
206 Copy(fCollID, localRun->fCollID);
207 size_t ncopies = Copy(fRunMap, localRun->fRunMap);
208 // copy function returns the fRunMap size if all data is copied
209 // so this loop isn't executed the first time around
210 for(size_t i = ncopies; i < fRunMap.size(); ++i)
211 {
212 *fRunMap[i] += *localRun->fRunMap[i];
213 }
214 G4Run::Merge(aRun);
215}
void Copy(std::vector< T > &main, const std::vector< T > &data)
Definition DicomRun.hh:91
DicomRun class.

Member Data Documentation

◆ fCollName

std::vector<G4String> DicomRun::fCollName
private

Definition at line 82 of file DicomRun.hh.

◆ fCollID

std::vector<G4int> DicomRun::fCollID
private

Definition at line 83 of file DicomRun.hh.

◆ fRunMap

std::vector<G4THitsMap<G4double>*> DicomRun::fRunMap
private

Definition at line 84 of file DicomRun.hh.


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

Applications | User Support | Publications | Collaboration