/[PAMELA software]/PamVMC/include/PamVMCDetectorSD.h
ViewVC logotype

Contents of /PamVMC/include/PamVMCDetectorSD.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Fri Jun 12 18:39:17 2009 UTC (15 years, 5 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v1r0, HEAD
Changes since 1.1: +5 -5 lines
File MIME type: text/plain
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

1 #ifndef PAMVMC_DETECTOR_SD_H
2 #define PAMVMC_DETECTOR_SD_H
3 #include <iostream>
4 #include <TClonesArray.h>
5 #include <TObject.h>
6 #include <TString.h>
7 #include <TObjString.h>
8 #include <TMap.h>
9 #include <TROOT.h>
10 #include "PamVMCDetectorHit.h"
11 #include "PamVMCDigMgr.h"
12 #include "PamVMCGeoIDMgr.h"
13 #include "PamRootManager.h"
14 #include "PamVMCStack.h"
15 #include <TParticle.h>
16
17
18 enum fin{INSIDE,ENTERING,EXITING};
19
20 class PamVMCDetectorSD : public TObject {
21
22
23 protected:
24
25 TString fcname;
26 TString fdname;
27 Int_t fnohit;
28 fin ffi;
29 TClonesArray *fHitColl;
30 TMap fdmap;
31 PamVMCGeoID *fdetID;
32 PamVMCDetectorHit * fhit;
33 PamVMCDigitizer * fdig;
34
35 public:
36
37
38 PamVMCDetectorSD(
39 const char *cname="PamVMCDetectorHit",
40 const char *dname="",
41 Int_t is=0):
42 fcname(cname), fdname(dname), fnohit(0), fdetID(0)
43 {
44 if(is) {
45 fHitColl=new TClonesArray(fcname.Data(),is);
46 } else {
47 fHitColl=new TClonesArray(fcname.Data());
48 }
49 fhit = new PamVMCDetectorHit();
50
51 fdig = (PamVMCDigitizer*)PamVMCDigMgr::Instance()->GetDIG(dname);
52
53 AddGeoID(dname);
54 }
55
56
57 virtual ~PamVMCDetectorSD() { delete fhit; delete fHitColl; delete fdetID;}
58
59 virtual void Register(){
60
61 PamRootManager::Instance()->
62 Register(fdname.Data(),"TClonesArray", &fHitColl);
63
64 if (fdig) fdig->RegisterCollections(fdname.Data(),fHitColl);
65
66 TString a=fHitColl?"exist":"not exist";
67 }
68
69 void AddGeoID(const char * dname){
70 TString temp=dname;
71 fdetID=new PamVMCGeoID(dname);
72 fdmap.Add(new TObjString(temp), fdetID);
73 cout <<" Inside AddGeoID "<<fdname.Data() << endl;
74 fdmap.Print();
75 }
76
77
78 virtual void CleanHit(){ fhit->CleanHit();}
79
80 virtual void InitHit() {
81 if(fdetID) {
82 fhit->SetPOS( fdetID->GetID( )) ;
83 } else { fhit->SetPOS(-1); }
84 }
85
86 virtual void UpdateHit(TVirtualMC *g, Bool_t is_prim ){ fhit->FillHit(g, is_prim); }
87
88 virtual void SaveHit(){
89 PamVMCDetectorHit * k=CreateHit();
90 k=fhit;
91 }
92
93 virtual void SaveHit(Int_t f){
94 PamVMCDetectorHit * k=CreateHit(f);
95 *k+=*fhit;
96 }
97
98 virtual void SaveHit(const char * dname){
99 PamVMCDetectorHit * k=CreateHit(dname);
100 *k=*fhit;
101 }
102
103 virtual PamVMCDetectorHit * CreateHit()
104 {
105 PamVMCDetectorHit *hit= (PamVMCDetectorHit *) fHitColl->New(fnohit++);
106 InitHit();
107 return hit;
108 }
109
110 virtual void FillVolID(){
111 fdetID->FillVolID();
112 fhit->SetPOS( fdetID->GetID( )) ;
113 }
114
115 virtual PamVMCDetectorHit * CreateHit(const char * dname)
116 {
117 fdetID=(PamVMCGeoID*)fdmap(dname);
118 return CreateHit();
119 }
120
121 virtual PamVMCDetectorHit * CreateHit(Int_t flag) {
122 if(!fHitColl->At(flag)) {
123 PamVMCDetectorHit *hit= (PamVMCDetectorHit *) fHitColl->New(flag);
124 InitHit();
125 return hit;
126 }
127 return (PamVMCDetectorHit*)fHitColl->At(flag);
128 }
129
130 virtual void PreEvent(){/* this method was created
131 for zeroing digits in common area.
132 calls from application before each event*/};
133
134 virtual void Compress(){ (*fHitColl).Compress(); };
135
136 virtual void Digitize(){/*this method do pre-digitize action,
137 ex. calculate strips energy release
138 (create something to be digitized (if any).
139 calls from application*/ }
140
141
142 virtual void ClearHitColl(){
143 fnohit=0;
144 (*fHitColl).Clear("C");
145 }
146
147 virtual void FillHit(fin f,TVirtualMC *g, Bool_t is_prim){
148 ffi=f;
149 switch(f) {
150 case ENTERING:
151 CleanHit();
152 FillVolID();
153 InitHit();
154 default:
155 UpdateHit(g, is_prim);
156 break;
157 }
158
159 switch(f){
160 case EXITING:
161 // Save hit if energy release is greater than zero
162 if(fhit->GetEREL()){
163 SaveHit(fdname.Data());
164 }
165 break;
166 default:
167 break;
168 }
169 }
170
171
172 virtual void Print(const Option_t* ="") const {
173
174 // Print more information like the name
175 std::cout<<"DETECTOR "<<fdname<<" HIT COLLECTION"<<std::endl;
176 fHitColl->Print();
177 }
178
179 ClassDef(PamVMCDetectorSD,1)
180 };
181
182
183 #endif //PAMVMC_DETECTOR_SD_H

  ViewVC Help
Powered by ViewVC 1.1.23