source: trunk/examples/advanced/radiation_monitor/sensitivity/src/RadmonSensitiveDetector.cc @ 1317

Last change on this file since 1317 was 807, checked in by garnier, 16 years ago

update

File size: 4.0 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// File name:     RadmonSensitiveDetector.cc
28// Creation date: Nov 2005
29// Main author:   Riccardo Capra <capra@ge.infn.it>
30//
31// Id:            $Id: RadmonSensitiveDetector.cc,v 1.2.2.2 2006/06/29 16:20:34 gunter Exp $
32// Tag:           $Name: geant4-09-01-patch-02 $
33//
34
35// Include files
36#include "RadmonSensitiveDetector.hh"
37#include "RadmonSensitiveDetectorDataStorer.hh"
38#include "G4SDManager.hh"
39#include "G4RunManager.hh"
40
41#define RADMONSENSITIVEDETECTOR_COLLECTIONNAME "radmon_default_"
42
43                                                RadmonSensitiveDetector :: RadmonSensitiveDetector(const G4String & name)
44:
45 G4VSensitiveDetector(name),
46 hitsCollection(0)
47{
48 collName=name;
49 collName+=RADMONSENSITIVEDETECTOR_COLLECTIONNAME;
50 collectionName.insert(collName);
51}
52 
53 
54 
55                                                RadmonSensitiveDetector :: ~RadmonSensitiveDetector()
56{
57}
58 
59 
60 
61
62
63void                                            RadmonSensitiveDetector :: ClearDataStorersList()
64{
65 dataStorersSet.clear();
66}
67 
68 
69 
70void                                            RadmonSensitiveDetector :: AttachDataStorer(RadmonSensitiveDetectorDataStorer * observer)
71{
72 dataStorersSet.insert(observer);
73}
74 
75 
76 
77
78
79void                                            RadmonSensitiveDetector :: Initialize(G4HCofThisEvent * hitsCollections)
80{
81 hitsCollection=new RadmonHitsCollection(GetName(), collName);
82 hitsCollections->AddHitsCollection(GetCollectionID(0), hitsCollection);
83}
84 
85 
86 
87G4bool                                          RadmonSensitiveDetector :: ProcessHits(G4Step * step, G4TouchableHistory * /* touchableHistory */)
88{
89 if (dataStorersSet.empty())
90  return false;
91 
92 RadmonHit * hit(new RadmonHit);
93 
94 hitsCollection->insert(hit);
95
96 DataStorersSet::iterator i(dataStorersSet.begin());
97 const DataStorersSet::iterator end(dataStorersSet.end());
98 
99 while (i!=end)
100 {
101  (*i)->StoreIntoHit(step, hit);
102  i++;
103 }
104
105 return true;
106}
107
108
109
110
111
112RadmonHitsCollection *                          RadmonSensitiveDetector :: GetDetectorCollection(void) const
113{
114 G4SDManager * sdManager(G4SDManager::GetSDMpointer());
115 
116 if (!sdManager)
117  return 0;
118 
119 G4RunManager * rManager(G4RunManager::GetRunManager());
120 
121 if (!rManager)
122  return 0;
123 
124 const G4Event * currentEvent(rManager->GetCurrentEvent());
125 G4HCofThisEvent * hitsCollections(currentEvent->GetHCofThisEvent());
126 return reinterpret_cast<RadmonHitsCollection *>(hitsCollections->GetHC(sdManager->GetCollectionID(collName)));
127}
128
Note: See TracBrowser for help on using the repository browser.