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