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
211 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++)
212 ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
220 //__________________________________________________________________
221 Int_t AliMUONv1::GetChamberId(Int_t volId) const
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.
229 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
230 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
232 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
233 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
238 //_______________________________________________________________________________
239 TString AliMUONv1::CurrentVolumePath() const
241 // Returns current volume path
242 // (Could be removed when this function is available via gMC)
250 name = gMC->CurrentVolOffName(imother);
251 gMC->CurrentVolOffID(imother++, copyNo);
258 while ( name != TString("ALIC") );
263 //_______________________________________________________________________________
264 void AliMUONv1::StepManager()
266 // Stepmanager for the chambers
269 if (fStepManagerVersionDE) {
274 if (fStepManagerVersionOld) {
279 // Only charged tracks
280 if( !(gMC->TrackCharge()) ) return;
281 // Only charged tracks
283 // Only gas gap inside chamber
284 // Tag chambers and record hits when track enters
285 static Int_t idvol=-1;
289 const Float_t kBig = 1.e10;
293 // Only gas gap inside chamber
294 // Tag chambers and record hits when track enters
295 id=gMC->CurrentVolID(copy);
296 iChamber = GetChamberId(id);
299 if (idvol == -1) return;
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());
305 if( gMC->IsTrackEntering() ) {
306 Float_t theta = fTrackMomentum.Theta();
307 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
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);
314 // Particule id and mass,
315 Int_t ipart = gMC->TrackPid();
316 Float_t mass = gMC->TrackMass();
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();
324 // Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
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()) ;
326 // gMC->TrackPosition(fTrackPosition);
327 // Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
330 // Track left chamber or StepSum larger than fStepMaxInActiveGas
331 if ( gMC->IsTrackExiting() ||
332 gMC->IsTrackStop() ||
333 gMC->IsTrackDisappeared()||
334 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
336 if ( gMC->IsTrackExiting() ||
337 gMC->IsTrackStop() ||
338 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
340 gMC->TrackPosition(fTrackPosition);
341 Float_t theta = fTrackMomentum.Theta();
342 Float_t phi = fTrackMomentum.Phi();
344 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
345 fStepSum[idvol]/2.*sin(theta)*sin(phi),
346 fStepSum[idvol]/2.*cos(theta),0.0 );
348 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
350 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
351 fTrackPosition-=backToWire;
353 //-------------- Angle effect
354 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
356 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
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
365 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
366 betaxGamma=TMath::Log(betaxGamma);
367 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
368 // 10 degrees is a reference for a model (arbitrary)
369 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
370 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
371 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
372 if ( (iChamber==1) || (iChamber==2) )
373 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
374 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
378 // Detection elements ids
379 AliMUONGeometryModule* geometry
380 = Chamber(iChamber-1).GetGeometry();
382 AliMUONGeometryDetElement* detElement
383 = geometry->FindBySensitiveVolume(CurrentVolumePath());
386 if (detElement) detElemId = detElement->GetUniqueID();
389 cerr << "Chamber id: "
390 << setw(3) << iChamber << " "
392 << CurrentVolumePath()
394 << setw(5) << detElemId
397 gMC->TrackPosition(x, y, z);
398 cerr << " global position: "
399 << x << ", " << y << ", " << z
401 AliWarning("DetElemId not identified.");
404 // One hit per chamber
405 GetMUONData()->AddHit(fIshunt,
406 gAlice->GetMCApp()->GetCurrentTrackNumber(),
409 fTrackPosition.Y()+yAngleEffect,
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()) ;
426 fStepSum[idvol] =0; // Reset for the next event
427 fDestepSum[idvol]=0; // Reset for the next event
431 //_______________________________________________________________________________
432 void AliMUONv1::StepManager2()
434 // Stepmanager for the chambers
436 if (fStepManagerVersionOld) {
441 // Only charged tracks
442 if( !(gMC->TrackCharge()) ) return;
443 // Only charged tracks
445 // Only gas gap inside chamber
446 // Tag chambers and record hits when track enters
447 static Int_t idvol=-1;
451 const Float_t kBig = 1.e10;
455 // Only gas gap inside chamber
456 // Tag chambers and record hits when track enters
457 id=gMC->CurrentVolID(copy);
458 iChamber = GetChamberId(id);
461 if (idvol == -1) return;
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());
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
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);
476 // Particule id and mass,
477 Int_t ipart = gMC->TrackPid();
478 Float_t mass = gMC->TrackMass();
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();
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()) ;
492 // Track left chamber or StepSum larger than fStepMaxInActiveGas
493 if ( gMC->IsTrackExiting() ||
494 gMC->IsTrackStop() ||
495 gMC->IsTrackDisappeared()||
496 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
498 if ( gMC->IsTrackExiting() ||
499 gMC->IsTrackStop() ||
500 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
502 gMC->TrackPosition(fTrackPosition);
503 Float_t theta = fTrackMomentum.Theta();
504 Float_t phi = fTrackMomentum.Phi();
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 );
510 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
512 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
513 fTrackPosition-=backToWire;
515 //-------------- Angle effect
516 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
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
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
540 // Detection elements ids
541 AliMUONGeometryModule* geometry
542 = Chamber(iChamber-1).GetGeometry();
544 AliMUONGeometryDetElement* detElement
545 = geometry->FindBySensitiveVolume(CurrentVolumePath());
548 if (detElement) detElemId = detElement->GetUniqueID();
551 cerr << "Chamber id: "
552 << setw(3) << iChamber << " "
554 << CurrentVolumePath()
556 << setw(5) << detElemId
559 gMC->TrackPosition(x, y, z);
560 cerr << " global position: "
561 << x << ", " << y << ", " << z
563 AliError("DetElemId not identified.");
566 // One hit per chamber
567 GetMUONData()->AddHit2(fIshunt,
568 gAlice->GetMCApp()->GetCurrentTrackNumber(),
571 fTrackPosition.Y()+yAngleEffect,
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()) ;
588 fStepSum[idvol] =0; // Reset for the next event
589 fDestepSum[idvol]=0; // Reset for the next event
593 //__________________________________________
594 void AliMUONv1::StepManagerOld()
596 // Old Stepmanager for the chambers
600 static Int_t idvol =-1;
606 Float_t destep, step;
608 static Float_t sstep;
609 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
610 const Float_t kBig = 1.e10;
611 static Float_t hits[15];
613 TClonesArray &lhits = *fHits;
617 // Only charged tracks
618 if( !(gMC->TrackCharge()) ) return;
620 // Only gas gap inside chamber
621 // Tag chambers and record hits when track enters
622 id=gMC->CurrentVolID(copy);
623 vol[0] = GetChamberId(id);
626 if (idvol == -1) return;
629 // Get current particle id (ipart), track position (pos) and momentum (mom)
630 gMC->TrackPosition(pos);
631 gMC->TrackMomentum(mom);
633 ipart = gMC->TrackPid();
636 // momentum loss and steplength in last step
637 destep = gMC->Edep();
638 step = gMC->TrackStep();
639 // cout<<"------------"<<step<<endl;
641 // record hits when track enters ...
642 if( gMC->IsTrackEntering()) {
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]);
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])
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
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
660 hits[4] = theta; // theta angle of incidence
661 hits[5] = phi; // phi angle of incidence
662 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
663 hits[9] = -1; // last pad hit
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
668 tof=gMC->TrackTime();
669 hits[14] = tof; // Time of flight
677 Chamber(idvol).ChargeCorrelationInit();
678 // Only if not trigger chamber
680 // printf("---------------------------\n");
681 // printf(">>>> Y = %f \n",hits[2]);
682 // printf("---------------------------\n");
686 // if(idvol < AliMUONConstants::NTrackingCh()) {
688 // // Initialize hit position (cursor) in the segmentation model
689 // ((AliMUONChamber*) (*fChambers)[idvol])
690 // ->SigGenInit(pos[0], pos[1], pos[2]);
692 // //geant3->Gpcxyz();
693 // //printf("In the Trigger Chamber #%d\n",idvol-9);
699 // cout<<sstep<<endl;
702 // Calculate the charge induced on a pad (disintegration) in case
704 // Mip left chamber ...
705 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
706 gMC->SetMaxStep(kBig);
712 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
713 gMC->Gmtod(globalPos,localPos,1);
715 if(idvol < AliMUONConstants::NTrackingCh()) {
717 x0 = 0.5*(xhit+pos[0]);
718 y0 = 0.5*(yhit+pos[1]);
719 z0 = 0.5*(zhit+pos[2]);
728 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
731 hits[6] = tlength; // track length
732 hits[7] = eloss2; // de/dx energy loss
735 // if (fNPadHits > (Int_t)hits[8]) {
736 // hits[8] = hits[8]+1;
737 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
743 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits, kTRUE);
746 // Check additional signal generation conditions
747 // defined by the segmentation
748 // model (boundary crossing conditions)
749 // only for tracking chambers
751 ((idvol < AliMUONConstants::NTrackingCh()) &&
752 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
754 ((AliMUONChamber*) (*fChambers)[idvol])
755 ->SigGenInit(pos[0], pos[1], pos[2]);
758 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
759 gMC->Gmtod(globalPos,localPos,1);
763 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
764 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
771 // nothing special happened, add up energy loss
778 //__________________________________________
779 void AliMUONv1::StepManagerOld2()
781 // Old Stepmanager for the chambers
783 static Int_t idvol =-1;
789 Float_t destep, step;
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];
796 TClonesArray &lhits = *fHits;
800 // Only charged tracks
801 if( !(gMC->TrackCharge()) ) return;
803 // Only gas gap inside chamber
804 // Tag chambers and record hits when track enters
805 id=gMC->CurrentVolID(copy);
807 Int_t iChamber = GetChamberId(id);
810 if (idvol == -1) return;
812 // Detection elements id
813 AliMUONGeometryModule* geometry
814 = Chamber(iChamber-1).GetGeometry();
816 AliMUONGeometryDetElement* detElement
817 = geometry->FindBySensitiveVolume(CurrentVolumePath());
820 if (detElement) detElemId = detElement->GetUniqueID();
823 cerr << "Chamber id: "
824 << setw(3) << iChamber << " "
826 << CurrentVolumePath()
828 << setw(5) << detElemId
831 gMC->TrackPosition(x, y, z);
832 cerr << " global position: "
833 << x << ", " << y << ", " << z
835 AliError("DetElemId not identified.");
840 // Get current particle id (ipart), track position (pos) and momentum (mom)
841 gMC->TrackPosition(pos);
842 gMC->TrackMomentum(mom);
844 ipart = gMC->TrackPid();
847 // momentum loss and steplength in last step
848 destep = gMC->Edep();
849 step = gMC->TrackStep();
850 // cout<<"------------"<<step<<endl;
852 // record hits when track enters ...
853 if( gMC->IsTrackEntering()) {
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])
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
888 Chamber(idvol).ChargeCorrelationInit();
889 // Only if not trigger chamber
891 // printf("---------------------------\n");
892 // printf(">>>> Y = %f \n",hits[2]);
893 // printf("---------------------------\n");
897 // if(idvol < AliMUONConstants::NTrackingCh()) {
899 // // Initialize hit position (cursor) in the segmentation model
900 // ((AliMUONChamber*) (*fChambers)[idvol])
901 // ->SigGenInit(pos[0], pos[1], pos[2]);
903 // //geant3->Gpcxyz();
904 // //printf("In the Trigger Chamber #%d\n",idvol-9);
910 // cout<<sstep<<endl;
913 // Calculate the charge induced on a pad (disintegration) in case
915 // Mip left chamber ...
916 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
917 gMC->SetMaxStep(kBig);
923 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
924 gMC->Gmtod(globalPos,localPos,1);
926 if(idvol < AliMUONConstants::NTrackingCh()) {
928 x0 = 0.5*(xhit+pos[0]);
929 y0 = 0.5*(yhit+pos[1]);
930 z0 = 0.5*(zhit+pos[2]);
939 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
942 hits[6] = tlength; // track length
943 hits[7] = eloss2; // de/dx energy loss
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;
954 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits,
958 // Check additional signal generation conditions
959 // defined by the segmentation
960 // model (boundary crossing conditions)
961 // only for tracking chambers
963 ((idvol < AliMUONConstants::NTrackingCh()) &&
964 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
966 ((AliMUONChamber*) (*fChambers)[idvol])
967 ->SigGenInit(pos[0], pos[1], pos[2]);
970 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
971 gMC->Gmtod(globalPos,localPos,1);
975 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
976 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
983 // nothing special happened, add up energy loss