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