]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONv0.cxx
oops
[u/mrichter/AliRoot.git] / MUON / AliMUONv0.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
88cb7938 16/* $Id$ */
4c039060 17
fe4da5cc 18/////////////////////////////////////////////////////////
19// Manager and hits classes for set:MUON version 0 //
20/////////////////////////////////////////////////////////
21
116cbefd 22#include <Riostream.h>
88cb7938 23
116cbefd 24#include <TLorentzVector.h>
fe4da5cc 25#include <TNode.h>
26#include <TRandom.h>
116cbefd 27#include <TTUBE.h>
88cb7938 28#include <TVirtualMC.h>
fe4da5cc 29
fe4da5cc 30#include "AliCallf77.h"
31#include "AliConst.h"
88cb7938 32#include "AliMUONChamber.h"
d1cd2474 33#include "AliMUONChamberGeometry.h"
f665c1ea 34#include "AliMUONConstants.h"
be3bb6c1 35#include "AliMUONFactory.h"
88cb7938 36#include "AliMUONHit.h"
37#include "AliMUONPadHit.h"
38#include "AliMUONv0.h"
39#include "AliMagF.h"
40#include "AliRun.h"
5d12ce38 41#include "AliMC.h"
88cb7938 42
fe4da5cc 43ClassImp(AliMUONv0)
44
45//___________________________________________
46AliMUONv0::AliMUONv0() : AliMUON()
47{
a9e2aefa 48// Constructor
fe4da5cc 49 fChambers = 0;
50}
51
52//___________________________________________
53AliMUONv0::AliMUONv0(const char *name, const char *title)
54 : AliMUON(name,title)
55{
a9e2aefa 56// Constructor
ba030c0e 57 AliMUONFactory factory;
58 factory.Build(this, title);
a897a37a 59}
60
a9e2aefa 61void AliMUONv0::CreateGeometry()
62{
63// Creates coarse geometry for hit density simulations
64 Int_t *idtmed = fIdtmed->GetArray()-1099;
fe4da5cc 65//
a9e2aefa 66 Float_t zpos, dAlu, tpar[3];
67 Int_t idAir=idtmed[1100];
68 Int_t idAlu=idtmed[1103];
69
70 AliMUONChamber *iChamber;
71 // Loop over all chambers (tracking and trigger)
f665c1ea 72 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++) {
a9e2aefa 73 char alu[8];
74 char gas[8];
75
76 iChamber=(AliMUONChamber*) (*fChambers)[ch];
77 // Z of the chamber
78 zpos=iChamber->Z();
79 dAlu=iChamber->DAlu();
f665c1ea 80 if (ch < AliMUONConstants::NTrackingCh()) {
a9e2aefa 81 // tracking chambers
b74f1c6a 82 sprintf(alu,"SA0%1d",ch);
83 sprintf(gas,"SG0%1d",ch);
a9e2aefa 84 } else {
85 // trigger chambers
b74f1c6a 86 sprintf(alu,"SA%2d",ch);
87 sprintf(gas,"SG%2d",ch);
a9e2aefa 88 }
89//
a9e2aefa 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);
95 tpar[2] = 0.1;
96 gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
97 } else {
98 gMC->Gsvolu(alu, "TUBE", idAlu, tpar, 3);
99 tpar[2] = 0.1;
100 gMC->Gsvolu(gas, "TUBE", idAir, tpar, 3);
101 }
102 gMC->Gspos(gas, 1, alu, 0., 0., 0., 0, "ONLY");
afa281f0 103 if (ch == 4 || ch ==5) {
82e22b99 104 if (gMC->VolId("DDIP")) {
105 gMC->Gspos(alu, 1, "DDIP", 0., 0., zpos, 0, "ONLY");
106 } else {
107 gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
108 }
afa281f0 109 } else {
110 gMC->Gspos(alu, 1, "ALIC", 0., 0., zpos, 0, "ONLY");
111 }
a897a37a 112 }
fe4da5cc 113}
114
fe4da5cc 115//___________________________________________
116void AliMUONv0::CreateMaterials()
117{
a9e2aefa 118// Creates materials for coarse geometry
82e22b99 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);
fe4da5cc 121
a9e2aefa 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
126 Float_t stmin = -.8;
127 Int_t isxfld = gAlice->Field()->Integ();
128 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 129
fe4da5cc 130 //
a9e2aefa 131 // Air
132 AliMedium(1, "AIR_CH_US ", 15, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
82e22b99 133 AliMedium(4, "ALU_CH_US ", 9, 0, isxfld, sxmgmx, tmaxfd, fMaxStepAlu,
a897a37a 134 fMaxDestepAlu, epsil, stmin);
135
fe4da5cc 136}
137
fe4da5cc 138void AliMUONv0::Init()
139{
fe4da5cc 140 //
141 // Initialize Tracking Chambers
142 //
b9046b8f 143 char vName[8];
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()) {
150 // tracking chambers
b74f1c6a 151 sprintf(vName,"SG0%1d",i);
b9046b8f 152 } else {
153 // trigger chambers
b74f1c6a 154 sprintf(vName,"SG%2d",i);
b9046b8f 155 }
d1cd2474 156 //((AliMUONChamber*) (*fChambers)[i])->SetGid(gMC->VolId(vName));
157 ((AliMUONChamber*) (*fChambers)[i])
158 ->GetGeometry()->SetSensitiveVolume(gMC->VolId(vName));
b9046b8f 159 }
fe4da5cc 160}
161
fe4da5cc 162void AliMUONv0::StepManager()
163{
a9e2aefa 164//
165// Step manager for hit density simulations
fe4da5cc 166 Int_t copy, id;
167 static Int_t idvol;
168 static Int_t vol[2];
169 Int_t ipart;
a897a37a 170 TLorentzVector pos;
171 TLorentzVector mom;
172 Float_t theta,phi;
fe4da5cc 173
a897a37a 174 // modifs perso
a9e2aefa 175 static Float_t hits[15];
a897a37a 176
fe4da5cc 177 TClonesArray &lhits = *fHits;
fe4da5cc 178 //
179 // Only gas gap inside chamber
180 // Tag chambers and record hits when track enters
181 idvol=-1;
0a6d8768 182 id=gMC->CurrentVolID(copy);
fe4da5cc 183
f665c1ea 184 for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) {
d1cd2474 185 //if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){
186 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(id) ) {
fe4da5cc 187 vol[0]=i;
188 idvol=i-1;
189 }
190 }
191 if (idvol == -1) return;
192 //
193 // Get current particle id (ipart), track position (pos) and momentum (mom)
cfce8870 194 gMC->TrackPosition(pos);
195 gMC->TrackMomentum(mom);
fe4da5cc 196
cfce8870 197 ipart = gMC->TrackPid();
fe4da5cc 198 //
199 // record hits when track enters ...
9fde056a 200 if( !(gMC->TrackCharge()) ) return;
0a6d8768 201 if( gMC->IsTrackEntering()) {
82e22b99 202// printf("\n Particle entering %f %f %f", pos[0], pos[1], pos[2] );
203
a897a37a 204 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
205 Double_t rt = TMath::Sqrt(tc);
a897a37a 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;
a9e2aefa 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
2eb55fab 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
fe4da5cc 221 new(lhits[fNhits++])
5d12ce38 222 AliMUONHit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
a9e2aefa 223
fe4da5cc 224 }
82e22b99 225// if( gMC->IsTrackExiting()) gMC->StopTrack();
fe4da5cc 226}
a9e2aefa 227
228
229
230
231
232
233
234
235