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