]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONv1.cxx
ENDIF replaced by endif (compilation problems)
[u/mrichter/AliRoot.git] / MUON / AliMUONv1.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
d7c4fbc4 3 * SigmaEffect_thetadegrees *
a9e2aefa 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 *
2c799aa2 12 * about the suitability of this software for any purpeateose. It is *
a9e2aefa 13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
18/////////////////////////////////////////////////////////
acc838fd 19// Manager and hits classes for set:MUON version 1 //
a9e2aefa 20/////////////////////////////////////////////////////////
acc838fd 21
abaf7c9d 22#include <TRandom.h>
23#include <TF1.h>
116cbefd 24#include <TClonesArray.h>
acc838fd 25#include <TLorentzVector.h>
26#include <TNode.h>
27#include <TRandom.h>
28#include <TTUBE.h>
29#include <TGeoMatrix.h>
88cb7938 30#include <TVirtualMC.h>
1391e633 31#include <TParticle.h>
a9e2aefa 32
a9e2aefa 33#include "AliConst.h"
34#include "AliMUONChamber.h"
88cb7938 35#include "AliMUONConstants.h"
36#include "AliMUONFactory.h"
a9e2aefa 37#include "AliMUONHit.h"
8c449e83 38#include "AliMUONTriggerCircuit.h"
88cb7938 39#include "AliMUONv1.h"
acc838fd 40#include "AliMUONVGeometryBuilder.h"
41#include "AliMUONChamberGeometry.h"
42#include "AliMUONGeometryEnvelope.h"
43#include "AliMUONGeometryConstituent.h"
88cb7938 44#include "AliMagF.h"
45#include "AliRun.h"
5d12ce38 46#include "AliMC.h"
a9e2aefa 47
48ClassImp(AliMUONv1)
49
50//___________________________________________
37c0cd40 51AliMUONv1::AliMUONv1() : AliMUON()
acc838fd 52 ,fTrackMomentum(), fTrackPosition(),fGlobalTransformation(0)
a9e2aefa 53{
54// Constructor
1391e633 55 fChambers = 0;
1391e633 56 fStepManagerVersionOld = kFALSE;
374ebd7d 57 fAngleEffect = kTRUE;
1391e633 58 fStepMaxInActiveGas = 0.6;
59 fStepSum = 0x0;
60 fDestepSum = 0x0;
61 fElossRatio = 0x0;
62 fAngleEffect10 = 0x0;
63 fAngleEffectNorma= 0x0;
64}
a9e2aefa 65//___________________________________________
66AliMUONv1::AliMUONv1(const char *name, const char *title)
1391e633 67 : AliMUON(name,title), fTrackMomentum(), fTrackPosition()
a9e2aefa 68{
69// Constructor
ba030c0e 70 // By default include all stations
ba030c0e 71 AliMUONFactory factory;
72 factory.Build(this, title);
c33d9661 73
74 fStepManagerVersionOld = kFALSE;
374ebd7d 75 fAngleEffect = kTRUE;
1391e633 76 fStepMaxInActiveGas = 0.6;
77
78 fStepSum = new Float_t [AliMUONConstants::NCh()];
79 fDestepSum = new Float_t [AliMUONConstants::NCh()];
80 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
81 fStepSum[i] =0.0;
82 fDestepSum[i]=0.0;
83 }
84 // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
85 fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.);
86 fElossRatio->SetParameter(0,1.02138);
87 fElossRatio->SetParameter(1,-9.54149e-02);
88 fElossRatio->SetParameter(2,+7.83433e-02);
89 fElossRatio->SetParameter(3,-9.98208e-03);
90 fElossRatio->SetParameter(4,+3.83279e-04);
91
92 // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
93 fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
94 fAngleEffect10->SetParameter(0, 1.90691e+02);
95 fAngleEffect10->SetParameter(1,-6.62258e+01);
96 fAngleEffect10->SetParameter(2,+1.28247e+01);
97 // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)
98 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
99 fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
100 fAngleEffectNorma->SetParameter(0,4.148);
101 fAngleEffectNorma->SetParameter(1,-6.809e-01);
102 fAngleEffectNorma->SetParameter(2,5.151e-02);
103 fAngleEffectNorma->SetParameter(3,-1.490e-03);
acc838fd 104
105 // Define the global transformation:
106 // Transformation from the old ALICE coordinate system to a new one:
107 // x->-x, z->-z
108 TGeoRotation* rotGlobal
109 = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.);
110 fGlobalTransformation = new TGeoCombiTrans(0., 0., 0., rotGlobal);
a9e2aefa 111}
112
113//___________________________________________
acc838fd 114AliMUONv1::~AliMUONv1()
a9e2aefa 115{
acc838fd 116// Destructor
a9e2aefa 117
acc838fd 118 delete fGlobalTransformation;
119}
b17c0c87 120
acc838fd 121//__________________________________________________
122void AliMUONv1::CreateGeometry()
123{
b17c0c87 124//
acc838fd 125// Construct geometry using geometry builders.
a9e2aefa 126//
a9e2aefa 127
acc838fd 128 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
3c084d9f 129
acc838fd 130 // Get the builder
131 AliMUONVGeometryBuilder* builder
132 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
1e8fff9c 133
acc838fd 134 // Create geometry with each builder
135 if (builder) {
136 builder->CreateGeometry();
137 builder->SetTransformations();
138 }
139 }
3c084d9f 140
acc838fd 141 for (Int_t j=0; j<AliMUONConstants::NCh(); j++) {
3c084d9f 142
acc838fd 143 AliMUONChamberGeometry* geometry = Chamber(j).GetGeometry();
3c084d9f 144
acc838fd 145 if (!geometry) continue;
146 // Skip chambers with not defined geometry
147
148 // Loop over envelopes
149 const TObjArray* kEnvelopes = geometry->GetEnvelopes();
150 for (Int_t k=0; k<kEnvelopes->GetEntriesFast(); k++) {
151
152 // Get envelope
153 AliMUONGeometryEnvelope* env = (AliMUONGeometryEnvelope*)kEnvelopes->At(k);
154 const TGeoCombiTrans* kEnvTrans = env->GetTransformation();
155
156 if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) {
157 // virtual envelope + nof constituents = 0
158 // => not allowed;
159 // empty virtual envelope has no sense
160 Fatal("CreateGeometry", "Virtual envelope must have constituents.");
161 return;
162 }
3c084d9f 163
acc838fd 164 if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) {
165 // non virtual envelope + nof constituents > 0
166 // => not allowed;
167 // use VMC to place constituents
168 Fatal("CreateGeometry", "Non virtual envelope cannot have constituents.");
169 return;
170 }
3c084d9f 171
acc838fd 172 if (!env->IsVirtual() && env->GetConstituents()->GetEntriesFast() == 0 ) {
173 // non virtual envelope + nof constituents = 0
174 // => place envelope in ALICE by composed transformation:
175 // Tglobal * Tch * Tenv
176
177 // Compound chamber transformation with the envelope one
178 TGeoHMatrix total
179 = (*fGlobalTransformation) *
180 (*geometry->GetTransformation()) *
181 (*kEnvTrans);
182 PlaceVolume(env->GetName(), geometry->GetMotherVolume(),
183 env->GetCopyNo(), total, 0, 0);
184 }
3c084d9f 185
acc838fd 186 if (env->IsVirtual() && env->GetConstituents()->GetEntriesFast() > 0 ) {
187 // virtual envelope + nof constituents > 0
188 // => do not place envelope and place constituents
189 // in ALICE by composed transformation:
190 // Tglobal * Tch * Tenv * Tconst
191
192 for (Int_t l=0; l<env->GetConstituents()->GetEntriesFast(); l++) {
193 AliMUONGeometryConstituent* constituent
194 = (AliMUONGeometryConstituent*)env->GetConstituents()->At(l);
195
196 // Compound chamber transformation with the envelope one + the constituent one
197 TGeoHMatrix total
198 = (*fGlobalTransformation) *
199 (*geometry->GetTransformation()) *
200 (*kEnvTrans) *
201 (*constituent->GetTransformation());
202
203 PlaceVolume(constituent->GetName(), geometry->GetMotherVolume(),
204 constituent->GetCopyNo(), total,
205 constituent->GetNpar(), constituent->GetParam());
206 }
207 }
208 }
209 }
210}
211//__________________________________________________________________
212Int_t AliMUONv1::GetChamberId(Int_t volId) const
213{
214// Check if the volume with specified volId is a sensitive volume (gas)
215// of some chamber and returns the chamber number;
216// if not sensitive volume - return 0.
217// ---
a9e2aefa 218
acc838fd 219/*
220 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
221 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
222*/
223 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
224 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
a9e2aefa 225
acc838fd 226 return 0;
a9e2aefa 227}
acc838fd 228//________________________________________________________________
a9e2aefa 229void AliMUONv1::CreateMaterials()
230{
acc838fd 231
a9e2aefa 232 // *** DEFINITION OF AVAILABLE MUON MATERIALS ***
233 //
b64652f5 234 // Ar-CO2 gas (80%+20%)
a9e2aefa 235 Float_t ag1[3] = { 39.95,12.01,16. };
236 Float_t zg1[3] = { 18.,6.,8. };
237 Float_t wg1[3] = { .8,.0667,.13333 };
238 Float_t dg1 = .001821;
239 //
240 // Ar-buthane-freon gas -- trigger chambers
241 Float_t atr1[4] = { 39.95,12.01,1.01,19. };
242 Float_t ztr1[4] = { 18.,6.,1.,9. };
243 Float_t wtr1[4] = { .56,.1262857,.2857143,.028 };
244 Float_t dtr1 = .002599;
245 //
246 // Ar-CO2 gas
247 Float_t agas[3] = { 39.95,12.01,16. };
248 Float_t zgas[3] = { 18.,6.,8. };
249 Float_t wgas[3] = { .74,.086684,.173316 };
250 Float_t dgas = .0018327;
251 //
252 // Ar-Isobutane gas (80%+20%) -- tracking
253 Float_t ag[3] = { 39.95,12.01,1.01 };
254 Float_t zg[3] = { 18.,6.,1. };
255 Float_t wg[3] = { .8,.057,.143 };
256 Float_t dg = .0019596;
257 //
258 // Ar-Isobutane-Forane-SF6 gas (49%+7%+40%+4%) -- trigger
259 Float_t atrig[5] = { 39.95,12.01,1.01,19.,32.066 };
260 Float_t ztrig[5] = { 18.,6.,1.,9.,16. };
261 Float_t wtrig[5] = { .49,1.08,1.5,1.84,0.04 };
262 Float_t dtrig = .0031463;
263 //
264 // bakelite
265
266 Float_t abak[3] = {12.01 , 1.01 , 16.};
267 Float_t zbak[3] = {6. , 1. , 8.};
268 Float_t wbak[3] = {6. , 6. , 1.};
269 Float_t dbak = 1.4;
270
271 Float_t epsil, stmin, deemax, tmaxfd, stemax;
272
273 Int_t iSXFLD = gAlice->Field()->Integ();
274 Float_t sXMGMX = gAlice->Field()->Max();
275 //
276 // --- Define the various materials for GEANT ---
277 AliMaterial(9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
278 AliMaterial(10, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
279 AliMaterial(15, "AIR$ ", 14.61, 7.3, .001205, 30423.24, 67500);
280 AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
281 AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
282 AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
283 AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
284 AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
285 AliMixture(24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas);
1e8fff9c 286 // materials for slat:
287 // Sensitive area: gas (already defined)
288 // PCB: copper
289 // insulating material and frame: vetronite
290 // walls: carbon, rohacell, carbon
291 Float_t aglass[5]={12.01, 28.09, 16., 10.8, 23.};
292 Float_t zglass[5]={ 6., 14., 8., 5., 11.};
293 Float_t wglass[5]={ 0.5, 0.105, 0.355, 0.03, 0.01};
294 Float_t dglass=1.74;
295
296 // rohacell: C9 H13 N1 O2
297 Float_t arohac[4] = {12.01, 1.01, 14.010, 16.};
298 Float_t zrohac[4] = { 6., 1., 7., 8.};
299 Float_t wrohac[4] = { 9., 13., 1., 2.};
300 Float_t drohac = 0.03;
301
302 AliMaterial(31, "COPPER$", 63.54, 29., 8.96, 1.4, 0.);
303 AliMixture(32, "Vetronite$",aglass, zglass, dglass, 5, wglass);
304 AliMaterial(33, "Carbon$", 12.01, 6., 2.265, 18.8, 49.9);
305 AliMixture(34, "Rohacell$", arohac, zrohac, drohac, -4, wrohac);
306
a9e2aefa 307
308 epsil = .001; // Tracking precision,
309 stemax = -1.; // Maximum displacement for multiple scat
310 tmaxfd = -20.; // Maximum angle due to field deflection
311 deemax = -.3; // Maximum fractional energy loss, DLS
312 stmin = -.8;
313 //
314 // Air
315 AliMedium(1, "AIR_CH_US ", 15, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
316 //
317 // Aluminum
318
319 AliMedium(4, "ALU_CH_US ", 9, 0, iSXFLD, sXMGMX, tmaxfd, fMaxStepAlu,
320 fMaxDestepAlu, epsil, stmin);
321 AliMedium(5, "ALU_CH_US ", 10, 0, iSXFLD, sXMGMX, tmaxfd, fMaxStepAlu,
322 fMaxDestepAlu, epsil, stmin);
323 //
324 // Ar-isoC4H10 gas
325
326 AliMedium(6, "AR_CH_US ", 20, 1, iSXFLD, sXMGMX, tmaxfd, fMaxStepGas,
327 fMaxDestepGas, epsil, stmin);
328//
329 // Ar-Isobuthane-Forane-SF6 gas
330
331 AliMedium(7, "GAS_CH_TRIGGER ", 21, 1, iSXFLD, sXMGMX, tmaxfd, stemax, deemax, epsil, stmin);
332
333 AliMedium(8, "BAKE_CH_TRIGGER ", 19, 0, iSXFLD, sXMGMX, tmaxfd, fMaxStepAlu,
334 fMaxDestepAlu, epsil, stmin);
335
336 AliMedium(9, "ARG_CO2 ", 22, 1, iSXFLD, sXMGMX, tmaxfd, fMaxStepGas,
337 fMaxDestepAlu, epsil, stmin);
1e8fff9c 338 // tracking media for slats: check the parameters!!
339 AliMedium(11, "PCB_COPPER ", 31, 0, iSXFLD, sXMGMX, tmaxfd,
340 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
341 AliMedium(12, "VETRONITE ", 32, 0, iSXFLD, sXMGMX, tmaxfd,
342 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
343 AliMedium(13, "CARBON ", 33, 0, iSXFLD, sXMGMX, tmaxfd,
344 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
345 AliMedium(14, "Rohacell ", 34, 0, iSXFLD, sXMGMX, tmaxfd,
346 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
acc838fd 347
348
349
350 //.Materials specific to stations
351 // created via builders
352
353 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
354
355 // Get the builder
356 AliMUONVGeometryBuilder* builder
357 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
358
359 // Create materials with each builder
360 if (builder) builder->CreateMaterials();
361 }
a9e2aefa 362}
363
acc838fd 364//______________________________________________________________________________
365void AliMUONv1::PlaceVolume(const TString& name, const TString& mName,
366 Int_t copyNo, const TGeoHMatrix& matrix,
367 Int_t npar, Double_t* param) const
368{
369// Place the volume specified by name with the given transformation matrix
370// ---
371
372 // Do not apply global transformation
373 // if mother volume == DDIP
374 // (as it is applied on this volume)
375 TGeoHMatrix transform(matrix);
376 if (mName == TString("DDIP")) {
377 transform = (*fGlobalTransformation) * transform;
378 // To be changed to (*fGlobalTransformation).inverse()
379 // when available in TGeo
380 // To make this correct also for a general case when
381 // (*fGlobalTransformation) * *fGlobalTransformation) != 1
382 }
383
384 // Decompose transformation
385 const Double_t* xyz = transform.GetTranslation();
386 const Double_t* rm = transform.GetRotationMatrix();
387
388 //cout << "Got translation: "
389 // << xyz[0] << " " << xyz[1] << " " << xyz[2] << endl;
390
391 //cout << "Got rotation: "
392 // << rm[0] << " " << rm[1] << " " << rm[2] << endl
393 // << rm[3] << " " << rm[4] << " " << rm[5] << endl
394 // << rm[6] << " " << rm[7] << " " << rm[8] << endl;
395
396 // Check for presence of rotation
397 // (will be nice to be available in TGeo)
398 const Double_t kTolerance = 1e-04;
399 Bool_t isRotation = true;
400 if (TMath::Abs(rm[0] - 1.) < kTolerance &&
401 TMath::Abs(rm[1] - 0.) < kTolerance &&
402 TMath::Abs(rm[2] - 0.) < kTolerance &&
403 TMath::Abs(rm[3] - 0.) < kTolerance &&
404 TMath::Abs(rm[4] - 1.) < kTolerance &&
405 TMath::Abs(rm[5] - 0.) < kTolerance &&
406 TMath::Abs(rm[6] - 0.) < kTolerance &&
407 TMath::Abs(rm[7] - 0.) < kTolerance &&
408 TMath::Abs(rm[8] - 1.) < kTolerance) isRotation = false;
409
410 Int_t krot = 0;
411 if (isRotation) {
412 TGeoRotation rot;
413 rot.SetMatrix(const_cast<Double_t*>(transform.GetRotationMatrix()));
414 Double_t theta1, phi1, theta2, phi2, theta3, phi3;
415 rot.GetAngles(theta1, phi1, theta2, phi2, theta3, phi3);
416
417 //cout << "angles: "
418 // << theta1 << " " << phi1 << " "
419 // << theta2 << " " << phi2 << " "
420 // << theta3 << " " << phi3 << endl;
421
422 AliMatrix(krot, theta1, phi1, theta2, phi2, theta3, phi3);
423 }
424
425 // Place the volume in ALIC
426 if (npar == 0)
427 gMC->Gspos(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, "ONLY");
428 else
429 gMC->Gsposp(name, copyNo, mName, xyz[0], xyz[1], xyz[2] , krot, "ONLY",
430 param, npar);
431
432}
a9e2aefa 433
acc838fd 434//___________________________________________
a9e2aefa 435void AliMUONv1::Init()
436{
437 //
438 // Initialize Tracking Chambers
439 //
440
9e1a0ddb 441 if(fDebug) printf("\n%s: Start Init for version 1 - CPC chamber type\n\n",ClassName());
e17592e9 442 Int_t i;
f665c1ea 443 for (i=0; i<AliMUONConstants::NCh(); i++) {
a9e2aefa 444 ( (AliMUONChamber*) (*fChambers)[i])->Init();
445 }
446
acc838fd 447 //
448 // Set the chamber (sensitive region) GEANT identifier
449 //
450 for (Int_t i=0; i<fGeometryBuilders->GetEntriesFast(); i++) {
451
452 // Get the builder
453 AliMUONVGeometryBuilder* builder
454 = (AliMUONVGeometryBuilder*)fGeometryBuilders->At(i);
455
456 // Set sesitive volumes with each builder
457 if (builder) builder->SetSensitiveVolumes();
458 }
459
460/*
a9e2aefa 461 //
462 // Set the chamber (sensitive region) GEANT identifier
b74f1c6a 463 ((AliMUONChamber*)(*fChambers)[0])->SetGid(gMC->VolId("S01G"));
464 ((AliMUONChamber*)(*fChambers)[1])->SetGid(gMC->VolId("S02G"));
b17c0c87 465
b74f1c6a 466 ((AliMUONChamber*)(*fChambers)[2])->SetGid(gMC->VolId("S03G"));
467 ((AliMUONChamber*)(*fChambers)[3])->SetGid(gMC->VolId("S04G"));
b17c0c87 468
1e8fff9c 469 ((AliMUONChamber*)(*fChambers)[4])->SetGid(gMC->VolId("S05G"));
470 ((AliMUONChamber*)(*fChambers)[5])->SetGid(gMC->VolId("S06G"));
b17c0c87 471
1e8fff9c 472 ((AliMUONChamber*)(*fChambers)[6])->SetGid(gMC->VolId("S07G"));
473 ((AliMUONChamber*)(*fChambers)[7])->SetGid(gMC->VolId("S08G"));
b17c0c87 474
1e8fff9c 475 ((AliMUONChamber*)(*fChambers)[8])->SetGid(gMC->VolId("S09G"));
476 ((AliMUONChamber*)(*fChambers)[9])->SetGid(gMC->VolId("S10G"));
b17c0c87 477
b74f1c6a 478 ((AliMUONChamber*)(*fChambers)[10])->SetGid(gMC->VolId("SG1A"));
479 ((AliMUONChamber*)(*fChambers)[11])->SetGid(gMC->VolId("SG2A"));
480 ((AliMUONChamber*)(*fChambers)[12])->SetGid(gMC->VolId("SG3A"));
481 ((AliMUONChamber*)(*fChambers)[13])->SetGid(gMC->VolId("SG4A"));
acc838fd 482*/
9e1a0ddb 483 if(fDebug) printf("\n%s: Finished Init for version 1 - CPC chamber type\n",ClassName());
a9e2aefa 484
485 //cp
9e1a0ddb 486 if(fDebug) printf("\n%s: Start Init for Trigger Circuits\n",ClassName());
f665c1ea 487 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
a9e2aefa 488 ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
489 }
9e1a0ddb 490 if(fDebug) printf("%s: Finished Init for Trigger Circuits\n",ClassName());
a9e2aefa 491 //cp
a9e2aefa 492}
1391e633 493
1391e633 494//_______________________________________________________________________________
c33d9661 495void AliMUONv1::StepManager()
496{
d7c4fbc4 497 // Stepmanager for the chambers
498
1391e633 499 if (fStepManagerVersionOld) {
c33d9661 500 StepManagerOld();
501 return;
502 }
c33d9661 503
504 // Only charged tracks
505 if( !(gMC->TrackCharge()) ) return;
1391e633 506 // Only charged tracks
507
c33d9661 508 // Only gas gap inside chamber
509 // Tag chambers and record hits when track enters
acc838fd 510 static Int_t idvol=-1;
1391e633 511 Int_t iChamber=0;
512 Int_t id=0;
513 Int_t copy;
514 const Float_t kBig = 1.e10;
515
acc838fd 516
517 //
518 // Only gas gap inside chamber
519 // Tag chambers and record hits when track enters
c33d9661 520 id=gMC->CurrentVolID(copy);
acc838fd 521 iChamber = GetChamberId(id);
522 idvol = iChamber -1;
523
524 if (idvol == -1) return;
abaf7c9d 525
1391e633 526 if( gMC->IsTrackEntering() ) {
527 Float_t theta = fTrackMomentum.Theta();
4ac9d21e 528 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
529 }
abaf7c9d 530
1391e633 531// if (GetDebug()) {
532// Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
533// Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
534// }
535 // Particule id and mass,
536 Int_t ipart = gMC->TrackPid();
537 Float_t mass = gMC->TrackMass();
538
539 fDestepSum[idvol]+=gMC->Edep();
540 // Get current particle id (ipart), track position (pos) and momentum (mom)
541 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
542 fStepSum[idvol]+=gMC->TrackStep();
abaf7c9d 543
1391e633 544// if (GetDebug()) {
545// Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
acc838fd 546// iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg, mass, fStepSum[idvol], gMC->Edep());
1391e633 547// Info("StepManager Step","Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(), fTrackMomentum.Z()) ;
548// gMC->TrackPosition(fTrackPosition);
549// Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
d08aff2d 550// }
1391e633 551
552 // Track left chamber or StepSum larger than fStepMaxInActiveGas
553 if ( gMC->IsTrackExiting() ||
554 gMC->IsTrackStop() ||
555 gMC->IsTrackDisappeared()||
556 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
557
558 if ( gMC->IsTrackExiting() ||
acc838fd 559 gMC->IsTrackStop() ||
560 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
1391e633 561
562 gMC->TrackPosition(fTrackPosition);
563 Float_t theta = fTrackMomentum.Theta();
564 Float_t phi = fTrackMomentum.Phi();
565
d7c4fbc4 566 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
acc838fd 567 fStepSum[idvol]/2.*sin(theta)*sin(phi),
568 fStepSum[idvol]/2.*cos(theta),0.0 );
1391e633 569 // if (GetDebug())
570 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
571 // if (GetDebug())
d7c4fbc4 572 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
573 fTrackPosition-=backToWire;
1391e633 574
575 //-------------- Angle effect
576 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
577
d7c4fbc4 578 Float_t BetaxGamma = fTrackMomentum.P()/mass;// pc/mc2
579 Float_t sigmaEffect10degrees;
580 Float_t sigmaEffectThetadegrees;
581 Float_t eLossParticleELossMip;
582 Float_t yAngleEffect=0.;
583 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
584
374ebd7d 585
586 if (fAngleEffect){
d7c4fbc4 587 if ( (BetaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
588 BetaxGamma=TMath::Log(BetaxGamma);
589 eLossParticleELossMip = fElossRatio->Eval(BetaxGamma);
1391e633 590 // 10 degrees is a reference for a model (arbitrary)
d7c4fbc4 591 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
1391e633 592 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
d7c4fbc4 593 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
1391e633 594 if ( (iChamber==1) || (iChamber==2) )
acc838fd 595 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
d7c4fbc4 596 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
1391e633 597 }
374ebd7d 598 }
1391e633 599
600 // One hit per chamber
5d12ce38 601 GetMUONData()->AddHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), iChamber, ipart,
acc838fd 602 fTrackPosition.X(), fTrackPosition.Y()+yAngleEffect, fTrackPosition.Z(), 0.0,
603 fTrackMomentum.P(),theta, phi, fStepSum[idvol], fDestepSum[idvol],
604 fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z());
1391e633 605// if (GetDebug()){
606// Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
607// Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
608// Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
609// }
610 fStepSum[idvol] =0; // Reset for the next event
611 fDestepSum[idvol]=0; // Reset for the next event
612 }
abaf7c9d 613}
5f91c9e8 614
4ac9d21e 615//__________________________________________
c33d9661 616void AliMUONv1::StepManagerOld()
a9e2aefa 617{
d7c4fbc4 618 // Old Stepmanager for the chambers
a9e2aefa 619 Int_t copy, id;
acc838fd 620 static Int_t idvol =-1;
a9e2aefa 621 static Int_t vol[2];
622 Int_t ipart;
623 TLorentzVector pos;
624 TLorentzVector mom;
625 Float_t theta,phi;
626 Float_t destep, step;
abaf7c9d 627
d7c4fbc4 628 static Float_t sstep;
1e8fff9c 629 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
2eb55fab 630 const Float_t kBig = 1.e10;
a9e2aefa 631 static Float_t hits[15];
632
633 TClonesArray &lhits = *fHits;
634
635 //
a9e2aefa 636 //
637 // Only charged tracks
638 if( !(gMC->TrackCharge()) ) return;
639 //
640 // Only gas gap inside chamber
641 // Tag chambers and record hits when track enters
a9e2aefa 642 id=gMC->CurrentVolID(copy);
5f91c9e8 643 vol[0] = GetChamberId(id);
644 idvol = vol[0] -1;
645
646 if (idvol == -1) return;
647
a9e2aefa 648 //
649 // Get current particle id (ipart), track position (pos) and momentum (mom)
650 gMC->TrackPosition(pos);
651 gMC->TrackMomentum(mom);
652
653 ipart = gMC->TrackPid();
a9e2aefa 654
655 //
656 // momentum loss and steplength in last step
657 destep = gMC->Edep();
658 step = gMC->TrackStep();
abaf7c9d 659 // cout<<"------------"<<step<<endl;
a9e2aefa 660 //
661 // record hits when track enters ...
662 if( gMC->IsTrackEntering()) {
abaf7c9d 663
a9e2aefa 664 gMC->SetMaxStep(fMaxStepGas);
665 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
666 Double_t rt = TMath::Sqrt(tc);
667 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
2eb55fab 668 Double_t tx = mom[0]/pmom;
669 Double_t ty = mom[1]/pmom;
670 Double_t tz = mom[2]/pmom;
671 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
acc838fd 672 ->ResponseModel()
673 ->Pitch()/tz;
a9e2aefa 674 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
675 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
676 hits[0] = Float_t(ipart); // Geant3 particle type
2eb55fab 677 hits[1] = pos[0]+s*tx; // X-position for hit
678 hits[2] = pos[1]+s*ty; // Y-position for hit
679 hits[3] = pos[2]+s*tz; // Z-position for hit
a9e2aefa 680 hits[4] = theta; // theta angle of incidence
681 hits[5] = phi; // phi angle of incidence
ce3f5e87 682 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
a9e2aefa 683 hits[9] = -1; // last pad hit
2eb55fab 684 hits[10] = mom[3]; // hit momentum P
685 hits[11] = mom[0]; // Px
686 hits[12] = mom[1]; // Py
687 hits[13] = mom[2]; // Pz
a9e2aefa 688 tof=gMC->TrackTime();
2eb55fab 689 hits[14] = tof; // Time of flight
690 tlength = 0;
691 eloss = 0;
692 eloss2 = 0;
d7c4fbc4 693 sstep=0;
2eb55fab 694 xhit = pos[0];
695 yhit = pos[1];
696 zhit = pos[2];
681d067b 697 Chamber(idvol).ChargeCorrelationInit();
a9e2aefa 698 // Only if not trigger chamber
1e8fff9c 699
abaf7c9d 700// printf("---------------------------\n");
701// printf(">>>> Y = %f \n",hits[2]);
702// printf("---------------------------\n");
703
1e8fff9c 704
705
abaf7c9d 706 // if(idvol < AliMUONConstants::NTrackingCh()) {
acc838fd 707// //
708// // Initialize hit position (cursor) in the segmentation model
709// ((AliMUONChamber*) (*fChambers)[idvol])
710// ->SigGenInit(pos[0], pos[1], pos[2]);
abaf7c9d 711// } else {
acc838fd 712// //geant3->Gpcxyz();
713// //printf("In the Trigger Chamber #%d\n",idvol-9);
abaf7c9d 714// }
a9e2aefa 715 }
716 eloss2+=destep;
d7c4fbc4 717 sstep+=step;
abaf7c9d 718
d7c4fbc4 719 // cout<<sstep<<endl;
abaf7c9d 720
a9e2aefa 721 //
722 // Calculate the charge induced on a pad (disintegration) in case
723 //
724 // Mip left chamber ...
725 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
726 gMC->SetMaxStep(kBig);
727 eloss += destep;
728 tlength += step;
729
802a864d 730 Float_t x0,y0,z0;
731 Float_t localPos[3];
732 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
802a864d 733 gMC->Gmtod(globalPos,localPos,1);
734
2eb55fab 735 if(idvol < AliMUONConstants::NTrackingCh()) {
a9e2aefa 736// tracking chambers
acc838fd 737 x0 = 0.5*(xhit+pos[0]);
738 y0 = 0.5*(yhit+pos[1]);
739 z0 = 0.5*(zhit+pos[2]);
a9e2aefa 740 } else {
741// trigger chambers
acc838fd 742 x0 = xhit;
743 y0 = yhit;
744 z0 = 0.;
a9e2aefa 745 }
746
1e8fff9c 747
ce3f5e87 748 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
a9e2aefa 749
acc838fd 750
2eb55fab 751 hits[6] = tlength; // track length
752 hits[7] = eloss2; // de/dx energy loss
753
abaf7c9d 754
ce3f5e87 755 // if (fNPadHits > (Int_t)hits[8]) {
acc838fd 756 // hits[8] = hits[8]+1;
757 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
ce3f5e87 758 //}
2eb55fab 759//
760// new hit
761
a9e2aefa 762 new(lhits[fNhits++])
acc838fd 763 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
a9e2aefa 764 eloss = 0;
765 //
766 // Check additional signal generation conditions
767 // defined by the segmentation
a75f073c 768 // model (boundary crossing conditions)
769 // only for tracking chambers
a9e2aefa 770 } else if
a75f073c 771 ((idvol < AliMUONConstants::NTrackingCh()) &&
772 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
a9e2aefa 773 {
774 ((AliMUONChamber*) (*fChambers)[idvol])
acc838fd 775 ->SigGenInit(pos[0], pos[1], pos[2]);
802a864d 776
777 Float_t localPos[3];
778 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
779 gMC->Gmtod(globalPos,localPos,1);
780
e0f71fb7 781 eloss += destep;
802a864d 782
ce3f5e87 783 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
acc838fd 784 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
a9e2aefa 785 xhit = pos[0];
786 yhit = pos[1];
e0f71fb7 787 zhit = pos[2];
788 eloss = 0;
a9e2aefa 789 tlength += step ;
790 //
791 // nothing special happened, add up energy loss
792 } else {
793 eloss += destep;
794 tlength += step ;
795 }
796}