00001 //---------------------------------------------------------------------------// 00002 //Description: Manage my SD classes 00003 //Author: Wu Chen(wuchen@mail.ihep.ac.cn) 00004 //Created: 17 Oct, 2012 00005 //Comment: 00006 //---------------------------------------------------------------------------// 00007 00008 #ifndef MyDetectorManager_h 00009 #define MyDetectorManager_h 1 00010 00011 #include "myglobals.hh" 00012 00013 #include <vector> 00014 00015 //supported SD 00016 #include "MonitorSD.hh" 00017 #include "KillerSD.hh" 00018 00019 //supported Svc 00020 #include "SimpleGeometrySvc.hh" 00021 00022 #include "SimpleGeometryParameter.hh" 00023 00024 class G4SDManager; 00025 class G4VSensitiveDetector; 00026 class G4VPhysicalVolume; 00027 class MyVGeometrySvc; 00028 class MySD; 00029 class MyDetectorManagerMessenger; 00030 00031 class MyDetectorManager 00032 { 00033 public: 00034 MyDetectorManager(); 00035 ~MyDetectorManager(); 00036 00037 static MyDetectorManager* GetMyDetectorManager(); 00038 00039 //***************************************ReadCard******************************************** 00040 //OBJECTIVE: Call recorded geometry service objects recursively to read input file for geometry settings 00041 //PROCEDURE: 00042 //0. delete existing geometry service objects 00043 //1. read $CONFIGUREROOT/file_name(or file_name), decide how many services are needed and what files they need. 00044 //2. create(or modify if exists) geometry service objects, push to vector, and call SetGeometry recursively with those file names. 00045 //NOTICE.1: file_name here should either be a complete file name with path or a pure file name w.r.t $CONFIGUREROOT, 00046 // cause MyVGeometry calsses would prepend $CONFIGUREROOT to file_name if not found '/' in it. 00047 void ReadCard(G4String); 00048 void AddGeo(G4String, G4String, G4String); 00049 void ClearGeo(); 00050 00051 //***************************************SetGeometry******************************************** 00052 //OBJECTIVE: Call recorded geometry service objects recursively to setup geometry 00053 //NOTICE.1: a return value is needed as the pointer to the physical volume of world. 00054 // According to conventions, this pointer would be returned by the first geometry service object. 00055 G4VPhysicalVolume* SetGeometry(); 00056 00057 //**************************************ReadOutputCard******************************************** 00058 //OBJECTIVE: Call recorded SD objects recursively to read the input file for output customising. 00059 //NOTICE.1: file_name here should either be a complete file name with path or a pure file name w.r.t $CONFIGUREROOT, 00060 // cause MySD calsses would prepend $CONFIGUREROOT to file_name if not found '/' in it. 00061 void ReadOutputCard(G4String); 00062 00063 //*****************************************SetBranch********************************************** 00064 //OBJECTIVE: Call recorded SD objects recursively to setup branches. 00065 void SetBranch(); 00066 00067 //************************GetSD********************************* 00068 //OBJECTIVE: Get the wanted SD. Create if not exists. 00069 //VolName: name of logical volume. 00070 //SDName: type of sensitive detector. 00071 // NOTICE: if a '/' is found in SDName, then SDName would be considered as "VolName/SDName" 00072 // and the parameter VolName would be ignored. 00073 //pointer: the pointer to the geometry service object which managed this volume. 00074 //PROCEDURE: 00075 //1. Search for (VolName, SDName). 00076 //2. If this pair exists, then return the corresponding G4VSensitiveDetector* 00077 // If not, then record this pair, new a G4VSensitiveDetector according to the type(SDName), 00078 // push the pointer to a vector, and return the pointer. 00079 //NOTICE.1: All sensitive detector classes used here are assumed to inherit from both 00080 // G4VSensitiveDetector and MySD, thus SetParameter is crucial. 00081 //NOTICE.2: Here I use VolName + SDName as the name of SD object to allow different volumes to use 00082 // the same type of SD while keeping different copies( In my case, they would create different branches in output file). 00083 G4VSensitiveDetector* GetSD(G4String, G4String, MyVGeometrySvc* ); 00084 G4VSensitiveDetector* GetSD(G4String, G4String); 00085 00086 //*************************GetSvc******************************** 00087 MyVGeometrySvc* GetSvc( G4String name ){ 00088 MyVGeometrySvc* pointer = 0; 00089 for ( int i = 0; i < fSvcName.size(); i++ ){ 00090 if ( fSvcName[i] == name ){ 00091 pointer = fMyVGeometrySvc[i]; 00092 break; 00093 } 00094 } 00095 return pointer; 00096 } 00097 00098 //*************************GetSvc******************************** 00099 SimpleGeometryParameter* GetParaFromVolume( G4String name ){ 00100 SimpleGeometryParameter* pointer = 0; 00101 for ( int i = 0; i < fMyVGeometrySvc.size(); i++ ){ 00102 SimpleGeometryParameter* ipointer = (SimpleGeometryParameter*) fMyVGeometrySvc[i]->get_GeometryParameter(); 00103 if ( ipointer->get_VolIndex(name) >= 0 ){ 00104 pointer = ipointer; 00105 break; 00106 } 00107 } 00108 return pointer; 00109 } 00110 00111 //**************************************RegistorDM & Digitize************************************************ 00112 //OBJECTIVE: For digitizing control. 00113 //Not well supported yet... 00114 void RegistorDM(G4String); 00115 00116 void Digitize(); 00117 00118 //==> Access 00119 void SetVerbose(int val){fVerboseLevel = val;}; 00120 00121 private: 00122 00123 void DEBUG(G4String); 00124 00125 private: 00126 00127 static MyDetectorManager* fMyDetectorManager; 00128 00129 MyDetectorManagerMessenger* m_MyDetectorManagerMessenger; //pointer to the Messenger 00130 00131 //For MySD 00132 00133 G4SDManager* fSDman; 00134 00135 std::vector<MySD*> fSDList; 00136 std::vector<G4String> fSDName; 00137 std::vector<G4String> fVolName; 00138 std::vector<G4String> fDMName; 00139 00140 //For MyVGeometrySvc 00141 00142 int fVerboseLevel; 00143 std::vector<MyVGeometrySvc*> fMyVGeometrySvc; 00144 std::vector<G4String> fSvcName; 00145 00146 }; 00147 00148 #endif 00149