Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4DigiManager.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 //
27 // $Id: G4DigiManager.cc 80987 2014-05-19 10:50:22Z gcosmo $
28 //
29 
30 #include "G4DigiManager.hh"
31 #include "G4Event.hh"
32 #include "G4VHitsCollection.hh"
33 #include "G4VDigiCollection.hh"
34 #include "G4DMmessenger.hh"
35 #include "G4DCofThisEvent.hh"
36 #include "G4RunManager.hh"
37 #include "G4SDManager.hh"
38 #include "G4ios.hh"
39 
40 
42 
44 {
45  if(!fDManager)
46  {
48  }
49  return fDManager;
50 }
51 
53 { return fDManager; }
54 
56 {
57  theMessenger = new G4DMmessenger(this);
60  DCtable = new G4DCtable;
61 }
62 
64 {
65  //DMtable.clearAndDestroy();
66  for(G4int i=0;i<int(DMtable.size());i++)
67  { delete DMtable[i]; }
68  DMtable.clear();
69  delete DCtable;
70  delete theMessenger;
71 }
72 
74 {
75  G4String DMname = DM->GetName();
76  for(int j=0;j<int(DMtable.size());j++)
77  {
78  if(DMtable[j]==DM)
79  {
80  G4cout << "<" << DMname << "> has already been registored." << G4endl;
81  return;
82  }
83  }
84  if( verboseLevel > 0 )
85  {
86  G4cout << "New DigitizerModule <" << DMname
87  << "> is registored." << G4endl;
88  }
89  DMtable.push_back(DM);
90 
91  G4int numberOfCollections = DM->GetNumberOfCollections();
92  for(int i=0;i<numberOfCollections;i++)
93  {
94  G4String DCname = DM->GetCollectionName(i);
95  if( DCtable->Registor(DMname,DCname) < 0 )
96  {
97  G4cout << "DigiCollection <" << DCname
98  << "> has already been registored with "
99  << DMname << " DigitizerModule." << G4endl;
100  }
101  else if( verboseLevel > 0 )
102  {
103  G4cout << "DigiCollection " << DCname
104  << " is registored. " << G4endl;
105  }
106  }
107 
109 }
110 
112 {
114  if(aDM)
115  { aDM->Digitize(); }
116  else
117  { G4cout << "Unknown digitizer module <" << mName << ">. Digitize() ignored." << G4endl; }
118 }
119 
121 {
122  for(G4int i=0;i<int(DMtable.size());i++)
123  {
124  if(DMtable[i]->GetName() == mName) return DMtable[i];
125  }
126  return NULL;
127 }
128 
130 {
131  const G4Event* evt = NULL;
132  if(eventID==0)
133  { evt = runManager->GetCurrentEvent(); }
134  else
135  { evt = runManager->GetPreviousEvent(eventID); }
136  if(evt==NULL) return NULL;
137 
138  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
139  if(HCE==NULL) return NULL;
140 
141  return HCE->GetHC(HCID);
142 }
143 
145 {
146  const G4Event* evt = NULL;
147  if(eventID==0)
148  { evt = runManager->GetCurrentEvent(); }
149  else
150  { evt = runManager->GetPreviousEvent(eventID); }
151  if(evt==NULL) return NULL;
152 
153  G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
154  if(DCE==NULL) return NULL;
155 
156  return DCE->GetDC(DCID);
157 }
158 
160 {
161  return SDManager->GetCollectionID(HCname);
162 }
163 
165 {
166  G4int i = DCtable->GetCollectionID(DCname);
167  if(i==-2)
168  { G4cout << "< " << DCname << "> is ambegious." << G4endl; }
169  return i;
170 }
171 
173 {
174  const G4Event* consEvt = runManager->GetCurrentEvent();
175  if(consEvt==NULL)
176  {
177  G4cout << "G4DigiManager::SetDigiCollection --- "
178  << "Event object is not available." << G4endl;
179  return;
180  }
181 
182  G4Event* evt = (G4Event*)consEvt;
183  G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
184  if(DCE==NULL)
185  {
186  DCE = new G4DCofThisEvent(DCtable->entries());
187  evt->SetDCofThisEvent(DCE);
188  if(verboseLevel>0)
189  { G4cout << "DCofThisEvent object is added to current G4Event." << G4endl; }
190  }
191 
192  DCE->AddDigiCollection(DCID,aDC);
193 
194  if(verboseLevel>0)
195  {
196  G4cout << aDC->GetName() << " is stored at " << DCID
197  << "-th slot of G4DCofThisEvent." << G4endl;
198  }
199 }
200 
202 {
203  verboseLevel = val;
204  for(G4int i=0;i<int(DMtable.size());i++)
205  { DMtable[i]->SetVerboseLevel(val); }
206 }
207 
209 {
210  for(G4int i=0;i<int(DMtable.size());i++)
211  { G4cout << " " << i << " : " << DMtable[i]->GetName() << G4endl; }
212 }
213 
214 
215 
static G4DigiManager * GetDMpointer()
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
void List() const
static G4DigiManager * GetDMpointerIfExist()
std::vector< G4VDigitizerModule * > DMtable
G4int GetDigiCollectionID(G4String DCname)
#define G4endl
Definition: G4ios.hh:61
G4int Registor(G4String SDname, G4String DCname)
Definition: G4DCtable.cc:37
const G4Event * GetPreviousEvent(G4int i) const
const G4VHitsCollection * GetHitsCollection(G4int HCID, G4int eventID=0)
void SetDCtable(G4DCtable *DCtbl)
G4int GetCollectionID(G4String DCname) const
Definition: G4DCtable.cc:46
G4SDManager * SDManager
G4DCtable * DCtable
#define G4ThreadLocal
Definition: tls.hh:69
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
G4DCofThisEvent * GetDCofThisEvent() const
Definition: G4Event.hh:187
void AddNewModule(G4VDigitizerModule *DM)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const G4VDigiCollection * GetDigiCollection(G4int DCID, G4int eventID=0)
void Digitize(G4String mName)
G4int entries() const
Definition: G4DCtable.hh:66
G4String GetCollectionName(G4int i) const
const G4Event * GetCurrentEvent() const
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
void SetVerboseLevel(G4int vl)
int G4int
Definition: G4Types.hh:78
G4int GetHitsCollectionID(G4String HCname)
void AddDigiCollection(G4int DCID, G4VDigiCollection *aDC)
void SetDCofThisEvent(G4DCofThisEvent *value)
Definition: G4Event.hh:119
G4RunManager * runManager
G4GLOB_DLL std::ostream G4cout
G4String GetName() const
G4DMmessenger * theMessenger
static G4ThreadLocal G4DigiManager * fDManager
G4VDigiCollection * GetDC(G4int i) const
G4int GetNumberOfCollections() const
virtual void Digitize()=0
G4VDigitizerModule * FindDigitizerModule(G4String mName)
void SetDigiCollection(G4int DCID, G4VDigiCollection *aDC)