]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STRUCT/AliPIPEv3.cxx
Fix Coverity leaks
[u/mrichter/AliRoot.git] / STRUCT / AliPIPEv3.cxx
index 66ccb22a111a3cce9b3227459ab9c4d20a2f1995..c0b6cd7edbc33e07125dac4702fecc4f5a339403 100644 (file)
 
 #include <Riostream.h>
 
-#include <TSystem.h>
-#include <TVirtualMC.h>
+#include <TGeoBBox.h>
+#include <TGeoCompositeShape.h>
+#include <TGeoCone.h>
+#include <TGeoGlobalMagField.h>
 #include <TGeoManager.h>
-#include <TGeoVolume.h>
+#include <TGeoMatrix.h>
+#include <TGeoPcon.h>
 #include <TGeoTorus.h>
 #include <TGeoTube.h>
-#include <TGeoCone.h>
-#include <TGeoPcon.h>
-#include <TGeoBBox.h>
+#include <TGeoVolume.h>
 #include <TGeoXtru.h>
-#include <TGeoCompositeShape.h>
+#include <TSystem.h>
+#include <TVirtualMC.h>
 
 #include "AliConst.h"
 #include "AliMagF.h"
@@ -61,11 +63,10 @@ AliPIPEv3::AliPIPEv3(const char *name, const char *title)
 //___________________________________________
 void AliPIPEv3::CreateGeometry()
 {
-    AliDebug(1,"Create PIPEv3 geometry");
 //
-//  Class describing the beam pipe geometry
+//  Method describing the beam pipe geometry
 //
-
+    AliDebug(1,"Create PIPEv3 geometry");
     Float_t dz, z, zsh, z0;
 //
 // Rotation Matrices
@@ -84,12 +85,15 @@ void AliPIPEv3::CreateGeometry()
     const TGeoMedium* kMedAir     =  gGeoManager->GetMedium("PIPE_AIR");
     const TGeoMedium* kMedAirHigh =  gGeoManager->GetMedium("PIPE_AIR_HIGH");
     const TGeoMedium* kMedVac     =  gGeoManager->GetMedium("PIPE_VACUUM");    
+    const TGeoMedium* kMedVacM    =  gGeoManager->GetMedium("PIPE_VACUUMM");    
     const TGeoMedium* kMedInsu    =  gGeoManager->GetMedium("PIPE_INS_C0");    
     const TGeoMedium* kMedSteel   =  gGeoManager->GetMedium("PIPE_INOX");        
     const TGeoMedium* kMedBe      =  gGeoManager->GetMedium("PIPE_BE");       
     const TGeoMedium* kMedCu      =  gGeoManager->GetMedium("PIPE_CU");        
     const TGeoMedium* kMedKapton  =  gGeoManager->GetMedium("PIPE_KAPTON");        
     const TGeoMedium* kMedAco     =  gGeoManager->GetMedium("PIPE_ANTICORODAL");        
+    const TGeoMedium* kMedNEG     =  gGeoManager->GetMedium("PIPE_NEG COATING"); 
+       
 // Top volume
     TGeoVolume* top    = gGeoManager->GetVolume("ALIC");
 //
@@ -137,6 +141,7 @@ void AliPIPEv3::CreateGeometry()
 //      CP/1     //
 ///////////////////
 //  Inner and outer radii of the Be-section [Pos 1]
+    const Float_t kCP1NegRo                      = 2.90 + 0.0002;
     const Float_t kCP1BeRi                       = 2.90;
     const Float_t kCP1BeRo                       = 2.98;
     const Float_t kCP1KaRo                       = 2.99;    
@@ -167,7 +172,7 @@ void AliPIPEv3::CreateGeometry()
 // CP/1 Be-Section                         //
 /////////////////////////////////////////////
     TGeoVolume* voCp1Vac = new TGeoVolume("CP1VAC", 
-                                         new TGeoTube(0., kCP1BeRi,  kCP1Length / 2.), 
+                                         new TGeoTube(0., kCP1BeRi,  kCP1BeLength / 2.), 
                                          kMedVac);
     TGeoVolume* voCp1Be  = new TGeoVolume("CP1BE", 
                                          new TGeoTube(0., kCP1BeRo,  kCP1BeLength / 2.), 
@@ -176,9 +181,14 @@ void AliPIPEv3::CreateGeometry()
     TGeoVolume* voCp1Ka  = new TGeoVolume("CP1KA", 
                                          new TGeoTube(0., kCP1KaRo,  kCP1BeLength / 2.), 
                                          kMedKapton);
+    // Inner NEG coating
+    TGeoVolume* voCp1NEG = new TGeoVolume("CP1NEG", 
+                                         new TGeoTube(kCP1BeRi, kCP1NegRo, kCP1BeLength / 2.), 
+                                         kMedNEG);
 
     voCp1Ka->AddNode(voCp1Be,  1, gGeoIdentity);
     voCp1Be->AddNode(voCp1Vac, 1, gGeoIdentity);
+    voCp1Be->AddNode(voCp1NEG, 1, gGeoIdentity);
     voCp1Mo->AddNode(voCp1Ka,  1, gGeoIdentity);
 
 /////////////////////////////////////////////
@@ -187,24 +197,26 @@ void AliPIPEv3::CreateGeometry()
     TGeoPcon* shCp1At = new TGeoPcon(0., 360., 8);
 //  First Bulge 
     z = - kCP1BeStAdaptorLength / 2.;
-    shCp1At->DefineSection(0, z, kCP1BeRi, kCP1BeStRo);
+    shCp1At->DefineSection(0, z, 0., kCP1BeStRo);
     z += kCP1BulgeLength;
-    shCp1At->DefineSection(1, z, kCP1BeRi, kCP1BeStRo);
-    shCp1At->DefineSection(2, z, kCP1BeRi, kCP1BeRo);
+    shCp1At->DefineSection(1, z, 0., kCP1BeStRo);
+    shCp1At->DefineSection(2, z, 0., kCP1BeRo);
 //  Between the bulges
     z += kCP1BulgeBulgeDistance;
-    shCp1At->DefineSection(3, z, kCP1BeRi, kCP1BeRo);
-    shCp1At->DefineSection(4, z, kCP1BeRi, kCP1BeStRo);
+    shCp1At->DefineSection(3, z, 0., kCP1BeRo);
+    shCp1At->DefineSection(4, z, 0., kCP1BeStRo);
 //  Second bulge
     z += kCP1BulgeLength;
-    shCp1At->DefineSection(5, z, kCP1BeRi, kCP1BeStRo);
-    shCp1At->DefineSection(6, z, kCP1BeRi, kCP1BeRo);
+    shCp1At->DefineSection(5, z, 0., kCP1BeStRo);
+    shCp1At->DefineSection(6, z, 0., kCP1BeRo);
 //  Straight piece
     z = kCP1BeStAdaptorLength / 2.;
-    shCp1At->DefineSection(7, z, kCP1BeRi, kCP1BeRo);
+    shCp1At->DefineSection(7, z, 0., kCP1BeRo);
 //
-    TGeoVolume* voCp1At = new TGeoVolume("CP1AT", shCp1At, kMedSteel);
-
+    TGeoVolume* voCp1At  = new TGeoVolume("CP1AT",  shCp1At, kMedSteel);
+    TGeoVolume* voCp1AtV = new TGeoVolume("CP1ATV", new TGeoTube(0., kCP1BeRi, kCP1BeStAdaptorLength / 2.), kMedVac);
+    voCp1At->AddNode(voCp1AtV, 1, gGeoIdentity);
+    
 //  Position adaptor tube at both ends
     dz = kCP1Length / 2. -  kCP1BeStAdaptorLength / 2.;
     voCp1Mo->AddNode(voCp1At,    1, new TGeoTranslation(0., 0., -dz));
@@ -359,10 +371,11 @@ void AliPIPEv3::CreateGeometry()
 //
 //  Central beam pipe support collars
 //  LHCVC2C_0019
+//  cp1l = 405.
 //  Position at z = -46., 40., 150.
-    TGeoVolume* voCpSupC = new TGeoVolume("CpSupC", new TGeoTube(3.0, 4.0, 0.35), kMedAco);
-    voCp1->AddNode(voCpSupC, 1, new TGeoTranslation(0., 0.,  kCP1Length / 2. - 81.5));
-    voCp1->AddNode(voCpSupC, 2, new TGeoTranslation(0., 0.,  kCP1Length / 2.- 191.5));
+    TGeoVolume* voCpSupC = new TGeoVolume("CpSupC", new TGeoTube(3.051, 4.00, 0.35), kMedAco);
+    voCp1->AddNode(voCpSupC, 1, new TGeoTranslation(0., 0.,  kCP1Length / 2. - 98.2 - 34.77 + 0.49));
+//    voCp1->AddNode(voCpSupC, 2, new TGeoTranslation(0., 0.,  kCP1Length / 2.- 191.5));
 //  Beam Pipe Protection Tube
 //
 //  ALIFWDA_0025
@@ -568,7 +581,7 @@ void AliPIPEv3::CreateGeometry()
     voCp3Mo->SetVisibility(0);
     TGeoVolumeAssembly* voCp3 = new TGeoVolumeAssembly("Cp3");
     voCp3->AddNode(voCp3Mo,  1, gGeoIdentity);
-    voCp3->AddNode(voCpSupC, 3, new TGeoTranslation(0., 0., - kCP3Length / 2. + 4.5));
+    voCp3->AddNode(voCpSupC, 3, new TGeoTranslation(0., 0., - kCP3Length / 2. + 4.6 - 0.49));
     dz = kCP3pos;
 
 //////////////////////////////////////////////
@@ -796,25 +809,29 @@ void AliPIPEv3::CreateGeometry()
 
 ////////////////////////////////////////////////////////////////////////////////     
 //                                                                            //
-//                                  RB24                                      // 
+//                                  RB24/1                                    // 
 //                                                                            //
 ////////////////////////////////////////////////////////////////////////////////
 //
 //
 // Drawing LHCVC2U_0001
-// Copper Tube             373.5 cm 
+// Copper Tube RB24/1      393.5 cm 
 // Warm module VMACA        18.0 cm
 // Annular Ion Pump         35.0 cm
 // Valve                     7.5 cm
-// Warm module WMABC        28.0 cm
+// Warm module VMABC        28.0 cm
 // ================================
 //                         462.0 cm
 //
 
-// Copper Tube
-    const Float_t  kRB24CuTubeL  = 373.5;
-    const Float_t  kRB24CuTubeRi = 8.0/2.;
-    const Float_t  kRB24CuTubeRo = 8.4/2.;
+    
+// Copper Tube RB24/1
+    const Float_t  kRB24CuTubeL   = 393.5;
+    const Float_t  kRB24CuTubeRi  = 8.0/2.;
+    const Float_t  kRB24CuTubeRo  = 8.4/2.;
+    const Float_t  kRB24CuTubeFRo = 7.6;
+    const Float_t  kRB24CuTubeFL  = 1.86;
+
     TGeoVolume* voRB24CuTubeM = new TGeoVolume("voRB24CuTubeM", 
                                               new TGeoTube(0., kRB24CuTubeRo, kRB24CuTubeL/2.), kMedVac);
     voRB24CuTubeM->SetVisibility(0);
@@ -825,6 +842,10 @@ void AliPIPEv3::CreateGeometry()
     TGeoVolume* voRB24CuTubeA  = new TGeoVolume("voRB24CuTubeA", 
                                                new TGeoTube(25., 100., kRB24CuTubeL/2.), kMedAirHigh);
     voRB24CuTubeA->SetVisibility(0);
+    // Simplified DN 100 Flange
+    TGeoVolume* voRB24CuTubeF  = new TGeoVolume("voRB24CuTubeF",
+                                                new TGeoTube(kRB24CuTubeRo, kRB24CuTubeFRo, kRB24CuTubeFL/2.), kMedSteel);
+
 // Warm Module Type VMACA
 // LHCVMACA_0002
 // 
@@ -969,8 +990,8 @@ void AliPIPEv3::CreateGeometry()
 // Pos 2.1 RF Contact Flange      LHCVSR__0003
 //
     TGeoPcon* shRB24B1RCTFlange = new TGeoPcon(0., 360., 6);
-    const Float_t kRB24B1RCTFlangeRin  = 8.06/2.;  // Inner radius
-    const Float_t kRB24B1RCTFlangeL    = 1.45;     // Length
+    const Float_t kRB24B1RCTFlangeRin  = 8.06/2. + 0.05;  // Inner radius
+    const Float_t kRB24B1RCTFlangeL    = 1.45;            // Length
     
     z = 0.;
     shRB24B1RCTFlange->DefineSection(0, z, kRB24B1RCTFlangeRin,  8.20/2.);
@@ -1001,7 +1022,7 @@ void AliPIPEv3::CreateGeometry()
     z =  kRB24B1RCTL -  kRB24B1RCTSL;
     // In the (VSR0004) this section is straight in (LHCVC2U_0001) it is conical ????
     shRB24B1RCT->DefineSection(1, z,  kRB24B1RCTRin + 0.35,  kRB24B1RCTRin + 0.35 + kRB24B1RCTd);
-    z = kRB24B1RCTL;
+    z = kRB24B1RCTL - 0.03;
     shRB24B1RCT->DefineSection(2, z,  kRB24B1RCTRin,  kRB24B1RCTRin + kRB24B1RCTd);
 
     TGeoVolume* voRB24B1RCT = new TGeoVolume("RB24B1RCT", shRB24B1RCT, kMedCu);
@@ -1029,7 +1050,7 @@ void AliPIPEv3::CreateGeometry()
     shRB24B1TTF->DefineSection(5, z,  6.30/2.,  6.7/2.);
     // Transition Tube
     z += 3.75;
-    shRB24B1TTF->DefineSection(6, z,  8.2/2.,  8.6/2.);
+    shRB24B1TTF->DefineSection(6, z,  8.05/2.,  8.45/2.);
     TGeoVolume* voRB24B1TTF = new TGeoVolume("RB24B1TTF", shRB24B1TTF, kMedSteel);
     z =  0.;
     voRB24B1BellowM->AddNode(voRB24B1TTF, 1, new TGeoTranslation(0., 0., z));    
@@ -1319,7 +1340,9 @@ void AliPIPEv3::CreateGeometry()
     const Float_t kRB24VMABCRBT1Ri = 10.0/2.;
     const Float_t kRB24VMABCRBT1Ro = 10.3/2.;
     const Float_t kRB24VMABCRBT1L  = 11.5;   
-    const Float_t kRB24VMABCRBT1L2 = 8.;   
+    const Float_t kRB24VMABCRBT1L2 = 8.;
+    const Float_t kRB24VMABCL      = 28.;
+    
     TGeoTube* shRB24VMABCRBT1 = new TGeoTube(kRB24VMABCRBT1Ri, kRB24VMABCRBT1Ro, kRB24VMABCRBT1L/2.);
     shRB24VMABCRBT1->SetName("RB24VMABCRBT1");
     TGeoTube* shRB24VMABCRBT1o = new TGeoTube(0., kRB24VMABCRBT1Ro,  kRB24VMABCRBT1L/2.);
@@ -1537,7 +1560,7 @@ void AliPIPEv3::CreateGeometry()
     z += (20.35 - 0.63);
     shRB24VMABCTT->DefineSection(5, z, 6.3/2.,  6.7/2.);
     z += 0.63;
-    shRB24VMABCTT->DefineSection(6, z, 6.5/2.,  6.9/2.);
+    shRB24VMABCTT->DefineSection(6, z, 6.3/2.,  6.7/2.);
     TGeoVolume* voRB24VMABCTT = new TGeoVolume("RB24VMABCTT", shRB24VMABCTT, kMedSteel);
     voRB24VMABCRB->AddNode(voRB24VMABCTT, 1, new TGeoTranslation(0., 0., - kRB24VMABCRBT1L/2.-1.));
 
@@ -1588,26 +1611,98 @@ void AliPIPEv3::CreateGeometry()
 
 
 //
-// Assembling RB24
+// Assembling RB24/1
 //    
     TGeoVolumeAssembly* voRB24 = new TGeoVolumeAssembly("RB24");
-
+    // Cu Tube with two simplified flanges
     voRB24->AddNode(voRB24CuTubeM, 1, gGeoIdentity);
     voRB24->AddNode(voRB24CuTubeA, 1, gGeoIdentity);
-
+    z = - kRB24CuTubeL/2 + kRB24CuTubeFL/2.;
+    voRB24->AddNode(voRB24CuTubeF, 1, new TGeoTranslation(0., 0., z));
+    z = + kRB24CuTubeL/2 - kRB24CuTubeFL/2.;
+    voRB24->AddNode(voRB24CuTubeF, 2, new TGeoTranslation(0., 0., z));
+    // VMABC close to compensator magnet
+    z = - kRB24CuTubeL/2. -  (kRB24VMABCL - kRB24VMABCRBT1L/2) + 1.;
+    
+    voRB24->AddNode(voRB24VMABCRB, 2, new TGeoTranslation(0., 0., z));
+    // Bellow
     z =  kRB24CuTubeL/2;
     voRB24->AddNode(voRB24B1BellowM, 1, new TGeoTranslation(0., 0., z));
     z +=  (kRB24B1L +  kRB24AIpML/2.);
-
+    // Annular ion pump
     voRB24->AddNode(voRB24AIpM, 1, new TGeoTranslation(0., 0., z));
     z +=  (kRB24AIpML/2. +  kRB24ValveWz/2.);
-
+    // Valve
     voRB24->AddNode(voRB24ValveMo, 1, new TGeoTranslation(0., 0., z));
     z += (kRB24ValveWz/2.+ kRB24VMABCRBT1L/2. + 1.);
+    // VMABC close to forward detectors
+    voRB24->AddNode(voRB24VMABCRB, 3, new TGeoTranslation(0., 0., z));
+//
+//   RB24/2
+//     
+// Copper Tube RB24/2
+//
+// This is the part inside the compensator magnet
+    const Float_t  kRB242CuTubeL  = 330.0;
+    
+    TGeoVolume* voRB242CuTubeM = new TGeoVolume("voRB242CuTubeM", 
+                                               new TGeoTube(0., kRB24CuTubeRo, kRB242CuTubeL/2.), kMedVacM);
+    voRB242CuTubeM->SetVisibility(0);
+    TGeoVolume* voRB242CuTube = new TGeoVolume("voRB242CuTube", 
+                                              new TGeoTube(kRB24CuTubeRi, kRB24CuTubeRo, kRB242CuTubeL/2.), kMedCu);
+    voRB242CuTubeM->AddNode(voRB242CuTube, 1, gGeoIdentity);
+    
 
-    voRB24->AddNode(voRB24VMABCRB, 1, new TGeoTranslation(0., 0., z));
-    top->AddNode(voRB24, 1, new TGeoCombiTrans(0., 0., kRB24CuTubeL/2 + 88.5 + 400., rot180));
+    TGeoVolumeAssembly* voRB242 = new TGeoVolumeAssembly("RB242");
+    voRB242->AddNode(voRB242CuTubeM, 1, gGeoIdentity);
+    z = - kRB242CuTubeL/2 + kRB24CuTubeFL/2.;
+    voRB242->AddNode(voRB24CuTubeF, 3, new TGeoTranslation(0., 0., z));
+    z = + kRB242CuTubeL/2 - kRB24CuTubeFL/2.;
+    voRB242->AddNode(voRB24CuTubeF, 4, new TGeoTranslation(0., 0., z));
+    z = - kRB24CuTubeL/2 - kRB24VMABCL - kRB242CuTubeL/2.;
+    voRB24->AddNode(voRB242, 1, new TGeoTranslation(0., 0., z));
+//
+//   RB24/3
+//     
+// Copper Tube RB24/3
+    const Float_t  kRB243CuTubeL  = 303.35;
+    
+    TGeoVolume* voRB243CuTubeM = new TGeoVolume("voRB243CuTubeM", 
+                                               new TGeoTube(0., kRB24CuTubeRo, kRB243CuTubeL/2.), kMedVac);
+    voRB24CuTubeM->SetVisibility(0);
+    TGeoVolume* voRB243CuTube = new TGeoVolume("voRB243CuTube", 
+                                              new TGeoTube(kRB24CuTubeRi, kRB24CuTubeRo, kRB243CuTubeL/2.), kMedCu);
+    voRB243CuTubeM->AddNode(voRB243CuTube, 1, gGeoIdentity);
     
+
+    TGeoVolumeAssembly* voRB243  = new TGeoVolumeAssembly("RB243");
+    TGeoVolumeAssembly* voRB243A = new TGeoVolumeAssembly("RB243A");
+    
+    voRB243A->AddNode(voRB243CuTubeM, 1, gGeoIdentity);
+    z = - kRB243CuTubeL/2 + kRB24CuTubeFL/2.;
+    voRB243A->AddNode(voRB24CuTubeF, 5, new TGeoTranslation(0., 0., z));
+    z = + kRB243CuTubeL/2 - kRB24CuTubeFL/2.;
+    voRB243A->AddNode(voRB24CuTubeF, 6, new TGeoTranslation(0., 0., z));
+    z = + kRB243CuTubeL/2;
+    voRB243A->AddNode(voRB24B1BellowM,  2, new TGeoTranslation(0., 0., z));    
+
+    z = - kRB243CuTubeL/2.  - kRB24B1L;
+    voRB243->AddNode(voRB243A, 1, new TGeoTranslation(0., 0., z));    
+    z = - (1.5 * kRB243CuTubeL + 2. * kRB24B1L);
+    voRB243->AddNode(voRB243A, 2, new TGeoTranslation(0., 0., z));    
+
+    z = - 2. * (kRB243CuTubeL + kRB24B1L) - (kRB24VMABCL - kRB24VMABCRBT1L/2) + 1.;
+    voRB243->AddNode(voRB24VMABCRB, 3, new TGeoTranslation(0., 0., z));    
+    
+    z = - kRB24CuTubeL/2 - kRB24VMABCL - kRB242CuTubeL;
+    voRB24->AddNode(voRB243, 1, new TGeoTranslation(0., 0., z));
+
+
+//
+//
+    top->AddNode(voRB24, 1, new TGeoCombiTrans(0., 0., kRB24CuTubeL/2 + 88.5 + 400., rot180));
+
+
 // 
 ////////////////////////////////////////////////////////////////////////////////     
 //                                                                            //
@@ -2036,7 +2131,7 @@ void AliPIPEv3::CreateGeometry()
       shRB26s3SFlange->DefineSection(5, z0, kRB26s3SFlangeRi3, kRB26s3SFlangeRo);
       TGeoVolume* voRB26s3SFlange = new TGeoVolume("RB26s3SFlange", shRB26s3SFlange, kMedSteel);
 
-      TGeoVolume* voRB26s3SFlangeM = new TGeoVolume("RB26s3SFlange", MakeMotherFromTemplate(shRB26s3SFlange, 0, 3), kMedVac);
+      TGeoVolume* voRB26s3SFlangeM = new TGeoVolume("RB26s3SFlangeM", MakeMotherFromTemplate(shRB26s3SFlange, 0, 3), kMedVac);
       voRB26s3SFlangeM->AddNode(voRB26s3SFlange, 1, gGeoIdentity);
         
 ///////////////////////////////////
@@ -2065,7 +2160,7 @@ void AliPIPEv3::CreateGeometry()
       shRB26s3FFlange->DefineSection(5, z0, kRB26s3FFlangeRi3, kRB26s3FFlangeRo);
       TGeoVolume* voRB26s3FFlange = new TGeoVolume("RB26s3FFlange", shRB26s3FFlange, kMedSteel);
       
-      TGeoVolume* voRB26s3FFlangeM = new TGeoVolume("RB26s3FFlange", MakeMotherFromTemplate(shRB26s3FFlange, 2, 5), kMedVac);
+      TGeoVolume* voRB26s3FFlangeM = new TGeoVolume("RB26s3FFlangeM", MakeMotherFromTemplate(shRB26s3FFlange, 2, 5), kMedVac);
       voRB26s3FFlangeM->AddNode(voRB26s3FFlange, 1, gGeoIdentity);
             
 
@@ -2303,7 +2398,7 @@ void AliPIPEv3::CreateGeometry()
       const Float_t kRB26s5CompTubeInnerR    = 10.00/2.;  // Connection tubes inner radius     [Pos 2 + 3]
       const Float_t kRB26s5CompTubeOuterR    = 10.30/2.;  // Connection tubes outer radius     [Pos 2 + 3]
       const Float_t kRB26s5WeldingTubeLeftL  =  3.70/2.;  // Left connection tube half length  [Pos 2]
-      const Float_t kRB26s5WeldingTubeRightL = 13.42/2.;  // Right connection tube half length [Pos 3]   (0.3 cm added for welding)
+      const Float_t kRB26s5WeldingTubeRightL = 13.40/2.;  // Right connection tube half length [Pos 3]   (0.3 cm added for welding)
       const Float_t kRB26s5RingInnerR        = 11.2/2.;   // Ring inner radius                 [Pos 4]
       const Float_t kRB26s5RingOuterR        = 16.0/2.;   // Ring inner radius                 [Pos 4]
       const Float_t kRB26s5RingL             =  0.4/2.;   // Ring half length                  [Pos 4]
@@ -2603,8 +2698,8 @@ void AliPIPEv3::CreateMaterials()
   //
 
   AliDebugClass(1,"Create PIPEv3 materials");
-  Int_t   isxfld = gAlice->Field()->Integ();
-  Float_t sxmgmx = gAlice->Field()->Max();
+  Int_t   isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
+  Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
   // Steel (Inox)  
   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
   Float_t zsteel[4] = { 26.,24.,28.,14. };
@@ -2625,7 +2720,7 @@ void AliPIPEv3::CreateMaterials()
   Float_t zAir[4]={6.,7.,8.,18.};
   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
   Float_t dAir = 1.20479E-3;
-  Float_t dAir1 = 1.20479E-10;
+  Float_t dAir1 = 1.20479E-11;
   //
   // Insulation powder
   //                    Si         O       Ti     Al
@@ -2647,7 +2742,14 @@ void AliPIPEv3::CreateMaterials()
   Float_t zKapton[4]={1.,6.,7.,8.};
   Float_t wKapton[4]={0.026362,0.69113,0.07327,0.209235};
   Float_t dKapton = 1.42;
+  // NEG coating
+  //                  Ti     V      Zr
+  Float_t aNEG[4] = {47.87, 50.94, 91.24};
+  Float_t zNEG[4] = {22.00, 23.00, 40.00};
+  Float_t wNEG[4] = {1./3., 1./3., 1./3.};  
+  Float_t dNEG = 5.6; // ?
 
+  //
   //
   //     Berillium 
   AliMaterial(5, "BERILLIUM$", 9.01, 4., 1.848, 35.3, 36.7);
@@ -2666,7 +2768,8 @@ void AliPIPEv3::CreateMaterials()
   AliMixture(35, "AIR_HIGH$ ", aAir, zAir, dAir, 4, wAir);
   //
   //     Vacuum 
-  AliMixture(16, "VACUUM$ ", aAir, zAir, dAir1, 4, wAir);
+  AliMixture(16, "VACUUM$ " , aAir, zAir, dAir1, 4, wAir);
+  AliMixture(17, "VACUUMM$ ", aAir, zAir, dAir1, 4, wAir);
   //
   //     stainless Steel 
   AliMixture(19, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
@@ -2684,12 +2787,17 @@ void AliPIPEv3::CreateMaterials()
   AliMixture(23, "KAPTON", aKapton, zKapton, dKapton, 4, wKapton);
   // Anticorodal 
   AliMixture(24, "ANTICORODAL", aaco, zaco, 2.66, 3, waco);
-
+  
   //
   //     Insulation powder 
    AliMixture(14, "INSULATION0$", ains, zins, 0.41, 4, wins);
    AliMixture(34, "INSULATION1$", ains, zins, 0.41, 4, wins);
    AliMixture(54, "INSULATION2$", ains, zins, 0.41, 4, wins);
+
+   //    NEG
+   AliMixture(25, "NEG COATING", aNEG, zNEG, dNEG, -3, wNEG);
+   
+   
    // **************** 
    //     Defines tracking media parameters. 
    //
@@ -2714,10 +2822,11 @@ void AliPIPEv3::CreateMaterials()
   //
   //    Air 
   AliMedium(15, "AIR",     15, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(35, "AIR_HIGH",15, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(35, "AIR_HIGH",35, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
   //
   //    Vacuum 
-  AliMedium(16, "VACUUM", 16, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(16, "VACUUM",  16, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(17, "VACUUMM", 17, 0, isxfld, sxmgmx, 0.1, stemax, deemax, epsil, stmin);
   //
   //    Steel 
   AliMedium(19, "INOX",   19, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
@@ -2739,10 +2848,14 @@ void AliPIPEv3::CreateMaterials()
   //
   //   KAPTON
   AliMedium(23, "KAPTON", 23, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+
+  //
+  //   NEG
+  AliMedium(25, "NEG COATING", 25, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
 }
 
 
-TGeoPcon* AliPIPEv3::MakeMotherFromTemplate(TGeoPcon* shape, Int_t imin, Int_t imax, Float_t r0, Int_t nz)
+TGeoPcon* AliPIPEv3::MakeMotherFromTemplate(const TGeoPcon* shape, Int_t imin, Int_t imax, Float_t r0, Int_t nz)
 {
 //
 //  Create a mother shape from a template setting some min radii to 0
@@ -2795,7 +2908,7 @@ TGeoPcon* AliPIPEv3::MakeInsulationFromTemplate(TGeoPcon* shape)
 }
 
 
-TGeoVolume* AliPIPEv3::MakeBellow(char* ext, Int_t nc, Float_t rMin, Float_t rMax, Float_t dU, Float_t rPlie, Float_t dPlie)
+TGeoVolume* AliPIPEv3::MakeBellow(const char* ext, Int_t nc, Float_t rMin, Float_t rMax, Float_t dU, Float_t rPlie, Float_t dPlie)
 {
     // nc     Number of convolution
     // rMin   Inner radius of the bellow
@@ -2807,45 +2920,45 @@ TGeoVolume* AliPIPEv3::MakeBellow(char* ext, Int_t nc, Float_t rMin, Float_t rMa
     const TGeoMedium* kMedSteel  =  gGeoManager->GetMedium("PIPE_INOX");   
 
     char name[64], nameA[64], nameB[64], bools[64];
-    sprintf(name, "%sBellowUS", ext);
+    snprintf(name, 64, "%sBellowUS", ext);
     TGeoVolume* voBellow = new TGeoVolume(name, new TGeoTube(rMin, rMax, dU/2.), kMedVac);
 //      
 //  Upper part of the undulation
 //
     TGeoTorus* shPlieTorusU  =  new TGeoTorus(rMax - rPlie, rPlie - dPlie, rPlie);
-    sprintf(nameA, "%sTorusU", ext);
+    snprintf(nameA, 64, "%sTorusU", ext);
     shPlieTorusU->SetName(nameA);
     TGeoTube*  shPlieTubeU   =  new TGeoTube (rMax - rPlie, rMax, rPlie);
-    sprintf(nameB, "%sTubeU", ext);
+    snprintf(nameB, 64, "%sTubeU", ext);
     shPlieTubeU->SetName(nameB);
-    sprintf(name, "%sUpperPlie", ext);
-    sprintf(bools, "%s*%s", nameA, nameB);
+    snprintf(name,  64, "%sUpperPlie", ext);
+    snprintf(bools, 64, "%s*%s", nameA, nameB);
     TGeoCompositeShape*  shUpperPlie = new TGeoCompositeShape(name, bools);
     
     TGeoVolume* voWiggleU = new TGeoVolume(name, shUpperPlie, kMedSteel);
 //
 // Lower part of the undulation
     TGeoTorus* shPlieTorusL =  new TGeoTorus(rMin + rPlie, rPlie - dPlie, rPlie);
-    sprintf(nameA, "%sTorusL", ext);
+    snprintf(nameA, 64, "%sTorusL", ext);
     shPlieTorusL->SetName(nameA);
     TGeoTube*  shPlieTubeL  =  new TGeoTube (rMin, rMin + rPlie, rPlie);
-    sprintf(nameB, "%sTubeL", ext);
+    snprintf(nameB, 64, "%sTubeL", ext);
     shPlieTubeL->SetName(nameB);
-    sprintf(name, "%sLowerPlie", ext);
-    sprintf(bools, "%s*%s", nameA, nameB);
+    snprintf(name,  64, "%sLowerPlie", ext);
+    snprintf(bools, 64, "%s*%s", nameA, nameB);
     TGeoCompositeShape*  shLowerPlie = new TGeoCompositeShape(name, bools);
     
     TGeoVolume* voWiggleL = new TGeoVolume(name, shLowerPlie, kMedSteel); 
     
 //
 // Connection between upper and lower part of undulation
-    sprintf(name, "%sPlieConn1", ext);
+    snprintf(name, 64, "%sPlieConn1", ext);
     TGeoVolume* voWiggleC1 = new TGeoVolume(name, new TGeoTube(rMin + rPlie, rMax - rPlie, dPlie/2.), kMedSteel);
 //
 // One wiggle
     Float_t dz = rPlie -  dPlie / 2.;
     Float_t z0 = -  dPlie / 2.;
-    sprintf(name, "%sWiggle", ext);
+    snprintf(name, 64, "%sWiggle", ext);
     TGeoVolumeAssembly* asWiggle = new TGeoVolumeAssembly(name);
     asWiggle->AddNode(voWiggleC1,  1 , new TGeoTranslation(0., 0., z0));
     z0 += dz;