File indexing completed on 2025-02-23 09:19:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifdef ddebug
0035 #include "G4Timer.hh"
0036 #endif
0037 #ifdef debug
0038 #include "CCalutils.hh"
0039 #endif
0040
0041 #include "CCalGeometryConfiguration.hh"
0042 #include "CCalG4Able.hh"
0043 #include "CCalSensitiveConfiguration.hh"
0044
0045 #include "G4Color.hh"
0046 #include "G4VisAttributes.hh"
0047
0048
0049 CCalG4Able::CCalG4Able( G4String name ) :
0050 detPhysicalVolume(0), g4ableName(name), sensitivity(false),
0051 visProperties(CCalSensitiveConfiguration::getInstance()->getFileName(name)+".vis") {
0052
0053 for (G4int i=0; i<CCalVisualisable::TotalVisTypes; ++i) g4VisAtt[i]=0;
0054 sensitivity = CCalSensitiveConfiguration::getInstance()->getSensitiveFlag(name);
0055 }
0056
0057
0058 CCalG4Able::~CCalG4Able() {
0059 if (detPhysicalVolume) delete[] detPhysicalVolume;
0060 }
0061
0062
0063 G4VPhysicalVolume* CCalG4Able::PhysicalVolume( G4VPhysicalVolume* pv ) {
0064
0065
0066 #ifdef ddebug
0067 G4Timer timer;
0068 timer.Start();
0069 #endif
0070 if (CCalGeometryConfiguration::getInstance()->getConstructFlag(G4Name())!=0){
0071 if (!detPhysicalVolume) {
0072 detPhysicalVolume = constructIn(pv);
0073 for (unsigned int i = 0; i < theG4DetectorsInside.size(); i++) {
0074 theG4DetectorsInside[i]->PhysicalVolume(detPhysicalVolume);
0075 }
0076 }
0077 }
0078 else {
0079 G4cout << "NOTE: You decided to skip the construction of " << G4Name() << G4endl;
0080 }
0081 #ifdef ddebug
0082 timer.Stop();
0083 G4cout << tab << "CCalG4Able::PhysicalVolume(...) --> time spent: " << timer << G4endl;
0084 #endif
0085 return detPhysicalVolume;
0086 }
0087
0088
0089 void CCalG4Able::sensitiveHandling() {
0090 if ( CCalGeometryConfiguration::getInstance()->getConstructFlag( G4Name() ) != 0 &&
0091 sensitivity ) {
0092 for (unsigned int i = 0; i < theG4DetectorsInside.size(); i++) {
0093 #ifdef debug
0094 G4cout << "==> Making " << detPhysicalVolume->GetName() << " sensitive..." << G4endl;
0095 #endif
0096 theG4DetectorsInside[i]->constructSensitive();
0097 }
0098 }
0099 }
0100
0101
0102 void CCalG4Able::AddCCalG4Able( CCalG4Able* det ) {
0103 theG4DetectorsInside.push_back(det);
0104 }
0105
0106
0107 void CCalG4Able::setVisType( CCalVisualisable::visType vt, G4LogicalVolume* log ) {
0108 if (!g4VisAtt[vt]) {
0109 #ifdef debug
0110 G4cout << "CCalG4Able::setVisType: Constructing G4VisAttributes for "
0111 << log->GetName() << " as " << vt << G4endl;
0112 #endif
0113 G4Color col( visProperties.colorRed(vt), visProperties.colorGreen(vt),
0114 visProperties.colorBlue(vt) );
0115 G4bool wf = visProperties.isWireFrame(vt);
0116 G4bool visible = visProperties.isVisible(vt);
0117 #ifdef debug
0118 G4cout << "Color: " << visProperties.colorRed(vt) << ", " << visProperties.colorGreen(vt)
0119 << ", " << visProperties.colorBlue(vt) << tab << "Wireframe: " << wf << tab
0120 << "Visible: " << visible << G4endl;
0121 #endif
0122 g4VisAtt[vt] = new G4VisAttributes(col);
0123 g4VisAtt[vt]->SetForceWireframe(wf);
0124 g4VisAtt[vt]->SetVisibility(visible);
0125 }
0126 log->SetVisAttributes(g4VisAtt[vt]);
0127 }
0128
0129
0130 G4bool CCalG4Able::operator==( const CCalG4Able& right ) const {
0131 return detPhysicalVolume==right.detPhysicalVolume;
0132 }
0133
0134
0135 std::ostream& operator<<( std::ostream& os, const CCalG4Able& det ) {
0136 if (det.detPhysicalVolume) os << "Physical volume already constructed." << G4endl;
0137 else os << "Physical volume still not constructed." << G4endl;
0138 if (det.isSensitive()) os << "and it is Sensitive" << G4endl;
0139 else os << "and it is not Sensitive" << G4endl;
0140 return os;
0141 }