11 #include <FairLogger.h>
14 #include <TGeoManager.h>
15 #include <TGeoMatrix.h>
17 #include <TGeoVolume.h>
28 : fPixelPathToAddressMap()
29 , fPixelAddressToDataMap()
49 Int_t currentPixelAddress = 1;
50 Int_t currentPmtId = 1;
53 Double_t pmtHeight = 5.2;
54 Double_t pmtWidth = 5.2;
55 TGeoVolume* pmtVolume = gGeoManager->FindVolumeFast(
"pmt");
56 if (pmtVolume ==
nullptr)
57 pmtVolume = gGeoManager->FindVolumeFast(
"pmt_vol_0");
58 if (pmtVolume !=
nullptr) {
59 const TGeoBBox*
shape = (
const TGeoBBox*) (pmtVolume->GetShape());
60 if (
shape !=
nullptr) {
61 pmtHeight = 2. *
shape->GetDY();
62 pmtWidth = 2. *
shape->GetDX();
66 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
67 geoIterator.SetTopName(
"/cave_1");
70 TString pixelNameStr(
"pmt_pixel");
72 while ((curNode = geoIterator())) {
73 TString nodeName(curNode->GetName());
75 if (TString(curNode->GetVolume()->GetName()).Contains(pixelNameStr)) {
76 geoIterator.GetPath(nodePath);
83 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
84 const Double_t* curNodeTr = curMatrix->GetTranslation();
85 string path = string(nodePath.Data());
87 size_t pmtInd = path.find_last_of(
"/");
88 if (string::npos == pmtInd)
continue;
89 string pmtPath = path.substr(0, pmtInd + 1);
92 pair<string, Int_t>(path, currentPixelAddress));
94 pixelData->
fX = curNodeTr[0];
95 pixelData->
fY = curNodeTr[1];
96 pixelData->
fZ = curNodeTr[2];
97 pixelData->
fAddress = currentPixelAddress;
99 pair<Int_t, CbmRichPixelData*>(pixelData->
fAddress, pixelData));
101 currentPixelAddress++;
107 pmtData->
fId = currentPmtId;
110 pmtData->
fWidth = pmtWidth;
112 pair<Int_t, CbmRichPmtData*>(pmtData->
fId, pmtData));
122 if (pmtData ==
nullptr || pmtId != pmtData->
fId) {
123 LOG(error) <<
"(pmtData == nullptr || pmtId != pmtData->fId) ";
129 <<
" pmtData->fId:" << pmtData->
fId
130 <<
" pmtPath:" << pmtPath << endl
138 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
139 const Double_t* curNodeTr = curMatrix->GetTranslation();
140 string path = string(nodePath.Data());
142 size_t pmtInd = path.find_last_of(
"/");
143 if (string::npos == pmtInd)
continue;
144 string pmtPath = path.substr(0, pmtInd + 1);
147 std::stoul(path.substr(pmtInd + 11));
148 Int_t posAtPmt = channel / 100;
149 channel = channel % 100;
151 size_t pmtVolInd = path.rfind(
"/", pmtInd - 1);
152 if (string::npos == pmtVolInd)
continue;
153 Int_t pmtPosBP = std::stoul(
154 path.substr(pmtVolInd + 11,
158 size_t bpInd = path.rfind(
"/", pmtVolInd - 1);
159 if (string::npos == bpInd)
continue;
160 Int_t posBP = std::stoul(
161 path.substr(bpInd + 14,
165 Int_t
x = (posBP / 10) + ((((pmtPosBP - 1) / 3) + 1) % 2);
166 Int_t
y = (posBP % 10) + (2 - ((pmtPosBP - 1) % 3));
168 Int_t DiRICH_Add = ((7 & 0xF) << 12) + ((
x & 0xF) << 8)
169 + ((
y & 0xF) << 4) + (posAtPmt & 0xF);
170 Int_t pixelUID = ((DiRICH_Add << 16) | (channel & 0x00FF));
171 Int_t pmtUID = ((
x & 0xF) << 4) + (
y & 0xF);
176 pixelData->
fX = curNodeTr[0];
177 pixelData->
fY = curNodeTr[1];
178 pixelData->
fZ = curNodeTr[2];
181 pair<Int_t, CbmRichPixelData*>(pixelData->
fAddress, pixelData));
189 pmtData->
fId = pmtUID;
192 pmtData->
fWidth = pmtWidth;
194 pair<Int_t, CbmRichPmtData*>(pmtData->
fId, pmtData));
203 if (pmtData ==
nullptr || pmtId != pmtData->
fId) {
204 LOG(error) <<
"(pmtData == nullptr || pmtId != pmtData->fId) ";
210 <<
" pmtData->fId:" << pmtData->
fId
211 <<
" pmtPath:" << pmtPath << endl
219 LOG(error) <<
"ERROR: Could not identify Detector setup!";
234 if (pixelData ==
nullptr)
continue;
235 pmtData->
fX += pixelData->
fX;
236 pmtData->
fY += pixelData->
fY;
237 pmtData->
fZ += pixelData->
fZ;
244 LOG(info) <<
"CbmRichDigiMapManager is initialized";
245 LOG(info) <<
"fPixelPathToAddressMap.size() = "
247 LOG(info) <<
"fPixelAddressToDataMap.size() = "
260 std::map<string, Int_t>::iterator it;
268 std::map<Int_t, CbmRichPixelData*>::iterator it;
276 Int_t index = gRandom->Integer(nofPixels);
289 std::map<Int_t, CbmRichPmtData*>::iterator it;
297 std::vector<Int_t>
v;
304 std::vector<Int_t>
v;
313 bool check = nodePath.Contains(
"mcbm");