228         bool AddPassives = 1;
 
  229         bool GlueStackOnly = 0;
 
  230         bool ElectronicsStackOnly = 0;
 
  240         gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
  243   gSystem->Load(
"libGeoBase");
 
  244   gSystem->Load(
"libParBase");
 
  245   gSystem->Load(
"libBase");
 
  246   gSystem->Load(
"libPndData");
 
  247   gSystem->Load(
"libPassive");
 
  248   gSystem->Load(
"libHypGe");
 
  253         FairGeoLoader* 
geoLoad = 
new FairGeoLoader(
"TGeo",
"FairGeoLoader");
 
  254   FairGeoInterface *
geoFace = geoLoad->getGeoInterface();
 
  255   geoFace->setMediaFile(
"../../../../geometry/media_pnd.geo");
 
  256   geoFace->readMedia();
 
  259   FairGeoMedia *
Media =  geoFace->getMedia();
 
  260   FairGeoBuilder *
geobuild=geoLoad->getGeoBuilder();
 
  262   FairGeoMedium *medcarbon  = Media->getMedium(
"carbon");
 
  263   Int_t nmedcap=geobuild->createMedium(medcarbon);
 
  264         TGeoMedium *Carbon = 
gGeoManager->GetMedium(
"carbon");
 
  266         FairGeoMedium *medcap  = Media->getMedium(
"HYPaluminium");
 
  267   Int_t nmedcap=geobuild->createMedium(medcap);
 
  268   TGeoMedium *Al = 
gGeoManager->GetMedium(
"HYPaluminium");
 
  270         FairGeoMedium *medGe  = Media->getMedium(
"germanium");
 
  271   Int_t nmedGe=geobuild->createMedium(medGe);
 
  272   TGeoMedium *Ge = 
gGeoManager->GetMedium(
"germanium");
 
  274   FairGeoMedium *medsteel  = Media->getMedium(
"steel");
 
  275   Int_t nmedcap=geobuild->createMedium(medsteel);
 
  276         TGeoMedium *Steel = 
gGeoManager->GetMedium(
"steel");
 
  278         FairGeoMedium *medcu  = Media->getMedium(
"copper");
 
  279   Int_t nmedcap=geobuild->createMedium(medcu);
 
  282         FairGeoMedium *medpe_bor5  = Media->getMedium(
"pe_bor5");
 
  283   Int_t nmedcap=geobuild->createMedium(medpe_bor5);
 
  284         TGeoMedium *pe_bor5 = 
gGeoManager->GetMedium(
"pe_bor5");        
 
  286         FairGeoMedium *medacrylicGlass  = Media->getMedium(
"acrylicGlass");
 
  287           Int_t nmedcap=geobuild->createMedium(medacrylicGlass);
 
  288         TGeoMedium *acrylicGlass = 
gGeoManager->GetMedium(
"acrylicGlass");
 
  291   TGeoManager *
geom = (TGeoManager*)gROOT->FindObject(
"FAIRGeom");
 
  292   TGeoVolume *
top = 
new TGeoVolumeAssembly(
"hpGe");
 
  293         TGeoVolume *PassivesTop = 
new TGeoVolumeAssembly(
"PassivesTop");
 
  294         TGeoVolume *ActivesTop = 
new TGeoVolumeAssembly(
"ActivesTop");
 
  297   geom->SetTopVolume(top);
 
  304         TGeoVolume *TargetAssembly = 
new TGeoVolumeAssembly(
"TargetAssembly");
 
  305         TGeoVolume* 
Target = geom->MakeBox(
"Target",Carbon,2.4,2.4,TargetThickness/2);
 
  306         Target->SetLineColor(kRed);
 
  307         Target->SetFillColor(kRed);
 
  308         TGeoRotation *TargetRot = 
new TGeoRotation(
"TargetRot",0,Angle,0);
 
  309         TargetRot->RegisterYourself();
 
  310         TargetAssembly->AddNode(Target,0,
new TGeoCombiTrans(
"",0,0,TargetThickness/2/
TMath::Cos(Angle*
Pi/180),TargetRot));
 
  312         TGeoVolume* TargetAddition = geom->MakeBox(
"TargetAddition",Carbon,0.5,2.4,2.4);
 
  313         TargetAddition->SetLineColor(kRed);
 
  314         TargetAddition->SetFillColor(kRed);
 
  315         TargetAssembly->AddNode(TargetAddition,1,
new TGeoCombiTrans(-2.9,0,-0.1+TargetThickness/2/
TMath::Cos(Angle*
Pi/180),TargetRot));
 
  316         TargetAssembly->AddNode(TargetAddition,2,
new TGeoCombiTrans(-3.9,0,-0.1+TargetThickness/2/
TMath::Cos(Angle*
Pi/180),TargetRot));
 
  318         if (!GlueStackOnly && !ElectronicsStackOnly ) PassivesTop->AddNode(TargetAssembly,0);
 
  322         TGeoVolume *AlSupportAssembly = 
