CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCSegtoRPC Class Reference

#include <CSCSegtoRPC.h>

Public Member Functions

 CSCSegtoRPC (edm::ConsumesCollector iC)
 
std::unique_ptr< RPCRecHitCollectionthePoints (CSCSegmentCollection const *allCSCSegments, edm::EventSetup const &iSetup, bool debug, double eyr)
 

Private Attributes

edm::ESGetToken< CSCGeometry, MuonGeometryRecordcscGeoToken_
 
edm::ESGetToken< CSCObjectMap, MuonGeometryRecordcscMapToken_
 
edm::ESGetToken< RPCGeometry, MuonGeometryRecordrpcGeoToken_
 

Detailed Description

Definition at line 17 of file CSCSegtoRPC.h.

Constructor & Destructor Documentation

◆ CSCSegtoRPC()

CSCSegtoRPC::CSCSegtoRPC ( edm::ConsumesCollector  iC)
explicit

Definition at line 15 of file CSCSegtoRPC.cc.

Member Function Documentation

◆ thePoints()

std::unique_ptr< RPCRecHitCollection > CSCSegtoRPC::thePoints ( CSCSegmentCollection const *  allCSCSegments,
edm::EventSetup const &  iSetup,
bool  debug,
double  eyr 
)

Definition at line 18 of file CSCSegtoRPC.cc.

