Adding include path to allow compilation of CleanGeom task
[u/mrichter/AliRoot.git] / AD / AliADv1.cxx
CommitLineData
5e319bd5 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: AliAD.cxx $ */
17
18///////////////////////////////////////////////////////////////////////////
19// //
20// AD (ALICE Diffractive) Detector //
21// //
22// This class contains the base procedures for the AD detector //
23// Default geometry of 2013: 16 modules //
24// All comments should be sent to : //
25// //
26// //
27///////////////////////////////////////////////////////////////////////////
28
29// --- Standard libraries ---
30#include <Riostream.h>
31
32// --- ROOT libraries ---
33#include <TMath.h>
34#include <TString.h>
35#include <TVirtualMC.h>
36#include <TGeoManager.h>
37#include <TGeoMatrix.h>
38#include <TGeoTube.h>
39#include <TGeoCone.h>
40#include <TGeoShape.h>
41#include <TTree.h>
42#include <TSystem.h>
43#include <TGeoCompositeShape.h>
44#include <TGeoGlobalMagField.h>
45#include <TGeoMaterial.h>
46#include <TGeoMedium.h>
47#include <TGeoVolume.h>
48#include <TGeoArb8.h>
49#include <TClonesArray.h>
50#include <TGeoTrd2.h>
51#include <TParticle.h>
52
53#include <TH2F.h>
54#include <TCanvas.h>
55
56// --- AliRoot header files ---
57
58
59#include "AliADhit.h"
60#include "AliADdigit.h"
61#include "AliADv1.h"
62#include "AliLog.h"
63#include "AliConst.h"
64#include "AliMagF.h"
65#include "AliRun.h"
66#include "AliMC.h"
67
68
69ClassImp(AliADv1)
70//__________________________________________________________________
71AliADv1::AliADv1()
72 : AliAD(),
73 fADCLightYield(93.75),
74 fADCPhotoCathodeEfficiency(0.18),
75 fADALightYield(93.75),
76 fADAPhotoCathodeEfficiency(0.18)
77
78{
79 // Default Constructor
80 fHits = 0;
81}
82
83//_____________________________________________________________________________
84AliADv1::AliADv1(const char *name, const char *title) :
85 AliAD(name,title),
86 fADCLightYield(93.75),
87 fADCPhotoCathodeEfficiency(0.18),
88 fADALightYield(93.75),
89 fADAPhotoCathodeEfficiency(0.18)
90{
91 // Standard constructor for AD Detector
92
93 AliModule* pipe = gAlice->GetModule("PIPE");
94 if( (!pipe) ) {
95 Error("Constructor","AD needs PIPE!!!\n");
96 exit(1);
97 }
98 fHits = new TClonesArray("AliADhit",400);
99 gAlice->GetMCApp()->AddHitList(fHits);
100}
101
102//_____________________________________________________________________________
103AliADv1::~AliADv1()
104{
105 // default destructor
106}
107//_____________________________________________________________________________
108void AliADv1::Init()
109{
110 // Initialise L3 magnet after it has been built
111 Int_t i;
112 if(AliLog::GetGlobalDebugLevel()>0) {
113 printf("\n%s: ",ClassName());
114 for(i=0;i<35;i++) printf("*");
115 printf(" ADv1_INIT ");
116 for(i=0;i<35;i++) printf("*");
117 printf("\n%s: ",ClassName());
118 for(i=0;i<80;i++) printf("*");
119 printf("\n");
120 }
121}
122
123//_____________________________________________________________________________
124void AliADv1::CreateGeometry()
125{
126 //
127 // Create the geometry for the AD arrays
128 //
129
130 CreateAD();
131
132}
133
134
135//_____________________________________________________________________________
136void AliADv1::CreateAD()
137{
138
139 // here we create AD: ADA & ADC
140
141 // Get ALICE volume
142
143 TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
144
145 // Define the mother volume for AD
146
147 TGeoVolume *ad = new TGeoVolumeAssembly("AD");
148
149 // Get medium
150
151 TGeoMedium *medADASci = gGeoManager->GetMedium("AD_NE102"); // AD Scin.
152 TGeoMedium *medADALG = gGeoManager->GetMedium("AD_PMMA"); // lightGuide
153 TGeoMedium *medADAPMGlass = gGeoManager->GetMedium("AD_Glass"); // Glass for Aluminium simulation
154 TGeoMedium *medADAPMAlum = gGeoManager->GetMedium("AD_Alum"); // Aluminium
155
156
157 /// ADA Scintillator Pad Measures
158 const Double_t kADATriangleSide = 7.8; //
159 const Double_t kADACellSide = 20.0;
160 const Double_t kADACellThickness = 2.0; // Half thickness
161 const int kColorADA = kGreen;
162
163
164 // Creation of the Box's pad
165
166 new TGeoBBox( "ADAbox", kADACellSide/2.0-kADATriangleSide/2., kADACellSide/2.0, kADACellThickness );
167 const Double_t boxSide2 = kADACellSide/2.0-kADATriangleSide/2.;
168 new TGeoBBox( "ADAbox1", kADATriangleSide/2., boxSide2, kADACellThickness );
169
170 // translation
171
172 TGeoTranslation *trada2 = new TGeoTranslation( -kADACellSide/2.0, kADACellSide/2.0 - boxSide2, 0. );
173 trada2->SetName( "trada2" );
174 trada2->RegisterYourself();
175
176 TGeoArb8* sADAtriang = new TGeoArb8( "ADAtriang", kADACellThickness );
177 for ( int iz = 0; iz < 2; iz++ ) {
178 sADAtriang->SetVertex( 0+iz*4, kADACellSide/2.0, kADACellSide/2.0 );
179 sADAtriang->SetVertex( 1+iz*4, kADACellSide/2.0, (kADACellSide/2.0)-kADATriangleSide );
180 sADAtriang->SetVertex( 2+iz*4, kADACellSide/2.0, (kADACellSide/2.0)-kADATriangleSide );
181 sADAtriang->SetVertex( 3+iz*4, kADACellSide/2.0-kADATriangleSide, kADACellSide/2.0 );
182 }
183 TGeoTranslation *trada1 = new TGeoTranslation( -kADACellSide+kADATriangleSide/2. , -kADACellSide+kADATriangleSide, 0. );
184 trada1->SetName( "trada1" );
185 trada1->RegisterYourself();
186
187 TGeoCompositeShape *sADA1 = new TGeoCompositeShape ( "sADA1s1", "ADAbox+(ADAbox1:trada2)+(ADAtriang:trada1)" );
188 TGeoVolume *vADA1 = new TGeoVolume( "ADApad", sADA1, medADASci );
189 vADA1->SetLineColor( kColorADA );
190
191 /// Light guide
192 Double_t kADALGThickness = 2.0; // Half thickness
193 Double_t kADALGSideScint = 20.0;
194 Double_t kADALGHeigth = TMath::Sqrt( kADALGSideScint*kADALGSideScint - (10.5 * 10.5) );
195 Double_t kADALGSideCoupling = 3.0;
196 const int kColorADALG = kYellow;
197
198 // Triangle
199 TGeoTrd2* sADALGtriang = new TGeoTrd2( kADALGThickness, kADALGThickness, kADALGSideScint/2., kADALGSideCoupling/2., kADALGHeigth/2.0);
200 TGeoVolume *vADALGtriang = new TGeoVolume( "ADALG", sADALGtriang, medADALG );
201 vADALGtriang->SetLineColor( kColorADALG );
202
203 // Coupling
204 Double_t kADALGCoupling = 5.0;
205 TGeoTube* sADACouplTube = new TGeoTube( "ADACouplTube", 0, 1.4, kADALGCoupling/2. );
206 TGeoVolume * vADACoupling = new TGeoVolume( "ADACoupling", sADACouplTube, medADALG );
207 vADACoupling->SetLineColor( kColorADALG );
208
209 TGeoVolume * vADALG1 = new TGeoVolumeAssembly( "ADALG" );
210 vADALG1->AddNode( vADALGtriang, 1 );
211 vADALG1->AddNode( vADACoupling, 1, new TGeoTranslation(0., 0., kADALGHeigth/2.+kADALGCoupling/2.) );
212 vADALG1->SetLineColor( kColorADALG );
213
214 /// PMT Hamamatsu R5946
215 Double_t kADAPMR1 = 1.95; // 3.9 cm diameter
216 Double_t kADAPMR2 = 2.15; // + 2 mm?? aluminium case
217 Double_t kADAPMlength = 6.4; // 5 cm PMT + 1.4 socket
218 const int kColorPMG = kWhite;
219 const int kColorPMA = kGray;
220
221 TGeoTube *sADAPMg1 = new TGeoTube( "sADAPMg", 0., kADAPMR1, kADAPMlength/2. );
222 TGeoVolume *vADAPMg1 = new TGeoVolume( "ADAPMg", sADAPMg1, medADAPMGlass );
223 vADAPMg1->SetLineColor( kColorPMG );
224 TGeoTube *sADAPMa1 = new TGeoTube( "ADAPMa", kADAPMR1, kADAPMR2, kADAPMlength/2. );
225 TGeoVolume *vADAPMa1 = new TGeoVolume( "ADAPMa", sADAPMa1, medADAPMAlum );
226 vADAPMa1->SetLineColor( kColorPMA );
227 TGeoVolume *vADAPM1 = new TGeoVolumeAssembly("ADAPM");
228 vADAPM1->AddNode( vADAPMg1, 1 );
229 vADAPM1->AddNode( vADAPMa1, 1 );
230
231 /// Sector (Assembly: Scintillator Pad + Light guide + PM )
232 TGeoVolume *secADA = new TGeoVolumeAssembly( "ADAsec" );
233 // Add PAD
234 secADA->AddNode( vADA1, 1, new TGeoTranslation( kADACellSide/2.0+kADATriangleSide/2. + 0.05, kADACellSide/2.0 + 0.05, 0. ) );
235 // Add Light Guide
236 TGeoCombiTrans *transrot = new TGeoCombiTrans( kADACellSide + kADALGHeigth/2.0 + 0.05, kADALGSideScint/2.0 + 0.05, 0.,
237 new TGeoRotation("rot",90.,90.,90.) );
238 secADA->AddNode( vADALG1, 1, transrot );
239 // Add PM
240 transrot = new TGeoCombiTrans( kADACellSide + kADALGHeigth + kADALGCoupling + kADAPMlength/2. + 0.05, kADACellSide/2.0 + 0.05, 0,
241 new TGeoRotation("rot",90.,90.,0.) );
242 secADA->AddNode(vADAPM1, 1, transrot);
243
244 // TODO: Add mechanical support
245
246 /// Assembling ADA adding 4 sectors // Sectors
247 TGeoVolume *vADAarray = new TGeoVolumeAssembly( "ADA" ); // ^ y
248 vADAarray->AddNode( secADA, 1 ); // |
249 vADAarray->AddNode( secADA, 2, new TGeoRotation("rot",0. , 180.,0.) ); // 4 | 1
250 vADAarray->AddNode( secADA, 3, new TGeoRotation("rot",180., 0., 0.) ); // ---------------> x
251 vADAarray->AddNode( secADA, 4, new TGeoRotation("rot",180., 180.,0.) ); // 3 | 2
252 TGeoRotation *rotADA90 = new TGeoRotation("adarot",90,0,0);
253 // here I add ADA to AD volume
254 const Float_t kPosADA = 1700.0;
255 ad->AddNode(vADAarray,1, new TGeoCombiTrans("ada",0,0,kPosADA,rotADA90)); // |
256
257 if (GetADAToInstalled())
258 {
259 const Float_t kPosADA2 = 1695.0;
260 ad->AddNode(vADAarray,2, new TGeoCombiTrans("ada",0,0,kPosADA2,rotADA90));
261 }
262
263 // Creation of ADC
264
265 // Get Medium for ADC (in principle is the same as ADA, but I keep the previous variables)
266
267 TGeoMedium *medADCSci = gGeoManager->GetMedium("AD_NE102");
268 TGeoMedium *medADCLG = gGeoManager->GetMedium("AD_PMMA");
269 TGeoMedium *medADCPMGlass = gGeoManager->GetMedium("AD_Glass");
270 TGeoMedium *medADCPMAlum = gGeoManager->GetMedium("AD_Alum");
271
272 /// Creation of assembly of one ADC sector
273
274 /// ADC Scintillator Pad
275 const Double_t kADCCellSide = 30.;
276 const Double_t kADCCellThickness = 4.0;
277 const int kColorADC = kGreen;
278
279 new TGeoBBox( "ADCbox0", kADCCellSide/4.0, kADCCellSide/2.0, kADCCellThickness/2.0 );
280 new TGeoBBox( "ADCbox1", kADCCellSide/4.0, kADCCellSide/4.0, kADCCellThickness/2.0 );
281 new TGeoBBox( "ADCbox2", 2.5, 5.5, kADCCellThickness/2.0 );
282 TGeoTranslation *tradd1 = new TGeoTranslation( -kADCCellSide/2.0, kADCCellSide/4.0, 0. );
283 TGeoTranslation *tradd2 = new TGeoTranslation( -kADCCellSide/4.0 - 2.5, -kADCCellSide/2.0 + 5.5 , 0. );
284 tradd1->SetName( "tradd1" );
285 tradd2->SetName( "tradd2" );
286 tradd1->RegisterYourself();
287 tradd2->RegisterYourself();
288 TGeoCompositeShape *sADC1 = new TGeoCompositeShape ( "sADCpad", "ADCbox0+(ADCbox1:tradd1)+(ADCbox2:tradd2)" );
289 TGeoVolume *vADC = new TGeoVolume( "ADCpad", sADC1, medADCSci );
290 vADC->SetLineColor( kColorADC );
291
292 /// Light guide
293 const Double_t kADCLGThickness = 4.0;
294 const Double_t kADCLGHeigth = 28.95; // Dist from scint to coupling
295 const Double_t kADCLGSideScint = kADCCellSide; // 30.0
296 const Double_t kADCLGSideCoupling = 4.0;
297 const int kColorADCLG = kYellow;
298
299 // Triangle
300 TGeoTrd2* sADCLGtriang = new TGeoTrd2( kADCLGThickness/2., kADCLGThickness/2., kADCLGSideScint/2., kADCLGSideCoupling/2., kADCLGHeigth/2.0);
301 TGeoVolume *vADCLGtriang = new TGeoVolume( "ADCLG", sADCLGtriang, medADCLG );
302 vADCLGtriang->SetLineColor( kColorADCLG );
303
304 // Coupling
305 Double_t kADCLGCoupling = 10.0; // Total lenght
306 new TGeoCone( "ADCCouplCone", kADCLGCoupling/4., 0, kADCLGSideCoupling/TMath::Sqrt(2.), 0, 1.4 );
307 new TGeoBBox( "ADCCouplBox", kADCLGSideCoupling/2., kADCLGSideCoupling/2., kADCLGCoupling/4. );
308 new TGeoTube( "ADCCouplTube", 0, 1.4, kADCLGCoupling/4. );
309 TGeoTranslation *tradd3 = new TGeoTranslation(0, 0, kADCLGCoupling/2. );
310 tradd3->SetName( "tradd3" );
311 tradd3->RegisterYourself();
312
313 TGeoCompositeShape * sADCCoupling = new TGeoCompositeShape ( "sADCCoupling", "ADCCouplBox * ADCCouplCone + (ADCCouplTube:tradd3)" );
314 TGeoVolume * vADCCoupling = new TGeoVolume( "ADCCoupling", sADCCoupling, medADCLG );
315 vADCCoupling->SetLineColor( kColorADCLG );
316
317 TGeoVolume * vADCLG = new TGeoVolumeAssembly( "ADCLG" );
318 vADCLG->AddNode( vADCLGtriang, 1 );
319 vADCLG->AddNode( vADCCoupling, 1, new TGeoTranslation(0., 0., kADCLGHeigth/2.+kADCLGCoupling/4.) );
320 vADCLG->SetLineColor( kColorADCLG );
321
322 /// PM Hamamatsu R5946
323 const Double_t kADCPMR1 = 1.95; // 3.9 cm diameter
324 const Double_t kADCPMR2 = 2.15; // + 2 mm?? aluminium case
325 const Double_t kADCPMlength = 6.4; // 5 cm PMT + 1.4 socket
326 //const int kColorPMG = kWhite;
327 ////const int kColorPMA = kGray;
328
329 TGeoTube *sADCPMg = new TGeoTube( "sADCPMg", 0., kADCPMR1, kADCPMlength/2. );
330 TGeoVolume *vADCPMg = new TGeoVolume( "ADCPMg", sADCPMg, medADCPMGlass );
331 vADCPMg->SetLineColor(kColorPMG);
332 TGeoTube *sADCPMa = new TGeoTube( "ADCPMa", kADCPMR1, kADCPMR2, kADCPMlength/2. );
333 TGeoVolume *vADCPMa = new TGeoVolume( "ADCPMa", sADCPMa, medADCPMAlum );
334 vADCPMa->SetLineColor( kColorPMA );
335 TGeoVolume *vADCPM = new TGeoVolumeAssembly( "ADCPM" );
336 vADCPM->AddNode( vADCPMg, 1 );
337 vADCPM->AddNode( vADCPMa, 1 );
338
339 /// Sector (Asembly: Scintillator Pad + Light guide + PM )
340 TGeoVolume *secADC = new TGeoVolumeAssembly("ADCsec");
341 // Add PAD
342 TGeoCombiTrans *transrot1 = new TGeoCombiTrans( 3*kADCCellSide/4.0, kADCCellSide/2.0, 0., new TGeoRotation("rot",0.,0.,0.) );
343 secADC->AddNode( vADC, 1, transrot1 );
344 // Add Light Guide
345 transrot1 = new TGeoCombiTrans( kADCCellSide + kADCLGHeigth/2.0, kADCLGSideScint/2.0, 0., new TGeoRotation("rot",90.,90.,90.) );
346 secADC->AddNode( vADCLG, 1, transrot1 );
347 // Add PM
348 transrot1 = new TGeoCombiTrans( kADCCellSide + kADCLGHeigth + kADCLGCoupling + kADCPMlength/2., kADCCellSide/2.0, 0, new TGeoRotation("rot",90.,90.,0.) );
349 secADC->AddNode( vADCPM, 1, transrot1 );
350
351 // TODO: Add mechanical support
352
353 /// Assembling ADC adding the 4 sectors // Sectors
354 TGeoVolume *vADCarray = new TGeoVolumeAssembly("ADC"); // ^ y
355 vADCarray->AddNode( secADC, 1 ); // |
356 vADCarray->AddNode( secADC, 2, new TGeoRotation("rot", 0. , 180., 0.) ); // 4 | 1
357 vADCarray->AddNode( secADC, 3, new TGeoRotation("rot", 180., 0., 0.) ); // ---------------> x
358 vADCarray->AddNode( secADC, 4, new TGeoRotation("rot", 180., 180., 0.) ); // 3 | 2
359 // |
360 // here I add ADC to AD volume
361
362 //const Float_t kPosADC = -1902.75; // -1902.75 (with 4cm thick) puts the ADC just next to the YSAA3_CC_BLOCK
363 const Float_t kPosADC = -1900.0;
364 ad->AddNode(vADCarray,3,new TGeoTranslation(0,0,kPosADC));
365 // add second array
366 if (GetADCToInstalled())
367 {
368 const Float_t kPosADC2 = -1895.0;
369 ad->AddNode(vADCarray,4,new TGeoTranslation(0,0,kPosADC2));
370 }
371
372 // at the end, I add "AD" volume into ALICE
373
374 alice->AddNode(ad,1);
375}
376
377//_____________________________________________________________________________
378void AliADv1::AddAlignableVolumes() const
379{
380 //
381 // Create entries for alignable volumes associating the symbolic volume
382 // name with the corresponding volume path. Needs to be syncronized with
383 // eventual changes in the geometry.
384 //
385 // ADA and ADC
386
387
388
389 TString volpath1 = "/ALIC_1/AD_1/ADC_3";
390 TString volpath2 = "/ALIC_1/AD_1/ADC_4";
391 TString volpath3 = "/ALIC_1/AD_1/ADA_1";
392 TString volpath4 = "/ALIC_1/AD_1/ADA_2";
393
394 TString symname1 = "AD/ADC3";
395 TString symname2 = "AD/ADC4";
396 TString symname3 = "AD/ADA1";
397 TString symname4 = "AD/ADA2";
398
399 if ( !gGeoManager->SetAlignableEntry(symname1.Data(), volpath1.Data()) )
400 AliFatal(Form( "Alignable entry %s not created. Volume path %s not valid", symname1.Data(), volpath1.Data()) );
401 if ( GetADCToInstalled() && !gGeoManager->SetAlignableEntry(symname2.Data(), volpath2.Data()) )
402 AliFatal(Form( "Alignable entry %s not created. Volume path %s not valid", symname2.Data(), volpath2.Data()) );
403 if ( !gGeoManager->SetAlignableEntry(symname3.Data(), volpath3.Data()) )
404 AliFatal(Form( "Alignable entry %s not created. Volume path %s not valid", symname3.Data(), volpath3.Data()) );
405 if ( GetADAToInstalled() && !gGeoManager->SetAlignableEntry(symname4.Data(), volpath4.Data()) )
406 AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname4.Data(), volpath4.Data()) );
407
408}
409
410
411//_____________________________________________________________________________
412void AliADv1::StepManager()
413{
414
415 //
416 // Routine called at every step in the AD
417 //
418
419 // ADA and ADC static Variables //
420 //static Int_t numStep_ad = 0; //
421// static Int_t vol_ad[2]; //
422
423 /////////////////////////////////////////////////////////////////////////
424 // ADA and ADC
425 /////////////////////////////////////////////////////////////////////////
426
427
428 // Get sensitive volumes id (scintillator pads)
aa8120bb 429 static Int_t idADA = gMC->VolId( "ADApad" );
430 static Int_t idADC = gMC->VolId( "ADCpad" );
5e319bd5 431
432 // We keep only charged tracks :
aa8120bb 433 // if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;
5e319bd5 434 // We keep charged and non-charged tracks :
aa8120bb 435 if ( !gMC->IsTrackAlive() ) return;
5e319bd5 436
437 Int_t copy;
aa8120bb 438 Int_t current_volid = gMC->CurrentVolID( copy );
5e319bd5 439
440 // check is the track is in a sensitive volume
441 if( current_volid != idADA && current_volid != idADC ) {
442 return; // not in the sensitive volume
443 }
444
445 // First read the position, otherwise weird reults! //ecv
446 Double_t s[3];
447 Float_t x[3];
aa8120bb 448 gMC->TrackPosition( s[0], s[1], s[2] );
5e319bd5 449 for ( Int_t j=0; j<3; j++ ) x[j] = s[j];
450
451 // Set detectro type: ADA or ADC
452 Int_t detType = (current_volid == idADA ) ? 0 : 1;
453
454 // Get sector copy (1,2,3,4) ( 1 level up from pad )
455 Int_t sect;
aa8120bb 456 gMC->CurrentVolOffID( 1, sect );
5e319bd5 457
458 // Get Detector copy (1,2) ( 2 levels up from pad )
459 Int_t detc;
aa8120bb 460 gMC->CurrentVolOffID( 2, detc );
5e319bd5 461
462 // Sector number
463 // ADA1 = 10-14
464 // ADA2 = 20-24
465 // ADC1 = 30-34
466 // ADC2 = 40-44
467 Int_t sectorNumber_AD = detType*20 + detc*10 + sect;
468
469 Double_t lightYield_ad;
470 Double_t photoCathodeEfficiency;
471
472 if( detType == 1 ) {
473 lightYield_ad = fADCLightYield;
474 photoCathodeEfficiency = fADCPhotoCathodeEfficiency;
475 } else {
476 lightYield_ad = fADALightYield;
477 photoCathodeEfficiency = fADAPhotoCathodeEfficiency;
478 }
479
aa8120bb 480 Float_t destep_ad = gMC->Edep();
481 Float_t step_ad = gMC->TrackStep();
5e319bd5 482 Int_t nPhotonsInStep_ad = Int_t( destep_ad / (lightYield_ad * 1e-9) );
483 nPhotonsInStep_ad = gRandom->Poisson( nPhotonsInStep_ad );
484
485 static Float_t eloss_ad = 0.;
486 static Float_t tlength_ad = 0.;
487 static Int_t nPhotons_ad = 0;
488 static Float_t hits_ad[11];
489 static Int_t vol_ad[5];
490
491 eloss_ad += destep_ad;
492 tlength_ad += step_ad;
493
aa8120bb 494 if ( gMC->IsTrackEntering() ) {
5e319bd5 495 nPhotons_ad = nPhotonsInStep_ad;
496 Double_t p[4];
aa8120bb 497 gMC->TrackMomentum( p[0], p[1], p[2], p[3] );
5e319bd5 498 Float_t pt = TMath::Sqrt( p[0]*p[0] + p[1]*p[1] + p[2]*p[2] );
499 TParticle *par = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber());
500 Int_t imo = par->GetFirstMother();
501 Int_t pdgMo = 0;
502 if ( imo > 0 ) {
503 TParticle * pmot = gAlice->GetMCApp()->Particle(imo);
504 pdgMo = pmot->GetPdgCode();
505 }
506
507 // Set integer values
508 vol_ad[0] = par->GetStatusCode(); // secondary flag //ecv
509 vol_ad[1] = par->GetPdgCode(); // PDG code
510 vol_ad[2] = pdgMo; // PDG of the mother
511 // Set float values
512 hits_ad[0] = x[0]; // X
513 hits_ad[1] = x[1]; // Y
514 hits_ad[2] = x[2]; // Z
515 hits_ad[3] = p[3]; // kinetic energy of the entering particle
516 hits_ad[4] = pt; // Pt
517 hits_ad[5] = p[0]; // Px
518 hits_ad[6] = p[1]; // Py
519 hits_ad[7] = p[2]; // Pz
aa8120bb 520 hits_ad[8] = 1.0e09*gMC->TrackTime(); // in ns!
5e319bd5 521
522 tlength_ad = 0.0;
523 eloss_ad = 0.0;
524
525 return; // without return, we count 2 times nPhotonsInStep_ad !!!???
526 }
527
528 nPhotons_ad += nPhotonsInStep_ad;
529
aa8120bb 530 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) {
5e319bd5 531
532 // Set integer values
533 vol_ad[3] = nPhotons_ad;
534 // brutal correction for ADA_1
535 if (sectorNumber_AD==11) sectorNumber_AD=0;
536 if (sectorNumber_AD==12) sectorNumber_AD=1;
537 if (sectorNumber_AD==13) sectorNumber_AD=2;
538 if (sectorNumber_AD==14) sectorNumber_AD=3;
539
540 // same for ADA_2
541 if (sectorNumber_AD==21) sectorNumber_AD=4;
542 if (sectorNumber_AD==22) sectorNumber_AD=5;
543 if (sectorNumber_AD==23) sectorNumber_AD=6;
544 if (sectorNumber_AD==24) sectorNumber_AD=7;
545
546 // brutal correction for ADC_3
547 if (sectorNumber_AD==51) sectorNumber_AD=8;
548 if (sectorNumber_AD==52) sectorNumber_AD=9;
549 if (sectorNumber_AD==53) sectorNumber_AD=10;
550 if (sectorNumber_AD==54) sectorNumber_AD=11;
551
552 // same for ADC_4
553 if (sectorNumber_AD==61) sectorNumber_AD=12;
554 if (sectorNumber_AD==62) sectorNumber_AD=13;
555 if (sectorNumber_AD==63) sectorNumber_AD=14;
556 if (sectorNumber_AD==64) sectorNumber_AD=15;
557
558
559 vol_ad[4] = sectorNumber_AD; // sector number (scintillator ID)
560 // Set float values
561 hits_ad[9] = tlength_ad; // track lenght inside ADC or ADA
562 hits_ad[10] = eloss_ad; // energy loss
563 Int_t track = gAlice->GetMCApp()->GetCurrentTrackNumber();
564 AddHit( track, vol_ad, hits_ad ); // <-- this is in AliAD.cxx
565 tlength_ad = 0.0;
566 eloss_ad = 0.0;
567 nPhotons_ad = 0;
568 }
569
570 // Do we need track reference ????
aa8120bb 571 // if( gMC->IsTrackEntering() || gMC->IsTrackExiting() ) {
5e319bd5 572 // AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), 49);
573 // }
574}
575//_________________________________________________________
576void AliADv1::AddHit(Int_t track, Int_t *vol, Float_t *hits)
577{
578 TClonesArray &lhits = *fHits;
579 new(lhits[fNhits++]) AliADhit(fIshunt,track,vol,hits);
580}
581//_________________________________________________________
5e319bd5 582void AliADv1::MakeBranch(Option_t *option)
583{
584
585 // Create branches in the current tree
586 TString branchname(Form("%s",GetName()));
587 AliDebug(2,Form("fBufferSize = %d",fBufferSize));
588 const char *cH = strstr(option,"H");
589 if (fHits && fLoader->TreeH() && cH)
590 {
591 fLoader->TreeH()->Branch(branchname.Data(),&fHits,fBufferSize);
592 AliDebug(2,Form("Making Branch %s for hits",branchname.Data()));
593 }
594 const char *cD = strstr(option,"D");
595 if (fDigits && fLoader->TreeD() && cD)
596 {
597 fLoader->TreeD()->Branch(branchname.Data(),&fDigits, fBufferSize);
598 AliDebug(2,Form("Making Branch %s for digits",branchname.Data()));
599 }
600}