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

Dicom2Run class. More...

#include <Dicom2Run.hh>

Inheritance diagram for Dicom2Run:
DicomRun G4Run

Public Types

typedef G4VTHitsVector< G4StatAnalysis, std::vector< G4StatAnalysis > > Dicom2RunVector
 

Public Member Functions

 Dicom2Run ()
 (Description) Dicom2Run Class is for accumulating scored quantities which is scored using G4MutiFunctionalDetector and G4VPrimitiveScorer.
 
 Dicom2Run (const std::vector< G4String > mfdName)
 
virtual ~Dicom2Run ()
 
virtual void RecordEvent (const G4Event *)
 
size_t GetNumberOfHitsMap () const
 
Dicom2RunVectorGetHitsVector (G4int i) const
 
Dicom2RunVectorGetHitsVector (const G4String &detName, const G4String &colName) const
 
Dicom2RunVectorGetHitsVector (const G4String &fullName) const
 
void ConstructMFD (const std::vector< G4String > &)
 
virtual void Merge (const G4Run *)
 
- Public Member Functions inherited from DicomRun
 DicomRun ()
 (Description) DicomRun Class is for accumulating scored quantities which is scored using G4MutiFunctionalDetector and G4VPrimitiveScorer.
 
 DicomRun (const std::vector< G4String > mfdName)
 
virtual ~DicomRun ()
 
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 > &)
 

Private Attributes

std::vector< G4StringfCollName
 
std::vector< G4int > fCollID
 
std::vector< Dicom2RunVector * > fRunMap
 

Detailed Description

Dicom2Run class.

Demonstrates how to use G4StatAnalysis as a vector of objects (instead of vector of pointers to objects) to reduce memory consumption

Definition at line 52 of file Dicom2Run.hh.

Member Typedef Documentation

◆ Dicom2RunVector

Definition at line 56 of file Dicom2Run.hh.

Constructor & Destructor Documentation

◆ Dicom2Run() [1/2]

Dicom2Run::Dicom2Run ( )

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

Accumulation is done using G4THitsVector object.

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

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

The resualtant HitsVector objects are obtain using access method, GetHitsVector(..).

Definition at line 69 of file Dicom2Run.cc.

70: DicomRun()
71{ }
DicomRun()
(Description) DicomRun Class is for accumulating scored quantities which is scored using G4MutiFuncti...
Definition DicomRun.cc:66

◆ Dicom2Run() [2/2]

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

Definition at line 77 of file Dicom2Run.cc.

78: DicomRun()
79{
80 ConstructMFD(mfdName);
81}
void ConstructMFD(const std::vector< G4String > &)
Definition Dicom2Run.cc:104

◆ ~Dicom2Run()

Dicom2Run::~Dicom2Run ( )
virtual

Definition at line 87 of file Dicom2Run.cc.

88{
89 //--- Clear HitsVector for RUN
90 for(std::size_t i = 0; i < fRunMap.size(); ++i)
91 {
92 if(fRunMap[i])
93 fRunMap[i]->clear();
94 }
95 fCollName.clear();
96 fCollID.clear();
97 fRunMap.clear();
98}
std::vector< G4int > fCollID
Definition Dicom2Run.hh:87
std::vector< G4String > fCollName
Definition Dicom2Run.hh:86
std::vector< Dicom2RunVector * > fRunMap
Definition Dicom2Run.hh:88

Member Function Documentation

◆ RecordEvent()

void Dicom2Run::RecordEvent ( const G4Event aEvent)
virtual

Reimplemented from DicomRun.

Definition at line 165 of file Dicom2Run.cc.

166{
167 DicomRun::RecordEvent(aEvent);
168
169 //G4cout << "Dicom Run :: Recording event " << aEvent->GetEventID()
170 //<< "..." << G4endl;
171 //=============================
172 // HitsCollection of This Event
173 //============================
174 G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
175 if (!HCE)
176 return;
177
178 //=======================================================
179 // Sum up HitsVector of this Event into HitsVector of this RUN
180 //=======================================================
181 for(std::size_t i = 0; i < fCollID.size(); ++i)
182 {
183 // Loop over HitsCollection
184 G4THitsMap<G4double>* EvtMap = nullptr;
185 if(fCollID[i] >= 0)
186 {
187 // Collection is attached to HCE
188 EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID[i]));
189 }
190 else
191 {
192 G4cout <<" Error EvtMap Not Found "<< i << G4endl;
193 }
194
195 // if valid pointer, add the pointer
196 if(EvtMap)
197 {
198 //for(auto itr = EvtMap->begin(); itr != EvtMap->end(); ++itr)
199 // G4cout << "adding " << *EvtMap->GetObject(itr) << G4endl;
200 //=== Sum up HitsVector of this event to HitsVector of RUN.===
201 *fRunMap[i] += *EvtMap;
202 }
203 }
204}
virtual void RecordEvent(const G4Event *)
Definition DicomRun.cc:157

