29#include <FairParAsciiFileIo.h>
30#include <FairParRootFileIo.h>
31#include <FairRunAna.h>
32#include <FairRuntimeDb.h>
37#include <TGeoManager.h>
51 : FairTask(
"TrdParManager")
72 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
97 TGeoNode* topNode = gGeoManager->GetTopNode();
98 TObjArray* nodes = topNode->GetNodes();
99 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
100 TGeoNode* node =
static_cast<TGeoNode*
>(nodes->At(iNode));
101 if (!TString(node->GetName()).Contains(
"trd"))
continue;
102 TGeoNode* station = node;
105 TObjArray* layers = station->GetNodes();
106 for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
107 TGeoNode* layer =
static_cast<TGeoNode*
>(layers->At(iLayer));
108 if (!TString(layer->GetName()).Contains(
"layer"))
continue;
110 TObjArray* modules = layer->GetNodes();
111 for (Int_t iModule = 0; iModule < modules->GetEntriesFast(); iModule++) {
112 TGeoNode* module =
static_cast<TGeoNode*
>(modules->At(iModule));
113 TObjArray* parts =
module->GetNodes();
114 for (Int_t iPart = 0; iPart < parts->GetEntriesFast(); iPart++) {
115 TGeoNode* part =
static_cast<TGeoNode*
>(parts->At(iPart));
116 if (!TString(part->GetName()).BeginsWith(
"gas_"))
continue;
122 TString path = TString(
"/") + topNode->GetName() +
"/" + station->GetName() +
"/" + layer->GetName() +
"/"
123 +
module->GetName() + "/" + part->GetName();
136 printf(
"CbmTrdParManager::Finish()\n");
137 FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
169 printf(
"\nCbmTrdParManager::CreateModuleParameters(%s) type[%d]\n", path.Data(), moduleType);
179 printf(
" sec[%d] dx[%5.2f] dy[%5.2f] px[%5.2f] py[%5.2f]\n", i, sectorSizeX[i], sectorSizeY[i], padSizeX[i],
201 sectorSizeY, padSizeX, padSizeY);
202 if (moduleType >= 9) {
214 if (moduleType >= 9) {
215 asics =
new CbmTrdParModAsic(Form(
"FaspPars%03d", moduleAddress), Form(
"Fasp set for Module %d", moduleAddress));
220 Int_t iasic(0), ncol(digi->
GetNofColumns()), asicAddress, chAddress;
222 for (Int_t r(0); r < digi->
GetNofRows(); r++) {
223 for (Int_t c(0); c < ncol; c++) {
226 asicAddress = moduleAddress * 1000 + iasic;
230 for (Int_t ipair(0); ipair < 2; ipair++) {
231 par[0] = gRandom->Gaus(300, 4);
232 par[2] = gRandom->Gaus(600, 40);
233 par[3] = gRandom->Gaus(2580, 10);
234 chAddress = 2 * (r * ncol + c) + ipair;
245 asics =
new CbmTrdParModAsic(
"TrdParModSpadic", Form(
"Spadic set for Module %d", moduleAddress));
252 Int_t nModuleChannels(nModuleColumns * nModuleRows);
254 Int_t nAsicsAlongColumns(-1);
256 std::vector<Int_t> chAddressesVec;
265 nAsicsAlongColumns = nModuleColumns < nModuleRows ? nModuleRows / 2 : nModuleColumns / (nAsicChannels / 2);
268 Int_t nThAsicRow(iAsic / nAsicsAlongColumns);
270 Int_t nThAsicColumn(iAsic % nAsicsAlongColumns);
272 chAddressesVec.clear();
273 chAddressesVec.resize(nAsicChannels);
275 Int_t iAsicChannel = 0;
276 for (
auto channelAddress : chAddressesVec) {
281 if ((channelAddress / (nAsicChannels / 2)) > 0) {
283 channelAddress -= (nAsicChannels / 2);
285 channelAddress += nModuleColumns;
288 channelAddress += nThAsicColumn * nAsicChannels / 2;
290 channelAddress += nThAsicRow * nModuleColumns * 2;
293 if (orientation == 2) {
294 channelAddress *= (-1);
295 channelAddress += (nModuleChannels - 1);
297 chAddressesVec.at(iAsicChannel) = channelAddress;
313 if (moduleType >= 9) {
314 gas =
new CbmTrdParModGas(Form(
"Module/%d/Ua/%d/Ud/%d/Gas/Xe", moduleAddress, 1900, 500));
319 gas =
new CbmTrdParModGas(Form(
"Module/%d/Ua/%d/Ud/%d/Gas/Xe", moduleAddress, 1600, 500));
340 FairRunAna* run = FairRunAna::Instance();
341 FairRuntimeDb* rtdb = run->GetRuntimeDb();
345 TString inputDirectory = run->GetGeoFile()->GetName();
346 inputDirectory.Resize((inputDirectory.Last(
'/') + 1));
347 TString geoName = run->GetGeoFile()->GetName();
348 geoName.ReplaceAll(inputDirectory.Data(),
"");
349 geoName.ReplaceAll(
"geofile_",
"");
350 geoName.ReplaceAll(
".root",
"");
352 if (outDir.IsNull()) { outDir = Form(
"%s/../src/parameters/trd", getenv(
"CBM_ROOT")); }
354 TList* containerList = rtdb->getListOfContainers();
356 TString currentPar =
"";
358 FairParRootFileIo parOut;
359 parOut.open(Form(
"%s/%s.par.root", outDir.Data(), geoName.Data()),
"RECREATE");
360 rtdb->setOutput(&parOut);
362 for (
auto iContainerIt : *containerList) {
363 currentPar = iContainerIt->GetName();
364 if (!currentPar.Contains(
"CbmTrd"))
continue;
366 currentContainer->setChanged();
367 currentContainer->setInputVersion(0, 1);
380 FairRunAna* run = FairRunAna::Instance();
381 FairRuntimeDb* rtdb = run->GetRuntimeDb();
385 TString inputDirectory = run->GetGeoFile()->GetName();
386 inputDirectory.Resize((inputDirectory.Last(
'/') + 1));
387 TString geoName = run->GetGeoFile()->GetName();
388 geoName.ReplaceAll(inputDirectory.Data(),
"");
389 geoName.ReplaceAll(
"geofile_",
"");
390 geoName.ReplaceAll(
".root",
"");
392 if (outDir.IsNull()) { outDir = Form(
"%s/../src/parameters/trd", getenv(
"CBM_ROOT")); }
394 TList* containerList = rtdb->getListOfContainers();
396 TString currentPar =
"";
397 TString currentFile =
"";
400 for (
auto iContainerIt : *containerList) {
401 currentPar = iContainerIt->GetName();
402 if (!currentPar.Contains(
"CbmTrd"))
continue;
404 currentPar.ReplaceAll(
"CbmTrdParSet",
"");
405 currentPar.ToLower();
406 currentFile.Form(
"%s/%s.%s.par", outDir.Data(), geoName.Data(), currentPar.Data());
407 FairParAsciiFileIo parOut;
408 parOut.open(currentFile,
"out");
409 rtdb->setOutput(&parOut);
410 currentContainer->setChanged();
411 currentContainer->setInputVersion(0, 1);
422 std::shared_ptr<CbmTrdParSet> parSet =
nullptr;
424 switch (iParSetType) {
431 parSetList->emplace_back(parSet);
439 switch (iParSetType) {
ClassImp(CbmConverterManager)
Helper class to extract information from the GeoManager.
Float_t fst1_pad_type[10][3][4]
Assign pad layout to TRD Modules.
Double_t GetY(const TString &path)
Int_t GetModuleType(const TString &path)
Double_t GetSizeX(const TString &path)
Double_t GetSizeZ(const TString &path)
Double_t GetSizeY(const TString &path)
Double_t GetZ(const TString &path)
Double_t GetX(const TString &path)
Int_t GetModuleOrientation(const TString &path)
Return pad orientation of the current node in the TGeoManager.
Int_t GetModuleAddress()
Return module address calculated based on the current node in the TGeoManager.
void SelectComponentIdMap(ECbmTrdHardwareSetupVersion hwSetup)
size_t GetComponentId(Int_t asicAddress, ECbmTrdHardwareSetupVersion hwSetup)
Retrieve componentId of the asic add the passed address for the passed hwSetup.
virtual Int_t QueryChannel(Int_t ch) const
Query ASIC for specific pad address.
virtual void SetComponentId(size_t id)
virtual Int_t GetAddress() const
virtual void SetChannelAddress(Int_t address)
virtual void SetChannelAddresses(std::vector< Int_t > addresses)
Definition of FASP parameters.
virtual Bool_t SetCalibParameters(Int_t ch, Double_t const *par)
Load FASP calibration parameters for a specific channel.
Manipulate calibration parameters for the TRD detectors.
static void GetParFileExtensions(std::vector< std::string > *vec)
virtual void SetParContainers()
Inherited from FairTask.
CbmTrdParSetDigi * fDigiPar
The set of read-out description parameters.
bool CreateParFilesFromGeometry(bool createRootFileOutput, TString outDir="")
Create parameter files from geometry in gGeoManager A run macro can be found in the trd cbm....
CbmTrdParSetGeo * fGeoPar
The set of gain conversion parameters.
void CreateModuleParameters(const TString &path)
virtual void Finish()
Inherited from FairTask.
CbmTrdParManager(Bool_t fasp=kFALSE)
enumerator for organising the existing parameter sets of the trd
static void GetParSetList(std::vector< std::shared_ptr< CbmTrdParSet > > *parSetList)
virtual InitStatus Init()
Inherited from FairTask.
virtual ~CbmTrdParManager()
Destructor.
CbmTrdParSetGas * fGasPar
The set of gas description parameters.
CbmTrdParSetAsic * fAsicPar
The set of ASIC characterization parameters.
CbmTrdGeoHandler * fGeoHandler
CbmTrdHardwareSetupR fHardwareSetup
virtual void Exec(Option_t *option)
Inherited from FairTask.
CbmTrdParSetGain * fGainPar
The set of gain conversion parameters.
Describe TRD module ASIC settings (electronic gain, delays, etc)
virtual void SetChamberType(Int_t t)
virtual void Print(Option_t *opt="") const
virtual void SetAsicPar(CbmTrdParAsic *p)
Initialize the ASIC parameters for DAQ id It applies to the list of ASICs.
Definition of chamber gain conversion for one TRD module.
void Print(Option_t *opt="") const
void SetAnodeWireToPadPlaneDistance(Double_t d)
void SetAnodeWireOffset(Double_t off)
void SetAnodeWireSpacing(Double_t dw)
Int_t GetNofColumns() const
Definition of gain parameters for one TRD module.
Definition of gas parameters for one TRD module.
void SetDetType(Int_t gsi=0)
void SetPidType(Int_t like=1)
virtual void Print(Option_t *opt="") const
Definition of geometry for one TRD module.
virtual void SetModuleId(int m)
Describe TRD module ASIC settings (electronic gain, delays, etc)
Describe TRD module working settings (HV, etc)
virtual void Print(Option_t *opt="") const
virtual void addParam(CbmTrdParMod *mod)
Definition of SPADIC parameters.
virtual Int_t GetNchannels() const
static Int_t GetNasicsOnModule(Int_t moduleType)
Returns the number of asics on a given moduleType defined in eCbmTrdModuleTypes.
Int_t GetAsicChAddress(const Int_t asicChannel)
Returns the nth asic Channel in asic coordinates in single asic padplane coordinates....