test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
PrimitiveConverterRPC Class Reference

#include <PrimitiveConverterRPC.h>

Public Member Functions

l1t::EMTFHitExtraCollection convert (std::vector< L1TMuon::TriggerPrimitive > TriggPrim, int SectIndex, edm::ESHandle< RPCGeometry > rpc_geom)
 
std::vector< ConvertedHitfillConvHits (l1t::EMTFHitExtraCollection exHits)
 
 PrimitiveConverterRPC ()
 
bool sameRpcChamber (l1t::EMTFHitExtra hitA, l1t::EMTFHitExtra hitB)
 

Detailed Description

Definition at line 20 of file PrimitiveConverterRPC.h.

Constructor & Destructor Documentation

PrimitiveConverterRPC::PrimitiveConverterRPC ( )

Definition at line 9 of file PrimitiveConverterRPC.cc.

9  {
10 }

Member Function Documentation

l1t::EMTFHitExtraCollection PrimitiveConverterRPC::convert ( std::vector< L1TMuon::TriggerPrimitive TriggPrim,
int  SectIndex,
edm::ESHandle< RPCGeometry rpc_geom 
)

Get all the input variables

Definition at line 13 of file PrimitiveConverterRPC.cc.

References funct::abs(), L1TMuon::TriggerPrimitive::RPCData::bx, gather_cfg::cout, L1TMuon::TriggerPrimitive::detId(), PV3DBase< T, PVType, FrameType >::eta(), L1TMuon::TriggerPrimitive::getRPCData(), l1t::EMTFHit::ImportRPCDetId(), l1t::EMTFHit::ImportRPCDigi(), L1TMuon::TriggerPrimitive::RPCData::layer, PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), RPCDetId::region(), l1t::EMTFHit::RPC_DetId(), sameRpcChamber(), RPCDetId::sector(), l1t::EMTFHitExtra::set_eta(), l1t::EMTFHitExtra::set_layer(), l1t::EMTFHitExtra::set_phi_glob_deg(), l1t::EMTFHitExtra::set_phi_glob_rad(), l1t::EMTFHit::set_sector_index(), l1t::EMTFHit::set_strip_hi(), l1t::EMTFHit::set_strip_low(), L1TMuon::TriggerPrimitive::RPCData::strip, l1t::EMTFHit::Strip_hi(), and l1t::EMTFHit::Strip_low().

14  {
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
std::vector< EMTFHitExtra > EMTFHitExtraCollection
Definition: EMTFHitExtra.h:112
RPCDetId RPC_DetId() const
Definition: EMTFHit.h:55
int Strip_hi() const
Definition: EMTFHit.h:105
bool sameRpcChamber(l1t::EMTFHitExtra hitA, l1t::EMTFHitExtra hitB)
void set_eta(float val)
Definition: EMTFHitExtra.h:68
void set_sector_index(int bits)
Definition: EMTFHit.h:67
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const RPCData getRPCData() const
void ImportRPCDigi(const RPCDigi &_digi)
void set_phi_glob_deg(float val)
Definition: EMTFHitExtra.h:61
void set_strip_low(int bits)
Definition: EMTFHit.h:78
int Strip_low() const
Definition: EMTFHit.h:106
void set_strip_hi(int bits)
Definition: EMTFHit.h:77
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
void set_phi_glob_rad(float val)
Definition: EMTFHitExtra.h:62
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
tuple cout
Definition: gather_cfg.py:145
constexpr double pi()
Definition: Pi.h:31
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
std::vector< ConvertedHit > PrimitiveConverterRPC::fillConvHits ( l1t::EMTFHitExtraCollection  exHits)

Definition at line 106 of file PrimitiveConverterRPC.cc.

References l1t::EMTFHit::BX(), l1t::EMTFHit::CSC_ID(), l1t::EMTFHitExtra::Layer(), l1t::EMTFHit::Pattern(), l1t::EMTFHitExtra::Phi_hit(), l1t::EMTFHitExtra::Phi_loc_int(), l1t::EMTFHitExtra::Phi_zone(), l1t::EMTFHit::Quality(), l1t::EMTFHit::RPC_DetId(), l1t::EMTFHit::Sector_index(), ConvertedHit::SetNeighbor(), ConvertedHit::SetSectorIndex(), ConvertedHit::SetTP(), ConvertedHit::SetValues(), ConvertedHit::SetZhit(), l1t::EMTFHit::Station(), l1t::EMTFHit::Strip(), l1t::EMTFHit::Subsector(), l1t::EMTFHitExtra::Theta_int(), l1t::EMTFHit::Wire(), and l1t::EMTFHitExtra::Zone().

106  {
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 }
RPCDetId RPC_DetId() const
Definition: EMTFHit.h:55
int Quality() const
Definition: EMTFHit.h:108
int Sector_index() const
Definition: EMTFHit.h:95
int Strip() const
Definition: EMTFHit.h:104
void SetNeighbor(int neighbor)
int Theta_int() const
Definition: EMTFHitExtra.h:81
int Wire() const
Definition: EMTFHit.h:103
int Subsector() const
Definition: EMTFHit.h:96
int BX() const
Definition: EMTFHit.h:114
void SetTP(L1TMuon::TriggerPrimitive tp)
int Station() const
Definition: EMTFHit.h:92
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 Phi_hit() const
Definition: EMTFHitExtra.h:73
int Zone() const
Definition: EMTFHitExtra.h:72
int Phi_loc_int() const
Definition: EMTFHitExtra.h:75
int CSC_ID() const
Definition: EMTFHit.h:98
void SetSectorIndex(int sectorIndex)
bool PrimitiveConverterRPC::sameRpcChamber ( l1t::EMTFHitExtra  hitA,
l1t::EMTFHitExtra  hitB 
)

Definition at line 130 of file PrimitiveConverterRPC.cc.

References l1t::EMTFHit::Endcap(), l1t::EMTFHitExtra::Layer(), l1t::EMTFHit::Ring(), l1t::EMTFHit::Roll(), l1t::EMTFHit::Sector(), l1t::EMTFHit::Station(), and l1t::EMTFHit::Subsector().

Referenced by convert().

130  {
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 }
int Roll() const
Definition: EMTFHit.h:99
int Subsector() const
Definition: EMTFHit.h:96
int Sector() const
Definition: EMTFHit.h:94
int Ring() const
Definition: EMTFHit.h:93
int Station() const
Definition: EMTFHit.h:92
int Layer() const
Definition: EMTFHitExtra.h:71
int Endcap() const
Definition: EMTFHit.h:91