11 using namespace cmsdt;
16 LogDebug(
"RPCIntegrator") <<
"RPCIntegrator constructor";
28 LogDebug(
"RPCIntegrator") <<
"RPCIntegrator destructor";
33 LogDebug(
"RPCIntegrator") <<
"RPCIntegrator initialisation";
36 LogDebug(
"RPCIntegrator") <<
"Getting RPC geometry";
39 dtGeo_ = &geom.
get(dtGeomH_);
40 rpcGeo_ = &geom.
get(rpcGeomH_);
41 shift_back_ = shift_back_fromDT;
47 RPCMetaprimitives_.clear();
48 rpcRecHits_translated_.clear();
49 for (
const auto& rpcIt : *rpcRecHits) {
51 GlobalPoint global_position = RPCGlobalPosition(rpcDetId, rpcIt);
52 int rpc_region = rpcDetId.
region();
58 RPCMetaprimitives_.emplace_back(
63 for (
auto dt_metaprimitive = dt_metaprimitives.begin(); dt_metaprimitive != dt_metaprimitives.end();
66 if (bestMatch_rpcRecHit) {
68 if ((*dt_metaprimitive).quality < m_max_quality_to_overwrite_t0_) {
69 (*dt_metaprimitive).t0 = bestMatch_rpcRecHit->
rpc_t0 + 25 * shift_back_;
70 (*dt_metaprimitive).rpcFlag =
RPC_TIME;
77 std::vector<L1Phase2MuDTPhDigi> rpc_only_segments;
78 for (
auto& rpc_mp_it_layer1 : RPCMetaprimitives_) {
79 RPCDetId rpc_id_l1 = rpc_mp_it_layer1.rpc_id;
80 const RPCRecHit* rpc_cluster_l1 = rpc_mp_it_layer1.rpc_cluster;
81 GlobalPoint rpc_gp_l1 = rpc_mp_it_layer1.global_position;
83 (rpc_mp_it_layer1.rpcFlag ==
RPC_ASSOCIATE && !m_storeAllRPCHits_))
90 for (
auto& rpc_mp_it_layer2 : RPCMetaprimitives_) {
91 RPCDetId rpc_id_l2 = rpc_mp_it_layer2.rpc_id;
92 const RPCRecHit* rpc_cluster_l2 = rpc_mp_it_layer2.rpc_cluster;
93 GlobalPoint rpc_gp_l2 = rpc_mp_it_layer2.global_position;
97 (rpc_mp_it_layer2.rpcFlag !=
RPC_ASSOCIATE || m_storeAllRPCHits_)) {
100 float tmp_dPhi = rpc_gp_l1.
phi() - rpc_gp_l2.
phi();
103 bestMatch_rpc_mp_layer2 = &rpc_mp_it_layer2;
107 if (bestMatch_rpc_mp_layer2) {
111 bestMatch_rpc_mp_layer2->
rpcFlag = 6;
112 double phiB = phiBending(&rpc_mp_it_layer1, &*bestMatch_rpc_mp_layer2);
114 double global_phi = rpc_mp_it_layer1.global_position.phi();
115 double t0 = (rpc_mp_it_layer1.rpc_t0 + bestMatch_rpc_mp_layer2->
rpc_t0) / 2;
118 createL1Phase2MuDTPhDigi(rpc_id_l1, rpc_mp_it_layer1.rpc_bx, t0, global_phi, phiB, 2);
119 rpc_only_segments.push_back(rpc_only_segment);
122 rpcRecHits_translated_.insert(rpcRecHits_translated_.end(), rpc_only_segments.begin(), rpc_only_segments.end());
126 for (
auto rpc_mp_it = RPCMetaprimitives_.begin(); rpc_mp_it != RPCMetaprimitives_.end(); rpc_mp_it++) {
127 RPCDetId rpcDetId = rpc_mp_it->rpc_id;
128 if (rpc_mp_it->rpcFlag == 6)
131 rpcDetId, rpc_mp_it->rpc_bx, rpc_mp_it->rpc_t0, rpc_mp_it->global_position.phi(), -10000, rpc_mp_it->rpcFlag);
132 rpcRecHits_translated_.push_back(rpc_out);
138 LogDebug(
"RPCIntegrator") <<
"RPCIntegrator removeRPCHitsUsed method";
139 if (!m_storeAllRPCHits_) {
142 auto rpcRecHit_translated_ = rpcRecHits_translated_.begin();
143 while (rpcRecHit_translated_ != rpcRecHits_translated_.end()) {
144 if (rpcRecHit_translated_->rpcFlag() ==
RPC_ASSOCIATE || rpcRecHit_translated_->rpcFlag() == 6) {
145 rpcRecHit_translated_ = rpcRecHits_translated_.erase(rpcRecHit_translated_);
147 ++rpcRecHit_translated_;
157 int dt_bx = (int)round(dt_metaprimitive->
t0 / 25.) - shift_back_;
159 int dt_sector = dt_chId.
sector();
166 for (
auto rpc_mp_it = RPCMetaprimitives_.begin(); rpc_mp_it != RPCMetaprimitives_.end(); rpc_mp_it++) {
167 RPCDetId rpc_det_id = rpc_mp_it->rpc_id;
170 std::abs(rpc_mp_it->rpc_bx - dt_bx) <= m_bx_window_) {
175 (int)round((phi_DT_MP_conv(rpc_mp_it->global_position.phi(), rpc_det_id.
sector()) - dt_metaprimitive->
phi) *
176 m_dt_phiB_granularity_);
177 if (
std::abs(delta_phi) < min_dPhi &&
std::abs(delta_phi) < m_phi_window_) {
179 bestMatch_rpcRecHit = &*rpc_mp_it;
183 if (bestMatch_rpcRecHit) {
186 return bestMatch_rpcRecHit;
190 RPCDetId rpcDetId,
int rpc_bx,
double rpc_time,
double rpc_global_phi,
double phiB,
int rpc_flag) {
192 LogDebug(
"RPCIntegrator") <<
"Creating DT TP out of RPC recHits";
193 int rpc_wheel = rpcDetId.
ring();
194 int trigger_sector = rpcDetId.
sector() - 1;
195 int rpc_station = rpcDetId.
station();
196 int rpc_layer = rpcDetId.
layer();
197 int rpc_trigger_phi = phiInDTTPFormat(rpc_global_phi, rpcDetId.
sector());
198 int rpc_trigger_phiB = (phiB == -10000) ? phiB : (
int)round(phiB * m_dt_phiB_granularity_);
199 int rpc_quality = -1;
219 double slope = (lp_rpc_hit_1_dtconv.x() - lp_rpc_hit_2_dtconv.
x()) / distance_between_two_rpc_layers_;
220 double average_x = (lp_rpc_hit_1_dtconv.x() + lp_rpc_hit_2_dtconv.
x()) / 2;
222 dtGeo_->chamber(DT_chamber)->toGlobal(
LocalPoint(average_x, 0., 0.));
223 double seg_phi = phi_DT_MP_conv(seg_middle_global.
phi(), rpc_hit_1->
rpc_id.
sector());
224 double psi = atan(slope);
225 double phiB = hasPosRF_rpc(rpc_hit_1->
rpc_id.
ring(), rpc_hit_1->
rpc_id.
sector()) ? psi - seg_phi : -psi - seg_phi;
230 double rpc_localDT_phi;
231 rpc_localDT_phi = phi_DT_MP_conv(rpc_global_phi, rpcSector) * m_dt_phi_granularity_;
232 return (
int)round(rpc_localDT_phi);
239 return rpc_global_phi;
242 if (rpc_global_phi >= 0)
243 return rpc_global_phi - (rpcSector - 1) *
M_PI * conversion;
245 return rpc_global_phi + (13 - rpcSector) *
M_PI * conversion;
252 const GlobalPoint& rpc_gp = rpcGeo_->idToDet(rpcid)->surface().toGlobal(rpc_lp);
T getUntrackedParameter(std::string const &, T const &) const
void storeRPCSingleHits()
Point3DBase< Scalar, LocalTag > LocalPoint
LocalPoint localPosition() const override
Return the 3-dimensional local position.
static const double slope[3]
void matchWithDTAndUseRPCTime(std::vector< cmsdt::metaPrimitive > &dt_metaprimitives)
Geom::Phi< T > phi() const
L1Phase2MuDTPhDigi createL1Phase2MuDTPhDigi(RPCDetId rpcDetId, int rpc_bx, double rpc_time, double rpc_global_phi, double phiB, int rpc_flag)
double phi_DT_MP_conv(double rpc_global_phi, int rpcSector)
std::map< std::string, int, std::less< std::string > > psi
GlobalPoint RPCGlobalPosition(RPCDetId rpcId, const RPCRecHit &rpcIt) const
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Abs< T >::type abs(const T &t)
void makeRPCOnlySegments()
RPCIntegrator(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
double delta_phi(double ph11, double phi2)
void conversion(EventAux const &from, EventAuxiliary &to)
bool hasPosRF_rpc(int wh, int sec) const
constexpr int LHC_CLK_FREQ
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
void prepareMetaPrimitives(edm::Handle< RPCRecHitCollection > rpcRecHits)
double phiBending(RPCMetaprimitive *rpc_hit_1, RPCMetaprimitive *rpc_hit_2)
int phiInDTTPFormat(double rpc_global_phi, int rpcSector)
void initialise(const edm::EventSetup &iEventSetup, double shift_back_fromDT)
int station() const
Return the station number.
int wheel() const
Return the wheel number.
RPCMetaprimitive * matchDTwithRPC(cmsdt::metaPrimitive *dt_metaprimitive)
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.