#include <MollerDetectorSD.hh>
Public Member Functions | |
MollerDetectorSD (G4String name) | |
virtual | ~MollerDetectorSD () |
virtual void | Initialize (G4HCofThisEvent *HCE) |
virtual G4bool | ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) |
virtual void | EndOfEvent (G4HCofThisEvent *HCE) |
Private Attributes | |
MollerDetectorHitsCollection * | hitsCollection |
G4int | HCID |
Definition at line 14 of file MollerDetectorSD.hh.
MollerDetectorSD::MollerDetectorSD | ( | G4String | name | ) |
Definition at line 16 of file MollerDetectorSD.cc.
References HCID.
00017 :G4VSensitiveDetector(name) 00018 { 00019 G4String HCname; 00020 collectionName.insert(HCname="hitsColl"); 00021 HCID = -1; 00022 }
MollerDetectorSD::~MollerDetectorSD | ( | ) | [virtual] |
Definition at line 24 of file MollerDetectorSD.cc.
void MollerDetectorSD::EndOfEvent | ( | G4HCofThisEvent * | HCE | ) | [virtual] |
Definition at line 153 of file MollerDetectorSD.cc.
void MollerDetectorSD::Initialize | ( | G4HCofThisEvent * | HCE | ) | [virtual] |
Definition at line 26 of file MollerDetectorSD.cc.
References HCID, and hitsCollection.
00027 { 00028 hitsCollection = new MollerDetectorHitsCollection 00029 (SensitiveDetectorName,collectionName[0]); 00030 if(HCID<0) 00031 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(hitsCollection); } 00032 HCE->AddHitsCollection(HCID,hitsCollection); 00033 00034 }
G4bool MollerDetectorSD::ProcessHits | ( | G4Step * | aStep, | |
G4TouchableHistory * | ROhist | |||
) | [virtual] |
Definition at line 36 of file MollerDetectorSD.cc.
References hitsCollection, MollerDetectorHit::SetCreatorProcess(), MollerDetectorHit::SetIon(), MollerDetectorHit::SetKineticEnergy(), MollerDetectorHit::SetKineticEnergy2(), MollerDetectorHit::SetMomentum(), MollerDetectorHit::SetMomentum2(), MollerDetectorHit::SetParticleName(), MollerDetectorHit::SetScatAngle(), MollerDetectorHit::SetTrackID(), MollerDetectorHit::SetType(), MollerDetectorHit::SetVertexPos(), MollerDetectorHit::SetVolume(), and MollerDetectorHit::SetWorldPos().
00037 { 00038 00039 00040 const G4Track* fTrack = aStep->GetTrack(); 00041 00042 G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); 00043 G4TouchableHistory* theTouchable 00044 = (G4TouchableHistory*)(preStepPoint->GetTouchable()); 00045 G4VPhysicalVolume* theMotherPhysical = theTouchable->GetVolume(1); // mother 00046 G4int copyNo = theMotherPhysical->GetCopyNo(); 00047 00048 00049 G4ThreeVector worldPos = preStepPoint->GetPosition(); 00050 G4ThreeVector vertexPos = fTrack->GetVertexPosition(); 00051 G4ThreeVector momentum = fTrack->GetMomentumDirection(); 00052 G4ThreeVector vertexMomentum = fTrack->GetVertexMomentumDirection(); 00053 00054 00055 const G4VProcess* creatorProcess = fTrack->GetCreatorProcess(); 00056 G4String process; 00057 if (creatorProcess!=0) process = creatorProcess->GetProcessName(); 00058 00059 G4bool ion = (process=="eIoni"); 00060 00061 G4String particle = fTrack->GetDefinition()->GetParticleName(); 00062 00063 // Need to get a number from the volume name somehow... 00064 //G4String volume = fTrack->GetVolume()->GetName(); 00065 char volumeName[200]; char volumeNameAlt0[200]; char volumeNameAlt1[200]; char volumeNameAlt2[200]; char volumeNameAlt3[200]; 00066 G4int offset=0; G4int alt0offset=1000; G4int alt1offset=1000; G4int alt2offset=2000; G4int alt3offset=2000; 00067 G4int volume=-1000; 00068 00069 for (G4int vol = 0; vol<100; vol++){ 00070 00071 snprintf(volumeName,200,"planeDet_%i",vol); offset = 0; 00072 snprintf(volumeNameAlt0,200,"UScoll_%i",vol); alt0offset = 1050; 00073 snprintf(volumeNameAlt1,200,"DScoll_%i",vol); alt1offset = 1100; 00074 snprintf(volumeNameAlt2,200,"UScoil_%i",vol); alt2offset = 2000; 00075 snprintf(volumeNameAlt3,200,"DScoil_%i",vol); alt3offset = 2050; 00076 00077 //Actual detectors will have volumes starting with 0-1000 (hopefully we won't need more than that?) 00078 //Collimators will have volumes starting with 1000 00079 //Coils will have volumes starting with 2000 00080 if (fTrack->GetVolume()->GetName().compare(volumeName)==0){ 00081 volume = vol+offset; 00082 } else if (fTrack->GetVolume()->GetName().compare(volumeNameAlt0)==0){ 00083 volume = vol+alt0offset; 00084 } else if (fTrack->GetVolume()->GetName().compare(volumeNameAlt1)==0){ 00085 volume = vol+alt1offset; 00086 } else if (fTrack->GetVolume()->GetName().compare(volumeNameAlt2)==0){ 00087 volume = vol+alt2offset; 00088 } else if (fTrack->GetVolume()->GetName().compare(volumeNameAlt3)==0){ 00089 volume = vol+alt3offset; 00090 } 00091 } 00092 // G4cout<<"The hit volume is : "<<fTrack->GetVolume()->GetName()<<" : Volume = "<<volume<<G4endl; 00093 00094 G4int trackID = fTrack->GetTrackID(); 00095 00096 G4int partType; 00097 00098 if (particle=="e-") partType=0; 00099 else if (particle=="e+") partType=1; 00100 else if (particle=="proton") partType=2; 00101 else if (particle=="antiproton") partType=3; 00102 else if (particle=="gamma") partType=4; 00103 else partType=5; 00104 00105 G4double kineE = fTrack->GetKineticEnergy(); 00106 G4double kineE0 = fTrack->GetVertexKineticEnergy(); 00107 00108 00109 //G4double rad_dist = sqrt(worldPos.x()*worldPos.x() + 00110 //worldPos.y()*worldPos.y()); 00111 00112 G4double scat_ang = sqrt(vertexMomentum.x()*vertexMomentum.x() + 00113 vertexMomentum.y()*vertexMomentum.y()); 00114 00115 /* Insert cut here for limiting hit creation */ 00116 /* This default cut ignores gamma particles, which have partType=4*/ 00117 00118 if (kineE0<100||!(partType==4||partType==0)) { 00119 return true; 00120 } 00121 00122 /* Create and define Hit attributes */ 00123 else { 00124 MollerDetectorHit* newHit = new MollerDetectorHit(copyNo); 00125 00126 00127 newHit->SetWorldPos(worldPos); 00128 newHit->SetVertexPos(vertexPos); 00129 newHit->SetMomentum(momentum); 00130 newHit->SetKineticEnergy(kineE); 00131 00132 newHit->SetMomentum2(vertexMomentum); 00133 newHit->SetKineticEnergy2(kineE0); 00134 newHit->SetScatAngle(scat_ang); 00135 00136 newHit->SetCreatorProcess(process); 00137 newHit->SetParticleName(particle); 00138 00139 newHit->SetIon(ion); 00140 newHit->SetType(partType); 00141 00142 // newHit->SetVolume(atof(volume)); 00143 newHit->SetVolume(volume); 00144 newHit->SetTrackID(trackID); 00145 00146 00147 hitsCollection->insert( newHit ); 00148 00149 return true; 00150 } 00151 }
G4int MollerDetectorSD::HCID [private] |
Definition at line 27 of file MollerDetectorSD.hh.
Referenced by Initialize(), and MollerDetectorSD().
Definition at line 26 of file MollerDetectorSD.hh.
Referenced by Initialize(), and ProcessHits().