1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * SigmaEffect_thetadegrees *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 *
12 * about the suitability of this software for any purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 /////////////////////////////////////////////////////////
19 // Manager and hits classes for set:MUON version 1 //
20 /////////////////////////////////////////////////////////
24 #include <TClonesArray.h>
26 #include <TVirtualMC.h>
27 #include <TGeoMatrix.h>
29 #include "AliMUONv1.h"
31 #include "AliMUONChamber.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONFactoryV2.h"
34 #include "AliMUONHit.h"
35 #include "AliMUONTriggerCircuit.h"
36 #include "AliMUONGeometryBuilder.h"
37 #include "AliMUONGeometryModule.h"
38 #include "AliMUONGeometrySVMap.h"
39 #include "AliMUONGeometryDetElement.h"
47 //___________________________________________
48 AliMUONv1::AliMUONv1()
50 fStepManagerVersionOld(kFALSE),
51 fStepManagerVersionDE(kFALSE),
53 fStepMaxInActiveGas(0.6),
60 fAngleEffectNorma(0x0)
62 // Default constructor
65 //___________________________________________
66 AliMUONv1::AliMUONv1(const char *name, const char *title)
67 : AliMUON(name,title),
68 fStepManagerVersionOld(kFALSE),
69 fStepManagerVersionDE(kFALSE),
71 fStepMaxInActiveGas(0.6),
78 fAngleEffectNorma(0x0)
80 // Standard onstructor
82 // By default include all stations
84 fStepSum = new Float_t [AliMUONConstants::NCh()];
85 fDestepSum = new Float_t [AliMUONConstants::NCh()];
86 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
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);
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);
112 //_____________________________________________________________________________
113 AliMUONv1::AliMUONv1(const AliMUONv1& right)
116 // copy constructor (not implemented)
118 AliFatal("Copy constructor not provided.");
121 //___________________________________________
122 AliMUONv1::~AliMUONv1()
127 delete [] fDestepSum;
129 delete fAngleEffect10;
130 delete fAngleEffectNorma;
133 //_____________________________________________________________________________
134 AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
136 // assignement operator (not implemented)
138 // check assignement to self
139 if (this == &right) return *this;
141 AliFatal("Assignement operator not provided.");
146 //__________________________________________________
147 void AliMUONv1::CreateGeometry()
150 // Construct geometry using geometry builder
153 fGeometryBuilder->CreateGeometry();
156 //________________________________________________________________
157 void AliMUONv1::CreateMaterials()
160 // Construct materials using geometry builder
163 fGeometryBuilder->CreateMaterials();
166 //___________________________________________
167 void AliMUONv1::Init()
169 AliDebug(1,"Start Init for version 1 - CPC chamber type");
174 // Initialize geometry
176 fGeometryBuilder->InitGeometry();
177 AliDebug(1,"Finished Init for version 1 - CPC chamber type");
179 if (fSegmentationType == 1) {
180 fFactory = new AliMUONFactory("Old MUON Factory");
181 printf("\n Old Segmentation \n");
184 if (fSegmentationType == 2) {
185 fFactory = new AliMUONFactoryV2("New MUON Factory");
186 printf("\n New Segmentation \n");
189 fFactory->Build(this, "default");
192 // Initialize segmentation
194 if (!fSegmentationType) {
195 AliFatal("No Segmentation Type defined.");
199 if (fSegmentationType == 1) {
200 for (i=0; i<AliMUONConstants::NCh(); i++)
201 ( (AliMUONChamber*) (*fChambers)[i])->Init();
204 if (fSegmentationType == 2) {
205 for (i=0; i<AliMUONConstants::NCh(); i++)
206 ( (AliMUONChamber*) (*fChambers)[i])->Init(fSegmentationType);// new segmentation
209 if (fSegmentationType == 1) {
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");
221 //__________________________________________________________________
222 Int_t AliMUONv1::GetChamberId(Int_t volId) const
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.
230 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
231 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
233 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
234 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
239 //_______________________________________________________________________________
240 TString AliMUONv1::CurrentVolumePath() const
242 // Returns current volume path
243 // (Could be removed when this function is available via gMC)
251 name = gMC->CurrentVolOffName(imother);
252 gMC->CurrentVolOffID(imother++, copyNo);
259 while ( name != TString("ALIC") );
264 //_______________________________________________________________________________
265 void AliMUONv1::StepManager()
267 // Stepmanager for the chambers
270 if (fStepManagerVersionDE) {
275 if (fStepManagerVersionOld) {
280 // Only charged tracks
281 if( !(gMC->TrackCharge()) ) return;
282 // Only charged tracks
284 // Only gas gap inside chamber
285 // Tag chambers and record hits when track enters
286 static Int_t idvol=-1;
290 const Float_t kBig = 1.e10;
294 // Only gas gap inside chamber
295 // Tag chambers and record hits when track enters
296 id=gMC->CurrentVolID(copy);
297 iChamber = GetChamberId(id);
300 if (idvol == -1) return;
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());
306 if( gMC->IsTrackEntering() ) {
307 Float_t theta = fTrackMomentum.Theta();
308 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
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);
315 // Particule id and mass,
316 Int_t ipart = gMC->TrackPid();
317 Float_t mass = gMC->TrackMass();
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();
325 // Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
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()) ;
327 // gMC->TrackPosition(fTrackPosition);
328 // Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
331 // Track left chamber or StepSum larger than fStepMaxInActiveGas
332 if ( gMC->IsTrackExiting() ||
333 gMC->IsTrackStop() ||
334 gMC->IsTrackDisappeared()||
335 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
337 if ( gMC->IsTrackExiting() ||
338 gMC->IsTrackStop() ||
339 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
341 gMC->TrackPosition(fTrackPosition);
342 Float_t theta = fTrackMomentum.Theta();
343 Float_t phi = fTrackMomentum.Phi();
345 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
346 fStepSum[idvol]/2.*sin(theta)*sin(phi),
347 fStepSum[idvol]/2.*cos(theta),0.0 );
349 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
351 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
352 fTrackPosition-=backToWire;
354 //-------------- Angle effect
355 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
357 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
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
366 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
367 betaxGamma=TMath::Log(betaxGamma);
368 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
369 // 10 degrees is a reference for a model (arbitrary)
370 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
371 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
372 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
373 if ( (iChamber==1) || (iChamber==2) )
374 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
375 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
379 // Detection elements ids
380 AliMUONGeometryModule* geometry
381 = Chamber(iChamber-1).GetGeometry();
383 AliMUONGeometryDetElement* detElement
384 = geometry->FindBySensitiveVolume(CurrentVolumePath());
387 if (detElement) detElemId = detElement->GetUniqueID();
390 cerr << "Chamber id: "
391 << setw(3) << iChamber << " "
393 << CurrentVolumePath()
395 << setw(5) << detElemId
398 gMC->TrackPosition(x, y, z);
399 cerr << " global position: "
400 << x << ", " << y << ", " << z
402 AliWarning("DetElemId not identified.");
405 // One hit per chamber
406 GetMUONData()->AddHit(fIshunt,
407 gAlice->GetMCApp()->GetCurrentTrackNumber(),
410 fTrackPosition.Y()+yAngleEffect,
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()) ;
427 fStepSum[idvol] =0; // Reset for the next event
428 fDestepSum[idvol]=0; // Reset for the next event
432 //_______________________________________________________________________________
433 void AliMUONv1::StepManager2()
435 // Stepmanager for the chambers
437 if (fStepManagerVersionOld) {
442 // Only charged tracks
443 if( !(gMC->TrackCharge()) ) return;
444 // Only charged tracks
446 // Only gas gap inside chamber
447 // Tag chambers and record hits when track enters
448 static Int_t idvol=-1;
452 const Float_t kBig = 1.e10;
456 // Only gas gap inside chamber
457 // Tag chambers and record hits when track enters
458 id=gMC->CurrentVolID(copy);
459 iChamber = GetChamberId(id);
462 if (idvol == -1) return;
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());
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
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);
477 // Particule id and mass,
478 Int_t ipart = gMC->TrackPid();
479 Float_t mass = gMC->TrackMass();
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();
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()) ;
493 // Track left chamber or StepSum larger than fStepMaxInActiveGas
494 if ( gMC->IsTrackExiting() ||
495 gMC->IsTrackStop() ||
496 gMC->IsTrackDisappeared()||
497 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
499 if ( gMC->IsTrackExiting() ||
500 gMC->IsTrackStop() ||
501 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
503 gMC->TrackPosition(fTrackPosition);
504 Float_t theta = fTrackMomentum.Theta();
505 Float_t phi = fTrackMomentum.Phi();
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 );
511 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
513 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
514 fTrackPosition-=backToWire;
516 //-------------- Angle effect
517 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
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
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
541 // Detection elements ids
542 AliMUONGeometryModule* geometry
543 = Chamber(iChamber-1).GetGeometry();
545 AliMUONGeometryDetElement* detElement
546 = geometry->FindBySensitiveVolume(CurrentVolumePath());
549 if (detElement) detElemId = detElement->GetUniqueID();
552 cerr << "Chamber id: "
553 << setw(3) << iChamber << " "
555 << CurrentVolumePath()
557 << setw(5) << detElemId
560 gMC->TrackPosition(x, y, z);
561 cerr << " global position: "
562 << x << ", " << y << ", " << z
564 AliError("DetElemId not identified.");
567 // One hit per chamber
568 GetMUONData()->AddHit2(fIshunt,
569 gAlice->GetMCApp()->GetCurrentTrackNumber(),
572 fTrackPosition.Y()+yAngleEffect,
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()) ;
589 fStepSum[idvol] =0; // Reset for the next event
590 fDestepSum[idvol]=0; // Reset for the next event
594 //__________________________________________
595 void AliMUONv1::StepManagerOld()
597 // Old Stepmanager for the chambers
601 static Int_t idvol =-1;
607 Float_t destep, step;
609 static Float_t sstep;
610 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
611 const Float_t kBig = 1.e10;
612 static Float_t hits[15];
614 TClonesArray &lhits = *fHits;
618 // Only charged tracks
619 if( !(gMC->TrackCharge()) ) return;
621 // Only gas gap inside chamber
622 // Tag chambers and record hits when track enters
623 id=gMC->CurrentVolID(copy);
624 vol[0] = GetChamberId(id);
627 if (idvol == -1) return;
630 // Get current particle id (ipart), track position (pos) and momentum (mom)
631 gMC->TrackPosition(pos);
632 gMC->TrackMomentum(mom);
634 ipart = gMC->TrackPid();
637 // momentum loss and steplength in last step
638 destep = gMC->Edep();
639 step = gMC->TrackStep();
640 // cout<<"------------"<<step<<endl;
642 // record hits when track enters ...
643 if( gMC->IsTrackEntering()) {
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]);
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])
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
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
661 hits[4] = theta; // theta angle of incidence
662 hits[5] = phi; // phi angle of incidence
663 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
664 hits[9] = -1; // last pad hit
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
669 tof=gMC->TrackTime();
670 hits[14] = tof; // Time of flight
678 Chamber(idvol).ChargeCorrelationInit();
679 // Only if not trigger chamber
681 // printf("---------------------------\n");
682 // printf(">>>> Y = %f \n",hits[2]);
683 // printf("---------------------------\n");
687 // if(idvol < AliMUONConstants::NTrackingCh()) {
689 // // Initialize hit position (cursor) in the segmentation model
690 // ((AliMUONChamber*) (*fChambers)[idvol])
691 // ->SigGenInit(pos[0], pos[1], pos[2]);
693 // //geant3->Gpcxyz();
694 // //printf("In the Trigger Chamber #%d\n",idvol-9);
700 // cout<<sstep<<endl;
703 // Calculate the charge induced on a pad (disintegration) in case
705 // Mip left chamber ...
706 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
707 gMC->SetMaxStep(kBig);
713 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
714 gMC->Gmtod(globalPos,localPos,1);
716 if(idvol < AliMUONConstants::NTrackingCh()) {
718 x0 = 0.5*(xhit+pos[0]);
719 y0 = 0.5*(yhit+pos[1]);
720 z0 = 0.5*(zhit+pos[2]);
729 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
732 hits[6] = tlength; // track length
733 hits[7] = eloss2; // de/dx energy loss
736 // if (fNPadHits > (Int_t)hits[8]) {
737 // hits[8] = hits[8]+1;
738 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
744 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits, kTRUE);
747 // Check additional signal generation conditions
748 // defined by the segmentation
749 // model (boundary crossing conditions)
750 // only for tracking chambers
752 ((idvol < AliMUONConstants::NTrackingCh()) &&
753 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
755 ((AliMUONChamber*) (*fChambers)[idvol])
756 ->SigGenInit(pos[0], pos[1], pos[2]);
759 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
760 gMC->Gmtod(globalPos,localPos,1);
764 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
765 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
772 // nothing special happened, add up energy loss
779 //__________________________________________
780 void AliMUONv1::StepManagerOld2()
782 // Old Stepmanager for the chambers
784 static Int_t idvol =-1;
790 Float_t destep, step;
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];
797 TClonesArray &lhits = *fHits;
801 // Only charged tracks
802 if( !(gMC->TrackCharge()) ) return;
804 // Only gas gap inside chamber
805 // Tag chambers and record hits when track enters
806 id=gMC->CurrentVolID(copy);
808 Int_t iChamber = GetChamberId(id);
811 if (idvol == -1) return;
813 // Detection elements id
814 AliMUONGeometryModule* geometry
815 = Chamber(iChamber-1).GetGeometry();
817 AliMUONGeometryDetElement* detElement
818 = geometry->FindBySensitiveVolume(CurrentVolumePath());
821 if (detElement) detElemId = detElement->GetUniqueID();
824 cerr << "Chamber id: "
825 << setw(3) << iChamber << " "
827 << CurrentVolumePath()
829 << setw(5) << detElemId
832 gMC->TrackPosition(x, y, z);
833 cerr << " global position: "
834 << x << ", " << y << ", " << z
836 AliError("DetElemId not identified.");
841 // Get current particle id (ipart), track position (pos) and momentum (mom)
842 gMC->TrackPosition(pos);
843 gMC->TrackMomentum(mom);
845 ipart = gMC->TrackPid();
848 // momentum loss and steplength in last step
849 destep = gMC->Edep();
850 step = gMC->TrackStep();
851 // cout<<"------------"<<step<<endl;
853 // record hits when track enters ...
854 if( gMC->IsTrackEntering()) {
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])
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
889 Chamber(idvol).ChargeCorrelationInit();
890 // Only if not trigger chamber
892 // printf("---------------------------\n");
893 // printf(">>>> Y = %f \n",hits[2]);
894 // printf("---------------------------\n");
898 // if(idvol < AliMUONConstants::NTrackingCh()) {
900 // // Initialize hit position (cursor) in the segmentation model
901 // ((AliMUONChamber*) (*fChambers)[idvol])
902 // ->SigGenInit(pos[0], pos[1], pos[2]);
904 // //geant3->Gpcxyz();
905 // //printf("In the Trigger Chamber #%d\n",idvol-9);
911 // cout<<sstep<<endl;
914 // Calculate the charge induced on a pad (disintegration) in case
916 // Mip left chamber ...
917 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
918 gMC->SetMaxStep(kBig);
924 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
925 gMC->Gmtod(globalPos,localPos,1);
927 if(idvol < AliMUONConstants::NTrackingCh()) {
929 x0 = 0.5*(xhit+pos[0]);
930 y0 = 0.5*(yhit+pos[1]);
931 z0 = 0.5*(zhit+pos[2]);
940 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
943 hits[6] = tlength; // track length
944 hits[7] = eloss2; // de/dx energy loss
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;
955 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits,
959 // Check additional signal generation conditions
960 // defined by the segmentation
961 // model (boundary crossing conditions)
962 // only for tracking chambers
964 ((idvol < AliMUONConstants::NTrackingCh()) &&
965 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
967 ((AliMUONChamber*) (*fChambers)[idvol])
968 ->SigGenInit(pos[0], pos[1], pos[2]);
971 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
972 gMC->Gmtod(globalPos,localPos,1);
976 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
977 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
984 // nothing special happened, add up energy loss