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