Position of bellow.
[u/mrichter/AliRoot.git] / CRT / AliCRT.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
19 */
20
21 ///////////////////////////////////////////////////////////////////////////////
22 //                                                                           //
23 //  Cosmic Rays ALICE Trigger                                                //
24 //  This class contains the basic functions for the Cosmic Ray ALICE         //
25 //  detector. Functions specific to one particular geometry are              //
26 //  contained in the derived classes                                         //
27 //
28 // Begin_Html
29 /*
30 <img src="picts/AliCRTClass.gif">
31 </pre>
32 <p>The responsible person for this module is
33 <a href="mailto:Enrique.Gamez.Flores@cern.ch">Enrique Gamez Flores</a>.
34 </font>
35 <pre>
36 */
37 //End_Html
38 //             
39 //
40 //                                                                           //
41 ///////////////////////////////////////////////////////////////////////////////
42
43
44 #include <iostream>
45 #include <fstream>
46
47 #include <TTree.h>
48
49
50 #include "AliMC.h"
51 #include "AliRun.h"
52 #include "AliMagF.h"
53
54 #include "AliCRT.h"
55 #include "AliCRTConstants.h"
56 #include "AliCRTdigit.h"
57 #include "AliCRThit.h"
58
59  
60 ClassImp(AliCRT)
61
62
63 static  AliCRTdigit *digits;
64  
65 //_____________________________________________________________________________
66 AliCRT::AliCRT()
67 {
68   //
69   // Default constructor for L3 magnet
70   //
71
72   fIshunt   = 1;
73   fHits     = 0;
74   fDigits   = 0;
75 }
76  
77 //_____________________________________________________________________________
78 AliCRT::AliCRT(const char *name, const char *title)
79   : AliDetector(name,title)
80 {
81   //
82   // Standard constructor for the CRT module
83   //
84
85   fIshunt       =  1; // All hits are associated with primary particles  
86
87   fHits         =  new TClonesArray("AliCRThit",400) ; 
88   fDigits       =  new TClonesArray("AliCRTdigit",400) ; 
89
90   gAlice->AddHitList(fHits);
91
92   SetMarkerColor(7);
93   SetMarkerStyle(2);
94   SetMarkerSize(0.4);
95
96 }
97
98 //_____________________________________________________________________________
99 AliCRT::~AliCRT()
100 {
101   //
102   // Standar destructor.
103   //
104   if (fHits) {
105     fHits->Delete();
106     delete fHits;
107   }
108 }
109
110 //_____________________________________________________________________________
111 void AliCRT::AddHit(Int_t track, Int_t *vol, Float_t *hits)
112 {
113   //
114   // Add a CRT hit
115   //
116   TClonesArray &lhits = *fHits;
117   new(lhits[fNhits++]) AliCRThit(fIshunt,track,vol,hits);
118 }
119
120 //_____________________________________________________________________________
121 void AliCRT::AddDigit(Int_t *tracks,Int_t *digits)
122 {
123   
124   //  Add a CRT digit to the list. Dummy function.
125   
126 }
127
128 //_____________________________________________________________________________
129 void AliCRT::Init() const
130 {
131   //
132   // Initialise ...
133   //
134
135   Int_t i;
136   //
137   if(fDebug) {
138     printf("\n%s: ",ClassName());
139     for(i=0;i<35;i++) printf("*");
140     printf(" CRT_INIT ");
141     for(i=0;i<35;i++) printf("*");
142     printf("\n%s: ",ClassName());
143     //
144     // Here the CRT initialisation code (if any!)
145     for(i=0;i<80;i++) printf("*");
146     printf("\n");
147   }
148 }
149
150 //_____________________________________________________________________________
151 void AliCRT::ResetHits ()
152 {
153   // Reset number of clusters and the cluster array for this detector
154   AliDetector::ResetHits ();
155 }
156
157 //_____________________________________________________________________________
158 void AliCRT::ResetDigits ()
159 {
160   //
161   // Reset number of digits and the digits array for this detector
162   AliDetector::ResetDigits ();
163   //
164
165
166 //____________________________________________________________________________
167 void AliCRT::FinishEvent()
168 {
169 // do nothing
170 }
171
172 //_____________________________________________________________________________
173 void AliCRT::BuildGeometry()
174 {
175   //
176   // Build simple ROOT TNode geometry for event display
177   //
178 }
179
180 //_____________________________________________________________________________
181 void AliCRT::CreateGeometry()
182 {
183   //
184   // Build simple ROOT TNode geometry for GEANT simulations
185   //
186 }
187
188 //_____________________________________________________________________________
189 void AliCRT::CreateMaterials()
190 {
191   // Magnatic field inside the pit
192   Int_t   isxfld = gAlice->Field()->Integ();
193   Float_t sxmgmx = gAlice->Field()->Max();
194
195   //Magnetic field above the Magnet.
196   Int_t xfield = 0;   // no Magnetic field.
197   Float_t xfieldm = 0;
198   Float_t xepsil = 0.1; // Tracking precission in cm. obove the pit
199
200   // --- Define the various materials for GEANT --- 
201   Float_t aconc[10] = { 1.,12.01,15.994,22.99,24.305,26.98,28.086,39.1,40.08,55.85 };
202   Float_t zconc[10] = { 1.,6.,8.,11.,12.,13.,14.,19.,20.,26. };
203   Float_t wconc[10] = { .01,.001,.529107,.016,.002,.033872,.337021,.013,.044,.014 };
204   
205   Float_t epsil, stmin, tmaxfd, deemax, stemax;
206   //
207   //     Aluminum 
208   AliMaterial(9,  "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
209   AliMaterial(29, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
210   AliMaterial(49, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
211   //
212   //     Iron 
213   AliMaterial(10, "IRON$     ", 55.85, 26., 7.87, 1.76, 17.1);
214   AliMaterial(30, "IRON$     ", 55.85, 26., 7.87, 1.76, 17.1);
215   AliMaterial(50, "IRON$     ", 55.85, 26., 7.87, 1.76, 17.1);
216   //
217   //     Air 
218   AliMaterial(15, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500.);
219   AliMaterial(35, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500.);
220   AliMaterial(55, "AIR$      ", 14.61, 7.3, .001205, 30423.24, 67500.);
221   //
222   //     Vacuum 
223   AliMaterial(16, "VACUUM$ ", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
224   AliMaterial(36, "VACUUM$ ", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
225   AliMaterial(56, "VACUUM$ ", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
226   //
227   //     Concrete
228   AliMixture(17, "CONCRETE$", aconc, zconc, 2.35, 10, wconc);
229   AliMixture(37, "CONCRETE$", aconc, zconc, 2.35, 10, wconc);
230   AliMixture(57, "CONCRETE$", aconc, zconc, 2.35, 10, wconc);
231
232
233   // Scintillator material polystyrene 
234   Float_t aP[2] = {12.011, 1.00794};
235   Float_t zP[2] = {6.0, 1.0};
236   Float_t wP[2] = {1.0, 1.0};
237   Float_t dP = 1.032;
238   AliMixture(3, "Polystyrene$", aP, zP, dP, -2, wP);
239   // Standard ROCK, ROCK1 and molasse. 
240   Float_t aRock[1] = {22.};
241   Float_t zRock[1] = {11.};
242   Float_t wRock[1] = {1.};
243   Float_t dRock = 2.65;
244   AliMixture(4, "Standard Rock$", aRock, zRock, dRock, 1, wRock);
245   Float_t dRock1 = 2.2;
246   AliMixture(5, "Rock1$", aRock, zRock, dRock1, 1, wRock);
247   Float_t dMolasse = 2.50;
248   AliMixture(6, "Molasse$", aRock, zRock, dMolasse, 1, wRock);
249   
250   // **************** 
251   //     Defines tracking media parameters. 
252   //     Les valeurs sont commentees pour laisser le defaut 
253   //     a GEANT (version 3-21, page CONS200), f.m. 
254   epsil  = .001;  // Tracking precision, Inside the pit
255   stemax = -1.;   // Maximum displacement for multiple scattering 
256   tmaxfd = -20.;  // Maximum angle due to field deflection 
257   deemax = -.3;   // Maximum fractional energy loss, DLS 
258   stmin  = -.8;
259   // *************** 
260
261   //
262   //    Aluminum 
263   AliMedium(9,  "ALU_C0          ",  9, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
264   AliMedium(29, "ALU_C1          ", 29, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
265   AliMedium(49, "ALU_C2          ", 49, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
266   //
267   //    Iron 
268   AliMedium(10, "FE_C0           ", 10, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
269   AliMedium(30, "FE_C1           ", 30, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
270   AliMedium(50, "FE_C2           ", 50, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
271   //
272   //    Air 
273   AliMedium(15, "AIR_C0          ", 15, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
274   AliMedium(35, "AIR_C1          ", 35, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
275   AliMedium(55, "AIR_C2          ", 55, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
276   //
277   //    Vacuum 
278   AliMedium(16, "VA_C0           ", 16, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
279   AliMedium(36, "VA_C1           ", 36, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
280   AliMedium(56, "VA_C2           ", 56, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
281   //
282   //    Concrete 
283   AliMedium(17, "CC_C0           ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
284   AliMedium(37, "CC_C1           ", 37, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
285   AliMedium(57, "CC_C2           ", 57, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
286
287
288   // The scintillator of the CPV made of Polystyrene 
289   // scintillator -> idtmed[1102]
290   AliMedium(3, "CPV scint.          ", 3, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
291   
292   //     Standard ROCK  -> idtmed[1103]
293   AliMedium(4, "Standard Rock ",  4, 0, xfield, xfieldm, tmaxfd, stemax, deemax, xepsil, stmin);
294   
295   //     ROCK1   -> idtmed[1104]
296   AliMedium(5, "Rock 1                 ", 5, 0, xfield, xfieldm, tmaxfd, stemax, deemax, xepsil, stmin);
297
298
299   //     Molasse -> idtmed[1105]
300   AliMedium(6, "Molasse          ", 6, 0, xfield, xfieldm, tmaxfd, stemax, deemax, xepsil, stmin);
301
302
303 }
304
305 //_____________________________________________________________________________
306 void AliCRT::MakeBranch(Option_t* option, const char *file)
307 {
308   //
309   // Specific CRT branches
310   //
311   // Create Tree branches for the CRT.
312   Int_t buffersize = 400;
313   char branchname[10];
314   sprintf(branchname,"%s",GetName());
315
316   AliDetector::MakeBranch(option,file);
317
318   const char *cD = strstr(option,"D");
319   
320   if (cD) {
321     digits = new AliCRTdigit();
322     MakeBranchInTree(gAlice->TreeD(), branchname, "AliCRTdigit", 
323                      digits, buffersize, 1, file);
324   } 
325
326 }
327 //_____________________________________________________________________________