/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSCCDPixelSD.cc

00001 #include "BDSGlobalConstants.hh" 
00002 #include "BDSExecOptions.hh"
00003 #include "BDSDebug.hh"
00004 #include "BDSCCDPixelSD.hh"
00005 #include "BDSCCDPixelHit.hh"
00006 #include "G4VPhysicalVolume.hh"
00007 #include "G4LogicalVolume.hh"
00008 #include "G4Track.hh"
00009 #include "G4Step.hh"
00010 #include "G4StepPoint.hh"
00011 #include "G4ParticleDefinition.hh"
00012 #include "G4VTouchable.hh"
00013 #include "G4TouchableHistory.hh"
00014 #include "G4ios.hh"
00015 #include "G4RotationMatrix.hh"
00016 #include "G4ThreeVector.hh"
00017 
00018 #include "G4AffineTransform.hh"
00019 
00020 #include <vector>
00021 
00022 #include "G4SDManager.hh"
00023 
00024 
00025 
00026 BDSCCDPixelSD::BDSCCDPixelSD(G4String name)
00027   :G4VSensitiveDetector(name),CCDPixelCollection(NULL)
00028 {
00029   _collectionName="CCDPixel";
00030   collectionName.insert(_collectionName);
00031 }
00032 
00033 BDSCCDPixelSD::~BDSCCDPixelSD()
00034 {;}
00035 
00036 void BDSCCDPixelSD::Initialize(G4HCofThisEvent*)
00037 {
00038   // Create CCDPixel hits collection
00039   CCDPixelCollection = new BDSCCDPixelHitsCollection(SensitiveDetectorName,collectionName[0]);
00040 }
00041 
00042 G4bool BDSCCDPixelSD::ProcessHits(G4Step*aStep,G4TouchableHistory*)
00043 {
00044 #ifdef BDSDEBUG
00045   G4cout << __METHOD_NAME__ << "processing hits for sensitive detector name " << SensitiveDetectorName << G4endl;  
00046 #endif
00047   G4TouchableHistory* hist = (G4TouchableHistory*) 
00048     (aStep->GetPreStepPoint()->GetTouchable());
00049   G4Track* theTrack = aStep->GetTrack();
00050   //only store a hit for optical photons.
00051   if(theTrack->GetDefinition()->GetPDGEncoding() != 0) return false;
00052   //Do not store hit if the particle is not on the boundary 
00053   if(aStep->GetPreStepPoint()->GetStepStatus()!=fGeomBoundary) return false;
00054   
00055   G4int nCCDPixel=hist->GetVolume()->GetCopyNo();
00056   G4double weight=theTrack->GetWeight();
00057   
00058 #ifdef BDSDEBUG
00059   G4cout << __METHOD_NAME__ << " Storing hit: nCCDPixel weight" << G4endl;
00060   G4cout << __METHOD_NAME__ << " " << nCCDPixel <<" "  << weight << G4endl;
00061 #endif
00062 
00063   BDSCCDPixelHit* pixelHit
00064     = new BDSCCDPixelHit(nCCDPixel, weight);
00065   CCDPixelCollection->insert(pixelHit);
00066   
00067 #ifdef BDSDEBUG
00068   G4cout << __METHOD_NAME__ << " entries in hits collection after inserting hit: " << CCDPixelCollection->entries() << G4endl;
00069 #endif
00070   //The hit was stored, so the return value is "true".
00071   return true;
00072 }
00073 
00074 void BDSCCDPixelSD::EndOfEvent(G4HCofThisEvent*HCE)
00075 {
00076   G4SDManager * SDman = G4SDManager::GetSDMpointer();
00077   G4int HCID = SDman->GetCollectionID(collectionName[0]);
00078   HCE->AddHitsCollection(HCID, CCDPixelCollection );
00079 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7