SND@LHC Software
Loading...
Searching...
No Matches
RPCUnpack Class Reference

#include <RPCUnpack.h>

Inheritance diagram for RPCUnpack:
Collaboration diagram for RPCUnpack:

Public Member Functions

 RPCUnpack ()
 
virtual ~RPCUnpack ()
 
virtual Bool_t Init () override
 
virtual Bool_t DoUnpack (Int_t *data, Int_t size) override
 
virtual void Reset () override
 
Int_t GetNHitsTotal ()
 
uint16_t GetPartition () override
 
- Public Member Functions inherited from ShipUnpack
 ShipUnpack ()
 
virtual ~ShipUnpack ()
 
Int_t GetNHitsTotal ()
 

Protected Member Functions

virtual void Register () override
 

Private Member Functions

 RPCUnpack (const RPCUnpack &)
 
RPCUnpackoperator= (const RPCUnpack &)
 

Private Attributes

std::unique_ptr< TClonesArray > fRawData
 
Int_t fNHits
 
Int_t fNHitsTotal
 
uint16_t fPartitionId
 

Detailed Description

Definition at line 16 of file RPCUnpack.h.

Constructor & Destructor Documentation

◆ RPCUnpack() [1/2]

RPCUnpack::RPCUnpack ( )

Definition at line 53 of file RPCUnpack.cxx.

53: fRawData(new TClonesArray("MuonTaggerHit")), fNHits(0), fNHitsTotal(0), fPartitionId(0x0B00) {}
std::unique_ptr< TClonesArray > fRawData
Definition RPCUnpack.h:42
uint16_t fPartitionId
Definition RPCUnpack.h:45
Int_t fNHitsTotal
Definition RPCUnpack.h:44
Int_t fNHits
Definition RPCUnpack.h:43

◆ ~RPCUnpack()

RPCUnpack::~RPCUnpack ( )
virtualdefault

Destructor.

◆ RPCUnpack() [2/2]

RPCUnpack::RPCUnpack ( const RPCUnpack )
private

Member Function Documentation

◆ DoUnpack()

Bool_t RPCUnpack::DoUnpack ( Int_t *  data,
Int_t  size 
)
overridevirtual

Process an MBS sub-event.

Reimplemented from ShipUnpack.

Definition at line 77 of file RPCUnpack.cxx.

78{
79 LOG(DEBUG) << "RPCUnpack : Unpacking frame... size/bytes = " << size;
80
81 auto df = reinterpret_cast<DataFrame *>(data);
82 switch (df->header.frameTime) {
83 case SoS: LOG(INFO) << "RPCUnpack: SoS frame."; return kTRUE;
84 case EoS: LOG(INFO) << "RPCUnpack: EoS frame."; return kTRUE;
85 default: break;
86 }
87 assert(df->header.size == size);
88 auto nhits = (size - sizeof(DataFrame)) / 12;
89 static_assert(sizeof(RawHit) == 12, "Padding is off");
90 int skipped = 0;
91 auto hits = reinterpret_cast<unsigned char *>(df->hits);
92 const int BYTES_PER_HITPATTERN = 8;
93 const int BYTES_PER_RECORD = 12;
94 for (int i = 0; i < nhits; i++) {
95 auto hit = hits + i * BYTES_PER_RECORD;
96 auto crate = (unsigned int)hit[0];
97 auto board = (unsigned int)hit[1];
98 for (int k = 1; k <= BYTES_PER_HITPATTERN; k++) {
99 auto index = k + 3;
100
101 auto bitMask = 0x1;
102 for (int j = 0; j < 8; j++) {
103 if (hit[index] & bitMask) {
104 auto channel = (BYTES_PER_HITPATTERN - k) * 8 + j;
105 if ((crate == 16 && (board == 5 || board == 10) && channel >= 48 && channel <= 53) ||
106 (crate == 16 && (board == 3 || board == 8) && channel >= 60 && channel <= 63) ||
107 (crate == 16 && (board == 4 || board == 9) && channel >= 10 && channel <= 15) ||
108 (crate == 16 && (board == 1 || board == 6) && channel >= 0 && channel <= 3) ||
109 (crate == 18 && (board == 5 || board == 10 || board == 15) && channel >= 48 && channel <= 53) ||
110 (crate == 18 && (board == 3 || board == 8 || board == 13) && channel >= 60 && channel <= 63) ||
111 (crate == 18 && (board == 4 || board == 9 || board == 14) && channel >= 10 && channel <= 15) ||
112 (crate == 18 && (board == 1 || board == 6 || board == 11) && channel >= 0 && channel <= 3)) {
113 skipped++;
114 continue;
115 }
116 new ((*fRawData)[fNHits])
117 MuonTaggerHit(GetId(crate, board, channel), Float_t(df->header.frameTime) * 25);
118 fNHits++;
119 }
120 bitMask <<= 1;
121 }
122 }
123 }
124
125 if (skipped) {
126 LOG(WARNING) << "Skipped " << skipped << " hits on unconnected channels (probably noise).";
127 }
129 return kTRUE;
130}
int GetId(int ncrate, int nboard, int channel)
Definition RPCUnpack.cxx:25
int i
Definition ShipAna.py:86
integer(mpi) nhits
number of hits
Definition mptest1.f90:58

◆ GetNHitsTotal()

Int_t RPCUnpack::GetNHitsTotal ( )
inline

Method for controlling the functionality.

Definition at line 33 of file RPCUnpack.h.

33{ return fNHitsTotal; }

◆ GetPartition()

uint16_t RPCUnpack::GetPartition ( )
inlineoverridevirtual

Implements ShipUnpack.

Definition at line 35 of file RPCUnpack.h.

35{ return fPartitionId; }

◆ Init()

Bool_t RPCUnpack::Init ( )
overridevirtual

Initialization. Called once, before the event loop.

Reimplemented from ShipUnpack.

Definition at line 59 of file RPCUnpack.cxx.

60{
61 Register();
62 return kTRUE;
63}
virtual void Register() override
Definition RPCUnpack.cxx:66

◆ operator=()

RPCUnpack & RPCUnpack::operator= ( const RPCUnpack )
private

◆ Register()

void RPCUnpack::Register ( )
overrideprotectedvirtual

Register the output structures.

Reimplemented from ShipUnpack.

Definition at line 66 of file RPCUnpack.cxx.

67{
68 LOG(INFO) << "RPCUnpack : Registering...";
69 FairRootManager *fMan = FairRootManager::Instance();
70 if (!fMan) {
71 return;
72 }
73 fMan->Register("Digi_MuonTaggerHits", "RPCs", fRawData.get(), kTRUE);
74}

◆ Reset()

void RPCUnpack::Reset ( )
overridevirtual

Clear the output structures.

Reimplemented from ShipUnpack.

Definition at line 133 of file RPCUnpack.cxx.

134{
135 LOG(DEBUG) << "RPCUnpack : Clearing Data Structure";
136 fRawData->Clear();
137 fNHits = 0;
138}

Member Data Documentation

◆ fNHits

Int_t RPCUnpack::fNHits
private

Number of raw items in current event.

Definition at line 43 of file RPCUnpack.h.

◆ fNHitsTotal

Int_t RPCUnpack::fNHitsTotal
private

Total number of raw items.

Definition at line 44 of file RPCUnpack.h.

◆ fPartitionId

uint16_t RPCUnpack::fPartitionId
private

Definition at line 45 of file RPCUnpack.h.

◆ fRawData

std::unique_ptr<TClonesArray> RPCUnpack::fRawData
private

Array of output raw items.

Definition at line 42 of file RPCUnpack.h.


The documentation for this class was generated from the following files: