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