source: trunk/examples/extended/optical/LXe/README @ 1282

Last change on this file since 1282 was 807, checked in by garnier, 16 years ago

update

File size: 20.5 KB
Line 
1
2                            LXe Example
3                            -----------
4
5**************
6*Classes Used*
7**************
8
9main()
10------
11
12 ==> Use G4UItcsh if available
13
14 ==> Provide interactive and macro mode
15
16G4VModularPhysicsList
17------------------
18(class: LXePhysicsList)
19
20 ==> Registers General, EM, Muon, and Optical physics lists
21
22 ==> define particles; including *** G4OpticalPhoton     ***
23     define processes; including *** G4Cerenkov          ***
24                                 *** G4Scintillation     ***
25                                 *** G4OpAbsorption      ***
26                                 *** G4OpRayleigh        ***
27                                 *** G4OpBoundaryProcess ***
28                                 *** G4OpWLS             ***
29
30G4VUserDetectorConstruction
31---------------------------
32(class: LXeDetectorConstruction)
33
34 ==> define material: LXe (liquid xenon), Aluminum, Air, Vacuum, Glass,...
35     define G4Box geometry with aluminum housing and LXe volume inside
36     define G4Tubs placed around the housing walls
37     define G4Sphere to demonstrate skin surfaces inside volumes
38     *** add G4MaterialPropertiesTable to G4Material         ***
39     *** define G4OpticalSurface(s)                          ***
40     *** define G4LogicalBorderSurface(s)                    ***
41     *** define G4LogicalSkinSurface(s)                      ***
42     *** add G4MaterialPropertiesTable to G4OpticalSurface(s)***
43
44 ==> Mesenger to change many of the dectector geometry properties
45
46 ==> Uses a alternative style of geometry definition. See "Geometry" section.
47
48G4VUserPrimaryGeneratorAction
49-----------------------------
50(class: LXePrimaryGeneratorAction)
51
52 ==> Use G4ParticleGun to shoot a 511 keV gamma through the housing into
53     liquid xenon scintillator
54 
55G4UserStackingAction
56--------------------
57(class: LXeStackingAction)
58
59 ==> show how to count the number of secondary particles in an event
60     differentiates between different creator processes
61
62G4UserRunAction
63---------------
64(class: LXeRunAction)
65
66 ==> Call recorder class for begin and end of run
67
68G4UserSteppingAction
69--------------------
70(class: LXeSteppingAction)
71
72 ==> Identify which secondaries were generated during a particular step
73
74 ==> ***Count reflections/absorptions/detections due to G4OpBoundaryProcess***
75     ***Count absorptions due to G4OpAbsorption                            ***
76     Manually trigger a sensitive detector when a boundary process detects
77
78 ==> Call recorder class at end of step
79
80G4UserTrackingAction
81____________________
82(class: LXeTrackingAction)
83
84 ==> Determine if the trajectory should be drawn by checking if it hit the
85     sphere(if enabled) and a pmt.
86
87 ==> Call recorder class at end of track
88
89G4UserEventAction
90-----------------
91(class: LXeEventAction)
92
93 ==> Triggers drawing of trajectories
94
95 ==> Calculates and stores data in a G4VUserEventInformation object
96
97 ==> Outputs basic event data at end of event
98
99 ==> Decides if the random seed should be saved for this event
100
101 ==> Call recorder class at begin and end of event
102
103G4VSensitiveDetector
104--------------------
105(classes: LXePMTSD, LXeScintSD)
106
107 ==> Basic sensitive detectors keeping hit collections
108     Keep one G4VHit object per hit
109      or
110     Keep one G4VHit object per volume containing hits
111
112 ==> LXePMTSD decides if the hits it is creating should be redrawn
113
114G4VHit
115------
116(classes: LXePMTHit, LXeScintHIT)
117
118 ==> Store individual hit positions
119      or
120     Store a count of hits in a particular volume
121
122 ==> Selectively redraw volumes containing hits at the end of event
123
124G4VUserEventInformation & G4VUserTrackInformation
125-------------------------------------------------
126(classes: LXeUserEventInformation, LXeUserTrackInformation)
127
128 ==> Store aditional information along with the G4Event/G4Track objects
129
130G4VSteppingVerbose
131------------------
132(classes: LXeSteppingVerbose)
133 
134 ==> Custom verbose stepping output to use G4BestUnit and print current volume
135      rather than next volume
136 ==> Same as ExN03SteppingVerbose but output reformated to fit nicer into
137      tables.
138
139G4UImessenger
140-------------
141(classes: LXeDetectorMessenger, LXeEventMessenger, LXeSteppingMessenger)
142
143 ==> Create /LXe and /LXe/detector interactive command folders
144
145 ==> Create new commands
146
147 ==> See interactive help when running the example for descriptions of commands
148
149G4Trajectory
150------------
151(class: LXeTrajectory)
152
153 ==> Derived from G4Trajectory to use most of the basic trajectory functions
154     already defined
155
156 ==> Uses a coppied and modified version of DrawTrajectory from G4VTrajectory
157     to enable/disable drawing of individual trajectories and to redefine
158     the colours used
159
160G4VisManager
161------------
162(class: LXeVisManager)
163
164 ==> Initialize graphics systems geant4 is configured for
165
166RecorderBase
167------------
168
169 ==> Virtual class provided for recording of simulation data
170
171 ==> Derive your own implementation from it and instantiate the recorder
172     object in main()
173
174 ==> For full description see RecorderBase.hh
175
176**********
177*Geometry*
178**********
179The way the geometry is constructed is an experiment for a new, more object
180oriented, way to construct geometry. It seperates the concept of how a volume
181is built from where it is placed. Each major volume in the geometry is defined
182as a class derived from G4PVPlacement. In this example, just the main LXe
183volume, the WLS scintillator slab, and the WLS fibers were chosen. To place
184one of these volumes, simply create an instance of it with the appropriate
185rotation, translation, and mother volumes.
186
187-------
188LXeMainVolume(G4RotationMatrix *pRot,
189              const G4ThreeVector &tlate,
190              G4LogicalVolume *pMotherLogical,
191              G4bool pMany,
192              G4int pCopyNo,
193              LXeDetectorConstruction* c);
194-------
195
196Also necessary are the pMany and pCopyNo variables with the same usage as in
197G4PVPlacement. Additionally, the detector construction must be passed to the
198main volume as a way to communicate the many parameters to the volume and its
199sub-volumes. The communication is done from the CopyValues() function which
200retrieves the information from the detector constructor.
201
202Notably, the name and logical volume parameters are no longer part of the
203constructor. This is because they are both to be decided by the volume itself.
204The volume must specify its own name and a temporary logical volume. The
205constructor will then procede to define its logical volume in the normal way.
206Once complete, the logical volume can be assigned to the physical volume using
207the SetLogicalVolume() function.
208
209To handle instances of the same type of volume, a new logical volume should not
210be defined for each one. Instead, the logical volume is kept as a static member
211and defined only once.
212
213------
214if(!housing_log || updated){
215//...
216//Define logical volume
217//...
218}
219SetLogicalVolume(housing_log);
220------
221
222The updated variable is to signal that the volume needs to be updated and a new
223logical volume made.
224
225***********************************
226*Modifying the geometry at runtime*
227***********************************
228This example allows the user to modify the geometry definition at runtime. This
229is accomplished through LXeDetecotrMessenger, a derived class of G4UImessenger.
230The commands it adds change variables stored in LXeDetectorConstructor that
231are used when constructing the geometry. After changing these variables
232the /LXe/detector/update command must be issued to reconstruct the geometry
233with the new values.
234
235------
236void LXeDetectorConstruction::UpdateGeometry(){
237  // clean-up previous geometry
238  G4SolidStore::GetInstance()->Clean();
239  G4LogicalVolumeStore::GetInstance()->Clean();
240  G4PhysicalVolumeStore::GetInstance()->Clean();
241
242  //define new one
243  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructDetector());
244  G4RunManager::GetRunManager()->GeometryHasBeenModified();
245}
246
247************************
248*PMT sensitive detector*
249************************
250The PMT sensitive detector cannot be triggered like a normal sensitive detector
251because the sensitive volume does not allow photons to pass through it. Rather,
252it detects them in the OpBoundary process based on an efficiency set on the
253skin of the volume.
254
255------
256
257  G4OpticalSurface* photocath_opsurf=
258     new G4OpticalSurface("photocath_opsurf",glisur,polished,
259                           dielectric_metal);
260  G4double photocath_EFF[num]={1.,1.};
261  G4double photocath_REFL[num]={0.,0.};
262  G4MaterialPropertiesTable* photocath_mt = new G4MaterialPropertiesTable();
263  photocath_mt->AddProperty("EFFICIENCY",Ephoton,photocath_EFF,num);
264  photocath_mt->AddProperty("REFLECTIVITY",Ephoton,photocath_REFL,num);
265  photocath_opsurf->SetMaterialPropertiesTable(photocath_mt);
266  new G4LogicalSkinSurface("photocath_surf",photocath_log,photocath_opsurf);
267
268------
269
270A normal sensitive detector would have its ProcessHits
271function called for each step by a particle inside the volume. So, to record
272these hits with a sensitive detector we watched the status of the OpBoundary
273process from the stepping manager whenever a photon hit the sensitive volume
274of the pmt. If the status was 'Detection', we retrieve the sensitive detector
275from G4SDManager and call its ProcessHits function.
276
277------
278
279  boundaryStatus=boundary->GetStatus();
280  //Check to see if the particle was actually at a boundary
281  //Otherwise the boundary status may not be valid
282  //Prior to Geant4.6.0-p1 this would not have been enough to check
283  if(thePostPoint->GetStepStatus()==fGeomBoundary){
284    switch(boundaryStatus){
285    //...   
286      case Detection: //Note, this assumes that the volume causing detection
287                      //is the photocathode because it is the only one with
288                      //non-zero efficiency
289        {
290          //Trigger sensitive detector manually since photon is
291          //absorbed but status was Detection
292          G4SDManager* SDman = G4SDManager::GetSDMpointer();
293          G4String sdName="/LXeDet/pmtSD";
294          LXePMTSD* pmtSD = (LXePMTSD*)SDman
295            ->FindSensitiveDetector(sdName);
296          if(pmtSD)
297            pmtSD->ProcessHits_constStep(theStep,NULL);
298          break;
299        }
300      //...
301    }
302
303**********************
304*Modular Physics List*
305**********************
306Using a modular physics list is an easy way to organize the physics list into
307categories for easier maintenance. It can also assist with testing code
308by making it easy to disable an entire category of physics at once if
309necessary. The physics list instantiated in main() is a derived class of
310G4VModularPhysics list rather than the usual G4VUserPhysicsList. The only
311function aside from the constructor that is necessary in this class is
312SetCuts(). The constructor must register the other physics lists individually.
313
314RegisterPhysics( new LXeGeneralPhysics("general") );
315
316The other physics lists (the modules) are derived from G4VPhysicsConstructor
317and it is necessary to write the ConstructParticle() and ConstructProcess()
318functions for each list. They work in the same way as in G4VUserPhysicsList.
319
320Do not create instances of the individual physics processes as members of the
321modules. Instead, use pointers to the processes and create the instances
322in the ConstructProcess() function. The reason for this is that the materials
323needed to build physics tables for the processes will not have been created
324at the time that the modules are created but will have been created before the
325ConstructProcess() function is called.
326
327**********************************************************
328*Selectively drawing trajectories or highlighting volumes*
329**********************************************************
330In a simulation such as this one, where an average of 6000 trajectories are
331generated in a small space, there is little use in drawing all of them. There
332are two ways to select which ones to draw. The first of which is to decide
333while looping through the trajectory container which ones to draw and only call
334DrawTrajectory on the important ones. However, trajectories only contain a
335small portion of the information from the track it represents. This may not
336be enough to decide if a trajectory is worth drawing.
337
338The alternative is to define your own trajectory class to store additional
339information to help decide if it should be drawn. To use your custom trajectory
340you must create it in the PreUserTrackingAction:
341
342fpTrackingManager->SetTrajectory(new LXeTrajectory(aTrack));
343
344Then at any point you can get access to the trajectory you can update the extra
345information within it. When it comes to drawing, you can then use this to
346decide if you want to call DrawTrajectory. Or you can call DrawTrajectory for
347all trajectories and have the logic decide how and if a trajectory should
348be drawn inside the DrawTrajectory function itself.
349
350Selectively highlighting volumes is useful to show which volumes were hit. To
351do this, you simply need a pointer to the physical volume. With that, you can
352modify its vis attributes and instruct the vis manager to redraw the volume
353with the new vis attributes.
354
355------
356  G4VisAttributes attribs(G4Colour(1.,0.,0.));
357  attribs.SetForceSolid(true);
358  G4RotationMatrix rot;
359  if(physVol->GetRotation())//If a rotation is defined use it
360    rot=*(physVol->GetRotation());
361  G4Transform3D trans(rot,physVol->GetTranslation());//Create transform
362  pVVisManager->Draw(*physVol,attribs,trans);//Draw it
363------
364
365In this case, it is done in Draw function of a PMT hit but it can be placed
366anywhere. The logic to decide if it should be drawn or not may be similar to
367the logic used in choosing which trajectories to draw.
368
369See /LXe/detector/volumes/sphere in "UI commands" below for info on what
370trajectories are drawn in this simulation.
371
372****************************
373*Saving random engine seeds*
374****************************
375At times it may be necessary to review a particular event of interest. To do
376this without redoing an entire run, which may take a long time, you must store
377the random engine seed from the beginning of the event. The run manager
378has some functions that help in this task.
379
380G4RunManager::SetRandomNumberStore(G4bool)
381
382When set to true, this causes the run manager to write the seed for the
383beginning of the current run to CurrentRun.rndm and the current event to
384CurrentEvent.rndm. However, at the beginning of each event this file will be
385overwritten with the new event. To keep a copy for a particular event there is
386a function to copy this file to run###evt###.rndm.
387
388G4RunManager::rndmSaveThisEvent()
389
390This can be done for every event so you can review any event you like but this
391may be awkward for runs with very large numbers of events. Instead, implement
392some form of logic in EndOfEventAction to decide if the event is worth saving.
393If it is, then call rndmSaveThisEvent(). By default, these files are stored in
394the current working directory. There is a function to change this as well.
395Typically you would call that at the same time SetRandomNumberStore. The
396directory to save in must exist first. GEANT4 will not create it for you.
397
398G4RunManager::SetRandomNumberStoreDir(G4String)
399
400**************
401*RecorderBase*
402**************
403RecorderBase is a virtual class to serve as a template for how to add
404histogram functionality to a GEANT4 application. To use it, derive a
405class from it and instantiate that in main(). Each of your user action classes
406to do any recording must have a pointer to this instance. Then at the end of
407the critical functions in each user action, call the appropriate recorder
408function. The recorder functions and the functions to call them from are listed
409here:
410
411  RecordBeginOfRun(const G4Run*)
412        -Call from BeginOfRunAction()
413  RecordEndOfRun(const G4Run*)
414        -Call from EndOfRunAction()
415  RecordBeginOfEvent(const G4Event*)
416        -Call from BeginOfEventAction()
417  RecordEndOfEvent(const G4Event*)
418        -Call from EndOfEventAction()
419  RecordTrack(const G4Track*)
420        -Call from PostUserTrackingAction()
421  RecordStep(const G4Step*)
422        -Call from UserSteppingAction()
423
424For the reasoning behind why it is done this way see RecorderBase.hh
425
426*************
427*UI commands*
428*************
429The method to define UI commands is well documented in the GEANT4 documentation
430so will not be discussed here. This is a description of the commands added to
431this example.
432
433Directories:
434/LXe/ - All custom commands belong below this directory
435/LXe/detector/ - Geometry related commands
436/LXe/detector/volumes/ - Commands to enable/disable volumes in the geometry
437
438Commands:
439/LXe/saveThreshold <int, default = 4500>
440-Specifies a threshold for saving the random seed for an event. If the number
441of photons generated in an event is below this number then the random seed is
442saved to ./random/run###evt###.rndm. See "Saving random engine seeds".
443
444/LXe/eventVerbose <int, default = 1>
445-Enables end of event verbose data to be printed. This includes information
446counted and calculated by the user action classes.
447
448/LXe/pmtThreshold <int, default = 1>
449-Sets the PMT threshold in # of photons being detected by the PMT. PMTs below
450with fewer hits than the threshold will not count as being hit and will also
451not be highlighted at the end of the event.
452
453/LXe/oneStepPrimaries <bool>
454-This causes primary particles to be killed after going only one step inside
455the scintillator volume. This is useful to view the photons generated during
456the initial conversion of the primary particle.
457
458/LXe/forceDrawPhotons <bool>
459-Forces all optical photon trajectories to be drawn at the end of the event
460regardless of the scheme mentioned in /LXe/detector/volumes/sphere below.
461
462/LXe/forceDrawNoPhotons <bool>
463-Forces all optical photon trajectories to NOT be drawn at the end of the
464event regardless of the scheme mentioned in /LXe/detector/volumes/sphere below.
465-If /LXe/forceDrawPhotons is set to true, this has no effect.
466
467/LXe/detector/dimensions <double x y z> <unit, default = cm>
468-Sets the dimensions of the main scintillator volume.
469
470/LXe/detector/housingThickness <double>
471-Sets the thickness of the housing surrounding the main detector volume.
472
473/LXe/detector/pmtRadius <double> <unit, default = cm>
474-Sets the radius of the PMTs
475
476/LXe/detector/nx
477/LXe/detector/ny
478/LXe/detector/nz
479-Sets the number of PMTs placed in a row along each axis.
480
481/LXe/detector/reflectivity <double>
482-Sets the reflectivity of the inside of the aluminum housing. The geometry
483uses a default value of 1.00 for a fully reflective surface.
484
485/LXe/detector/nfibers <int>
486-Sets the number of WLS fibers placed in the WLS scintillator slab. The
487geometry uses a default value of 15 fibers.
488
489/LXe/detector/scintYieldFactor <double>
490-Sets the yield factor for the scintillation process. This is cumulative with
491the yield factor set on individual materials. Set to 0 to produce no
492scintillation photons.
493
494/LXe/detector/update
495-Builds the new geometry based on any parameters that have been updated with
496the other UI commands. ***This must be called for the changes to take effect***
497
498/LXe/detector/defaults
499-Resets all detector values customizable with commands above to their defaults.
500
501/LXe/detector/volumes/sphere <bool>
502-Enables/disables the sphere placed inside the main scintillator volume. When
503the sphere is enabled, only photons that hit the sphere and hit a PMT are
504drawn. If it is disabled, then all photons that hit PMTs are drawn.
505
506/LXe/detector/volumes/wls <bool>
507-Enables/disables the WLS scintillator slab containing WLS fibers. By default
508this is not part of the geometry. Enabling it will place it behind the LXe
509scintillator volume.
510
511/LXe/detector/volumes/lxe <bool>
512-Enables/disables the main LXe scintillator volume. By default this is part of
513the geometry.
514
515*************
516*Macro files*
517*************
518The following are the macro files included in this example and what they do.
519
520LXe.in
521-This produces a standard event with a 511 keV gamma fired into the LXe volume.
522All values are left at their default states but verbose output has been
523enabled.
524
525cerenkov.mac
526-This is to demonstrate the cerenkov process. It disables the scintillation
527process and uses a 200MeV mu+ to produce cerenkov photons. The volume has
528been resized and the number of pmts has been increased to more accurately
529show the cone. OneStepPrimaries has been enabled so that the cone does not fill
530itself in as the muon slows down.
531
532wls.mac
533-This disables the main volume and enables the WLS slab volume. It sets the
534particle gun to use an e- to produce scintillation in the slab which will be
535absorbed by the WLS fibers and re-emited at a different wavelength.
536
537vis.mac
538-This is a standard vis.mac file to tell the vis manager how to visualize the
539simulation.
540
541photon.mac
542-A very simple test in which the gun is set to produce a single photon inside
543the main scintillator volume.
544
545reviewEvent.mac
546-This is to review an event by loading in a random seed and running the event
547with verbose output. Modify the file to specify the filename of the random
548seed.
549
550defaults.mac
551-This resets all values that can be changed with the /LXe/ commands back to
552their initial configuration including those that are not reset with
553/LXe/detector/defaults
Note: See TracBrowser for help on using the repository browser.