Skip to content

Commit 55ff2d3

Browse files
Daniel Estradajfernan2
authored andcommitted
Refactor DTTrigPh2ShowerProducer
change pluging to manage emulation of DT Muon Shower firmware algorithm v 0.2.0
1 parent e502372 commit 55ff2d3

File tree

13 files changed

+695
-478
lines changed

13 files changed

+695
-478
lines changed

DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTShower.h

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
// muon barrel Phase2 trigger
77
//
88
//
9-
// Author List: Carlos Vico Oviedo Spain
10-
//
9+
// Author List:
10+
// Federica Primavera Bologna INFN
11+
// Carlos Vico Oviedo Spain,
12+
// Daniel Estrada Acevedo Oviedo Spain.
13+
//
1114
//
1215
//--------------------------------------------------
1316
#ifndef L1Phase2MuDTShower_H
@@ -24,6 +27,7 @@
2427
//---------------
2528
// C++ Headers --
2629
//---------------
30+
#include <vector>
2731

2832
// ---------------------
2933
// -- Class Interface --
@@ -34,40 +38,49 @@ class L1Phase2MuDTShower {
3438
// Constructors
3539
L1Phase2MuDTShower();
3640

37-
L1Phase2MuDTShower(int bx, // BX estimation
38-
int wh, // Wheel
41+
L1Phase2MuDTShower(int wh, // Wheel
3942
int sc, // Sector
4043
int st, // Station
44+
int sl, // Superlayer
4145
int ndigis, // Number of digis within shower
46+
int bx, // BX estimation
47+
int min_wire, // Minimum wire
48+
int max_wire, // Maximum wire
4249
float avg_pos, // Averaged position of the shower
43-
float avg_time); // Averaged time of the shower
50+
float avg_time, // Averaged time of the shower
51+
const std::vector<int> wires_profile // Wires profile
52+
);
4453

4554

4655
virtual ~L1Phase2MuDTShower(){};
4756

4857
// Operations
49-
int bxNum() const;
50-
58+
5159
int whNum() const;
5260
int scNum() const;
5361
int stNum() const;
54-
62+
int slNum() const;
5563
int ndigis() const;
64+
int bxNum() const;
65+
int minWire() const;
66+
int maxWire() const;
5667
float avg_time() const;
5768
float avg_pos() const;
58-
69+
std::vector<int> wiresProfile() const;
70+
5971
private:
6072

61-
int m_bx;
62-
6373
int m_wheel;
6474
int m_sector;
6575
int m_station;
66-
76+
int m_superlayer;
6777
int m_ndigis;
78+
int m_bx;
79+
int m_min_wire;
80+
int m_max_wire;
6881
float m_avg_pos;
6982
float m_avg_time;
70-
83+
std::vector<int> m_wires_profile;
7184
};
7285

7386
#endif

DataFormats/L1DTTrackFinder/src/L1Phase2MuDTShower.cc

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// muon barrel Phase2 trigger
77
//
88
//
9-
// Author List: Federica Primavera Bologna INFN
9+
// Author List:
10+
// Federica Primavera Bologna INFN
11+
// Carlos Vico Oviedo Spain,
12+
// Daniel Estrada Acevedo Oviedo Spain.
1013
//
1114
//
1215
//--------------------------------------------------
@@ -32,23 +35,32 @@
3235
// Constructors --
3336
//----------------
3437
L1Phase2MuDTShower::L1Phase2MuDTShower()
35-
: m_bx(-100),
36-
m_wheel(0),
38+
: m_wheel(0),
3739
m_sector(0),
3840
m_station(0),
41+
m_superlayer(0),
3942
m_ndigis(0),
43+
m_bx(-100),
44+
m_min_wire(0),
45+
m_max_wire(0),
4046
m_avg_pos(0),
41-
m_avg_time(0) {}
47+
m_avg_time(0) {
48+
m_wires_profile.resize(96, 0);
49+
}
4250

4351
L1Phase2MuDTShower::L1Phase2MuDTShower(
44-
int bx, int wh, int sc, int st, int ndigis, float avg_pos, float avg_time)
45-
: m_bx(bx),
46-
m_wheel(wh),
47-
m_sector(sc),
48-
m_station(st),
49-
m_ndigis(ndigis),
50-
m_avg_pos(avg_pos),
51-
m_avg_time(avg_time) {}
52+
int wh, int sc, int st, int sl, int ndigis, int bx, int min_wire, int max_wire, float avg_pos, float avg_time, const std::vector<int> wires_profile)
53+
: m_wheel(wh),
54+
m_sector(sc),
55+
m_station(st),
56+
m_superlayer(sl),
57+
m_ndigis(ndigis),
58+
m_bx(bx),
59+
m_min_wire(min_wire),
60+
m_max_wire(max_wire),
61+
m_avg_pos(avg_pos),
62+
m_avg_time(avg_time),
63+
m_wires_profile(wires_profile) {}
5264

