]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCv2.cxx
Cleanup of STEER coding conventions
[u/mrichter/AliRoot.git] / TPC / AliTPCv2.cxx
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.44  2002/11/21 22:43:32  alibrary
19 Removing AliMC and AliMCProcess
20
21 Revision 1.43  2002/10/14 14:57:43  hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
23
24 Revision 1.40.6.2  2002/07/24 10:09:01  alibrary
25 Updating VirtualMC
26
27 Revision 1.42  2002/06/12 14:56:56  kowal2
28 Added track length to the reference hits
29
30 Revision 1.41  2002/05/27 14:33:15  hristov
31 The new class AliTrackReference used (M.Ivanov)
32
33 Revision 1.40  2002/01/21 17:12:00  kowal2
34 New track hits structure using root containers
35
36 Revision 1.39  2001/05/16 14:57:25  alibrary
37 New files for folders and Stack
38
39 Revision 1.38  2001/05/08 16:03:06  kowal2
40 Geometry update according to the latest technical spec.
41
42 Revision 1.37  2001/04/27 15:23:07  kowal2
43 Correct materian in the central part of the inner containment vessel
44
45 Revision 1.36  2001/04/26 06:15:12  kowal2
46 Corrected bug in the inner containment vessel (cones)
47
48 Revision 1.35  2001/04/24 11:17:33  kowal2
49 New TPC geometry.
50
51 Revision 1.34  2001/04/23 10:20:18  hristov
52 Constant casted to avoid ambiguity
53
54 Revision 1.33  2001/04/20 08:16:47  kowal2
55 Protection against too small betaGamma. Thanks to Ivana and Yves.
56
57 Revision 1.32  2001/03/13 13:07:34  kowal2
58 Corrected bug in the TPC mother volume geometry.
59 Thanks to A. Morsch
60
61 Revision 1.31  2000/11/30 11:48:50  kowal2
62 TLorentzVector.h adde to satisfy the latest changes by Federico
63
64 Revision 1.30  2000/11/14 10:48:57  kowal2
65 Correct material used for TSA4. Thanks to J. Barbosa.
66
67 Revision 1.29  2000/11/06 17:24:10  kowal2
68 Corrected bug in the outer containment vessel and
69 the outer field cage geometry.
70 Thanks to J. Barbosa.
71
72 Revision 1.28  2000/11/02 16:55:24  kowal2
73 Corrected bug in the inner containment vessel geometry.
74 Thanks to J. Belikov
75
76 Revision 1.27  2000/11/02 07:24:11  kowal2
77 Correction in the TPC geometry.
78 Changes due to the new hit structure.
79
80 Revision 1.26  2000/10/05 16:16:29  kowal2
81 Corrections of the hit recording algorithm.
82
83 Revision 1.25  2000/10/02 21:28:18  fca
84 Removal of useless dependecies via forward declarations
85
86 Revision 1.24  2000/08/28 10:02:30  kowal2
87 Corrected bug in the StepManager
88
89 Revision 1.23  2000/07/10 20:57:39  hristov
90 Update of TPC code and macros by M.Kowalski
91
92 Revision 1.22  2000/06/30 12:07:50  kowal2
93 Updated from the TPC-PreRelease branch
94
95 Revision 1.21.2.4  2000/06/26 07:39:42  kowal2
96 Changes to obey the coding rules
97
98 Revision 1.21.2.3  2000/06/25 08:38:41  kowal2
99 Splitted from AliTPCtracking
100
101 Revision 1.21.2.2  2000/06/16 12:58:13  kowal2
102 Changed parameter settings
103
104 Revision 1.21.2.1  2000/06/09 07:15:07  kowal2
105
106 Defaults loaded automatically (hard-wired)
107 Optional parameters can be set via macro called in the constructor
108
109 Revision 1.21  2000/05/15 10:00:30  kowal2
110 Corrected bug in the TPC geometry, thanks to Ivana Hrivnacova
111
112 Revision 1.20  2000/04/17 09:37:33  kowal2
113 removed obsolete AliTPCDigitsDisplay.C
114
115 Revision 1.19.8.2  2000/04/10 08:31:52  kowal2
116
117 Different geometry for different sectors
118 Updated readout chambers
119 Some modifications to StepManager by J.Belikov
120
121 Revision 1.19.8.1  2000/04/10 07:56:53  kowal2
122 Not used anymore - removed
123
124 Revision 1.19  1999/11/04 17:28:07  fca
125 Correct barrel part of HV Degrader
126
127 Revision 1.18  1999/10/14 16:52:08  fca
128 Only use PDG codes and not GEANT ones
129
130 Revision 1.17  1999/10/08 06:27:23  fca
131 Corrected bug in the HV degrader geometry, thanks to G.Tabary
132
133 Revision 1.16  1999/10/04 13:39:54  fca
134 Correct array index problem
135
136 Revision 1.15  1999/09/29 09:24:34  fca
137 Introduction of the Copyright and cvs Log
138
139 */
140
141 //
142 ///////////////////////////////////////////////////////////////////////////////
143 //                                                                           //
144 //  Time Projection Chamber version 2 -- detailed TPC and slow simulation    //
145 //                                                                           //
146 //Begin_Html
147 /*
148 <img src="picts/AliTPCv2Class.gif">
149 */
150 //End_Html
151 //                                                                           //
152 //                                                                           //
153 ///////////////////////////////////////////////////////////////////////////////
154
155 #include <stdlib.h>
156
157 #include <TMath.h>
158 #include <TPDGCode.h>
159
160 #include "AliConst.h"
161 #include "AliRun.h"
162 #include "AliTPCDigitsArray.h"
163 #include "AliTPCParam.h"
164 #include "AliTPCParamSR.h"
165 #include "AliTPCTrackHitsV2.h"
166 #include "AliTPCv2.h"
167 #include "TLorentzVector.h"
168
169 ClassImp(AliTPCv2)
170  
171 //_____________________________________________________________________________
172 AliTPCv2::AliTPCv2(const char *name, const char *title) :
173   AliTPC(name, title) 
174 {
175   //
176   // Standard constructor for Time Projection Chamber version 2
177   //
178   fIdSens=0;
179   fIdLSec=0;
180   fIdUSec=0;
181
182   SetBufferSize(128000);
183
184   SetGasMixt(2,20,10,-1,0.9,0.1,0.); // Ne-CO2 90-10
185
186   // Default sectors
187
188   SetSecAL(4);
189   SetSecAU(4);
190   SetSecLows(1,  2,  3, 19, 20, 21);
191   SetSecUps(37, 38, 39, 37+18, 38+18, 39+18, -1, -1, -1, -1, -1, -1);
192   SetSens(1); // sensitive strips set 
193
194   if (fTPCParam)
195      fTPCParam->Write(fTPCParam->GetTitle());
196 }
197  
198 //_____________________________________________________________________________
199 void AliTPCv2::CreateGeometry()
200 {
201   //
202   // Create the geometry of Time Projection Chamber version 2
203   //
204   //Begin_Html
205   /*
206     <img src="picts/AliTPC.gif">
207   */
208   //End_Html
209   //Begin_Html
210   /*
211     <img src="picts/AliTPCv2Tree.gif">
212   */
213   //End_Html
214
215
216   Int_t *idtmed = fIdtmed->GetArray();
217
218   Float_t dm[50];
219   Int_t idrotm[120];
220
221   Int_t nRotMat = 0;
222
223   Int_t i,ifl1=0;
224
225   // number of sectors
226
227   Int_t nInnerSector = fTPCParam->GetNInnerSector()/2;
228   Int_t nOuterSector = fTPCParam->GetNOuterSector()/2;
229   
230   // --------------------------------------------------- 
231   //        sector specification check 
232   // --------------------------------------------------- 
233   if (fSecAL >= 0) {
234     ifl1 = 0;
235     
236     for (i = 0; i < 6; ++i) {
237       if (fSecLows[i] >= 0 && fSecLows[i] < 2*nInnerSector) {
238         ifl1 = 1;
239         printf("%s: *** SECTOR %d selected\n",ClassName(),fSecLows[i]);
240       }
241     }
242
243   } else {
244     printf("%s: *** ALL LOWER SECTORS SELECTED ***\n",ClassName());
245     ifl1 = 1;
246   }
247
248   if (ifl1 == 0) {
249     printf("%s: *** ERROR: AT LEAST ONE LOWER SECTOR MUST BE SPECIFIED ***\n",ClassName());
250     printf("%s: !!! PROGRAM STOPPED !!!\n",ClassName());
251     exit(1);
252   }
253
254   if (fSecAU >= 0) {
255     
256     for (i = 0; i < 12; ++i) {
257       if (fSecUps[i] > 2*nInnerSector-1 && 
258           fSecUps[i] < 2*(nInnerSector+nOuterSector)) {
259         printf("%s: *** SECTOR %d selected\n",ClassName(),fSecUps[i]);
260       }
261     }
262     
263   } else {
264     printf("%s: *** ALL UPPER SECTORS SELECTED ***\n",ClassName());
265   }
266   
267  
268
269   //--------------------------------------------------------------------
270
271   //
272   //  Mother volume TPC (Air) - all volumes will be positioned in it
273   //
274
275   dm[0]=0.;
276   dm[1]=360.;
277   dm[2]=8.;
278
279   //
280
281   dm[3]=-283.7;
282   dm[4]=65.6;
283   dm[5]=278.;
284
285   //
286
287   dm[6]=-253.6;
288   dm[7]=65.6;
289   dm[8]=278.;
290
291   //
292
293   dm[9]=-73.3;
294   dm[10]=60.9;
295   dm[11]=278.;  
296
297   //
298
299   dm[12]=-73.3;
300   dm[13]=56.9;
301   dm[14]=278.;
302
303   //
304
305   dm[15]=73.3;
306   dm[16]=56.9;
307   dm[17]=278.;
308
309   //
310
311   dm[18]=73.3;
312   dm[19]=60.9;
313   dm[20]=278.;
314
315   //
316
317   dm[21]=253.6;
318   dm[22]=65.6;
319   dm[23]=278.;
320
321   //
322
323   dm[24]=283.7;
324   dm[25]=65.6;
325   dm[26]=278.;
326   
327   gMC->Gsvolu("TPC ","PCON",idtmed[0],dm,27);
328
329   // outer part
330
331   //-------------------------------------------------------------------
332   //   Tpc Outer INsulator (CO2) - contains cont. vessel and field cage
333   //-------------------------------------------------------------------
334
335   dm[0]= 0.;
336   dm[1]= 360.;
337   dm[2]= 6.;
338
339   //
340
341   dm[3]=-253.6;
342   dm[4]=258.;
343   dm[5]=275.5;
344
345   //
346
347   dm[6]=-250.6;
348   dm[7]=258.;
349   dm[8]=275.5; 
350
351   //
352
353   dm[9]=-250.6;
354   dm[10]=258.;
355   dm[11]=278.;
356
357   //
358
359   dm[12]=253.6;
360   dm[13]=258.;
361   dm[14]=278.; 
362
363   //
364
365   dm[15]=253.6;
366   dm[16]=264.8;
367   dm[17]=278.;  
368
369   //
370
371   dm[18]=256.6;
372   dm[19]=264.8;
373   dm[20]=278.;
374
375   gMC->Gsvolu("TOIN","PCON",idtmed[3],dm,21);
376
377   //----------------------------------------------------------------
378   // Tpc Outer Contaiment Vessel  
379   //  mother volume - Al, daughters - composite (sandwich)
380   //----------------------------------------------------------------
381
382   dm[0]=0.;
383   dm[1]=360.;
384   dm[2]=6.;
385
386   //
387
388   dm[3]=-250.6;
389   dm[4]=270.4;
390   dm[5]=278.;
391
392   //
393
394   dm[6]=-247.6;
395   dm[7]=270.4;
396   dm[8]=278.; 
397
398   //
399
400   dm[9]=-247.6;
401   dm[10]=274.8124;
402   dm[11]=278.;
403
404   //
405
406   dm[12]=253.6;
407   dm[13]=274.8124;
408   dm[14]=278.;
409
410   //
411
412   dm[15]=253.6;
413   dm[16]=264.8;
414   dm[17]=278.;
415
416   //
417
418   dm[18]=256.6;
419   dm[19]=264.8;
420   dm[20]=278.;
421
422   gMC->Gsvolu("TOCV","PCON",idtmed[4],dm,21);
423
424   // Daughter volumes - sandwich
425
426   // Tpc SAndwich 1 - Al
427
428   dm[0]=274.8124;
429   dm[1]=278.;
430   dm[2]=252.1;
431
432   gMC->Gsvolu("TSA1","TUBE",idtmed[4],dm,3);
433
434   // Tpc SAndwich 2 - epoxy glue (I use Lexan)
435
436   dm[0] += 5.e-3;
437   dm[1] -= 5.e-3;
438
439   gMC->Gsvolu("TSA2","TUBE",idtmed[14],dm,3);
440
441   // Tpc SAndwich 3 - Tedlar
442
443   dm[0] += 0.01;
444   dm[1] -= 0.01;
445   
446   gMC->Gsvolu("TSA3","TUBE",idtmed[9],dm,3);
447
448
449   // Tpc SAndwich 4 - fiber glass (G10)
450
451   dm[0] += 3.8e-3;
452   dm[1] -= 3.8e-3;
453
454   gMC->Gsvolu("TSA4","TUBE",idtmed[12],dm,3);  
455
456   // Tpc SAndwich 5 - NOMEX honeycomb
457
458   dm[0] += 0.075;
459   dm[1] -= 0.075;   
460   
461   gMC->Gsvolu("TSA5","TUBE",idtmed[6],dm,3);
462
463   // 5->4->3->2->1->TCOV
464
465
466   gMC->Gspos("TSA5",1,"TSA4",0.,0.,0.,0,"ONLY");
467   gMC->Gspos("TSA4",1,"TSA3",0.,0.,0.,0,"ONLY");
468   gMC->Gspos("TSA3",1,"TSA2",0.,0.,0.,0,"ONLY");
469   gMC->Gspos("TSA2",1,"TSA1",0.,0.,0.,0,"ONLY");  
470
471   gMC->Gspos("TSA1",1,"TOCV",0.,0.,3.,0,"ONLY");
472
473   // TCOV-> TOIN
474
475   gMC->Gspos("TOCV",1,"TOIN",0.,0.,0.,0,"ONLY");
476
477   //-------------------------------------------------------
478   //  Tpc Outer Field Cage
479   //  mother volume - Al, daughters - composite (sandwich)
480   //-------------------------------------------------------
481
482   dm[0]=0.;
483   dm[1]=360.;
484   dm[2]=6.;
485
486   //
487
488   dm[3]=-253.6;
489   dm[4]=258.;
490   dm[5]=275.5;
491
492   //
493
494   dm[6]=-250.6;
495   dm[7]=258.;
496   dm[8]=275.5;
497
498   //
499
500   dm[9]=-250.6;
501   dm[10]=258.;
502   dm[11]=260.0476;
503
504   //
505
506   dm[12]=250.6;
507   dm[13]=258.;
508   dm[14]=260.0476;
509
510   //
511
512   dm[15]=250.6;
513   dm[16]=258.;
514   dm[17]=275.5;
515
516   //
517
518   dm[18]=253.6;
519   dm[19]=258.;
520   dm[20]=275.5;
521
522   gMC->Gsvolu("TOFC","PCON",idtmed[4],dm,21);
523
524   // Daughter volumes 
525
526   // Tpc SAndwich 6 - Tedlar
527
528   dm[0]= 258.;
529   dm[1]= 260.0476;
530   dm[2]= 252.1;
531
532   gMC->Gsvolu("TSA6","TUBE",idtmed[9],dm,3);
533
534   // Tpc SAndwich 7 - fiber glass
535
536   dm[0] += 3.8e-3;
537   dm[1] -= 3.8e-3;
538
539   gMC->Gsvolu("TSA7","TUBE",idtmed[12],dm,3);
540
541
542   // Tpc SAndwich 8 - NOMEX
543
544   dm[0] += 0.02;
545   dm[1] -= 0.02;
546
547   gMC->Gsvolu("TSA8","TUBE",idtmed[6],dm,3);    
548
549   // 8->7->6->TOFC
550
551   gMC->Gspos("TSA8",1,"TSA7",0.,0.,0.,0,"ONLY");
552   gMC->Gspos("TSA7",1,"TSA6",0.,0.,0.,0,"ONLY"); 
553   gMC->Gspos("TSA6",1,"TOFC",0.,0.,0.,0,"ONLY");
554
555   // TOFC->TOIN
556
557   gMC->Gspos("TOFC",1,"TOIN",0.,0.,0.,0,"ONLY");
558
559   // TOIN->TPC
560
561   gMC->Gspos("TOIN",1,"TPC ",0.,0.,0.,0,"ONLY");
562
563   // inner part
564
565   //--------------------------------------------------------------------
566   // Tpc Inner INsulator (CO2) - inner f.c. will be placed there
567   // Inner containment vessel will be placed directly in the TPC
568   //-------------------------------------------------------------------- 
569
570   dm[0]=0.;
571   dm[1]=360.;
572   dm[2]=4.;
573
574   // 
575
576   dm[3]=-253.6;
577   dm[4]=65.9;
578   dm[5]=79.2;
579
580   //
581
582   dm[6]=-73.3;
583   dm[7]=61.2;
584   dm[8]=79.2;  
585
586   //
587
588   dm[9]=73.3;
589   dm[10]=61.2;
590   dm[11]=79.2;
591
592   //
593
594   dm[12]=253.6;
595   dm[13]=65.9;
596   dm[14]=79.2;
597
598   gMC->Gsvolu("TIIN","PCON",idtmed[3],dm,15);
599
600   // the middle part of the F.C. is thinner - carve out the strip - Ne-CO2
601
602   dm[0]=79.16;
603   dm[1]=79.2;
604   dm[2]=88.;
605
606   gMC->Gsvolu("TII1","TUBE",idtmed[1],dm,3);
607
608   gMC->Gspos("TII1",1,"TIIN",0.,0.,0.,0,"ONLY");
609
610   //-----------------------------------------------------
611   // Tpc Inner Field Cage
612   // mother volume - Al, daughters - composite (sandwich)
613   //------------------------------------------------------
614
615   dm[0]=0.;
616   dm[1]=360.;
617   dm[2]=10.;
618
619   //
620
621   dm[3]=-253.6;
622   dm[4]=70.3;
623   dm[5]=79.2;
624
625   //
626
627   dm[6]=-250.6;
628   dm[7]=70.3;
629   dm[8]=79.2;
630
631   //
632
633   dm[9]=-250.6;
634   dm[10]=77.0524;
635   dm[11]=79.2;
636
637   //
638
639   dm[12]=-88.;
640   dm[13]=77.0524;
641   dm[14]=79.2;
642
643   //
644
645   dm[15]=-88.;
646   dm[16]=77.0924;
647   dm[17]=79.16;
648
649   //
650
651   dm[18]=88.;
652   dm[19]=77.0924;
653   dm[20]=79.16;
654
655   //
656
657   dm[21]=88.;
658   dm[22]=77.0524;
659   dm[23]=79.2;
660
661   //
662
663   dm[24]=250.6;
664   dm[25]=77.0524;
665   dm[26]=79.2;
666
667   //
668
669   dm[27]=250.6;
670   dm[28]=70.3;
671   dm[29]=79.2;
672
673   //
674
675   dm[30]=253.6;
676   dm[31]=70.3;
677   dm[32]=79.2;
678
679   gMC->Gsvolu("TIFC","PCON",idtmed[4],dm,33);
680
681   // daughter volumes - central part
682
683   // Tpc Sandwich 9 -Tedlar
684
685   dm[0]=77.0924;
686   dm[1]=79.16;
687   dm[2]=88.;
688
689   gMC->Gsvolu("TSA9","TUBE",idtmed[9],dm,3); 
690
691   // Tpc Sandwich 10 - fiber glass (G10) 
692
693   dm[0] += 3.8e-3;
694   dm[1] -= 3.8e-3;
695
696   gMC->Gsvolu("TS10","TUBE",idtmed[12],dm,3);
697
698   // Tpc Sandwich 11 - NOMEX
699
700   dm[0] += 0.03;
701   dm[1] -= 0.03; 
702
703   gMC->Gsvolu("TS11","TUBE",idtmed[6],dm,3);
704
705   // 11->10->9->TIFC
706
707   gMC->Gspos("TS11",1,"TS10",0.,0.,0.,0,"ONLY");
708   gMC->Gspos("TS10",1,"TSA9",0.,0.,0.,0,"ONLY");
709
710   gMC->Gspos("TSA9",1,"TIFC",0.,0.,0.,0,"ONLY");
711
712   // daughter volumes - outer parts (reinforced)
713
714   // Tpc Sandwich 12 -Tedlar
715
716   dm[0]=77.0524;
717   dm[1]=79.2;
718   dm[2]=82.05;
719
720   gMC->Gsvolu("TS12","TUBE",idtmed[9],dm,3);
721
722   // Tpc Sandwich 13 - fiber glass (G10) 
723
724   dm[0] += 3.8e-3;
725   dm[1] -= 3.8e-3;
726
727   gMC->Gsvolu("TS13","TUBE",idtmed[12],dm,3);
728
729   // Tpc Sandwich 14 - NOMEX
730
731   dm[0] += 0.07;
732   dm[1] -= 0.07;  
733
734   gMC->Gsvolu("TS14","TUBE",idtmed[6],dm,3);
735
736   // 14->13->12->TIFC
737
738   gMC->Gspos("TS14",1,"TS13",0.,0.,0.,0,"ONLY");
739   gMC->Gspos("TS13",1,"TS12",0.,0.,0.,0,"ONLY"); 
740
741   gMC->Gspos("TS12",1,"TIFC",0.,0.,170.05,0,"ONLY");
742   gMC->Gspos("TS12",2,"TIFC",0.,0.,-170.05,0,"ONLY"); 
743
744   // place this inside the inner insulator
745
746   gMC->Gspos("TIFC",1,"TIIN",0.,0.,0.,0,"ONLY");
747
748   // and now in the TPC...
749
750   gMC->Gspos("TIIN",1,"TPC ",0.,0.,0.,0,"ONLY");
751
752   //---------------------------------------------------------
753   // Tpc Inner Containment vessel - Cones
754   //---------------------------------------------------------
755
756   dm[0]=0.;
757   dm[1]=360.;
758   dm[2]=8.;
759
760   //
761
762   dm[3]=71.8;
763   dm[4]=56.9;
764   dm[5]=59.4;
765
766   //
767
768   dm[6]=73.;
769   dm[7]=56.9;
770   dm[8]=59.4;
771
772   //
773
774   dm[9]=73.;
775   dm[10]=56.9;
776   dm[11]=61.2;
777
778   //
779
780   dm[12]=73.3;
781   dm[13]=56.9;
782   dm[14]=61.2;
783
784   //
785    
786   dm[15]=73.3;
787   dm[16]=60.9;
788   dm[17]=61.2;
789
790   // 
791
792   dm[18]=253.6;
793   dm[19]=65.6;
794   dm[20]=65.9; 
795
796   //
797
798   dm[21]=253.6;
799   dm[22]=65.6;
800   dm[23]=74.6;
801
802   //
803
804   dm[24]=256.6;
805   dm[25]=65.6;
806   dm[26]=74.6;
807
808   gMC->Gsvolu("TICC","PCON",idtmed[4],dm,27);
809
810   Float_t phi1,phi2,phi3,theta1,theta2,theta3; // rotation angles
811
812   // reflection matrix
813   
814   theta1 = 90.;
815   phi1   = 0.;
816   theta2 = 90.;
817   phi2   = 270.;
818   theta3 = 180.;
819   phi3   = 0.;
820
821   AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
822
823   gMC->Gspos("TICC",1,"TPC ",0.,0.,0.,0,"ONLY");
824   gMC->Gspos("TICC",2,"TPC ",0.,0.,0.,idrotm[nRotMat],"ONLY");
825
826
827   //---------------------------------------------------------
828   // Tpc Inner Containment vessel - Middle part -Al
829   //---------------------------------------------------------
830
831   dm[0]=0.;
832   dm[1]=360.;
833   dm[2]=6.;
834
835   //
836
837   dm[3]=-71.6;
838   dm[4]=60.2;
839   dm[5]=61.2;
840
841   //
842
843   dm[6]=-69.1;
844   dm[7]=60.2;
845   dm[8]=61.2;
846
847   //
848
849   dm[9]=-69.1;
850   dm[10]=60.6224;
851   dm[11]=61.2;  
852
853   //
854
855   dm[12]=69.1;
856   dm[13]=60.6224;
857   dm[14]=61.2;
858
859   //
860
861   dm[15]=69.1;
862   dm[16]=60.2;
863   dm[17]=61.2;
864
865   //
866
867   dm[18]=71.6;
868   dm[19]=60.2;
869   dm[20]=61.2;
870
871   gMC->Gsvolu("TICM","PCON",idtmed[4],dm,21);
872
873   // Tpc Sandwich 15 - Al
874
875   dm[0]=60.6224;
876   dm[1]=61.2;
877   dm[2]=70.1;
878
879   gMC->Gsvolu("TS15","TUBE",idtmed[4],dm,3);
880
881   // Tpc Sandwich 16 -  epoxy glue
882
883   dm[0] += 5.e-3;
884   dm[1] -= 5.e-3;
885
886   gMC->Gsvolu("TS16","TUBE",idtmed[14],dm,3);
887
888   // Tpc Sandwich 17 - Tedlar
889
890   dm[0] += 0.01;
891   dm[1] -= 0.01;
892
893   gMC->Gsvolu("TS17","TUBE",idtmed[9],dm,3);
894
895   // Tpc Sandwich 18 - carbon fiber
896
897   dm[0] += 3.8e-3;
898   dm[1] -= 3.8e-3;
899
900   gMC->Gsvolu("TS18","TUBE",idtmed[15],dm,3);  
901
902   // Tpc Sandwich 19 - Nomex
903
904   dm[0] += 0.02;
905   dm[1] -= 0.02;
906
907   gMC->Gsvolu("TS19","TUBE",idtmed[6],dm,3); 
908
909   // 19->18->17->16->15-> TICM
910
911   gMC->Gspos("TS19",1,"TS18",0.,0.,0.,0,"ONLY"); 
912   gMC->Gspos("TS18",1,"TS17",0.,0.,0.,0,"ONLY");
913   gMC->Gspos("TS17",1,"TS16",0.,0.,0.,0,"ONLY");
914   gMC->Gspos("TS16",1,"TS15",0.,0.,0.,0,"ONLY");
915
916   gMC->Gspos("TS15",1,"TICM ",0.,0.,0.,0,"ONLY");
917  
918
919   // TPc inner cont. vessel Joints
920
921   dm[0]=60.2;
922   dm[1]=61.2;
923   dm[2]=0.5;
924
925   gMC->Gsvolu("TPJ1","TUBE",idtmed[4],dm,3);
926
927   gMC->Gspos("TPJ1",1,"TPC ",0.,0.,72.3,0,"ONLY");
928   gMC->Gspos("TPJ1",2,"TPC ",0.,0.,-72.3,0,"ONLY");
929
930   //
931
932   dm[0]=0.;
933   dm[1]=360.;
934   dm[2]=4.;
935
936   //
937
938   dm[3]=70.8;
939   dm[4]=58.4;
940   dm[5]=60.1;
941
942   //
943
944   dm[6]=71.2;
945   dm[7]=58.4;
946   dm[8]=60.1;
947
948   //
949
950   dm[9]=71.2;
951   dm[10]=58.4;
952   dm[11]=59.4;
953
954   //
955
956   dm[12]=71.6;
957   dm[13]=58.4;
958   dm[14]=59.4;
959
960   gMC->Gsvolu("TPJ2","PCON",idtmed[4],dm,15);
961
962   gMC->Gspos("TPJ2",1,"TPC ",0.,0.,0.,0,"ONLY");
963   gMC->Gspos("TPJ2",2,"TPC ",0.,0.,0.,idrotm[nRotMat],"ONLY");
964
965
966
967   // Tpc Inner Containment vessel Seal (Viton, I use Lexan for a time being)
968
969   dm[0]=58.4;
970   dm[1]=61.2;
971   dm[2]=0.1;
972
973   gMC->Gsvolu("TICS","TUBE",idtmed[14],dm,3);
974
975   gMC->Gspos("TICS",1,"TPC ",0.,0.,71.7,0,"ONLY");
976   gMC->Gspos("TICS",2,"TPC ",0.,0.,-71.7,0,"ONLY"); 
977
978   // TICM -> TPC
979
980   gMC->Gspos("TICM",1,"TPC ",0.,0.,0.,0,"ONLY");
981
982   //
983
984   nRotMat++; // prepare for the next rotation matrix 
985
986   //---------------------------------------------------------
987   //  Tpc Dift Gas volume Nonsensitive (Ne-CO2 90/10)
988   //  and its daughters (HV membrane, rods, readout chambers)
989   //---------------------------------------------------------
990
991   dm[0]= 79.2;
992   dm[1]= 258.0;
993   dm[2]= 253.6;
994
995   gMC->Gsvolu("TDGN","TUBE",idtmed[1],dm,3); 
996
997   // sector opening angles
998
999   Float_t innerOpenAngle = fTPCParam->GetInnerAngle();
1000   Float_t outerOpenAngle = fTPCParam->GetOuterAngle();
1001
1002   // sector angle shift
1003
1004   Float_t innerAngleShift = fTPCParam->GetInnerAngleShift();
1005
1006
1007   // All above parameters are identical for inner and outer
1008   // sectors. The distinction is kept for the historical reasons
1009   // and eventually will disappear.
1010
1011   Float_t tanAlpha = TMath::Tan(0.5*innerOpenAngle);
1012   Float_t cosAlpha = TMath::Sqrt(1.+tanAlpha*tanAlpha);
1013   Float_t space;
1014
1015   //-------------------------------------------------------------------------
1016   //   Tpc Inner Readout Chambers 
1017   //-------------------------------------------------------------------------
1018
1019   dm[0]= 14.483;
1020   dm[1]= 23.3345; 
1021   dm[2]= 1.6; // thickness
1022   dm[3]= 25.1;
1023
1024   gMC->Gsvolu("TIRC","TRD1",idtmed[4],dm,4);
1025
1026   // this volume will be positioned in the empty space
1027   // of the end-cap to avoid overlaps
1028
1029   dm[0]= 13.7305;
1030   dm[1]= 21.1895;
1031   dm[2]= 2.25;
1032   dm[3]= 21.15;
1033
1034   gMC->Gsvolu("TIC1","TRD1",idtmed[4],dm,4);
1035
1036
1037   //------------------------------------------------
1038   // Tpc Inner readout chamber Pad Plane
1039   //------------------------------------------------
1040
1041   dm[0]= 14.483;
1042   dm[1]= 23.3345;
1043   dm[2]= 0.5;
1044   dm[3]= 25.1;
1045
1046   gMC->Gsvolu("TIPP","TRD1",idtmed[12],dm,4);
1047
1048   // 
1049
1050   dm[0] -= 1.218511934;
1051   dm[1] -= 1.218511934;
1052   dm[2] = 0.35;
1053
1054   gMC->Gsvolu("TIC3","TRD1",idtmed[1],dm,4);
1055
1056   gMC->Gspos("TIC3",1,"TIPP",0.,0.15,0.,0,"ONLY");
1057
1058   gMC->Gspos("TIPP",1,"TIRC",0.,1.1,0.,0,"ONLY");
1059
1060
1061   //----------------------------------------------
1062   // Tpc Readout Chambers Empty spaces - for both
1063   // inner and outer sectors
1064   //----------------------------------------------
1065
1066   gMC->Gsvolu("TRCE","TRD1",idtmed[0],dm,0);
1067
1068   // Inner sector - 4 spaces
1069
1070
1071   dm[3] = 4.7625;
1072   dm[0] = 12.472;
1073
1074   Float_t rr = 90.52;
1075   Float_t zz;
1076
1077   zz= -12.7875;
1078   
1079   space = rr*tanAlpha-dm[0];
1080
1081   for(Int_t nsLow=0;nsLow<4;nsLow++){
1082
1083     rr += 9.525;
1084     dm[1]= rr*tanAlpha - space;  
1085
1086     dm[2]=0.8;
1087
1088     gMC->Gsposp("TRCE",nsLow+1,"TIRC",0.,-0.8,zz,0,"ONLY",dm,4);
1089
1090     //
1091
1092     dm[2] = 1.2;
1093
1094     gMC->Gsposp("TRCE",nsLow+5,"TIC1",0.,1.05,zz-2.1,0,"ONLY",dm,4);
1095
1096     rr += 0.4;
1097     dm[0] = rr*tanAlpha - space;
1098     zz += (0.4+9.525); 
1099
1100   }
1101
1102   dm[0]= 12.472;
1103   // dm[1] - this is the dm[1] from the previous TRCE
1104   dm[2]= 1.05;
1105   dm[3]= 19.65;
1106
1107   gMC->Gsposp("TRCE",9,"TIC1",0.,-1.2,0.,0,"ONLY",dm,4);   
1108
1109   //
1110   // TPc Space for Connectors
1111   //
1112
1113   dm[0]= .3;
1114   dm[1]= .3;
1115   dm[2]= 4.5;
1116
1117   gMC->Gsvolu("TPSC","BOX ",idtmed[0],dm,3);
1118
1119   // TPC Connectors
1120
1121   dm[0]= .25;
1122   dm[1]= .15;
1123   dm[2]= 3.75;
1124
1125   gMC->Gsvolu("TPCC","BOX ",idtmed[13],dm,3); 
1126
1127   gMC->Gspos("TPCC",1,"TPSC",0.,0.15,0.,0,"ONLY");
1128
1129   zz = -12.7875;
1130
1131
1132   Float_t alpha;
1133   Float_t astep;
1134
1135   // inner part of the inner sector - 2 x 20 holes
1136   
1137   astep = 20.00096874/19.;
1138
1139   alpha = 10.00048437-astep;
1140
1141   Float_t x1,x2;
1142
1143     x1 = 13.31175725;
1144     x1 -= 0.996357832; 
1145
1146     x2 = 15.06180253;
1147     x2 -= 1.163028812;
1148
1149   Int_t ncon;
1150
1151   for(ncon=0;ncon<20;ncon++){
1152
1153     phi1 = 0.;
1154     theta1 = 90.+alpha;
1155     phi2=90.;
1156     theta2 = 90.;
1157     phi3 = (alpha>0) ? 0. : 180.;
1158     theta3 = TMath::Abs(alpha);
1159
1160     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1161
1162  
1163
1164     gMC->Gspos("TPSC",ncon+1,"TIRC",x1,0.3,-12.7875,idrotm[nRotMat],"ONLY");
1165     gMC->Gspos("TPSC",ncon+21,"TIRC",x2,0.3,-2.8625,idrotm[nRotMat],"ONLY");
1166
1167
1168     x1 -= 1.296357833;
1169     x2 -= 1.463028812;
1170
1171     alpha -= astep;   
1172     nRotMat++; 
1173
1174   }
1175
1176   // outer part of the inner sector - 2 x 25 holes
1177
1178    astep = 20.00096874/24.; 
1179    alpha = 10.00048437-astep;
1180
1181    x1 = 16.81184781;
1182    x1 -= 1.016295986;
1183
1184    x2 = 18.5618931;
1185    x2 -= 1.150914854;
1186
1187   for(ncon=0;ncon<25;ncon++){
1188
1189     phi1 = 0.;
1190     theta1 = 90.+alpha;
1191     phi2=90.;
1192     theta2 = 90.;
1193     phi3 = (alpha>0) ? 0. : 180.;
1194     theta3 = TMath::Abs(alpha);
1195
1196     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1197
1198  
1199
1200     gMC->Gspos("TPSC",ncon+41,"TIRC",x1,0.3,7.0625,idrotm[nRotMat],"ONLY");
1201     gMC->Gspos("TPSC",ncon+66,"TIRC",x2,0.3,16.9875,idrotm[nRotMat],"ONLY");
1202
1203
1204     x1 -= 1.316295986;
1205     x2 -= 1.450914854;
1206
1207     alpha -= astep;   
1208     nRotMat++; 
1209
1210   }  
1211
1212   //--------------------------------------------------------------------------
1213   //  TPC Outer Readout Chambers
1214   //  this is NOT a final design
1215   //--------------------------------------------------------------------------
1216
1217   dm[0]= 23.3875;
1218   dm[1]= 43.524;
1219   dm[2]= 1.5; //thickness
1220   dm[3]= 57.1;
1221
1222   gMC->Gsvolu("TORC","TRD1",idtmed[4],dm,4);
1223
1224   //------------------------------------------------
1225   // Tpc Outer readout chamber Pad Plane
1226   //------------------------------------------------
1227
1228   dm[2]= 0.5;
1229
1230   gMC->Gsvolu("TOPP","TRD1",idtmed[12],dm,4);
1231
1232   dm[0] -= 1.218511934;
1233   dm[1] -= 1.218511934;
1234   dm[2] = 0.35;
1235
1236   gMC->Gsvolu("TOC3","TRD1",idtmed[1],dm,4);
1237
1238   gMC->Gspos("TOC3",1,"TOPP",0.,0.15,0.,0,"ONLY");
1239
1240   gMC->Gspos("TOPP",1,"TORC",0.,1.0,0.,0,"ONLY");
1241
1242   // empty space
1243
1244   dm[0]= 21.035;
1245   dm[1]= 38.7205;
1246   dm[2]= 0.7; 
1247   dm[3]= 50.15;
1248
1249   gMC->Gsposp("TRCE",10,"TORC",0.,-0.8,-2.15,0,"ONLY",dm,4);  
1250
1251   dm[0]= 22.2935;
1252   dm[1]= 40.5085;
1253   dm[2]= 2.25;
1254   dm[3]= 51.65;
1255
1256   gMC->Gsvolu("TOC1","TRD1",idtmed[4],dm,4);
1257
1258   dm[0]= 21.35;
1259   dm[1]= 38.7205;
1260   dm[2]= 2.25;
1261   dm[3]= 50.15;
1262
1263   gMC->Gsposp("TRCE",11,"TOC1",0.,0.,0.,0,"ONLY",dm,4);
1264
1265   //-----------------------------------------------
1266   // Tpc Services Support Wheel
1267   //-----------------------------------------------
1268
1269   dm[0]=0.;
1270   dm[1]=360.;
1271   dm[2]=18.;
1272   dm[3]=2.;
1273
1274   dm[4]= -5.;
1275   dm[5]= 77.017;
1276   dm[6]= 255.267;
1277
1278   dm[7]= 5.;
1279   dm[8]= dm[5];
1280   dm[9]= dm[6];
1281
1282   gMC->Gsvolu("TSSW","PGON",idtmed[4],dm,10);
1283
1284   // Tpc Services Wheel Cover
1285
1286   dm[4]= -0.5;
1287   dm[7]= 0.5;
1288
1289   gMC->Gsvolu("TSWC","PGON",idtmed[4],dm,10);
1290
1291   // Tpc Service wheel Cover Empty space
1292    
1293   dm[0]= 10.99;
1294   dm[1]= 39.599;
1295   dm[2]= .5;
1296   dm[3]= 81.125;
1297
1298   gMC->Gsvolu("TSCE","TRD1",idtmed[0],dm,4);
1299
1300   // Tpc services Wheel Empty Spaces
1301
1302   dm[0]= 13.18017507;
1303   dm[1]= 44.61045938;
1304   dm[2]= 4.;
1305   dm[3]= 89.125;
1306
1307   gMC->Gsvolu("TWES","TRD1",idtmed[0],dm,4);
1308
1309   // Tpc Services Wheel Bars
1310
1311   gMC->Gsvolu("TSWB","TRD1",idtmed[4],dm,0);
1312
1313   // bars-> TWES
1314
1315   dm[2]= 4.;
1316   dm[3]= .4;
1317
1318   dm[0]= 13.8149522;
1319   dm[1]= 13.95601379;
1320   
1321   gMC->Gsposp("TSWB",1,"TWES",0.,0.,-85.125,0,"ONLY",dm,4);
1322
1323   dm[0]= 43.83462067; 
1324   dm[1]= 43.97568225;
1325
1326   gMC->Gsposp("TSWB",2,"TWES",0.,0.,85.125,0,"ONLY",dm,4);
1327
1328   // TPc ELectronics - right now 30% X0 Si
1329
1330   dm[0]= 14.03813696;
1331   dm[1]= 43.3524075;
1332   dm[2]= 1.404;
1333   dm[3]= 83.125;
1334
1335   gMC->Gsvolu("TPEL","TRD1",idtmed[11],dm,4);
1336   gMC->Gspos("TPEL",1,"TWES",0.,0.,0.,0,"ONLY");
1337
1338   //--------------------------------------------------------------------------
1339   //  End caps
1340   //--------------------------------------------------------------------------
1341
1342   // TPc Main Wheel - Al
1343
1344   dm[0]= 74.9;
1345   dm[1]= 264.4;
1346   dm[2]= 3.0;
1347
1348   gMC->Gsvolu("TPMW","TUBE",idtmed[4],dm,3);
1349
1350   //--------------------------------------------------------------------------
1351   //  Tpc Empty Space for the Readout chambers
1352   //--------------------------------------------------------------------------  
1353
1354   Float_t rLow= 86.2;
1355   Float_t rUp= 243.5;
1356   Float_t dR = 0.5*(rUp-rLow);
1357
1358   space= 1.5/cosAlpha; // wheel ribs are 3.0 cm wide
1359
1360   dm[0]= rLow*tanAlpha-space;
1361   dm[1]= rUp*tanAlpha-space;
1362   dm[2] = 3.0;
1363   dm[3]= dR;
1364
1365   gMC->Gsvolu("TESR","TRD1",idtmed[0],dm,4);
1366
1367   // TIC1->TESR
1368
1369   gMC->Gspos("TIC1",1,"TESR",0.,0.75,-dR+23.97,0,"ONLY");
1370
1371   // TOC1->TESR
1372
1373   gMC->Gspos("TOC1",1,"TESR",0.,0.75,dR-55.02,0,"ONLY");
1374
1375   // Tpc Empty Space Bars - Al (daughters of TESR)
1376
1377   Float_t zBar;
1378
1379   gMC->Gsvolu("TESB","TRD1",idtmed[4],dm,0);
1380
1381   // lower bar
1382
1383   dm[0]= rLow*tanAlpha-space;
1384   dm[1]= 88.7*tanAlpha-space;
1385   dm[2]= 2.25;
1386   dm[3]= 1.275;
1387
1388   zBar = -dR+dm[3];
1389
1390   gMC->Gsposp("TESB",1,"TESR",0.,0.75,zBar,0,"ONLY",dm,4);
1391
1392   // middle bar
1393
1394   dm[0]= 131.65*tanAlpha-space;
1395   dm[1]= 136.5*tanAlpha-space;
1396   dm[3]= 2.425;
1397
1398   zBar = -dR +131.65+dm[3]-rLow;
1399
1400   gMC->Gsposp("TESB",2,"TESR",0.,0.75,zBar,0,"ONLY",dm,4);  
1401
1402   // upper bar
1403
1404   dm[0]= 240.4*tanAlpha-space;
1405   dm[1]= rUp*tanAlpha-space;
1406   dm[3]= 1.55;
1407
1408   zBar = dR-dm[3];
1409
1410   gMC->Gsposp("TESB",3,"TESR",0.,0.75,zBar,0,"ONLY",dm,4);
1411
1412   //------------------------------------------------------
1413   //  TPc Lower "S" Sectors 
1414   //------------------------------------------------------
1415
1416
1417   Float_t inSecLowEdge = fTPCParam->GetInnerRadiusLow();
1418   Float_t inSecUpEdge =  fTPCParam->GetInnerRadiusUp();
1419
1420   dm[0] = inSecLowEdge*TMath::Tan(0.5*innerOpenAngle)-0.01;
1421   dm[1] = inSecUpEdge*TMath::Tan(0.5*innerOpenAngle)-0.01;
1422   dm[2] = 0.5*(250. - 5.e-3);
1423   dm[3] = 0.5*(inSecUpEdge-inSecLowEdge);  
1424
1425   gMC->Gsvolu("TPLS", "TRD1", idtmed[2], dm, 4); // sensitive 
1426
1427
1428   //----------------------------------------------------------
1429   //  TPc Upper Sectors
1430   //----------------------------------------------------------
1431
1432   Float_t ouSecLowEdge = fTPCParam->GetOuterRadiusLow();
1433   Float_t ouSecUpEdge = fTPCParam->GetOuterRadiusUp();
1434
1435   dm[0] = ouSecLowEdge*TMath::Tan(0.5*outerOpenAngle)-0.01;  
1436   dm[1] = ouSecUpEdge*TMath::Tan(0.5*outerOpenAngle)-0.01;  
1437   dm[2] = 0.5*(250. - 5.e-3);
1438   dm[3] = 0.5*(ouSecUpEdge-ouSecLowEdge);
1439
1440   gMC->Gsvolu("TPUS", "TRD1", idtmed[2], dm, 4); // sensitive
1441
1442
1443
1444   // sensitive strips
1445
1446     gMC->Gsvolu("TPSS","TRD1",idtmed[2],dm,0); // sensitive
1447
1448     Int_t nofStrips,nstr;
1449     Float_t r1,r2,zs;
1450     Float_t stripThick = 0.01; // 100 microns
1451     Float_t deadSpace;
1452
1453     // inner sector
1454
1455
1456     // if all lower sectors selected define only 1 strip
1457
1458     nofStrips=((fSecAL <0)||(fSecAL>=0 && fSens<0)) ? 1 : fTPCParam->GetNRowLow(); 
1459     deadSpace = fTPCParam->GetInnerWireMount();
1460
1461     dm[2] = 0.5*(250. - 5.e-3);
1462     dm[3] = 0.5 * stripThick;
1463
1464     for(nstr=0;nstr<nofStrips;nstr++){
1465
1466       r1 = fTPCParam->GetPadRowRadiiLow(nstr);
1467       r2 = r1 + stripThick;     
1468       dm[0] = r1 * TMath::Tan(0.5*innerOpenAngle) - deadSpace;
1469       dm[1] = r2 * TMath::Tan(0.5*innerOpenAngle) - deadSpace;
1470       zs = -inSecLowEdge -0.5*(inSecUpEdge-inSecLowEdge);
1471       zs += r1;
1472       zs += dm[3];
1473     
1474       gMC->Gsposp("TPSS", nstr+1, "TPLS", 0., 0., zs, 0, "ONLY", dm, 4);
1475
1476
1477     }
1478
1479     // strips only if several upper sectors selected end fSens > 0
1480
1481     if(fSecAU >=0 && fSens >0){
1482
1483     Int_t nsSave = nofStrips;
1484
1485     // outer sector
1486
1487     nofStrips = fTPCParam->GetNRowUp();
1488     deadSpace = fTPCParam->GetOuterWireMount();
1489
1490     dm[2] = 0.5*(250. - 5.e-3);
1491     dm[3] = 0.5 * stripThick;
1492
1493   
1494     for(nstr=0;nstr<nofStrips;nstr++){
1495     
1496       r1 = fTPCParam->GetPadRowRadiiUp(nstr); 
1497       r2 = r1 + stripThick;
1498       dm[0] = r1 * TMath::Tan(0.5*outerOpenAngle) - deadSpace;
1499       dm[1] = r2 * TMath::Tan(0.5*outerOpenAngle) - deadSpace;
1500       zs = -ouSecLowEdge -0.5*(ouSecUpEdge-ouSecLowEdge);
1501       zs += r1;
1502       zs += dm[3];
1503
1504       gMC->Gsposp("TPSS", nstr+1+nsSave, "TPUS", 0., 0., zs, 0, "ONLY", dm, 4);
1505
1506      }    
1507     }    
1508
1509
1510   //-------------------------------------------------------
1511   //  positioning of the empty spaces into the main wheel
1512   //  and readout chambers and sectors into the drift gas
1513   //-------------------------------------------------------
1514
1515   Float_t rCenter,xc,yc;
1516   Float_t rInner,rOuter; // center of the inner and outer chamber
1517
1518   rCenter = rLow+dR;
1519
1520   rInner = 108.07;
1521   rOuter = 190.68;
1522
1523
1524   for(Int_t ns=0; ns<nInnerSector;ns++){
1525
1526     phi1 = ns * innerOpenAngle + innerAngleShift;
1527     phi1 *= kRaddeg; // in degrees
1528
1529     phi1 = (Float_t)TMath::Nint(phi1) + 270.;
1530
1531     if (phi1 > 360.) phi1 -= 360.;
1532
1533     theta1 = 90.;
1534     phi2   = 90.;
1535     theta2 = 180.;
1536     phi3   = ns * innerOpenAngle + innerAngleShift;
1537     phi3 *= kRaddeg; // in degrees
1538
1539     phi3 = (Float_t)TMath::Nint(phi3);
1540       
1541     if(phi3 > 360.) phi3 -= 360.;
1542
1543     theta3 = 90.;
1544
1545     // "holes"->End plate
1546
1547     xc = rCenter*TMath::Cos(phi3*kDegrad);
1548     yc = rCenter*TMath::Sin(phi3*kDegrad);
1549
1550     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1551
1552     gMC->Gspos("TESR",ns+1,"TPMW",xc,yc,0.,idrotm[nRotMat],"ONLY");
1553
1554     // TSCE->TSWC (services wheel volumes)
1555
1556     xc = 166.142*TMath::Cos(phi3*kDegrad);
1557     yc = 166.142*TMath::Sin(phi3*kDegrad);
1558
1559     gMC->Gspos("TSCE",ns+1,"TSWC",xc,yc,0.,idrotm[nRotMat],"ONLY");
1560     gMC->Gspos("TWES",ns+1,"TSSW",xc,yc,0.,idrotm[nRotMat],"ONLY");
1561
1562
1563     // readout chambers->TDGN (drift gas)
1564
1565     xc = rInner*TMath::Cos(phi3*kDegrad);
1566     yc = rInner*TMath::Sin(phi3*kDegrad);
1567
1568     gMC->Gspos("TIRC",ns+1,"TDGN",xc,yc,252.,idrotm[nRotMat],"ONLY");
1569
1570     // here lower sectors 
1571
1572     if(fSecAL <0){
1573
1574       // all lower sectors are positioned
1575
1576       gMC->Gspos("TPLS",ns+1,"TDGN",xc,yc,125.0025,idrotm[nRotMat],"ONLY");
1577       gMC->
1578         Gspos("TPLS",ns+nInnerSector+1,"TDGN",xc,yc,-125.0025,idrotm[nRotMat],"ONLY");
1579     }
1580     else{
1581
1582       // only selected sectors are positioned (up to 6 sectors)
1583
1584       for(Int_t sel=0;sel<6;sel++){
1585
1586         if(fSecLows[sel] == ns){
1587           gMC->Gspos("TPLS",ns+1,"TDGN",xc,yc,125.0025,idrotm[nRotMat],"ONLY");
1588         }
1589         else if(fSecLows[sel] == ns+nInnerSector){
1590          gMC->
1591          Gspos("TPLS",ns+nInnerSector+1,"TDGN",xc,yc,-125.0025,idrotm[nRotMat],"ONLY");
1592         }
1593       }
1594     } // lower sectors finished
1595
1596     
1597     xc = rOuter*TMath::Cos(phi3*kDegrad);
1598     yc = rOuter*TMath::Sin(phi3*kDegrad);
1599
1600     gMC->Gspos("TORC",ns+1,"TDGN",xc,yc,252.1,idrotm[nRotMat],"ONLY");
1601
1602     // here upper sectors 
1603
1604     if(fSecAU <0){
1605
1606       // all upper sectors
1607
1608       gMC->Gspos("TPUS",ns+1,"TDGN",xc,yc,125.0025,idrotm[nRotMat],"ONLY");
1609       gMC->
1610         Gspos("TPUS",ns+nOuterSector+1,"TDGN",xc,yc,-125.0025,idrotm[nRotMat],"ONLY");
1611     }
1612     else{
1613
1614       // only selected sectors (up to 12)
1615
1616       for(Int_t sel=0;sel<12;sel++){
1617         if(fSecUps[sel] == ns+2*nInnerSector){
1618           gMC->Gspos("TPUS",ns+1,"TDGN",xc,yc,125.0025,idrotm[nRotMat],"ONLY");
1619         }         
1620         else if(fSecUps[sel] == ns+2*nInnerSector+nOuterSector){
1621          gMC->
1622           Gspos("TPUS",ns+nOuterSector+1,"TDGN",xc,yc,-125.0025,idrotm[nRotMat],"ONLY"); 
1623         }
1624       }
1625     } // upper sectors finished
1626
1627
1628     nRotMat++;
1629
1630     theta2 = 0.; // reflection
1631
1632     AliMatrix(idrotm[nRotMat], theta1, phi1, theta2, phi2, theta3, phi3);
1633
1634     xc = rInner*TMath::Cos(phi3*kDegrad);
1635     yc = rInner*TMath::Sin(phi3*kDegrad);
1636
1637     gMC->Gspos("TIRC",ns+nInnerSector+1,"TDGN",xc,yc,-252.,idrotm[nRotMat],"ONLY");
1638
1639     xc = rOuter*TMath::Cos(phi3*kDegrad);
1640     yc = rOuter*TMath::Sin(phi3*kDegrad);
1641
1642     gMC->Gspos("TORC",ns+nOuterSector+1,"TDGN",xc,yc,-252.1,idrotm[nRotMat],"ONLY");
1643
1644     nRotMat++;
1645
1646   } 
1647   // TPMW->TPC
1648
1649   gMC->Gspos("TPMW",1,"TPC ",0.,0.,256.6,0,"ONLY");
1650   gMC->Gspos("TPMW",2,"TPC ",0.,0.,-256.6,idrotm[0],"ONLY");
1651
1652   //---------------------------------------------------------
1653   //  Tpc High Voltage Membrane - 100 microns of mylar
1654   //---------------------------------------------------------
1655
1656   dm[0]=82.8;
1657   dm[1]=252.;
1658   dm[2]=0.005;
1659
1660   gMC->Gsvolu("THVM","TUBE",idtmed[8],dm,3);
1661
1662   gMC->Gspos("THVM",1,"TDGN",0.,0.,0.,0,"ONLY");
1663
1664   // Tpc High Voltage membrane Holders
1665
1666   gMC->Gsvolu("THVH","TUBE",idtmed[4],dm,0);
1667
1668   
1669
1670   // inner
1671
1672   dm[0]=79.3;
1673   dm[1]=82.8;
1674   dm[2]=0.2;
1675
1676   gMC->Gsposp("THVH",1,"TDGN",0.,0.,0.,0,"ONLY",dm,3);
1677   
1678   // outer
1679
1680   dm[0]= 252.;
1681   dm[1]= 257.9;
1682   dm[2]= 0.4;
1683
1684   gMC->Gsposp("THVH",2,"TDGN",0.,0.,0.,0,"ONLY",dm,3);
1685
1686   //----------------------------------------------------------
1687   // TPc Support Rods - MAKROLON
1688   //----------------------------------------------------------
1689
1690   dm[0]= 0.9;
1691   dm[1]= 1.2;
1692
1693   gMC->Gsvolu("TPSR","TUBE",idtmed[7],dm,0); // inner and outer rods differ
1694
1695
1696   for(Int_t nrod=0;nrod<18;nrod++){
1697     Float_t angle=innerOpenAngle*(Float_t)nrod;
1698
1699     xc=81.5*TMath::Cos(angle);
1700     yc=81.5*TMath::Sin(angle); 
1701
1702     dm[2]=126.7;
1703
1704     gMC->Gsposp("TPSR",nrod+1,"TDGN",xc,yc,126.9,0,"ONLY",dm,3); 
1705     gMC->Gsposp("TPSR",nrod+19,"TDGN",xc,yc,-126.9,0,"ONLY",dm,3);
1706
1707     dm[2]=126.6;
1708
1709     xc=254.25*TMath::Cos(angle);
1710     yc=254.25*TMath::Sin(angle);   
1711       
1712     // rod number 54 contans the HV cable
1713
1714     if(nrod<17) {
1715       gMC->Gsposp("TPSR",nrod+37,"TDGN",xc,yc,127.,0,"ONLY",dm,3);
1716       gMC->Gsposp("TPSR",nrod+54,"TDGN",xc,yc,-127.,0,"ONLY",dm,3);
1717     }
1718     
1719   }
1720
1721   //----------------------------------------------------------
1722   // Tpc High Voltage Rod - MAKROLON + Copper cable
1723   //----------------------------------------------------------
1724
1725   // rod with cable (Left)
1726
1727   dm[0]=0.;
1728   dm[1]=2.25;
1729   dm[2]=126.6;
1730
1731   gMC->Gsvolu("THVL","TUBE",idtmed[7],dm,3);
1732
1733   // HV cable
1734  
1735   dm[0]=0.;
1736   dm[1]=0.3;
1737   dm[2]=126.6;
1738
1739   gMC->Gsvolu("THVC","TUBE",idtmed[10],dm,3);  
1740
1741   // empty space
1742
1743   dm[0]=0.3;
1744   dm[1]=1.;
1745   dm[2]=126.6;
1746
1747   gMC->Gsvolu("THVE","TUBE",idtmed[1],dm,3);
1748
1749   gMC->Gspos("THVC",1,"THVL",0.,0.,0.,0,"ONLY");
1750   gMC->Gspos("THVE",1,"THVL",0.,0.,0.,0,"ONLY");
1751
1752   // rod without cable
1753
1754   dm[0]=1.8;
1755   dm[1]=2.25;
1756   dm[2]=126.6;
1757
1758   gMC->Gsvolu("THVR","TUBE",idtmed[7],dm,3);
1759
1760   gMC->Gspos("THVL",1,"TDGN",xc,yc,-127.,0,"ONLY");  
1761   gMC->Gspos("THVR",1,"TDGN",xc,yc,127.,0,"ONLY");
1762
1763   gMC->Gspos("TDGN",1,"TPC ",0.,0.,0.,0,"ONLY"); 
1764  
1765   // services wheel cover -> wheel
1766
1767
1768   gMC->Gspos("TSWC",1,"TSSW",0.,0.,4.5,0,"ONLY");
1769   gMC->Gspos("TSWC",2,"TSSW",0.,0.,-4.5,0,"ONLY");
1770
1771
1772   // put the wheel into the TPC
1773
1774   gMC->Gspos("TSSW",1,"TPC ",0.,0.,278.7,0,"ONLY");
1775   gMC->Gspos("TSSW",2,"TPC ",0.,0.,-278.7,0,"ONLY");
1776
1777   //
1778
1779   gMC->Gsord("TPMW",6);
1780   gMC->Gsord("TSSW",6);
1781   gMC->Gsord("TSWC",6);
1782   if(fSecAL >=0)  gMC->Gsord("TPLS",3);
1783   if(fSecAU >=0 && fSens >0)  gMC->Gsord("TPUS",3);
1784   gMC->Gsord("TDGN",6);
1785
1786   // put the TPC into ALIC (main mother volume)
1787
1788   gMC->Gspos("TPC ",1,"ALIC",0.,0.,0.,0,"ONLY");
1789
1790  
1791
1792 } // end of function
1793  
1794 //_____________________________________________________________________________
1795 void AliTPCv2::DrawDetector()
1796 {
1797   //
1798   // Draw a shaded view of the Time Projection Chamber version 1
1799   //
1800
1801   // Set everything unseen
1802   gMC->Gsatt("*", "seen", -1);
1803   // 
1804   // Set ALIC mother transparent
1805   gMC->Gsatt("ALIC","SEEN",0);
1806   //
1807   // Set the volumes visible
1808   //
1809
1810   gMC->Gsatt("TPC ","SEEN",0);
1811   gMC->Gsatt("TOIN","SEEN",1);
1812   gMC->Gsatt("TOIN","COLO",7);
1813   gMC->Gsatt("TOCV","SEEN",1);
1814   gMC->Gsatt("TOCV","COLO",4);
1815   gMC->Gsatt("TSA1","SEEN",0);
1816   gMC->Gsatt("TSA2","SEEN",0);
1817   gMC->Gsatt("TSA3","SEEN",0);
1818   gMC->Gsatt("TSA4","SEEN",0);  
1819   gMC->Gsatt("TSA5","SEEN",0);
1820   gMC->Gsatt("TOFC","SEEN",1);
1821   gMC->Gsatt("TOFC","COLO",4);
1822   gMC->Gsatt("TSA6","SEEN",0);
1823   gMC->Gsatt("TSA7","SEEN",0);
1824   gMC->Gsatt("TSA8","SEEN",0);    
1825   gMC->Gsatt("TIIN","SEEN",1);
1826   gMC->Gsatt("TIIN","COLO",7);
1827   gMC->Gsatt("TII1","SEEN",0);
1828   gMC->Gsatt("TIFC","SEEN",1);
1829   gMC->Gsatt("TIFC","COLO",4);
1830   gMC->Gsatt("TSA9","SEEN",0); 
1831   gMC->Gsatt("TS10","SEEN",0);
1832   gMC->Gsatt("TS11","SEEN",0);
1833   gMC->Gsatt("TS12","SEEN",0);
1834   gMC->Gsatt("TS13","SEEN",0);
1835   gMC->Gsatt("TS14","SEEN",0);
1836   gMC->Gsatt("TICC","SEEN",0);
1837   gMC->Gsatt("TICM","SEEN",0);
1838   gMC->Gsatt("TS15","SEEN",0);
1839   gMC->Gsatt("TS16","SEEN",0);
1840   gMC->Gsatt("TS17","SEEN",0);
1841   gMC->Gsatt("TS18","SEEN",0);  
1842   gMC->Gsatt("TS19","SEEN",0); 
1843   gMC->Gsatt("TPJ1","SEEN",0);
1844   gMC->Gsatt("TPJ2","SEEN",0);
1845   gMC->Gsatt("TICS","SEEN",0);
1846   gMC->Gsatt("TDGN","SEEN",0); 
1847   gMC->Gsatt("TIRC","SEEN",0);
1848   gMC->Gsatt("TIC1","SEEN",1);
1849   gMC->Gsatt("TIPP","SEEN",0);
1850   gMC->Gsatt("TIC3","SEEN",0);
1851   gMC->Gsatt("TRCE","SEEN",0);
1852   gMC->Gsatt("TPSC","SEEN",0);
1853   gMC->Gsatt("TPCC","SEEN",0); 
1854   gMC->Gsatt("TORC","SEEN",0);
1855   gMC->Gsatt("TOPP","SEEN",0);
1856   gMC->Gsatt("TOC3","SEEN",0);
1857   gMC->Gsatt("TOC1","SEEN",1);
1858   gMC->Gsatt("TSSW","SEEN",1);
1859   gMC->Gsatt("TSWC","SEEN",1);
1860   gMC->Gsatt("TSSW","COLO",3);
1861   gMC->Gsatt("TSWC","COLO",3);
1862   gMC->Gsatt("TSCE","COLO",6);
1863   gMC->Gsatt("TSCE","SEEN",1);
1864   gMC->Gsatt("TWES","SEEN",0);
1865   gMC->Gsatt("TSWB","SEEN",0);
1866   gMC->Gsatt("TPEL","SEEN",0);
1867   gMC->Gsatt("TPMW","SEEN",1);
1868   gMC->Gsatt("TESR","SEEN",1);
1869   gMC->Gsatt("TPMW","COLO",12);
1870   gMC->Gsatt("TIC1","COLO",5);
1871   gMC->Gsatt("TOC1","COLO",5);
1872   gMC->Gsatt("TESB","SEEN",0);
1873   gMC->Gsatt("THVM","SEEN",1);
1874   gMC->Gsatt("THVM","COLO",11);
1875   gMC->Gsatt("THVH","SEEN",0);
1876   gMC->Gsatt("TPSR","SEEN",0); 
1877   gMC->Gsatt("THVL","SEEN",0);
1878   gMC->Gsatt("THVC","SEEN",0);  
1879   gMC->Gsatt("THVE","SEEN",0);
1880   gMC->Gsatt("THVR","SEEN",0);
1881   gMC->Gsatt("TPSS","SEEN",0);
1882   gMC->Gsatt("TPUS","SEEN",0);
1883   gMC->Gsatt("TPLS","SEEN",0);
1884
1885   //
1886   gMC->Gdopt("hide", "on");
1887   gMC->Gdopt("shad", "on");
1888   gMC->Gsatt("*", "fill", 7);
1889   gMC->SetClipBox(".");
1890   gMC->SetClipBox("TPMW",-300,300,-300,300,254.,270.);
1891   gMC->SetClipBox("TESR",-300,300,-300,300,254.,270.);
1892   gMC->SetClipBox("TSSW",-300,300,-300,300,283.,284.);
1893   gMC->SetClipBox("TSWC",-300,300,-300,300,283.,284.);
1894   gMC->SetClipBox("*", 0, 300, -300, 300, -290, 290);
1895   gMC->DefaultRange();
1896   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .025, .025);
1897   gMC->Gdhead(1111, "Time Projection Chamber");
1898   gMC->Gdman(18, 4, "MAN");
1899   gMC->Gdopt("hide","off");
1900 }
1901
1902 //_____________________________________________________________________________
1903 void AliTPCv2::CreateMaterials()
1904 {
1905   //
1906   // Define materials for version 2 of the Time Projection Chamber
1907   //
1908  
1909   AliTPC::CreateMaterials();
1910 }
1911
1912 //_____________________________________________________________________________
1913 void AliTPCv2::Init()
1914 {
1915   //
1916   // Initialises version 2 of the TPC after that it has been built
1917   //
1918
1919   Int_t *idtmed = fIdtmed->GetArray();
1920   
1921   AliTPC::Init();
1922
1923
1924   
1925   fIdSens=gMC->VolId("TPSS");  
1926
1927   fIdLSec=gMC->VolId("TPLS"); // lower sector 
1928   fIdUSec=gMC->VolId("TPUS"); // upper sector
1929
1930   gMC->SetMaxNStep(30000); // max. number of steps increased
1931
1932   gMC->Gstpar(idtmed[2],"LOSS",5); // specific energy loss
1933
1934   printf("%s: *** TPC version 2 initialized ***\n",ClassName());
1935   printf("%s: Maximum number of steps = %d\n",ClassName(),gMC->GetMaxNStep());
1936
1937   //
1938   
1939 }
1940
1941 //_____________________________________________________________________________
1942 void AliTPCv2::StepManager()
1943 {
1944   //
1945   // Called for every step in the Time Projection Chamber
1946   //
1947
1948   //
1949   // parameters used for the energy loss calculations
1950   //
1951   const Float_t kprim = 14.35; // number of primary collisions per 1 cm
1952   const Float_t kpoti = 20.77e-9; // first ionization potential for Ne/CO2
1953   const Float_t kwIon = 35.97e-9; // energy for the ion-electron pair creation 
1954  
1955  
1956   const Float_t kbig = 1.e10;
1957
1958   Int_t id,copy;
1959   Float_t hits[4];
1960   Int_t vol[2];  
1961   TLorentzVector p;
1962   
1963   vol[1]=0; // preset row number to 0
1964
1965   //
1966
1967   gMC->SetMaxStep(kbig);
1968   
1969   if(!gMC->IsTrackAlive()) return; // particle has disappeared
1970   
1971   Float_t charge = gMC->TrackCharge();
1972   
1973   if(TMath::Abs(charge)<=0.) return; // take only charged particles
1974   
1975   // check the sensitive volume
1976
1977   id = gMC->CurrentVolID(copy); // current volume Id
1978
1979   if (gMC->IsTrackEntering() && ( (id == fIdLSec) || (id == fIdUSec))){
1980     //    printf("track  %d entering volume %d\n",gAlice->CurrentTrack(),id);
1981     TLorentzVector p;
1982     TLorentzVector x;
1983     gMC->TrackMomentum(p);
1984     gMC->TrackPosition(x);
1985     AddTrackReference(gAlice->CurrentTrack(),p,x,gMC->TrackLength());
1986   }
1987
1988   if (gMC->IsTrackExiting() && ( (id == fIdLSec) || (id == fIdUSec))){
1989     //    printf("track  %d exiting volume %d\n",gAlice->CurrentTrack(),id);
1990     TLorentzVector p;
1991     TLorentzVector x;
1992     gMC->TrackMomentum(p);
1993     gMC->TrackPosition(x);
1994     AddTrackReference(gAlice->CurrentTrack(),p,x,gMC->TrackLength());
1995   }
1996
1997
1998   if(id == fIdLSec){
1999     vol[0] = copy-1; // lower sector number
2000   }
2001   else if(id == fIdUSec){
2002     vol[0] = copy+fTPCParam->GetNInnerSector()-1; // upper sector number
2003   }
2004   else if(id == fIdSens && gMC->IsTrackEntering()){
2005  
2006     // track is entering the sensitive strip
2007     
2008     vol[1]= copy-1; // row number (absolute)
2009    
2010     // sector type
2011  
2012     id = gMC->CurrentVolOffID(1,copy);
2013
2014     if(id == fIdLSec){
2015
2016       // lower sector
2017      
2018       vol[0] = copy-1; // sector number
2019
2020     }
2021     else {
2022    
2023       // upper sector
2024
2025       vol[0] = copy-1+fTPCParam->GetNInnerSector(); // sector number
2026       vol[1] -= fTPCParam->GetNRowLow(); // row number (starts also from 0)  
2027
2028     } 
2029
2030     if(vol[1] == 0){
2031   
2032       // because Jouri wants to have this
2033
2034       gMC->TrackMomentum(p);
2035       hits[0]=p[0];
2036       hits[1]=p[1];
2037       hits[2]=p[2];
2038       hits[3]=0.; // this hit has no energy loss
2039       // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
2040
2041       AddHit(gAlice->CurrentTrack(), vol,hits);  //MI change
2042
2043     }
2044
2045      gMC->TrackPosition(p);
2046      hits[0]=p[0];
2047      hits[1]=p[1];
2048      hits[2]=p[2];
2049      hits[3]=0.; // this hit has no energy loss
2050      // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
2051
2052      AddHit(gAlice->CurrentTrack(), vol,hits);  //MI change    
2053
2054   }
2055   else return;
2056     
2057   //-----------------------------------------------------------------
2058   //  charged particle is in the sensitive volume
2059   //-----------------------------------------------------------------
2060   
2061   if(gMC->TrackStep() > 0) {
2062     
2063     Int_t nel = (Int_t)(((gMC->Edep())-kpoti)/kwIon) + 1;
2064     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
2065     
2066     gMC->TrackPosition(p);
2067     hits[0]=p[0];
2068     hits[1]=p[1];
2069     hits[2]=p[2];
2070     hits[3]=(Float_t)nel;
2071     
2072     // Add this hit
2073     
2074     // new(lhits[fNhits++]) AliTPChit(fIshunt,gAlice->CurrentTrack(),vol,hits);
2075     if (fHitType&&2){
2076       gMC->TrackMomentum(p);
2077       Float_t momentum = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
2078       Float_t precision =   (momentum>0.1) ? 0.002 :0.01;
2079       fTrackHits->SetHitPrecision(precision);
2080     }
2081     AddHit(gAlice->CurrentTrack(), vol,hits);  //MI change 
2082     
2083   } 
2084   
2085   // Stemax calculation for the next step
2086   
2087   Float_t pp;
2088   TLorentzVector mom;
2089   gMC->TrackMomentum(mom);
2090   Float_t ptot=mom.Rho();
2091   Float_t betaGamma = ptot/gMC->TrackMass();
2092   
2093   Int_t pid=gMC->TrackPid();
2094   if((pid==kElectron || pid==kPositron) && ptot > 0.002)
2095     { 
2096       pp = kprim*1.58; // electrons above 20 MeV/c are on the plateau!
2097     }
2098   else
2099     {
2100
2101       betaGamma = TMath::Max(betaGamma,(Float_t)7.e-3); // protection against too small bg
2102       pp=kprim*BetheBloch(betaGamma); 
2103    
2104       if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
2105     }
2106   
2107   Double_t rnd = gMC->GetRandom()->Rndm();
2108   
2109   gMC->SetMaxStep(-TMath::Log(rnd)/pp);
2110   
2111 }
2112
2113 //_____________________________________________________________________________
2114 Float_t AliTPCv2::BetheBloch(Float_t bg)
2115 {
2116   //
2117   // Bethe-Bloch energy loss formula
2118   //
2119   const Double_t kp1=0.76176e-1;
2120   const Double_t kp2=10.632;
2121   const Double_t kp3=0.13279e-4;
2122   const Double_t kp4=1.8631;
2123   const Double_t kp5=1.9479;
2124
2125   Double_t dbg = (Double_t) bg;
2126
2127   Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
2128
2129   Double_t aa = TMath::Power(beta,kp4);
2130   Double_t bb = TMath::Power(1./dbg,kp5);
2131
2132   bb=TMath::Log(kp3+bb);
2133   
2134   return ((Float_t)((kp2-aa-bb)*kp1/aa));
2135 }
2136
2137