Skip to content

Commit 62a7c80

Browse files
committed
refactor TRD digit class
1 parent 5cec71a commit 62a7c80

File tree

8 files changed

+106
-54
lines changed

8 files changed

+106
-54
lines changed

Detectors/TRD/base/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ o2_add_library(TRDBase
1313
src/Geometry.cxx
1414
src/GeometryFlat.cxx
1515
src/CommonParam.cxx
16+
src/Digit.cxx
1617
src/DiffAndTimeStructEstimator.cxx
1718
src/SimParam.cxx
1819
src/PadResponse.cxx
19-
src/Digit.cxx
2020
src/CalDet.cxx
2121
src/CalROC.cxx
2222
src/FeeParam.cxx
@@ -47,8 +47,8 @@ o2_target_root_dictionary(TRDBase
4747
include/TRDBase/GeometryFlat.h
4848
include/TRDBase/SimParam.h
4949
include/TRDBase/CommonParam.h
50-
include/TRDBase/PadResponse.h
5150
include/TRDBase/Digit.h
51+
include/TRDBase/PadResponse.h
5252
include/TRDBase/MCLabel.h
5353
include/TRDBase/CalDet.h
5454
include/TRDBase/CalROC.h

Detectors/TRD/base/include/TRDBase/Digit.h

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
#include <numeric>
1919
#include "Rtypes.h" // for ClassDef
2020

21-
#include "CommonDataFormat/TimeStamp.h"
22-
#include "TRDBase/CommonParam.h"
21+
#include "TRDBase/FeeParam.h"
2322
#include "DataFormatsTRD/Constants.h"
2423

2524
namespace o2
@@ -30,37 +29,56 @@ namespace trd
3029
using ADC_t = std::uint16_t;
3130
using ArrayADC = std::array<ADC_t, constants::TIMEBINS>;
3231

33-
using TimeStamp = o2::dataformats::TimeStamp<double>;
34-
35-
class Digit : public TimeStamp
32+
// Digit class for TRD
33+
// Notes:
34+
// Shared pads:
35+
// the lowe mcm and rob is chosen for a given shared pad.
36+
// this negates the need for need alternate indexing strategies.
37+
// it does however mean that if you are trying to go from pad/row to mcm/rob you need to remember to manually do the shared ones.
38+
// TODO we could change the get methods to return the value in negaitve to indicate a shared pad, but I feel this is just added complexity? Comments?
39+
// if you are going to have to check for negative you may as well check for it being shared.
40+
class Digit
3641
{
3742
public:
3843
Digit() = default;
3944
~Digit() = default;
40-
Digit(const int det, const int row, const int pad, const ArrayADC adc, double t)
41-
: mDetector(det), mRow(row), mPad(pad), mADC(adc), TimeStamp(t) {}
45+
Digit(const int det, const int row, const int pad, const ArrayADC adc);
46+
Digit(const int det, const int row, const int pad); // add adc data in a seperate step
47+
Digit(const int det, const int rob, const int mcm, const int channel, const ArrayADC adc);
48+
Digit(const int det, const int rob, const int mcm, const int channel); // add adc data in a seperate step
49+
4250
// Copy
4351
Digit(const Digit&) = default;
4452
// Assignment
4553
Digit& operator=(const Digit&) = default;
4654
// Modifiers
55+
void setROB(int rob) { mROB = rob; }
56+
void setROB(int row, int pad) { mROB = FeeParam::getROBfromPad(row, pad); }
57+
void setMCM(int mcm) { mMCM = mcm; }
58+
void setMCM(int row, int pad) { mMCM = FeeParam::getMCMfromPad(row, pad); }
59+
void setChannel(int channel) { mChannel = channel; }
4760
void setDetector(int det) { mDetector = det; }
48-
void setRow(int row) { mRow = row; }
49-
void setPad(int pad) { mPad = pad; }
5061
void setADC(ArrayADC const& adc) { mADC = adc; }
5162
// Get methods
52-
int getDetector() const { return mDetector; }
53-
int getRow() const { return mRow; }
54-
int getPad() const { return mPad; }
63+
int getDetector() const { return mROB; }
64+
int getRow() const { return FeeParam::getPadRowFromMCM(mROB, mMCM); }
65+
int getPad() const { return FeeParam::getPadColFromADC(mROB, mMCM, mChannel); }
66+
int getROB() const { return mROB; }
67+
int getMCM() const { return mMCM; }
68+
int getChannel() const { return mChannel; }
69+
int isSharedDigit();
70+
5571
ArrayADC const& getADC() const { return mADC; }
5672
ADC_t getADCsum() const { return std::accumulate(mADC.begin(), mADC.end(), (ADC_t)0); }
5773

5874
private:
59-
std::uint16_t mDetector{0}; // TRD detector number, 0-539
60-
std::uint8_t mRow{0}; // pad row, 0-15
61-
std::uint8_t mPad{0}; // pad within pad row, 0-143
62-
ArrayADC mADC{}; // ADC vector (30 time-bins)
63-
ClassDefNV(Digit, 2);
75+
std::uint16_t mDetector{0}; // detector, the chamber
76+
std::uint8_t mROB{0}; // read out board with in chamber
77+
std::uint8_t mMCM{0}; // MCM chip this digit is attached to
78+
std::uint8_t mChannel{0}; // channel of this chip the digit is attached to.
79+
80+
ArrayADC mADC{}; // ADC vector (30 time-bins)
81+
ClassDefNV(Digit, 3);
6482
};
6583

6684
} // namespace trd

Detectors/TRD/base/include/TRDBase/FeeParam.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class FeeParam
5353
static void terminate();
5454

5555
// Translation from MCM to Pad and vice versa
56-
virtual int getPadRowFromMCM(int irob, int imcm) const;
57-
virtual int getPadColFromADC(int irob, int imcm, int iadc) const;
58-
virtual int getExtendedPadColFromADC(int irob, int imcm, int iadc) const;
59-
virtual int getMCMfromPad(int irow, int icol) const;
60-
virtual int getMCMfromSharedPad(int irow, int icol) const;
61-
virtual int getROBfromPad(int irow, int icol) const;
62-
virtual int getROBfromSharedPad(int irow, int icol) const;
63-
virtual int getRobSide(int irob) const;
64-
virtual int getColSide(int icol) const;
56+
static int getPadRowFromMCM(int irob, int imcm);
57+
static int getPadColFromADC(int irob, int imcm, int iadc);
58+
static int getExtendedPadColFromADC(int irob, int imcm, int iadc);
59+
static int getMCMfromPad(int irow, int icol);
60+
static int getMCMfromSharedPad(int irow, int icol);
61+
static int getROBfromPad(int irow, int icol);
62+
static int getROBfromSharedPad(int irow, int icol);
63+
static int getRobSide(int irob);
64+
static int getColSide(int icol);
6565

6666
// SCSN-related
6767
static unsigned int aliToExtAli(int rob, int aliid); // Converts the MCM-ROB combination to the extended MCM ALICE ID (used to address MCMs on the SCSN Bus)
@@ -70,11 +70,11 @@ class FeeParam
7070
static short getRobAB(unsigned short robsel, unsigned short linkpair); // Returns the chamber side (A=0, B=0) of a ROB
7171

7272
// wiring
73-
virtual int getORI(int detector, int readoutboard) const;
74-
virtual int getORIinSM(int detector, int readoutboard) const;
75-
// virtual void createORILookUpTable();
76-
virtual int getORIfromHCID(int hcid) const;
77-
virtual int getHCIDfromORI(int ori, int readoutboard) const; // TODO we need more info than just ori, for now readoutboard is there ... might change
73+
static int getORI(int detector, int readoutboard);
74+
static int getORIinSM(int detector, int readoutboard);
75+
// static void createORILookUpTable();
76+
static int getORIfromHCID(int hcid);
77+
static int getHCIDfromORI(int ori, int readoutboard); // TODO we need more info than just ori, for now readoutboard is there ... might change
7878

7979
// tracklet simulation
8080
bool getTracklet() const { return mgTracklet; }

Detectors/TRD/base/src/Digit.cxx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,41 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "TRDBase/Digit.h"
12+
namespace o2::trd
13+
{
14+
Digit::Digit(const int det, const int row, const int pad, const ArrayADC adc)
15+
{
16+
setDetector(det);
17+
setROB(row, pad);
18+
setMCM(row, pad);
19+
setADC(adc);
20+
}
21+
Digit::Digit(const int det, const int row, const int pad) // add adc data in a seperate step
22+
{
23+
setDetector(det);
24+
setROB(row, pad);
25+
setMCM(row, pad);
26+
}
27+
Digit::Digit(const int det, const int rob, const int mcm, const int channel, const ArrayADC adc)
28+
{
29+
setROB(rob);
30+
setMCM(mcm);
31+
setChannel(channel);
32+
setADC(adc);
33+
}
34+
Digit::Digit(const int det, const int rob, const int mcm, const int channel) // add adc data in a seperate step
35+
{
36+
setROB(rob);
37+
setMCM(mcm);
38+
setChannel(channel);
39+
}
40+
int Digit::isSharedDigit()
41+
{
42+
if (mChannel == 0 || mChannel == 19 || mChannel == 20) {
43+
return 1;
44+
} else {
45+
return 0;
46+
}
47+
}
48+
49+
} // namespace o2::trd

Detectors/TRD/base/src/FeeParam.cxx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void FeeParam::Copy(FeeParam& p) const
195195
}
196196

