]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONv1.cxx
Geometry framework classes were made independent from the rest of MUON and linked...
[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 //
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
e118b27e 202 // To do - move PrintLocalTransforms to geometryModule
203 //Chamber(i).GetGeometry()
204 // ->GetDetElementStore()->PrintLocalTransforms();
333f7cda 205
206 Chamber(i).GetGeometry()
207 ->GetSVMap()->Print("");
208 }
209 cout << endl;
e118b27e 210 }
a9e2aefa 211}
1391e633 212
d4bb94a1 213//__________________________________________________________________
214Int_t AliMUONv1::GetChamberId(Int_t volId) const
215{
216// Check if the volume with specified volId is a sensitive volume (gas)
217// of some chamber and returns the chamber number;
218// if not sensitive volume - return 0.
219// ---
220
221/*
222 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
223 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
224*/
225 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
226 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
227
228 return 0;
229}
333f7cda 230
231//_______________________________________________________________________________
232TString AliMUONv1::CurrentVolumePath() const
233{
234// Returns current volume path
235// (Could be removed when this function is available via gMC)
236// ---
237
238 TString path = "";
239 TString name;
240 Int_t copyNo;
241 Int_t imother = 0;
242 do {
243 name = gMC->CurrentVolOffName(imother);
244 gMC->CurrentVolOffID(imother++, copyNo);
245 TString add = "/";
246 add += name;
247 add += ".";
248 add += copyNo;
249 path.Insert(0,add);
250 }
251 while ( name != TString("ALIC") );
252
253 return path;
254}
255
1391e633 256//_______________________________________________________________________________
c33d9661 257void AliMUONv1::StepManager()
258{
d7c4fbc4 259 // Stepmanager for the chambers
260
1391e633 261 if (fStepManagerVersionOld) {
c33d9661 262 StepManagerOld();
263 return;
264 }
c33d9661 265
266 // Only charged tracks
333f7cda 267 if( !(gMC->TrackCharge()) && !(gMC->TrackPid()==0) ) return;
1391e633 268 // Only charged tracks
269
c33d9661 270 // Only gas gap inside chamber
271 // Tag chambers and record hits when track enters
acc838fd 272 static Int_t idvol=-1;
1391e633 273 Int_t iChamber=0;
274 Int_t id=0;
275 Int_t copy;
276 const Float_t kBig = 1.e10;
277
acc838fd 278
279 //
280 // Only gas gap inside chamber
281 // Tag chambers and record hits when track enters
c33d9661 282 id=gMC->CurrentVolID(copy);
acc838fd 283 iChamber = GetChamberId(id);
284 idvol = iChamber -1;
285
286 if (idvol == -1) return;
333f7cda 287
288 if (GetDebug() > 1) {
289 // Fill the global position of detection elements
290 // Only for verification
291 AliMUONGeometrySVMap* svMap
292 = Chamber(iChamber-1).GetGeometry()->GetSVMap();
293 Double_t x, y, z;
294 gMC->TrackPosition(x, y, z);
295 svMap->AddPosition(CurrentVolumePath(), TGeoTranslation(x, y, z));
296 }
297
298 if (gMC->TrackPid()==0) return;
abaf7c9d 299
967a2a25 300 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
301 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
302 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
303
1391e633 304 if( gMC->IsTrackEntering() ) {
305 Float_t theta = fTrackMomentum.Theta();
4ac9d21e 306 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
307 }
abaf7c9d 308
1391e633 309// if (GetDebug()) {
310// Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
311// Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
312// }
313 // Particule id and mass,
314 Int_t ipart = gMC->TrackPid();
315 Float_t mass = gMC->TrackMass();
316
317 fDestepSum[idvol]+=gMC->Edep();
318 // Get current particle id (ipart), track position (pos) and momentum (mom)
319 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
320 fStepSum[idvol]+=gMC->TrackStep();
abaf7c9d 321
1391e633 322// if (GetDebug()) {
323// Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
333f7cda 324// 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 325// gMC->TrackPosition(fTrackPosition);
326// Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
d08aff2d 327// }
1391e633 328
329 // Track left chamber or StepSum larger than fStepMaxInActiveGas
330 if ( gMC->IsTrackExiting() ||
331 gMC->IsTrackStop() ||
332 gMC->IsTrackDisappeared()||
333 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
334
335 if ( gMC->IsTrackExiting() ||
acc838fd 336 gMC->IsTrackStop() ||
337 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
1391e633 338
339 gMC->TrackPosition(fTrackPosition);
340 Float_t theta = fTrackMomentum.Theta();
341 Float_t phi = fTrackMomentum.Phi();
342
d7c4fbc4 343 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
acc838fd 344 fStepSum[idvol]/2.*sin(theta)*sin(phi),
345 fStepSum[idvol]/2.*cos(theta),0.0 );
1391e633 346 // if (GetDebug())
347 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
348 // if (GetDebug())
d7c4fbc4 349 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
350 fTrackPosition-=backToWire;
1391e633 351
352 //-------------- Angle effect
353 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
354
30178c30 355 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
d7c4fbc4 356 Float_t sigmaEffect10degrees;
357 Float_t sigmaEffectThetadegrees;
358 Float_t eLossParticleELossMip;
359 Float_t yAngleEffect=0.;
360 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
361
374ebd7d 362
363 if (fAngleEffect){
30178c30 364 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
365 betaxGamma=TMath::Log(betaxGamma);
366 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
1391e633 367 // 10 degrees is a reference for a model (arbitrary)
d7c4fbc4 368 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
1391e633 369 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
d7c4fbc4 370 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
1391e633 371 if ( (iChamber==1) || (iChamber==2) )
acc838fd 372 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
d7c4fbc4 373 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
1391e633 374 }
374ebd7d 375 }
1391e633 376
333f7cda 377 // Detection elements ids
e118b27e 378 AliMUONGeometryModule* geometry
379 = Chamber(iChamber-1).GetGeometry();
380
381 AliMUONGeometryDetElement* detElement
382 = geometry->FindBySensitiveVolume(CurrentVolumePath());
383
333f7cda 384 Int_t detElemId = 0;
e118b27e 385 if (detElement) detElemId = detElement->GetUniqueID();
333f7cda 386
387 if (!detElemId) {
388 cerr << "Chamber id: "
389 << setw(3) << iChamber << " "
390 << "Current SV: "
391 << CurrentVolumePath()
392 << " detElemId: "
393 << setw(5) << detElemId
394 << endl;
395 Double_t x, y, z;
396 gMC->TrackPosition(x, y, z);
397 cerr << " global position: "
398 << x << ", " << y << ", " << z
399 << endl;
8c343c7c 400 AliWarning("DetElemId not identified.");
333f7cda 401 }
402
1391e633 403 // One hit per chamber
47464038 404 GetMUONData()->AddHit(fIshunt,
405 gAlice->GetMCApp()->GetCurrentTrackNumber(),
406 iChamber, ipart,
407 fTrackPosition.X(),
408 fTrackPosition.Y()+yAngleEffect,
409 fTrackPosition.Z(),
410 gMC->TrackTime(),
411 fTrackMomentum.P(),
412 theta,
413 phi,
414 fStepSum[idvol],
415 fDestepSum[idvol],
416 fTrackPosition.X(),
417 fTrackPosition.Y(),
418 fTrackPosition.Z());
419
1391e633 420// if (GetDebug()){
421// Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
422// Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
423// Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
424// }
425 fStepSum[idvol] =0; // Reset for the next event
426 fDestepSum[idvol]=0; // Reset for the next event
427 }
abaf7c9d 428}
5f91c9e8 429
4ac9d21e 430//__________________________________________
c33d9661 431void AliMUONv1::StepManagerOld()
a9e2aefa 432{
d7c4fbc4 433 // Old Stepmanager for the chambers
a9e2aefa 434 Int_t copy, id;
acc838fd 435 static Int_t idvol =-1;
a9e2aefa 436 static Int_t vol[2];
437 Int_t ipart;
438 TLorentzVector pos;
439 TLorentzVector mom;
440 Float_t theta,phi;
441 Float_t destep, step;
abaf7c9d 442
d7c4fbc4 443 static Float_t sstep;
1e8fff9c 444 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
2eb55fab 445 const Float_t kBig = 1.e10;
a9e2aefa 446 static Float_t hits[15];
447
448 TClonesArray &lhits = *fHits;
449
450 //
a9e2aefa 451 //
452 // Only charged tracks
453 if( !(gMC->TrackCharge()) ) return;
454 //
455 // Only gas gap inside chamber
456 // Tag chambers and record hits when track enters
a9e2aefa 457 id=gMC->CurrentVolID(copy);
5f91c9e8 458 vol[0] = GetChamberId(id);
459 idvol = vol[0] -1;
460
461 if (idvol == -1) return;
462
a9e2aefa 463 //
464 // Get current particle id (ipart), track position (pos) and momentum (mom)
465 gMC->TrackPosition(pos);
466 gMC->TrackMomentum(mom);
467
468 ipart = gMC->TrackPid();
a9e2aefa 469
470 //
471 // momentum loss and steplength in last step
472 destep = gMC->Edep();
473 step = gMC->TrackStep();
abaf7c9d 474 // cout<<"------------"<<step<<endl;
a9e2aefa 475 //
476 // record hits when track enters ...
477 if( gMC->IsTrackEntering()) {
abaf7c9d 478
a9e2aefa 479 gMC->SetMaxStep(fMaxStepGas);
480 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
481 Double_t rt = TMath::Sqrt(tc);
482 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
2eb55fab 483 Double_t tx = mom[0]/pmom;
484 Double_t ty = mom[1]/pmom;
485 Double_t tz = mom[2]/pmom;
486 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
acc838fd 487 ->ResponseModel()
488 ->Pitch()/tz;
a9e2aefa 489 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
490 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
491 hits[0] = Float_t(ipart); // Geant3 particle type
2eb55fab 492 hits[1] = pos[0]+s*tx; // X-position for hit
493 hits[2] = pos[1]+s*ty; // Y-position for hit
494 hits[3] = pos[2]+s*tz; // Z-position for hit
a9e2aefa 495 hits[4] = theta; // theta angle of incidence
496 hits[5] = phi; // phi angle of incidence
ce3f5e87 497 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
a9e2aefa 498 hits[9] = -1; // last pad hit
2eb55fab 499 hits[10] = mom[3]; // hit momentum P
500 hits[11] = mom[0]; // Px
501 hits[12] = mom[1]; // Py
502 hits[13] = mom[2]; // Pz
a9e2aefa 503 tof=gMC->TrackTime();
2eb55fab 504 hits[14] = tof; // Time of flight
505 tlength = 0;
506 eloss = 0;
507 eloss2 = 0;
d7c4fbc4 508 sstep=0;
2eb55fab 509 xhit = pos[0];
510 yhit = pos[1];
511 zhit = pos[2];
681d067b 512 Chamber(idvol).ChargeCorrelationInit();
a9e2aefa 513 // Only if not trigger chamber
1e8fff9c 514
abaf7c9d 515// printf("---------------------------\n");
516// printf(">>>> Y = %f \n",hits[2]);
517// printf("---------------------------\n");
518
1e8fff9c 519
520
abaf7c9d 521 // if(idvol < AliMUONConstants::NTrackingCh()) {
acc838fd 522// //
523// // Initialize hit position (cursor) in the segmentation model
524// ((AliMUONChamber*) (*fChambers)[idvol])
525// ->SigGenInit(pos[0], pos[1], pos[2]);
abaf7c9d 526// } else {
acc838fd 527// //geant3->Gpcxyz();
528// //printf("In the Trigger Chamber #%d\n",idvol-9);
abaf7c9d 529// }
a9e2aefa 530 }
531 eloss2+=destep;
d7c4fbc4 532 sstep+=step;
abaf7c9d 533
d7c4fbc4 534 // cout<<sstep<<endl;
abaf7c9d 535
a9e2aefa 536 //
537 // Calculate the charge induced on a pad (disintegration) in case
538 //
539 // Mip left chamber ...
540 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
541 gMC->SetMaxStep(kBig);
542 eloss += destep;
543 tlength += step;
544
802a864d 545 Float_t x0,y0,z0;
546 Float_t localPos[3];
547 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
802a864d 548 gMC->Gmtod(globalPos,localPos,1);
549
2eb55fab 550 if(idvol < AliMUONConstants::NTrackingCh()) {
a9e2aefa 551// tracking chambers
acc838fd 552 x0 = 0.5*(xhit+pos[0]);
553 y0 = 0.5*(yhit+pos[1]);
554 z0 = 0.5*(zhit+pos[2]);
a9e2aefa 555 } else {
556// trigger chambers
acc838fd 557 x0 = xhit;
558 y0 = yhit;
559 z0 = 0.;
a9e2aefa 560 }
561
1e8fff9c 562
ce3f5e87 563 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
a9e2aefa 564
acc838fd 565
2eb55fab 566 hits[6] = tlength; // track length
567 hits[7] = eloss2; // de/dx energy loss
568
abaf7c9d 569
ce3f5e87 570 // if (fNPadHits > (Int_t)hits[8]) {
acc838fd 571 // hits[8] = hits[8]+1;
572 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
ce3f5e87 573 //}
2eb55fab 574//
575// new hit
576
a9e2aefa 577 new(lhits[fNhits++])
acc838fd 578 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
a9e2aefa 579 eloss = 0;
580 //
581 // Check additional signal generation conditions
582 // defined by the segmentation
a75f073c 583 // model (boundary crossing conditions)
584 // only for tracking chambers
a9e2aefa 585 } else if
a75f073c 586 ((idvol < AliMUONConstants::NTrackingCh()) &&
587 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
a9e2aefa 588 {
589 ((AliMUONChamber*) (*fChambers)[idvol])
acc838fd 590 ->SigGenInit(pos[0], pos[1], pos[2]);
802a864d 591
592 Float_t localPos[3];
593 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
594 gMC->Gmtod(globalPos,localPos,1);
595
e0f71fb7 596 eloss += destep;
802a864d 597
ce3f5e87 598 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
acc838fd 599 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
a9e2aefa 600 xhit = pos[0];
601 yhit = pos[1];
e0f71fb7 602 zhit = pos[2];
603 eloss = 0;
a9e2aefa 604 tlength += step ;
605 //
606 // nothing special happened, add up energy loss
607 } else {
608 eloss += destep;
609 tlength += step ;
610 }
611}
333f7cda 612
613//______________________________________________________________________________
614void AliMUONv1::FinishRun()
615{
616// Print debug info
617// ---
618
619 if (GetDebug() <= 1) return;
620
621 // Print the global positions of detection elements
622 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
623
624 cout << "Chamber: " << i+1 << endl;
625 cout << "===================" << endl;
626
627 AliMUONGeometrySVMap* svMap
628 = Chamber(i).GetGeometry()->GetSVMap();
629
630 svMap->SortPositions();
631 svMap->PrintPositions();
632 svMap->ClearPositions();
633 }
634 cout << endl;
635}