SND@LHC Software
Loading...
Searching...
No Matches
PixelUnpack.cxx
Go to the documentation of this file.
1
#include <cassert>
2
3
// ROOT headers
4
#include "TClonesArray.h"
5
6
// Fair headers
7
#include "FairRootManager.h"
8
#include "FairRunOnline.h"
9
#include "FairLogger.h"
10
11
// SHiP headers
12
#include "
PixelUnpack.h
"
13
#include "ShipPixelHit.h"
14
#include "
ShipOnlineDataFormat.h
"
15
16
struct
HitData
{
17
uint16_t
relative_BCID
: 4;
18
uint16_t
flags
: 4;
19
uint16_t
moduleID
: 4;
20
uint16_t
tot
: 4;
21
};
22
struct
ChannelId
{
23
uint16_t
column
: 7;
24
uint16_t
row
: 9;
25
};
26
27
// PixelUnpack: Constructor
28
PixelUnpack::PixelUnpack
(uint16_t PartitionId)
29
: fRawData(new TClonesArray(
"ShipPixelHit"
)), fNHits(0), fNHitsTotal(0), fPartitionId(PartitionId)
30
{
31
}
32
33
// Virtual PixelUnpack: Public method
34
PixelUnpack::~PixelUnpack
()
35
{
36
LOG(INFO) <<
"PixelUnpack: Delete instance"
;
37
delete
fRawData
;
38
}
39
40
// Init: Public method
41
Bool_t
PixelUnpack::Init
()
42
{
43
Register
();
44
return
kTRUE;
45
}
46
47
// Register: Protected method
48
void
PixelUnpack::Register
()
49
{
50
LOG(INFO) <<
"PixelUnpack : Registering..."
;
51
auto
*fMan = FairRootManager::Instance();
52
if
(!fMan) {
53
return
;
54
}
55
fMan->Register(
"Digi_PixelHits"
,
"Pixels"
,
fRawData
, kTRUE);
56
}
57
58
// DoUnpack: Public method
59
Bool_t
PixelUnpack::DoUnpack
(Int_t *data, Int_t size)
60
{
61
LOG(INFO) <<
"PixelUnpack : Unpacking frame... size/bytes = "
<< size;
62
63
auto
df =
reinterpret_cast<
DataFrame
*
>
(data);
64
switch
(df->header.frameTime) {
65
case
SoS
: LOG(INFO) <<
"PixelUnpacker: SoS frame."
;
return
kTRUE;
66
case
EoS
: LOG(INFO) <<
"PixelUnpacker: EoS frame."
;
return
kTRUE;
67
default
:
break
;
68
}
69
assert(df->header.size == size);
70
auto
nhits = df->getHitCount();
71
std::vector<RawDataHit> hits(df->hits, df->hits + nhits);
72
for
(
auto
&&hit : hits) {
73
auto
hitData =
reinterpret_cast<
HitData
*
>
(&(hit.hitTime));
74
auto
channelId =
reinterpret_cast<
ChannelId
*
>
(&(hit.channelId));
75
auto
detectorID = (df->header.partitionId%0x0800) * 10000000 + 1000000 * hitData->moduleID + 1000 * channelId->
row
+ channelId->column;
76
auto
tot = hitData->tot;
77
new
((*fRawData)[
fNHits
]) ShipPixelHit(detectorID, tot);
//tot is measured in steps of 25 ns
78
fNHits
++;
79
}
80
81
fNHitsTotal
+=
fNHits
;
82
return
kTRUE;
83
}
84
85
// Reset: Public method
86
void
PixelUnpack::Reset
()
87
{
88
LOG(DEBUG) <<
"PixelUnpack : Clearing Data Structure"
;
89
fRawData
->Clear();
90
fNHits
= 0;
91
}
92
93
ClassImp
(
PixelUnpack
)
PixelUnpack.h
ShipOnlineDataFormat.h
EoS
@ EoS
Definition
ShipOnlineDataFormat.h:203
SoS
@ SoS
Definition
ShipOnlineDataFormat.h:203
PixelUnpack
Definition
PixelUnpack.h:16
PixelUnpack::fNHitsTotal
Int_t fNHitsTotal
Definition
PixelUnpack.h:44
PixelUnpack::Register
virtual void Register() override
Definition
PixelUnpack.cxx:48
PixelUnpack::DoUnpack
virtual Bool_t DoUnpack(Int_t *data, Int_t size) override
Definition
PixelUnpack.cxx:59
PixelUnpack::fNHits
Int_t fNHits
Definition
PixelUnpack.h:43
PixelUnpack::Reset
virtual void Reset() override
Definition
PixelUnpack.cxx:86
PixelUnpack::~PixelUnpack
virtual ~PixelUnpack()
Definition
PixelUnpack.cxx:34
PixelUnpack::Init
virtual Bool_t Init() override
Definition
PixelUnpack.cxx:41
PixelUnpack::fRawData
TClonesArray * fRawData
Definition
PixelUnpack.h:42
PixelUnpack::PixelUnpack
PixelUnpack(uint16_t PartitionId)
Definition
PixelUnpack.cxx:28
ClassImp
ClassImp(ecalContFact) ecalContFact
Definition
ecalContFact.cxx:8
ChannelId
Definition
PixelUnpack.cxx:22
ChannelId::column
uint16_t column
Definition
PixelUnpack.cxx:23
ChannelId::row
uint16_t row
Definition
PixelUnpack.cxx:24
DataFrame
Definition
ShipOnlineDataFormat.h:23
HitData
Definition
PixelUnpack.cxx:16
HitData::flags
uint16_t flags
Definition
PixelUnpack.cxx:18
HitData::relative_BCID
uint16_t relative_BCID
Definition
PixelUnpack.cxx:17
HitData::moduleID
uint16_t moduleID
Definition
PixelUnpack.cxx:19
HitData::tot
uint16_t tot
Definition
PixelUnpack.cxx:20
online
PixelUnpack.cxx
Generated by
1.9.8