Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:05

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 
0029 #ifndef G4SDManager_h
0030 #define G4SDManager_h 1
0031 
0032 #include "G4HCtable.hh"
0033 #include "G4SDStructure.hh"
0034 #include "globals.hh"
0035 class G4VHitsCollection;
0036 class G4VSensitiveDetector;
0037 class G4HCofThisEvent;
0038 class G4SDmessenger;
0039 
0040 #include "G4VSDFilter.hh"
0041 
0042 #include <vector>
0043 
0044 // class description:
0045 //
0046 //  This is a singleton class which manages the sensitive detectors.
0047 // The user cannot access to the constructor. The pointer of the
0048 // only existing object can be got via G4SDManager::GetSDMpointer()
0049 // static method. The first invokation of this static method makes
0050 // the singleton object.
0051 //
0052 
0053 class G4SDManager
0054 {
0055  public:
0056   // Returns the pointer to the singleton object, creating it if not null
0057   static G4SDManager* GetSDMpointer();
0058 
0059   // Returns current pointer to the singleton object
0060   // Caller is responsible for checking value against `nullptr`
0061   static G4SDManager* GetSDMpointerIfExist();
0062 
0063   G4SDManager(const G4SDManager&) = delete;
0064   G4SDManager& operator=(const G4SDManager&) = delete;
0065   ~G4SDManager();
0066 
0067   // Register sensitive detector instance
0068   // This method must be invoked when the user constructs their sensitive detector
0069   void AddNewDetector(G4VSensitiveDetector* aSD);
0070 
0071   // Activate/inactivate the registered sensitive detector.
0072   // For the inactivated detectors, hits collections will not be stored to the G4HCofThisEvent
0073   // object.
0074   void Activate(G4String dName, G4bool activeFlag);
0075 
0076   // Return ID number of sensitive detector with given name
0077   G4int GetCollectionID(G4String colName);
0078 
0079   // Return ID number of sensitive detector creating given hits collection
0080   G4int GetCollectionID(G4VHitsCollection* aHC);
0081 
0082   G4VSensitiveDetector* FindSensitiveDetector(G4String dName, G4bool warning = true);
0083   G4HCofThisEvent* PrepareNewEvent();
0084   void TerminateCurrentEvent(G4HCofThisEvent* HCE);
0085   void AddNewCollection(G4String SDname, G4String DCname);
0086 
0087   inline void SetVerboseLevel(G4int vl)
0088   {
0089     verboseLevel = vl;
0090     treeTop->SetVerboseLevel(vl);
0091   }
0092   inline G4SDStructure* GetTreeTop() const { return treeTop; }
0093   inline void ListTree() const { treeTop->ListTree(); }
0094   inline G4int GetCollectionCapacity() const { return HCtable->entries(); }
0095   inline G4HCtable* GetHCtable() const { return HCtable; }
0096 
0097   void RegisterSDFilter(G4VSDFilter* filter);
0098   void DeRegisterSDFilter(G4VSDFilter* filter);
0099 
0100  protected:
0101   G4SDManager();
0102 
0103  private:
0104   void DestroyFilters();
0105 
0106  private:
0107   static G4ThreadLocal G4SDManager* fSDManager;
0108   G4SDStructure* treeTop;
0109   G4int verboseLevel{0};
0110   G4HCtable* HCtable;
0111   G4SDmessenger* theMessenger;
0112   std::vector<G4VSDFilter*> FilterList;
0113 };
0114 
0115 #endif