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