Skip to content

Commit 5a35f2c

Browse files
committed
move to cmssw_14_1_x
fix clean up fix errors lets not forget the format check rename Hit to DigiHitRecord address comments from mmusich build check rename rename rename rename add some descriptions rename format split it and ot repos Update Phase2PixelQCoreNtuple.cc Remove dummies Update Phase2PixelQCoreNtuple.cc remove unnecessary revert ...
1 parent 617f485 commit 5a35f2c

File tree

15 files changed

+1708
-0
lines changed

15 files changed

+1708
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITChip_H
2+
#define DataFormats_Phase2TrackerDigi_Phase2ITChip_H
3+
#include <vector>
4+
#include <utility>
5+
#include <string>
6+
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITQCore.h"
7+
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITDigiHit.h"
8+
9+
class Phase2ITChip {
10+
// Quarter cores collected into a chip (only active quarter cores with hits gets collected)
11+
std::vector<Phase2ITDigiHit> hitList;
12+
int rocnum_;
13+
14+
public:
15+
Phase2ITChip(int rocnum, std::vector<Phase2ITDigiHit> hl);
16+
17+
unsigned int size();
18+
int rocnum() const { return rocnum_; }
19+
20+
std::vector<Phase2ITQCore> get_organized_QCores();
21+
std::vector<bool> get_chip_code();
22+
23+
private:
24+
std::pair<int, int> get_QCore_pos(Phase2ITDigiHit hit);
25+
26+
Phase2ITQCore get_QCore_from_hit(Phase2ITDigiHit pixel);
27+
std::vector<Phase2ITQCore> rem_duplicates(std::vector<Phase2ITQCore> qcores);
28+
std::vector<Phase2ITQCore> organize_QCores(std::vector<Phase2ITQCore> qcores);
29+
};
30+
31+
#endif // DataFormats_Phase2TrackerDigi_Phase2ITChip_H
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITChipBitStream_H
2+
#define DataFormats_Phase2TrackerDigi_Phase2ITChipBitStream_H
3+
#include <vector>
4+
5+
class Phase2ITChipBitStream {
6+
// Encoded bit stream output from chips
7+
public:
8+
Phase2ITChipBitStream(int rocid, const std::vector<bool>& bitstream) {
9+
rocid_ = rocid;
10+
bitstream_ = bitstream;
11+
}
12+
13+
Phase2ITChipBitStream() { rocid_ = -1; }
14+
15+
int get_rocid() const { return rocid_; }
16+
17+
const std::vector<bool>& get_bitstream() const { return bitstream_; }
18+
19+
const bool operator<(const Phase2ITChipBitStream& other) { return rocid_ < other.rocid_; }
20+
21+
private:
22+
int rocid_; // Chip index
23+
std::vector<bool> bitstream_; // Chip bit stream output
24+
};
25+
#endif // DataFormats_Phase2TrackerDigi_Phase2ITChipBitStream_H
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITDigiHit_H
2+
#define DataFormats_Phase2TrackerDigi_Phase2ITDigiHit_H
3+
4+
class Phase2ITDigiHit {
5+
private:
6+
int row_; // Hit position row
7+
int col_; // Hit position column
8+
int adc_; // Hit position adc
9+
10+
public:
11+
Phase2ITDigiHit(int row_num, int col_num, int adc_num);
12+
13+
void set_row(int row) { row_ = row; }
14+
void set_col(int col) { col_ = col; }
15+
16+
int row() const { return row_; }
17+
int col() const { return col_; }
18+
int adc() const { return adc_; }
19+
};
20+
21+
#endif // DataFormats_Phase2TrackerDigi_Phase2ITDigiHit_H
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITQCore_H
2+
#define DataFormats_Phase2TrackerDigi_Phase2ITQCore_H
3+
#include <vector>
4+
5+
class Phase2ITQCore {
6+
// Collects hits and creates a quarter core (16 pixel positions)
7+
private:
8+
std::vector<int> adcs; // Full array of adc values in a quarter core
9+
std::vector<int> hits; // Full array of hit occurrences
10+
bool islast_; // RD53 chip encoding bits
11+
bool isneighbour_; // RD53 chip encoding bits
12+
int rocid_; // Chip index number
13+
int ccol; // QCore position column
14+
int qcrow; // QCore position row
15+
16+
public:
17+
Phase2ITQCore(int rocid,
18+
int ccol_in,
19+
int qcrow_in,
20+
bool isneighbour_in,
21+
bool islast_in,
22+
std::vector<int> adcs_in,
23+
std::vector<int> hits_in);
24+
25+
Phase2ITQCore() {
26+
rocid_ = -1;
27+
islast_ = false;
28+
isneighbour_ = false;
29+
ccol = -1;
30+
qcrow = -1;
31+
}
32+
33+
void setIsLast(bool islast) { islast_ = islast; }
34+
bool islast() const { return islast_; }
35+
36+
void setIsNeighbour(bool isneighbour) { isneighbour_ = isneighbour; }
37+
38+
int rocid() const { return rocid_; }
39+
int get_col() const { return ccol; }
40+
int get_row() const { return qcrow; }
41+
42+
std::vector<bool> getHitmap();
43+
std::vector<int> getADCs();
44+
std::vector<bool> encodeQCore(bool is_new_col);
45+
46+
const bool operator<(const Phase2ITQCore& other) {
47+
if (ccol == other.ccol) {
48+
return (ccol < other.ccol);
49+
} else {
50+
return (qcrow < other.qcrow);
51+
}
52+
}
53+
54+
private:
55+
std::vector<bool> toRocCoordinates(std::vector<bool>& hitmap);
56+
std::vector<bool> intToBinary(int num, int length);
57+
bool containsHit(std::vector<bool>& hitmap);
58+
std::vector<bool> getHitmapCode(std::vector<bool> hitmap);
59+
};
60+
61+
#endif // DataFormats_Phase2TrackerDigi_Phase2ITQCore_H
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#include <vector>
2+
#include <utility>
3+
#include <string>
4+
#include <iostream>
5+
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITQCore.h"
6+
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITChip.h"
7+
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITDigiHit.h"
8+
9+
Phase2ITChip::Phase2ITChip(int rocnum, std::vector<Phase2ITDigiHit> hl) {
10+
hitList = hl;
11+
rocnum_ = rocnum;
12+
}
13+
14+
unsigned int Phase2ITChip::size() { return hitList.size(); }
15+
16+
//Returns the position (row,col) of the 4x4 QCores that contains a hit
17+
std::pair<int, int> Phase2ITChip::get_QCore_pos(Phase2ITDigiHit hit) {
18+
int row = hit.row() / 4;
19+
int col = hit.col() / 4;
20+
return {row, col};
21+
}
22+
23+
//Takes a hit and returns the 4x4 QCore that contains it
24+
Phase2ITQCore Phase2ITChip::get_QCore_from_hit(Phase2ITDigiHit pixel) {
25+
std::vector<int> adcs(16, 0), hits(16, 0);
26+
std::pair<int, int> pos = get_QCore_pos(pixel);
27+
28+
for (const auto& hit : hitList) {
29+
if (get_QCore_pos(hit) == pos) {
30+
int i = (4 * (hit.row() % 4) + (hit.col() % 4) + 8) % 16;
31+
adcs[i] = hit.adc();
32+
hits[i] = 1;
33+
}
34+
}
35+
36+
Phase2ITQCore qcore(0, pos.second, pos.first, false, false, adcs, hits);
37+
return qcore;
38+
}
39+
40+
//Removes duplicated Phase2ITQCores
41+
std::vector<Phase2ITQCore> Phase2ITChip::rem_duplicates(std::vector<Phase2ITQCore> qcores) {
42+
std::vector<Phase2ITQCore> list = {};
43+
44+
size_t i = 0;
45+
while (i < qcores.size()) {
46+
for (size_t j = i + 1; j < qcores.size();) {
47+
if (qcores[j].get_col() == qcores[i].get_col() && qcores[j].get_row() == qcores[i].get_row()) {
48+
qcores.erase(qcores.begin() + j);
49+
} else {
50+
++j;
51+
}
52+
}
53+
list.push_back(qcores[i]);
54+
++i;
55+
}
56+
57+
return list;
58+
}
59+
60+
//Returns a list of the qcores with hits arranged by increasing column and then row numbers
61+
std::vector<Phase2ITQCore> Phase2ITChip::organize_QCores(std::vector<Phase2ITQCore> qcores) {
62+
std::vector<Phase2ITQCore> organized_list = {};
63+
while (qcores.size() > 0) {
64+
int min = 0;
65+
66+
for (size_t i = 1; i < qcores.size(); i++) {
67+
if (qcores[i].get_col() < qcores[min].get_col()) {
68+
min = i;
69+
} else if (qcores[i].get_col() == qcores[min].get_col() && qcores[i].get_row() < qcores[min].get_row()) {
70+
min = i;
71+
}
72+
}
73+
74+
organized_list.push_back(qcores[min]);
75+
qcores.erase(qcores.begin() + min);
76+
}
77+
78+
return organized_list;
79+
}
80+
81+
//Takes in an oranized list of Phase2ITQCores and sets the islast and isneighbor properties of those qcores
82+
std::vector<Phase2ITQCore> link_QCores(std::vector<Phase2ITQCore> qcores) {
83+
for (size_t i = 1; i < qcores.size(); i++) {
84+
if (qcores[i].get_row() == qcores[i - 1].get_row()) {
85+
qcores[i].setIsNeighbour(true);
86+
}
87+
}
88+
89+
//.size() is unsigned. If size is zero size()-1 is a huge number hence this needs to be protected
90+
if (qcores.size() > 0) {
91+
for (size_t i = 0; i < qcores.size() - 1; i++) {
92+
if (qcores[i].get_col() != qcores[i + 1].get_col()) {
93+
qcores[i].setIsLast(true);
94+
}
95+
}
96+
qcores[qcores.size() - 1].setIsLast(true);
97+
}
98+
99+
return qcores;
100+
}
101+
102+
//Takes in a list of hits and organizes them into the 4x4 QCores that contains them
103+
std::vector<Phase2ITQCore> Phase2ITChip::get_organized_QCores() {
104+
std::vector<Phase2ITQCore> qcores = {};
105+
106+
for (const auto& hit : hitList) {
107+
qcores.push_back(get_QCore_from_hit(hit));
108+
}
109+
110+
return (link_QCores(organize_QCores(rem_duplicates(qcores))));
111+
}
112+
113+
//Returns the encoding of the readout chip
114+
std::vector<bool> Phase2ITChip::get_chip_code() {
115+
std::vector<bool> code = {};
116+
117+
if (hitList.size() > 0) {
118+
std::vector<Phase2ITQCore> qcores = get_organized_QCores();
119+
bool is_new_col = true;
120+
121+
for (auto& qcore : qcores) {
122+
std::vector<bool> qcore_code = qcore.encodeQCore(is_new_col);
123+
code.insert(code.end(), qcore_code.begin(), qcore_code.end());
124+
125+
is_new_col = qcore.islast();
126+
}
127+
}
128+
129+
return code;
130+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITDigiHit.h"
2+
3+
// Describes the 4x4=16 bit hitmap with its row and column numbers and the ADC values
4+
Phase2ITDigiHit::Phase2ITDigiHit(int row_num, int col_num, int adc_num) {
5+
row_ = row_num;
6+
col_ = col_num;
7+
adc_ = adc_num;
8+
}

0 commit comments

Comments
 (0)