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 "AliMUONFactoryV4.h"
34 #include "AliMUONFactoryV3.h"
35 #include "AliMUONFactoryV2.h"
36 #include "AliMUONHit.h"
37 #include "AliMUONTriggerCircuit.h"
38 #include "AliMUONGeometryBuilder.h"
39 #include "AliMUONGeometryModule.h"
40 #include "AliMUONGeometrySVMap.h"
41 #include "AliMUONGeometryDetElement.h"
51 //___________________________________________
52 AliMUONv1::AliMUONv1()
54 fStepManagerVersionOld(kTRUE),
55 fStepManagerVersionDE(kTRUE),
57 fStepMaxInActiveGas(0.6),
64 fAngleEffectNorma(0x0),
67 // Default constructor
68 AliDebug(1,Form("default (empty) ctor this=%p",this));
71 //___________________________________________
72 AliMUONv1::AliMUONv1(const char *name, const char *title)
73 : AliMUON(name,title),
74 fStepManagerVersionOld(kTRUE),
75 fStepManagerVersionDE(kTRUE),
77 fStepMaxInActiveGas(0.6),
84 fAngleEffectNorma(0x0),
87 // Standard onstructor
89 AliDebug(1,Form("ctor this=%p",this));
91 // By default include all stations
93 fStepSum = new Float_t [AliMUONConstants::NCh()];
94 fDestepSum = new Float_t [AliMUONConstants::NCh()];
95 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
99 // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
100 fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.);
101 fElossRatio->SetParameter(0,1.02138);
102 fElossRatio->SetParameter(1,-9.54149e-02);
103 fElossRatio->SetParameter(2,+7.83433e-02);
104 fElossRatio->SetParameter(3,-9.98208e-03);
105 fElossRatio->SetParameter(4,+3.83279e-04);
107 // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
108 fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
109 fAngleEffect10->SetParameter(0, 1.90691e+02);
110 fAngleEffect10->SetParameter(1,-6.62258e+01);
111 fAngleEffect10->SetParameter(2,+1.28247e+01);
112 // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)
113 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
114 fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
115 fAngleEffectNorma->SetParameter(0,4.148);
116 fAngleEffectNorma->SetParameter(1,-6.809e-01);
117 fAngleEffectNorma->SetParameter(2,5.151e-02);
118 fAngleEffectNorma->SetParameter(3,-1.490e-03);
121 //_____________________________________________________________________________
122 AliMUONv1::AliMUONv1(const AliMUONv1& right)
125 // copy constructor (not implemented)
127 AliFatal("Copy constructor not provided.");
130 //___________________________________________
131 AliMUONv1::~AliMUONv1()
134 AliDebug(1,Form("dtor this=%p",this));
136 delete [] fDestepSum;
138 delete fAngleEffect10;
139 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");
183 // Initialize geometry
185 fGeometryBuilder->InitGeometry();
186 AliDebug(1,"Finished Init for version 1 - CPC chamber type");
188 std::string ftype(GetTitle());
190 if ( ftype == "default" || ftype == "AliMUONFactoryV2")
192 fFactory = new AliMUONFactoryV2("New MUON Factory");
193 (static_cast<AliMUONFactoryV2*>(fFactory))->Build(this,"default");
195 else if ( ftype == "AliMUONFactoryV3" )
197 fFactory = new AliMUONFactoryV3("New MUON Factory");
198 (static_cast<AliMUONFactoryV3*>(fFactory))->Build(this,"default");
200 else if ( ftype == "AliMUONFactoryV4" )
202 fFactory = new AliMUONFactoryV4("New MUON Factory (w/ Trigger)");
203 (static_cast<AliMUONFactoryV4*>(fFactory))->Build(this,"default");
207 AliFatal(Form("Wrong factory type : %s",ftype.c_str()));
211 // Initialize segmentation
214 for (i=0; i<AliMUONConstants::NCh(); i++)
215 ( (AliMUONChamber*) (*fChambers)[i])->Init(2);// new segmentation
220 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++)
222 AliMUONTriggerCircuit* c = (AliMUONTriggerCircuit*)(fTriggerCircuits->At(i));
229 //__________________________________________________________________
230 Int_t AliMUONv1::GetChamberId(Int_t volId) const
232 // Check if the volume with specified volId is a sensitive volume (gas)
233 // of some chamber and returns the chamber number;
234 // if not sensitive volume - return 0.
238 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
239 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
241 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
242 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
247 //_______________________________________________________________________________
248 TString AliMUONv1::CurrentVolumePath() const
250 // Returns current volume path
251 // (Could be removed when this function is available via gMC)
259 name = gMC->CurrentVolOffName(imother);
260 gMC->CurrentVolOffID(imother++, copyNo);
267 while ( name != TString("ALIC") );
272 //_______________________________________________________________________________
273 void AliMUONv1::StepManager()
275 // Stepmanager for the chambers
278 if (fStepManagerVersionDE) {
284 // Only charged tracks
285 if( !(gMC->TrackCharge()) ) return;
286 // Only charged tracks
288 // Only gas gap inside chamber
289 // Tag chambers and record hits when track enters
290 static Int_t idvol=-1;
294 const Float_t kBig = 1.e10;
298 // Only gas gap inside chamber
299 // Tag chambers and record hits when track enters
300 id=gMC->CurrentVolID(copy);
301 iChamber = GetChamberId(id);
304 if (idvol == -1) return;
306 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
307 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
308 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
310 if( gMC->IsTrackEntering() ) {
311 Float_t theta = fTrackMomentum.Theta();
312 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
316 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
317 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z()));
318 // Particule id and mass,
319 Int_t ipart = gMC->TrackPid();
320 Float_t mass = gMC->TrackMass();
322 fDestepSum[idvol]+=gMC->Edep();
323 // Get current particle id (ipart), track position (pos) and momentum (mom)
324 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
325 fStepSum[idvol]+=gMC->TrackStep();
327 // if(AliDebugLevel()) {
329 // Form("iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
330 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
331 // mass, fStepSum[idvol], gMC->Edep()));
333 // Form("Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
334 // fTrackMomentum.Z()));
335 // gMC->TrackPosition(fTrackPosition);
337 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),
338 // fTrackPosition.Z())) ;
341 // Track left chamber or StepSum larger than fStepMaxInActiveGas
342 if ( gMC->IsTrackExiting() ||
343 gMC->IsTrackStop() ||
344 gMC->IsTrackDisappeared()||
345 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
347 if ( gMC->IsTrackExiting() ||
348 gMC->IsTrackStop() ||
349 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
351 gMC->TrackPosition(fTrackPosition);
352 Float_t theta = fTrackMomentum.Theta();
353 Float_t phi = fTrackMomentum.Phi();
355 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
356 fStepSum[idvol]/2.*sin(theta)*sin(phi),
357 fStepSum[idvol]/2.*cos(theta),0.0 );
358 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),
359 // fTrackPosition.Y(),fTrackPosition.Z())) ;
360 // AliDebug(1,Form("Exit: Track backToWire %f %f %f",backToWire.X(),
361 // backToWire.Y(),backToWire.Z()) ;
362 fTrackPosition-=backToWire;
364 //-------------- Angle effect
365 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
367 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
368 Float_t sigmaEffect10degrees;
369 Float_t sigmaEffectThetadegrees;
370 Float_t eLossParticleELossMip;
371 Float_t yAngleEffect=0.;
372 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
376 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
377 betaxGamma=TMath::Log(betaxGamma);
378 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
379 // 10 degrees is a reference for a model (arbitrary)
380 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
381 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
382 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
383 if ( (iChamber==1) || (iChamber==2) )
384 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
385 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
389 // Detection elements ids
390 AliMUONGeometryModule* geometry
391 = Chamber(iChamber-1).GetGeometry();
393 AliMUONGeometryDetElement* detElement
394 = geometry->FindBySensitiveVolume(CurrentVolumePath());
397 if (detElement) detElemId = detElement->GetUniqueID();
400 cerr << "Chamber id: "
401 << setw(3) << iChamber << " "
403 << CurrentVolumePath()
405 << setw(5) << detElemId
408 gMC->TrackPosition(x, y, z);
409 cerr << " global position: "
410 << x << ", " << y << ", " << z
412 AliWarning("DetElemId not identified.");
415 // One hit per chamber
416 GetMUONData()->AddHit(fIshunt,
417 gAlice->GetMCApp()->GetCurrentTrackNumber(),
420 fTrackPosition.Y()+yAngleEffect,
432 // if (AliDebugLevel()){
433 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
434 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
435 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z())) ;
437 fStepSum[idvol] =0; // Reset for the next event
438 fDestepSum[idvol]=0; // Reset for the next event
442 //_______________________________________________________________________________
443 void AliMUONv1::StepManager2()
445 // Stepmanager for the chambers
447 // Only charged tracks
448 if( !(gMC->TrackCharge()) ) return;
449 // Only charged tracks
451 // Only gas gap inside chamber
452 // Tag chambers and record hits when track enters
453 static Int_t idvol=-1;
457 const Float_t kBig = 1.e10;
461 // Only gas gap inside chamber
462 // Tag chambers and record hits when track enters
463 id=gMC->CurrentVolID(copy);
464 iChamber = GetChamberId(id);
467 if (idvol == -1) return;
469 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
470 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
471 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
473 if( gMC->IsTrackEntering() ) {
474 Float_t theta = fTrackMomentum.Theta();
475 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
479 // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber,
480 // ( (AliMUONChamber*)(*fChambers)[idvol])->Z())) ;
481 // Particule id and mass,
482 Int_t ipart = gMC->TrackPid();
483 Float_t mass = gMC->TrackMass();
485 fDestepSum[idvol]+=gMC->Edep();
486 // Get current particle id (ipart), track position (pos) and momentum (mom)
487 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
488 fStepSum[idvol]+=gMC->TrackStep();
490 // if (AliDebugLevel()) {
491 // AliDebug(1,Form("Step, iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
492 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg,
493 // mass, fStepSum[idvol], gMC->Edep()));
494 // AliDebug(1,Form("Step:Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(),
495 // fTrackMomentum.Z()));
496 // gMC->TrackPosition(fTrackPosition);
497 // AliDebug(1,Form("Step: Track Position %f %f %f",fTrackPosition.X(),
498 // fTrackPosition.Y(),fTrackPosition.Z())) ;
501 // Track left chamber or StepSum larger than fStepMaxInActiveGas
502 if ( gMC->IsTrackExiting() ||
503 gMC->IsTrackStop() ||
504 gMC->IsTrackDisappeared()||
505 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
507 if ( gMC->IsTrackExiting() ||
508 gMC->IsTrackStop() ||
509 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
511 gMC->TrackPosition(fTrackPosition);
512 Float_t theta = fTrackMomentum.Theta();
513 Float_t phi = fTrackMomentum.Phi();
515 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
516 fStepSum[idvol]/2.*sin(theta)*sin(phi),
517 fStepSum[idvol]/2.*cos(theta),0.0 );
519 // Form("Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()));
521 // Form("Exit: Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z())) ;
522 fTrackPosition-=backToWire;
524 //-------------- Angle effect
525 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
527 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
528 Float_t sigmaEffect10degrees;
529 Float_t sigmaEffectThetadegrees;
530 Float_t eLossParticleELossMip;
531 Float_t yAngleEffect=0.;
532 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
536 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
537 betaxGamma=TMath::Log(betaxGamma);
538 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
539 // 10 degrees is a reference for a model (arbitrary)
540 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
541 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
542 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
543 if ( (iChamber==1) || (iChamber==2) )
544 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
545 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
549 // Detection elements ids
550 AliMUONGeometryModule* geometry
551 = Chamber(iChamber-1).GetGeometry();
553 AliMUONGeometryDetElement* detElement
554 = geometry->FindBySensitiveVolume(CurrentVolumePath());
557 if (detElement) detElemId = detElement->GetUniqueID();
560 cerr << "Chamber id: "
561 << setw(3) << iChamber << " "
563 << CurrentVolumePath()
565 << setw(5) << detElemId
568 gMC->TrackPosition(x, y, z);
569 cerr << " global position: "
570 << x << ", " << y << ", " << z
572 AliError("DetElemId not identified.");
575 // One hit per chamber
576 GetMUONData()->AddHit2(fIshunt,
577 gAlice->GetMCApp()->GetCurrentTrackNumber(),
580 fTrackPosition.Y()+yAngleEffect,
592 // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
593 // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
594 // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
596 fStepSum[idvol] =0; // Reset for the next event
597 fDestepSum[idvol]=0; // Reset for the next event