X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSv11GeomCableRound.cxx;h=17b613aec6aefdf67e799f0b512b6f56437f54fc;hb=770a1f1dd5ac19809a13bba8c977cb81e24aa413;hp=24a8e671674bb5706401312e24ace925a7bb3f80;hpb=5d7a6c6d3b22c077943736dbd6412f32c7422264;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSv11GeomCableRound.cxx b/ITS/AliITSv11GeomCableRound.cxx index 24a8e671674..17b613aec6a 100644 --- a/ITS/AliITSv11GeomCableRound.cxx +++ b/ITS/AliITSv11GeomCableRound.cxx @@ -41,9 +41,9 @@ // ************************************************************************ // Getting some media - TGeoMedium *air = gGeoManager->GetMedium("ITSair"); - TGeoMedium *water = gGeoManager->GetMedium("WATER"); - TGeoMedium *alu = gGeoManager->GetMedium("ITSal"); + TGeoMedium *air = gGeoManager->GetMedium("ITS_AIR$"); + TGeoMedium *water = gGeoManager->GetMedium("ITS_WATER"); + TGeoMedium *alu = gGeoManager->GetMedium("ITS_ITSal"); // Creating a small box inside a bigger one (containers) TGeoBBox *box1 = new TGeoBBox("box1", 6,10,10); @@ -161,17 +161,18 @@ ClassImp(AliITSv11GeomCableRound) //________________________________________________________________________ AliITSv11GeomCableRound:: AliITSv11GeomCableRound(const char* name, Double_t radius) : -AliITSv11GeomCable(name) { + AliITSv11GeomCable(name), + fRadius(radius), + fNlayer(0), + fPhiMin(0), + fPhiMax(360) + { // Constructor - fRadius = radius; - fNlayer = 0; for (Int_t i=0; iGetListOfNodes(); - if (nodes->GetEntriesFast()==0) return kFALSE; + if (nodes->GetEntriesFast()==0) return 0; mainNode = (TGeoNode *) nodes->UncheckedAt(0); } else { mainNode = fInitialNode; @@ -310,7 +312,7 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertCableSegment(Int_t p2) fCurrentVol = p1Vol; if (! CheckDaughter(mainNode)) { printf("Error::volume containing point is not visible in node tree!\n"); - return kFALSE; + return 0; }; Double_t coord1[3], coord2[3], vect1[3], vect2[3]; @@ -328,7 +330,7 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertCableSegment(Int_t p2) fCurrentVol = p2Vol; if (! CheckDaughter(mainNode)) { printf("Error::volume containing point is not visible in node tree!\n"); - return kFALSE; + return 0; }; Int_t p2nodeInd[fgkCableMaxNodeLevel]; for (Int_t i=0; iAddNode(vCableSeg, p2, combi); @@ -410,7 +412,7 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertCableSegment(Int_t p2) printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]); }; // #include -// TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir"); +// TGeoMedium *airSDD = gGeoManager->GetMedium("ITS_AIR$"); // TGeoSphere *sphere = new TGeoSphere(0, 0.15); // TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD); // TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz); @@ -422,12 +424,141 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertCableSegment(Int_t p2) // p2Vol->AddNode(vSphere, p2*3-1, tr1); // p2Vol->AddNode(vSphere, p2*3 , tr2); - return kTRUE; + if (ct) *ct = combi; + return vCableSeg; } +//________________________________________________________________________ +TGeoVolume* AliITSv11GeomCableRound::CreateAndInsertTubeSegment(Int_t p2, + TGeoCombiTrans** ct) +{ +// Creates a cable segment between points p1 and p2. +// +// This creates simple tube sections, i.e. the cable ends are +// cutted perpendicularly to the tube axis. The method has to +// be used only in this simple case, in ordder to save some memory + + TGeoNode *mainNode; + if (fInitialNode==0) { + TObjArray *nodes = gGeoManager->GetListOfNodes(); + if (nodes->GetEntriesFast()==0) return 0; + mainNode = (TGeoNode *) nodes->UncheckedAt(0); + } else { + mainNode = fInitialNode; + }; + + Int_t p1 = p2 - 1; + TGeoVolume *p1Vol = GetVolume(p1); + TGeoVolume *p2Vol = GetVolume(p2); + + ResetCheckDaughter(); + fCurrentVol = p1Vol; + if (! CheckDaughter(mainNode)) { + printf("Error::volume containing point is not visible in node tree!\n"); + return 0; + }; + + Double_t coord1[3], coord2[3], vect1[3], vect2[3]; + //================================================= + // Get p1 position in the systeme of p2 + if (p1Vol!=p2Vol) { + + Int_t p1nodeInd[fgkCableMaxNodeLevel]; + for (Int_t i=0; iGetDaughter(p2nodeInd[i]); + }; + Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]}; + Double_t globalVect1[3] = {vect1[0], vect1[1], vect1[2]}; + + for (Int_t i = commonMotherLevel+1; i<=p2volLevel; i++) { + pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1); + pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1); + CopyFrom(globalCoord1, coord1); + CopyFrom(globalVect1, vect1); + }; + } else { + GetCheckPoint(p1, 0, 0, coord1); + GetCheckVect(p1, 0, 0, vect1); + }; + + //================================================= + // Get p2 position in the systeme of p2 + GetCheckPoint(p2, 0, 0, coord2); + GetCheckVect(p2, 0, 0, vect2); + + Double_t cx = (coord1[0]+coord2[0])/2; + Double_t cy = (coord1[1]+coord2[1])/2; + Double_t cz = (coord1[2]+coord2[2])/2; + Double_t dx = coord2[0]-coord1[0]; + Double_t dy = coord2[1]-coord1[1]; + Double_t dz = coord2[2]-coord1[2]; + + //================================================= + // Positionning of the segment between the 2 points + if ((dy<1e-31)&&(dy>0)) dy = 1e-31; + if ((dz<1e-31)&&(dz>0)) dz = 1e-31; + if ((dy>-1e-31)&&(dy<0)) dy = -1e-31; + if ((dz>-1e-31)&&(dz<0)) dz = -1e-31; + + Double_t angleRot1 = -TMath::ATan2(dx,dy); + Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx); + Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz); + TGeoRotation *rot = new TGeoRotation("",angleRot1*TMath::RadToDeg(), + angleRotDiag*TMath::RadToDeg(), + 0); + TGeoTranslation *trans = new TGeoTranslation("",cx, cy, cz); + + //================================================= + // Create the segment and add it to the mother volume + TGeoVolume *vCableSeg = CreateTubeSegment( coord1,coord2, p2); + + TGeoCombiTrans *combi = new TGeoCombiTrans(*trans, *rot); + p2Vol->AddNode(vCableSeg, p2, combi); + //================================================= + delete rot; + delete trans; + + if (fDebug) { + printf("---\n Cable segment points : "); + printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]); + printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]); + }; + + if (ct) *ct = combi; + return vCableSeg; +} //________________________________________________________________________ -Int_t AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, Double_t rotation) +TGeoVolume* AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, + Double_t rotation, + TGeoCombiTrans** ct) { // Create a torus cable segment between points p1 and p2. // The radius and position of the torus is defined by the @@ -438,7 +569,7 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, Double_t ro TGeoNode *mainNode; if (fInitialNode==0) { TObjArray *nodes = gGeoManager->GetListOfNodes(); - if (nodes->GetEntriesFast()==0) return kFALSE; + if (nodes->GetEntriesFast()==0) return 0; mainNode = (TGeoNode *) nodes->UncheckedAt(0); } else { mainNode = fInitialNode; @@ -452,7 +583,7 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, Double_t ro fCurrentVol = p1Vol; if (! CheckDaughter(mainNode)) { printf("Error::volume containing point is not visible in node tree!\n"); - return kFALSE; + return 0; }; Double_t coord1[3], coord2[3], vect1[3], vect2[3]; @@ -470,7 +601,7 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, Double_t ro fCurrentVol = p2Vol; if (! CheckDaughter(mainNode)) { printf("Error::volume containing point is not visible in node tree!\n"); - return kFALSE; + return 0; }; Int_t p2nodeInd[fgkCableMaxNodeLevel]; for (Int_t i=0; iAddNode(vCableSegT, p2, combiTorus); if (fDebug) { @@ -587,16 +719,18 @@ Int_t AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, Double_t ro printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]); }; - return kTRUE; + if (ct) *ct = combiTorus; + return vCableSegT; } //________________________________________________________________________ TGeoVolume *AliITSv11GeomCableRound::CreateSegment( Double_t *coord1, Double_t *coord2, Double_t *localVect1, - Double_t *localVect2 ) + Double_t *localVect2, Int_t p) { - // Create one cylindrical segment and its layers + // Create a cylindrical segment and its layers. The tube section is cutted by + // two planes, defined by the normal vectors localVect1 and localVect2 //================================================= // Calculate segment "deformation" @@ -622,13 +756,16 @@ TGeoVolume *AliITSv11GeomCableRound::CreateSegment( Double_t *coord1, localVect1[0],localVect1[1],localVect1[2], localVect2[0],localVect2[1],localVect2[2]); - TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair"); - TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD); + TGeoMedium *skinMedia = fLayMedia[fNlayer-1]; + char name[100]; + sprintf(name, "%s_%i",GetName(), p); + TGeoVolume *vCableSeg = new TGeoVolume(name, cableSeg, skinMedia); + vCableSeg->SetLineColor(fLayColor[fNlayer-1]); // add all cable layers Double_t layThickness[100+1]; // 100 layers max !!! layThickness[0] = 0; - for (Int_t iLay=0; iLayAddNode(vLay, iLay+1, 0); }; - vCableSeg->SetVisibility(kFALSE); + //vCableSeg->SetVisibility(kFALSE); return vCableSeg; } //________________________________________________________________________ -TGeoVolume *AliITSv11GeomCableRound::CreateTorus( Double_t &phi, - Double_t &r) +TGeoVolume *AliITSv11GeomCableRound::CreateTubeSegment( Double_t *coord1, + Double_t *coord2, Int_t p) { - // Create one torus segment and its layers - - Double_t torusR = r; - Double_t torusPhi1 = phi; - Double_t torusDPhi = -2*torusPhi1; + // Create a cylindrical segment and its layers //================================================= + // Calculate segment "deformation" + Double_t dx = coord2[0]-coord1[0]; + Double_t dy = coord2[1]-coord1[1]; + Double_t dz = coord2[2]-coord1[2]; + Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz); + + //================================================= // Create the segment - TGeoTorus *cableSeg = new TGeoTorus(torusR, 0,fRadius,torusPhi1,torusDPhi); - TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair"); - TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD); + + TGeoTubeSeg *cableSeg = new TGeoTubeSeg(0, fRadius, length/2, fPhiMin, fPhiMax); + + TGeoMedium *skinMedia = fLayMedia[fNlayer-1]; + char name[100]; + sprintf(name, "%s_%i",GetName(), p); + TGeoVolume *vCableSeg = new TGeoVolume(name, cableSeg, skinMedia); + vCableSeg->SetLineColor(fLayColor[fNlayer-1]); // add all cable layers Double_t layThickness[100+1]; // 100 layers max !!! layThickness[0] = 0; - for (Int_t iLay=0; iLaySetLineColor(fLayColor[iLay]); + vCableSeg->AddNode(vLay, iLay+1, 0); + }; + + //vCableSeg->SetVisibility(kFALSE); + return vCableSeg; +} + + +//________________________________________________________________________ +TGeoVolume *AliITSv11GeomCableRound::CreateTorus( Double_t &phi, + Double_t &r, Int_t p) +{ + // Create one torus segment and its layers + + Double_t torusR = r; +// Double_t torusPhi1 = phi; +// Double_t torusDPhi = -2*torusPhi1; // bug in root ... + Double_t torusPhi1 = 360-phi; + Double_t torusDPhi = 2*phi; + + // // Create the segment, it will also work as the last layer + TGeoTorus *cableSeg = new TGeoTorus(torusR, 0, fRadius, torusPhi1, torusDPhi); + TGeoMedium *skinMedia = fLayMedia[fNlayer-1]; + char name[100]; + sprintf(name, "%s_%i",GetName(),p); + TGeoVolume *vCableSeg = new TGeoVolume(name, cableSeg, skinMedia); + vCableSeg->SetLineColor(fLayColor[fNlayer-1]); + + // add all cable layers but last + Double_t layThickness[100+1]; // 100 layers max !!! + layThickness[0] = 0; + for (Int_t iLay=0; iLaySetLineColor(fLayColor[iLay]); - vCableSeg->AddNode(vLay, iLay+1, 0); + + vCableSeg->AddNode(vLay, iLay+1,0); }; - vCableSeg->SetVisibility(kFALSE); + //vCableSeg->SetVisibility(kFALSE); return vCableSeg; } - //________________________________________________________________________ void AliITSv11GeomCableRound::SetNLayers(Int_t nLayers) { // Set the total number of layers