-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ...
- Loading branch information
1 parent
617f485
commit 5a35f2c
Showing
15 changed files
with
1,708 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITChip_H | ||
#define DataFormats_Phase2TrackerDigi_Phase2ITChip_H | ||
#include <vector> | ||
#include <utility> | ||
#include <string> | ||
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITQCore.h" | ||
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITDigiHit.h" | ||
|
||
class Phase2ITChip { | ||
// Quarter cores collected into a chip (only active quarter cores with hits gets collected) | ||
std::vector<Phase2ITDigiHit> hitList; | ||
int rocnum_; | ||
|
||
public: | ||
Phase2ITChip(int rocnum, std::vector<Phase2ITDigiHit> hl); | ||
|
||
unsigned int size(); | ||
int rocnum() const { return rocnum_; } | ||
|
||
std::vector<Phase2ITQCore> get_organized_QCores(); | ||
std::vector<bool> get_chip_code(); | ||
|
||
private: | ||
std::pair<int, int> get_QCore_pos(Phase2ITDigiHit hit); | ||
|
||
Phase2ITQCore get_QCore_from_hit(Phase2ITDigiHit pixel); | ||
std::vector<Phase2ITQCore> rem_duplicates(std::vector<Phase2ITQCore> qcores); | ||
std::vector<Phase2ITQCore> organize_QCores(std::vector<Phase2ITQCore> qcores); | ||
}; | ||
|
||
#endif // DataFormats_Phase2TrackerDigi_Phase2ITChip_H |
25 changes: 25 additions & 0 deletions
25
DataFormats/Phase2TrackerDigi/interface/Phase2ITChipBitStream.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITChipBitStream_H | ||
#define DataFormats_Phase2TrackerDigi_Phase2ITChipBitStream_H | ||
#include <vector> | ||
|
||
class Phase2ITChipBitStream { | ||
// Encoded bit stream output from chips | ||
public: | ||
Phase2ITChipBitStream(int rocid, const std::vector<bool>& bitstream) { | ||
rocid_ = rocid; | ||
bitstream_ = bitstream; | ||
} | ||
|
||
Phase2ITChipBitStream() { rocid_ = -1; } | ||
|
||
int get_rocid() const { return rocid_; } | ||
|
||
const std::vector<bool>& get_bitstream() const { return bitstream_; } | ||
|
||
const bool operator<(const Phase2ITChipBitStream& other) { return rocid_ < other.rocid_; } | ||
|
||
private: | ||
int rocid_; // Chip index | ||
std::vector<bool> bitstream_; // Chip bit stream output | ||
}; | ||
#endif // DataFormats_Phase2TrackerDigi_Phase2ITChipBitStream_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITDigiHit_H | ||
#define DataFormats_Phase2TrackerDigi_Phase2ITDigiHit_H | ||
|
||
class Phase2ITDigiHit { | ||
private: | ||
int row_; // Hit position row | ||
int col_; // Hit position column | ||
int adc_; // Hit position adc | ||
|
||
public: | ||
Phase2ITDigiHit(int row_num, int col_num, int adc_num); | ||
|
||
void set_row(int row) { row_ = row; } | ||
void set_col(int col) { col_ = col; } | ||
|
||
int row() const { return row_; } | ||
int col() const { return col_; } | ||
int adc() const { return adc_; } | ||
}; | ||
|
||
#endif // DataFormats_Phase2TrackerDigi_Phase2ITDigiHit_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef DataFormats_Phase2TrackerDigi_Phase2ITQCore_H | ||
#define DataFormats_Phase2TrackerDigi_Phase2ITQCore_H | ||
#include <vector> | ||
|
||
class Phase2ITQCore { | ||
// Collects hits and creates a quarter core (16 pixel positions) | ||
private: | ||
std::vector<int> adcs; // Full array of adc values in a quarter core | ||
std::vector<int> hits; // Full array of hit occurrences | ||
bool islast_; // RD53 chip encoding bits | ||
bool isneighbour_; // RD53 chip encoding bits | ||
int rocid_; // Chip index number | ||
int ccol; // QCore position column | ||
int qcrow; // QCore position row | ||
|
||
public: | ||
Phase2ITQCore(int rocid, | ||
int ccol_in, | ||
int qcrow_in, | ||
bool isneighbour_in, | ||
bool islast_in, | ||
std::vector<int> adcs_in, | ||
std::vector<int> hits_in); | ||
|
||
Phase2ITQCore() { | ||
rocid_ = -1; | ||
islast_ = false; | ||
isneighbour_ = false; | ||
ccol = -1; | ||
qcrow = -1; | ||
} | ||
|
||
void setIsLast(bool islast) { islast_ = islast; } | ||
bool islast() const { return islast_; } | ||
|
||
void setIsNeighbour(bool isneighbour) { isneighbour_ = isneighbour; } | ||
|
||
int rocid() const { return rocid_; } | ||
int get_col() const { return ccol; } | ||
int get_row() const { return qcrow; } | ||
|
||
std::vector<bool> getHitmap(); | ||
std::vector<int> getADCs(); | ||
std::vector<bool> encodeQCore(bool is_new_col); | ||
|
||
const bool operator<(const Phase2ITQCore& other) { | ||
if (ccol == other.ccol) { | ||
return (ccol < other.ccol); | ||
} else { | ||
return (qcrow < other.qcrow); | ||
} | ||
} | ||
|
||
private: | ||
std::vector<bool> toRocCoordinates(std::vector<bool>& hitmap); | ||
std::vector<bool> intToBinary(int num, int length); | ||
bool containsHit(std::vector<bool>& hitmap); | ||
std::vector<bool> getHitmapCode(std::vector<bool> hitmap); | ||
}; | ||
|
||
#endif // DataFormats_Phase2TrackerDigi_Phase2ITQCore_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include <vector> | ||
#include <utility> | ||
#include <string> | ||
#include <iostream> | ||
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITQCore.h" | ||
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITChip.h" | ||
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITDigiHit.h" | ||
|
||
Phase2ITChip::Phase2ITChip(int rocnum, std::vector<Phase2ITDigiHit> hl) { | ||
hitList = hl; | ||
rocnum_ = rocnum; | ||
} | ||
|
||
unsigned int Phase2ITChip::size() { return hitList.size(); } | ||
|
||
//Returns the position (row,col) of the 4x4 QCores that contains a hit | ||
std::pair<int, int> Phase2ITChip::get_QCore_pos(Phase2ITDigiHit hit) { | ||
int row = hit.row() / 4; | ||
int col = hit.col() / 4; | ||
return {row, col}; | ||
} | ||
|
||
//Takes a hit and returns the 4x4 QCore that contains it | ||
Phase2ITQCore Phase2ITChip::get_QCore_from_hit(Phase2ITDigiHit pixel) { | ||
std::vector<int> adcs(16, 0), hits(16, 0); | ||
std::pair<int, int> pos = get_QCore_pos(pixel); | ||
|
||
for (const auto& hit : hitList) { | ||
if (get_QCore_pos(hit) == pos) { | ||
int i = (4 * (hit.row() % 4) + (hit.col() % 4) + 8) % 16; | ||
adcs[i] = hit.adc(); | ||
hits[i] = 1; | ||
} | ||
} | ||
|
||
Phase2ITQCore qcore(0, pos.second, pos.first, false, false, adcs, hits); | ||
return qcore; | ||
} | ||
|
||
//Removes duplicated Phase2ITQCores | ||
std::vector<Phase2ITQCore> Phase2ITChip::rem_duplicates(std::vector<Phase2ITQCore> qcores) { | ||
std::vector<Phase2ITQCore> list = {}; | ||
|
||
size_t i = 0; | ||
while (i < qcores.size()) { | ||
for (size_t j = i + 1; j < qcores.size();) { | ||
if (qcores[j].get_col() == qcores[i].get_col() && qcores[j].get_row() == qcores[i].get_row()) { | ||
qcores.erase(qcores.begin() + j); | ||
} else { | ||
++j; | ||
} | ||
} | ||
list.push_back(qcores[i]); | ||
++i; | ||
} | ||
|
||
return list; | ||
} | ||
|
||
//Returns a list of the qcores with hits arranged by increasing column and then row numbers | ||
std::vector<Phase2ITQCore> Phase2ITChip::organize_QCores(std::vector<Phase2ITQCore> qcores) { | ||
std::vector<Phase2ITQCore> organized_list = {}; | ||
while (qcores.size() > 0) { | ||
int min = 0; | ||
|
||
for (size_t i = 1; i < qcores.size(); i++) { | ||
if (qcores[i].get_col() < qcores[min].get_col()) { | ||
min = i; | ||
} else if (qcores[i].get_col() == qcores[min].get_col() && qcores[i].get_row() < qcores[min].get_row()) { | ||
min = i; | ||
} | ||
} | ||
|
||
organized_list.push_back(qcores[min]); | ||
qcores.erase(qcores.begin() + min); | ||
} | ||
|
||
return organized_list; | ||
} | ||
|
||
//Takes in an oranized list of Phase2ITQCores and sets the islast and isneighbor properties of those qcores | ||
std::vector<Phase2ITQCore> link_QCores(std::vector<Phase2ITQCore> qcores) { | ||
for (size_t i = 1; i < qcores.size(); i++) { | ||
if (qcores[i].get_row() == qcores[i - 1].get_row()) { | ||
qcores[i].setIsNeighbour(true); | ||
} | ||
} | ||
|
||
//.size() is unsigned. If size is zero size()-1 is a huge number hence this needs to be protected | ||
if (qcores.size() > 0) { | ||
for (size_t i = 0; i < qcores.size() - 1; i++) { | ||
if (qcores[i].get_col() != qcores[i + 1].get_col()) { | ||
qcores[i].setIsLast(true); | ||
} | ||
} | ||
qcores[qcores.size() - 1].setIsLast(true); | ||
} | ||
|
||
return qcores; | ||
} | ||
|
||
//Takes in a list of hits and organizes them into the 4x4 QCores that contains them | ||
std::vector<Phase2ITQCore> Phase2ITChip::get_organized_QCores() { | ||
std::vector<Phase2ITQCore> qcores = {}; | ||
|
||
for (const auto& hit : hitList) { | ||
qcores.push_back(get_QCore_from_hit(hit)); | ||
} | ||
|
||
return (link_QCores(organize_QCores(rem_duplicates(qcores)))); | ||
} | ||
|
||
//Returns the encoding of the readout chip | ||
std::vector<bool> Phase2ITChip::get_chip_code() { | ||
std::vector<bool> code = {}; | ||
|
||
if (hitList.size() > 0) { | ||
std::vector<Phase2ITQCore> qcores = get_organized_QCores(); | ||
bool is_new_col = true; | ||
|
||
for (auto& qcore : qcores) { | ||
std::vector<bool> qcore_code = qcore.encodeQCore(is_new_col); | ||
code.insert(code.end(), qcore_code.begin(), qcore_code.end()); | ||
|
||
is_new_col = qcore.islast(); | ||
} | ||
} | ||
|
||
return code; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "DataFormats/Phase2TrackerDigi/interface/Phase2ITDigiHit.h" | ||
|
||
// Describes the 4x4=16 bit hitmap with its row and column numbers and the ADC values | ||
Phase2ITDigiHit::Phase2ITDigiHit(int row_num, int col_num, int adc_num) { | ||
row_ = row_num; | ||
col_ = col_num; | ||
adc_ = adc_num; | ||
} |
Oops, something went wrong.