/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/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 
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   // NOTE ON COPYNUMBER: It is not possible (?) to get the copy number of the
00048   //                     calorimeter directly because the cal is built with 
00049   //                     the exact same specifications each time and so the 
00050   //                     last copynumber given is the copynumber for each.
00051   //                     Solution for now is to take the copynumber of the
00052   //                     mother volume (i.e. MarkerVolume). Drawback is that
00053   //                     it is not possible to have more than one cal per
00054   //                     marker volume.
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   G4cout << "ITS COPY NUMBER IS: " << itsCopyNumber << G4endl;
00076   G4cout << "ITS TOTAL ENERGY IS: " << itsTotalEnergy << G4endl;
00077   G4cout << "ITS EVENT NUMBER IS: " << nEvent << G4endl;
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 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7