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 AliMUONFactory* factory = 0x0;
181 if (fSegmentationType == 1) {
182 factory = new AliMUONFactory();
183 printf("\n Old Segmentation \n");
186 if (fSegmentationType == 2) {
187 factory = new AliMUONFactoryV2();
188 printf("\n New Segmentation \n");
191 factory->Build(this, "default");
194 // Initialize segmentation
196 if (!fSegmentationType) {
197 AliFatal("No Segmentation Type defined.");
201 if (fSegmentationType == 1) {
202 for (i=0; i<AliMUONConstants::NCh(); i++)
203 ( (AliMUONChamber*) (*fChambers)[i])->Init();
206 if (fSegmentationType == 2) {
207 for (i=0; i<AliMUONConstants::NCh(); i++)
208 ( (AliMUONChamber*) (*fChambers)[i])->Init(fSegmentationType);// new segmentation
211 if (fSegmentationType == 1) {
213 AliDebug(1,"Start Init for Trigger Circuits");
214 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++)
215 ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
216 AliDebug(1,"Finished Init for Trigger Circuits");
223 //__________________________________________________________________
224 Int_t AliMUONv1::GetChamberId(Int_t volId) const
226 // Check if the volume with specified volId is a sensitive volume (gas)
227 // of some chamber and returns the chamber number;
228 // if not sensitive volume - return 0.
232 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
233 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
235 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
236 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
241 //_______________________________________________________________________________
242 TString AliMUONv1::CurrentVolumePath() const
244 // Returns current volume path
245 // (Could be removed when this function is available via gMC)
253 name = gMC->CurrentVolOffName(imother);
254 gMC->CurrentVolOffID(imother++, copyNo);
261 while ( name != TString("ALIC") );
266 //_______________________________________________________________________________
267 void AliMUONv1::StepManager()
269 // Stepmanager for the chambers
272 if (fStepManagerVersionDE) {
277 if (fStepManagerVersionOld) {
282 // Only charged tracks
283 if( !(gMC->TrackCharge()) ) return;
284 // Only charged tracks
286 // Only gas gap inside chamber
287 // Tag chambers and record hits when track enters
288 static Int_t idvol=-1;
292 const Float_t kBig = 1.e10;
296 // Only gas gap inside chamber
297 // Tag chambers and record hits when track enters
298 id=gMC->CurrentVolID(copy);
299 iChamber = GetChamberId(id);
302 if (idvol == -1) return;
304 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
305 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
306 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
308 if( gMC->IsTrackEntering() ) {
309 Float_t theta = fTrackMomentum.Theta();
310 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
314 // Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
315 // Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
317 // Particule id and mass,
318 Int_t ipart = gMC->TrackPid();
319 Float_t mass = gMC->TrackMass();
321 fDestepSum[idvol]+=gMC->Edep();
322 // Get current particle id (ipart), track position (pos) and momentum (mom)
323 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
324 fStepSum[idvol]+=gMC->TrackStep();
327 // Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
328 // 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()) ;
329 // gMC->TrackPosition(fTrackPosition);
330 // Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
333 // Track left chamber or StepSum larger than fStepMaxInActiveGas
334 if ( gMC->IsTrackExiting() ||
335 gMC->IsTrackStop() ||
336 gMC->IsTrackDisappeared()||
337 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
339 if ( gMC->IsTrackExiting() ||
340 gMC->IsTrackStop() ||
341 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
343 gMC->TrackPosition(fTrackPosition);
344 Float_t theta = fTrackMomentum.Theta();
345 Float_t phi = fTrackMomentum.Phi();
347 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
348 fStepSum[idvol]/2.*sin(theta)*sin(phi),
349 fStepSum[idvol]/2.*cos(theta),0.0 );
351 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
353 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
354 fTrackPosition-=backToWire;
356 //-------------- Angle effect
357 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
359 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
360 Float_t sigmaEffect10degrees;
361 Float_t sigmaEffectThetadegrees;
362 Float_t eLossParticleELossMip;
363 Float_t yAngleEffect=0.;
364 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
368 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
369 betaxGamma=TMath::Log(betaxGamma);
370 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
371 // 10 degrees is a reference for a model (arbitrary)
372 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
373 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
374 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
375 if ( (iChamber==1) || (iChamber==2) )
376 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
377 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
381 // Detection elements ids
382 AliMUONGeometryModule* geometry
383 = Chamber(iChamber-1).GetGeometry();
385 AliMUONGeometryDetElement* detElement
386 = geometry->FindBySensitiveVolume(CurrentVolumePath());
389 if (detElement) detElemId = detElement->GetUniqueID();
392 cerr << "Chamber id: "
393 << setw(3) << iChamber << " "
395 << CurrentVolumePath()
397 << setw(5) << detElemId
400 gMC->TrackPosition(x, y, z);
401 cerr << " global position: "
402 << x << ", " << y << ", " << z
404 AliWarning("DetElemId not identified.");
407 // One hit per chamber
408 GetMUONData()->AddHit(fIshunt,
409 gAlice->GetMCApp()->GetCurrentTrackNumber(),
412 fTrackPosition.Y()+yAngleEffect,
425 // Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
426 // Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
427 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
429 fStepSum[idvol] =0; // Reset for the next event
430 fDestepSum[idvol]=0; // Reset for the next event
434 //_______________________________________________________________________________
435 void AliMUONv1::StepManager2()
437 // Stepmanager for the chambers
439 if (fStepManagerVersionOld) {
444 // Only charged tracks
445 if( !(gMC->TrackCharge()) ) return;
446 // Only charged tracks
448 // Only gas gap inside chamber
449 // Tag chambers and record hits when track enters
450 static Int_t idvol=-1;
454 const Float_t kBig = 1.e10;
458 // Only gas gap inside chamber
459 // Tag chambers and record hits when track enters
460 id=gMC->CurrentVolID(copy);
461 iChamber = GetChamberId(id);
464 if (idvol == -1) return;
466 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
467 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
468 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
470 if( gMC->IsTrackEntering() ) {
471 Float_t theta = fTrackMomentum.Theta();
472 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
476 // Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
477 // Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
479 // Particule id and mass,
480 Int_t ipart = gMC->TrackPid();
481 Float_t mass = gMC->TrackMass();
483 fDestepSum[idvol]+=gMC->Edep();
484 // Get current particle id (ipart), track position (pos) and momentum (mom)
485 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
486 fStepSum[idvol]+=gMC->TrackStep();
489 // Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
490 // 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()) ;
491 // gMC->TrackPosition(fTrackPosition);
492 // Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
495 // Track left chamber or StepSum larger than fStepMaxInActiveGas
496 if ( gMC->IsTrackExiting() ||
497 gMC->IsTrackStop() ||
498 gMC->IsTrackDisappeared()||
499 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
501 if ( gMC->IsTrackExiting() ||
502 gMC->IsTrackStop() ||
503 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
505 gMC->TrackPosition(fTrackPosition);
506 Float_t theta = fTrackMomentum.Theta();
507 Float_t phi = fTrackMomentum.Phi();
509 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
510 fStepSum[idvol]/2.*sin(theta)*sin(phi),
511 fStepSum[idvol]/2.*cos(theta),0.0 );
513 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
515 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
516 fTrackPosition-=backToWire;
518 //-------------- Angle effect
519 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
521 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
522 Float_t sigmaEffect10degrees;
523 Float_t sigmaEffectThetadegrees;
524 Float_t eLossParticleELossMip;
525 Float_t yAngleEffect=0.;
526 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
530 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
531 betaxGamma=TMath::Log(betaxGamma);
532 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
533 // 10 degrees is a reference for a model (arbitrary)
534 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
535 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
536 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
537 if ( (iChamber==1) || (iChamber==2) )
538 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
539 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
543 // Detection elements ids
544 AliMUONGeometryModule* geometry
545 = Chamber(iChamber-1).GetGeometry();
547 AliMUONGeometryDetElement* detElement
548 = geometry->FindBySensitiveVolume(CurrentVolumePath());
551 if (detElement) detElemId = detElement->GetUniqueID();
554 cerr << "Chamber id: "
555 << setw(3) << iChamber << " "
557 << CurrentVolumePath()
559 << setw(5) << detElemId
562 gMC->TrackPosition(x, y, z);
563 cerr << " global position: "
564 << x << ", " << y << ", " << z
566 AliError("DetElemId not identified.");
569 // One hit per chamber
570 GetMUONData()->AddHit2(fIshunt,
571 gAlice->GetMCApp()->GetCurrentTrackNumber(),
574 fTrackPosition.Y()+yAngleEffect,
587 // Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
588 // Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
589 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
591 fStepSum[idvol] =0; // Reset for the next event
592 fDestepSum[idvol]=0; // Reset for the next event
596 //__________________________________________
597 void AliMUONv1::StepManagerOld()
599 // Old Stepmanager for the chambers
603 static Int_t idvol =-1;
609 Float_t destep, step;
611 static Float_t sstep;
612 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
613 const Float_t kBig = 1.e10;
614 static Float_t hits[15];
616 TClonesArray &lhits = *fHits;
620 // Only charged tracks
621 if( !(gMC->TrackCharge()) ) return;
623 // Only gas gap inside chamber
624 // Tag chambers and record hits when track enters
625 id=gMC->CurrentVolID(copy);
626 vol[0] = GetChamberId(id);
629 if (idvol == -1) return;
632 // Get current particle id (ipart), track position (pos) and momentum (mom)
633 gMC->TrackPosition(pos);
634 gMC->TrackMomentum(mom);
636 ipart = gMC->TrackPid();
639 // momentum loss and steplength in last step
640 destep = gMC->Edep();
641 step = gMC->TrackStep();
642 // cout<<"------------"<<step<<endl;
644 // record hits when track enters ...
645 if( gMC->IsTrackEntering()) {
647 gMC->SetMaxStep(fMaxStepGas);
648 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
649 Double_t rt = TMath::Sqrt(tc);
650 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
651 Double_t tx = mom[0]/pmom;
652 Double_t ty = mom[1]/pmom;
653 Double_t tz = mom[2]/pmom;
654 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
657 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
658 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
659 hits[0] = Float_t(ipart); // Geant3 particle type
660 hits[1] = pos[0]+s*tx; // X-position for hit
661 hits[2] = pos[1]+s*ty; // Y-position for hit
662 hits[3] = pos[2]+s*tz; // Z-position for hit
663 hits[4] = theta; // theta angle of incidence
664 hits[5] = phi; // phi angle of incidence
665 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
666 hits[9] = -1; // last pad hit
667 hits[10] = mom[3]; // hit momentum P
668 hits[11] = mom[0]; // Px
669 hits[12] = mom[1]; // Py
670 hits[13] = mom[2]; // Pz
671 tof=gMC->TrackTime();
672 hits[14] = tof; // Time of flight
680 Chamber(idvol).ChargeCorrelationInit();
681 // Only if not trigger chamber
683 // printf("---------------------------\n");
684 // printf(">>>> Y = %f \n",hits[2]);
685 // printf("---------------------------\n");
689 // if(idvol < AliMUONConstants::NTrackingCh()) {
691 // // Initialize hit position (cursor) in the segmentation model
692 // ((AliMUONChamber*) (*fChambers)[idvol])
693 // ->SigGenInit(pos[0], pos[1], pos[2]);
695 // //geant3->Gpcxyz();
696 // //printf("In the Trigger Chamber #%d\n",idvol-9);
702 // cout<<sstep<<endl;
705 // Calculate the charge induced on a pad (disintegration) in case
707 // Mip left chamber ...
708 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
709 gMC->SetMaxStep(kBig);
715 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
716 gMC->Gmtod(globalPos,localPos,1);
718 if(idvol < AliMUONConstants::NTrackingCh()) {
720 x0 = 0.5*(xhit+pos[0]);
721 y0 = 0.5*(yhit+pos[1]);
722 z0 = 0.5*(zhit+pos[2]);
731 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
734 hits[6] = tlength; // track length
735 hits[7] = eloss2; // de/dx energy loss
738 // if (fNPadHits > (Int_t)hits[8]) {
739 // hits[8] = hits[8]+1;
740 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
746 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits, kTRUE);
749 // Check additional signal generation conditions
750 // defined by the segmentation
751 // model (boundary crossing conditions)
752 // only for tracking chambers
754 ((idvol < AliMUONConstants::NTrackingCh()) &&
755 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
757 ((AliMUONChamber*) (*fChambers)[idvol])
758 ->SigGenInit(pos[0], pos[1], pos[2]);
761 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
762 gMC->Gmtod(globalPos,localPos,1);
766 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
767 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
774 // nothing special happened, add up energy loss
781 //__________________________________________
782 void AliMUONv1::StepManagerOld2()
784 // Old Stepmanager for the chambers
786 static Int_t idvol =-1;
792 Float_t destep, step;
794 static Float_t sstep;
795 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
796 const Float_t kBig = 1.e10;
797 static Float_t hits[15];
799 TClonesArray &lhits = *fHits;
803 // Only charged tracks
804 if( !(gMC->TrackCharge()) ) return;
806 // Only gas gap inside chamber
807 // Tag chambers and record hits when track enters
808 id=gMC->CurrentVolID(copy);
810 Int_t iChamber = GetChamberId(id);
813 if (idvol == -1) return;
815 // Detection elements id
816 AliMUONGeometryModule* geometry
817 = Chamber(iChamber-1).GetGeometry();
819 AliMUONGeometryDetElement* detElement
820 = geometry->FindBySensitiveVolume(CurrentVolumePath());
823 if (detElement) detElemId = detElement->GetUniqueID();
826 cerr << "Chamber id: "
827 << setw(3) << iChamber << " "
829 << CurrentVolumePath()
831 << setw(5) << detElemId
834 gMC->TrackPosition(x, y, z);
835 cerr << " global position: "
836 << x << ", " << y << ", " << z
838 AliError("DetElemId not identified.");
843 // Get current particle id (ipart), track position (pos) and momentum (mom)
844 gMC->TrackPosition(pos);
845 gMC->TrackMomentum(mom);
847 ipart = gMC->TrackPid();
850 // momentum loss and steplength in last step
851 destep = gMC->Edep();
852 step = gMC->TrackStep();
853 // cout<<"------------"<<step<<endl;
855 // record hits when track enters ...
856 if( gMC->IsTrackEntering()) {
858 gMC->SetMaxStep(fMaxStepGas);
859 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
860 Double_t rt = TMath::Sqrt(tc);
861 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
862 Double_t tx = mom[0]/pmom;
863 Double_t ty = mom[1]/pmom;
864 Double_t tz = mom[2]/pmom;
865 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
868 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
869 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
870 hits[0] = Float_t(ipart); // Geant3 particle type
871 hits[1] = pos[0]+s*tx; // X-position for hit
872 hits[2] = pos[1]+s*ty; // Y-position for hit
873 hits[3] = pos[2]+s*tz; // Z-position for hit
874 hits[4] = theta; // theta angle of incidence
875 hits[5] = phi; // phi angle of incidence
876 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
877 hits[9] = -1; // last pad hit
878 hits[10] = mom[3]; // hit momentum P
879 hits[11] = mom[0]; // Px
880 hits[12] = mom[1]; // Py
881 hits[13] = mom[2]; // Pz
882 tof=gMC->TrackTime();
883 hits[14] = tof; // Time of flight
891 Chamber(idvol).ChargeCorrelationInit();
892 // Only if not trigger chamber
894 // printf("---------------------------\n");
895 // printf(">>>> Y = %f \n",hits[2]);
896 // printf("---------------------------\n");
900 // if(idvol < AliMUONConstants::NTrackingCh()) {
902 // // Initialize hit position (cursor) in the segmentation model
903 // ((AliMUONChamber*) (*fChambers)[idvol])
904 // ->SigGenInit(pos[0], pos[1], pos[2]);
906 // //geant3->Gpcxyz();
907 // //printf("In the Trigger Chamber #%d\n",idvol-9);
913 // cout<<sstep<<endl;
916 // Calculate the charge induced on a pad (disintegration) in case
918 // Mip left chamber ...
919 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
920 gMC->SetMaxStep(kBig);
926 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
927 gMC->Gmtod(globalPos,localPos,1);
929 if(idvol < AliMUONConstants::NTrackingCh()) {
931 x0 = 0.5*(xhit+pos[0]);
932 y0 = 0.5*(yhit+pos[1]);
933 z0 = 0.5*(zhit+pos[2]);
942 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
945 hits[6] = tlength; // track length
946 hits[7] = eloss2; // de/dx energy loss
949 // if (fNPadHits > (Int_t)hits[8]) {
950 // hits[8] = hits[8]+1;
951 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
957 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
960 // Check additional signal generation conditions
961 // defined by the segmentation
962 // model (boundary crossing conditions)
963 // only for tracking chambers
965 ((idvol < AliMUONConstants::NTrackingCh()) &&
966 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
968 ((AliMUONChamber*) (*fChambers)[idvol])
969 ->SigGenInit(pos[0], pos[1], pos[2]);
972 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
973 gMC->Gmtod(globalPos,localPos,1);
977 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
978 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
985 // nothing special happened, add up energy loss