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";
118 TString snStr = "TRD/sm";
119 TString snApp1 = "/st";
120 TString snApp2 = "/pl";
124 // The symbolic names are: TRD/sm00
128 for (Int_t isector = 0; isector < AliTRDgeometry::Nsector(); isector++) {
137 symName += Form("%02d",isector);
139 gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
144 // The readout chambers
145 // The symbolic names are: TRD/sm00/st0/pl0
149 AliGeomManager::ELayerID idTRD1 = AliGeomManager::kTRD1;
152 for (Int_t isector = 0; isector < AliTRDgeometry::Nsector(); isector++) {
154 if (fGeometry->GetSMstatus(isector) == 0) continue;
156 for (Int_t istack = 0; istack < AliTRDgeometry::Nstack(); istack++) {
157 for (Int_t ilayer = 0; ilayer < AliTRDgeometry::Nlayer(); ilayer++) {
159 layer = idTRD1 + ilayer;
160 modUID = AliGeomManager::LayerToVolUIDSafe(layer,isector*5+istack);
162 Int_t idet = AliTRDgeometry::GetDetectorSec(ilayer,istack);
185 volPath += Form("%02d",idet);
189 symName += Form("%02d",isector);
195 TGeoPNEntry *alignableEntry =
196 gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data(),modUID);
198 // Add the tracking to local matrix following the TPC example
199 if (alignableEntry) {
200 TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
201 Double_t sectorAngle = 20.0 * (isector % 18) + 10.0;
202 TGeoHMatrix *t2lMatrix = new TGeoHMatrix();
203 t2lMatrix->RotateZ(sectorAngle);
204 t2lMatrix->MultiplyLeft(&(globMatrix->Inverse()));
205 alignableEntry->SetMatrix(t2lMatrix);
208 AliError(Form("Alignable entry %s is not valid!",symName.Data()));
217 //_____________________________________________________________________________
218 void AliTRDv1::CreateGeometry()
221 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
222 // This version covers the full azimuth.
225 // Check that FRAME is there otherwise we have no place where to put the TRD
226 AliModule* frame = gAlice->GetModule("FRAME");
228 AliError("TRD needs FRAME to be present\n");
232 // Define the chambers
233 AliTRD::CreateGeometry();
237 //_____________________________________________________________________________
238 void AliTRDv1::CreateMaterials()
241 // Create materials for the Transition Radiation Detector version 1
244 AliTRD::CreateMaterials();
248 //_____________________________________________________________________________
249 void AliTRDv1::CreateTRhit(Int_t det)
252 // Creates an electron cluster from a TR photon.
253 // The photon is assumed to be created a the end of the radiator. The
254 // distance after which it deposits its energy takes into account the
255 // absorbtion of the entrance window and of the gas mixture in drift
259 // Maximum number of TR photons per track
260 const Int_t kNTR = 50;
269 gMC->TrackMomentum(mom);
270 Float_t pTot = mom.Rho();
271 fTR->CreatePhotons(11,pTot,nTR,eTR);
273 AliFatal(Form("Boundary error: nTR = %d, kNTR = %d",nTR,kNTR));
276 // Loop through the TR photons
277 for (Int_t iTR = 0; iTR < nTR; iTR++) {
279 Float_t energyMeV = eTR[iTR] * 0.001;
280 Float_t energyeV = eTR[iTR] * 1000.0;
281 Float_t absLength = 0.0;
284 // Take the absorbtion in the entrance window into account
285 Double_t muMy = fTR->GetMuMy(energyMeV);
286 sigma = muMy * fFoilDensity;
288 absLength = gRandom->Exp(1.0/sigma);
289 if (absLength < AliTRDgeometry::MyThick()) {
297 // The absorbtion cross sections in the drift gas
298 // Gas-mixture (Xe/CO2)
300 if (AliTRDCommonParam::Instance()->IsXenon()) {
301 muNo = fTR->GetMuXe(energyMeV);
303 else if (AliTRDCommonParam::Instance()->IsArgon()) {
304 muNo = fTR->GetMuAr(energyMeV);
306 Double_t muCO = fTR->GetMuCO(energyMeV);
307 sigma = (fGasNobleFraction * muNo + (1.0 - fGasNobleFraction) * muCO)
311 // The distance after which the energy of the TR photon
314 absLength = gRandom->Exp(1.0/sigma);
315 if (absLength > (AliTRDgeometry::DrThick()
316 + AliTRDgeometry::AmThick())) {
324 // The position of the absorbtion
326 gMC->TrackPosition(pos);
327 posHit[0] = pos[0] + mom[0] / pTot * absLength;
328 posHit[1] = pos[1] + mom[1] / pTot * absLength;
329 posHit[2] = pos[2] + mom[2] / pTot * absLength;
332 Int_t q = ((Int_t) (energyeV / fWion));
334 // Add the hit to the array. TR photon hits are marked
335 // by negative charge
336 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
340 ,gMC->TrackTime()*1.0e06
347 //_____________________________________________________________________________
348 void AliTRDv1::Init()
351 // Initialise Transition Radiation Detector after geometry has been built.
356 AliDebug(1,"Slow simulator\n");
358 // Switch on TR simulation as default
360 AliInfo("TR simulation off");
363 fTR = new AliTRDsimTR();
366 AliDebug(1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
370 //_____________________________________________________________________________
371 void AliTRDv1::StepManager()
374 // Slow simulator. Every charged track produces electron cluster as hits
375 // along its path across the drift volume. The step size is fixed in
376 // this version of the step manager.
378 // Works for Xe/CO2 as well as Ar/CO2
382 const Int_t kPdgElectron = 11;
393 Bool_t drRegion = kFALSE;
394 Bool_t amRegion = kFALSE;
401 TString cIdSensDr = "J";
402 TString cIdSensAm = "K";
403 Char_t cIdChamber[3];
409 const Int_t kNlayer = AliTRDgeometry::Nlayer();
410 const Int_t kNstack = AliTRDgeometry::Nstack();
411 const Int_t kNdetsec = kNlayer * kNstack;
413 const Double_t kBig = 1.0e+12;
414 const Float_t kEkinMinStep = 1.0e-5; // Minimum energy for the step size adjustment
416 // Set the maximum step size to a very large number for all
417 // neutral particles and those outside the driftvolume
418 if (!fPrimaryIonisation) gMC->SetMaxStep(kBig);
420 // If not charged track or already stopped or disappeared, just return.
421 if ((!gMC->TrackCharge()) ||
422 gMC->IsTrackDisappeared()) {
426 // Inside a sensitive volume?
427 cIdCurrent = gMC->CurrentVolName();
429 if (cIdSensDr == cIdCurrent[1]) {
432 if (cIdSensAm == cIdCurrent[1]) {
441 // The hit coordinates and charge
442 gMC->TrackPosition(pos);
447 // The sector number (0 - 17), according to standard coordinate system
448 cIdPath = gGeoManager->GetPath();
449 cIdSector[0] = cIdPath[21];
450 cIdSector[1] = cIdPath[22];
451 sector = atoi(cIdSector);
453 // The plane and chamber number
454 cIdChamber[0] = cIdCurrent[2];
455 cIdChamber[1] = cIdCurrent[3];
456 Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
457 stack = ((Int_t) idChamber / kNlayer);
458 layer = ((Int_t) idChamber % kNlayer);
460 // The detector number
461 det = fGeometry->GetDetector(layer,stack,sector);
463 // 0: InFlight 1:Entering 2:Exiting
466 // Special hits only in the drift region
468 (gMC->IsTrackEntering())) {
470 // Create a track reference at the entrance of each
471 // chamber that contains the momentum components of the particle
472 gMC->TrackMomentum(mom);
473 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
476 // Create the hits from TR photons if electron/positron is
477 // entering the drift volume
480 (TMath::Abs(gMC->TrackPid()) == kPdgElectron)) {
485 else if ((amRegion) &&
486 (gMC->IsTrackExiting())) {
488 // Create a track reference at the exit of each
489 // chamber that contains the momentum components of the particle
490 gMC->TrackMomentum(mom);
491 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
496 // Calculate the charge according to GEANT Edep
497 // Create a new dEdx hit
498 eDep = TMath::Max(gMC->Edep(),0.0) * 1.0e+09;
499 qTot = (Int_t) (eDep / fWion);
502 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
506 ,gMC->TrackTime()*1.0e06
510 // Set Maximum Step Size
511 // Produce only one hit if Ekin is below cutoff
512 if ((gMC->Etot() - gMC->TrackMass()) < kEkinMinStep) {
515 if (!fPrimaryIonisation) gMC->SetMaxStep(fStepSize);