]> git.uio.no Git - u/mrichter/AliRoot.git/blame - BCM/AliBCM.cxx
effc++ warnings
[u/mrichter/AliRoot.git] / BCM / AliBCM.cxx
CommitLineData
80165cad 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
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// Beam Condition Monitor BCM //
21// //
22// andreas.morsch@cern.ch //
23///////////////////////////////////////////////////////////////////////////////
24
25#include <TVirtualMC.h>
26#include <TClonesArray.h>
27#include <TGeoMaterial.h>
28#include <TGeoMedium.h>
29#include <TGeoVolume.h>
30#include <TGeoMatrix.h>
31#include <TGeoPgon.h>
32#include <TGeoXtru.h>
33#include <TGeoCompositeShape.h>
34#include <TGeoManager.h>
35
36#include "AliBCM.h"
37#include "AliBCMHit.h"
45e280ce 38#include "AliBCMLoader.h"
80165cad 39#include "AliMagF.h"
40#include "AliRun.h"
41#include "AliMC.h"
42
43ClassImp(AliBCM)
44
45
46//_____________________________________________________________________________
47AliBCM::AliBCM():
48 AliDetector(),
49 fVolId(0)
50{
51 //
52 // Default constructor for BCM
53 //
54}
55
56//_____________________________________________________________________________
57AliBCM::AliBCM(const char *name, const char *title):
58 AliDetector(name,title),
59 fVolId(0)
60{
61//
62// Constructor
63 fHits = new TClonesArray("AliBCMHit");
64 fNhits = 0;
65 gAlice->GetMCApp()->AddHitList(fHits);
66}
67AliBCM::~AliBCM()
68{
69 // Destructor
70 if(fHits) delete fHits;
71}
72
73void AliBCM::StepManager()
74{
75//
76// Step Manager for ALICE Beam Condition Monitor
77//
78
79 static Float_t edepT;
45e280ce 80 static Double_t xh[4] = {0., 0., 0., 0.};
80165cad 81 Float_t edep = 0.;
82 Int_t copy = -1;
83
84
85 if (gMC->TrackCharge() &&
86 gMC->CurrentVolID(copy) == fVolId) {
87 // Charged particle inside sensitive volume
88 //
89 // Entering
90 if (gMC->IsTrackEntering()) {
91 edepT = 0.;
45e280ce 92 gMC->TrackPosition(xh[0],xh[1],xh[2]);
93 xh[3] = gMC->TrackTime();
80165cad 94 }
95
96 //
97 // Any step
98 if ((edep = gMC->Edep()) > 0.) {
99 Double_t x[3];
100 gMC->TrackPosition(x[0],x[1],x[2]);
101 edepT += edep;
102 }
103 //
104 // Exiting
105 if(gMC->IsTrackExiting()||gMC->IsTrackStop()||gMC->IsTrackDisappeared())
106 {
107 Int_t track = gAlice->GetMCApp()->GetCurrentTrackNumber();
108 TClonesArray &lhits = *fHits;
109 Int_t ic = copy + 10;
110 if (xh[2] < 0.) ic+=10;
111 new(lhits[fNhits++]) AliBCMHit(1, track, xh, ic, edepT);
112 }
113 }
114
115
116}
117
118//_____________________________________________________________________________
119void AliBCM::CreateGeometry()
120{
121 //
122 // Create geometry for BCM
123 //
124
125 //
126 // Top volume
127 TGeoVolume* top = gGeoManager->GetVolume("ALIC");
128 // Media
129 TGeoMedium* medPCD = gGeoManager->GetMedium("BCM_PCD");
130 // Rotations
131 TGeoRotation* rotxz = new TGeoRotation("rotxz" , 270., 0., 90., 90., 180., 0.);
132 TGeoRotation* rot000 = new TGeoRotation("rot000", 90., 0., 90., 90., 0., 0.);
133 TGeoRotation* rot090 = new TGeoRotation("rot090", 90., 90., 90., 180., 0., 0.);
134 TGeoRotation* rot180 = new TGeoRotation("rot180", 90., 180., 90., 270., 0., 0.);
135 TGeoRotation* rot270 = new TGeoRotation("rot270", 90., 270., 90., 0., 0., 0.);
136 //
137 const Float_t kWidth = 1.00;
138 const Float_t kThickness = 0.05;
139 const Float_t rBCM = 7.;
140
141
142 TGeoBBox* shBCMpcd = new TGeoBBox(kWidth/2., kWidth/2., kThickness/2.);
143 TGeoVolume* voBCMpcd = new TGeoVolume("BCMpcd", shBCMpcd, medPCD);
144 TGeoVolumeAssembly* voBCM = new TGeoVolumeAssembly("BCM");
145
146 voBCM->AddNode(voBCMpcd, 1, new TGeoCombiTrans(+rBCM, 0. , 0., rot000));
147 voBCM->AddNode(voBCMpcd, 2, new TGeoCombiTrans(0. , +rBCM , 0., rot090));
148 voBCM->AddNode(voBCMpcd, 3, new TGeoCombiTrans(-rBCM, 0., 0., rot180));
149 voBCM->AddNode(voBCMpcd, 4, new TGeoCombiTrans(0. , -rBCM , 0., rot270));
150
151 top->AddNode(voBCM, 1, new TGeoTranslation(0., 0., 1561.));
152 top->AddNode(voBCM, 2, new TGeoCombiTrans(0., 0., -1908., rotxz));
153
154}
155
156//_____________________________________________________________________________
157void AliBCM::CreateMaterials()
158{
159 //
160 // Create materials for BCM
161 //
162 // Polycristalline Diamond
163 Float_t rho = 3.53;
164 Float_t absl = 86.3 / rho;
165 Float_t radl = 42.7 / rho;
166 //
167 Float_t epsil = .001; // Tracking precision,
168 Float_t stemax = -1.; // Maximum displacement for multiple scat
169 Float_t tmaxfd = -20. ; // Maximum angle due to field deflection
170 Float_t deemax = -.01; // Maximum fractional energy loss, DLS
171 Float_t stmin = -.8;
172 Int_t isxfld = gAlice->Field()->Integ();
173 Float_t sxmgmx = gAlice->Field()->Max();
174
175 AliMaterial(1, "PCD", 12.011, 6., rho, radl, absl);
176 //
177 AliMedium(1, "PCD", 1, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
178}
179
180//_____________________________________________________________________________
181void AliBCM::Init()
182{
183 //
184 // Initialise BCM magnet after it has been built
185 //
186 Int_t i;
187 //
188 if(AliLog::GetGlobalDebugLevel()>0) {
189 printf("\n%s: ",ClassName());
190 for(i=0;i<35;i++) printf("*");
191 printf(" BCM_INIT ");
192 for(i=0;i<35;i++) printf("*");
193 printf("\n%s: ",ClassName());
194 for(i=0;i<80;i++) printf("*");
195 printf("\n");
196 }
197
198 //
199 // Here the BCM initialisation code (if any!)
200 fVolId = gMC->VolId("BCMpcd");
201}
202
203void AliBCM::MakeBranch(Option_t* option)
204{
205//Create Tree branches for the BCM
206
207 const Int_t kBufSize = 4000;
208 const char *cH = strstr(option,"H");
209// const char *cD = strstr(option,"D");
210// const char *cR = strstr(option,"R");
211// const char *cS = strstr(option,"S");
212
213 if(cH && TreeH() && (fHits == 0x0)){
214 fHits = new TClonesArray("AliBCMHit");
215 fNhits = 0;
216 MakeBranchInTree(TreeH(), "BCM" ,&fHits ,kBufSize, 0);
217 }
218 AliDetector::MakeBranch(option);
219}
220
221void AliBCM::SetTreeAddress()
222{
223 // Set branch address
224
225 if (TreeH() && fHits==0x0)
226 fHits = new TClonesArray("AliBCMHit", 4000);
227 AliDetector::SetTreeAddress();
228}
45e280ce 229
230//_____________________________________________________________________________
231AliLoader* AliBCM::MakeLoader(const char* topfoldername)
232{
233 //
234 // Builds BCM getter (AliLoader type)
235 AliDebug(1,Form("Creating AliBCMLoader, Top folder is %s ",topfoldername));
236 fLoader = new AliBCMLoader(GetName(),topfoldername);
237 return fLoader;
238}