new TGeoVolumeAssembly(
"AlSupportAssembly"); 
 
  325         TGeoTube *AlPlateTube = 
new TGeoTube(
"AlPlateTube",0,6,0.2);
 
  326                 TGeoRotation *AlPlateTubeRotation = 
new TGeoRotation (
"AlPlateTubeRotation",90,90,0);
 
  327                 AlPlateTubeRotation->RegisterYourself();
 
  328         TGeoBBox *AlPlateBox = 
new TGeoBBox(
"AlPlateBox",0.2,6,11.6/2);
 
  329                 TGeoTranslation *AlPlateBoxTranslation = 
new TGeoTranslation (
"AlPlateBoxTranslation",0,0,+5.8);
 
  330                 AlPlateBoxTranslation->RegisterYourself();
 
  331         TGeoCompositeShape *AlPlateShape = 
new TGeoCompositeShape(
"AlPlateShape", 
"AlPlateTube : AlPlateTubeRotation +  AlPlateBox : AlPlateBoxTranslation");
 
  332         TGeoVolume *AlPlate = 
new TGeoVolume(
"AlPlate", AlPlateShape, Al);
 
  333         AlPlate->SetLineColor(14);
 
  334         AlPlate->SetFillColor(14);
 
  337         TGeoBBox *AlFrontAngleTop = 
new TGeoBBox(
"AlFrontAngleTop",0.5,2.5,0.1);
 
  338                 TGeoTranslation *AlFrontAngleTopTranslation = 
new TGeoTranslation (
"AlFrontAngleTopTranslation",+0.2+0.5,0,-0.1);
 
  339                 AlFrontAngleTopTranslation->RegisterYourself();
 
  340         TGeoBBox *AlFrontAngleBottom = 
new TGeoBBox(
"AlFrontAngleBottom",0.1,2.5,1.5);
 
  341                 TGeoTranslation *AlFrontAngleBottomTranslation = 
new TGeoTranslation (
"AlFrontAngleBottomTranslation",+0.3,0,-1.5);
 
  342                 AlFrontAngleBottomTranslation->RegisterYourself();
 
  343         TGeoBBox *AlFrontAngleBottomCutout = 
new TGeoBBox(
"AlFrontAngleBottomCutout",1,0.25,1.5);
 
  344                 TGeoTranslation *AlFrontAngleBottomCutoutTranslation = 
new TGeoTranslation (
"AlFrontAngleBottomCutoutTranslation",+0.3,0,-2.5);
 
  345                 AlFrontAngleBottomCutoutTranslation->RegisterYourself();
 
  346         TGeoCompositeShape *AlFrontAngleShape = 
new TGeoCompositeShape(
"AlFrontAngleShape", 
"(AlFrontAngleTop : AlFrontAngleTopTranslation +  AlFrontAngleBottom : AlFrontAngleBottomTranslation ) - ( AlFrontAngleBottomCutout : AlFrontAngleBottomCutoutTranslation)");
 
  347         TGeoVolume *AlFrontAngle = 
new TGeoVolume(
"AlFrontAngle", AlFrontAngleShape, Al);
 
  348         AlFrontAngle ->SetLineColor(14);
 
  349         AlFrontAngle ->SetFillColor(14);
 
  352         TGeoBBox *AlBackAngleTop = 
new TGeoBBox(
"AlBackAngleTop",0.5,2.5,0.1);
 
  353                 TGeoTranslation *AlBackAngleTopTranslation = 
new TGeoTranslation (
"AlBackAngleTopTranslation",+0.2+0.5,0,4.9);
 
  354                 AlBackAngleTopTranslation->RegisterYourself();
 
  355         TGeoBBox *AlBackAngleBottom = 
new TGeoBBox(
"AlBackAngleBottom",0.1,2.5,5);
 
  356                 TGeoTranslation *AlBackAngleBottomTranslation = 