5365
//--------------
5466
// Operations --
@@ -60,10 +72,18 @@ int L1Phase2MuDTShower::scNum() const { return m_sector; }
6072

6173
int L1Phase2MuDTShower::stNum() const { return m_station; }
6274

63-
int L1Phase2MuDTShower::bxNum() const { return m_bx; }
75+
int L1Phase2MuDTShower::slNum() const { return m_superlayer; }
6476

6577
int L1Phase2MuDTShower::ndigis() const { return m_ndigis; }
6678

79+
int L1Phase2MuDTShower::bxNum() const { return m_bx; }
80+
81+
int L1Phase2MuDTShower::minWire() const { return m_min_wire; }
82+
83+
int L1Phase2MuDTShower::maxWire() const { return m_max_wire; }
84+
6785
float L1Phase2MuDTShower::avg_time() const { return m_avg_time; }
6886

6987
float L1Phase2MuDTShower::avg_pos() const { return m_avg_pos; }
88+
89+
std::vector<int> L1Phase2MuDTShower::wiresProfile() const { return m_wires_profile; }

DataFormats/L1DTTrackFinder/src/classes_def.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<version ClassVersion="3" checksum="1236020577"/>
1818
</class>
1919

20-
<class name="L1Phase2MuDTShower" ClassVersion="7">
20+
<class name="L1Phase2MuDTShower" ClassVersion="9">
21+
<version ClassVersion="9" checksum="448482846"/>
22+
<version ClassVersion="8" checksum="1870162932"/>
2123
<version ClassVersion="7" checksum="3499440359"/>
2224
<version ClassVersion="6" checksum="1855990307"/>
2325
<version ClassVersion="5" checksum="1887794940"/>

