22 #include <FairParAsciiFileIo.h>
23 #include <FairParRootFileIo.h>
24 #include <FairRunAna.h>
25 #include <FairRuntimeDb.h>
30 #include <TGeoManager.h>
33 #include <TObjArray.h>
42 : FairTask(
"TrdParManager")
60 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
83 TGeoNode* topNode = gGeoManager->GetTopNode();
84 TObjArray* nodes = topNode->GetNodes();
85 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
86 TGeoNode* node =
static_cast<TGeoNode*
>(nodes->At(iNode));
87 if (!TString(node->GetName()).Contains(
"trd"))
89 TGeoNode* station = node;
92 TObjArray* layers = station->GetNodes();
93 for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
94 TGeoNode* layer =
static_cast<TGeoNode*
>(layers->At(iLayer));
95 if (!TString(layer->GetName()).Contains(
"layer"))
98 TObjArray* modules = layer->GetNodes();
99 for (Int_t iModule = 0; iModule < modules->GetEntriesFast(); iModule++) {
100 TGeoNode* module =
static_cast<TGeoNode*
>(modules->At(iModule));
101 TObjArray* parts = module->GetNodes();
102 for (Int_t iPart = 0; iPart < parts->GetEntriesFast(); iPart++) {
103 TGeoNode* part =
static_cast<TGeoNode*
>(parts->At(iPart));
104 if (!TString(part->GetName()).BeginsWith(
"gas_"))
111 TString path = TString(
"/") + topNode->GetName() +
"/"
112 + station->GetName() +
"/" + layer->GetName() +
"/"
113 + module->GetName() +
"/" + part->GetName();
125 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
156 printf(
"\nCbmTrdParManager::CreateModuleParameters(%s) type[%d]\n",
164 printf(
" sec[%d] dx[%5.2f] dy[%5.2f] px[%5.2f] py[%5.2f]\n",
214 if (moduleType >= 9) {
217 Form(
"Fasp set for Module %d", moduleAddress) );
222 Int_t iasic(0), ncol(digi->
GetNofColumns()), asicAddress, chAddress;
224 for (Int_t r(0); r < digi->
GetNofRows(); r++) {
225 for (Int_t c(0); c < ncol; c++) {
227 if (asic) asics->
SetAsicPar(asicAddress, asic);
228 asicAddress = moduleAddress * 1000 + iasic;
232 for (Int_t ipair(0); ipair < 2; ipair++) {
233 par[0] = gRandom->Gaus(300, 4);
234 par[2] = gRandom->Gaus(600, 40);
235 par[3] = gRandom->Gaus(2580, 10);
236 chAddress = 2 * (r * ncol + c) + ipair;
244 if (asic) asics->
SetAsicPar(asicAddress, asic);
247 "TrdParModSpadic", Form(
"Spadic set for Module %d", moduleAddress));
254 Int_t nModuleChannels(nModuleColumns * nModuleRows);
256 Int_t nAsicsAlongColumns(-1);
258 std::vector<Int_t> chAddressesVec;
259 for (Int_t iAsic = 0;
269 nAsicsAlongColumns = nModuleColumns < nModuleRows
271 : nModuleColumns / (nAsicChannels / 2);
274 Int_t nThAsicRow(iAsic / nAsicsAlongColumns);
276 Int_t nThAsicColumn(iAsic % nAsicsAlongColumns);
278 chAddressesVec.clear();
279 chAddressesVec.resize(nAsicChannels);
283 for (
auto channelAddress : chAddressesVec) {
289 if ((channelAddress / (nAsicChannels / 2)) > 0) {
291 channelAddress -= (nAsicChannels / 2);
293 channelAddress += nModuleColumns;
297 nThAsicColumn * nAsicChannels / 2;
300 nThAsicRow * nModuleColumns * 2;
303 if (orientation == 2) {
304 channelAddress *= (-1);
305 channelAddress += (nModuleChannels - 1);
307 chAddressesVec.at(iAsicChannel) = channelAddress;
324 if (moduleType >= 9) {
326 Form(
"Module/%d/Ua/%d/Ud/%d/Gas/Xe", moduleAddress, 1900, 500));
331 Form(
"Module/%d/Ua/%d/Ud/%d/Gas/Xe", moduleAddress, 1600, 500));
353 FairRunAna* run = FairRunAna::Instance();
354 FairRuntimeDb* rtdb = run->GetRuntimeDb();
358 TString inputDirectory = run->GetGeoFile()->GetName();
359 inputDirectory.Resize((inputDirectory.Last(
'/') + 1));
360 TString geoName = run->GetGeoFile()->GetName();
361 geoName.ReplaceAll(inputDirectory.Data(),
"");
362 geoName.ReplaceAll(
"geofile_",
"");
363 geoName.ReplaceAll(
".root",
"");
365 if (outDir.IsNull()) {
366 outDir = Form(
"%s/../src/parameters/trd", getenv(
"CBM_ROOT"));
369 TList* containerList = rtdb->getListOfContainers();
371 TString currentPar =
"";
373 FairParRootFileIo parOut;
374 parOut.open(Form(
"%s/%s.par.root", outDir.Data(), geoName.Data()),
376 rtdb->setOutput(&parOut);
378 for (
auto iContainerIt : *containerList) {
379 currentPar = iContainerIt->GetName();
380 if (!currentPar.Contains(
"CbmTrd"))
383 currentContainer->setChanged();
384 currentContainer->setInputVersion(0, 1);
396 FairRunAna* run = FairRunAna::Instance();
397 FairRuntimeDb* rtdb = run->GetRuntimeDb();
401 TString inputDirectory = run->GetGeoFile()->GetName();
402 inputDirectory.Resize((inputDirectory.Last(
'/') + 1));
403 TString geoName = run->GetGeoFile()->GetName();
404 geoName.ReplaceAll(inputDirectory.Data(),
"");
405 geoName.ReplaceAll(
"geofile_",
"");
406 geoName.ReplaceAll(
".root",
"");
408 if (outDir.IsNull()) {
409 outDir = Form(
"%s/../src/parameters/trd", getenv(
"CBM_ROOT"));
412 TList* containerList = rtdb->getListOfContainers();
414 TString currentPar =
"";
415 TString currentFile =
"";
418 for (
auto iContainerIt : *containerList) {
419 currentPar = iContainerIt->GetName();
420 if (!currentPar.Contains(
"CbmTrd"))
423 currentPar.ReplaceAll(
"CbmTrdParSet",
"");
424 currentPar.ToLower();
426 "%s/%s.%s.par", outDir.Data(), geoName.Data(), currentPar.Data());
427 FairParAsciiFileIo parOut;
428 parOut.open(currentFile,
"out");
429 rtdb->setOutput(&parOut);
430 currentContainer->setChanged();
431 currentContainer->setInputVersion(0, 1);
445 switch (iParSetType) {
459 parSetList->emplace_back(parSet);
468 switch (iParSetType) {
470 vec->emplace_back(
"asic");
473 vec->emplace_back(
"digi");
476 vec->emplace_back(
"gas");
479 vec->emplace_back(
"gain");