00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "BDSGlobalConstants.hh"
00014
00015 #include "BDSDumpSD.hh"
00016 #include "BDSDump.hh"
00017 #include "BDSSamplerHit.hh"
00018 #include "BDSDebug.hh"
00019 #include "G4VPhysicalVolume.hh"
00020 #include "G4LogicalVolume.hh"
00021 #include "G4Track.hh"
00022 #include "G4Step.hh"
00023 #include "G4ParticleDefinition.hh"
00024 #include "G4VTouchable.hh"
00025 #include "G4TouchableHistory.hh"
00026 #include "G4ios.hh"
00027 #include "G4RotationMatrix.hh"
00028 #include "G4ThreeVector.hh"
00029
00030 #include "G4Navigator.hh"
00031 #include "G4AffineTransform.hh"
00032
00033 #include "G4RunManager.hh"
00034 #include <vector>
00035
00036 #include "G4SDManager.hh"
00037
00038 extern G4double initial_x,initial_xp,initial_y,initial_yp,initial_z,initial_E;
00039
00040 #define DEBUG 1
00041
00042 BDSDumpSD::BDSDumpSD(G4String name, G4String type):
00043 G4VSensitiveDetector(name),
00044 itsType(type)
00045 {
00046 }
00047
00048 BDSDumpSD::~BDSDumpSD()
00049 {;}
00050
00051 void BDSDumpSD::Initialize(G4HCofThisEvent*)
00052 {
00053 }
00054
00055 G4bool BDSDumpSD::ProcessHits(G4Step*aStep,G4TouchableHistory*)
00056 {
00057 G4cout << __METHOD_NAME__ <<G4endl;
00058 G4Track* theTrack=aStep->GetTrack();
00059 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
00060
00061
00062
00063
00064 if(preStepPoint->GetStepStatus()==fGeomBoundary){
00065 if(BDSGlobalConstants::Instance()->isReference){
00066 G4double referenceTime = theTrack->GetGlobalTime();
00067 #ifdef DEBUG
00068 G4cout << __METHOD_NAME__ << "refTime= " << referenceTime <<G4endl;
00069 G4cout << __METHOD_NAME__ << theTrack->GetVolume()->GetName() << G4endl;
00070 #endif
00071 if(lastVolume!=theTrack->GetVolume()->GetName())
00072 BDSGlobalConstants::Instance()->referenceQueue.at(nCounter++)[trackCounter] = referenceTime;
00073
00074 #ifdef DEBUG
00075 G4cout << __METHOD_NAME__ << "Track: " << trackCounter
00076 << " Dump : " << nCounter
00077 << " Time: " << referenceTime << G4endl;
00078 #endif
00079
00080 if(nCounter==BDSDump::GetNumberOfDumps()){
00081 nCounter=0;
00082 ++trackCounter;
00083 lastVolume="";
00084 }
00085
00086 lastVolume = theTrack->GetVolume()->GetName();
00087
00088 }
00089 else if(abs(theTrack->GetDefinition()->GetPDGEncoding()) == 11){
00090 #ifdef DEBUG
00091 G4cout << __METHOD_NAME__ <<"Dump: postponing track..."<<G4endl;
00092 #endif
00093 BDSGlobalConstants::Instance()->setWaitingForDump(true);
00094
00095
00096 theTrack->SetTrackStatus(fPostponeToNextEvent);
00097
00098
00099 G4AffineTransform tf(aStep->GetPreStepPoint()->GetTouchableHandle()->
00100 GetHistory()->GetTopTransform().Inverse());
00101 BDSGlobalConstants::Instance()->SetDumpTransform(tf);
00102 }
00103 }
00104 return true;
00105 }
00106
00107 void BDSDumpSD::EndOfEvent(G4HCofThisEvent*)
00108 {
00109 }
00110
00111 void BDSDumpSD::clear(){}
00112
00113 void BDSDumpSD::DrawAll(){}
00114
00115 void BDSDumpSD::PrintAll(){}
00116
00117 G4int BDSDumpSD::nCounter = 0;
00118
00119 G4int BDSDumpSD::trackCounter = 0;
00120
00121 G4String BDSDumpSD::lastVolume = "";
00122
00123