197197
//_____________________________________________________________________________
198-
int FeeParam::getPadRowFromMCM(int irob, int imcm) const
198+
int FeeParam::getPadRowFromMCM(int irob, int imcm)
199199
{
200200
//
201201
// Return on which pad row this mcm sits
@@ -205,7 +205,7 @@ int FeeParam::getPadRowFromMCM(int irob, int imcm) const
205205
}
206206

207207
//_____________________________________________________________________________
208-
int FeeParam::getPadColFromADC(int irob, int imcm, int iadc) const
208+
int FeeParam::getPadColFromADC(int irob, int imcm, int iadc)
209209
{
210210
//
211211
// Return which pad is connected to this adc channel.
@@ -232,7 +232,7 @@ int FeeParam::getPadColFromADC(int irob, int imcm, int iadc) const
232232
}
233233

234234
//_____________________________________________________________________________
235-
int FeeParam::getExtendedPadColFromADC(int irob, int imcm, int iadc) const
235+
int FeeParam::getExtendedPadColFromADC(int irob, int imcm, int iadc)
236236
{
237237
//
238238
// Return which pad coresponds to the extended digit container pad numbering
@@ -250,7 +250,7 @@ int FeeParam::getExtendedPadColFromADC(int irob, int imcm, int iadc) const
250250
}
251251

