LCOV - code coverage report
Current view: top level - TPC/TPCsim - AliTPCv2.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1411 1458 96.8 %
Date: 2016-06-14 17:26:59 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : //
      19             : ///////////////////////////////////////////////////////////////////////////////
      20             : //                                                                           //
      21             : //  Time Projection Chamber version 2 -- detailed TPC and slow simulation    //
      22             : //                                                                           //
      23             : //Begin_Html
      24             : /*
      25             : <img src="picts/AliTPCv2Class.gif">
      26             : */
      27             : //End_Html
      28             : //                                                                           //
      29             : //                                                                           //
      30             : ///////////////////////////////////////////////////////////////////////////////
      31             : 
      32             : //#include <stdlib.h>
      33             : 
      34             : #include <TLorentzVector.h>
      35             : #include <TPDGCode.h>
      36             : #include <TString.h>
      37             : #include "AliLog.h"
      38             : #include "AliMathBase.h"
      39             : #include "AliTrackReference.h"
      40             : #include "AliTPCParam.h"
      41             : #include "AliTPCTrackHitsV2.h"
      42             : #include "AliTPCv2.h"
      43             : #include "AliGeomManager.h"
      44             : #include "TGeoVolume.h"
      45             : #include "TGeoPcon.h"
      46             : #include "TGeoTube.h"
      47             : #include "TGeoCone.h"
      48             : #include "TGeoPgon.h"
      49             : #include "TGeoTrd1.h"
      50             : #include "TGeoCompositeShape.h"
      51             : #include "TGeoPara.h"
      52             : #include "TGeoPhysicalNode.h"
      53             : #include "TGeoHalfSpace.h"
      54             : #include "TTreeStream.h"
      55             : #include "TGeoArb8.h"
      56             : #include <iostream>
      57             : #include <fstream>
      58             : 
      59             : using std::ifstream;
      60             : using std::ios_base;
      61             : extern "C"{
      62             :   Gas gaspar_;
      63             : };
      64          12 : ClassImp(AliTPCv2)
      65             :  
      66             : //_____________________________________________________________________________
      67             : AliTPCv2::AliTPCv2(const char *name, const char *title) :
      68           1 :   AliTPC(name, title),
      69           1 :   fIdSens(0),
      70           1 :   fIDrift(0),
      71           1 :   fSecOld(0) 
      72           5 : {
      73             :   //
      74             :   // Standard constructor for Time Projection Chamber version 2
      75             :   //
      76             : 
      77             : 
      78           1 :   SetBufferSize(128000);
      79           1 :   if(!fTPCParam) {AliFatal("TPC parameters not set");
      80             :       return;
      81             :   }
      82           1 :   gaspar_.fpot=fTPCParam->GetFpot();
      83           1 :   gaspar_.eend=fTPCParam->GetEend();
      84           1 :   gaspar_.eexpo=fTPCParam->GetExp();
      85             : 
      86             : 
      87           3 : }
      88             :  
      89             : //_____________________________________________________________________________
      90             : void AliTPCv2::CreateGeometry()
      91             : {
      92             :   //
      93             :   // Create the geometry of Time Projection Chamber version 2
      94             :   //
      95             :   //Begin_Html
      96             :   /*
      97             :     <img src="picts/AliTPC.gif">
      98             :   */
      99             :   //End_Html
     100             :   //Begin_Html
     101             :   /*
     102             :     <img src="picts/AliTPCv2Tree.gif">
     103             :   */
     104             :   //End_Html
     105             : 
     106             :   //----------------------------------------------------------
     107             :   // This geometry is written using TGeo class
     108             :   // Firstly the shapes are defined, and only then the volumes
     109             :   // What is recognized by the MC are volumes
     110             :   //----------------------------------------------------------
     111             :   //
     112             :   //  tpc - this will be the mother volume
     113             :   //
     114             : 
     115             :   //
     116             :   // here I define a volume TPC
     117             :   // retrive the medium name with "TPC_" as a leading string
     118             :   //
     119           2 :   TGeoPcon *tpc = new TGeoPcon(0.,360.,30); //30 sections
     120             :   //
     121           1 :   tpc->DefineSection(0,-289.6,77.,278.);
     122           1 :   tpc->DefineSection(1,-262.1,77.,278.);
     123             :   //
     124           1 :   tpc->DefineSection(2,-262.1,83.1,278.);
     125           1 :   tpc->DefineSection(3,-260.,83.1,278.);
     126             :   //
     127           1 :   tpc->DefineSection(4,-260.,70.,278.);    
     128           1 :   tpc->DefineSection(5,-259.6,70.,278.);
     129             :   //
     130           1 :   tpc->DefineSection(6,-259.6,68.1,278.);
     131           1 :   tpc->DefineSection(7,-253.6,68.1,278.);
     132             :   //
     133           1 :   tpc->DefineSection(8,-253.6,67.88,278.);//hs
     134           1 :   tpc->DefineSection(9,-74.0,60.68,278.);// hs
     135             :   //
     136           1 :   tpc->DefineSection(10,-74.0,60.1,278.);
     137           1 :   tpc->DefineSection(11,-73.3,60.1,278.);
     138             :   //
     139           1 :   tpc->DefineSection(12,-73.3,56.9,278.); 
     140           1 :   tpc->DefineSection(13,-68.5,56.9,278.);
     141             :   //
     142           1 :   tpc->DefineSection(14,-68.5,60.,278.);
     143           1 :   tpc->DefineSection(15,-64.7,60.,278.);
     144             :   //
     145           1 :   tpc->DefineSection(16,-64.7,56.9,278.); 
     146           1 :   tpc->DefineSection(17,73.3,56.9,278.);
     147             :   //
     148           1 :   tpc->DefineSection(18,73.3,60.1,278.);
     149           1 :   tpc->DefineSection(19,74.0,60.1,278.);
     150             :   //
     151           1 :   tpc->DefineSection(20,74.0,60.68,278.);// hs
     152           1 :   tpc->DefineSection(21,253.6,65.38,278.);// hs
     153             :   //
     154           1 :   tpc->DefineSection(22,253.6,65.6,278.);
     155           1 :   tpc->DefineSection(23,259.6,65.6,278.);
     156             :   //
     157           1 :   tpc->DefineSection(24,259.6,70.0,278.);
     158           1 :   tpc->DefineSection(25,260.,70.0,278.);
     159             :   //
     160           1 :   tpc->DefineSection(26,260.,83.1,278.);
     161           1 :   tpc->DefineSection(27,262.1,83.1,278.);
     162             :   //
     163           1 :   tpc->DefineSection(28,262.1,77.,278);
     164           1 :   tpc->DefineSection(29,289.6,77.,278.);
     165             :   //
     166           1 :   TGeoMedium *m1 = gGeoManager->GetMedium("TPC_Air");
     167           1 :   TGeoVolume *v1 = new TGeoVolume("TPC_M",tpc,m1);
     168             :   //
     169             :   // drift volume - sensitive volume, extended beyond the
     170             :   // endcaps, because of the alignment
     171             :   //
     172           1 :   TGeoPcon *dvol = new TGeoPcon(0.,360.,6);
     173           1 :   dvol->DefineSection(0,-260.,74.5,264.4);
     174           1 :   dvol->DefineSection(1,-253.6,74.5,264.4);
     175             :   //
     176           1 :   dvol->DefineSection(2,-253.6,76.6774,258.);
     177           1 :   dvol->DefineSection(3,253.6,76.6774,258.); 
     178             :   //
     179           1 :   dvol->DefineSection(4,253.6,74.5,264.4);
     180           1 :   dvol->DefineSection(5,260.,74.5,264.4);
     181             :   //
     182           1 :   TGeoMedium *m5 = gGeoManager->GetMedium("TPC_DriftGas2");
     183           1 :   TGeoVolume *v9 = new TGeoVolume("TPC_Drift",dvol,m5);
     184             :   //
     185           1 :   v1->AddNode(v9,1);
     186             :   //
     187             :   // outer insulator
     188             :   //
     189           1 :   TGeoPcon *tpco = new TGeoPcon(0.,360.,6); //insulator
     190             :   //
     191           1 :   tpco->DefineSection(0,-256.6,264.8,278.);
     192           1 :   tpco->DefineSection(1,-253.6,264.8,278.);
     193             :   //
     194           1 :   tpco->DefineSection(2,-253.6,258.,278.);
     195           1 :   tpco->DefineSection(3,250.6,258.,278.);
     196             :   //
     197           1 :   tpco->DefineSection(4,250.6,258.,275.5);
     198           1 :   tpco->DefineSection(5,253.6,258.,275.5);
     199             :   //
     200           1 :   TGeoMedium *m2 = gGeoManager->GetMedium("TPC_CO2");
     201           1 :   TGeoVolume *v2 = new TGeoVolume("TPC_OI",tpco,m2);
     202             :   //
     203             :   TGeoRotation *segrot;//segment rotations
     204             :   //
     205             :   // outer containment vessel
     206             :   //
     207           1 :   TGeoPcon *tocv = new TGeoPcon(0.,360.,6);  // containment vessel
     208             :   //
     209           1 :   tocv->DefineSection(0,-256.6,264.8,278.);
     210           1 :   tocv->DefineSection(1,-253.6,264.8,278.);
     211             :   //
     212           1 :   tocv->DefineSection(2,-253.6,274.8124,278.);
     213           1 :   tocv->DefineSection(3,247.6,274.8124,278.);  
     214             :   //
     215           1 :   tocv->DefineSection(4,247.6,270.4,278.);
     216           1 :   tocv->DefineSection(5,250.6,270.4,278.);
     217             :   //
     218           1 :   TGeoMedium *m3 = gGeoManager->GetMedium("TPC_Al");
     219           1 :   TGeoVolume *v3 = new TGeoVolume("TPC_OCV",tocv,m3); 
     220             :   //
     221           1 :   TGeoTubeSeg *to1 = new TGeoTubeSeg(274.8174,277.995,252.1,0.,59.9); //epoxy
     222           1 :   TGeoTubeSeg *to2 = new TGeoTubeSeg(274.8274,277.985,252.1,0.,59.9); //tedlar
     223           1 :   TGeoTubeSeg *to3 = new TGeoTubeSeg(274.8312,277.9812,252.1,0.,59.9);//prepreg2
     224           1 :   TGeoTubeSeg *to4 = new TGeoTubeSeg(274.9062,277.9062,252.1,0.,59.9);//nomex
     225           1 :   TGeoTubeSeg *tog5 = new TGeoTubeSeg(274.8174,277.995,252.1,59.9,60.);//epoxy
     226             :   //
     227           1 :   TGeoMedium *sm1 = gGeoManager->GetMedium("TPC_Epoxy");
     228           1 :   TGeoMedium *sm2 = gGeoManager->GetMedium("TPC_Tedlar");
     229           1 :   TGeoMedium *sm3 = gGeoManager->GetMedium("TPC_Prepreg2");
     230           1 :   TGeoMedium *sm4 = gGeoManager->GetMedium("TPC_Nomex");
     231             :   //
     232           1 :   TGeoMedium *smep = gGeoManager->GetMedium("TPC_Epoxy1");
     233             :   //
     234           1 :   TGeoVolume *tov1 = new TGeoVolume("TPC_OCV1",to1,sm1);
     235           1 :   TGeoVolume *tov2 = new TGeoVolume("TPC_OCV2",to2,sm2);
     236           1 :   TGeoVolume *tov3 = new TGeoVolume("TPC_OCV3",to3,sm3);
     237           1 :   TGeoVolume *tov4 = new TGeoVolume("TPC_OCV4",to4,sm4);
     238           1 :   TGeoVolume *togv5 = new TGeoVolume("TPC_OCVG5",tog5,sm1);
     239             :   //
     240           1 :   TGeoMedium *mhs = gGeoManager->GetMedium("TPC_Steel");
     241           1 :   TGeoMedium *m12 =  gGeoManager->GetMedium("TPC_Water");
     242             :   //-------------------------------------------------------
     243             :   //  Tpc Outer Field Cage
     244             :   //  daughters - composite (sandwich)
     245             :   //-------------------------------------------------------
     246             : 
     247           1 :   TGeoPcon *tofc = new TGeoPcon(0.,360.,6);
     248             :   //
     249           1 :   tofc->DefineSection(0,-253.6,258.,269.6);
     250           1 :   tofc->DefineSection(1,-250.6,258.,269.6);
     251             :   //
     252           1 :   tofc->DefineSection(2,-250.6,258.,260.0676); 
     253           1 :   tofc->DefineSection(3,250.6,258.,260.0676);
     254             :   //
     255           1 :   tofc->DefineSection(4,250.6,258.,275.5);
     256           1 :   tofc->DefineSection(5,253.6,258.,275.5);
     257             :   //
     258           1 :   TGeoVolume *v4 = new TGeoVolume("TPC_TOFC",tofc,m3); 
     259             :   //sandwich
     260           1 :   TGeoTubeSeg *tf1 = new TGeoTubeSeg(258.0,260.0676,252.1,0.,59.9); //tedlar
     261           1 :   TGeoTubeSeg *tf2 = new TGeoTubeSeg(258.0038,260.0638,252.1,0.,59.9); //prepreg3
     262           1 :   TGeoTubeSeg *tf3 = new TGeoTubeSeg(258.0338,260.0338,252.1,0.,59.9);//nomex
     263           1 :   TGeoTubeSeg *tfg4 = new TGeoTubeSeg(258.0,260.0676,252.1,59.9,60.); //epoxy glue
     264             :   //
     265           1 :   TGeoMedium *sm5 = gGeoManager->GetMedium("TPC_Prepreg3");
     266             :   //
     267           1 :   TGeoVolume *tf1v = new TGeoVolume("TPC_OFC1",tf1,sm2);
     268           1 :   TGeoVolume *tf2v = new TGeoVolume("TPC_OFC2",tf2,sm5);
     269           1 :   TGeoVolume *tf3v = new TGeoVolume("TPC_OFC3",tf3,sm4);
     270           1 :   TGeoVolume *tfg4v = new TGeoVolume("TPC_OFCG4",tfg4,smep);
     271             :   //
     272             :   // outer part - positioning
     273             :   //
     274           1 :   tov1->AddNode(tov2,1); tov2->AddNode(tov3,1); tov3->AddNode(tov4,1);//ocv
     275             :   //
     276           1 :   tf1v->AddNode(tf2v,1); tf2v->AddNode(tf3v,1);//ofc
     277             :   //
     278           1 :   TGeoVolumeAssembly *t200 = new TGeoVolumeAssembly("TPC_OCVSEG");
     279           1 :   TGeoVolumeAssembly *t300 = new TGeoVolumeAssembly("TPC_OFCSEG");
     280             :   //
     281             :   // assembly OCV and OFC
     282             :   //
     283             :   // 1st - no rotation
     284           1 :   t200->AddNode(tov1,1); t200->AddNode(togv5,1);
     285           1 :   t300->AddNode(tf1v,1); t300->AddNode(tfg4v,1);
     286             :   // 2nd - rotation 60 deg
     287           1 :   segrot = new TGeoRotation();
     288           1 :   segrot->RotateZ(60.);
     289           1 :   t200->AddNode(tov1,2,segrot); t200->AddNode(togv5,2,segrot);
     290           1 :   t300->AddNode(tf1v,2,segrot); t300->AddNode(tfg4v,2,segrot);
     291             :   // 3rd rotation 120 deg
     292           1 :   segrot = new TGeoRotation();
     293           1 :   segrot->RotateZ(120.);
     294           1 :   t200->AddNode(tov1,3,segrot); t200->AddNode(togv5,3,segrot);
     295           1 :   t300->AddNode(tf1v,3,segrot); t300->AddNode(tfg4v,3,segrot);
     296             :   //4th rotation 180 deg
     297           1 :   segrot = new TGeoRotation();
     298           1 :   segrot->RotateZ(180.);
     299           1 :   t200->AddNode(tov1,4,segrot); t200->AddNode(togv5,4,segrot);
     300           1 :   t300->AddNode(tf1v,4,segrot); t300->AddNode(tfg4v,4,segrot);
     301             :   //5th rotation 240 deg
     302           1 :   segrot = new TGeoRotation();
     303           1 :   segrot->RotateZ(240.);
     304           1 :   t200->AddNode(tov1,5,segrot); t200->AddNode(togv5,5,segrot);
     305           1 :   t300->AddNode(tf1v,5,segrot); t300->AddNode(tfg4v,5,segrot);
     306             :   //6th rotation 300 deg
     307           1 :   segrot = new TGeoRotation();
     308           1 :   segrot->RotateZ(300.);
     309           1 :   t200->AddNode(tov1,6,segrot); t200->AddNode(togv5,6,segrot);
     310           1 :   t300->AddNode(tf1v,6,segrot); t300->AddNode(tfg4v,6,segrot);
     311             :   //
     312           2 :   v3->AddNode(t200,1,new TGeoTranslation(0.,0.,-1.5)); v4->AddNode(t300,1);
     313             :   //
     314           1 :   v2->AddNode(v3,1); v2->AddNode(v4,1); 
     315             :   //
     316           1 :   v1->AddNode(v2,1);
     317             :   //--------------------------------------------------------------------
     318             :   // Tpc Inner INsulator (CO2) 
     319             :   // the cones, the central drum and the inner f.c. sandwich with a piece
     320             :   // of the flane will be placed in the TPC
     321             :   //--------------------------------------------------------------------
     322           1 :   TGeoPcon *tpci = new TGeoPcon(0.,360.,4);
     323             :   //
     324           1 :   tpci->DefineSection(0,-253.6,68.4,76.6774);
     325           1 :   tpci->DefineSection(1,-74.0,61.2,76.6774);
     326             :   //
     327           1 :   tpci->DefineSection(2,74.0,61.2,76.6774);  
     328             :   //
     329           1 :   tpci->DefineSection(3,253.6,65.9,76.6774);
     330             :   //
     331           1 :   TGeoVolume *v5 = new TGeoVolume("TPC_INI",tpci,m2);
     332             :   //
     333             :   // now the inner field cage - only part of flanges (2 copies)
     334             :   //
     335           1 :   TGeoTube *tif1 = new TGeoTube(69.9,76.6774,1.5); 
     336           1 :   TGeoVolume *v6 = new TGeoVolume("TPC_IFC1",tif1,m3);
     337             :   //
     338             :  //---------------------------------------------------------
     339             :   // Tpc Inner Containment vessel - Muon side
     340             :   //---------------------------------------------------------
     341           1 :   TGeoPcon *tcms = new TGeoPcon(0.,360.,10);
     342             :   //
     343           1 :   tcms->DefineSection(0,-259.1,68.1,74.2);
     344           1 :   tcms->DefineSection(1,-253.6,68.1,74.2);
     345             :   //
     346           1 :   tcms->DefineSection(2,-253.6,68.1,68.4);
     347           1 :   tcms->DefineSection(3,-74.0,60.9,61.2);
     348             :   //
     349           1 :   tcms->DefineSection(4,-74.0,60.1,61.2);
     350           1 :   tcms->DefineSection(5,-73.3,60.1,61.2);
     351             :   //
     352           1 :   tcms->DefineSection(6,-73.3,56.9,61.2);
     353           1 :   tcms->DefineSection(7,-73.0,56.9,61.2);
     354             :   //
     355           1 :   tcms->DefineSection(8,-73.0,56.9,58.8);
     356           1 :   tcms->DefineSection(9,-71.3,56.9,58.8);
     357             :   //
     358           1 :   TGeoVolume *v7 = new TGeoVolume("TPC_ICVM",tcms,m3);
     359             :   //------------------------------------------------
     360             :   //  Heat screen muon side
     361             :   //------------------------------------------------
     362             :  
     363           1 :   TGeoCone *thsm = new TGeoCone(89.8,67.88,68.1,60.68,60.9);
     364           1 :   TGeoCone *thsmw = new TGeoCone(89.8,67.94,68.04,60.74,60.84);
     365           1 :   TGeoVolume *hvsm = new TGeoVolume("TPC_HSM",thsm,mhs); //steel
     366           1 :   TGeoVolume *hvsmw = new TGeoVolume("TPC_HSMW",thsmw,m12); //water 
     367             :   // assembly heat screen muon
     368           1 :   hvsm->AddNode(hvsmw,1);
     369             :   //-----------------------------------------------
     370             :   // inner containment vessel - shaft side
     371             :   //-----------------------------------------------
     372           1 :   TGeoPcon *tcss = new TGeoPcon(0.,360.,10);
     373             :   //
     374           1 :   tcss->DefineSection(0,71.3,56.9,58.8);
     375           1 :   tcss->DefineSection(1,73.0,56.9,58.8);
     376             :   //
     377           1 :   tcss->DefineSection(2,73.0,56.9,61.2);
     378           1 :   tcss->DefineSection(3,73.3,56.9,61.2);
     379             :   //  
     380           1 :   tcss->DefineSection(4,73.3,60.1,61.2);
     381           1 :   tcss->DefineSection(5,74.0,60.1,61.2);
     382             :   //
     383           1 :   tcss->DefineSection(6,74.0,60.9,61.2);
     384           1 :   tcss->DefineSection(7,253.6,65.6,65.9);
     385             :   //
     386           1 :   tcss->DefineSection(8,253.6,65.6,74.2);
     387           1 :   tcss->DefineSection(9,258.1,65.6,74.2);
     388             :   //
     389           1 :   TGeoVolume *v8 = new TGeoVolume("TPC_ICVS",tcss,m3);
     390             :   //-------------------------------------------------
     391             :   //  Heat screen shaft side
     392             :   //--------------------------------------------------
     393           1 :   TGeoCone *thss = new TGeoCone(89.8,60.68,60.9,65.38,65.6);       
     394           1 :   TGeoCone *thssw = new TGeoCone(89.8,60.74,60.84,65.44,65.54);     
     395           1 :   TGeoVolume *hvss = new TGeoVolume("TPC_HSS",thss,mhs); //steel
     396           1 :   TGeoVolume *hvssw = new TGeoVolume("TPC_HSSW",thssw,m12); //water 
     397             :   //assembly heat screen shaft
     398           1 :   hvss->AddNode(hvssw,1);
     399             :   //-----------------------------------------------
     400             :   //  Inner field cage
     401             :   //  define 4 parts and make an assembly
     402             :   //-----------------------------------------------
     403             :   // part1 - Al - 2 copies
     404           1 :   TGeoTube *t1 = new TGeoTube(76.6774,78.845,0.75);
     405           1 :   TGeoVolume *tv1 = new TGeoVolume("TPC_IFC2",t1,m3);
     406             :   // sandwich - outermost parts - 2 copies
     407             :   //
     408             :   // segment outermost
     409             :   //
     410           1 :   TGeoTubeSeg *t2 = new TGeoTubeSeg(76.6774,78.845,74.175,350.,109.4); // tedlar 38 microns
     411           1 :   TGeoTubeSeg *t3 = new TGeoTubeSeg(76.6812,78.8412,74.175,350.,109.4); // prepreg2 500 microns
     412           1 :   TGeoTubeSeg *t4 = new TGeoTubeSeg(76.7312,78.7912,74.175,350.,109.4); // prepreg3 300 microns
     413           1 :   TGeoTubeSeg *t5 = new TGeoTubeSeg(76.7612,78.7612,74.175,350.,109.4); // nomex 2 cm
     414           1 :   TGeoTubeSeg *tepox1 = new TGeoTubeSeg(76.6774,78.845,74.175,109.4,110.);//epoxy
     415           1 :   TGeoTubeSeg *tpr1 = new TGeoTubeSeg(78.845,78.885,74.175,109.,111.);
     416             :   
     417             :   // volumes for the outer part  
     418           1 :   TGeoVolume *tv2 = new TGeoVolume("TPC_IFC3",t2,sm2);
     419           1 :   TGeoVolume *tv3 = new TGeoVolume("TPC_IFC4",t3,sm3);
     420           1 :   TGeoVolume *tv4 = new TGeoVolume("TPC_IFC5",t4,sm5);
     421           1 :   TGeoVolume *tv5 = new TGeoVolume("TPC_IFC6",t5,sm4);
     422           1 :   TGeoVolume *tvep1 = new TGeoVolume("TPC_IFEPOX1",tepox1,smep); 
     423           1 :   TGeoVolume *tvpr1 = new TGeoVolume("TPC_PRSTR1",tpr1,sm2); 
     424             :   //
     425             :   // middle parts - 2 copies
     426             :   //
     427             :   // segment middle
     428             :   //
     429           1 :   TGeoTubeSeg *t6 = new TGeoTubeSeg(76.6774,78.795,5.,350.,109.4); // tedlar 38 microns
     430           1 :   TGeoTubeSeg *t7 = new TGeoTubeSeg(76.6812,78.7912,5.,350.,109.4); // prepreg2 250 microns
     431           1 :   TGeoTubeSeg *t8 = new TGeoTubeSeg(76.7062,78.7662,5.,350.,109.4); // prepreg3 300 microns
     432           1 :   TGeoTubeSeg *t9 = new TGeoTubeSeg(76.7362,78.7362,5.,350.,109.4); // nomex 2 cm
     433           1 :   TGeoTubeSeg *tepox2 = new TGeoTubeSeg(76.6774,78.795,5.,109.4,110.);//epoxy
     434           1 :   TGeoTubeSeg *tpr2 = new TGeoTubeSeg(78.795,78.835,5.,109.,111.);
     435             :   // volumes for the middle part
     436           1 :   TGeoVolume *tv6 = new TGeoVolume("TPC_IFC7",t6,sm2);
     437           1 :   TGeoVolume *tv7 = new TGeoVolume("TPC_IFC8",t7,sm3);
     438           1 :   TGeoVolume *tv8 = new TGeoVolume("TPC_IFC9",t8,sm5);
     439           1 :   TGeoVolume *tv9 = new TGeoVolume("TPC_IFC10",t9,sm4);
     440           1 :   TGeoVolume *tvep2 = new TGeoVolume("TPC_IFEPOX2",tepox2,smep);
     441           1 :   TGeoVolume *tvpr2 = new TGeoVolume("TPC_PRSTR2",tpr2,sm2);
     442             :   // central part - 1 copy
     443             :   // 
     444             :   // segment central part
     445             :   //
     446           1 :   TGeoTubeSeg *t10 = new TGeoTubeSeg(76.6774,78.785,93.75,350.,109.4); // tedlar 38 microns 
     447           1 :   TGeoTubeSeg *t11 = new TGeoTubeSeg(76.6812,78.7812,93.75,350.,109.4); // prepreg3 500 microns
     448           1 :   TGeoTubeSeg *t12 = new TGeoTubeSeg(76.7312,78.7312,93.75,350.,109.4); // nomex 2 cm 
     449           1 :   TGeoTubeSeg *tepox3 = new TGeoTubeSeg(76.6774,78.785,93.75,109.4,110.);//epoxy
     450           1 :   TGeoTubeSeg *tpr3 = new TGeoTubeSeg(78.785,78.825,93.75,109.,111.);
     451             :   // volumes for the central part
     452           1 :   TGeoVolume *tv10 = new TGeoVolume("TPC_IFC11",t10,sm2);
     453           1 :   TGeoVolume *tv11 = new TGeoVolume("TPC_IFC12",t11,sm5);
     454           1 :   TGeoVolume *tv12 = new TGeoVolume("TPC_IFC13",t12,sm4);
     455           1 :   TGeoVolume *tvep3 = new TGeoVolume("TPC_IFEPOX3",tepox3,smep);
     456           1 :   TGeoVolume *tvpr3 = new TGeoVolume("TPC_PRSTR3",tpr3,sm2);  
     457             :   //
     458             :   // creating a sandwich for the outer par,t tv2 is the mother
     459             :   //
     460           1 :   tv2->AddNode(tv3,1); tv3->AddNode(tv4,1); tv4->AddNode(tv5,1);
     461             :   //
     462             :   // creating a sandwich for the middle part, tv6 is the mother
     463             :   //
     464           1 :   tv6->AddNode(tv7,1); tv7->AddNode(tv8,1); tv8->AddNode(tv9,1);
     465             :   //
     466             :   // creating a sandwich for the central part, tv10 is the mother
     467             :   //
     468           1 :   tv10->AddNode(tv11,1); tv11->AddNode(tv12,1);
     469             :   //
     470           1 :   TGeoVolumeAssembly *tv100 = new TGeoVolumeAssembly("TPC_IFC"); // ifc itself - 3 segments
     471             : 
     472             :   //
     473             :   // first segment - no rotation
     474             :   //
     475             :   // central
     476           1 :   tv100->AddNode(tv10,1); //sandwich
     477           1 :   tv100->AddNode(tvep3,1);//epoxy
     478           1 :   tv100->AddNode(tvpr3,1);//prepreg strip                                 
     479             :   // middle
     480           2 :   tv100->AddNode(tv6,1,new TGeoTranslation(0.,0.,-98.75)); //sandwich1
     481           2 :   tv100->AddNode(tv6,2,new TGeoTranslation(0.,0.,98.75)); // sandwich2
     482           2 :   tv100->AddNode(tvep2,1,new TGeoTranslation(0.,0.,-98.75)); //epoxy
     483           2 :   tv100->AddNode(tvep2,2,new TGeoTranslation(0.,0.,98.75)); //epoxy
     484           2 :   tv100->AddNode(tvpr2,1,new TGeoTranslation(0.,0.,-98.75));//prepreg strip
     485           2 :   tv100->AddNode(tvpr2,2,new TGeoTranslation(0.,0.,98.75));
     486             :   // outer
     487           2 :   tv100->AddNode(tv2,1,new TGeoTranslation(0.,0.,-177.925)); //sandwich
     488           2 :   tv100->AddNode(tv2,2,new TGeoTranslation(0.,0.,177.925));
     489           2 :   tv100->AddNode(tvep1,1,new TGeoTranslation(0.,0.,-177.925)); //epoxy
     490           2 :   tv100->AddNode(tvep1,2,new TGeoTranslation(0.,0.,177.925));
     491           2 :   tv100->AddNode(tvpr1,1,new TGeoTranslation(0.,0.,-177.925));//prepreg strip
     492           2 :   tv100->AddNode(tvpr1,2,new TGeoTranslation(0.,0.,-177.925));
     493             :   //
     494             :   // second segment - rotation 120 deg.
     495             :   //
     496           1 :   segrot = new TGeoRotation();
     497           1 :   segrot->RotateZ(120.);
     498             :   //
     499             :   // central    
     500           1 :   tv100->AddNode(tv10,2,segrot); //sandwich
     501           1 :   tv100->AddNode(tvep3,2,segrot);//epoxy
     502           1 :   tv100->AddNode(tvpr3,2,segrot);//prepreg strip
     503             :   // middle
     504           2 :   tv100->AddNode(tv6,3,new TGeoCombiTrans(0.,0.,-98.75,segrot)); //sandwich1
     505           2 :   tv100->AddNode(tv6,4,new TGeoCombiTrans(0.,0.,98.75,segrot)); // sandwich2
     506           2 :   tv100->AddNode(tvep2,3,new TGeoCombiTrans(0.,0.,-98.75,segrot)); //epoxy
     507           2 :   tv100->AddNode(tvep2,4,new TGeoCombiTrans(0.,0.,98.75,segrot)); //epoxy
     508           2 :   tv100->AddNode(tvpr2,3,new TGeoCombiTrans(0.,0.,-98.75,segrot));//prepreg strip
     509           2 :   tv100->AddNode(tvpr2,4,new TGeoCombiTrans(0.,0.,98.75,segrot));
     510             :   //outer
     511           2 :   tv100->AddNode(tv2,3,new TGeoCombiTrans(0.,0.,-177.925,segrot));//sandwich
     512           2 :   tv100->AddNode(tv2,4,new TGeoCombiTrans(0.,0.,177.925,segrot));
     513           2 :   tv100->AddNode(tvep1,3,new TGeoCombiTrans(0.,0.,-177.925,segrot));//epoxy
     514           2 :   tv100->AddNode(tvep1,4,new TGeoCombiTrans(0.,0.,177.925,segrot));
     515           2 :   tv100->AddNode(tvpr1,3,new TGeoCombiTrans(0.,0.,-177.925,segrot));//prepreg strip
     516           2 :   tv100->AddNode(tvpr1,4,new TGeoCombiTrans(0.,0.,177.925,segrot));
     517             :   //
     518             :   //  third segment - rotation 240 deg.
     519             :   //
     520           1 :   segrot = new TGeoRotation();
     521           1 :   segrot->RotateZ(240.);
     522             :   //
     523             :   // central    
     524           1 :   tv100->AddNode(tv10,3,segrot); //sandwich
     525           1 :   tv100->AddNode(tvep3,3,segrot);//epoxy
     526           1 :   tv100->AddNode(tvpr3,3,segrot);//prepreg strip
     527             :   // middle
     528           2 :   tv100->AddNode(tv6,5,new TGeoCombiTrans(0.,0.,-98.75,segrot)); //sandwich1
     529           2 :   tv100->AddNode(tv6,6,new TGeoCombiTrans(0.,0.,98.75,segrot)); // sandwich2
     530           2 :   tv100->AddNode(tvep2,5,new TGeoCombiTrans(0.,0.,-98.75,segrot)); //epoxy
     531           2 :   tv100->AddNode(tvep2,6,new TGeoCombiTrans(0.,0.,98.75,segrot)); //epoxy
     532           2 :   tv100->AddNode(tvpr2,5,new TGeoCombiTrans(0.,0.,-98.75,segrot));//prepreg strip
     533           2 :   tv100->AddNode(tvpr2,6,new TGeoCombiTrans(0.,0.,98.75,segrot));
     534             :   //outer
     535           2 :   tv100->AddNode(tv2,5,new TGeoCombiTrans(0.,0.,-177.925,segrot));//sandwich
     536           2 :   tv100->AddNode(tv2,6,new TGeoCombiTrans(0.,0.,177.925,segrot));
     537           2 :   tv100->AddNode(tvep1,5,new TGeoCombiTrans(0.,0.,-177.925,segrot));//epoxy
     538           2 :   tv100->AddNode(tvep1,6,new TGeoCombiTrans(0.,0.,177.925,segrot));
     539           2 :   tv100->AddNode(tvpr1,5,new TGeoCombiTrans(0.,0.,-177.925,segrot));//prepreg strip
     540           2 :   tv100->AddNode(tvpr1,6,new TGeoCombiTrans(0.,0.,177.925,segrot));
     541             :   // Al parts - rings
     542           2 :   tv100->AddNode(tv1,1,new TGeoTranslation(0.,0.,-252.85));
     543           2 :   tv100->AddNode(tv1,2,new TGeoTranslation(0.,0.,252.85));
     544             :   //
     545           2 :   v5->AddNode(v6,1, new TGeoTranslation(0.,0.,-252.1));
     546           2 :   v5->AddNode(v6,2, new TGeoTranslation(0.,0.,252.1));
     547           1 :   v1->AddNode(v5,1); v1->AddNode(v7,1); v1->AddNode(v8,1); 
     548           2 :   v1->AddNode(hvsm,1,new TGeoTranslation(0.,0.,-163.8)); 
     549           2 :   v1->AddNode(hvss,1,new TGeoTranslation(0.,0.,163.8)); 
     550           1 :   v9->AddNode(tv100,1);
     551             :   //
     552             :   // central drum 
     553             :   //
     554             :   // flange + sandwich
     555             :   //
     556           1 :   TGeoPcon *cfl = new TGeoPcon(0.,360.,6);
     557           1 :   cfl->DefineSection(0,-71.1,59.7,61.2);
     558           1 :   cfl->DefineSection(1,-68.6,59.7,61.2);
     559             :   //
     560           1 :   cfl->DefineSection(2,-68.6,60.6124,61.2);
     561           1 :   cfl->DefineSection(3,68.6,60.6124,61.2); 
     562             :   //
     563           1 :   cfl->DefineSection(4,68.6,59.7,61.2);
     564           1 :   cfl->DefineSection(5,71.1,59.7,61.2);  
     565             :   //
     566           1 :   TGeoVolume *cflv = new TGeoVolume("TPC_CDR",cfl,m3);
     567             :   // sandwich
     568           1 :   TGeoTubeSeg *cd1 = new TGeoTubeSeg(60.6224,61.19,71.1,0.2,119.2);
     569           1 :   TGeoTubeSeg *cd2 = new TGeoTubeSeg(60.6262,61.1862,71.1,0.2,119.2);
     570           1 :   TGeoTubeSeg *cd3 = new TGeoTubeSeg(60.6462,61.1662,71.1,0.2,119.2);
     571           1 :   TGeoTubeSeg *cd4 = new TGeoTubeSeg(60.6562,61.1562,71.1,0.2,119.2);
     572           1 :   TGeoTubeSeg *tepox4 = new TGeoTubeSeg(60.6224,61.19,71.1,359.8,0.8);
     573             :   //
     574           1 :   TGeoMedium *sm6 = gGeoManager->GetMedium("TPC_Prepreg1");
     575           1 :   TGeoMedium *sm8 = gGeoManager->GetMedium("TPC_Epoxyfm");
     576           1 :   TGeoVolume *cd1v = new TGeoVolume("TPC_CDR1",cd1,sm2); //tedlar
     577           1 :   TGeoVolume *cd2v = new TGeoVolume("TPC_CDR2",cd2,sm6);// prepreg1
     578           1 :   TGeoVolume *cd3v = new TGeoVolume("TPC_CDR3",cd3,sm8); //epoxy film
     579           1 :   TGeoVolume *cd4v = new TGeoVolume("TPC_CDR4",cd4,sm4); //nomex
     580           1 :   TGeoVolume *tvep4 = new TGeoVolume("TPC_IFEPOX4",tepox4,smep);
     581             : 
     582             :   //
     583             :   // seals for central drum 2 copies
     584             :   //
     585           1 :   TGeoTube *cs = new TGeoTube(56.9,61.2,0.1);
     586           1 :   TGeoMedium *sm7 = gGeoManager->GetMedium("TPC_Mylar");
     587           1 :   TGeoVolume *csv = new TGeoVolume("TPC_CDRS",cs,sm7);
     588           2 :   v1->AddNode(csv,1,new TGeoTranslation(0.,0.,-71.2));
     589           2 :   v1->AddNode(csv,2,new TGeoTranslation(0.,0.,71.2));
     590             :   //
     591             :   // seal collars 
     592           1 :   TGeoPcon *se = new TGeoPcon(0.,360.,6);
     593           1 :   se->DefineSection(0,-72.8,59.7,61.2);
     594           1 :   se->DefineSection(1,-72.3,59.7,61.2);
     595             :   //
     596           1 :   se->DefineSection(2,-72.3,58.85,61.2);
     597           1 :   se->DefineSection(3,-71.6,58.85,61.2); 
     598             :   //
     599           1 :   se->DefineSection(4,-71.6,59.7,61.2);
     600           1 :   se->DefineSection(5,-71.3,59.7,61.2);  
     601             :   //
     602           1 :   TGeoVolume *sev = new TGeoVolume("TPC_CDCE",se,m3);
     603             :   //
     604           1 :   TGeoTube *si = new TGeoTube(56.9,58.8,1.); 
     605           1 :   TGeoVolume *siv = new TGeoVolume("TPC_CDCI",si,m3);
     606             :   //
     607             :   // define reflection matrix 
     608             :   //
     609           1 :   TGeoRotation *ref = new TGeoRotation("ref",90.,0.,90.,90.,180.,0.);
     610             :   //
     611           1 :   cd1v->AddNode(cd2v,1); cd2v->AddNode(cd3v,1); cd3v->AddNode(cd4v,1); //sandwich
     612             :   // first segment  
     613           1 :   cflv->AddNode(cd1v,1); cflv->AddNode(tvep4,1);
     614             :   // second segment
     615           1 :   segrot = new TGeoRotation();
     616           1 :   segrot->RotateZ(120.);
     617           1 :   cflv->AddNode(cd1v,2,segrot); cflv->AddNode(tvep4,2,segrot);
     618             :   // third segment
     619           1 :   segrot = new TGeoRotation();
     620           1 :   segrot->RotateZ(240.);
     621           1 :   cflv->AddNode(cd1v,3,segrot); cflv->AddNode(tvep4,3,segrot);
     622             :   //
     623           2 :   v1->AddNode(siv,1,new TGeoTranslation(0.,0.,-69.9));
     624           2 :   v1->AddNode(siv,2,new TGeoTranslation(0.,0.,69.9));
     625           1 :   v1->AddNode(sev,1); v1->AddNode(sev,2,ref); v1->AddNode(cflv,1);
     626             :   //
     627             :   // central membrane - 2 rings and a mylar membrane - assembly
     628             :   //
     629           1 :   TGeoTube *ih = new TGeoTube(81.05,84.05,0.3);
     630           1 :   TGeoTube *oh = new TGeoTube(250.,256.,0.5);
     631           1 :   TGeoTube *mem = new TGeoTube(84.05,250.,0.00115);
     632             : 
     633             :   //
     634           1 :   TGeoMedium *m4 = gGeoManager->GetMedium("TPC_G10");
     635             :   //
     636           1 :   TGeoVolume *ihv = new TGeoVolume("TPC_IHVH",ih,m3);
     637           1 :   TGeoVolume *ohv = new TGeoVolume("TPC_OHVH",oh,m3);
     638             :   
     639           1 :   TGeoVolume *memv = new TGeoVolume("TPC_HV",mem,sm7);
     640             :   //
     641           1 :   TGeoVolumeAssembly *cm = new TGeoVolumeAssembly("TPC_HVMEM");
     642           1 :   cm->AddNode(ihv,1);
     643           1 :   cm->AddNode(ohv,1);
     644           1 :   cm->AddNode(memv,1);
     645             :  
     646           1 :   v9->AddNode(cm,1);
     647             :   //
     648             :   // end caps - they are make as an assembly of single segments
     649             :   // containing both readout chambers
     650             :   //
     651           1 :   Double_t openingAngle = 10.*TMath::DegToRad();
     652             :   Double_t thick=1.5; // rib
     653           1 :   Double_t shift = thick/TMath::Sin(openingAngle);
     654             :   //
     655             :   Double_t lowEdge = 86.3; // hole in the wheel
     656             :   Double_t upEdge = 240.4; // hole in the wheel
     657             :   //
     658           1 :   new TGeoTubeSeg("sec",74.5,264.4,3.,0.,20.);
     659             :   //
     660           1 :   TGeoPgon *hole = new TGeoPgon("hole",0.,20.,1,4);
     661             :   //
     662           1 :   hole->DefineSection(0,-3.5,lowEdge-shift,upEdge-shift);
     663           1 :   hole->DefineSection(1,-1.5,lowEdge-shift,upEdge-shift);
     664             :   //
     665           1 :   hole->DefineSection(2,-1.5,lowEdge-shift,upEdge+3.-shift);
     666           1 :   hole->DefineSection(3,3.5,lowEdge-shift,upEdge+3.-shift);
     667             :   //
     668           1 :   Double_t ys = shift*TMath::Sin(openingAngle); 
     669           1 :   Double_t xs = shift*TMath::Cos(openingAngle);
     670           1 :   TGeoTranslation *tr = new TGeoTranslation("tr",xs,ys,0.);  
     671           1 :   tr->RegisterYourself();
     672           1 :   TGeoCompositeShape *chamber = new TGeoCompositeShape("sec-hole:tr");
     673           1 :   TGeoVolume *sv = new TGeoVolume("TPC_WSEG",chamber,m3);
     674           1 :   TGeoPgon *bar = new TGeoPgon("bar",0.,20.,1,2);
     675           1 :   bar->DefineSection(0,-3.,131.5-shift,136.5-shift);
     676           1 :   bar->DefineSection(1,1.5,131.5-shift,136.5-shift);
     677           1 :   TGeoVolume *barv = new TGeoVolume("TPC_WBAR",bar,m3);
     678           1 :   TGeoVolumeAssembly *ch = new TGeoVolumeAssembly("TPC_WCH");//empty segment
     679             :   //
     680           1 :   ch->AddNode(sv,1); ch->AddNode(barv,1,tr);
     681             :   //
     682             :   // readout chambers
     683             :   //
     684             :   // IROC first
     685             :   //
     686           1 :    TGeoTrd1 *ibody = new TGeoTrd1(13.8742,21.3328,4.29,21.15);
     687           1 :    TGeoVolume *ibdv = new TGeoVolume("TPC_IROCB",ibody,m3);
     688             :   // empty space
     689           1 :    TGeoTrd1 *emp = new TGeoTrd1(12.3742,19.8328,3.99,19.65);
     690           1 :    TGeoVolume *empv = new TGeoVolume("TPC_IROCE",emp,m1);
     691           2 :    ibdv->AddNode(empv,1,new TGeoTranslation(0.,-0.3,0.));
     692             :    //bars
     693             :    Double_t tga = (19.8328-12.3742)/39.3;
     694             :    Double_t xmin,xmax;
     695             :    xmin = 9.55*tga+12.3742;
     696             :    xmax = 9.95*tga+12.3742;
     697           1 :    TGeoTrd1 *ib1 = new TGeoTrd1(xmin,xmax,3.29,0.2);
     698           1 :    TGeoVolume *ib1v = new TGeoVolume("TPC_IRB1",ib1,m3);
     699           2 :    empv->AddNode(ib1v,1,new TGeoTranslation("tt1",0.,0.7,-9.9));
     700             :    xmin=19.4*tga+12.3742;
     701             :    xmax=19.9*tga+12.3742;
     702           1 :    TGeoTrd1 *ib2 = new TGeoTrd1(xmin,xmax,3.29,0.25);
     703           1 :    TGeoVolume *ib2v = new TGeoVolume("TPC_TRB2",ib2,m3);
     704           2 :    empv->AddNode(ib2v,1,new TGeoTranslation(0.,0.7,0.));
     705             :    xmin=29.35*tga+12.3742;
     706             :    xmax=29.75*tga+12.3742;
     707           1 :    TGeoTrd1 *ib3 = new TGeoTrd1(xmin,xmax,3.29,0.2); 
     708           1 :    TGeoVolume *ib3v = new TGeoVolume("TPC_IRB3",ib3,m3);    
     709           2 :    empv->AddNode(ib3v,1,new TGeoTranslation(0.,0.7,9.9));
     710             :    //
     711             :    // holes for connectors
     712             :    //
     713           1 :    TGeoBBox *conn = new TGeoBBox(0.4,0.3,4.675); // identical for iroc and oroc
     714           1 :    TGeoVolume *connv = new TGeoVolume("TPC_RCCON",conn,m1);
     715           1 :    TString fileName(gSystem->Getenv("ALICE_ROOT"));
     716           1 :    fileName += "/TPC/conn_iroc.dat";
     717           1 :    ifstream in;
     718           2 :    in.open(fileName.Data(), ios_base::in); // asci file
     719           1 :    TGeoRotation *rrr[86];
     720         174 :    for(Int_t i =0;i<86;i++){
     721             :       Double_t y = 3.99;
     722          86 :       Double_t x,z,ang;
     723         258 :       in>>x>>z>>ang;
     724          86 :       z-=26.5;
     725         258 :       rrr[i]= new TGeoRotation();
     726          86 :       rrr[i]->RotateY(ang);
     727         258 :       ibdv->AddNode(connv,i+1,new TGeoCombiTrans(x,y,z,rrr[i]));
     728          86 :    }
     729           1 :    in.close();
     730             :    // "cap"
     731           2 :    new TGeoTrd1("icap",14.5974,23.3521,1.19,24.825);
     732             :    // "hole"
     733           2 :    new TGeoTrd1("ihole",13.8742,21.3328,1.2,21.15);
     734           2 :    TGeoTranslation *tr1 = new TGeoTranslation("tr1",0.,0.,1.725);  
     735           1 :    tr1->RegisterYourself();
     736           2 :    TGeoCompositeShape *ic = new TGeoCompositeShape("icap-ihole:tr1");
     737           2 :    TGeoVolume *icv = new TGeoVolume("TPC_IRCAP",ic,m3);
     738             :    //
     739             :    // pad plane and wire fixations
     740             :    //
     741           2 :    TGeoTrd1 *pp = new TGeoTrd1(14.5974,23.3521,0.3,24.825); //pad+iso
     742           2 :    TGeoVolume *ppv = new TGeoVolume("TPC_IRPP",pp,m4);
     743           2 :    TGeoPara *f1 = new TGeoPara(.6,.5,24.825,0.,-10.,0.);
     744           2 :    TGeoVolume *f1v = new TGeoVolume("TPC_IRF1",f1,m4);
     745           2 :    TGeoPara *f2 = new TGeoPara(.6,.5,24.825,0.,10.,0.);
     746           2 :    TGeoVolume *f2v = new TGeoVolume("TPC_IRF2",f2,m4);
     747             :    //
     748           2 :    TGeoVolumeAssembly *iroc = new TGeoVolumeAssembly("TPC_IROC");
     749             :    //
     750           1 :    iroc->AddNode(ibdv,1);
     751           3 :    iroc->AddNode(icv,1,new TGeoTranslation(0.,3.1,-1.725));
     752           3 :    iroc->AddNode(ppv,1,new TGeoTranslation(0.,4.59,-1.725));
     753             :    tga =(23.3521-14.5974)/49.65; 
     754             :    Double_t xx = 24.825*tga+14.5974-0.6;
     755           3 :    iroc->AddNode(f1v,1,new TGeoTranslation(-xx,5.39,-1.725));
     756           3 :    iroc->AddNode(f2v,1,new TGeoTranslation(xx,5.39,-1.725));
     757             :    //
     758             :    // OROC
     759             :    //
     760           2 :    TGeoTrd1 *obody = new TGeoTrd1(22.2938,40.5084,4.19,51.65);
     761           2 :    TGeoVolume *obdv = new TGeoVolume("TPC_OROCB",obody,m3);
     762           2 :    TGeoTrd1 *oemp = new TGeoTrd1(20.2938,38.5084,3.89,49.65);
     763           2 :    TGeoVolume *oempv = new TGeoVolume("TPC_OROCE",oemp,m1);
     764           3 :    obdv->AddNode(oempv,1,new TGeoTranslation(0.,-0.3,0.));
     765             :    //horizontal bars
     766             :    tga=(38.5084-20.2938)/99.3;
     767             :    xmin=tga*10.2+20.2938;
     768             :    xmax=tga*10.6+20.2938;
     769           2 :    TGeoTrd1 *ob1 = new TGeoTrd1(xmin,xmax,2.915,0.2);
     770           2 :    TGeoVolume *ob1v = new TGeoVolume("TPC_ORB1",ob1,m3);
     771             :    //
     772             :    xmin=22.55*tga+20.2938;
     773             :    xmax=24.15*tga+20.2938;
     774           2 :    TGeoTrd1 *ob2 = new TGeoTrd1(xmin,xmax,2.915,0.8);
     775           2 :    TGeoVolume *ob2v = new TGeoVolume("TPC_ORB2",ob2,m3);
     776             :    //
     777             :    xmin=36.1*tga+20.2938;
     778             :    xmax=36.5*tga+20.2938;
     779           2 :    TGeoTrd1 *ob3 = new TGeoTrd1(xmin,xmax,2.915,0.2);
     780           2 :    TGeoVolume *ob3v = new TGeoVolume("TPC_ORB3",ob3,m3);
     781             :    //
     782             :    xmin=49.0*tga+20.2938;
     783             :    xmax=50.6*tga+20.2938;   
     784           2 :    TGeoTrd1 *ob4 = new TGeoTrd1(xmin,xmax,2.915,0.8);
     785           2 :    TGeoVolume *ob4v = new TGeoVolume("TPC_ORB4",ob4,m3);
     786             :    //
     787             :    xmin=63.6*tga+20.2938;
     788             :    xmax=64.0*tga+20.2938;
     789           2 :    TGeoTrd1 *ob5 = new TGeoTrd1(xmin,xmax,2.915,0.2);
     790           2 :    TGeoVolume *ob5v = new TGeoVolume("TPC_ORB5",ob5,m3);
     791             :    //
     792             :    xmin=75.5*tga+20.2938;
     793             :    xmax=77.15*tga+20.2938;
     794           2 :    TGeoTrd1 *ob6 = new TGeoTrd1(xmin,xmax,2.915,0.8);
     795           2 :    TGeoVolume *ob6v = new TGeoVolume("TPC_ORB6",ob6,m3);
     796             :    //
     797             :    xmin=88.7*tga+20.2938;
     798             :    xmax=89.1*tga+20.2938;
     799           2 :    TGeoTrd1 *ob7 = new TGeoTrd1(xmin,xmax,2.915,0.2);
     800           2 :    TGeoVolume *ob7v = new TGeoVolume("TPC_ORB7",ob7,m3);
     801             :    //
     802           3 :    oempv->AddNode(ob1v,1,new TGeoTranslation(0.,0.975,-39.25));
     803           3 :    oempv->AddNode(ob2v,1,new TGeoTranslation(0.,0.975,-26.3));
     804           3 :    oempv->AddNode(ob3v,1,new TGeoTranslation(0.,0.975,-13.35));
     805           3 :    oempv->AddNode(ob4v,1,new TGeoTranslation(0.,0.975,0.15));
     806           3 :    oempv->AddNode(ob5v,1,new TGeoTranslation(0.,0.975,14.15));
     807           3 :    oempv->AddNode(ob6v,1,new TGeoTranslation(0.,0.975,26.7));
     808           3 :    oempv->AddNode(ob7v,1,new TGeoTranslation(0.,0.975,39.25));
     809             :    // vertical bars
     810           2 :    TGeoBBox *ob8 = new TGeoBBox(0.8,2.915,5.1); 
     811           2 :    TGeoBBox *ob9 = new TGeoBBox(0.8,2.915,5.975);
     812           2 :    TGeoBBox *ob10 = new TGeoBBox(0.8,2.915,5.775);
     813           2 :    TGeoBBox *ob11 = new TGeoBBox(0.8,2.915,6.25);
     814           2 :    TGeoBBox *ob12 = new TGeoBBox(0.8,2.915,6.5);
     815             :    //
     816           2 :    TGeoVolume *ob8v = new TGeoVolume("TPC_ORB8",ob8,m3);
     817           2 :    TGeoVolume *ob9v = new TGeoVolume("TPC_ORB9",ob9,m3);
     818           2 :    TGeoVolume *ob10v = new TGeoVolume("TPC_ORB10",ob10,m3);
     819           2 :    TGeoVolume *ob11v = new TGeoVolume("TPC_ORB11",ob11,m3);
     820           2 :    TGeoVolume *ob12v = new TGeoVolume("TPC_ORB12",ob12,m3);
     821             :    //
     822           3 :    oempv->AddNode(ob8v,1,new TGeoTranslation(0.,0.975,-44.55));
     823           3 :    oempv->AddNode(ob8v,2,new TGeoTranslation(0.,0.975,44.55));
     824           3 :    oempv->AddNode(ob9v,1,new TGeoTranslation(0.,0.975,-33.075));
     825           3 :    oempv->AddNode(ob9v,2,new TGeoTranslation(0.,0.975,-19.525));
     826           3 :    oempv->AddNode(ob10v,1,new TGeoTranslation(0.,0.975,20.125));
     827           3 :    oempv->AddNode(ob10v,2,new TGeoTranslation(0.,0.975,33.275));
     828           3 :    oempv->AddNode(ob11v,1,new TGeoTranslation(0.,0.975,-6.9));
     829           3 :    oempv->AddNode(ob12v,1,new TGeoTranslation(0.,0.975,7.45));
     830             :    //
     831             :    // holes for connectors
     832             :    //
     833           2 :    fileName = gSystem->Getenv("ALICE_ROOT");
     834           1 :    fileName += "/TPC/conn_oroc.dat";
     835           2 :    in.open(fileName.Data(), ios_base::in); // asci file
     836           1 :    TGeoRotation *rr[78];
     837         158 :    for(Int_t i =0;i<78;i++){
     838             :       Double_t y =3.89;
     839          78 :       Double_t x,z,ang;
     840             :       Double_t x1,z1,x2,z2;
     841         234 :       in>>x>>z>>ang;        
     842         156 :       Double_t xr = 4.7*TMath::Sin(ang*TMath::DegToRad());
     843         156 :       Double_t zr = 4.7*TMath::Cos(ang*TMath::DegToRad());
     844             :       //
     845          78 :       x1=xr+x; x2=-xr+x; z1=zr+z; z2 = -zr+z;      
     846             :       //
     847         234 :       rr[i]= new TGeoRotation();
     848          78 :       rr[i]->RotateY(ang); 
     849          78 :       z1-=54.95;
     850          78 :       z2-=54.95;
     851             :       //
     852         234 :       obdv->AddNode(connv,i+1,new TGeoCombiTrans(x1,y,z1,rr[i]));
     853         234 :       obdv->AddNode(connv,i+79,new TGeoCombiTrans(x2,y,z2,rr[i]));
     854          78 :    }
     855           1 :    in.close();
     856             :    // cap
     857           2 :    new TGeoTrd1("ocap",23.3874,43.5239,1.09,57.1);
     858           2 :    new TGeoTrd1("ohole",22.2938,40.5084,1.09,51.65);
     859           2 :    TGeoTranslation *tr5 = new TGeoTranslation("tr5",0.,0.,-2.15);
     860           1 :    tr5->RegisterYourself();
     861           2 :    TGeoCompositeShape *oc = new TGeoCompositeShape("ocap-ohole:tr5");
     862           2 :    TGeoVolume *ocv = new TGeoVolume("TPC_ORCAP",oc,m3);
     863             :    //
     864             :    // pad plane and wire fixations
     865             :    //
     866           2 :    TGeoTrd1 *opp = new TGeoTrd1(23.3874,43.5239,0.3,57.1);
     867           2 :    TGeoVolume *oppv = new TGeoVolume("TPC_ORPP",opp,m4);
     868             :    //
     869             :    tga=(43.5239-23.3874)/114.2;
     870           2 :    TGeoPara *f3 = new TGeoPara(.7,.6,57.1,0.,-10.,0.);
     871           2 :    TGeoPara *f4 = new TGeoPara(.7,.6,57.1,0.,10.,0.);  
     872             :    xx = 57.1*tga+23.3874-0.7;
     873           2 :    TGeoVolume *f3v = new TGeoVolume("TPC_ORF1",f3,m4);
     874           2 :    TGeoVolume *f4v = new TGeoVolume("TPC_ORF2",f4,m4);
     875             :    //
     876           2 :    TGeoVolumeAssembly *oroc = new TGeoVolumeAssembly("TPC_OROC");
     877             :    //
     878           1 :    oroc->AddNode(obdv,1);
     879           3 :    oroc->AddNode(ocv,1,new TGeoTranslation(0.,3.1,2.15));
     880           3 :    oroc->AddNode(oppv,1,new TGeoTranslation(0.,4.49,2.15));
     881           3 :    oroc->AddNode(f3v,1,new TGeoTranslation(-xx,5.39,2.15));
     882           3 :    oroc->AddNode(f4v,1,new TGeoTranslation(xx,5.39,2.15));
     883             :    // 
     884             :    // now iroc and oroc are placed into a sector...
     885             :    //
     886           2 :    TGeoVolumeAssembly *secta = new TGeoVolumeAssembly("TPC_SECT"); // a-side
     887           2 :    TGeoVolumeAssembly *sectc = new TGeoVolumeAssembly("TPC_SECT"); // c-side
     888           1 :    TGeoRotation rot1("rot1",90.,90.,0.);
     889           1 :    TGeoRotation rot2("rot2");
     890           1 :    rot2.RotateY(10.);
     891           2 :    TGeoRotation *rot = new TGeoRotation("rot");
     892           2 :    *rot=rot1*rot2;
     893             :    //
     894             :    Double_t x0,y0;
     895           1 :    x0=110.2*TMath::Cos(openingAngle);
     896           1 :    y0=110.2*TMath::Sin(openingAngle);
     897           2 :    TGeoCombiTrans *combi1a = new TGeoCombiTrans("combi1",x0,y0,1.09+0.195,rot); //a-side 
     898           2 :    TGeoCombiTrans *combi1c = new TGeoCombiTrans("combi1",x0,y0,1.09+0.222,rot); //c-side
     899           1 :    x0=188.45*TMath::Cos(openingAngle);
     900           1 :    y0=188.45*TMath::Sin(openingAngle);
     901           2 :    TGeoCombiTrans *combi2a = new TGeoCombiTrans("combi2",x0,y0,0.99+0.195,rot); //a-side
     902           2 :    TGeoCombiTrans *combi2c = new TGeoCombiTrans("combi2",x0,y0,0.99+0.222,rot); //c-side
     903             :    //
     904             :    //
     905             :    // A-side
     906             :    //
     907           1 :    secta->AddNode(ch,1);
     908           1 :    secta->AddNode(iroc,1,combi1a);
     909           1 :    secta->AddNode(oroc,1,combi2a);
     910             :    //
     911             :    // C-side
     912             :    //
     913           1 :    sectc->AddNode(ch,1);
     914           1 :    sectc->AddNode(iroc,1,combi1c);
     915           1 :    sectc->AddNode(oroc,1,combi2c);
     916             :    //
     917             :    // now I try to make  wheels...
     918             :    //
     919           2 :    TGeoVolumeAssembly *wheela = new TGeoVolumeAssembly("TPC_ENDCAP");
     920           2 :    TGeoVolumeAssembly *wheelc = new TGeoVolumeAssembly("TPC_ENDCAP");
     921             :    //
     922           1 :    TGeoRotation *rwh[18]; 
     923          38 :    for(Int_t i =0;i<18;i++){
     924          18 :      Double_t phi = (20.*i);
     925          54 :      rwh[i]=new TGeoRotation();
     926          18 :      rwh[i]->RotateZ(phi);
     927          18 :      wheela->AddNode(secta,i+1,rwh[i]);
     928          18 :      wheelc->AddNode(sectc,i+1,rwh[i]); 
     929             :     
     930             :    }
     931             :    // wheels in the drift volume!   
     932             : 
     933           2 :    TGeoCombiTrans *combi3 = new TGeoCombiTrans("combi3",0.,0.,256.6,ref);
     934           1 :    v9->AddNode(wheela,1,combi3);
     935           3 :    v9->AddNode(wheelc,2,new TGeoTranslation(0.,0.,-256.6));
     936             :    //_____________________________________________________________
     937             :    // service support wheel
     938             :    //_____________________________________________________________
     939           2 :   TGeoPgon *sw = new TGeoPgon(0.,20.,1,2);
     940           1 :   sw->DefineSection(0,-4.,80.5,251.75);
     941           1 :   sw->DefineSection(1,4.,80.5,251.75); 
     942           2 :   TGeoVolume *swv = new TGeoVolume("TPC_SWSEG",sw,m3); //Al
     943             :   //
     944             :   thick=1.;
     945           1 :   shift = thick/TMath::Sin(openingAngle);
     946           2 :   TGeoPgon *sh = new TGeoPgon(0.,20.,1,2);
     947           1 :   sh->DefineSection(0,-4.,81.5-shift,250.75-shift);
     948           1 :   sh->DefineSection(1,4.,81.5-shift,250.75-shift);
     949           2 :   TGeoVolume *shv = new TGeoVolume("TPC_SWS1",sh,m1); //Air
     950             :   //
     951           1 :   TGeoMedium *m9 =  gGeoManager->GetMedium("TPC_Si"); 
     952           2 :   TGeoPgon *el = new TGeoPgon(0.,20.,1,2);
     953           1 :   el->DefineSection(0,-1.872,81.5-shift,250.75-shift);
     954           1 :   el->DefineSection(1,1.872,81.5-shift,250.75-shift);
     955           2 :   TGeoVolume *elv = new TGeoVolume("TPC_ELEC",el,m9); //Si 
     956             :   //
     957           1 :   shv->AddNode(elv,1);
     958             :   //
     959             :   //
     960           1 :   ys = shift*TMath::Sin(openingAngle);
     961           1 :   xs = shift*TMath::Cos(openingAngle);
     962           3 :   swv->AddNode(shv,1,new TGeoTranslation(xs,ys,0.));
     963             :   // cover
     964           2 :   TGeoPgon *co = new TGeoPgon(0.,20.,1,2);
     965           1 :   co->DefineSection(0,-0.5,77.,255.25);
     966           1 :   co->DefineSection(1,0.5,77.,255.25);
     967           2 :   TGeoVolume *cov = new TGeoVolume("TPC_SWC1",co,m3);//Al
     968             :   // hole in a cover
     969           2 :   TGeoPgon *coh = new TGeoPgon(0.,20.,1,2);
     970           1 :   shift=4./TMath::Sin(openingAngle);
     971           1 :   coh->DefineSection(0,-0.5,85.-shift,247.25-shift);
     972           1 :   coh->DefineSection(1,0.5,85.-shift,247.25-shift);  
     973             :   //
     974           2 :   TGeoVolume *cohv = new TGeoVolume("TPC_SWC2",coh,m1);
     975             :   //
     976           1 :   ys = shift*TMath::Sin(openingAngle);
     977           1 :   xs = shift*TMath::Cos(openingAngle);  
     978           3 :   cov->AddNode(cohv,1,new TGeoTranslation(xs,ys,0.));
     979             :   //
     980             :   // Sector as an Assembly
     981             :   //
     982           2 :   TGeoVolumeAssembly *swhs = new TGeoVolumeAssembly("TPC_SSWSEC");
     983           1 :   swhs->AddNode(swv,1);
     984           3 :   swhs->AddNode(cov,1,new TGeoTranslation(0.,0.,-4.5));
     985           3 :   swhs->AddNode(cov,2,new TGeoTranslation(0.,0.,4.5));
     986             :   //
     987             :   // SSW as an Assembly of sectors
     988             :   //
     989           1 :   TGeoRotation *rsw[18];
     990           2 :   TGeoVolumeAssembly *swheel = new TGeoVolumeAssembly("TPC_SSWHEEL");
     991          38 :    for(Int_t i =0;i<18;i++){
     992          18 :      Double_t phi = (20.*i);
     993          54 :      rsw[i] = new TGeoRotation();
     994          18 :      rsw[i]->RotateZ(phi);
     995          18 :      swheel->AddNode(swhs,i+1,rsw[i]);   
     996             :    }
     997           3 :    v1->AddNode(swheel,1,new TGeoTranslation(0.,0.,-284.6));
     998           3 :    v1->AddNode(swheel,2,new TGeoTranslation(0.,0.,284.6));
     999             : 
    1000             :    // sensitive strips - strip "0" is always set
    1001             :    // conditional
    1002             :    Int_t totrows;
    1003           3 :    totrows = fTPCParam->GetNRowLow() + fTPCParam->GetNRowUp();
    1004             :    Double_t *upar;
    1005             :    upar=NULL;
    1006           1 :    gGeoManager->Volume("TPC_Strip","PGON",m5->GetId(),upar);
    1007           2 :    upar=new Double_t [10];
    1008           1 :    upar[0]=0.;
    1009           1 :    upar[1]=360.;
    1010           1 :    upar[2]=18.;
    1011           1 :    upar[3]=2.;
    1012             :    //
    1013           1 :    upar[4]=-124.8;
    1014           1 :    upar[7]=124.8;
    1015             : 
    1016           2 :    Double_t rlow=fTPCParam->GetPadRowRadiiLow(0);
    1017             : 
    1018           1 :    upar[5]=rlow;
    1019           1 :    upar[6]=rlow+.01;
    1020           1 :    upar[8]=upar[5];
    1021           1 :    upar[9]=upar[6];
    1022             :    //
    1023           1 :    gGeoManager->Node("TPC_Strip",1,"TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10);
    1024           1 :    gGeoManager->Node("TPC_Strip",totrows+1,
    1025             :                      "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10);
    1026             :    //
    1027             :    // now, strips optionally
    1028             :    //
    1029           1 :    if(fSens){
    1030             :      //lower sectors
    1031           0 :      for(Int_t i=2;i<fTPCParam->GetNRowLow()+1;i++){
    1032           0 :        rlow=fTPCParam->GetPadRowRadiiLow(i-1);
    1033           0 :        upar[5]=rlow;
    1034           0 :        upar[6]=rlow+.01;
    1035           0 :        upar[8]=upar[5];
    1036           0 :        upar[9]=upar[6];
    1037           0 :        gGeoManager->Node("TPC_Strip",i,
    1038             :                          "TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10);
    1039           0 :        gGeoManager->Node("TPC_Strip",totrows+i,
    1040             :                          "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10);       
    1041             :      }
    1042             :      //upper sectors
    1043           0 :      for(Int_t i=1;i<fTPCParam->GetNRowUp()+1;i++){
    1044           0 :        rlow=fTPCParam->GetPadRowRadiiUp(i-1); 
    1045           0 :        upar[5]=rlow;
    1046           0 :        upar[6]=rlow+.01;
    1047           0 :        upar[8]=upar[5];
    1048           0 :        upar[9]=upar[6];
    1049           0 :        gGeoManager->Node("TPC_Strip",i+fTPCParam->GetNRowLow(),
    1050             :                          "TPC_Drift",0.,0.,124.82,0,kTRUE,upar,10); 
    1051           0 :        gGeoManager->Node("TPC_Strip",totrows+i+fTPCParam->GetNRowLow(),
    1052             :                          "TPC_Drift",0.,0.,-124.82,0,kTRUE,upar,10); 
    1053             :      }
    1054           0 :    }//strips
    1055             :   //----------------------------------------------------------
    1056             :   // TPC Support Rods - MAKROLON
    1057             :   //----------------------------------------------------------
    1058           1 :   TGeoMedium *m6=gGeoManager->GetMedium("TPC_Makrolon");
    1059           1 :   TGeoMedium *m7=gGeoManager->GetMedium("TPC_Cu");
    1060           1 :   TGeoMedium *m10 =  gGeoManager->GetMedium("TPC_Alumina");
    1061           1 :   TGeoMedium *m11 =  gGeoManager->GetMedium("TPC_Peek");;
    1062           1 :   TGeoMedium *m13 = gGeoManager->GetMedium("TPC_Brass");
    1063           1 :   TGeoMedium *m14 = gGeoManager->GetMedium("TPC_Alumina1");
    1064             :   // 
    1065             :   // tpc rod is an assembly of 10 long parts and 2 short parts
    1066             :   // connected with alu rings and plagged on both sides.
    1067             :   //
    1068             :   //
    1069             :   // tpc rod long
    1070             :   //
    1071           2 :   TGeoPcon *rod = new TGeoPcon("rod",0.,360.,6);
    1072           1 :  rod->DefineSection(0,-10.43,1.92,2.08);
    1073           1 :  rod->DefineSection(1,-9.75,1.92,2.08);
    1074             : 
    1075           1 :  rod->DefineSection(2,-9.75,1.8,2.2);
    1076           1 :  rod->DefineSection(3,9.75,1.8,2.2);
    1077             : 
    1078           1 :  rod->DefineSection(4,9.75,1.92,2.08);
    1079           1 :  rod->DefineSection(5,10.43,1.92,2.08);
    1080             :  //
    1081           2 :  TGeoVolume *mrodl = new TGeoVolume("TPC_mrodl",rod,m6);
    1082             :  //
    1083             :  // tpc rod short 
    1084             :  //
    1085           2 :  TGeoPcon *rod1 = new TGeoPcon("rod1",0.,360.,6);
    1086           1 :  rod1->DefineSection(0,-8.93,1.92,2.08);
    1087           1 :  rod1->DefineSection(1,-8.25,1.92,2.08);
    1088             : 
    1089           1 :  rod1->DefineSection(2,-8.25,1.8,2.2);
    1090           1 :  rod1->DefineSection(3,8.25,1.8,2.2);
    1091             : 
    1092           1 :  rod1->DefineSection(4,8.25,1.92,2.08);
    1093           1 :  rod1->DefineSection(5,8.93,1.92,2.08);
    1094             :  //
    1095           2 :  TGeoVolume *mrods = new TGeoVolume("TPC_mrods",rod1,m6);
    1096             :  //
    1097             :  // below is for the resistor rod
    1098             :  //
    1099             :  // hole for the brass connectors
    1100             :  //
    1101             : 
    1102           2 :  new TGeoTube("hhole",0.,0.3,0.3);
    1103             :  //
    1104             :  //transformations for holes - initialy they
    1105             :  // are placed at x=0 and negative y
    1106             :  //
    1107           2 :   TGeoRotation *rhole = new TGeoRotation();
    1108           1 :   rhole->RotateX(90.);
    1109           1 :   TGeoCombiTrans *transf[13];
    1110           1 :   Char_t name[30];
    1111          28 :   for(Int_t i=0;i<13;i++){
    1112          13 :     snprintf(name,30,"transf%d",i);
    1113          39 :     transf[i]= new TGeoCombiTrans(name,0.,-2.,-9.+i*1.5,rhole);
    1114          13 :     transf[i]->RegisterYourself();
    1115             :   }
    1116             :   // union expression for holes
    1117           1 :   TString operl("hhole:transf0");
    1118          26 :   for (Int_t i=1;i<13;i++){
    1119          12 :     snprintf(name,30,"+hhole:transf%d",i);
    1120          12 :     operl.Append(name);   
    1121             :   }
    1122             :   //
    1123           1 :  TString opers("hhole:transf1");
    1124          22 :   for (Int_t i=2;i<12;i++){
    1125          10 :     snprintf(name,30,"+hhole:transf%d",i); 
    1126          10 :     opers.Append(name);   
    1127             :   }
    1128             :   //union of holes
    1129           3 :   new TGeoCompositeShape("hlv",operl.Data());
    1130           3 :   new TGeoCompositeShape("hsv",opers.Data());
    1131             :   //
    1132           2 :   TGeoCompositeShape *rodl = new TGeoCompositeShape("rodl","rod-hlv");
    1133           2 :   TGeoCompositeShape *rods = new TGeoCompositeShape("rods","rod1-hsv");
    1134             :  //rods - volumes - makrolon rods with holes
    1135           2 :   TGeoVolume *rodlv = new TGeoVolume("TPC_rodl",rodl,m6);
    1136           2 :   TGeoVolume *rodsv = new TGeoVolume("TPC_rods",rods,m6);
    1137             :   //brass connectors
    1138             :  //connectors
    1139           2 :   TGeoTube *bcon = new TGeoTube(0.,0.3,0.3);//connectors
    1140           2 :   TGeoVolume *bconv = new TGeoVolume("TPC_bcon",bcon,m13);
    1141             :  //
    1142             :  // hooks holding strips
    1143             :  //
    1144           2 :  new TGeoBBox("hk1",0.625,0.015,0.75);
    1145           2 :  new TGeoBBox("hk2",0.625,0.015,0.15);
    1146           2 :  TGeoTranslation *tr21 = new TGeoTranslation("tr21",0.,-0.03,-0.6);
    1147           2 :  TGeoTranslation *tr12 = new TGeoTranslation("tr12",0.,-0.03,0.6);
    1148           1 :  tr21->RegisterYourself();
    1149           1 :  tr12->RegisterYourself();
    1150             :  
    1151           2 :  TGeoCompositeShape *hook = new TGeoCompositeShape("hook","hk1+hk2:tr21+hk2:tr12");
    1152           2 :  TGeoVolume *hookv = new TGeoVolume("TPC_hook",hook,m13);
    1153             :  //
    1154             :  // assembly of the short rod with connectors and hooks
    1155             :  //
    1156             :  //
    1157             :  // short rod
    1158             :  //
    1159           2 :   TGeoVolumeAssembly *spart = new TGeoVolumeAssembly("TPC_spart");
    1160             :   //
    1161           1 :   spart->AddNode( rodsv,1);
    1162          24 :   for(Int_t i=1;i<12;i++){
    1163          11 :   spart->AddNode(bconv,i,transf[i]);
    1164             :   }
    1165          24 :   for(Int_t i =0;i<11;i++){
    1166          33 :     spart->AddNode(hookv,i+1,new TGeoTranslation(0.,-2.315,-7.5+i*1.5));
    1167             :   } 
    1168             :  //
    1169             :  // long rod
    1170             :  //
    1171           2 :   TGeoVolumeAssembly *lpart = new TGeoVolumeAssembly("TPC_lpart");
    1172             :   //
    1173           1 :   lpart->AddNode( rodlv,1);
    1174          28 :   for(Int_t i=0;i<13;i++){
    1175          13 :   lpart->AddNode(bconv,i+12,transf[i]);
    1176             :   }
    1177          28 :   for(Int_t i =0;i<13;i++){
    1178          39 :     lpart->AddNode(hookv,i+12,new TGeoTranslation(0.,-2.315,-9.+i*1.5));
    1179             :   }   
    1180             :   //
    1181             :   // alu ring
    1182             :   //
    1183           2 :   new TGeoTube("ring1",2.1075,2.235,0.53);
    1184           2 :   new TGeoTube("ring2",1.7925,1.89,0.43);
    1185           2 :   new TGeoTube("ring3",1.89,2.1075,0.05);
    1186           2 :   TGeoCompositeShape *ring = new TGeoCompositeShape("ring","ring1+ring2+ring3");
    1187           2 :   TGeoVolume *ringv = new TGeoVolume("TPC_ring",ring,m3);
    1188             :   //
    1189             :   // rod assembly
    1190             :   //
    1191           2 :   TGeoVolumeAssembly *tpcrrod = new TGeoVolumeAssembly("TPC_rrod");//rrod
    1192           2 :   TGeoVolumeAssembly *tpcmrod = new TGeoVolumeAssembly("TPC_mrod");//makrolon rod  
    1193             :   //long pieces
    1194          24 :   for(Int_t i=0;i<11;i++){
    1195          33 :     tpcrrod->AddNode(ringv,i+1,new TGeoTranslation(0.,0.,-105.+i*21));
    1196          33 :     tpcmrod->AddNode(ringv,i+12,new TGeoTranslation(0.,0.,-105.+i*21));
    1197             :   }
    1198          22 :   for(Int_t i=0;i<10;i++){
    1199          30 :     tpcrrod->AddNode(lpart,i+1,new TGeoTranslation(0.,0.,-94.5+i*21));//resistor rod
    1200          30 :     tpcmrod->AddNode(mrodl,i+1,new TGeoTranslation(0.,0.,-94.5+i*21));//makrolon rod     
    1201             :   }
    1202             :   //
    1203             :   // right plug - identical for all rods
    1204             :   //
    1205           2 :   TGeoPcon *tpcrp = new TGeoPcon(0.,360.,6);
    1206             :   //
    1207           1 :   tpcrp->DefineSection(0,123.05,1.89,2.1075);
    1208           1 :   tpcrp->DefineSection(1,123.59,1.89,2.1075);
    1209             :   //
    1210           1 :   tpcrp->DefineSection(2,123.59,1.8,2.2);
    1211           1 :   tpcrp->DefineSection(3,127.,1.8,2.2);
    1212             :   //
    1213           1 :   tpcrp->DefineSection(4,127.,0.,2.2);
    1214           1 :   tpcrp->DefineSection(5,127.5,0.,2.2);
    1215             :   //
    1216           2 :   TGeoVolume *tpcrpv = new TGeoVolume("TPC_RP",tpcrp,m6);
    1217             :   //
    1218             :   // adding short pieces and right plug
    1219             :   //
    1220           3 :   tpcrrod->AddNode(spart,1,new TGeoTranslation(0.,0.,-114.));
    1221           3 :   tpcrrod->AddNode(spart,2,new TGeoTranslation(0.,0.,114.)); 
    1222           3 :   tpcrrod->AddNode(ringv,23,new TGeoTranslation(0.,0.,-123.));
    1223           3 :   tpcrrod->AddNode(ringv,24,new TGeoTranslation(0.,0.,123.));
    1224           1 :   tpcrrod->AddNode(tpcrpv,1);
    1225             :   //
    1226           3 :   tpcmrod->AddNode(mrods,1,new TGeoTranslation(0.,0.,-114.));
    1227           3 :   tpcmrod->AddNode(mrods,2,new TGeoTranslation(0.,0.,114.)); 
    1228           3 :   tpcmrod->AddNode(ringv,25,new TGeoTranslation(0.,0.,-123.));
    1229           3 :   tpcmrod->AddNode(ringv,26,new TGeoTranslation(0.,0.,123.));
    1230           1 :   tpcmrod->AddNode(tpcrpv,2);
    1231             :   //
    1232             :   // from the ringv position to the CM is 3.0 cm!
    1233             :   //----------------------------------------
    1234             :   //
    1235             :   //
    1236             :   //HV rods - makrolon + 0.58cm (diameter) Cu ->check the length
    1237           2 :   TGeoTube *hvr = new TGeoTube(0.,1.465,123.);
    1238           2 :   TGeoTube *hvc = new TGeoTube(0.,0.29,123.);
    1239             :   //
    1240           2 :   TGeoVolume *hvrv = new TGeoVolume("TPC_HV_Rod",hvr,m6);
    1241           2 :   TGeoVolume *hvcv = new TGeoVolume("TPC_HV_Cable",hvc,m7);
    1242           1 :   hvrv->AddNode(hvcv,1);
    1243             :   //
    1244             :   //resistor rod
    1245             :   //
    1246           2 :   TGeoTube *cr = new TGeoTube(0.,0.45,123.);   
    1247           2 :   TGeoTube *cw = new TGeoTube(0.,0.15,123.);  
    1248           2 :   TGeoVolume *crv = new TGeoVolume("TPC_CR",cr,m10);
    1249           2 :   TGeoVolume *cwv = new TGeoVolume("TPC_W",cw,m12);   
    1250             :   //
    1251             :   // ceramic rod with water
    1252             :   //
    1253           1 :   crv->AddNode(cwv,1);
    1254             :   //
    1255             :   //peek rod
    1256             :   //
    1257           2 :   TGeoTube *pr =new TGeoTube(0.2,0.35,123.);  
    1258           2 :   TGeoVolume *prv = new TGeoVolume("TPC_PR",pr,m11); 
    1259             :   //
    1260             :   // copper plates with connectors
    1261             :   //
    1262           2 :   new TGeoTube("tub",0.,1.7,0.025);
    1263             :   //
    1264             :   // half space - points on the plane and a normal vector
    1265             :   //
    1266           1 :   Double_t n[3],p[3];
    1267           2 :   Double_t slope = TMath::Tan(22.*TMath::DegToRad());
    1268             :   Double_t intp = 1.245;
    1269             :   //
    1270           1 :   Double_t b = slope*slope+1.;
    1271           1 :   p[0]=intp*slope/b;
    1272           1 :   p[1]=-intp/b;
    1273           1 :   p[2]=0.;
    1274             :   //
    1275           1 :   n[0]=-p[0];
    1276           1 :   n[1]=-p[1];
    1277           1 :   n[2]=0.;
    1278             :   Double_t norm;
    1279           1 :   norm=TMath::Sqrt(n[0]*n[0]+n[1]*n[1]);
    1280           1 :   n[0] /= norm;
    1281           1 :   n[1] /=norm;
    1282             :   //
    1283           2 :   new TGeoHalfSpace("sp1",p,n);
    1284             :   //
    1285           1 :   slope = -slope; 
    1286             :   //
    1287           1 :   p[0]=intp*slope/b;
    1288           1 :   p[1]=-intp/b;
    1289             :   //
    1290           1 :   n[0]=-p[0];
    1291           1 :   n[1]=-p[1];
    1292           1 :   norm=TMath::Sqrt(n[0]*n[0]+n[1]*n[1]);
    1293           1 :   n[0] /= norm;
    1294           1 :   n[1] /=norm;
    1295             :   //
    1296           2 :   new TGeoHalfSpace("sp2",p,n);
    1297             :   // holes for rods
    1298             :  //holes
    1299           2 :  new TGeoTube("h1",0.,0.5,0.025);
    1300           2 :  new TGeoTube("h2",0.,0.35,0.025);
    1301             :  //translations:
    1302           2 :  TGeoTranslation *ttr11 = new TGeoTranslation("ttr11",-0.866,0.5,0.);
    1303           2 :  TGeoTranslation *ttr22 = new TGeoTranslation("ttr22",0.866,0.5,0.);
    1304           1 :  ttr11->RegisterYourself();
    1305           1 :  ttr22->RegisterYourself();
    1306             :  // elastic connector
    1307           2 :  new TGeoBBox("elcon",0.72,0.005,0.3);
    1308           2 :  TGeoRotation *crr1 = new TGeoRotation();
    1309           1 :  crr1->RotateZ(-22.);
    1310           2 : TGeoCombiTrans *ctr1 = new TGeoCombiTrans("ctr1",-0.36011, -1.09951,-0.325,crr1);
    1311           1 : ctr1->RegisterYourself();
    1312           2 :  TGeoCompositeShape *cs1 = new TGeoCompositeShape("cs1",
    1313             : "(((((tub-h1:ttr11)-h1:ttr22)-sp1)-sp2)-h2)+elcon:ctr1");
    1314             :  //
    1315           2 :  TGeoVolume *csvv = new TGeoVolume("TPC_RR_CU",cs1,m7);
    1316             :  //
    1317             :  // resistor rod assembly 2 ceramic rods, peak rod, Cu plates
    1318             :  // and resistors
    1319             :  //
    1320           2 :  TGeoVolumeAssembly *rrod = new TGeoVolumeAssembly("TPC_RRIN");
    1321             :  // rods
    1322           1 :  rrod->AddNode(crv,1,ttr11);
    1323           1 :  rrod->AddNode(crv,2,ttr22); 
    1324           1 :  rrod->AddNode(prv,1);
    1325             :  //Cu plates
    1326         332 :  for(Int_t i=0;i<165;i++){
    1327         495 :    rrod->AddNode(csvv,i+1,new TGeoTranslation(0.,0.,-122.675+i*1.5));
    1328             :  }
    1329             :  //resistors
    1330           2 :  TGeoTube *res = new TGeoTube(0.,0.15,0.5);
    1331           2 :  TGeoVolume *resv = new TGeoVolume("TPC_RES",res,m14);
    1332           2 :  TGeoVolumeAssembly *ress = new TGeoVolumeAssembly("TPC_RES_CH");
    1333           3 :  ress->AddNode(resv,1,new TGeoTranslation(0.2,0.,0.));
    1334           3 :  ress->AddNode(resv,2,new TGeoTranslation(-0.2,0.,0.));
    1335             :  //
    1336           2 :  TGeoRotation *crr2 = new TGeoRotation();
    1337           1 :  crr2->RotateY(30.);
    1338           2 :  TGeoRotation *crr3 = new TGeoRotation();
    1339           1 :  crr3->RotateY(-30.); 
    1340             :  //
    1341         166 :  for(Int_t i=0;i<164;i+=2){
    1342         246 :    rrod->AddNode(ress,i+1, new TGeoCombiTrans(0.,1.2,-121.925+i*1.5,crr2));
    1343         246 :    rrod->AddNode(ress,i+2, new TGeoCombiTrans(0.,1.2,-121.925+(i+1)*1.5,crr3));
    1344             :  }
    1345             : 
    1346           3 :  tpcrrod->AddNode(rrod,1,new TGeoCombiTrans(0.,0.,0.5,crr1));
    1347             :  //
    1348             :  // rod left head with holders - inner
    1349             :  //
    1350             :  // first element - support for inner holder  TPC_IHS
    1351           1 :  Double_t shift1[3] = {0.0,-0.175,0.0};
    1352             : 
    1353           2 : new TGeoBBox("tpcihs1", 4.7, 0.66, 2.35);               
    1354           2 : new TGeoBBox("tpcihs2", 4.7, 0.485, 1.0, shift1);
    1355           2 : new TGeoBBox("tpcihs3", 1.5, 0.485, 2.35, shift1);
    1356           2 : new TGeoTube("tpcihs4", 0.0, 2.38, 0.1);
    1357             : //
    1358           1 : Double_t pointstrap[16];    
    1359           1 : pointstrap[0]= 0.0;
    1360           1 : pointstrap[1]= 0.0;
    1361           1 : pointstrap[2]= 0.0;
    1362           1 : pointstrap[3]= 1.08;
    1363           1 : pointstrap[4]= 2.3;
    1364           1 : pointstrap[5]= 1.08;
    1365           1 : pointstrap[6]= 3.38;
    1366           1 : pointstrap[7]= 0.0;
    1367           1 : pointstrap[8]= 0.0;
    1368           1 : pointstrap[9]= 0.0;
    1369           1 : pointstrap[10]= 0.0;
    1370           1 : pointstrap[11]= 1.08;
    1371           1 : pointstrap[12]= 2.3;
    1372           1 : pointstrap[13]= 1.08;
    1373           1 : pointstrap[14]= 3.38;
    1374           1 : pointstrap[15]= 0.0;
    1375             : //
    1376           2 : TGeoArb8 *tpcihs5 = new TGeoArb8("tpcihs5", 0.6, pointstrap);
    1377             : //
    1378             : //  half space - cutting "legs"
    1379             : // 
    1380           1 :  p[0]=0.0;
    1381           1 :  p[1]=0.105;
    1382           1 :  p[2]=0.0;
    1383             :  //       
    1384           1 : n[0] = 0.0;
    1385           1 : n[1] = 1.0;
    1386           1 : n[2] = 0.0;
    1387             : 
    1388           2 : new TGeoHalfSpace("cutil1", p, n);
    1389             : 
    1390             : //
    1391             : // transformations
    1392             : //
    1393           2 : TGeoTranslation *trans2 = new TGeoTranslation("trans2", 0.0, 2.84, 2.25);
    1394           1 : trans2->RegisterYourself();
    1395           2 : TGeoTranslation*trans3= new TGeoTranslation("trans3", 0.0, 2.84, -2.25);
    1396           1 : trans3->RegisterYourself();
    1397             : //support - composite volume
    1398             : //
    1399           2 : TGeoCompositeShape *tpcihs6 = new TGeoCompositeShape("tpcihs6", "tpcihs1-(tpcihs2+tpcihs3)-(tpcihs4:trans2)-(tpcihs4:trans3)-cutil1");
    1400             : //
    1401             : // volumes - all makrolon
    1402             : //  
    1403           2 :  TGeoVolume *tpcihss = new TGeoVolume("TPC_IHSS", tpcihs6, m6); //support
    1404           2 :  TGeoVolume *tpcihst = new TGeoVolume("TPC_IHSTR",tpcihs5 , m6); //trapesoid
    1405             :  //now assembly
    1406           2 : TGeoRotation *rot111 = new TGeoRotation(); 
    1407           1 : rot111->RotateY(180.0);
    1408             : //
    1409           2 : TGeoVolumeAssembly *tpcihs = new TGeoVolumeAssembly("TPC_IHS");    // assembly of the support
    1410           1 : tpcihs->AddNode(tpcihss, 1);
    1411           3 : tpcihs->AddNode(tpcihst, 1, new TGeoTranslation(-4.7, 0.66, 0.0));
    1412           3 : tpcihs->AddNode(tpcihst, 2, new TGeoCombiTrans(4.7, 0.66, 0.0, rot111));
    1413             : //
    1414             : // two rod holders (TPC_IRH) assembled with the support
    1415             : //
    1416           2 : new TGeoBBox("tpcirh1", 4.7, 1.33, 0.5);
    1417           1 :  shift1[0]=-3.65;
    1418           1 :  shift1[1]=0.53;
    1419           1 :  shift1[2]=0.;
    1420           2 : new TGeoBBox("tpcirh2", 1.05, 0.8, 0.5, shift1);
    1421           1 :  shift1[0]=3.65;
    1422           1 :  shift1[1]=0.53;
    1423           1 :  shift1[2]=0.;
    1424           2 : new TGeoBBox("tpcirh3", 1.05, 0.8, 0.5, shift1);
    1425           1 :  shift1[0]=0.0;
    1426           1 :  shift1[1]=1.08;
    1427           1 :  shift1[2]=0.;
    1428           2 : new TGeoBBox("tpcirh4", 1.9, 0.25, 0.5, shift1);
    1429           2 : new TGeoTube("tpcirh5", 0, 1.9, 5);
    1430             : //
    1431           2 : TGeoTranslation *trans4 = new TGeoTranslation("trans4", 0, 0.83, 0.0); 
    1432           1 : trans4->RegisterYourself();
    1433             : //
    1434           2 : TGeoCompositeShape *tpcirh6 = new TGeoCompositeShape("tpcirh6", "tpcirh1-tpcirh2-tpcirh3-(tpcirh5:trans4)-tpcirh4");
    1435             : //
    1436             : // now volume
    1437             : //
    1438           2 : TGeoVolume *tpcirh = new TGeoVolume("TPC_IRH", tpcirh6, m6);   
    1439             : //
    1440             : // and all together...
    1441             : //
    1442           3 : TGeoVolume *tpciclamp = new TGeoVolumeAssembly("TPC_ICLP");
    1443           1 : tpciclamp->AddNode(tpcihs, 1);
    1444           3 : tpciclamp->AddNode(tpcirh, 1, new TGeoTranslation(0, 1.99, 1.1));
    1445           3 : tpciclamp->AddNode(tpcirh, 2, new TGeoTranslation(0, 1.99, -1.1));
    1446             : //
    1447             : // and now left inner "head"
    1448             : //
    1449           2 : TGeoPcon *inplug = new TGeoPcon("inplug", 0.0, 360.0, 14); 
    1450             : 
    1451           1 : inplug->DefineSection(0, 0.3, 0.0, 2.2);
    1452           1 : inplug->DefineSection(1, 0.6, 0.0, 2.2);
    1453             : 
    1454           1 : inplug->DefineSection(2, 0.6, 0.0, 1.75);
    1455           1 : inplug->DefineSection(3, 0.7, 0.0, 1.75);
    1456             : 
    1457           1 : inplug->DefineSection(4, 0.7, 1.55, 1.75);
    1458           1 : inplug->DefineSection(5, 1.6, 1.55, 1.75);
    1459             : 
    1460           1 : inplug->DefineSection(6, 1.6, 1.55, 2.2);
    1461           1 : inplug->DefineSection(7, 1.875, 1.55, 2.2);
    1462             : 
    1463           1 : inplug->DefineSection(8, 1.875, 1.55, 2.2);
    1464           1 : inplug->DefineSection(9, 2.47, 1.75, 2.2);
    1465             : 
    1466           1 : inplug->DefineSection(10, 2.47, 1.75, 2.08);
    1467           1 : inplug->DefineSection(11, 2.57, 1.8, 2.08);
    1468             : 
    1469           1 : inplug->DefineSection(12, 2.57, 1.92, 2.08);
    1470           1 : inplug->DefineSection(13, 2.95, 1.92, 2.08);
    1471             : //
    1472           1 :  shift1[0]=0.0;
    1473           1 :  shift1[1]=-2.09;
    1474           1 :  shift1[2]=1.075;
    1475             :  //
    1476           2 : new TGeoBBox("pcuti", 1.5, 0.11, 1.075, shift1);
    1477             : //
    1478           2 : TGeoCompositeShape *inplleft = new TGeoCompositeShape("inplleft", "inplug-pcuti");
    1479           2 : TGeoVolume *tpcinlplug = new TGeoVolume("TPC_INPLL", inplleft, m6);   
    1480             : //
    1481             : //  holder + plugs
    1482             : //
    1483           3 :  TGeoVolume *tpcihpl = new TGeoVolumeAssembly("TPC_IHPL"); //holder+2 plugs (reflected)
    1484           1 :  tpcihpl->AddNode(tpcinlplug, 1);
    1485           1 :  tpcihpl->AddNode(tpcinlplug, 2,ref);
    1486           3 :  tpcihpl->AddNode(tpciclamp,1,new TGeoTranslation(0.0, -2.765, 0.0)); 
    1487             :  //
    1488             :  // outer holders and clamps
    1489             :  //
    1490             : 
    1491             :  // outer membrane holder (between rods)  
    1492           1 : pointstrap[0]= 0.0;
    1493           1 : pointstrap[1]= 0.0;
    1494           1 : pointstrap[2]= 0.0;
    1495           1 : pointstrap[3]= 2.8;
    1496           1 : pointstrap[4]= 3.1;
    1497           2 : pointstrap[5]= 2.8-3.1*TMath::Tan(15.*TMath::DegToRad());
    1498           1 : pointstrap[6]= 3.1;
    1499           1 : pointstrap[7]= 0.0;
    1500           1 : pointstrap[8]= 0.0;
    1501           1 : pointstrap[9]= 0.0;
    1502           1 : pointstrap[10]= 0.0;
    1503           1 : pointstrap[11]= 2.8;
    1504           1 : pointstrap[12]= 3.1;
    1505           2 : pointstrap[13]= 2.8-3.1*TMath::Tan(15.*TMath::DegToRad());
    1506           1 : pointstrap[14]= 3.1;
    1507           1 : pointstrap[15]= 0.0;
    1508             : //
    1509           2 : TGeoArb8 *tpcomh1 = new TGeoArb8("tpcomh1", 1.05, pointstrap);   
    1510           2 : TGeoBBox *tpcomh2 = new TGeoBBox("tpcomh2", 0.8, 1.4, 6);
    1511             : //
    1512           2 : TGeoVolume *tpcomh1v = new TGeoVolume("TPC_OMH1", tpcomh1, m7);    
    1513           2 : TGeoVolume *tpcomh2v = new TGeoVolume("TPC_OMH2", tpcomh2, m7);
    1514             : //
    1515           3 : TGeoVolume *tpcomh3v = new TGeoVolumeAssembly("TPC_OMH3");    // assembly1
    1516           3 : tpcomh3v->AddNode(tpcomh1v, 1, new TGeoTranslation(0.8, -1.4, 4.95));
    1517           3 :  tpcomh3v->AddNode(tpcomh1v, 2, new TGeoTranslation(0.8, -1.4, -4.95));
    1518           1 : tpcomh3v->AddNode(tpcomh2v, 1);
    1519             : //
    1520           1 : shift1[0] = 0.9;
    1521           1 : shift1[1] = -1.85;
    1522           1 : shift1[2] = 0.0;
    1523             : //
    1524           2 : new TGeoBBox("tpcomh3", 1.65, 1.15, 3.4);
    1525           2 : TGeoBBox *tpcomh4 = new TGeoBBox("tpcomh4", 0.75, 0.7, 3.4, shift1);
    1526             : //
    1527             : // halfspace 1
    1528             : //
    1529           1 : p[0] = 0.0;
    1530           1 : p[1] = -1.05;   
    1531           1 : p[2] = -3.4;
    1532             : //
    1533           1 : n[0] = 0.0;
    1534           2 : n[1] = -1.0*TMath::Tan(30.*TMath::DegToRad());
    1535           1 : n[2] = 1.0;
    1536             : //
    1537           2 : new TGeoHalfSpace("cutomh1", p, n); 
    1538             : //
    1539             : // halfspace 2
    1540             : //
    1541           1 : p[0] = 0.0;
    1542           1 : p[1] = -1.05;   
    1543           1 : p[2] = 3.4;
    1544             : //
    1545           1 : n[0] = 0.0;
    1546           2 : n[1] = -1.0*TMath::Tan(30.*TMath::DegToRad());
    1547           1 : n[2] = -1.0;
    1548             : //
    1549           2 : new TGeoHalfSpace("cutomh2", p, n);
    1550             : //
    1551             : // halfspace 3
    1552             : //
    1553           1 : p[0] = -1.65;
    1554           1 : p[1] = 0.0;     
    1555           1 : p[2] = -0.9;
    1556             : //
    1557           2 : n[0] = 1.0*TMath::Tan(75.*TMath::DegToRad());
    1558           1 : n[1] = 0.0;
    1559           1 : n[2] = 1.0;
    1560             : //
    1561           2 : new TGeoHalfSpace("cutomh3", p, n);   
    1562             : //
    1563             : // halfspace 4
    1564             : //
    1565           1 : p[0] = -1.65;
    1566           1 : p[1] = 0.0;      
    1567           1 : p[2] = 0.9;
    1568             : //
    1569           2 : n[0] = 1.0*TMath::Tan(75*TMath::DegToRad());
    1570           1 : n[1] = 0.0;
    1571           1 : n[2] = -1.0;
    1572             : //
    1573           2 : new TGeoHalfSpace("cutomh4", p, n); 
    1574             : //
    1575             : // halsfspace 5
    1576             : //
    1577           1 : p[0] = 1.65;
    1578           1 : p[1] = -1.05;      
    1579           1 : p[2] = 0.0;  
    1580             : //
    1581           1 : n[0] = -1.0;
    1582           2 : n[1] = -1.0*TMath::Tan(20.*TMath::DegToRad());
    1583           1 : n[2] = 0.0;
    1584             : //
    1585           2 : new TGeoHalfSpace("cutomh5", p, n); 
    1586             : //  
    1587           2 : TGeoCompositeShape *tpcomh5 = new TGeoCompositeShape("tpcomh5", "tpcomh3-cutomh1-cutomh2-cutomh3-cutomh4-cutomh5"); 
    1588             : //
    1589           2 :  TGeoVolume *tpcomh5v = new TGeoVolume("TPC_OMH5",tpcomh5,m6);
    1590           2 :  TGeoVolume *tpcomh4v = new TGeoVolume("TPC_OMH6",tpcomh4,m6);
    1591             :  //
    1592           2 :  TGeoVolumeAssembly *tpcomh7v = new TGeoVolumeAssembly("TPC_OMH7");
    1593           1 :  tpcomh7v->AddNode(tpcomh5v,1);
    1594           1 :  tpcomh7v->AddNode(tpcomh4v,1);
    1595             :  //
    1596             :  // full membrane holder - tpcomh3v + tpcomh7v
    1597             :  //
    1598           2 :  TGeoVolumeAssembly *tpcomh = new TGeoVolumeAssembly("TPC_OMH");
    1599           3 :  tpcomh->AddNode(tpcomh3v,1,new TGeoTranslation(1.5,0.,0.));
    1600           3 :  tpcomh->AddNode(tpcomh3v,2,new TGeoCombiTrans(-1.5,0.,0.,rot111));
    1601           3 :  tpcomh->AddNode(tpcomh7v,1,new TGeoTranslation(0.65+1.5, 2.55, 0.0));
    1602           3 :  tpcomh->AddNode(tpcomh7v,2,new TGeoCombiTrans(-0.65-1.5, 2.55, 0.0,rot111)); 
    1603             :  //
    1604             :  //  outer rod holder support
    1605             :  //
    1606           2 : new TGeoBBox("tpcohs1", 3.8, 0.675, 2.35); 
    1607             : //
    1608           1 : shift1[0] = 0.0;
    1609           1 : shift1[1] = 0.175;
    1610           1 : shift1[2] = 0.0;
    1611             : //
    1612           2 : new TGeoBBox("tpcohs2", 1.5, 0.5, 2.35, shift1);
    1613           2 : new TGeoBBox("tpcohs3", 3.8, 0.5, 0.85, shift1);
    1614             : //
    1615           1 : shift1[0] = 0.0;
    1616           1 : shift1[1] = -1.175;
    1617           1 : shift1[2] = 0.0;
    1618             : //
    1619           2 : TGeoBBox *tpcohs4 = new TGeoBBox("tpsohs4", 3.1, 0.5, 0.7, shift1);
    1620             : //
    1621           2 : TGeoVolume *tpcohs4v = new TGeoVolume("TPC_OHS4", tpcohs4, m6);
    1622             : //
    1623           1 : p[0] = 0.0;
    1624           1 : p[1] = -0.186;   
    1625           1 : p[2] = 0.0;
    1626             : //
    1627           1 : n[0] = 0.0;
    1628           1 : n[1] = -1.0;
    1629           1 : n[2] = 0.0;
    1630             : //
    1631           2 : new TGeoHalfSpace("cutohs1", p, n);
    1632             : //
    1633           2 : TGeoCompositeShape *tpcohs5 = new TGeoCompositeShape("tpcohs5", "tpcohs1-tpcohs2-tpcohs3-cutohs1"); 
    1634           2 : TGeoVolume *tpcohs5v = new TGeoVolume("TPC_OHS5", tpcohs5, m6); 
    1635             : //
    1636           2 : TGeoVolumeAssembly *tpcohs = new TGeoVolumeAssembly("TPC_OHS");    
    1637           1 : tpcohs->AddNode(tpcohs5v, 1);
    1638           1 : tpcohs->AddNode(tpcohs4v, 1); 
    1639             : //
    1640             : // outer rod holder itself
    1641             : //
    1642           1 : shift1[0] = 0.0;
    1643           1 : shift1[1] = 1.325;
    1644           1 : shift1[2] = 0.0;
    1645           2 :  new TGeoBBox("tpcorh1", 3.1, 1.825, 0.55); //from this box we cut pieces...
    1646             :  //
    1647           1 : shift1[0] = -3.1;       
    1648           1 : shift1[1] = -0.5;       
    1649           1 : shift1[2] = 0.0;
    1650             : //
    1651           2 : new TGeoBBox("tpcorh2", 0.5, 2.75, 1.1, shift1);
    1652             : //
    1653           1 : shift1[0] = 3.1;        
    1654           1 : shift1[1] = -0.5;       
    1655           1 : shift1[2] = 0.0;
    1656             : //
    1657           2 : new TGeoBBox("tpcorh3", 0.5, 2.75, 1.1, shift1);
    1658             : //
    1659           1 : shift1[0] = 0.0;
    1660           1 : shift1[1] = -0.5;       
    1661           1 : shift1[2] = -0.95;
    1662             : //
    1663           2 : new TGeoBBox("tpcorh4", 3.9, 2.75, 0.5, shift1);
    1664             : //
    1665           1 : shift1[0] = 0.0;
    1666           1 : shift1[1] = -0.5;
    1667           1 : shift1[2] = 0.0;
    1668             : //
    1669           2 : new TGeoBBox("tpcorh5", 1.95, 0.5, 1.1, shift1);
    1670             : //
    1671           1 : shift1[0] = 0.0;
    1672           1 : shift1[1] = -0.5;
    1673           1 : shift1[2] = 0.55;
    1674             : //
    1675           2 : new TGeoBBox("tpcorh6", 2.4, 0.5, 0.6, shift1);
    1676             : //
    1677           2 : new TGeoTube("tpcorh7", 0, 1.95, 0.85);
    1678           2 : new TGeoTube("tpcorh8", 0, 2.4, 0.6);
    1679             : //
    1680           2 : TGeoTranslation *trans33 = new TGeoTranslation("trans33", 0.0, 0.0, 0.55); 
    1681           1 : trans33->RegisterYourself();
    1682             : //
    1683           2 : TGeoCompositeShape *tpcorh9 = new TGeoCompositeShape("tpcorh9", "tpcorh1-tpcorh2-tpcorh3-tpcorh4-tpcorh5-tpcorh6-(tpcorh8:trans33)-tpcorh7");
    1684             : //
    1685           2 :  TGeoVolume *tpcorh9v = new TGeoVolume("TPC_ORH",tpcorh9,m6); //outer rod holder 
    1686             :  //
    1687             :  // now 2 holders together
    1688             :  //
    1689           2 :  TGeoVolumeAssembly *tpcorh = new TGeoVolumeAssembly("TPC_ORH2");
    1690             :  //
    1691           3 :  tpcorh->AddNode(tpcorh9v,1,new TGeoTranslation(0.0, 0.0, 1.25));
    1692           3 :  tpcorh->AddNode(tpcorh9v,2,new TGeoCombiTrans(0.0, 0.0, -1.25,rot111));
    1693             : //
    1694             : // outer rod plug left
    1695             : //
    1696           2 : TGeoPcon *outplug = new TGeoPcon("outplug", 0.0, 360.0, 14); 
    1697             : 
    1698           1 : outplug->DefineSection(0, 0.5, 0.0, 2.2);
    1699           1 : outplug->DefineSection(1, 0.7, 0.0, 2.2);
    1700             : 
    1701           1 : outplug->DefineSection(2, 0.7, 1.55, 2.2);
    1702           1 : outplug->DefineSection(3, 0.8, 1.55, 2.2);
    1703             : 
    1704           1 : outplug->DefineSection(4, 0.8, 1.55, 1.75);
    1705           1 : outplug->DefineSection(5, 1.2, 1.55, 1.75);
    1706             : 
    1707           1 : outplug->DefineSection(6, 1.2, 1.55, 2.2);
    1708           1 : outplug->DefineSection(7, 1.875, 1.55, 2.2);
    1709             : 
    1710           1 : outplug->DefineSection(8, 1.875, 1.55, 2.2);
    1711           1 : outplug->DefineSection(9, 2.47, 1.75, 2.2);
    1712             : 
    1713           1 : outplug->DefineSection(10, 2.47, 1.75, 2.08);
    1714           1 : outplug->DefineSection(11, 2.57, 1.8, 2.08);
    1715             : 
    1716           1 : outplug->DefineSection(12, 2.57, 1.92, 2.08);
    1717           1 : outplug->DefineSection(13, 2.95, 1.92, 2.08);
    1718             : //
    1719           1 : shift1[0] = 0.0;
    1720           1 : shift1[1] = 2.09;
    1721           1 : shift1[2] = 1.01;
    1722             : 
    1723           2 : new TGeoBBox("cutout", 2.5, 0.11, 1.01, shift1);
    1724             : //
    1725             : 
    1726           2 : TGeoCompositeShape *outplleft = new TGeoCompositeShape("outplleft", "outplug-cutout");    
    1727           2 : TGeoVolume *outplleftv = new TGeoVolume("TPC_OPLL", outplleft, m6); 
    1728             : //
    1729             : //  support + holder + plug
    1730             : //
    1731             : 
    1732             :  
    1733           2 :  TGeoVolumeAssembly *tpcohpl = new TGeoVolumeAssembly("TPC_OHPL"); 
    1734             :  //
    1735           1 :  tpcohpl->AddNode(outplleftv,1); //plug
    1736           1 :  tpcohpl->AddNode(outplleftv,2,ref); //plug reflected
    1737           1 :  tpcohpl->AddNode(tpcorh,1); //rod holder
    1738           3 :  tpcohpl->AddNode(tpcohs,1,new TGeoTranslation(0.0, 3.925, 0)); // support
    1739             :  //
    1740             : 
    1741             :  //
    1742             :  // main membrane holder
    1743             :  //           
    1744           1 : pointstrap[0]= 0.0;
    1745           1 : pointstrap[1]= 0.0;
    1746           1 : pointstrap[2]= 0.0;
    1747           1 : pointstrap[3]= 2.8;
    1748           1 : pointstrap[4]= 3.1;
    1749           1 : pointstrap[5]= 1.96;
    1750           1 : pointstrap[6]= 3.1;
    1751           1 : pointstrap[7]= 0.0;
    1752           1 : pointstrap[8]= 0.0;
    1753           1 : pointstrap[9]= 0.0;
    1754           1 : pointstrap[10]= 0.0;
    1755           1 : pointstrap[11]= 2.8;
    1756           1 : pointstrap[12]= 3.1;
    1757           1 : pointstrap[13]= 1.96;
    1758           1 : pointstrap[14]= 3.1;
    1759           1 : pointstrap[15]= 0.0; 
    1760             : //
    1761           2 : TGeoArb8 *tpcmmh1 = new TGeoArb8("tpcmmh1", 1.75, pointstrap);
    1762           2 : TGeoBBox *tpcmmh2 = new TGeoBBox("tpcmmh2", 0.8, 1.4, 12.5); 
    1763             : //
    1764           2 : TGeoVolume *tpcmmh1v = new TGeoVolume("TPC_MMH1", tpcmmh1, m6);   
    1765           2 : TGeoVolume *tpcmmh2v = new TGeoVolume("TPC_MMH2", tpcmmh2, m6);
    1766             : //
    1767           2 :  TGeoVolumeAssembly *tpcmmhs = new TGeoVolumeAssembly("TPC_MMHS");
    1768           3 :  tpcmmhs->AddNode(tpcmmh1v,1,new TGeoTranslation(0.8, -1.4, 10.75));
    1769           3 :  tpcmmhs->AddNode(tpcmmh1v,2,new TGeoTranslation(0.8, -1.4, -10.75));
    1770           1 :  tpcmmhs->AddNode(tpcmmh2v,1);
    1771             :  //
    1772             :  // main membrahe holder clamp
    1773             :  //
    1774           1 : shift1[0] = -0.75;
    1775           1 : shift1[1] = -1.15;
    1776           1 : shift1[2] = 0.0;
    1777             : //
    1778           2 : new TGeoBBox("tpcmmhc1", 1.65, 1.85, 8.9); 
    1779           2 : new TGeoBBox("tpcmmhc2", 0.9, 0.7, 8.9, shift1);
    1780             : //
    1781             : // half spaces  - cuts
    1782             : //
    1783           1 : p[0] = -1.65;
    1784           1 : p[1] = 0.0;   
    1785           1 : p[2] = -0.9;
    1786             : //
    1787           1 : n[0] = 8.0;
    1788           1 : n[1] = 0.0;
    1789           2 : n[2] = 8.0*TMath::Tan(13.*TMath::DegToRad());
    1790             : //
    1791           2 : new TGeoHalfSpace("cutmmh1", p, n);
    1792             : //
    1793           1 : p[0] = -1.65;
    1794           1 : p[1] = 0.0;   
    1795           1 : p[2] = 0.9;
    1796             : //
    1797           1 : n[0] = 8.0;
    1798           1 : n[1] = 0.0;
    1799           2 : n[2] = -8.0*TMath::Tan(13.*TMath::DegToRad());
    1800             : //
    1801           2 : new TGeoHalfSpace("cutmmh2", p, n);
    1802             : //
    1803           1 : p[0] = 0.0;
    1804           1 : p[1] = 1.85;   
    1805           1 : p[2] = -2.8;
    1806             : //
    1807           1 : n[0] = 0.0;
    1808           1 : n[1] = -6.1;
    1809           2 : n[2] = 6.1*TMath::Tan(20.*TMath::DegToRad());
    1810             : //
    1811           2 : new TGeoHalfSpace("cutmmh3", p, n);
    1812             : //
    1813           1 : p[0] = 0.0;
    1814           1 : p[1] = 1.85;      
    1815           1 : p[2] = 2.8;
    1816             : //
    1817           1 : n[0] = 0.0;
    1818           1 : n[1] = -6.1;
    1819           2 : n[2] = -6.1*TMath::Tan(20*TMath::DegToRad());
    1820             : //
    1821           2 : new TGeoHalfSpace("cutmmh4", p, n);
    1822             : //
    1823           1 : p[0] = 0.75;
    1824           1 : p[1] = 0.0; 
    1825           1 : p[2] = -8.9;
    1826             : //
    1827           2 : n[0] = 2.4*TMath::Tan(30*TMath::DegToRad());
    1828           1 : n[1] = 0.0;
    1829           1 : n[2] = 2.4;
    1830             : //
    1831           2 :  new TGeoHalfSpace("cutmmh5", p, n);
    1832             : //
    1833           1 : p[0] = 0.75;
    1834           1 : p[1] = 0.0;
    1835           1 : p[2] = 8.9;
    1836             : //
    1837           2 : n[0] = 2.4*TMath::Tan(30*TMath::DegToRad());
    1838           1 : n[1] = 0.0;
    1839           1 : n[2] = -2.4;
    1840             : //
    1841           2 : new TGeoHalfSpace("cutmmh6", p, n);
    1842             : 
    1843           2 : TGeoCompositeShape *tpcmmhc = new TGeoCompositeShape("TPC_MMHC", "tpcmmhc1-tpcmmhc2-cutmmh1-cutmmh2-cutmmh3-cutmmh4-cutmmh5-cutmmh6"); 
    1844             : 
    1845           2 :  TGeoVolume *tpcmmhcv = new TGeoVolume("TPC_MMHC",tpcmmhc,m6);
    1846             :  //
    1847           3 : TGeoVolume *tpcmmh = new TGeoVolumeAssembly("TPC_MMH");
    1848             : //
    1849           3 :  tpcmmh->AddNode(tpcmmhcv,1,new TGeoTranslation(0.65+1.5, 1.85, 0.0));
    1850           3 :  tpcmmh->AddNode(tpcmmhcv,2,new TGeoCombiTrans(-0.65-1.5, 1.85, 0.0,rot111));
    1851           3 :  tpcmmh->AddNode(tpcmmhs,1,new TGeoTranslation(1.5, 0.0, 0.0));
    1852           3 :  tpcmmh->AddNode(tpcmmhs,2,new TGeoCombiTrans(-1.5, 0.0, 0.0,rot111));
    1853             :  //
    1854             :  
    1855             :  //
    1856             : 
    1857             : //--------------------------------------------
    1858             :  //
    1859             :  // guard ring resistor chain
    1860             :  //
    1861             : 
    1862           2 :  TGeoTube *gres1 = new TGeoTube(0.,0.375,125.);// inside ifc
    1863             :  //
    1864           2 :  TGeoVolume *vgres1 = new TGeoVolume("TPC_GRES1",gres1,m14);
    1865             : 
    1866             :  //
    1867             :  Double_t xrc,yrc;
    1868             :  //
    1869           2 :  xrc=79.3*TMath::Cos(350.*TMath::DegToRad());
    1870           2 :  yrc=79.3*TMath::Sin(350.*TMath::DegToRad());
    1871             :  //
    1872           3 :  v9->AddNode(vgres1,1,new TGeoTranslation(xrc,yrc,126.9));
    1873           3 :  v9->AddNode(vgres1,2,new TGeoTranslation(xrc,yrc,-126.9));
    1874             :  //
    1875           2 :  xrc=79.3*TMath::Cos(190.*TMath::DegToRad());
    1876           2 :  yrc=79.3*TMath::Sin(190.*TMath::DegToRad()); 
    1877             :  //
    1878           3 :  v9->AddNode(vgres1,3,new TGeoTranslation(xrc,yrc,126.9));
    1879           3 :  v9->AddNode(vgres1,4,new TGeoTranslation(xrc,yrc,-126.9));
    1880             :  //------------------------------------------------------------------
    1881           1 :  TGeoRotation refl("refl",90.,0.,90.,90.,180.,0.);
    1882           1 :  TGeoRotation rotrod("rotrod");
    1883             :  //
    1884             :  TGeoRotation *rotpos[2]; 
    1885             :  //
    1886             :  TGeoRotation *rotrod1[2]; 
    1887             :  //
    1888             :  // clamps holding rods
    1889             :  //
    1890           2 :   TGeoBBox *clampi1 = new TGeoBBox("clampi1",0.2,3.1,0.8);
    1891           2 :   TGeoVolume *clampi1v = new TGeoVolume("TPC_clampi1v",clampi1,m6);
    1892             :  //
    1893           1 :  pointstrap[0]=0.49;
    1894           1 :  pointstrap[1]=0.375;
    1895             :  //
    1896           1 :  pointstrap[2]=0.49;
    1897           1 :  pointstrap[3]=-0.375;
    1898             :  //
    1899           1 :  pointstrap[4]=-0.49;
    1900           1 :  pointstrap[5]=-0.375;
    1901             :  //
    1902           1 :  pointstrap[6]=-0.49;
    1903           1 :  pointstrap[7]=1.225;
    1904             :  //
    1905           1 :  pointstrap[8]=0.49;
    1906           1 :  pointstrap[9]=0.375;
    1907             :  //
    1908           1 :  pointstrap[10]=0.49;
    1909           1 :  pointstrap[11]=-0.375;
    1910             :  //
    1911           1 :  pointstrap[12]=-0.49;
    1912           1 :  pointstrap[13]=-0.375;
    1913             :  //
    1914           1 :  pointstrap[14]=-0.49;
    1915           1 :  pointstrap[15]=1.225;
    1916             :  //
    1917           2 :  TGeoArb8 *clitrap = new TGeoArb8("clitrap",0.25,pointstrap);
    1918           2 :  TGeoVolume *clitrapv = new TGeoVolume("TPC_clitrapv",clitrap,m6);  
    1919             :  //
    1920           2 :  TGeoRotation *clamprot = new TGeoRotation();
    1921           1 :  clamprot->RotateX(180.);
    1922             :  //
    1923           2 :  new TGeoBBox("clibox",1.125,3.1,.1);
    1924           2 :  new TGeoTube("clitub",0.,2.2,0.1);
    1925             :  //
    1926             :  // copmisite shape for the clamp holder
    1927             :  //
    1928           2 :  TGeoTranslation *clitr1 = new TGeoTranslation("clitr1",1.125,0.,0.);
    1929           1 :  clitr1->RegisterYourself();
    1930           2 :  TGeoCompositeShape *clihold = new TGeoCompositeShape("clihold","clibox-clitub:clitr1"); 
    1931           2 :  TGeoVolume *cliholdv = new TGeoVolume("TPC_cliholdv",clihold,m6);
    1932             :  //
    1933             :  // now assembly the whole inner clamp
    1934             :  //
    1935           3 :  TGeoVolume *iclamp = new TGeoVolumeAssembly("TPC_iclamp");
    1936             :  //
    1937           1 :  iclamp->AddNode(clampi1v,1); //main box
    1938           3 :  iclamp->AddNode(clitrapv,1,new TGeoTranslation(0.69,-2.725,0.35)); //trapezoids
    1939           3 :  iclamp->AddNode(clitrapv,2,new TGeoTranslation(0.69,-2.725,-0.35));
    1940           3 :  iclamp->AddNode(clitrapv,3,new TGeoCombiTrans(0.69,2.725,0.35,clamprot));
    1941           3 :  iclamp->AddNode(clitrapv,4,new TGeoCombiTrans(0.69,2.725,-0.35,clamprot));
    1942           3 :  iclamp->AddNode(cliholdv,1,new TGeoTranslation(1.325,0.,0.)); //holder
    1943             :  //
    1944             :  //  outer clamps
    1945             :  //
    1946           2 :   TGeoBBox *clampo1 = new TGeoBBox("clampo1",0.25,3.1,1.);
    1947           2 :   TGeoBBox *clampo2 = new TGeoBBox("clampo2",0.4,0.85,1.);
    1948             :   //
    1949           2 :   TGeoVolume *clampo1v = new TGeoVolume("TPC_clampo1v",clampo1,m6);
    1950           2 :   TGeoVolume *clampo2v = new TGeoVolume("TPC_clampo2v",clampo2,m6);
    1951             :   //
    1952           2 :   TGeoVolumeAssembly *oclamp = new TGeoVolumeAssembly("TPC_oclamp");
    1953             :   //
    1954           1 :   oclamp->AddNode(clampo1v,1);
    1955             :  //
    1956           3 :  oclamp->AddNode(clampo2v,1,new TGeoTranslation(0.65,-2.25,0));
    1957           3 :  oclamp->AddNode(clampo2v,2,new TGeoTranslation(0.65,2.25,0));
    1958             : 
    1959             :  //
    1960           1 :  pointstrap[0]=0.375; 
    1961           1 :  pointstrap[1]=0.75;
    1962           1 :  pointstrap[2]=0.375;
    1963           1 :  pointstrap[3]=-0.35;
    1964           1 :  pointstrap[5]=-0.375;
    1965           1 :  pointstrap[4]=-0.35;
    1966           1 :  pointstrap[6]=-0.375; 
    1967           1 :  pointstrap[7]=0.35;
    1968             :  //
    1969           1 :  pointstrap[8]=0.375; 
    1970           1 :  pointstrap[9]=0.75;
    1971           1 :  pointstrap[10]=0.375;
    1972           1 :  pointstrap[11]=-0.35;
    1973           1 :  pointstrap[12]=-0.375;
    1974           1 :  pointstrap[13]=-0.35;
    1975           1 :  pointstrap[14]=-0.375; 
    1976           1 :  pointstrap[15]=0.35;
    1977             :  //
    1978           2 :  TGeoArb8 *clotrap = new TGeoArb8("clotrap",0.25,pointstrap);
    1979           2 :  TGeoVolume *clotrapv = new TGeoVolume("TPC_clotrapv",clotrap,m6);
    1980             :  //
    1981           3 :  oclamp->AddNode(clotrapv,1,new TGeoTranslation(-0.625,-2.75,0.35)); 
    1982           3 :  oclamp->AddNode(clotrapv,2,new TGeoTranslation(-0.625,-2.75,-0.35));
    1983           3 :  oclamp->AddNode(clotrapv,3,new TGeoCombiTrans(-0.625,2.75,0.35,clamprot)); 
    1984           3 :  oclamp->AddNode(clotrapv,4,new TGeoCombiTrans(-0.625,2.75,-0.35,clamprot));  
    1985             :  //
    1986           2 :  TGeoBBox *clampo3 = new TGeoBBox("clampo3",1.6,0.45,.1);
    1987           2 :  TGeoVolume *clampo3v = new TGeoVolume("TPC_clampo3v",clampo3,m6); 
    1988             :  //
    1989           3 :  oclamp->AddNode(clampo3v,1,new TGeoTranslation(-1.85,2.625,0.));
    1990           3 :  oclamp->AddNode(clampo3v,2,new TGeoTranslation(-1.85,-2.625,0));
    1991             :  //
    1992           2 :  TGeoTubeSeg *clampo4 = new TGeoTubeSeg("clampo4",2.2,3.1,0.1,90.,270.);
    1993           2 :  TGeoVolume *clampo4v = new TGeoVolume("TPC_clampo4v",clampo4,m6);
    1994             :  //
    1995           3 :  oclamp->AddNode(clampo4v,1,new TGeoTranslation(-3.45,0.,0.));
    1996             : 
    1997             : 
    1998             : 
    1999             :  //v9 - drift gas
    2000             : 
    2001           1 :     TGeoRotation rot102("rot102");
    2002           1 :     rot102.RotateY(-90.);
    2003             : 
    2004          38 :   for(Int_t i=0;i<18;i++){
    2005             :     Double_t angle,x,y;
    2006             :     Double_t z,r; 
    2007          36 :     angle=TMath::DegToRad()*20.*(Double_t)i;
    2008             :     //inner rods
    2009             :     r=81.5;
    2010          18 :     x=r * TMath::Cos(angle);
    2011          18 :     y=r * TMath::Sin(angle);
    2012             :     z = 126.;
    2013          36 :     TGeoRotation *rot12 = new TGeoRotation();
    2014          18 :     rot12->RotateZ(-90.0+i*20.);
    2015          54 :     v9->AddNode(tpcihpl,i+1,new TGeoCombiTrans(x, y, 0., rot12));
    2016             :     //
    2017          18 :     if(i==11){//resistor rod inner
    2018           1 :        rotrod.RotateZ(-90.+i*20.);
    2019           2 :        rotrod1[0]= new TGeoRotation();
    2020           2 :        rotpos[0]= new TGeoRotation();
    2021             :        //
    2022           1 :        rotrod1[0]->RotateZ(90.+i*20.);
    2023           2 :        *rotpos[0] = refl*rotrod; //rotation+reflection
    2024           3 :         v9->AddNode(tpcrrod,1,new TGeoCombiTrans(x,y, z, rotrod1[0])); //A
    2025           3 :         v9->AddNode(tpcrrod,2,new TGeoCombiTrans(x,y,-z, rotpos[0])); //C      
    2026             :     } 
    2027             :     else { 
    2028          51 :       v9->AddNode(tpcmrod,i+1,new TGeoTranslation(x,y,z));//shaft
    2029          51 :       v9->AddNode(tpcmrod,i+19,new TGeoCombiTrans(x,y,-z,ref));//muon
    2030             :     }
    2031             :     //
    2032             :     // inner clamps positioning
    2033             :     //
    2034             :     r=79.05;
    2035          18 :     x=r * TMath::Cos(angle);
    2036          18 :     y=r * TMath::Sin(angle);
    2037          36 :     rot12= new TGeoRotation();
    2038          18 :     rot12->RotateZ(i*20.);
    2039             :     //
    2040             :       //A-side
    2041          54 :       v9->AddNode(iclamp,7*i+1,new TGeoCombiTrans(x,y,5.25,rot12));
    2042          54 :       v9->AddNode(iclamp,7*i+2,new TGeoCombiTrans(x,y,38.25,rot12));
    2043          54 :       v9->AddNode(iclamp,7*i+3,new TGeoCombiTrans(x,y,80.25,rot12));
    2044          54 :       v9->AddNode(iclamp,7*i+4,new TGeoCombiTrans(x,y,122.25,rot12));
    2045          54 :       v9->AddNode(iclamp,7*i+5,new TGeoCombiTrans(x,y,164.25,rot12));
    2046          54 :       v9->AddNode(iclamp,7*i+6,new TGeoCombiTrans(x,y,206.25,rot12));
    2047          54 :       v9->AddNode(iclamp,7*i+7,new TGeoCombiTrans(x,y,246.75,rot12));
    2048             :       //C-side
    2049          54 :       v9->AddNode(iclamp,7*i+127,new TGeoCombiTrans(x,y,-5.25,rot12));
    2050          54 :       v9->AddNode(iclamp,7*i+128,new TGeoCombiTrans(x,y,-38.25,rot12));
    2051          54 :       v9->AddNode(iclamp,7*i+129,new TGeoCombiTrans(x,y,-80.25,rot12));
    2052          54 :       v9->AddNode(iclamp,7*i+130,new TGeoCombiTrans(x,y,-122.25,rot12));
    2053          54 :       v9->AddNode(iclamp,7*i+131,new TGeoCombiTrans(x,y,-164.25,rot12));
    2054          54 :       v9->AddNode(iclamp,7*i+132,new TGeoCombiTrans(x,y,-206.25,rot12));
    2055          54 :       v9->AddNode(iclamp,7*i+133,new TGeoCombiTrans(x,y,-246.75,rot12));
    2056             :     //
    2057             :     //--------------------------
    2058             :     // outer rods
    2059             :     r=254.25;
    2060          18 :     x=r * TMath::Cos(angle);
    2061          18 :     y=r * TMath::Sin(angle);
    2062             :     z=126.;
    2063             :     //
    2064             :     // outer rod holder + outer left plug
    2065             :     //
    2066             : 
    2067          36 :     TGeoRotation *rot33 = new TGeoRotation();
    2068          18 :     rot33->RotateZ(-90+i*20.);
    2069             :     //
    2070          54 :     v9->AddNode(tpcohpl,i+1,new TGeoCombiTrans(x, y, 0., rot33));
    2071             :     //
    2072          36 :     Double_t xxx = 256.297*TMath::Cos((i*20.+10.)*TMath::DegToRad());
    2073          36 :     Double_t yyy = 256.297*TMath::Sin((i*20.+10.)*TMath::DegToRad());
    2074             :     //
    2075          18 :     TGeoRotation rot101("rot101");
    2076          18 :     rot101.RotateZ(90.+i*20.+10.);
    2077          36 :     TGeoRotation *rot103 = new TGeoRotation("rot103");
    2078          36 :     *rot103 = rot101*rot102;
    2079             :     //
    2080          36 :     TGeoCombiTrans *trh100 = new TGeoCombiTrans(xxx,yyy,0.,rot103);
    2081             :     //
    2082          36 :     if(i==2) {
    2083             :       //main membrane holder
    2084          19 :       v9->AddNode(tpcmmh,1,trh100);
    2085             :     }
    2086             :     else{
    2087             :       // "normal" membrane holder
    2088          17 :       v9->AddNode(tpcomh,i+1,trh100);      
    2089             :     }
    2090             : 
    2091             :     //
    2092          18 :     if(i==3){//resistor rod outer
    2093           1 :       rotrod.RotateZ(90.+i*20.);
    2094           2 :       rotrod1[1]= new TGeoRotation();
    2095           2 :       rotpos[1]= new TGeoRotation();
    2096           1 :       rotrod1[1]->RotateZ(90.+i*20.);
    2097           2 :       *rotpos[1] = refl*rotrod;//rotation+reflection
    2098           3 :       v9->AddNode(tpcrrod,3,new TGeoCombiTrans(x,y, z, rotrod1[1])); //A 
    2099           3 :       v9->AddNode(tpcrrod,4,new TGeoCombiTrans(x,y, -z, rotpos[1])); //C
    2100             :     }
    2101             :     else {
    2102          51 :       v9->AddNode(tpcmrod,i+37,new TGeoTranslation(x,y,z));//shaft
    2103          51 :       v9->AddNode(tpcmrod,i+55,new TGeoCombiTrans(x,y,-z,ref));//muon      
    2104             :     }
    2105          18 :     if(i==15){
    2106           3 :       v9->AddNode(hvrv,1,new TGeoTranslation(x,y,z+0.7)); //hv->A-side only     
    2107             :     }
    2108             :     //
    2109             :     // outer clamps
    2110             :     //
    2111             :     r=256.9;
    2112          18 :     x=r * TMath::Cos(angle);
    2113          18 :     y=r * TMath::Sin(angle);
    2114          36 :     rot12= new TGeoRotation();
    2115          18 :     rot12->RotateZ(i*20.);
    2116             :     //
    2117             :       //A-side
    2118          54 :       v9->AddNode(oclamp,7*i+1,new TGeoCombiTrans(x,y,5.25,rot12));
    2119          54 :       v9->AddNode(oclamp,7*i+2,new TGeoCombiTrans(x,y,38.25,rot12));
    2120          54 :       v9->AddNode(oclamp,7*i+3,new TGeoCombiTrans(x,y,80.25,rot12));
    2121          54 :       v9->AddNode(oclamp,7*i+4,new TGeoCombiTrans(x,y,122.25,rot12));
    2122          54 :       v9->AddNode(oclamp,7*i+5,new TGeoCombiTrans(x,y,164.25,rot12));
    2123          54 :       v9->AddNode(oclamp,7*i+6,new TGeoCombiTrans(x,y,206.25,rot12));
    2124          54 :       v9->AddNode(oclamp,7*i+7,new TGeoCombiTrans(x,y,246.75,rot12));
    2125             :       //C-side
    2126          54 :       v9->AddNode(oclamp,7*i+127,new TGeoCombiTrans(x,y,-5.25,rot12));
    2127          54 :       v9->AddNode(oclamp,7*i+128,new TGeoCombiTrans(x,y,-38.25,rot12));
    2128          54 :       v9->AddNode(oclamp,7*i+129,new TGeoCombiTrans(x,y,-80.25,rot12));
    2129          54 :       v9->AddNode(oclamp,7*i+130,new TGeoCombiTrans(x,y,-122.25,rot12));
    2130          54 :       v9->AddNode(oclamp,7*i+131,new TGeoCombiTrans(x,y,-164.25,rot12));
    2131          54 :       v9->AddNode(oclamp,7*i+132,new TGeoCombiTrans(x,y,-206.25,rot12));
    2132          54 :       v9->AddNode(oclamp,7*i+133,new TGeoCombiTrans(x,y,-246.75,rot12));
    2133             :     
    2134          18 :   } //end of rods positioning
    2135             : 
    2136           1 :   TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
    2137           1 :   alice->AddNode(v1,1);  
    2138             :   
    2139           1 : } // end of function
    2140             :  
    2141             : //_____________________________________________________________________________
    2142             : void AliTPCv2::AddAlignableVolumes() const
    2143             : {
    2144             :   //
    2145             :   // Create entries for alignable volumes associating the symbolic volume
    2146             :   // name with the corresponding volume path. Needs to be syncronized with
    2147             :   // eventual changes in the geometry.
    2148             :   // 
    2149           2 :   SetInnerChambersAlignable();
    2150           1 :   SetOuterChambersAlignable();
    2151           1 : }
    2152             :  
    2153             : //_____________________________________________________________________________
    2154             : void AliTPCv2::SetInnerChambersAlignable() const
    2155             : {
    2156             :   //
    2157             :   AliGeomManager::ELayerID idTPC1 = AliGeomManager::kTPC1;
    2158             :   Int_t modUID, modnum = 0;
    2159           2 :   TString vpstr1 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_1/TPC_SECT_";
    2160           1 :   TString vpstr2 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_2/TPC_SECT_";
    2161           1 :   TString vpappend = "/TPC_IROC_1";
    2162           1 :   TString snstr1="TPC/EndcapA/Sector";
    2163           1 :   TString snstr2="TPC/EndcapC/Sector";
    2164           1 :   TString snappend="/InnerChamber";
    2165           2 :   TString volpath, symname;
    2166             :   
    2167          38 :   for(Int_t cnt=1; cnt<=18; cnt++){
    2168          36 :     modUID = AliGeomManager::LayerToVolUID(idTPC1,modnum++);
    2169          18 :     volpath = vpstr1;
    2170          18 :     volpath += cnt;
    2171          18 :     volpath += vpappend;
    2172          18 :     symname = snstr1;
    2173          18 :     symname += cnt;
    2174          18 :     symname += snappend;
    2175          72 :     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
    2176           0 :       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
    2177          18 :     TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
    2178          18 :     TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
    2179          18 :     TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,cnt-1);
    2180          18 :     alignableEntry->SetMatrix(matTtoL);
    2181             :   }
    2182             : 
    2183          38 :   for(Int_t cnt=1; cnt<=18; cnt++){
    2184          36 :     modUID = AliGeomManager::LayerToVolUID(idTPC1,modnum++);
    2185          18 :     volpath = vpstr2;
    2186          18 :     volpath += cnt;
    2187          18 :     volpath += vpappend;
    2188          18 :     symname = snstr2;
    2189          18 :     symname += cnt;
    2190          18 :     symname += snappend;
    2191          72 :     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
    2192           0 :       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
    2193          18 :     TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
    2194          18 :     TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
    2195          18 :     TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,18+cnt-1);
    2196          18 :     alignableEntry->SetMatrix(matTtoL);
    2197             :   }
    2198           1 : }
    2199             : 
    2200             : //_____________________________________________________________________________
    2201             : void AliTPCv2::SetOuterChambersAlignable() const
    2202             : {
    2203             :   //
    2204             :   AliGeomManager::ELayerID idTPC2 = AliGeomManager::kTPC2;
    2205             :   Int_t modUID, modnum = 0;
    2206           2 :   TString vpstr1 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_1/TPC_SECT_";
    2207           1 :   TString vpstr2 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_2/TPC_SECT_";
    2208           1 :   TString vpappend = "/TPC_OROC_1";
    2209           1 :   TString snstr1="TPC/EndcapA/Sector";
    2210           1 :   TString snstr2="TPC/EndcapC/Sector";
    2211           1 :   TString snappend="/OuterChamber";
    2212           2 :   TString volpath, symname;
    2213             :   
    2214          38 :   for(Int_t cnt=1; cnt<=18; cnt++){
    2215          36 :     modUID = AliGeomManager::LayerToVolUID(idTPC2,modnum++);
    2216          18 :     volpath = vpstr1;
    2217          18 :     volpath += cnt;
    2218          18 :     volpath += vpappend;
    2219          18 :     symname = snstr1;
    2220          18 :     symname += cnt;
    2221          18 :     symname += snappend;
    2222          72 :     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
    2223           0 :       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
    2224          18 :     TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
    2225          18 :     TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
    2226          18 :     TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,36+cnt-1);
    2227          18 :     alignableEntry->SetMatrix(matTtoL);
    2228             :   }
    2229             : 
    2230          38 :   for(Int_t cnt=1; cnt<=18; cnt++){
    2231          36 :     modUID = AliGeomManager::LayerToVolUID(idTPC2,modnum++);
    2232          18 :     volpath = vpstr2;
    2233          18 :     volpath += cnt;
    2234          18 :     volpath += vpappend;
    2235          18 :     symname = snstr2;
    2236          18 :     symname += cnt;
    2237          18 :     symname += snappend;
    2238          72 :     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data(),modUID))
    2239           0 :       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
    2240          18 :     TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
    2241          18 :     TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
    2242          18 :     TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,36+18+cnt-1);
    2243          18 :     alignableEntry->SetMatrix(matTtoL);
    2244             :   }
    2245           1 : }
    2246             : 
    2247             : 
    2248             : //_____________________________________________________________________________
    2249             : void AliTPCv2::CreateMaterials()
    2250             : {
    2251             :   //
    2252             :   // Define materials for version 2 of the Time Projection Chamber
    2253             :   //
    2254             :  
    2255           2 :   AliTPC::CreateMaterials();
    2256           1 : }
    2257             : 
    2258             : //_____________________________________________________________________________
    2259             : void AliTPCv2::Init()
    2260             : {
    2261             :   //
    2262             :   // Initialises version 2 of the TPC after that it has been built
    2263             :   //
    2264             : 
    2265           2 :   Int_t *idtmed = fIdtmed->GetArray();
    2266             :   
    2267           1 :   AliTPC::Init();
    2268             : 
    2269             :  
    2270           1 :   fIdSens=TVirtualMC::GetMC()->VolId("TPC_Strip");  // one strip is always selected...
    2271             : 
    2272           1 :   fIDrift=TVirtualMC::GetMC()->VolId("TPC_Drift");
    2273           1 :   fSecOld=-100; // fake number 
    2274             : 
    2275           1 :   TVirtualMC::GetMC()->SetMaxNStep(-120000); // max. number of steps increased
    2276             : 
    2277           1 :   if (fPrimaryIonisation) {
    2278             :     // for FLUKA
    2279           0 :       TVirtualMC::GetMC()->Gstpar(idtmed[2],"PRIMIO_E", 20.77); // 1st ionisation potential
    2280             :  
    2281           0 :       TVirtualMC::GetMC()->Gstpar(idtmed[2],"PRIMIO_N", 14.35);
    2282           0 :       TVirtualMC::GetMC()->Gstpar(idtmed[2],"LOSS", 14); // specific energy loss
    2283           0 :       TVirtualMC::GetMC()->Gstpar(idtmed[2],"STRA",4);
    2284           0 :   } 
    2285             :   // specific energy loss for geant3 is now defined in galice.cuts
    2286             : 
    2287             : 
    2288           3 :   AliDebug(1,"*** TPC version 2 initialized ***");
    2289           3 :   AliDebug(1,Form("Maximum number of steps = %d",TVirtualMC::GetMC()->GetMaxNStep()));
    2290             : 
    2291             :   //
    2292             :   
    2293           1 : }
    2294             : 
    2295             : //_____________________________________________________________________________
    2296             : void AliTPCv2::StepManager()
    2297             : {
    2298             :   //
    2299             :   // Called for every step in the Time Projection Chamber
    2300             :   //
    2301             : 
    2302             :   //
    2303             :   // parameters used for the energy loss calculations
    2304             :   //
    2305             :   //const Float_t kprim = 14.35; // number of primary collisions per 1 cm
    2306             :   //const Float_t kpoti = 20.77e-9; // first ionization potential for Ne/CO2
    2307             :   //const Float_t kwIon = 35.97e-9; // energy for the ion-electron pair creation 
    2308             :   const Float_t kScalewIonG4 = 0.85; // scale factor to tune kwIon for Geant4 
    2309             :   const Float_t kFanoFactorG4 = 0.7; // parameter for smearing the number of ionizations (nel) using Geant4
    2310             :   const Int_t   kMaxDistRef =15;     // maximal difference between 2 stored references 
    2311     1729272 :   Float_t prim = fTPCParam->GetNprim();
    2312      864636 :   Float_t poti = fTPCParam->GetFpot();
    2313      864636 :   Float_t wIon = fTPCParam->GetWmean();
    2314             :  
    2315             :   const Float_t kbig = 1.e10;
    2316             : 
    2317      864636 :   Int_t id,copy;
    2318      864636 :   Float_t hits[5];
    2319      864636 :   Int_t vol[2];  
    2320      864636 :   TLorentzVector p;
    2321             :   
    2322      864636 :   vol[1]=0; // preset row number to 0
    2323             :   //
    2324     2593908 :   if (!fPrimaryIonisation) TVirtualMC::GetMC()->SetMaxStep(kbig);
    2325             :   
    2326     2594911 :   if(!TVirtualMC::GetMC()->IsTrackAlive()) return; // particle has disappeared
    2327             :   
    2328     2590899 :   Float_t charge = TVirtualMC::GetMC()->TrackCharge();
    2329             :   
    2330      889931 :   if(TMath::Abs(charge)<=0.) return; // take only charged particles
    2331             :   
    2332             :   // check the sensitive volume
    2333             : 
    2334     1674670 :   id = TVirtualMC::GetMC()->CurrentVolID(copy); // vol ID and copy number (starts from 1!)
    2335      863493 :   if(id != fIDrift && id != fIdSens) return; // not in the sensitive folume 
    2336             : 
    2337      824399 :   if ( fPrimaryIonisation && id == fIDrift ) {
    2338           0 :     Double_t rnd = TVirtualMC::GetMC()->GetRandom()->Rndm();
    2339           0 :     TVirtualMC::GetMC()->SetMaxStep(0.2+(2.*rnd-1.)*0.05);  // 2 mm +- rndm*0.5mm step
    2340           0 :   }   
    2341             : 
    2342             :   //if ( fPrimaryIonisation && id == fIDrift && TVirtualMC::GetMC()->IsTrackEntering()) {
    2343             :   //  TVirtualMC::GetMC()->SetMaxStep(0.2);  // 2 mm 
    2344             :   //}   
    2345             :   
    2346     1648798 :   TVirtualMC::GetMC()->TrackPosition(p);
    2347     4121995 :   Double_t r = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
    2348             :   //
    2349             :   
    2350             :   //
    2351     1648798 :   Double_t angle = TMath::ACos(p[0]/r);  
    2352     3297596 :   angle = (p[1]<0.) ? TMath::TwoPi()-angle : angle;
    2353             :   //
    2354             :   // angular segment, it is not a real sector number...
    2355             :   //
    2356     2473197 :   Int_t sector=TMath::Nint((angle-fTPCParam->GetInnerAngleShift())/
    2357     1648798 :                fTPCParam->GetInnerAngle());
    2358             :   // rotate to segment "0"
    2359      824399 :   Float_t cos,sin;
    2360      824399 :   fTPCParam->AdjustCosSin(sector,cos,sin);
    2361     2473197 :   Float_t x1=p[0]*cos + p[1]*sin;
    2362             :   // check if within sector's limits
    2363     2009805 :   if((x1>=fTPCParam->GetInnerRadiusLow()&&x1<=fTPCParam->GetInnerRadiusUp())
    2364     1579824 :      ||(x1>=fTPCParam->GetOuterRadiusLow()&&x1<=fTPCParam->GetOuterRadiusUp())){
    2365             :   // calculate real sector number...
    2366      740611 :   if (x1>fTPCParam->GetOuterRadiusLow()){
    2367      931890 :     sector = TMath::Nint((angle-fTPCParam->GetOuterAngleShift())/
    2368      931890 :              fTPCParam->GetOuterAngle())+fTPCParam->GetNInnerSector();
    2369      790034 :     if (p[2]<0)      sector+=(fTPCParam->GetNOuterSector()>>1);
    2370             :   }
    2371             :     else   
    2372     1087183 :       if (p[2]<0) sector+=(fTPCParam->GetNInnerSector()>>1);  
    2373             :   //
    2374             :   // here I have a sector number
    2375             :   //
    2376             : 
    2377      740611 :   vol[0]=sector;
    2378             : 
    2379             :   static Double_t lastReferenceR=0;
    2380      740611 :   if (TMath::Abs(lastReferenceR-r)>kMaxDistRef){
    2381        1796 :     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTPC);
    2382         898 :     lastReferenceR = r;
    2383         898 :   }
    2384             : 
    2385             :   // check if change of sector
    2386      740611 :   if(sector != fSecOld){
    2387         354 :     fSecOld=sector;
    2388             :     // add track reference
    2389         708 :     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTPC);
    2390             :   }  
    2391             :   // track is in the sensitive strip
    2392      740611 :   if(id == fIdSens){
    2393             :     // track is entering the strip
    2394         858 :     if (TVirtualMC::GetMC()->IsTrackEntering()){
    2395         363 :       Int_t totrows = fTPCParam->GetNRowLow()+fTPCParam->GetNRowUp();
    2396         121 :       vol[1] = (copy<=totrows) ? copy-1 : copy-1-totrows;
    2397             :       // row numbers are autonomous for lower and upper sectors
    2398         121 :       if(vol[0] > fTPCParam->GetNInnerSector()) {
    2399           0 :         vol[1] -= fTPCParam->GetNRowLow();
    2400           0 :       }
    2401             :     //
    2402         242 :       if(vol[0]<fTPCParam->GetNInnerSector()&&vol[1] == 0){
    2403             :   
    2404             :         // lower sector, row 0, because Jouri wants to have this
    2405             : 
    2406         242 :         TVirtualMC::GetMC()->TrackMomentum(p);
    2407         242 :         hits[0]=p[0];
    2408         242 :         hits[1]=p[1];
    2409         242 :         hits[2]=p[2];
    2410         121 :         hits[3]=0.; // this hit has no energy loss
    2411             :         // Get also the track time for pileup simulation
    2412         363 :         hits[4]=TVirtualMC::GetMC()->TrackTime();
    2413             : 
    2414         242 :         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);  
    2415             :       }
    2416             :     //
    2417             : 
    2418         242 :        TVirtualMC::GetMC()->TrackPosition(p);
    2419         242 :        hits[0]=p[0];
    2420         242 :        hits[1]=p[1];
    2421         242 :        hits[2]=p[2];
    2422         121 :        hits[3]=0.; // this hit has no energy loss
    2423             :        // Get also the track time for pileup simulation
    2424         363 :        hits[4]=TVirtualMC::GetMC()->TrackTime();
    2425             : 
    2426         242 :        AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);  
    2427             :     
    2428             :     }
    2429         165 :     else return;
    2430         121 :   }  
    2431             :   //-----------------------------------------------------------------
    2432             :   //  charged particle is in the sensitive drift volume
    2433             :   //-----------------------------------------------------------------
    2434     2221338 :   if(TVirtualMC::GetMC()->TrackStep() > 0) {
    2435             :     Int_t nel=0;
    2436      739852 :     if (!fPrimaryIonisation) {
    2437     2219556 :       nel = (Int_t)(((TVirtualMC::GetMC()->Edep())-poti)/wIon) + 1;
    2438      739852 :     }
    2439             :     else {
    2440             :       
    2441             :       /*
    2442             :       static Double_t deForNextStep = 0.;
    2443             :       // Geant4 (the meaning of Edep as in Geant3) - wrong
    2444             :       //nel = (Int_t)(((TVirtualMC::GetMC()->Edep())-poti)/wIon) + 1;
    2445             : 
    2446             :       // Geant4 (the meaning of Edep as in Geant3) - NEW
    2447             :       Double_t eAvailable = TVirtualMC::GetMC()->Edep() + deForNextStep;
    2448             :       nel = (Int_t)(eAvailable/wIon);
    2449             :       deForNextStep = eAvailable - nel*wIon;
    2450             :       */
    2451             : 
    2452             :       //new Geant4-approach
    2453           0 :       Double_t meanIon = TVirtualMC::GetMC()->Edep()/(wIon*kScalewIonG4);
    2454           0 :       nel = (Int_t) ( kFanoFactorG4*AliMathBase::Gamma(meanIon/kFanoFactorG4)); // smear nel using gamma distr w mean = meanIon and variance = meanIon/kFanoFactorG4
    2455             :     }
    2456      739852 :     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
    2457             :     //
    2458     1479704 :     TVirtualMC::GetMC()->TrackPosition(p);
    2459     1479704 :     hits[0]=p[0];
    2460     1479704 :     hits[1]=p[1];
    2461     1479704 :     hits[2]=p[2];
    2462      739852 :     hits[3]=(Float_t)nel;
    2463             : 
    2464             :     // Add this hit
    2465             : 
    2466             :     //    if (fHitType&&2){
    2467      739852 :     if(fHitType){
    2468     1479704 :       TVirtualMC::GetMC()->TrackMomentum(p);
    2469     3699260 :       Float_t momentum = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
    2470      739852 :       Float_t precision =   (momentum>0.1) ? 0.002 :0.01;
    2471      739852 :       fTrackHits->SetHitPrecision(precision);
    2472      739852 :     }
    2473             : 
    2474             :     // Get also the track time for pileup simulation
    2475     2219556 :     hits[4]=TVirtualMC::GetMC()->TrackTime();
    2476             :  
    2477     1479704 :     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
    2478      739852 :     if (fDebugStreamer){   
    2479             :       // You can dump here what you need
    2480             :       // function  CreateDebugStremer() to be called in the Config.C  macro
    2481             :       // if you want to enable it
    2482             :       // By default debug streaemer is OFF
    2483           0 :       Float_t edep = TVirtualMC::GetMC()->Edep();
    2484           0 :       Float_t tstep = TVirtualMC::GetMC()->TrackStep();
    2485           0 :       Int_t pid=TVirtualMC::GetMC()->TrackPid();
    2486           0 :       (*fDebugStreamer)<<"hit"<<      
    2487           0 :         "x="<<hits[0]<<  // hit position
    2488           0 :         "y="<<hits[1]<<
    2489           0 :         "z="<<hits[2]<<
    2490           0 :         "nel="<<hits[3]<<  // number of electorns
    2491           0 :         "tof="<<hits[4]<<  // hit TOF
    2492           0 :         "edep="<<edep<<    // energy deposit
    2493           0 :         "pid="<<pid<<      // pid
    2494           0 :         "step="<<tstep<<
    2495           0 :         "p.="<<&p<<
    2496             :         "\n";
    2497           0 :     }
    2498             :     
    2499      739852 :   } // step>0 
    2500             :   } //within sector's limits
    2501             :   // Stemax calculation for the next step
    2502             :   
    2503             :   Float_t pp;
    2504      824234 :   TLorentzVector mom;
    2505             :   // below is valid only for Geant3 (fPromaryIonisation not set)
    2506      824234 :   if(!fPrimaryIonisation){
    2507     1648468 :     TVirtualMC::GetMC()->TrackMomentum(mom);
    2508     1648468 :     Float_t ptot=mom.Rho();
    2509     2472702 :     Float_t betaGamma = ptot/TVirtualMC::GetMC()->TrackMass();
    2510             : 
    2511             :     //Int_t pid=TVirtualMC::GetMC()->TrackPid();
    2512             :     // if((pid==kElectron || pid==kPositron) && ptot > 0.002)
    2513             :     //       { 
    2514             :     //         pp = prim*1.58; // electrons above 20 MeV/c are on the plateau!
    2515             :     //       }
    2516             :     //     else
    2517             :     //       {
    2518             :     
    2519      824234 :     betaGamma = TMath::Max(betaGamma,(Float_t)7.e-3); // protection against too small bg
    2520      824234 :     TVectorD *bbpar = fTPCParam->GetBetheBlochParametersMC(); //get parametrization from OCDB
    2521     5769638 :     pp=prim*AliMathBase::BetheBlochAleph(betaGamma,(*bbpar)(0),(*bbpar)(1),(*bbpar)(2),(*bbpar)(3),(*bbpar)(4));         
    2522             :     //     }
    2523             :   
    2524     2472702 :     Double_t rnd = TVirtualMC::GetMC()->GetRandom()->Rndm();
    2525             :   
    2526     1648468 :     TVirtualMC::GetMC()->SetMaxStep(-TMath::Log(rnd)/pp);
    2527      824234 :   }
    2528             :   
    2529     2513269 : }
    2530             : 
    2531             : 

Generated by: LCOV version 1.11