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 "AliMUONConstants.h"
32 #include "AliMUONSegFactoryV4.h"
33 #include "AliMUONSegFactoryV3.h"
34 #include "AliMUONSegFactoryV2.h"
35 #include "AliMUONResponseFactory.h"
36 #include "AliMUONSegmentation.h"
37 #include "AliMUONHit.h"
38 #include "AliMUONTriggerCircuit.h"
39 #include "AliMUONGeometryBuilder.h"
40 #include "AliMUONGeometry.h"
41 #include "AliMUONGeometryTransformer.h"
42 #include "AliMUONGeometryModule.h"
43 #include "AliMUONGeometrySVMap.h"
44 #include "AliMUONGeometryDetElement.h"
54 //___________________________________________
55 AliMUONv1::AliMUONv1()
57 fStepManagerVersionOld(kTRUE),
58 fStepManagerVersionDE(kTRUE),
60 fStepMaxInActiveGas(0.6),
67 fAngleEffectNorma(0x0)
69 // Default constructor
70 AliDebug(1,Form("default (empty) ctor this=%p",this));
73 //___________________________________________
74 AliMUONv1::AliMUONv1(const char *name, const char *title)
75 : AliMUON(name,title),
76 fStepManagerVersionOld(kTRUE),
77 fStepManagerVersionDE(kTRUE),
79 fStepMaxInActiveGas(0.6),
86 fAngleEffectNorma(0x0)
88 // Standard onstructor
90 AliDebug(1,Form("ctor this=%p",this));
92 // By default include all stations
94 fStepSum = new Float_t [AliMUONConstants::NCh()];
95 fDestepSum = new Float_t [AliMUONConstants::NCh()];
96 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
100 // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
101 fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.);
102 fElossRatio->SetParameter(0,1.02138);
103 fElossRatio->SetParameter(1,-9.54149e-02);
104 fElossRatio->SetParameter(2,+7.83433e-02);
105 fElossRatio->SetParameter(3,-9.98208e-03);
106 fElossRatio->SetParameter(4,+3.83279e-04);
108 // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
109 fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
110 fAngleEffect10->SetParameter(0, 1.90691e+02);
111 fAngleEffect10->SetParameter(1,-6.62258e+01);
112 fAngleEffect10->SetParameter(2,+1.28247e+01);
113 // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)
114 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
115 fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
116 fAngleEffectNorma->SetParameter(0,4.148);
117 fAngleEffectNorma->SetParameter(1,-6.809e-01);
118 fAngleEffectNorma->SetParameter(2,5.151e-02);
119 fAngleEffectNorma->SetParameter(3,-1.490e-03);
122 //_____________________________________________________________________________
123 AliMUONv1::AliMUONv1(const AliMUONv1& right)
126 // copy constructor (not implemented)
128 AliFatal("Copy constructor not provided.");
131 //___________________________________________
132 AliMUONv1::~AliMUONv1()
135 AliDebug(1,Form("dtor this=%p",this));
137 delete [] fDestepSum;
139 delete fAngleEffect10;
140 delete fAngleEffectNorma;
143 //_____________________________________________________________________________
144 AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
146 // assignement operator (not implemented)
148 // check assignement to self
149 if (this == &right) return *this;
151 AliFatal("Assignement operator not provided.");
156 //__________________________________________________
157 void AliMUONv1::CreateGeometry()
160 // Construct geometry using geometry builder
163 fGeometryBuilder->CreateGeometry();
166 //________________________________________________________________
167 void AliMUONv1::CreateMaterials()
170 // Construct materials using geometry builder
173 fGeometryBuilder->CreateMaterials();
176 //___________________________________________
177 void AliMUONv1::Init()
179 AliDebug(1,"Start Init for version 1 - CPC chamber type");
182 // Initialize geometry
184 fGeometryBuilder->InitGeometry();
185 AliDebug(1,"Finished Init for version 1 - CPC chamber type");
188 std::string ftype(GetTitle());
190 // Build segmentation
191 // using geometry parametrisation
193 if ( ftype == "default" || ftype == "FactoryV2") {
194 AliMUONSegFactoryV2 segFactory("default");
195 segFactory.Build(GetGeometryTransformer());
196 fSegmentation = segFactory.GetSegmentation();
198 else if ( ftype == "FactoryV3" ) {
199 AliMUONSegFactoryV3 segFactory("default");
200 segFactory.Build(GetGeometryTransformer());
201 fSegmentation = segFactory.GetSegmentation();
203 else if ( ftype == "FactoryV4" ) {
204 AliMUONSegFactoryV4 segFactory("default");
205 segFactory.Build(GetGeometryTransformer());
206 fSegmentation = segFactory.GetSegmentation();
209 AliFatal(Form("Wrong factory type : %s",ftype.c_str()));
214 AliMUONResponseFactory respFactory("default");
215 respFactory.Build(this);
218 // Initialize segmentation
220 fSegmentation->Init();
222 // Initialize trigger circuits
224 for (Int_t i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
225 AliMUONTriggerCircuit* c = (AliMUONTriggerCircuit*)(fTriggerCircuits->At(i));
232 //__________________________________________________________________
233 Int_t AliMUONv1::GetChamberId(Int_t volId) const
235 // Check if the volume with specified volId is a sensitive volume (gas)
236 // of some chamber and returns the chamber number;
237 // if not sensitive volume - return 0.
240 for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
241 if ( GetGeometry()->GetModule(i)->IsSensitiveVolume(volId) )
248 //_______________________________________________________________________________
249 TString AliMUONv1::CurrentVolumePath() const
251 // Returns current volume path
252 // (Could be removed when this function is available via gMC)
260 name = gMC->CurrentVolOffName(imother);
261 gMC->CurrentVolOffID(imother++, copyNo);
268 while ( name != TString("ALIC") );
273 //_______________________________________________________________________________
274 void AliMUONv1::StepManager()
276 // Stepmanager for the chambers
279 if (fStepManagerVersionDE) {
285 // Only charged tracks
286 if( !(gMC->TrackCharge()) ) return;
287 // Only charged tracks
289 // Only gas gap inside chamber
290 // Tag chambers and record hits when track enters
291 static Int_t idvol=-1;
295 const Float_t kBig = 1.e10;
299 // Only gas gap inside chamber
300 // Tag chambers and record hits when track enters
301 id=gMC->CurrentVolID(copy);
302 iChamber = GetChamberId(id);
305 if (idvol == -1) return;
307 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
308 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
309 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
311 if( gMC->IsTrackEntering() ) {
312 Float_t theta = fTrackMomentum.Theta();
313 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
317 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
318 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z()));
319 // Particule id and mass,
320 Int_t ipart = gMC->TrackPid();
321 Float_t mass = gMC->TrackMass();
323 fDestepSum[idvol]+=gMC->Edep();
324 // Get current particle id (ipart), track position (pos) and momentum (mom)
325 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
326 fStepSum[idvol]+=gMC->TrackStep();
328 // if(AliDebugLevel()) {
330 // Form("iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
331 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
332 // mass, fStepSum[idvol], gMC->Edep()));
334 // Form("Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
335 // fTrackMomentum.Z()));
336 // gMC->TrackPosition(fTrackPosition);
338 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),
339 // fTrackPosition.Z())) ;
342 // Track left chamber or StepSum larger than fStepMaxInActiveGas
343 if ( gMC->IsTrackExiting() ||
344 gMC->IsTrackStop() ||
345 gMC->IsTrackDisappeared()||
346 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
348 if ( gMC->IsTrackExiting() ||
349 gMC->IsTrackStop() ||
350 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
352 gMC->TrackPosition(fTrackPosition);
353 Float_t theta = fTrackMomentum.Theta();
354 Float_t phi = fTrackMomentum.Phi();
356 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
357 fStepSum[idvol]/2.*sin(theta)*sin(phi),
358 fStepSum[idvol]/2.*cos(theta),0.0 );
359 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),
360 // fTrackPosition.Y(),fTrackPosition.Z())) ;
361 // AliDebug(1,Form("Exit: Track backToWire %f %f %f",backToWire.X(),
362 // backToWire.Y(),backToWire.Z()) ;
363 fTrackPosition-=backToWire;
365 //-------------- Angle effect
366 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
368 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
369 Float_t sigmaEffect10degrees;
370 Float_t sigmaEffectThetadegrees;
371 Float_t eLossParticleELossMip;
372 Float_t yAngleEffect=0.;
373 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
377 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
378 betaxGamma=TMath::Log(betaxGamma);
379 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
380 // 10 degrees is a reference for a model (arbitrary)
381 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
382 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
383 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
384 if ( (iChamber==1) || (iChamber==2) )
385 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
386 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
390 // Detection elements ids
391 const AliMUONGeometryModule* kGeometryModule
392 = GetGeometry()->GetModule(iChamber-1);
394 AliMUONGeometryDetElement* detElement
395 = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath());
398 if (detElement) detElemId = detElement->GetUniqueID();
401 cerr << "Chamber id: "
402 << setw(3) << iChamber << " "
404 << CurrentVolumePath()
406 << setw(5) << detElemId
409 gMC->TrackPosition(x, y, z);
410 cerr << " global position: "
411 << x << ", " << y << ", " << z
413 AliWarning("DetElemId not identified.");
416 // One hit per chamber
417 GetMUONData()->AddHit(fIshunt,
418 gAlice->GetMCApp()->GetCurrentTrackNumber(),
421 fTrackPosition.Y()+yAngleEffect,
433 // if (AliDebugLevel()){
434 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
435 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
436 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z())) ;
438 fStepSum[idvol] =0; // Reset for the next event
439 fDestepSum[idvol]=0; // Reset for the next event
443 //_______________________________________________________________________________
444 void AliMUONv1::StepManager2()
446 // Stepmanager for the chambers
448 // Only charged tracks
449 if( !(gMC->TrackCharge()) ) return;
450 // Only charged tracks
452 // Only gas gap inside chamber
453 // Tag chambers and record hits when track enters
454 static Int_t idvol=-1;
458 const Float_t kBig = 1.e10;
462 // Only gas gap inside chamber
463 // Tag chambers and record hits when track enters
464 id=gMC->CurrentVolID(copy);
465 iChamber = GetChamberId(id);
468 if (idvol == -1) return;
470 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
471 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
472 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
474 if( gMC->IsTrackEntering() ) {
475 Float_t theta = fTrackMomentum.Theta();
476 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
480 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
481 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z())) ;
482 // Particule id and mass,
483 Int_t ipart = gMC->TrackPid();
484 Float_t mass = gMC->TrackMass();
486 fDestepSum[idvol]+=gMC->Edep();
487 // Get current particle id (ipart), track position (pos) and momentum (mom)
488 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
489 fStepSum[idvol]+=gMC->TrackStep();
491 // if (AliDebugLevel()) {
492 // AliDebug(1,Form("Step, iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
493 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
494 // mass, fStepSum[idvol], gMC->Edep()));
495 // AliDebug(1,Form("Step:Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
496 // fTrackMomentum.Z()));
497 // gMC->TrackPosition(fTrackPosition);
498 // AliDebug(1,Form("Step: Track Position %f %f %f",fTrackPosition.X(),
499 // fTrackPosition.Y(),fTrackPosition.Z())) ;
502 // Track left chamber or StepSum larger than fStepMaxInActiveGas
503 if ( gMC->IsTrackExiting() ||
504 gMC->IsTrackStop() ||
505 gMC->IsTrackDisappeared()||
506 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
508 if ( gMC->IsTrackExiting() ||
509 gMC->IsTrackStop() ||
510 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
512 gMC->TrackPosition(fTrackPosition);
513 Float_t theta = fTrackMomentum.Theta();
514 Float_t phi = fTrackMomentum.Phi();
516 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
517 fStepSum[idvol]/2.*sin(theta)*sin(phi),
518 fStepSum[idvol]/2.*cos(theta),0.0 );
520 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()));
522 // Form("Exit: Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z())) ;
523 fTrackPosition-=backToWire;
525 //-------------- Angle effect
526 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
528 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
529 Float_t sigmaEffect10degrees;
530 Float_t sigmaEffectThetadegrees;
531 Float_t eLossParticleELossMip;
532 Float_t yAngleEffect=0.;
533 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
537 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
538 betaxGamma=TMath::Log(betaxGamma);
539 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
540 // 10 degrees is a reference for a model (arbitrary)
541 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
542 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
543 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
544 if ( (iChamber==1) || (iChamber==2) )
545 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
546 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
550 // Detection elements ids
551 const AliMUONGeometryModule* kGeometryModule
552 = GetGeometry()->GetModule(iChamber-1);
554 AliMUONGeometryDetElement* detElement
555 = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath());
558 if (detElement) detElemId = detElement->GetUniqueID();
561 cerr << "Chamber id: "
562 << setw(3) << iChamber << " "
564 << CurrentVolumePath()
566 << setw(5) << detElemId
569 gMC->TrackPosition(x, y, z);
570 cerr << " global position: "
571 << x << ", " << y << ", " << z
573 AliError("DetElemId not identified.");
576 // One hit per chamber
577 GetMUONData()->AddHit2(fIshunt,
578 gAlice->GetMCApp()->GetCurrentTrackNumber(),
581 fTrackPosition.Y()+yAngleEffect,
593 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
594 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
595 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
597 fStepSum[idvol] =0; // Reset for the next event
598 fDestepSum[idvol]=0; // Reset for the next event