/home/cern/BDSIM_new/src/BDSDrift.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 24.7.2002
00004    Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 */
00006 #include "BDSGlobalConstants.hh" // must be first in include list
00007 
00008 #include "BDSDrift.hh"
00009 #include "G4Box.hh"
00010 #include "G4Tubs.hh"
00011 #include "G4VisAttributes.hh"
00012 #include "G4LogicalVolume.hh"
00013 #include "G4VPhysicalVolume.hh"
00014 #include "G4UserLimits.hh"
00015 #include "G4TransportationManager.hh"
00016 
00017 #include <map>
00018 
00019 const int DEBUG = 0;
00020 
00021 //============================================================
00022 
00023 typedef std::map<G4String,int> LogVolCountMap;
00024 extern LogVolCountMap* LogVolCount;
00025 
00026 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00027 extern LogVolMap* LogVol;
00028 
00029 extern BDSMaterials* theMaterials;
00030 //============================================================
00031 
00032 BDSDrift::BDSDrift (G4String aName, G4double aLength,
00033                     G4double bpRad):
00034   BDSMultipole(aName, aLength, bpRad, bpRad, SetVisAttributes())
00035 {
00036   G4double outerR=bpRad+1*mm;
00037   SetOuterRadius(outerR);
00038   itsType="drift";
00039 
00040   if (!(*LogVolCount)[itsName])
00041     {
00042       //
00043       // build external volume
00044       // 
00045       BuildDefaultMarkerLogicalVolume();
00046 
00047       //
00048       // build beampipe (geometry + magnetic field)
00049       //
00050       itsBPFieldMgr=NULL;
00051       BuildBeampipe(itsLength);
00052 
00053       // drift doesn't have an outer volume - but include it for laserwire
00054       // BuildDefaultOuterLogicalVolume(itsLength,true);
00055 
00056       //
00057       // define sensitive volumes for hit generation
00058       //
00059       SetSensitiveVolume(itsBeampipeLogicalVolume);// for laserwire
00060       //SetSensitiveVolume(itsOuterLogicalVolume);// for laserwire
00061 
00062       //
00063       // append marker logical volume to volume map
00064       //
00065       (*LogVolCount)[itsName]=1;
00066       (*LogVol)[itsName]=itsMarkerLogicalVolume;
00067     }
00068   else
00069     {
00070       (*LogVolCount)[itsName]++;
00071 
00072       //
00073       // use already defined marker volume
00074       //
00075       itsMarkerLogicalVolume=(*LogVol)[itsName];
00076     }
00077 }
00078 
00079 G4VisAttributes* BDSDrift::SetVisAttributes()
00080 {
00081   itsVisAttributes=new G4VisAttributes(G4Colour(0,1,0)); //useless
00082   return itsVisAttributes;
00083 }
00084 
00085 BDSDrift::~BDSDrift()
00086 {
00087   if(itsVisAttributes) delete itsVisAttributes;
00088   if(itsMarkerLogicalVolume) delete itsMarkerLogicalVolume;
00089   if(itsOuterLogicalVolume) delete itsOuterLogicalVolume;
00090   if(itsPhysiComp) delete itsPhysiComp;
00091   //if(itsField) delete itsField;
00092   //if(itsEqRhs) delete itsEqRhs;
00093   //if(itsStepper) delete itsStepper;
00094 }

Generated on Wed Mar 5 17:25:22 2008 for BDSIM by  doxygen 1.5.3