6 #include "G4Material.hh" 7 #include "G4LogicalVolume.hh" 8 #include "G4PVPlacement.hh" 9 #include "G4RotationMatrix.hh" 10 #include "G4Sphere.hh" 11 #include "G4ThreeVector.hh" 13 #include "G4VPhysicalVolume.hh" 14 #include "G4UnionSolid.hh" 29 bool useLambda(
false);
33 std::cout <<
"Updating target object length using interaction length info:" <<
std::endl;
36 <<
", rho = " <<
fTargetDensity*CLHEP::cm3/CLHEP::g <<
", NLambda = " 47 std::cout <<
"Checking length for SAT" <<
std::endl;
57 std::cout <<
"Nominal number of spheres = " << NumNominal <<
std::endl;
120 bool useLambda(
false);
124 std::cout <<
"Updating target 2 object length using interaction length info:" <<
std::endl;
138 std::cout <<
"Checking length for 2nd SAT" <<
std::endl;
148 std::cout <<
"Nominal number of spheres = " << NumNominal <<
std::endl;
204 std::cout <<
"Finding number of target spheres for NLambda = " << targetNLambda <<
std::endl;
206 double xSigma = targetRadius/3.0;
207 double ySigma = targetRadius/3.0;
208 double x0(0.0), y0(0.0);
232 std::cout <<
"Assuming beam sigma_x = " << xSigma <<
", sigma_y = " << ySigma <<
std::endl;
233 std::cout <<
"Assuming beam offset_x = " << x0 <<
", offset_y = " << y0 <<
std::endl;
237 double RSq = targetRadius*targetRadius;
239 double xMin(-targetRadius);
240 double xMax(targetRadius);
241 double dx = (xMax - xMin)/(N*1.0);
243 double yMin(-targetRadius);
245 double invXSigmaSq(0.0);
246 if (xSigma > 0.0) {invXSigmaSq = 1.0/(xSigma*xSigma);}
247 double invYSigmaSq(0.0);
248 if (ySigma > 0.0) {invYSigmaSq = 1.0/(ySigma*ySigma);}
251 if (xSigma > 0.0 && ySigma > 0.0) {
252 norm = 1.0/(M_PI*xSigma*ySigma);
258 for (
i = 0;
i < N1;
i++) {
260 double x = dx*
i + xMin - x0;
263 for (j = 0; j < N1; j++) {
265 double y = dy*j + yMin - y0;
268 double rSq = xSq + ySq;
272 double expPower = -0.5*(xSq*invXSigmaSq + ySq*invYSigmaSq);
274 if (fabs(expPower) < 30.0) {expTerm = exp(expPower);}
276 result += expTerm*sqrt(RSq - rSq);
285 result *= norm*dx*dy;
286 std::cout <<
"Sphere double integral = " << result <<
std::endl;
288 G4double nSpheres = targetNLambda*targetSpecificLambda/(targetDensity*
result);
295 std::cout <<
"Calling PlaceTargetModule" << number <<
std::endl;
308 std::ostringstream cNumStrStr; cNumStrStr << number;
309 G4String numString = cNumStrStr.str();
312 G4String outerCanName(
"Target");
313 outerCanName += numString; outerCanName +=
"OuterCan";
316 if (!mother) {
return;}
317 double hallLength = mother->
fParams[2];
321 if (!horn1) {
return;}
326 G4ThreeVector
position(0.0, 0.0, 0.0);
329 G4double horn1Length = horn1->
fParams[2];
336 position[2] = 0.5*hallLength - horn1Length - 0.5*targetModuleTotL;
339 position[2] += targetInHorn;
343 G4RotationMatrix* rotMatrix = 0;
355 new G4PVPlacement(rotMatrix, position, canInfo->
fCurrent,
359 G4String heName(
"Target");
360 heName += numString; heName +=
"OuterHeGas";
364 new G4PVPlacement((G4RotationMatrix*) 0, G4ThreeVector(0.0, 0.0, 0.0), heInfo->
fCurrent,
372 std::ostringstream cNumStrStr; cNumStrStr << number;
373 G4String numString = cNumStrStr.str();
375 G4String innerCanName(
"Target");
376 innerCanName += numString; innerCanName +=
"InnerCan";
378 G4String outerHeName(
"Target");
379 outerHeName += numString; outerHeName +=
"OuterHeGas";
382 if (!mother) {
return;}
388 G4ThreeVector
position(0.0, 0.0, zShift);
390 new G4PVPlacement((G4RotationMatrix*) 0, position, canInfo->
fCurrent,
394 G4String innerHeName(
"Target");
395 innerHeName += numString; innerHeName +=
"InnerHeGas";
398 new G4PVPlacement((G4RotationMatrix*) 0, G4ThreeVector(0.0, 0.0, 0.0), heInfo->
fCurrent,
411 std::ostringstream cNumStrStr; cNumStrStr << number;
412 G4String numString = cNumStrStr.str();
414 G4String supportName(
"Target");
415 supportName += numString; supportName +=
"Support";
417 G4String innerHeName(
"Target");
418 innerHeName += numString; innerHeName +=
"InnerHeGas";
422 if (!mother) {
return;}
432 for (i = 0; i < 3; i++) {
434 G4double phi = -M_PI*120.0*i/180.0;
435 G4double cPhi = cos(phi);
436 G4double sPhi = sin(phi);
437 G4double
x = x0*cPhi - y0*sPhi;
438 G4double
y = y0*cPhi + x0*sPhi;
444 std::ostringstream sNumStrStr; sNumStrStr <<
i;
445 new G4PVPlacement((G4RotationMatrix*) 0, position, rodInfo->
fCurrent,
446 (supportName +
"_P" + sNumStrStr.str()),
456 std::ostringstream cNumStrStr; cNumStrStr << number;
457 G4String numString = cNumStrStr.str();
459 G4String label(
"Target"); label += numString;
469 G4String innerHeName(
"Target");
470 innerHeName += numString; innerHeName +=
"InnerHeGas";
472 if (!mother) {
return;}
476 G4ThreeVector
position(0.0, 0.0, 0.0);
498 for (iSph = 0; iSph < numTargetObjects; iSph++) {
500 position[2] = z0 + iSph*(targetRadius*2.0 +
tolerance);
502 std::ostringstream sNumStrStr; sNumStrStr << iSph;
503 new G4PVPlacement((G4RotationMatrix*) 0, position, placeInfo->
fCurrent,
504 (label +
"_P" + sNumStrStr.str()),
512 new G4PVPlacement((G4RotationMatrix*) 0, position, placeInfo->
fCurrent,
527 std::ostringstream mStrStr;
528 mStrStr <<
" Volume named " << volName <<
" Already defined. Fatal ";
529 G4String mStr(mStrStr.str());
530 G4Exception(
"LBNEVolumePlacements::Create",
" ", FatalErrorInArgument, mStr.c_str());
537 std::ostringstream cNumStrStr; cNumStrStr << number;
538 G4String numString = cNumStrStr.str();
539 G4String targetLabel(
"Target"); targetLabel += numString;
541 if (!volName.contains(
"Target")) {
return 0;}
561 if (volName.contains(
"Sphere")) {
564 info.fParams[0] = 0.0;
565 info.fParams[1] = targetRadius;
566 info.fParams[2] = 0.0;
567 G4Sphere* aSphere =
new G4Sphere(volName,
570 0.0, 360.0*CLHEP::degree,
571 0.0, 180.0*CLHEP::degree);
573 info.fCurrent =
new G4LogicalVolume(aSphere, G4Material::GetMaterial(targetLabel), volName);
575 }
else if (volName.contains(
"Cylinder")) {
578 info.fParams[0] = 0.0;
579 info.fParams[1] = targetRadius;
580 info.fParams[2] = targetLength;
581 G4Tubs* aTube =
new G4Tubs(volName, 0.0, targetRadius,
583 0.0, 360.0*CLHEP::degree);
585 info.fCurrent =
new G4LogicalVolume(aTube, G4Material::GetMaterial(targetLabel), volName);
587 }
else if (volName.contains(
"OuterCan")) {
592 double halfTubeL = 0.5*targetOutCaseL;
595 G4String tubeName(volName); tubeName +=
"Tube";
596 G4Tubs* aTube =
new G4Tubs(tubeName, innerR, outerR,
598 0.0, 360.0*CLHEP::degree);
601 G4String sphereName(volName); sphereName +=
"Sphere";
602 G4Sphere* aSphere =
new G4Sphere(sphereName, innerR, outerR,
603 0.0, 360.0*CLHEP::degree,
604 0.0, 180.0*CLHEP::degree);
607 G4UnionSolid* outerCan =
new G4UnionSolid(volName, aTube, aSphere, 0, G4ThreeVector(0.0, 0.0, halfTubeL));
609 info.fCurrent =
new G4LogicalVolume(outerCan, G4Material::GetMaterial(
std::string(
"Titanium")), volName);
612 info.fParams[0] = innerR;
613 info.fParams[1] = outerR;
614 info.fParams[2] = targetModuleTotL;
616 }
else if (volName.contains(
"OuterHeGas")) {
620 double outerR = targetOutCaseInnerR;
621 double halfTubeL = 0.5*targetOutCaseL;
624 G4String tubeName(volName); tubeName +=
"Tube";
625 G4Tubs* aTube =
new G4Tubs(tubeName, innerR, outerR,
627 0.0, 360.0*CLHEP::degree);
630 G4String sphereName(volName); sphereName +=
"Sphere";
631 G4Sphere* aSphere =
new G4Sphere(sphereName, innerR, outerR,
632 0.0, 360.0*CLHEP::degree,
633 0.0, 180.0*CLHEP::degree);
636 G4UnionSolid* outerCan =
new G4UnionSolid(volName, aTube, aSphere, 0, G4ThreeVector(0.0, 0.0, halfTubeL));
638 info.fCurrent =
new G4LogicalVolume(outerCan, G4Material::GetMaterial(
std::string(
"HeliumTarget")), volName);
641 info.fParams[0] = innerR;
642 info.fParams[1] = outerR;
645 }
else if (volName.contains(
"InnerCan")) {
650 double halfTubeL = 0.5*targetInCaseL;
653 G4String tubeName(volName); tubeName +=
"Tube";
654 G4Tubs* aTube =
new G4Tubs(tubeName, innerR, outerR,
656 0.0, 360.0*CLHEP::degree);
658 info.fCurrent =
new G4LogicalVolume(aTube, G4Material::GetMaterial(
std::string(
"Titanium")), volName);
661 info.fParams[0] = innerR;
662 info.fParams[1] = outerR;
663 info.fParams[2] = targetInCaseL;
665 }
else if (volName.contains(
"InnerHeGas")) {
670 double halfTubeL = 0.5*targetInCaseL;
673 G4String tubeName(volName); tubeName +=
"Tube";
674 G4Tubs* aTube =
new G4Tubs(tubeName, innerR, outerR,
676 0.0, 360.0*CLHEP::degree);
678 info.fCurrent =
new G4LogicalVolume(aTube, G4Material::GetMaterial(
std::string(
"HeliumTarget")), volName);
681 info.fParams[0] = innerR;
682 info.fParams[1] = outerR;
683 info.fParams[2] = targetInCaseL;
685 }
else if (volName.contains(
"Support")) {
689 info.fParams[0] = 0.0;
690 info.fParams[1] = radius;
691 info.fParams[2] = targetInCaseL;
692 G4Tubs* aTube =
new G4Tubs(volName, 0.0, radius,
694 0.0, 360.0*CLHEP::degree);
696 info.fCurrent =
new G4LogicalVolume(aTube, G4Material::GetMaterial(
std::string(
"Titanium")), volName);
701 fSubVolumes.insert(std::pair<G4String, LBNEVolumePlacementData>(volName, info));
G4double fTargetLengthOutsideHorn
G4double fTarget2ModuleTotL
bool fUseLBNFOptimConceptDesignHornA
G4double fTarget2SpecificLambda
G4double fTargetModuleTotL
const LBNEVolumePlacementData * Find(const G4String &name, const char *motherName, const char *method) const
void PlaceTargetSupport(int number=1)
G4double fTargetSpecificLambda
G4LogicalVolume * fCurrent
void PlaceTargetObject(int number=1)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::map< G4String, LBNEVolumePlacementData > fSubVolumes
void PlaceTargetModule(int number=1)
LBNEVolumePlacementData * CreateTargetVol(const G4String &volName, int number=1)
std::vector< double > fParams
G4double fTargetInCaseUpL
G4double fTargetInCaseDnL
auto norm(Vector const &v)
Return norm of the specified vector.
G4double fTargetOutCaseInnerR
G4double fTargetCaseDiffL
void PlaceTargetOuterCan(int number=1)
bool fCheckVolumeOverLapWC
G4RotationMatrix * fMirrorRotation
G4double fTargetLengthOutsideExtra
void PlaceTargetInnerCan(int number=1)
G4double fTarget2OutCaseL
G4double FindNTargetSpheres(int number=1) const
G4double fTarget2OutCaseInnerR
QTextStream & endl(QTextStream &s)
G4double fTargetFracOutHornL