Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DicomRun Class Reference

#include <DicomRun.hh>

Inheritance diagram for DicomRun:
Collaboration diagram for DicomRun:

Public Member Functions

 DicomRun ()
 
 DicomRun (const std::vector< G4String > mfdName)
 
virtual ~DicomRun ()
 
virtual void RecordEvent (const G4Event *)
 
G4int 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 *)
 
- Public Member Functions inherited from G4Run
 G4Run ()
 
virtual ~G4Run ()
 
G4int GetRunID () const
 
G4int GetNumberOfEvent () const
 
G4int GetNumberOfEventToBeProcessed () const
 
const G4HCtableGetHCtable () const
 
const G4DCtableGetDCtable () const
 
const G4StringGetRandomNumberStatus () const
 
void SetRunID (G4int id)
 
void SetNumberOfEventToBeProcessed (G4int n_ev)
 
void SetHCtable (G4HCtable *HCtbl)
 
void SetDCtable (G4DCtable *DCtbl)
 
void SetRandomNumberStatus (G4String &st)
 
void StoreEvent (G4Event *evt)
 
const std::vector< const
G4Event * > * 
GetEventVector () const
 

Additional Inherited Members

- Protected Attributes inherited from G4Run
G4int runID
 
G4int numberOfEvent
 
G4int numberOfEventToBeProcessed
 
G4HCtableHCtable
 
G4DCtableDCtable
 
G4String randomNumberStatus
 
std::vector< const G4Event * > * eventVector
 

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 50 of file DicomRun.hh.

Constructor & Destructor Documentation

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 67 of file DicomRun.cc.

68 : G4Run()
69 { }
G4Run()
Definition: G4Run.cc:34
DicomRun::DicomRun ( const std::vector< G4String mfdName)

Definition at line 75 of file DicomRun.cc.

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

Here is the call graph for this function:

DicomRun::~DicomRun ( )
virtual

Definition at line 84 of file DicomRun.cc.

85 {
86  //--- Clear HitsMap for RUN
87  G4int Nmap = fRunMap.size();
88  for ( G4int i = 0; i < Nmap; i++){
89  if(fRunMap[i] ) fRunMap[i]->clear();
90  }
91  fCollName.clear();
92  fCollID.clear();
93  fRunMap.clear();
94 }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

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

Definition at line 100 of file DicomRun.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 71 of file DicomRun.hh.

71 {return fRunMap[i];}

Here is the caller graph for this function:

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

Definition at line 210 of file DicomRun.cc.

212 {
213  G4String fullName = detName+"/"+colName;
214  return GetHitsMap(fullName);
215 }
G4THitsMap< G4double > * GetHitsMap(G4int i) const
Definition: DicomRun.hh:71

Here is the call graph for this function:

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

Definition at line 221 of file DicomRun.cc.

222 {
223 
224  //G4THitsMap<G4double>* hitsmap = 0;
225 
226  G4int Ncol = fCollName.size();
227  for ( G4int i = 0; i < Ncol; i++){
228  if ( fCollName[i] == fullName ){
229  return fRunMap[i];
230  //if(hitsmap) { *hitsmap += *fRunMap[i]; }
231  //if(!hitsmap) { hitsmap = fRunMap[i]; }
232  }
233  }
234 
235  //if(hitsmap) { return hitsmap; }
236 
237  G4Exception("DicomRun", fullName.c_str(), JustWarning,
238  "GetHitsMap failed to locate the requested HitsMap");
239  return NULL;
240 }
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

G4int DicomRun::GetNumberOfHitsMap ( ) const
inline

Definition at line 67 of file DicomRun.hh.

67 {return fRunMap.size();}
void DicomRun::Merge ( const G4Run aRun)
virtual

Reimplemented from G4Run.

Definition at line 188 of file DicomRun.cc.

189 {
190  const DicomRun* localRun = static_cast<const DicomRun*>(aRun);
191  Copy(fCollName, localRun->fCollName);
192  Copy(fCollID, localRun->fCollID);
193  unsigned ncopies = Copy(fRunMap, localRun->fRunMap);
194  // copy function returns the fRunMap size if all data is copied
195  // so this loop isn't executed the first time around
196  G4cout << "DicomRun :: Num copies = " << ncopies << G4endl;
197  for(unsigned i = ncopies; i < fRunMap.size(); ++i) {
198  *fRunMap[i] += *localRun->fRunMap[i];
199  }
200  G4Run::Merge(aRun);
201 }
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
void Copy(std::vector< T > &main, const std::vector< T > &data)
Definition: DicomRun.hh:91
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void DicomRun::RecordEvent ( const G4Event aEvent)
virtual

Reimplemented from G4Run.

Definition at line 151 of file DicomRun.cc.

152 {
153  G4Run::RecordEvent(aEvent);
154 
155  //G4cout << "Dicom Run :: Recording event " << aEvent->GetEventID()
156  //<< "..." << G4endl;
157  //=============================
158  // HitsCollection of This Event
159  //============================
160  G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
161  if (!HCE) return;
162 
163  //=======================================================
164  // Sum up HitsMap of this Event into HitsMap of this RUN
165  //=======================================================
166  G4int Ncol = fCollID.size();
167  for ( G4int i = 0; i < Ncol ; i++ ){ // Loop over HitsCollection
168  G4THitsMap<G4double>* EvtMap = 0;
169  if ( fCollID[i] >= 0 ){ // Collection is attached to HCE
170  EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID[i]));
171  }else{
172  G4cout <<" Error EvtMap Not Found "<< i << G4endl;
173  }
174  if ( EvtMap ) {
175  //=== Sum up HitsMap of this event to HitsMap of RUN.===
176  *fRunMap[i] += *EvtMap;
177  //G4cout << "Summing EvtMap into RunMap at " << i << "..." << G4endl;
178  //======================================================
179  } //else {
180  //G4cout << "Null pointer to EvtMap at " << i << "..." << G4endl;
181  //}
182  }
183 
184 }
G4VHitsCollection * GetHC(G4int i)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:51
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185

Here is the call graph for this function:


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