]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONv1.cxx
- Using AliMUONStringIntMap instead of AliMUONGeometrySVMap
[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
30178c30 22#include "AliMUONv1.h"
88cb7938 23#include "AliMUONConstants.h"
40afd6cd 24#include "AliMUONSegFactory.h"
b7ef3c96 25#include "AliMUONResponseFactory.h"
26#include "AliMUONSegmentation.h"
a9e2aefa 27#include "AliMUONHit.h"
8c449e83 28#include "AliMUONTriggerCircuit.h"
d4bb94a1 29#include "AliMUONGeometryBuilder.h"
b7ef3c96 30#include "AliMUONGeometry.h"
31#include "AliMUONGeometryTransformer.h"
e118b27e 32#include "AliMUONGeometryModule.h"
7ecf374b 33#include "AliMUONStringIntMap.h"
e118b27e 34#include "AliMUONGeometryDetElement.h"
7ecf374b 35
36#include "AliConst.h"
88cb7938 37#include "AliMagF.h"
38#include "AliRun.h"
5d12ce38 39#include "AliMC.h"
8c343c7c 40#include "AliLog.h"
a9e2aefa 41
7ecf374b 42#include <TRandom.h>
43#include <TF1.h>
44#include <TClonesArray.h>
45#include <TRandom.h>
46#include <TVirtualMC.h>
47#include <TGeoMatrix.h>
48
edee5e63 49#include <string>
50
a9e2aefa 51ClassImp(AliMUONv1)
52
53//___________________________________________
30178c30 54AliMUONv1::AliMUONv1()
55 : AliMUON(),
e8e385f7 56 fStepManagerVersionOld(kTRUE),
57 fStepManagerVersionDE(kTRUE),
d4bb94a1 58 fAngleEffect(kTRUE),
59 fStepMaxInActiveGas(0.6),
60 fStepSum(0x0),
61 fDestepSum(0x0),
62 fTrackMomentum(),
63 fTrackPosition(),
64 fElossRatio(0x0),
65 fAngleEffect10(0x0),
b7ef3c96 66 fAngleEffectNorma(0x0)
a9e2aefa 67{
d4bb94a1 68// Default constructor
edee5e63 69 AliDebug(1,Form("default (empty) ctor this=%p",this));
1391e633 70}
d4bb94a1 71
a9e2aefa 72//___________________________________________
b05d84a5 73AliMUONv1::AliMUONv1(const char *name, const char *title,
74 const char* sDigitizerClassName,
75 const char* digitizerClassName)
76: AliMUON(name,title,sDigitizerClassName,digitizerClassName),
e8e385f7 77 fStepManagerVersionOld(kTRUE),
78 fStepManagerVersionDE(kTRUE),
d4bb94a1 79 fAngleEffect(kTRUE),
80 fStepMaxInActiveGas(0.6),
81 fStepSum(0x0),
82 fDestepSum(0x0),
83 fTrackMomentum(),
84 fTrackPosition(),
85 fElossRatio(0x0),
86 fAngleEffect10(0x0),
b7ef3c96 87 fAngleEffectNorma(0x0)
a9e2aefa 88{
d4bb94a1 89// Standard onstructor
90
edee5e63 91 AliDebug(1,Form("ctor this=%p",this));
92
ba030c0e 93 // By default include all stations
c33d9661 94
1391e633 95 fStepSum = new Float_t [AliMUONConstants::NCh()];
96 fDestepSum = new Float_t [AliMUONConstants::NCh()];
97 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
98 fStepSum[i] =0.0;
99 fDestepSum[i]=0.0;
100 }
101 // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
102 fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.);
103 fElossRatio->SetParameter(0,1.02138);
104 fElossRatio->SetParameter(1,-9.54149e-02);
105 fElossRatio->SetParameter(2,+7.83433e-02);
106 fElossRatio->SetParameter(3,-9.98208e-03);
107 fElossRatio->SetParameter(4,+3.83279e-04);
108
109 // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
110 fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
111 fAngleEffect10->SetParameter(0, 1.90691e+02);
112 fAngleEffect10->SetParameter(1,-6.62258e+01);
113 fAngleEffect10->SetParameter(2,+1.28247e+01);
114 // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)
115 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
116 fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
117 fAngleEffectNorma->SetParameter(0,4.148);
118 fAngleEffectNorma->SetParameter(1,-6.809e-01);
119 fAngleEffectNorma->SetParameter(2,5.151e-02);
120 fAngleEffectNorma->SetParameter(3,-1.490e-03);
a9e2aefa 121}
122
fb1bf5c0 123//_____________________________________________________________________________
124AliMUONv1::AliMUONv1(const AliMUONv1& right)
125 : AliMUON(right)
126{
127 // copy constructor (not implemented)
128
8c343c7c 129 AliFatal("Copy constructor not provided.");
fb1bf5c0 130}
131
a9e2aefa 132//___________________________________________
acc838fd 133AliMUONv1::~AliMUONv1()
a9e2aefa 134{
acc838fd 135// Destructor
edee5e63 136 AliDebug(1,Form("dtor this=%p",this));
d4bb94a1 137 delete [] fStepSum;
138 delete [] fDestepSum;
139 delete fElossRatio;
140 delete fAngleEffect10;
8109731a 141 delete fAngleEffectNorma;
acc838fd 142}
b17c0c87 143
fb1bf5c0 144//_____________________________________________________________________________
145AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
146{
147 // assignement operator (not implemented)
148
149 // check assignement to self
150 if (this == &right) return *this;
151
8c343c7c 152 AliFatal("Assignement operator not provided.");
fb1bf5c0 153
154 return *this;
155}
156
acc838fd 157//__________________________________________________
158void AliMUONv1::CreateGeometry()
159{
b17c0c87 160//
d4bb94a1 161// Construct geometry using geometry builder
a9e2aefa 162//
a9e2aefa 163
d4bb94a1 164 fGeometryBuilder->CreateGeometry();
acc838fd 165}
a9e2aefa 166
acc838fd 167//________________________________________________________________
a9e2aefa 168void AliMUONv1::CreateMaterials()
169{
a9e2aefa 170//
d4bb94a1 171// Construct materials using geometry builder
172//
acc838fd 173
d4bb94a1 174 fGeometryBuilder->CreateMaterials();
a9e2aefa 175}
176
acc838fd 177//___________________________________________
a9e2aefa 178void AliMUONv1::Init()
a713db22 179{
edee5e63 180 AliDebug(1,"Start Init for version 1 - CPC chamber type");
002920d1 181
edee5e63 182 //
183 // Initialize geometry
184 //
185 fGeometryBuilder->InitGeometry();
186 AliDebug(1,"Finished Init for version 1 - CPC chamber type");
b7ef3c96 187
188
edee5e63 189 std::string ftype(GetTitle());
b7ef3c96 190
191 // Build segmentation
192 // using geometry parametrisation
193 //
40afd6cd 194 AliMUONSegFactory segFactory(GetGeometryTransformer());
195 fSegmentation = segFactory.CreateSegmentation(ftype);
196
197 if (!fSegmentation) {
198 AliFatal(Form("Wrong factory type : %s",ftype.c_str()));
199 }
b7ef3c96 200
201 // Build response
edee5e63 202 //
b7ef3c96 203 AliMUONResponseFactory respFactory("default");
204 respFactory.Build(this);
205
206
edee5e63 207 // Initialize segmentation
208 //
b7ef3c96 209 fSegmentation->Init();
210
211 // Initialize trigger circuits
212 //
213 for (Int_t i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
e1d9a0df 214 AliMUONTriggerCircuit* c = (AliMUONTriggerCircuit*)(fTriggerCircuits->At(i));
215 c->Init(i);
216// c->Print();
217 }
edee5e63 218
a9e2aefa 219}
1391e633 220
d4bb94a1 221//__________________________________________________________________
222Int_t AliMUONv1::GetChamberId(Int_t volId) const
223{
224// Check if the volume with specified volId is a sensitive volume (gas)
225// of some chamber and returns the chamber number;
226// if not sensitive volume - return 0.
227// ---
228
b7ef3c96 229 for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
230 if ( GetGeometry()->GetModule(i)->IsSensitiveVolume(volId) )
231 return i+1;
232 }
d4bb94a1 233
234 return 0;
235}
333f7cda 236
237//_______________________________________________________________________________
238TString AliMUONv1::CurrentVolumePath() const
239{
240// Returns current volume path
241// (Could be removed when this function is available via gMC)
242// ---
243
244 TString path = "";
245 TString name;
246 Int_t copyNo;
247 Int_t imother = 0;
248 do {
249 name = gMC->CurrentVolOffName(imother);
250 gMC->CurrentVolOffID(imother++, copyNo);
251 TString add = "/";
252 add += name;
7ecf374b 253 add += "_";
333f7cda 254 add += copyNo;
255 path.Insert(0,add);
256 }
257 while ( name != TString("ALIC") );
258
259 return path;
260}
261
1391e633 262//_______________________________________________________________________________
c33d9661 263void AliMUONv1::StepManager()
264{
d7c4fbc4 265 // Stepmanager for the chambers
d59b2ec3 266 // TBR
267
268 if (fStepManagerVersionDE) {
269 StepManager2();
270 return;
271 }
d7c4fbc4 272
c33d9661 273
274 // Only charged tracks
d59b2ec3 275 if( !(gMC->TrackCharge()) ) return;
1391e633 276 // Only charged tracks
277
c33d9661 278 // Only gas gap inside chamber
279 // Tag chambers and record hits when track enters
acc838fd 280 static Int_t idvol=-1;
1391e633 281 Int_t iChamber=0;
282 Int_t id=0;
283 Int_t copy;
284 const Float_t kBig = 1.e10;
285
acc838fd 286
287 //
288 // Only gas gap inside chamber
289 // Tag chambers and record hits when track enters
c33d9661 290 id=gMC->CurrentVolID(copy);
acc838fd 291 iChamber = GetChamberId(id);
292 idvol = iChamber -1;
293
294 if (idvol == -1) return;
abaf7c9d 295
967a2a25 296 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
297 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
298 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
299
1391e633 300 if( gMC->IsTrackEntering() ) {
301 Float_t theta = fTrackMomentum.Theta();
4ac9d21e 302 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
303 }
abaf7c9d 304
5a0e88a7 305 // AliDebug(1,
306 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
307 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z()));
308 // Particule id and mass,
1391e633 309 Int_t ipart = gMC->TrackPid();
310 Float_t mass = gMC->TrackMass();
311
312 fDestepSum[idvol]+=gMC->Edep();
313 // Get current particle id (ipart), track position (pos) and momentum (mom)
314 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
315 fStepSum[idvol]+=gMC->TrackStep();
abaf7c9d 316
5a0e88a7 317 // if(AliDebugLevel()) {
318 // AliDebug(1,
319 // Form("iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
320 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
321 // mass, fStepSum[idvol], gMC->Edep()));
322 // AliDebug(1,
323 // Form("Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
324 // fTrackMomentum.Z()));
325 // gMC->TrackPosition(fTrackPosition);
326 // AliDebug(1,
327 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),
328 // fTrackPosition.Z())) ;
329 // }
1391e633 330
331 // Track left chamber or StepSum larger than fStepMaxInActiveGas
332 if ( gMC->IsTrackExiting() ||
333 gMC->IsTrackStop() ||
334 gMC->IsTrackDisappeared()||
335 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
336
337 if ( gMC->IsTrackExiting() ||
acc838fd 338 gMC->IsTrackStop() ||
339 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
1391e633 340
341 gMC->TrackPosition(fTrackPosition);
342 Float_t theta = fTrackMomentum.Theta();
343 Float_t phi = fTrackMomentum.Phi();
344
d7c4fbc4 345 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
acc838fd 346 fStepSum[idvol]/2.*sin(theta)*sin(phi),
347 fStepSum[idvol]/2.*cos(theta),0.0 );
5a0e88a7 348 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),
349 // fTrackPosition.Y(),fTrackPosition.Z())) ;
350 // AliDebug(1,Form("Exit: Track backToWire %f %f %f",backToWire.X(),
351 // backToWire.Y(),backToWire.Z()) ;
d7c4fbc4 352 fTrackPosition-=backToWire;
1391e633 353
354 //-------------- Angle effect
355 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
356
30178c30 357 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
d7c4fbc4 358 Float_t sigmaEffect10degrees;
359 Float_t sigmaEffectThetadegrees;
360 Float_t eLossParticleELossMip;
361 Float_t yAngleEffect=0.;
362 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
363
374ebd7d 364
365 if (fAngleEffect){
30178c30 366 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
367 betaxGamma=TMath::Log(betaxGamma);
368 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
1391e633 369 // 10 degrees is a reference for a model (arbitrary)
d7c4fbc4 370 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
1391e633 371 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
d7c4fbc4 372 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
1391e633 373 if ( (iChamber==1) || (iChamber==2) )
acc838fd 374 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
d7c4fbc4 375 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
1391e633 376 }
374ebd7d 377 }
1391e633 378
333f7cda 379 // Detection elements ids
b7ef3c96 380 const AliMUONGeometryModule* kGeometryModule
381 = GetGeometry()->GetModule(iChamber-1);
e118b27e 382
383 AliMUONGeometryDetElement* detElement
b7ef3c96 384 = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath());
e118b27e 385
333f7cda 386 Int_t detElemId = 0;
e118b27e 387 if (detElement) detElemId = detElement->GetUniqueID();
333f7cda 388
389 if (!detElemId) {
390 cerr << "Chamber id: "
391 << setw(3) << iChamber << " "
392 << "Current SV: "
393 << CurrentVolumePath()
394 << " detElemId: "
395 << setw(5) << detElemId
396 << endl;
397 Double_t x, y, z;
398 gMC->TrackPosition(x, y, z);
399 cerr << " global position: "
400 << x << ", " << y << ", " << z
401 << endl;
8c343c7c 402 AliWarning("DetElemId not identified.");
333f7cda 403 }
404
1391e633 405 // One hit per chamber
47464038 406 GetMUONData()->AddHit(fIshunt,
407 gAlice->GetMCApp()->GetCurrentTrackNumber(),
408 iChamber, ipart,
409 fTrackPosition.X(),
410 fTrackPosition.Y()+yAngleEffect,
411 fTrackPosition.Z(),
412 gMC->TrackTime(),
413 fTrackMomentum.P(),
414 theta,
415 phi,
416 fStepSum[idvol],
417 fDestepSum[idvol],
418 fTrackPosition.X(),
419 fTrackPosition.Y(),
420 fTrackPosition.Z());
421
5a0e88a7 422// if (AliDebugLevel()){
423// AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
424// AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
425// AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z())) ;
1391e633 426// }
427 fStepSum[idvol] =0; // Reset for the next event
428 fDestepSum[idvol]=0; // Reset for the next event
429 }
abaf7c9d 430}
5f91c9e8 431
d59b2ec3 432//_______________________________________________________________________________
433void AliMUONv1::StepManager2()
434{
435 // Stepmanager for the chambers
436
d59b2ec3 437 // Only charged tracks
438 if( !(gMC->TrackCharge()) ) return;
439 // Only charged tracks
440
441 // Only gas gap inside chamber
442 // Tag chambers and record hits when track enters
c5ce4e69 443 static Int_t idvol=-1, iEnter = 0;
d59b2ec3 444 Int_t iChamber=0;
445 Int_t id=0;
446 Int_t copy;
447 const Float_t kBig = 1.e10;
c5ce4e69 448 static Double_t xyzEnter[3];
d59b2ec3 449
450 //
451 // Only gas gap inside chamber
452 // Tag chambers and record hits when track enters
453 id=gMC->CurrentVolID(copy);
454 iChamber = GetChamberId(id);
455 idvol = iChamber -1;
456
457 if (idvol == -1) return;
458
459 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
460 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
461 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
462
463 if( gMC->IsTrackEntering() ) {
464 Float_t theta = fTrackMomentum.Theta();
465 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
c5ce4e69 466 iEnter = 1;
467 gMC->TrackPosition(xyzEnter[0], xyzEnter[1], xyzEnter[2]); // save coordinates of entrance point
d59b2ec3 468 }
469
5a0e88a7 470 // AliDebug(1,
471 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
472 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z())) ;
d59b2ec3 473 // Particule id and mass,
474 Int_t ipart = gMC->TrackPid();
475 Float_t mass = gMC->TrackMass();
476
477 fDestepSum[idvol]+=gMC->Edep();
478 // Get current particle id (ipart), track position (pos) and momentum (mom)
479 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
480 fStepSum[idvol]+=gMC->TrackStep();
481
5a0e88a7 482 // if (AliDebugLevel()) {
483 // AliDebug(1,Form("Step, iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
484 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
485 // mass, fStepSum[idvol], gMC->Edep()));
486 // AliDebug(1,Form("Step:Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
487 // fTrackMomentum.Z()));
488 // gMC->TrackPosition(fTrackPosition);
489 // AliDebug(1,Form("Step: Track Position %f %f %f",fTrackPosition.X(),
490 // fTrackPosition.Y(),fTrackPosition.Z())) ;
491 //}
d59b2ec3 492
493 // Track left chamber or StepSum larger than fStepMaxInActiveGas
494 if ( gMC->IsTrackExiting() ||
495 gMC->IsTrackStop() ||
496 gMC->IsTrackDisappeared()||
497 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
498
499 if ( gMC->IsTrackExiting() ||
500 gMC->IsTrackStop() ||
501 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
c5ce4e69 502 if (fDestepSum[idvol] == 0) {
503 // AZ - no energy release
504 fStepSum[idvol] = 0; // Reset for the next event
505 iEnter = 0;
506 return;
507 }
d59b2ec3 508
509 gMC->TrackPosition(fTrackPosition);
510 Float_t theta = fTrackMomentum.Theta();
511 Float_t phi = fTrackMomentum.Phi();
512
c5ce4e69 513 if (gMC->IsTrackExiting() && iEnter != 0) {
514 // AZ - this code is to avoid artificial hit splitting at the
515 // "fake" boundary inside the same chamber. It will still produce
516 // 2 hits but with the same coordinates (at the wire) to allow
517 // their merging at the digitization level.
518
519 // Only for a track going from the entrance to the exit from the volume
520 // Get local coordinates
521 Double_t xyz0[3], xyz1[3], tmp[3];
522 gMC->Gmtod(xyzEnter, xyz0, 1); // local coord. at the entrance
523
524 fTrackPosition.Vect().GetXYZ(tmp);
525 gMC->Gmtod(tmp, xyz1, 1); // local coord. at the exit
526
527 Double_t dz = -0.5;
528 if (xyz1[2] != xyz0[2]) dz = xyz0[2] / (xyz1[2] - xyz0[2]);
529 tmp[0] = xyz0[0] - (xyz1[0] - xyz0[0]) * dz; // local coord. at the wire
530 tmp[1] = xyz0[1] - (xyz1[1] - xyz0[1]) * dz;
531 tmp[2] = xyz0[2] - (xyz1[2] - xyz0[2]) * dz;
532 gMC->Gdtom(tmp, xyz1, 1); // global coord. at the wire
533 fTrackPosition.SetXYZT(xyz1[0], xyz1[1], xyz1[2], fTrackPosition.T());
534 } else {
535 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
536 fStepSum[idvol]/2.*sin(theta)*sin(phi),
537 fStepSum[idvol]/2.*cos(theta),0.0 );
538 fTrackPosition-=backToWire;
539 //printf(" %d %d %d %f %d \n", gMC->IsTrackExiting(), gMC->IsTrackStop(), gMC->IsTrackDisappeared(), fStepSum[idvol], iEnter);
540 // AliDebug(1,
541 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()));
542 // AliDebug(1,
543 // Form("Exit: Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z())) ;
544 }
d59b2ec3 545
546 //-------------- Angle effect
547 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
548
549 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
550 Float_t sigmaEffect10degrees;
551 Float_t sigmaEffectThetadegrees;
552 Float_t eLossParticleELossMip;
553 Float_t yAngleEffect=0.;
554 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
555
556
557 if (fAngleEffect){
558 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
559 betaxGamma=TMath::Log(betaxGamma);
560 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
561 // 10 degrees is a reference for a model (arbitrary)
562 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
563 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
564 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
565 if ( (iChamber==1) || (iChamber==2) )
566 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
567 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
568 }
569 }
570
571 // Detection elements ids
b7ef3c96 572 const AliMUONGeometryModule* kGeometryModule
573 = GetGeometry()->GetModule(iChamber-1);
d59b2ec3 574
575 AliMUONGeometryDetElement* detElement
b7ef3c96 576 = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath());
d59b2ec3 577
578 Int_t detElemId = 0;
579 if (detElement) detElemId = detElement->GetUniqueID();
580
581 if (!detElemId) {
582 cerr << "Chamber id: "
583 << setw(3) << iChamber << " "
584 << "Current SV: "
585 << CurrentVolumePath()
586 << " detElemId: "
587 << setw(5) << detElemId
588 << endl;
589 Double_t x, y, z;
590 gMC->TrackPosition(x, y, z);
591 cerr << " global position: "
592 << x << ", " << y << ", " << z
593 << endl;
594 AliError("DetElemId not identified.");
595 }
596
597 // One hit per chamber
8690a0a6 598 GetMUONData()->AddHit2(fIshunt,
d59b2ec3 599 gAlice->GetMCApp()->GetCurrentTrackNumber(),
600 detElemId, ipart,
601 fTrackPosition.X(),
602 fTrackPosition.Y()+yAngleEffect,
603 fTrackPosition.Z(),
604 gMC->TrackTime(),
605 fTrackMomentum.P(),
606 theta,
607 phi,
608 fStepSum[idvol],
609 fDestepSum[idvol],
610 fTrackPosition.X(),
611 fTrackPosition.Y(),
612 fTrackPosition.Z());
613
5a0e88a7 614 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
615 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
616 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
617
d59b2ec3 618 fStepSum[idvol] =0; // Reset for the next event
619 fDestepSum[idvol]=0; // Reset for the next event
c5ce4e69 620 iEnter = 0;
d59b2ec3 621 }
622}