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 for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
46 CSCSegmentsCounter[segment->cscDetId()]++;
49 float myTime = -9999.;
50 float myTimeErr = -9999.;
52 const float bunchCrossTimeDiff = 25.;
55 LogDebug(
"CSCSegtoRPC") <<
"CSC \t loop over all the CSCSegments " << std::endl;
56 for (segment = allCSCSegments->begin(); segment != allCSCSegments->end(); ++segment) {
57 CSCDetId CSCId = segment->cscDetId();
59 myTime = segment->time();
60 myBx = round(myTime / bunchCrossTimeDiff);
61 if (!(myBx <= maxBX && myBx >=
minBX))
65 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t This Segment is in Chamber id: " << CSCId << std::endl;
67 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Number of segments in this CSC = " << CSCSegmentsCounter[CSCId]
71 <<
"CSC \t \t Is the only one in this CSC? is not ind the ring 1? Are there more than 2 " 72 "segments in the event?" 75 if (CSCSegmentsCounter[CSCId] == 1 && CSCId.
ring() != 1 && allCSCSegments->size() >= 2) {
77 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t yes" << std::endl;
78 int cscEndCap = CSCId.
endcap();
79 int cscStation = CSCId.
station();
80 int cscRing = CSCId.
ring();
84 int rpcRing = cscRing;
87 int rpcStation = cscStation;
88 int rpcSegment = CSCId.
chamber();
90 LocalPoint segmentPosition = segment->localPosition();
91 LocalVector segmentDirection = segment->localDirection();
92 float dz = segmentDirection.
z();
95 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Information about the segment" 96 <<
"RecHits =" << segment->nRecHits() <<
"Angle =" << acos(
dz) * 180 / 3.1415926
101 <<
"CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < " 102 << acos(
dz) * 180 / 3.1415926 <<
" < 135? " << std::endl;
104 if ((segment->dimension() == 4) && (segment->nRecHits() <= 10 && segment->nRecHits() >= 4)) {
106 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t yes" << std::endl;
108 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t CSC Segment Dimension " << segment->dimension() << std::endl;
110 float Xo = segmentPosition.
x();
111 float Yo = segmentPosition.
y();
112 float Zo = segmentPosition.
z();
113 float dx = segmentDirection.
x();
114 float dy = segmentDirection.
y();
115 float dz = segmentDirection.
z();
118 LogDebug(
"CSCSegtoRPC") <<
"Creating the CSCIndex" << std::endl;
121 LogDebug(
"CSCSegtoRPC") <<
"Getting the Rolls for the given index" << std::endl;
122 std::set<RPCDetId> rollsForThisCSC = cscMap->
getRolls(theindex);
124 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Getting chamber from Geometry" << std::endl;
127 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Getting ID from Chamber" << std::endl;
131 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Number of rolls for this CSC = " << rollsForThisCSC.size()
135 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Printing The Id" << TheId << std::endl;
139 assert(!rollsForThisCSC.empty());
142 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t Loop over all the rolls asociated to this CSC" << std::endl;
143 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin(); iteraRoll != rollsForThisCSC.end();
145 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
149 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t We are in the roll getting the surface" << rpcId << std::endl;
153 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t RollID: " << rpcId << std::endl;
156 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Doing the extrapolation to this roll" << std::endl;
158 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t CSC Segment Direction in CSCLocal " << segmentDirection
161 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t CSC Segment Point in CSCLocal " << segmentPosition
166 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal
170 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Center (0,0,0) of the CSC in Global" << CenterPointCSCGlobal
173 TheChamber->
toGlobal(segmentPosition);
175 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Segment Position in Global" << segmentPositionInGlobal
183 (CenterPointRollGlobal.
barePhi() < 0) ? rpcphi = 2 * 3.141592 + CenterPointRollGlobal.
barePhi()
184 : rpcphi = CenterPointRollGlobal.
barePhi();
186 (CenterPointCSCGlobal.
barePhi() < 0) ? cscphi = 2 * 3.1415926536 + CenterPointCSCGlobal.
barePhi()
187 : cscphi = CenterPointCSCGlobal.
barePhi();
189 float df = fabs(cscphi - rpcphi);
190 float dr = fabs(CenterPointRollGlobal.
perp() - CenterPointCSCGlobal.
perp());
191 float diffz = CenterPointRollGlobal.
z() - CenterPointCSCGlobal.
z();
192 float dfg =
df * 180. / 3.14159265;
195 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t z of RPC=" << CenterPointRollGlobal.
z() <<
"z of CSC" 196 << CenterPointCSCGlobal.
z() <<
" dfg=" << dfg << std::endl;
200 if (
dr > 200. || fabs(
dz) > 55. || dfg > 1.) {
203 <<
"\t \t \t CSC Station= " << CSCId.
station() <<
" Ring= " << CSCId.
ring()
204 <<
" Chamber= " << CSCId.
chamber() <<
" cscphi=" << cscphi * 180 / 3.14159265
205 <<
"\t RPC Station= " << rpcId.
station() <<
" ring= " << rpcId.
ring() <<
" segment =-> " 206 << rpcsrv.
segment() <<
" rollphi=" << rpcphi * 180 / 3.14159265 <<
"\t dfg=" << dfg
207 <<
" dz=" << diffz <<
" dr=" <<
dr << std::endl;
211 float D = CenterRollinCSCFrame.
z();
213 float X = Xo +
dx *
D /
dz;
214 float Y = Yo +
dy *
D /
dz;
221 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t xmin of this Roll " <<
xmin <<
"cm" << std::endl;
224 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t xmax of this Roll " <<
xmax <<
"cm" << std::endl;
225 float rsize = fabs(
xmax.x() -
xmin.x());
227 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Roll Size " << rsize <<
"cm" << std::endl;
229 float stripw = top_->
pitch();
232 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Strip Lenght " << stripl <<
"cm" << std::endl;
234 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Strip Width " << stripw <<
"cm" << std::endl;
237 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t X Predicted in CSCLocal= " <<
X <<
"cm" << std::endl;
239 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Y Predicted in CSCLocal= " <<
Y <<
"cm" << std::endl;
241 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Z Predicted in CSCLocal= " <<
Z <<
"cm" << std::endl;
243 float extrapolatedDistance =
sqrt((
X - Xo) * (
X - Xo) + (
Y - Yo) * (
Y - Yo) + (
Z - Zo) * (
Z - Zo));
246 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Is the distance of extrapolation less than MaxD? =" 247 << extrapolatedDistance <<
"cm" 248 <<
" MaxD=" <<
MaxD <<
"cm" << std::endl;
250 if (extrapolatedDistance <=
MaxD) {
252 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t yes" << std::endl;
257 <<
"CSC \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
259 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
263 <<
"CSC \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
265 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Corner of the Roll = (" << rsize * eyr <<
"," << stripl * eyr
269 <<
"CSC \t \t \t Info About the Point Extrapolated in X Abs (" 270 << fabs(PointExtrapolatedRPCFrame.
x()) <<
"," << fabs(PointExtrapolatedRPCFrame.
y()) <<
"," 271 << fabs(PointExtrapolatedRPCFrame.
z()) <<
")" << std::endl;
273 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t dz=" << fabs(PointExtrapolatedRPCFrame.
z())
274 <<
" dx=" << fabs(PointExtrapolatedRPCFrame.
x())
275 <<
" dy=" << fabs(PointExtrapolatedRPCFrame.
y()) << std::endl;
278 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t Does the extrapolation go inside this roll????" << std::endl;
280 if (fabs(PointExtrapolatedRPCFrame.
z()) < 1. && fabs(PointExtrapolatedRPCFrame.
x()) < rsize * eyr &&
281 fabs(PointExtrapolatedRPCFrame.
y()) < stripl * eyr) {
283 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t yes" << std::endl;
285 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Creating the RecHit" << std::endl;
287 RPCRecHit RPCPoint(rpcId, myBx, PointExtrapolatedRPCFrame);
291 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Clearing the vector" << std::endl;
292 RPCPointVector.clear();
294 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Pushing back" << std::endl;
295 RPCPointVector.push_back(RPCPoint);
297 LogDebug(
"CSCSegtoRPC") <<
"CSC \t \t \t \t Putting the vector" << std::endl;
298 _ThePoints->put(rpcId, RPCPointVector.begin(), RPCPointVector.end());
T getParameter(std::string const &) const
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
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void setTimeAndError(float time, float err)
Set the time and its error.
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
std::unique_ptr< RPCRecHitCollection > thePoints(CSCSegmentCollection const *allCSCSegments, edm::EventSetup const &iSetup, bool debug, double eyr)
float stripLength() const override
det heigth (strip length in the middle)
edm::ESGetToken< CSCObjectMap, MuonGeometryRecord > cscMapToken_
CSCSegtoRPC(edm::ConsumesCollector iC, const edm::ParameterSet &)
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.