Updated to the latest TVirtualMC
[u/mrichter/AliRoot.git] / MUON / AliMUONv3.cxx
CommitLineData
8d7b49a7 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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
8d7b49a7 17
18/////////////////////////////////////////////////////////
19// Manager and hits classes for set:MUON version 2 //
20/////////////////////////////////////////////////////////
21
22#include <Riostream.h>
23#include <TClonesArray.h>
24#include <TLorentzVector.h>
25#include <TNode.h>
26#include <TRandom.h>
27#include <TTUBE.h>
28
29#include "AliMUONv3.h"
30#include "AliRun.h"
31#include "AliMagF.h"
32#include "AliCallf77.h"
33#include "AliConst.h"
34#include "AliMUONChamber.h"
35#include "AliMUONHit.h"
36#include "AliMUONPadHit.h"
37#include "AliMUONConstants.h"
38#include "AliMUONTriggerCircuit.h"
39#include "AliMUONFactory.h"
40
41ClassImp(AliMUONv3)
42
43//___________________________________________
44AliMUONv3::AliMUONv3() : AliMUONv1()
45{
46// Constructor
47 fChambers = 0;
48 fStations = 0;
49}
50
51//___________________________________________
52AliMUONv3::AliMUONv3(const char *name, const char *title)
53 : AliMUONv1(name,title)
54{
55// Constructor
56 // By default include all stations
57 fStations = new Int_t[5];
58 for (Int_t i=0; i<5; i++) fStations[i] = 1;
59
60 AliMUONFactory factory;
61 factory.Build(this, title);
62}
63//___________________________________________
64void AliMUONv3::StepManager()
65{
66
67 // Volume id
68 Int_t copy, id;
69 Int_t idvol;
70 Int_t iChamber=0;
71 // Particule id, pos and mom vectors,
72 // theta, phi angles with respect the normal of the chamber,
73 // spatial step, delta_energy and time of flight
74 Int_t ipart;
75 TLorentzVector pos, mom;
76 Float_t theta, phi, tof;
77 Float_t destep, step;
78
79 TClonesArray &lhits = *fHits;
80
81 // Only charged tracks
82 if( !(gMC->TrackCharge()) ) return;
83
84 // Only gas gap inside chamber
85 // Tag chambers and record hits when track enters
86 idvol=-1;
87 id=gMC->CurrentVolID(copy);
88 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++) {
89 if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) {
90 iChamber = i;
91 idvol = i-1;
92 }
93 }
94 if (idvol == -1) return;
95
96 // Get current particle id (ipart), track position (pos) and momentum (mom)
97 gMC->TrackPosition(pos);
98 gMC->TrackMomentum(mom);
99 ipart = gMC->TrackPid();
100 theta = mom.Theta()*kRaddeg; // theta of track
101 phi = mom.Phi() *kRaddeg; // phi of the track
102 tof = gMC->TrackTime(); // Time of flight
103 //
104 // momentum loss and steplength in last step
105 destep = gMC->Edep();
106 step = gMC->TrackStep();
2468d1a9 107 //new hit
108 if (destep>0.) new(lhits[fNhits++])
642f15cf 109 AliMUONHit(fIshunt, gAlice->GetCurrentTrackNumber(), iChamber, ipart,
2468d1a9 110 pos.X(), pos.Y(), pos.Z(), tof, mom.P(),
111 theta, phi, step, destep);
8d7b49a7 112}
113
114