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