13 debug_(
pset.getUntrackedParameter<
bool>(
"debug")),
16 LogDebug(
"LateralityCoarsedProvider") <<
"LateralityCoarsedProvider: constructor";
23 LogDebug(
"LateralityCoarsedProvider") <<
"LateralityCoarsedProvider: destructor";
31 LogDebug(
"LateralityCoarsedProvider") <<
"LateralityCoarsedProvider::initialiase";
37 std::vector<lat_vector> &lateralities) {
39 LogDebug(
"LateralityCoarsedProvider") <<
"LateralityCoarsedProvider: run";
42 for (
auto &muonpath : muonpaths) {
43 analyze(muonpath, lateralities);
49 LogDebug(
"LateralityCoarsedProvider") <<
"LateralityCoarsedProvider: finish";
58 LogDebug(
"LateralityCoarsedProvider") <<
"DTp2:analyze \t\t\t\t starts";
84 if (inMPath->missingLayer() ==
layer)
86 if (inMPath->primitive(
layer)->tdcTimeStamp() > max_time)
87 max_time = inMPath->primitive(
layer)->tdcTimeStamp();
91 std::vector<short> coarsified_times;
93 if (inMPath->missingLayer() ==
layer) {
94 coarsified_times.push_back(-1);
97 auto coarsified_time = max_time - inMPath->primitive(
layer)->tdcTimeStamp();
103 if (inMPath->missingLayer() == -1) {
105 coarsified_times.push_back(0);
107 coarsified_times.push_back(1);
109 coarsified_times.push_back(2);
111 coarsified_times.push_back(3);
114 coarsified_times.push_back(0);
116 coarsified_times.push_back(1);
118 coarsified_times.push_back(2);
120 coarsified_times.push_back(3);
123 return coarsified_times;
128 if (latFile.fail()) {
136 short line_counter = 0;
139 int _12bitMask = 0xFFF;
140 int _layoutMask = 0xE00;
141 int _is4HitMask = 0x100;
142 int _coarsedMask = 0xFF;
143 int _layerMask = 0xC0;
145 while (std::getline(latFile,
line)) {
146 if (
line ==
"000000000000") {
151 if (
line.size() == 12) {
154 transformedVector[0][0], transformedVector[0][1], transformedVector[0][2], transformedVector[0][3]};
156 transformedVector[1][0], transformedVector[1][1], transformedVector[1][2], transformedVector[1][3]};
158 transformedVector[2][0], transformedVector[2][1], transformedVector[2][2], transformedVector[2][3]};
161 short address = line_counter & _12bitMask;
164 (address & _layoutMask) >> 9;
165 short is4Hit = (address & _is4HitMask) >> 8;
166 short coarsed = address & _coarsedMask;
168 short bit1Layout = (
layout & (1));
169 short bit2Layout = (
layout & (1 << 1)) >> 1;
170 short bit3Layout = (
layout & (1 << 2)) >> 2;
173 short missingLayer = -1;
174 short layout_comb[
NUM_LAYERS] = {bit3Layout, bit2Layout, bit1Layout, -1};
175 short coarsedTimes[
NUM_LAYERS] = {0, 0, 0, 0};
179 (coarsed & _layerMask) >> 6;
180 coarsedTimes[missingLayer] = -1;
184 if (missingLayer != -1) {
185 switch (missingLayer) {
187 coarsedTimes[1] = (coarsed & 0x30) >> 4;
188 coarsedTimes[2] = (coarsed & 0x0C) >> 2;
189 coarsedTimes[3] = coarsed & 0x03;
190 lat0 = {-1, transformedVector[0][1], transformedVector[0][2], transformedVector[0][3]};
191 lat1 = {-1, transformedVector[1][1], transformedVector[1][2], transformedVector[1][3]};
192 lat2 = {-1, transformedVector[2][1], transformedVector[2][2], transformedVector[2][3]};
195 coarsedTimes[0] = (coarsed & 0x30) >> 4;
196 coarsedTimes[2] = (coarsed & 0x0C) >> 2;
197 coarsedTimes[3] = coarsed & 0x03;
198 lat0 = {transformedVector[0][0], -1, transformedVector[0][2], transformedVector[0][3]};
199 lat1 = {transformedVector[1][0], -1, transformedVector[1][2], transformedVector[1][3]};
200 lat2 = {transformedVector[2][0], -1, transformedVector[2][2], transformedVector[2][3]};
203 coarsedTimes[0] = (coarsed & 0x30) >> 4;
204 coarsedTimes[1] = (coarsed & 0x0C) >> 2;
205 coarsedTimes[3] = coarsed & 0x03;
206 lat0 = {transformedVector[0][0], transformedVector[0][1], -1, transformedVector[0][3]};
207 lat1 = {transformedVector[1][0], transformedVector[1][1], -1, transformedVector[1][3]};
208 lat2 = {transformedVector[2][0], transformedVector[2][1], -1, transformedVector[2][3]};
211 coarsedTimes[0] = (coarsed & 0x30) >> 4;
212 coarsedTimes[1] = (coarsed & 0x0C) >> 2;
213 coarsedTimes[2] = coarsed & 0x03;
214 lat0 = {transformedVector[0][0], transformedVector[0][1], transformedVector[0][2], -1};
215 lat1 = {transformedVector[1][0], transformedVector[1][1], transformedVector[1][2], -1};
216 lat2 = {transformedVector[2][0], transformedVector[2][1], transformedVector[2][2], -1};
224 coarsedTimes[0] = (coarsed & 0xC0) >> 6;
225 coarsedTimes[1] = (coarsed & 0x30) >> 4;
226 coarsedTimes[2] = (coarsed & 0x0C) >> 2;
227 coarsedTimes[3] = coarsed & 0x03;
231 {layout_comb[0], layout_comb[1], layout_comb[2], layout_comb[3]},
232 {coarsedTimes[0], coarsedTimes[1], coarsedTimes[2], coarsedTimes[3]},
237 std::cerr <<
"Error: line " << line_counter <<
" does not contain 12 bits." << std::endl;
248 std::vector<std::vector<short>>
result;
250 for (
size_t i = 0;
i < chain.size();
i += 4) {
251 std::vector<short>
group;
252 for (
size_t j = 0;
j < 4;
j++) {
253 group.push_back(chain[
i +
j] -
'0');
~LateralityCoarsedProvider() override
void fill_lat_combinations()
edm::FileInPath laterality_filename_
std::string fullPath() const
std::vector< MuonPathPtr > MuonPathPtrs
lat_vector LAT_VECTOR_NULL
void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMpath, std::vector< lat_vector > &lateralities) override
std::vector< short > latcomb
void analyze(MuonPathPtr &inMPath, std::vector< lat_vector > &lateralities)
std::vector< lat_coarsed_combination > lat_combinations
LateralityCoarsedProvider(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
constexpr int TIME_TO_TDC_COUNTS
std::vector< short > coarsify_times(MuonPathPtr &inMPath)
constexpr int LHC_CLK_FREQ
std::shared_ptr< MuonPath > MuonPathPtr
constexpr int LAT_TOTAL_BITS
std::vector< std::vector< short > > convertString(std::string chain)
void initialise(const edm::EventSetup &iEventSetup) override
constexpr int LAT_MSB_BITS
short cellLayout[cmsdt::NUM_LAYERS]