16#include <TDirectory.h>
18#include <TGeoManager.h>
22#include <TObjString.h>
32using std::setprecision;
43 , fFoilThick(FoilThick)
45 , fFoilMaterial(material)
61 , fSpBinWidth((Float_t) fSpRange / (Float_t) fSpNBins)
66 , fWinSpectrum(nullptr)
67 , fDetSpectrumA(nullptr)
68 , fDetSpectrum(nullptr)
69 , fTrackMomentum(nullptr)
76 for (Int_t i = 0; i <
fNMom; i++) {
109 , fSpBinWidth((Float_t) fSpRange / (Float_t) fSpNBins)
114 , fWinSpectrum(nullptr)
115 , fDetSpectrumA(nullptr)
116 , fDetSpectrum(nullptr)
117 , fTrackMomentum(nullptr)
122 , fMom(-1., -1., -1.)
124 for (Int_t i = 0; i <
fNMom; i++) {
136 LOG(info) <<
" -I DELETING fSpectrum ";
143 for (Int_t i = 0; i <
fNMom; i++) {
157 Float_t SpUpper = SpLower + (Float_t)
fSpRange;
159 size_t buf_size = 50;
160 Char_t name[buf_size];
169 fDetSpectrum =
new TH1D(
"fDetSpectrum",
"TR spectrum escaped from detector",
fSpNBins, SpLower, SpUpper);
172 fDetSpectrumA =
new TH1D(
"fDetSpectrumA",
"TR spectrum absorbed in detector",
fSpNBins, SpLower, SpUpper);
174 for (Int_t i = 0; i <
fNMom; i++) {
175 snprintf(name, buf_size - 1,
"fFinal%d", i + 1);
186 LOG(info) <<
"================CbmTrdRadiator===============";
218 LOG(warn) <<
"CbmTrdRadiator::Init : *********** Radiator prototype not known ***********";
219 LOG(warn) <<
"CbmTrdRadiator::Init : switch to default parameters ";
262 LOG(warn) <<
"CbmTrdRadiator::Init : *********** Radiator material not known ***********";
263 LOG(warn) <<
"CbmTrdRadiator::Init : switch to default material ";
283 LOG(info) <<
"CbmTrdRadiator::Init : Window type : " <<
fWindowFoil;
284 LOG(info) <<
"CbmTrdRadiator::Init : Window density : " <<
fWinDens <<
" g/cm^3";
285 LOG(info) <<
"CbmTrdRadiator::Init : Window thickness : " <<
fWinThick <<
" cm";
289 LOG(info) <<
"CbmTrdRadiator::Init : Prototype : " <<
fRadType;
290 LOG(info) <<
"CbmTrdRadiator::Init : Scaling factor : " <<
fnPhotonCorr;
291 LOG(info) <<
"CbmTrdRadiator::Init : Foil material : " <<
fFoilMaterial;
292 LOG(info) <<
"CbmTrdRadiator::Init : Nr. of foils : " <<
fNFoils;
293 LOG(info) <<
"CbmTrdRadiator::Init : Foil thickness : " << setprecision(4) <<
fFoilThick <<
" cm";
294 LOG(info) <<
"CbmTrdRadiator::Init : Gap thickness : " <<
fGapThick <<
" cm";
295 LOG(info) <<
"CbmTrdRadiator::Init : Simple TR production: " << setprecision(2) <<
fSimpleTR;
296 LOG(info) <<
"CbmTrdRadiator::Init : Foil plasm. frequ. : " <<
fFoilOmega <<
" keV";
297 LOG(info) <<
"CbmTrdRadiator::Init : Gap plasm. frequ. : " <<
fGapOmega <<
" keV";
312 LOG(info) <<
"CbmTrdRadiator::Init : Detector noble gas : " << fTrdGas->
GetNobleGas();
313 LOG(info) <<
"CbmTrdRadiator::Init : Detector quenching gas: " << fTrdGas->
GetCO2();
314 LOG(info) <<
"CbmTrdRadiator::Init : Detector type : " << fTrdGas->
GetDetType();
315 LOG(info) <<
"CbmTrdRadiator::Init : Detector gas thick. : " << fTrdGas->
GetGasThick() <<
" cm";
326 TFile* oldFile = gFile;
327 TDirectory* oldDir = gDirectory;
329 TFile* f1 =
new TFile(
"TRhistos.root",
"recreate");
331 for (Int_t i = 0; i <
fNMom; i++) {
354 TObjArray* mats = def.Tokenize(
";");
355 for (fN = 0; fN < mats->GetEntriesFast(); fN++) {
356 TObjString* mat = (TObjString*) (*mats)[fN];
357 TString mname = mat->String();
358 if (mname.CompareTo(
"Al") == 0) {
363 else if (mname.CompareTo(
"C") == 0) {
368 else if (mname.CompareTo(
"HC") == 0) {
373 else if (mname.CompareTo(
"Po") == 0) {
378 else if (mname.CompareTo(
"Pok") == 0) {
383 else if (mname.CompareTo(
"Ka") == 0) {
388 else if (mname.CompareTo(
"Air") == 0) {
390 fDens[fN] = 1.205e-3;
393 else if (mname.CompareTo(
"Xe") == 0) {
398 else if (mname.CompareTo(
"CO2") == 0) {
400 fDens[fN] = 1.9767e-3;
403 else if (mname.CompareTo(
"My") == 0) {
409 LOG(warn) <<
"CbmTrdEntranceWindow::Init : material " << mname.Data() <<
" not in the DB. Can't create "
410 << def.Data() <<
" entrance window structure. Default to Mylar.";
414 LOG(info) <<
"CbmTrdEntranceWindow::Init : C" << fN <<
" type : " << fMat[fN];
415 LOG(info) <<
"CbmTrdEntranceWindow::Init : density : " << fDens[fN] <<
" g/cm^3";
416 LOG(info) <<
"CbmTrdEntranceWindow::Init : thickness : " << fThick[fN] <<
" cm";
427 LOG(warn) <<
"CbmTrdEntranceWindow : can support only up to " <<
NCOMPONENTS
428 <<
" plane-parallel elements. Please check your simulations";
438 Double_t point_in[3];
439 Double_t point_out[3];
440 if (
nullptr != point) {
441 point_in[0] = point->
GetXIn();
442 point_in[1] = point->
GetYIn();
443 point_in[2] = point->
GetZIn();
445 point_out[0] = point->
GetXOut();
446 point_out[1] = point->
GetYOut();
447 point_out[2] = point->
GetZOut();
448 Double_t back_direction[3] = {(point_in[0] - point_out[0]), (point_in[1] - point_out[1]),
449 (point_in[2] - point_out[2])};
450 if (back_direction[2] > 0) {
451 LOG(debug2) <<
"CbmTrdRadiator::LatticeHit: MC-track points towards target!";
456 Double_t trackLength = TMath::Sqrt(back_direction[0] * back_direction[0] + back_direction[1] * back_direction[1]
457 + back_direction[2] * back_direction[2]);
461 gGeoManager->FindNode((point_out[0] + point_in[0]) / 2, (point_out[1] + point_in[1]) / 2,
462 (point_out[2] + point_in[2]) / 2);
464 Double_t
pos[3] = {point_in[0], point_in[1], point_in[2]};
466 for (Int_t i = 0; i < 3; i++) {
467 back_direction[i] /= trackLength;
470 if (TString(gGeoManager->GetPath()).Contains(
"gas")) {
474 pos[2] >= point_in[2] - 5 && stepCount < 50) {
477 for (Int_t i = 0; i < 3; i++) {
478 pos[i] += back_direction[i];
482 gGeoManager->FindNode(
pos[0],
pos[1],
pos[2]);
483 if (TString(gGeoManager->GetPath()).Contains(
"radiator")) {
487 else if (TString(gGeoManager->GetPath()).Contains(
"lattice")) {
491 else if (TString(gGeoManager->GetPath()).Contains(
"frame")) {
501 LOG(error) <<
"CbmTrdRadiator::LatticeHit: MC-track not in TRD! Node:" << TString(gGeoManager->GetPath()).Data()
502 <<
" gGeoManager->MasterToLocal() failed!";
507 LOG(error) <<
"CbmTrdRadiator::LatticeHit: CbmTrdPoint == nullptr!";
519 Double_t trackMomentum[
fNMom] = {0.1, 0.25, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
521 for (Int_t imom = 0; imom <
fNMom; imom++) {
525 for (Int_t i = 0; i <
fNMom; i++) {
536 for (Int_t j = 0; j <
fSpNBins; j++) {
538 fFinal[i]->SetBinContent(j + 1, tmp);
556 Float_t m = Mom.Mag();
592 Float_t fNormPhi =
fMom.Mag() /
fMom.Pz();
613 Float_t energiefirst =
fELoss;
614 Float_t fTRAbsfirst =
fnTRab;
638 Int_t maxPhoton = 50;
639 Double32_t eLoss = 0;
644 LOG(error) <<
" -Err :: No input spectra ";
649 if (nPhoton > maxPhoton) nPhoton = maxPhoton;
650 for (Int_t i = 0; i < nPhoton; i++) {
658 LOG(error) <<
" -Err :: No input spectra ";
663 if (nPhoton > maxPhoton) nPhoton = maxPhoton;
664 for (Int_t i = 0; i < nPhoton; i++) {
666 eTR =
fFinal[index]->GetRandom();
672 fELoss = eLoss / 1000000.0;
690 const Float_t kAlpha = 0.0072973;
691 const Int_t kSumMax = 30;
708 for (Int_t iBin = 0; iBin <
fSpNBins; iBin++) {
711 Float_t energyeV = (
fSpBinWidth * iBin + 1.0) * 1e3;
716 Float_t rho1 = energyeV *
fFoilThickCorr * 1e4 * 2.5 * (1.0 / (gamma * gamma) + csFoil * csFoil);
717 Float_t rho2 = energyeV *
fFoilThickCorr * 1e4 * 2.5 * (1.0 / (gamma * gamma) + csGap * csGap);
721 for (Int_t iSum = 0; iSum < kSumMax; iSum++) {
722 Float_t tetan = (TMath::Pi() * 2.0 * (iSum + 1) - (rho1 + kappa * rho2)) / (kappa + 1.0);
723 if (tetan < 0.0) { tetan = 0.0; }
724 Float_t aux = 1.0 / (rho1 + tetan) - 1.0 / (rho2 + tetan);
725 sum += tetan * (aux * aux) * (1.0 - TMath::Cos(rho1 + tetan));
730 Float_t energykeV = energyeV * 0.001;
733 Float_t wn = kAlpha * 4.0 / (
fSigma[iBin] * (kappa + 1.0)) * conv * sum / energykeV;
770 for (Int_t iBin = 0; iBin <
fSpNBins; iBin++) {
778 Float_t conv = TMath::Exp(-
fSigmaWin[iBin]);
779 Float_t wn = sp * conv;
805 for (Int_t iBin = 0; iBin <
fSpNBins; iBin++) {
810 Float_t conv = TMath::Exp(-
fSigmaDet[iBin]);
811 Float_t wn = sp * conv;
817 Float_t conv2 = 1 - TMath::Exp(-
fSigmaDet[iBin]);
818 Float_t wn2 = sp * conv2;
842 Float_t massE = 5.1099907e-4;
844 Float_t p2 =
fMom.Mag2();
845 Float_t result = TMath::Sqrt(p2 + massE * massE) / massE;
862 for (Int_t iBin = 0; iBin <
fSpNBins; iBin++) {
871 for (Int_t iBin = 0; iBin <
fSpNBins; iBin++) {
880 for (Int_t iBin = 0; iBin <
fSpNBins; iBin++) {
896 Float_t energyMeV = energykeV * 0.001;
909 LOG(error) <<
"ERROR:: unknown radiator material";
912 if (energyMeV >= 0.001) {
930 Float_t energyMeV = energykeV * 0.001;
931 if (energyMeV >= 0.001) {
938 for (Int_t iwin(0); iwin <
WINDOW.
fN; iwin++)
956 Float_t energyMeV = energykeV * 0.001;
958 if (energyMeV >= 0.001) {
1071 Int_t istat =
Locate(en, n, energyMeV, index, de);
1077 (TMath::Log(mu[index]) - de * (TMath::Log(mu[index]) - TMath::Log(mu[index + 1])) / (en[index + 1] - en[index]));
1078 return TMath::Exp(result);
1093 if (xval >= xv[n - 1])
return 1;
1094 if (xval < xv[0])
return -1;
1100 while (kh - kl > 1) {
1101 if (xval < xv[km = (kl + kh) / 2]) kh = km;
1105 if (xval < xv[kl] || xval > xv[kl + 1] || kl >= n - 1) {
1106 printf(
"Locate failed xv[%d] %f xval %f xv[%d] %f!!!\n", kl, xv[kl], xval, kl + 1, xv[kl + 1]);
1111 if (xval == 0.001) LOG(info) <<
"Locat = 0";
ClassImp(CbmConverterManager)
Container for gas properties of TRD.
Float_t(* GetMuPtr)(Float_t)
Double_t GetNobleGas() const
Double_t GetGasThick() const
static CbmTrdGas * Instance()
static constexpr Float_t fMu_c[46]
static const Int_t fKN_xe
static constexpr Float_t fMu_ka[46]
static constexpr Float_t fEn_co2[36]
static Int_t Locate(const Float_t *xv, Int_t n, Float_t xval, Int_t &kl, Float_t &dx)
Bool_t LatticeHit(const CbmTrdPoint *point)
Float_t SigmaDet(Float_t energykeV)
static const Int_t fNMom
TR passed through Detector.
static Float_t GetMuKa(Float_t energyMeV)
CbmTrdRadiator(Bool_t SimpleTR=true, Int_t Nfoils=337, Float_t FoilThick=0.0012, Float_t GapThick=0.09, TString material="pefoam20", TString window="Kapton")
Float_t Sigma(Float_t energykeV)
static constexpr Float_t fEn_c[46]
static Float_t GetMuC(Float_t energyMeV)
static Float_t GetMuPo(Float_t energyMeV)
void SetSigma(Int_t SigmaT)
static constexpr Float_t fEn_my[36]
Float_t fnTRabs[fNMom]
Absorption spectra for different momenta.
Float_t * fSigmaDet
[fSpNBins] Array of sigma values for the entrance window of detector
static const Int_t fKN_pok
static Float_t GetMuXe(Float_t energyMeV)
static const Int_t fKN_co2
static Float_t GetMuAir(Float_t energyMeV)
static constexpr Float_t fMu_my[36]
static constexpr Float_t fEn_pok[46]
CbmTrdEntranceWindow WINDOW
Float_t * fSigmaWin
[fSpNBins] Array of sigma values for the foil of the radiator
static const Int_t fKN_po
static constexpr Float_t fMu_al[48]
static constexpr Float_t fMu_pok[46]
static Float_t Interpolate(Float_t energyMeV, const Float_t *en, const Float_t *mu, Int_t n)
Float_t SigmaWin(Float_t energykeV)
static constexpr Float_t fMu_co2[36]
TH1D * fDetSpectrumA
TR spectra in gas-window foil.
TH1D * fDetSpectrum
TR absorbed in Detector.
static const Int_t fKN_ka
Float_t GetTR(TVector3 mom)
Double_t * fTrackMomentum
static constexpr Float_t fEn_ka[46]
static const Int_t fSpNBins
TH1D * fSpectrum
[fSpNBins] Array of sigma values for the active gas
TH1D * fWinSpectrum
TR photon energy spectrum.
static constexpr Float_t fMu_po[36]
static constexpr Float_t fMu_air[38]
void SetEWwidths(Int_t n, Float_t *w)
static const Int_t fSpRange
static Float_t GetMuAl(Float_t energyMeV)
static constexpr Float_t fEn_al[48]
static constexpr Float_t fEn_po[36]
static constexpr Float_t fMu_xe[48]
static const Int_t fKN_air
static Float_t GetMuMy(Float_t energyMeV)
virtual ~CbmTrdRadiator()
static constexpr Float_t fEn_xe[48]
static Float_t GetMuCO2(Float_t energyMeV)
static Float_t GetMuPok(Float_t energyMeV)
static const Int_t fKN_al
static constexpr Float_t fEn_air[38]
static const Int_t fKN_my
TH1D * fFinal[fNMom]
[fNMom] Track momenta for which spectra
GetMuPtr GetMu[NCOMPONENTS]
Float_t fThick[NCOMPONENTS]
Float_t fDens[NCOMPONENTS]
CbmTrdEntranceWindow(TString def="")