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