252252
//_____________________________________________________________________________
253-
int FeeParam::getMCMfromPad(int irow, int icol) const
253+
int FeeParam::getMCMfromPad(int irow, int icol)
254254
{
255255
//
256256
// Return on which MCM this pad is directry connected.
@@ -264,7 +264,7 @@ int FeeParam::getMCMfromPad(int irow, int icol) const
264264
}
265265

266266
//_____________________________________________________________________________
267-
int FeeParam::getMCMfromSharedPad(int irow, int icol) const
267+
int FeeParam::getMCMfromSharedPad(int irow, int icol)
268268
{
269269
//
270270
// Return on which MCM this pad is directry connected.
@@ -295,7 +295,7 @@ int FeeParam::getMCMfromSharedPad(int irow, int icol) const
295295
}
296296

297297
//_____________________________________________________________________________
298-
int FeeParam::getROBfromPad(int irow, int icol) const
298+
int FeeParam::getROBfromPad(int irow, int icol)
299299
{
300300
//
301301
// Return on which rob this pad is
@@ -304,7 +304,7 @@ int FeeParam::getROBfromPad(int irow, int icol) const
304304
}
305305

306306
//_____________________________________________________________________________
307-
int FeeParam::getROBfromSharedPad(int irow, int icol) const
307+
int FeeParam::getROBfromSharedPad(int irow, int icol)
308308
{
309309
//
310310
// Return on which rob this pad is for shared pads
@@ -318,7 +318,7 @@ int FeeParam::getROBfromSharedPad(int irow, int icol) const
318318
}
319319

320320
//_____________________________________________________________________________
321-
int FeeParam::getRobSide(int irob) const
321+
int FeeParam::getRobSide(int irob)
322322
{
323323
//
324324
// Return on which side this rob sits (A side = 0, B side = 1)
@@ -332,7 +332,7 @@ int FeeParam::getRobSide(int irob) const
332332
}
333333

334334
//_____________________________________________________________________________
335-
int FeeParam::getColSide(int icol) const
335+
int FeeParam::getColSide(int icol)
336336
{
337337
//
338338
// Return on which side this column sits (A side = 0, B side = 1)
@@ -511,14 +511,14 @@ void FeeParam::createORILookUpTable()
511511
}
512512
*/
513513

514-
int FeeParam::getORI(int detector, int readoutboard) const
514+
int FeeParam::getORI(int detector, int readoutboard)
515515
{
516516
int supermodule = detector / 30;
517517
LOG(debug3) << "getORI : " << detector << " :: " << readoutboard << getORIinSM(detector, readoutboard) + 60 * detector;
518518
return getORIinSM(detector, readoutboard) + 2 * detector; // 2 ORI per detector
519519
}
520520

521-
int FeeParam::getORIinSM(int detector, int readoutboard) const
521+
int FeeParam::getORIinSM(int detector, int readoutboard)
522522
{
523523
int ori = -1;
524524
int chamberside = 0;
@@ -546,7 +546,7 @@ int FeeParam::getORIinSM(int detector, int readoutboard) const
546546
return ori;
547547
}
548548

