#include <Ext_track.h>
Public Member Functions | |
void | Dir (const int dir) |
void | Dir (const int dir) |
Ext_track (const bool msgFlag, const bool myBFieldOn, const bool GeomOptimization) | |
Ext_track () | |
Ext_track (const bool msgFlag, const bool myBFieldOn, const bool GeomOptimization) | |
Ext_track () | |
ExtSteppingAction * | GetStepAction () |
ExtSteppingAction * | GetStepAction () |
void | Initialization (const bool aMsgFlag, const bool Bfield, const bool GeomOptimization) |
void | Initialization (const bool aMsgFlag, const bool Bfield, const bool GeomOptimization) |
bool | Set (const Hep3Vector &xv3, const Hep3Vector &pv3, const HepSymMatrix &err, const std::string &particleName, const double pathInMDC, const double tofInMdc) |
bool | Set (const Hep3Vector &xv3, const Hep3Vector &pv3, const HepSymMatrix &err, const std::string &particleName, const double pathInMDC, const double tofInMdc) |
void | TrackExtrapotation () |
void | TrackExtrapotation () |
~Ext_track () | |
~Ext_track () | |
Private Member Functions | |
void | CheckRegions () |
void | CheckRegions () |
bool | CheckVertexInsideWorld (const Hep3Vector &pos) |
bool | CheckVertexInsideWorld (const Hep3Vector &pos) |
bool | GeometryInitialization () |
bool | GeometryInitialization () |
bool | PhysicsInitialization () |
bool | PhysicsInitialization () |
Private Attributes | |
G4VUserDetectorConstruction * | bes3DetectorConstruction |
G4VUserDetectorConstruction * | bes3DetectorConstruction |
G4VPhysicalVolume * | bes3WorldVolume |
G4VPhysicalVolume * | bes3WorldVolume |
G4VUserPhysicsList * | extPhysicsList |
G4VUserPhysicsList * | extPhysicsList |
G4RunManagerKernel * | extRunManagerKernel |
G4RunManagerKernel * | extRunManagerKernel |
ExtSteppingAction * | extSteppingAction |
ExtSteppingAction * | extSteppingAction |
G4Track * | extTrack |
G4Track * | extTrack |
G4TrackingManager * | extTrackingManager |
G4TrackingManager * | extTrackingManager |
int | m_dir |
float | m_vect [7] |
Ext_xp_err | m_xp_err |
bool | myBFieldOn |
bool | myGeomOptimization |
bool | myMsgFlag |
|
00035 : myMsgFlag(true),myBFieldOn(true),myGeomOptimization(true),m_dir(0) 00036 { 00037 // BesSensitiveManager *besSensitiveManager = new BesSensitiveManager; 00038 bes3DetectorConstruction = new ExtBesDetectorConstruction(myBFieldOn); 00039 bes3WorldVolume = bes3DetectorConstruction->Construct(); 00040 extPhysicsList = new ExtPhysicsList; 00041 extTrack = new G4Track; 00042 00043 //for geant4.8.1, move this line to Initialization, extSteppingAction = new ExtSteppingAction; 00044 extTrackingManager = new G4TrackingManager; 00045 //RunManagerKernel for geant4.9.0 00046 extRunManagerKernel = new G4RunManagerKernel; 00047 }
|
|
00049 : myMsgFlag(msgFlag),myBFieldOn(BFieldOn),myGeomOptimization(GeomOptimization),m_dir(0) 00050 { 00051 // BesSensitiveManager *besSensitiveManager = new BesSensitiveManager; 00052 bes3DetectorConstruction = new ExtBesDetectorConstruction(myBFieldOn); 00053 bes3WorldVolume = bes3DetectorConstruction->Construct(); 00054 extPhysicsList = new ExtPhysicsList; 00055 extTrack = new G4Track; 00056 00057 //for geant4.8.1, move this line to Initialization, extSteppingAction = new ExtSteppingAction; 00058 extTrackingManager = new G4TrackingManager; 00059 //RunManagerKernel for geant4.9.0 00060 extRunManagerKernel = new G4RunManagerKernel; 00061 }
|
|
00066 { 00067 if(extRunManagerKernel) delete extRunManagerKernel; 00068 if(extTrackingManager) delete extTrackingManager; 00069 // if(extSteppingAction) delete extSteppingAction; 00070 if(extTrack) delete extTrack; 00071 if(bes3DetectorConstruction) delete bes3DetectorConstruction; 00072 if(extPhysicsList) delete extPhysicsList; 00073 00074 // open geometry for deletion 00075 G4GeometryManager::GetInstance()->OpenGeometry(); 00076 00077 // deletion of Geant4 kernel classes 00078 G4SDManager* fSDM = G4SDManager::GetSDMpointerIfExist(); 00079 if(fSDM) 00080 { 00081 delete fSDM; 00082 } 00083 }
|
|
|
|
|
|
|
|
|
|
00208 { 00209 //add for geant4.8.1 00210 G4RegionStore::GetInstance()->SetWorldVolume(); 00211 00212 for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++) 00213 { 00214 G4Region* region = (*(G4RegionStore::GetInstance()))[i]; 00215 //add for geant4.8.1 00216 if(region->GetWorldPhysical()!=bes3WorldVolume) continue; 00217 G4ProductionCuts* cuts = region->GetProductionCuts(); 00218 if(!cuts) 00219 { 00220 region->SetProductionCuts(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()); 00221 } 00222 } 00223 }
|
|
|
|
00322 { 00323 G4Navigator* navigator= G4TransportationManager::GetTransportationManager()-> GetNavigatorForTracking(); 00324 00325 G4VPhysicalVolume* world= navigator-> GetWorldVolume(); 00326 G4VSolid* solid= world-> GetLogicalVolume()-> GetSolid(); 00327 EInside qinside= solid-> Inside(pos); 00328 00329 if( qinside != kInside) return false; 00330 else return true; 00331 }
|
|
Modifiers for the track direction. (0/1)=(outgoing/incoming). |
|
Modifiers for the track direction. (0/1)=(outgoing/incoming). 00152 { m_dir = dir; }
|
|
|
|
00116 { 00117 if(myMsgFlag) cout << "Ext_track::GeometryInitialization()." << endl; 00118 00119 //for geant4.9.0, DefaultRegionForTheWorld has been defined in G4RunManagerKernel. 00120 /*G4RegionStore* rStore = G4RegionStore::GetInstance(); 00121 G4Region* defaultRegion=rStore->GetRegion("DefaultRegionForTheWorld",false); 00122 if(!defaultRegion) 00123 { 00124 defaultRegion=new G4Region("DefaultRegionForTheWorld"); 00125 defaultRegion->SetProductionCuts(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()); 00126 }*/ 00127 G4Region *defaultRegion=new G4Region("DefaultRegionForBesWorld"); 00128 defaultRegion->SetProductionCuts(G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts()); 00129 00130 // The world volume MUST NOT have a region defined by the user 00131 if(bes3WorldVolume->GetLogicalVolume()->GetRegion()) 00132 { 00133 if(bes3WorldVolume->GetLogicalVolume()->GetRegion()!=defaultRegion) 00134 { 00135 cout << "The world volume has a user-defined region <" 00136 << bes3WorldVolume->GetLogicalVolume()->GetRegion()->GetName() 00137 << ">." << G4endl; 00138 return 0; 00139 } 00140 } 00141 00142 // Remove old world logical volume from the default region, if exist 00143 if(defaultRegion->GetNumberOfRootVolumes()) 00144 { 00145 if(defaultRegion->GetNumberOfRootVolumes()>size_t(1)) 00146 { 00147 cout <<"DefaultRegionHasMoreThanOneVolume,Default world region should have a unique logical volume."<<endl; 00148 return 0; 00149 } 00150 std::vector<G4LogicalVolume*>::iterator lvItr = defaultRegion->GetRootLogicalVolumeIterator(); 00151 defaultRegion->RemoveRootLogicalVolume(*lvItr); 00152 cout << (*lvItr)->GetName() 00153 << " is removed from the default region." << endl; 00154 } 00155 00156 // Set the default region to the world 00157 G4LogicalVolume* bes3WorldLog = bes3WorldVolume->GetLogicalVolume(); 00158 bes3WorldLog->SetRegion(defaultRegion); 00159 defaultRegion->AddRootLogicalVolume(bes3WorldLog); 00160 00161 // Set the world volume, notify the Navigator and reset its state 00162 G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->SetWorldVolume(bes3WorldVolume); 00163 00164 return 1; 00165 }
|
|
00090 {return extSteppingAction;};
|
|
00090 {return extSteppingAction;};
|
|
|
|
00090 { 00091 myMsgFlag=aMsgFlag; 00092 myGeomOptimization = GeomOptimization; 00093 myBFieldOn=Bfield, 00094 00095 //add for geant4.8.1 00096 G4ParticleTable::GetParticleTable()->SetReadiness(); 00097 extPhysicsList->ConstructParticle(); 00098 00099 if(myMsgFlag) cout << "Ext_track::Init will execute geant initialization." << endl; 00100 if(!GeometryInitialization()) cout << "Error in Ext_track::GeometryInitialization()" << endl; 00101 PhysicsInitialization(); 00102 00103 extSteppingAction = new ExtSteppingAction; 00104 extSteppingAction->SetMsgFlag(aMsgFlag); 00105 //Set extSteppingAction 00106 extTrackingManager->SetUserAction(extSteppingAction); 00107 00108 00109 00110 }
|
|
|
|
00170 { 00171 if(myMsgFlag) cout<<"Ext_track::PhysicsInitialization()."<<endl; 00172 // Following line is tentatively moved from SetPhysics method 00173 // G4ParticleTable::GetParticleTable()->SetReadiness(); 00174 00175 // extPhysicsList->ConstructParticle(); 00176 extPhysicsList->Construct(); 00177 extPhysicsList->SetCuts(); 00178 00179 CheckRegions(); 00180 00181 //update region 00182 G4RegionStore::GetInstance()->UpdateMaterialList(bes3WorldVolume); 00183 G4ProductionCutsTable::GetProductionCutsTable()->UpdateCoupleTable(bes3WorldVolume); 00184 00185 //Build PhysicsTables 00186 if(myMsgFlag) cout<<"Build PhysicsTables"<<endl; 00187 extPhysicsList->BuildPhysicsTable(); 00188 if(myMsgFlag) cout<<"Build PhysicsTables end."<<endl; 00189 G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated(); 00190 extPhysicsList->DumpCutValuesTableIfRequested(); 00191 00192 //Geometry Optimization 00193 if(myGeomOptimization) 00194 { 00195 cout<<"Geometry Optimization,please wait for a few minutes."<<endl; 00196 G4GeometryManager* geomManager = G4GeometryManager::GetInstance(); 00197 geomManager->OpenGeometry(); 00198 geomManager->CloseGeometry(true, false); 00199 } 00200 00201 return 1; 00202 }
|
|
Print out the contents of the error skip list. |
|
Print out the contents of the error skip list. 00232 { 00233 if( err.num_row() != 6 ){ // ?static const int Ndim_err=6, see Ext_errmx.h line58 00234 std::cerr << "%ERROR at Ext_track::Set. Dimension of error matrix: " 00235 << err.num_row() << " should be 6" << std::endl; 00236 exit( 0 ); 00237 } 00238 00239 m_vect[0] = xv3.x();// ?set starting position,private data 00240 m_vect[1] = xv3.y(); 00241 m_vect[2] = xv3.z(); 00242 00243 // m_errskip_flag = 0; 00244 // m_errskip_level = 0; 00245 00246 00247 // Check the starting point is inside the setup. 00248 if(!CheckVertexInsideWorld(xv3)) return 0; 00249 00250 float p( pv3.mag() ); 00251 m_vect[3] = pv3.x()/p; //?set direction of momentum 00252 m_vect[4] = pv3.y()/p; 00253 m_vect[5] = pv3.z()/p; 00254 m_vect[6] = p; 00255 00256 // check Particlename 00257 if(particleName!="e+"&&particleName!="e-"&& 00258 particleName!="mu+"&&particleName!="mu-"&& 00259 particleName!="pi+"&&particleName!="pi-"&& 00260 particleName!="kaon+"&&particleName!="kaon-"&& 00261 particleName!="proton"&&particleName!="anti_proton"&& 00262 particleName!="gamma") 00263 { 00264 std::cerr <<"Unknown or unconstructed Particle."<< std::endl; 00265 return 0; 00266 } 00267 00268 00269 double mass; 00270 double Q; 00271 00272 G4ParticleDefinition* particleDefinition=G4ParticleTable::GetParticleTable()->FindParticle(particleName); 00273 Q = particleDefinition->GetPDGCharge(); 00274 mass = particleDefinition->GetPDGMass(); 00275 00276 00277 Hep3Vector xv( m_vect[0], m_vect[1], m_vect[2] ); 00278 Hep3Vector pv(m_vect[3]*m_vect[6], m_vect[4]*m_vect[6], m_vect[5]*m_vect[6]); 00279 00280 m_xp_err.set_err( err, xv, pv, Q, mass ); // Set error matrix. 00281 00282 extSteppingAction->SetXpErrPointer(&m_xp_err); 00283 extSteppingAction->SetInitialPath(pathInMDC); 00284 extSteppingAction->SetInitialTof(tofInMdc); 00285 00286 double betaInMDC = p/sqrt(mass*mass+p*p);//velocity 00287 extSteppingAction->SetBetaInMDC(betaInMDC); 00288 // double tofInMDC = pathInMDC/(betaInMDC*299.792458); 00289 // if(myMsgFlag) cout<<"TOF in MDC: "<<tofInMDC<<endl; 00290 00291 extSteppingAction->Reset(); 00292 00293 // extTrack Initialization. 00294 00295 /* // comment 2008.04.07 due to memory loss 00296 // Initialize a G4PrimaryParticle. 00297 G4PrimaryParticle* primaryParticle = new G4PrimaryParticle(particleDefinition,pv3.x(),pv3.y(),pv3.z()); 00298 primaryParticle->SetMass(mass); 00299 primaryParticle->SetCharge(Q); 00300 00301 // Initialize a G4DynamicParticle. 00302 // G4DynamicParticle* DP = new G4DynamicParticle(particleDefinition,primaryParticle->GetMomentum()); 00303 // DP->SetPrimaryParticle(primaryParticle); 00304 */ 00305 G4DynamicParticle* DP = new G4DynamicParticle(particleDefinition,pv); 00306 00307 delete extTrack; // add on 2008.04.07 to avoid memory loss 00308 extTrack = new G4Track(DP,0.0,xv3); 00309 // extTrack->CopyTrackInfo(G4Track::G4Track(DP,0.0,xv3)); 00310 00311 // Reset navigator 00312 Hep3Vector center(0,0,0); 00313 G4Navigator* navigator= G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); 00314 navigator->LocateGlobalPointAndSetup(center,0,false); 00315 00316 return 1; 00317 }
|
|
|
|
00340 { 00341 extTrackingManager->ProcessOneTrack(extTrack); 00342 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|