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