ARTEMIS-CRIB
 
Loading...
Searching...
No Matches
TModuleDecoderTimestamp.cc
Go to the documentation of this file.
1/**
2 * @file TModuleDecoderTimestamp.cc
3 * @brief
4 * @author Kodai Okawa <okawa@cns.s.u-tokyo.ac.jp>
5 * @date 2022?
6 * @note last modified: 2024-08-23 20:59:52
7 * @details
8 */
9
11
12#include <TRawDataSimple.h>
13
15
16typedef art::TRawDataSimple<ULong64_t> TimestampRaw_t;
17
19
24
29
30Int_t TModuleDecoderTimestamp::Decode(char *buf, const Int_t &size, TObjArray *seg) {
31 UShort_t *evtdata = reinterpret_cast<UShort_t *>(buf);
32 UInt_t evtsize = size / sizeof(UShort_t);
33 Int_t igeo, ich;
34 ULong64_t ts;
35 TimestampRaw_t *data;
36
37 // clear old hits
38 fHitData->Clear();
39
40 for (UInt_t i = 0; i < evtsize; i++) {
41 igeo = 0;
42 ich = 0;
43
44 ts = (ULong64_t)evtdata[3] << 48;
45 ts += (ULong64_t)evtdata[2] << 32;
46 ts += (ULong64_t)evtdata[1] << 16;
47 ts += (ULong64_t)evtdata[0];
48
49 // check if the data object exists.
50 if (fHitData->GetEntriesFast() <= ich || !fHitData->At(ich)) {
51 // if no data object is available, create one
52 TimestampRaw_t *obj = static_cast<TimestampRaw_t *>(this->New());
53 obj->SetSegInfo(seg->GetUniqueID(), igeo, ich);
54 fHitData->AddAtAndExpand(obj, ich);
55 seg->Add(obj);
56 }
57
58 data = static_cast<TimestampRaw_t *>(fHitData->At(ich));
59 data->Set(ts);
60
61 fHitData->AddAt(nullptr, ich);
62 }
63
64 return 0;
65}
ClassImp(TModuleDecoderTimestamp)
art::TRawDataSimple< ULong64_t > TimestampRaw_t
Int_t Decode(char *buffer, const Int_t &size, TObjArray *seg) override
return to the guide