Geant4 Cross Reference |
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 // G4DigiManager 27 // 28 // class description: 29 // 30 // This is a singleton class which manages the digitizer modules. 31 // The user cannot access to the constructor. The pointer of the 32 // only existing object can be got via G4DigiManager::GetDMpointer() 33 // static method. The first invokation in the program makes the 34 // singleton object. 35 36 // Author: M.Asai 37 // -------------------------------------------------------------------- 38 #ifndef G4DigiManager_hh 39 #define G4DigiManager_hh 1 40 41 #include "globals.hh" 42 #include "G4VDigitizerModule.hh" 43 #include "G4DCtable.hh" 44 45 #include <vector> 46 47 class G4Event; 48 class G4VHitsCollection; 49 class G4VDigiCollection; 50 class G4DMmessenger; 51 class G4RunManager; 52 class G4SDManager; 53 54 class G4DigiManager 55 { 56 public: 57 58 static G4DigiManager* GetDMpointer(); 59 // Returns the pointer to the singleton object 60 61 static G4DigiManager* GetDMpointerIfExist(); 62 63 ~G4DigiManager(); 64 65 G4DigiManager(const G4DigiManager&) = delete; 66 G4DigiManager& operator=(const G4DigiManager&) = delete; 67 68 void AddNewModule(G4VDigitizerModule* DM); 69 // Registers the user's digitizer mudule. This method must be invoked when 70 // the user construct his/her digitizer module(s). 71 void Digitize(const G4String& mName); 72 // Invokes Digitize() method of specified digitizer module. This is a kind 73 // of service method. The user can invoke Digitize() method of a particular 74 // module without knowing the pointer of the module object. The argument 75 // "mName" is the name of the module, which is defined at the constructor 76 // of the concrete digitizer module. 77 G4VDigitizerModule* FindDigitizerModule(const G4String& mName); 78 // Returns the pointer to the digitizer module object with the given name. 79 // Null will be returned if the name is not defined. 80 const G4VHitsCollection* GetHitsCollection(G4int HCID, G4int eventID = 0); 81 const G4VDigiCollection* GetDigiCollection(G4int DCID, G4int eventID = 0); 82 // These two methods return the pointer to the hits and digi collection 83 // object, respectively. "HCID" and "DCID" are the ID numbers of hits and 84 // digi collections, which can be obtained vir the next two methods. 85 // If "eventID" is greater than zero, corresponding hits or digi collection 86 // of "eventID" prevuois event is returned so that event overlap can be 87 // handled. To do this, necessary number of events must be set to G4RunManager 88 // by G4RunManager::SetNumberOfEventsToBeStored() method previously to the 89 // event loop. 90 G4int GetHitsCollectionID(const G4String& HCname); 91 G4int GetDigiCollectionID(const G4String& DCname); 92 // Returns the ID number of hits and digi collections, respectively. "HCname" 93 // and "DCname" can be the collection name if it is unique, or can be detector 94 // or module name and the collection name connected by "/". 95 void SetDigiCollection(G4int DCID, G4VDigiCollection* aDC); 96 // This method must exclusively used by the base class of G4VDigitizerModule. 97 // To set digi collection, the user must use SetDigiCollection of G4VDigitizerModule. 98 99 public: 100 101 void SetVerboseLevel(G4int vl); 102 void List() const; 103 104 inline G4int GetVerboseLevel() const 105 { return verboseLevel; } 106 inline G4int GetCollectionCapacity() const 107 { return DCtable->entries(); } 108 inline G4int GetModuleCapacity() const 109 { return G4int(DMtable.size()); } 110 inline G4DCtable* GetDCtable() const 111 { return DCtable; } 112 inline void RestoreDCtable(G4DCtable* dc) 113 { 114 if(DCtable) delete DCtable; 115 DCtable = dc; 116 } 117 118 protected: 119 120 G4DigiManager(); 121 122 private: 123 124 static G4ThreadLocal G4DigiManager * fDManager; 125 G4int verboseLevel; 126 std::vector<G4VDigitizerModule*> DMtable; 127 G4DCtable* DCtable; 128 G4DMmessenger* theMessenger; 129 G4RunManager* runManager; 130 G4SDManager* SDManager; 131 }; 132 133 #endif 134