◆ GetNumberOfHitsMap()

size_t Dicom2Run::GetNumberOfHitsMap ( ) const
inline

Definition at line 71 of file Dicom2Run.hh.

71{ return fRunMap.size(); }

◆ GetHitsVector() [1/3]

Dicom2RunVector * Dicom2Run::GetHitsVector ( G4int  i) const
inline

Definition at line 75 of file Dicom2Run.hh.

75{return fRunMap[i];}

◆ GetHitsVector() [2/3]

Dicom2Run::Dicom2RunVector * Dicom2Run::GetHitsVector ( const G4String detName,
const G4String colName 
) const

Definition at line 231 of file Dicom2Run.cc.

233{
234 G4String fullName = detName+"/"+colName;
235 return GetHitsVector(fullName);
236}
Dicom2RunVector * GetHitsVector(G4int i) const
Definition Dicom2Run.hh:75

◆ GetHitsVector() [3/3]

Dicom2Run::Dicom2RunVector * Dicom2Run::GetHitsVector ( const G4String fullName) const

Definition at line 243 of file Dicom2Run.cc.

244{
245
246 std::size_t Ncol = fCollName.size();
247 for(std::size_t i = 0; i < Ncol; ++i)
248 {
249 if(fCollName[i] == fullName)
250 {
251 return fRunMap[i];
252 }
253 }
254
255 G4Exception("Dicom2Run", fullName.c_str(), JustWarning,
256 "GetHitsVector failed to locate the requested HitsVector");
257 return nullptr;
258}

◆ ConstructMFD()

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

Definition at line 104 of file Dicom2Run.cc.

105{
106 DicomRun::ConstructMFD(mfdName);
107
108 G4SDManager* SDman = G4SDManager::GetSDMpointer();
109 //=================================================
110 // Initalize RunMaps for accumulation.
111 // Get CollectionIDs for HitCollections.
112 //=================================================
113 for(std::size_t idet = 0; idet < mfdName.size(); ++idet)
114 {
115 // Loop for all MFD.
116 G4String detName = mfdName[idet];
117 //--- Seek and Obtain MFD objects from SDmanager.
120 (SDman->FindSensitiveDetector(detName));
121 //
122 if(mfd)
123 {
124 //--- Loop over the registered primitive scorers.
125 for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); ++icol)
126 {
127 // Get Primitive Scorer object.
128 G4VPrimitiveScorer* scorer = mfd->GetPrimitive(icol);
129 // collection name and collectionID for HitsCollection,
130 // where type of HitsCollection is G4THitsVector in case
131 // of primitive scorer.
132 // The collection name is given by :
133 // <MFD name>/<Primitive Scorer name>.
134 G4String collectionName = scorer->GetName();
135 G4String fullCollectionName = detName+"/"+collectionName;
136 G4int collectionID = SDman->GetCollectionID(fullCollectionName);
137 //
138 if(collectionID >= 0)
139 {
140 G4cout << "++ "<<fullCollectionName<< " id " << collectionID
141 << G4endl;
142 // Store obtained HitsCollection information into data
143 // members. qnd creates new G4THitsVector for accumulating
144 // quantities during RUN.
145 fCollName.push_back(fullCollectionName);
146 fCollID.push_back(collectionID);
147 fRunMap.push_back(new Dicom2RunVector(detName,
148 collectionName));
149 }
150 else
151 {
152 G4cout << "** collection " << fullCollectionName << " not found. "
153 <<G4endl;
154 }
155 }
156 }
157 }
158}
G4VTHitsVector< G4StatAnalysis, std::vector< G4StatAnalysis > > Dicom2RunVector
Definition Dicom2Run.hh:56
void ConstructMFD(const std::vector< G4String > &)
Definition DicomRun.cc:100

◆ Merge()

void Dicom2Run::Merge ( const G4Run aRun)
virtual

Reimplemented from DicomRun.

Definition at line 208 of file Dicom2Run.cc.

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

Member Data Documentation

◆ fCollName

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

Definition at line 86 of file Dicom2Run.hh.

◆ fCollID

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

Definition at line 87 of file Dicom2Run.hh.

◆ fRunMap

std::vector<Dicom2RunVector*> Dicom2Run::fRunMap
private

Definition at line 88 of file Dicom2Run.hh.


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

Applications | User Support | Publications | Collaboration