/home/cern/BDSIM_new/src/BDSLWCalorimeterSD.cc

00001 /* BDSIM code for LW Calorimeter.    Version 1.0
00002    Author: John Carter, Royal Holloway, Univ. of London.
00003    Last modified 26.7.2004
00004    Copyright (c) 2004 by J.C.Carter.  ALL RIGHTS RESERVED. 
00005 */
00006 #include "BDSGlobalConstants.hh" // must be first in include list
00007 
00008 #include "BDSLWCalorimeterSD.hh"
00009 #include "BDSLWCalorimeterHit.hh"
00010 #include "G4VPhysicalVolume.hh"
00011 #include "G4LogicalVolume.hh"
00012 #include "G4Track.hh"
00013 #include "G4Step.hh"
00014 #include "G4ParticleDefinition.hh"
00015 #include "G4VTouchable.hh"
00016 #include "G4TouchableHistory.hh"
00017 #include "G4ios.hh"
00018 #include "G4RotationMatrix.hh"
00019 #include "G4ThreeVector.hh"
00020 
00021 #include "G4Navigator.hh"
00022 #include "G4AffineTransform.hh"
00023 
00024 #include "G4RunManager.hh"
00025 #include <vector>
00026 
00027 //typedef std::vector<G4int> MuonTrackVector;
00028 //extern MuonTrackVector* theMuonTrackVector;
00029 
00030 extern G4double initial_x,initial_xp,initial_y,initial_yp,initial_z,initial_E;
00031 
00032 
00033 BDSLWCalorimeterSD::BDSLWCalorimeterSD(G4String name)
00034 :G4VSensitiveDetector(name),StoreHit(true)
00035 {
00036   collectionName.insert("LWCalorimeterCollection");
00037 }
00038 
00039 BDSLWCalorimeterSD::~BDSLWCalorimeterSD()
00040 {;}
00041 
00042 void BDSLWCalorimeterSD::Initialize(G4HCofThisEvent*HCE)
00043 {
00044   LWCalorimeterCollection = 
00045     new BDSLWCalorimeterHitsCollection(SensitiveDetectorName,collectionName[0]);
00046   itsTotalEnergy = 0.;
00047 }
00048 
00049 G4bool BDSLWCalorimeterSD::ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist)
00050 {
00051   
00052   // NOTE ON COPYNUMBER: It is not possible (?) to get the copy number of the
00053   //                     calorimeter directly because the cal is built with 
00054   //                     the exact same specifications each time and so the 
00055   //                     last copynumber given is the copynumber for each.
00056   //                     Solution for now is to take the copynumber of the
00057   //                     mother volume (i.e. MarkerVolume). Drawback is that
00058   //                     it is not possible to have more than one cal per
00059   //                     marker volume.
00060 
00061 
00062   G4int motherCopyNo = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume(1)->GetCopyNo();
00063   itsCopyNumber = motherCopyNo+1;
00064   AddEnergy(aStep->GetTotalEnergyDeposit());
00065   /*
00066   G4cout << "Its Copy Number is: " << itsCopyNumber << G4endl; 
00067   G4cout << "The Volumer here is: " << aStep->GetTrack()->GetVolume()->GetName() << G4endl;
00068   G4cout<<"edep="<<aStep->GetTotalEnergyDeposit()/GeV<<"Total so far="<<itsTotalEnergy/GeV<< " for event: " << G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID() << G4endl;
00069   */
00070   return true;
00071   
00072 }
00073 
00074 void BDSLWCalorimeterSD::EndOfEvent(G4HCofThisEvent*HCE)
00075 {
00076   G4int nEvent= 
00077         G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
00078   /*
00079   G4cout << "ITS COPY NUMBER IS: " << itsCopyNumber << G4endl;
00080   G4cout << "ITS TOTAL ENERGY IS: " << itsTotalEnergy << G4endl;
00081   G4cout << "ITS EVENT NUMBER IS: " << nEvent << G4endl;
00082   */
00083   if(itsCopyNumber > 0){
00084     BDSLWCalorimeterHit* smpHit=
00085       new BDSLWCalorimeterHit(itsCopyNumber,itsTotalEnergy,nEvent);
00086     
00087     LWCalorimeterCollection->insert(smpHit);
00088   }
00089     
00090   static G4int HCID = -1;
00091   if(HCID<0)
00092     { HCID = GetCollectionID(0); }
00093   HCE->AddHitsCollection( HCID, LWCalorimeterCollection );
00094 }
00095 
00096 void BDSLWCalorimeterSD::clear(){} 
00097 
00098 void BDSLWCalorimeterSD::DrawAll(){} 
00099 
00100 void BDSLWCalorimeterSD::PrintAll(){} 

Generated on Wed Mar 5 17:25:22 2008 for BDSIM by  doxygen 1.5.3