21  {
22  edm::ESHandle<RPCGeometry> rpcGeo = iSetup.getHandle(rpcGeoToken_);
23  edm::ESHandle<CSCGeometry> cscGeo = iSetup.getHandle(cscGeoToken_);
24  edm::ESHandle<CSCObjectMap> cscMap = iSetup.getHandle(cscMapToken_);
25 
26  double MaxD = 80.;
27 
28  if (debug)
29  std::cout << "CSC \t Number of CSC Segments in this event = " << allCSCSegments->size() << std::endl;
30 
31  auto _ThePoints = std::make_unique<RPCRecHitCollection>();
32  edm::OwnVector<RPCRecHit> RPCPointVector;
33 
34  if (allCSCSegments->size() == 0) {
35  if (debug)
36  std::cout << "CSC 0 segments skiping event" << std::endl;
37  } else {
38  std::map<CSCDetId, int> CSCSegmentsCounter;
40 
41  int segmentsInThisEventInTheEndcap = 0;
42 
43  for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
44  CSCSegmentsCounter[segment->cscDetId()]++;
45  segmentsInThisEventInTheEndcap++;
46  }
47 
48  if (debug)
49  std::cout << "CSC \t loop over all the CSCSegments " << std::endl;
50  for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
51  CSCDetId CSCId = segment->cscDetId();
52 
53  if (debug)
54  std::cout << "CSC \t \t This Segment is in Chamber id: " << CSCId << std::endl;
55  if (debug)
56  std::cout << "CSC \t \t Number of segments in this CSC = " << CSCSegmentsCounter[CSCId] << std::endl;
57  if (debug)
58  std::cout << "CSC \t \t Is the only one in this CSC? is not ind the ring 1 or station 4? Are there more than 2 "
59  "segments in the event?"
60  << std::endl;
61 
62  if (CSCSegmentsCounter[CSCId] == 1 && CSCId.station() != 4 && CSCId.ring() != 1 && allCSCSegments->size() >= 2) {
63  if (debug)
64  std::cout << "CSC \t \t yes" << std::endl;
65  int cscEndCap = CSCId.endcap();
66  int cscStation = CSCId.station();
67  int cscRing = CSCId.ring();
68  int rpcRegion = 1;
69  if (cscEndCap == 2)
70  rpcRegion = -1; //Relacion entre las endcaps
71  int rpcRing = cscRing;
72  if (cscRing == 4)
73  rpcRing = 1;
74  int rpcStation = cscStation;
75  int rpcSegment = CSCId.chamber();
76 
77  LocalPoint segmentPosition = segment->localPosition();
78  LocalVector segmentDirection = segment->localDirection();
79  float dz = segmentDirection.z();
80 
81  if (debug)
82  std::cout << "CSC \t \t \t Information about the segment"
83  << "RecHits =" << segment->nRecHits() << "Angle =" << acos(dz) * 180 / 3.1415926 << std::endl;
84 
85  if (debug)
86  std::cout << "CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < "
87  << acos(dz) * 180 / 3.1415926 << " < 135? " << std::endl;
88 
89  if ((segment->dimension() == 4) && (segment->nRecHits() <= 10 && segment->nRecHits() >= 4)) {
90  //&& acos(dz)*180/3.1415926 > 45. && acos(dz)*180/3.1415926 < 135.){
91  //&& segment->chi2()< ??)Add 3 segmentes in the endcaps???
92 
93  if (debug)
94  std::cout << "CSC \t \t yes" << std::endl;
95  if (debug)
96  std::cout << "CSC \t \t CSC Segment Dimension " << segment->dimension() << std::endl;
97 
98  float Xo = segmentPosition.x();
99  float Yo = segmentPosition.y();
100  float Zo = segmentPosition.z();
101  float dx = segmentDirection.x();
102  float dy = segmentDirection.y();
103  float dz = segmentDirection.z();
104 
105  if (debug)
106  std::cout << "Creating the CSCIndex" << std::endl;
107  CSCStationIndex theindex(rpcRegion, rpcStation, rpcRing, rpcSegment);
108  if (debug)
109  std::cout << "Getting the Rolls for the given index" << std::endl;
110  std::set<RPCDetId> rollsForThisCSC = cscMap->getRolls(theindex);
111  if (debug)
112  std::cout << "CSC \t \t Getting chamber from Geometry" << std::endl;
113  const CSCChamber* TheChamber = cscGeo->chamber(CSCId);
114  if (debug)
115  std::cout << "CSC \t \t Getting ID from Chamber" << std::endl;
116  const CSCDetId TheId = TheChamber->id();
117 
118  if (debug)
119  std::cout << "CSC \t \t Number of rolls for this CSC = " << rollsForThisCSC.size() << std::endl;
120 
121  if (debug)
122  std::cout << "CSC \t \t Printing The Id" << TheId << std::endl;
123 
124  if (rpcRing != 1 && rpcStation != 4) { //They don't exist!
125 
126  assert(!rollsForThisCSC.empty());
127 
128  if (debug)
129  std::cout << "CSC \t \t Loop over all the rolls asociated to this CSC" << std::endl;
130  for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin(); iteraRoll != rollsForThisCSC.end();
131  iteraRoll++) {
132  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
133  RPCDetId rpcId = rollasociated->id();
134 
135  if (debug)
136  std::cout << "CSC \t \t \t We are in the roll getting the surface" << rpcId << std::endl;
137  const BoundPlane& RPCSurface = rollasociated->surface();
138 
139  if (debug)
140  std::cout << "CSC \t \t \t RollID: " << rpcId << std::endl;
141 
142  if (debug)
143  std::cout << "CSC \t \t \t Doing the extrapolation to this roll" << std::endl;
144  if (debug)
145  std::cout << "CSC \t \t \t CSC Segment Direction in CSCLocal " << segmentDirection << std::endl;
146  if (debug)
147  std::cout << "CSC \t \t \t CSC Segment Point in CSCLocal " << segmentPosition << std::endl;
148 
149  GlobalPoint CenterPointRollGlobal = RPCSurface.toGlobal(LocalPoint(0, 0, 0));
150  if (debug)
151  std::cout << "CSC \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal << std::endl;
152  GlobalPoint CenterPointCSCGlobal = TheChamber->toGlobal(LocalPoint(0, 0, 0));
153  if (debug)
154  std::cout << "CSC \t \t \t Center (0,0,0) of the CSC in Global" << CenterPointCSCGlobal << std::endl;
155  GlobalPoint segmentPositionInGlobal =
156  TheChamber->toGlobal(segmentPosition); //new way to convert to global
157  if (debug)
158  std::cout << "CSC \t \t \t Segment Position in Global" << segmentPositionInGlobal << std::endl;
159  LocalPoint CenterRollinCSCFrame = TheChamber->toLocal(CenterPointRollGlobal);
160 
161  if (debug) { //to check CSC RPC phi relation!
162  float rpcphi = 0;
163  float cscphi = 0;
164 
165  (CenterPointRollGlobal.barePhi() < 0) ? rpcphi = 2 * 3.141592 + CenterPointRollGlobal.barePhi()
166  : rpcphi = CenterPointRollGlobal.barePhi();
167 
168  (CenterPointCSCGlobal.barePhi() < 0) ? cscphi = 2 * 3.1415926536 + CenterPointCSCGlobal.barePhi()
169  : cscphi = CenterPointCSCGlobal.barePhi();
170 
171  float df = fabs(cscphi - rpcphi);
172  float dr = fabs(CenterPointRollGlobal.perp() - CenterPointCSCGlobal.perp());
173  float diffz = CenterPointRollGlobal.z() - CenterPointCSCGlobal.z();
174  float dfg = df * 180. / 3.14159265;
175 
176  if (debug)
177  std::cout << "CSC \t \t \t z of RPC=" << CenterPointRollGlobal.z() << "z of CSC"
178  << CenterPointCSCGlobal.z() << " dfg=" << dfg << std::endl;
179 
180  RPCGeomServ rpcsrv(rpcId);
181 
182  if (dr > 200. || fabs(dz) > 55. || dfg > 1.) {
183  //if(rpcRegion==1&&dfg>1.&&dr>100.){
184  if (debug)
185  std::cout << "\t \t \t CSC Station= " << CSCId.station() << " Ring= " << CSCId.ring()
186  << " Chamber= " << CSCId.chamber() << " cscphi=" << cscphi * 180 / 3.14159265
187  << "\t RPC Station= " << rpcId.station() << " ring= " << rpcId.ring() << " segment =-> "
188  << rpcsrv.segment() << " rollphi=" << rpcphi * 180 / 3.14159265 << "\t dfg=" << dfg
189  << " dz=" << diffz << " dr=" << dr << std::endl;
190  }
191  }
192 
193  float D = CenterRollinCSCFrame.z();
194 
195  float X = Xo + dx * D / dz;
196  float Y = Yo + dy * D / dz;
197  float Z = D;
198 
199  const TrapezoidalStripTopology* top_ =
200  dynamic_cast<const TrapezoidalStripTopology*>(&(rollasociated->topology()));
201  LocalPoint xmin = top_->localPosition(0.);
202  if (debug)
203  std::cout << "CSC \t \t \t xmin of this Roll " << xmin << "cm" << std::endl;
204  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
205  if (debug)
206  std::cout << "CSC \t \t \t xmax of this Roll " << xmax << "cm" << std::endl;
207  float rsize = fabs(xmax.x() - xmin.x());
208  if (debug)
209  std::cout << "CSC \t \t \t Roll Size " << rsize << "cm" << std::endl;
210  float stripl = top_->stripLength();
211  float stripw = top_->pitch();
212 
213  if (debug)
214  std::cout << "CSC \t \t \t Strip Lenght " << stripl << "cm" << std::endl;
215  if (debug)
216  std::cout << "CSC \t \t \t Strip Width " << stripw << "cm" << std::endl;
217 
218  if (debug)
219  std::cout << "CSC \t \t \t X Predicted in CSCLocal= " << X << "cm" << std::endl;
220  if (debug)
221  std::cout << "CSC \t \t \t Y Predicted in CSCLocal= " << Y << "cm" << std::endl;
222  if (debug)
223  std::cout << "CSC \t \t \t Z Predicted in CSCLocal= " << Z << "cm" << std::endl;
224 
225  float extrapolatedDistance = sqrt((X - Xo) * (X - Xo) + (Y - Yo) * (Y - Yo) + (Z - Zo) * (Z - Zo));
226 
227  if (debug)
228  std::cout << "CSC \t \t \t Is the distance of extrapolation less than MaxD? =" << extrapolatedDistance
229  << "cm"
230  << " MaxD=" << MaxD << "cm" << std::endl;
231 
232  if (extrapolatedDistance <= MaxD) {
233  if (debug)
234  std::cout << "CSC \t \t \t yes" << std::endl;
235 
236  GlobalPoint GlobalPointExtrapolated = TheChamber->toGlobal(LocalPoint(X, Y, Z));
237  if (debug)
238  std::cout << "CSC \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
239 
240  LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
241 
242  if (debug)
243  std::cout << "CSC \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
244  if (debug)
245  std::cout << "CSC \t \t \t Corner of the Roll = (" << rsize * eyr << "," << stripl * eyr << ")"
246  << std::endl;
247  if (debug)
248  std::cout << "CSC \t \t \t Info About the Point Extrapolated in X Abs ("
249  << fabs(PointExtrapolatedRPCFrame.x()) << "," << fabs(PointExtrapolatedRPCFrame.y()) << ","
250  << fabs(PointExtrapolatedRPCFrame.z()) << ")" << std::endl;
251  if (debug)
252  std::cout << "CSC \t \t \t dz=" << fabs(PointExtrapolatedRPCFrame.z())
253  << " dx=" << fabs(PointExtrapolatedRPCFrame.x())
254  << " dy=" << fabs(PointExtrapolatedRPCFrame.y()) << std::endl;
255 
256  if (debug)
257  std::cout << "CSC \t \t \t Does the extrapolation go inside this roll????" << std::endl;
258 
259  if (fabs(PointExtrapolatedRPCFrame.z()) < 1. && fabs(PointExtrapolatedRPCFrame.x()) < rsize * eyr &&
260  fabs(PointExtrapolatedRPCFrame.y()) < stripl * eyr) {
261  if (debug)
262  std::cout << "CSC \t \t \t \t yes" << std::endl;
263  if (debug)
264  std::cout << "CSC \t \t \t \t Creating the RecHit" << std::endl;
265  RPCRecHit RPCPoint(rpcId, 0, PointExtrapolatedRPCFrame);
266  if (debug)
267  std::cout << "CSC \t \t \t \t Clearing the vector" << std::endl;
268  RPCPointVector.clear();
269  if (debug)
270  std::cout << "CSC \t \t \t \t Pushing back" << std::endl;
271  RPCPointVector.push_back(RPCPoint);
272  if (debug)
273  std::cout << "CSC \t \t \t \t Putting the vector" << std::endl;
274  _ThePoints->put(rpcId, RPCPointVector.begin(), RPCPointVector.end());
275  }
276  }
277  }
278  }
279  }
280  }
281  }
282  }
283  return _ThePoints;
284 }

