9#include <FairParGenericSet.h>
10#include <FairParamList.h>
11#include <FairRunAna.h>
12#include <FairRuntimeDb.h>
17#include <TGeoElement.h>
18#include <TGeoManager.h>
30 TGeoNode* topNode = gGeoManager->GetTopNode();
31 TObjArray* nodes = topNode->GetNodes();
32 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
33 TGeoNode* trdGeo =
static_cast<TGeoNode*
>(nodes->At(iNode));
34 if (
string(trdGeo->GetName()).find(
"trd") != 0)
continue;
38 string uname =
"John Doe", ucontact =
"not-defined", udescr =
"not-defined";
40 auto uinfo = gSystem->GetUserInfo(gSystem->GetEffectiveUid());
42 LOG(warning) <<
"Couldn't read user_name.";
44 uname = uinfo->fRealName;
46 LOG(warning) <<
"No contact info were provided for responsible " << uname;
50 LOG(error) <<
"No comments provided for setup. Please add them by SetupManager::SetDescription()";
59 uname += d.AsString();
65 TObjArray* layers = trdGeo->GetNodes();
66 for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
67 TGeoNode* lyGeo =
static_cast<TGeoNode*
>(layers->At(iLayer));
68 if (
string(lyGeo->GetName()).find(
"layer") != 0)
continue;
70 TObjArray* modules = lyGeo->GetNodes();
71 for (Int_t iModule = 0; iModule < modules->GetEntriesFast(); iModule++) {
72 TGeoNode* modGeo =
static_cast<TGeoNode*
>(modules->At(iModule));
74 if (
string(modGeo->GetName()).find(
"module") != 0)
continue;
76 LOG(info) <<
" Reading module " << modGeo->GetName() <<
" [" << lyGeo->GetName() <<
"].";
77 stat = modSetup.
init(modGeo);
79 case kERROR:
continue;
80 case kFATAL: LOG(fatal) << GetName() <<
" Couldn't process geometry file.";
break;
93 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
100 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
101 fSetup = (
Setup*) (rtdb->getContainer(
"TrdSetup"));
106Setup::Setup(
const char* n,
const char* t) : FairParGenericSet(n, t,
"default")
121 LOG(warning) <<
"Number of info fields " << ii <<
" less than required (" <<
fMetaFields.size()
122 <<
"). Info might be spoiled. Check input.\n";
125 for (
auto info :
fMeta) {
126 if (strcmp(info.second.data(),
"") != 0)
continue;
127 Help(info.first.data());
139 return fMeta.at(label).data();
145 LOG(info) <<
"* meta info; list of \";\" separated information in the following order:";
146 LOG(info) <<
"* - \"name\" : responsible person's name";
147 LOG(info) <<
"* - \"email\" : responsible person's email";
148 LOG(info) <<
"* - \"date\" : date of creation";
152 LOG(error) <<
"Meta info \"" <<
lab <<
"\" not defined.\n";
154 LOG(warning) <<
"Meta info for\"" <<
lab <<
"\" not registered.\n";
162 string s(GetTitle());
163 char* p = strtok(s.data(),
";");
166 p = strtok(
nullptr,
";");
178 uint16_t
id =
fModule[i]->GetModuleId();
189 if (mod->GetModuleId() == detId)
return mod;
196 if (!l)
return false;
197 if (!l->fill(
"Version", &
fVersion)) {
198 LOG(error) << GetName() <<
"::getParams : Couldn't find \"Version\"";
202 if (!l->fill(
"NrOfModules", &nmods)) {
203 LOG(error) << GetName() <<
"::getParams : Couldn't find \"NrOfModules\"";
206 TArrayI modId(nmods), typId(nmods), rot(nmods);
207 if (!l->fill(
"Trd.Id", &modId)) {
208 LOG(error) << GetName() <<
"::getParams : Couldn't find \"Trd.Id\"";
211 if (!l->fill(
"Trd.Type", &typId)) {
212 LOG(error) << GetName() <<
"::getParams : Couldn't find \"Trd.Type\"";
215 if (!l->fill(
"Trd.Rot", &rot)) {
216 LOG(error) << GetName() <<
"::getParams : Couldn't find \"Trd.Rot\"";
220 if (!l->fill(
"Trd.Gas", textIn, 100)) {
221 LOG(error) << GetName() <<
"::getParams : Couldn't find \"Trd.Gas\"";
224 if (textIn[0] ==
'A' && textIn[1] ==
'r')
229 for (
int imod(0); imod < nmods; imod++) {
230 fModule.push_back(
new Module(Form(
"Trd%s.%d", (modId[imod] < 0 ?
"2D" :
"1D"), abs(modId[imod])), GetTitle()));
232 mod->fType = typId[imod];
233 mod->fRot = rot[imod];
246 l->add(
"NrOfModules", nmods);
247 TArrayI modId(nmods), typId(nmods), rot(nmods);
249 modId[ii] = mod->GetModuleId() * (mod->GetFamily() ==
ePadPlane::k1d ? 1 : -1);
250 typId[ii] = mod->GetType();
251 rot[ii] = mod->GetRotation();
254 l->add(
"Trd.Id", modId);
255 l->add(
"Trd.Type", typId);
256 l->add(
"Trd.Rot", rot);
258 l->add(
"Trd.Gas",
"ArCO2");
260 l->add(
"Trd.Gas",
"XeCO2");
298 bool hasRadiator(
false);
302 TObjArray* components = n->GetNodes();
303 for (Int_t icomp = 0; icomp < components->GetEntriesFast(); icomp++) {
304 TGeoNode* comp =
static_cast<TGeoNode*
>(components->At(icomp));
305 string cname(comp->GetName());
308 LOG(debug4) << GetName() <<
" Initialize " << comp->GetName() <<
" with "
313 LOG(debug4) << GetName() <<
" Initialize " << comp->GetName() <<
" with "
318 int selectFeature(0);
319 TIter ipcs(comp->GetNodes());
320 while (
auto pcs = (TGeoNode*) ipcs()) {
321 if (
string(pcs->GetName()).find(
"winIn_C") == 0)
323 else if (
string(pcs->GetName()).find(
"winIn_HC") == 0)
326 if (selectFeature == 2)
331 LOG(info) << GetName() <<
" Initialize TR absorption in " << (fWindow ==
eWindow::kThick ?
"thick" :
"thin")
332 <<
" entrance window.";
336 LOG(debug4) << GetName() <<
" Initialize " << comp->GetName() <<
" with "
339 auto gas = (TGeoNode*) comp->GetNodes()->FindObject(
"gas_0");
341 LOG(error) << GetName() <<
" Couldn't find \"gas_0\" in " << comp->GetName();
343 auto activeGas = gas->GetMedium()->GetMaterial();
344 for (
int imat(0); imat < activeGas->GetNelements(); imat++) {
345 auto elem = activeGas->GetElement(imat);
357 LOG(error) << GetName() <<
" Couldn't found element in active gas from " << comp->GetName();
363 LOG(warning) << GetName() <<
" Couldn't identify active gas type. Use legacy mode.";
366 LOG(info) << GetName() <<
" Initialize active gas to " << (
fGas ==
eGas::kXe ?
"XeCO2." :
"ArCO2.");
369 LOG(debug4) << GetName() <<
" Initialize " << comp->GetName() <<
" with "
372 TIter ibkp(comp->GetNodes());
373 while (
auto bkp = (TGeoNode*) ibkp()) {
374 if (
string(bkp->GetName()).find(
"pp_pcb2d") == 0) {
376 SetName(Form(
"Trd2D.%d", info.
address));
379 else if (
string(bkp->GetName()).find(
"pp_pcb1d") == 0) {
381 SetName(Form(
"Trd1D.%d", info.
address));
386 LOG(error) << GetName() <<
" Couldn't identify TRD module family for " << n->GetName() <<
" " << n->GetTitle();
389 LOG(info) << GetName() <<
" Initialize TRD family to " << (fFamily ==
ePadPlane::k2d ?
"2D." :
"1D;");
392 LOG(info) << GetName() <<
" Initialize " << comp->GetName() <<
" with "
395 if (!
ReadFebInfo(comp->GetName(), info))
return kERROR;
398 LOG(info) << GetName() <<
"Geometry of module " << n->GetName() <<
" uses legacy setup.";
419 TArrayI daqId(fDaq.size());
422 l->add(Form(
"%s.DaqInfo", GetName()), daqId);
425 auto pads = fFEE[0]->GetPads();
426 TArrayI asicSetup(fFEE.size() * (pads.size() + 2));
427 for (
auto asic : fFEE) {
428 asicSetup[ii++] = asic->GetId();
429 asicSetup[ii++] = asic->GetMask();
430 pads = asic->GetPads();
431 for (
auto pad : pads)
432 asicSetup[ii++] = pad;
434 l->add(Form(
"%s.%sInfo", GetName(), (fFee ==
eAsic::kSpadic ?
"Spadic" :
"Fasp")), asicSetup);
442 int ndaq = pMod.
ndaq;
443 int nasic = pMod.
nasic;
446 if (!l->fill(Form(
"%s.DaqInfo", GetName()), &daqId)) {
447 LOG(error) << GetName() <<
"::getParams : Couldn't find \"DaqInfo\"";
450 fDaq.assign(daqId.GetArray(), daqId.GetArray() + ndaq);
452 TArrayI asicInfo(nasic);
453 if (!l->fill(Form(
"%s.SpadicInfo", GetName()), &asicInfo)) fFee =
eAsic::kSpadic;
454 if (!l->fill(Form(
"%s.FaspInfo", GetName()), &asicInfo))
457 LOG(error) << GetName() <<
"::getParams : Couldn't find \"AsicInfo\"";
460 for (
int i(0), k(0); i < nasic; i++) {
461 fFEE.push_back(
new Asic(Form(
"%s%d", (fFee ==
eAsic::kSpadic ?
"Spadic" :
"Fasp"), i), GetName()));
462 auto asic = fFEE.back();
463 asic->fUnique = asicInfo[k++];
464 asic->fMask = asicInfo[k++];
465 asic->fPad.assign(&asicInfo[k], &asicInfo[k + nch]);
478 if (name.find(
"Spadic") == 0) {
482 fId = stoi(name.substr(nskip, 10));
ClassImp(CbmConverterManager)
Builder class for the TRD chamber geometry.
Describing class of the TRD setup geometry, FEE, gas.
static const char * fgName[(int) eGeoPart::kNparts]
Generate setup meta info for the TRD system.
string fDescription
further description of the current setup
Setup * fSetup
the setup object
virtual void Finish()
Inherited from FairTask.
string fContact
contact info (usual email) of the responsible
virtual InitStatus Init()
Inherited from FairTask.
virtual void SetParContainers()
Inherited from FairTask.
string fGeoTag
the setup name
Meta info for one TRD ASIC.
Asic(const char *n, const char *t)
uint8_t fId
ASIC id in the chamber.
Meta info for one TRD module.
int fRot
rotation of chamber in steps of 90 deg
ePadPlane fFamily
Chamber family (1D / 2D)
virtual void putParams(FairParamList *)
Write out the setup from object to FairParamList.
int fFeeType
FEB type for each FEE version.
uint16_t fId
TRD chamber id in the setup.
virtual InitStatus init(TGeoNode *)
Read info relevant for the module from the geometry.
int fType
TRD chamber sub-type (e.g. 1, 3, 5, 7 for TRD1D)
Module(const char *n="", const char *t="")
eWindow fWindow
Entrance window type.
eAsic fFee
ASIC family (SPADIC/FASP)
virtual bool getParams(FairParamList *)
Read in the setup from FairParamList.
Setup meta info for the TRD system to supplement the geometry.
virtual const Module * GetModulePar(int detId) const
Get module par by detector id.
virtual void addParam(Module *mod)
void Help(const char *lab=nullptr) const
Help message for user.
vector< Module * > fModule
list of modules defined in the setup
Setup(const char *n, const char *t)
Setup descriptor for the TRD setup. The identification should be :
map< string, string > fMeta
meta info attached to this setup
virtual int GetModuleId(int i) const
Get module par by index.
virtual bool getParams(FairParamList *)
Read in the setup from FairParamList.
virtual void putParams(FairParamList *)
Write out the setup from object to FairParamList.
vector< string > fMetaFields
ordered list of meta info types
virtual const char * GetInfo(const char *label) const
Retrieve meta info for the setup according to label.
virtual size_t GetNrOfModules() const
Retrieve no of modules in the setup.
size_t Parse()
Parse setup description for meta info.
bool ReadModuleInfo(const char *modTxt, info_t &info)
Identify information related to the module encrypted in the geoManager path. Based on legacy function...
bool ReadFebInfo(const char *febTxt, info_t &info)
Identify information related to one FEB encrypted in the geoManager path.
static constexpr FEB faspFeb[2]
@ kNotSet
active gas not set / recognized
@ kNotSet
window not set / recognized
@ kThin
1D case (Al+mylar)
@ kThick
2D case (Kapton + C + HC)
@ kNotSet
pad=plane not set / recognized
static const READOUT mod2D[3]
@ kSpadic
SPADIC type definition.
@ kFasp
FASP ASIC definition.
int nchannels
no of channels / asic
int ndaq
no of concentrators (e.g. CROB) to read-out the pad-plane
int nasic
no of ASICs to read-out the pad-plane
Information to be storred in the geoManager path. Based on legacy class CbmTrdGeoHandler.