00001
00002
00003
00004
00005
00006
00007 #include "BDSGlobalConstants.hh"
00008
00009 #include "BDSRunManager.hh"
00010 #include "BDSLWCalorimeterSD.hh"
00011 #include "BDSLWCalorimeterHit.hh"
00012 #include "G4VPhysicalVolume.hh"
00013 #include "G4LogicalVolume.hh"
00014 #include "G4Track.hh"
00015 #include "G4Step.hh"
00016 #include "G4ParticleDefinition.hh"
00017 #include "G4VTouchable.hh"
00018 #include "G4TouchableHistory.hh"
00019 #include "G4ios.hh"
00020 #include "G4RotationMatrix.hh"
00021 #include "G4ThreeVector.hh"
00022
00023 #include "G4AffineTransform.hh"
00024
00025 #include <vector>
00026
00027 BDSLWCalorimeterSD::BDSLWCalorimeterSD(G4String name)
00028 :G4VSensitiveDetector(name),itsTotalEnergy(0.0),itsCopyNumber(-1),
00029 LWCalorimeterCollection(NULL)
00030 {
00031 collectionName.insert("LWCalorimeterCollection");
00032 }
00033
00034 BDSLWCalorimeterSD::~BDSLWCalorimeterSD()
00035 {;}
00036
00037 void BDSLWCalorimeterSD::Initialize(G4HCofThisEvent*)
00038 {
00039 LWCalorimeterCollection =
00040 new BDSLWCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
00041 itsTotalEnergy = 0.;
00042 }
00043
00044 G4bool BDSLWCalorimeterSD::ProcessHits(G4Step*aStep,G4TouchableHistory*)
00045 {
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 G4int motherCopyNo = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume(1)->GetCopyNo();
00058 itsCopyNumber = motherCopyNo+1;
00059 AddEnergy(aStep->GetTotalEnergyDeposit());
00060
00061 #ifdef BDSDEBUG
00062 G4cout << "Its Copy Number is: " << itsCopyNumber << G4endl;
00063 G4cout << "The Volumer here is: " << aStep->GetTrack()->GetVolume()->GetName() << G4endl;
00064 G4cout<<"edep="<<aStep->GetTotalEnergyDeposit()/CLHEP::GeV<<"Total so far="<<itsTotalEnergy/CLHEP::GeV<< " for event: " << BDSRunManager::GetRunManager()->GetCurrentEvent()->GetEventID() << G4endl;
00065 #endif
00066 return true;
00067
00068 }
00069
00070 void BDSLWCalorimeterSD::EndOfEvent(G4HCofThisEvent*HCE)
00071 {
00072 G4int nEvent=
00073 BDSRunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
00074
00075
00076
00077
00078
00079 if(itsCopyNumber > 0){
00080 BDSLWCalorimeterHit* smpHit=
00081 new BDSLWCalorimeterHit(itsCopyNumber,itsTotalEnergy,nEvent);
00082
00083 LWCalorimeterCollection->insert(smpHit);
00084 }
00085
00086 static G4int HCID = -1;
00087 if(HCID<0)
00088 { HCID = GetCollectionID(0); }
00089 HCE->AddHitsCollection( HCID, LWCalorimeterCollection );
00090 }