ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/geant482-cms1.patch
Revision: 1.2
Committed: Tue Jan 23 10:10:28 2007 UTC (18 years, 3 months ago) by eulisse
Branch: MAIN
CVS Tags: pe20070205b, pe20070205a, pe20070205
Changes since 1.1: +2 -2 lines
Log Message:
Typo fixed.

File Contents

# User Rev Content
1 eulisse 1.1 diff -Naur --exclude CVS source/geant4e/b.log source/geant4e/b.log
2     --- source/geant4e/b.log 1970-01-01 01:00:00.000000000 +0100
3     +++ source/geant4e/b.log 2007-01-17 12:41:58.000000000 +0100
4     @@ -0,0 +1,7 @@
5     +Compiling G4eManager.cc ...
6     +src/G4eManager.cc: In member function `bool
7     + G4eManager::InitFieldForBackwards()':
8     +src/G4eManager.cc:211: no matching function for call to `G4MagIntegratorStepper
9     + ::SetEquationOfMotion(G4Mag_UsualEqRhs*&)'
10     +gmake: *** [/afs/cern.ch/cms/external/geant4/8.1.p01.pCMS2/share/tmp/Linux-g++/G4error/G4eManager.o] Error 1
11     +gmake: Target `lib' not remade because of errors.
12     diff -Naur --exclude CVS source/geant4source/GNUmakefile source/geant4e/GNUmakefile
13     --- source/geant4source/GNUmakefile 1970-01-01 01:00:00.000000000 +0100
14     +++ source/geant4source/GNUmakefile 2007-01-17 12:41:58.000000000 +0100
15     @@ -0,0 +1,52 @@
16     +# $Id: GNUmakefile,v 1.1 1999/01/07 16:14:28 gunter Exp $
17     +# ----------------------------------------------------------
18     +# GNUmakefile for tracking library. Katsuya Amako, 5/9/95.
19     +# ----------------------------------------------------------
20     +
21     +name := G4error
22     +
23     +ifndef G4INSTALL
24     + G4INSTALL = ../..
25     +endif
26     +
27     +include $(G4INSTALL)/config/architecture.gmk
28     +
29     +CPPFLAGS += -I$(G4BASE)/global/management/include \
30     + -I$(G4BASE)/global/HEPRandom/include \
31     + -I$(G4BASE)/global/HEPGeometry/include \
32     + -I$(G4BASE)/geometry/management/include \
33     + -I$(G4BASE)/geometry/volumes/include \
34     + -I$(G4BASE)/geometry/solids/CSG/include \
35     + -I$(G4BASE)/geometry/navigation/include \
36     + -I$(G4BASE)/track/include \
37     + -I$(G4BASE)/materials/include \
38     + -I$(G4BASE)/processes/management/include \
39     + -I$(G4BASE)/processes/electromagnetic/utils/include \
40     + -I$(G4BASE)/particles/management/include \
41     + -I$(G4BASE)/digits_hits/detector/include \
42     + -I$(G4BASE)/digits_hits/hits/include \
43     + -I$(G4BASE)/graphics_reps/include \
44     + -I$(G4BASE)/intercoms/include \
45     + -I$(G4BASE)/geometry/magneticfield/include \
46     + -I$(G4BASE)/tracking/include \
47     + -I$(G4BASE)/event/include \
48     + -I$(G4BASE)/run/include \
49     + -I$(G4BASE)/particles/bosons/include \
50     + -I$(G4BASE)/particles/leptons/include \
51     + -I$(G4BASE)/particles/hadrons/mesons/include \
52     + -I$(G4BASE)/particles/hadrons/barions/include \
53     + -I$(G4BASE)/particles/hadrons/ions/include \
54     + -I$(G4BASE)/digits_hits/digits/include \
55     + -I$(G4BASE)/processes/electromagnetic/standard/include \
56     + -I$(G4BASE)/processes/electromagnetic/muons/include \
57     + -I$(G4BASE)/processes/cuts/include \
58     + -I$(G4BASE)/processes/transportation/include \
59     + -I$(G4BASE)/processes/decay/include
60     +
61     +CPPFLAGS += -DG4EVERBOSE
62     +
63     +include $(G4INSTALL)/config/common.gmk
64     +
65     +.PHONY: global
66     +
67     +global: lib
68     diff -Naur --exclude CVS source/geant4e/include/ExN02PhysicsList.hh source/geant4e/include/ExN02PhysicsList.hh
69     --- source/geant4e/include/ExN02PhysicsList.hh 1970-01-01 01:00:00.000000000 +0100
70     +++ source/geant4e/include/ExN02PhysicsList.hh 2007-01-17 12:41:58.000000000 +0100
71     @@ -0,0 +1,51 @@
72     +//
73     +// class ExN02PhysicsList
74     +//
75     +// Class description:
76     +//
77     +//
78     +//
79     +
80     +// History:
81     +//
82     +// --------------------------------------------------------------------
83     +#ifndef ExN02PhysicsList_h
84     +#define ExN02PhysicsList_h 1
85     +
86     +#include "G4VUserPhysicsList.hh"
87     +#include "globals.hh"
88     +
89     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90     +
91     +class ExN02PhysicsList: public G4VUserPhysicsList
92     +{
93     + public:
94     + ExN02PhysicsList();
95     + ~ExN02PhysicsList();
96     +
97     + protected:
98     + // Construct particle and physics
99     + void ConstructParticle();
100     + void ConstructProcess();
101     +
102     + void SetCuts();
103     +
104     +
105     + protected:
106     + // these methods Construct particles
107     + void ConstructBosons();
108     + void ConstructLeptons();
109     + void ConstructMesons();
110     + void ConstructBaryons();
111     +
112     + protected:
113     + // these methods Construct physics processes and register them
114     + void ConstructGeneral();
115     + void ConstructEM();
116     +};
117     +
118     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119     +
120     +#endif
121     +
122     +
123     diff -Naur --exclude CVS source/geant4e/include/G4eEnergyLossProcess.hh source/geant4e/include/G4eEnergyLossProcess.hh
124     --- source/geant4e/include/G4eEnergyLossProcess.hh 1970-01-01 01:00:00.000000000 +0100
125     +++ source/geant4e/include/G4eEnergyLossProcess.hh 2007-01-17 12:41:58.000000000 +0100
126     @@ -0,0 +1,67 @@
127     +//
128     +// class G4eEnergyLossProcess
129     +//
130     +// Class description:
131     +//
132     +// Description: Continuous Process to calcualte energy loss through G4EnergyLossForExtrapolator
133     +
134     +// History:
135     +//
136     +// --------------------------------------------------------------------
137     +//
138     +
139     +#ifndef G4eEnergyLossProcess_h
140     +#define G4eEnergyLossProcess_h 1
141     +
142     +#include "globals.hh"
143     +#include "G4VContinuousProcess.hh"
144     +class G4EnergyLossForExtrapolator;
145     +
146     +/////////////////////
147     +// Class Definition
148     +/////////////////////
149     +
150     +class G4eEnergyLossProcess : public G4VContinuousProcess
151     +{
152     +
153     +public:
154     +
155     + G4eEnergyLossProcess(const G4String& processName = "G4eEnergyLossProcess");
156     +
157     + ~G4eEnergyLossProcess();
158     +
159     +public:
160     +
161     + G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
162     + // Returns true -> 'is applicable', for all charged particles.
163     +
164     + G4double GetContinuousStepLimit(const G4Track& aTrack,
165     + G4double ,
166     + G4double ,
167     + G4double& );
168     + // Returns DBL_MAX as continuous step limit
169     +
170     + G4VParticleChange* AlongStepDoIt(const G4Track& aTrack,
171     + const G4Step& aStep);
172     + // This is the method implementing the energy loss process.
173     +
174     +private:
175     + static void InstantiateEforExtrapolator();
176     + // Create the G4EnergyLossForExtrapolator
177     +
178     +private:
179     + static G4EnergyLossForExtrapolator* theELossForExtrapolator;
180     +
181     +};
182     +
183     +////////////////////
184     +// Inline methods
185     +////////////////////
186     +
187     +inline
188     +G4bool G4eEnergyLossProcess::IsApplicable(const G4ParticleDefinition& aParticleType)
189     +{
190     + return (aParticleType.GetPDGCharge() != 0);
191     +}
192     +
193     +#endif /* G4eEnergyLossProcess_h */
194     diff -Naur --exclude CVS source/geant4e/include/G4eIonisationChange.hh source/geant4e/include/G4eIonisationChange.hh
195     --- source/geant4e/include/G4eIonisationChange.hh 1970-01-01 01:00:00.000000000 +0100
196     +++ source/geant4e/include/G4eIonisationChange.hh 2007-01-17 12:41:58.000000000 +0100
197     @@ -0,0 +1,42 @@
198     +//
199     +// class G4eIonisationChange
200     +//
201     +// Class description:
202     +//
203     +//
204     +//
205     +
206     +// History:
207     +//
208     +// --------------------------------------------------------------------
209     +//
210     +// Class description:
211     +//
212     +// Serves to reverse the sign of the energy lost if propagationis backwards
213     +//
214     +// History:
215     +// - Created. P. Arce
216     +// ------------------------------------------------------------
217     +
218     +#ifndef G4eIonisationChange_h
219     +#define G4eIonisationChange_h 1
220     +
221     +#include "globals.hh"
222     +class G4ParticleChangeForLoss;
223     +class G4Track;
224     +
225     +class G4eIonisationChange
226     +{
227     + public:
228     +
229     + G4eIonisationChange(const G4String& processName = "GEANT4eMuIoni");
230     +
231     + ~G4eIonisationChange();
232     +
233     + void RecomputeParticleChange( G4ParticleChangeForLoss* fParticleChange, const G4Track& trackData);
234     +
235     +};
236     +
237     +
238     +#endif
239     +
240     diff -Naur --exclude CVS source/geant4e/include/G4eMagneticFieldLimitsMessenger.hh source/geant4e/include/G4eMagneticFieldLimitsMessenger.hh
241     --- source/geant4e/include/G4eMagneticFieldLimitsMessenger.hh 1970-01-01 01:00:00.000000000 +0100
242     +++ source/geant4e/include/G4eMagneticFieldLimitsMessenger.hh 2007-01-17 12:41:58.000000000 +0100
243     @@ -0,0 +1,44 @@
244     +//
245     +// class G4eMagneticFieldLimitsMessenger
246     +//
247     +// Class description:
248     +//
249     +// Messenger class for G4eMagneticFieldLimitsProcess
250     +//
251     +
252     +// History:
253     +//
254     +//-----------------------------------------------------------------
255     +
256     +#ifndef G4eMagneticFieldLimitsMessenger_h
257     +#define G4eMagneticFieldLimitsMessenger_h 1
258     +
259     +#include "globals.hh"
260     +#include "G4UImessenger.hh"
261     +
262     +class G4UIdirectory;
263     +class G4UIcmdWithAString;
264     +class G4UIcmdWithADoubleAndUnit;
265     +class G4eMagneticFieldLimitsProcess;
266     +
267     +//-----------------------------------------------------------------
268     +
269     +class G4eMagneticFieldLimitsMessenger: public G4UImessenger
270     +{
271     +public:
272     + G4eMagneticFieldLimitsMessenger(G4eMagneticFieldLimitsProcess*);
273     + ~G4eMagneticFieldLimitsMessenger();
274     +
275     + void SetNewValue(G4UIcommand*, G4String);
276     +
277     +private:
278     +
279     + G4eMagneticFieldLimitsProcess* myAction;
280     +
281     + G4UIdirectory* myDir;
282     +
283     + G4UIcmdWithADoubleAndUnit* StepLimitCmd;
284     +};
285     +
286     +#endif
287     +
288     diff -Naur --exclude CVS source/geant4e/include/G4eMagneticFieldLimitsProcess.hh source/geant4e/include/G4eMagneticFieldLimitsProcess.hh
289     --- source/geant4e/include/G4eMagneticFieldLimitsProcess.hh 1970-01-01 01:00:00.000000000 +0100
290     +++ source/geant4e/include/G4eMagneticFieldLimitsProcess.hh 2007-01-17 12:41:58.000000000 +0100
291     @@ -0,0 +1,69 @@
292     +//
293     +// class G4eMagneticFieldLimitsProcess
294     +//
295     +// Class description:
296     +//
297     +// Limits the step length if change of magnetic field is too big (user defined limit)
298     +
299     +// History:
300     +// - Created. P. Arce, September 2004
301     +//
302     +//-----------------------------------------------------------------
303     +
304     +#ifndef G4eMagneticFieldLimitsProcess_h
305     +#define G4eMagneticFieldLimitsProcess_h 1
306     +
307     +#include "G4ios.hh"
308     +#include "globals.hh"
309     +#include "G4VDiscreteProcess.hh"
310     +#include "G4PhysicsTable.hh"
311     +#include "G4PhysicsLogVector.hh"
312     +#include "G4ElementTable.hh"
313     +#include "G4Gamma.hh"
314     +#include "G4Electron.hh"
315     +#include "G4Step.hh"
316     +class G4eMagneticFieldLimitsMessenger;
317     +
318     +//-----------------------------------------------------------------
319     +
320     +class G4eMagneticFieldLimitsProcess : public G4VDiscreteProcess
321     +{
322     +public: // with description
323     +
324     + G4eMagneticFieldLimitsProcess(const G4String& processName ="G4eMagneticFieldLimitsProcess");
325     +
326     + ~G4eMagneticFieldLimitsProcess();
327     +
328     + virtual G4double PostStepGetPhysicalInteractionLength(
329     + const G4Track& track,
330     + G4double previousStepSize,
331     + G4ForceCondition* condition
332     + );
333     + // returns the step limit
334     +
335     + virtual G4double GetMeanFreePath(const class G4Track &, G4double, enum G4ForceCondition *);
336     + // Never called, but needed as it is an abstract method
337     +
338     + virtual G4VParticleChange* PostStepDoIt(
339     + const G4Track& ,
340     + const G4Step& );
341     + // No action, but retrieving the G4VParticleChange extracted from the G4Track
342     +
343     + // Get and Set methods
344     + G4double GetStepLimit() const { return theStepLimit; }
345     +
346     + void SetStepLimit( G4double val ) {
347     + theStepLimit = val;
348     + // G4cout << " G4eMagneticFieldLimitsProcess set theStepLimit " << theStepLimit << G4endl;
349     + }
350     +
351     +private:
352     + G4double theStepLimit;
353     + G4eMagneticFieldLimitsMessenger* theMessenger;
354     +};
355     +
356     +//-----------------------------------------------------------------
357     +
358     +
359     +#endif
360     +
361     diff -Naur --exclude CVS source/geant4e/include/G4eMag_UsualEqRhs.hh source/geant4e/include/G4eMag_UsualEqRhs.hh
362     --- source/geant4e/include/G4eMag_UsualEqRhs.hh 1970-01-01 01:00:00.000000000 +0100
363     +++ source/geant4e/include/G4eMag_UsualEqRhs.hh 2007-01-17 12:41:58.000000000 +0100
364     @@ -0,0 +1,33 @@
365     +//
366     +// class G4eMag_UsualEqRhs
367     +//
368     +// Class description:
369     +//
370     +// Serves to reverse the magnetic field when propagation is backwards
371     +//
372     +
373     +// History:
374     +//
375     +// --------------------------------------------------------------------
376     +
377     +#ifndef G4EMAG_USUAL_EQRHS
378     +#define G4EMAG_USUAL_EQRHS
379     +
380     +#include "G4Mag_UsualEqRhs.hh"
381     +#include "G4MagneticField.hh"
382     +
383     +class G4eMag_UsualEqRhs : public G4Mag_UsualEqRhs
384     +{
385     + public: // with description
386     +
387     + G4eMag_UsualEqRhs( G4MagneticField* MagField )
388     + : G4Mag_UsualEqRhs( MagField ) {;}
389     + ~G4eMag_UsualEqRhs() {;}
390     +
391     + void EvaluateRhsGivenB( const G4double y[],
392     + const G4double B[3],
393     + G4double dydx[] ) const;
394     + // reverses dedx if propagation is backwards
395     +};
396     +
397     +#endif /* G4MAG_USUAL_EQRHS */
398     diff -Naur --exclude CVS source/geant4e/include/G4eManager.hh source/geant4e/include/G4eManager.hh
399     --- source/geant4e/include/G4eManager.hh 1970-01-01 01:00:00.000000000 +0100
400     +++ source/geant4e/include/G4eManager.hh 2007-01-17 12:41:58.000000000 +0100
401     @@ -0,0 +1,163 @@
402     +//
403     +// class G4eManager
404     +//
405     +// Class description:
406     +//
407     +// This is the class manager of the GEANT4e package
408     +// It is the main interface for the user to define the setup and start the propagation
409     +// Initializes GEANT4 for the propagation
410     +//
411     +// Keeps the G4eState, that controls when the propagation has ended
412     +// and the G4eMode, that controls if propagation is forwards or backwards
413     +//
414     +
415     +// History:
416     +// - Created. Pedro Arce, February 2001
417     +// --------------------------------------------------------------------
418     +#ifndef G4eManager_h
419     +#define G4eManager_h 1
420     +
421     +
422     +#include "globals.hh"
423     +#include "G4ApplicationState.hh"
424     +
425     +enum G4eState {G4eState_PreInit = 1, G4eState_Init, G4eState_Propagating, G4eState_TargetCloserThanBoundary, G4eState_StoppedAtTarget};
426     +enum G4eMode {G4eMode_PropForwards = 1, G4eMode_PropBackwards, G4eMode_PropTest};
427     +
428     +class G4eNavigator;
429     +class G4ePropagator;
430     +class G4eRunManagerKernel;
431     +class G4eTarget;
432     +class G4eTrajState;
433     +class G4eTrajStateFree;
434     +
435     +class G4VUserDetectorConstruction;
436     +class G4VPhysicalVolume;
437     +class G4VUserPhysicsList;
438     +class G4UserRunAction;
439     +class G4UserEventAction;
440     +class G4UserStackingAction;
441     +class G4UserTrackingAction;
442     +class G4UserSteppingAction;
443     +class G4Mag_UsualEqRhs;
444     +class G4Track;
445     +
446     +
447     +class G4eManager
448     +{
449     +public:
450     + G4eManager();
451     + // Initialise data to 0. Starts the G4eRunManagerKernel and G4eNavigator.
452     +
453     +public:
454     + ~G4eManager();
455     +
456     + static G4eManager* GetG4eManager();
457     + // Get only instance of G4eManager. If it does not exists, creates it
458     +
459     + void EventTermination();
460     + // Set state to G4eState_Init
461     +
462     + void RunTermination();
463     + // Set state to G4eState_Init and invoke G4eRunManagerKernel::RunTermination()
464     +
465     + void InitGeant4e();
466     + // Initializes Geant4 and Geant4e
467     +
468     + void InitTrackPropagation();
469     + // Set the propagator step number to 0 and the G4eState to Propagating
470     +
471     + bool InitFieldForBackwards();
472     + // Creates the G4eMag_UsualEqRhs, that will control backwards tracking
473     +
474     + int Propagate( G4eTrajState* currentTS, const G4eTarget* target, G4eMode mode = G4eMode_PropForwards );
475     + //invokes G4ePropagator::Propagate
476     +
477     + int PropagateOneStep( G4eTrajState* currentTS, G4eMode mode = G4eMode_PropForwards );
478     + //invokes G4ePropagator::PropagateOneStep
479     +
480     + void InvokePreUserTrackingAction( G4Track* fpTrack );
481     + // Invoke the G4UserTrackingAction::PreUserTrackingAction
482     + void InvokePostUserTrackingAction( G4Track* fpTrack );
483     + // Invoke the G4UserTrackingAction::PostUserTrackingAction
484     +
485     + bool CloseGeometry();
486     + // Close Geant4 geometry
487     +
488     + void SetUserInitialization(G4VUserDetectorConstruction* userInit);
489     + // Invokes G4eRunManagerKernel to construct detector and set world volume
490     + void SetUserInitialization(G4VPhysicalVolume* userInit);
491     + // Invokes G4eRunManagerKernel to set world volume
492     + void SetUserInitialization(G4VUserPhysicsList* userInit);
493     + // Invokes G4eRunManagerKernel to initialize physics
494     +
495     + void SetUserAction(G4UserTrackingAction* userAction);
496     + // Invokes G4EventManager to set a G4UserTrackingAction
497     + void SetUserAction(G4UserSteppingAction* userAction);
498     + // Invokes G4EventManager to set a G4UserSteppingAction
499     +
500     + G4String PrintG4eState();
501     + G4String PrintG4eState( G4eState state );
502     + // print Geant4e state
503     + G4String PrintG4State();
504     + G4String PrintG4State( G4ApplicationState state );
505     + // print Geant4 state
506     +
507     +private:
508     + void StartG4eRunManagerKernel();
509     + // Create a G4eRunManagerKernel if it does not exist and set to it the G4ePhysicsList
510     +
511     + void StartNavigator();
512     + // Create a G4eNavigator
513     +
514     +public:
515     + // Set and Get methods
516     + G4eRunManagerKernel* GetG4eRunManagerKernel() const;
517     +
518     + void SetSteppingManagerVerboseLevel();
519     +
520     + const G4eState GetState() const;
521     + void SetState( G4eState sta );
522     +
523     + const G4eMode GetMode() const;
524     + void SetMode( G4eMode mode );
525     +
526     + const G4eTarget* GetTarget( bool mustExist = 0) const;
527     + void SetTarget( const G4eTarget* target );
528     +
529     + static int verbose();
530     + static void SetVerbose( int ver );
531     +
532     + G4eNavigator* GetG4eNavigator() const { return theG4eNavigator; }
533     +
534     +private:
535     + static G4eManager* theG4eManager;
536     + //--- The only instance
537     +
538     + G4eRunManagerKernel* theG4eRunManagerKernel;
539     + //--- The G4eRunManagerKernel
540     +
541     + static int theVerbosity;
542     + //--- the verbosity for all GEANT4e classes
543     +
544     + //--- State of the GEANT4e tracking to the target
545     + G4eState theState;
546     +
547     + G4eMode thePropagationMode;
548     +
549     + G4eTarget* theFinalTarget;
550     +
551     + G4ePropagator* thePropagator;
552     +
553     + G4Mag_UsualEqRhs* theEquationOfMotion;
554     +
555     + G4eTrajStateFree* theCurrentTS_FREE;
556     +
557     + G4eNavigator* theG4eNavigator;
558     +
559     +};
560     +
561     +#include "G4eManager.icc"
562     +
563     +#endif
564     +
565     diff -Naur --exclude CVS source/geant4e/include/G4eManager.icc source/geant4e/include/G4eManager.icc
566     --- source/geant4e/include/G4eManager.icc 1970-01-01 01:00:00.000000000 +0100
567     +++ source/geant4e/include/G4eManager.icc 2007-01-17 12:41:58.000000000 +0100
568     @@ -0,0 +1,85 @@
569     +//
570     +// ********************************************************************
571     +// * DISCLAIMER *
572     +// * *
573     +// * The following disclaimer summarizes all the specific disclaimers *
574     +// * of contributors to this software. The specific disclaimers,which *
575     +// * govern, are listed with their locations in: *
576     +// * http://cern.ch/geant4/license *
577     +// * *
578     +// * Neither the authors of this software system, nor their employing *
579     +// * institutes,nor the agencies providing financial support for this *
580     +// * work make any representation or warranty, express or implied, *
581     +// * regarding this software system or assume any liability for its *
582     +// * use. *
583     +// * *
584     +// * This code implementation is the intellectual property of the *
585     +// * GEANT4 collaboration. *
586     +// * By copying, distributing or modifying the Program (or any work *
587     +// * based on the Program) you indicate your acceptance of this *
588     +// * statement, and all its terms. *
589     +// ********************************************************************
590     +//
591     +
592     +inline
593     +void G4eManager::SetState( G4eState sta )
594     +{
595     +// G4cout << " setting G4eState " << sta << G4endl;
596     + theState = sta;
597     +}
598     +
599     +inline
600     +const G4eState G4eManager::GetState() const
601     +{
602     + return theState;
603     +}
604     +
605     +
606     +inline
607     +void G4eManager::SetMode( G4eMode mode )
608     +{
609     + thePropagationMode = mode;
610     +}
611     +
612     +
613     +inline
614     +const G4eMode G4eManager::GetMode() const
615     +{
616     + return thePropagationMode;
617     +}
618     +
619     +
620     +inline
621     +const G4eTarget* G4eManager::GetTarget( bool mustExist ) const
622     +{
623     + if( theFinalTarget == 0 && mustExist ) {
624     + G4Exception(" G4ePropagator defined but without final target ");
625     + }
626     + return theFinalTarget;
627     +}
628     +
629     +
630     +inline
631     +void G4eManager::SetTarget( const G4eTarget* target )
632     +{
633     + theFinalTarget = const_cast<G4eTarget*>(target);
634     +}
635     +
636     +
637     +inline
638     +int G4eManager::verbose()
639     +{
640     + return theVerbosity;
641     +}
642     +
643     +inline
644     +void G4eManager::SetVerbose( int ver )
645     +{
646     + theVerbosity = ver;
647     +}
648     +
649     +inline
650     +G4eRunManagerKernel* G4eManager::GetG4eRunManagerKernel() const
651     +{
652     + return theG4eRunManagerKernel;
653     +}
654     diff -Naur --exclude CVS source/geant4e/include/G4eMuIonisation.hh source/geant4e/include/G4eMuIonisation.hh
655     --- source/geant4e/include/G4eMuIonisation.hh 1970-01-01 01:00:00.000000000 +0100
656     +++ source/geant4e/include/G4eMuIonisation.hh 2007-01-17 12:41:58.000000000 +0100
657     @@ -0,0 +1,81 @@
658     +//
659     +// class G4eMuIonisation
660     +//
661     +// Class description:
662     +//
663     +//
664     +//
665     +
666     +// History:
667     +//
668     +// --------------------------------------------------------------------
669     +#define private public
670     +#include "G4MuIonisation.hh"
671     +#define private private
672     +
673     +// class G4eManager
674     +//
675     +// Class description:
676     +//
677     +// Manages the energy loss processes: suppresses fluctuations and takes care that energy is gained instead of lost if propagation is backwards (by calling G4eIonisationChange methods)
678     +//
679     +// History:
680     +// - Created. Patricia Mendez
681     +// - Adapted to geant4.6.2.p01: P.Arce - Aug 04
682     +//
683     +
684     +#ifndef G4eMuIonisation_h
685     +#define G4eMuIonisation_h 1
686     +#define private public
687     +#include "G4VEnergyLossProcess.hh"
688     +#define private private
689     +
690     +#include "globals.hh"
691     +#include "G4eIonisationChange.hh"
692     +#include "G4MuIonisation.hh"
693     +#include "G4VParticleChange.hh"
694     +#include "G4VProcess.hh"
695     +#include "G4ParticleChange.hh"
696     +class G4Track;
697     +class G4Step;
698     +
699     +
700     +class G4eMuIonisation:public G4MuIonisation, public G4eIonisationChange
701     +{
702     +
703     +public:
704     + G4eMuIonisation(const G4String& name = "G4eMuIoni");
705     +
706     + ~G4eMuIonisation();
707     +
708     + /* virtual std::vector<G4Track*>* SecondariesAlongStep(
709     + const G4Step&,
710     + G4double&,
711     + G4double&,
712     + G4double&);
713     + */
714     + std::vector<G4DynamicParticle*>* SecondariesPostStep(
715     + G4VEmModel*,
716     + const G4MaterialCutsCouple*,
717     + const G4DynamicParticle*,
718     + G4double& tcut);
719     +
720     +
721     + G4VParticleChange* AlongStepDoIt( const G4Track& trackData,
722     + const G4Step& stepData);
723     +/* not needed becuase step is huge: this way AlongStepDoIt computes all the energy loss, if not the creation of secondaries will account for some energy loss, in a random way
724     + virtual G4double AlongStepGetPhysicalInteractionLength(
725     + const G4Track&,
726     + G4double ,
727     + G4double ,
728     + G4double& ,
729     + G4GPILSelection*);
730     + G4double PostStepGetPhysicalInteractionLength(
731     + const G4Track& track,
732     + G4double previousStepSize,
733     + G4ForceCondition* condition );
734     +*/
735     +
736     +};
737     +
738     +#endif
739     diff -Naur --exclude CVS source/geant4e/include/G4eNavigator.hh source/geant4e/include/G4eNavigator.hh
740     --- source/geant4e/include/G4eNavigator.hh 1970-01-01 01:00:00.000000000 +0100
741     +++ source/geant4e/include/G4eNavigator.hh 2007-01-17 12:41:58.000000000 +0100
742     @@ -0,0 +1,49 @@
743     +//
744     +// class G4eNavigator
745     +//
746     +// Class description:
747     +// This class serves to do the double navigation, in the detector geometry and in the target surface, by overwriting the ComputeStep and ComputeSafety methods
748     +//
749     +// History:
750     +// - Created. P. Arce
751     +//
752     +
753     +#ifndef G4eNavigator_H
754     +#define G4eNavigator_H 1
755     +
756     +#include "G4Navigator.hh"
757     +
758     +#include "G4eManager.hh"
759     +class G4eTargetSurface;
760     +class G4edd;
761     +#include "G4ThreeVector.hh"
762     +#include "geomdefs.hh"
763     +class G4eTargetSurface;
764     +
765     +#include <iostream>
766     +
767     +class G4eNavigator : public G4Navigator
768     +{
769     + public:
770     +
771     + G4eNavigator();
772     + ~G4eNavigator();
773     +
774     + G4double ComputeStep (const G4ThreeVector &pGlobalPoint,
775     + const G4ThreeVector &pDirection,
776     + const G4double pCurrentProposedStepLength,
777     + G4double &pNewSafety);
778     + // calls the navigation in the detector geometry and then checks if the distance to surface is smaller than the proposed step
779     +
780     + G4double ComputeSafety(const G4ThreeVector &globalpoint,
781     + const G4double pProposedMaxLength = DBL_MAX);
782     + // calls the navigation in the detector geometry and then checks if the distance to surface is smaller than the proposed safety
783     +
784     + void SetTarget( const G4eTarget* target );
785     +
786     +private:
787     + // G4edd* theTarget; // any data makes it crash??!!
788     +};
789     +
790     +#endif
791     +
792     diff -Naur --exclude CVS source/geant4e/include/G4ePhysicsList.hh source/geant4e/include/G4ePhysicsList.hh
793     --- source/geant4e/include/G4ePhysicsList.hh 1970-01-01 01:00:00.000000000 +0100
794     +++ source/geant4e/include/G4ePhysicsList.hh 2007-01-17 12:41:58.000000000 +0100
795     @@ -0,0 +1,47 @@
796     +//
797     +// class G4ePhysicsList
798     +//
799     +// Class description:
800     +// Default physics lsit for GEANT4e (should not be overridden, unless by experts)
801     +// No multiple scattering and no production of secondaries.
802     +// The energy loss process is G4EnergyLossForExtrapolator
803     +// It also defines the geant4e processes to limit the step: G4eMagneticFieldLimitProcess, G4eStepLimitProcess
804     +
805     +// History:
806     +//
807     +// --------------------------------------------------------------------
808     +//
809     +#ifndef G4ePhysicsList_h
810     +#define G4ePhysicsList_h 1
811     +
812     +#include "G4VUserPhysicsList.hh"
813     +#include "globals.hh"
814     +
815     +class G4ePhysicsList: public G4VUserPhysicsList
816     +{
817     +public:
818     + G4ePhysicsList();
819     + virtual ~G4ePhysicsList();
820     +
821     +protected:
822     + virtual void ConstructParticle();
823     + // constructs gamma, e+/- and mu+/-
824     +
825     + virtual void ConstructProcess();
826     + // construct physical processes
827     +
828     + virtual void SetCuts();
829     + // SetCutsWithDefault
830     +
831     +protected:
832     + virtual void ConstructEM();
833     +
834     + private:
835     + // G4VPhysicsConstructor* emPhysicsList;
836     +
837     +};
838     +
839     +#endif
840     +
841     +
842     +
843     diff -Naur --exclude CVS source/geant4e/include/G4ePropagatorG4.hh source/geant4e/include/G4ePropagatorG4.hh
844     --- source/geant4e/include/G4ePropagatorG4.hh 1970-01-01 01:00:00.000000000 +0100
845     +++ source/geant4e/include/G4ePropagatorG4.hh 2007-01-17 12:41:58.000000000 +0100
846     @@ -0,0 +1,72 @@
847     +//
848     +// class G4ePropagatorG4
849     +//
850     +// Class description:
851     +//
852     +//
853     +//
854     +
855     +// History:
856     +//
857     +// --------------------------------------------------------------------
858     +//
859     +#ifndef G4ePropagatorG4_h
860     +#define G4ePropagatorG4_h
861     +//
862     +// class G4ePropagatorG4
863     +//
864     +// Class description:
865     +//
866     +// Manages the propagation of tracks by GEANT4. Creates a G4Track, asks GEANT4 to propagate it and takes also care to propagate the errors. Stops the track when GEANT4 stops it or a G4eTarget is reached
867     +//
868     +// History:
869     +// - Created. Pedro Arce, June 2001
870     +
871     +#include "globals.hh"
872     +#include "G4ePropagator.hh"
873     +#include "G4TrackingManager.hh"
874     +
875     +class G4eTrajState;
876     +class G4eErrorMatrix;
877     +class G4Track;
878     +class G4eTrajState;
879     +class G4eTrajStateFree;
880     +
881     +class G4ePropagatorG4 : public G4ePropagator
882     +{
883     +public:
884     + G4ePropagatorG4();
885     + virtual ~G4ePropagatorG4(){};
886     +
887     + G4Track* InitG4Track( G4eTrajState& initialTS );
888     + virtual int Propagate( G4eTrajState* currentTS, const G4eTarget* target, G4eMode mode = G4eMode_PropForwards);
889     + virtual int PropagateOneStep( G4eTrajState* currentTS );
890     + int MakeOneStep( G4eTrajStateFree* currentTS_FREE );
891     + // Creates theCurrentTS_FREE (transforms the user G4eTrajStateOnSurface or copies the G4eTrajStateFree)
892     + G4eTrajStateFree* InitFreeTrajState( G4eTrajState* currentTS );
893     + //--- After steps are done, convert the G4eTrajStateFree used for error propagation to the class of origin (G4eTrajStateFree or G4eTrajStatOnSurface)
894     + void GetFinalTrajState( G4eTrajState* currentTS, G4eTrajStateFree* currentTS_FREE, const G4eTarget* target );
895     +
896     +private:
897     + int MakeSteps( G4eTrajStateFree* currentTS_FREE );
898     +
899     + G4bool CheckIfLastStep( G4Track* aTrack );
900     +
901     + void SetTargetToNavigator( const G4eTarget* target );
902     + // Set the target to G4eNavigator. Called at beginning of Propagate and PropagateOneStep (as user is allowed to change target to his will)
903     +
904     +private:
905     + G4Track* theG4Track;
906     +
907     + G4SteppingManager* fpSteppingManager;
908     +
909     + G4int verbose;
910     +
911     + //t G4VPhysicslVolume* theTrackingGeometry;
912     + //t static G4VPhysicslVolume* theCurrentTrackingGeometry;
913     +
914     + G4bool thePropIsInitialized;
915     +
916     +};
917     +
918     +#endif
919     diff -Naur --exclude CVS source/geant4e/include/G4ePropagator.hh source/geant4e/include/G4ePropagator.hh
920     --- source/geant4e/include/G4ePropagator.hh 1970-01-01 01:00:00.000000000 +0100
921     +++ source/geant4e/include/G4ePropagator.hh 2007-01-17 12:41:58.000000000 +0100
922     @@ -0,0 +1,68 @@
923     +//
924     +// class G4ePropagator
925     +//
926     +// Class description:
927     +//
928     +//
929     +//
930     +
931     +// History:
932     +//
933     +// --------------------------------------------------------------------
934     +#ifndef G4ePropagator_h
935     +#define G4ePropagator_h
936     +//
937     +// class G4ePropagator
938     +//
939     +// Class description:
940     +// Base classes of propagators
941     +//
942     +// History:
943     +// - Created. Pedro Arce, June 2001
944     +
945     +class G4eTrajState;
946     +class G4eTarget;
947     +
948     +#include "G4eManager.hh"
949     +#include "globals.hh"
950     +#include "G4ThreeVector.hh"
951     +
952     +class G4ePropagator
953     +{
954     +public:
955     + G4ePropagator(){};
956     + virtual ~G4ePropagator(){};
957     +
958     + virtual int Propagate( G4eTrajState* currentTS, const G4eTarget* target, G4eMode mode ) = 0;
959     + virtual int PropagateOneStep( G4eTrajState* currentTS ) = 0;
960     + // Steers the GEANT4 propagation of a track:
961     + // The particle will be extrapolated until theFinalTarget is reached. The final G4Track parameters will be passed to theFinalTrajState
962     +
963     +
964     +private:
965     + // set and get methods
966     +public:
967     + inline const G4eTrajState* GetInitialTrajState() const;
968     +
969     + G4double GetStepLength() const
970     + { return theStepLength; }
971     +
972     + void SetStepLength( const G4double sl )
973     + { theStepLength = sl; }
974     +
975     + void SetStepN( const int sn ){
976     + theStepN = sn; }
977     +
978     +protected:
979     + G4double theStepLength;
980     + G4eTrajState* theInitialTrajState;
981     + G4eTrajState* theFinalTrajState;
982     +
983     + G4int theStepN;
984     +
985     +};
986     +
987     +#include "G4ePropagator.icc"
988     +
989     +#endif
990     +
991     diff -Naur --exclude CVS source/geant4e/include/G4ePropagator.icc source/geant4e/include/G4ePropagator.icc
992     --- source/geant4e/include/G4ePropagator.icc 1970-01-01 01:00:00.000000000 +0100
993     +++ source/geant4e/include/G4ePropagator.icc 2007-01-17 12:41:58.000000000 +0100
994     @@ -0,0 +1,29 @@
995     +//
996     +// ********************************************************************
997     +// * DISCLAIMER *
998     +// * *
999     +// * The following disclaimer summarizes all the specific disclaimers *
1000     +// * of contributors to this software. The specific disclaimers,which *
1001     +// * govern, are listed with their locations in: *
1002     +// * http://cern.ch/geant4/license *
1003     +// * *
1004     +// * Neither the authors of this software system, nor their employing *
1005     +// * institutes,nor the agencies providing financial support for this *
1006     +// * work make any representation or warranty, express or implied, *
1007     +// * regarding this software system or assume any liability for its *
1008     +// * use. *
1009     +// * *
1010     +// * This code implementation is the intellectual property of the *
1011     +// * GEANT4 collaboration. *
1012     +// * By copying, distributing or modifying the Program (or any work *
1013     +// * based on the Program) you indicate your acceptance of this *
1014     +// * statement, and all its terms. *
1015     +// ********************************************************************
1016     +//
1017     +
1018     +inline
1019     +const G4eTrajState* G4ePropagator::GetInitialTrajState() const
1020     +{
1021     + return theInitialTrajState;
1022     +}
1023     +
1024     diff -Naur --exclude CVS source/geant4e/include/G4eRunManagerKernel.hh source/geant4e/include/G4eRunManagerKernel.hh
1025     --- source/geant4e/include/G4eRunManagerKernel.hh 1970-01-01 01:00:00.000000000 +0100
1026     +++ source/geant4e/include/G4eRunManagerKernel.hh 2007-01-17 12:41:58.000000000 +0100
1027     @@ -0,0 +1,79 @@
1028     +//
1029     +// class G4eRunManagerKernel
1030     +//
1031     +// Class description:
1032     +//
1033     +//
1034     +//
1035     +
1036     +// History:
1037     +//
1038     +// --------------------------------------------------------------------
1039     +// class G4eRunManagerKernel
1040     +//
1041     +// Class description:
1042     +//
1043     +// This is the G4RunManagerKernel of the GEANT4e package, it allows G4eManager to implement the run initialization and termination
1044     +// It does not inherit from G4RunManagerKernel but has a pointer to it. This is because G4RunManagerKernel cannot be inherited from, as G4RunManager creates one instance and then there would be two instances (what is forbidden)
1045     +//
1046     +// History:
1047     +// - Created. Pedro Arce, January 2005
1048     +
1049     +#ifndef G4eRunManagerKernel_h
1050     +#define G4eRunManagerKernel_h 1
1051     +
1052     +class G4RunManagerKernel;
1053     +class G4VUserDetectorConstruction;
1054     +class G4VPhysicalVolume;
1055     +class G4VUserPhysicsList;
1056     +class G4UserTrackingAction;
1057     +class G4UserSteppingAction;
1058     +
1059     +
1060     +class G4eRunManagerKernel
1061     +//: public G4RunManagerKernel
1062     +{
1063     +public: // with description
1064     + static G4eRunManagerKernel* GetRunManagerKernel();
1065     + // Static method which returns the singleton pointer of G4eRunManagerKernel or
1066     + // its derived class.
1067     +
1068     +private:
1069     + static G4eRunManagerKernel* fRunManagerKernel;
1070     +
1071     +public:
1072     + G4eRunManagerKernel();
1073     + virtual ~G4eRunManagerKernel();
1074     + // The constructor and the destructor. The user must construct this class
1075     + // object at the beginning of his/her main() and must delete it at the
1076     + // bottom of the main().
1077     +
1078     +public: // with description
1079     + // file is executed.
1080     +
1081     + void SetUserInitialization(G4VUserDetectorConstruction* userInit);
1082     + void SetUserInitialization(G4VPhysicalVolume* userInit);
1083     +
1084     + void SetUserInitialization(G4VUserPhysicsList* userInit);
1085     +
1086     + void SetUserAction(G4UserTrackingAction* userAction);
1087     + void SetUserAction(G4UserSteppingAction* userAction);
1088     +
1089     + G4VUserPhysicsList* GetUserPhysicsList() const
1090     + { return theUserPhysicsList; }
1091     +
1092     + void RunInitialization();
1093     + void InitializeGeometry();
1094     + void InitializePhysics();
1095     +
1096     + void RunTermination();
1097     +
1098     +private:
1099     + G4VUserPhysicsList* theUserPhysicsList;
1100     + G4VPhysicalVolume* theUserWorld;
1101     +
1102     + G4RunManagerKernel* theG4RunManagerKernel;
1103     +};
1104     +
1105     +#endif
1106     +
1107     diff -Naur --exclude CVS source/geant4e/include/G4eTargetCylindricalSurface.hh source/geant4e/include/G4eTargetCylindricalSurface.hh
1108     --- source/geant4e/include/G4eTargetCylindricalSurface.hh 1970-01-01 01:00:00.000000000 +0100
1109     +++ source/geant4e/include/G4eTargetCylindricalSurface.hh 2007-01-17 12:41:58.000000000 +0100
1110     @@ -0,0 +1,56 @@
1111     +//
1112     +// class G4eTargetCylindricalSurface
1113     +//
1114     +// Class description:
1115     +//
1116     +//
1117     +//
1118     +
1119     +// History:
1120     +//
1121     +// --------------------------------------------------------------------
1122     +//
1123     +// class G4eTargetSurface
1124     +//
1125     +// Class description:
1126     +//
1127     +// G4eTarget class: limits step when track reaches this cylindrical surface
1128     +//
1129     +// History:
1130     +// - Created. P. Arce, September 2004
1131     +
1132     +#ifndef G4eTargetCylindricalSurface_h
1133     +#define G4eTargetCylindricalSurface_h
1134     +
1135     +#include "globals.hh"
1136     +#include "G4eTargetSurface.hh"
1137     +#include "G4ThreeVector.hh"
1138     +#include "G4RotationMatrix.hh"
1139     +#include "G4Transform3D.hh"
1140     +#include "G4Plane3D.hh"
1141     +
1142     +class G4eTargetCylindricalSurface : public G4eTargetSurface
1143     +{
1144     +public:
1145     + G4eTargetCylindricalSurface( const G4float& radius, const G4ThreeVector& trans=G4ThreeVector(), const G4RotationMatrix& rotm=G4RotationMatrix());
1146     + G4eTargetCylindricalSurface( const G4float& radius, const G4Transform3D& trans3D);
1147     +
1148     + ~G4eTargetCylindricalSurface(){};
1149     +
1150     +public:
1151     +
1152     + virtual G4ThreeVector Intersect( const G4ThreeVector& point, const G4ThreeVector& direc ) const;
1153     + virtual G4ThreeVector IntersectLocal( const G4ThreeVector& point, const G4ThreeVector& direc ) const;
1154     + virtual G4double GetDistanceFromPoint( const G4ThreeVector& point, const G4ThreeVector& direc ) const;
1155     + virtual G4double GetDistanceFromPoint( const G4ThreeVector& point ) const;
1156     + virtual G4Plane3D GetTangentPlane( const G4ThreeVector& point ) const;
1157     + virtual void Dump( G4String msg ) const;
1158     +
1159     + private:
1160     + G4float fradius;
1161     + G4Transform3D ftransform3D;
1162     +
1163     +};
1164     +
1165     +#endif
1166     +
1167     diff -Naur --exclude CVS source/geant4e/include/G4eTargetG4Volume.hh source/geant4e/include/G4eTargetG4Volume.hh
1168     --- source/geant4e/include/G4eTargetG4Volume.hh 1970-01-01 01:00:00.000000000 +0100
1169     +++ source/geant4e/include/G4eTargetG4Volume.hh 2007-01-17 12:41:58.000000000 +0100
1170     @@ -0,0 +1,51 @@
1171     +//
1172     +// class G4eTargetG4Volume
1173     +//
1174     +// Class description:
1175     +//
1176     +//
1177     +//
1178     +
1179     +// History:
1180     +//
1181     +// --------------------------------------------------------------------
1182     +#ifndef G4eTargetG4Volume_HH
1183     +#define G4eTargetG4Volume_HH
1184     +//
1185     +// Class description:
1186     +//
1187     +// G4eTarget class: limits step when volume is reached.
1188     +// !! NOT IMPLEMENTED YET
1189     +//
1190     +// History:
1191     +// - Created. P. Arce, September 2004
1192     +
1193     +#include "globals.hh"
1194     +#include "G4ThreeVector.hh"
1195     +#include "G4eTargetWithTangentPlane.hh"
1196     +#include "G4Plane3D.hh"
1197     +
1198     +class G4Step;
1199     +class G4String;
1200     +
1201     +class G4eTargetG4Volume : public G4eTargetWithTangentPlane
1202     +{
1203     +public:
1204     + G4eTargetG4Volume( const G4String& name );
1205     + virtual ~G4eTargetG4Volume(){};
1206     +
1207     +public:
1208     + virtual G4ThreeVector Intersect( const G4ThreeVector& point, const G4ThreeVector& direc ) const = 0;
1209     + virtual G4Plane3D GetTangentPlane( const G4ThreeVector& point ) const;
1210     + virtual bool TargetReached(const G4Step* aStep);
1211     + virtual void Dump( G4String msg ) const;
1212     +
1213     +//access methods
1214     + private:
1215     + G4String theName;
1216     +
1217     +};
1218     +
1219     +#endif
1220     +
1221     +
1222     diff -Naur --exclude CVS source/geant4e/include/G4eTarget.hh source/geant4e/include/G4eTarget.hh
1223     --- source/geant4e/include/G4eTarget.hh 1970-01-01 01:00:00.000000000 +0100
1224     +++ source/geant4e/include/G4eTarget.hh 2007-01-17 12:41:58.000000000 +0100
1225     @@ -0,0 +1,45 @@
1226     +//
1227     +// class G4eTarget
1228     +//
1229     +// Class description:
1230     +//
1231     +// Base class for all targets
1232     +//
1233     +// History:
1234     +// - Created. P. Arce, September 2004
1235     +
1236     +#ifndef G4eTarget_h
1237     +#define G4eTarget_h
1238     +
1239     +#include "globals.hh"
1240     +#include "G4ThreeVector.hh"
1241     +class G4Step;
1242     +
1243     +enum G4eTargetType{ G4eTarget_PlaneSurface, G4eTarget_CylindricalSurface, G4eTarget_G4Volume, G4eTarget_TrkL };
1244     +
1245     +
1246     +class G4eTarget
1247     +{
1248     +public:
1249     + G4eTarget(){};
1250     + virtual ~G4eTarget(){};
1251     +
1252     +public:
1253     + virtual double GetDistanceFromPoint( const G4ThreeVector&, const G4ThreeVector& ) const { return DBL_MAX; } //for targetVolume
1254     + virtual double GetDistanceFromPoint( const G4ThreeVector& ) const { return DBL_MAX; } //for targetVolume
1255     +
1256     + virtual bool TargetReached(const G4Step*){ return 0; } //for TargetSurface and TargetTrackLength
1257     +
1258     + virtual void Dump( G4String msg ) const = 0;
1259     +
1260     +//access methods
1261     + G4eTargetType GetType() const { return theType; }
1262     +
1263     + protected:
1264     +
1265     + G4eTargetType theType;
1266     +};
1267     +
1268     +#endif
1269     +
1270     +
1271     diff -Naur --exclude CVS source/geant4e/include/G4eTargetPlaneSurface.hh source/geant4e/include/G4eTargetPlaneSurface.hh
1272     --- source/geant4e/include/G4eTargetPlaneSurface.hh 1970-01-01 01:00:00.000000000 +0100
1273     +++ source/geant4e/include/G4eTargetPlaneSurface.hh 2007-01-17 12:41:58.000000000 +0100
1274     @@ -0,0 +1,59 @@
1275     +//
1276     +// class G4eTargetPlaneSurface
1277     +//
1278     +// Class description:
1279     +//
1280     +//
1281     +//
1282     +
1283     +// History:
1284     +//
1285     +// --------------------------------------------------------------------
1286     +// class G4eTargetPlaneSurface
1287     +//
1288     +// Class description:
1289     +//
1290     +// G4eTarget class: limits step when track reaches this plane surface
1291     +//
1292     +//
1293     +// History:
1294     +// - Created. P. Arce, September 2004
1295     +
1296     +#ifndef G4eTargetPlaneSurface_h
1297     +#define G4eTargetPlaneSurface_h
1298     +
1299     +#include "globals.hh"
1300     +#include "G4eTargetSurface.hh"
1301     +#include "G4ThreeVector.hh"
1302     +#include "G4Plane3D.hh"
1303     +
1304     +class G4eTargetPlaneSurface : public G4eTargetSurface, G4Plane3D
1305     +{
1306     +public:
1307     + G4eTargetPlaneSurface(G4double a=0, G4double b=0, G4double c=0, G4double d=0);
1308     + G4eTargetPlaneSurface(const G4Normal3D &n, const G4Point3D &p);
1309     + G4eTargetPlaneSurface(const G4Point3D &p1, const G4Point3D &p2, const G4Point3D &p3);
1310     +
1311     + ~G4eTargetPlaneSurface(){};
1312     +
1313     +public:
1314     + virtual G4ThreeVector Intersect( const G4ThreeVector& point, const G4ThreeVector& direc ) const;
1315     + // Intersects the surface with the line given by point + vector
1316     +
1317     + virtual double GetDistanceFromPoint( const G4ThreeVector& point, const G4ThreeVector& direc ) const;
1318     + // Gets distance from point to surface in the direction of direc
1319     +
1320     + virtual double GetDistanceFromPoint( const G4ThreeVector& pt ) const;
1321     + // Gets closest distance from point to surface
1322     +
1323     + virtual G4Plane3D GetTangentPlane( const G4ThreeVector& point ) const;
1324     + // Returns tangent plane as itself
1325     +
1326     + virtual void Dump( G4String msg ) const;
1327     +
1328     + private:
1329     +
1330     +};
1331     +
1332     +#endif
1333     +
1334     diff -Naur --exclude CVS source/geant4e/include/G4eTargetSurface.hh source/geant4e/include/G4eTargetSurface.hh
1335     --- source/geant4e/include/G4eTargetSurface.hh 1970-01-01 01:00:00.000000000 +0100
1336     +++ source/geant4e/include/G4eTargetSurface.hh 2007-01-17 12:41:58.000000000 +0100
1337     @@ -0,0 +1,43 @@
1338     +//
1339     +// class G4eTargetSurface
1340     +//
1341     +// Class description:
1342     +//
1343     +// Base class for targets that are surfaces
1344     +
1345     +//
1346     +// History:
1347     +// - Created. P. Arce, September 2004
1348     +
1349     +#ifndef G4eTargetSurface_h
1350     +#define G4eTargetSurface_h
1351     +
1352     +#include "globals.hh"
1353     +#include "G4ThreeVector.hh"
1354     +#include "G4eTargetWithTangentPlane.hh"
1355     +#include "G4Plane3D.hh"
1356     +
1357     +
1358     +class G4eTargetSurface : public G4eTargetWithTangentPlane
1359     +{
1360     +public:
1361     + G4eTargetSurface(){ };
1362     + virtual ~G4eTargetSurface(){};
1363     +
1364     +public:
1365     + virtual double GetDistanceFromPoint( const G4ThreeVector& point, const G4ThreeVector& direc ) const = 0;
1366     +
1367     + virtual double GetDistanceFromPoint( const G4ThreeVector& point ) const = 0;
1368     +
1369     + virtual G4Plane3D GetTangentPlane( const G4ThreeVector& point ) const = 0;
1370     +
1371     + virtual void Dump( G4String msg ) const = 0;
1372     +
1373     + private:
1374     + virtual G4ThreeVector Intersect( const G4ThreeVector& point, const G4ThreeVector& direc ) const = 0;
1375     + // Intersects the surface with the line given by point + vector
1376     +};
1377     +
1378     +#endif
1379     +
1380     +
1381     diff -Naur --exclude CVS source/geant4e/include/G4eTargetTrackLength.hh source/geant4e/include/G4eTargetTrackLength.hh
1382     --- source/geant4e/include/G4eTargetTrackLength.hh 1970-01-01 01:00:00.000000000 +0100
1383     +++ source/geant4e/include/G4eTargetTrackLength.hh 2007-01-17 12:41:58.000000000 +0100
1384     @@ -0,0 +1,63 @@
1385     +//
1386     +// class G4eTargetTrackLength
1387     +//
1388     +// Class description:
1389     +//
1390     +// G4eTarget class: limits step when track length is bigger than theMaximumTrackLength
1391     +// It is a G4VDiscreteProcess: limits the step in PostStepGetPhysicalInteractionLength
1392     +//
1393     +// History:
1394     +// - Created. P. Arce, September 2004
1395     +
1396     +#ifndef G4eTargetTrackLength_h
1397     +#define G4eTargetTrackLength_h 1
1398     +
1399     +#include "G4ios.hh"
1400     +#include "globals.hh"
1401     +#include "G4VDiscreteProcess.hh"
1402     +#include "G4PhysicsTable.hh"
1403     +#include "G4PhysicsLogVector.hh"
1404     +#include "G4ElementTable.hh"
1405     +#include "G4Step.hh"
1406     +#include "G4eTarget.hh"
1407     +
1408     +//----------------------------------------------------------------------------
1409     +class G4eTargetTrackLength : public G4VDiscreteProcess, public G4eTarget
1410     +{
1411     +public: // with description
1412     +
1413     + virtual double GetDistanceFromPoint( const G4ThreeVector&, const G4ThreeVector& ) const { return DBL_MAX; } //for targetVolume
1414     + virtual double GetDistanceFromPoint( const G4ThreeVector& ) const { return DBL_MAX; } //for targetVolume
1415     +
1416     + G4eTargetTrackLength(const double maxTrkLength );
1417     + // Constructs and add this process to G4ProcessManager
1418     +
1419     + virtual ~G4eTargetTrackLength(){ };
1420     +
1421     + virtual G4double PostStepGetPhysicalInteractionLength(
1422     + const G4Track& track,
1423     + G4double previousStepSize,
1424     + G4ForceCondition* condition
1425     + );
1426     + // Checks if the maximum track length has been reached
1427     +
1428     + /*
1429     + virtual G4VParticleChange* PostStepDoIt(
1430     + const G4Track& ,
1431     + const G4Step& );
1432     +
1433     + */
1434     +
1435     + virtual G4double GetMeanFreePath(const class G4Track & track, G4double, G4ForceCondition *);
1436     + // Mean free path = theMaximumTrackLength - track.GetTrackLength();
1437     +
1438     + void Dump( G4String msg ) const;
1439     +
1440     +private:
1441     + G4double theMaximumTrackLength;
1442     +};
1443     +
1444     +
1445     +
1446     +#endif
1447     +
1448     diff -Naur --exclude CVS source/geant4e/include/G4eTargetWithTangentPlane.hh source/geant4e/include/G4eTargetWithTangentPlane.hh
1449     --- source/geant4e/include/G4eTargetWithTangentPlane.hh 1970-01-01 01:00:00.000000000 +0100
1450     +++ source/geant4e/include/G4eTargetWithTangentPlane.hh 2007-01-17 12:41:58.000000000 +0100
1451     @@ -0,0 +1,35 @@
1452     +//
1453     +// class G4eTargetWithTangentPlane
1454     +//
1455     +// Class description:
1456     +//
1457     +// Base class for G4eTarget classes for which a tangent plane is defined
1458     +//
1459     +// History:
1460     +// - Created. P. Arce, September 2004
1461     +#ifndef G4eTargetWithTangentPlane_HH
1462     +#define G4eTargetWithTangentPlane_HH
1463     +
1464     +#include "globals.hh"
1465     +#include "G4ThreeVector.hh"
1466     +#include "G4eTarget.hh"
1467     +#include "G4Plane3D.hh"
1468     +
1469     +class G4eTargetWithTangentPlane : public G4eTarget
1470     +{
1471     +public:
1472     + G4eTargetWithTangentPlane(){};
1473     + virtual ~G4eTargetWithTangentPlane(){};
1474     +
1475     +public:
1476     + virtual G4Plane3D GetTangentPlane( const G4ThreeVector& point ) const = 0;
1477     +
1478     + virtual void Dump( G4String msg ) const = 0;
1479     +
1480     + private:
1481     +
1482     +};
1483     +
1484     +#endif
1485     +
1486     +
1487     diff -Naur --exclude CVS source/geant4e/include/G4eTrajError.hh source/geant4e/include/G4eTrajError.hh
1488     --- source/geant4e/include/G4eTrajError.hh 1970-01-01 01:00:00.000000000 +0100
1489     +++ source/geant4e/include/G4eTrajError.hh 2007-01-17 12:41:58.000000000 +0100
1490     @@ -0,0 +1,18 @@
1491     +//
1492     +// class G4eTrajError
1493     +//
1494     +// Class description:
1495     +//
1496     +// Trajectory error. Implemented for the moment as a CLHEP HepSymMatrix, until other possibly faster implementations are studied
1497     +//
1498     +// History:
1499     +// - Created. P. Arce
1500     +#ifndef G4eTrajError_h
1501     +#define G4eTrajError_h
1502     +
1503     +#include "CLHEP/Matrix/SymMatrix.h"
1504     +
1505     +typedef HepSymMatrix G4eTrajError;
1506     +
1507     +#endif
1508     +
1509     diff -Naur --exclude CVS source/geant4e/include/G4eTrajParamFree.hh source/geant4e/include/G4eTrajParamFree.hh
1510     --- source/geant4e/include/G4eTrajParamFree.hh 1970-01-01 01:00:00.000000000 +0100
1511     +++ source/geant4e/include/G4eTrajParamFree.hh 2007-01-17 12:41:58.000000000 +0100
1512     @@ -0,0 +1,60 @@
1513     +//
1514     +// class G4eTrajParamFree
1515     +//
1516     +// Class description:
1517     +//
1518     +// Holds the 5 independent variables of the trajectory for a G4eTrajStateFree object. It is not used for anything but for printing, but anyhow it is updated everytime the position and momentum are updated
1519     +//
1520     +// History:
1521     +// - Created. Pedro Arce, September 2002
1522     +
1523     +#ifndef G4eTrajParamFree_h
1524     +#define G4eTrajParamFree_h
1525     +
1526     +#include "G4Point3D.hh"
1527     +#include "G4Vector3D.hh"
1528     +
1529     +#include "globals.hh"
1530     +#include "G4Track.hh"
1531     +
1532     +class G4eTrajParamFree
1533     +{
1534     +public:
1535     + G4eTrajParamFree(){};
1536     + G4eTrajParamFree( const G4Point3D& pos, const G4Vector3D& mom );
1537     + // Build parameters from position and momentum
1538     + virtual ~G4eTrajParamFree(){};
1539     +
1540     + void Update( const G4Track* aTrack );
1541     + // Update parameters from G4Track
1542     +
1543     + friend
1544     + std::ostream& operator<<(std::ostream&, const G4eTrajParamFree& ts);
1545     +
1546     + // Set and Get methods
1547     +public:
1548     + void SetParameters( const G4Point3D& pos, const G4Vector3D& mom );
1549     +
1550     + G4Vector3D GetDirection() const { return fDir;}
1551     +
1552     + double GetInvP() const { return fInvP; }
1553     +
1554     + double GetLambda() const { return fLambda; }
1555     +
1556     + double GetPhi() const { return fPhi; }
1557     +
1558     + double GetYPerp() const { return fYPerp; }
1559     +
1560     + double GetZPerp() const { return fZPerp; }
1561     +
1562     +private:
1563     + G4Vector3D fDir; //direction to which YPerp, ZPerp refer
1564     + double fInvP;
1565     + double fLambda; // 90 - theta
1566     + double fPhi;
1567     + double fYPerp;
1568     + double fZPerp;
1569     +
1570     +};
1571     +
1572     +#endif
1573     diff -Naur --exclude CVS source/geant4e/include/G4eTrajParamOnSurface.hh source/geant4e/include/G4eTrajParamOnSurface.hh
1574     --- source/geant4e/include/G4eTrajParamOnSurface.hh 1970-01-01 01:00:00.000000000 +0100
1575     +++ source/geant4e/include/G4eTrajParamOnSurface.hh 2007-01-17 12:41:58.000000000 +0100
1576     @@ -0,0 +1,60 @@
1577     +// class G4eTrajParamOnSurface
1578     +//
1579     +// Class description:
1580     +//
1581     +// Holds the 5 independent variables of the trajectory for a G4eTrajStateOnSurface object. It is not used for anything but for printing, but anyhow it is updated everytime the position and momentum are updated
1582     +//
1583     +// History:
1584     +// - Created. P. Arce
1585     +
1586     +#ifndef G4eTrajParamOnSurface_h
1587     +#define G4eTrajParamOnSurface_h
1588     +
1589     +#include "G4Point3D.hh"
1590     +#include "G4Vector3D.hh"
1591     +#include "G4Plane3D.hh"
1592     +#include "G4ThreeVector.hh"
1593     +
1594     +#include "globals.hh"
1595     +#include "G4Track.hh"
1596     +
1597     +class G4eTrajParamOnSurface
1598     +{
1599     +public:
1600     + G4eTrajParamOnSurface(){};
1601     + G4eTrajParamOnSurface( const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecV, const G4Vector3D& vecW );
1602     + G4eTrajParamOnSurface( const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane );
1603     + virtual ~G4eTrajParamOnSurface(){};
1604     +
1605     + friend
1606     + std::ostream& operator<<(std::ostream&, const G4eTrajParamOnSurface& ts);
1607     +
1608     + // set and get methods
1609     +public:
1610     + void SetParameters( const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecV, const G4Vector3D& vecW );
1611     + void SetParameters( const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane );
1612     +
1613     + G4Vector3D GetDirection() const { return fDir;}
1614     + G4Vector3D GetPlaneNormal() const { return fVectorV.cross(fVectorW);}
1615     + G4Vector3D GetVectorV() const { return fVectorV;}
1616     + G4Vector3D GetVectorW() const { return fVectorW;}
1617     + double GetPV() const{ return fPV; }
1618     + double GetPW() const{ return fPW; }
1619     + double GetV() const{ return fV; }
1620     + double GetW() const{ return fW; }
1621     +
1622     +private:
1623     + G4ThreeVector fDir;
1624     + G4Vector3D fVectorV; //one of the vectors defining the plane
1625     + G4Vector3D fVectorW; //one of the vectors defining the plane
1626     + double fInvP;
1627     + double fPV;
1628     + double fPW;
1629     + double fV;
1630     + double fW;
1631     +
1632     +};
1633     +
1634     +#endif
1635     +
1636     +
1637     diff -Naur --exclude CVS source/geant4e/include/G4eTrajStateFree.hh source/geant4e/include/G4eTrajStateFree.hh
1638     --- source/geant4e/include/G4eTrajStateFree.hh 1970-01-01 01:00:00.000000000 +0100
1639     +++ source/geant4e/include/G4eTrajStateFree.hh 2007-01-17 12:41:58.000000000 +0100
1640     @@ -0,0 +1,94 @@
1641     +//
1642     +// class G4eTrajStateFree
1643     +//
1644     +// Class description:
1645     +//
1646     +// Represents a free trG4eTrajState
1647     +// It can be represented by the 5 variables
1648     +// 1/p, lambda, phi, y_perp, z_perp
1649     +// where lambda and phi are the dip and azimuthal angles related
1650     +// to the momentum components in the following way:
1651     +// p_x = p cos(lambda) cos(phi) ! lambda = 90 - theta
1652     +// p_y = p cos(lambda) sin(phi)
1653     +// p_z = p sin(lambda)
1654     +// y_perp and z_perp are the coordinates of the trajectory in a
1655     +// local orthonormal reference frame with the x_perp axis along the
1656     +// particle direction, the y_perp being parallel to the x-y plane.
1657     +//
1658     +// History:
1659     +//
1660     +//-------------------------------------------------------------------
1661     +#ifndef G4eTrajStateFree_hh
1662     +#define G4eTrajStateFree_hh
1663     +
1664     +#include "globals.hh"
1665     +
1666     +#include "G4eTrajState.hh"
1667     +#include "G4eTrajParamFree.hh"
1668     +
1669     +#include "G4Point3D.hh"
1670     +#include "G4Vector3D.hh"
1671     +#include "CLHEP/Matrix/Matrix.h"
1672     +class G4eTrajStateOnSurface;
1673     +
1674     +class G4eTrajStateFree : public G4eTrajState
1675     +{
1676     +public:
1677     + G4eTrajStateFree(){ }; //- ??
1678     + G4eTrajStateFree( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4eTrajError& errmat = G4eTrajError(5,0) );
1679     + // Construct by providing particle, position and momentum
1680     + G4eTrajStateFree( const G4eTrajStateOnSurface& tpOS );
1681     + // Construct by providing G4eTrajStateOnSurface
1682     +
1683     + ~G4eTrajStateFree(){};
1684     +
1685     + virtual int Update( const G4Track* aTrack );
1686     + // Update parameters from G4Track
1687     +
1688     + virtual int PropagateError( const G4Track* aTrack );
1689     + // Propagate the error along the step
1690     +
1691     + virtual void Dump( std::ostream& out = G4cout ) const;
1692     + // Dump TrajState parameters
1693     + friend
1694     + std::ostream& operator<<(std::ostream&, const G4eTrajStateFree& ts);
1695     +
1696     + // Set and Get methods
1697     + virtual void SetPosition( const G4Point3D pos ) {
1698     + SetParameters( pos, fMomentum ); }
1699     +
1700     + virtual void SetMomentum( const G4Vector3D& mom ) {
1701     + SetParameters( fPosition, mom ); }
1702     +
1703     + void SetParameters( const G4Point3D& pos, const G4Vector3D& mom ){
1704     + fPosition = pos;
1705     + fMomentum = mom;
1706     + fTrajParam.SetParameters( pos, mom ); }
1707     +
1708     +private:
1709     + void Init();
1710     + // Define TS type and build charge
1711     +
1712     + int PropagateErrorMSC( const G4Track* aTrack );
1713     + // Add the error associated to multiple scattering
1714     +
1715     + void CalculateEffectiveZandA( const G4Material* mate, double& effZ, double& effA );
1716     + // Calculate effective Z and A (needed by PropagateErrorMSC)
1717     +
1718     + int PropagateErrorIoni( const G4Track* aTrack );
1719     + // Add the error associated to ionization energy loss
1720     +
1721     + // Set and Get methods
1722     +public:
1723     + G4eTrajParamFree GetParameters() const { return fTrajParam; }
1724     +
1725     +private:
1726     + G4eTrajParamFree fTrajParam;
1727     +
1728     + HepMatrix theTransfMat;
1729     +
1730     + bool theFirstStep; // to count if transf mat is updated or initialized
1731     +};
1732     +
1733     +#endif
1734     +
1735     diff -Naur --exclude CVS source/geant4e/include/G4eTrajState.hh source/geant4e/include/G4eTrajState.hh
1736     --- source/geant4e/include/G4eTrajState.hh 1970-01-01 01:00:00.000000000 +0100
1737     +++ source/geant4e/include/G4eTrajState.hh 2007-01-17 12:41:58.000000000 +0100
1738     @@ -0,0 +1,111 @@
1739     +//
1740     +// class G4eTrajState
1741     +//
1742     +// Class description:
1743     +//
1744     +// Base class for the trajectory state
1745     +//
1746     +
1747     +// History:
1748     +//
1749     +// --------------------------------------------------------------------
1750     +//
1751     +#ifndef G4eTrajState_h
1752     +#define G4eTrajState_h
1753     +
1754     +#include "globals.hh"
1755     +#include "G4Track.hh"
1756     +#include "G4Point3D.hh"
1757     +#include "G4Vector3D.hh"
1758     +#include "G4eTrajError.hh"
1759     +
1760     +enum G4eTSType{ G4eTS_FREE, G4eTS_OS };
1761     +
1762     +class G4eTrajState
1763     +{
1764     +public:
1765     + G4eTrajState(){ };
1766     +
1767     + G4eTrajState( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4eTrajError& errmat = G4eTrajError(5,0) );
1768     + // Construct by providing particle, position and momentum
1769     +
1770     + virtual ~G4eTrajState(){};
1771     +
1772     + void SetData( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom );
1773     + // Set particle, position and momentum
1774     +
1775     + void BuildCharge();
1776     + // Build charge based on particle type
1777     +
1778     + friend
1779     + std::ostream& operator<<(std::ostream&, const G4eTrajState& ts);
1780     +
1781     + virtual int PropagateError( const G4Track* ){
1782     + G4cout << " THIS SHOULD NOT BE CALLED PropagateError type " << int(GetTSType()) << G4endl;
1783     + return -1; };
1784     + // Propagate the error along the step
1785     +
1786     + virtual int Update( const G4Track* ){ return -1; };
1787     + // Update parameters from G4Track
1788     +
1789     + void UpdatePosMom( const G4Point3D& pos, const G4Vector3D& mom );
1790     + // Update position and momentum
1791     +
1792     + void DumpPosMomError( std::ostream& out = G4cout ) const;
1793     + // Dump position, momentum and error
1794     +
1795     + virtual void Dump( std::ostream& out = G4cout ) const = 0;
1796     + // Abstract method to dump all TrajState parameters
1797     +
1798     + // Set and Get methods
1799     + const G4String& GetParticleType() const{
1800     + return fParticleType;}
1801     +
1802     + G4Point3D GetPosition() const {
1803     + return fPosition; }
1804     +
1805     + G4Vector3D GetMomentum() const {
1806     + return fMomentum; }
1807     +
1808     + double GetCharge() const {
1809     + return fCharge; }
1810     +
1811     + G4eTrajError GetError() const {
1812     + return fError; }
1813     +
1814     + virtual G4eTSType GetTSType() const { return theTSType; }
1815     +
1816     + G4Track* GetG4Track() const{
1817     + return theG4Track; }
1818     +
1819     + void SetParticleType( const G4String& partType ){
1820     + fParticleType = partType;}
1821     +
1822     + virtual void SetPosition( const G4Point3D pos ) {
1823     + fPosition = pos; }
1824     +
1825     + virtual void SetMomentum( const G4Vector3D& mom ) {
1826     + fMomentum = mom; }
1827     +
1828     + virtual void SetError( G4eTrajError em ) {
1829     + fError = em; }
1830     +
1831     + void SetG4Track( G4Track* trk ){
1832     + theG4Track = trk; }
1833     +
1834     +protected:
1835     + G4String fParticleType;
1836     + G4Point3D fPosition;
1837     + G4Vector3D fMomentum;
1838     + double fCharge;
1839     + G4eTrajError fError;
1840     +
1841     + G4eTSType theTSType;
1842     +
1843     + G4Track* theG4Track;
1844     +
1845     + int iverbose;
1846     +};
1847     +
1848     +#endif
1849     +
1850     diff -Naur --exclude CVS source/geant4e/include/G4eTrajStateOnSurface.hh source/geant4e/include/G4eTrajStateOnSurface.hh
1851     --- source/geant4e/include/G4eTrajStateOnSurface.hh 1970-01-01 01:00:00.000000000 +0100
1852     +++ source/geant4e/include/G4eTrajStateOnSurface.hh 2007-01-17 12:41:58.000000000 +0100
1853     @@ -0,0 +1,90 @@
1854     +//
1855     +// class G4eTrajStateOnSurface
1856     +//
1857     +// Class description:
1858     +//
1859     +// Represents a trajectory state on a surface
1860     +// It can be represented by the 5 variables
1861     +// 1/p, v', w', v, w
1862     +// where v'=dv/du and w'=dw/du in an orthonormal coordinate system with
1863     +// axis u, v and w
1864     +//
1865     +// History:
1866     +//
1867     +// --------------------------------------------------------------------
1868     +//
1869     +#ifndef G4eTrajStateOnSurface_hh
1870     +#define G4eTrajStateOnSurface_hh
1871     +
1872     +#include "globals.hh"
1873     +
1874     +#include "G4eTrajState.hh"
1875     +#include "G4eTrajParamOnSurface.hh"
1876     +#include "G4eTrajStateFree.hh"
1877     +
1878     +#include "G4Point3D.hh"
1879     +#include "G4Vector3D.hh"
1880     +#include "G4Plane3D.hh"
1881     +
1882     +
1883     +class G4eTrajStateOnSurface : public G4eTrajState
1884     +{
1885     +
1886     +public:
1887     + // G4eTrajStateOnSurface(){}; //- ??
1888     +
1889     + G4eTrajStateOnSurface( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane, const G4eTrajError& errmat = G4eTrajError(5,0) );
1890     + // Construct by providing particle, position, momentum and G4Plane3D surface
1891     +
1892     + G4eTrajStateOnSurface( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecV, const G4Vector3D& vecW, const G4eTrajError& errmat = G4eTrajError(5,0) );
1893     + // Construct by providing particle, position, momentum and two vectors on surface
1894     +
1895     + G4eTrajStateOnSurface( G4eTrajStateFree& tpSC, const G4Plane3D& plane );
1896     + // Construct by providing G4eTrajStateFree and G4Plane3D surface
1897     +
1898     + G4eTrajStateOnSurface( G4eTrajStateFree& tpSC, const G4Vector3D& vecV, const G4Vector3D& vecW );
1899     + // Construct by providing G4eTrajStateFree and two vectors on surface
1900     +
1901     + void BuildErrorMatrix( G4eTrajStateFree& tpSC, const G4Vector3D& vecV, const G4Vector3D& vecW );
1902     +
1903     + ~G4eTrajStateOnSurface(){};
1904     +
1905     + virtual void Dump( std::ostream& out = G4cout ) const;
1906     + // Dump class parameters
1907     + friend
1908     + std::ostream& operator<<(std::ostream&, const G4eTrajStateOnSurface& ts);
1909     +
1910     + //--- Set and Get methods
1911     + virtual void SetPosition( const G4Point3D pos ) {
1912     + SetParameters( pos, fMomentum, GetVectorV(), GetVectorW() ); }
1913     +
1914     + virtual void SetMomentum( const G4Vector3D& mom ) {
1915     + SetParameters( fPosition, mom, GetVectorV(), GetVectorW() ); }
1916     +
1917     + void SetParameters( const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecV, const G4Vector3D& vecW ){
1918     + fPosition = pos;
1919     + fMomentum = mom;
1920     + fTrajParam.SetParameters( pos, mom, vecV, vecW ); }
1921     +
1922     + void SetParameters( const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane ){
1923     + fPosition = pos;
1924     + fMomentum = mom;
1925     + fTrajParam.SetParameters( pos, mom, plane ); }
1926     +
1927     + G4eTrajParamOnSurface GetParameters() const { return fTrajParam; }
1928     +
1929     + G4Vector3D GetVectorV() const { return fTrajParam.GetVectorV();}
1930     +
1931     + G4Vector3D GetVectorW() const { return fTrajParam.GetVectorW();}
1932     +
1933     +private:
1934     + void Init();
1935     + // Define TS type and build charge
1936     +
1937     +private:
1938     + G4eTrajParamOnSurface fTrajParam;
1939     +
1940     +};
1941     +
1942     +#endif
1943     +
1944     diff -Naur --exclude CVS source/geant4e/include/lista.txt source/geant4e/include/lista.txt
1945     --- source/geant4e/include/lista.txt 1970-01-01 01:00:00.000000000 +0100
1946     +++ source/geant4e/include/lista.txt 2007-01-17 12:41:58.000000000 +0100
1947     @@ -0,0 +1,28 @@
1948     +ExN02PhysicsList.hh
1949     +G4eEnergyLossProcess.hh
1950     +G4eIonisationChange.hh
1951     +G4eMagneticFieldLimitsMessenger.hh
1952     +G4eMagneticFieldLimitsProcess.hh
1953     +G4eMag_UsualEqRhs.hh
1954     +G4eManager.hh
1955     +G4eMuIonisation.hh
1956     +G4eNavigator.hh
1957     +G4ePhysicsList.hh
1958     +G4ePropagatorG4.hh
1959     +G4ePropagator.hh
1960     +G4eRunManagerKernel.hh
1961     +G4eSteppingManager.hh
1962     +G4eSteppingMessenger.hh
1963     +G4eTargetCylindricalSurface.hh
1964     +G4eTargetG4Volume.hh
1965     +G4eTarget.hh
1966     +G4eTargetPlaneSurface.hh
1967     +G4eTargetSurface.hh
1968     +G4eTargetTrackLength.hh
1969     +G4eTargetWithTangentPlane.hh
1970     +G4eTrajError.hh
1971     +G4eTrajParamFree.hh
1972     +G4eTrajParamOnSurface.hh
1973     +G4eTrajStateFree.hh
1974     +G4eTrajState.hh
1975     +G4eTrajStateOnSurface.hh
1976     diff -Naur --exclude CVS source/geant4e/src/ExN02PhysicsList.cc source/geant4e/src/ExN02PhysicsList.cc
1977     --- source/geant4e/src/ExN02PhysicsList.cc 1970-01-01 01:00:00.000000000 +0100
1978     +++ source/geant4e/src/ExN02PhysicsList.cc 2007-01-17 12:41:58.000000000 +0100
1979     @@ -0,0 +1,222 @@
1980     +#include "globals.hh"
1981     +#include "ExN02PhysicsList.hh"
1982     +
1983     +#include "G4ProcessManager.hh"
1984     +#include "G4ParticleTypes.hh"
1985     +#include "G4eMagneticFieldLimitsProcess.hh"
1986     +
1987     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1988     +
1989     +ExN02PhysicsList::ExN02PhysicsList(): G4VUserPhysicsList()
1990     +{
1991     +
1992     + defaultCutValue = 1.0*cm;
1993     + SetVerboseLevel(1);
1994     + // G4cout << " ExN02PhysicsList::ExN02PhysicsList() " << G4endl;
1995     +}
1996     +
1997     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1998     +
1999     +ExN02PhysicsList::~ExN02PhysicsList()
2000     +{}
2001     +
2002     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2003     +
2004     +void ExN02PhysicsList::ConstructParticle()
2005     +{
2006     + // In this method, static member functions should be called
2007     + // for all particles which you want to use.
2008     + // This ensures that objects of these particle types will be
2009     + // created in the program.
2010     +
2011     + ConstructBosons();
2012     + ConstructLeptons();
2013     + ConstructMesons();
2014     + ConstructBaryons();
2015     +}
2016     +
2017     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2018     +
2019     +void ExN02PhysicsList::ConstructBosons()
2020     +{
2021     + // pseudo-particles
2022     + G4Geantino::GeantinoDefinition();
2023     + G4ChargedGeantino::ChargedGeantinoDefinition();
2024     +
2025     + // gamma
2026     + G4Gamma::GammaDefinition();
2027     +}
2028     +
2029     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2030     +
2031     +void ExN02PhysicsList::ConstructLeptons()
2032     +{
2033     + // leptons
2034     + // e+/-
2035     + G4Electron::ElectronDefinition();
2036     + G4Positron::PositronDefinition();
2037     + // mu+/-
2038     + G4MuonPlus::MuonPlusDefinition();
2039     + G4MuonMinus::MuonMinusDefinition();
2040     + // nu_e
2041     + G4NeutrinoE::NeutrinoEDefinition();
2042     + G4AntiNeutrinoE::AntiNeutrinoEDefinition();
2043     + // nu_mu
2044     + G4NeutrinoMu::NeutrinoMuDefinition();
2045     + G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
2046     +}
2047     +
2048     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2049     +
2050     +void ExN02PhysicsList::ConstructMesons()
2051     +{
2052     + // mesons
2053     + // light mesons
2054     + G4PionPlus::PionPlusDefinition();
2055     + G4PionMinus::PionMinusDefinition();
2056     + G4PionZero::PionZeroDefinition();
2057     + G4Eta::EtaDefinition();
2058     + G4EtaPrime::EtaPrimeDefinition();
2059     + G4KaonPlus::KaonPlusDefinition();
2060     + G4KaonMinus::KaonMinusDefinition();
2061     + G4KaonZero::KaonZeroDefinition();
2062     + G4AntiKaonZero::AntiKaonZeroDefinition();
2063     + G4KaonZeroLong::KaonZeroLongDefinition();
2064     + G4KaonZeroShort::KaonZeroShortDefinition();
2065     +}
2066     +
2067     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2068     +
2069     +void ExN02PhysicsList::ConstructBaryons()
2070     +{
2071     + // barions
2072     + G4Proton::ProtonDefinition();
2073     + G4AntiProton::AntiProtonDefinition();
2074     +
2075     + G4Neutron::NeutronDefinition();
2076     + G4AntiNeutron::AntiNeutronDefinition();
2077     +}
2078     +
2079     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2080     +
2081     +void ExN02PhysicsList::ConstructProcess()
2082     +{
2083     + AddTransportation();
2084     + ConstructEM();
2085     + ConstructGeneral();
2086     +}
2087     +
2088     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2089     +
2090     +#include "G4ComptonScattering.hh"
2091     +#include "G4GammaConversion.hh"
2092     +#include "G4PhotoElectricEffect.hh"
2093     +
2094     +#include "G4MultipleScattering.hh"
2095     +
2096     +#include "G4eIonisation.hh"
2097     +#include "G4eBremsstrahlung.hh"
2098     +#include "G4eplusAnnihilation.hh"
2099     +
2100     +#include "G4MuIonisation.hh"
2101     +#include "G4MuBremsstrahlung.hh"
2102     +#include "G4MuPairProduction.hh"
2103     +
2104     +#include "G4hIonisation.hh"
2105     +
2106     +#include "G4StepLimiter.hh"
2107     +#include "G4UserSpecialCuts.hh"
2108     +
2109     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2110     +
2111     +void ExN02PhysicsList::ConstructEM()
2112     +{
2113     + theParticleIterator->reset();
2114     + while( (*theParticleIterator)() ){
2115     + G4ParticleDefinition* particle = theParticleIterator->value();
2116     + G4ProcessManager* pmanager = particle->GetProcessManager();
2117     + G4String particleName = particle->GetParticleName();
2118     +
2119     + if (particleName == "gamma") {
2120     + // gamma
2121     + pmanager->AddDiscreteProcess(new G4PhotoElectricEffect);
2122     + pmanager->AddDiscreteProcess(new G4ComptonScattering);
2123     + pmanager->AddDiscreteProcess(new G4GammaConversion);
2124     +
2125     + } else if (particleName == "e-") {
2126     + //electron
2127     + pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
2128     + pmanager->AddProcess(new G4eIonisation, -1, 2,2);
2129     + pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
2130     +
2131     + } else if (particleName == "e+") {
2132     + //positron
2133     + pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
2134     + pmanager->AddProcess(new G4eIonisation, -1, 2,2);
2135     + pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
2136     + pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
2137     +
2138     + } else if( particleName == "mu+" ||
2139     + particleName == "mu-" ) {
2140     + //muon
2141     + pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
2142     + G4VProcess* anIonisation = new G4MuIonisation();
2143     + G4eMagneticFieldLimitsProcess* theG4eMagneticFieldLimitsProcess = new G4eMagneticFieldLimitsProcess;
2144     + pmanager->AddDiscreteProcess( theG4eMagneticFieldLimitsProcess );
2145     + G4VEnergyLossProcess* io = (G4VEnergyLossProcess*)anIonisation;
2146     + io->SetLossFluctuations( FALSE );
2147     +
2148     + pmanager->AddProcess(anIonisation, -1, 2,2);
2149     + pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3,3);
2150     + pmanager->AddProcess(new G4MuPairProduction, -1, 4,4);
2151     + // pmanager->AddProcess(anIonisation, -1);
2152     + // pmanager->AddProcess(new G4MuBremsstrahlung, -1);
2153     + // pmanager->AddProcess(new G4MuPairProduction, -1);
2154     +
2155     + } else if ((!particle->IsShortLived()) &&
2156     + (particle->GetPDGCharge() != 0.0) &&
2157     + (particle->GetParticleName() != "chargedgeantino")) {
2158     + //all others charged particles except geantino
2159     + pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
2160     + pmanager->AddProcess(new G4hIonisation, -1, 2,2);
2161     + //step limit
2162     + pmanager->AddProcess(new G4StepLimiter, -1,-1,3);
2163     + ///pmanager->AddProcess(new G4UserSpecialCuts, -1,-1,4);
2164     + }
2165     + }
2166     +}
2167     +
2168     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2169     +
2170     +#include "G4Decay.hh"
2171     +void ExN02PhysicsList::ConstructGeneral()
2172     +{
2173     + // Add Decay Process
2174     + G4Decay* theDecayProcess = new G4Decay();
2175     + theParticleIterator->reset();
2176     + while( (*theParticleIterator)() ){
2177     + G4ParticleDefinition* particle = theParticleIterator->value();
2178     + G4ProcessManager* pmanager = particle->GetProcessManager();
2179     + if (theDecayProcess->IsApplicable(*particle)) {
2180     + pmanager ->AddProcess(theDecayProcess);
2181     + // set ordering for PostStepDoIt and AtRestDoIt
2182     + pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
2183     + pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
2184     + }
2185     + }
2186     +}
2187     +
2188     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2189     +
2190     +void ExN02PhysicsList::SetCuts()
2191     +{
2192     + //G4VUserPhysicsList::SetCutsWithDefault method sets
2193     + //the default cut value for all particle types
2194     + //
2195     + SetCutsWithDefault();
2196     +
2197     + if (verboseLevel>0) DumpCutValuesTable();
2198     +}
2199     +
2200     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2201     +
2202     diff -Naur --exclude CVS source/geant4e/src/G4eEnergyLossProcess.cc source/geant4e/src/G4eEnergyLossProcess.cc
2203     --- source/geant4e/src/G4eEnergyLossProcess.cc 1970-01-01 01:00:00.000000000 +0100
2204     +++ source/geant4e/src/G4eEnergyLossProcess.cc 2007-01-17 12:41:58.000000000 +0100
2205     @@ -0,0 +1,114 @@
2206     +////////////////////////////////////////////////////////////////////////
2207     +// Energy Loss for extrapolator Implementation
2208     +////////////////////////////////////////////////////////////////////////
2209     +//
2210     +// File: G4eEnergyLossProcess.cc
2211     +// Description: Continuous Process -- energy loss for extrapolator
2212     +// Version: 2.1
2213     +// Created: 2005-12-22
2214     +// Author: Pedro Arce
2215     +// Updated:
2216     +//
2217     +// mail: pedro.arce@cern.ch
2218     +//
2219     +////////////////////////////////////////////////////////////////////////
2220     +
2221     +#include "G4eEnergyLossProcess.hh"
2222     +#include "G4eManager.hh"
2223     +#include "G4EnergyLossForExtrapolator.hh"
2224     +
2225     +//--------------------------------------------------------------------------
2226     +
2227     +G4EnergyLossForExtrapolator* G4eEnergyLossProcess::theELossForExtrapolator = 0;
2228     +
2229     +//--------------------------------------------------------------------------
2230     +G4eEnergyLossProcess::G4eEnergyLossProcess(const G4String& processName)
2231     + : G4VContinuousProcess(processName)
2232     +{
2233     + if (verboseLevel>0) {
2234     + G4cout << GetProcessName() << " is created " << G4endl;
2235     + }
2236     +
2237     + G4eEnergyLossProcess::InstantiateEforExtrapolator();
2238     +
2239     +}
2240     +
2241     +
2242     +//--------------------------------------------------------------------------
2243     +void G4eEnergyLossProcess::InstantiateEforExtrapolator()
2244     +{
2245     +
2246     + if( theELossForExtrapolator == 0 ) {
2247     + theELossForExtrapolator = new G4EnergyLossForExtrapolator;
2248     + }
2249     +}
2250     +
2251     +
2252     +//--------------------------------------------------------------------------
2253     +G4eEnergyLossProcess::~G4eEnergyLossProcess()
2254     +{
2255     +}
2256     +
2257     +
2258     +//--------------------------------------------------------------------------
2259     +G4VParticleChange*
2260     +G4eEnergyLossProcess::AlongStepDoIt(const G4Track& aTrack, const G4Step& aStep)
2261     +{
2262     + aParticleChange.Initialize(aTrack);
2263     +
2264     + G4eManager* g4emgr = G4eManager::GetG4eManager();
2265     +
2266     + G4double kinEnergyStart = aTrack.GetKineticEnergy();
2267     + G4double step_length = aStep.GetStepLength();
2268     + // step_length = 10*mm;
2269     + const G4Material* aMaterial = aTrack.GetMaterial();
2270     + const G4ParticleDefinition* aParticleDef = aTrack.GetDynamicParticle()->GetDefinition();
2271     + G4double kinEnergyEnd;
2272     +
2273     + // G4cout << " mode " << g4emgr->GetMode()<< " " << G4eMode_PropForwards << std::endl;
2274     +
2275     + if( g4emgr->GetMode() == G4eMode(G4eMode_PropBackwards) ) {
2276     + kinEnergyEnd = G4eEnergyLossProcess::theELossForExtrapolator->EnergyBeforeStep( kinEnergyStart, step_length, aMaterial, aParticleDef );
2277     + G4double kinEnergyHalfStep = kinEnergyStart - (kinEnergyStart-kinEnergyEnd)/2.;
2278     + //- G4cout << " G4eEnergyLossProcess FWD end " << kinEnergyEnd << " halfstep " << kinEnergyHalfStep << G4endl;
2279     + //--- rescale to energy lost at 1/2 step
2280     + kinEnergyEnd = G4eEnergyLossProcess::theELossForExtrapolator->EnergyBeforeStep( kinEnergyHalfStep, step_length, aMaterial, aParticleDef );
2281     + kinEnergyEnd = kinEnergyStart - (kinEnergyHalfStep - kinEnergyEnd );
2282     + }else if( g4emgr->GetMode() == G4eMode(G4eMode_PropForwards) ) {
2283     + kinEnergyEnd = G4eEnergyLossProcess::theELossForExtrapolator->EnergyAfterStep( kinEnergyStart, step_length, aMaterial, aParticleDef );
2284     + G4double kinEnergyHalfStep = kinEnergyStart - (kinEnergyStart-kinEnergyEnd)/2.;
2285     + //- G4cout << " G4eEnergyLossProcess BCKD end " << kinEnergyEnd << " halfstep " << kinEnergyHalfStep << G4endl;
2286     + //--- rescale to energy lost at 1/2 step
2287     + kinEnergyEnd = G4eEnergyLossProcess::theELossForExtrapolator->EnergyAfterStep( kinEnergyHalfStep, step_length, aMaterial, aParticleDef );
2288     + kinEnergyEnd = kinEnergyStart - (kinEnergyHalfStep - kinEnergyEnd );
2289     + }
2290     +
2291     + G4double edepo = kinEnergyEnd - kinEnergyStart;
2292     +
2293     + if( G4eManager::verbose() >= 2 ) G4cout << "G4eEnergyLossProcess::AlongStepDoIt Estart= " << kinEnergyStart << " Eend " << kinEnergyEnd << " Ediff " << kinEnergyStart-kinEnergyEnd << " step= " << step_length << " mate= " << aMaterial->GetName() << " particle= " << aParticleDef->GetParticleName() << G4endl;
2294     +
2295     + aParticleChange.ClearDebugFlag();
2296     + aParticleChange.ProposeLocalEnergyDeposit( edepo );
2297     + aParticleChange.SetNumberOfSecondaries(0);
2298     +
2299     + aParticleChange.ProposeEnergy( kinEnergyEnd );
2300     +
2301     + /*?????
2302     + //---- If it has lost all its energy, it is in status StopAndAlive: change it!
2303     + if(fParticleChange->GetTrackStatus() == fStopButAlive ) {
2304     + fParticleChange->ProposeTrackStatus( fAlive );
2305     + }
2306     + */
2307     +
2308     + return &aParticleChange;
2309     +}
2310     +
2311     +
2312     +//--------------------------------------------------------------------
2313     +G4double G4eEnergyLossProcess::GetContinuousStepLimit(const G4Track&,
2314     + G4double,
2315     + G4double,
2316     + G4double& )
2317     +{
2318     + return DBL_MAX;
2319     +}
2320     diff -Naur --exclude CVS source/geant4e/src/G4eIonisationChange.cc source/geant4e/src/G4eIonisationChange.cc
2321     --- source/geant4e/src/G4eIonisationChange.cc 1970-01-01 01:00:00.000000000 +0100
2322     +++ source/geant4e/src/G4eIonisationChange.cc 2007-01-17 12:41:58.000000000 +0100
2323     @@ -0,0 +1,64 @@
2324     +//
2325     +// --------------------------------------------------------------
2326     +// GEANT 4 class implementation file
2327     +//
2328     +// History: September 2001, P. Arce
2329     +// --------------------------------------------------------------
2330     +
2331     +#include "G4eIonisationChange.hh"
2332     +
2333     +#include "G4Track.hh"
2334     +#include "G4ParticleChangeForLoss.hh"
2335     +
2336     +#include "G4eManager.hh"
2337     +
2338     +// constructor and destructor
2339     + G4eIonisationChange::G4eIonisationChange(const G4String& )
2340     +{ }
2341     +
2342     +G4eIonisationChange::~G4eIonisationChange()
2343     +{ }
2344     +
2345     +
2346     +void G4eIonisationChange::RecomputeParticleChange( G4ParticleChangeForLoss* fParticleChange, const G4Track& trackData )
2347     +{
2348     +
2349     + //----- Reset number of secondaries to 0
2350     + // fParticleChange->Clear();
2351     +
2352     + //----- If propagation is backwards:
2353     + G4eManager* g4emgr = G4eManager::GetG4eManager();
2354     + if( g4emgr->GetMode() == G4eMode(G4eMode_PropBackwards) ) {
2355     +#ifdef G4EVERBOSE
2356     + if( g4emgr->verbose() >= 1) {
2357     + G4cout << "G4eIonisationChange::RecomputeParticleChange: backwards. fParticleChange->GetProposedKineticEnergy() " << fParticleChange->GetProposedKineticEnergy() << G4endl;
2358     + }
2359     +#endif
2360     + //---- Reset energy deposited to negative value (gaining energy)
2361     + // double eDepoOld = trackData.GetStep()->GetTotalEnergyDeposit();
2362     + double eDepo = fParticleChange->GetLocalEnergyDeposit();
2363     + fParticleChange->ProposeLocalEnergyDeposit( -eDepo );
2364     + //---- Reset energy change to negative value (gaining energy)
2365     + double energyNew = fParticleChange->GetProposedKineticEnergy();
2366     + double mass = trackData.GetDynamicParticle()->GetDefinition()->GetPDGMass();
2367     + double energyOld = trackData.GetDynamicParticle()->GetTotalEnergy()-mass;
2368     + //energyChange is =0
2369     + fParticleChange->SetProposedKineticEnergy( energyNew - 2*(energyNew-energyOld) );
2370     +
2371     + //---- If it has lost all its energy, it is in status StopAndAlive: change it!
2372     + if(fParticleChange->GetTrackStatus() == fStopButAlive ) {
2373     + fParticleChange->ProposeTrackStatus( fAlive );
2374     + }
2375     +
2376     +#ifdef G4EVERBOSE
2377     + if( g4emgr->verbose() >= 4) {
2378     + if( trackData.GetStep() != 0 ) G4cout << "G4eIonisationChange::RecomputeParticleChange energyDeposited new " << eDepo << " old " << trackData.GetStep()->GetTotalEnergyDeposit() << G4endl;
2379     + G4cout << " G4eIonisationChange::RecomputeParticleChangeForIoniPost energyChange new " << energyNew << " old " << energyOld << G4endl;
2380     + }
2381     +#endif
2382     + }
2383     +
2384     + return;
2385     +
2386     +}
2387     +
2388     diff -Naur --exclude CVS source/geant4e/src/G4eMagneticFieldLimitsMessenger.cc source/geant4e/src/G4eMagneticFieldLimitsMessenger.cc
2389     --- source/geant4e/src/G4eMagneticFieldLimitsMessenger.cc 1970-01-01 01:00:00.000000000 +0100
2390     +++ source/geant4e/src/G4eMagneticFieldLimitsMessenger.cc 2007-01-17 12:41:58.000000000 +0100
2391     @@ -0,0 +1,43 @@
2392     +
2393     +#include "G4eMagneticFieldLimitsMessenger.hh"
2394     +#include "G4eMagneticFieldLimitsProcess.hh"
2395     +
2396     +#include "G4UIdirectory.hh"
2397     +#include "G4UIcmdWithADoubleAndUnit.hh"
2398     +#include "globals.hh"
2399     +
2400     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2401     +
2402     +G4eMagneticFieldLimitsMessenger::G4eMagneticFieldLimitsMessenger(G4eMagneticFieldLimitsProcess* myAct)
2403     +:myAction(myAct)
2404     +{
2405     +
2406     + myDir = new G4UIdirectory("/geant4e/");
2407     + myDir->SetGuidance("GEANT4e control commands");
2408     +
2409     + StepLimitCmd = new G4UIcmdWithADoubleAndUnit("/geant4e/stepLimit",this);
2410     + StepLimitCmd->SetGuidance("Limit the length of an step");
2411     + StepLimitCmd->SetDefaultUnit("mm");
2412     + //- StepLimitCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
2413     + // G4cout << " G4eMagneticFieldLimitsMessenger::G4eMagneticFieldLimitsMessenger " << G4endl;
2414     +}
2415     +
2416     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2417     +
2418     +G4eMagneticFieldLimitsMessenger::~G4eMagneticFieldLimitsMessenger()
2419     +{
2420     + delete StepLimitCmd;
2421     + delete myDir;
2422     +}
2423     +
2424     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2425     +
2426     +void G4eMagneticFieldLimitsMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
2427     +{
2428     + if( command == StepLimitCmd ) {
2429     + // G4cout << " G4eMagneticFieldLimitsMessenger::SetNewValue " << newValue << G4endl;
2430     + myAction->SetStepLimit(StepLimitCmd->GetNewDoubleValue(newValue));}
2431     +
2432     +}
2433     +
2434     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2435     diff -Naur --exclude CVS source/geant4e/src/G4eMagneticFieldLimitsProcess.cc source/geant4e/src/G4eMagneticFieldLimitsProcess.cc
2436     --- source/geant4e/src/G4eMagneticFieldLimitsProcess.cc 1970-01-01 01:00:00.000000000 +0100
2437     +++ source/geant4e/src/G4eMagneticFieldLimitsProcess.cc 2007-01-17 12:41:58.000000000 +0100
2438     @@ -0,0 +1,48 @@
2439     +#include "G4eMagneticFieldLimitsProcess.hh"
2440     +#include "G4UnitsTable.hh"
2441     +#include "G4eMagneticFieldLimitsMessenger.hh"
2442     +
2443     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2444     +G4eMagneticFieldLimitsProcess::G4eMagneticFieldLimitsProcess(const G4String& processName)
2445     + : G4VDiscreteProcess (processName)
2446     +{
2447     + theMessenger = new G4eMagneticFieldLimitsMessenger(this);
2448     + theStepLimit = 1000.*mm;// kInfinity;
2449     +}
2450     +
2451     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2452     +G4eMagneticFieldLimitsProcess::~G4eMagneticFieldLimitsProcess()
2453     +{ }
2454     +
2455     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2456     +
2457     +
2458     +G4double G4eMagneticFieldLimitsProcess::PostStepGetPhysicalInteractionLength(
2459     + //G4double G4eMagneticFieldLimitsProcess::PostStepGPIL(
2460     + const G4Track& ,
2461     + G4double ,
2462     + G4ForceCondition* condition )
2463     +{
2464     + *condition = NotForced;
2465     + //- G4cout << "G4eMagneticFieldLimitsProcess::PostStepGetPhysicalInteractionLength " << theStepLimit << G4endl;
2466     + return theStepLimit;
2467     + //return kInfinity;
2468     +}
2469     +
2470     +G4double G4eMagneticFieldLimitsProcess::GetMeanFreePath(const class G4Track &, G4double, enum G4ForceCondition *)
2471     +{
2472     + //- G4cout << "G4eMagneticFieldLimitsProcess GetMeanFreePath " << theStepLimit << G4endl;
2473     + return theStepLimit;
2474     +}
2475     +
2476     +G4VParticleChange* G4eMagneticFieldLimitsProcess::PostStepDoIt(
2477     + const G4Track& aTrack ,
2478     + const G4Step& )
2479     +{
2480     + G4ParticleChange* aParticleChange = new G4ParticleChange;
2481     + aParticleChange->Initialize(aTrack);
2482     + return aParticleChange;
2483     +
2484     +}
2485     +
2486     +
2487     diff -Naur --exclude CVS source/geant4e/src/G4eMag_UsualEqRhs.cc source/geant4e/src/G4eMag_UsualEqRhs.cc
2488     --- source/geant4e/src/G4eMag_UsualEqRhs.cc 1970-01-01 01:00:00.000000000 +0100
2489     +++ source/geant4e/src/G4eMag_UsualEqRhs.cc 2007-01-17 12:41:58.000000000 +0100
2490     @@ -0,0 +1,32 @@
2491     +//
2492     +#include "G4eMag_UsualEqRhs.hh"
2493     +#include "G4eManager.hh"
2494     +
2495     +
2496     +void
2497     +G4eMag_UsualEqRhs::EvaluateRhsGivenB( const G4double y[],
2498     + const G4double B[3],
2499     + G4double dydx[] ) const
2500     +{
2501     +
2502     + G4Mag_UsualEqRhs::EvaluateRhsGivenB(y, B, dydx );
2503     +
2504     + if(G4eManager::GetG4eManager()->GetMode() == G4eMode_PropBackwards){
2505     + G4double momentum_mag_square = sqr(y[3]) + sqr(y[4]) + sqr(y[5]);
2506     + G4double inv_momentum_magnitude = 1.0 / sqrt( momentum_mag_square );
2507     +
2508     + G4double cof = FCof()*inv_momentum_magnitude;
2509     +
2510     + dydx[3] = cof*(y[4]*(-B[2]) - y[5]*(-B[1])) ;
2511     + dydx[4] = cof*(y[5]*(-B[0]) - y[3]*(-B[2])) ;
2512     + dydx[5] = cof*(y[3]*(-B[1]) - y[4]*(-B[0])) ;
2513     +
2514     + }
2515     +
2516     + return ;
2517     +}
2518     +
2519     +
2520     +
2521     +
2522     +
2523     diff -Naur --exclude CVS source/geant4e/src/G4eManager.cc source/geant4e/src/G4eManager.cc
2524     --- source/geant4e/src/G4eManager.cc 1970-01-01 01:00:00.000000000 +0100
2525     +++ source/geant4e/src/G4eManager.cc 2007-01-17 12:41:58.000000000 +0100
2526     @@ -0,0 +1,416 @@
2527     +
2528     +#define private public
2529     +#include "G4MagIntegratorStepper.hh"
2530     +#define private private
2531     +#include "G4Mag_UsualEqRhs.hh"
2532     +#include "G4Mag_EqRhs.hh"
2533     +#include "G4MagIntegratorDriver.hh"
2534     +
2535     +#include "G4ClassicalRK4.hh"
2536     +#include "G4ExactHelixStepper.hh"
2537     +#include "G4HelixExplicitEuler.hh"
2538     +
2539     +#include "G4eManager.hh"
2540     +
2541     +#include "G4EventManager.hh"
2542     +#include "G4eRunManagerKernel.hh"
2543     +#include "G4ePropagatorG4.hh"
2544     +#include "G4eTrajStateFree.hh"
2545     +#include "G4eTrajStateOnSurface.hh"
2546     +#include "G4eMag_UsualEqRhs.hh"
2547     +
2548     +#include "G4VParticleChange.hh"
2549     +#include "G4ParticleChangeForMSC.hh"
2550     +#include "G4ParticleChange.hh"
2551     +#include "G4Track.hh"
2552     +#include "G4TransportationManager.hh"
2553     +#include "G4eNavigator.hh"
2554     +#include "G4GeometryManager.hh"
2555     +#include "G4StateManager.hh"
2556     +#include "G4ChordFinder.hh"
2557     +#include "G4EquationOfMotion.hh"
2558     +#include "G4FieldManager.hh"
2559     +#include "G4VParticleChange.hh"
2560     +
2561     +G4eManager* G4eManager::theG4eManager = 0;
2562     +
2563     +int G4eManager::theVerbosity;
2564     +
2565     +//-----------------------------------------------------------------------
2566     +G4eManager* G4eManager::GetG4eManager()
2567     +{
2568     + if( theG4eManager == NULL ) {
2569     + theG4eManager = new G4eManager;
2570     + }
2571     +
2572     + return theG4eManager;
2573     +}
2574     +
2575     +
2576     +//-----------------------------------------------------------------------
2577     +G4eManager::G4eManager()
2578     +{
2579     + //----- Initialize a few things
2580     + //o theG4eManager = this;
2581     +
2582     + char* g4emverb = getenv("G4EVERBOSE");
2583     + if( !g4emverb ) {
2584     + theVerbosity = 0;
2585     + } else {
2586     + theVerbosity = atoi( g4emverb );
2587     + }
2588     +
2589     + thePropagator = 0;
2590     +
2591     + theEquationOfMotion = 0;
2592     +
2593     + theCurrentTS_FREE = 0;
2594     +
2595     + StartG4eRunManagerKernel();
2596     +
2597     + theState = G4eState_PreInit;
2598     +
2599     + theG4eNavigator = 0;
2600     +
2601     + StartNavigator(); //navigator has to be initialized at the beggining !?!?!
2602     +
2603     +
2604     +}
2605     +
2606     +//-----------------------------------------------------------------------
2607     +G4eManager::~G4eManager()
2608     +{
2609     +}
2610     +
2611     +
2612     +//-----------------------------------------------------------------------
2613     +void G4eManager::StartG4eRunManagerKernel()
2614     +{
2615     + //----- Initialize G4eRunManagerKernel
2616     + theG4eRunManagerKernel = G4eRunManagerKernel::GetRunManagerKernel();
2617     +
2618     + if( theG4eRunManagerKernel == 0 ) {
2619     + theG4eRunManagerKernel = new G4eRunManagerKernel();
2620     + }
2621     +
2622     + //----- User Initialization classes
2623     + //--- GEANT4e PhysicsList
2624     + if( theVerbosity >= 4 ) G4cout << " G4eManager::StartG4eRunManager() done " << theG4eRunManagerKernel << G4endl;
2625     + //- theG4eRunManager->SetUserInitialization(new G4ePhysicsList);
2626     +
2627     +}
2628     +
2629     +
2630     +//-----------------------------------------------------------------------
2631     +void G4eManager::StartNavigator()
2632     +{
2633     + if( theG4eNavigator == 0 ) {
2634     + G4TransportationManager*transportationManager = G4TransportationManager::GetTransportationManager();
2635     +
2636     + G4Navigator* g4navi = transportationManager->GetNavigatorForTracking();
2637     +
2638     + G4VPhysicalVolume* world = g4navi->GetWorldVolume();
2639     + int verb = g4navi->GetVerboseLevel();
2640     + delete g4navi;
2641     +
2642     + theG4eNavigator = new G4eNavigator();
2643     +
2644     + if( world != 0 ) {
2645     + theG4eNavigator->SetWorldVolume( world );
2646     + }
2647     + theG4eNavigator->SetVerboseLevel( verb );
2648     +
2649     + transportationManager->SetNavigatorForTracking(theG4eNavigator);
2650     + // G4ThreeVector center(0,0,0);
2651     + // theG4eNavigator->LocateGlobalPointAndSetup(center,0,false);
2652     +
2653     + }
2654     +
2655     + if( theVerbosity >= 2 ) G4cout << " theState at StartNavigator " << PrintG4eState() << G4endl;
2656     +
2657     +}
2658     +
2659     +
2660     +//-----------------------------------------------------------------------
2661     +void G4eManager::InitGeant4e()
2662     +{
2663     + if( theVerbosity >= 1 ) G4cout << "InitGeant4e GEANT4e State= " << PrintG4eState() << " GEANT4 State= " << PrintG4State() << G4endl;
2664     + G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
2665     + //----- Initialize run
2666     + // if( G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit) {
2667     + if( theState == G4eState_PreInit && (currentState == G4State_PreInit || currentState == G4State_Idle)) {
2668     + // G4eRunManager::GetRunManager()->Initialize();
2669     + theG4eRunManagerKernel->InitializeGeometry();
2670     + theG4eRunManagerKernel->InitializePhysics();
2671     +
2672     + InitFieldForBackwards();
2673     +
2674     + //- G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
2675     +
2676     + if( theVerbosity >= 4 ) G4cout << " bef theG4eManager->RunInitialization() " << G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
2677     + theG4eRunManagerKernel->RunInitialization();
2678     + if( theVerbosity >= 4 ) G4cout << " aft theG4eManager->RunInitialization() " << G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
2679     +
2680     + if( !thePropagator ) thePropagator = new G4ePropagatorG4(); // currently the only propagator possible
2681     +
2682     + InitTrackPropagation();
2683     + } else {
2684     + G4cerr << "G4eManager::InitGeant4e: Illegal application state - "
2685     + << "G4eManager::InitGeant4e() ignored." << G4endl;
2686     + G4cerr << " GEANT4e State= " << PrintG4eState() << " GEANT4 State= " << PrintG4State() << G4endl;
2687     + }
2688     +
2689     + //----- Set the tracking geometry for this propagation
2690     + //t SetTrackingGeometry();
2691     + //----- Set the physics list for this propagation
2692     + //t SetPhysicsList();
2693     + //----- Set the field propagation parameters for this propagation
2694     + //t SetFieldPropagationParameters();
2695     + if( theVerbosity >= 2 ) G4cout << "End InitGeant4e GEANT4e State= " << PrintG4eState() << " GEANT4 State= " << PrintG4State() << G4endl;
2696     +
2697     +}
2698     +
2699     +
2700     +//-----------------------------------------------------------------------
2701     +void G4eManager::InitTrackPropagation()
2702     +{
2703     + thePropagator->SetStepN( 0 );
2704     +
2705     + SetState( G4eState_Propagating );
2706     +
2707     +}
2708     +
2709     +//-----------------------------------------------------------------------
2710     +bool G4eManager::InitFieldForBackwards()
2711     +{
2712     +
2713     + if( theVerbosity >= 4 ) G4cout << " G4eManager::InitFieldForBackwards() " << G4endl;
2714     + //----- Gets the current equation of motion
2715     + G4FieldManager* fieldMgr= G4TransportationManager::GetTransportationManager()->GetFieldManager();
2716     + // G4cout << " fieldMgr " << fieldMgr << G4endl;
2717     + if( !fieldMgr ) return 0;
2718     +
2719     + // G4Field* myfield = fieldMgr->GetDetectorField();
2720     + G4ChordFinder* cf = fieldMgr ->GetChordFinder();
2721     + if( !cf ) return 0;
2722     + G4MagInt_Driver* mid = cf->GetIntegrationDriver();
2723     + if( !mid ) return 0;
2724     + G4MagIntegratorStepper* stepper = const_cast<G4MagIntegratorStepper*>(mid->GetStepper());
2725     + if( !stepper ) return 0;
2726     + G4EquationOfMotion* equation = stepper->GetEquationOfMotion();
2727     +
2728     + //----- Replaces the equation by a G4eMag_UsualEqRhs to handle backwards tracking
2729     + if ( !dynamic_cast<G4eMag_UsualEqRhs*>(equation) ) {
2730     +
2731     + G4MagneticField* myfield = (G4MagneticField*)fieldMgr->GetDetectorField();
2732     +
2733     + // G4Mag_UsualEqRhs* fEquation_usual = dynamic_cast<G4Mag_UsualEqRhs*>(equation);
2734     + if( theEquationOfMotion == 0 ) theEquationOfMotion = new G4eMag_UsualEqRhs(myfield);
2735     +
2736     + //---- Pass the equation of motion to the G4MagIntegratorStepper
2737     +// stepper->SetEquationOfMotion( theEquationOfMotion );
2738     + stepper->fEquation_Rhs = theEquationOfMotion;
2739     +
2740     +
2741     + //--- change stepper for speed tests
2742     + /*
2743     + G4MagIntegratorStepper* g4eStepper = new G4ClassicalRK4(theEquationOfMotion);
2744     + //G4MagIntegratorStepper* g4eStepper = new G4ExactHelixStepper(theEquationOfMotion);
2745     +
2746     + //----
2747     + G4MagneticField* field = static_cast<G4MagneticField*>(const_cast<G4Field*>(fieldMgr->GetDetectorField()));
2748     + G4ChordFinder* pChordFinder = new G4ChordFinder(field, 1.0e-2*mm, g4eStepper);
2749     +
2750     + fieldMgr->SetChordFinder(pChordFinder);
2751     + */
2752     +
2753     + }
2754     +
2755     + return 1;
2756     +}
2757     +
2758     +
2759     +//-----------------------------------------------------------------------
2760     +int G4eManager::Propagate( G4eTrajState* currentTS, const G4eTarget* target, G4eMode mode )
2761     +{
2762     + thePropagationMode = mode;
2763     + if( !thePropagator ) thePropagator = new G4ePropagatorG4(); // currently the only propagator possible
2764     +
2765     + return thePropagator->Propagate( currentTS, target, mode );
2766     +}
2767     +
2768     +
2769     +//-----------------------------------------------------------------------
2770     +int G4eManager::PropagateOneStep( G4eTrajState* currentTS, G4eMode mode )
2771     +{
2772     + thePropagationMode = mode;
2773     +
2774     + if( !thePropagator ) thePropagator = new G4ePropagatorG4(); // currently the only propagator possible
2775     +
2776     + return thePropagator->PropagateOneStep( currentTS );
2777     +}
2778     +
2779     +//---------------------------------------------------------------------------
2780     +void G4eManager::InvokePreUserTrackingAction( G4Track* fpTrack )
2781     +{
2782     + const G4UserTrackingAction* fpUserTrackingAction = G4EventManager::GetEventManager()->GetUserTrackingAction();
2783     + if( fpUserTrackingAction != NULL ) {
2784     + const_cast<G4UserTrackingAction*>(fpUserTrackingAction)->PreUserTrackingAction((fpTrack) );
2785     + }
2786     +
2787     +}
2788     +
2789     +
2790     +//---------------------------------------------------------------------------
2791     +void G4eManager::InvokePostUserTrackingAction( G4Track* fpTrack )
2792     +{
2793     + const G4UserTrackingAction* fpUserTrackingAction = G4EventManager::GetEventManager()->GetUserTrackingAction();
2794     + if( fpUserTrackingAction != NULL ) {
2795     + const_cast<G4UserTrackingAction*>(fpUserTrackingAction)->PostUserTrackingAction((fpTrack) );
2796     + }
2797     +
2798     +}
2799     +
2800     +
2801     +//-----------------------------------------------------------------------
2802     +bool G4eManager::CloseGeometry()
2803     +{
2804     + G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
2805     + geomManager->OpenGeometry();
2806     + if( G4StateManager::GetStateManager()->GetCurrentState() != G4State_GeomClosed) {
2807     + G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
2808     + }
2809     +
2810     + return TRUE;
2811     +}
2812     +
2813     +
2814     +//---------------------------------------------------------------------------
2815     +void G4eManager::SetUserInitialization(G4VUserDetectorConstruction* userInit)
2816     +{
2817     + theG4eRunManagerKernel->SetUserInitialization( userInit);
2818     +}
2819     +
2820     +
2821     +//---------------------------------------------------------------------------
2822     +void G4eManager::SetUserInitialization(G4VPhysicalVolume* userInit)
2823     +{
2824     + theG4eRunManagerKernel->SetUserInitialization( userInit);
2825     +}
2826     +
2827     +
2828     +//---------------------------------------------------------------------------
2829     +void G4eManager::SetUserInitialization(G4VUserPhysicsList* userInit)
2830     +{
2831     + theG4eRunManagerKernel->SetUserInitialization( userInit);
2832     +}
2833     +
2834     +
2835     +//---------------------------------------------------------------------------
2836     +void G4eManager::SetUserAction(G4UserTrackingAction* userAction)
2837     +{
2838     + G4EventManager::GetEventManager()->SetUserAction( userAction );
2839     +}
2840     +
2841     +
2842     +//---------------------------------------------------------------------------
2843     +void G4eManager::SetUserAction(G4UserSteppingAction* userAction)
2844     +{
2845     + G4EventManager::GetEventManager()->SetUserAction( userAction );
2846     +}
2847     +
2848     +
2849     +//---------------------------------------------------------------------------
2850     +void G4eManager::SetSteppingManagerVerboseLevel()
2851     +{
2852     + G4TrackingManager* trkmgr = G4EventManager::GetEventManager()->GetTrackingManager();
2853     + trkmgr->GetSteppingManager()->SetVerboseLevel( trkmgr->GetVerboseLevel() );
2854     +}
2855     +
2856     +
2857     +//---------------------------------------------------------------------------
2858     +void G4eManager::EventTermination()
2859     +{
2860     + SetState( G4eState_Init );
2861     +}
2862     +
2863     +
2864     +//---------------------------------------------------------------------------
2865     +void G4eManager::RunTermination()
2866     +{
2867     + SetState( G4eState_PreInit );
2868     + theG4eRunManagerKernel->RunTermination();
2869     +}
2870     +
2871     +
2872     +//---------------------------------------------------------------------------
2873     +G4String G4eManager::PrintG4eState()
2874     +{
2875     + return PrintG4eState( theState );
2876     +}
2877     +
2878     +
2879     +//---------------------------------------------------------------------------
2880     +G4String G4eManager::PrintG4eState( G4eState state )
2881     +{
2882     + G4String nam = "";
2883     + switch (state){
2884     + case G4eState_PreInit:
2885     + nam = "G4eState_PreInit";
2886     + break;
2887     + case G4eState_Init:
2888     + nam = "G4eState_Init";
2889     + break;
2890     + case G4eState_Propagating:
2891     + nam = "G4eState_Propagating";
2892     + break;
2893     + case G4eState_TargetCloserThanBoundary:
2894     + nam = "G4eState_TargetCloserThanBoundary";
2895     + break;
2896     + case G4eState_StoppedAtTarget:
2897     + nam = "G4eState_StoppedAtTarget";
2898     + break;
2899     + }
2900     +
2901     + return nam;
2902     +}
2903     +
2904     +
2905     +//---------------------------------------------------------------------------
2906     +G4String G4eManager::PrintG4State()
2907     +{
2908     + return PrintG4State(G4StateManager::GetStateManager()->GetCurrentState());
2909     +}
2910     +
2911     +
2912     +//---------------------------------------------------------------------------
2913     +G4String G4eManager::PrintG4State( G4ApplicationState state )
2914     +{
2915     + G4String nam = "";
2916     + switch ( state ){
2917     + case G4State_PreInit:
2918     + nam = "G4State_PreInit";
2919     + break;
2920     + case G4State_Init:
2921     + nam = "G4State_Init";
2922     + break;
2923     + case G4State_Idle:
2924     + nam = "G4State_Idle";
2925     + break;
2926     + case G4State_GeomClosed:
2927     + nam = "G4State_GeomClosed";
2928     + break;
2929     + case G4State_EventProc:
2930     + nam = "G4State_EventProc";
2931     + break;
2932     + case G4State_Quit:
2933     + nam = "G4State_Quit";
2934     + break;
2935     + case G4State_Abort:
2936     + nam = "G4State_Abort";
2937     + break;
2938     + }
2939     +
2940     + return nam;
2941     +
2942     +}
2943     diff -Naur --exclude CVS source/geant4e/src/G4eMuIonisation.cc source/geant4e/src/G4eMuIonisation.cc
2944     --- source/geant4e/src/G4eMuIonisation.cc 1970-01-01 01:00:00.000000000 +0100
2945     +++ source/geant4e/src/G4eMuIonisation.cc 2007-01-17 12:41:58.000000000 +0100
2946     @@ -0,0 +1,170 @@
2947     +
2948     +#define private public
2949     +#include "G4VEnergyLossProcess.hh"
2950     +#define private private
2951     +#include "G4eMuIonisation.hh"
2952     +#include "G4VMuEnergyLoss.hh"
2953     +#include "G4eIonisationChange.hh"
2954     +#include "G4ios.hh"
2955     +#include "G4Track.hh"
2956     +#include "G4Step.hh"
2957     +#include "G4VParticleChange.hh"
2958     +#include "G4ParticleChange.hh"
2959     +
2960     +#include "G4eManager.hh"
2961     +
2962     +G4eMuIonisation::G4eMuIonisation(const G4String& name)
2963     + : G4MuIonisation(name)
2964     +{
2965     +}
2966     +
2967     +G4eMuIonisation::~G4eMuIonisation(){}
2968     +
2969     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
2970     +/*inline std::vector<G4Track*>* G4eMuIonisation::SecondariesAlongStep(
2971     + const G4Step& ,
2972     + G4double& ,
2973     + G4double& ,
2974     + G4double& )
2975     +{
2976     + std::vector<G4Track*>* neqwp = 0;
2977     +
2978     + return newp;
2979     +}*/
2980     +
2981     +
2982     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
2983     +G4VParticleChange* G4eMuIonisation::AlongStepDoIt( const G4Track& trackData,
2984     + const G4Step& stepData)
2985     +{
2986     +
2987     + G4double energyStart = trackData.GetKineticEnergy();
2988     +
2989     + // G4VParticleChange* fParticleChange = G4VEnergyLossProcessAlongStepDoIt( trackData, stepData );
2990     + G4VParticleChange* fParticleChange = G4MuIonisation::AlongStepDoIt( trackData, stepData );
2991     + G4ParticleChangeForLoss* fParticleChangen = static_cast<G4ParticleChangeForLoss*>(fParticleChange);
2992     +
2993     + RecomputeParticleChange( fParticleChangen, trackData );
2994     +
2995     + // return fParticleChangen;
2996     +
2997     + //-------------------------------------
2998     + //--- rescale to energy lost at 1/2 step
2999     +
3000     + G4double energyEnd = fParticleChangen->GetProposedKineticEnergy();
3001     + // G4cout << " G4eMuIonisation::AlongStepDoIt( energyStart " << energyStart << " energyEnd " << energyEnd << " diff " << energyEnd-energyStart << G4endl;
3002     +
3003     + G4double energyHalfStep = energyStart - (energyStart-energyEnd)/2.;
3004     + G4Track trknew = trackData;
3005     + trknew.SetKineticEnergy(energyHalfStep);
3006     +
3007     + preStepKinEnergy = energyHalfStep;
3008     + preStepScaledEnergy = preStepKinEnergy*massRatio;
3009     +
3010     + // G4cout << " G4eMuIonisation::AlongStepDoIt( preStepKinEnergy set " << preStepKinEnergy << " -trknew.GetKineticEnergy() " << preStepKinEnergy-trknew.GetKineticEnergy() << G4endl;
3011     +
3012     + fParticleChange = G4MuIonisation::AlongStepDoIt( trknew, stepData );
3013     +
3014     + fParticleChangen = static_cast<G4ParticleChangeForLoss*>(fParticleChange);
3015     + RecomputeParticleChange( fParticleChangen, trknew );
3016     +
3017     + // G4cout << " G4eMuIonisation::AlongStepDoIt( energyEnd new " << fParticleChangen->GetProposedKineticEnergy() << " diff " << trknew.GetKineticEnergy() - fParticleChangen->GetProposedKineticEnergy() << G4endl;
3018     +
3019     + //recover the 1/2 energy substracted above
3020     + fParticleChangen->SetProposedKineticEnergy( fParticleChangen->GetProposedKineticEnergy() + (energyStart-energyEnd)/2. );
3021     +
3022     + //t preStepKinEnergy = oldPreStepKinEnergy;
3023     +
3024     + //- delete condition;
3025     +
3026     + return fParticleChangen;
3027     +
3028     +}
3029     +
3030     +
3031     +/*
3032     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
3033     +G4double G4eMuIonisation::AlongStepGetPhysicalInteractionLength(
3034     + const G4Track& track,
3035     + G4double previousStepSize,
3036     + G4double currentMinimumStep,
3037     + G4double& currentSafety,
3038     + G4GPILSelection* selection)
3039     +{
3040     +
3041     + // G4VContinuousDiscreteProcess::AlongStepGetPhysicalInteractionLength(
3042     +
3043     + G4MuIonisation::AlongStepGetPhysicalInteractionLength(
3044     + track, previousStepSize, currentMinimumStep, currentSafety, selection );
3045     +
3046     + return DBL_MAX;
3047     +}
3048     +
3049     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
3050     +G4double G4eMuIonisation::PostStepGetPhysicalInteractionLength(
3051     + const G4Track& track,
3052     + G4double previousStepSize,
3053     + G4ForceCondition* condition )
3054     +{
3055     +
3056     + G4VContinuousDiscreteProcess::PostStepGetPhysicalInteractionLength(
3057     + track, previousStepSize, condition );
3058     +
3059     + *condition = Forced;
3060     + return DBL_MAX;
3061     +}
3062     +*/
3063     +
3064     +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
3065     +inline std::vector<G4DynamicParticle*>* G4eMuIonisation::SecondariesPostStep(
3066     + G4VEmModel*,
3067     + const G4MaterialCutsCouple*,
3068     + const G4DynamicParticle*,
3069     + G4double&)
3070     +{
3071     + std::vector<G4DynamicParticle*>* empty = 0;
3072     + return empty;
3073     +}
3074     +
3075     +/*
3076     + G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
3077     + G4double DEDX2;
3078     + if( stepLengthCm < 1.E-7 ) {
3079     + DEDX2=0.;
3080     + }
3081     + // * Calculate xi factor (KeV).
3082     + G4Material* mate = aTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
3083     + G4double effZ, effA;
3084     + CalculateEffectiveZandA( mate, effZ, effA );
3085     +
3086     + G4double Etot = aTrack->GetTotalEnergy()/GeV;
3087     + G4double beta = aTrack->GetMomentum().mag()/GeV / Etot;
3088     + G4double mass = aTrack->GetDynamicParticle()->GetMass() / GeV;
3089     + G4double gamma = Etot / mass;
3090     +
3091     + // * Calculate xi factor (KeV).
3092     + G4double XI = 153.5*effZ*stepLengthCm*(mate->GetDensity()/mg*mole) /
3093     + (effA*beta*beta);
3094     +
3095     +#ifdef G4EVERBOSE
3096     + if( iverbose >= 2 ){
3097     + std::cout << "G4EP:IONI: XI " << XI << " beta " << beta << " gamma " << gamma << std::endl;
3098     + std::cout << " density " << (mate->GetDensity()/mg*mole) << " effA " << effA << " step " << stepLengthCm << std::endl;
3099     + }
3100     +#endif
3101     + // * Maximum energy transfer to atomic electron (KeV).
3102     + G4double eta = beta*gamma;
3103     + G4double etasq = eta*eta;
3104     + G4double eMass = 0.51099906/GeV;
3105     + G4double massRatio = eMass / mass;
3106     + G4double F1 = 2*eMass*etasq;
3107     + G4double F2 = 1. + 2. * massRatio * gamma + massRatio * massRatio;
3108     + G4double Emax = 1.E+6*F1/F2;
3109     +
3110     + // * *** and now sigma**2 in GeV
3111     + G4double dedxSq = XI*Emax*(1.-(beta*beta/2.))*1.E-12;
3112     +
3113     +}
3114     +
3115     +
3116     +*/
3117     diff -Naur --exclude CVS source/geant4e/src/G4eNavigator.cc source/geant4e/src/G4eNavigator.cc
3118     --- source/geant4e/src/G4eNavigator.cc 1970-01-01 01:00:00.000000000 +0100
3119     +++ source/geant4e/src/G4eNavigator.cc 2007-01-17 12:41:58.000000000 +0100
3120     @@ -0,0 +1,113 @@
3121     +//
3122     +#include "G4eNavigator.hh"
3123     +#include "G4Navigator.hh"
3124     +#include "globals.hh"
3125     +
3126     +#include "G4eManager.hh"
3127     +#include "G4eTargetSurface.hh"
3128     +
3129     +#include "G4ThreeVector.hh"
3130     +
3131     +#define geant4e
3132     +
3133     +G4eNavigator::G4eNavigator():G4Navigator()
3134     +{
3135     + G4cout << "creating G4eNavigator" << G4endl;}
3136     +
3137     +G4eNavigator::~G4eNavigator()
3138     +{
3139     +}
3140     +
3141     +
3142     +void G4eNavigator::SetTarget( const G4eTarget* target )
3143     +{
3144     + /*
3145     + G4cout << " set target " << G4endl;
3146     + if( static_cast<const G4eTargetSurface*>(target) ) {
3147     + const G4eTargetSurface* targetc = static_cast<const G4eTargetSurface*>(target);
3148     + theTarget = const_cast<G4eTargetSurface*>(targetc);
3149     + G4cout << " set target " << theTarget << G4endl;
3150     + } else {
3151     + theTarget = 0;
3152     + }
3153     +*/
3154     +}
3155     +
3156     +
3157     +G4double G4eNavigator::ComputeStep (const G4ThreeVector &pGlobalPoint,
3158     + const G4ThreeVector &pDirection,
3159     + const G4double pCurrentProposedStepLength,
3160     + G4double &pNewSafety)
3161     +{
3162     + double Step = G4Navigator::ComputeStep(pGlobalPoint,pDirection,pCurrentProposedStepLength,pNewSafety);
3163     +
3164     +#ifdef geant4e
3165     + G4eManager *g4emgr = G4eManager::GetG4eManager();
3166     + if (g4emgr !=0){
3167     +
3168     + const G4eTarget* target = g4emgr->GetTarget();
3169     + // G4cout << " G4eNavigator::ComputeStep target = " << target << G4endl;
3170     + if( target != 0 ) {
3171     + G4double StepPlane = target->GetDistanceFromPoint(pGlobalPoint,pDirection);
3172     + if( StepPlane < 0. ) StepPlane = 1.E9; //negative means target is crossed, will not be found
3173     + //t if( StepPlane < 0. ) StepPlane = DBL_MAX; //negative means target is crossed, will not be found
3174     + if( G4eManager::verbose() >= 5 ) G4cout << " G4eNavigator::ComputeStep target step " << StepPlane << " transp step " << Step << G4endl;
3175     +
3176     +#ifdef G4EVERBOSE
3177     + if( G4eManager::verbose() >= 5 ) target->Dump( "G4eNavigator::ComputeStep Target " );
3178     +#endif
3179     +
3180     + if(StepPlane<Step){
3181     +#ifdef G4EVERBOSE
3182     + if( G4eManager::verbose() >= 2 ) std::cout << "G4eNavigator::ComputeStep TargetCloserThanBoundary " << StepPlane << " < " << Step << std::endl;
3183     +#endif
3184     + Step = StepPlane;
3185     + g4emgr->SetState(G4eState_TargetCloserThanBoundary);
3186     + } else {
3187     + g4emgr->SetState(G4eState_Propagating);
3188     + }
3189     + }
3190     +
3191     + }
3192     +
3193     +#endif
3194     +
3195     + pNewSafety = ComputeSafety(pGlobalPoint, pCurrentProposedStepLength);
3196     +
3197     +#ifdef G4EVERBOSE
3198     + if( G4eManager::verbose() >= 3 ) std::cout << "G4eNavigator::ComputeStep " << Step << " ComputeSafety " << pNewSafety << std::endl;
3199     +#endif
3200     +
3201     +
3202     + return Step;
3203     +
3204     +}
3205     +
3206     +G4double G4eNavigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
3207     + const G4double pMaxLength)
3208     +{
3209     + double newSafety = G4Navigator::ComputeSafety(pGlobalpoint,pMaxLength);
3210     +
3211     +#ifdef geant4e
3212     +
3213     + G4eManager *g4emgr = G4eManager::GetG4eManager();
3214     + if (g4emgr !=0){
3215     +
3216     + const G4eTarget* target = g4emgr->GetTarget();
3217     + if( target != 0 ) {
3218     + G4double distance = target->GetDistanceFromPoint(pGlobalpoint);
3219     +
3220     + if(distance<newSafety){
3221     + newSafety = distance;
3222     + // g4emgr->SetState(G4eState(G4eState_TargetCloserThanBoundary) );
3223     + } else{
3224     + // g4emgr->SetState(G4eState(G4eState_Init) );
3225     + }
3226     + }
3227     + }
3228     +
3229     +#endif
3230     +
3231     + return newSafety;
3232     +
3233     +}
3234     diff -Naur --exclude CVS source/geant4e/src/G4ePhysicsList.cc source/geant4e/src/G4ePhysicsList.cc
3235     --- source/geant4e/src/G4ePhysicsList.cc 1970-01-01 01:00:00.000000000 +0100
3236     +++ source/geant4e/src/G4ePhysicsList.cc 2007-01-17 12:41:58.000000000 +0100
3237     @@ -0,0 +1,256 @@
3238     +// no decay
3239     +// no annihilation
3240     +
3241     +#include "globals.hh"
3242     +#include "G4eMuIonisation.hh"
3243     +#include "G4ePhysicsList.hh"
3244     +#include "G4ComptonScattering.hh"
3245     +#include "G4GammaConversion.hh"
3246     +#include "G4PhotoElectricEffect.hh"
3247     +
3248     +#include "G4eIonisation.hh"
3249     +#include "G4eBremsstrahlung.hh"
3250     +#include "G4eplusAnnihilation.hh"
3251     +
3252     +#include "G4MuIonisation.hh"
3253     +#include "G4MuBremsstrahlung.hh"
3254     +#include "G4MuPairProduction.hh"
3255     +
3256     +#include "G4hIonisation.hh"
3257     +
3258     +#include "G4MuIonisation.hh"
3259     +#include "G4MuBremsstrahlung.hh"
3260     +#include "G4MuPairProduction.hh"
3261     +
3262     +#include "G4hIonisation.hh"
3263     +
3264     +#include "G4ParticleDefinition.hh"
3265     +#include "G4ParticleWithCuts.hh"
3266     +#include "G4ProcessManager.hh"
3267     +#include "G4ProcessVector.hh"
3268     +#include "G4ParticleTypes.hh"
3269     +#include "G4ParticleTable.hh"
3270     +#include "G4Material.hh"
3271     +#include "G4MaterialTable.hh"
3272     +#include "G4ios.hh"
3273     +#include <iomanip.h>
3274     +#include "G4PhysicsTable.hh"
3275     +#include "G4Transportation.hh"
3276     +
3277     +//#include "G4ePhysListEmModel.hh"
3278     +#include "G4eEnergyLossProcess.hh"
3279     +
3280     +G4ePhysicsList::G4ePhysicsList(): G4VUserPhysicsList()
3281     +{
3282     + defaultCutValue = 1.0E+9*cm; // set big step so that AlongStep computes all the energy
3283     +}
3284     +
3285     +G4ePhysicsList::~G4ePhysicsList()
3286     +{
3287     +}
3288     +
3289     +void G4ePhysicsList::ConstructParticle()
3290     +{
3291     +// In this method, static member functions should be called
3292     + // for all particles which you want to use.
3293     + // This ensures that objects of these particle types will be
3294     + // created in the program.
3295     + // gamma
3296     + G4Gamma::GammaDefinition();
3297     + // e+/-
3298     + G4Electron::ElectronDefinition();
3299     + G4Positron::PositronDefinition();
3300     + // mu+/-
3301     + G4MuonPlus::MuonPlusDefinition();
3302     + G4MuonMinus::MuonMinusDefinition();
3303     +
3304     +}
3305     +
3306     +void G4ePhysicsList::ConstructProcess()
3307     +{
3308     + G4Transportation* theTransportationProcess= new G4Transportation();
3309     +
3310     +#ifdef G4VERBOSE
3311     + if (verboseLevel >= 4){
3312     + G4cout << "G4VUserPhysicsList::ConstructProcess() "<< G4endl;
3313     + }
3314     +#endif
3315     +
3316     + // loop over all particles in G4ParticleTable
3317     + theParticleIterator->reset();
3318     + while( (*theParticleIterator)() ){
3319     + G4ParticleDefinition* particle = theParticleIterator->value();
3320     + G4ProcessManager* pmanager = particle->GetProcessManager();
3321     + if (!particle->IsShortLived()) {
3322     + G4cout << particle << "G4ePhysicsList:: particle process manager " << particle->GetParticleName() << " = " << particle->GetProcessManager() << G4endl;
3323     + // Add transportation process for all particles other than "shortlived"
3324     + if ( pmanager == 0) {
3325     + // Error !! no process manager
3326     + G4String particleName = particle->GetParticleName();
3327     + G4Exception("G4VUserPhysicsList::AddTransportation","No process manager",
3328     + RunMustBeAborted, particleName );
3329     + } else {
3330     + // add transportation with ordering = ( -1, "first", "first" )
3331     + pmanager ->AddProcess(theTransportationProcess);
3332     + pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
3333     + pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
3334     + }
3335     + } else {
3336     + // shortlived particle case
3337     + }
3338     + }
3339     +
3340     + ConstructEM();
3341     +}
3342     +
3343     +#include "G4eBremsstrahlung.hh"
3344     +#include "G4eIonisation.hh"
3345     +
3346     +#include "G4eIonisation.hh"
3347     +
3348     +#include "G4MuBremsstrahlung.hh"
3349     +#include "G4MuIonisation.hh"
3350     +#include "G4MuPairProduction.hh"
3351     +
3352     +//#include "G4eMuIonisation"
3353     +
3354     +#include "G4PhysicsTable.hh"
3355     +
3356     +#include "G4VeEnergyLoss.hh"
3357     +#include "G4VEnergyLoss.hh"
3358     +#include "G4VMuEnergyLoss.hh"
3359     +
3360     +#include "G4MuIonisation.hh"
3361     +
3362     +#include "G4eMagneticFieldLimitsProcess.hh"
3363     +
3364     +void G4ePhysicsList::ConstructEM()
3365     +{
3366     +
3367     + G4eMagneticFieldLimitsProcess* theG4eMagneticFieldLimitsProcess = new G4eMagneticFieldLimitsProcess;
3368     +
3369     + theParticleIterator->reset();
3370     + while( (*theParticleIterator)() ){
3371     + G4ParticleDefinition* particle = theParticleIterator->value();
3372     + G4ProcessManager* pmanager = particle->GetProcessManager();
3373     + G4String particleName = particle->GetParticleName();
3374     +
3375     + if (particleName == "gamma") {
3376     + // gamma
3377     + pmanager->AddDiscreteProcess(new G4GammaConversion());
3378     + pmanager->AddDiscreteProcess(new G4ComptonScattering());
3379     + pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
3380     +
3381     + } else if (particleName == "e-" || particleName == "e+") {
3382     + pmanager->AddProcess(new G4eIonisation, -1, 2,2);
3383     + pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
3384     +
3385     + //electron or positron
3386     + // G4VProcess* theeIonisation = new G4eMuIonisation(); //!!!
3387     + //
3388     + // add processes
3389     + //t pmanager->AddProcess(theeIonisation);
3390     + pmanager->AddDiscreteProcess( theG4eMagneticFieldLimitsProcess );
3391     + //
3392     + // set ordering for AtRestDoIt
3393     + //
3394     + // set ordering for AlongStepDoIt
3395     + //t pmanager->SetProcessOrdering(theeIonisation, idxAlongStep,1);
3396     + // pmanager->SetProcessOrdering(theG4eMagneticFieldLimitsProcess, idxAlongStep,2);
3397     + //
3398     + // set ordering for PostStepDoIt
3399     + //t pmanager->SetProcessOrdering(theeIonisation, idxPostStep,1);
3400     + // pmanager->SetProcessOrdering(theG4eMagneticFieldLimitsProcess, idxPostStep,2);
3401     +
3402     + } else if( particleName == "mu+" ||
3403     + particleName == "mu-" ) {
3404     +
3405     + G4bool bElossExtrap;
3406     + char* elext = getenv("G4EELOSSEXTRAP");
3407     + if( !elext ) {
3408     + bElossExtrap = 0;
3409     + } else {
3410     + bElossExtrap = atoi( elext );
3411     + }
3412     +
3413     + if( ! bElossExtrap ) {
3414     + G4cout << "!! G4ePhysicsList setting old G4e physics " << G4endl;
3415     + //muon
3416     + // G4VProcess* aMultipleScattering = new G4MultipleScattering();
3417     + G4VProcess* aBremsstrahlung = new G4MuBremsstrahlung();
3418     + G4VProcess* aPairProduction = new G4MuPairProduction();
3419     + //G4VProcess* anIonisation = new G4MuIonisation();
3420     +
3421     + G4VProcess* anIonisation = new G4eMuIonisation();
3422     +
3423     + G4VEnergyLossProcess* io = (G4VEnergyLossProcess*)anIonisation;
3424     + io->SetLossFluctuations( FALSE );
3425     + // add processes
3426     + pmanager->AddProcess(anIonisation,-1,1,1);
3427     + // pmanager->AddProcess(aMultipleScattering);
3428     + pmanager->AddProcess(aBremsstrahlung,-1,2,2);
3429     + pmanager->AddProcess(aPairProduction,-1,3,3);
3430     + pmanager->AddDiscreteProcess( theG4eMagneticFieldLimitsProcess );
3431     + //
3432     + // set ordering for AlongStepDoIt
3433     + // pmanager->SetProcessOrdering(aMultipleScattering, idxAlongStep,1);
3434     + pmanager->SetProcessOrdering(anIonisation, idxAlongStep,1);
3435     + // pmanager->SetProcessOrdering(theG4eMagneticFieldLimitsProcess, idxAlongStep,2);
3436     +
3437     + //
3438     + // set ordering for PostStepDoIt
3439     + pmanager->SetProcessOrdering(anIonisation, idxPostStep,1);
3440     + // pmanager->SetProcessOrdering(theG4eMagneticFieldLimitsProcess, idxPostStep,2);
3441     + }else {
3442     + G4cout << "!! G4ePhysicsList setting new G4e physics (G4eEnergyLossProcess) " << G4endl;
3443     +
3444     + G4VProcess* anEloss = new G4eEnergyLossProcess();
3445     +
3446     + // add processes
3447     + pmanager->AddContinuousProcess(anEloss);
3448     + pmanager->AddDiscreteProcess( theG4eMagneticFieldLimitsProcess );
3449     + //
3450     + // set ordering for AlongStepDoIt
3451     + // pmanager->SetProcessOrdering(anEloss, idxAlongStep,1);
3452     +
3453     + // set ordering for PostStepDoIt
3454     + // pmanager->SetProcessOrdering(theG4eMagneticFieldLimitsProcess, idxPostStep,1);
3455     + }
3456     + } else if ((!particle->IsShortLived()) &&
3457     + (particle->GetPDGCharge() != 0.0) &&
3458     + (particle->GetParticleName() != "chargedgeantino")) {
3459     + // all others charged particles except geantino
3460     + // G4VProcess* aMultipleScattering = new G4MultipleScattering();
3461     + G4VProcess* anIonisation = new G4hIonisation();
3462     + ////G4VProcess* theUserCuts = new G4UserSpecialCuts();
3463     +
3464     + //
3465     + // add processes
3466     + pmanager->AddProcess(anIonisation);
3467     + // pmanager->AddProcess(aMultipleScattering);
3468     + ////pmanager->AddProcess(theUserCuts);
3469     +
3470     + //
3471     + // set ordering for AlongStepDoIt
3472     + // pmanager->SetProcessOrdering(aMultipleScattering, idxAlongStep,1);
3473     + pmanager->SetProcessOrdering(anIonisation, idxAlongStep,1);
3474     +
3475     + //
3476     + // set ordering for PostStepDoIt
3477     + // pmanager->SetProcessOrdering(aMultipleScattering, idxPostStep,1);
3478     + pmanager->SetProcessOrdering(anIonisation, idxPostStep,1);
3479     + ////pmanager->SetProcessOrdering(theUserCuts, idxPostStep,2);
3480     + }
3481     + }
3482     +}
3483     +
3484     +
3485     +void G4ePhysicsList::SetCuts()
3486     +{
3487     + // " G4VUserPhysicsList::SetCutsWithDefault" method sets
3488     + // the default cut value or all particle types
3489     + SetCutsWithDefault();
3490     + // if (verboseLevel>0)
3491     + // DumpCutValuesTable();
3492     +}
3493     +
3494     diff -Naur --exclude CVS source/geant4e/src/G4ePropagatorG4.cc source/geant4e/src/G4ePropagatorG4.cc
3495     --- source/geant4e/src/G4ePropagatorG4.cc 1970-01-01 01:00:00.000000000 +0100
3496     +++ source/geant4e/src/G4ePropagatorG4.cc 2007-01-17 12:41:58.000000000 +0100
3497     @@ -0,0 +1,436 @@
3498     +#include "G4ePropagatorG4.hh"
3499     +#include "G4eManager.hh"
3500     +#include "G4eTrajStateFree.hh"
3501     +#include "G4eTrajStateOnSurface.hh"
3502     +#include "G4eTargetG4Volume.hh"
3503     +#include "G4eNavigator.hh"
3504     +
3505     +#include "G4DynamicParticle.hh"
3506     +#include "G4Track.hh"
3507     +#include "G4UserTrackingAction.hh"
3508     +#include "G4SteppingManager.hh"
3509     +#include "G4EventManager.hh"
3510     +#include "G4TrackingManager.hh"
3511     +#include "G4StepStatus.hh"
3512     +#include "G4GeometryManager.hh"
3513     +#include "G4ParticleTable.hh"
3514     +#include "G4UnitsTable.hh"
3515     +#include "G4StateManager.hh"
3516     +
3517     +#include "G4VPhysicalVolume.hh"
3518     +#include "G4PhysicalVolumeStore.hh"
3519     +#include <vector>
3520     +
3521     +
3522     +//---------------------------------------------------------------------------
3523     +G4ePropagatorG4::G4ePropagatorG4(): G4ePropagator()
3524     +{
3525     + verbose = G4eManager::verbose();
3526     +#ifdef G4EVERBOSE
3527     + if(verbose >= 5) G4cout << "G4ePropagatorG4 " << this << G4endl;
3528     +#endif
3529     + //t theTrackingGeometry = 0; //by default set it to 0, and when propagation it will be set to the world
3530     +
3531     + theG4Track = 0;
3532     +
3533     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3534     + if( g4emgr->GetState() == G4eState_PreInit ) {
3535     + G4cout << " calling InitGeant4e " << G4endl;
3536     + g4emgr->InitGeant4e();
3537     + }
3538     +
3539     + fpSteppingManager = G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager();
3540     +
3541     + thePropIsInitialized = false;
3542     +
3543     +}
3544     +
3545     +
3546     +//-----------------------------------------------------------------------
3547     +int G4ePropagatorG4::Propagate( G4eTrajState* currentTS, const G4eTarget* target, G4eMode mode )
3548     +{
3549     +
3550     + // to start ierror is set to 1 (= OK)
3551     + int ierr = 1;
3552     +
3553     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3554     + g4emgr->SetSteppingManagerVerboseLevel();
3555     +
3556     + //t if( !thePropIsInitialized ) InitPropagation( target ); // allows several propagation with same field, geometry and target !!! IT CRASHES
3557     +
3558     + g4emgr->InitTrackPropagation();
3559     +
3560     + //--- Do not propagate zero or too low energy particles
3561     + if( currentTS->GetMomentum().mag() < 1.E-9*MeV ) {
3562     + G4cerr << " !! G4ePropagatorG4::Propagate: energy too low to be propagated " << G4BestUnit(currentTS->GetMomentum().mag(),"Energy") << G4endl;
3563     + return -3;
3564     + }
3565     +
3566     + g4emgr->SetMode( mode );
3567     +
3568     +#ifdef G4EVERBOSE
3569     + if( verbose >= 1 ) G4cout << " =====> starting GEANT4E tracking for " << currentTS->GetParticleType() << " Forwards= " << g4emgr->GetMode() << G4endl;
3570     + if(verbose >= 1 ) G4cout << G4endl << "@@@@@@@@@@@@@@@@@@@@@@@@@ NEW STEP " << G4endl;
3571     +
3572     + if( verbose >= 3 ){
3573     + G4cout << " G4ePropagatorG4::Propagate initialTS ";
3574     + // initialTS.Dump();
3575     + G4cout << *currentTS << G4endl;
3576     + target->Dump(G4String(" to target "));
3577     + }
3578     +#endif
3579     +
3580     + g4emgr->SetTarget( target );
3581     + // SetTargetToNavigator( target );
3582     +
3583     + //----- Create a track
3584     + if( theG4Track != 0 ) delete theG4Track;
3585     + theG4Track = InitG4Track( *currentTS );
3586     +
3587     + //----- Create a G4eTrajStateFree
3588     + G4eTrajStateFree* currentTS_FREE = InitFreeTrajState( currentTS );
3589     +
3590     + //----- Track the particle
3591     + ierr = MakeSteps( currentTS_FREE );
3592     +
3593     + //------ Tracking ended, check if target has been reached
3594     + // if target not found
3595     + if( g4emgr->GetState() != G4eState_StoppedAtTarget ){
3596     + if( theG4Track->GetKineticEnergy() > 0. ) {
3597     + ierr = -ierr - 10;
3598     + } else {
3599     + ierr = -ierr - 20;
3600     + }
3601     + *currentTS = *currentTS_FREE;
3602     + if(verbose >= 0 ) G4cerr << " !!ERROR G4ePropagatorG4: particle does not reach target " << *currentTS << G4endl;
3603     + } else {
3604     + GetFinalTrajState( currentTS, currentTS_FREE, target );
3605     + }
3606     +
3607     +#ifdef G4EVERBOSE
3608     + if( verbose >= 1 ) G4cout << " G4ePropagator: propagation ended " << G4endl;
3609     + if( verbose >= 2 ) G4cout << " Current TrajState " << currentTS << G4endl;
3610     +#endif
3611     +
3612     + g4emgr->InvokePostUserTrackingAction( theG4Track );
3613     +
3614     + // Inform end of tracking to physics processes
3615     + theG4Track->GetDefinition()->GetProcessManager()->EndTracking();
3616     +
3617     + g4emgr->EventTermination();
3618     +
3619     + return ierr;
3620     +}
3621     +
3622     +
3623     +//-----------------------------------------------------------------------
3624     +int G4ePropagatorG4::PropagateOneStep( G4eTrajState* currentTS )
3625     +{
3626     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3627     + g4emgr->SetSteppingManagerVerboseLevel();
3628     +
3629     + if( g4emgr->GetState() == G4eState_PreInit || G4StateManager::GetStateManager()->GetCurrentState() != G4State_GeomClosed) {
3630     + //G4cout << g4emgr << " G4eState " << g4emgr->GetState() << " <> " << G4eState_Propagating
3631     + // << " G4State " << G4StateManager::GetStateManager()->GetCurrentState()<< " <> " << G4State_GeomClosed << G4endl;
3632     + G4Exception("!!! G4ePropagatorG4::PropagateOneStep called before initialization is done for this track, please call G4eManager::InitGeant4e() " );
3633     + }
3634     +
3635     + // to start ierror is set to 0 (= OK)
3636     + int ierr = 0;
3637     +
3638     + //--- Do not propagate zero or too low energy particles
3639     + if( currentTS->GetMomentum().mag() < 1.E-9*MeV ) {
3640     + G4cerr << " !! G4ePropagatorG4::PropagateOneStep: energy too low to be propagated " << G4BestUnit(currentTS->GetMomentum().mag(),"Energy") << G4endl;
3641     + return -3;
3642     + }
3643     +
3644     +#ifdef G4EVERBOSE
3645     + if( verbose >= 1 ) G4cout << " =====> starting GEANT4E tracking for " << currentTS->GetParticleType() << " Forwards= " << g4emgr->GetMode() << G4endl;
3646     +
3647     + if( verbose >= 3 ){
3648     + G4cout << " G4ePropagatorG4::Propagate initialTS ";
3649     + G4cout << *currentTS << G4endl;
3650     + }
3651     +#endif
3652     +
3653     + // SetTargetToNavigator( (G4eTarget*)0 );
3654     +
3655     + //----- If it is the first step, create a track
3656     + if( theStepN == 0 ) theG4Track = InitG4Track( *currentTS ); // set to 0 by the initialization in G4eManager
3657     + theStepN++;
3658     +
3659     + //----- Create a G4eTrajStateFree
3660     + G4eTrajStateFree* currentTS_FREE = InitFreeTrajState( currentTS );
3661     +
3662     + //----- Track the particle one step
3663     + ierr = MakeOneStep( currentTS_FREE );
3664     +
3665     + //----- Get the state on target
3666     + GetFinalTrajState( currentTS, currentTS_FREE, g4emgr->GetTarget() );
3667     +
3668     + return ierr;
3669     +}
3670     +
3671     +
3672     +//---------------------------------------------------------------------------
3673     +G4Track* G4ePropagatorG4::InitG4Track( G4eTrajState& initialTS )
3674     +{
3675     + if( verbose >= 5 ) G4cout << "InitG4Track " << G4endl;
3676     +
3677     + //----- Close geometry
3678     + //- bool geometryToBeOptimized = true;
3679     + // if(verboseLevel>1)
3680     + //- G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
3681     + //- geomManager->OpenGeometry();
3682     + //- geomManager->CloseGeometry(geometryToBeOptimized);
3683     +
3684     + //----- Create Particle
3685     + const G4String partType = initialTS.GetParticleType();
3686     + G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
3687     + G4ParticleDefinition* particle = particleTable->FindParticle(partType);
3688     + if( particle == 0) {
3689     + G4Exception( "!!! G4eManager::InitializeTrack: particle type not defined " + partType );
3690     + } else {
3691     +
3692     + }
3693     +
3694     + G4DynamicParticle* DP =
3695     + new G4DynamicParticle(particle,initialTS.GetMomentum());
3696     + DP->SetPolarization(0.,0.,0.);
3697     + // Set Charge
3698     + // if (abs(primaryParticle->GetCharge()-DP->GetPDGCharge())>eplus) {
3699     + // DP->SetCharge(primaryParticle->GetCharge());
3700     + if( particle->GetPDGCharge() < 0 ) {
3701     + DP->SetCharge(-eplus);
3702     + } else {
3703     + DP->SetCharge(eplus);
3704     + }
3705     + // Set decay products to the DynamicParticle
3706     + //?? SetDecayProducts( primaryParticle, DP );
3707     +
3708     + //----- Create Track
3709     + theG4Track = new G4Track(DP, 0., initialTS.GetPosition() );
3710     + theG4Track->SetParentID(0);
3711     +#ifdef G4EVERBOSE
3712     + if(verbose >= 3) G4cout << " G4eManager new track of energy: " << theG4Track->GetKineticEnergy() << G4endl;
3713     +#endif
3714     +
3715     + //---- Reproduce G4TrackingManager::ProcessOneTrack initialization
3716     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3717     + g4emgr->InvokePreUserTrackingAction( theG4Track );
3718     +
3719     + if( fpSteppingManager == 0 ) {
3720     + // G4cerr << " event manager " << G4EventManager::GetEventManager() << G4endl;
3721     + G4Exception( "G4ePropagator::InitG4Track. GEANT4e error: G4SteppingManager not initialized yet " );
3722     + } else {
3723     + fpSteppingManager->SetInitialStep(theG4Track);
3724     + }
3725     +
3726     + // Give SteppingManger the maximum number of processes
3727     + fpSteppingManager->GetProcessNumber();
3728     +
3729     + // Give track the pointer to the Step
3730     + theG4Track->SetStep(fpSteppingManager->GetStep());
3731     +
3732     + // Inform beginning of tracking to physics processes
3733     + theG4Track->GetDefinition()->GetProcessManager()->StartTracking(theG4Track);
3734     +
3735     + initialTS.SetG4Track( theG4Track );
3736     +
3737     + return theG4Track;
3738     +}
3739     +
3740     +
3741     +//-----------------------------------------------------------------------
3742     +int G4ePropagatorG4::MakeSteps( G4eTrajStateFree* currentTS_FREE )
3743     +{
3744     + int ierr = 0;
3745     + //----- Track the particle Step-by-Step while it is alive
3746     + theStepLength = 0.;
3747     +
3748     + while( (theG4Track->GetTrackStatus() == fAlive) ||
3749     + (theG4Track->GetTrackStatus() == fStopButAlive) ){
3750     + ierr = MakeOneStep( currentTS_FREE );
3751     + if( ierr != 0 ) break;
3752     + //----- Check if last step for GEANT4e
3753     + if( CheckIfLastStep( theG4Track ) ) {
3754     + if( verbose >= 5 ) G4cout << "!!!! Last Step reached " << G4endl;
3755     + break;
3756     + }
3757     + }
3758     +
3759     + return ierr;
3760     +
3761     +}
3762     +
3763     +//-----------------------------------------------------------------------
3764     +int G4ePropagatorG4::MakeOneStep( G4eTrajStateFree* currentTS_FREE )
3765     +{
3766     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3767     + int ierr = 0;
3768     +
3769     + //---------- Track one step
3770     +#ifdef G4EVERBOSE
3771     + if(verbose >= 2 ) G4cout << G4endl << "@@@@@@@@@@@@@@@@@@@@@@@@@ NEW STEP " << G4endl;
3772     +#endif
3773     +
3774     + theG4Track->IncrementCurrentStepNumber();
3775     + //- G4StepStatus stepStatus =
3776     + fpSteppingManager->Stepping(); //t
3777     +
3778     + //---------- Check if Target has been reached (and then set G4eState)
3779     +#ifdef G4EVERBOSE
3780     + if(verbose >= 5 ) G4cout << " process = " << theG4Track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() << " g4estate " << g4emgr->PrintG4eState() << G4endl;
3781     +#endif
3782     +
3783     + // G4eNavigator limits the step if target is closer than boundary (but the winner process is always "Transportation": then geant4e will stop the track
3784     + if( theG4Track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "Transportation" ){
3785     + if( g4emgr->GetState() == G4eState(G4eState_TargetCloserThanBoundary) ){ // target or step length reached
3786     +
3787     +#ifdef G4EVERBOSE
3788     + if(verbose >= 5 ) G4cout << " transportation determined by geant4e " << G4endl;
3789     +#endif
3790     +
3791     + g4emgr->SetState( G4eState_StoppedAtTarget );
3792     + /*t } else if( theFinalTarget->GetType() == G4eTarget_Volume ) {
3793     + if( static_cast<G4eTargetG4Volume*>( theFinalTarget )->TargetReached( theG4Track->GetStep() ) ) {
3794     + g4emgr->SetState( G4eState_StoppedAtTarget );
3795     + } */
3796     + }
3797     + }else if( theG4Track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "G4eTargetTrackLength" ){
3798     + g4emgr->SetState( G4eState_StoppedAtTarget );
3799     + }
3800     +
3801     + /*if( g4emgr->GetState() == G4eState_StoppedAtTarget ) {
3802     + G4cout << " Run termination " << g4emgr->GetState() << G4endl;
3803     + g4emgr->RunTermination();
3804     + }*/
3805     +
3806     +
3807     + //---------- Propagate error
3808     +#ifdef G4EVERBOSE
3809     + if(verbose >= 2 ) G4cout << " propagating error " << *currentTS_FREE << G4endl;
3810     +#endif
3811     + const G4Track* cTrack = const_cast<G4Track*>(theG4Track);
3812     + ierr = currentTS_FREE->PropagateError( cTrack );
3813     +
3814     +#ifdef G4EVERBOSE
3815     + if(verbose >= 3 ) G4cout << " PropagateError returns " << ierr << G4endl;
3816     +#endif
3817     +
3818     + currentTS_FREE->Update( cTrack );
3819     +
3820     + theStepLength += theG4Track->GetStepLength();
3821     +
3822     + if(ierr != 0 ) {
3823     + G4cerr << "!!! G4ePropagatorG4:MakeOneStep returns an error " << ierr << G4endl;
3824     + G4cerr << "!!! GEANT4 tracking will be stopped " << G4endl;
3825     + }
3826     +
3827     + return ierr;
3828     +}
3829     +
3830     +
3831     +//-----------------------------------------------------------------------
3832     +G4eTrajStateFree* G4ePropagatorG4::InitFreeTrajState( G4eTrajState* currentTS )
3833     +{
3834     + G4eTrajStateFree* currentTS_FREE;
3835     + //----- Transform the TrajState to Free coordinates if it is OnSurface
3836     + if( currentTS->GetTSType() == G4eTS_OS ){
3837     + G4eTrajStateOnSurface* tssd = static_cast<G4eTrajStateOnSurface*>(currentTS);
3838     + //t if( theCurrentTS_FREE != 0 ) delete theCurrentTS_FREE;
3839     + currentTS_FREE = new G4eTrajStateFree( *tssd );
3840     + }else if( currentTS->GetTSType() == G4eTS_FREE ){
3841     + currentTS_FREE = static_cast<G4eTrajStateFree*>(currentTS);
3842     + } else {
3843     + G4Exception("G4ePropagatorG4::InitFreeTrajState WRONG TrajState " + currentTS->GetTSType());
3844     + }
3845     +
3846     + return currentTS_FREE;
3847     +}
3848     +
3849     +
3850     +
3851     +//-----------------------------------------------------------------------
3852     +void G4ePropagatorG4::GetFinalTrajState( G4eTrajState* currentTS, G4eTrajStateFree* currentTS_FREE, const G4eTarget* target )
3853     +{
3854     +
3855     +#ifdef G4EVERBOSE
3856     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3857     + if(verbose >= 1 ) G4cout << " G4ePropagatorG4::Propagate: final state " << int(g4emgr->GetState()) << " TSType " << currentTS->GetTSType() << G4endl;
3858     +#endif
3859     +
3860     + if( currentTS->GetTSType() == G4eTS_FREE ||
3861     + ! g4emgr->GetState() == G4eState_StoppedAtTarget ){
3862     + currentTS = currentTS_FREE;
3863     + } else if( currentTS->GetTSType() == G4eTS_OS ){
3864     + if( target->GetType() == G4eTarget_TrkL ){
3865     + G4Exception("G4ePropagatorG4:GetFinalTrajState !! Using a G4eTrajStateOnSurface with a target of type G4eTargetTrackLength ");
3866     + }
3867     + //- G4eTrajStateOnSurface* tssd = static_cast<G4eTrajStateOnSurface*>(currentTS);
3868     + // delete currentTS;
3869     + const G4eTargetWithTangentPlane* targetWTP = static_cast<const G4eTargetWithTangentPlane*>(target);
3870     + *currentTS = G4eTrajStateOnSurface( *(static_cast<G4eTrajStateFree*>(currentTS_FREE)), targetWTP->GetTangentPlane( currentTS_FREE->GetPosition() ) );
3871     +#ifdef G4EVERBOSE
3872     + if(verbose >= 1 ) G4cout << currentTS << " returning tssd " << *currentTS << G4endl;
3873     +#endif
3874     + delete currentTS_FREE;
3875     + }
3876     +}
3877     +
3878     +
3879     +//-------------------------------------------------------------------------
3880     +G4bool G4ePropagatorG4::CheckIfLastStep( G4Track* aTrack )
3881     +{
3882     + G4bool exception = 0;
3883     + G4bool lastG4eStep = false;
3884     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3885     +
3886     + if( verbose >= 4 ) G4cout << " G4ePropagatorG4::CheckIfLastStep G4eState= " << int(g4emgr->GetState()) << G4endl;
3887     +
3888     + //----- Check if this is the last step: track has reached the target or the end of world
3889     + if(g4emgr->GetState() == G4eState(G4eState_StoppedAtTarget) ) {
3890     + lastG4eStep = true;
3891     +#ifdef G4EVERBOSE
3892     + if(verbose >= 5 ) G4cout << " G4ePropagatorG4::CheckIfLastStep " << lastG4eStep << " " << int(g4emgr->GetState()) << G4endl;
3893     +#endif
3894     + } else if( aTrack->GetNextVolume() == 0 ) {
3895     + //----- If particle is out of world, without finding the G4eTarget, give a n error/warning
3896     + lastG4eStep = true;
3897     + if( exception ){
3898     + G4cerr << " !!!EXITING: G4ePropagatorG4::CheckIfLastSte: track extrapolated until end of World without finding the defined target " << G4endl;
3899     + exit(1);
3900     + } else {
3901     + if( verbose >= 1 ) G4cerr << " !!!WARNING: G4ePropagatorG4::CheckIfLastSte: track extrapolated until end of World without finding the defined target " << G4endl;
3902     + }
3903     + //----- not last step from G4e, but track is stopped (energy exhausted)
3904     + } else if( aTrack->GetTrackStatus() == fStopAndKill ) {
3905     + if( exception ){
3906     + G4cerr << " !!!EXITING: G4ePropagatorG4::CheckIfLastSte: track extrapolated until energy is exhausted without finding the defined target " << G4endl;
3907     + exit(1);
3908     + } else {
3909     + if( verbose >= 1 ) G4cerr << " !!!WARNING: G4ePropagatorG4::CheckIfLastSte track extrapolated until energy is exhausted without finding the defined target " << G4endl;
3910     + lastG4eStep = 1;
3911     + }
3912     + }
3913     +
3914     + if( verbose >= 5 ) G4cout << " return CheckIfLastStep " << lastG4eStep << G4endl;
3915     + return lastG4eStep;
3916     +}
3917     +
3918     +
3919     +//-------------------------------------------------------------------------
3920     +void G4ePropagatorG4::SetTargetToNavigator( const G4eTarget* target )
3921     +{
3922     + G4eManager* g4emgr = G4eManager::GetG4eManager();
3923     +
3924     + if( target == 0 ){
3925     + target = g4emgr->GetTarget();
3926     + }
3927     +
3928     + // g4emgr->GetG4eNavigator()->SetTarget( target );
3929     +
3930     +}
3931     +
3932     +
3933     +
3934     diff -Naur --exclude CVS source/geant4e/src/G4eRunManagerKernel.cc source/geant4e/src/G4eRunManagerKernel.cc
3935     --- source/geant4e/src/G4eRunManagerKernel.cc 1970-01-01 01:00:00.000000000 +0100
3936     +++ source/geant4e/src/G4eRunManagerKernel.cc 2007-01-17 12:41:58.000000000 +0100
3937     @@ -0,0 +1,126 @@
3938     +
3939     +#include "G4Navigator.hh"
3940     +// On Sun, to prevent conflict with ObjectSpace, G4Timer.hh has to be
3941     +// loaded *before* globals.hh...
3942     +#include "G4Timer.hh"
3943     +
3944     +#include "G4eRunManagerKernel.hh"
3945     +
3946     +#include "G4RunManagerKernel.hh"
3947     +#include "G4VUserDetectorConstruction.hh"
3948     +#include "G4ePhysicsList.hh"
3949     +#include "ExN02PhysicsList.hh"
3950     +#include "G4TransportationManager.hh"
3951     +
3952     +//-----------------------------------------------------------------------
3953     +
3954     +G4eRunManagerKernel* G4eRunManagerKernel::fRunManagerKernel = 0;
3955     +
3956     +//-----------------------------------------------------------------------
3957     +G4eRunManagerKernel* G4eRunManagerKernel::GetRunManagerKernel()
3958     +{ return fRunManagerKernel; }
3959     +
3960     +//-----------------------------------------------------------------------
3961     +G4eRunManagerKernel::G4eRunManagerKernel()
3962     +{
3963     + if(fRunManagerKernel)
3964     + { G4Exception("G4eRunManageKernel constructed twice."); }
3965     + fRunManagerKernel = this;
3966     +
3967     + //----- Look if somebody has created a G4RunManagerKernel
3968     + theG4RunManagerKernel = G4RunManagerKernel::GetRunManagerKernel();
3969     + if( theG4RunManagerKernel == 0 ) {
3970     + //--- if not create it
3971     + theG4RunManagerKernel = new G4RunManagerKernel();
3972     + G4cout << " creating G4RunManagerKernel " << theG4RunManagerKernel << G4endl;
3973     + }
3974     +
3975     + theG4RunManagerKernel->SetVerboseLevel(2);
3976     + theUserPhysicsList = 0;
3977     + theUserWorld = 0;
3978     +
3979     +}
3980     +
3981     +//-----------------------------------------------------------------------
3982     +G4eRunManagerKernel::~G4eRunManagerKernel()
3983     +{
3984     +}
3985     +
3986     +//-----------------------------------------------------------------------
3987     +void G4eRunManagerKernel::SetUserInitialization(G4VUserDetectorConstruction* userInit)
3988     +{
3989     + theUserWorld = userInit->Construct();
3990     +}
3991     +
3992     +//-----------------------------------------------------------------------
3993     +void G4eRunManagerKernel::SetUserInitialization(G4VPhysicalVolume* userInit)
3994     +{
3995     + theUserWorld = userInit;
3996     +}
3997     +
3998     +//-----------------------------------------------------------------------
3999     +void G4eRunManagerKernel::SetUserInitialization(G4VUserPhysicsList* userInit)
4000     +{
4001     + theUserPhysicsList = userInit;
4002     +}
4003     +
4004     +//-----------------------------------------------------------------------
4005     + void G4eRunManagerKernel::InitializeGeometry()
4006     +{
4007     + //check if user world has been directly called or someone initialized theworld volume already
4008     + if( theUserWorld != 0 ) {
4009     + theG4RunManagerKernel->DefineWorldVolume( theUserWorld );
4010     + } else {
4011     +
4012     + G4cerr << "G4 TM " << G4TransportationManager::GetTransportationManager()
4013     + << " NAV " << G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()
4014     + << " WORLD " << G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume() << std::endl;
4015     + if ( G4TransportationManager::GetTransportationManager()
4016     + ->GetNavigatorForTracking()->GetWorldVolume() == 0 ) {
4017     + G4Exception("G4eRunManagerKernel::InitializeGeometry no world defined in your geometry!" );
4018     + }
4019     + }
4020     +
4021     +}
4022     +
4023     +//-----------------------------------------------------------------------
4024     +void G4eRunManagerKernel::InitializePhysics()
4025     +{
4026     +
4027     + if( theUserPhysicsList == 0 ) {
4028     + theG4RunManagerKernel->SetPhysics(new G4ePhysicsList);
4029     + // theG4RunManagerKernel->SetPhysics(new ExN02PhysicsList);
4030     + }else {
4031     + theG4RunManagerKernel->SetPhysics(theUserPhysicsList);
4032     + }
4033     + G4cout << " G4eRunManagerKernel::InitializePhysics " << G4endl;
4034     + theG4RunManagerKernel->InitializePhysics();
4035     +
4036     +}
4037     +
4038     +//-----------------------------------------------------------------------
4039     +void G4eRunManagerKernel::RunInitialization()
4040     +{
4041     + theG4RunManagerKernel->RunInitialization();
4042     +}
4043     +
4044     +
4045     +//-----------------------------------------------------------------------
4046     +void G4eRunManagerKernel::SetUserAction(G4UserTrackingAction* userAction)
4047     +{
4048     +
4049     + G4EventManager::GetEventManager()->SetUserAction( userAction );
4050     +}
4051     +
4052     +//-----------------------------------------------------------------------
4053     +void G4eRunManagerKernel::SetUserAction(G4UserSteppingAction* userAction)
4054     +{
4055     + G4EventManager::GetEventManager()->SetUserAction( userAction );
4056     +}
4057     +
4058     +//-----------------------------------------------------------------------
4059     +void G4eRunManagerKernel::RunTermination()
4060     +{
4061     + theG4RunManagerKernel->RunTermination();
4062     +}
4063     +
4064     diff -Naur --exclude CVS source/geant4e/src/G4eTargetCylindricalSurface.cc source/geant4e/src/G4eTargetCylindricalSurface.cc
4065     --- source/geant4e/src/G4eTargetCylindricalSurface.cc 1970-01-01 01:00:00.000000000 +0100
4066     +++ source/geant4e/src/G4eTargetCylindricalSurface.cc 2007-01-17 12:41:58.000000000 +0100
4067     @@ -0,0 +1,149 @@
4068     +//
4069     +#include "G4eTargetCylindricalSurface.hh"
4070     +#include "G4eManager.hh" //for verbosity checking
4071     +#include "geomdefs.hh"
4072     +
4073     +#include "G4Plane3D.hh"
4074     +
4075     + // Initialise a single volume, positioned in a frame which is rotated by
4076     + // *pRot and traslated by tlate, relative to the coordinate system of the
4077     + // mother volume pMotherLogical.
4078     + // If pRot=0 the volume is unrotated with respect to its mother.
4079     + // The physical volume is added to the mother's logical volume.
4080     + // Arguments particular to G4PVPlacement:
4081     + // pMany Currently NOT used. For future use to identify if the volume
4082     + // is meant to be considered an overlapping structure, or not.
4083     + // pCopyNo should be set to 0 for the first volume of a given type.
4084     + // This is a very natural way of defining a physical volume, and is
4085     + // especially useful when creating subdetectors: the mother volumes are
4086     + // not placed until a later stage of the assembly program.
4087     +
4088     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4089     +G4eTargetCylindricalSurface::G4eTargetCylindricalSurface( const G4float& radius, const G4ThreeVector& trans, const G4RotationMatrix& rotm ): fradius(radius)
4090     +{
4091     + theType = G4eTarget_CylindricalSurface;
4092     +
4093     + ftransform3D = G4Transform3D( rotm.inverse(), -trans );
4094     + Dump( " $$$ creating G4eTargetCylindricalSurface ");
4095     +}
4096     +
4097     + // Additional constructor, which expects a G4Transform3D that represents
4098     + // the direct rotation and translation of the solid (NOT of the frame).
4099     + // The G4Transform3D argument should be constructed by:
4100     + // i) First rotating it to align the solid to the system of
4101     + // reference of its mother volume *pMotherLogical, and
4102     + // ii) Then placing the solid at the location Transform3D.getTranslation(),
4103     + // with respect to the origin of the system of coordinates of the
4104     + // mother volume.
4105     + // [ This is useful for the people who prefer to think in terms
4106     + // of moving objects in a given reference frame. ]
4107     + // All other arguments are the same as for the previous constructor.
4108     +
4109     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4110     +G4eTargetCylindricalSurface::G4eTargetCylindricalSurface( const G4float& radius, const G4Transform3D& trans3D): fradius(radius), ftransform3D(trans3D.inverse())
4111     +{
4112     + theType = G4eTarget_CylindricalSurface;
4113     +}
4114     +
4115     +
4116     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4117     +G4ThreeVector G4eTargetCylindricalSurface::Intersect( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
4118     +{
4119     + G4ThreeVector localPoint = ftransform3D * G4Point3D(pt);
4120     + G4ThreeVector localDir = ftransform3D * G4Normal3D(dir);
4121     + return IntersectLocal( localPoint, localDir );
4122     +
4123     +}
4124     +
4125     +
4126     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4127     +G4ThreeVector G4eTargetCylindricalSurface::IntersectLocal( const G4ThreeVector& localPoint, const G4ThreeVector& localDir ) const
4128     +{
4129     + G4double pointPerp = localPoint.perp();
4130     + G4double dirPerp = localDir.perp();
4131     +
4132     + if( dirPerp == 0. ) {
4133     + G4Exception("G4eTargetCylindricalSurface::Intersect. Direction is perpendicular to cylinder axis ");
4134     + }
4135     +
4136     + G4double lam = (fradius - pointPerp ) / dirPerp;
4137     + G4ThreeVector inters = localPoint + lam * localDir;
4138     +
4139     +#ifdef G4EVERBOSE
4140     + if(G4eManager::verbose() >= 4 ) {
4141     + G4cout << " G4eTargetCylindricalSurface::getIntersection " << inters << " " << inters.perp() << G4endl;
4142     + }
4143     +#endif
4144     +
4145     + return inters;
4146     +}
4147     +
4148     +
4149     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4150     +G4double G4eTargetCylindricalSurface::GetDistanceFromPoint( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
4151     +{
4152     +
4153     + if( dir.mag() == 0. ) {
4154     + G4Exception("G4eTargetCylindricalSurface::GetDistanceFromPoint: direction is zero ");
4155     + }
4156     +
4157     + //transform to local coordinates
4158     + G4ThreeVector localPoint = ftransform3D * G4Point3D(pt) ;
4159     + G4ThreeVector localDir = ftransform3D * G4Normal3D(dir/dir.mag());
4160     +
4161     +#ifdef G4EVERBOSE
4162     + if(G4eManager::verbose() >= 4 ) {
4163     + G4cout << " global pt " << pt << " dir " << dir << G4endl;
4164     + G4cout << " transformed to local coordinates pt " << localPoint << " dir " << localDir << G4endl;
4165     + Dump( " cylsurf " );
4166     + }
4167     +#endif
4168     +
4169     + // If parallel to cylinder axis there is no intersection
4170     + if( localDir.perp() == 0 ) {
4171     + return kInfinity;
4172     + }
4173     +
4174     +
4175     + G4ThreeVector inters = IntersectLocal( localPoint, localDir );
4176     + G4double lam = (inters - localPoint).mag();
4177     +#ifdef G4EVERBOSE
4178     + if(G4eManager::verbose() >= 3 ) {
4179     + G4cout << this << " G4eTargetCylindricalSurface::getDistanceFromPoint " << lam << " point " << pt << " direc " << dir << G4endl;
4180     + }
4181     +#endif
4182     +
4183     + return lam;
4184     +
4185     +}
4186     +
4187     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4188     +G4double G4eTargetCylindricalSurface::GetDistanceFromPoint( const G4ThreeVector& pt ) const
4189     +{
4190     + G4ThreeVector localPoint = ftransform3D * G4Point3D(pt);
4191     +
4192     + return fradius - localPoint.perp();
4193     +}
4194     +
4195     +
4196     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4197     +G4Plane3D G4eTargetCylindricalSurface::GetTangentPlane( const G4ThreeVector& pt ) const
4198     +{
4199     + G4ThreeVector localPoint = ftransform3D * G4Point3D(pt);
4200     +
4201     + //check that point is at cylinder surface
4202     + if( fabs( localPoint.perp() - fradius ) > 1000.*kCarTolerance ) {
4203     + G4cerr << " !!WARNING G4eTargetCylindricalSurface::GetTangentPlane: point " << pt << " is not at surface, but it is distant " << localPoint.perp() - fradius << G4endl;
4204     + }
4205     +
4206     + G4Normal3D normal = localPoint - ftransform3D.getTranslation();
4207     + return G4Plane3D( normal ,pt );
4208     +
4209     +}
4210     +
4211     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4212     +void G4eTargetCylindricalSurface::Dump( G4String msg ) const
4213     +{
4214     + G4cout << msg << " radius " << fradius << " centre " << ftransform3D.getTranslation() << " rotation " << ftransform3D.getRotation() << G4endl;
4215     +
4216     +}
4217     diff -Naur --exclude CVS source/geant4e/src/G4eTargetG4Volume.cc source/geant4e/src/G4eTargetG4Volume.cc
4218     --- source/geant4e/src/G4eTargetG4Volume.cc 1970-01-01 01:00:00.000000000 +0100
4219     +++ source/geant4e/src/G4eTargetG4Volume.cc 2007-01-17 12:41:58.000000000 +0100
4220     @@ -0,0 +1,40 @@
4221     +#include "G4eTargetG4Volume.hh"
4222     +#include "G4eManager.hh" //for verbosity checking
4223     +#include "G4Point3D.hh"
4224     +#include "G4ThreeVector.hh"
4225     +#include "G4Step.hh"
4226     +
4227     +
4228     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4229     +G4eTargetG4Volume::G4eTargetG4Volume( const G4String& name )
4230     +{
4231     + theType = G4eTarget_G4Volume;
4232     + theName = name;
4233     +}
4234     +
4235     +
4236     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4237     +bool G4eTargetG4Volume::TargetReached( const G4Step* aStep )
4238     +{
4239     + if( aStep->GetTrack()->GetNextVolume()->GetName() == theName ){
4240     + return 1;
4241     + }else {
4242     + return 0;
4243     + }
4244     +}
4245     +
4246     +
4247     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4248     +G4Plane3D G4eTargetG4Volume::GetTangentPlane( const G4ThreeVector& point ) const
4249     +{
4250     + return G4Plane3D( G4Normal3D(1,0.,0), G4Point3D(0,0,0) );
4251     + // return SurfaceNormal*this;
4252     +}
4253     +
4254     +
4255     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4256     +void G4eTargetG4Volume::Dump( G4String msg ) const
4257     +{
4258     + // G4cout << msg << " point = " << point() << " normal = " << normal() << G4endl;
4259     +
4260     +}
4261     diff -Naur --exclude CVS source/geant4e/src/G4eTargetPlaneSurface.cc source/geant4e/src/G4eTargetPlaneSurface.cc
4262     --- source/geant4e/src/G4eTargetPlaneSurface.cc 1970-01-01 01:00:00.000000000 +0100
4263     +++ source/geant4e/src/G4eTargetPlaneSurface.cc 2007-01-17 12:41:58.000000000 +0100
4264     @@ -0,0 +1,83 @@
4265     +#include "G4eTargetPlaneSurface.hh"
4266     +#include "G4eManager.hh" //for verbosity checking
4267     +#include "G4Point3D.hh"
4268     +#include "G4ThreeVector.hh"
4269     +
4270     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4271     +G4eTargetPlaneSurface::G4eTargetPlaneSurface(G4double a, G4double b, G4double c, G4double d)
4272     + : G4Plane3D( a, b, c, d )
4273     +{
4274     + theType = G4eTarget_PlaneSurface;
4275     +}
4276     +
4277     +
4278     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4279     +G4eTargetPlaneSurface::G4eTargetPlaneSurface(const G4Normal3D &n, const G4Point3D &p)
4280     + : G4Plane3D( n, p )
4281     +{
4282     + theType = G4eTarget_PlaneSurface;
4283     +}
4284     +
4285     +
4286     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4287     +G4eTargetPlaneSurface::G4eTargetPlaneSurface(const G4Point3D &p1, const G4Point3D &p2, const G4Point3D &p3) : G4Plane3D( p1, p2, p3 )
4288     +{
4289     + theType = G4eTarget_PlaneSurface;
4290     +}
4291     +
4292     +
4293     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4294     +//G4Point3D G4eTargetPlaneSurface::Intersect( const G4Point3D& pt, const G4ThreeVector& dir ) const
4295     +G4ThreeVector G4eTargetPlaneSurface::Intersect( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
4296     +{
4297     + double lam = GetDistanceFromPoint( pt, dir);
4298     + G4Point3D inters = pt + lam * dir;
4299     + return inters;
4300     +
4301     +}
4302     +
4303     +
4304     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4305     +//double G4eTargetPlaneSurface::GetDistanceFromPoint( const G4Point3D& pt, const G4ThreeVector& dir ) const
4306     +G4double G4eTargetPlaneSurface::GetDistanceFromPoint( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
4307     +{
4308     + if( fabs( dir.mag() -1. ) > 1.E-6 ) G4cerr << "!!!WARNING G4eTargetPlaneSurface::GetDistanceFromPoint: direction is not a unit vector " << dir << G4endl;
4309     + double lam = -(a_ * pt.x() + b_ * pt.y() + c_ * pt.z() + d_) /
4310     +(a_ * dir.x() + b_ * dir.y() + c_ * dir.z() );
4311     +
4312     +#ifdef G4EVERBOSE
4313     + if(G4eManager::verbose() >= 5 ) {
4314     + G4cout << " G4eTargetPlaneSurface::getDistanceFromPoint " << lam << " point " << pt << " direc " << dir << G4endl;
4315     + G4cout << " a_ " << a_ << " b_ " << b_ << " c_ " << c_ << " d_ " << d_ << G4endl;
4316     + }
4317     +#endif
4318     +
4319     + return lam;
4320     +
4321     +}
4322     +
4323     +
4324     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4325     +G4double G4eTargetPlaneSurface::GetDistanceFromPoint( const G4ThreeVector& pt ) const
4326     +{
4327     + G4ThreeVector vec = point() - pt;
4328     + double alpha = acos( vec * normal() / vec.mag() / normal().mag() );
4329     + double dist = fabs(vec.mag() * cos( alpha ));
4330     +
4331     + return dist;
4332     +
4333     +}
4334     +
4335     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4336     +G4Plane3D G4eTargetPlaneSurface::GetTangentPlane( const G4ThreeVector& ) const
4337     +{
4338     + return *this;
4339     +}
4340     +
4341     +
4342     +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4343     +void G4eTargetPlaneSurface::Dump( G4String msg ) const
4344     +{
4345     + G4cout << msg << " point = " << point() << " normal = " << normal() << G4endl;
4346     +
4347     +}
4348     diff -Naur --exclude CVS source/geant4e/src/G4eTargetTrackLength.cc source/geant4e/src/G4eTargetTrackLength.cc
4349     --- source/geant4e/src/G4eTargetTrackLength.cc 1970-01-01 01:00:00.000000000 +0100
4350     +++ source/geant4e/src/G4eTargetTrackLength.cc 2007-01-17 12:41:58.000000000 +0100
4351     @@ -0,0 +1,90 @@
4352     +
4353     +#include "G4eTargetTrackLength.hh"
4354     +#include "G4UnitsTable.hh"
4355     +#include "G4eMagneticFieldLimitsMessenger.hh"
4356     +
4357     +#include "G4ParticleTable.hh"
4358     +#include "G4ParticleDefinition.hh"
4359     +#include "G4VProcess.hh"
4360     +#include "G4ProcessVector.hh"
4361     +#include "G4ProcessManager.hh"
4362     +
4363     +//----------------------------------------------------------------------------
4364     +G4eTargetTrackLength::G4eTargetTrackLength(const double maxTrkLength )
4365     + : G4VDiscreteProcess ("G4eTargetTrackLength"), theMaximumTrackLength( maxTrkLength )
4366     +{
4367     + theType = G4eTarget_TrkL;
4368     +
4369     + G4ParticleTable::G4PTblDicIterator* theParticleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
4370     + // loop over all particles in G4ParticleTable
4371     + theParticleIterator->reset();
4372     + while( (*theParticleIterator)() ){
4373     + G4ParticleDefinition* particle = theParticleIterator->value();
4374     + G4ProcessManager* pmanager = particle->GetProcessManager();
4375     + if (!particle->IsShortLived()) {
4376     + // Add transportation process for all particles other than "shortlived"
4377     + if ( pmanager == 0) {
4378     + // Error !! no process manager
4379     + G4String particleName = particle->GetParticleName();
4380     + G4Exception("G4VUserPhysicsList::AddTransportation","No process manager",
4381     + RunMustBeAborted, particleName );
4382     + } else {
4383     + G4ProcessVector* procvec = pmanager->GetProcessList();
4384     + uint isiz = procvec->size();
4385     + G4bool processAlreadyDefined = false;
4386     + //- G4eTargetTrackLength* tlproc = 0;
4387     + for( uint ii=0; ii < isiz; ii++ ){
4388     + if( ((*procvec)[ii])->GetProcessName() == "G4eTargetTrackLength") {
4389     + pmanager->RemoveProcess( (*procvec)[ii] );
4390     + processAlreadyDefined = true;
4391     + }
4392     + }
4393     + pmanager ->AddDiscreteProcess(this);
4394     + isiz = procvec->size();
4395     + }
4396     + } else {
4397     + // shortlived particle case
4398     + }
4399     + }
4400     +
4401     +}
4402     +
4403     +//-----------------------------------------------------------------------
4404     +G4double G4eTargetTrackLength::PostStepGetPhysicalInteractionLength(
4405     + const G4Track& track,
4406     + G4double,
4407     + G4ForceCondition* condition )
4408     +{
4409     + *condition = NotForced;
4410     + return GetMeanFreePath( track, 0., condition );
4411     +
4412     +}
4413     +
4414     +
4415     +//-----------------------------------------------------------------------
4416     +G4double G4eTargetTrackLength::GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
4417     +{
4418     + return theMaximumTrackLength - track.GetTrackLength();
4419     +}
4420     +
4421     +
4422     +/*
4423     +//-----------------------------------------------------------------------
4424     +G4VParticleChange* G4eTargetTrackLength::PostStepDoIt(
4425     + const G4Track& aTrack ,
4426     + const G4Step& )
4427     +{
4428     + G4ParticleChange* aParticleChange = new G4ParticleChange;
4429     + aParticleChange->Initialize(aTrack);
4430     + return aParticleChange;
4431     +
4432     +}
4433     +*/
4434     +
4435     +
4436     +//-----------------------------------------------------------------------
4437     +void G4eTargetTrackLength::Dump( G4String msg ) const
4438     +{
4439     + G4cout << msg << "G4eTargetTrackLength: max track length = " << theMaximumTrackLength << G4endl;
4440     +
4441     +}
4442     diff -Naur --exclude CVS source/geant4e/src/G4eTrajParamFree.cc source/geant4e/src/G4eTrajParamFree.cc
4443     --- source/geant4e/src/G4eTrajParamFree.cc 1970-01-01 01:00:00.000000000 +0100
4444     +++ source/geant4e/src/G4eTrajParamFree.cc 2007-01-17 12:41:58.000000000 +0100
4445     @@ -0,0 +1,57 @@
4446     +
4447     +#include "G4eTrajParamFree.hh"
4448     +#include "G4ThreeVector.hh"
4449     +#include <iomanip>
4450     +
4451     +//------------------------------------------------------------------------
4452     +G4eTrajParamFree::G4eTrajParamFree( const G4Point3D& pos, const G4Vector3D& mom )
4453     +{
4454     + SetParameters( pos, mom );
4455     +}
4456     +
4457     +
4458     +//------------------------------------------------------------------------
4459     +void G4eTrajParamFree::SetParameters( const G4Point3D& pos, const G4Vector3D& mom )
4460     +{
4461     + fDir = mom;
4462     + fInvP = 1./mom.mag();
4463     + fLambda = 90.*deg - mom.theta();
4464     + fPhi = mom.phi();
4465     + G4Vector3D vxPerp(0.,0.,0.);
4466     + if( mom.mag() > 0.) {
4467     + vxPerp = mom/mom.mag();
4468     + }
4469     + G4Vector3D vyPerp = G4Vector3D( -vxPerp.y(), vxPerp.x(), 0.);
4470     + G4Vector3D vzPerp = vxPerp.cross( vyPerp );
4471     + // check if right handed
4472     + // fXPerp = pos.proj( mom );
4473     + G4ThreeVector posv(pos);
4474     + if( vyPerp.mag() != 0. ) {
4475     + fYPerp = posv.project( vyPerp ).mag();
4476     + fZPerp = posv.project( vzPerp ).mag();
4477     + } else {
4478     + fYPerp = 0.;
4479     + fZPerp = 0.;
4480     + }
4481     +}
4482     +
4483     +//------------------------------------------------------------------------
4484     +void G4eTrajParamFree::Update( const G4Track* aTrack )
4485     +{
4486     + SetParameters( aTrack->GetPosition(), aTrack->GetMomentum() );
4487     +
4488     +}
4489     +
4490     +
4491     +//------------------------------------------------------------------------
4492     +std::ostream& operator<<(std::ostream& out, const G4eTrajParamFree& tp)
4493     +{
4494     + // long mode = out.setf(std::ios::fixed,std::ios::floatfield);
4495     +
4496     + // out << tp.theType;
4497     + // out << std::setprecision(5) << std::setw(10);
4498     + out << std::setprecision(8) << " InvP= " << tp.fInvP << " Theta= " << tp.fLambda << " Phi= " << tp.fPhi << " YPerp= " << tp.fYPerp << " ZPerp= " << tp.fZPerp << G4endl;
4499     + out << " momentum direction= " << tp.fDir << G4endl;
4500     +
4501     + return out;
4502     +}
4503     diff -Naur --exclude CVS source/geant4e/src/G4eTrajParamOnSurface.cc source/geant4e/src/G4eTrajParamOnSurface.cc
4504     --- source/geant4e/src/G4eTrajParamOnSurface.cc 1970-01-01 01:00:00.000000000 +0100
4505     +++ source/geant4e/src/G4eTrajParamOnSurface.cc 2007-01-17 12:41:58.000000000 +0100
4506     @@ -0,0 +1,71 @@
4507     +
4508     +#include "G4eTrajParamOnSurface.hh"
4509     +#include "G4ThreeVector.hh"
4510     +#include <iomanip>
4511     +
4512     +//------------------------------------------------------------------------
4513     +G4eTrajParamOnSurface::G4eTrajParamOnSurface( const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecV, const G4Vector3D& vecW )
4514     +{
4515     + SetParameters( pos, mom, vecV, vecW );
4516     +}
4517     +
4518     +//------------------------------------------------------------------------
4519     +G4eTrajParamOnSurface::G4eTrajParamOnSurface( const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane )
4520     +{
4521     + SetParameters( pos, mom, plane );
4522     +}
4523     +
4524     +
4525     +//------------------------------------------------------------------------
4526     +void G4eTrajParamOnSurface::SetParameters( const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane )
4527     +{
4528     + //--- Get two perpendicular vectors: first parallel X (unless normal is parallel to X, then take Y)
4529     + G4ThreeVector Xvec(1.,0.,0.);
4530     + G4Vector3D vecV = -Xvec.cross(plane.normal());
4531     + if( vecV.mag() < kCarTolerance ) {
4532     + G4ThreeVector Zvec(0.,0.,1.);
4533     + vecV = Zvec.cross(plane.normal());
4534     + }
4535     +
4536     + G4Vector3D vecW = plane.normal().cross( vecV );
4537     +
4538     + SetParameters( pos, mom, vecV, vecW );
4539     +}
4540     +
4541     +
4542     +//------------------------------------------------------------------------
4543     +void G4eTrajParamOnSurface::SetParameters( const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecV, const G4Vector3D& vecW )
4544     +{
4545     + if( mom.mag() > 0. ) {
4546     + fDir = mom;
4547     + fDir /= mom.mag();
4548     + } else {
4549     + fDir = G4Vector3D(0.,0.,0.);
4550     + }
4551     + fVectorV = vecV / vecV.mag();
4552     + fVectorW = vecW / vecW.mag();
4553     + fInvP = 1./mom.mag();
4554     + G4ThreeVector posv(pos);
4555     + //check 3 vectors are ortogonal and right handed
4556     +
4557     + fPV = mom*vecV;
4558     + fPW = mom*vecW;
4559     +
4560     + fV = pos*vecV;
4561     + fW = pos*vecW;
4562     +
4563     +}
4564     +
4565     +
4566     +//------------------------------------------------------------------------
4567     +std::ostream& operator<<(std::ostream& out, const G4eTrajParamOnSurface& tp)
4568     +{
4569     + // long mode = out.setf(std::ios::fixed,std::ios::floatfield);
4570     +
4571     + // out << tp.theType;
4572     + // out << std::setprecision(5) << std::setw(10);
4573     + out << " InvP= " << tp.fInvP << " PV= " << tp.fPV << " PW= " << tp.fPW << " V= " << tp.fV << " W= " << tp.fW << G4endl;
4574     + out << " vectorV direction= " << tp.fVectorV << " vectorW direction= " << tp.fVectorW << G4endl;
4575     +
4576     + return out;
4577     +}
4578     diff -Naur --exclude CVS source/geant4e/src/G4eTrajState.cc source/geant4e/src/G4eTrajState.cc
4579     --- source/geant4e/src/G4eTrajState.cc 1970-01-01 01:00:00.000000000 +0100
4580     +++ source/geant4e/src/G4eTrajState.cc 2007-01-17 12:41:58.000000000 +0100
4581     @@ -0,0 +1,63 @@
4582     +#include "G4eTrajState.hh"
4583     +#include "G4ParticleTable.hh"
4584     +#include "G4ParticleDefinition.hh"
4585     +#include "G4eManager.hh"
4586     +
4587     +#include <iomanip>
4588     +
4589     +
4590     +//--------------------------------------------------------------------------
4591     +G4eTrajState::G4eTrajState( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4eTrajError& errmat): fParticleType(partType), fPosition(pos), fMomentum(mom), fError(errmat)
4592     +{
4593     + iverbose = G4eManager::verbose();
4594     +
4595     +}
4596     +
4597     +
4598     +//--------------------------------------------------------------------------
4599     +void G4eTrajState::UpdatePosMom( const G4Point3D& pos, const G4Vector3D& mom )
4600     +{
4601     + fPosition = pos;
4602     + fMomentum = mom;
4603     +}
4604     +
4605     +//--------------------------------------------------------------------------
4606     +void G4eTrajState::SetData( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom )
4607     +{
4608     + fParticleType = partType;
4609     + BuildCharge();
4610     + fPosition = pos;
4611     + fMomentum = mom;
4612     +}
4613     +
4614     +//--------------------------------------------------------------------------
4615     +void G4eTrajState::BuildCharge()
4616     +{
4617     + G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
4618     + G4ParticleDefinition* particle = particleTable->FindParticle(fParticleType);
4619     + if( particle == 0) {
4620     + G4Exception( "!!!EXITING: G4eTrajState::BuildCharge: particle type not defined: " + fParticleType );
4621     + }else {
4622     + fCharge = particle->GetPDGCharge();
4623     + }
4624     +}
4625     +
4626     +//------------------------------------------------------------------------
4627     +void G4eTrajState::DumpPosMomError( std::ostream& out ) const
4628     +{
4629     + out << *this;
4630     +}
4631     +
4632     +//--------------------------------------------------------------------------
4633     +std::ostream& operator<<(std::ostream& out, const G4eTrajState& ts)
4634     +{
4635     + // long mode = out.setf(std::ios::fixed,std::ios::floatfield);
4636     + out
4637     + << " G4eTrajState of type " << ts.theTSType << " : partycle: " << ts.fParticleType << " position: " << std::setw(6) << ts.fPosition
4638     + << " momentum: " << ts.fMomentum
4639     + << " error matrix ";
4640     + G4cout << ts.fError << G4endl;
4641     +
4642     + return out;
4643     +}
4644     +
4645     diff -Naur --exclude CVS source/geant4e/src/G4eTrajStateFree.cc source/geant4e/src/G4eTrajStateFree.cc
4646     --- source/geant4e/src/G4eTrajStateFree.cc 1970-01-01 01:00:00.000000000 +0100
4647     +++ source/geant4e/src/G4eTrajStateFree.cc 2007-01-17 12:41:58.000000000 +0100
4648     @@ -0,0 +1,669 @@
4649     +//
4650     +#include "G4eTrajStateFree.hh"
4651     +#include "G4eTrajParamFree.hh"
4652     +#include "G4eTrajStateOnSurface.hh"
4653     +
4654     +#include "G4Field.hh"
4655     +#include "G4FieldManager.hh"
4656     +#include "G4TransportationManager.hh"
4657     +#include "CLHEP/Matrix/Matrix.h"
4658     +#include "G4Material.hh"
4659     +#include "G4eManager.hh"
4660     +#include <iomanip>
4661     +
4662     +//------------------------------------------------------------------------
4663     +G4eTrajStateFree::G4eTrajStateFree( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4eTrajError& errmat) : G4eTrajState( partType, pos, mom, errmat )
4664     +{
4665     + // G4cout << " G4eTrajStateFree::G4eTrajStateFree: pos " << GetPosition() << std::endl;
4666     + fTrajParam = G4eTrajParamFree( pos, mom );
4667     + Init();
4668     +}
4669     +
4670     +
4671     +//------------------------------------------------------------------------
4672     +G4eTrajStateFree::G4eTrajStateFree( const G4eTrajStateOnSurface& tpSD ) : G4eTrajState( tpSD.GetParticleType(), tpSD.GetPosition(), tpSD.GetMomentum() )
4673     +{
4674     + // G4ThreeVector planeNormal = tpSD.GetPlaneNormal();
4675     + // double fPt = tpSD.GetMomentum()*planeNormal;//mom projected on normal to plane
4676     + // G4eTrajParamOnSurface tpSDparam = tpSD.GetParameters();
4677     + // G4ThreeVector Psc = fPt * planeNormal + tpSDparam.GetPU()*tpSDparam.GetVectorU() + tpSD.GetPV()*tpSD.GetVectorW();
4678     +
4679     + fTrajParam = G4eTrajParamFree( fPosition, fMomentum );
4680     + Init();
4681     +
4682     + //----- Get the error matrix in SC coordinates
4683     + G4eTrajParamOnSurface tpSDparam = tpSD.GetParameters();
4684     + double mom = fMomentum.mag();
4685     + double mom2 = fMomentum.mag2();
4686     + double TVW1 = sqrt( mom2 / ( mom2 + tpSDparam.GetPV()*tpSDparam.GetPV() + tpSDparam.GetPV()*tpSDparam.GetPV()) );
4687     + G4ThreeVector vTVW( TVW1, tpSDparam.GetPV()/mom * TVW1, tpSDparam.GetPW()/mom * TVW1 );
4688     + G4Vector3D vectorU = tpSDparam.GetVectorV().cross( tpSDparam.GetVectorW() );
4689     + G4Vector3D vTN = vTVW.x()*vectorU + vTVW.y()*tpSDparam.GetVectorV() + vTVW.z()*tpSDparam.GetVectorW();
4690     +
4691     + double pc2 = asin( vTN.z() );
4692     + double pc3 = atan (vTN.y()/vTN.x());
4693     +
4694     +#ifdef G4EVERBOSE
4695     + if( iverbose >= 5){
4696     + std::cout << " CHECK: pc2 " << pc2 << " = " << GetParameters().GetLambda() << " diff " << pc2-GetParameters().GetLambda() << std::endl;
4697     + std::cout << " CHECK: pc3 " << pc3 << " = " << GetParameters().GetPhi() << " diff " << pc3-GetParameters().GetPhi() << std::endl;
4698     + }
4699     +#endif
4700     +
4701     + //--- Get the unit vectors perp to P
4702     + double cosl = cos( GetParameters().GetLambda() );
4703     + if (cosl < 1.E-30) cosl = 1.E-30;
4704     + double cosl1 = 1./cosl;
4705     + G4Vector3D vUN(-vTN.y()*cosl1, vTN.x()*cosl1, 0. );
4706     + G4Vector3D vVN(-vTN.z()*vUN.y(), vTN.z()*vUN.x(), cosl );
4707     +
4708     + G4Vector3D vUperp = G4Vector3D( -fMomentum.y(), fMomentum.x(), 0.);
4709     + G4Vector3D vVperp = vUperp.cross( fMomentum );
4710     + vUperp *= 1./vUperp.mag();
4711     + vVperp *= 1./vVperp.mag();
4712     +
4713     +#ifdef G4EVERBOSE
4714     + if( iverbose >= 5){
4715     + std::cout << " CHECK: vUN " << vUN << " = " << vUperp << " diff " << (vUN-vUperp).mag() << std::endl;
4716     + std::cout << " CHECK: vVN " << vVN << " = " << vVperp << " diff " << (vVN-vVperp).mag() << std::endl;
4717     + }
4718     +#endif
4719     +
4720     + //get the dot products of vectors perpendicular to direction and vector defining SD plane
4721     + double dUU = vUperp * tpSD.GetVectorV();
4722     + double dUV = vUperp * tpSD.GetVectorW();
4723     + double dVU = vVperp * tpSD.GetVectorV();
4724     + double dVV = vVperp * tpSD.GetVectorW();
4725     +
4726     +
4727     + //--- Get transformation first
4728     + HepMatrix transfM(5, 5, 1 );
4729     + //--- Get magnetic field
4730     + const G4Field* field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
4731     + G4ThreeVector dir = fTrajParam.GetDirection();
4732     + G4double invCosTheta = 1./cos( dir.theta() );
4733     +
4734     + if( fCharge != 0
4735     +&& field ) {
4736     + G4double pos1[3]; pos1[0] = fPosition.x()*cm; pos1[1] = fPosition.y()*cm; pos1[2] = fPosition.z()*cm;
4737     + G4double h1[3];
4738     + field->GetFieldValue( pos1, h1 );
4739     + G4ThreeVector HPre = G4ThreeVector( h1[0], h1[1], h1[2] ) / tesla *10.;
4740     + G4double magHPre = HPre.mag();
4741     + G4double invP = 1./fMomentum.mag();
4742     + G4double magHPreM = magHPre * invP;
4743     + if( magHPre != 0. ) {
4744     + G4double magHPreM2 = fCharge / magHPre;
4745     +
4746     + G4double Q = -magHPreM * c_light;
4747     + G4double sinz = -HPre*vUperp * magHPreM2;
4748     + G4double cosz = HPre*vVperp * magHPreM2;
4749     +
4750     + transfM[1][3] = -Q*dir.y()*sinz;
4751     + transfM[1][4] = -Q*dir.z()*sinz;
4752     + transfM[2][3] = -Q*dir.y()*cosz*invCosTheta;
4753     + transfM[2][4] = -Q*dir.z()*cosz*invCosTheta;
4754     + }
4755     + }
4756     +
4757     + transfM[0][0] = 1.;
4758     + transfM[1][1] = dir.x()*dVU;
4759     + transfM[1][2] = dir.x()*dVV;
4760     + transfM[2][1] = dir.x()*dUU*invCosTheta;
4761     + transfM[2][2] = dir.x()*dUV*invCosTheta;
4762     + transfM[3][3] = dUU;
4763     + transfM[3][4] = dUV;
4764     + transfM[4][3] = dVU;
4765     + transfM[4][4] = dVV;
4766     +
4767     + fError = G4eTrajError( tpSD.GetError().similarity( transfM ) );
4768     +
4769     +#ifdef G4EVERBOSE
4770     + if( iverbose >= 1) std::cout << "error matrix SD2SC " << fError << std::endl;
4771     + if( iverbose >= 4) std::cout << "G4eTrajStateFree from SD " << *this << std::endl;
4772     +#endif
4773     +}
4774     +
4775     +
4776     +//------------------------------------------------------------------------
4777     +void G4eTrajStateFree::Init()
4778     +{
4779     + theTSType = G4eTS_FREE;
4780     + BuildCharge();
4781     + theTransfMat = HepMatrix(5,5,0);
4782     + //- theFirstStep = true;
4783     +}
4784     +
4785     +//------------------------------------------------------------------------
4786     +void G4eTrajStateFree::Dump( std::ostream& out ) const
4787     +{
4788     + out << *this;
4789     +}
4790     +
4791     +//------------------------------------------------------------------------
4792     +G4int G4eTrajStateFree::Update( const G4Track* aTrack )
4793     +{
4794     + G4int ierr = 0;
4795     + fTrajParam.Update( aTrack );
4796     + UpdatePosMom( aTrack->GetPosition(), aTrack->GetMomentum() );
4797     + return ierr;
4798     +
4799     +}
4800     +
4801     +
4802     +//------------------------------------------------------------------------
4803     +std::ostream& operator<<(std::ostream& out, const G4eTrajStateFree& ts)
4804     +{
4805     + out.setf(std::ios::fixed,std::ios::floatfield);
4806     +
4807     +
4808     + ts.DumpPosMomError( out );
4809     +
4810     + out << " G4eTrajStateFree: Params: " << ts.fTrajParam << std::endl;
4811     +
4812     + return out;
4813     +
4814     +}
4815     +
4816     +
4817     +//------------------------------------------------------------------------
4818     +int G4eTrajStateFree::PropagateError( const G4Track* aTrack )
4819     +{
4820     + G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
4821     + //- if( G4eManager::GetG4eManager()->GetMode() == G4eMode_PropBackwards ) stepLengthCm*= -1;
4822     + if( fabs(stepLengthCm) <= kCarTolerance/cm ) return 0;
4823     +
4824     +#ifdef G4EVERBOSE
4825     + if( iverbose >= 2 )std::cout << " G4eTrajStateFree::PropagateError " << std::endl;
4826     +#endif
4827     +
4828     + // * *** ERROR PROPAGATION ON A HELIX ASSUMING SC VARIABLES
4829     + G4Point3D vposPost = aTrack->GetPosition()/cm;
4830     + G4Vector3D vpPost = aTrack->GetMomentum()/GeV;
4831     + // G4Point3D vposPre = fPosition/cm;
4832     + // G4Vector3D vpPre = fMomentum/GeV;
4833     + G4Point3D vposPre = aTrack->GetStep()->GetPreStepPoint()->GetPosition()/cm;
4834     + G4Vector3D vpPre = aTrack->GetStep()->GetPreStepPoint()->GetMomentum()/GeV;
4835     + //correct to avoid propagation along Z
4836     + if( vpPre.mag() == vpPre.z() ) vpPre.setX( 1.E-6*MeV );
4837     + if( vpPost.mag() == vpPost.z() ) vpPost.setX( 1.E-6*MeV );
4838     +
4839     + G4double pPre = vpPre.mag();
4840     + G4double pPost = vpPost.mag();
4841     +#ifdef G4EVERBOSE
4842     + if( iverbose >= 2 ) {
4843     + std::cout << "G4EP: vposPre " << vposPre << std::endl
4844     + << "G4EP: vposPost " << vposPost << std::endl;
4845     + std::cout << "G4EP: vpPre " << vpPre << std::endl
4846     + << "G4EP: vpPost " << vpPost << std::endl;
4847     + std::cout << " err start step " << fError << std::endl;
4848     + std::cout << "G4EP: stepLengthCm " << stepLengthCm << std::endl;
4849     + }
4850     +#endif
4851     +
4852     + if( pPre == 0. || pPost == 0 ) return 2;
4853     + G4double pInvPre = 1./pPre;
4854     + G4double pInvPost = 1./pPost;
4855     + G4double deltaPInv = pInvPost - pInvPre;
4856     +
4857     + G4Vector3D vpPreNorm = vpPre * pInvPre;
4858     + G4Vector3D vpPostNorm = vpPost * pInvPost;
4859     + // if( iverbose >= 2 ) std::cout << "G4EP: vpPreNorm " << vpPreNorm << " vpPostNorm " << vpPostNorm << std::endl;
4860     + //return if propagation along Z??
4861     + if( 1. - fabs(vpPostNorm.z()) < kCarTolerance ) return 4;
4862     + G4double sinpPre = sin( vpPreNorm.theta() ); //cosine perpendicular to pPre = sine pPre
4863     + G4double sinpPost = sin( vpPostNorm.theta() ); //cosine perpendicular to pPost = sine pPost
4864     + G4double sinpPostInv = 1./sin( vpPreNorm.theta() );
4865     +
4866     +#ifdef G4EVERBOSE
4867     + if( iverbose >= 2 ) std::cout << "G4EP: cosl " << sinpPre << " cosl0 " << sinpPost << std::endl;
4868     +#endif
4869     + //* *** DEFINE TRANSFORMATION MATRIX BETWEEN X1 AND X2 FOR
4870     + //* *** NEUTRAL PARTICLE OR FIELDFREE REGION
4871     + HepMatrix transf(5, 5, 0 );
4872     +
4873     + transf[3][2] = stepLengthCm * sinpPost;
4874     + transf[4][1] = stepLengthCm;
4875     + for( uint ii=0;ii < 5; ii++ ){
4876     + transf[ii][ii] = 1.;
4877     + }
4878     +#ifdef G4EVERBOSE
4879     + if( iverbose >= 2 ) {
4880     + std::cout << "G4EP: transf matrix neutral " << transf;
4881     + }
4882     +#endif
4883     +
4884     + // charge X propagation direction
4885     + G4double charge = aTrack->GetDynamicParticle()->GetCharge();
4886     + if( G4eManager::GetG4eManager()->GetMode() == G4eMode_PropBackwards ) {
4887     + charge *= -1.;
4888     + }
4889     + // std::cout << " charge " << charge << std::endl;
4890     + //t check if particle has charge
4891     + //t if( charge == 0 ) goto 45;
4892     + // check if the magnetic field is = 0.
4893     +
4894     + //position is from geant4, it is assumed to be in mm (for debugging, eventually it will not be transformed)
4895     + G4double pos1[3]; pos1[0] = vposPre.x()*cm; pos1[1] = vposPre.y()*cm; pos1[2] = vposPre.z()*cm;
4896     + G4double pos2[3]; pos2[0] = vposPost.x()*cm; pos2[1] = vposPost.y()*cm; pos2[2] = vposPost.z()*cm;
4897     + G4double h1[3], h2[3];
4898     +
4899     + const G4Field* field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
4900     + if( !field ) return 0; //goto 45
4901     +
4902     + // calculate transformation except it NEUTRAL PARTICLE OR FIELDFREE REGION
4903     + if( charge != 0. && field ) {
4904     +
4905     + field->GetFieldValue( pos1, h1 );
4906     + field->GetFieldValue( pos2, h2 );
4907     + G4ThreeVector HPre = G4ThreeVector( h1[0], h1[1], h1[2] ) / tesla *10.; //10. is to get same dimensions as GEANT3 (kilogauss)
4908     + G4ThreeVector HPost= G4ThreeVector( h2[0], h2[1], h2[2] ) / tesla *10.;
4909     + G4double magHPre = HPre.mag();
4910     + G4double magHPost = HPost.mag();
4911     +#ifdef G4EVERBOSE
4912     + if( iverbose >= 2 ) std::cout << "G4EP: HPre " << HPre << std::endl
4913     + << "G4EP: HPost " << HPost << std::endl;
4914     +#endif
4915     +
4916     + if( magHPre + magHPost != 0. ) {
4917     +
4918     + //* *** CHECK WHETHER H*ALFA/P IS TOO DIFFERENT AT X1 AND X2
4919     + G4double gam;
4920     + if( magHPost != 0. ){
4921     + gam = HPost * vpPostNorm / magHPost;
4922     + }else {
4923     + gam = HPre * vpPreNorm / magHPre;
4924     + }
4925     +
4926     + // G4eMagneticLimitsProcess will limit the step, but based on an straight line trajectory
4927     + G4double alphaSqr = 1. - gam * gam;
4928     + G4double diffHSqr = ( HPre * pInvPre - HPost * pInvPost ).mag2();
4929     + G4double delhp6Sqr = 300.*300.;
4930     +#ifdef G4EVERBOSE
4931     + if( iverbose >= 2 ) std::cout << " G4EP: gam " << gam << " alphaSqr " << alphaSqr << " diffHSqr " << diffHSqr << std::endl;
4932     +#endif
4933     + if( diffHSqr * alphaSqr > delhp6Sqr ) return 3;
4934     +
4935     +
4936     + //* *** DEFINE AVERAGE MAGNETIC FIELD AND GRADIENT
4937     + G4double pInvAver = 1./(pInvPre + pInvPost );
4938     + G4double CFACT8 = 2.997925E-4;
4939     + //G4double HAver
4940     + G4ThreeVector vHAverNorm( (HPre*pInvPre + HPost*pInvPost ) * pInvAver * charge * CFACT8 );
4941     + G4double HAver = vHAverNorm.mag();
4942     + G4double invHAver = 1./HAver;
4943     + vHAverNorm *= invHAver;
4944     +#ifdef G4EVERBOSE
4945     + if( iverbose >= 2 ) std::cout << " G4EP: HaverNorm " << vHAverNorm << " magHAver " << HAver << " charge " << charge<< std::endl;
4946     +#endif
4947     +
4948     + G4double pAver = (pPre+pPost)*0.5;
4949     + G4double QAver = -HAver/pAver;
4950     + G4double thetaAver = QAver * stepLengthCm;
4951     + G4double sinThetaAver = sin(thetaAver);
4952     + G4double cosThetaAver = cos(thetaAver);
4953     + G4double gamma = vHAverNorm * vpPostNorm;
4954     + G4ThreeVector AN2 = vHAverNorm.cross( vpPostNorm );
4955     +
4956     +#ifdef G4EVERBOSE
4957     + if( iverbose >= 2 ) std::cout << " G4EP: AN2 " << AN2 << std::endl;
4958     +#endif
4959     + G4double AU = 1./vpPreNorm.perp();
4960     + //t G4ThreeVector vU( vpPreNorm.cross( G4ThreeVector(0.,0.,1.) ) * AU );
4961     + G4ThreeVector vUPre( -AU*vpPreNorm.y(),
4962     + AU*vpPreNorm.x(),
4963     + 0. );
4964     + G4ThreeVector vVPre( -vpPreNorm.z()*vUPre.y(),
4965     + vpPreNorm.z()*vUPre.x(),
4966     + vpPreNorm.x()*vUPre.y() - vpPreNorm.y()*vUPre.x() );
4967     +
4968     + //
4969     + AU = 1./vpPostNorm.perp();
4970     + //t G4ThreeVector vU( vpPostNorm.cross( G4ThreeVector(0.,0.,1.) ) * AU );
4971     + G4ThreeVector vUPost( -AU*vpPostNorm.y(),
4972     + AU*vpPostNorm.x(),
4973     + 0. );
4974     + G4ThreeVector vVPost( -vpPostNorm.z()*vUPost.y(),
4975     + vpPostNorm.z()*vUPost.x(),
4976     + vpPostNorm.x()*vUPost.y() - vpPostNorm.y()*vUPost.x() );
4977     +#ifdef G4EVERBOSE
4978     + //- std::cout << " vpPostNorm " << vpPostNorm << std::endl;
4979     + if( iverbose >= 2 ) std::cout << " G4EP: AU " << AU << " vUPre " << vUPre << " vVPre " << vVPre << " vUPost " << vUPost << " vVPost " << vVPost << std::endl;
4980     +#endif
4981     + G4Point3D deltaPos( vposPre - vposPost );
4982     +
4983     + // * *** COMPLETE TRANSFORMATION MATRIX BETWEEN ERRORS AT X1 AND X2
4984     + // * *** FIELD GRADIENT PERPENDICULAR TO TRACK IS PRESENTLY NOT
4985     + // * *** TAKEN INTO ACCOUNT
4986     +
4987     + G4double QP = QAver * pAver; // = -HAver
4988     +#ifdef G4EVERBOSE
4989     + if( iverbose >= 2) std::cout << " G4EP: QP " << QP << " QAver " << QAver << " pAver " << pAver << std::endl;
4990     +#endif
4991     + G4double ANV = -( vHAverNorm.x()*vUPost.x() + vHAverNorm.y()*vUPost.y() );
4992     + G4double ANU = ( vHAverNorm.x()*vVPost.x() + vHAverNorm.y()*vVPost.y() + vHAverNorm.z()*vVPost.z() );
4993     + G4double OMcosThetaAver = 1. - cosThetaAver;
4994     +#ifdef G4EVERBOSE
4995     + if( iverbose >= 2) std::cout << "G4EP: OMcosThetaAver " << OMcosThetaAver << " cosThetaAver " << cosThetaAver << " thetaAver " << thetaAver << " QAver " << QAver << " stepLengthCm " << stepLengthCm << std::endl;
4996     +#endif
4997     + G4double TMSINT = thetaAver - sinThetaAver;
4998     +#ifdef G4EVERBOSE
4999     + if( iverbose >= 2 ) std::cout << " G4EP: ANV " << ANV << " ANU " << ANU << std::endl;
5000     +#endif
5001     +
5002     + G4ThreeVector vHUPre( -vHAverNorm.z() * vUPre.y(),
5003     + vHAverNorm.z() * vUPre.x(),
5004     + vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x() );
5005     +#ifdef G4EVERBOSE
5006     + // if( iverbose >= 2 ) std::cout << "G4EP: HUPre(1) " << vHUPre.x() << " " << vHAverNorm.z() << " " << vUPre.y() << std::endl;
5007     +#endif
5008     + G4ThreeVector vHVPre( vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(),
5009     + vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(),
5010     + vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x() );
5011     +#ifdef G4EVERBOSE
5012     + if( iverbose >= 2 ) std::cout << " G4EP: HUPre " << vHUPre << " HVPre " << vHVPre << std::endl;
5013     +#endif
5014     +
5015     + //------------------- COMPUTE MATRIX
5016     + //---------- 1/P
5017     +
5018     + transf[0][0] = 1.-deltaPInv*pAver*(1.+(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())/stepLengthCm)
5019     + +2.*deltaPInv*pAver;
5020     +
5021     + transf[0][1] = -deltaPInv/thetaAver*
5022     + ( TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) +
5023     + sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
5024     + OMcosThetaAver*(vHVPre.x()*vpPostNorm.x()+vHVPre.y()*vpPostNorm.y()+vHVPre.z()*vpPostNorm.z()) );
5025     +
5026     + transf[0][2] = -sinpPre*deltaPInv/thetaAver*
5027     + ( TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) +
5028     + sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
5029     + OMcosThetaAver*(vHUPre.x()*vpPostNorm.x()+vHUPre.y()*vpPostNorm.y()+vHUPre.z()*vpPostNorm.z()) );
5030     +
5031     + transf[0][3] = -deltaPInv/stepLengthCm*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
5032     +
5033     + transf[0][4] = -deltaPInv/stepLengthCm*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
5034     +
5035     + // *** Lambda
5036     + transf[1][0] = -QP*ANV*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())
5037     + *(1.+deltaPInv*pAver);
5038     +#ifdef G4EVERBOSE
5039     + if(iverbose >= 3) std::cout << "ctransf10= " << transf[1][0] << " " << -QP<< " " << ANV<< " " << vpPostNorm.x()<< " " << deltaPos.x()<< " " << vpPostNorm.y()<< " " << deltaPos.y()<< " " << vpPostNorm.z()<< " " << deltaPos.z()
5040     + << " " << deltaPInv<< " " << pAver << std::endl;
5041     +#endif
5042     +
5043     + transf[1][1] = cosThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
5044     + sinThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
5045     + OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
5046     + (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
5047     + ANV*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
5048     + OMcosThetaAver*(vVPre.x()*AN2.x()+vVPre.y()*AN2.y()+vVPre.z()*AN2.z()) -
5049     + TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
5050     +
5051     + transf[1][2] = cosThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
5052     + sinThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
5053     + OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
5054     + (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
5055     + ANV*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
5056     + OMcosThetaAver*(vUPre.x()*AN2.x()+vUPre.y()*AN2.y() ) -
5057     + TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
5058     + transf[1][2] = sinpPre*transf[1][3];
5059     +
5060     + transf[1][3] = -QAver*ANV*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
5061     +
5062     + transf[1][4] = -QAver*ANV*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
5063     +
5064     + // *** Phi
5065     +
5066     + transf[2][0] = -QP*ANU*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())*sinpPostInv
5067     + *(1.+deltaPInv*pAver);
5068     +#ifdef G4EVERBOSE
5069     + if(iverbose >= 3)std::cout <<"ctransf20= " << transf[2][0] <<" "<< -QP<<" "<<ANU<<" "<<vpPostNorm.x()<<" "<<deltaPos.x()<<" "<<vpPostNorm.y()<<" "<<deltaPos.y()<<" "<<vpPostNorm.z()<<" "<<deltaPos.z()<<" "<<sinpPostInv
5070     + <<" "<<deltaPInv<<" "<<pAver<< std::endl;
5071     +#endif
5072     + transf[2][1] = cosThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
5073     + sinThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
5074     + OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
5075     + (vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
5076     + ANU*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
5077     + OMcosThetaAver*(vVPre.x()*AN2.x()+vVPre.y()*AN2.y()+vVPre.z()*AN2.z()) -
5078     + TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
5079     + transf[2][1] = sinpPostInv*transf[2][1];
5080     +
5081     + transf[2][2] = cosThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
5082     + sinThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
5083     + OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
5084     + (vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
5085     + ANU*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
5086     + OMcosThetaAver*(vUPre.x()*AN2.x()+vUPre.y()*AN2.y() ) -
5087     + TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
5088     + transf[2][2] = sinpPostInv*sinpPre*transf[2][2];
5089     +
5090     + transf[2][3] = -QAver*ANU*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() )*sinpPostInv;
5091     +#ifdef G4EVERBOSE
5092     + if(iverbose >= 3)std::cout <<"ctransf23= " << transf[2][3] <<" "<< -QAver<<" "<<ANU<<" "<<vUPre.x()<<" "<<vpPostNorm.x()<<" "<< vUPre.y()<<" "<<vpPostNorm.y()<<" "<<sinpPostInv<<std::endl;
5093     +#endif
5094     +
5095     + transf[2][4] = -QAver*ANU*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z())*sinpPostInv;
5096     +
5097     + // *** Yt
5098     +
5099     + transf[3][0] = pAver*(vUPost.x()*deltaPos.x()+vUPost.y()*deltaPos.y() )
5100     + *(1.+deltaPInv*pAver);
5101     +#ifdef G4EVERBOSE
5102     + if(iverbose >= 3) std::cout <<"ctransf30= " << transf[3][0] <<" "<< pAver<<" "<<vUPost.x()<<" "<<deltaPos.x()<<" "<<vUPost.y()<<" "<<deltaPos.y()
5103     + <<" "<<deltaPInv<<" "<<pAver<<std::endl;
5104     +#endif
5105     +
5106     + transf[3][1] = ( sinThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
5107     + OMcosThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
5108     + TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
5109     + (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
5110     +
5111     + transf[3][2] = ( sinThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
5112     + OMcosThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
5113     + TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
5114     + (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
5115     +#ifdef G4EVERBOSE
5116     + if(iverbose >= 3) std::cout <<"ctransf32= " << transf[3][2] <<" "<< sinThetaAver<<" "<<vUPre.x()<<" "<<vUPost.x()<<" "<<vUPre.y()<<" "<<vUPost.y() <<" "<<
5117     + OMcosThetaAver<<" "<<vHUPre.x()<<" "<<vUPost.x()<<" "<<vHUPre.y()<<" "<<vUPost.y() <<" "<<
5118     + TMSINT<<" "<<vHAverNorm.x()<<" "<<vUPost.x()<<" "<<vHAverNorm.y()<<" "<<vUPost.y() <<" "<<
5119     + vHAverNorm.x()<<" "<<vUPre.x()<<" "<<vHAverNorm.y()<<" "<<vUPre.y() <<" "<<sinpPre<<" "<<QAver<<std::endl;
5120     +#endif
5121     +
5122     + transf[3][3] = (vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() );
5123     +
5124     + transf[3][4] = (vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() );
5125     +
5126     + // *** Zt
5127     + transf[4][0] = pAver*(vVPost.x()*deltaPos.x()+vVPost.y()*deltaPos.y()+vVPost.z()*deltaPos.z())
5128     + *(1.+deltaPInv*pAver);
5129     +
5130     + transf[4][1] = ( sinThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
5131     + OMcosThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
5132     + TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
5133     + (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
5134     +#ifdef G4EVERBOSE
5135     + if(iverbose >= 3)std::cout <<"ctransf41= " << transf[4][1] <<" "<< sinThetaAver<<" "<< OMcosThetaAver <<" "<<TMSINT<<" "<< vVPre <<" "<<vVPost <<" "<<vHVPre<<" "<<vHAverNorm <<" "<< QAver<<std::endl;
5136     +#endif
5137     +
5138     + transf[4][2] = ( sinThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
5139     + OMcosThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
5140     + TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
5141     + (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
5142     +
5143     + transf[4][3] = (vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() );
5144     +
5145     + transf[4][4] = (vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z());
5146     + // if(iverbose >= 3) std::cout <<"ctransf44= " << transf[4][4] <<" "<< vVPre.x() <<" "<<vVPost.x() <<" "<< vVPre.y() <<" "<< vVPost.y() <<" "<< vVPre.z() <<" "<< vVPost.z() << std::endl;
5147     +
5148     +
5149     +#ifdef G4EVERBOSE
5150     + if( iverbose >= 1 ) std::cout << "G4EP: transf matrix computed " << transf << std::endl;
5151     +#endif
5152     + /* for( int ii=0;ii<5;ii++){
5153     + for( int jj=0;jj<5;jj++){
5154     + std::cout << transf[ii][jj] << " ";
5155     + }
5156     + std::cout << std::endl;
5157     + } */
5158     + }
5159     + }
5160     + // end of calculate transformation except it NEUTRAL PARTICLE OR FIELDFREE REGION
5161     + /* if( iverbose >= 1 ) std::cout << "G4EP: transf not updated but initialized " << theFirstStep << std::endl;
5162     + if( theFirstStep ) {
5163     + theTransfMat = transf;
5164     + theFirstStep = false;
5165     + }else{
5166     + theTransfMat = theTransfMat * transf;
5167     + if( iverbose >= 1 ) std::cout << "G4EP: transf matrix accumulated" << theTransfMat << std::endl;
5168     + }
5169     + */
5170     + theTransfMat = transf;
5171     +#ifdef G4EVERBOSE
5172     + if( iverbose >= 1 ) std::cout << "G4EP: error matrix before transformation " << fError << std::endl;
5173     + if( iverbose >= 2 ) std::cout << " tf * err " << theTransfMat * fError << std::endl
5174     + << " transf matrix " << theTransfMat.T() << std::endl;
5175     +#endif
5176     +
5177     + fError = fError.similarity(theTransfMat).T();
5178     + //- fError = transf * fError * transf.T();
5179     +#ifdef G4EVERBOSE
5180     + if( iverbose >= 1 ) std::cout << "G4EP: error matrix propagated " << fError << std::endl;
5181     +#endif
5182     +
5183     + //? S = B*S*BT S.similarity(B)
5184     + //? R = S
5185     + // not needed * *** TRANSFORM ERROR MATRIX FROM INTERNAL TO EXTERNAL VARIABLES;
5186     +
5187     + PropagateErrorMSC( aTrack );
5188     +
5189     + PropagateErrorIoni( aTrack );
5190     +
5191     + return 0;
5192     +}
5193     +
5194     +
5195     +//------------------------------------------------------------------------
5196     +int G4eTrajStateFree::PropagateErrorMSC( const G4Track* aTrack )
5197     +{
5198     + G4ThreeVector vpPre = aTrack->GetMomentum()/GeV;
5199     + G4double pPre = vpPre.mag();
5200     + G4double pBeta = pPre*pPre / (aTrack->GetTotalEnergy()/GeV);
5201     + G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
5202     +
5203     + G4Material* mate = aTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
5204     + G4double effZ, effA;
5205     + CalculateEffectiveZandA( mate, effZ, effA );
5206     +
5207     +#ifdef G4EVERBOSE
5208     + if( iverbose >= 4 ) std::cout << "material " << mate->GetName()
5209     + //<< " " << mate->GetZ() << " " << mate->GetA()
5210     + << " " << effZ << " " << effA
5211     + << " " << mate->GetDensity()/g*mole << " " << mate->GetRadlen()/cm << " " << mate->GetNuclearInterLength()/cm << std::endl;
5212     +#endif
5213     +
5214     + G4double RI = stepLengthCm / (aTrack->GetVolume()->GetLogicalVolume()->GetMaterial()->GetRadlen()/cm);
5215     +#ifdef G4EVERBOSE
5216     + if( iverbose >= 4 ) std::cout << std::setprecision(6) << std::setw(6) << "G4EP:MSC: RI " << RI << " stepLengthCm " << stepLengthCm << " radlen " << (aTrack->GetVolume()->GetLogicalVolume()->GetMaterial()->GetRadlen()/cm) << " " << RI*1.e10 << std::endl;
5217     +#endif
5218     + G4double charge = aTrack->GetDynamicParticle()->GetCharge();
5219     + G4double DD = 1.8496E-4*RI*(charge/pBeta * charge/pBeta );
5220     +#ifdef G4EVERBOSE
5221     + if( iverbose >= 3 ) std::cout << "G4EP:MSC: D*1E6= " << DD*1.E6 <<" pBeta " << pBeta << std::endl;
5222     +#endif
5223     + G4double S1 = DD*stepLengthCm*stepLengthCm/3.;
5224     + G4double S2 = DD;
5225     + G4double S3 = DD*stepLengthCm/2.;
5226     +
5227     + G4double CLA = sqrt( vpPre.x() * vpPre.x() + vpPre.y() * vpPre.y() )/pPre;
5228     +#ifdef G4EVERBOSE
5229     + if( iverbose >= 2 ) std::cout << std::setw(6) << "G4EP:MSC: RI " << RI << " S1 " << S1 << " S2 " << S2 << " S3 " << S3 << " CLA " << CLA << std::endl;
5230     +#endif
5231     + fError[1][1] += S2;
5232     + fError[1][4] -= S3;
5233     + fError[2][2] += S2/CLA/CLA;
5234     + fError[2][3] += S3/CLA;
5235     + fError[3][3] += S1;
5236     + fError[4][4] += S1;
5237     +
5238     +#ifdef G4EVERBOSE
5239     + if( iverbose >= 2 ) std::cout << "G4EP:MSC: error matrix propagated msc " << fError << std::endl;
5240     +#endif
5241     +
5242     + return 0;
5243     +}
5244     +
5245     +
5246     +//------------------------------------------------------------------------
5247     +void G4eTrajStateFree::CalculateEffectiveZandA( const G4Material* mate, double& effZ, double& effA )
5248     +{
5249     + effZ = 0.;
5250     + effA = 0.;
5251     + G4int ii, nelem = mate->GetNumberOfElements();
5252     + const G4double* fracVec = mate->GetFractionVector();
5253     + for(ii=0; ii < nelem; ii++ ) {
5254     + effZ += mate->GetElement( ii )->GetZ() * fracVec[ii];
5255     + effA += mate->GetElement( ii )->GetA() * fracVec[ii] /g*mole;
5256     + }
5257     +
5258     +}
5259     +
5260     +
5261     +//------------------------------------------------------------------------
5262     +int G4eTrajStateFree::PropagateErrorIoni( const G4Track* aTrack )
5263     +{
5264     + G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
5265     + G4double DEDX2;
5266     + if( stepLengthCm < 1.E-7 ) {
5267     + DEDX2=0.;
5268     + }
5269     + // * Calculate xi factor (KeV).
5270     + G4Material* mate = aTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
5271     + G4double effZ, effA;
5272     + CalculateEffectiveZandA( mate, effZ, effA );
5273     +
5274     + G4double Etot = aTrack->GetTotalEnergy()/GeV;
5275     + G4double beta = aTrack->GetMomentum().mag()/GeV / Etot;
5276     + G4double mass = aTrack->GetDynamicParticle()->GetMass() / GeV;
5277     + G4double gamma = Etot / mass;
5278     +
5279     + // * Calculate xi factor (KeV).
5280     + G4double XI = 153.5*effZ*stepLengthCm*(mate->GetDensity()/mg*mole) /
5281     + (effA*beta*beta);
5282     +
5283     +#ifdef G4EVERBOSE
5284     + if( iverbose >= 2 ){
5285     + std::cout << "G4EP:IONI: XI " << XI << " beta " << beta << " gamma " << gamma << std::endl;
5286     + std::cout << " density " << (mate->GetDensity()/mg*mole) << " effA " << effA << " step " << stepLengthCm << std::endl;
5287     + }
5288     +#endif
5289     + // * Maximum energy transfer to atomic electron (KeV).
5290     + G4double eta = beta*gamma;
5291     + G4double etasq = eta*eta;
5292     + G4double eMass = 0.51099906/GeV;
5293     + G4double massRatio = eMass / mass;
5294     + G4double F1 = 2*eMass*etasq;
5295     + G4double F2 = 1. + 2. * massRatio * gamma + massRatio * massRatio;
5296     + G4double Emax = 1.E+6*F1/F2;
5297     +
5298     + // * *** and now sigma**2 in GeV
5299     + G4double dedxSq = XI*Emax*(1.-(beta*beta/2.))*1.E-12;
5300     +#ifdef G4EVERBOSE
5301     + if( iverbose >= 2 ) std::cout << "G4EP:IONI: DEDX2 " << dedxSq << " emass " << eMass << " Emax " << Emax << std::endl;
5302     +#endif
5303     +
5304     + // if( iverbose >= 2 ) std::cout << "G4EP:IONI: Etot " << Etot << " DEDX2 " << dedxSq << " emass " << eMass << std::endl;
5305     +
5306     + G4double pPre6 = (aTrack->GetStep()->GetPreStepPoint()->GetMomentum()/GeV).mag();
5307     + pPre6 = pow(pPre6, 6 );
5308     + //Apply it to error
5309     + fError[0][0] += Etot*Etot*dedxSq / pPre6;
5310     +#ifdef G4EVERBOSE
5311     + if( iverbose >= 2 ) std::cout << "G4:IONI getot " << Etot << " dedx2 " << dedxSq << " p " << pPre6 << std::endl;
5312     + if( iverbose >= 2 ) std::cout << "G4EP:IONI: error_from_ionisation " << (Etot*Etot*dedxSq) / pPre6 << std::endl;
5313     +#endif
5314     +
5315     + return 0;
5316     +}
5317     +
5318     diff -Naur --exclude CVS source/geant4e/src/G4eTrajStateOnSurface.cc source/geant4e/src/G4eTrajStateOnSurface.cc
5319     --- source/geant4e/src/G4eTrajStateOnSurface.cc 1970-01-01 01:00:00.000000000 +0100
5320     +++ source/geant4e/src/G4eTrajStateOnSurface.cc 2007-01-17 12:41:58.000000000 +0100
5321     @@ -0,0 +1,178 @@
5322     +#include "G4eTrajStateOnSurface.hh"
5323     +#include "G4eManager.hh"
5324     +
5325     +#include "G4Field.hh"
5326     +#include "G4FieldManager.hh"
5327     +#include "G4TransportationManager.hh"
5328     +
5329     +#include "CLHEP/Matrix/Matrix.h"
5330     +#include <iomanip>
5331     +
5332     +
5333     +//------------------------------------------------------------------------
5334     +G4eTrajStateOnSurface::G4eTrajStateOnSurface( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4Vector3D& vecU, const G4Vector3D& vecV, const G4eTrajError& errmat) : G4eTrajState( partType, pos, mom, errmat )
5335     +{
5336     + Init();
5337     + fTrajParam = G4eTrajParamOnSurface( pos, mom, vecU, vecV );
5338     +}
5339     +
5340     +//------------------------------------------------------------------------
5341     +G4eTrajStateOnSurface::G4eTrajStateOnSurface( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4Plane3D& plane, const G4eTrajError& errmat ): G4eTrajState( partType, pos, mom, errmat )
5342     +{
5343     + Init();
5344     + fTrajParam = G4eTrajParamOnSurface( pos, mom, plane );
5345     +
5346     +}
5347     +
5348     +
5349     +//------------------------------------------------------------------------
5350     +G4eTrajStateOnSurface::G4eTrajStateOnSurface( G4eTrajStateFree& tpSC, const G4Plane3D& plane ): G4eTrajState( tpSC.GetParticleType(), tpSC.GetPosition(), tpSC.GetMomentum() )
5351     +{
5352     + // fParticleType = tpSC.GetParticleType();
5353     + // fPosition = tpSC.GetPosition();
5354     + // fMomentum = tpSC.GetMomentum();
5355     + fTrajParam = G4eTrajParamOnSurface( fPosition, fMomentum, plane );
5356     + Init();
5357     +
5358     + //----- Get the error matrix in SC coordinates
5359     + BuildErrorMatrix( tpSC, GetVectorV(), GetVectorW() );
5360     +}
5361     +
5362     +//------------------------------------------------------------------------
5363     +G4eTrajStateOnSurface::G4eTrajStateOnSurface( G4eTrajStateFree& tpSC, const G4Vector3D& vecU, const G4Vector3D& vecV ) : G4eTrajState( tpSC.GetParticleType(), tpSC.GetPosition(), tpSC.GetMomentum() )
5364     +{
5365     + fTrajParam = G4eTrajParamOnSurface( fPosition, fMomentum, vecU, vecV );
5366     + theTSType = G4eTS_OS;
5367     + //----- Get the error matrix in SC coordinates
5368     + BuildErrorMatrix( tpSC, vecU, vecV );
5369     +}
5370     +
5371     +
5372     +//------------------------------------------------------------------------
5373     +void G4eTrajStateOnSurface::BuildErrorMatrix( G4eTrajStateFree& tpSC, const G4Vector3D&, const G4Vector3D& )
5374     +{
5375     + double sclambda = tpSC.GetParameters().GetLambda();
5376     + double scphi = tpSC.GetParameters().GetPhi();
5377     + if( G4eManager::GetG4eManager()->GetMode() == G4eMode_PropBackwards ){
5378     + sclambda *= -1;
5379     + scphi += M_PI;
5380     + }
5381     + double cosLambda = cos( sclambda );
5382     + double sinLambda = sin( sclambda );
5383     + double sinPhi = sin( scphi );
5384     + double cosPhi = cos( scphi );
5385     +
5386     +#ifdef G4EVERBOSE
5387     + if( iverbose >= 4) G4cout << " PM " << fMomentum.mag() << " pLambda " << sclambda << " pPhi " << scphi << G4endl;
5388     +#endif
5389     +
5390     + G4ThreeVector vTN( cosLambda*cosPhi, cosLambda*sinPhi,sinLambda );
5391     + G4ThreeVector vUN( -sinPhi, cosPhi, 0. );
5392     + G4ThreeVector vVN( -vTN.z()*vUN.y(),vTN.z()*vUN.x(), cosLambda );
5393     +
5394     +#ifdef G4EVERBOSE
5395     + if( iverbose >= 4) std::cout << " SC2SD: vTN " << vTN << " vUN " << vUN << " vVN " << vVN << std::endl;
5396     +#endif
5397     + double UJ = vUN*GetVectorV();
5398     + double UK = vUN*GetVectorW();
5399     + double VJ = vVN*GetVectorV();
5400     + double VK = vVN*GetVectorW();
5401     +
5402     +
5403     + //--- Get transformation first
5404     + HepMatrix transfM(5, 5, 0 );
5405     + //--- Get magnetic field
5406     + const G4Field* field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
5407     +
5408     + G4Vector3D vectorU = GetVectorV().cross( GetVectorW() );
5409     +
5410     +#ifdef G4EVERBOSE
5411     + if( iverbose >= 4) std::cout << "vectors " << vectorU << " " << GetVectorV() << " " << GetVectorW() << std::endl;
5412     +#endif
5413     + double T1R = 1. / ( vTN * vectorU );
5414     +
5415     + if( fCharge != 0 && field ) {
5416     + G4double pos[3]; pos[0] = fPosition.x()*cm; pos[1] = fPosition.y()*cm; pos[2] = fPosition.z()*cm;
5417     + G4double Hd[3];
5418     + field->GetFieldValue( pos, Hd );
5419     + G4ThreeVector H = G4ThreeVector( Hd[0], Hd[1], Hd[2] ) / tesla *10.; //in kilogauus
5420     + G4double magH = H.mag();
5421     + G4double invP = 1./(fMomentum.mag()/GeV);
5422     + G4double magHM = magH * invP;
5423     + if( magH != 0. ) {
5424     + G4double magHM2 = fCharge / magH;
5425     + G4double Q = -magHM * c_light/ (km/ns);
5426     +#ifdef G4EVERBOSE
5427     + if( iverbose >= 4) std::cout << GeV << " Q " << Q << " magHM " << magHM << " c_light/(km/ns) " << c_light/(km/ns) << std::endl;
5428     +#endif
5429     +
5430     + G4double sinz = -H*vUN * magHM2;
5431     + G4double cosz = H*vVN * magHM2;
5432     + double T3R = Q * pow(T1R,3);
5433     + double UI = vUN * vectorU;
5434     + double VI = vVN * vectorU;
5435     +#ifdef G4EVERBOSE
5436     + if( iverbose >= 4) {
5437     + G4cout << " T1R " << T1R << " T3R " << T3R << G4endl;
5438     + G4cout << " UI " << UI << " VI " << VI << " vectorU " << vectorU << G4endl;
5439     + G4cout << " UJ " << UJ << " VJ " << VJ << G4endl;
5440     + G4cout << " UK " << UK << " VK " << VK << G4endl;
5441     + }
5442     +#endif
5443     +
5444     + transfM[1][3] = -UI*( VK*cosz-UK*sinz)*T3R;
5445     + transfM[1][4] = -VI*( VK*cosz-UK*sinz)*T3R;
5446     + transfM[2][3] = UI*( VJ*cosz-UJ*sinz)*T3R;
5447     + transfM[2][4] = VI*( VJ*cosz-UJ*sinz)*T3R;
5448     + }
5449     + }
5450     +
5451     + double T2R = T1R * T1R;
5452     + transfM[0][0] = 1.;
5453     + transfM[1][1] = -UK*T2R;
5454     + transfM[1][2] = VK*cosLambda*T2R;
5455     + transfM[2][1] = UJ*T2R;
5456     + transfM[2][2] = -VJ*cosLambda*T2R;
5457     + transfM[3][3] = VK*T1R;
5458     + transfM[3][4] = -UK*T1R;
5459     + transfM[4][3] = -VJ*T1R;
5460     + transfM[4][4] = UJ*T1R;
5461     +
5462     +#ifdef G4EVERBOSE
5463     + if( iverbose >= 4) G4cout << " SC2SD transf matrix A= " << transfM << G4endl;
5464     +#endif
5465     + fError = G4eTrajError( tpSC.GetError().similarity( transfM ) );
5466     +
5467     +#ifdef G4EVERBOSE
5468     + if( iverbose >= 1) std::cout << "G4EP: error matrix SC2SD " << fError << std::endl;
5469     + if( iverbose >= 4) G4cout << "G4eTrajStateOnSurface from SC " << *this << G4endl;
5470     +#endif
5471     +
5472     +}
5473     +
5474     +//------------------------------------------------------------------------
5475     +void G4eTrajStateOnSurface::Init()
5476     +{
5477     + theTSType = G4eTS_OS;
5478     + BuildCharge();
5479     +}
5480     +
5481     +
5482     +//------------------------------------------------------------------------
5483     +void G4eTrajStateOnSurface::Dump( std::ostream& out ) const
5484     +{
5485     + out << *this;
5486     +}
5487     +
5488     +
5489     +//------------------------------------------------------------------------
5490     +std::ostream& operator<<(std::ostream& out, const G4eTrajStateOnSurface& ts)
5491     +{
5492     + out.setf(std::ios::fixed,std::ios::floatfield);
5493     +
5494     + ts.DumpPosMomError( out );
5495     +
5496     + out << " G4eTrajStateOnSurface: Params: " << ts.fTrajParam << G4endl;
5497     + return out;
5498     +}
5499     +
5500     diff -Naur --exclude CVS source/track/include/G4VParticleChange.hh source/track/include/G4VParticleChange.hh
5501     --- source/track/include/G4VParticleChange.hh 2006-10-30 10:50:13.000000000 +0100
5502     +++ source/track/include/G4VParticleChange.hh 2007-01-17 15:35:14.000000000 +0100
5503     @@ -264,6 +264,15 @@
5504     void SetDebugFlag();
5505     G4bool GetDebugFlag() const;
5506    
5507     + //>>GEANT4E
5508     + static void SetAccuracyForWarning( double accu ){
5509     + accuracyForWarning = accu; }
5510     +
5511     + static void SetAccuracyForException(double accu ){
5512     + accuracyForException = accu; };
5513     + //<<GEANT4E
5514     +
5515     +
5516     protected:
5517     // CheckSecondary method is provided for debug
5518     G4bool CheckSecondary(G4Track&);
5519     @@ -275,8 +284,12 @@
5520     G4bool debugFlag;
5521    
5522     // accuracy levels
5523     - static const G4double accuracyForWarning;
5524     - static const G4double accuracyForException;
5525     + //>>GEANT4E
5526     + // static const G4double accuracyForWarning;
5527     + // static const G4double accuracyForException;
5528     + static G4double accuracyForWarning;
5529     + static G4double accuracyForException;
5530     + //<< GEANT4E
5531    
5532    
5533     protected:
5534     diff -Naur --exclude CVS source/track/src/G4VParticleChange.cc source/track/src/G4VParticleChange.cc
5535     --- source/track/src/G4VParticleChange.cc 2006-10-30 10:50:13.000000000 +0100
5536     +++ source/track/src/G4VParticleChange.cc 2007-01-17 15:36:53.000000000 +0100
5537     @@ -42,8 +42,12 @@
5538     #include "G4TrackFastVector.hh"
5539     #include "G4ExceptionSeverity.hh"
5540    
5541     -const G4double G4VParticleChange::accuracyForWarning = 1.0e-9;
5542     -const G4double G4VParticleChange::accuracyForException = 0.001;
5543     +//>>GEANT4E
5544     +//const G4double G4VParticleChange::accuracyForWarning = 1.0e-9;
5545     +//const G4double G4VParticleChange::accuracyForException = 0.001;
5546     +G4double G4VParticleChange::accuracyForWarning = 1.0e-9;
5547     +G4double G4VParticleChange::accuracyForException = 0.001;
5548     +//<<GEANT4E
5549    
5550     G4VParticleChange::G4VParticleChange():
5551     theNumberOfSecondaries(0),
5552 eulisse 1.2 --- source/GNUmakefile 2006-12-14 11:39:45.000000000 +0100
5553     +++ source/GNUmakefile 2007-01-23 10:57:51.000000000 +0100
5554 eulisse 1.1 @@ -19,7 +19,7 @@
5555    
5556     include $(G4INSTALL)/config/architecture.gmk
5557    
5558     -SUBDIR1 = global intercoms graphics_reps materials
5559     +SUBDIR1 = geant4e global intercoms graphics_reps materials
5560     SUBDIR2 = geometry particles track digits_hits processes
5561     SUBDIR2 += parameterisations tracking event run readout
5562     SUBDIR3 = persistency interfaces visualization