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 ////////////////////////////////////////////////////////////////////////////
26 #include <TLorentzVector.h>
30 #include <TVirtualMC.h>
31 #include <TGeoManager.h>
32 #include <TGeoMatrix.h>
33 #include <TGeoPhysicalNode.h>
37 #include "AliTrackReference.h"
40 #include "AliGeomManager.h"
42 #include "AliTRDgeometry.h"
43 #include "AliTRDCommonParam.h"
44 #include "AliTRDhit.h"
45 #include "AliTRDsimTR.h"
50 //_____________________________________________________________________________
59 // Default constructor
64 //_____________________________________________________________________________
65 AliTRDv1::AliTRDv1(const char *name, const char *title)
73 // Standard constructor for Transition Radiation Detector version 1
76 SetBufferSize(128000);
78 if (AliTRDCommonParam::Instance()->IsXenon()) {
79 fWion = 23.53; // Ionization energy XeCO2 (85/15)
81 else if (AliTRDCommonParam::Instance()->IsArgon()) {
82 fWion = 27.21; // Ionization energy ArCO2 (82/18)
85 AliFatal("Wrong gas mixture");
91 //_____________________________________________________________________________
95 // AliTRDv1 destructor
105 //_____________________________________________________________________________
106 void AliTRDv1::AddAlignableVolumes() const
109 // Create entries for alignable volumes associating the symbolic volume
110 // name with the corresponding volume path. Needs to be syncronized with
111 // eventual changes in the geometry.
117 TString vpStr = "ALIC_1/B077_1/BSEGMO";
118 TString vpApp1 = "_1/BTRD";
119 TString vpApp2 = "_1";
120 TString vpApp3a = "/UTR1_1/UTS1_1/UTI1_1/UT";
121 TString vpApp3b = "/UTR2_1/UTS2_1/UTI2_1/UT";
122 TString vpApp3c = "/UTR3_1/UTS3_1/UTI3_1/UT";
124 TString snStr = "TRD/sm";
125 TString snApp1 = "/st";
126 TString snApp2 = "/pl";
130 // The symbolic names are: TRD/sm00
134 for (Int_t isector = 0; isector < AliTRDgeometry::Nsector(); isector++) {
143 symName += Form("%02d",isector);
145 gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
150 // The readout chambers
151 // The symbolic names are: TRD/sm00/st0/pl0
155 AliGeomManager::ELayerID idTRD1 = AliGeomManager::kTRD1;
158 for (Int_t isector = 0; isector < AliTRDgeometry::Nsector(); isector++) {
160 if (fGeometry->GetSMstatus(isector) == 0) continue;
162 for (Int_t istack = 0; istack < AliTRDgeometry::Nstack(); istack++) {
163 for (Int_t ilayer = 0; ilayer < AliTRDgeometry::Nlayer(); ilayer++) {
165 layer = idTRD1 + ilayer;
166 modUID = AliGeomManager::LayerToVolUIDSafe(layer,isector*5+istack);
168 Int_t idet = AliTRDgeometry::GetDetectorSec(ilayer,istack);
191 volPath += Form("%02d",idet);
195 symName += Form("%02d",isector);
201 TGeoPNEntry *alignableEntry =
202 gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data(),modUID);
204 // Add the tracking to local matrix following the TPC example
205 if (alignableEntry) {
206 TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
207 Double_t sectorAngle = 20.0 * (isector % 18) + 10.0;
208 TGeoHMatrix *t2lMatrix = new TGeoHMatrix();
209 t2lMatrix->RotateZ(sectorAngle);
210 t2lMatrix->MultiplyLeft(&(globMatrix->Inverse()));
211 alignableEntry->SetMatrix(t2lMatrix);
214 AliError(Form("Alignable entry %s is not valid!",symName.Data()));
223 //_____________________________________________________________________________
224 void AliTRDv1::CreateGeometry()
227 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
228 // This version covers the full azimuth.
231 // Check that FRAME is there otherwise we have no place where to put the TRD
232 AliModule* frame = gAlice->GetModule("FRAME");
234 AliError("TRD needs FRAME to be present\n");
238 // Define the chambers
239 AliTRD::CreateGeometry();
243 //_____________________________________________________________________________
244 void AliTRDv1::CreateMaterials()
247 // Create materials for the Transition Radiation Detector version 1
250 AliTRD::CreateMaterials();
254 //_____________________________________________________________________________
255 void AliTRDv1::CreateTRhit(Int_t det)
258 // Creates an electron cluster from a TR photon.
259 // The photon is assumed to be created a the end of the radiator. The
260 // distance after which it deposits its energy takes into account the
261 // absorbtion of the entrance window and of the gas mixture in drift
265 // Maximum number of TR photons per track
266 const Int_t kNTR = 50;
275 gMC->TrackMomentum(mom);
276 Float_t pTot = mom.Rho();
277 fTR->CreatePhotons(11,pTot,nTR,eTR);
279 AliFatal(Form("Boundary error: nTR = %d, kNTR = %d",nTR,kNTR));
282 // Loop through the TR photons
283 for (Int_t iTR = 0; iTR < nTR; iTR++) {
285 Float_t energyMeV = eTR[iTR] * 0.001;
286 Float_t energyeV = eTR[iTR] * 1000.0;
287 Float_t absLength = 0.0;
290 // Take the absorbtion in the entrance window into account
291 Double_t muMy = fTR->GetMuMy(energyMeV);
292 sigma = muMy * fFoilDensity;
294 absLength = gRandom->Exp(1.0/sigma);
295 if (absLength < AliTRDgeometry::MyThick()) {
303 // The absorbtion cross sections in the drift gas
304 // Gas-mixture (Xe/CO2)
306 if (AliTRDCommonParam::Instance()->IsXenon()) {
307 muNo = fTR->GetMuXe(energyMeV);
309 else if (AliTRDCommonParam::Instance()->IsArgon()) {
310 muNo = fTR->GetMuAr(energyMeV);
312 Double_t muCO = fTR->GetMuCO(energyMeV);
313 sigma = (fGasNobleFraction * muNo + (1.0 - fGasNobleFraction) * muCO)
317 // The distance after which the energy of the TR photon
320 absLength = gRandom->Exp(1.0/sigma);
321 if (absLength > (AliTRDgeometry::DrThick()
322 + AliTRDgeometry::AmThick())) {
330 // The position of the absorbtion
332 gMC->TrackPosition(pos);
333 posHit[0] = pos[0] + mom[0] / pTot * absLength;
334 posHit[1] = pos[1] + mom[1] / pTot * absLength;
335 posHit[2] = pos[2] + mom[2] / pTot * absLength;
338 Int_t q = ((Int_t) (energyeV / fWion));
340 // Add the hit to the array. TR photon hits are marked
341 // by negative charge
342 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
346 ,gMC->TrackTime()*1.0e06
353 //_____________________________________________________________________________
354 void AliTRDv1::Init()
357 // Initialise Transition Radiation Detector after geometry has been built.
362 AliDebug(1,"Slow simulator\n");
364 // Switch on TR simulation as default
366 AliInfo("TR simulation off");
369 fTR = new AliTRDsimTR();
372 AliDebug(1,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
376 //_____________________________________________________________________________
377 void AliTRDv1::StepManager()
380 // Slow simulator. Every charged track produces electron cluster as hits
381 // along its path across the drift volume. The step size is fixed in
382 // this version of the step manager.
384 // Works for Xe/CO2 as well as Ar/CO2
388 const Int_t kPdgElectron = 11;
399 Bool_t drRegion = kFALSE;
400 Bool_t amRegion = kFALSE;
407 TString cIdSensDr = "J";
408 TString cIdSensAm = "K";
409 Char_t cIdChamber[3];
415 const Int_t kNlayer = AliTRDgeometry::Nlayer();
416 const Int_t kNstack = AliTRDgeometry::Nstack();
417 const Int_t kNdetsec = kNlayer * kNstack;
419 const Double_t kBig = 1.0e+12;
420 const Float_t kEkinMinStep = 1.0e-5; // Minimum energy for the step size adjustment
422 // Set the maximum step size to a very large number for all
423 // neutral particles and those outside the driftvolume
424 gMC->SetMaxStep(kBig);
426 // If not charged track or already stopped or disappeared, just return.
427 if ((!gMC->TrackCharge()) ||
428 gMC->IsTrackDisappeared()) {
432 // Inside a sensitive volume?
433 cIdCurrent = gMC->CurrentVolName();
435 if (cIdSensDr == cIdCurrent[1]) {
438 if (cIdSensAm == cIdCurrent[1]) {
447 // The hit coordinates and charge
448 gMC->TrackPosition(pos);
453 // The sector number (0 - 17), according to standard coordinate system
454 cIdPath = gGeoManager->GetPath();
455 cIdSector[0] = cIdPath[21];
456 cIdSector[1] = cIdPath[22];
457 sector = atoi(cIdSector);
459 // The plane and chamber number
460 cIdChamber[0] = cIdCurrent[2];
461 cIdChamber[1] = cIdCurrent[3];
462 Int_t idChamber = (atoi(cIdChamber) % kNdetsec);
463 stack = ((Int_t) idChamber / kNlayer);
464 layer = ((Int_t) idChamber % kNlayer);
466 // The detector number
467 det = fGeometry->GetDetector(layer,stack,sector);
469 // 0: InFlight 1:Entering 2:Exiting
472 // Special hits only in the drift region
474 (gMC->IsTrackEntering())) {
476 // Create a track reference at the entrance of each
477 // chamber that contains the momentum components of the particle
478 gMC->TrackMomentum(mom);
479 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
482 // Create the hits from TR photons if electron/positron is
483 // entering the drift volume
485 (TMath::Abs(gMC->TrackPid()) == kPdgElectron)) {
490 else if ((amRegion) &&
491 (gMC->IsTrackExiting())) {
493 // Create a track reference at the exit of each
494 // chamber that contains the momentum components of the particle
495 gMC->TrackMomentum(mom);
496 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
501 // Calculate the charge according to GEANT Edep
502 // Create a new dEdx hit
503 eDep = TMath::Max(gMC->Edep(),0.0) * 1.0e+09;
504 qTot = (Int_t) (eDep / fWion);
507 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
511 ,gMC->TrackTime()*1.0e06
515 // Set Maximum Step Size
516 // Produce only one hit if Ekin is below cutoff
517 if ((gMC->Etot() - gMC->TrackMass()) < kEkinMinStep) {
520 gMC->SetMaxStep(fStepSize);