References cms::cuda::assert(), PV3DBase< T, PVType, FrameType >::barePhi(), edm::OwnVector< T, P >::begin(), CSCDetId::chamber(), CSCGeometry::chamber(), edm::OwnVector< T, P >::clear(), gather_cfg::cout, cscGeoToken_, cscMapToken_, debug, hgcalPerformanceValidation::df, flavorHistoryFilter_cfi::dr, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, edm::OwnVector< T, P >::end(), CSCDetId::endcap(), edm::EventSetup::getHandle(), CSCObjectMap::getRolls(), RPCRoll::id(), CSCChamber::id(), TrapezoidalStripTopology::localPosition(), RPCResidualsHLT_cfi::MaxD, RPCRoll::nstrips(), PV3DBase< T, PVType, FrameType >::perp(), TrapezoidalStripTopology::pitch(), edm::OwnVector< T, P >::push_back(), RPCDetId::ring(), CSCDetId::ring(), RPCGeometry::roll(), rpcGeoToken_, RPCGeomServ::segment(), mathSSE::sqrt(), RPCDetId::station(), CSCDetId::station(), TrapezoidalStripTopology::stripLength(), GeomDet::surface(), GeomDet::toGlobal(), GeomDet::toLocal(), RPCRoll::topology(), X, PV3DBase< T, PVType, FrameType >::x(), TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, BeamSpotPI::Y, PV3DBase< T, PVType, FrameType >::y(), BeamSpotPI::Z, and PV3DBase< T, PVType, FrameType >::z().

