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