33 LogDebug(
"CSCSegtoRPC") <<
"CSC \t Number of CSC Segments in this event = " << allCSCSegments->size() << std::endl;
35 auto _ThePoints = std::make_unique<RPCRecHitCollection>();
38 if (allCSCSegments->size() == 0) {
40 LogDebug(
"CSCSegtoRPC") <<
"CSC 0 segments skiping event" << std::endl;
42 std::map<CSCDetId, int> CSCSegmentsCounter;
45 int segmentsInThisEventInTheEndcap = 0;
47 for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
48 CSCSegmentsCounter[segment->cscDetId()]++;
49 segmentsInThisEventInTheEndcap++;
52 float myTime = -9999.;
53 float myTimeErr = -9999.;
55 const float bunchCrossTimeDiff = 25.;
58 LogDebug(
"CSCSegtoRPC") <<
"CSC \t loop over all the CSCSegments " << std::endl;
59 for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
60 CSCDetId CSCId = segment->cscDetId();
62 myTime = segment->time();
63 myBx = round(myTime / bunchCrossTimeDiff);
64 if (!(myBx <= maxBX && myBx >=
minBX))
68 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t This Segment is in Chamber id: " << CSCId << std::endl;
70 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Number of segments in this CSC = " << CSCSegmentsCounter[CSCId]
74 <<
"CSC \t \t Is the only one in this CSC? is not ind the ring 1? Are there more than 2 " 75 "segments in the event?" 78 if (CSCSegmentsCounter[CSCId] == 1 && CSCId.
ring() != 1 && allCSCSegments->size() >= 2) {
80 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t yes" << std::endl;
81 int cscEndCap = CSCId.
endcap();
82 int cscStation = CSCId.
station();
83 int cscRing = CSCId.
ring();
87 int rpcRing = cscRing;
90 int rpcStation = cscStation;
91 int rpcSegment = CSCId.
chamber();
93 LocalPoint segmentPosition = segment->localPosition();
94 LocalVector segmentDirection = segment->localDirection();
95 float dz = segmentDirection.
z();
98 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Information about the segment" 99 <<
"RecHits =" << segment->nRecHits() <<
"Angle =" << acos(
dz) * 180 / 3.1415926
104 <<
"CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < " 105 << acos(
dz) * 180 / 3.1415926 <<
" < 135? " << std::endl;
107 if ((segment->dimension() == 4) && (segment->nRecHits() <= 10 && segment->nRecHits() >= 4)) {
109 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t yes" << std::endl;
111 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t CSC Segment Dimension " << segment->dimension() << std::endl;
113 float Xo = segmentPosition.
x();
114 float Yo = segmentPosition.
y();
115 float Zo = segmentPosition.
z();
116 float dx = segmentDirection.
x();
117 float dy = segmentDirection.
y();
118 float dz = segmentDirection.
z();
121 LogDebug(
"CSCSegtoRPC") <<
"Creating the CSCIndex" << std::endl;
124 LogDebug(
"CSCSegtoRPC") <<
"Getting the Rolls for the given index" << std::endl;
125 std::set<RPCDetId> rollsForThisCSC = cscMap->
getRolls(theindex);
127 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Getting chamber from Geometry" << std::endl;
130 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Getting ID from Chamber" << std::endl;
134 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Number of rolls for this CSC = " << rollsForThisCSC.size()
138 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Printing The Id" << TheId << std::endl;
142 assert(!rollsForThisCSC.empty());
145 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Loop over all the rolls asociated to this CSC" << std::endl;
146 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin(); iteraRoll != rollsForThisCSC.end();
148 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
152 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t We are in the roll getting the surface" << rpcId << std::endl;
156 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t RollID: " << rpcId << std::endl;
159 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Doing the extrapolation to this roll" << std::endl;
161 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t CSC Segment Direction in CSCLocal " << segmentDirection
164 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t CSC Segment Point in CSCLocal " << segmentPosition
169 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal
173 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Center (0,0,0) of the CSC in Global" << CenterPointCSCGlobal
176 TheChamber->
toGlobal(segmentPosition);
178 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Segment Position in Global" << segmentPositionInGlobal
186 (CenterPointRollGlobal.
barePhi() < 0) ? rpcphi = 2 * 3.141592 + CenterPointRollGlobal.
barePhi()
187 : rpcphi = CenterPointRollGlobal.
barePhi();
189 (CenterPointCSCGlobal.
barePhi() < 0) ? cscphi = 2 * 3.1415926536 + CenterPointCSCGlobal.
barePhi()
190 : cscphi = CenterPointCSCGlobal.
barePhi();
192 float df = fabs(cscphi - rpcphi);
193 float dr = fabs(CenterPointRollGlobal.
perp() - CenterPointCSCGlobal.
perp());
194 float diffz = CenterPointRollGlobal.
z() - CenterPointCSCGlobal.
z();
195 float dfg =
df * 180. / 3.14159265;
198 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t z of RPC=" << CenterPointRollGlobal.
z() <<
"z of CSC" 199 << CenterPointCSCGlobal.
z() <<
" dfg=" << dfg << std::endl;
203 if (
dr > 200. || fabs(
dz) > 55. || dfg > 1.) {
206 <<
"\t \t \t CSC Station= " << CSCId.
station() <<
" Ring= " << CSCId.
ring()
207 <<
" Chamber= " << CSCId.
chamber() <<
" cscphi=" << cscphi * 180 / 3.14159265
208 <<
"\t RPC Station= " << rpcId.
station() <<
" ring= " << rpcId.
ring() <<
" segment =-> " 209 << rpcsrv.segment() <<
" rollphi=" << rpcphi * 180 / 3.14159265 <<
"\t dfg=" << dfg
210 <<
" dz=" << diffz <<
" dr=" <<
dr << std::endl;
214 float D = CenterRollinCSCFrame.
z();
216 float X = Xo +
dx *
D /
dz;
217 float Y = Yo +
dy *
D /
dz;
224 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t xmin of this Roll " <<
xmin <<
"cm" << std::endl;
227 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t xmax of this Roll " <<
xmax <<
"cm" << std::endl;
228 float rsize = fabs(
xmax.x() -
xmin.x());
230 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Roll Size " << rsize <<
"cm" << std::endl;
232 float stripw = top_->
pitch();
235 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Strip Lenght " << stripl <<
"cm" << std::endl;
237 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Strip Width " << stripw <<
"cm" << std::endl;
240 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t X Predicted in CSCLocal= " <<
X <<
"cm" << std::endl;
242 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Y Predicted in CSCLocal= " <<
Y <<
"cm" << std::endl;
244 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Z Predicted in CSCLocal= " <<
Z <<
"cm" << std::endl;
246 float extrapolatedDistance =
sqrt((
X - Xo) * (
X - Xo) + (
Y - Yo) * (
Y - Yo) + (
Z - Zo) * (
Z - Zo));
249 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Is the distance of extrapolation less than MaxD? =" 250 << extrapolatedDistance <<
"cm" 251 <<
" MaxD=" <<
MaxD <<
"cm" << std::endl;
253 if (extrapolatedDistance <=
MaxD) {
255 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t yes" << std::endl;
260 <<
"CSC \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
262 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
266 <<
"CSC \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
268 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Corner of the Roll = (" << rsize * eyr <<
"," << stripl * eyr
272 <<
"CSC \t \t \t Info About the Point Extrapolated in X Abs (" 273 << fabs(PointExtrapolatedRPCFrame.
x()) <<
"," << fabs(PointExtrapolatedRPCFrame.
y()) <<
"," 274 << fabs(PointExtrapolatedRPCFrame.
z()) <<
")" << std::endl;
276 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t dz=" << fabs(PointExtrapolatedRPCFrame.
z())
277 <<
" dx=" << fabs(PointExtrapolatedRPCFrame.
x())
278 <<
" dy=" << fabs(PointExtrapolatedRPCFrame.
y()) << std::endl;
281 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Does the extrapolation go inside this roll????" << std::endl;
283 if (fabs(PointExtrapolatedRPCFrame.
z()) < 1. && fabs(PointExtrapolatedRPCFrame.
x()) < rsize * eyr &&
284 fabs(PointExtrapolatedRPCFrame.
y()) < stripl * eyr) {
286 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t yes" << std::endl;
288 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Creating the RecHit" << std::endl;
290 RPCRecHit RPCPoint(rpcId, myBx, PointExtrapolatedRPCFrame);
291 RPCPoint.setTimeAndError(myTime, myTimeErr);
294 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Clearing the vector" << std::endl;
295 RPCPointVector.clear();
297 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Pushing back" << std::endl;
298 RPCPointVector.push_back(RPCPoint);
300 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Putting the vector" << std::endl;
301 _ThePoints->put(rpcId, RPCPointVector.begin(), RPCPointVector.end());
Point3DBase< Scalar, LocalTag > LocalPoint
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeoToken_
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
C::const_iterator const_iterator
constant access iterator type
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
const Plane & surface() const
The nominal surface of the GeomDet.
DecomposeProduct< arg, typename Div::arg > D
float pitch() const override
const Topology & topology() const override
float stripLength() const override
det heigth (strip length in the middle)
edm::ESGetToken< CSCObjectMap, MuonGeometryRecord > cscMapToken_
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeoToken_
std::set< RPCDetId > const & getRolls(CSCStationIndex index) const
LocalPoint localPosition(float strip) const override
CSCDetId id() const
Get the (concrete) DetId.