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