7   const Int_t     kNofDisks = 4;
 
   12   const Double_t  kDiskInnerRadius[kNofDisks]    = {  2.5,  2.5,  2.5,  2.5};
 
   13   const Double_t  kDiskOuterRadius[kNofDisks]    = { 45.0, 45.0, 56.0, 74.0};
 
   14   const Double_t  kDiskZPosition  [kNofDisks]    = { 84.0,117.0,153.0,189.0};
 
   15   const Int_t     kDiskNFoils     [kNofDisks]    = {  2  ,  2  ,  2  ,  4  };
 
   16   const Double_t  kMiddleROBarHfTh[kNofDisks]    = {  4.3,  4.3,  4.3,  4.3};
 
   18   const Double_t kHalfStationThickness = 3.00;
 
   20   const Int_t    kNofLayers = 39;
 
   21   const TString  kLayerName [kNofLayers] = {
"WindowF_kapton",
"WindowF_aluminium",
 
   23                                             "CathodeF_kapton",
"CathodeF_aluminium",
 
   24                                             "Gem1_Sensor_GEMmixture",
 
   25                                             "Gem1F_copper",
"Gem1_kapton",
"Gem1B_copper",
 
   27                                             "Gem2F_copper",
"Gem2_kapton",
"Gem2B_copper",
 
   29                                             "Gem3F_copper",
"Gem3_kapton",
"Gem3B_copper",
 
   31                                             "PadF_copper",
"Pad_kapton",
"Pad_copper",
 
   33                                             "Gem4F_copper",
"Gem4_kapton",
"Gem4B_copper",
 
   35                                             "Gem5F_copper",
"Gem5_kapton",
"Gem5B_copper",
 
   37                                             "Gem6F_copper",
"Gem6_kapton",
"Gem6B_copper",
 
   38                                             "Gem6_Sensor_GEMmixture",
 
   39                                             "CathodeB_aluminium",
"CathodeB_kapton",
 
   41                                             "WindowB_aluminium",
"WindowB_kapton"};
 
   42   const Double_t kLayerThick[kNofLayers] = {  0.0007,  0.0001,          
 
   46                                               0.0002,  0.0050,  0.0002, 
 
   48                                               0.0002,  0.0050,  0.0002, 
 
   50                                               0.0002,  0.0050,  0.0002, 
 
   52                                               0.0012,  0.0050,  0.0012, 
 
   54                                               0.0002,  0.0050,  0.0002, 
 
   56                                               0.0002,  0.0050,  0.0002, 
 
   58                                               0.0002,  0.0050,  0.0002, 
 
   68   const Int_t    kSensorStripType [2]    = {  0   ,         2   };  
 
   70   const Double_t kSensorStripAngle[2][2] = {  0.  ,  0.  ,  0.  ,  0.  };
 
   71   const Double_t kSensorStripPitch[2][2] = {  0.02,  0.02,  0.02,  0.02};
 
   75   for ( Int_t ilayer = 0 ; ilayer < kNofLayers ; ilayer++ ) {
 
   76     cout << kLayerName[ilayer].Data() << 
" -> " << kLayerThick[ilayer] << endl;
 
   77     firstLayerOffset += kLayerThick[ilayer];
 
   80   cout << 
"total thickness is " << firstLayerOffset << endl;
 
   81   firstLayerOffset = firstLayerOffset/2.;
 
   82   firstLayerOffset = -0.001*(TMath::Floor(1000.*firstLayerOffset));
 
   83   cout << 
"first layer offset is " << firstLayerOffset << endl;
 
   86   TString vmcWorkdir = getenv(
"VMCWORKDIR");
 
   89   TFile* 
fi = 
new TFile(outfile,
"RECREATE");  
 
   91   cout << 
"created output file" << endl;
 
   92   FairGeoLoader* 
geoLoad = 
new FairGeoLoader(
"TGeo",
"FairGeoLoader");
 
   93   FairGeoInterface *
geoFace = geoLoad->getGeoInterface();
 
   94   cout << 
"geoface setmediafile" << endl;
 
   95   geoFace->setMediaFile(
"../../geometry/media_pnd.geo");
 
   96   cout << 
"geoface readmedia" << endl;
 
   98   cout << 
"geoface print" << endl;
 
  100   cout << 
"geoface done" << endl;
 
  102   FairGeoMedia *
Media =  geoFace->getMedia();
 
  103   FairGeoBuilder *
geobuild=geoLoad->getGeoBuilder();
 
  109   FairGeoMedium *CbmMediumCopper    = Media->getMedium(
"copper");
 
  110   FairGeoMedium *CbmMediumKapton    = Media->getMedium(
"kapton");
 
  111   FairGeoMedium *CbmMediumArCO2     = Media->getMedium(
"GEMmixture");
 
  113   Int_t 
nmed=geobuild->createMedium(CbmMediumAir);
 
  114   nmed=geobuild->createMedium(CbmMediumPWO);
 
  115   nmed=geobuild->createMedium(CbmMediumCarbon);
 
  116   nmed=geobuild->createMedium(CbmMediumAluminium);
 
  117   nmed=geobuild->createMedium(CbmMediumCopper);
 
  118   nmed=geobuild->createMedium(CbmMediumKapton);
 
  119   nmed=geobuild->createMedium(CbmMediumArCO2);
 
  121   TGeoManager* 
gGeoMan = (TGeoManager*)gROOT->FindObject(
"FAIRGeom");
 
  123   TGeoVolume *
top = 
new TGeoVolumeAssembly(
"Gem");
 
  125   gGeoMan->SetTopVolume(top);
 
  127   cout << 
"-------------------------------------------------------------------" << endl;
 
  128   TList* mediaList = (TList*)gGeoMan->GetListOfMedia();
 
  130   cout << 
"media known: " << mediaList->GetEntries() << 
"." << endl;
 
  131   for ( Int_t itemp = 0 ; itemp < mediaList->GetEntries() ; itemp++ ) {
 
  132     TGeoMedium* 
medium = (TGeoMedium*)mediaList->At(itemp);
 
  133     cout << 
"medium " << itemp << 
" name is " << medium->GetName() << endl;
 
  135   cout << 
"-------------------------------------------------------------------" << endl;
 
  137   TGeoRotation* 
dummyrot = 
new TGeoRotation();
 
  139   TGeoVolumeAssembly* 
SubunitVol = 
new TGeoVolumeAssembly(
"Gem_Disks");
 
  141   TGeoShape        *DiskShape[kNofDisks];
 
  142   TGeoVolume       *DiskVol  [kNofDisks];
 
  143   TGeoTranslation  *DiskTrans[kNofDisks];
 
  144   TGeoCombiTrans   *DiskCombi[kNofDisks];
 
  146   TGeoShape        *DiskLayersShapeA[kNofDisks][kNofLayers][4];
 
  147   TGeoShape        *DiskLayersShapeB[kNofDisks][kNofLayers][4];
 
  148   TGeoSubtraction  *DiskLayersSubtr [kNofDisks][kNofLayers][4];
 
  149   TGeoShape        *DiskLayersShapeC[kNofDisks][kNofLayers][4]; 
 
  150   TGeoVolume       *DiskLayersVol  [kNofDisks][kNofLayers][4];
 
  151   TGeoTranslation  *DiskLayersTrans[kNofDisks][kNofLayers][4];
 
  152   TGeoCombiTrans   *DiskLayersCombi[kNofDisks][kNofLayers][4];
 
  154   TString outParFileName = Form(
"%s/macro/params/gem_4Stations.digi.par",vmcWorkdir.Data());
 
  156   cout << 
"parameter file = \"" << outParFileName.Data() << 
"\"" << endl;
 
  158   ofstream pout(outParFileName.Data());
 
  159   pout.setf(ios::fixed);
 
  161   pout << 
"#################################################################" << endl;
 
  162   pout << 
"# Digitization parameters for GEM                                " << endl;
 
  163   pout << 
"# with 4 Stations at 90, 120, 150, 180 cm from the target        " << endl;
 
  164   pout << 
"# Format:                                                        " << endl;
 
  165   pout << 
"#Description of parameters:                                      " << endl;
 
  166   pout << 
"#[PndGemDetectors]                                            " << endl;
 
  167   pout << 
"#parameters:d station_number, rotation_angle, number_of_sensors, \\" << endl;
 
  168   pout << 
"#                 sensor_number, sensor_type, pos_x, pos_y, pos_z, rotAngle, inn_rad, out_rad, thick, str_ang_0, str_ang_1, pitch_0, pitch_1, \\" << endl;
 
  169   pout << 
"#                 sensor_number, ...." << endl;
 
  170   pout << 
"#             station_number, ..." << endl;
 
  171   pout << 
"#################################################################" << endl;
 
  172   pout << 
"[PndGemDetectors]" << setprecision(4) << endl;
 
  174   pout << 
"parameters:Double_t \\" << endl;
 
  176   for ( Int_t istat = 0 ; istat < kNofDisks ; istat++ ) {
 
  178     pout << 
"                    " << istat+1 << 
",  " 
  179          << setw(9) << kDiskZPosition[istat]
 
  180          << 
",  0.0, " << 2 << 
", \\" << endl;
 
  182     DiskShape[istat] = 
new TGeoTube  (Form(
"disk%dshape",istat+1),kDiskInnerRadius[istat],kDiskOuterRadius[istat],kHalfStationThickness);
 
  183     DiskVol  [istat] = 
new TGeoVolume(Form(
"Gem_Disk%d_Volume",istat+1),DiskShape[istat],gGeoMan->GetMedium(
"GEMmixture"));
 
  184     DiskTrans[istat] = 
new TGeoTranslation(0.,0.,kDiskZPosition[istat]);
 
  185     cout << 
"station " << kDiskInnerRadius[istat] << 
" " << kDiskOuterRadius[istat] << 
" at " << kDiskZPosition[istat] << endl;
 
  186     DiskCombi[istat] = 
new TGeoCombiTrans(*DiskTrans[istat],*dummyrot); 
 
  187     DiskCombi[istat]->SetName(Form(
"Gem_Disk%d_Volume",istat+1));
 
  188     DiskCombi[istat]->RegisterYourself();
 
  190     Double_t layerPosition = firstLayerOffset;
 
  192     Int_t sensorNumber = 0;
 
  194     for ( Int_t ilay = 0 ; ilay < kNofLayers ; ilay++ ) {
 
  195       layerPosition += kLayerThick[ilay]/2.;
 
  196       if ( kLayerName[ilay].Contains(
"space") && kLayerName[ilay].Length() == 5 ) {
 
  197         layerPosition += kLayerThick[ilay]/2.;
 
  204       for ( Int_t iseg = 0 ; iseg < kDiskNFoils[istat] ; iseg++ ) {
 
  205         DiskLayersShapeA[istat][ilay][iseg] = 
new TGeoTubeSeg(Form(
"disk%dseg%d%sshape",istat+1,iseg+1,kLayerName[ilay].Data()),
 
  206                                                              kDiskInnerRadius[istat],kDiskOuterRadius[istat],
 
  207                                                              kLayerThick[ilay]/2.,
 
  208                                                              segBegin,segBegin+segPhiSpan);
 
  209         DiskLayersShapeB[istat][ilay][iseg] = 
new TGeoBBox   (Form(
"robo%dseg%d%sshape",istat+1,iseg+1,kLayerName[ilay].Data()),
 
  210                                                               kMiddleROBarHfTh[istat]/2.,
 
  211                                                               kDiskOuterRadius[istat],
 
  213         DiskLayersSubtr [istat][ilay][iseg] = 
new TGeoSubtraction(DiskLayersShapeA[istat][ilay][iseg],
 
  214                                                                   DiskLayersShapeB[istat][ilay][iseg]);
 
  215         DiskLayersShapeC[istat][ilay][iseg] = 
new TGeoCompositeShape(Form(
"comp%dseg%d%sshape",istat+1,iseg+1,kLayerName[ilay].Data()),
 
  216                                                                      DiskLayersSubtr[istat][ilay][iseg]);
 
  217         segBegin += segPhiSpan;
 
  219         TString layerMaterial = kLayerName[ilay].Data();
 
  220         layerMaterial.Remove(0,layerMaterial.Last(
'_')+1);
 
  222         DiskLayersVol  [istat][ilay][iseg] = 
new TGeoVolume(Form(
"Gem_Disk%d_Seg%d_%s",istat+1,iseg+1,kLayerName[ilay].Data()),
 
  223                                                             DiskLayersShapeC[istat][ilay][iseg],
 
  224                                                             gGeoMan->GetMedium(layerMaterial.Data()));
 
  227         if ( layerMaterial.Contains(
"copper" ) )
 
  229         if ( layerMaterial.Contains(
"kapton" ) )
 
  231         if ( layerMaterial.Contains(
"aluminium" ) )
 
  233         DiskLayersTrans[istat][ilay][iseg] = 
new TGeoTranslation(0.,0.,layerPosition);
 
  234         DiskLayersCombi[istat][ilay][iseg] = 
new TGeoCombiTrans(*DiskLayersTrans[istat][ilay][iseg],*dummyrot);
 
  235         DiskLayersCombi[istat][ilay][iseg]->SetName(Form(
"Gem_Disk%d_Seg%d_%s",istat+1,iseg+1,kLayerName[ilay].Data()));
 
  236         DiskLayersCombi[istat][ilay][iseg]->RegisterYourself();
 
  237         DiskVol[istat]->AddNode(DiskLayersVol  [istat][ilay][iseg],0,DiskLayersCombi[istat][ilay][iseg]);
 
  241       cout << 
"volume " << kLayerName[ilay] << 
" from "  
  242            << setprecision(10) << kDiskZPosition[istat]+layerPosition-kLayerThick[ilay]/2. << 
" to " 
  243            << setprecision(10) << kDiskZPosition[istat]+layerPosition+kLayerThick[ilay]/2. << endl;
 
  245       if ( kLayerName[ilay].Contains(
"Gem") && kLayerName[ilay].Contains(
"Sensor") ) {
 
  246         Double_t newRadius = kDiskInnerRadius[istat];
 
  249         cout << 
"rad = " << kDiskInnerRadius[istat] << 
" pitch = " << kSensorStripPitch[sensorNumber][0] << 
" for sensor " << sensorNumber << endl;
 
  250         if ( kSensorStripType[sensorNumber] != 2 ) {
 
  251           nofStrips = TMath::Ceil(2.*
TMath::Pi()*kDiskInnerRadius[istat]/kSensorStripPitch[sensorNumber][0]);
 
  252           newRadius = nofStrips*kSensorStripPitch[sensorNumber][0]/2./
TMath::Pi();
 
  254         cout << 
"!!!! " << istat << 
" " << ilay << 
" > there shall be " << nofStrips << 
" strips here so the radius should be " << newRadius << endl;
 
  255         pout << 
"                        " << sensorNumber+1 << 
",  " << kSensorStripType[sensorNumber] << 
",  "  
  256              << setw(9) << 0. << 
",  " 
  257              << setw(9) << 0. << 
",  "  
  258              << setw(9) << kDiskZPosition[istat]+layerPosition << 
",  " 
  259              << setw(9) << 0. << 
",  " 
  260              << setw(9) << newRadius << 
",  " 
  261              << setw(9) << kDiskOuterRadius[istat] << 
",  " 
  262              << setw(9) << kLayerThick[ilay] << 
",  " 
  263              << setw(9) << kSensorStripAngle[sensorNumber][0] << 
",  " 
  265              << setw(9) << kMiddleROBarHfTh[istat] << 
",  " 
  266              << setw(9) << kSensorStripPitch[sensorNumber][0] << 
",  " 
  267              << setw(9) << kSensorStripPitch[sensorNumber][1] << ((istat==kNofDisks-1&&sensorNumber==1)?
"":
", \\") 
 
  272         layerPosition += kLayerThick[ilay]/2.;
 
  274     SubunitVol->AddNode(DiskVol[istat],0,DiskCombi[istat]);
 
  276   pout << 
"TrackFinderOnHits_ParThetaA: Double_t 59.4" << endl
 
  277        << 
"TrackFinderOnHits_ParThetaB: Double_t -0.02" << endl
 
  278        << 
"TrackFinderOnHits_ParTheta0: Double_t 56.1372" << endl
 
  279        << 
"TrackFinderOnHits_ParTheta1: Double_t -0.000564362" << endl
 
  280        << 
"TrackFinderOnHits_ParTheta2: Double_t -0.181828" << endl
 
  281        << 
"TrackFinderOnHits_ParTheta3: Double_t  0.284289" << endl
 
  282        << 
"TrackFinderOnHits_ParRadPhi0:Double_t  0.9944432" << endl
 
  283        << 
"TrackFinderOnHits_ParRadPhi2:Double_t -0.000590706" << endl
 
  284        << 
"TrackFinderOnHits_ParMat0:   Double_t \\" << endl
 
  285        << 
"                                      -2.31333e-6,    0.00067035,    0.10173" << endl
 
  286        << 
"TrackFinderOnHits_ParMat1:   Double_t \\" << endl
 
  287        << 
"                                      -7.46844e-10,   -6.6696e-7,    0.000736672" << endl
 
  288        << 
"##########################################################################################" << flush;
 
  290   top->AddNode(SubunitVol,0,
new TGeoCombiTrans());
 
  292   gGeoMan->CloseGeometry();
 
FairGeoMedium * CbmMediumCarbon
FairGeoMedium * CbmMediumAluminium
FairGeoBuilder * geobuild
FairGeoMedium * CbmMediumAir
FairGeoMedium * CbmMediumPWO
FairGeoInterface * geoFace
vDisk SetLineColor(colYellow)