Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
DicomRun Class Reference

#include <DicomRun.hh>

Inheritance diagram for DicomRun:
G4Run

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.

References ConstructMFD().

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

References G4SDManager::FindSensitiveDetector(), G4cout, G4endl, G4SDManager::GetCollectionID(), G4VPrimitiveScorer::GetName(), G4MultiFunctionalDetector::GetNumberOfPrimitives(), G4MultiFunctionalDetector::GetPrimitive(), and G4SDManager::GetSDMpointer().

Referenced by DicomRun().

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 of primitive scorer.
122  // The collection name is given by <MFD name>/<Primitive Scorer name>.
123  G4String collectionName = scorer->GetName();
124  G4String fullCollectionName = detName+"/"+collectionName;
125  G4int collectionID = SDman->GetCollectionID(fullCollectionName);
126  //
127  if ( collectionID >= 0 ){
128  G4cout << "++ "<<fullCollectionName<< " id " << collectionID << G4endl;
129  // Store obtained HitsCollection information into data members.
130  // And, creates new G4THitsMap for accumulating quantities during RUN.
131  fCollName.push_back(fullCollectionName);
132  fCollID.push_back(collectionID);
133  fRunMap.push_back(new G4THitsMap<G4double>(detName,collectionName));
134  } else {
135  G4cout << "** collection " << fullCollectionName << " not found. "<<G4endl;
136  }
137  }
138  }
139  }
140 }
G4String GetName() const
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
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:124
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
G4THitsMap<G4double>* DicomRun::GetHitsMap ( G4int  i) const
inline

Definition at line 71 of file DicomRun.hh.

Referenced by DicomRunAction::EndOfRunAction(), and GetHitsMap().

71 {return fRunMap[i];}
G4THitsMap< G4double > * DicomRun::GetHitsMap ( const G4String detName,
const G4String colName 
) const

Definition at line 208 of file DicomRun.cc.

References GetHitsMap().

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

Definition at line 219 of file DicomRun.cc.

References G4Exception(), and JustWarning.

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

References copy(), G4endl, and G4Run::Merge().

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

Reimplemented from G4Run.

Definition at line 147 of file DicomRun.cc.

References G4cout, G4endl, G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), G4Run::numberOfEvent, and G4Run::RecordEvent().

148 {
149  numberOfEvent++; // This is an original line.
150 
151  //G4cout << "Dicom Run :: Recording event " << aEvent->GetEventID() << "..." << G4endl;
152  //=============================
153  // HitsCollection of This Event
154  //============================
155  G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
156  if (!HCE) return;
157 
158  //=======================================================
159  // Sum up HitsMap of this Event into HitsMap of this RUN
160  //=======================================================
161  G4int Ncol = fCollID.size();
162  for ( G4int i = 0; i < Ncol ; i++ ){ // Loop over HitsCollection
163  G4THitsMap<G4double>* EvtMap = 0;
164  if ( fCollID[i] >= 0 ){ // Collection is attached to HCE
165  EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID[i]));
166  }else{
167  G4cout <<" Error EvtMap Not Found "<< i << G4endl;
168  }
169  if ( EvtMap ) {
170  //=== Sum up HitsMap of this event to HitsMap of RUN.===
171  *fRunMap[i] += *EvtMap;
172  //G4cout << "Summing EvtMap into RunMap at " << i << "..." << G4endl;
173  //======================================================
174  } //else {
175  //G4cout << "Null pointer to EvtMap at " << i << "..." << G4endl;
176  //}
177  }
178 
179  G4Run::RecordEvent(aEvent);
180 
181 }
G4int numberOfEvent
Definition: G4Run.hh:59
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:174

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