new TGeoTranslation (
"AlBackAngleBottomTranslation",+0.3,0,4.8+5);
 
  357                 AlBackAngleBottomTranslation->RegisterYourself();
 
  358         TGeoBBox *AlBackAngleBottomCutout = 
new TGeoBBox(
"AlBackAngleBottomCutout",1,0.25,5);
 
  359                 TGeoTranslation *AlBackAngleBottomCutoutTranslation = 
new TGeoTranslation (
"AlBackAngleBottomCutoutTranslation",+0.3,0,4.8+7);
 
  360                 AlBackAngleBottomCutoutTranslation->RegisterYourself();
 
  361         TGeoCompositeShape *AlBackAngleShape = 
new TGeoCompositeShape(
"AlBackAngleShape", 
"(AlBackAngleTop : AlBackAngleTopTranslation +  AlBackAngleBottom : AlBackAngleBottomTranslation ) - ( AlBackAngleBottomCutout : AlBackAngleBottomCutoutTranslation)");
 
  362         TGeoVolume *AlBackAngle = 
new TGeoVolume(
"AlBackAngle", AlBackAngleShape, Al);
 
  363         AlBackAngle ->SetLineColor(14);
 
  364         AlBackAngle ->SetFillColor(14);
 
  367         TGeoTube *AlGoniometerTube = 
new TGeoTube(
"AlGoniometerTube",5,6,2);
 
  368                 TGeoCombiTrans *AlGoniometerTubeCombiTrans = 
new TGeoCombiTrans (
"AlGoniometerTubeCombiTrans",-2.2,0,0, 
new TGeoRotation(
"",90,90,0));
 
  369                 AlGoniometerTubeCombiTrans->RegisterYourself();
 
  370         TGeoVolume *AlGoniometer = 
new TGeoVolume(
"AlGoniometer",AlGoniometerTube,Al);
 
  371         AlGoniometer ->SetLineColor(14);
 
  372         AlGoniometer ->SetFillColor(14);
 
  376         TGeoTube *M5ScrewHeadOut = 
new TGeoTube(
"M5ScrewHeadOut",0.45/2,0.4,0.25);
 
  377         TGeoTube *M5ScrewHeadIn = 
new TGeoTube(
"M5ScrewHeadIn",0,0.45/2,0.25/2);
 
  378         TGeoTranslation *M5ScrewHeadInTrans = 
new TGeoTranslation(
"M5ScrewHeadInTrans",0,0,0.25/2);
 
  380         TGeoCompositeShape *M5ScrewHeadShape = 
new TGeoCompositeShape(
"M5SrewHeadShape",
"M5ScrewHeadOut + M5ScrewHeadIn : M5ScrewHeadInTrans");
 
  381         TGeoVolume *M5ScrewHead = 
new TGeoVolume(
"M5ScrewHead",M5ScrewHeadShape,Steel);
 
  382         TGeoCombiTrans *M5ScrewHeadCombiTrans = 
new TGeoCombiTrans (
"M5ScrewHeadCombiTrans",+0.4+0.25,0,8, 
new TGeoRotation(
"",90,270,0));
 
  383                 M5ScrewHeadCombiTrans->RegisterYourself();
 
  384         TGeoCombiTrans *M5ScrewHead2CombiTrans = 
new TGeoCombiTrans (
"M5ScrewHead2CombiTrans",+0.4+0.25,0,-2, 
new TGeoRotation(
"",90,270,0));
 
  385                 M5ScrewHead2CombiTrans->RegisterYourself();     
 
  386         M5ScrewHead->SetLineColor(36);
 
  387         M5ScrewHead->SetFillColor(36);
 
  389         AlSupportAssembly->AddNode(M5ScrewHead,1, M5ScrewHeadCombiTrans);
 
  390         AlSupportAssembly->AddNode(M5ScrewHead,2, M5ScrewHead2CombiTrans);
 
  394         TGeoBBox *AlBasePlateBox = 
new TGeoBBox(
"AlBasePlateBox",0.4,30,40);
 
  395                 TGeoCombiTrans *AlBasePlateCombiTrans = 
new TGeoCombiTrans (
"AlBasePlateCombiTrans",-4.6,25,-25, 
new TGeoRotation(
"",0,60,0));
 
  396                 AlBasePlateCombiTrans->RegisterYourself();
 
  397         TGeoVolume *AlBasePlate = 
