23 #include <Riostream.h>
26 #ifndef Gw_AgataGeometryTransformer
42 #ifndef ROOT_TGeoManager
43 #include "TGeoManager.h"
50 #ifndef ROOT_TGeoShape
51 #include "TGeoShape.h"
62 #ifndef ROOT_TGeoMatrix
63 #include "TGeoMatrix.h"
74 #ifndef ROOT_TObjArray
75 #include "TObjArray.h"
82 #ifndef ROOT_TGeoCompositeShape
83 #include "TGeoCompositeShape.h"
90 const Int_t AgataGeometryTransformer::fgkMaxDetectorID = 180;
91 const Int_t AgataGeometryTransformer::fgkMaxDepthID = 6;
92 const Float_t AgataGeometryTransformer::fgkDepth[6] = {0, 8, 21, 36, 54, 72};
93 const Char_t* AgataGeometryTransformer::fgkGeomName =
"Agata";
94 const Char_t* AgataGeometryTransformer::fgkGeomTitle =
"Geometry for Agata";
95 Char_t AgataGeometryTransformer::fgDefaultTransp = 50;
100 fMatrixList(new TObjArray(fgkMaxDetectorID)),
101 fLog(
"AgataGeometryTransformer")
104 fMatrixList->SetOwner(
true);
119 ifstream in(fileName, ios::in);
121 fLog <<
error << Form(
"file %s not found\n", fileName.Data()) <<
dolog;
132 while ( !in.eof() ) {
134 in.getline(line,255);
136 if(sscanf(line,
"%d %d %lf %lf %lf", &nd, &k, &x, &y, &z) != 5) {
137 fLog <<
error <<
"Problem reading translation factors" <<
dolog;
140 trans[0] = x; trans[1] = y, trans[2] = z;
142 if (nd > fgkMaxDetectorID) {
143 fLog <<
error << Form(
"Id %d too large, max: %d\n", nd, fgkMaxDetectorID) <<
dolog;
147 in.getline(line,255);
148 if(sscanf(line,
"%d %lf %lf %lf", &k, &x, &y, &z) != 4)
150 fLog <<
error << Form(
"Problem reading 1st rotation factors for id %d\n", nd) <<
dolog;
153 rot[0] = x; rot[1] = y; rot[2] = z;
155 in.getline(line,255);
156 if(sscanf(line,
"%d %lf %lf %lf", &k, &x, &y, &z) != 4)
158 fLog <<
error << Form(
"Problem reading 2nd rotation factors for id %d\n", nd) <<
dolog;
161 rot[3] = x; rot[4] = y; rot[5] = z;
163 in.getline(line,255);
164 if(sscanf(line,
"%d %lf %lf %lf", &k, &x, &y, &z) != 4)
166 fLog <<
error << Form(
"Problem reading 3rd rotation factors for id %d\n", nd) <<
dolog;
169 rot[6] = x; rot[7] = y; rot[8] = z;
172 if (fMatrixList->At(nd)) {
173 fLog <<
error << Form(
"Matrix transformation already exist for id %d\n", nd) <<
dolog;
190 TGeoRotation rotation; rotation.SetMatrix(rot);
192 TGeoTranslation translation;
193 translation.SetTranslation(trans[0], trans[1], trans[2]);
195 return new TGeoCombiTrans(translation, rotation);
201 Double_t xg, Double_t yg, Double_t zg,
202 Double_t& xl, Double_t& yl, Double_t& zl)
const
204 if (detID < 0 || detID > fgkMaxDetectorID) {
206 fLog <<
error <<
"Wrong detector id number" <<
dolog;
210 TGeoCombiTrans* mat =
static_cast<TGeoCombiTrans*
> ( fMatrixList->At(detID) );
211 Double_t local[3] = {0., 0., 0.};
212 Double_t global[3] = {xg, yg, zg};
214 mat->MasterToLocal(global, local);
223 Float_t xg, Float_t yg, Float_t zg,
224 Float_t& xl, Float_t& yl, Float_t& zl)
const
226 if (detID < 0 || detID > fgkMaxDetectorID) {
228 fLog <<
error <<
"Wrong detector id number" <<
dolog;
232 TGeoCombiTrans* mat =
static_cast<TGeoCombiTrans*
> ( fMatrixList->At(detID) );
233 Double_t local[3] = {0., 0., 0.};
234 Double_t global[3] = {xg, yg, zg};
236 mat->MasterToLocal(global, local);
246 Double_t xl, Double_t yl, Double_t zl,
247 Double_t& xg, Double_t& yg, Double_t& zg)
const
249 if (detID < 0 || detID > fgkMaxDetectorID) {
251 fLog <<
error <<
"Wrong detector id number" <<
dolog;
255 TGeoCombiTrans* mat =
static_cast<TGeoCombiTrans*
> ( fMatrixList->At(detID) );
256 Double_t local[3] = {xl, yl, zl};
257 Double_t global[3] = {0., 0., 0.};
259 mat->LocalToMaster(local, global);
268 Float_t xl, Float_t yl, Float_t zl,
269 Float_t& xg, Float_t& yg, Float_t& zg)
const
271 if (detID < 0 || detID > fgkMaxDetectorID) {
273 fLog <<
error <<
"Wrong detector id number" <<
dolog;
277 TGeoCombiTrans* mat =
static_cast<TGeoCombiTrans*
> ( fMatrixList->At(detID) );
278 Double_t local[3] = {xl, yl, zl};
279 Double_t global[3] = {0., 0., 0.};
281 mat->LocalToMaster(local, global);
292 for (Int_t i = fgkMaxDepthID-1; i >= 0; --i) {
293 if (z > fgkDepth[i]) {
305 Double_t rho = TMath::Sqrt(x*x + y*y);
306 Double_t phi = TMath::ACos(x/rho);
308 Double_t angle = TMath::Pi()/3;
310 Int_t
id = Int_t(phi/angle);
330 const Double_t mm = 0.1;
358 ASolid() : Which(-1),Sides(0),
359 HoleR(0.0),HoleL(0.0),CylR(0.0),CylL(0.0),CylX(0.0),CylY(0.0),CylZ(0.0),
360 ThickB(0.0),ThickC(0.0),CapS(0.0),CapT(0.0),Tolerance(0.0),
361 ColX(0.0),ColY(0.0),ColZ(0.0) { Vertex =
new TObjArray(); Vertex->SetOwner() ; }
362 ~ASolid() { Vertex->Delete();
delete Vertex; }
367 void ASolid::Print()
const
369 cout <<
" Crystal Type " << Which <<
endl;
370 cout <<
" Sides " << Sides <<
endl;
371 cout <<
" Dimensions crystal " << CylL <<
" " << CylR <<
endl;
372 cout <<
" Dimensions hole " << HoleL <<
" " << HoleR <<
endl;
380 if ( gGeoManager == 0x0 )
381 { cout <<
" BuildAgataCrystals needs an existing gGeoManager ... " <<
endl;
return 0 ; }
384 ifstream infil; infil.open(filename);
if ( !infil.is_open() )
return 0 ;
386 cout <<
" ---> Reading description of crystals from file " << filename <<
" ..." <<
endl;
389 int i1,i2,i3,lline;
double x,y,z,X,Y,
Z;
char line[255];
391 std::vector<ASolid *> pgons; ASolid *pPg = 0x0;
int nPgons = 0;
394 while( infil.good() ) {
395 infil.getline(line,255); lline = strlen(line);
397 if ( lline < 2 )
continue;
if ( line[0] ==
'#' )
continue;
400 if(sscanf(line,
"%d %d %d %lf %lf %lf %lf %lf %lf", &i1, &i2, &i3, &x, &y, &z, &X, &Y, &Z) != 9) {
407 pPg =
new ASolid(); pPg->Which = i1; pPg->Sides = i2; pgons.push_back( pPg );
417 else if(i2==0 && i3==1) {
419 pPg->ThickB = y * mm;
420 pPg->ThickC = z * mm;
423 pPg->Tolerance = Z * mm;
425 else if(i2==0 && i3==2) {
431 pPg->Vertex->AddAt(
new TVector3( x * mm, y * mm, z * mm ), i3);
432 pPg->Vertex->AddAt(
new TVector3( X * mm, Y * mm, Z * mm ),i3+i2);
436 cout <<
" ... " << nPgons <<
" different crystals have been built " <<
endl;
442 if ( (mat = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Ge")) == 0x0 )
443 mat =
new TGeoMaterial(
"Ge", 72.59,32,5.32);
445 if ( (med = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Ge")) == 0x0 )
446 med =
new TGeoMedium(
"Ge",1,mat);
448 vector<ASolid*>::iterator itthesolids;
449 for (itthesolids = pgons.begin(); itthesolids!=pgons.end(); itthesolids++) {
451 pPg = *itthesolids; TString cname, pname;
457 TGeoPcon *baseshape =
new TGeoPcon(0.0,360.0,4);
459 baseshape->SetName(cname.Data());
460 baseshape->DefineSection(0,0.0,0.0,pPg->CylR);
461 baseshape->DefineSection(1,0.9990*pPg->HoleL,0.0,pPg->CylR);
462 baseshape->DefineSection(2,pPg->HoleL,pPg->HoleR,pPg->CylR);
463 baseshape->DefineSection(3,pPg->CylL,pPg->HoleR,pPg->CylR);
466 Double_t scale = 0.0, xv[12], yv[12];
468 for (
int i = 0; i < pPg->Sides; i++ ) {
470 p1 = (TVector3 *)pPg->Vertex->At(i); p2 = (TVector3 *)pPg->Vertex->At(i+pPg->Sides);
471 xv[i] = p1->x(); yv[i] = p1->y();
473 Double_t s = TMath::Sqrt(p2->x()*p2->x()+p2->y()*p2->y())
474 / TMath::Sqrt(p1->x()*p1->x()+p1->y()*p1->y()) ;
476 if ( s > scale ) scale = s;
480 pname =
"Shaper"; pname += pPg->Which;
481 TGeoXtru *shaper =
new TGeoXtru(2); shaper->SetName(pname.Data());
483 shaper->DefinePolygon(pPg->Sides,xv,yv);
484 shaper->DefineSection(0,-0.001,0.0,0.0,1.0);
485 shaper->DefineSection(1,1.001*pPg->CylL,0.0,0.0,scale);
488 cname +=
" * "; cname +=
"Shaper"; cname += pPg->Which;
493 pname = basecrysname; pname += pPg->Which;
494 TGeoCompositeShape *crysshape =
new TGeoCompositeShape(pname.Data(),cname.Data());
498 TGeoVolume *thecrys =
new TGeoVolume(pname.Data(),crysshape,med);
500 thecrys->SetLineColor(TColor::GetColor(pPg->ColX,pPg->ColY,pPg->ColZ));
501 thecrys->SetTransparency(fgDefaultTransp);
511 if ( gGeoManager == 0x0 ) {
512 cout <<
" BuildAgataClusters needs an existing gGeoManager ... " <<
endl;
517 ifstream infil; infil.open(filename);
if ( !infil.is_open() )
return 0 ;
519 cout <<
"\nReading description of clusters from file " << filename <<
" ..." <<
endl;
522 Int_t lline, i1, i2, i3, oclust, nclust; Double_t ps, th, ph, x, y, z;
524 TString crysname, clusname; TGeoVolume *clu = 0x0, *cris = 0x0;
526 nclust = 0; oclust = -1;
527 while(infil.good()) {
528 infil.getline(line,255); lline = strlen(line);
529 if(lline < 2)
continue;
530 if(line[0] ==
'#')
continue;
531 if(sscanf(line,
"%d %d %d %lf %lf %lf %lf %lf %lf", &i1, &i2, &i3, &ps, &th, &ph, &x, &y, &z) != 9) {
539 clusname = baseclusname; clusname += oclust; clu =
new TGeoVolumeAssembly(clusname.Data());
542 crysname = basecrysname; crysname += i2; cris = gGeoManager->GetVolume(crysname.Data());
544 cout <<
"Cannot build correctly the cluster " << clusname <<
", " << crysname <<
" does not exist " <<
endl;
547 TGeoHMatrix H; TGeoRotation R; TGeoTranslation T(x*mm,y*mm,z*mm);
553 TGeoHMatrix *h =
new TGeoHMatrix(H); clu->AddNode(cris,i3,h);
558 cout << nclust <<
" different cluster(s) have been build " <<
endl;
return nclust;
565 if ( gGeoManager == 0x0 ) {
566 cout <<
" BuildAgata needs an existing gGeoManager ... " <<
endl;
571 ifstream infil; infil.open(filename);
if ( !infil.is_open() )
return 0x0 ;
573 cout <<
"\n Reading description of AGATA from file " << filename <<
" ..." <<
endl;
577 Int_t lline, i1, i2, nclust = 0; Double_t ps, th, ph, x, y, z;
579 TGeoVolume *agata = 0x0;
580 while(infil.good()) {
581 infil.getline(line,255); lline = strlen(line);
582 if(lline < 2)
continue;
583 if(line[0] ==
'#')
continue;
584 if(sscanf(line,
"%d %d %lf %lf %lf %lf %lf %lf",
585 &i1, &i2, &ps, &th, &ph, &x, &y, &z) != 8)
break;
587 clusname = baseclusname; clusname += i2;
588 TGeoVolume *clus = gGeoManager->GetVolume(clusname.Data());
592 if ( (mat = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
593 mat =
new TGeoMaterial(
"Vacuum",0,0,0);
594 if ( (med = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
595 med =
new TGeoMedium(
"Vacuum",1,mat);
598 agata = gGeoManager->MakeBox(agataName,med,60,60,60);
600 TGeoHMatrix H; TGeoRotation R; TGeoTranslation T(x*mm,y*mm,z*mm);
606 TGeoHMatrix *h =
new TGeoHMatrix(H); agata->AddNode(clus,i1,h); nclust++;
611 cout << nclust <<
" cluster(s) composed this geometry " <<
endl;
return agata;
616 const char *baseclusname,
const char *agataName)
618 if ( gGeoManager == 0x0 ) {
619 new TGeoManager(fgkGeomName, fgkGeomTitle);
623 TGeoVolume *agata = 0x0;
635 const char *baseclusname,
const char *agataName)
637 if ( gGeoManager == 0x0 ) {
638 new TGeoManager(fgkGeomName, fgkGeomTitle);
641 TString path(agataPath);
642 if (!path.EndsWith(
"/"))
644 TString geoSolid(asolid);
645 TString geoCluster(aclust);
646 TString geoEuler(aeuler);
648 geoSolid.Prepend(path);
649 geoCluster.Prepend(path);
650 geoEuler.Prepend(path);
653 TGeoVolume *agata = 0x0;
666 std::ifstream in(danteConf); std::string
tmp;
668 if ( in.is_open() == false ) {
669 cout <<
" ---> Problem opening file " << danteConf <<
" ..." <<
endl;
673 cout <<
" ---> Reading description of Dante from file " << danteConf <<
" ..." <<
endl;
677 TGeoVolume* dante = 0x0;
678 while ( in.good() && !in.eof() ) {
680 if ( tmp[0] ==
'#' ) {
685 Float_t dz, rz1, ry, rz2, rx, tx1, tx2,ty1, ty2, ax, bx, cx, ay, by, cy ;
687 std::istringstream decode(tmp);
693 decode >> dz >> rz1 >> ry >> rz2 >> rx >> tx1 >> tx2 >> ty1 >> ty2 >> ax >> bx >> cx >> ay >> by >> cy ;
712 const Float_t rotX,
const char* basemoduleName,
const char *danteName)
714 if ( gGeoManager == 0x0 ) {
715 new TGeoManager(fgkGeomName, fgkGeomTitle);
718 TGeoVolume* dante = gGeoManager->FindVolumeFast(danteName);
719 if ( dante == 0x0 ) {
722 if ( (mat = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
723 mat =
new TGeoMaterial(
"Vacuum",0,0,0);
724 if ( (med = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
725 med =
new TGeoMedium(
"Vacuum",1,mat);
727 dante = gGeoManager->MakeBox(danteName,med,60,60,60);
731 TGeoMaterial* matMod;
734 if ( (matMod = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Si")) == 0x0 )
735 matMod =
new TGeoMaterial(
"Si", 28.09, 14, 2.3);
736 if ( (medMod = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Si")) == 0x0 )
737 medMod =
new TGeoMedium(
"Si",2,matMod);
739 TGeoBBox *box =
new TGeoBBox(Form(
"%s_Box",basemoduleName), 2., 3., 0.2);
744 TGeoHMatrix* hm = 0x0;
745 TGeoTranslation trans(0., 0., dZ);
752 transfo = rot * trans;
753 hm =
new TGeoHMatrix(transfo);
757 TGeoVolume *danteMod =
new TGeoVolume(Form(
"%s_Dante",basemoduleName),box, medMod);
758 danteMod->SetLineColor(kAzure-5);
759 danteMod->SetTransparency(fgDefaultTransp);
761 TObjArray* list = dante->GetNodes();
763 for (Int_t i = 0; i < list->GetEntries(); ++i) {
764 TGeoVolume* vol = (TGeoVolume*)list->At(i);
766 TString name(vol->GetName());
767 if ( name.Contains(Form(
"%s_Dante",basemoduleName)) )
773 dante->AddNode(danteMod, nbModule, hm);
780 if ( gGeoManager == 0x0 ) {
781 new TGeoManager(fgkGeomName, fgkGeomTitle);
785 TGeoMaterial* matPipe;
788 if ( (matPipe = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Al")) == 0x0 )
789 matPipe =
new TGeoMaterial(
"Al", 26.98,13,2.7);
790 if ( (medPipe = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Al")) == 0x0 )
791 medPipe =
new TGeoMedium(
"Al", 2, matPipe);
794 TGeoVolume* tube = gGeoManager->MakeTube(pipeName, medPipe, minR, maxR, dZ);
795 tube->SetVisibility(
true);
796 tube->SetLineColor(17);
797 tube->SetTransparency(fgDefaultTransp);
804 const char *targetName, TGeoMaterial* mat)
806 if ( gGeoManager == 0x0 ) {
807 new TGeoManager(fgkGeomName, fgkGeomTitle);
811 TGeoMaterial* matTarget;
812 TGeoMedium* medTarget;
816 medTarget =
new TGeoMedium(
"Medium", 1, matTarget);
818 if ( (matTarget = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
819 matTarget =
new TGeoMaterial(
"Vacuum", 0., 0., 0.);
820 if ( (medTarget = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
821 medTarget =
new TGeoMedium(
"Vacuum", 1, matTarget);
824 TGeoVolume* target = gGeoManager->MakeBox(targetName, medTarget, dx, dy, dz);
825 target->SetVisibility(
true);
833 if ( gGeoManager == 0x0 ) {
834 new TGeoManager(fgkGeomName, fgkGeomTitle);
838 TGeoMaterial* matFloor;
839 TGeoMedium* medFloor;
841 if ( (matFloor = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Al")) == 0x0 )
842 matFloor =
new TGeoMaterial(
"Al", 26.98,13,2.7);
843 if ( (medFloor = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Al")) == 0x0 )
844 medFloor =
new TGeoMedium(
"Al", 2, matFloor);
847 TGeoVolume* floor = gGeoManager->MakeBox(floorName, medFloor, dx, dy, dz);
848 floor->SetVisibility(
true);
849 floor->SetLineColor(kWhite);
850 floor->SetTransparency(fgDefaultTransp);
857 if ( gGeoManager == 0x0 ) {
858 new TGeoManager(fgkGeomName, fgkGeomTitle);
862 TGeoMaterial* matMCP;
867 medMCP =
new TGeoMedium(
"Medium", 1, matMCP);
869 if ( (matMCP = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
870 matMCP =
new TGeoMaterial(
"Vacuum", 0., 0., 0.);
871 if ( (medMCP = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
872 medMCP =
new TGeoMedium(
"Vacuum", 1, matMCP);
876 TGeoVolume* mcp = gGeoManager->MakeBox(prismaName,medMCP,dx,dy,dz);
878 TGeoVolume* start = gGeoManager->MakeBox(
"start", medMCP, dx, dy, dz);
879 start->SetVisibility(
true);
880 start->SetLineColor(kBlue);
881 start->SetTransparency(fgDefaultTransp);
885 TGeoHMatrix *hm =
new TGeoHMatrix(rot);
886 mcp->AddNode(start, 0, hm);
895 if ( gGeoManager == 0x0 ) {
896 new TGeoManager(fgkGeomName, fgkGeomTitle);
899 TGeoMaterial* matPrismaDipole;
900 TGeoMedium* medPrismaDipole;
902 if ( (matPrismaDipole = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Fe")) == 0x0 )
903 matPrismaDipole =
new TGeoMaterial(
"Fe", 55.9, 26, 7.87);
904 if ( (medPrismaDipole = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Fe")) == 0x0 )
905 medPrismaDipole =
new TGeoMedium(
"Fe", 3, matPrismaDipole);
909 if ( (mat = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
910 mat =
new TGeoMaterial(
"Vacuum",0,0,0);
911 if ( (med = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
912 med =
new TGeoMedium(
"Vacuum",1,mat);
919 TGeoTranslation trans(-(rmax+rmin)/2*(1+(1-TMath::Cos(20.*TMath::DegToRad()))), 0., (rmax+rmin)/2);
921 TGeoHMatrix *hm =
new TGeoHMatrix(transfo);
923 TGeoVolume* dipole = gGeoManager->MakeCons(Form(
"%s_%s", prismaName,
"Dipole"), medPrismaDipole, dz, rmin, rmax, rmin, rmax, phi1, phi2);
924 dipole->SetVisibility(
true);
925 dipole->SetLineColor(55);
926 dipole->SetTransparency(fgDefaultTransp);
928 TGeoConeSeg* shape = (TGeoConeSeg*)dipole->GetShape();
929 shape->ComputeBBox();
930 Float_t boxSizeX = shape->GetDX();
931 Float_t boxSizeY = shape->GetDY();
932 Float_t boxSizeZ = shape->GetDZ();
934 TGeoVolume* prisma = gGeoManager->MakeBox(prismaName, med, boxSizeX, boxSizeY, boxSizeZ);
935 prisma->AddNode(dipole, 1, hm);
944 if ( gGeoManager == 0x0 ) {
945 new TGeoManager(fgkGeomName, fgkGeomTitle);
948 TGeoMaterial* matPrismaDipole;
949 TGeoMedium* medPrismaDipole;
951 if ( (matPrismaDipole = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Fe")) == 0x0 )
952 matPrismaDipole =
new TGeoMaterial(
"Fe", 55.9, 26, 7.87);
953 if ( (medPrismaDipole = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Fe")) == 0x0 )
954 medPrismaDipole =
new TGeoMedium(
"Fe", 3, matPrismaDipole);
958 if ( (mat = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
959 mat =
new TGeoMaterial(
"Vacuum",0,0,0);
960 if ( (med = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
961 med =
new TGeoMedium(
"Vacuum",1,mat);
967 TGeoHMatrix transfo1;
969 TGeoHMatrix *hm1 =
new TGeoHMatrix(transfo1);
971 TGeoVolume* dipoleIn = gGeoManager->MakeBox(Form(
"%s_%s", prismaName,
"Dipole"), medPrismaDipole, dx, dy, dz);
972 dipoleIn->SetVisibility(
true);
973 dipoleIn->SetLineColor(kViolet);
974 dipoleIn->SetTransparency(fgDefaultTransp);
980 Float_t posZ = 60.*TMath::Tan(60.*TMath::DegToRad());
981 TGeoTranslation trans2(-posX, 0, posZ);
983 TGeoHMatrix transfo2;
984 transfo2 = trans2*rot2;
985 TGeoHMatrix *hm2 =
new TGeoHMatrix(transfo2);
987 TGeoVolume* dipoleOut = gGeoManager->MakeBox(Form(
"%s_%s", prismaName,
"Dipole"), medPrismaDipole, dx, dy, dz);
988 dipoleOut->SetVisibility(
true);
989 dipoleOut->SetLineColor(kViolet);
990 dipoleOut->SetTransparency(fgDefaultTransp);
992 TGeoVolume* prisma = gGeoManager->MakeBox(prismaName, med, 200, 200, 200);
993 prisma->AddNode(dipoleIn, 1, hm1);
994 prisma->AddNode(dipoleOut, 2, hm2);
1002 if ( gGeoManager == 0x0 ) {
1003 new TGeoManager(fgkGeomName, fgkGeomTitle);
1006 TGeoMaterial* matPrismaQpole;
1007 TGeoMedium* medPrismaQpole;
1009 if ( (matPrismaQpole = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Fe")) == 0x0 )
1010 matPrismaQpole =
new TGeoMaterial(
"Fe", 55.9, 26, 7.87);
1011 if ( (medPrismaQpole = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Fe")) == 0x0 )
1012 medPrismaQpole =
new TGeoMedium(
"Fe", 3, matPrismaQpole);
1014 TGeoVolume* prisma = gGeoManager->MakeTube(prismaName, medPrismaQpole, rmin, rmax, dz);
1015 prisma->SetVisibility(
true);
1016 prisma->SetLineColor(kViolet);
1017 prisma->SetTransparency(fgDefaultTransp);
1025 if ( gGeoManager == 0x0 ) {
1026 new TGeoManager(fgkGeomName, fgkGeomTitle);
1030 TGeoMaterial* matMWPC;
1031 TGeoMedium* medMWPC;
1035 medMWPC =
new TGeoMedium(
"Medium", 1, matMWPC);
1037 if ( (matMWPC = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
1038 matMWPC =
new TGeoMaterial(
"Vacuum", 0., 0., 0.);
1039 if ( (medMWPC = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
1040 medMWPC =
new TGeoMedium(
"Vacuum", 1, matMWPC);
1044 TGeoVolume* mwpc = gGeoManager->MakeBox(prismaName,medMWPC,dx,dy,100);
1046 TGeoVolume* fc = gGeoManager->MakeBox(
"FC", medMWPC, dx, 10, 1);
1047 fc->SetVisibility(
true);
1048 fc->SetLineColor(kBlue);
1049 fc->SetTransparency(fgDefaultTransp);
1050 mwpc->AddNode(fc,0);
1052 TGeoVolume* ic = gGeoManager->MakeBox(
"IC", medMWPC, dx, 10, dz);
1053 ic->SetVisibility(
true);
1054 ic->SetLineColor(kBlue);
1055 ic->SetTransparency(fgDefaultTransp);
1056 TGeoTranslation trans1(0., 0., dzFcIc+dz);
1057 TGeoHMatrix *hm1 =
new TGeoHMatrix(trans1);
1058 mwpc->AddNode(ic, 1, hm1);
1066 const char* nameMCP,
const char* nameQPole,
const char* nameDipole,
const char* nameMWPC,
1067 const char* prismaName)
1069 if ( gGeoManager == 0x0 ) {
1070 new TGeoManager(fgkGeomName, fgkGeomTitle);
1075 if ( (mat = (TGeoMaterial *)gGeoManager->GetListOfMaterials()->FindObject(
"Vacuum")) == 0x0 )
1076 mat =
new TGeoMaterial(
"Vacuum",0,0,0);
1077 if ( (med = (TGeoMedium *)gGeoManager->GetListOfMedia()->FindObject(
"Vacuum")) == 0x0 )
1078 med =
new TGeoMedium(
"Vacuum",1,mat);
1081 Float_t dzMCPLoc; Float_t dzQpoleLoc; Float_t dzDipoleLoc; Float_t dzDipMWPCLoc;
1082 if (
ReadPrismaConf(dzMCPLoc, dzQpoleLoc, dzDipoleLoc, dzDipMWPCLoc, prismaConf) ) {
1084 dzQpole = dzQpoleLoc;
1085 dzDipole = dzDipoleLoc;
1086 dzDipMWPC = dzDipMWPCLoc;
1087 cout <<
" ---> Reading description of Prisma from file " << prismaConf <<
" ..." <<
endl;
1089 cout <<
" ---> Using default values for Prisma geometry" <<
" ..." <<
endl;
1093 Float_t dyRot = 30.;
1094 TGeoVolume* prisma = gGeoManager->MakeBox(prismaName,med,450,450,450);
1098 TGeoTranslation trans0(0., 0., dzMCP);
1099 TGeoHMatrix *hm0 =
new TGeoHMatrix(trans0);
1101 prisma->AddNode(mcp, 0, hm0);
1105 TGeoTube* shape = (TGeoTube*)Qpole->GetShape();
1106 shape->ComputeBBox();
1107 Float_t dzQp = shape->GetDZ();
1108 Float_t posZQp = dzQpole + dzQp;
1110 TGeoTranslation trans1(0., 0., posZQp);
1111 TGeoHMatrix *hm1 =
new TGeoHMatrix(trans1);
1113 prisma->AddNode(Qpole, 1, hm1);
1116 Float_t posZDip = dzDipole;
1119 TGeoHMatrix transfo2;
1120 TGeoTranslation trans2(0., 0.,posZDip);
1122 TGeoHMatrix *hm2 =
new TGeoHMatrix(transfo2);
1123 prisma->AddNode(dipole, 2, hm2);
1126 Float_t posXmwpc = 60 + dzDipMWPC * TMath::Cos(dyRot*TMath::DegToRad());
1127 Float_t posZmwpc = posZDip + 60.*TMath::Sqrt(3.) + dzDipMWPC * TMath::Sin(dyRot*TMath::DegToRad());
1130 TGeoHMatrix transfo3;
1131 Float_t dphi = dyRot-90;
1132 TGeoTranslation trans3(-posXmwpc, 0, posZmwpc);
1134 transfo3 = trans3*rot3;
1135 TGeoHMatrix *hm3 =
new TGeoHMatrix(transfo3);
1137 prisma->AddNode(mwpc, 3, hm3);
1145 std::map<TString, float> map;
1146 ifstream in(prismaConf);
1152 while ( in.getline(line,255) ) {
1156 if (tmp[0] ==
'#')
continue;
1157 if (tmp[0] ==
' ')
continue;
1158 if (tmp.Length() < 5)
continue;
1160 Int_t pos = tmp.First(
'=');
1162 TString sValue =
tmp(pos+1, tmp.Length()-pos);
1164 TString sToken =
tmp(0, pos-1);
1166 Float_t
value = sValue.Atof();
1167 map[sToken] =
value;
1170 std::map<TString, float>::iterator iter;
1172 iter = map.find(TString(
"target_mcp_distance"));
1173 dzMCP = iter->second/10.;
1175 iter = map.find(TString(
"target_quad_distance"));
1176 dzQpole = iter->second/10.;
1178 iter = map.find(TString(
"target_dipole_distance"));
1179 dzDipole = iter->second/10.;
1181 iter = map.find(TString(
"dip_fp_dist"));
1182 dzDipMWPC= iter->second/10.;
LogMessage & error(LogMessage &)
LogMessage & dolog(LogMessage &)
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual void SetProcessMethod(const char *)
To set the current method.