]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONv1.cxx
AliMUONHit can store now optionnally either chamber Id either (Ivana)
[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),
d59b2ec3 51 fStepManagerVersionDE(kFALSE),
d4bb94a1 52 fAngleEffect(kTRUE),
53 fStepMaxInActiveGas(0.6),
54 fStepSum(0x0),
55 fDestepSum(0x0),
56 fTrackMomentum(),
57 fTrackPosition(),
58 fElossRatio(0x0),
59 fAngleEffect10(0x0),
60 fAngleEffectNorma(0x0)
a9e2aefa 61{
d4bb94a1 62// Default constructor
1391e633 63}
d4bb94a1 64
a9e2aefa 65//___________________________________________
66AliMUONv1::AliMUONv1(const char *name, const char *title)
d4bb94a1 67 : AliMUON(name,title),
68 fStepManagerVersionOld(kFALSE),
d59b2ec3 69 fStepManagerVersionDE(kFALSE),
d4bb94a1 70 fAngleEffect(kTRUE),
71 fStepMaxInActiveGas(0.6),
72 fStepSum(0x0),
73 fDestepSum(0x0),
74 fTrackMomentum(),
75 fTrackPosition(),
76 fElossRatio(0x0),
77 fAngleEffect10(0x0),
78 fAngleEffectNorma(0x0)
a9e2aefa 79{
d4bb94a1 80// Standard onstructor
81
ba030c0e 82 // By default include all stations
ba030c0e 83 AliMUONFactory factory;
84 factory.Build(this, title);
c33d9661 85
1391e633 86 fStepSum = new Float_t [AliMUONConstants::NCh()];
87 fDestepSum = new Float_t [AliMUONConstants::NCh()];
88 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
89 fStepSum[i] =0.0;
90 fDestepSum[i]=0.0;
91 }
92 // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
93 fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.);
94 fElossRatio->SetParameter(0,1.02138);
95 fElossRatio->SetParameter(1,-9.54149e-02);
96 fElossRatio->SetParameter(2,+7.83433e-02);
97 fElossRatio->SetParameter(3,-9.98208e-03);
98 fElossRatio->SetParameter(4,+3.83279e-04);
99
100 // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
101 fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
102 fAngleEffect10->SetParameter(0, 1.90691e+02);
103 fAngleEffect10->SetParameter(1,-6.62258e+01);
104 fAngleEffect10->SetParameter(2,+1.28247e+01);
105 // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)
106 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
107 fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
108 fAngleEffectNorma->SetParameter(0,4.148);
109 fAngleEffectNorma->SetParameter(1,-6.809e-01);
110 fAngleEffectNorma->SetParameter(2,5.151e-02);
111 fAngleEffectNorma->SetParameter(3,-1.490e-03);
a9e2aefa 112}
113
fb1bf5c0 114//_____________________________________________________________________________
115AliMUONv1::AliMUONv1(const AliMUONv1& right)
116 : AliMUON(right)
117{
118 // copy constructor (not implemented)
119
8c343c7c 120 AliFatal("Copy constructor not provided.");
fb1bf5c0 121}
122
a9e2aefa 123//___________________________________________
acc838fd 124AliMUONv1::~AliMUONv1()
a9e2aefa 125{
acc838fd 126// Destructor
a9e2aefa 127
d4bb94a1 128 delete [] fStepSum;
129 delete [] fDestepSum;
130 delete fElossRatio;
131 delete fAngleEffect10;
132 delete fAngleEffectNorma;
acc838fd 133}
b17c0c87 134
fb1bf5c0 135//_____________________________________________________________________________
136AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
137{
138 // assignement operator (not implemented)
139
140 // check assignement to self
141 if (this == &right) return *this;
142
8c343c7c 143 AliFatal("Assignement operator not provided.");
fb1bf5c0 144
145 return *this;
146}
147
acc838fd 148//__________________________________________________
149void AliMUONv1::CreateGeometry()
150{
b17c0c87 151//
d4bb94a1 152// Construct geometry using geometry builder
a9e2aefa 153//
a9e2aefa 154
d4bb94a1 155 fGeometryBuilder->CreateGeometry();
acc838fd 156}
a9e2aefa 157
acc838fd 158//________________________________________________________________
a9e2aefa 159void AliMUONv1::CreateMaterials()
160{
a9e2aefa 161//
d4bb94a1 162// Construct materials using geometry builder
163//
acc838fd 164
d4bb94a1 165 fGeometryBuilder->CreateMaterials();
a9e2aefa 166}
167
acc838fd 168//___________________________________________
a9e2aefa 169void AliMUONv1::Init()
170{
171 //
172 // Initialize Tracking Chambers
173 //
8c343c7c 174 AliDebug(1,"Start Init for version 1 - CPC chamber type");
e17592e9 175 Int_t i;
f665c1ea 176 for (i=0; i<AliMUONConstants::NCh(); i++) {
a9e2aefa 177 ( (AliMUONChamber*) (*fChambers)[i])->Init();
178 }
179
acc838fd 180 //
d4bb94a1 181 // Initialize geometry
a9e2aefa 182 //
d4bb94a1 183 fGeometryBuilder->InitGeometry();
8c343c7c 184 AliDebug(1,"Finished Init for version 1 - CPC chamber type");
a9e2aefa 185
186 //cp
8c343c7c 187 AliDebug(1,"Start Init for Trigger Circuits");
f665c1ea 188 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
a9e2aefa 189 ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
190 }
8c343c7c 191 AliDebug(1,"Finished Init for Trigger Circuits");
a9e2aefa 192 //cp
a9e2aefa 193}
1391e633 194
d4bb94a1 195//__________________________________________________________________
196Int_t AliMUONv1::GetChamberId(Int_t volId) const
197{
198// Check if the volume with specified volId is a sensitive volume (gas)
199// of some chamber and returns the chamber number;
200// if not sensitive volume - return 0.
201// ---
202
203/*
204 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
205 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
206*/
207 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
208 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
209
210 return 0;
211}
333f7cda 212
213//_______________________________________________________________________________
214TString AliMUONv1::CurrentVolumePath() const
215{
216// Returns current volume path
217// (Could be removed when this function is available via gMC)
218// ---
219
220 TString path = "";
221 TString name;
222 Int_t copyNo;
223 Int_t imother = 0;
224 do {
225 name = gMC->CurrentVolOffName(imother);
226 gMC->CurrentVolOffID(imother++, copyNo);
227 TString add = "/";
228 add += name;
229 add += ".";
230 add += copyNo;
231 path.Insert(0,add);
232 }
233 while ( name != TString("ALIC") );
234
235 return path;
236}
237
1391e633 238//_______________________________________________________________________________
c33d9661 239void AliMUONv1::StepManager()
240{
d7c4fbc4 241 // Stepmanager for the chambers
d59b2ec3 242 // TBR
243
244 if (fStepManagerVersionDE) {
245 StepManager2();
246 return;
247 }
d7c4fbc4 248
1391e633 249 if (fStepManagerVersionOld) {
c33d9661 250 StepManagerOld();
251 return;
252 }
c33d9661 253
254 // Only charged tracks
d59b2ec3 255 if( !(gMC->TrackCharge()) ) return;
1391e633 256 // Only charged tracks
257
c33d9661 258 // Only gas gap inside chamber
259 // Tag chambers and record hits when track enters
acc838fd 260 static Int_t idvol=-1;
1391e633 261 Int_t iChamber=0;
262 Int_t id=0;
263 Int_t copy;
264 const Float_t kBig = 1.e10;
265
acc838fd 266
267 //
268 // Only gas gap inside chamber
269 // Tag chambers and record hits when track enters
c33d9661 270 id=gMC->CurrentVolID(copy);
acc838fd 271 iChamber = GetChamberId(id);
272 idvol = iChamber -1;
273
274 if (idvol == -1) return;
abaf7c9d 275
967a2a25 276 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
277 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
278 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
279
1391e633 280 if( gMC->IsTrackEntering() ) {
281 Float_t theta = fTrackMomentum.Theta();
4ac9d21e 282 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
283 }
abaf7c9d 284
1391e633 285// if (GetDebug()) {
286// Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
287// Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
288// }
289 // Particule id and mass,
290 Int_t ipart = gMC->TrackPid();
291 Float_t mass = gMC->TrackMass();
292
293 fDestepSum[idvol]+=gMC->Edep();
294 // Get current particle id (ipart), track position (pos) and momentum (mom)
295 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
296 fStepSum[idvol]+=gMC->TrackStep();
abaf7c9d 297
1391e633 298// if (GetDebug()) {
299// Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
333f7cda 300// 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 301// gMC->TrackPosition(fTrackPosition);
302// Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
d08aff2d 303// }
1391e633 304
305 // Track left chamber or StepSum larger than fStepMaxInActiveGas
306 if ( gMC->IsTrackExiting() ||
307 gMC->IsTrackStop() ||
308 gMC->IsTrackDisappeared()||
309 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
310
311 if ( gMC->IsTrackExiting() ||
acc838fd 312 gMC->IsTrackStop() ||
313 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
1391e633 314
315 gMC->TrackPosition(fTrackPosition);
316 Float_t theta = fTrackMomentum.Theta();
317 Float_t phi = fTrackMomentum.Phi();
318
d7c4fbc4 319 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
acc838fd 320 fStepSum[idvol]/2.*sin(theta)*sin(phi),
321 fStepSum[idvol]/2.*cos(theta),0.0 );
1391e633 322 // if (GetDebug())
323 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
324 // if (GetDebug())
d7c4fbc4 325 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
326 fTrackPosition-=backToWire;
1391e633 327
328 //-------------- Angle effect
329 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
330
30178c30 331 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
d7c4fbc4 332 Float_t sigmaEffect10degrees;
333 Float_t sigmaEffectThetadegrees;
334 Float_t eLossParticleELossMip;
335 Float_t yAngleEffect=0.;
336 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
337
374ebd7d 338
339 if (fAngleEffect){
30178c30 340 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
341 betaxGamma=TMath::Log(betaxGamma);
342 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
1391e633 343 // 10 degrees is a reference for a model (arbitrary)
d7c4fbc4 344 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
1391e633 345 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
d7c4fbc4 346 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
1391e633 347 if ( (iChamber==1) || (iChamber==2) )
acc838fd 348 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
d7c4fbc4 349 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
1391e633 350 }
374ebd7d 351 }
1391e633 352
333f7cda 353 // Detection elements ids
e118b27e 354 AliMUONGeometryModule* geometry
355 = Chamber(iChamber-1).GetGeometry();
356
357 AliMUONGeometryDetElement* detElement
358 = geometry->FindBySensitiveVolume(CurrentVolumePath());
359
333f7cda 360 Int_t detElemId = 0;
e118b27e 361 if (detElement) detElemId = detElement->GetUniqueID();
333f7cda 362
363 if (!detElemId) {
364 cerr << "Chamber id: "
365 << setw(3) << iChamber << " "
366 << "Current SV: "
367 << CurrentVolumePath()
368 << " detElemId: "
369 << setw(5) << detElemId
370 << endl;
371 Double_t x, y, z;
372 gMC->TrackPosition(x, y, z);
373 cerr << " global position: "
374 << x << ", " << y << ", " << z
375 << endl;
8c343c7c 376 AliWarning("DetElemId not identified.");
333f7cda 377 }
378
1391e633 379 // One hit per chamber
47464038 380 GetMUONData()->AddHit(fIshunt,
381 gAlice->GetMCApp()->GetCurrentTrackNumber(),
382 iChamber, ipart,
383 fTrackPosition.X(),
384 fTrackPosition.Y()+yAngleEffect,
385 fTrackPosition.Z(),
386 gMC->TrackTime(),
387 fTrackMomentum.P(),
388 theta,
389 phi,
390 fStepSum[idvol],
391 fDestepSum[idvol],
392 fTrackPosition.X(),
393 fTrackPosition.Y(),
394 fTrackPosition.Z());
395
1391e633 396// if (GetDebug()){
397// Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
398// Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
399// Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
400// }
401 fStepSum[idvol] =0; // Reset for the next event
402 fDestepSum[idvol]=0; // Reset for the next event
403 }
abaf7c9d 404}
5f91c9e8 405
d59b2ec3 406//_______________________________________________________________________________
407void AliMUONv1::StepManager2()
408{
409 // Stepmanager for the chambers
410
411 if (fStepManagerVersionOld) {
412 StepManagerOld2();
413 return;
414 }
415
416 // Only charged tracks
417 if( !(gMC->TrackCharge()) ) return;
418 // Only charged tracks
419
420 // Only gas gap inside chamber
421 // Tag chambers and record hits when track enters
422 static Int_t idvol=-1;
423 Int_t iChamber=0;
424 Int_t id=0;
425 Int_t copy;
426 const Float_t kBig = 1.e10;
427
428
429 //
430 // Only gas gap inside chamber
431 // Tag chambers and record hits when track enters
432 id=gMC->CurrentVolID(copy);
433 iChamber = GetChamberId(id);
434 idvol = iChamber -1;
435
436 if (idvol == -1) return;
437
438 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
439 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
440 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
441
442 if( gMC->IsTrackEntering() ) {
443 Float_t theta = fTrackMomentum.Theta();
444 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
445 }
446
447// if (GetDebug()) {
448// Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
449// Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
450// }
451 // Particule id and mass,
452 Int_t ipart = gMC->TrackPid();
453 Float_t mass = gMC->TrackMass();
454
455 fDestepSum[idvol]+=gMC->Edep();
456 // Get current particle id (ipart), track position (pos) and momentum (mom)
457 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
458 fStepSum[idvol]+=gMC->TrackStep();
459
460// if (GetDebug()) {
461// Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
462// 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()) ;
463// gMC->TrackPosition(fTrackPosition);
464// Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
465// }
466
467 // Track left chamber or StepSum larger than fStepMaxInActiveGas
468 if ( gMC->IsTrackExiting() ||
469 gMC->IsTrackStop() ||
470 gMC->IsTrackDisappeared()||
471 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
472
473 if ( gMC->IsTrackExiting() ||
474 gMC->IsTrackStop() ||
475 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
476
477 gMC->TrackPosition(fTrackPosition);
478 Float_t theta = fTrackMomentum.Theta();
479 Float_t phi = fTrackMomentum.Phi();
480
481 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
482 fStepSum[idvol]/2.*sin(theta)*sin(phi),
483 fStepSum[idvol]/2.*cos(theta),0.0 );
484 // if (GetDebug())
485 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
486 // if (GetDebug())
487 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
488 fTrackPosition-=backToWire;
489
490 //-------------- Angle effect
491 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
492
493 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
494 Float_t sigmaEffect10degrees;
495 Float_t sigmaEffectThetadegrees;
496 Float_t eLossParticleELossMip;
497 Float_t yAngleEffect=0.;
498 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
499
500
501 if (fAngleEffect){
502 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
503 betaxGamma=TMath::Log(betaxGamma);
504 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
505 // 10 degrees is a reference for a model (arbitrary)
506 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
507 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
508 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
509 if ( (iChamber==1) || (iChamber==2) )
510 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
511 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
512 }
513 }
514
515 // Detection elements ids
516 AliMUONGeometryModule* geometry
517 = Chamber(iChamber-1).GetGeometry();
518
519 AliMUONGeometryDetElement* detElement
520 = geometry->FindBySensitiveVolume(CurrentVolumePath());
521
522 Int_t detElemId = 0;
523 if (detElement) detElemId = detElement->GetUniqueID();
524
525 if (!detElemId) {
526 cerr << "Chamber id: "
527 << setw(3) << iChamber << " "
528 << "Current SV: "
529 << CurrentVolumePath()
530 << " detElemId: "
531 << setw(5) << detElemId
532 << endl;
533 Double_t x, y, z;
534 gMC->TrackPosition(x, y, z);
535 cerr << " global position: "
536 << x << ", " << y << ", " << z
537 << endl;
538 AliError("DetElemId not identified.");
539 }
540
541 // One hit per chamber
542 GetMUONData()->AddHit(fIshunt,
543 gAlice->GetMCApp()->GetCurrentTrackNumber(),
544 detElemId, ipart,
545 fTrackPosition.X(),
546 fTrackPosition.Y()+yAngleEffect,
547 fTrackPosition.Z(),
548 gMC->TrackTime(),
549 fTrackMomentum.P(),
550 theta,
551 phi,
552 fStepSum[idvol],
553 fDestepSum[idvol],
554 fTrackPosition.X(),
555 fTrackPosition.Y(),
556 fTrackPosition.Z());
557
558// if (GetDebug()){
559// Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
560// Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
561// Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
562// }
563 fStepSum[idvol] =0; // Reset for the next event
564 fDestepSum[idvol]=0; // Reset for the next event
565 }
566}
567
4ac9d21e 568//__________________________________________
c33d9661 569void AliMUONv1::StepManagerOld()
a9e2aefa 570{
d7c4fbc4 571 // Old Stepmanager for the chambers
d59b2ec3 572 // TBR
573
a9e2aefa 574 Int_t copy, id;
acc838fd 575 static Int_t idvol =-1;
a9e2aefa 576 static Int_t vol[2];
577 Int_t ipart;
578 TLorentzVector pos;
579 TLorentzVector mom;
580 Float_t theta,phi;
581 Float_t destep, step;
abaf7c9d 582
d7c4fbc4 583 static Float_t sstep;
1e8fff9c 584 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
2eb55fab 585 const Float_t kBig = 1.e10;
a9e2aefa 586 static Float_t hits[15];
587
588 TClonesArray &lhits = *fHits;
589
590 //
a9e2aefa 591 //
592 // Only charged tracks
593 if( !(gMC->TrackCharge()) ) return;
594 //
595 // Only gas gap inside chamber
596 // Tag chambers and record hits when track enters
a9e2aefa 597 id=gMC->CurrentVolID(copy);
5f91c9e8 598 vol[0] = GetChamberId(id);
599 idvol = vol[0] -1;
600
601 if (idvol == -1) return;
602
a9e2aefa 603 //
604 // Get current particle id (ipart), track position (pos) and momentum (mom)
605 gMC->TrackPosition(pos);
606 gMC->TrackMomentum(mom);
607
608 ipart = gMC->TrackPid();
a9e2aefa 609
610 //
611 // momentum loss and steplength in last step
612 destep = gMC->Edep();
613 step = gMC->TrackStep();
abaf7c9d 614 // cout<<"------------"<<step<<endl;
a9e2aefa 615 //
616 // record hits when track enters ...
617 if( gMC->IsTrackEntering()) {
abaf7c9d 618
a9e2aefa 619 gMC->SetMaxStep(fMaxStepGas);
620 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
621 Double_t rt = TMath::Sqrt(tc);
622 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
2eb55fab 623 Double_t tx = mom[0]/pmom;
624 Double_t ty = mom[1]/pmom;
625 Double_t tz = mom[2]/pmom;
626 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
acc838fd 627 ->ResponseModel()
628 ->Pitch()/tz;
a9e2aefa 629 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
630 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
631 hits[0] = Float_t(ipart); // Geant3 particle type
2eb55fab 632 hits[1] = pos[0]+s*tx; // X-position for hit
633 hits[2] = pos[1]+s*ty; // Y-position for hit
634 hits[3] = pos[2]+s*tz; // Z-position for hit
a9e2aefa 635 hits[4] = theta; // theta angle of incidence
636 hits[5] = phi; // phi angle of incidence
ce3f5e87 637 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
a9e2aefa 638 hits[9] = -1; // last pad hit
2eb55fab 639 hits[10] = mom[3]; // hit momentum P
640 hits[11] = mom[0]; // Px
641 hits[12] = mom[1]; // Py
642 hits[13] = mom[2]; // Pz
a9e2aefa 643 tof=gMC->TrackTime();
2eb55fab 644 hits[14] = tof; // Time of flight
645 tlength = 0;
646 eloss = 0;
647 eloss2 = 0;
d7c4fbc4 648 sstep=0;
2eb55fab 649 xhit = pos[0];
650 yhit = pos[1];
651 zhit = pos[2];
681d067b 652 Chamber(idvol).ChargeCorrelationInit();
a9e2aefa 653 // Only if not trigger chamber
1e8fff9c 654
abaf7c9d 655// printf("---------------------------\n");
656// printf(">>>> Y = %f \n",hits[2]);
657// printf("---------------------------\n");
658
1e8fff9c 659
660
abaf7c9d 661 // if(idvol < AliMUONConstants::NTrackingCh()) {
acc838fd 662// //
663// // Initialize hit position (cursor) in the segmentation model
664// ((AliMUONChamber*) (*fChambers)[idvol])
665// ->SigGenInit(pos[0], pos[1], pos[2]);
abaf7c9d 666// } else {
acc838fd 667// //geant3->Gpcxyz();
668// //printf("In the Trigger Chamber #%d\n",idvol-9);
abaf7c9d 669// }
a9e2aefa 670 }
671 eloss2+=destep;
d7c4fbc4 672 sstep+=step;
abaf7c9d 673
d7c4fbc4 674 // cout<<sstep<<endl;
abaf7c9d 675
a9e2aefa 676 //
677 // Calculate the charge induced on a pad (disintegration) in case
678 //
679 // Mip left chamber ...
680 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
681 gMC->SetMaxStep(kBig);
682 eloss += destep;
683 tlength += step;
684
802a864d 685 Float_t x0,y0,z0;
686 Float_t localPos[3];
687 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
802a864d 688 gMC->Gmtod(globalPos,localPos,1);
689
2eb55fab 690 if(idvol < AliMUONConstants::NTrackingCh()) {
a9e2aefa 691// tracking chambers
acc838fd 692 x0 = 0.5*(xhit+pos[0]);
693 y0 = 0.5*(yhit+pos[1]);
694 z0 = 0.5*(zhit+pos[2]);
a9e2aefa 695 } else {
696// trigger chambers
acc838fd 697 x0 = xhit;
698 y0 = yhit;
699 z0 = 0.;
a9e2aefa 700 }
701
1e8fff9c 702
ce3f5e87 703 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
a9e2aefa 704
acc838fd 705
2eb55fab 706 hits[6] = tlength; // track length
707 hits[7] = eloss2; // de/dx energy loss
708
abaf7c9d 709
ce3f5e87 710 // if (fNPadHits > (Int_t)hits[8]) {
acc838fd 711 // hits[8] = hits[8]+1;
712 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
ce3f5e87 713 //}
2eb55fab 714//
715// new hit
716
a9e2aefa 717 new(lhits[fNhits++])
acc838fd 718 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
a9e2aefa 719 eloss = 0;
720 //
721 // Check additional signal generation conditions
722 // defined by the segmentation
a75f073c 723 // model (boundary crossing conditions)
724 // only for tracking chambers
a9e2aefa 725 } else if
a75f073c 726 ((idvol < AliMUONConstants::NTrackingCh()) &&
727 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
a9e2aefa 728 {
729 ((AliMUONChamber*) (*fChambers)[idvol])
acc838fd 730 ->SigGenInit(pos[0], pos[1], pos[2]);
802a864d 731
732 Float_t localPos[3];
733 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
734 gMC->Gmtod(globalPos,localPos,1);
735
e0f71fb7 736 eloss += destep;
802a864d 737
ce3f5e87 738 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
acc838fd 739 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
a9e2aefa 740 xhit = pos[0];
741 yhit = pos[1];
e0f71fb7 742 zhit = pos[2];
743 eloss = 0;
a9e2aefa 744 tlength += step ;
745 //
746 // nothing special happened, add up energy loss
747 } else {
748 eloss += destep;
749 tlength += step ;
750 }
751}
333f7cda 752
d59b2ec3 753//__________________________________________
754void AliMUONv1::StepManagerOld2()
333f7cda 755{
d59b2ec3 756 // Old Stepmanager for the chambers
757 Int_t copy, id;
758 static Int_t idvol =-1;
759 static Int_t vol[2];
760 Int_t ipart;
761 TLorentzVector pos;
762 TLorentzVector mom;
763 Float_t theta,phi;
764 Float_t destep, step;
765
766 static Float_t sstep;
767 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
768 const Float_t kBig = 1.e10;
769 static Float_t hits[15];
770
771 TClonesArray &lhits = *fHits;
772
773 //
774 //
775 // Only charged tracks
776 if( !(gMC->TrackCharge()) ) return;
777 //
778 // Only gas gap inside chamber
779 // Tag chambers and record hits when track enters
780 id=gMC->CurrentVolID(copy);
781
782 Int_t iChamber = GetChamberId(id);
783 idvol = iChamber-1;
784
785 if (idvol == -1) return;
786
787 // Detection elements id
788 AliMUONGeometryModule* geometry
789 = Chamber(iChamber-1).GetGeometry();
790
791 AliMUONGeometryDetElement* detElement
792 = geometry->FindBySensitiveVolume(CurrentVolumePath());
793
794 Int_t detElemId = 0;
795 if (detElement) detElemId = detElement->GetUniqueID();
796
797 if (!detElemId) {
798 cerr << "Chamber id: "
799 << setw(3) << iChamber << " "
800 << "Current SV: "
801 << CurrentVolumePath()
802 << " detElemId: "
803 << setw(5) << detElemId
804 << endl;
805 Double_t x, y, z;
806 gMC->TrackPosition(x, y, z);
807 cerr << " global position: "
808 << x << ", " << y << ", " << z
809 << endl;
810 AliError("DetElemId not identified.");
811 }
812 vol[0] = detElemId;
813
814 //
815 // Get current particle id (ipart), track position (pos) and momentum (mom)
816 gMC->TrackPosition(pos);
817 gMC->TrackMomentum(mom);
818
819 ipart = gMC->TrackPid();
820
821 //
822 // momentum loss and steplength in last step
823 destep = gMC->Edep();
824 step = gMC->TrackStep();
825 // cout<<"------------"<<step<<endl;
826 //
827 // record hits when track enters ...
828 if( gMC->IsTrackEntering()) {
829
830 gMC->SetMaxStep(fMaxStepGas);
831 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
832 Double_t rt = TMath::Sqrt(tc);
833 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
834 Double_t tx = mom[0]/pmom;
835 Double_t ty = mom[1]/pmom;
836 Double_t tz = mom[2]/pmom;
837 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
838 ->ResponseModel()
839 ->Pitch()/tz;
840 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
841 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
842 hits[0] = Float_t(ipart); // Geant3 particle type
843 hits[1] = pos[0]+s*tx; // X-position for hit
844 hits[2] = pos[1]+s*ty; // Y-position for hit
845 hits[3] = pos[2]+s*tz; // Z-position for hit
846 hits[4] = theta; // theta angle of incidence
847 hits[5] = phi; // phi angle of incidence
848 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
849 hits[9] = -1; // last pad hit
850 hits[10] = mom[3]; // hit momentum P
851 hits[11] = mom[0]; // Px
852 hits[12] = mom[1]; // Py
853 hits[13] = mom[2]; // Pz
854 tof=gMC->TrackTime();
855 hits[14] = tof; // Time of flight
856 tlength = 0;
857 eloss = 0;
858 eloss2 = 0;
859 sstep=0;
860 xhit = pos[0];
861 yhit = pos[1];
862 zhit = pos[2];
863 Chamber(idvol).ChargeCorrelationInit();
864 // Only if not trigger chamber
865
866// printf("---------------------------\n");
867// printf(">>>> Y = %f \n",hits[2]);
868// printf("---------------------------\n");
869
870
871
872 // if(idvol < AliMUONConstants::NTrackingCh()) {
873// //
874// // Initialize hit position (cursor) in the segmentation model
875// ((AliMUONChamber*) (*fChambers)[idvol])
876// ->SigGenInit(pos[0], pos[1], pos[2]);
877// } else {
878// //geant3->Gpcxyz();
879// //printf("In the Trigger Chamber #%d\n",idvol-9);
880// }
881 }
882 eloss2+=destep;
883 sstep+=step;
884
885 // cout<<sstep<<endl;
886
887 //
888 // Calculate the charge induced on a pad (disintegration) in case
889 //
890 // Mip left chamber ...
891 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
892 gMC->SetMaxStep(kBig);
893 eloss += destep;
894 tlength += step;
895
896 Float_t x0,y0,z0;
897 Float_t localPos[3];
898 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
899 gMC->Gmtod(globalPos,localPos,1);
900
901 if(idvol < AliMUONConstants::NTrackingCh()) {
902// tracking chambers
903 x0 = 0.5*(xhit+pos[0]);
904 y0 = 0.5*(yhit+pos[1]);
905 z0 = 0.5*(zhit+pos[2]);
906 } else {
907// trigger chambers
908 x0 = xhit;
909 y0 = yhit;
910 z0 = 0.;
911 }
912
333f7cda 913
d59b2ec3 914 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
915
916
917 hits[6] = tlength; // track length
918 hits[7] = eloss2; // de/dx energy loss
333f7cda 919
333f7cda 920
d59b2ec3 921 // if (fNPadHits > (Int_t)hits[8]) {
922 // hits[8] = hits[8]+1;
923 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
924 //}
925//
926// new hit
927
928 new(lhits[fNhits++])
929 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
930 eloss = 0;
931 //
932 // Check additional signal generation conditions
933 // defined by the segmentation
934 // model (boundary crossing conditions)
935 // only for tracking chambers
936 } else if
937 ((idvol < AliMUONConstants::NTrackingCh()) &&
938 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
939 {
940 ((AliMUONChamber*) (*fChambers)[idvol])
941 ->SigGenInit(pos[0], pos[1], pos[2]);
333f7cda 942
d59b2ec3 943 Float_t localPos[3];
944 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
945 gMC->Gmtod(globalPos,localPos,1);
946
947 eloss += destep;
948
949 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
950 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
951 xhit = pos[0];
952 yhit = pos[1];
953 zhit = pos[2];
954 eloss = 0;
955 tlength += step ;
956 //
957 // nothing special happened, add up energy loss
958 } else {
959 eloss += destep;
960 tlength += step ;
333f7cda 961 }
d59b2ec3 962}