Skip to content

Commit 5dd01d9

Browse files
jdbriceCopilot
andauthored
STGC DB fix for Run22 production (#776)
This PR fixes an error found in the production (Run22) tests. Two issues were identified: - The `fttDataWindows` table incorrectly used an octet for the id field, (needs a short) -> update to use `fttDataWindowsB` with fix - Mix up of two different hardware mapping systems (geometry based vs. hardware based). Update to use correct hardware based indexing Test-case, run production test chain: root4star -b -q -l 'bfc.C(5,"pp2022a,StiCA,fst,ftt,ImpBToFt0Mode","st_physics_23010027_raw_1000015.daq")' verify no messages like: StFttClusterMaker:WARN - StFttClusterMaker::PassTimeCut - Unknown hit time mode from database: -1717986919 --------- Co-authored-by: Copilot <[email protected]>
1 parent f4d4b69 commit 5dd01d9

File tree

4 files changed

+73
-41
lines changed

4 files changed

+73
-41
lines changed

StRoot/StFttDbMaker/StFttDb.cxx

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <math.h>
1515

1616
#include "tables/St_fttHardwareMap_Table.h"
17-
#include "tables/St_fttDataWindows_Table.h"
17+
#include "tables/St_fttDataWindowsB_Table.h"
1818

1919

2020
ClassImp(StFttDb)
@@ -66,12 +66,59 @@ size_t StFttDb::uuid( StFttRawHit * h, bool includeStrip ) {
6666

6767
size_t StFttDb::uuid( StFttCluster * c ) {
6868
// this UUID is not really universally unique
69-
// it is unique up to the hardware location
69+
// it is unique up to the hardware location
7070

7171
size_t _uuid = (size_t)c->orientation() + (nStripOrientations) * ( c->row() + nRowsPerQuad * ( c->quadrant() + nQuadPerPlane * c->plane() ) );
7272
return _uuid;
7373
}
7474

75+
size_t StFttDb::vmmId( StFttRawHit * h ) {
76+
// Calculate VMM hardware ID based on electronic readout structure
77+
// VMM_ID = vmm + nVMMPerFob * (feb + nFobPerQuad * (quadrant + nQuadPerPlane * plane))
78+
// Where: plane [0-3], quadrant [0-3], feb [0-5], vmm [0-3]
79+
// Valid range: 0-383 (total of 384 VMMs)
80+
81+
u_char iPlane = h->sector() - 1; // sector is 1-based
82+
u_char iQuad = h->rdo() - 1; // rdo is 1-based
83+
u_char iFeb = h->feb(); // feb is 0-based
84+
u_char iVmm = h->vmm(); // vmm is 0-based
85+
86+
size_t vmm_id = iVmm + nVMMPerFob * ( iFeb + nFobPerQuad * ( iQuad + nQuadPerPlane * iPlane ) );
87+
88+
return vmm_id;
89+
}
90+
91+
92+
void StFttDb::getTimeCut( StFttRawHit * hit, int &mode, int &l, int &h ){
93+
mode = mTimeCutMode;
94+
l = mTimeCutLow;
95+
h = mTimeCutHigh;
96+
if (mUserDefinedTimeCut)
97+
return;
98+
99+
// load calibrated data windows from DB
100+
// NOTE: dwMap is indexed by VMM hardware ID, not geometric UUID
101+
size_t hit_vmmid = vmmId( hit );
102+
103+
// Validate VMM ID is in expected range
104+
if ( hit_vmmid >= nVMM ) {
105+
LOG_WARN << "StFttDb::getTimeCut - VMM ID out of range: " << hit_vmmid
106+
<< " (max=" << (nVMM-1) << ")" << endm;
107+
LOG_WARN << " Hit: plane=" << (int)plane(hit)
108+
<< " quad=" << (int)quadrant(hit)
109+
<< " feb=" << (int)hit->feb()
110+
<< " vmm=" << (int)hit->vmm() << endm;
111+
return;
112+
}
113+
114+
if ( dwMap.count( hit_vmmid ) ){
115+
mode = dwMap[ hit_vmmid ].mode;
116+
l = dwMap[ hit_vmmid ].min;
117+
h = dwMap[ hit_vmmid ].max;
118+
}
119+
120+
}
121+
75122

76123
uint16_t StFttDb::packKey( int feb, int vmm, int ch ) const{
77124
// feb = [1 - 6] = 3 bits
@@ -96,15 +143,15 @@ void StFttDb::unpackVal( int val, int &row, int &strip ) const{
96143
return;
97144
}
98145

99-
void StFttDb::loadDataWindowsFromDb( St_fttDataWindows * dataset ) {
146+
void StFttDb::loadDataWindowsFromDb( St_fttDataWindowsB * dataset ) {
100147
if (dataset) {
101148
Int_t rows = dataset->GetNRows();
102149

103150
if ( !rows ) return;
104151

105152
dwMap.clear();
106153

107-
fttDataWindows_st *table = dataset->GetTable();
154+
fttDataWindowsB_st *table = dataset->GetTable();
108155
for (Int_t i = 0; i < rows; i++) {
109156
for ( int j = 0; j < StFttDb::nVMM; j++ ) {
110157
// printf( "[feb=%d, vmm=%d, ch=%d] ==> [row=%d, strip%d]\n", table[i].feb[j], table[i].vmm[j], table[i].vmm_ch[j], table[i].row[j], table[i].strip[j] );
@@ -122,19 +169,16 @@ void StFttDb::loadDataWindowsFromDb( St_fttDataWindows * dataset ) {
122169
fdw.anchor = table[i].anchor[j];
123170
dwMap[ fdw.uuid ] = fdw;
124171

125-
126172
// std::cout << (int)table[i].feb[j] << std::endl;
127173
}
128174
// sample output of first member variable
129175
}
130176
} else {
131-
std::cout << "ERROR: dataset does not contain requested table" << std::endl;
177+
LOG_ERROR << "dataset does not contain requested table" << endm;
132178
}
133179
}
134180

135181
void StFttDb::loadDataWindowsFromFile( std::string fn ) {
136-
137-
138182
}
139183

140184

@@ -224,7 +268,7 @@ UChar_t StFttDb::getOrientation( int rob, int feb, int vmm, int row ) const {
224268
}
225269

226270
if ( rob % 2 == 0 ){ // even rob
227-
if ( feb % 2 != 0 ) { // odd
271+
if ( feb % 2 == 0 ) { // even feb
228272
// row 3 and 4 are always diagonal
229273
if ( 3 == row || 4 == row )
230274
return kFttDiagonalH;
@@ -237,7 +281,7 @@ UChar_t StFttDb::getOrientation( int rob, int feb, int vmm, int row ) const {
237281
return kFttVertical;
238282
} else { // odd rob
239283

240-
if ( feb % 2 != 0 ) { // odd
284+
if ( feb % 2 == 0 ) { // even feb
241285
// row 3 and 4 are always diagonal
242286
if ( 3 == row || 4 == row )
243287
return kFttDiagonalV;
@@ -250,6 +294,9 @@ UChar_t StFttDb::getOrientation( int rob, int feb, int vmm, int row ) const {
250294
return kFttHorizontal;
251295
}
252296
// should never get here!
297+
if ( mDebug ) {
298+
LOG_DEBUG << "kFttUnknownOrientation = " << kFttUnknownOrientation << endm;
299+
}
253300
return kFttUnknownOrientation;
254301
}
255302

@@ -344,7 +391,7 @@ void StFttDb::getGloablOffset( UChar_t plane, UChar_t quad,
344391

345392
// shifts
346393
dx = 0.0;
347-
dy = 0.0;
394+
dy = 6.0;
348395
dz = 0.0;
349396

350397
if ( plane < 4 )

StRoot/StFttDbMaker/StFttDb.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class StFttCluster;
2222
class StFttPoint;
2323

2424
struct FttDataWindow {
25-
UChar_t uuid;
25+
Short_t uuid;
2626
UChar_t mode;
2727
Short_t min;
2828
Short_t max;
@@ -31,7 +31,7 @@ struct FttDataWindow {
3131

3232

3333
class St_fttHardwareMap;
34-
class St_fttDataWindows;
34+
class St_fttDataWindowsB;
3535

3636
class StFttDb : public TDataSet {
3737

@@ -49,6 +49,7 @@ class StFttDb : public TDataSet {
4949

5050
static size_t uuid( StFttRawHit * h, bool includeStrip = false ) ;
5151
static size_t uuid( StFttCluster * c ) ;
52+
static size_t vmmId( StFttRawHit * h ) ;
5253

5354
// HARDWARE Mapping StFttRawHits
5455
uint16_t packKey( int feb, int vmm, int ch ) const;
@@ -58,7 +59,7 @@ class StFttDb : public TDataSet {
5859
void loadHardwareMapFromFile( std::string fn );
5960
void loadHardwareMapFromDb( St_fttHardwareMap * );
6061
void loadDataWindowsFromFile( std::string fn );
61-
void loadDataWindowsFromDb( St_fttDataWindows * );
62+
void loadDataWindowsFromDb( St_fttDataWindowsB * );
6263

6364

6465
UChar_t plane( StFttRawHit * hit );
@@ -126,22 +127,7 @@ class StFttDb : public TDataSet {
126127
mTimeCutHigh=high;
127128
}
128129

129-
void getTimeCut( StFttRawHit * hit, int &mode, int &l, int &h ){
130-
mode = mTimeCutMode;
131-
l = mTimeCutLow;
132-
h = mTimeCutHigh;
133-
if (mUserDefinedTimeCut)
134-
return;
135-
136-
// load calibrated data windows from DB
137-
size_t hit_uuid = uuid( hit );
138-
if ( dwMap.count( hit_uuid ) ){
139-
mode = dwMap[ hit_uuid ].mode;
140-
l = dwMap[ hit_uuid ].min;
141-
h = dwMap[ hit_uuid ].max;
142-
}
143-
144-
}
130+
void getTimeCut( StFttRawHit * hit, int &mode, int &l, int &h );
145131

146132
private:
147133
int mDbAccess=1; //! enable(1) or disabe(0) DB access
@@ -154,12 +140,10 @@ class StFttDb : public TDataSet {
154140

155141
std :: map< uint16_t , uint16_t > mMap;
156142
std :: map< uint16_t , uint16_t > rMap; // reverse map
157-
158143
std :: map< uint16_t , FttDataWindow > dwMap;
159144

160145
ClassDef(StFttDb,1) //StAF chain virtual base class for Makers
161146
};
162147

163148
#endif
164-
165149

StRoot/StFttDbMaker/StFttDbMaker.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ int StFttDbMaker::Make(){
3838
int StFttDbMaker::InitRun(int runNumber) {
3939
LOG_INFO << "StFttDbMaker::InitRun - run = " << runNumber << endm;
4040

41-
4241
std::ifstream file("vmm_map.dat");
4342
if(file.is_open()){ // debugging / calibration only
4443
file.close();
@@ -56,17 +55,18 @@ int StFttDbMaker::InitRun(int runNumber) {
5655
}
5756
}
5857

58+
loadDataWindows();
59+
60+
return kStOK;
61+
}
62+
63+
void StFttDbMaker::loadDataWindows(){
64+
TDataSet *mDbDataSetDW = GetDataBase("Calibrations/ftt/fttDataWindowsB");
5965

60-
TDataSet *mDbDataSetDW = GetDataBase("Calibrations/ftt/fttDataWindows");
61-
6266
if ( mDbDataSetDW ) {
63-
St_fttDataWindows *dataset = (St_fttDataWindows*) mDbDataSetDW->Find("fttDataWindows");
67+
St_fttDataWindowsB *dataset = (St_fttDataWindowsB*) mDbDataSetDW->Find("fttDataWindowsB");
6468
mFttDb->loadDataWindowsFromDb( dataset );
6569
} else {
66-
LOG_WARN << "Cannot access `Calibrations/ftt/fttDataWindows`" << endm;
70+
LOG_WARN << "Cannot access Calibrations/ftt/fttDataWindowsB" << endm;
6771
}
68-
69-
70-
71-
return kStOK;
7272
}

StRoot/StFttDbMaker/StFttDbMaker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class StFttDbMaker : public StMaker {
1616
void Clear(Option_t *option);
1717
int Make();
1818
void setDbAccess(int v){mDbAccess=v;}
19+
void loadDataWindows();
1920

2021
private:
2122
StFttDb *mFttDb;

0 commit comments

Comments
 (0)