]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDE.cxx
- Added class for Global Crate object
[u/mrichter/AliRoot.git] / ACORDE / AliACORDE.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Cosmic Rays ALICE Trigger                                                //
21 //  This class contains the basic functions for the Cosmic Ray ALICE         //
22 //  detector. Functions specific to one particular geometry are              //
23 //  contained in the derived classes                                         //
24 //
25 // Begin_Html
26 /*
27 <img src="picts/AliACORDEClass.gif">
28 </pre>
29 <p>The responsible person for this module is
30 <a href="mailto:Enrique.Gamez.Flores@cern.ch">Enrique Gamez Flores</a>.
31 </font>
32 <pre>
33 */
34 //End_Html
35 //             
36 //
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 #include <TClonesArray.h>
41 #include <TTree.h>
42 #include <TVirtualMC.h>
43 #include <TGeoManager.h>
44
45 #include "AliACORDE.h"
46 #include "AliMagF.h"
47 #include "AliRun.h"
48 #include "AliACORDERawData.h"
49
50 ClassImp(AliACORDE)
51
52 //_____________________________________________________________________________
53 AliACORDE::AliACORDE()
54   : AliDetector(),
55     fCreateCavern(0),
56     fITSGeometry(0)
57 {
58   //
59   // Default constructor
60   //
61 }
62  
63 //_____________________________________________________________________________
64 AliACORDE::AliACORDE(const char *name, const char *title)
65   : AliDetector(name, title),
66     fCreateCavern(kFALSE),
67     fITSGeometry(kTRUE)
68
69 {
70   //
71   // Standard constructor
72 }
73
74 //_____________________________________________________________________________
75 AliACORDE::~AliACORDE()
76 {
77   //
78   // Default destructor
79   //
80 }
81
82 //_____________________________________________________________________________
83 void AliACORDE::CreateMaterials()
84 {
85   // Magnatic field inside the pit
86   Int_t   isxfld = gAlice->Field()->Integ();
87   Float_t sxmgmx = gAlice->Field()->Max();
88
89   //Magnetic field above the Magnet.
90   Int_t xfield = 0;   // no Magnetic field.
91   Float_t xfieldm = 0;
92   Float_t xepsil = 0.1; // Tracking precission in cm. obove the pit
93
94   // --- Define the various materials for GEANT --- 
95   Float_t epsil, stmin, tmaxfd, deemax, stemax;
96   //
97   //     Aluminum 
98   AliMaterial(9,  "ALUMINIUM0$", 26.98, 13., 2.7, 8.9, 37.2);
99   //  AliMaterial(29, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2);
100   //AliMaterial(49, "ALUMINIUM2$", 26.98, 13., 2.7, 8.9, 37.2);
101   //
102   //     Iron 
103   //AliMaterial(10, "IRON0$    ", 55.85, 26., 7.87, 1.76, 17.1);
104   //AliMaterial(30, "IRON1$    ", 55.85, 26., 7.87, 1.76, 17.1);
105   //AliMaterial(50, "IRON2$    ", 55.85, 26., 7.87, 1.76, 17.1);
106   //
107   //     Air 
108   Float_t as[] = { 12.0107, 14.0067,   15.9994,  39.948 };
109   Float_t zs[] = {  6.,      7.,       8.,       18. };
110   Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 }; 
111   Double_t density      = .00120479;
112   AliMixture(15, "AIR0$", as, zs, density, 4, ws);
113
114   //AliMaterial(15, "AIR0$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
115   //AliMaterial(35, "AIR1$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
116   //AliMaterial(55, "AIR2$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
117   //AliMaterial(75, "AIR3$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
118   //AliMaterial(95, "AIR4$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
119
120
121   // Scintillator material polystyrene 
122   Float_t aP[2] = {12.011, 1.00794};
123   Float_t zP[2] = {6.0, 1.0};
124   Float_t wP[2] = {1.0, 1.0};
125   Float_t dP = 1.032;
126   AliMixture(13, "Polystyrene$", aP, zP, dP, -2, wP);
127   // Subalpine Molasse over the ALICE hall. 
128   Float_t aMolasse[10] = { 1., 12.01, 15.994, 22.99, 24.305, 26.98, 28.086, 39.1, 40.08, 55.85 };
129   Float_t zMolasse[10] = {1., 6., 8., 11., 12., 13., 14., 19., 20., 26.};
130   Float_t wMolasse[10] = {0.008, 0.043, 0.485, 0.007, 0.042, 0.037, 0.215, 0.023, 0.1, 0.04};
131   Float_t dMolasse = 2.40;
132   AliMixture(24, "Molasse$", aMolasse, zMolasse, dMolasse, 10, wMolasse);
133
134   // **************** 
135   //     Defines tracking media parameters. 
136   //     Les valeurs sont commentees pour laisser le defaut 
137   //     a GEANT (version 3-21, page CONS200), f.m. 
138   epsil  = .001;  // Tracking precision, Inside the pit
139   stemax = -1.;   // Maximum displacement for multiple scattering 
140   tmaxfd = -20.;  // Maximum angle due to field deflection 
141   deemax = -.3;   // Maximum fractional energy loss, DLS 
142   stmin  = -.8;
143   // *************** 
144
145   Float_t atmaxfd = 10.;
146   Float_t adeemax = -0.1;
147   Float_t aepsil = 0.1;
148   Float_t astmin = -10.;
149
150   //
151   //    Aluminum 
152   AliMedium(9,  "ALU_C0          ",  9, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
153   // AliMedium(29, "ALU_C1          ", 29, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
154   //AliMedium(49, "ALU_C2          ", 49, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
155   //
156   //    Iron 
157   //AliMedium(10, "FE_C0           ", 10, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
158   //AliMedium(30, "FE_C1           ", 30, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
159   //AliMedium(50, "FE_C2           ", 50, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
160   //
161   //    Air 
162   AliMedium(15, "AIR_C0          ", 15, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
163   // AliMedium(35, "AIR_C1          ", 35, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
164   //AliMedium(55, "AIR_C2          ", 55, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
165   //AliMedium(75, "AIR_C4          ", 75, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
166   //AliMedium(95, "AIR_C5          ", 95, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
167
168
169
170   // The scintillator of the CPV made of Polystyrene 
171   // scintillator -> idtmed[1112]
172   //AliMedium(12 , "CPV scint.0     ", 13, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
173   AliMedium(13 , "CPV scint.1     ", 13, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
174   //AliMedium(14 , "CPV scint.2     ", 13, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
175
176   //     Molasse -> idtmed[1123]
177   AliMedium(24 , "Molasse         ", 24, 0, xfield, xfieldm, tmaxfd, stemax, deemax, xepsil, stmin);
178
179   // Concrete, in case if we need to put hte shafts by ourselves.
180
181   Float_t aconc[10] = { 1.,12.01,15.994,22.99,24.305,26.98,28.086,39.1,40.08,55.85 };
182   Float_t zconc[10] = { 1.,6.,8.,11.,12.,13.,14.,19.,20.,26. };
183   Float_t wconc[10] = { .01,.001,.529107,.016,.002,.033872,.337021,.013,.044,.014 };
184
185   AliMixture(17, "CONCRETE$", aconc, zconc, 2.35, 10, wconc);
186   //    Concrete 
187   AliMedium(17, "CC_C0            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
188   //  AliMedium(27, "CC_C1            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin); // MX24
189   //AliMedium(37, "CC_C2            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin); // PM25
190   //AliMedium(47, "CC_C3            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin); // PGC2
191
192 }
193
194 //_____________________________________________________________________________
195 void AliACORDE::SetTreeAddress()
196 {
197
198   TBranch *branch;
199   char branchname[20];
200   sprintf(branchname,"%s",GetName());
201   // Branch address for hit tree
202   TTree *treeH = fLoader->TreeH();
203   if (treeH ) {
204     branch = treeH->GetBranch(branchname);
205     if (branch) branch->SetAddress(&fHits);
206   }
207 }
208
209 //_____________________________________________________________________________
210 void AliACORDE::MakeBranch(Option_t* opt)
211 {
212   //
213   // Initializes the branches of the ACORDE inside the trees written
214   // for each event.
215   //
216   const char* oH = strstr(opt, "H");
217   if ( fLoader->TreeH() && oH && (fHits == 0x0) ) {
218     fHits = new TClonesArray("AliACORDEhit", 1000);
219     fNhits = 0;
220   }
221   AliDetector::MakeBranch(opt);
222 }
223
224 AliLoader* AliACORDE::MakeLoader(const char* topfoldername)
225
226  
227   AliDebug(1,Form("Creating AliACORDELoader, Top folder is %s ",
228                   topfoldername));
229   fLoader = new AliACORDELoader(GetName(),topfoldername);
230   return fLoader;
231 }
232
233
234 AliDigitizer* AliACORDE::CreateDigitizer(AliRunDigitizer* manager) const
235 {
236   //
237   //
238   return new AliACORDEDigitizer(manager);
239 }
240
241 void AliACORDE::Digits2Raw()
242 {
243   // Produce Raw data starting from digits
244   // 1. Get digits
245   // 2. From digits get an array with the state of the modules
246   // 3. Unload digits
247   // 4. Write raw data
248
249   // 1. Get digits
250
251   // 1.1 Get detector, load digits and set branch
252   AliACORDE* acorde = (AliACORDE*)gAlice->GetDetector("ACORDE");
253   fLoader->LoadDigits("READ");
254   TTree* treeD = fLoader->TreeD();
255   if (!treeD) {
256     Error("Digits2Raw", "no digits tree");
257     return;
258   }
259   TClonesArray *adigits = new TClonesArray ("AliACORDEdigit", 1000);
260   treeD->GetBranch("ACORDEdigit")->SetAddress(&adigits);
261   // 1.2 Get first entry (there is always only one)
262   acorde->ResetDigits();
263   treeD->GetEvent(0);
264   
265   // 2. From digits get an array with the state of the modules
266   // 2.1 Define and initialize the array
267   Bool_t Modules[60];
268   for (Int_t i=0;i<60;i++) Modules[i]= kFALSE;
269   // 2.2 Loop over all digits
270   Int_t ndig = adigits->GetEntriesFast();
271   for (Int_t idig=0;idig<ndig;idig++) {
272     // 2.3 set the array entry for each digit
273     AliACORDEdigit* digit = (AliACORDEdigit*) adigits->At(idig);
274     Int_t mod = digit->GetModule();
275     Modules[mod-1]=kTRUE;
276   } 
277   // 3. Unload digits
278   fLoader->UnloadDigits();
279
280   // 4. Write raw data
281   AliACORDERawData rawdata;
282   rawdata.WriteACORDERawData(Modules);
283 }
284
285 //_____________________________________________________________________________
286 void AliACORDE::AddAlignableVolumes() const
287 {
288   //
289   // Create entries for alignable volumes associating the symbolic volume
290   // name with the corresponding volume path. Needs to be syncronized with
291   // eventual changes in the geometry.
292   // 
293   TString vpstr1 = "ALIC_1/ACORDE1_";
294   TString snstr1="ACORDE/Array";
295   TString volpath, symname;
296   
297   for(Int_t cnt=1; cnt<=3; cnt++){
298     volpath = vpstr1;
299     volpath += cnt;
300     symname = snstr1;
301     symname += cnt;
302     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
303       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
304   }
305
306 }