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 **************************************************************************/
18 /////////////////////////////////////////////////////////
19 // Manager and hits classes for set:MUON version 0 //
20 /////////////////////////////////////////////////////////
22 #include <Riostream.h>
24 #include <TLorentzVector.h>
28 #include <TVirtualMC.h>
30 #include "AliCallf77.h"
32 #include "AliMUONChamber.h"
33 #include "AliMUONChamberGeometry.h"
34 #include "AliMUONConstants.h"
35 #include "AliMUONFactory.h"
36 #include "AliMUONHit.h"
37 #include "AliMUONPadHit.h"
38 #include "AliMUONv0.h"
45 //___________________________________________
46 AliMUONv0::AliMUONv0() : AliMUON()
52 //___________________________________________
53 AliMUONv0::AliMUONv0(const char *name, const char *title)
57 AliMUONFactory factory;
58 factory.Build(this, title);
61 void AliMUONv0::CreateGeometry()
63 // Creates coarse geometry for hit density simulations
64 Int_t *idtmed = fIdtmed->GetArray()-1099;
66 Float_t zpos, dAlu, tpar[3];
67 Int_t idAir=idtmed[1100];
68 Int_t idAlu=idtmed[1103];
70 AliMUONChamber *iChamber;
71 // Loop over all chambers (tracking and trigger)
72 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++) {
76 iChamber=(AliMUONChamber*) (*fChambers)[ch];
79 dAlu=iChamber->DAlu();
80 if (ch < AliMUONConstants::NTrackingCh()) {
82 sprintf(alu,"SA0%1d",ch);
83 sprintf(gas,"SG0%1d",ch);
86 sprintf(alu,"SA%2d",ch);
87 sprintf(gas,"SG%2d",ch);
90 tpar[0] = iChamber->RInner();
91 tpar[1] = iChamber->ROuter();
92 tpar[2] = (dAlu+0.2)/2.;
93 if (ch !=4 && ch !=5) {
94 gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
96 gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
98 gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
100 gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
102 gMC->Gspos(gas, 1, alu, 0., 0., 0., 0, "ONLY");
103 if (ch == 4 || ch ==5) {
104 if (gMC->VolId("DDIP")) {
105 gMC->Gspos(alu, 1, "DDIP", 0., 0., zpos, 0, "ONLY");
107 gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
110 gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
115 //___________________________________________
116 void AliMUONv0::CreateMaterials()
118 // Creates materials for coarse geometry
119 AliMaterial(15, "AIR$ ", 14.61, 7.3, .001205, 30423.24, 67500);
120 AliMaterial( 9, "ALUMINIUM$", 26.98, 13. , 2.7, 8.9, 37.2);
122 Float_t epsil = .001; // Tracking precision,
123 Float_t stemax = -1.; // Maximum displacement for multiple scat
124 Float_t tmaxfd = -20.; // Maximum angle due to field deflection
125 Float_t deemax = -.3; // Maximum fractional energy loss, DLS
127 Int_t isxfld = gAlice->Field()->Integ();
128 Float_t sxmgmx = gAlice->Field()->Max();
132 AliMedium(1, "AIR_CH_US ", 15, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
133 AliMedium(4, "ALU_CH_US ", 9, 0, isxfld, sxmgmx, tmaxfd, fMaxStepAlu,
134 fMaxDestepAlu, epsil, stmin);
138 void AliMUONv0::Init()
141 // Initialize Tracking Chambers
144 printf("\n\n\n Start Init for version 0 - CPC chamber type\n\n\n");
145 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
146 // Initialise chamber
147 ((AliMUONChamber*) (*fChambers)[i])->Init();
148 // Set sensitive volume Id
149 if (i < AliMUONConstants::NTrackingCh()) {
151 sprintf(vName,"SG0%1d",i);
154 sprintf(vName,"SG%2d",i);
156 //((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
157 ((AliMUONChamber*) (*fChambers)[i])
158 ->GetGeometry()->SetSensitiveVolume(gMC->VolId(vName));
162 void AliMUONv0::StepManager()
165 // Step manager for hit density simulations
175 static Float_t hits[15];
177 TClonesArray &lhits = *fHits;
179 // Only gas gap inside chamber
180 // Tag chambers and record hits when track enters
182 id=gMC->CurrentVolID(copy);
184 for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
185 //if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){
186 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(id) ) {
191 if (idvol == -1) return;
193 // Get current particle id (ipart), track position (pos) and momentum (mom)
194 gMC->TrackPosition(pos);
195 gMC->TrackMomentum(mom);
197 ipart = gMC->TrackPid();
199 // record hits when track enters ...
200 if( !(gMC->TrackCharge()) ) return;
201 if( gMC->IsTrackEntering()) {
202 // printf("\n Particle entering %f %f %f", pos[0], pos[1], pos[2] );
204 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
205 Double_t rt = TMath::Sqrt(tc);
206 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
207 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
208 hits[0] = Float_t(ipart); // Geant3 particle type
209 hits[1] = pos[0]; // X-position for hit
210 hits[2] = pos[1]; // Y-position for hit
211 hits[3] = pos[2]; // Z-position for hit
212 hits[4] = theta; // theta angle of incidence
213 hits[5] = phi; // phi angle of incidence
214 hits[8] = -1; // first padhit
215 hits[9] = -1; // last pad hit
216 hits[10] = mom[3]; // hit Energy
217 hits[11] = mom[0]; // Px
218 hits[12] = mom[1]; // Py
219 hits[13] = mom[2]; // Pz
220 hits[14] = gMC->TrackTime(); // time of flight
222 AliMUONHit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
225 // if( gMC->IsTrackExiting()) gMC->StopTrack();