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