/// @file AllPixDetectorConstructionTestStructure.cc /// @brief Implementation of the test structure construction. #include "AllPixDetectorConstruction.hh" // GEANT4 include statements. #include "G4Material.hh" #include "G4MaterialTable.hh" #include "G4Element.hh" #include "G4ElementTable.hh" #include "G4LogicalBorderSurface.hh" #include "G4LogicalSkinSurface.hh" #include "G4Box.hh" #include "G4Tubs.hh" #include "G4Orb.hh" #include "G4LogicalVolume.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" #include "G4PVPlacement.hh" #include "G4OpBoundaryProcess.hh" #include "G4SubtractionSolid.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4ThreeVector.hh" #include "G4GDMLParser.hh" #include "G4NistManager.hh" // ROOT include statements. #include "TString.h" // // AllPixDetectorConstruction::BuildTestStructure method. // void AllPixDetectorConstruction::BuildTestStructure(G4int) { #ifdef _EUTELESCOPE //////////////////////////////////////////////////////////////////////// // Get GDML volume G4GDMLParser parser; G4LogicalVolume * eud_log; //parser.Read("models/test_beam_telescope.gdml"); parser.Read("share/GDML_EUDETAlHolder/EUDETAlHolder.gdml"); //eud_log = parser.GetVolume("EUD0"); eud_log = parser.GetVolume("Structure_105681480"); G4VisAttributes * invisibleVisAtt = new G4VisAttributes(G4Color(1.0, 0.65, 0.0, 0.1)); invisibleVisAtt->SetVisibility(false); int nDaugh = eud_log->GetNoDaughters(); G4cout << " Read volume has " << nDaugh << " daughters" << G4endl; G4VisAttributes * AlFoilVisAtt = new G4VisAttributes(G4Color(1, 1, 1, 1.0)); AlFoilVisAtt->SetVisibility(false); AlFoilVisAtt->SetForceSolid(true); eud_log->SetVisAttributes(AlFoilVisAtt); /* for(int dItr = 0 ; dItr < nDaugh ; dItr++){ G4VPhysicalVolume * tempPhys = eud_log->GetDaughter(dItr); G4cout << tempPhys->GetName() << G4endl; } */ // I will extract the wrapper from this volume G4VSolid * eudAlPlaneSolid = eud_log->GetSolid(); G4VSolid * wrapperSolid; G4SubtractionSolid * subtractionSolid; TString physName = ""; map::iterator testStructItr = m_posVectorTestStructure.begin(); for( ; testStructItr != m_posVectorTestStructure.end() ; testStructItr++){ G4ThreeVector posRel = m_posVector[m_detectorLinkTestStructure[(*testStructItr).first]] - (*testStructItr).second; G4RotationMatrix * rotRel = m_rotVector[m_detectorLinkTestStructure[(*testStructItr).first]]; wrapperSolid = m_wrapper_log[m_detectorLinkTestStructure[(*testStructItr).first]]->GetSolid(); // match to an specific detector subtractionSolid = new G4SubtractionSolid("EUDETAlPlane", eudAlPlaneSolid, wrapperSolid, rotRel, posRel); // match to an specific detector eud_log->SetSolid(subtractionSolid); physName = "test_phys_"; physName += (*testStructItr).first; new G4PVPlacement(m_rotVectorTestStructure[(*testStructItr).first], (*testStructItr).second, eud_log, // Logical volume physName.Data(), // Name expHall_log, // Mother volume logical false, // Unused boolean 0, // copy number true); // overlap } ////////////////////////////////////////////////////////// // Scintillators for EUDET // Materials if( m_scintPos.empty() ) { G4cout << "[ERROR] no scintillators defined. In the macro use the command" << " /allpix/eudet/scint1Pos 0.0 0.0 -24.0 mm" << " Can't recover ... giving up." << G4endl; exit(1); } /* // first plane at 0. mm G4double z1 = -24*mm; G4double z2 = -18*mm; // last plane at 490 mm G4double z3 = 523*mm; G4double z4 = 529*mm; */ G4NistManager * nistman = G4NistManager::Instance(); // Scintillator G4Material * scplastic = nistman->FindOrBuildMaterial("G4_POLYSTYRENE"); // Scintillators G4Box* scintb = new G4Box("scintb", 11.0*mm, 5.4*mm, 3*mm); // scintillators 6mm thick G4VisAttributes * scintAtt = new G4VisAttributes(G4Color(1,0,1,1)); scintAtt->SetLineWidth(1); scintAtt->SetForceSolid(true); // Place scintillators vector::iterator scintItr = m_scintPos.begin(); TString labelLog = ""; TString labelPlacement = ""; TString labelSD = ""; Int_t cntr = 1; G4SDManager * SDman = G4SDManager::GetSDMpointer(); for( ; scintItr != m_scintPos.end() ; scintItr++) { labelLog = "scint"; labelLog += cntr; labelLog += "_log"; labelPlacement = "Scint"; labelPlacement += cntr; G4LogicalVolume * scint_log = new G4LogicalVolume( scintb, scplastic, labelLog.Data()); scint_log->SetVisAttributes(scintAtt); G4RotationMatrix* matrix_s = new G4RotationMatrix(); matrix_s->rotateX(0.*deg); new G4PVPlacement( matrix_s, (*scintItr), scint_log, labelPlacement.Data(), expHall_log, false, 0, true); labelSD = "sdscint"; labelSD += cntr; AllPixTrackerSD * scintTrack = new AllPixTrackerSD( labelSD.Data(), (*scintItr), 0); SDman->AddNewDetector( scintTrack ); scint_log->SetSensitiveDetector( scintTrack ); cntr++; } /* // G4LogicalVolume * scint1_log = new G4LogicalVolume( scintb, scplastic, "scint1_log"); scint1_log->SetVisAttributes(scintAtt); G4RotationMatrix* matrix_s1 = new G4RotationMatrix(); matrix_s1->rotateX(0.*deg); new G4PVPlacement( matrix_s1 , G4ThreeVector(0., 0., z1), scint1_log, "Scint1", expHall_log, false, 0, true); G4LogicalVolume * scint2_log = new G4LogicalVolume( scintb, scplastic, "scint2_log"); scint2_log->SetVisAttributes(scintAtt); G4RotationMatrix* matrix_s2 = new G4RotationMatrix(); matrix_s2->rotateX(0.*deg); new G4PVPlacement( matrix_s2 , G4ThreeVector(0., 0., z2), scint2_log, "Scint2", expHall_log, false, 0, true); G4LogicalVolume * scint3_log = new G4LogicalVolume( scintb, scplastic, "scint3_log"); scint3_log->SetVisAttributes(scintAtt); G4RotationMatrix* matrix_s3 = new G4RotationMatrix(); matrix_s3->rotateX(0.*deg); new G4PVPlacement( matrix_s3 , G4ThreeVector(0., 0., z3), scint3_log, "Scint3", expHall_log, false, 0, true); G4LogicalVolume * scint4_log = new G4LogicalVolume( scintb, scplastic, "scint4_log"); scint4_log->SetVisAttributes(scintAtt); G4RotationMatrix* matrix_s4 = new G4RotationMatrix(); matrix_s4->rotateX(0.*deg); new G4PVPlacement( matrix_s4 , G4ThreeVector(0., 0., z4), scint4_log, "Scint4", expHall_log, false, 0, true); // SD manager G4SDManager * SDman = G4SDManager::GetSDMpointer(); AllPixTrackerSD * scintTrack1 = new AllPixTrackerSD( "sdscint1", G4ThreeVector(0., 0., z1), 0); SDman->AddNewDetector( scintTrack1 ); scint1_log->SetSensitiveDetector( scintTrack1 ); AllPixTrackerSD * scintTrack2 = new AllPixTrackerSD( "sdscint2", G4ThreeVector(0., 0., z2), 0); SDman->AddNewDetector( scintTrack2 ); scint2_log->SetSensitiveDetector( scintTrack2 ); AllPixTrackerSD * scintTrack3 = new AllPixTrackerSD( "sdscint3", G4ThreeVector(0., 0., z3), 0); SDman->AddNewDetector( scintTrack3 ); scint3_log->SetSensitiveDetector( scintTrack3 ); AllPixTrackerSD * scintTrack4 = new AllPixTrackerSD( "sdscint4", G4ThreeVector(0., 0., z4), 0); SDman->AddNewDetector( scintTrack4 ); scint4_log->SetSensitiveDetector( scintTrack4 ); */ /* for(int itr = 0 ; itr < (int)m_posVectorTestStructure.size() ; itr++) { cout << "link : " << m_detectorLinkTestStructure[itr] << " | itr : " << itr << endl; G4ThreeVector posRel = m_posVector[m_detectorLinkTestStructure[itr]] - m_posVectorTestStructure[itr]; G4RotationMatrix * rotRel = m_rotVector[m_detectorLinkTestStructure[itr]]; wrapperSolid = m_wrapper_log[m_detectorLinkTestStructure[itr]]->GetSolid(); // match to an specific detector subtractionSolid = new G4SubtractionSolid("EUDETAlPlane", eudAlPlaneSolid, wrapperSolid, rotRel, posRel); // match to an specific detector eud_log->SetSolid(subtractionSolid); physName = "test_phys_"; physName += itr; new G4PVPlacement(m_rotVectorTestStructure[itr], m_posVectorTestStructure[itr], eud_log, // Logical volume physName.Data(), // Name expHall_log, // Mother volume logical false, // Unused boolean 0, // copy number true); // overlap } */ /* G4NistManager * nistman = G4NistManager::Instance(); std::vector mats = nistman->GetNistMaterialNames(); std::vector::iterator itr = mats.begin(); for( ; itr != mats.end() ; itr++) G4cout << *itr << G4endl; */ #endif } /* void AllPixDetectorConstruction::BuildTestStructure(G4int){ // materials G4NistManager* nistman = G4NistManager::Instance(); G4Material * Silicon = nistman->FindOrBuildMaterial("SILICONE"); G4cout << Silicon << G4endl; } */ /* void AllPixDetectorConstruction::BuildTestStructure(G4int){ // materials G4NistManager* nistman = G4NistManager::Instance(); G4Material * Bone = nistman->FindOrBuildMaterial("G4_B-100_BONE"); G4cout << Bone << G4endl; G4Material * SoftTissue = nistman->FindOrBuildMaterial("G4_TISSUE_SOFT_ICRP"); G4cout << SoftTissue << G4endl; G4Material * AdiposeTissue = nistman->FindOrBuildMaterial("G4_ADIPOSE_TISSUE_ICRP"); G4cout << AdiposeTissue << G4endl; G4Material * Carbon = nistman->FindOrBuildMaterial("G4_C"); G4cout << Carbon << G4endl; // bone G4Tubs * bone_tube = new G4Tubs("Bone", //3.0*mm, //innerRadiusOfTheTube, 0.*mm, //innerRadiusOfTheTube, 5.0*mm, //outerRadiusOfTheTube, 15.0*mm, //hightOfTheTube, 0.*deg, //startAngleOfTheTube, 360.*deg); //spanningAngleOfTheTube); m_TestStructure_log = new G4LogicalVolume(bone_tube, //Bone, Carbon, "Bone", 0,0,0); G4VisAttributes * visAtt_bone = new G4VisAttributes(G4Color(1,0,1,1)); visAtt_bone->SetLineWidth(1); visAtt_bone->SetForceSolid(true); m_TestStructure_log->SetVisAttributes(visAtt_bone); G4RotationMatrix* matrix = new G4RotationMatrix(); matrix->rotateX(0.*deg); m_TestStructure_phys = new G4PVPlacement(matrix, m_posVectorTestStructure[0], m_TestStructure_log, "Bone", expHall_log, false, 0); // marrow G4Tubs * marrow_tube = new G4Tubs("Marrow", 0.*mm, //innerRadiusOfTheTube, 2.5*mm, //outerRadiusOfTheTube, 15.0*mm, //hightOfTheTube, 0.*deg, //startAngleOfTheTube, 360.*deg); //spanningAngleOfTheTube); G4LogicalVolume * marrow_log = new G4LogicalVolume(marrow_tube, //SoftTissue, Carbon, "Marrow", 0,0,0); //G4VisAttributes * visAtt_marrow = new G4VisAttributes(G4Color(0.5, 0.5, 0.1, 0.7)); G4VisAttributes * visAtt_marrow = new G4VisAttributes(G4Color(1, 0, 0.5, 1)); visAtt_marrow->SetLineWidth(1); visAtt_marrow->SetForceSolid(true); marrow_log->SetVisAttributes(visAtt_marrow); G4PVPlacement * marrow_phys = new G4PVPlacement(0, // it mother is m_TestStructure_log already rotated G4ThreeVector(0., 0., 0.), marrow_log, "Marrow", m_TestStructure_log, false, 0); } */