/// @file AllPixDetectorConstructionAppliances.cc /// @brief Implementation of the appliance construction methods. #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 "G4UnionSolid.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4SubtractionSolid.hh" #include "G4NistManager.hh" //void AllPixDetectorConstruction::BuildAppliances(G4int){ // // G4NistManager * nistman = G4NistManager::Instance(); // // G4Material * Alu = nistman->FindOrBuildMaterial("G4_Al"); // G4Box * appliance_box = new G4Box("Appliance_box", // (10/2.)*mm, // (10/2.)*mm, // (1500/2.)*um); // // G4VisAttributes * applianceAtt = new G4VisAttributes(G4Color(1,0,0,1)); // applianceAtt->SetLineWidth(2); // applianceAtt->SetForceSolid(true); // applianceAtt->SetVisibility(true); // // // take into account wrapper for placemente // map::iterator aplItr = m_posVectorAppliances.begin(); // int detId = 0; // G4String appLogS = "Appliance_"; // G4String appPhysS = "Appliance_"; // char temp[128]; // // // G4Tubs * supportTop // = new G4Tubs("supportTop", // //3.0*mm, //innerRadiusOfTheTube, // 0.0*mm, //innerRadiusOfTheTube, // 10.0*mm, //outerRadiusOfTheTube, // 67*mm, //hightOfTheTube, // 0.*deg, //startAngleOfTheTube, // 360.*deg); //spanningAngleOfTheTube) // // G4Tubs * supportBottom // = new G4Tubs("supportBottom", // //3.0*mm, //innerRadiusOfTheTube, // 0.0*mm, //innerRadiusOfTheTube, // 10.0*mm, //outerRadiusOfTheTube, // 67*mm, //hightOfTheTube, // 0.*deg, //startAngleOfTheTube, // 360.*deg); //spanningAngleOfTheTube) // // G4Tubs * supportLeft // = new G4Tubs("supportLeft", // //3.0*mm, //innerRadiusOfTheTube, // 0.0*mm, //innerRadiusOfTheTube, // 10.0*mm, //outerRadiusOfTheTube, // 99*mm, //hightOfTheTube, // 0.*deg, //startAngleOfTheTube, // 360.*deg); //spanningAngleOfTheTube) // // G4Tubs * supportRight // = new G4Tubs("supportRight", // //3.0*mm, //innerRadiusOfTheTube, // 0.0*mm, //innerRadiusOfTheTube, // 10.0*mm, //outerRadiusOfTheTube, // 99*mm, //hightOfTheTube, // 0.*deg, //startAngleOfTheTube, // 360.*deg); //spanningAngleOfTheTube) // // G4RotationMatrix zRot90deg; // yRot45deg.rotateZ(M_PI/2); // G4ThreeVector translation(0,49.5,0); // // G4UnionSolid *support1 = new G4UnionSolid("top+left",supportTop,supportLeft,&zRot90deg,translation); // G4UnionSolid *support2 = new G4UnionSolid("bottom+right",supportBottom,supportRight,&zRot90deg,translation); // // G4UnionSolid *support = new G4UnionSolid("bottom+right",support1,support2); // // for( ; aplItr != m_posVectorAppliances.end() ; aplItr++) { // // detId = (*aplItr).first; // appLogS = "Appliance_"; // appPhysS = "Appliance_"; // sprintf(temp, "%d", detId); // appLogS += temp; // appPhysS += temp; // appLogS += "_log"; // appPhysS += "_phys"; // // G4LogicalVolume * appliance_log = new G4LogicalVolume( // appliance_box, // mat, // appLogS); // appliance_log->SetVisAttributes(applianceAtt); // // // If you mother vol is m_wrapper_log[detId], // // it will rotate with the medipix // new G4PVPlacement(0, // m_posVectorAppliances[detId], // appliance_log, // appPhysS, // m_wrapper_log[detId], // mother volume // false, // 0, // true); // // // Make this volume a sensitive device // // I get automatically a hits ROOT file for each device // sprintf(temp, "NeutronSD_%d", detId); // G4String sdname = temp; // AllPixTrackerSD * aTrackerSD = new AllPixTrackerSD( sdname, // m_posVectorAppliances[detId], // 0); // // SDman->AddNewDetector( aTrackerSD ); // appliance_log->SetSensitiveDetector( aTrackerSD ); // // } // // //} void AllPixDetectorConstruction::BuildAppliances(G4int) { G4cout << "* DEBUG: Beginning of BuildAppliances method." << G4endl; // Through the comand // --> /allpix/extras/setAppliancePosition // you can fill the vector "m_posVectorAppliances" available in this scope. // This vector holds the positions of the appliances volumes which can be placed with // respect to 'm_wrapper_log[detId]'. This way your appliance properly rotates // with the detector. // Through the comand // --> /allpix/extras/setWrapperEnhancement // you can enhance the size of the wrapper so daughter volumens of 'm_wrapper_log[index]' // fit in. // Example G4cout << "Build Appliance " << G4endl; G4NistManager * nistman = G4NistManager::Instance(); //G4Material * mat = nistman->FindOrBuildMaterial("G4_C"); G4Material * mat = nistman->FindOrBuildMaterial("G4_Al"); //G4_C //G4_Al //G4_LITHIUM_FLUORIDE //G4_POLYETHYLENE //std::vector mats = nistman->GetNistMaterialNames(); //std::vector::iterator itr = mats.begin(); //for( ; itr != mats.end() ; itr++) G4cout << *itr << G4endl; G4Box * appliance_box = new G4Box("Appliance_box", (100/2.)*mm, (100/2.)*mm, (20/2.)*mm); G4VisAttributes * applianceAtt = new G4VisAttributes(G4Color(0,0,0,0.6)); applianceAtt->SetLineWidth(2); applianceAtt->SetForceSolid(true); applianceAtt->SetVisibility(true); // take into account wrapper for placemente map::iterator aplItr = m_posVectorAppliances.begin(); int detId = 0; G4String appLogS = "Appliance_"; G4String appPhysS = "Appliance_"; char temp[128]; // SD manager G4SDManager * SDman = G4SDManager::GetSDMpointer(); G4Box *boxSup=new G4Box("boxSup",87*mm/2,79*mm/2,5*mm); G4Box *boxSupn=new G4Box("boxSupn",72*mm/2,54*mm/2,8*mm); G4Box *boxSupn2=new G4Box("boxSupn",52*mm/2,54*mm/2,5*mm); G4SubtractionSolid *supporttmp = new G4SubtractionSolid("BoxSup-BoxSupn",boxSup,boxSupn); G4SubtractionSolid *support = new G4SubtractionSolid("BoxSup-BoxSupn",supporttmp,boxSupn2,0,G4ThreeVector(0,44.5*mm,4*mm)); for( ; aplItr != m_posVectorAppliances.end() ; aplItr++) { detId = (*aplItr).first; appLogS = "Appliance_"; appPhysS = "Appliance_"; sprintf(temp, "%d", detId); appLogS += temp; appPhysS += temp; appLogS += "_log"; appPhysS += "_phys"; G4LogicalVolume * appliance_log = new G4LogicalVolume( support, mat, appLogS); appliance_log->SetVisAttributes(applianceAtt); // If you mother vol is m_wrapper_log[detId], // it will rotate with the medipix new G4PVPlacement(0, m_posVectorAppliances[detId]-G4ThreeVector(0,20*mm,0*mm), appliance_log, appPhysS, m_wrapper_log[detId], // mother volume false, 0, true); // Make this volume a sensitive device // I get automatically a hits ROOT file for each device // sprintf(temp, "NeutronSD_%d", detId); // G4String sdname = temp; // AllPixTrackerSD * aTrackerSD = new AllPixTrackerSD( sdname, // m_posVectorAppliances[detId], // 0); // // SDman->AddNewDetector( aTrackerSD ); // appliance_log->SetSensitiveDetector( aTrackerSD ); } }