CbmRoot
Loading...
Searching...
No Matches
CbmTrdParSetGas.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer], Alexandru Bercuci */
4
5#include "CbmTrdParSetGas.h"
6
7#include "CbmTrdParModGas.h" // for CbmTrdParModGas
8
9#include <FairParamList.h> // for FairParamList
10#include <Logger.h> // for Logger, LOG
11
12#include <TArrayI.h> // for TArrayI
13#include <TDirectory.h> // for TDirectory (ptr only), gDirectory
14#include <TFile.h> // for TFile, gFile
15#include <TGenericClassInfo.h> // for TGenericClassInfo
16#include <TH2.h> // for TH2F
17#include <TObjArray.h> // for TObjArray
18#include <TObjString.h> // for TObjString
19#include <TString.h> // for Form, TString
20#include <TSystem.h> // for TSystem, gSystem
21
22#include <map> // for map, map<>::iterator, operator!=, __m...
23#include <utility> // for pair
24
25CbmTrdParSetGas::CbmTrdParSetGas(const char* name, const char* title, const char* context)
26 : CbmTrdParSet(name, title, context)
27{
28}
29
30
31//_______________________________________________________________________________
32Bool_t CbmTrdParSetGas::getParams(FairParamList* l)
33{
34 if (!l) return kFALSE;
35 if (!l->fill("NrOfModules", &fNrOfModules)) return kFALSE;
36 Text_t gasMix[100];
37 if (!l->fill("Gas", gasMix, 100)) return kFALSE;
38 Text_t repo[100], pid[100];
39 if (!l->fill("RepoDrift", repo, 100)) return kFALSE;
40 if (!l->fill("RepoPid", pid, 100)) return kFALSE;
41 TFile* oldFile = gFile;
42 TDirectory* oldDir = gDirectory;
43
44 TDirectory* cwd(gDirectory);
45
46 TFile* infile = TFile::Open(Form("%s/%s", gSystem->Getenv("VMCWORKDIR"), repo));
47 if (!infile->IsOpen()) {
48 LOG(error) << "Missing TRD DriftMap Repository : " << repo;
49 gFile = oldFile;
50 gDirectory = oldDir;
51 return kFALSE;
52 }
53 else {
54 LOG(debug) << "TRD DriftMap Repository : " << gFile->GetName();
55 LOG(debug) << "TRD PID Repository : " << pid;
56 }
57
58 TArrayI moduleId(fNrOfModules);
59 if (!l->fill("ModuleIdArray", &moduleId)) return kFALSE;
60
61 TString sgas(gasMix);
62 TObjArray* so = sgas.Tokenize("_");
63 Int_t pgas = ((TObjString*) (*so)[1])->String().Atoi();
64
65 TArrayI value(4);
66 for (Int_t i = 0; i < fNrOfModules; i++) {
67 if (!l->fill(Form("%d", moduleId[i]), &value)) return kFALSE;
68 fModuleMap[moduleId[i]] = new CbmTrdParModGas(
69 Form("Module/%d/Ua/%d/Ud/%d/Gas/%s", moduleId[i], value[0], value[1], ((TObjString*) (*so)[0])->GetName()));
70 ((CbmTrdParModGas*) fModuleMap[moduleId[i]])
71 ->SetDriftMap(GetDriftMap(((TObjString*) (*so)[0])->GetName(), value[0], value[1]), cwd);
72 ((CbmTrdParModGas*) fModuleMap[moduleId[i]])->SetNobleGas(1.e-2 * pgas);
73 ((CbmTrdParModGas*) fModuleMap[moduleId[i]])->SetDetType(value[2]);
74 ((CbmTrdParModGas*) fModuleMap[moduleId[i]])->SetPidType(value[3]);
75 ((CbmTrdParModGas*) fModuleMap[moduleId[i]])->SetFileName(pid);
76
77 //if (fair::Logger::Logging(fair::Severity::debug) fModuleMap[moduleId[i]]->Print();
78 }
79 so->Delete();
80 delete so;
81
82 infile->Close();
83 delete infile;
84
85 gFile = oldFile;
86 gDirectory = oldDir;
87
88 return kTRUE;
89}
90
91//_____________________________________________________________________
92void CbmTrdParSetGas::putParams(FairParamList* l)
93{
94 if (!l) return;
95 LOG(info) << GetName() << "::putParams(FairParamList*)";
96
97 TArrayI moduleId(fNrOfModules);
98 Int_t idx(0);
99 for (std::map<Int_t, CbmTrdParMod*>::iterator imod = fModuleMap.begin(); imod != fModuleMap.end(); imod++) {
100 moduleId[idx++] = imod->first;
101 }
102 CbmTrdParModGas* mod = (CbmTrdParModGas*) fModuleMap[moduleId[0]];
103
104
105 TString repopid(mod->GetFileName().Data());
106
107 l->add("RepoDrift", "parameters/trd/CbmTrdDriftMap.root");
108 l->add("RepoPid", repopid);
109 l->add("Gas", Form("Xe_%d", Int_t(1.e2 * mod->GetNobleGas())));
110 l->add("NrOfModules", fNrOfModules);
111 l->add("ModuleIdArray", moduleId);
112
113 TArrayI values(4);
114 for (Int_t i = 0; i < fNrOfModules; i++) {
115 mod = (CbmTrdParModGas*) fModuleMap[moduleId[i]];
116 values[0] = mod->GetUanode();
117 values[1] = mod->GetUdrift();
118 values[2] = mod->GetDetType();
119 values[3] = mod->GetPidType();
120 l->add(Form("%d", moduleId[i]), values);
121 }
122}
123
124//_______________________________________________________________________________
125TH2F* CbmTrdParSetGas::GetDriftMap(const Char_t* g, const Int_t ua, const Int_t ud)
126{
127 TString smap = Form("%s_%4d_%3d", g, ua, ud);
128 TH2F* hm = gFile->Get<TH2F>(smap.Data());
129 if (hm) return hm;
130
131 LOG(debug) << GetName() << "::GetDriftMap() : Interpolate drift map for " << g << " Ua[" << ua << "]"
132 << " Ud[" << ud << "]";
133
134 return gFile->Get<TH2F>(Form("%s_1500_300", g));
135}
136
ClassImp(CbmConverterManager)
Definition of gas parameters for one TRD module.
UShort_t GetUanode() const
Int_t GetDetType() const
Int_t GetPidType() const
UShort_t GetUdrift() const
TString GetFileName() const
Double_t GetNobleGas() const
Describe TRD module working settings (HV, etc)
CbmTrdParSetGas(const char *name="CbmTrdParSetGas", const char *title="TRD chamber parameters", const char *context="Default")
TH2F * GetDriftMap(const Char_t *g, const Int_t ua, const Int_t ud)
void putParams(FairParamList *)
Bool_t getParams(FairParamList *)
std::map< Int_t, CbmTrdParMod * > fModuleMap
Int_t fNrOfModules
no of modules in the current run