1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
#ifndef EventFilter_CSCRawToDigi_CSCEventData_h
#define EventFilter_CSCRawToDigi_CSCEventData_h
class CSCCFEBData;
class CSCTMBHeader;
class CSCComparatorData;
class CSCWireDigi;
class CSCStripDigi;
#include <map>
#include <vector>
#ifndef LOCAL_UNPACK
#include <atomic>
#endif
#include "EventFilter/CSCRawToDigi/interface/CSCDMBHeader.h"
#include "EventFilter/CSCRawToDigi/interface/CSCDMBTrailer.h"
#include "EventFilter/CSCRawToDigi/interface/CSCALCTHeader.h"
#include "EventFilter/CSCRawToDigi/interface/CSCAnodeData.h"
#include "EventFilter/CSCRawToDigi/interface/CSCALCTTrailer.h"
#include "EventFilter/CSCRawToDigi/interface/CSCTMBData.h"
#include "EventFilter/CSCRawToDigi/interface/CSCDMBTrailer.h"
#include "DataFormats/CSCDigi/interface/CSCRPCDigi.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include "DataFormats/MuonDetId/interface/GEMDetId.h"
#include <boost/dynamic_bitset.hpp>
class CSCEventData {
public:
explicit CSCEventData(int chamberType, uint16_t format_version = 2005);
/// should make const input soon
CSCEventData(const uint16_t *buf, uint16_t format_version = 2005);
CSCEventData() {}
/// since we need deep copies, need the Big Three
/// (destructor, copy ctor, op=)
~CSCEventData();
CSCEventData(const CSCEventData &data);
CSCEventData operator=(const CSCEventData &data);
/// size of the data buffer used, in bytes
unsigned short size() const { return size_; }
/** turns on/off debug flag for this class */
static void setDebug(const bool value) { debug = value; }
///if dealing with ALCT data
bool isALCT(const uint16_t *buf);
///if dealing with TMB data
bool isTMB(const uint16_t *buf);
/// unpacked in long mode: has overflow and error bits decoded
const CSCCFEBData *cfebData(unsigned icfeb) const;
/// returns all the strip digis in the chamber, with the comparator information.
std::vector<CSCStripDigi> stripDigis(const CSCDetId &idlayer) const;
/// returns all the strip digis in the chamber's cfeb
std::vector<CSCStripDigi> stripDigis(unsigned idlayer, unsigned icfeb) const;
/// deprecated. Use the above methods instead
std::vector<std::vector<CSCStripDigi> > stripDigis() const;
std::vector<CSCWireDigi> wireDigis(unsigned ilayer) const;
/// deprecated. Use the above method instead.
std::vector<std::vector<CSCWireDigi> > wireDigis() const;
/// the flag for existence of ALCT data
int nalct() const { return theDMBHeader.nalct(); }
/// the number of CLCTs
int nclct() const { return theDMBHeader.nclct(); }
/// the DAQ motherboard header. A good place for event and chamber info
const CSCDMBHeader *dmbHeader() const { return &theDMBHeader; }
CSCDMBHeader *dmbHeader() { return &theDMBHeader; }
/// user must check if nalct > 0
CSCALCTHeader *alctHeader() const;
/// user must check if nalct > 0
CSCALCTTrailer *alctTrailer() const;
/// user must check if nalct > 0
CSCAnodeData *alctData() const;
///user must check in nclct > 0
CSCTMBData *tmbData() const;
/// user must check if nclct > 0
CSCTMBHeader *tmbHeader() const;
/// user must check if nclct > 0
CSCComparatorData *comparatorData() const;
/// DMB trailer
const CSCDMBTrailer *dmbTrailer() const { return &theDMBTrailer; }
/// routines to add digis to the data
void add(const CSCStripDigi &, int layer);
void add(const CSCWireDigi &, int layer);
void add(const CSCComparatorDigi &, int layer);
void add(const CSCComparatorDigi &, const CSCDetId &);
/// these go in as vectors, so they get sorted right away
void add(const std::vector<CSCALCTDigi> &);
void add(const std::vector<CSCCLCTDigi> &);
void add(const std::vector<CSCCorrelatedLCTDigi> &);
/// Run3 CSC Shower HMT objects
void addShower(const std::vector<CSCShowerDigi> &); // add LCT CSCShower
void addAnodeShower(const std::vector<CSCShowerDigi> &); // add Anode CSCShower
void addCathodeShower(const std::vector<CSCShowerDigi> &); // add Cathode CSCShower
void addAnodeALCTShower(const std::vector<CSCShowerDigi> &); // add Anode ALCT CSCShower
/// Run3 GEM Pad Clusters obecjts
void add(const std::vector<GEMPadDigiCluster> &, const GEMDetId &);
/// this will fill the DMB header, and change all related fields in
/// the DMBTrailer, ALCTHeader, and TMBHeader
void setEventInformation(int bxnum, int lvl1num);
/// returns the packed event data.
boost::dynamic_bitset<> pack();
/// adds an empty ALCTHeader, trailer, and anode data
void addALCTStructures();
/// might not be set in real data
int chamberType() const { return theChamberType; }
uint16_t getFormatVersion() const { return theFormatVersion; }
unsigned int calcALCTcrc(std::vector<std::pair<unsigned int, unsigned short *> > &vec);
#ifdef LOCAL_UNPACK
static bool debug;
#else
static std::atomic<bool> debug;
#endif
//uint16_t dataPresent; // 7 bit word which will tell if alct, clct, and 5 cfebs are present
static void selfTest();
private:
/// helpers for ctors, dtor, and op=
/// zeroes all pointers
void init();
void unpack_data(const uint16_t *buf);
void copy(const CSCEventData &);
void destroy();
/// makes new ALCT classes, if needed
void checkALCTClasses();
/// makes new TMB classes, if needed
void checkTMBClasses();
/// adds the comparators to the strip digis
void addComparatorInformation(std::vector<CSCStripDigi> &, int layer) const;
CSCDMBHeader theDMBHeader;
//these are empty data objects unless filled in CSCEventData.cc
/// these may or may not be present. I decided to make them
/// dynamic because most CSC chambers don't have LCTs,
/// therefore don't have data, except for DMB headers and trailers.
CSCALCTHeader *theALCTHeader;
CSCAnodeData *theAnodeData;
CSCALCTTrailer *theALCTTrailer;
CSCTMBData *theTMBData;
/// for up to MAX_CFEB CFEB boards
CSCCFEBData *theCFEBData[CSCConstants::MAX_CFEBS_RUN2];
CSCDMBTrailer theDMBTrailer;
int size_;
/// this won't be filled when real data is read it. It's only used when packing
/// simulated data, so we know how many wire and strip channels to make.
int theChamberType;
/// Auxiliary bufer to recove the ALCT raw payload from zero suppression
unsigned short *alctZSErecovered;
int zseEnable;
/// Output Format Version (2005, 2013)
uint16_t theFormatVersion;
};
std::ostream &operator<<(std::ostream &os, const CSCEventData &evt);
#endif
|