Member Data Documentation

◆ cscGeoToken_

edm::ESGetToken<CSCGeometry, MuonGeometryRecord> CSCSegtoRPC::cscGeoToken_
private

Definition at line 27 of file CSCSegtoRPC.h.

Referenced by thePoints().

◆ cscMapToken_

edm::ESGetToken<CSCObjectMap, MuonGeometryRecord> CSCSegtoRPC::cscMapToken_
private

Definition at line 28 of file CSCSegtoRPC.h.

Referenced by thePoints().

◆ rpcGeoToken_

edm::ESGetToken<RPCGeometry, MuonGeometryRecord> CSCSegtoRPC::rpcGeoToken_
private

Definition at line 26 of file CSCSegtoRPC.h.

Referenced by thePoints().

Vector3DBase< float, LocalTag >
RPCRoll
Definition: RPCRoll.h:12
TrapezoidalStripTopology::stripLength
float stripLength() const override
det heigth (strip length in the middle)
Definition: TrapezoidalStripTopology.h:63
RPCGeomServ
Definition: RPCGeomServ.h:8
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
CSCSegtoRPC::rpcGeoToken_
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeoToken_
Definition: CSCSegtoRPC.h:26
edm::OwnVector::end
iterator end()
Definition: OwnVector.h:285
CSCSegtoRPC::cscGeoToken_
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeoToken_
Definition: CSCSegtoRPC.h:27
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
X
#define X(str)
Definition: MuonsGrabber.cc:38
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::cuda::assert
assert(be >=bs)
RPCGeometry::roll
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
RPCRoll::topology
const Topology & topology() const override
Definition: RPCRoll.cc:18
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
RPCRoll::id
RPCDetId id() const
Definition: RPCRoll.cc:16
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
debug
#define debug
Definition: HDRShower.cc:19
TrapezoidalStripTopology
Definition: TrapezoidalStripTopology.h:21
RPCRecHit
Definition: RPCRecHit.h:14
CSCObjectMap::getRolls
std::set< RPCDetId > const & getRolls(CSCStationIndex index) const
Definition: CSCObjectMap.cc:42
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< RPCGeometry >
RPCResidualsHLT_cfi.MaxD
MaxD
Definition: RPCResidualsHLT_cfi.py:18
CSCChamber
Definition: CSCChamber.h:22
Point3DBase< float, LocalTag >
GeomDet::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
TrapezoidalStripTopology::pitch
float pitch() const override
Definition: TrapezoidalStripTopology.cc:106
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
RPCRoll::nstrips
int nstrips() const
Definition: RPCRoll.cc:24
PVValHelper::dy
Definition: PVValidationHelpers.h:50
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
funct::D
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
PVValHelper::dz
Definition: PVValidationHelpers.h:51
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
BoundPlane
BeamSpotPI::Y
Definition: BeamSpotPayloadInspectorHelper.h:32
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
TrapezoidalStripTopology::localPosition
LocalPoint localPosition(float strip) const override
Definition: TrapezoidalStripTopology.cc:27
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
BeamSpotPI::Z
Definition: BeamSpotPayloadInspectorHelper.h:33
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
edm::OwnVector::begin
iterator begin()
Definition: OwnVector.h:280
CSCChamber::id
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:34
CSCStationIndex
Definition: GEMCSCSegmentBuilder.h:32
edm::OwnVector::clear
void clear()
Definition: OwnVector.h:481
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PVValHelper::dx
Definition: PVValidationHelpers.h:49
CSCGeometry::chamber
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Definition: CSCGeometry.cc:100
CSCSegtoRPC::cscMapToken_
edm::ESGetToken< CSCObjectMap, MuonGeometryRecord > cscMapToken_
Definition: CSCSegtoRPC.h:28
edm::OwnVector
Definition: OwnVector.h:24