G4VSensitiveDetector.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #ifndef G4VSensitiveDetector_h
00031 #define G4VSensitiveDetector_h 1
00032 
00033 #include "G4VHit.hh"
00034 #include "G4Step.hh"
00035 #include "G4HCofThisEvent.hh"
00036 #include "G4VReadOutGeometry.hh"
00037 #include "G4TouchableHistory.hh"
00038 #include "G4CollectionNameVector.hh"
00039 #include "G4VSDFilter.hh"
00040 
00041 // class description:
00042 //
00043 //  This is the abstract base class of the sensitive detector. The user's
00044 // sensitive detector which generates hits must be derived from this
00045 // class.
00046 //  In the derived class constructor, name(s) of hits collection(s) which
00047 // are made by the sensitive detector must be set to "collectionName" string
00048 // vector.
00049 
00050 class G4VSensitiveDetector 
00051 {
00052 
00053   public: // with description
00054       G4VSensitiveDetector(G4String name);
00055       G4VSensitiveDetector(const G4VSensitiveDetector &right);
00056       // Constructors. The user's concrete class must use one of these constructors
00057       // by the constructor initializer of the derived class. The name of
00058       // the sensitive detector must be unique.
00059 
00060   public:
00061       virtual ~G4VSensitiveDetector();
00062 
00063       const G4VSensitiveDetector & operator=(const G4VSensitiveDetector &right);
00064 
00065       G4int operator==(const G4VSensitiveDetector &right) const;
00066       G4int operator!=(const G4VSensitiveDetector &right) const;
00067 
00068   public: // with description
00069       virtual void Initialize(G4HCofThisEvent*);
00070       virtual void EndOfEvent(G4HCofThisEvent*);
00071       //  These two methods are invoked at the begining and at the end of each
00072       // event. The hits collection(s) created by this sensitive detector must
00073       // be set to the G4HCofThisEvent object at one of these two methods.
00074       virtual void clear();
00075       //  This method is invoked if the event abortion is occured. Hits collections
00076       // created but not beibg set to G4HCofThisEvent at the event should be deleted.
00077       // Collection(s) which have already set to G4HCofThisEvent will be deleted 
00078       // automatically.
00079 
00080   public:
00081       virtual void DrawAll();
00082       virtual void PrintAll();
00083 
00084   protected: // with description
00085       virtual G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist) = 0;
00086       //  The user MUST implement this method for generating hit(s) using the 
00087       // information of G4Step object. Note that the volume and the position
00088       // information is kept in PreStepPoint of G4Step.
00089       //  Be aware that this method is a protected method and it sill be invoked 
00090       // by Hit() method of Base class after Readout geometry associated to the
00091       // sensitive detector is handled.
00092       //  "ROhist" will be given only is a Readout geometry is defined to this
00093       // sensitive detector. The G4TouchableHistory object of the tracking geometry
00094       // is stored in the PreStepPoint object of G4Step.
00095       virtual G4int GetCollectionID(G4int i);
00096       //  This is a utility method which returns the hits collection ID of the
00097       // "i"-th collection. "i" is the order (starting with zero) of the collection
00098       // whose name is stored to the collectionName protected vector.
00099       G4CollectionNameVector collectionName;
00100       //  This protected name vector must be filled at the constructor of the user's
00101       // concrete class for registering the name(s) of hits collection(s) being
00102       // created by this particular sensitive detector.
00103 
00104   protected:
00105       G4String SensitiveDetectorName; // detector name
00106       G4String thePathName;           // directory path
00107       G4String fullPathName;          // path + detector name
00108       G4int verboseLevel;
00109       G4bool active;
00110       G4VReadOutGeometry * ROgeometry;
00111       G4VSDFilter* filter;
00112 
00113   public: // with description
00114       inline G4bool Hit(G4Step*aStep)
00115       {
00116         G4TouchableHistory* ROhis = 0;
00117         if(!isActive()) return false;
00118         if(filter)
00119         { if(!(filter->Accept(aStep))) return false; }
00120         if(ROgeometry)
00121         { if(!(ROgeometry->CheckROVolume(aStep,ROhis))) return false; }
00122         return ProcessHits(aStep,ROhis);
00123       }
00124       //  This is the public method invoked by G4SteppingManager for generating
00125       // hit(s). The actual user's implementation for generating hit(s) must be
00126       // implemented in GenerateHits() virtual protected method. This method
00127       // MUST NOT be overrided.
00128       inline void SetROgeometry(G4VReadOutGeometry*value)
00129       { ROgeometry = value; }
00130       //  Register the Readout geometry.
00131       inline void SetFilter(G4VSDFilter*value)
00132       { filter = value; }
00133       //  Register a filter
00134 
00135   public:
00136       inline G4int GetNumberOfCollections() const
00137       { return collectionName.size(); }
00138       inline G4String GetCollectionName(G4int id) const
00139       { return collectionName[id]; }
00140       inline void SetVerboseLevel(G4int vl)
00141       { verboseLevel = vl; }
00142       inline void Activate(G4bool activeFlag)
00143       { active = activeFlag; }
00144       inline G4bool isActive() const
00145       { return active; }
00146       inline G4String GetName() const
00147       { return SensitiveDetectorName; }
00148       inline G4String GetPathName() const
00149       { return thePathName; }
00150       inline G4String GetFullPathName() const
00151       { return fullPathName; }
00152       inline G4VReadOutGeometry* GetROgeometry() const
00153       { return ROgeometry; }
00154       inline G4VSDFilter* GetFilter() const
00155       { return filter; }
00156 };
00157 
00158 
00159 
00160 
00161 #endif
00162 

Generated on Mon May 27 17:50:22 2013 for Geant4 by  doxygen 1.4.7