Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:58

0001 #include "PHG4EnvelopeDetector.h"
0002 
0003 #include <g4main/PHG4Detector.h>  // for PHG4Detector
0004 
0005 #include <Geant4/G4Colour.hh>
0006 #include <Geant4/G4Cons.hh>
0007 #include <Geant4/G4LogicalVolume.hh>
0008 #include <Geant4/G4PVPlacement.hh>
0009 #include <Geant4/G4RotationMatrix.hh>  // for G4RotationMatrix
0010 #include <Geant4/G4String.hh>          // for G4String
0011 #include <Geant4/G4SystemOfUnits.hh>   // for mm, m
0012 #include <Geant4/G4ThreeVector.hh>     // for G4ThreeVector
0013 #include <Geant4/G4Transform3D.hh>     // for G4Transform3D
0014 #include <Geant4/G4Tubs.hh>
0015 #include <Geant4/G4Types.hh>            // for G4double
0016 #include <Geant4/G4VPhysicalVolume.hh>  // for G4VPhysicalVolume
0017 #include <Geant4/G4VisAttributes.hh>
0018 
0019 #include <cmath>  // for M_PI
0020 #include <iostream>
0021 
0022 class G4Material;
0023 class G4VSolid;
0024 class PHCompositeNode;
0025 
0026 //___________________________________________________________________________________
0027 PHG4EnvelopeDetector::PHG4EnvelopeDetector(PHG4Subsystem* subsys, PHCompositeNode* Node, const std::string& dnam)
0028   : PHG4Detector(subsys, Node, dnam)
0029   , _placeInX(0.0 * mm)
0030   , _placeInY(0.0 * mm)
0031   , _placeInZ(2.0 * m)
0032   , _innerRadius(0.0 * m)
0033   , _outerRadius(1.0 * m)
0034   , _dZ(1.0 * mm)
0035   , _dZ_cyl(2.0 * m)
0036   , _sPhi(0)
0037   , _dPhi(2 * M_PI)
0038   , _materialCrystal("G4_PbWO4")
0039   , _active(1)
0040   , _layer(0)
0041   , _superdetector("NONE")
0042 {
0043 }
0044 
0045 //_______________________________________________________________________________________
0046 bool PHG4EnvelopeDetector::IsInEnvelope(G4VPhysicalVolume* volume) const
0047 {
0048   if (volume->GetName().find("arbage") != std::string::npos)
0049   {
0050     return true;
0051   }
0052   else
0053   {
0054     return false;
0055   }
0056 }
0057 
0058 void PHG4EnvelopeDetector::ConstructMe(G4LogicalVolume* logicWorld)
0059 {
0060   //***************
0061   // Backward Endcap
0062   //***************
0063 
0064   G4double placeInZ = _placeInZ;
0065   G4double placeInY = _placeInY;
0066   G4double placeInX = _placeInX;
0067 
0068   G4double rMin1 = _innerRadius;
0069   G4double rMax1 = _outerRadius;
0070   G4double rMin2 = rMin1;
0071   G4double rMax2 = rMax1;
0072   G4double dZ = _dZ;
0073   G4double sPhi = _sPhi;
0074   G4double dPhi = _dPhi;
0075 
0076   G4Material* material_crystal = GetDetectorMaterial("G4_PbWO4");
0077 
0078   G4VSolid* GarbageCollector_solid = new G4Cons("GarbageCollector_solid",
0079                                                 rMin1, rMax1,
0080                                                 rMin2, rMax2,
0081                                                 dZ / 2.,
0082                                                 sPhi, dPhi);
0083 
0084   G4LogicalVolume* GarbageCollector_logical = new G4LogicalVolume(GarbageCollector_solid, material_crystal, G4String("GarbageCollector"), nullptr, nullptr, nullptr);
0085 
0086   G4VisAttributes* ecalVisAtt = new G4VisAttributes();
0087   ecalVisAtt->SetVisibility(true);
0088   ecalVisAtt->SetForceSolid(false);
0089   ecalVisAtt->SetColour(G4Colour::Magenta());
0090   GarbageCollector_logical->SetVisAttributes(ecalVisAtt);
0091 
0092   G4RotationMatrix ecal_rotm;
0093   ecal_rotm.rotateX(0);
0094   ecal_rotm.rotateY(0);
0095   ecal_rotm.rotateZ(0);
0096 
0097   new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(placeInX, placeInY, placeInZ)),
0098                     GarbageCollector_logical,
0099                     "GarbageCollector",
0100                     logicWorld,
0101                     false,
0102                     false,
0103                     OverlapCheck());
0104 
0105   //**************
0106   // Forward Endcap
0107   //**************
0108 
0109   new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(placeInX, placeInY, -1 * placeInZ)),
0110                     GarbageCollector_logical,
0111                     "GarbageCollector_front",
0112                     logicWorld,
0113                     false,
0114                     false,
0115                     OverlapCheck());
0116 
0117   //*****************************
0118   // Cylinder Surrounding Detector
0119   //*****************************
0120 
0121   G4double cyl_place = 0 * mm;
0122   G4double r_min = _outerRadius + (1) * mm;
0123   G4double r_max = r_min + 1 * mm;
0124   G4double dZ_cyl = _dZ_cyl;
0125 
0126   G4VSolid* GarbageCollector_cyl_solid = new G4Tubs("GarbageCollector_cyl_solid",
0127                                                     r_min,
0128                                                     r_max,
0129                                                     dZ_cyl,
0130                                                     sPhi,
0131                                                     dPhi);
0132 
0133   G4LogicalVolume* GarbageCollector_cyl_logical = new G4LogicalVolume(GarbageCollector_cyl_solid,
0134                                                                       material_crystal,
0135                                                                       G4String("GarbageCollector_cyl"),
0136                                                                       nullptr,
0137                                                                       nullptr,
0138                                                                       nullptr);
0139 
0140   GarbageCollector_cyl_logical->SetVisAttributes(ecalVisAtt);
0141 
0142   new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(0, 0, cyl_place)),
0143                     GarbageCollector_cyl_logical,
0144                     "GarbageCollector_cyl",
0145                     logicWorld,
0146                     false,
0147                     false,
0148                     OverlapCheck());
0149 }