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

Generated by: LCOV version 1.11