CMS 3D CMS Logo

PrimitiveConverterRPC.cc
Go to the documentation of this file.
1 
8 
10 }
11 
13 PrimitiveConverterRPC::convert( std::vector<L1TMuon::TriggerPrimitive> TrigPrim,
14  int SectIndex, edm::ESHandle<RPCGeometry> rpc_geom ) {
15 
16  // bool verbose = true;
17  bool verbose = false;
18 
19 
20  if (verbose) std::cout << "\n========== RPC Primitive Converter ==========" << std::endl;
21 
23  for (std::vector<L1TMuon::TriggerPrimitive>::iterator iter = TrigPrim.begin(); iter != TrigPrim.end(); iter++) {
24 
26  L1TMuon::TriggerPrimitive prim = *iter; // Eventually would like to deprecate TriggerPrimitive entirely - AWB 03.06.16
27  RPCDetId detID = prim.detId<RPCDetId>();
28  RPCDigi digi = RPCDigi( prim.getRPCData().strip, prim.getRPCData().bx );
29 
30  // Only include RPC hits from correct sector in endcap
31  if ( abs(detID.region()) != 1 ) continue;
32  if ( SectIndex != (detID.sector() - 1) + (detID.region() == -1)*6 ) continue;
33 
34  l1t::EMTFHitExtra thisHit;
35  thisHit.ImportRPCDetId( detID );
36  thisHit.ImportRPCDigi( digi );
37  thisHit.set_sector_index( SectIndex );
38  thisHit.set_layer( prim.getRPCData().layer ); // In RE1/2 there are two layers of chambers: 1 is inner (front) and 2 is outer (rear)
39 
40  tmpHits.push_back( thisHit );
41  }
42 
44  for (unsigned int iHit = 0; iHit < tmpHits.size(); iHit++) {
45  l1t::EMTFHitExtra hit1 = tmpHits.at(iHit);
46 
47  // Skip hit if it is already in a cluster
48  bool hit_in_cluster = false;
49  for (unsigned int jHit = 0; jHit < clustHits.size(); jHit++) {
50  l1t::EMTFHitExtra clustHit = clustHits.at(jHit);
51  if ( sameRpcChamber(hit1, clustHit) && hit1.Strip_hi() <= clustHit.Strip_hi() &&
52  hit1.Strip_low() >= clustHit.Strip_low() ) hit_in_cluster = true;
53  }
54  if (hit_in_cluster) continue;
55 
56  // Cluster adjascent strip hits. Phi of cluster corresponds to central strip.
57  // Does this clustering catch all the hits in large clusters? - AWB 03.06.16
58  int prevHi = -999, prevLow = -999;
59  while (hit1.Strip_hi() != prevHi || hit1.Strip_low() != prevLow) {
60  prevHi = hit1.Strip_hi();
61  prevLow = hit1.Strip_low();
62 
63  for (unsigned int jHit = 0; jHit < tmpHits.size(); jHit++) {
64  if (iHit == jHit) continue;
65  l1t::EMTFHitExtra hit2 = tmpHits.at(jHit);
66 
67  if (not sameRpcChamber(hit1, hit2)) continue;
68  if (hit2.Strip_hi() == hit1.Strip_hi() + 1) hit1.set_strip_hi ( hit2.Strip_hi() );
69  if (hit2.Strip_low() == hit1.Strip_low() - 1) hit1.set_strip_low( hit2.Strip_low() );
70  }
71  }
72 
73  // Get phi and eta
74  std::unique_ptr<const RPCRoll> roll(rpc_geom->roll( hit1.RPC_DetId() ));
75  const LocalPoint lpHi = roll->centreOfStrip(hit1.Strip_hi());
76  const GlobalPoint gpHi = roll->toGlobal(lpHi);
77  const LocalPoint lpLow = roll->centreOfStrip(hit1.Strip_low());
78  const GlobalPoint gpLow = roll->toGlobal(lpLow);
79  roll.release();
80 
81  float glob_phi_hi = gpHi.phi(); // Averaging global point phi's directly does weird things,
82  float glob_phi_low = gpLow.phi(); // e.g. 2*pi/3 + 2*pi/3 = 4*pi/3 = -2*pi/3, so avg. = -pi/3, not 2*pi/3
83  float glob_phi = (glob_phi_hi + glob_phi_low) / 2.0;
84  float glob_eta = (gpHi.eta() + gpLow.eta()) / 2.0;
85 
86  if (verbose) std::cout << "RPC cluster phi = " << glob_phi << " (" << glob_phi_hi << ", " << glob_phi_low
87  << "), eta = " << glob_eta << " (" << gpHi.eta() << ", " << gpLow.eta() << ")" << std::endl;
88 
89  hit1.set_phi_glob_rad( glob_phi );
90  hit1.set_phi_glob_deg( glob_phi*180/Geom::pi() );
91  hit1.set_eta( glob_eta );
92  clustHits.push_back( hit1 );
93 
94  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
95  // Need to set phi_loc_int, theta_int, phi_hit, zone, csc_ID, quality,
96  // pattern, wire, strip, phi_zone, and zone_contribution
97  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98 
99  } // End loop over iHit
100 
101  return clustHits;
102 
103 } // End PrimitiveConverterRPC::convert
104 
105 std::vector<ConvertedHit>
107 
108  std::vector<ConvertedHit> ConvHits;
109  for (unsigned int iHit = 0; iHit < exHits.size(); iHit++) {
110  l1t::EMTFHitExtra exHit = exHits.at(iHit);
111 
112  // // Replace with SetZoneWord - AWB 04.09.16
113  // std::vector<int> zone_contribution;
114 
115  ConvertedHit ConvHit;
116  ConvHit.SetValues(exHit.Phi_loc_int(), exHit.Theta_int(), exHit.Phi_hit(), exHit.Zone(),
117  exHit.Station(), exHit.Subsector(), exHit.CSC_ID(), exHit.Quality(),
118  exHit.Pattern(), exHit.Wire(), exHit.Strip(), exHit.BX() + 6);
119  ConvHit.SetTP( L1TMuon::TriggerPrimitive( exHit.RPC_DetId(), exHit.Strip(), exHit.Layer(), exHit.BX() + 6 ) );
120  ConvHit.SetZhit( exHit.Phi_zone() );
121  // // Replace with SetZoneWord - AWB 04.09.16
122  // ConvHit.SetZoneContribution(zone_contribution);
123  ConvHit.SetSectorIndex( exHit.Sector_index() );
124  ConvHit.SetNeighbor(0);
125  ConvHits.push_back(ConvHit);
126  }
127  return ConvHits;
128 }
129 
131 
132  if ( hitA.Endcap() == hitB.Endcap() && hitA.Station() == hitB.Station() && hitA.Ring() == hitB.Ring() &&
133  hitA.Roll() == hitB.Roll() && hitA.Sector() == hitB.Sector() && hitA.Subsector() == hitB.Subsector() &&
134  hitA.Layer() == hitB.Layer() ) return true;
135  else return false;
136 }
std::vector< EMTFHitExtra > EMTFHitExtraCollection
Definition: EMTFHitExtra.h:112
RPCDetId RPC_DetId() const
Definition: EMTFHit.h:55
int Strip_hi() const
Definition: EMTFHit.h:105
int Quality() const
Definition: EMTFHit.h:108
bool sameRpcChamber(l1t::EMTFHitExtra hitA, l1t::EMTFHitExtra hitB)
void set_eta(float val)
Definition: EMTFHitExtra.h:68
int Sector_index() const
Definition: EMTFHit.h:95
int Strip() const
Definition: EMTFHit.h:104
void set_sector_index(int bits)
Definition: EMTFHit.h:67
void SetNeighbor(int neighbor)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
int Theta_int() const
Definition: EMTFHitExtra.h:81
int Roll() const
Definition: EMTFHit.h:99
l1t::EMTFHitExtraCollection convert(std::vector< L1TMuon::TriggerPrimitive > TriggPrim, int SectIndex, edm::ESHandle< RPCGeometry > rpc_geom)
const RPCData getRPCData() const
void ImportRPCDigi(const RPCDigi &_digi)
int Wire() const
Definition: EMTFHit.h:103
void set_phi_glob_deg(float val)
Definition: EMTFHitExtra.h:61
int Subsector() const
Definition: EMTFHit.h:96
int Sector() const
Definition: EMTFHit.h:94
void set_strip_low(int bits)
Definition: EMTFHit.h:78
int Strip_low() const
Definition: EMTFHit.h:106
int BX() const
Definition: EMTFHit.h:114
void set_strip_hi(int bits)
Definition: EMTFHit.h:77
void SetTP(L1TMuon::TriggerPrimitive tp)
std::vector< ConvertedHit > fillConvHits(l1t::EMTFHitExtraCollection exHits)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void set_layer(int bits)
Definition: EMTFHitExtra.h:54
void ImportRPCDetId(const RPCDetId &_detId)
Definition: EMTFHitTools.cc:45
int Ring() const
Definition: EMTFHit.h:93
void set_phi_glob_rad(float val)
Definition: EMTFHitExtra.h:62
int Station() const
Definition: EMTFHit.h:92
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
T eta() const
Definition: PV3DBase.h:76
int Pattern() const
Definition: EMTFHit.h:109
void SetZhit(int zhit)
void SetValues(int phi, int theta, int ph_hit, int phzvl, int station, int sub, int id, int quality, int pattern, int wire, int strip, int BX)
int Layer() const
Definition: EMTFHitExtra.h:71
int Phi_zone() const
Definition: EMTFHitExtra.h:74
int Endcap() const
Definition: EMTFHit.h:91
int Phi_hit() const
Definition: EMTFHitExtra.h:73
constexpr double pi()
Definition: Pi.h:31
int Zone() const
Definition: EMTFHitExtra.h:72
int Phi_loc_int() const
Definition: EMTFHitExtra.h:75
int CSC_ID() const
Definition: EMTFHit.h:98
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:75
void SetSectorIndex(int sectorIndex)
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63