new TGeoVolume(
"AlBasePlate",AlBasePlateBox,Al);
 
  398         AlBasePlate ->SetLineColor(14);
 
  399         AlBasePlate ->SetFillColor(14);
 
  402         AlSupportAssembly->AddNode(AlBasePlate,1, AlBasePlateCombiTrans);
 
  403         AlSupportAssembly->AddNode(AlGoniometer,1, AlGoniometerTubeCombiTrans);
 
  404         AlSupportAssembly->AddNode(AlFrontAngle,1);
 
  405         AlSupportAssembly->AddNode(AlBackAngle,1);
 
  406         AlSupportAssembly->AddNode(AlPlate,1);
 
  411                 if (!GlueStackOnly && !ElectronicsStackOnly ) PassivesTop->AddNode(AlSupportAssembly,1, 
new TGeoTranslation (-4.6,0,0));
 
  415         TGeoBBox *PlasticBlockBox = 
new TGeoBBox(
"PlasticBlockBox",5,6,10);
 
  416         TGeoVolume *PlasticBlock = 
new TGeoVolume (
"PlasticBlock", PlasticBlockBox,acrylicGlass);
 
  417         TGeoVolume *PlasticBlock2 = 
new TGeoVolume (
"PlasticBlock2", PlasticBlockBox,acrylicGlass);
 
  419                 PlasticBlock->SetFillColor(kBlue+4);
 
  420                 PlasticBlock->SetLineColor(kBlue+4);
 
  421                 PlasticBlock2->SetFillColor(kBlue+4);
 
  422                 PlasticBlock2->SetLineColor(kBlue+4);
 
  425                 PlasticBlock1Trans->RegisterYourself();
 
  427                 PlasticBlock2Trans->RegisterYourself();
 
  428         if (!GlueStackOnly && !ElectronicsStackOnly ) PassivesTop->AddNode (PlasticBlock,0,PlasticBlock1Trans);
 
  429         if (!GlueStackOnly && !ElectronicsStackOnly ) PassivesTop->AddNode (PlasticBlock2,0,PlasticBlock2Trans);
 
  435                 TGeoVolume *NeutronDetectorAssembly = 
new TGeoVolumeAssembly(
"NeutronDetectorAssembly");
 
  437                 TGeoTube *KermitTube= 
new TGeoTube(
"KermitTube",0,23.5/2,26.4/2);
 
  438                 TGeoVolume *KermitVolume = 
new TGeoVolume(
"CrystalKermit",KermitTube,pe_bor5);
 
  439                 KermitVolume->SetFillColor(19);
 
  440                 KermitVolume->SetLineColor(19);
 
  441                 TGeoCombiTrans *KermitCombiTrans = 
new TGeoCombiTrans (
"KermitHeadCombiTrans",24.5+23.5/2+OffsetToAlPlate,15+(26.4/2)*
TMath::Sin(
TMath::Pi()/180*60),-(15+26.4/2)*
TMath::Cos(
TMath::Pi()/180*60), 
new TGeoRotation(
"",0,60,0));
 
  442                         KermitCombiTrans->RegisterYourself();
 
  443                 NeutronDetectorAssembly ->AddNode(KermitVolume,2000, KermitCombiTrans);         
 
  446                 TGeoSphere *NeutronBallSphere = 
new TGeoSphere(
"NeutronBallSphere",0,32/2,0,180,0,360);
 
  447                 TGeoVolume *NeutronBall = 
new TGeoVolume (
"CrystalNeutronBall", NeutronBallSphere,pe_bor5);
 
  448                 NeutronBall->SetFillColor(12);
 
  449                 NeutronBall->SetLineColor(12);
 
  450                 TGeoCombiTrans *NeutronBallCombiTrans = 
new TGeoCombiTrans (
"NeutronBallHeadCombiTrans",20+OffsetToAlPlate,21.5+32/2,-54, 
new TGeoRotation(
"",0,0,0));
 
  451                         NeutronBallCombiTrans->RegisterYourself();
 
  452                 NeutronDetectorAssembly ->AddNode(NeutronBall,2001, NeutronBallCombiTrans);
 
  454                 if (!GlueStackOnly && !ElectronicsStackOnly ) ActivesTop->AddNode(NeutronDetectorAssembly,1, 
new TGeoTranslation (-4.6,0,0));
 
  459                 Int_t CrystalNumber = 1;
 
  460                         if (!GlueStackOnly && !ElectronicsStackOnly ) SingleCluster ->
PlaceCluster(ActivesTop,  0,GeDistance, 0,60,0,&CrystalNumber);
 
  463                 TGeoVolume* Piezo = geom->MakeBox(
"CrystalPiezo1",acrylicGlass,0.75,0.25,0.2);
 
  464                 TGeoVolume* Piezo2 = geom->MakeBox(
"CrystalPiezo2",acrylicGlass,0.75,0.25,0.2);
 
  465                         Piezo->SetLineColor(kBlue);
 
  466                         Piezo->SetFillColor(kBlue);
 
  467                         if (!GlueStackOnly && !ElectronicsStackOnly ) ActivesTop->AddNode(Piezo,1000,
new TGeoCombiTrans(-1,0,5.2,
new TGeoRotation(
"",90,0,0)));
 
  468                         Piezo2->SetLineColor(kBlue);
 
  469                         Piezo2->SetFillColor(kBlue);
 
  470                         if (!GlueStackOnly && !ElectronicsStackOnly ) ActivesTop->AddNode(Piezo2,1001,
new TGeoCombiTrans(1,0,5.2,
new TGeoRotation(
"",90,0,0)));
 
  475         TGeoVolume *GlueStackAssemblyActive = 
new TGeoVolumeAssembly(
"GlueStackAssemblyActive");
 
  476         TGeoVolume *GlueStackAssemblyPassive = 
new TGeoVolumeAssembly(
"GlueStackAssemblyPassive");
 
  479                 GlueStackAssemblyPassive->AddNode(GlueStackFrame,1);
 
  481         TGeoVolume *GlueSamplesActive[23];
 
  482         TGeoVolume *GlueSamplesPassive[23];
 
  485         for (
int i= 0; 
i < 23; 
i++)
 
  490                 GlueStackAssemblyActive->AddNode(GlueSamplesActive[
i],i, 
new TGeoCombiTrans (0,0,-(0.4 + i*(0.203)), 
new TGeoRotation(
"",i*90,0,0)));
 
  491                 GlueStackAssemblyPassive->AddNode(GlueSamplesPassive[i],i, 
new TGeoCombiTrans (0,0,-(0.4 + i*(0.203)), 
new TGeoRotation(
"",i*90,0,0)));
 
  496         if (AddActives)  top->AddNode(ActivesTop,0);
 
  497         if (AddPassives) top->AddNode(PassivesTop,0);
 
  499         geom->CheckOverlaps();
 
  500         geom->CloseGeometry();  
 
  501         cout << 
"# of Nodes: " << PassivesTop->CountNodes(10,1) << endl;
 
  506         TString outfileWithoutPath =
"hypGeGeoCOSY2014setupPassives.root";
 
  508                 outfile += outfileWithoutPath;
 
  510                 cout << outfile << endl;
 
  511                 PassivesTop->PrintNodes();
 
  514         TFile* 
fi = 
new TFile(outfile,
"RECREATE");
 
  515         TGeoVolume *PassivesTopWrap = 
new TGeoVolumeAssembly(
"PassivesTopWrap");
 
  516         PassivesTopWrap->AddNode(PassivesTop,0);
 
  517           PassivesTopWrap->Write();
 
  519         cout << 
"Wrote passives geometry to file: " << outfileWithoutPath << endl;
 
  522         outfileWithoutPath =
"hypGeGeoCOSY2014setupActives.root";
 
  523         outfile= 
"../../../../geometry/";
 
  524                 outfile += outfileWithoutPath;
 
  526                                         cout << outfile << endl;
 
  527         fi->Open(outfile,
"RECREATE");
 
  529         TGeoVolume *ActivesTopWrap = 
new TGeoVolumeAssembly(
"ActivesTopWrap");
 
  530                 ActivesTopWrap->AddNode(ActivesTop,0);
 
  531         ActivesTopWrap->Write();
 
  542         return outfileWithoutPath; 
 
TGeoManager * gGeoManager
TGeoVolume * makeMaytecFrame(TGeoMedium *Med_ext)
FairGeoBuilder * geobuild
TGeoVolume * makeGlueStackFrame(TGeoMedium *Al_ext, TGeoMedium *Steel_ext)
TGeoVolume * makeGlueSample(TGeoMedium *Al_ext, TGeoMedium *Glue_ext, Int_t SampleNumber, Bool_t PassivePart, Bool_t ActivePart)
void PlaceCluster(TGeoVolume *top, TGeoMatrix *ClusterPlaceAndDirectionTranslation, Int_t *CrystalNumber)
FairGeoInterface * geoFace