FairRoot/PandaRoot
createJuelichHCal.C
Go to the documentation of this file.
1  // Geometry for a prototype of calorimeter
2 
3  // Simone Bianco 21/12/2009
4 
5  {
6  // Detectors defined as TGeoBBoxes, so the following dx,dy and dz
7  // are half of the real sizes of the boxes
8 
9  // Sizes of the scintillators
10  const Double_t dxSci = 1.4; // in cm!!
11  const Double_t dySci = 1.4; // in cm!!
12  const Double_t dzSci = 0.225; // in cm!!
13 
14  // Sizes of the absorbers
15  const Double_t dxAbs = 1.4; // in cm!!
16  const Double_t dyAbs = 1.4; // in cm!!
17  const Double_t dzAbs = 0.25; // in cm!!
18 
19  // number of stages in the sandwich of Scintillators and Absorbers
20  const Int_t nStages = 15;
21 
22 
23  //##################################################
24 
25 
26  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
27 
28  // Load this libraries
29  gSystem->Load("libGeoBase");
30  gSystem->Load("libParBase");
31  gSystem->Load("libBase");
32  gSystem->Load("libPndData");
33  gSystem->Load("libPassive");
34 
35  std::string outfile= "HCal.root";
36  TFile* fi = new TFile(outfile.c_str(),"RECREATE");
37 
38  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
39  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
40  geoFace->setMediaFile("../../../../geometry/media_pnd.geo");
41  geoFace->readMedia();
42  geoFace->print();
43 
44  //##################################################
45 
46  FairGeoMedia *Media = geoFace->getMedia();
47  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
48 
49  FairGeoMedium *CbmMediumScint = Media->getMedium("polyvinyltoluene");
50  FairGeoMedium *CbmMediumIron = Media->getMedium("iron");
51 
52  Int_t nmed=geobuild->createMedium(CbmMediumScint);
53  nmed=geobuild->createMedium(CbmMediumIron);
54 
55  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
56 
57  TGeoVolume *top = new TGeoVolumeAssembly("HCAL");
58 
59  gGeoMan->SetTopVolume(top);
60 
61 
62  TGeoVolumeAssembly* SubunitVol = new TGeoVolumeAssembly("TTVol");
63  TGeoRotation* dummyrot = new TGeoRotation();
64  TGeoRotation* rot1 = new TGeoRotation("",90.,0.,0.);
65 
66  std::string name1,name2;
67 
68  for (int i=0; i < nStages; i++)
69  {
70 
71  name1 = Form("TestHCalScintillator%d",i+1);
72  name2 = Form("TestHCalAbsorber%d",i+1);
73  TGeoShape* Box1 = new TGeoBBox(name1.c_str(), dxSci, dySci, dzSci);
74  TGeoShape* Box2 = new TGeoBBox(name2.c_str(), dxAbs, dyAbs, dzAbs);
75  TGeoVolume* BoxVolume1 = new TGeoVolume(name1.c_str(),Box1,gGeoMan->GetMedium("polyvinyltoluene"));
76  TGeoVolume* BoxVolume2 = new TGeoVolume(name2.c_str(),Box2,gGeoMan->GetMedium("iron"));
77  TGeoTranslation* translation1 = new TGeoTranslation(0.,0.,(double)i * 2. *(dzSci+dzAbs));
78  TGeoTranslation* translation2 = new TGeoTranslation(0.,0.,(double)i * 2. * (dzSci+dzAbs) + dzSci+dzAbs);
79 
80  TGeoCombiTrans* geocombi1= new TGeoCombiTrans(*translation1,*dummyrot);
81  TGeoCombiTrans* geocombi2= new TGeoCombiTrans(*translation2,*dummyrot);
82  geocombi1->SetName("scintillator"+i);
83  geocombi2->SetName("absorber"+i);
84  geocombi1->RegisterYourself();
85  geocombi2->RegisterYourself();
86  SubunitVol->AddNode(BoxVolume1,0,geocombi1);
87  SubunitVol->AddNode(BoxVolume2,0,geocombi2);
88 
89  }
90 
91  top->AddNode(SubunitVol,0,new TGeoCombiTrans());
92 
93  gGeoMan->CloseGeometry();
94  //gGeoMan->Export(outfile.Data());
95  top->Write();
96  fi->Close();
97  //gGeoManager->Export(outfile);
98  //top->Draw("ogl");
99 
100  std::string directory = gSystem->Getenv("VMCWORKDIR");
101  std::string move = Form("mv %s %s/geometry/.", outfile.c_str(), directory.c_str());
102  cout << "moving geometry to the correct folder" << endl;
103  system(move.c_str());
104 }
105 
const Double_t dySci
TGeoRotation * dummyrot
const Double_t dyAbs
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoMedia * Media
TGeoManager * gGeoMan
TGeoVolume * top
std::string move
TGeoRotation * rot1
TGeoVolume * SubunitVol
const Double_t dxAbs
FairGeoMedium * CbmMediumScint
FairGeoBuilder * geobuild
TFile * fi
Double_t
const Double_t dzSci
const Double_t dzAbs
FairGeoInterface * geoFace
TString directory
FairGeoMedium * CbmMediumIron
const Int_t nStages
TString outfile