Adding StepManager function to AliPHOSv0hits class to set the tracknumber
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv0.cxx
CommitLineData
4c039060 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
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// Implementation version v0 of PHOS Manager class
20// Layout EMC + PPSD has name GPS2
21//
22//*-- Author: Yves Schutz (SUBATECH)
23
d2cf0e38 24
fe4da5cc 25// --- ROOT system ---
d15a28e7 26
fe4da5cc 27#include "TBRIK.h"
28#include "TNode.h"
0869cea5 29#include "TRandom.h"
fe4da5cc 30
d15a28e7 31// --- Standard library ---
32
de9ec31b 33#include <stdio.h>
34#include <string.h>
35#include <stdlib.h>
36#include <strstream.h>
d15a28e7 37
38// --- AliRoot header files ---
39
fe4da5cc 40#include "AliPHOSv0.h"
d15a28e7 41#include "AliPHOSHit.h"
42#include "AliPHOSDigit.h"
43#include "AliPHOSReconstructioner.h"
fe4da5cc 44#include "AliRun.h"
d15a28e7 45#include "AliConst.h"
fe4da5cc 46
47ClassImp(AliPHOSv0)
48
d15a28e7 49//____________________________________________________________________________
8c933dd7 50AliPHOSv0::AliPHOSv0()
fe4da5cc 51{
b2a60966 52 // ctor
d15a28e7 53 fNTmpHits = 0 ;
54 fTmpHits = 0 ;
fe4da5cc 55}
d15a28e7 56
57//____________________________________________________________________________
58AliPHOSv0::AliPHOSv0(const char *name, const char *title):
59 AliPHOS(name,title)
60{
b2a60966 61 // ctor : title is used to identify the layout
62 // GPS2 = 5 modules (EMC + PPSD)
d15a28e7 63 // We use 2 arrays of hits :
64 //
65 // - fHits (the "normal" one), which retains the hits associated with
66 // the current primary particle being tracked
67 // (this array is reset after each primary has been tracked).
68 //
69 // - fTmpHits, which retains all the hits of the current event. It
70 // is used for the digitization part.
71
3a6a7952 72 fPinElectronicNoise = 0.010 ;
73 fDigitThreshold = 1. ; // 1 GeV
0869cea5 74
83974468 75 // We do not want to save in TreeH the raw hits
76 // fHits = new TClonesArray("AliPHOSHit",100) ;
77 // gAlice->AddHitList(fHits) ;
6ad0bfa0 78
83974468 79 // But save the cumulated hits instead (need to create the branch myself)
80 // It is put in the Digit Tree because the TreeH is filled after each primary
81 // and the TreeD at the end of the event (branch is set in FinishEvent() ).
82
d15a28e7 83 fTmpHits= new TClonesArray("AliPHOSHit",100) ;
84
d15a28e7 85 fNTmpHits = fNhits = 0 ;
86
6ad0bfa0 87 fDigits = new TClonesArray("AliPHOSDigit",100) ;
88
89
d15a28e7 90 fIshunt = 1 ; // All hits are associated with primary particles
fe4da5cc 91
d15a28e7 92 // gets an instance of the geometry parameters class
6ad0bfa0 93
d15a28e7 94 fGeom = AliPHOSGeometry::GetInstance(title, "") ;
95
96 if (fGeom->IsInitialized() )
97 cout << "AliPHOSv0 : PHOS geometry intialized for " << fGeom->GetName() << endl ;
98 else
99 cout << "AliPHOSv0 : PHOS geometry initialization failed !" << endl ;
100}
9110b6c7 101
d15a28e7 102//____________________________________________________________________________
6ad0bfa0 103AliPHOSv0::AliPHOSv0(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title):
d15a28e7 104 AliPHOS(name,title)
105{
b2a60966 106 // ctor : title is used to identify the layout
107 // GPS2 = 5 modules (EMC + PPSD)
d15a28e7 108 // We use 2 arrays of hits :
109 //
110 // - fHits (the "normal" one), which retains the hits associated with
111 // the current primary particle being tracked
112 // (this array is reset after each primary has been tracked).
113 //
114 // - fTmpHits, which retains all the hits of the current event. It
115 // is used for the digitization part.
b2a60966 116
3a6a7952 117 fPinElectronicNoise = 0.010 ;
83974468 118
119 // We do not want to save in TreeH the raw hits
120 //fHits = new TClonesArray("AliPHOSHit",100) ;
121
d15a28e7 122 fDigits = new TClonesArray("AliPHOSDigit",100) ;
123 fTmpHits= new TClonesArray("AliPHOSHit",100) ;
124
d15a28e7 125 fNTmpHits = fNhits = 0 ;
126
127 fIshunt = 1 ; // All hits are associated with primary particles
128
129 // gets an instance of the geometry parameters class
130 fGeom = AliPHOSGeometry::GetInstance(title, "") ;
131
132 if (fGeom->IsInitialized() )
133 cout << "AliPHOSv0 : PHOS geometry intialized for " << fGeom->GetName() << endl ;
134 else
135 cout << "AliPHOSv0 : PHOS geometry initialization failed !" << endl ;
136
137 // Defining the PHOS Reconstructioner
138
6ad0bfa0 139 fReconstructioner = Reconstructioner ;
d15a28e7 140}
141
142//____________________________________________________________________________
143AliPHOSv0::~AliPHOSv0()
144{
b2a60966 145 // dtor
146
9f616d61 147 fTmpHits->Delete() ;
d15a28e7 148 delete fTmpHits ;
9f616d61 149 fTmpHits = 0 ;
150
9110b6c7 151 fEmcRecPoints->Delete() ;
152 delete fEmcRecPoints ;
153 fEmcRecPoints = 0 ;
9f616d61 154
9110b6c7 155 fPpsdRecPoints->Delete() ;
156 delete fPpsdRecPoints ;
157 fPpsdRecPoints = 0 ;
9f616d61 158
159 fTrackSegments->Delete() ;
160 delete fTrackSegments ;
161 fTrackSegments = 0 ;
d15a28e7 162}
163
164//____________________________________________________________________________
ff4c968a 165void AliPHOSv0::AddHit(Int_t primary, Int_t Id, Float_t * hits)
d15a28e7 166{
b2a60966 167 // Add a hit to the hit list.
168 // A PHOS hit is the sum of all hits in a single crystal
169 // or in a single PPSD gas cell
170
d15a28e7 171 Int_t hitCounter ;
92862013 172 TClonesArray &ltmphits = *fTmpHits ;
d15a28e7 173 AliPHOSHit *newHit ;
92862013 174 AliPHOSHit *curHit ;
31aa6d6c 175 // AliPHOSHit *curHit2 ;
ff4c968a 176 Bool_t deja = kFALSE ;
d15a28e7 177
178 // In any case, fills the fTmpHit TClonesArray (with "accumulated hits")
179
ff4c968a 180 newHit = new AliPHOSHit(primary, Id, hits) ;
83974468 181
182 // We do not want to save in TreeH the raw hits
183 // TClonesArray &lhits = *fHits;
d15a28e7 184
92862013 185 for ( hitCounter = 0 ; hitCounter < fNTmpHits && !deja ; hitCounter++ ) {
d15a28e7 186 curHit = (AliPHOSHit*) ltmphits[hitCounter] ;
31aa6d6c 187 if( *curHit == *newHit ) {
188 *curHit = *curHit + *newHit ;
31aa6d6c 189 deja = kTRUE ;
d15a28e7 190 }
191 }
31aa6d6c 192
92862013 193 if ( !deja ) {
d15a28e7 194 new(ltmphits[fNTmpHits]) AliPHOSHit(*newHit) ;
195 fNTmpHits++ ;
196 }
197
83974468 198 // We do not want to save in TreeH the raw hits
199 // new(lhits[fNhits]) AliPHOSHit(*newHit) ;
200 // fNhits++ ;
201
d15a28e7 202 // Please note that the fTmpHits array must survive up to the
203 // end of the events, so it does not appear e.g. in ResetHits() (
204 // which is called at the end of each primary).
fe4da5cc 205
ff4c968a 206 delete newHit;
d15a28e7 207
208}
209
210
211//____________________________________________________________________________
212void AliPHOSv0::BuildGeometry()
fe4da5cc 213{
b2a60966 214 // Build the PHOS geometry for the ROOT display
215 //BEGIN_HTML
216 /*
217 <H2>
218 PHOS in ALICE displayed by root
219 </H2>
220 <UL>
221 <LI> All Views
222 <P>
223 <CENTER>
224 <IMG Align=BOTTOM ALT="All Views" SRC="../images/AliPHOSv0AllViews.gif">
225 </CENTER></P></LI>
226 <LI> Front View
227 <P>
228 <CENTER>
229 <IMG Align=BOTTOM ALT="Front View" SRC="../images/AliPHOSv0FrontView.gif">
230 </CENTER></P></LI>
231 <LI> 3D View 1
232 <P>
233 <CENTER>
234 <IMG Align=BOTTOM ALT="3D View 1" SRC="../images/AliPHOSv03DView1.gif">
235 </CENTER></P></LI>
236 <LI> 3D View 2
237 <P>
238 <CENTER>
239 <IMG Align=BOTTOM ALT="3D View 2" SRC="../images/AliPHOSv03DView2.gif">
240 </CENTER></P></LI>
241 </UL>
242 */
243 //END_HTML
d15a28e7 244
245 this->BuildGeometryforPHOS() ;
246 if ( ( strcmp(fGeom->GetName(), "GPS2" ) == 0 ) )
247 this->BuildGeometryforPPSD() ;
248 else
249 cout << "AliPHOSv0::BuildGeometry : no charged particle identification system installed" << endl;
250
fe4da5cc 251}
d15a28e7 252
253//____________________________________________________________________________
254void AliPHOSv0:: BuildGeometryforPHOS(void)
255{
b2a60966 256 // Build the PHOS-EMC geometry for the ROOT display
d15a28e7 257
258 const Int_t kColorPHOS = kRed ;
259 const Int_t kColorXTAL = kBlue ;
260
92862013 261 Double_t const kRADDEG = 180.0 / kPI ;
d15a28e7 262
263 new TBRIK( "OuterBox", "PHOS box", "void", fGeom->GetOuterBoxSize(0)/2,
264 fGeom->GetOuterBoxSize(1)/2,
265 fGeom->GetOuterBoxSize(2)/2 );
266
267 // Textolit Wall box, position inside PHOS
268
269 new TBRIK( "TextolitBox", "PHOS Textolit box ", "void", fGeom->GetTextolitBoxSize(0)/2,
270 fGeom->GetTextolitBoxSize(1)/2,
271 fGeom->GetTextolitBoxSize(2)/2);
272
273 // Polystyrene Foam Plate
274
275 new TBRIK( "UpperFoamPlate", "PHOS Upper foam plate", "void", fGeom->GetTextolitBoxSize(0)/2,
276 fGeom->GetSecondUpperPlateThickness()/2,
277 fGeom->GetTextolitBoxSize(2)/2 ) ;
278
279 // Air Filled Box
fe4da5cc 280
d15a28e7 281 new TBRIK( "AirFilledBox", "PHOS air filled box", "void", fGeom->GetAirFilledBoxSize(0)/2,
282 fGeom->GetAirFilledBoxSize(1)/2,
283 fGeom->GetAirFilledBoxSize(2)/2 );
284
285 // Crystals Box
286
92862013 287 Float_t xtlX = fGeom->GetCrystalSize(0) ;
288 Float_t xtlY = fGeom->GetCrystalSize(1) ;
289 Float_t xtlZ = fGeom->GetCrystalSize(2) ;
d15a28e7 290
92862013 291 Float_t xl = fGeom->GetNPhi() * ( xtlX + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 + fGeom->GetModuleBoxThickness() ;
292 Float_t yl = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0
d15a28e7 293 + fGeom->GetModuleBoxThickness() / 2.0 ;
92862013 294 Float_t zl = fGeom->GetNZ() * ( xtlZ + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 + fGeom->GetModuleBoxThickness() ;
d15a28e7 295
92862013 296 new TBRIK( "CrystalsBox", "PHOS crystals box", "void", xl, yl, zl ) ;
d15a28e7 297
298// position PHOS into ALICE
299
92862013 300 Float_t r = fGeom->GetIPtoOuterCoverDistance() + fGeom->GetOuterBoxSize(1) / 2.0 ;
d15a28e7 301 Int_t number = 988 ;
302 Float_t pphi = TMath::ATan( fGeom->GetOuterBoxSize(0) / ( 2.0 * fGeom->GetIPtoOuterCoverDistance() ) ) ;
92862013 303 pphi *= kRADDEG ;
304 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
d15a28e7 305
306 char * nodename = new char[20] ;
307 char * rotname = new char[20] ;
308
309 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
310 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
311 sprintf(rotname, "%s%d", "rot", number++) ;
312 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
92862013 313 top->cd();
d15a28e7 314 sprintf(nodename,"%s%d", "Module", i) ;
92862013 315 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
316 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
317 TNode * outerboxnode = new TNode(nodename, nodename, "OuterBox", x, y, 0, rotname ) ;
318 outerboxnode->SetLineColor(kColorPHOS) ;
319 fNodes->Add(outerboxnode) ;
320 outerboxnode->cd() ;
d15a28e7 321 // now inside the outer box the textolit box
92862013 322 y = ( fGeom->GetOuterBoxThickness(1) - fGeom->GetUpperPlateThickness() ) / 2. ;
d15a28e7 323 sprintf(nodename,"%s%d", "TexBox", i) ;
92862013 324 TNode * textolitboxnode = new TNode(nodename, nodename, "TextolitBox", 0, y, 0) ;
325 textolitboxnode->SetLineColor(kColorPHOS) ;
326 fNodes->Add(textolitboxnode) ;
d15a28e7 327 // upper foam plate inside outre box
92862013 328 outerboxnode->cd() ;
d15a28e7 329 sprintf(nodename, "%s%d", "UFPlate", i) ;
92862013 330 y = ( fGeom->GetTextolitBoxSize(1) - fGeom->GetSecondUpperPlateThickness() ) / 2.0 ;
331 TNode * upperfoamplatenode = new TNode(nodename, nodename, "UpperFoamPlate", 0, y, 0) ;
332 upperfoamplatenode->SetLineColor(kColorPHOS) ;
333 fNodes->Add(upperfoamplatenode) ;
d15a28e7 334 // air filled box inside textolit box (not drawn)
92862013 335 textolitboxnode->cd();
336 y = ( fGeom->GetTextolitBoxSize(1) - fGeom->GetAirFilledBoxSize(1) ) / 2.0 - fGeom->GetSecondUpperPlateThickness() ;
d15a28e7 337 sprintf(nodename, "%s%d", "AFBox", i) ;
92862013 338 TNode * airfilledboxnode = new TNode(nodename, nodename, "AirFilledBox", 0, y, 0) ;
339 fNodes->Add(airfilledboxnode) ;
d15a28e7 340 // crystals box inside air filled box
92862013 341 airfilledboxnode->cd() ;
342 y = fGeom->GetAirFilledBoxSize(1) / 2.0 - yl
d15a28e7 343 - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetModuleBoxThickness()
344 - fGeom->GetUpperPlateThickness() - fGeom->GetSecondUpperPlateThickness() ) ;
345 sprintf(nodename, "%s%d", "XTBox", i) ;
92862013 346 TNode * crystalsboxnode = new TNode(nodename, nodename, "CrystalsBox", 0, y, 0) ;
347 crystalsboxnode->SetLineColor(kColorXTAL) ;
348 fNodes->Add(crystalsboxnode) ;
d15a28e7 349 }
350}
351
352//____________________________________________________________________________
353void AliPHOSv0:: BuildGeometryforPPSD(void)
fe4da5cc 354{
b2a60966 355 // Build the PHOS-PPSD geometry for the ROOT display
356 //BEGIN_HTML
357 /*
358 <H2>
359 PPSD displayed by root
360 </H2>
361 <UL>
362 <LI> Zoom on PPSD: Front View
363 <P>
364 <CENTER>
365 <IMG Align=BOTTOM ALT="PPSD Front View" SRC="../images/AliPHOSv0PPSDFrontView.gif">
366 </CENTER></P></LI>
367 <LI> Zoom on PPSD: Perspective View
368 <P>
369 <CENTER>
370 <IMG Align=BOTTOM ALT="PPSD Prespective View" SRC="../images/AliPHOSv0PPSDPerspectiveView.gif">
371 </CENTER></P></LI>
372 </UL>
373 */
374 //END_HTML
92862013 375 Double_t const kRADDEG = 180.0 / kPI ;
d15a28e7 376
377 const Int_t kColorPHOS = kRed ;
378 const Int_t kColorPPSD = kGreen ;
379 const Int_t kColorGas = kBlue ;
380 const Int_t kColorAir = kYellow ;
381
382 // Box for a full PHOS module
383
384 new TBRIK( "PPSDBox", "PPSD box", "void", fGeom->GetPPSDBoxSize(0)/2,
385 fGeom->GetPPSDBoxSize(1)/2,
386 fGeom->GetPPSDBoxSize(2)/2 );
387
388 // Box containing one micromegas module
389
390 new TBRIK( "PPSDModule", "PPSD module", "void", fGeom->GetPPSDModuleSize(0)/2,
391 fGeom->GetPPSDModuleSize(1)/2,
392 fGeom->GetPPSDModuleSize(2)/2 );
393 // top lid
394
395 new TBRIK ( "TopLid", "Micromegas top lid", "void", fGeom->GetPPSDModuleSize(0)/2,
396 fGeom->GetLidThickness()/2,
397 fGeom->GetPPSDModuleSize(2)/2 ) ;
398 // composite panel (top and bottom)
399
400 new TBRIK ( "TopPanel", "Composite top panel", "void", ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
401 fGeom->GetCompositeThickness()/2,
402 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;
403
404 new TBRIK ( "BottomPanel", "Composite bottom panel", "void", ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
405 fGeom->GetCompositeThickness()/2,
406 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;
407 // gas gap (conversion and avalanche)
408
409 new TBRIK ( "GasGap", "gas gap", "void", ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
410 ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() )/2,
411 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;
412
413 // anode and cathode
414
415 new TBRIK ( "Anode", "Anode", "void", ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
416 fGeom->GetAnodeThickness()/2,
417 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;
418
419 new TBRIK ( "Cathode", "Cathode", "void", ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
420 fGeom->GetCathodeThickness()/2,
421 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;
422 // PC
423
424 new TBRIK ( "PCBoard", "Printed Circuit", "void", ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() )/2,
425 fGeom->GetPCThickness()/2,
426 ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() )/2 ) ;
427 // Gap between Lead and top micromegas
428
429 new TBRIK ( "LeadToM", "Air Gap top", "void", fGeom->GetPPSDBoxSize(0)/2,
430 fGeom->GetMicro1ToLeadGap()/2,
431 fGeom->GetPPSDBoxSize(2)/2 ) ;
432
433// Gap between Lead and bottom micromegas
434
435 new TBRIK ( "MToLead", "Air Gap bottom", "void", fGeom->GetPPSDBoxSize(0)/2,
436 fGeom->GetLeadToMicro2Gap()/2,
437 fGeom->GetPPSDBoxSize(2)/2 ) ;
438 // Lead converter
439
440 new TBRIK ( "Lead", "Lead converter", "void", fGeom->GetPPSDBoxSize(0)/2,
441 fGeom->GetLeadConverterThickness()/2,
442 fGeom->GetPPSDBoxSize(2)/2 ) ;
443
444 // position PPSD into ALICE
445
446 char * nodename = new char[20] ;
447 char * rotname = new char[20] ;
448
92862013 449 Float_t r = fGeom->GetIPtoTopLidDistance() + fGeom->GetPPSDBoxSize(1) / 2.0 ;
d15a28e7 450 Int_t number = 988 ;
92862013 451 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
d15a28e7 452
453 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) { // the number of PHOS modules
454 Float_t angle = fGeom->GetPHOSAngle(i) ;
455 sprintf(rotname, "%s%d", "rotg", number++) ;
456 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
92862013 457 top->cd();
d15a28e7 458 sprintf(nodename, "%s%d", "Moduleg", i) ;
92862013 459 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
460 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
461 TNode * ppsdboxnode = new TNode(nodename , nodename ,"PPSDBox", x, y, 0, rotname ) ;
462 ppsdboxnode->SetLineColor(kColorPPSD) ;
463 fNodes->Add(ppsdboxnode) ;
464 ppsdboxnode->cd() ;
d15a28e7 465 // inside the PPSD box:
466 // 1. fNumberOfModulesPhi x fNumberOfModulesZ top micromegas
92862013 467 x = ( fGeom->GetPPSDBoxSize(0) - fGeom->GetPPSDModuleSize(0) ) / 2. ;
31aa6d6c 468 {
469 for ( Int_t iphi = 1; iphi <= fGeom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
470 Float_t z = ( fGeom->GetPPSDBoxSize(2) - fGeom->GetPPSDModuleSize(2) ) / 2. ;
471 TNode * micro1node ;
472 for ( Int_t iz = 1; iz <= fGeom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
473 y = ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas1Thickness() ) / 2. ;
474 sprintf(nodename, "%s%d%d%d", "Mic1", i, iphi, iz) ;
475 micro1node = new TNode(nodename, nodename, "PPSDModule", x, y, z) ;
476 micro1node->SetLineColor(kColorPPSD) ;
477 fNodes->Add(micro1node) ;
478 // inside top micromegas
479 micro1node->cd() ;
480 // a. top lid
481 y = ( fGeom->GetMicromegas1Thickness() - fGeom->GetLidThickness() ) / 2. ;
482 sprintf(nodename, "%s%d%d%d", "Lid", i, iphi, iz) ;
483 TNode * toplidnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
484 toplidnode->SetLineColor(kColorPPSD) ;
485 fNodes->Add(toplidnode) ;
486 // b. composite panel
487 y = y - fGeom->GetLidThickness() / 2. - fGeom->GetCompositeThickness() / 2. ;
488 sprintf(nodename, "%s%d%d%d", "CompU", i, iphi, iz) ;
489 TNode * compupnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
490 compupnode->SetLineColor(kColorPPSD) ;
491 fNodes->Add(compupnode) ;
492 // c. anode
493 y = y - fGeom->GetCompositeThickness() / 2. - fGeom->GetAnodeThickness() / 2. ;
494 sprintf(nodename, "%s%d%d%d", "Ano", i, iphi, iz) ;
495 TNode * anodenode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
496 anodenode->SetLineColor(kColorPHOS) ;
497 fNodes->Add(anodenode) ;
498 // d. gas
499 y = y - fGeom->GetAnodeThickness() / 2. - ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2. ;
500 sprintf(nodename, "%s%d%d%d", "GGap", i, iphi, iz) ;
501 TNode * ggapnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
502 ggapnode->SetLineColor(kColorGas) ;
503 fNodes->Add(ggapnode) ;
d15a28e7 504 // f. cathode
31aa6d6c 505 y = y - ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2. - fGeom->GetCathodeThickness() / 2. ;
506 sprintf(nodename, "%s%d%d%d", "Cathode", i, iphi, iz) ;
507 TNode * cathodenode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
508 cathodenode->SetLineColor(kColorPHOS) ;
509 fNodes->Add(cathodenode) ;
510 // g. printed circuit
511 y = y - fGeom->GetCathodeThickness() / 2. - fGeom->GetPCThickness() / 2. ;
512 sprintf(nodename, "%s%d%d%d", "PC", i, iphi, iz) ;
513 TNode * pcnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
514 pcnode->SetLineColor(kColorPPSD) ;
515 fNodes->Add(pcnode) ;
516 // h. composite panel
517 y = y - fGeom->GetPCThickness() / 2. - fGeom->GetCompositeThickness() / 2. ;
518 sprintf(nodename, "%s%d%d%d", "CompDown", i, iphi, iz) ;
519 TNode * compdownnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
520 compdownnode->SetLineColor(kColorPPSD) ;
521 fNodes->Add(compdownnode) ;
522 z = z - fGeom->GetPPSDModuleSize(2) ;
523 ppsdboxnode->cd() ;
524 } // end of Z module loop
525 x = x - fGeom->GetPPSDModuleSize(0) ;
92862013 526 ppsdboxnode->cd() ;
31aa6d6c 527 } // end of phi module loop
528 }
d15a28e7 529 // 2. air gap
92862013 530 ppsdboxnode->cd() ;
531 y = ( fGeom->GetPPSDBoxSize(1) - 2 * fGeom->GetMicromegas1Thickness() - fGeom->GetMicro1ToLeadGap() ) / 2. ;
d15a28e7 532 sprintf(nodename, "%s%d", "GapUp", i) ;
92862013 533 TNode * gapupnode = new TNode(nodename, nodename, "LeadToM", 0, y, 0) ;
534 gapupnode->SetLineColor(kColorAir) ;
535 fNodes->Add(gapupnode) ;
d15a28e7 536 // 3. lead converter
92862013 537 y = y - fGeom->GetMicro1ToLeadGap() / 2. - fGeom->GetLeadConverterThickness() / 2. ;
d15a28e7 538 sprintf(nodename, "%s%d", "LeadC", i) ;
92862013 539 TNode * leadcnode = new TNode(nodename, nodename, "Lead", 0, y, 0) ;
540 leadcnode->SetLineColor(kColorPPSD) ;
541 fNodes->Add(leadcnode) ;
d15a28e7 542 // 4. air gap
92862013 543 y = y - fGeom->GetLeadConverterThickness() / 2. - fGeom->GetLeadToMicro2Gap() / 2. ;
d15a28e7 544 sprintf(nodename, "%s%d", "GapDown", i) ;
92862013 545 TNode * gapdownnode = new TNode(nodename, nodename, "MToLead", 0, y, 0) ;
546 gapdownnode->SetLineColor(kColorAir) ;
547 fNodes->Add(gapdownnode) ;
d15a28e7 548 // 5. fNumberOfModulesPhi x fNumberOfModulesZ bottom micromegas
92862013 549 x = ( fGeom->GetPPSDBoxSize(0) - fGeom->GetPPSDModuleSize(0) ) / 2. - fGeom->GetPhiDisplacement() ;
31aa6d6c 550 {
551 for ( Int_t iphi = 1; iphi <= fGeom->GetNumberOfModulesPhi(); iphi++ ) {
552 Float_t z = ( fGeom->GetPPSDBoxSize(2) - fGeom->GetPPSDModuleSize(2) ) / 2. - fGeom->GetZDisplacement() ;;
553 TNode * micro2node ;
554 for ( Int_t iz = 1; iz <= fGeom->GetNumberOfModulesZ(); iz++ ) {
555 y = - ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas2Thickness() ) / 2. ;
556 sprintf(nodename, "%s%d%d%d", "Mic2", i, iphi, iz) ;
557 micro2node = new TNode(nodename, nodename, "PPSDModule", x, y, z) ;
558 micro2node->SetLineColor(kColorPPSD) ;
559 fNodes->Add(micro2node) ;
560 // inside bottom micromegas
561 micro2node->cd() ;
d15a28e7 562 // a. top lid
92862013 563 y = ( fGeom->GetMicromegas2Thickness() - fGeom->GetLidThickness() ) / 2. ;
d15a28e7 564 sprintf(nodename, "%s%d", "Lidb", i) ;
92862013 565 TNode * toplidbnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ;
566 toplidbnode->SetLineColor(kColorPPSD) ;
567 fNodes->Add(toplidbnode) ;
d15a28e7 568 // b. composite panel
92862013 569 y = y - fGeom->GetLidThickness() / 2. - fGeom->GetCompositeThickness() / 2. ;
d15a28e7 570 sprintf(nodename, "%s%d", "CompUb", i) ;
92862013 571 TNode * compupbnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ;
572 compupbnode->SetLineColor(kColorPPSD) ;
573 fNodes->Add(compupbnode) ;
d15a28e7 574 // c. anode
92862013 575 y = y - fGeom->GetCompositeThickness() / 2. - fGeom->GetAnodeThickness() / 2. ;
d15a28e7 576 sprintf(nodename, "%s%d", "Anob", i) ;
92862013 577 TNode * anodebnode = new TNode(nodename, nodename, "Anode", 0, y, 0) ;
578 anodebnode->SetLineColor(kColorPPSD) ;
579 fNodes->Add(anodebnode) ;
d15a28e7 580 // d. conversion gas
92862013 581 y = y - fGeom->GetAnodeThickness() / 2. - ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2. ;
d15a28e7 582 sprintf(nodename, "%s%d", "GGapb", i) ;
92862013 583 TNode * ggapbnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ;
584 ggapbnode->SetLineColor(kColorGas) ;
585 fNodes->Add(ggapbnode) ;
d15a28e7 586 // f. cathode
92862013 587 y = y - ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2. - fGeom->GetCathodeThickness() / 2. ;
d15a28e7 588 sprintf(nodename, "%s%d", "Cathodeb", i) ;
92862013 589 TNode * cathodebnode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ;
590 cathodebnode->SetLineColor(kColorPPSD) ;
591 fNodes->Add(cathodebnode) ;
d15a28e7 592 // g. printed circuit
92862013 593 y = y - fGeom->GetCathodeThickness() / 2. - fGeom->GetPCThickness() / 2. ;
d15a28e7 594 sprintf(nodename, "%s%d", "PCb", i) ;
92862013 595 TNode * pcbnode = new TNode(nodename, nodename, "PCBoard", 0, y, 0) ;
596 pcbnode->SetLineColor(kColorPPSD) ;
597 fNodes->Add(pcbnode) ;
d15a28e7 598 // h. composite pane
92862013 599 y = y - fGeom->GetPCThickness() / 2. - fGeom->GetCompositeThickness() / 2. ;
d15a28e7 600 sprintf(nodename, "%s%d", "CompDownb", i) ;
92862013 601 TNode * compdownbnode = new TNode(nodename, nodename, "BottomPanel", 0, y, 0) ;
602 compdownbnode->SetLineColor(kColorPPSD) ;
603 fNodes->Add(compdownbnode) ;
604 z = z - fGeom->GetPPSDModuleSize(2) ;
605 ppsdboxnode->cd() ;
d15a28e7 606 } // end of Z module loop
92862013 607 x = x - fGeom->GetPPSDModuleSize(0) ;
608 ppsdboxnode->cd() ;
31aa6d6c 609 } // end of phi module loop
610 }
611 } // PHOS modules
612
613 delete rotname ;
614 delete nodename ;
615
fe4da5cc 616}
617
d15a28e7 618//____________________________________________________________________________
fe4da5cc 619void AliPHOSv0::CreateGeometry()
620{
b2a60966 621 // Create the PHOS geometry for Geant
d15a28e7 622
92862013 623 AliPHOSv0 *phostmp = (AliPHOSv0*)gAlice->GetModule("PHOS") ;
d15a28e7 624
92862013 625 if ( phostmp == NULL ) {
d15a28e7 626
627 fprintf(stderr, "PHOS detector not found!\n") ;
628 return;
fe4da5cc 629
d15a28e7 630 }
d15a28e7 631 // Get pointer to the array containing media indeces
92862013 632 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
d15a28e7 633
92862013 634 Float_t bigbox[3] ;
635 bigbox[0] = fGeom->GetOuterBoxSize(0) / 2.0 ;
636 bigbox[1] = ( fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) / 2.0 ;
637 bigbox[2] = fGeom->GetOuterBoxSize(2) / 2.0 ;
d15a28e7 638
92862013 639 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
d15a28e7 640
641 this->CreateGeometryforPHOS() ;
642 if ( strcmp( fGeom->GetName(), "GPS2") == 0 )
643 this->CreateGeometryforPPSD() ;
644 else
645 cout << "AliPHOSv0::CreateGeometry : no charged particle identification system installed" << endl;
646
647 // --- Position PHOS mdules in ALICE setup ---
648
92862013 649 Int_t idrotm[99] ;
650 Double_t const kRADDEG = 180.0 / kPI ;
d15a28e7 651
652 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
653
654 Float_t angle = fGeom->GetPHOSAngle(i) ;
92862013 655 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
d15a28e7 656
92862013 657 Float_t r = fGeom->GetIPtoOuterCoverDistance() + ( fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) / 2.0 ;
d15a28e7 658
92862013 659 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
660 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
d15a28e7 661
92862013 662 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
d15a28e7 663
664 } // for GetNModules
665
fe4da5cc 666}
d15a28e7 667
668//____________________________________________________________________________
669void AliPHOSv0::CreateGeometryforPHOS()
670{
b2a60966 671 // Create the PHOS-EMC geometry for GEANT
672 //BEGIN_HTML
673 /*
674 <H2>
675 Geant3 geometry tree of PHOS-EMC in ALICE
676 </H2>
677 <P><CENTER>
678 <IMG Align=BOTTOM ALT="EMC geant tree" SRC="../images/EMCinAlice.gif">
679 </CENTER><P>
680 */
681 //END_HTML
682
683 // Get pointer to the array containing media indexes
92862013 684 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
d15a28e7 685
686 // ---
687 // --- Define PHOS box volume, fPUFPill with thermo insulating foam ---
688 // --- Foam Thermo Insulating outer cover dimensions ---
92862013 689 // --- Put it in bigbox = PHOS
d15a28e7 690
92862013 691 Float_t dphos[3] ;
692 dphos[0] = fGeom->GetOuterBoxSize(0) / 2.0 ;
693 dphos[1] = fGeom->GetOuterBoxSize(1) / 2.0 ;
694 dphos[2] = fGeom->GetOuterBoxSize(2) / 2.0 ;
d15a28e7 695
92862013 696 gMC->Gsvolu("EMCA", "BOX ", idtmed[706], dphos, 3) ;
d15a28e7 697
92862013 698 Float_t yO = - fGeom->GetPPSDBoxSize(1) / 2.0 ;
d15a28e7 699
92862013 700 gMC->Gspos("EMCA", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 701
702 // ---
703 // --- Define Textolit Wall box, position inside EMCA ---
704 // --- Textolit Wall box dimentions ---
705
706
92862013 707 Float_t dptxw[3];
708 dptxw[0] = fGeom->GetTextolitBoxSize(0) / 2.0 ;
709 dptxw[1] = fGeom->GetTextolitBoxSize(1) / 2.0 ;
710 dptxw[2] = fGeom->GetTextolitBoxSize(2) / 2.0 ;
d15a28e7 711
92862013 712 gMC->Gsvolu("PTXW", "BOX ", idtmed[707], dptxw, 3);
d15a28e7 713
92862013 714 yO = ( fGeom->GetOuterBoxThickness(1) - fGeom->GetUpperPlateThickness() ) / 2. ;
d15a28e7 715
92862013 716 gMC->Gspos("PTXW", 1, "EMCA", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 717
718 // ---
719 // --- Define Upper Polystyrene Foam Plate, place inside PTXW ---
720 // --- immediately below Foam Thermo Insulation Upper plate ---
721
722 // --- Upper Polystyrene Foam plate thickness ---
723
92862013 724 Float_t dpufp[3] ;
725 dpufp[0] = fGeom->GetTextolitBoxSize(0) / 2.0 ;
726 dpufp[1] = fGeom->GetSecondUpperPlateThickness() / 2. ;
727 dpufp[2] = fGeom->GetTextolitBoxSize(2) /2.0 ;
d15a28e7 728
92862013 729 gMC->Gsvolu("PUFP", "BOX ", idtmed[703], dpufp, 3) ;
d15a28e7 730
92862013 731 yO = ( fGeom->GetTextolitBoxSize(1) - fGeom->GetSecondUpperPlateThickness() ) / 2.0 ;
d15a28e7 732
92862013 733 gMC->Gspos("PUFP", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 734
735 // ---
736 // --- Define air-filled box, place inside PTXW ---
737 // --- Inner AIR volume dimensions ---
fe4da5cc 738
d15a28e7 739
92862013 740 Float_t dpair[3] ;
741 dpair[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
742 dpair[1] = fGeom->GetAirFilledBoxSize(1) / 2.0 ;
743 dpair[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
d15a28e7 744
92862013 745 gMC->Gsvolu("PAIR", "BOX ", idtmed[798], dpair, 3) ;
d15a28e7 746
92862013 747 yO = ( fGeom->GetTextolitBoxSize(1) - fGeom->GetAirFilledBoxSize(1) ) / 2.0 - fGeom->GetSecondUpperPlateThickness() ;
d15a28e7 748
92862013 749 gMC->Gspos("PAIR", 1, "PTXW", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 750
751// --- Dimensions of PbWO4 crystal ---
752
92862013 753 Float_t xtlX = fGeom->GetCrystalSize(0) ;
754 Float_t xtlY = fGeom->GetCrystalSize(1) ;
755 Float_t xtlZ = fGeom->GetCrystalSize(2) ;
d15a28e7 756
92862013 757 Float_t dptcb[3] ;
758 dptcb[0] = fGeom->GetNPhi() * ( xtlX + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 + fGeom->GetModuleBoxThickness() ;
759 dptcb[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0
d15a28e7 760 + fGeom->GetModuleBoxThickness() / 2.0 ;
92862013 761 dptcb[2] = fGeom->GetNZ() * ( xtlZ + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 + fGeom->GetModuleBoxThickness() ;
d15a28e7 762
92862013 763 gMC->Gsvolu("PTCB", "BOX ", idtmed[706], dptcb, 3) ;
d15a28e7 764
92862013 765 yO = fGeom->GetAirFilledBoxSize(1) / 2.0 - dptcb[1]
d15a28e7 766 - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetModuleBoxThickness()
767 - fGeom->GetUpperPlateThickness() - fGeom->GetSecondUpperPlateThickness() ) ;
768
92862013 769 gMC->Gspos("PTCB", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 770
771 // ---
772 // --- Define Crystal BLock filled with air, position it inside PTCB ---
92862013 773 Float_t dpcbl[3] ;
d15a28e7 774
92862013 775 dpcbl[0] = fGeom->GetNPhi() * ( xtlX + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 ;
776 dpcbl[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 ;
777 dpcbl[2] = fGeom->GetNZ() * ( xtlZ + 2 * fGeom->GetGapBetweenCrystals() ) / 2.0 ;
d15a28e7 778
92862013 779 gMC->Gsvolu("PCBL", "BOX ", idtmed[798], dpcbl, 3) ;
d15a28e7 780
781 // --- Divide PCBL in X (phi) and Z directions --
782 gMC->Gsdvn("PROW", "PCBL", Int_t (fGeom->GetNPhi()), 1) ;
783 gMC->Gsdvn("PCEL", "PROW", Int_t (fGeom->GetNZ()), 3) ;
784
92862013 785 yO = -fGeom->GetModuleBoxThickness() / 2.0 ;
d15a28e7 786
92862013 787 gMC->Gspos("PCBL", 1, "PTCB", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 788
789 // ---
790 // --- Define STeel (actually, it's titanium) Cover volume, place inside PCEL
92862013 791 Float_t dpstc[3] ;
d15a28e7 792
92862013 793 dpstc[0] = ( xtlX + 2 * fGeom->GetCrystalWrapThickness() ) / 2.0 ;
794 dpstc[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 ;
795 dpstc[2] = ( xtlZ + 2 * fGeom->GetCrystalWrapThickness() + 2 * fGeom->GetCrystalHolderThickness() ) / 2.0 ;
d15a28e7 796
92862013 797 gMC->Gsvolu("PSTC", "BOX ", idtmed[704], dpstc, 3) ;
d15a28e7 798
799 gMC->Gspos("PSTC", 1, "PCEL", 0.0, 0.0, 0.0, 0, "ONLY") ;
800
801 // ---
802 // --- Define Tyvek volume, place inside PSTC ---
92862013 803 Float_t dppap[3] ;
d15a28e7 804
92862013 805 dppap[0] = xtlX / 2.0 + fGeom->GetCrystalWrapThickness() ;
806 dppap[1] = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 ;
807 dppap[2] = xtlZ / 2.0 + fGeom->GetCrystalWrapThickness() ;
d15a28e7 808
92862013 809 gMC->Gsvolu("PPAP", "BOX ", idtmed[702], dppap, 3) ;
d15a28e7 810
92862013 811 yO = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0
812 - ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() + fGeom->GetCrystalHolderThickness() ) / 2.0 ;
d15a28e7 813
92862013 814 gMC->Gspos("PPAP", 1, "PSTC", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 815
816 // ---
817 // --- Define PbWO4 crystal volume, place inside PPAP ---
92862013 818 Float_t dpxtl[3] ;
d15a28e7 819
92862013 820 dpxtl[0] = xtlX / 2.0 ;
821 dpxtl[1] = xtlY / 2.0 ;
822 dpxtl[2] = xtlZ / 2.0 ;
d15a28e7 823
92862013 824 gMC->Gsvolu("PXTL", "BOX ", idtmed[699], dpxtl, 3) ;
d15a28e7 825
92862013 826 yO = ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 - xtlY / 2.0 - fGeom->GetCrystalWrapThickness() ;
d15a28e7 827
92862013 828 gMC->Gspos("PXTL", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 829
830 // ---
831 // --- Define crystal support volume, place inside PPAP ---
92862013 832 Float_t dpsup[3] ;
d15a28e7 833
92862013 834 dpsup[0] = xtlX / 2.0 + fGeom->GetCrystalWrapThickness() ;
835 dpsup[1] = fGeom->GetCrystalSupportHeight() / 2.0 ;
836 dpsup[2] = xtlZ / 2.0 + fGeom->GetCrystalWrapThickness() ;
d15a28e7 837
92862013 838 gMC->Gsvolu("PSUP", "BOX ", idtmed[798], dpsup, 3) ;
d15a28e7 839
92862013 840 yO = fGeom->GetCrystalSupportHeight() / 2.0 - ( xtlY + fGeom->GetCrystalSupportHeight() + fGeom->GetCrystalWrapThickness() ) / 2.0 ;
d15a28e7 841
92862013 842 gMC->Gspos("PSUP", 1, "PPAP", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 843
844 // ---
845 // --- Define PIN-diode volume and position it inside crystal support ---
846 // --- right behind PbWO4 crystal
847
848 // --- PIN-diode dimensions ---
849
850
92862013 851 Float_t dppin[3] ;
852 dppin[0] = fGeom->GetPinDiodeSize(0) / 2.0 ;
853 dppin[1] = fGeom->GetPinDiodeSize(1) / 2.0 ;
854 dppin[2] = fGeom->GetPinDiodeSize(2) / 2.0 ;
d15a28e7 855
92862013 856 gMC->Gsvolu("PPIN", "BOX ", idtmed[705], dppin, 3) ;
d15a28e7 857
92862013 858 yO = fGeom->GetCrystalSupportHeight() / 2.0 - fGeom->GetPinDiodeSize(1) / 2.0 ;
d15a28e7 859
92862013 860 gMC->Gspos("PPIN", 1, "PSUP", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 861
862 // ---
863 // --- Define Upper Cooling Panel, place it on top of PTCB ---
92862013 864 Float_t dpucp[3] ;
d15a28e7 865 // --- Upper Cooling Plate thickness ---
866
92862013 867 dpucp[0] = dptcb[0] ;
868 dpucp[1] = fGeom->GetUpperCoolingPlateThickness() ;
869 dpucp[2] = dptcb[2] ;
d15a28e7 870
92862013 871 gMC->Gsvolu("PUCP", "BOX ", idtmed[701], dpucp,3) ;
d15a28e7 872
92862013 873 yO = ( fGeom->GetAirFilledBoxSize(1) - fGeom->GetUpperCoolingPlateThickness() ) / 2.
d15a28e7 874 - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetModuleBoxThickness()
875 - fGeom->GetUpperPlateThickness() - fGeom->GetSecondUpperPlateThickness() - fGeom->GetUpperCoolingPlateThickness() ) ;
876
92862013 877 gMC->Gspos("PUCP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 878
879 // ---
880 // --- Define Al Support Plate, position it inside PAIR ---
881 // --- right beneath PTCB ---
882 // --- Al Support Plate thickness ---
883
92862013 884 Float_t dpasp[3] ;
885 dpasp[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
886 dpasp[1] = fGeom->GetSupportPlateThickness() / 2.0 ;
887 dpasp[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
d15a28e7 888
92862013 889 gMC->Gsvolu("PASP", "BOX ", idtmed[701], dpasp, 3) ;
d15a28e7 890
92862013 891 yO = ( fGeom->GetAirFilledBoxSize(1) - fGeom->GetSupportPlateThickness() ) / 2.
d15a28e7 892 - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance()
92862013 893 - fGeom->GetUpperPlateThickness() - fGeom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 ) ;
d15a28e7 894
92862013 895 gMC->Gspos("PASP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 896
897 // ---
898 // --- Define Thermo Insulating Plate, position it inside PAIR ---
899 // --- right beneath PASP ---
900 // --- Lower Thermo Insulating Plate thickness ---
901
92862013 902 Float_t dptip[3] ;
903 dptip[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
904 dptip[1] = fGeom->GetLowerThermoPlateThickness() / 2.0 ;
905 dptip[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
d15a28e7 906
92862013 907 gMC->Gsvolu("PTIP", "BOX ", idtmed[706], dptip, 3) ;
d15a28e7 908
92862013 909 yO = ( fGeom->GetAirFilledBoxSize(1) - fGeom->GetLowerThermoPlateThickness() ) / 2.
d15a28e7 910 - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetUpperPlateThickness()
92862013 911 - fGeom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + fGeom->GetSupportPlateThickness() ) ;
d15a28e7 912
92862013 913 gMC->Gspos("PTIP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 914
915 // ---
916 // --- Define Textolit Plate, position it inside PAIR ---
917 // --- right beneath PTIP ---
918 // --- Lower Textolit Plate thickness ---
919
92862013 920 Float_t dptxp[3] ;
921 dptxp[0] = fGeom->GetAirFilledBoxSize(0) / 2.0 ;
922 dptxp[1] = fGeom->GetLowerTextolitPlateThickness() / 2.0 ;
923 dptxp[2] = fGeom->GetAirFilledBoxSize(2) / 2.0 ;
d15a28e7 924
92862013 925 gMC->Gsvolu("PTXP", "BOX ", idtmed[707], dptxp, 3) ;
d15a28e7 926
92862013 927 yO = ( fGeom->GetAirFilledBoxSize(1) - fGeom->GetLowerTextolitPlateThickness() ) / 2.
d15a28e7 928 - ( fGeom->GetIPtoCrystalSurface() - fGeom->GetIPtoOuterCoverDistance() - fGeom->GetUpperPlateThickness()
92862013 929 - fGeom->GetSecondUpperPlateThickness() + dpcbl[1] * 2 + fGeom->GetSupportPlateThickness()
d15a28e7 930 + fGeom->GetLowerThermoPlateThickness() ) ;
931
92862013 932 gMC->Gspos("PTXP", 1, "PAIR", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 933
934}
935
936//____________________________________________________________________________
937void AliPHOSv0::CreateGeometryforPPSD()
fe4da5cc 938{
b2a60966 939 // Create the PHOS-PPSD geometry for GEANT
940
941 //BEGIN_HTML
942 /*
943 <H2>
944 Geant3 geometry tree of PHOS-PPSD in ALICE
945 </H2>
946 <P><CENTER>
947 <IMG Align=BOTTOM ALT="PPSD geant tree" SRC="../images/PPSDinAlice.gif">
948 </CENTER><P>
949 */
950 //END_HTML
951
952 // Get pointer to the array containing media indexes
92862013 953 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
d15a28e7 954
92862013 955 // The box containing all ppsd's for one PHOS module filled with air
956 Float_t ppsd[3] ;
957 ppsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;
958 ppsd[1] = fGeom->GetPPSDBoxSize(1) / 2.0 ;
959 ppsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
fe4da5cc 960
92862013 961 gMC->Gsvolu("PPSD", "BOX ", idtmed[798], ppsd, 3) ;
d15a28e7 962
92862013 963 Float_t yO = fGeom->GetOuterBoxSize(1) / 2.0 ;
d15a28e7 964
92862013 965 gMC->Gspos("PPSD", 1, "PHOS", 0.0, yO, 0.0, 0, "ONLY") ;
d15a28e7 966
967 // Now we build a micromegas module
968 // The box containing the whole module filled with epoxy (FR4)
969
92862013 970 Float_t mppsd[3] ;
971 mppsd[0] = fGeom->GetPPSDModuleSize(0) / 2.0 ;
972 mppsd[1] = fGeom->GetPPSDModuleSize(1) / 2.0 ;
973 mppsd[2] = fGeom->GetPPSDModuleSize(2) / 2.0 ;
d15a28e7 974
92862013 975 gMC->Gsvolu("MPPS", "BOX ", idtmed[708], mppsd, 3) ;
d15a28e7 976
92862013 977 // Inside mppsd :
d15a28e7 978 // 1. The Top Lid made of epoxy (FR4)
979
92862013 980 Float_t tlppsd[3] ;
981 tlppsd[0] = fGeom->GetPPSDModuleSize(0) / 2.0 ;
982 tlppsd[1] = fGeom->GetLidThickness() / 2.0 ;
983 tlppsd[2] = fGeom->GetPPSDModuleSize(2) / 2.0 ;
d15a28e7 984
92862013 985 gMC->Gsvolu("TLPS", "BOX ", idtmed[708], tlppsd, 3) ;
d15a28e7 986
92862013 987 Float_t y0 = ( fGeom->GetMicromegas1Thickness() - fGeom->GetLidThickness() ) / 2. ;
d15a28e7 988
92862013 989 gMC->Gspos("TLPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 990
991 // 2. the upper panel made of composite material
992
92862013 993 Float_t upppsd[3] ;
994 upppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
995 upppsd[1] = fGeom->GetCompositeThickness() / 2.0 ;
996 upppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
d15a28e7 997
92862013 998 gMC->Gsvolu("UPPS", "BOX ", idtmed[709], upppsd, 3) ;
d15a28e7 999
92862013 1000 y0 = y0 - fGeom->GetLidThickness() / 2. - fGeom->GetCompositeThickness() / 2. ;
d15a28e7 1001
92862013 1002 gMC->Gspos("UPPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1003
1004 // 3. the anode made of Copper
1005
92862013 1006 Float_t anppsd[3] ;
1007 anppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
1008 anppsd[1] = fGeom->GetAnodeThickness() / 2.0 ;
1009 anppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
d15a28e7 1010
92862013 1011 gMC->Gsvolu("ANPS", "BOX ", idtmed[710], anppsd, 3) ;
d15a28e7 1012
92862013 1013 y0 = y0 - fGeom->GetCompositeThickness() / 2. - fGeom->GetAnodeThickness() / 2. ;
d15a28e7 1014
92862013 1015 gMC->Gspos("ANPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1016
1017 // 4. the conversion gap + avalanche gap filled with gas
1018
92862013 1019 Float_t ggppsd[3] ;
1020 ggppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
1021 ggppsd[1] = ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2.0 ;
1022 ggppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
d15a28e7 1023
92862013 1024 gMC->Gsvolu("GGPS", "BOX ", idtmed[715], ggppsd, 3) ;
d15a28e7 1025
1026 // --- Divide GGPP in X (phi) and Z directions --
1027 gMC->Gsdvn("GROW", "GGPS", fGeom->GetNumberOfPadsPhi(), 1) ;
1028 gMC->Gsdvn("GCEL", "GROW", fGeom->GetNumberOfPadsZ() , 3) ;
1029
92862013 1030 y0 = y0 - fGeom->GetAnodeThickness() / 2. - ( fGeom->GetConversionGap() + fGeom->GetAvalancheGap() ) / 2. ;
d15a28e7 1031
92862013 1032 gMC->Gspos("GGPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1033
1034
1035 // 6. the cathode made of Copper
1036
92862013 1037 Float_t cappsd[3] ;
1038 cappsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
1039 cappsd[1] = fGeom->GetCathodeThickness() / 2.0 ;
1040 cappsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
d15a28e7 1041
92862013 1042 gMC->Gsvolu("CAPS", "BOX ", idtmed[710], cappsd, 3) ;
d15a28e7 1043
92862013 1044 y0 = y0 - ( fGeom->GetAvalancheGap() + fGeom->GetAvalancheGap() ) / 2. - fGeom->GetCathodeThickness() / 2. ;
d15a28e7 1045
92862013 1046 gMC->Gspos("CAPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1047
1048 // 7. the printed circuit made of G10
1049
92862013 1050 Float_t pcppsd[3] ;
1051 pcppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2,.0 ;
1052 pcppsd[1] = fGeom->GetPCThickness() / 2.0 ;
1053 pcppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
d15a28e7 1054
92862013 1055 gMC->Gsvolu("PCPS", "BOX ", idtmed[711], cappsd, 3) ;
d15a28e7 1056
92862013 1057 y0 = y0 - fGeom->GetCathodeThickness() / 2. - fGeom->GetPCThickness() / 2. ;
d15a28e7 1058
92862013 1059 gMC->Gspos("PCPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1060
1061 // 8. the lower panel made of composite material
1062
92862013 1063 Float_t lpppsd[3] ;
1064 lpppsd[0] = ( fGeom->GetPPSDModuleSize(0) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
1065 lpppsd[1] = fGeom->GetCompositeThickness() / 2.0 ;
1066 lpppsd[2] = ( fGeom->GetPPSDModuleSize(2) - fGeom->GetMicromegasWallThickness() ) / 2.0 ;
d15a28e7 1067
92862013 1068 gMC->Gsvolu("LPPS", "BOX ", idtmed[709], lpppsd, 3) ;
d15a28e7 1069
92862013 1070 y0 = y0 - fGeom->GetPCThickness() / 2. - fGeom->GetCompositeThickness() / 2. ;
d15a28e7 1071
92862013 1072 gMC->Gspos("LPPS", 1, "MPPS", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1073
92862013 1074 // Position the fNumberOfModulesPhi x fNumberOfModulesZ modules (mppsd) inside PPSD to cover a PHOS module
d15a28e7 1075 // the top and bottom one's (which are assumed identical) :
1076
92862013 1077 Float_t yt = ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas1Thickness() ) / 2. ;
1078 Float_t yb = - ( fGeom->GetPPSDBoxSize(1) - fGeom->GetMicromegas2Thickness() ) / 2. ;
d15a28e7 1079
92862013 1080 Int_t copyNumbertop = 0 ;
1081 Int_t copyNumberbot = fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() ;
d15a28e7 1082
92862013 1083 Float_t x = ( fGeom->GetPPSDBoxSize(0) - fGeom->GetPPSDModuleSize(0) ) / 2. ;
d15a28e7 1084
1085 for ( Int_t iphi = 1; iphi <= fGeom->GetNumberOfModulesPhi(); iphi++ ) { // the number of micromegas modules in phi per PHOS module
92862013 1086 Float_t z = ( fGeom->GetPPSDBoxSize(2) - fGeom->GetPPSDModuleSize(2) ) / 2. ;
d15a28e7 1087
1088 for ( Int_t iz = 1; iz <= fGeom->GetNumberOfModulesZ(); iz++ ) { // the number of micromegas modules in z per PHOS module
92862013 1089 gMC->Gspos("MPPS", ++copyNumbertop, "PPSD", x, yt, z, 0, "ONLY") ;
1090 gMC->Gspos("MPPS", ++copyNumberbot, "PPSD", x, yb, z, 0, "ONLY") ;
1091 z = z - fGeom->GetPPSDModuleSize(2) ;
d15a28e7 1092 } // end of Z module loop
92862013 1093 x = x - fGeom->GetPPSDModuleSize(0) ;
d15a28e7 1094 } // end of phi module loop
1095
1096 // The Lead converter between two air gaps
1097 // 1. Upper air gap
1098
92862013 1099 Float_t uappsd[3] ;
1100 uappsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;
1101 uappsd[1] = fGeom->GetMicro1ToLeadGap() / 2.0 ;
1102 uappsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
d15a28e7 1103
92862013 1104 gMC->Gsvolu("UAPPSD", "BOX ", idtmed[798], uappsd, 3) ;
d15a28e7 1105
92862013 1106 y0 = ( fGeom->GetPPSDBoxSize(1) - 2 * fGeom->GetMicromegas1Thickness() - fGeom->GetMicro1ToLeadGap() ) / 2. ;
d15a28e7 1107
92862013 1108 gMC->Gspos("UAPPSD", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1109
1110 // 2. Lead converter
1111
92862013 1112 Float_t lcppsd[3] ;
1113 lcppsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;
1114 lcppsd[1] = fGeom->GetLeadConverterThickness() / 2.0 ;
1115 lcppsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
d15a28e7 1116
92862013 1117 gMC->Gsvolu("LCPPSD", "BOX ", idtmed[712], lcppsd, 3) ;
d15a28e7 1118
92862013 1119 y0 = y0 - fGeom->GetMicro1ToLeadGap() / 2. - fGeom->GetLeadConverterThickness() / 2. ;
d15a28e7 1120
92862013 1121 gMC->Gspos("LCPPSD", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1122
1123 // 3. Lower air gap
1124
92862013 1125 Float_t lappsd[3] ;
1126 lappsd[0] = fGeom->GetPPSDBoxSize(0) / 2.0 ;
1127 lappsd[1] = fGeom->GetLeadToMicro2Gap() / 2.0 ;
1128 lappsd[2] = fGeom->GetPPSDBoxSize(2) / 2.0 ;
d15a28e7 1129
92862013 1130 gMC->Gsvolu("LAPPSD", "BOX ", idtmed[798], lappsd, 3) ;
fe4da5cc 1131
92862013 1132 y0 = y0 - fGeom->GetLeadConverterThickness() / 2. - fGeom->GetLeadToMicro2Gap() / 2. ;
d15a28e7 1133
92862013 1134 gMC->Gspos("LAPPSD", 1, "PPSD", 0.0, y0, 0.0, 0, "ONLY") ;
d15a28e7 1135
fe4da5cc 1136}
1137
d15a28e7 1138//___________________________________________________________________________
b2a60966 1139Int_t AliPHOSv0::Digitize(Float_t Energy)
1140{
1141 // Applies the energy calibration
1142
83974468 1143 Float_t fB = 100000000. ;
d15a28e7 1144 Float_t fA = 0. ;
1145 Int_t chan = Int_t(fA + Energy*fB ) ;
1146 return chan ;
1147}
31aa6d6c 1148
d15a28e7 1149//___________________________________________________________________________
1150void AliPHOSv0::FinishEvent()
fe4da5cc 1151{
b2a60966 1152 // Makes the digits from the sum of summed hit in a single crystal or PPSD gas cell
1153 // Adds to the energy the electronic noise
1154 // Keeps digits with energy above fDigitThreshold
1155
83974468 1156 // Save the cumulated hits instead of raw hits (need to create the branch myself)
1157 // It is put in the Digit Tree because the TreeH is filled after each primary
1158 // and the TreeD at the end of the event.
1159 if ( fTmpHits && gAlice->TreeD() ) {
1160 char branchname[10] ;
1161 sprintf(branchname, "%sCH", GetName()) ;
1162 gAlice->TreeD()->Branch(branchname, &fTmpHits, fBufferSize) ;
1163 } else
1164 cout << "AliPHOSv0::AliPHOSv0: Failed to create branch PHOSCH in TreeD " << endl ;
1165
d15a28e7 1166 Int_t i ;
cf239357 1167 Int_t relid[4];
ff4c968a 1168 Int_t j ;
d15a28e7 1169 TClonesArray &lDigits = *fDigits ;
92862013 1170 AliPHOSHit * hit ;
ff4c968a 1171 AliPHOSDigit * newdigit ;
1172 AliPHOSDigit * curdigit ;
1173 Bool_t deja = kFALSE ;
b2a60966 1174
d15a28e7 1175 for ( i = 0 ; i < fNTmpHits ; i++ ) {
92862013 1176 hit = (AliPHOSHit*)fTmpHits->At(i) ;
ff4c968a 1177 newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
6a72c964 1178 deja =kFALSE ;
ff4c968a 1179 for ( j = 0 ; j < fNdigits ; j++) {
cf239357 1180 curdigit = (AliPHOSDigit*) lDigits[j] ;
ff4c968a 1181 if ( *curdigit == *newdigit) {
cf239357 1182 *curdigit = *curdigit + *newdigit ;
ff4c968a 1183 deja = kTRUE ;
1184 }
1185 }
d1232693 1186 if ( !deja ) {
ff4c968a 1187 new(lDigits[fNdigits]) AliPHOSDigit(* newdigit) ;
1188 fNdigits++ ;
1189 }
1190
1191 delete newdigit ;
0869cea5 1192 }
ff4c968a 1193
cf239357 1194 // Noise induced by the PIN diode of the PbWO crystals
26d4b141 1195
0869cea5 1196 Float_t energyandnoise ;
1197 for ( i = 0 ; i < fNdigits ; i++ ) {
ff4c968a 1198 newdigit = (AliPHOSDigit * ) fDigits->At(i) ;
cf239357 1199 fGeom->AbsToRelNumbering(newdigit->GetId(), relid) ;
ae37f159 1200
cf239357 1201 if (relid[1]==0){ // Digits belong to EMC (PbW0_4 crystals)
3a6a7952 1202 energyandnoise = newdigit->GetAmp() + Digitize(gRandom->Gaus(0., fPinElectronicNoise)) ;
ae37f159 1203
cf239357 1204 if (energyandnoise < 0 )
1205 energyandnoise = 0 ;
ae37f159 1206
ae37f159 1207 if ( newdigit->GetAmp() < fDigitThreshold ) // if threshold not surpassed, remove digit from list
1208 fDigits->RemoveAt(i) ;
cf239357 1209 }
fe4da5cc 1210 }
31aa6d6c 1211
83974468 1212 fDigits->Compress() ;
1213
1214 fNdigits = fDigits->GetEntries() ;
1215 for (i = 0 ; i < fNdigits ; i++) {
1216 newdigit = (AliPHOSDigit *) fDigits->At(i) ;
1217 newdigit->SetIndexInList(i) ;
1218 }
31aa6d6c 1219
fe4da5cc 1220}
d15a28e7 1221
1222//____________________________________________________________________________
1223void AliPHOSv0::Init(void)
1224{
b2a60966 1225 // Just prints an information message
1226
d15a28e7 1227 Int_t i;
1228
1229 printf("\n");
1230 for(i=0;i<35;i++) printf("*");
1231 printf(" PHOS_INIT ");
1232 for(i=0;i<35;i++) printf("*");
1233 printf("\n");
1234
1235 // Here the PHOS initialisation code (if any!)
1236
1237 for(i=0;i<80;i++) printf("*");
1238 printf("\n");
1239
1240}
1241
1242//___________________________________________________________________________
1243void AliPHOSv0::MakeBranch(Option_t* opt)
1244{
b2a60966 1245 // Create new branche in the current Root Tree in the digit Tree
1246
d15a28e7 1247 AliDetector::MakeBranch(opt) ;
1248
1249 char branchname[10];
1250 sprintf(branchname,"%s",GetName());
c198e326 1251 char *cdD = strstr(opt,"D");
d15a28e7 1252
c198e326 1253 if (fDigits && gAlice->TreeD() && cdD) {
31aa6d6c 1254 gAlice->TreeD()->Branch(branchname, &fDigits, fBufferSize);
c198e326 1255 }
d15a28e7 1256}
d15a28e7 1257
9110b6c7 1258//____________________________________________________________________________
1259RecPointsList * AliPHOSv0::PpsdRecPoints(Int_t evt)
1260{
1261 // returns the pointer to the PPSD RecPoints list
1262 // if the list is empty, get it from TreeR on the disk file
1263
1264 RecPointsList * rv = 0 ;
1265
1266 if ( fPpsdRecPoints )
1267 rv = fPpsdRecPoints ;
1268
1269 else {
1270 fPpsdRecPoints = new TClonesArray("AliPHOSPpsdRecPoint", 100) ;
1271 gAlice->GetEvent(evt) ;
1272 TTree * fReconstruct = gAlice->TreeR() ;
1273 fReconstruct->SetBranchAddress( "PHOSPpsdRP", &fPpsdRecPoints) ;
1274 fReconstruct->GetEvent(0) ;
1275 rv = fPpsdRecPoints ;
1276 }
1277
1278 fPpsdRecPoints->Expand( fPpsdRecPoints->GetEntries() ) ;
1279
1280 return rv ;
1281
1282}
1283
9f616d61 1284//_____________________________________________________________________________
6ad0bfa0 1285void AliPHOSv0::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
d15a28e7 1286{
b2a60966 1287 // 1. Reinitializes the existing RecPoint, TrackSegment, and RecParticles Lists and
83974468 1288 // 2. Creates TreeR wit a branch for each list
b2a60966 1289 // 3. Steers the reconstruction processes
1290 // 4. Saves the 3 lists in TreeR
1291 // 5. Write the Tree to File
1292
6ad0bfa0 1293 fReconstructioner = Reconstructioner ;
b2a60966 1294
1295 char branchname[10] ;
6ad0bfa0 1296
b2a60966 1297 // 1.
83974468 1298
1299 gAlice->MakeTree("R") ;
1300 Int_t splitlevel = 0 ;
b2a60966 1301
9110b6c7 1302 if (fEmcRecPoints) {
1303 fEmcRecPoints->Delete() ;
1304 delete fEmcRecPoints ;
1305 fEmcRecPoints = 0 ;
9f616d61 1306 }
83974468 1307
9110b6c7 1308 // fEmcRecPoints= new RecPointsList("AliPHOSEmcRecPoint", 100) ; if TClonesArray
1309 fEmcRecPoints= new RecPointsList(100) ;
83974468 1310
9110b6c7 1311 if ( fEmcRecPoints && gAlice->TreeR() ) {
83974468 1312 sprintf(branchname,"%sEmcRP",GetName()) ;
1313
9110b6c7 1314 // gAlice->TreeR()->Branch(branchname, &fEmcRecPoints, fBufferSize); if TClonesArray
1315 gAlice->TreeR()->Branch(branchname, "TObjArray", &fEmcRecPoints, fBufferSize, splitlevel) ;
b2a60966 1316 }
1317
9110b6c7 1318 if (fPpsdRecPoints) {
1319 fPpsdRecPoints->Delete() ;
1320 delete fPpsdRecPoints ;
1321 fPpsdRecPoints = 0 ;
9f616d61 1322 }
83974468 1323
9110b6c7 1324 // fPpsdRecPoints = new RecPointsList("AliPHOSPpsdRecPoint", 100) ; if TClonesArray
1325 fPpsdRecPoints = new RecPointsList(100) ;
83974468 1326
9110b6c7 1327 if ( fPpsdRecPoints && gAlice->TreeR() ) {
83974468 1328 sprintf(branchname,"%sPpsdRP",GetName()) ;
1329
9110b6c7 1330 // gAlice->TreeR()->Branch(branchname, &fPpsdRecPoints, fBufferSize); if TClonesArray
1331 gAlice->TreeR()->Branch(branchname, "TObjArray", &fPpsdRecPoints, fBufferSize, splitlevel) ;
83974468 1332 }
9f616d61 1333
b2a60966 1334 if (fTrackSegments) {
9f616d61 1335 fTrackSegments->Delete() ;
1336 delete fTrackSegments ;
1337 fTrackSegments = 0 ;
1338 }
83974468 1339
b2a60966 1340 fTrackSegments = new TrackSegmentsList("AliPHOSTrackSegment", 100) ;
1341 if ( fTrackSegments && gAlice->TreeR() ) {
1342 sprintf(branchname,"%sTS",GetName()) ;
9110b6c7 1343 gAlice->TreeR()->Branch(branchname, &fTrackSegments, fBufferSize) ;
b2a60966 1344 }
1345
83974468 1346 if (fRecParticles) {
1347 fRecParticles->Delete() ;
6ad0bfa0 1348 delete fRecParticles ;
1349 fRecParticles = 0 ;
1350 }
1351 fRecParticles = new RecParticlesList("AliPHOSRecParticle", 100) ;
b2a60966 1352 if ( fRecParticles && gAlice->TreeR() ) {
83974468 1353 sprintf(branchname,"%sRP",GetName()) ;
9110b6c7 1354 gAlice->TreeR()->Branch(branchname, &fRecParticles, fBufferSize) ;
b2a60966 1355 }
1356
1357 // 3.
6ad0bfa0 1358
9110b6c7 1359 fReconstructioner->Make(fDigits, fEmcRecPoints, fPpsdRecPoints, fTrackSegments, fRecParticles);
9f616d61 1360
83974468 1361 // 4. Expand or Shrink the arrays to the proper size
1362
1363 Int_t size ;
1364
9110b6c7 1365 size = fEmcRecPoints->GetEntries() ;
1366 fEmcRecPoints->Expand(size) ;
83974468 1367
9110b6c7 1368 size = fPpsdRecPoints->GetEntries() ;
1369 fPpsdRecPoints->Expand(size) ;
83974468 1370
1371 size = fTrackSegments->GetEntries() ;
1372 fTrackSegments->Expand(size) ;
1373
1374 size = fRecParticles->GetEntries() ;
1375 fRecParticles->Expand(size) ;
b2a60966 1376
1377 gAlice->TreeR()->Fill() ;
1378
1379 // 5.
1380
1381 gAlice->TreeR()->Write() ;
83974468 1382
d15a28e7 1383}
1384
1385//____________________________________________________________________________
83974468 1386void AliPHOSv0::ResetDigits()
1387{
1388 // May sound strange, but cumulative hits are store in digits Tree
1389
1390 if( fTmpHits ) {
1391 fTmpHits->Delete();
1392 fNTmpHits = 0 ;
1393 }
1394}
1395
1396//____________________________________________________________________________
d15a28e7 1397void AliPHOSv0::StepManager(void)
1398{
b2a60966 1399 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
1400
92862013 1401 Int_t relid[4] ; // (box, layer, row, column) indices
d15a28e7 1402 Float_t xyze[4] ; // position wrt MRS and energy deposited
1403 TLorentzVector pos ;
ff4c968a 1404 Int_t copy ;
d15a28e7 1405
ff4c968a 1406 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
d15a28e7 1407 TString name = fGeom->GetName() ;
d15a28e7 1408 if ( name == "GPS2" ) { // the CPV is a PPSD
b2a60966 1409 if( gMC->CurrentVolID(copy) == gMC->VolId("GCEL") ) // We are inside a gas cell
d15a28e7 1410 {
1411 gMC->TrackPosition(pos) ;
1412 xyze[0] = pos[0] ;
1413 xyze[1] = pos[1] ;
1414 xyze[2] = pos[2] ;
1415 xyze[3] = gMC->Edep() ;
1416
1417 if ( xyze[3] != 0 ) { // there is deposited energy
92862013 1418 gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number
1419 gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number
d15a28e7 1420 // 1-> Geom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper
1421 // > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower
92862013 1422 gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell
1423 gMC->CurrentVolID(relid[3]) ; // get the column number
d15a28e7 1424
1425 // get the absolute Id number
1426
92862013 1427 Int_t absid ;
ff4c968a 1428 fGeom->RelToAbsNumbering(relid, absid) ;
d15a28e7 1429
1430 // add current hit to the hit list
ff4c968a 1431 AddHit(primary, absid, xyze);
d15a28e7 1432
1433 } // there is deposited energy
1434 } // We are inside the gas of the CPV
1435 } // GPS2 configuration
1436
ff4c968a 1437 if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) // We are inside a PBWO crystal
d15a28e7 1438 {
1439 gMC->TrackPosition(pos) ;
1440 xyze[0] = pos[0] ;
1441 xyze[1] = pos[1] ;
1442 xyze[2] = pos[2] ;
1443 xyze[3] = gMC->Edep() ;
1444
1445 if ( xyze[3] != 0 ) {
92862013 1446 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
ff4c968a 1447 relid[1] = 0 ; // means PBW04
92862013 1448 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
1449 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
d15a28e7 1450
1451 // get the absolute Id number
1452
92862013 1453 Int_t absid ;
1454 fGeom->RelToAbsNumbering(relid, absid) ;
d15a28e7 1455
1456 // add current hit to the hit list
1457
ff4c968a 1458 AddHit(primary, absid, xyze);
d15a28e7 1459
1460 } // there is deposited energy
1461 } // we are inside a PHOS Xtal
1462}
1463