MUSIC unknown
Analysis for the MUSIC active-target ionization chamber
Loading...
Searching...
No Matches
HitAdapter.hpp
Go to the documentation of this file.
1#ifndef HIT_ADAPTER_HPP
2#define HIT_ADAPTER_HPP
3
4#include "BinaryUtils.hpp"
5#include <Rtypes.h>
6
17
19namespace SOLFlags {
22const UInt_t PILEUP = 0x01;
23const UInt_t EVENT_SATURATION = 0x04;
24const UInt_t POST_SATURATION = 0x08;
25const UInt_t CHARGE_OVERFLOW = 0x10;
26const UInt_t SCA_SELECTED = 0x20;
27const UInt_t FINE_TS_VALID = 0x40;
29
32const UInt_t EXT_INHIBIT = 0x0001;
33const UInt_t UNDER_SAT = 0x0002;
34const UInt_t OVER_SAT = 0x0004;
35const UInt_t EXT_TRIGGER = 0x0008;
36const UInt_t GLOBAL_TRIGGER = 0x0010;
37const UInt_t SW_TRIGGER = 0x0020;
38const UInt_t SELF_TRIGGER = 0x0040;
39const UInt_t LVDS_TRIGGER = 0x0080;
40const UInt_t TRIGGER_64CH = 0x0100;
41const UInt_t ITLA_TRIGGER = 0x0200;
42const UInt_t ITLB_TRIGGER = 0x0400;
44} // namespace SOLFlags
45
70namespace SOLPack {
71const Int_t LOW_SHIFT = 16;
72const UInt_t LOW_MASK = 0x7FF;
73const Int_t HIGH_SHIFT = 27;
74const Int_t HIGH_SKIP = 2;
75const UInt_t HIGH_MASK = 0x1F;
76} // namespace SOLPack
77
94inline UInt_t MapSOLFlagsToCoMPASS(UShort_t sol_flags_high,
95 UShort_t sol_flags_low) {
96 UInt_t mapped = 0;
97
98 // SOLARIS high-priority pileup -> CoMPASS PILEUP
99 if (sol_flags_high & SOLFlags::PILEUP) {
100 mapped |= CoMPASSData::PILEUP;
101 }
102
103 // SOLARIS event saturation -> CoMPASS SATURATION_IN_GATE
104 if (sol_flags_high & SOLFlags::EVENT_SATURATION) {
105 mapped |= CoMPASSData::SATURATION_IN_GATE;
106 }
107
108 // SOLARIS post-saturation -> CoMPASS INPUT_SATURATING
109 if (sol_flags_high & SOLFlags::POST_SATURATION) {
110 mapped |= CoMPASSData::INPUT_SATURATING;
111 }
112
113 // The rest, packed per the layout above. Each word is masked to the width it
114 // actually defines; the previous shifts (16 and 20) overlapped in bits 20-23,
115 // so flags_high bits 4-7 and flags_low bits 0-3 were ORed on top of each
116 // other and neither could be read back.
117 mapped |= (static_cast<UInt_t>(sol_flags_low) & SOLPack::LOW_MASK)
119 mapped |= ((static_cast<UInt_t>(sol_flags_high) >> SOLPack::HIGH_SKIP) &
122
123 return mapped;
124}
125
133inline UShort_t SOLFlagsLowFrom(UInt_t mapped) {
134 return UShort_t((mapped >> SOLPack::LOW_SHIFT) & SOLPack::LOW_MASK);
135}
136
144inline UShort_t SOLFlagsHighFrom(UInt_t mapped) {
145 return UShort_t(((mapped >> SOLPack::HIGH_SHIFT) & SOLPack::HIGH_MASK)
147}
148
159inline RawHit SOLHitToRawHit(const SOLHit &sol) {
160 RawHit raw;
161 raw.board = 0;
162 raw.channel = sol.channel;
163 raw.energy = sol.energy;
164 raw.timestamp = sol.timestamp * 1000;
165 raw.flags = MapSOLFlagsToCoMPASS(sol.flags_high, sol.flags_low);
166 return raw;
167}
168
172inline std::vector<RawHit>
173SOLHitsToRawHits(const std::vector<SOLHit> &sol_hits) {
174 std::vector<RawHit> raw_hits;
175 raw_hits.reserve(sol_hits.size());
176 for (Int_t i = 0; i < Int_t(sol_hits.size()); i++) {
177 raw_hits.push_back(SOLHitToRawHit(sol_hits[i]));
178 }
179 return raw_hits;
180}
181
182#endif
UShort_t SOLFlagsLowFrom(UInt_t mapped)
Recover the SOLARIS low-priority word from a packed value.
UShort_t SOLFlagsHighFrom(UInt_t mapped)
Recover the SOLARIS high-priority word from a packed value.
RawHit SOLHitToRawHit(const SOLHit &sol)
Adapt one SOLARIS hit into the pipeline's RawHit.
UInt_t MapSOLFlagsToCoMPASS(UShort_t sol_flags_high, UShort_t sol_flags_low)
Pack SOLARIS flags into a CoMPASS-compatible word.
std::vector< RawHit > SOLHitsToRawHits(const std::vector< SOLHit > &sol_hits)
Adapt a whole run's SOLARIS hits.
SOLARIS status flag bits, from the SOLARIS DAQ source.
const UInt_t EVENT_SATURATION
bit 2
const UInt_t GLOBAL_TRIGGER
bit 4
const UInt_t LVDS_TRIGGER
bit 7
const UInt_t EXT_TRIGGER
bit 3
const UInt_t ITLA_TRIGGER
bit 9
const UInt_t ITLB_TRIGGER
bit 10
const UInt_t POST_SATURATION
bit 3
const UInt_t SW_TRIGGER
bit 5
const UInt_t CHARGE_OVERFLOW
bit 4
const UInt_t EXT_INHIBIT
bit 0
const UInt_t SELF_TRIGGER
bit 6
const UInt_t SCA_SELECTED
bit 5
const UInt_t UNDER_SAT
bit 1
const UInt_t PILEUP
bit 0
const UInt_t FINE_TS_VALID
bit 6
const UInt_t TRIGGER_64CH
bit 8
const UInt_t OVER_SAT
bit 2
Layout of the packed word MapSOLFlagsToCoMPASS() returns.
const Int_t HIGH_SHIFT
Where the flags_high remnant starts.
const UInt_t LOW_MASK
flags_low bits 0-10.
const Int_t LOW_SHIFT
Where flags_low starts.
const Int_t HIGH_SKIP
flags_high bits 0-1 are not carried here.
const UInt_t HIGH_MASK
flags_high bits 2-6.