Commit 7f71a49c authored by Valentina Fioretti's avatar Valentina Fioretti
Browse files

EXP5 added

parent 81afa280
Loading
Loading
Loading
Loading
+223 −0
Original line number Diff line number Diff line
@@ -3938,6 +3938,229 @@ G4VPhysicalVolume* EXACRAD::ConstructGeometry(G4VPhysicalVolume* World_phys) {
        
    }

    if (EXACRAD_exp_type == 5){
        // ------------------------------------------------------------
        // AREMBES CCN2 experiment
        // only target and detector
        // target = Si slab
        
        
        //%%%%%%%%% LABORATORY CHAMBER
        
        // vacuum or not vacuum in the laboratory
        G4int vacuum_flag = 0;
        gm.config->readInto(vacuum_flag, "GEOM.EXACRAD.5.VACUUM");
        G4cout << "GEOM.EXACRAD.5.VACUUM: " << vacuum_flag << G4endl;
        
        if (vacuum_flag){
            chamber_mat = materials->GetMaterial(12);
        }
        if (!vacuum_flag){
            chamber_mat = materials->GetMaterial(45);
        }
        
        
        //chamber
        G4double chamber_side = 20.0*m;
        G4Box* chamber = new G4Box("chamber",
                                   chamber_side/2.,
                                   chamber_side/2.,
                                   chamber_side/2.);
        
        G4LogicalVolume* log_chamber = new G4LogicalVolume(chamber, chamber_mat, "log_chamber");
        G4VPhysicalVolume* phys_chamber = new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), log_chamber, "phys_chamber", World_log, false, 0);
        
        log_chamber->SetVisAttributes (G4VisAttributes::GetInvisible());
        
        // %%%%%%%%%%% USER LIMIT
        // Sets a max Step length:
        G4double maxStep = 0.;
        gm.config->readInto(maxStep, "GEOM.EXACRAD.5.MAXSTEP");
        G4cout << "GEOM.EXACRAD.5.MAXSTEP: " << maxStep << G4endl;
        target_limit = new G4UserLimits(maxStep);
        
        
        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        // dummy volume for input sampling
        G4double coll_dist = 0.; // distance from the coll right side to the target center
        gm.config->readInto(coll_dist, "GEOM.EXACRAD.5.COLLIMATOR.DISTANCE");
        G4cout << "GEOM.EXACRAD.5.COLLIMATOR.DISTANCE: " << coll_dist << G4endl;
        
        //Rotations
        G4RotationMatrix* input_rotation = new G4RotationMatrix;
        input_rotation->rotateY(-90.*degree);

        G4double dummy_exit_xside = 0.; // xside of the collimator exit (zside when rotated)
        gm.config->readInto(dummy_exit_xside, "GEOM.EXACRAD.5.COLLIMATOR.ZSIDE");
        G4cout << "GEOM.EXACRAD.5.COLLIMATOR.ZSIDE: " << dummy_exit_xside << G4endl;

        G4double dummy_exit_yside = 0.; // xside of the collimator exit (zside when rotated)
        gm.config->readInto(dummy_exit_yside, "GEOM.EXACRAD.5.COLLIMATOR.YSIDE");
        G4cout << "GEOM.EXACRAD.5.COLLIMATOR.YSIDE: " << dummy_exit_yside << G4endl;
        
        // dummy collimator exit
        G4double dummy_coll_exit_t = 0.001*mm;
        
        G4Box* dummy_coll_exit = new G4Box("dummy_coll_exit",
                                           dummy_exit_xside*0.5,
                                           dummy_exit_yside*0.5,
                                           dummy_coll_exit_t/2.);
        
        //copy number of input sampling
        G4int dummy_coll_exit_copyno = 2;
        
        // position
        G4ThreeVector dummy_coll_exit_pos(-coll_dist + dummy_coll_exit_t*0.5,0.,0.);
        
        //Logical and Physical Volume
        G4LogicalVolume* logDummyCollExit  = new G4LogicalVolume(dummy_coll_exit,chamber_mat,"logDummyCollExit",0,0,0);
        G4VPhysicalVolume* physDummyCollExit = new G4PVPlacement(input_rotation,dummy_coll_exit_pos,logDummyCollExit,"pDummyCollExit",log_chamber,false,dummy_coll_exit_copyno);
        
        G4VisAttributes* visCollExit = new G4VisAttributes(G4Colour::Green());
        logDummyCollExit->SetVisAttributes(visCollExit);
        gm.AddXYZDetector( logDummyCollExit);
        
        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        
        //%%%%%%%%% target
        
        // target type
        G4int target_type = 0;
        gm.config->readInto(target_type, "GEOM.EXACRAD.5.TARGET");
        G4cout << "GEOM.EXACRAD.5.TARGET: " << target_type << G4endl;
        
        // incident angle
        G4double incident_angle = 0;
        gm.config->readInto(incident_angle, "GEOM.EXACRAD.5.INCIDENT.ANGLE");
        G4cout << "GEOM.EXACRAD.5.INCIDENT.ANGLE: " << incident_angle << G4endl;
        
        // set the slab thickness
        G4double spo_plate_t = 0;
        gm.config->readInto(spo_plate_t, "GEOM.SLAB.THICKNESS");
        G4cout << "GEOM.SLAB.THICKNESS: " << spo_plate_t << G4endl;
        
        //Rotations
        G4RotationMatrix* target_rotation = new G4RotationMatrix;
        target_rotation->rotateY(incident_angle*degree);
        

        if (target_type == 1){//single slab made of Si
            
            G4double plate_yside = 5.0*cm;
            G4double plate_xside = 11.0*cm;

            spo_plate_mat = materials->GetMaterial(9); // Si
            G4int spo_plate_copyno = 34;
            
            // Coating 3
            auto rotation = new G4RotationMatrix();
            G4VSolid* solid_Coating3;
            
            G4double tan_theta = tan ( incident_angle * PI / 180.0 );
            G4double sin_theta = sin ( incident_angle * PI / 180.0 );
            G4double stepH = spo_plate_t;
            G4double trans_right = stepH*sin_theta;
            G4double trans_right_no3D = (stepH/2.)*sin_theta;
            G4double stepE = trans_right/tan_theta;
            G4double stepE_no3D = trans_right_no3D/tan_theta;
            G4double trans_up = stepH - stepE;
            G4double trans_up_no3D = (stepH/2.) - stepE_no3D;

            G4Box* coating3 = new G4Box("coating3",
                                        plate_xside/2.,
                                        plate_yside/2.,
                                        spo_plate_t/2.);
                
            G4LogicalVolume* log_coating3 = new G4LogicalVolume(coating3, spo_plate_mat, "log_coating3");
            G4VPhysicalVolume* phys_coating3 = new G4PVPlacement(target_rotation, G4ThreeVector(trans_right_no3D,0.0, -spo_plate_t/2. + trans_up_no3D), log_coating3, "phys_coating3", log_chamber, false, spo_plate_copyno);
                
            G4VisAttributes* visCoating3 = new G4VisAttributes(G4Colour::Green());
            log_coating3->SetVisAttributes(visCoating3);
            gm.AddXYZDetector( log_coating3);
            log_coating3->SetUserLimits(target_limit);
            region_target->AddRootLogicalVolume(log_coating3);

        }
        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        // dummy detector implementation as circle
        
        //Rotations
        G4RotationMatrix* coll_rotation = new G4RotationMatrix;
        coll_rotation->rotateY(-90.*degree);
        
        if (target_type >= 1){
            // detector thickness
            G4double det_t = 0.1*mm;
            
            // central detector
            G4double det_diameter = 16.*cm;


            G4double det_dist;
            // distance from the target center to the dummy panel left side
            gm.config->readInto(det_dist, "GEOM.EXACRAD.5.PANEL.DISTANCE");
            G4cout << "GEOM.EXACRAD.5.PANEL.DISTANCE: " << det_dist << G4endl;
            
            G4Tubs* detector = new G4Tubs("detector",
                                          0.*mm,
                                          det_diameter/2.,
                                          det_t/2.,
                                          0*degree,
                                          360*degree);
            
            
            //detector copy number
            G4int det_copy = 100;
            // detector material
            det_mat = materials->GetMaterial(12); // vacuum
            
            //Logical and Physical Volume
            G4LogicalVolume* logDetector  = new G4LogicalVolume(detector,det_mat,"logDetector",0,0,0);
            
            // central and lateral detector
            G4VPhysicalVolume* physDetector = new G4PVPlacement(input_rotation,G4ThreeVector(det_dist + det_t*0.5,0., 0), logDetector, "physDetector",log_chamber,false,det_copy);

            G4VisAttributes* visDetector = new G4VisAttributes(G4Colour::Grey());
            //logDetector->SetVisAttributes (G4VisAttributes::Invisible);
            logDetector->SetVisAttributes(visDetector);
            gm.AddXYZDetector( logDetector);
            
        }
        


        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
        // dummy sphere
        G4double dummySphere_Rin = 499.99*cm;
        G4double dummySphere_Rext = 500.*cm;
        
        
        G4Sphere* dummySphere = new G4Sphere("dummySphere",
                                             dummySphere_Rin,
                                             dummySphere_Rext,
                                             0.*rad,
                                             2.*pi*rad,
                                             0.*rad,
                                             pi*rad);
        
        
        
        //fake sphere copy number
        G4int dummySphere_copy = 4;
        
        // fake sphere position
        G4ThreeVector dummySphere_pos(0.,0.,0.);
        
        //Logical and Physical Volume
        G4LogicalVolume* logDummySphere  = new G4LogicalVolume(dummySphere,chamber_mat,"logDummySphere",0,0,0);
        G4VPhysicalVolume* physDummySphere = new G4PVPlacement(0,dummySphere_pos,logDummySphere,"pDummySphere",log_chamber,false,dummySphere_copy);
        
        logDummySphere->SetVisAttributes (G4VisAttributes::GetInvisible());
        gm.AddXYZDetector( logDummySphere);
        
        
    }

    return World_phys;
}