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