Skip to content

Commit a5155af

Browse files
shahor02sawenzel
authored andcommitted
Split InteractionRecord to InteractionTimeRecord->InteractionRecord
InteractionRecord will provide scalers only which can be used in the real data objects. InteractionTimeRecord will augment the InteractionRecord by the MC-truth time in ns
1 parent a2f845a commit a5155af

7 files changed

Lines changed: 46 additions & 18 deletions

File tree

DataFormats/common/include/CommonDataFormat/InteractionRecord.h

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
#include <Rtypes.h>
1717
#include <iosfwd>
1818
#include <cmath>
19+
#include <cstdint>
1920
#include "CommonConstants/LHCConstants.h"
2021

2122
namespace o2
2223
{
2324
struct InteractionRecord {
24-
double timeNS = 0.; ///< time in NANOSECONDS from start of run (orbit=0)
25-
int bc = 0; ///< bunch crossing ID of interaction
26-
unsigned int orbit = 0; ///< LHC orbit
25+
// information about bunch crossing and orbit
26+
27+
uint16_t bc = 0; ///< bunch crossing ID of interaction
28+
uint32_t orbit = 0; ///< LHC orbit
2729

2830
InteractionRecord() = default;
2931

@@ -32,14 +34,12 @@ struct InteractionRecord {
3234
setFromNS(tNS);
3335
}
3436

35-
InteractionRecord(int b, unsigned int orb) : bc(b), orbit(orb)
37+
InteractionRecord(uint16_t b, uint32_t orb) : bc(b), orbit(orb)
3638
{
37-
timeNS = bc2ns(bc, orbit);
3839
}
3940

4041
void setFromNS(double ns)
4142
{
42-
timeNS = ns;
4343
bc = ns2bc(ns, orbit);
4444
}
4545

@@ -57,7 +57,28 @@ struct InteractionRecord {
5757

5858
void print() const;
5959

60-
ClassDefNV(InteractionRecord, 2);
60+
ClassDefNV(InteractionRecord, 3);
61+
};
62+
63+
struct InteractionTimeRecord : public InteractionRecord {
64+
double timeNS = 0.; ///< time in NANOSECONDS from start of run (orbit=0)
65+
66+
InteractionTimeRecord() = default;
67+
68+
InteractionTimeRecord(double tNS)
69+
{
70+
setFromNS(tNS);
71+
}
72+
73+
void setFromNS(double ns)
74+
{
75+
timeNS = ns;
76+
InteractionRecord::setFromNS(ns);
77+
}
78+
79+
void print() const;
80+
81+
ClassDefNV(InteractionTimeRecord, 1);
6182
};
6283
}
6384

DataFormats/common/src/CommonDataFormatLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#pragma link C++ class o2::dataformats::RangeReference < o2::dataformats::EvIndex < int, int >, int > +;
3535

3636
#pragma link C++ class o2::InteractionRecord + ;
37+
#pragma link C++ class o2::InteractionTimeRecord + ;
3738
#pragma link C++ class o2::BunchFilling + ;
3839

3940
#endif

DataFormats/common/src/InteractionRecord.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
namespace o2
1414
{
15+
1516
void InteractionRecord::print() const
17+
{
18+
std::cout << "BCid: " << bc << " Orbit: " << orbit << std::endl;
19+
}
20+
21+
void InteractionTimeRecord::print() const
1622
{
1723
std::cout << "BCid: " << bc << " Orbit: " << orbit << " T(ns): " << timeNS << std::endl;
1824
}

DataFormats/simulation/include/SimulationDataFormat/RunContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class RunContext
4747
void setMaxNumberParts(int maxp) { mMaxPartNumber = maxp; }
4848
int getMaxNumberParts() const { return mMaxPartNumber; }
4949

50-
std::vector<o2::InteractionRecord>& getEventRecords() { return mEventRecords; }
50+
std::vector<o2::InteractionTimeRecord>& getEventRecords() { return mEventRecords; }
5151
std::vector<std::vector<o2::steer::EventPart>>& getEventParts() { return mEventParts; }
5252

53-
const std::vector<o2::InteractionRecord>& getEventRecords() const { return mEventRecords; }
53+
const std::vector<o2::InteractionTimeRecord>& getEventRecords() const { return mEventRecords; }
5454
const std::vector<std::vector<o2::steer::EventPart>>& getEventParts() const { return mEventParts; }
5555

5656
o2::BunchFilling& getBunchFilling() { return mBCFilling; }
@@ -66,7 +66,7 @@ class RunContext
6666
int mMaxPartNumber = 0; // max number of parts in any given collision
6767
float mMuBC; // probability of hadronic interaction per bunch
6868

69-
std::vector<o2::InteractionRecord> mEventRecords;
69+
std::vector<o2::InteractionTimeRecord> mEventRecords;
7070
// for each collision we record the constituents (which shall not exceed mMaxPartNumber)
7171
std::vector<std::vector<o2::steer::EventPart>> mEventParts;
7272

Steer/include/Steer/InteractionSampler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class InteractionSampler
3030
public:
3131
static constexpr float Sec2NanoSec = 1.e9; // s->ns conversion
3232

33-
o2::InteractionRecord generateCollisionTime();
34-
void generateCollisionTimes(std::vector<o2::InteractionRecord>& dest);
33+
o2::InteractionTimeRecord generateCollisionTime();
34+
void generateCollisionTimes(std::vector<o2::InteractionTimeRecord>& dest);
3535

3636
void init();
3737

@@ -74,7 +74,7 @@ class InteractionSampler
7474
};
7575

7676
//_________________________________________________
77-
inline void InteractionSampler::generateCollisionTimes(std::vector<o2::InteractionRecord>& dest)
77+
inline void InteractionSampler::generateCollisionTimes(std::vector<o2::InteractionTimeRecord>& dest)
7878
{
7979
// fill vector with interaction records
8080
dest.clear();

Steer/src/InteractionSampler.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void InteractionSampler::print() const
7272
}
7373

7474
//_________________________________________________
75-
o2::InteractionRecord InteractionSampler::generateCollisionTime()
75+
o2::InteractionTimeRecord InteractionSampler::generateCollisionTime()
7676
{
7777
// generate single interaction record
7878
if (mIntRate < 0) {
@@ -82,13 +82,13 @@ o2::InteractionRecord InteractionSampler::generateCollisionTime()
8282
if (mIntBCCache < 1) { // do we still have interaction in current BC?
8383
mIntBCCache = simulateInteractingBC(); // decide which BC interacts and N collisions
8484
}
85-
double timeInt = mTimeInBC.back() + o2::InteractionRecord::bc2ns(mBCCurrent, mOrbit);
85+
double timeInt = mTimeInBC.back() + o2::InteractionTimeRecord::bc2ns(mBCCurrent, mOrbit);
8686
mTimeInBC.pop_back();
8787
mIntBCCache--;
8888

89-
o2::InteractionRecord tmp(timeInt);
89+
o2::InteractionTimeRecord tmp(timeInt);
9090

91-
return o2::InteractionRecord(timeInt);
91+
return o2::InteractionTimeRecord(timeInt);
9292
}
9393

9494
//_________________________________________________

Steer/test/testInteractionSampler.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(InteractionSampler)
2323
using Sampler = o2::steer::InteractionSampler;
2424

2525
const int ntest = 100;
26-
std::vector<o2::InteractionRecord> records; // destination for records
26+
std::vector<o2::InteractionTimeRecord> records; // destination for records
2727
records.reserve(ntest);
2828

2929
printf("Testing sampler with default settings\n");

0 commit comments

Comments
 (0)