-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLCT.h
148 lines (120 loc) · 3.5 KB
/
CLCT.h
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
#ifndef CLCT_H
#define CLCT_H
#include <cstdlib>
#include <fstream>
#include <string.h>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
//#include "TaoFunc.h"
#include "CSCConstants.h"
/// TODO
// --.pat output function
// --Add Overlapping Hit Checking
#define COMPILE_TYPE 0xc
#define LAYERS 6
#define NUM_CFEB 7
#define STRIPS_CFEB 32 // number halfstrips in cfeb
#define RAMPAGE_SIZE 4*1024
#define LAYER_SET 1
#define CLUSTER_BITS 14
#define GEM_FIBERS 4
namespace cw {
// Structures & Classes
struct Hit
{
public:
// Data Members
int bx;
int hs;
int lay;
// Constructors
Hit(void);
Hit(int Bx, int Hs, int Layer);
friend std::ostream& operator << (std::ostream& os, const Hit& hit);
friend std::istream& operator >> (std::istream& is, Hit& hit);
};
// CSC Macro Object
class CLCT
{
public:
// Data Members
int bx;
int hs;
int pat;
int nhits;
std::vector<Hit> hits;
// Constructors
CLCT(void);
CLCT(int, int, int, int);
CLCT(int, int, int, std::vector<Hit>&);
CLCT(const CLCT& clct);
void RelativeSpaceTime(void); // Sets bx, hs params of <hits> relative (+-) this->bx
void NormalSpaceTime(void); // undo the above operation
// Operators
//CLCT& operator = (const CLCT&);
friend std::ostream& operator << (std::ostream&, const CLCT&);
friend std::istream& operator >> (std::istream&, CLCT&);
};
// CSC object for writing (.pat)
class Group
{
public:
std::vector<unsigned char> hexdata;
Group(void);
Group(std::vector<Hit>&, int);
void addHit(Hit&, int);
friend std::ostream& operator << (std::ostream&, const Group&);
};
// GEM Macro object
class Cluster
{
public:
// Data Members Range
int bx; // 0-500
int roll; // 1-8
int pad; // 0-383
int size; // 1-8
int layer; // 1-2
Cluster(void);
Cluster(int, int, int, int, int);
Cluster(const Cluster&);
friend std::ostream& operator<<(std::ostream&, const Cluster&);
friend std::istream& operator>>(std::istream&, Cluster&);
unsigned int info(void);
};
// GEM object for writing (.pat)
struct gemPacket {
int num_clusters;
std::vector<unsigned int> raw_info;
gemPacket(void);
gemPacket(std::vector<Cluster>& iClu, unsigned int sInd = 0);
friend std::ostream& operator<<(std::ostream&, const gemPacket&); // writes 8 bytes (i.e. 1 bx of gem data for a single channel)
};
// Positioning Functions
int GetCFEB(int hs); // Out: Cfeb given half strip
int GetLocal(int hs); // Out: Halfstrip relative to CFEB
// Text File Parsers / Writers (human readable)
int ReadTxt(std::string&, std::vector<CLCT>&); // input : file prefix ONLY
std::string ReadTxt(std::string&, std::vector<CLCT>&, std::vector<Cluster>&); // input : (file prefix) + ".txt" GEM Capable!!
void WriteTxt(std::string&, std::vector<CLCT>&);
// Writes Patterns (.pat) to be loaded to EmuBoard
bool WritePat(std::string&, std::vector<CLCT>&); // CSC
bool WritePat(std::string&, std::vector<Cluster>&); // GEM
// For Sorting purposes
bool compareHit(Hit, Hit);
bool compareCLCT(CLCT, CLCT);
void ExtractHits(std::vector<CLCT>& clcts, std::vector<Hit>& hits, int feb = -1);
void CollectClusters(std::vector<Cluster>& pads, std::vector<Cluster>* in_pads, int layer, int gem_fiber = -1);
// Print object data to console
void DumpGroup(Group grp, int Bx);
void DumpHit(Hit&);
void PrintCLCT(CLCT&, std::ostream& oss = (std::cout), bool opt = true);
}
#endif