1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Transition Radiation Detector version 1 -- slow simulator //
22 ////////////////////////////////////////////////////////////////////////////
24 #include <TLorentzVector.h>
27 #include <TVirtualMC.h>
28 #include <TGeoManager.h>
29 #include <TGeoMatrix.h>
30 #include <TGeoPhysicalNode.h>
32 #include "AliTrackReference.h"
35 #include "AliGeomManager.h"
37 #include "AliTRDgeometry.h"
38 #include "AliTRDCommonParam.h"
39 #include "AliTRDsimTR.h"
44 //_____________________________________________________________________________
53 // Default constructor
58 //_____________________________________________________________________________
59 AliTRDv1::AliTRDv1(const char *name, const char *title)
67 // Standard constructor for Transition Radiation Detector version 1
70 SetBufferSize(128000);
72 if (AliTRDCommonParam::Instance()->IsXenon()) {
73 fWion = 23.53; // Ionization energy XeCO2 (85/15)
75 else if (AliTRDCommonParam::Instance()->IsArgon()) {
76 fWion = 27.21; // Ionization energy ArCO2 (82/18)
79 AliFatal("Wrong gas mixture");
85 //_____________________________________________________________________________
89 // AliTRDv1 destructor
99 //_____________________________________________________________________________
100 void AliTRDv1::AddAlignableVolumes() const
103 // Create entries for alignable volumes associating the symbolic volume
104 // name with the corresponding volume path. Needs to be syncronized with
105 // eventual changes in the geometry.
111 TString vpStr = "ALIC_1/B077_1/BSEGMO";
112 TString vpApp1 = "_1/BTRD";
113 TString vpApp2 = "_1";
114 TString vpApp3a = "/UTR1_1/UTS1_1/UTI1_1/UT";
115 TString vpApp3b = "/UTR2_1/UTS2_1/UTI2_1/UT";
116 TString vpApp3c = "/UTR3_1/UTS3_1/UTI3_1/UT";
117 TString vpApp3d = "/UTR4_1/UTS4_1/UTI4_1/UT";
119 TString snStr = "TRD/sm";
120 TString snApp1 = "/st";
121 TString snApp2 = "/pl";
125 // The symbolic names are: TRD/sm00
129 for (Int_t isector = 0; isector < AliTRDgeometry::Nsector(); isector++) {
138 symName += Form("%02d",isector);
140 gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
145 // The readout chambers
146 // The symbolic names are: TRD/sm00/st0/pl0
150 AliGeomManager::ELayerID idTRD1 = AliGeomManager::kTRD1;
153 for (Int_t isector = 0; isector < AliTRDgeometry::Nsector(); isector++) {
155 if (fGeometry->GetSMstatus(isector) == 0) continue;
157 for (Int_t istack = 0; istack < AliTRDgeometry::Nstack(); istack++) {
158 for (Int_t ilayer = 0; ilayer < AliTRDgeometry::Nlayer(); ilayer++) {
160 layer = idTRD1 + ilayer;
161 modUID = AliGeomManager::LayerToVolUIDSafe(layer,isector*5+istack);
163 Int_t idet = AliTRDgeometry::GetDetectorSec(ilayer,istack);
172 if ((istack == 4) && (ilayer == 4)) {
192 volPath += Form("%02d",idet);
196 symName += Form("%02d",isector);
202 TGeoPNEntry *alignableEntry =
203 gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data(),modUID);
205 // Add the tracking to local matrix following the TPC example
206 if (alignableEntry) {
207 TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
208 Double_t sectorAngle = 20.0 * (isector % 18) + 10.0;
209 TGeoHMatrix *t2lMatrix = new TGeoHMatrix();
210 t2lMatrix->RotateZ(sectorAngle);
211 t2lMatrix->MultiplyLeft(&(globMatrix->Inverse()));
212 alignableEntry->SetMatrix(t2lMatrix);
215 AliError(Form("Alignable entry %s is not valid!",symName.Data()));
224 //_____________________________________________________________________________
225 void AliTRDv1::CreateGeometry()
228 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
229 // This version covers the full azimuth.
232 // Check that FRAME is there otherwise we have no place where to put the TRD
233 AliModule* frame = gAlice->GetModule("FRAME");
235 AliError("TRD needs FRAME to be present\n");
239 // Define the chambers
240 AliTRD::CreateGeometry();
244 //_____________________________________________________________________________
245 void AliTRDv1::CreateMaterials()
248 // Create materials for the Transition Radiation Detector version 1
251 AliTRD::CreateMaterials();
255 //_____________________________________________________________________________
256 void AliTRDv1::CreateTRhit(Int_t det)
259 // Creates an electron cluster from a TR photon.
260 // The photon is assumed to be created a the end of the radiator. The
261 // distance after which it deposits its energy takes into account the
262 // absorbtion of the entrance window and of the gas mixture in drift
266 // Maximum number of TR photons per track
267 const Int_t kNTR = 50;
276 TVirtualMC::GetMC()->TrackMomentum(mom);
277 Float_t pTot = mom.Rho();
278 fTR->CreatePhotons(11,pTot,nTR,eTR);
280 AliFatal(Form("Boundary error: nTR = %d, kNTR = %d",nTR,kNTR));
283 // Loop through the TR photons
284 for (Int_t iTR = 0; iTR < nTR; iTR++) {
286 Float_t energyMeV = eTR[iTR] * 0.001;
287 Float_t energyeV = eTR[iTR] * 1000.0;
288 Float_t absLength = 0.0;
291 // Take the absorbtion in the entrance window into account
292 Double_t muMy = fTR->GetMuMy(energyMeV);
293 sigma = muMy * fFoilDensity;
295 absLength = gRandom->Exp(1.0/sigma);
296 if (absLength < AliTRDgeometry::MyThick()) {
304 // The absorbtion cross sections in the drift gas
305 // Gas-mixture (Xe/CO2)
307 if (AliTRDCommonParam::Instance()->IsXenon()) {
308 muNo = fTR->GetMuXe(energyMeV);
310 else if (AliTRDCommonParam::Instance()->IsArgon()) {
311 muNo = fTR->GetMuAr(energyMeV);
313 Double_t muCO = fTR->GetMuCO(energyMeV);
314 sigma = (fGasNobleFraction * muNo + (1.0 - fGasNobleFraction) * muCO)
318 // The distance after which the energy of the TR photon
321 absLength = gRandom->Exp(1.0/sigma);
322 if (absLength > (AliTRDgeometry::DrThick()
323 + AliTRDgeometry::AmThick())) {
331 // The position of the absorbtion
333 TVirtualMC::GetMC()->TrackPosition(pos);
334 posHit[0] = pos[0] + mom[0] / pTot * absLength;
335 posHit[1] = pos[1] + mom[1] / pTot * absLength;
336 posHit[2] = pos[2] + mom[2] / pTot * absLength;
339 Int_t q = ((Int_t) (energyeV / fWion));
341 // Add the hit to the array. TR photon hits are marked
342 // by negative charge
343 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
347 ,TVirtualMC::GetMC()->TrackTime()*1.0e06
354 //_____________________________________________________________________________
355 void AliTRDv1::Init()
358 // Initialise Transition Radiation Detector after geometry has been built.
363 AliDebug(1,"Slow simulator\n");
365 // Switch on TR simulation as default
367 AliInfo("TR simulation off");
370 fTR = new AliTRDsimTR();
373 AliDebug(1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
377 //_____________________________________________________________________________
378 void AliTRDv1::StepManager()
381 // Slow simulator. Every charged track produces electron cluster as hits
382 // along its path across the drift volume. The step size is fixed in
383 // this version of the step manager.
385 // Works for Xe/CO2 as well as Ar/CO2
389 const Int_t kPdgElectron = 11;
400 Bool_t drRegion = kFALSE;
401 Bool_t amRegion = kFALSE;
408 TString cIdSensDr = "J";
409 TString cIdSensAm = "K";
410 Char_t cIdChamber[3];
416 const Int_t kNlayer = AliTRDgeometry::Nlayer();
417 const Int_t kNstack = AliTRDgeometry::Nstack();
418 const Int_t kNdetsec = kNlayer * kNstack;
420 const Double_t kBig = 1.0e+12;
421 const Float_t kEkinMinStep = 1.0e-5; // Minimum energy for the step size adjustment
423 // Set the maximum step size to a very large number for all
424 // neutral particles and those outside the driftvolume
425 if (!fPrimaryIonisation) TVirtualMC::GetMC()->SetMaxStep(kBig);
427 // If not charged track or already stopped or disappeared, just return.
428 if ((!TVirtualMC::GetMC()->TrackCharge()) ||
429 TVirtualMC::GetMC()->IsTrackDisappeared()) {
433 // Inside a sensitive volume?
434 cIdCurrent = TVirtualMC::GetMC()->CurrentVolName();
436 if (cIdSensDr == cIdCurrent[1]) {
439 if (cIdSensAm == cIdCurrent[1]) {
448 // The hit coordinates and charge
449 TVirtualMC::GetMC()->TrackPosition(pos);
454 // The sector number (0 - 17), according to standard coordinate system
455 cIdPath = gGeoManager->GetPath();
456 cIdSector[0] = cIdPath[21];
457 cIdSector[1] = cIdPath[22];
458 sector = atoi(cIdSector);
460 // The plane and chamber number
461 cIdChamber[0] = cIdCurrent[2];
462 cIdChamber[1] = cIdCurrent[3];
463 Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
464 stack = ((Int_t) idChamber / kNlayer);
465 layer = ((Int_t) idChamber % kNlayer);
467 // The detector number
468 det = fGeometry->GetDetector(layer,stack,sector);
470 // 0: InFlight 1:Entering 2:Exiting
473 // Special hits only in the drift region
475 (TVirtualMC::GetMC()->IsTrackEntering())) {
477 // Create a track reference at the entrance of each
478 // chamber that contains the momentum components of the particle
479 TVirtualMC::GetMC()->TrackMomentum(mom);
480 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
483 // Create the hits from TR photons if electron/positron is
484 // entering the drift volume
487 (TMath::Abs(TVirtualMC::GetMC()->TrackPid()) == kPdgElectron)) {
492 else if ((amRegion) &&
493 (TVirtualMC::GetMC()->IsTrackExiting())) {
495 // Create a track reference at the exit of each
496 // chamber that contains the momentum components of the particle
497 TVirtualMC::GetMC()->TrackMomentum(mom);
498 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
503 // Calculate the charge according to GEANT Edep
504 // Create a new dEdx hit
505 eDep = TMath::Max(TVirtualMC::GetMC()->Edep(),0.0) * 1.0e+09;
506 qTot = (Int_t) (eDep / fWion);
509 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
513 ,TVirtualMC::GetMC()->TrackTime()*1.0e06
517 // Set Maximum Step Size
518 // Produce only one hit if Ekin is below cutoff
519 if ((TVirtualMC::GetMC()->Etot() - TVirtualMC::GetMC()->TrackMass()) < kEkinMinStep) {
522 if (!fPrimaryIonisation) TVirtualMC::GetMC()->SetMaxStep(fStepSize);