00001
00002
00003 #include "musrIForwardSD.hh"
00004 #include "G4HCofThisEvent.hh"
00005 #include "G4Step.hh"
00006 #include "G4ThreeVector.hh"
00007 #include "G4SDManager.hh"
00008 #include "G4ios.hh"
00009
00010
00011
00012 musrIForwardSD::musrIForwardSD(G4String name)
00013 :G4VSensitiveDetector(name)
00014 {
00015 G4String HCname;
00016 collectionName.insert(HCname="iforwardCollection");
00017 }
00018
00019
00020
00021 musrIForwardSD::~musrIForwardSD(){ }
00022
00023
00024
00025 void musrIForwardSD::Initialize(G4HCofThisEvent* HCE)
00026 {
00027 iforwardCollection = new musrIForwardHitsCollection
00028 (SensitiveDetectorName,collectionName[0]);
00029 static G4int HCID = -1;
00030 if(HCID<0)
00031 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
00032 HCE->AddHitsCollection( HCID, iforwardCollection );
00033 }
00034
00035
00036
00037 G4bool musrIForwardSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00038 {
00039 G4double edep = aStep->GetTotalEnergyDeposit();
00040
00041 if(edep==0.) return false;
00042
00043 musrIForwardHit* newHit = new musrIForwardHit();
00044 newHit->SetParticleName (aStep->GetTrack()->GetDefinition()->GetParticleName());
00045 newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
00046 newHit->SetEdep (edep);
00047 newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
00048 newHit->SetPol (aStep->GetTrack()->GetPolarization());
00049 newHit->SetLogVolName (aStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetName());
00050 newHit->SetGlobTime (aStep->GetTrack()->GetGlobalTime());
00051 newHit->SetIFChamberNb(aStep->GetPreStepPoint()->GetTouchable()
00052 ->GetReplicaNumber());
00053 iforwardCollection->insert( newHit );
00054
00055 newHit->Print();
00056 newHit->Draw();
00057
00058 return true;
00059 }
00060
00061
00062
00063 void musrIForwardSD::EndOfEvent(G4HCofThisEvent*)
00064 {
00065 if (verboseLevel>0) {
00066 G4int NbHits = iforwardCollection->entries();
00067 G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
00068 << " hits in the tracker chambers: " << G4endl;
00069 for (G4int i=0;i<NbHits;i++) (*iforwardCollection)[i]->Print();
00070 }
00071 }
00072
00073
00074