549-
int FeeParam::getORIfromHCID(int hcid) const
549+
int FeeParam::getORIfromHCID(int hcid)
550550
{
551551
int detector = hcid / 2;
552552
int side = hcid % 2; // 0 for side 0, 1 for side 1;
@@ -555,9 +555,8 @@ int FeeParam::getORIfromHCID(int hcid) const
555555
int trdstack = Geometry::getStack(detector);
556556
int trdlayer = Geometry::getLayer(detector);
557557
return getORIinSM(detector, side); // it takes readoutboard but only cares if its odd or even hence side here.
558-
return 1;
559558
}
560-
int FeeParam::getHCIDfromORI(int ori, int readoutboard) const
559+
int FeeParam::getHCIDfromORI(int ori, int readoutboard)
561560
{
562561
// ori = 60*SM+offset[0-29 A, 30-59 C]
563562
// from the offset, we can derive the stack/layer/side combination giving the decector.

Detectors/TRD/base/src/TRDBaseLinkDef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#pragma link C++ class o2::trd::Geometry + ;
1919
#pragma link C++ class o2::trd::GeometryBase + ;
2020
#pragma link C++ class o2::trd::CommonParam + ;
21-
#pragma link C++ class o2::trd::SimParam + ;
2221
#pragma link C++ class o2::trd::Digit + ;
23-
#pragma link C++ class std::vector < o2::trd::Digit> + ;
22+
#pragma link C++ class std::vector < o2::trd::Digit > +;
23+
#pragma link C++ class o2::trd::SimParam + ;
2424
#pragma link C++ class o2::trd::FeeParam + ;
2525
#pragma link C++ class o2::trd::CalDet + ;
2626
#pragma link C++ class o2::trd::CalROC + ;

Detectors/TRD/simulation/src/Digitizer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ bool Digitizer::convertSignalsToADC(SignalContainer& signalMapCont, DigitContain
519519
adcs[tb] = adc;
520520
} // loop over timebins
521521
// Convert the map to digits here, and push them to the container
522-
digits.emplace_back(det, row, col, adcs, getEventTime());
522+
digits.emplace_back(det, row, col, adcs);
523523
} // loop over digits
524524
return true;
525525
}

Detectors/TRD/workflow/src/TRDTrapSimulatorSpec.cxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ bool digitindexcompare(unsigned int A, unsigned int B, const std::vector<o2::trd
211211
const o2::trd::Digit *a, *b;
212212
a = &originalDigits[A];
213213
b = &originalDigits[B];
214-
// timestamps are equal
215214
if (a->getDetector() < b->getDetector()) {
216215
return 1;
217216
}
@@ -365,7 +364,7 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc)
365364
//for (auto& digit : msgDigits) {
366365
for (auto& digitindex : msgDigitsIndex) {
367366
Digit digit = msgDigits[digitindex];
368-
LOG(debug) << "sorted digit time:" << digit.getTimeStamp() << " detector:row:pad:rob:mcm ::"
367+
LOG(debug) << "sorted digit detector:row:pad:rob:mcm ::"
369368
<< digit.getDetector() << ":" << digit.getRow() << ":" << digit.getPad() << ":"
370369
<< mFeeParam->getROBfromPad(digit.getRow(), digit.getPad()) << ":"
371370
<< mFeeParam->getMCMfromPad(digit.getRow(), digit.getPad())
@@ -402,7 +401,6 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc)
402401
// fireup trapsim, do its thing with each 18 sequence of pads data that already exists inside the class from previous iterations of the loop
403402
LOG(debug) << "Digit iterator is : " << *digititerator;
404403
Digit* digit = &msgDigits[*digititerator];
405-
double digittime = digit->getTimeStamp();
406404
int pad = digit->getPad();
407405
int row = digit->getRow();
408406
int detector = digit->getDetector();
@@ -416,7 +414,6 @@ void TRDDPLTrapSimulatorTask::run(o2::framework::ProcessingContext& pc)
416414
<< detector << ":" << row << ":" << pad << ":" << rob << ":" << mcm
417415
<< " LinkId:" << LinkRecord::getHalfChamberLinkId(detector, rob) << "\t\t SM:stack:layer:side " << detector / 30 << ":" << trdstack << ":" << trdlayer << ":" << fibreside
418416
<< " with ORI : " << mFeeParam->getORI(detector, rob) << " and within supermodule ori index:" << mFeeParam->getORIinSM(detector, rob);
419-
LOG(debug) << "digit time : " << digittime;
420417
if (digititerator == msgDigitsIndex.begin()) { // first time in loop
421418
oldrow = row;
422419
olddetector = detector;

0 commit comments

Comments
 (0)