00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "BesMucConstruction.hh"
00012 #include "BesMucSD.hh"
00013 #include "ReadBoostRoot.hh"
00014 #include "G4Tubs.hh"
00015 #include "G4LogicalVolume.hh"
00016 #include "G4VPhysicalVolume.hh"
00017 #include "G4ThreeVector.hh"
00018 #include "G4Material.hh"
00019 #include "G4PVPlacement.hh"
00020 #include "globals.hh"
00021 #include "G4SDManager.hh"
00022 #include "G4VisAttributes.hh"
00023 #include "G4Color.hh"
00024 #include "G4ios.hh"
00025 #include "globals.hh"
00026 #include <cstdlib>
00027
00028 #include "strstream"
00029
00030 #include "G4Geo/MucG4Geo.h"
00031
00032
00033 BesMucConstruction::BesMucConstruction()
00034 {
00035 }
00036
00037 BesMucConstruction::~BesMucConstruction()
00038 {
00039 }
00040
00041 void BesMucConstruction::Construct(G4LogicalVolume* logicBes)
00042 {
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 MucG4Geo *aMucG4Geo = new MucG4Geo();
00069 G4LogicalVolume* logicalMuc = aMucG4Geo->GetTopVolume();
00070
00071
00072 if(!logicalMuc) {
00073 G4cout << "BesMucConstruction::Construct() 1, logicalMuc not found!" << G4endl;
00074 }
00075 else {
00076
00077 physicalMuc = new G4PVPlacement(0,
00078 G4ThreeVector(0,0,0),
00079 logicalMuc,
00080 "PhysicalMuc",
00081 logicBes,
00082 false,
00083 0);
00084 logicalMuc->SetVisAttributes (G4VisAttributes::Invisible);
00085 }
00086
00087
00088 G4SDManager* aSDman = G4SDManager::GetSDMpointer();
00089 BesMucSD* aMucSD = new BesMucSD("BesMucSD", this);
00090 aSDman->AddNewDetector(aMucSD);
00091
00092 G4LogicalVolume* lv = 0;
00093
00094 G4int partMax = 3;
00095
00096 G4int stripMax = 96, bakeliteMax = 4, gasChamberMax = 2;
00097 G4int segOnPart[3] = {4, 8, 4};
00098 G4int absorberOnPart[3] = {9, 9, 9};
00099 G4int gapOnPart[3] = {8, 9, 8};
00100 G4int panelOnPart[3] = {3, 4, 3};
00101 G4int part, seg, absorber, panel, gap, bakelite, gasChamber, strip;
00102
00103 for(part = 0; part < partMax; part++) {
00104
00105 for(seg = 0; seg < segOnPart[part]; seg++) {
00106 if(seg==0||part==1&&seg==2){
00107 for(gap = 0; gap < gapOnPart[part]; gap++) {
00108 for(gasChamber = 0; gasChamber < gasChamberMax; gasChamber++) {
00109 int seg_shift = 0; if(part==1&&seg==2) seg_shift = 1;
00110 for(panel = 0; panel < panelOnPart[part] + seg_shift; panel++) {
00111 std::ostrstream sf;
00112 sf << "l" << "Muc"
00113 << "P" << part
00114 << "S" << seg
00115 << "G" << gap
00116 << "R" << gasChamber
00117 << "Pn" << panel
00118 << "C"
00119 << std::ends;
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 lv = FindLogicalVolume(sf.str());
00131 if(!lv) {
00132 G4cout << "BesMucConstruction::Construct(), " << sf.str() << " not found!" << G4endl;
00133 }
00134 else {
00135 lv->SetSensitiveDetector(aMucSD);
00136 }
00137 }
00138 }
00139 }
00140 }
00141 }
00142 }
00143
00144
00145 G4VisAttributes* mucVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0, 0.05));
00146 G4VisAttributes* absorberVisAtt = new G4VisAttributes(G4Colour(1.0, 0.3, 0.0, 1.0));
00147 G4VisAttributes* gapVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 1.0));
00148 G4VisAttributes* stripVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0, 1.0));
00149 G4VisAttributes* bakeliteVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0, 1.0));
00150 G4VisAttributes* gasChamberVisAtt = new G4VisAttributes(G4Colour(0.6, 0.8, 1.0, 1.0));
00151
00152 lv = FindLogicalVolume("logicalMuc");
00153 if(!lv) {
00154 G4cout << "BesMucConstruction::Construct() 2, logicMuc not found!" << G4endl;
00155 }
00156 else {
00157 lv->SetVisAttributes(mucVisAtt);
00158 lv->SetVisAttributes (G4VisAttributes::Invisible);
00159 }
00160
00161 for(part = 0; part < partMax; part++) {
00162 for(seg = 0; seg < segOnPart[part]; seg++) {
00163 for(absorber = 0; absorber < absorberOnPart[part]; absorber++) {
00164 std::ostrstream sf;
00165 sf << "logical" << "Muc"
00166 << "Part" << part
00167 << "Seg" << seg
00168 << "Absorber" << absorber
00169 << std::ends;
00170
00171 lv = FindLogicalVolume(sf.str());
00172 if(lv) {
00173 lv->SetVisAttributes(absorberVisAtt);
00174
00175 if(part != 1) {
00176 lv->SetVisAttributes (G4VisAttributes::Invisible);
00177 }
00178 }
00179 }
00180 }
00181 }
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 for(part = 0; part < partMax; part++) {
00209 for(seg = 0; seg < segOnPart[part]; seg++) {
00210 for(gap = 0; gap < gapOnPart[part]; gap++) {
00211 std::ostrstream sf;
00212 sf << "logical" << "Muc"
00213 << "Part" << part
00214 << "Seg" << seg
00215 << "Gap" << gap
00216 << std::ends;
00217
00218 lv = FindLogicalVolume(sf.str());
00219 if(lv) {
00220 lv->SetVisAttributes(gapVisAtt);
00221 lv->SetVisAttributes(G4VisAttributes::Invisible);
00222 }
00223 }
00224 }
00225 }
00226
00227 for(part = 0; part < partMax; part++) {
00228 for(seg = 0; seg < 1; seg++) {
00229
00230 for(gap = 0; gap < gapOnPart[part]; gap++) {
00231 std::ostrstream sf;
00232 sf << "logical" << "Muc"
00233 << "Part" << part
00234 << "Seg" << seg
00235 << "Gap" << gap
00236 << "StripPlane"
00237 << std::ends;
00238
00239 lv = FindLogicalVolume(sf.str());
00240 if(lv) {
00241 lv->SetVisAttributes(gapVisAtt);
00242 lv->SetVisAttributes(G4VisAttributes::Invisible);
00243 }
00244 }
00245 }
00246 }
00247
00248 for(part = 0; part < partMax; part++) {
00249 for(seg = 0; seg < 1; seg++) {
00250
00251 for(gap = 0; gap < gapOnPart[part]; gap++) {
00252 for(strip = 0; strip < stripMax; strip++) {
00253 std::ostrstream sf;
00254 if(strip >= 0 && strip < 10) {
00255 sf << "logical" << "Muc"
00256 << "Part" << part
00257 << "Seg" << seg
00258 << "Gap" << gap
00259 << "Strip0" << strip
00260 << std::ends;
00261 }
00262 else if(strip >= 10 && strip < 100) {
00263 sf << "logical" << "Muc"
00264 << "Part" << part
00265 << "Seg" << seg
00266 << "Gap" << gap
00267 << "Strip" << strip
00268 << std::ends;
00269 }
00270 else {
00271 G4cout << "BesMucConstruction::Construct(), strip=" << strip << " error!" << G4endl;
00272 }
00273
00274 lv = FindLogicalVolume(sf.str());
00275 if(lv) {
00276 lv->SetVisAttributes(stripVisAtt);
00277 lv->SetVisAttributes(G4VisAttributes::Invisible);
00278 }
00279 }
00280 }
00281 }
00282 }
00283
00284 for(part = 0; part < partMax; part++) {
00285 for(seg = 0; seg < 1; seg++) {
00286
00287 for(gap = 0; gap < gapOnPart[part]; gap++) {
00288 for(panel = 0; panel < panelOnPart[part]; panel++) {
00289 for(bakelite = 0; bakelite < bakeliteMax; bakelite++) {
00290 std::ostrstream sf;
00291 sf << "logical" << "Muc"
00292 << "Part" << part
00293 << "Seg" << seg
00294 << "Gap" << gap
00295 << "Panel" << panel
00296 << "Bakelite" << bakelite
00297 << std::ends;
00298
00299 lv = FindLogicalVolume(sf.str());
00300 if(lv) {
00301 lv->SetVisAttributes(bakeliteVisAtt);
00302 lv->SetVisAttributes(G4VisAttributes::Invisible);
00303 }
00304 }
00305 }
00306 }
00307 }
00308 }
00309
00310
00311 for(part = 0; part < partMax; part++) {
00312 for(seg = 0; seg < 1; seg++) {
00313
00314 for(gap = 0; gap < gapOnPart[part]; gap++) {
00315 for(panel = 0; panel < panelOnPart[part]; panel++) {
00316 for(gasChamber = 0; gasChamber < gasChamberMax; gasChamber++) {
00317 std::ostrstream sf;
00318 sf << "logical" << "Muc"
00319 << "Part" << part
00320 << "Seg" << seg
00321 << "Gap" << gap
00322 << "Panel" << panel
00323 << "GasChamber" << gasChamber
00324 << std::ends;
00325
00326 lv = FindLogicalVolume(sf.str());
00327 if(lv) {
00328 lv->SetVisAttributes(gasChamberVisAtt);
00329
00330
00331
00332
00333 if(part != 1) {
00334 lv->SetVisAttributes(G4VisAttributes::Invisible);
00335 }
00336 }
00337 }
00338 }
00339 }
00340 }
00341 }
00342
00343 delete aMucG4Geo;
00344 }
00345
00346
00347
00348
00349
00350