L1Trigger/DTTriggerPhase2/interface/ShowerBuffer.h

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#ifndef Phase2L1Trigger_DTTrigger_ShowerBuilder_h
2+
#define Phase2L1Trigger_DTTrigger_ShowerBuilder_h
3+
4+
#include "FWCore/Framework/interface/Event.h"
5+
#include "FWCore/Framework/interface/Frameworkfwd.h"
6+
#include "FWCore/Framework/interface/EventSetup.h"
7+
#include "FWCore/Framework/interface/Run.h"
8+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
9+
10+
#include "DataFormats/DTDigi/interface/DTDigiCollection.h"
11+
#include "L1Trigger/DTTriggerPhase2/interface/ShowerCandidate.h"
12+
#include "L1Trigger/DTTriggerPhase2/interface/constants.h"
13+
14+
#include "Geometry/Records/interface/MuonGeometryRecord.h"
15+
#include "Geometry/DTGeometry/interface/DTGeometry.h"
16+
#include "Geometry/DTGeometry/interface/DTLayer.h"
17+
18+
#include <iostream>
19+
#include <fstream>
20+
21+
// ===============================================================================
22+
// Previous definitions and declarations
23+
// ===============================================================================
24+
25+
namespace showerb {
26+
typedef std::pair<int, DTPrimitive> DTPrimPlusBx;
27+
typedef std::deque<DTPrimPlusBx> ShowerBuffer;
28+
29+
bool hitWireSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2){
30+
int wi1 = hit1.channelId();
31+
int wi2 = hit2.channelId();
32+
33+
if (wi1 < wi2) return true;
34+
else return false;
35+
}
36+
37+
bool hitLayerSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) {
38+
int lay1 = hit1.layerId();
39+
int lay2 = hit2.layerId();
40+
41+
if (lay1 < lay2) return true;
42+
else if (lay1 > lay2) return false;
43+
else return hitWireSort_shower(hit1, hit2);
44+
}
45+
46+
bool hitTimeSort_shower(const DTPrimitive& hit1, const DTPrimitive& hit2) {
47+
int tdc1 = hit1.tdcTimeStamp();
48+
int tdc2 = hit2.tdcTimeStamp();
49+
50+
if (tdc1 < tdc2) return true;
51+
else return false;
52+
// else if (tdc1 > tdc2) return false;
53+
// else return hitLayerSort_shower(hit1, hit2); --> ignoring those sortings for now
54+
}
55+
56+
float compute_avg_pos(DTPrimitives& hits) {
57+
int nhits_ = hits.size();
58+
59+
if (nhits_ == 0) return -1.0;
60+
61+
float aux_avgPos_ = 0;
62+
63+
for (auto& hit : hits) {
64+
aux_avgPos_ += hit.wireHorizPos();
65+
}
66+
67+
return aux_avgPos_ / nhits_;
68+
}
69+
70+
float compute_avg_time(DTPrimitives& hits) {
71+
int nhits_ = hits.size();
72+
73+
if (nhits_ == 0) return -1.0;
74+
75+
float aux_avgTime_ = 0;
76+
77+
for (auto& hit : hits) {
78+
aux_avgTime_ += hit.tdcTimeStamp();
79+
}
80+
return aux_avgTime_ / nhits_;
81+
}
82+
83+
void set_wires_profile(std::vector<int>& wires_profile, DTPrimitives& hits) {
84+
for (auto& hit : hits) {
85+
wires_profile[hit.channelId()-1]++;
86+
}
87+
}
88+
89+
bool buffer_contains(const ShowerBuffer& buffer, const DTPrimitive& hit) {
90+
for (const auto& item : buffer) {
91+
if (item.second.channelId() == hit.channelId()) return true;
92+
}
93+
return false;
94+
}
95+
96+
void buffer_get_hits(const ShowerBuffer& buffer, DTPrimitives& hits) {
97+
for (const auto& item : buffer) {
98+
hits.push_back(item.second);
99+
}
100+
}
101+
102+
void buffer_clear_olds(ShowerBuffer& buffer, const int _current_bx, const int persistence_bx_units) {
103+
while (!buffer.empty() && (_current_bx - buffer.front().first) > persistence_bx_units) {
104+
buffer.pop_front();
105+
}
106+
}
107+
108+
void buffer_reset(ShowerBuffer& buffer) {
109+
buffer.clear();
110+
}
111+
}
112+
113+
// ===============================================================================
114+
// Class declarations
115+
// ===============================================================================
116+
117+
class ShowerBuilder {
118+
119+
public:
120+
// Constructors and destructor
121+
ShowerBuilder(const edm::ParameterSet& pset, edm::ConsumesCollector& iC);
122+
virtual ~ShowerBuilder();
123+
124+
// Main methods
125+
virtual void initialise(const edm::EventSetup& iEventSetup);
126+
virtual void run(edm::Event& iEvent,
127+
const edm::EventSetup& iEventSetup,
128+
const DTDigiCollection& digis,
129+
ShowerCandidatePtr &showerCandidate_SL1,
130+
ShowerCandidatePtr &showerCandidate_SL3);
131+
virtual void finish();
132+
133+
private:
134+
// Private auxiliary methods
135+
void clear();
136+
void setInChannels(const DTDigiCollection* digi);
137+
void processHits_standAlone(std::map<int, ShowerCandidatePtr> &showerCands);
138+
void processHitsFirmwareEmulation(std::map<int, ShowerCandidatePtr> &showerCands);
139+
140+
bool triggerShower(const showerb::ShowerBuffer& buffer);
141+
void set_shower_properties(
142+
ShowerCandidatePtr &showerCand,
143+
showerb::ShowerBuffer& buffer,
144+
int nhits = -1,
145+
int bx = -1,
146+
int min_wire = -1,
147+
int max_wire = -1,
148+
float avg_pos = -1.,
149+
float avg_time = -1.
150+
);
151+
void groupHits_byBx();
152+
void fill_obdt(const int bx);
153+
void fill_bmtl1_buffers();
154+
void bxStep(const int _current_bx);
155+
156+
// Private attributes
157+
const int showerTaggingAlgo_;
158+
const int threshold_for_shower_;
159+
const int nHits_per_bx_;
160+
const int obdt_hits_bxpersistence_;
161+
const int obdt_wire_relaxing_time_;
162+
const int bmtl1_hits_bxpersistence_;
163+
const bool debug_;
164+
const int scenario_;
165+
166+
// auxiliary variables
167+
DTPrimitives all_hits;
168+
std::map<int, DTPrimitives, std::less<int>> all_hits_perBx;
169+
showerb::ShowerBuffer obdt_buffer; // Buffer to emulate the OBDT behavior
170+
showerb::ShowerBuffer hot_wires_buffer; // Buffer to emulate the hot wires behavior
171+
showerb::ShowerBuffer bmtl1_sl1_buffer; // Buffer to emulate the BMTL1 shower buffer for SL1
172+
showerb::ShowerBuffer bmtl1_sl3_buffer; // Buffer to emulate the BMTL1 shower buffer for SL3
173+
};
174+
175+
#endif

0 commit comments

Comments
 (0)