1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // Manager class for PHOS version for fast simulations
18 //*-- Author : Y. Schutz SUBATECH
19 //////////////////////////////////////////////////////////////////////////////
21 // --- ROOT system ---
25 #include "TParticle.h"
27 // --- Standard library ---
32 // --- AliRoot header files ---
34 #include "AliPHOSvFast.h"
35 #include "AliPHOSReconstructioner.h"
39 ClassImp(AliPHOSvFast)
41 //____________________________________________________________________________
42 AliPHOSvFast::AliPHOSvFast()
48 //____________________________________________________________________________
49 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
52 // gets an instance of the geometry parameters class
54 fGeom = AliPHOSGeometry::GetInstance(title, "") ;
56 if (fGeom->IsInitialized() )
57 cout << "AliPHOSvFast : PHOS geometry intialized for " << fGeom->GetName() << endl ;
59 cout << "AliPHOSvFast : PHOS geometry initialization failed !" << endl ;
61 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
62 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) ;
63 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
68 //____________________________________________________________________________
69 AliPHOSvFast::~AliPHOSvFast()
72 fRecParticles->Delete() ;
73 delete fRecParticles ;
78 //____________________________________________________________________________
79 void AliPHOSvFast::AddRecParticle(Int_t primary)
81 TClonesArray * particlelist = gAlice->Particles() ;
82 TParticle * part = (TParticle *)particlelist->At(primary) ;
83 cout << " AliPHOSvFast::AddRecParticle " << part->GetName() << endl ;
86 //____________________________________________________________________________
87 void AliPHOSvFast::BuildGeometry()
90 // Build the PHOS geometry for the ROOT display
92 const Int_t kColorPHOS = kRed ;
94 Double_t const kRADDEG = 180.0 / kPI ;
96 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
100 // position PHOS into ALICE
102 Float_t r = fGeom->GetIPtoOuterCoverDistance() + GetBigBox(1) / 2.0 ;
104 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoOuterCoverDistance() ) ) ;
106 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
108 char * nodename = new char[20] ;
109 char * rotname = new char[20] ;
111 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
112 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
113 sprintf(rotname, "%s%d", "rot", number++) ;
114 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
116 sprintf(nodename,"%s%d", "Module", i) ;
117 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
118 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
119 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
120 bigboxnode->SetLineColor(kColorPHOS) ;
121 fNodes->Add(bigboxnode) ;
127 //____________________________________________________________________________
128 void AliPHOSvFast::CreateGeometry()
131 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
133 if ( phostmp == NULL ) {
135 fprintf(stderr, "PHOS detector not found!\n") ;
140 // Get pointer to the array containing media indeces
141 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
144 bigbox[0] = GetBigBox(0) / 2.0 ;
145 bigbox[1] = GetBigBox(1) / 2.0 ;
146 bigbox[2] = GetBigBox(2) / 2.0 ;
148 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
150 // --- Position PHOS mdules in ALICE setup ---
153 Double_t const kRADDEG = 180.0 / kPI ;
155 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
157 Float_t angle = fGeom->GetPHOSAngle(i) ;
158 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
160 Float_t r = fGeom->GetIPtoOuterCoverDistance() + GetBigBox(1) / 2.0 ;
162 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
163 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
165 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
172 //____________________________________________________________________________
173 void AliPHOSvFast::Init(void)
179 for(i=0;i<35;i++) printf("*");
180 printf(" FAST PHOS_INIT ");
181 for(i=0;i<35;i++) printf("*");
184 // Here the PHOS initialisation code (if any!)
186 for(i=0;i<80;i++) printf("*");
191 //___________________________________________________________________________
192 Float_t AliPHOSvFast::GetBigBox(Int_t index)
210 //___________________________________________________________________________
211 void AliPHOSvFast::MakeBranch(Option_t* opt)
214 // Create a new branch in the current Root Tree
215 // The branch of fHits is automatically split
217 AliDetector::MakeBranch(opt) ;
220 sprintf(branchname,"%s",GetName());
221 char *cd = strstr(opt,"D");
223 if (fDigits && gAlice->TreeD() && cd) {
224 gAlice->TreeD()->Branch(branchname, &fRecParticles, fBufferSize);
225 // printf("* AliPHOS::MakeBranch * Making Branch %s for RecParticles \n",branchname);
229 //___________________________________________________________________________
230 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
247 //____________________________________________________________________________
248 void AliPHOSvFast::StepManager(void)
251 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
252 TString name = fGeom->GetName() ;
254 // add the primary particle to the RecParticles list
256 AddRecParticle(primary);