71 _ThePoints = std::make_unique<RPCRecHitCollection>();
73 if (all4DSegments->size() > 8) {
75 std::cout <<
"Too many segments in this event we are not doing the extrapolation" << std::endl;
95 std::map<DTChamberId, int> DTSegmentCounter;
98 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
99 DTSegmentCounter[segment->chamberId()]++;
113 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
117 std::cout <<
"DT \t \t This Segment is in Chamber id: " << DTId << std::endl;
119 std::cout <<
"DT \t \t Number of segments in this DT = " << DTSegmentCounter[DTId] << std::endl;
121 std::cout <<
"DT \t \t Is the only one in this DT? and is not in the 4th Station?" << std::endl;
123 if (DTSegmentCounter[DTId] != 1 || DTId.
station() == 4) {
125 std::cout <<
"DT \t \t More than one segment in this chamber, or we are in Station 4" << std::endl;
129 int dtWheel = DTId.
wheel();
130 int dtStation = DTId.
station();
131 int dtSector = DTId.
sector();
133 LocalPoint segmentPosition = segment->localPosition();
134 LocalVector segmentDirection = segment->localDirection();
142 std::cout <<
"DT \t \t Is the segment 4D?" << std::endl;
144 if (segment->dimension() != 4) {
151 std::cout <<
"DT \t \t yes" << std::endl;
153 std::cout <<
"DT \t \t DT Segment Dimension " << segment->dimension() << std::endl;
155 float Xo = segmentPosition.
x();
156 float Yo = segmentPosition.
y();
157 float Zo = segmentPosition.
z();
158 float dx = segmentDirection.
x();
159 float dy = segmentDirection.
y();
160 float dz = segmentDirection.
z();
163 std::cout <<
"Creating the DTIndex" << std::endl;
166 std::cout <<
"Getting the Rolls for the given index" << std::endl;
167 std::set<RPCDetId> rollsForThisDT = dtMap->
getRolls(theindex);
170 std::cout <<
"DT \t \t Number of rolls for this DT = " << rollsForThisDT.size() << std::endl;
172 assert(!rollsForThisDT.empty());
175 std::cout <<
"DT \t \t Loop over all the rolls asociated to this DT" << std::endl;
176 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin(); iteraRoll != rollsForThisDT.end();
178 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
186 std::cout <<
"DT \t \t \t RollName: " << nameRoll << std::endl;
188 std::cout <<
"DT \t \t \t Doing the extrapolation to this roll" << std::endl;
190 std::cout <<
"DT \t \t \t DT Segment Direction in DTLocal " << segmentDirection << std::endl;
192 std::cout <<
"DT \t \t \t DT Segment Point in DTLocal " << segmentPosition << std::endl;
196 LocalPoint CenterRollinDTFrame = DTSurface.toLocal(CenterPointRollGlobal);
199 std::cout <<
"DT \t \t \t Center (0,0,0) Roll In DTLocal" << CenterRollinDTFrame << std::endl;
201 std::cout <<
"DT \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal << std::endl;
203 float D = CenterRollinDTFrame.
z();
205 float X = Xo +
dx *
D /
dz;
206 float Y = Yo +
dy *
D /
dz;
210 dynamic_cast<const RectangularStripTopology*>(&(rollasociated->
topology()));
213 std::cout <<
"DT \t \t \t xmin of this Roll " <<
xmin <<
"cm" << std::endl;
216 std::cout <<
"DT \t \t \t xmax of this Roll " <<
xmax <<
"cm" << std::endl;
217 float rsize = fabs(
xmax.x() -
xmin.x());
219 std::cout <<
"DT \t \t \t Roll Size " << rsize <<
"cm" << std::endl;
222 float stripw = top_->
pitch();
225 std::cout <<
"DT \t \t \t Strip Lenght " << stripl <<
"cm" << std::endl;
227 std::cout <<
"DT \t \t \t Strip Width " << stripw <<
"cm" << std::endl;
229 std::cout <<
"DT \t \t \t X Predicted in DTLocal= " <<
X <<
"cm" << std::endl;
231 std::cout <<
"DT \t \t \t Y Predicted in DTLocal= " <<
Y <<
"cm" << std::endl;
233 std::cout <<
"DT \t \t \t Z Predicted in DTLocal= " <<
Z <<
"cm" << std::endl;
235 float extrapolatedDistance =
sqrt((
X - Xo) * (
X - Xo) + (
Y - Yo) * (
Y - Yo) + (
Z - Zo) * (
Z - Zo));
238 std::cout <<
"DT \t \t \t Is the distance of extrapolation less than MaxD? =" << extrapolatedDistance
240 <<
"MaxD=" <<
MaxD <<
"cm" << std::endl;
242 if (extrapolatedDistance <=
MaxD) {
244 std::cout <<
"DT \t \t \t yes" << std::endl;
247 std::cout <<
"DT \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
248 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
251 std::cout <<
"DT \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
253 std::cout <<
"DT \t \t \t Corner of the Roll = (" << rsize * eyr <<
"," << stripl * eyr <<
")"
256 std::cout <<
"DT \t \t \t Info About the Point Extrapolated in X Abs ("
257 << fabs(PointExtrapolatedRPCFrame.
x()) <<
"," << fabs(PointExtrapolatedRPCFrame.
y()) <<
","
258 << fabs(PointExtrapolatedRPCFrame.
z()) <<
")" << std::endl;
260 std::cout <<
"DT \t \t \t Does the extrapolation go inside this roll?" << std::endl;
262 if (fabs(PointExtrapolatedRPCFrame.
z()) < 1. && fabs(PointExtrapolatedRPCFrame.
x()) < rsize * eyr &&
263 fabs(PointExtrapolatedRPCFrame.
y()) < stripl * eyr) {
265 std::cout <<
"DT \t \t \t \t yes" << std::endl;
267 std::cout <<
"DT \t \t \t \t Creating the RecHit" << std::endl;
268 RPCRecHit RPCPoint(rpcId, 0, PointExtrapolatedRPCFrame);
270 std::cout <<
"DT \t \t \t \t Clearing the vector" << std::endl;
273 std::cout <<
"DT \t \t \t \t Pushing back" << std::endl;
276 std::cout <<
"DT \t \t \t \t Putting the vector" << std::endl;
280 std::cout <<
"DT \t \t \t \t Filling container with " << nameRoll
281 <<
" Point.x=" << PointExtrapolatedRPCFrame.
x()
287 std::cout <<
"DT \t \t \t \t No the prediction is outside of this roll" << std::endl;
291 std::cout <<
"DT \t \t \t No, Exrtrapolation too long!, canceled" << std::endl;
298 if (all4DSegments->size() > 0) {
300 std::cout <<
"MB4 \t \t Loop Over all4DSegments " << all4DSegments->size() << std::endl;
302 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
306 std::cout <<
"MB4 \t \t This Segment is in Chamber id: " << DTId << std::endl;
308 std::cout <<
"MB4 \t \t Number of segments in this DT = " << DTSegmentCounter[DTId] << std::endl;
310 std::cout <<
"MB4 \t \t \t Is the only one in this DT? and is in the Station 4?" << std::endl;
312 if (DTSegmentCounter[DTId] == 1 && DTId.
station() == 4) {
314 std::cout <<
"MB4 \t \t \t yes" << std::endl;
315 int dtWheel = DTId.
wheel();
316 int dtStation = DTId.
station();
317 int dtSector = DTId.
sector();
319 LocalPoint segmentPosition = segment->localPosition();
320 LocalVector segmentDirection = segment->localDirection();
323 std::cout <<
"MB4 \t \t \t \t The Segment in MB4 is 2D?" << std::endl;
324 if (segment->dimension() == 2) {
326 std::cout <<
"MB4 \t \t \t \t yes" << std::endl;
327 const LocalVector& segmentDirectionMB4 = segmentDirection;
328 const LocalPoint& segmentPositionMB4 = segmentPosition;
335 std::cout <<
"MB4 \t \t \t \t Loop on segments in =sector && MB3 && adjacent sectors && y dim=4"
337 for (segMB3 = all4DSegments->begin(); segMB3 != all4DSegments->end(); ++segMB3) {
341 std::cout <<
"MB4 \t \t \t \t Segment in Chamber =" << dtid3 << std::endl;
347 && dtid3.
station() == 3 && DTSegmentCounter[dtid3] == 1 && segMB3->dimension() == 4) {
355 const BoundPlane& DTSurface3 = gdet3->surface();
357 LocalVector segmentDirectionMB3 = segMB3->localDirection();
358 GlobalPoint segmentPositionMB3inGlobal = DTSurface3.toGlobal(segMB3->localPosition());
359 GlobalPoint segmentPositionMB4inGlobal = DTSurface4.toGlobal(segmentPosition);
362 LocalVector segDirMB3inMB4Frame = DTSurface4.toLocal(DTSurface3.toGlobal(segmentDirectionMB3));
364 GlobalVector segDirMB4inGlobalFrame = DTSurface4.toGlobal(segmentDirectionMB4);
365 GlobalVector segDirMB3inGlobalFrame = DTSurface3.toGlobal(segmentDirectionMB3);
367 float dx = segDirMB4inGlobalFrame.
x();
368 float dy = segDirMB4inGlobalFrame.
y();
370 float dx3 = segDirMB3inGlobalFrame.
x();
371 float dy3 = segDirMB3inGlobalFrame.
y();
373 double cosAng = fabs(
dx * dx3 +
dy * dy3 /
sqrt((dx3 * dx3 + dy3 * dy3) * (
dx *
dx +
dy *
dy)));
376 std::cout <<
"MB4 \t \t \t \t cosAng" << cosAng <<
"Beetween " << dtid3 <<
" and " << DTId
380 std::cout <<
"MB4 \t \t \t \t dx=" <<
dx <<
" dy=" <<
dy << std::endl;
381 std::cout <<
"MB4 \t \t \t \t dx3=" << dx3 <<
" dy3=" <<
dy << std::endl;
382 std::cout <<
"MB4 \t \t \t \t cosAng=" << cosAng << std::endl;
385 float DistanceBetweenSegments = ((segmentPositionMB3inGlobal) - (segmentPositionMB4inGlobal)).
mag();
389 std::cout <<
"MB4 \t \t \t \t Distance between segments=" << DistanceBetweenSegments << std::endl;
392 std::cout <<
"MB4 \t \t We found compatible Segments (similar direction and close enough) in "
393 << dtid3 <<
" and " << DTId << std::endl;
395 if (dtSector == 13) {
398 if (dtSector == 14) {
403 std::cout <<
"Creating the DTIndex" << std::endl;
406 std::cout <<
"Getting the Rolls for the given index" << std::endl;
407 std::set<RPCDetId> rollsForThisDT = dtMap->
getRolls(theindex);
410 std::cout <<
"MB4 \t \t Number of rolls for this DT = " << rollsForThisDT.size() << std::endl;
412 assert(!rollsForThisDT.empty());
415 std::cout <<
"MB4 \t \t Loop over all the rolls asociated to this DT" << std::endl;
416 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();
417 iteraRoll != rollsForThisDT.end();
419 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
427 std::cout <<
"MB4 \t \t \t RollName: " << nameRoll << std::endl;
429 std::cout <<
"MB4 \t \t \t Doing the extrapolation to this roll" << std::endl;
432 LocalPoint CenterRollinMB4Frame = DTSurface4.toLocal(CenterPointRollGlobal);
434 DTSurface4.toLocal(segmentPositionMB3inGlobal);
436 LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.toLocal(segDirMB3inGlobalFrame);
439 float Dxz = CenterRollinMB4Frame.
z();
440 float Xo4 = segmentPositionMB4.
x();
441 float dxl = segmentDirectionMB4.
x();
442 float dzl = segmentDirectionMB4.
z();
444 float X = Xo4 + dxl * Dxz / dzl;
448 float Yo34 = segmentPositionMB3inMB4Frame.
y();
449 float dy34 = segmentDirectionMB3inMB4Frame.
y();
450 float dz34 = segmentDirectionMB3inMB4Frame.
z();
453 (segmentPositionMB3inMB4Frame.
z());
456 std::cout <<
"MB4 \t \t \t The distance to extrapolate in Y from MB3 is " <<
Dy <<
"cm"
459 float Y = Yo34 + dy34 *
Dy / dz34;
465 float rsize = fabs(
xmax.x() -
xmin.x());
467 float stripw = top_->
pitch();
470 std::cout <<
"MB4 \t \t \t Strip Lenght " << stripl <<
"cm" << std::endl;
472 std::cout <<
"MB4 \t \t \t Strip Width " << stripw <<
"cm" << std::endl;
475 std::cout <<
"MB4 \t \t \t X Predicted in MB4DTLocal= " <<
X <<
"cm" << std::endl;
477 std::cout <<
"MB4 \t \t \t Y Predicted in MB4DTLocal= " <<
Y <<
"cm" << std::endl;
479 std::cout <<
"MB4 \t \t \t Z Predicted in MB4DTLocal= " <<
Z <<
"cm" << std::endl;
481 float extrapolatedDistance =
sqrt((
Y - Yo34) * (
Y - Yo34) +
Dy *
Dy);
484 std::cout <<
"MB4 \t \t \t segmentPositionMB3inMB4Frame" << segmentPositionMB3inMB4Frame
487 std::cout <<
"MB4 \t \t \t segmentPositionMB4inMB4Frame" << segmentPosition << std::endl;
490 std::cout <<
"MB4 \t \t \t segmentDirMB3inMB4Frame" << segDirMB3inMB4Frame << std::endl;
492 std::cout <<
"MB4 \t \t \t segmentDirMB4inMB4Frame" << segmentDirectionMB4 << std::endl;
495 std::cout <<
"MB4 \t \t \t CenterRB4PositioninMB4Frame" << CenterRollinMB4Frame << std::endl;
498 std::cout <<
"MB4 \t \t \t Is the extrapolation distance =" << extrapolatedDistance
499 <<
"less than " <<
MaxDrb4 << std::endl;
501 if (extrapolatedDistance <=
MaxDrb4) {
503 std::cout <<
"MB4 \t \t \t yes" << std::endl;
508 std::cout <<
"MB4 \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated
511 LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.toLocal(GlobalPointExtrapolated);
514 std::cout <<
"MB4 \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame
517 std::cout <<
"MB4 \t \t \t Corner of the Roll = (" << rsize * eyr <<
"," << stripl * eyr
520 std::cout <<
"MB4 \t \t \t Info About the Point Extrapolated in X Abs ("
521 << fabs(PointExtrapolatedRPCFrame.
x()) <<
"," << fabs(PointExtrapolatedRPCFrame.
y())
522 <<
"," << fabs(PointExtrapolatedRPCFrame.
z()) <<
")" << std::endl;
525 std::cout <<
"MB4 \t \t \t Does the extrapolation go inside this roll?" << std::endl;
527 if (fabs(PointExtrapolatedRPCFrame.
z()) < 5. &&
528 fabs(PointExtrapolatedRPCFrame.
x()) < rsize * eyr &&
529 fabs(PointExtrapolatedRPCFrame.
y()) < stripl * eyr) {
531 std::cout <<
"MB4 \t \t \t \t yes" << std::endl;
533 std::cout <<
"MB4 \t \t \t \t Creating the RecHit" << std::endl;
534 RPCRecHit RPCPointMB4(rpcId, 0, PointExtrapolatedRPCFrame);
536 std::cout <<
"MB4 \t \t \t \t Clearing the RPCPointVector" << std::endl;
539 std::cout <<
"MB4 \t \t \t \t Pushing Back" << std::endl;
542 std::cout <<
"MB4 \t \t \t \t Putting for " << rpcId << std::endl;
544 std::cout <<
"MB4 \t \t \t \t Filling container with " << nameRoll
545 <<
" Point.x=" << PointExtrapolatedRPCFrame.
x()
546 <<
" Point.y=" << PointExtrapolatedRPCFrame.
y()
549 std::cout <<
"MB4 \t \t \t \t Number of rolls already extrapolated in RB4 = "
557 std::cout <<
"MB4 \t \t \t \t roll already extrapolated " << rpcId << std::endl;
560 std::cout <<
"MB4 \t \t \t \t Extrapolations done after this point = "
567 std::cout <<
"MB4 \t \t \t \t No the prediction is outside of this roll" << std::endl;
572 std::cout <<
"MB4 \t \t \t No, Exrtrapolation too long!, canceled" << std::endl;
577 std::cout <<
"MB4 \t \t \t \t I found segments in MB4 and MB3 adjacent wheel and/or sector but "
578 "not compatibles, Diferent Directions"
583 std::cout <<
"MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D"
589 std::cout <<
"MB4 \t \t \t Is NOT a 2D Segment" << std::endl;
593 std::cout <<
"MB4 \t \t \t \t There is not just one segment or is not in station 4" << std::endl;
598 std::cout <<
"MB4 \t This event doesn't have 4D Segment" << std::endl;