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 fFactory = new AliMUONFactoryV2("New MUON Factory");
180 AliInfo("New Segmentation");
183 fFactory->Build(this, "default");
186 // Initialize segmentation
189 for (i=0; i<AliMUONConstants::NCh(); i++)
190 ( (AliMUONChamber*) (*fChambers)[i])->Init(2);// new segmentation
195 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++)
196 ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
204 //__________________________________________________________________
205 Int_t AliMUONv1::GetChamberId(Int_t volId) const
207 // Check if the volume with specified volId is a sensitive volume (gas)
208 // of some chamber and returns the chamber number;
209 // if not sensitive volume - return 0.
213 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
214 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
216 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
217 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
222 //_______________________________________________________________________________
223 TString AliMUONv1::CurrentVolumePath() const
225 // Returns current volume path
226 // (Could be removed when this function is available via gMC)
234 name = gMC->CurrentVolOffName(imother);
235 gMC->CurrentVolOffID(imother++, copyNo);
242 while ( name != TString("ALIC") );
247 //_______________________________________________________________________________
248 void AliMUONv1::StepManager()
250 // Stepmanager for the chambers
253 if (fStepManagerVersionDE) {
259 // Only charged tracks
260 if( !(gMC->TrackCharge()) ) return;
261 // Only charged tracks
263 // Only gas gap inside chamber
264 // Tag chambers and record hits when track enters
265 static Int_t idvol=-1;
269 const Float_t kBig = 1.e10;
273 // Only gas gap inside chamber
274 // Tag chambers and record hits when track enters
275 id=gMC->CurrentVolID(copy);
276 iChamber = GetChamberId(id);
279 if (idvol == -1) return;
281 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
282 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
283 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
285 if( gMC->IsTrackEntering() ) {
286 Float_t theta = fTrackMomentum.Theta();
287 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
291 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
292 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z()));
293 // Particule id and mass,
294 Int_t ipart = gMC->TrackPid();
295 Float_t mass = gMC->TrackMass();
297 fDestepSum[idvol]+=gMC->Edep();
298 // Get current particle id (ipart), track position (pos) and momentum (mom)
299 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
300 fStepSum[idvol]+=gMC->TrackStep();
302 // if(AliDebugLevel()) {
304 // Form("iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
305 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
306 // mass, fStepSum[idvol], gMC->Edep()));
308 // Form("Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
309 // fTrackMomentum.Z()));
310 // gMC->TrackPosition(fTrackPosition);
312 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),
313 // fTrackPosition.Z())) ;
316 // Track left chamber or StepSum larger than fStepMaxInActiveGas
317 if ( gMC->IsTrackExiting() ||
318 gMC->IsTrackStop() ||
319 gMC->IsTrackDisappeared()||
320 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
322 if ( gMC->IsTrackExiting() ||
323 gMC->IsTrackStop() ||
324 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
326 gMC->TrackPosition(fTrackPosition);
327 Float_t theta = fTrackMomentum.Theta();
328 Float_t phi = fTrackMomentum.Phi();
330 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
331 fStepSum[idvol]/2.*sin(theta)*sin(phi),
332 fStepSum[idvol]/2.*cos(theta),0.0 );
333 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),
334 // fTrackPosition.Y(),fTrackPosition.Z())) ;
335 // AliDebug(1,Form("Exit: Track backToWire %f %f %f",backToWire.X(),
336 // backToWire.Y(),backToWire.Z()) ;
337 fTrackPosition-=backToWire;
339 //-------------- Angle effect
340 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
342 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
343 Float_t sigmaEffect10degrees;
344 Float_t sigmaEffectThetadegrees;
345 Float_t eLossParticleELossMip;
346 Float_t yAngleEffect=0.;
347 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
351 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
352 betaxGamma=TMath::Log(betaxGamma);
353 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
354 // 10 degrees is a reference for a model (arbitrary)
355 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
356 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
357 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
358 if ( (iChamber==1) || (iChamber==2) )
359 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
360 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
364 // Detection elements ids
365 AliMUONGeometryModule* geometry
366 = Chamber(iChamber-1).GetGeometry();
368 AliMUONGeometryDetElement* detElement
369 = geometry->FindBySensitiveVolume(CurrentVolumePath());
372 if (detElement) detElemId = detElement->GetUniqueID();
375 cerr << "Chamber id: "
376 << setw(3) << iChamber << " "
378 << CurrentVolumePath()
380 << setw(5) << detElemId
383 gMC->TrackPosition(x, y, z);
384 cerr << " global position: "
385 << x << ", " << y << ", " << z
387 AliWarning("DetElemId not identified.");
390 // One hit per chamber
391 GetMUONData()->AddHit(fIshunt,
392 gAlice->GetMCApp()->GetCurrentTrackNumber(),
395 fTrackPosition.Y()+yAngleEffect,
407 // if (AliDebugLevel()){
408 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
409 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
410 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z())) ;
412 fStepSum[idvol] =0; // Reset for the next event
413 fDestepSum[idvol]=0; // Reset for the next event
417 //_______________________________________________________________________________
418 void AliMUONv1::StepManager2()
420 // Stepmanager for the chambers
422 // Only charged tracks
423 if( !(gMC->TrackCharge()) ) return;
424 // Only charged tracks
426 // Only gas gap inside chamber
427 // Tag chambers and record hits when track enters
428 static Int_t idvol=-1;
432 const Float_t kBig = 1.e10;
436 // Only gas gap inside chamber
437 // Tag chambers and record hits when track enters
438 id=gMC->CurrentVolID(copy);
439 iChamber = GetChamberId(id);
442 if (idvol == -1) return;
444 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
445 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
446 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
448 if( gMC->IsTrackEntering() ) {
449 Float_t theta = fTrackMomentum.Theta();
450 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
454 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
455 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z())) ;
456 // Particule id and mass,
457 Int_t ipart = gMC->TrackPid();
458 Float_t mass = gMC->TrackMass();
460 fDestepSum[idvol]+=gMC->Edep();
461 // Get current particle id (ipart), track position (pos) and momentum (mom)
462 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
463 fStepSum[idvol]+=gMC->TrackStep();
465 // if (AliDebugLevel()) {
466 // AliDebug(1,Form("Step, iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
467 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
468 // mass, fStepSum[idvol], gMC->Edep()));
469 // AliDebug(1,Form("Step:Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
470 // fTrackMomentum.Z()));
471 // gMC->TrackPosition(fTrackPosition);
472 // AliDebug(1,Form("Step: Track Position %f %f %f",fTrackPosition.X(),
473 // fTrackPosition.Y(),fTrackPosition.Z())) ;
476 // Track left chamber or StepSum larger than fStepMaxInActiveGas
477 if ( gMC->IsTrackExiting() ||
478 gMC->IsTrackStop() ||
479 gMC->IsTrackDisappeared()||
480 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
482 if ( gMC->IsTrackExiting() ||
483 gMC->IsTrackStop() ||
484 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
486 gMC->TrackPosition(fTrackPosition);
487 Float_t theta = fTrackMomentum.Theta();
488 Float_t phi = fTrackMomentum.Phi();
490 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
491 fStepSum[idvol]/2.*sin(theta)*sin(phi),
492 fStepSum[idvol]/2.*cos(theta),0.0 );
494 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()));
496 // Form("Exit: Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z())) ;
497 fTrackPosition-=backToWire;
499 //-------------- Angle effect
500 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
502 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
503 Float_t sigmaEffect10degrees;
504 Float_t sigmaEffectThetadegrees;
505 Float_t eLossParticleELossMip;
506 Float_t yAngleEffect=0.;
507 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
511 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
512 betaxGamma=TMath::Log(betaxGamma);
513 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
514 // 10 degrees is a reference for a model (arbitrary)
515 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
516 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
517 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
518 if ( (iChamber==1) || (iChamber==2) )
519 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
520 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
524 // Detection elements ids
525 AliMUONGeometryModule* geometry
526 = Chamber(iChamber-1).GetGeometry();
528 AliMUONGeometryDetElement* detElement
529 = geometry->FindBySensitiveVolume(CurrentVolumePath());
532 if (detElement) detElemId = detElement->GetUniqueID();
535 cerr << "Chamber id: "
536 << setw(3) << iChamber << " "
538 << CurrentVolumePath()
540 << setw(5) << detElemId
543 gMC->TrackPosition(x, y, z);
544 cerr << " global position: "
545 << x << ", " << y << ", " << z
547 AliError("DetElemId not identified.");
550 // One hit per chamber
551 GetMUONData()->AddHit2(fIshunt,
552 gAlice->GetMCApp()->GetCurrentTrackNumber(),
555 fTrackPosition.Y()+yAngleEffect,
567 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
568 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
569 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
571 fStepSum[idvol] =0; // Reset for the next event
572 fDestepSum[idvol]=0; // Reset for the next event