75 auto _ThePoints = std::make_unique<RPCRecHitCollection>();
77 std::vector<uint32_t> extrapolatedRolls;
79 if (all4DSegments->size() > 8) {
81 std::cout <<
"Too many segments in this event we are not doing the extrapolation" << std::endl;
97 std::map<DTChamberId, int> DTSegmentCounter;
100 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
101 DTSegmentCounter[segment->chamberId()]++;
115 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
119 std::cout <<
"DT \t \t This Segment is in Chamber id: " << DTId << std::endl;
121 std::cout <<
"DT \t \t Number of segments in this DT = " << DTSegmentCounter[DTId] << std::endl;
123 std::cout <<
"DT \t \t Is the only one in this DT? and is not in the 4th Station?" << std::endl;
125 if (DTSegmentCounter[DTId] != 1 || DTId.
station() == 4) {
127 std::cout <<
"DT \t \t More than one segment in this chamber, or we are in Station 4" << std::endl;
131 int dtWheel = DTId.
wheel();
132 int dtStation = DTId.
station();
133 int dtSector = DTId.
sector();
135 LocalPoint segmentPosition = segment->localPosition();
136 LocalVector segmentDirection = segment->localDirection();
144 std::cout <<
"DT \t \t Is the segment 4D?" << std::endl;
146 if (segment->dimension() != 4) {
153 std::cout <<
"DT \t \t yes" << std::endl;
155 std::cout <<
"DT \t \t DT Segment Dimension " << segment->dimension() << std::endl;
157 float Xo = segmentPosition.
x();
158 float Yo = segmentPosition.
y();
159 float Zo = segmentPosition.
z();
160 float dx = segmentDirection.
x();
161 float dy = segmentDirection.
y();
162 float dz = segmentDirection.
z();
165 std::cout <<
"Creating the DTIndex" << std::endl;
168 std::cout <<
"Getting the Rolls for the given index" << std::endl;
169 std::set<RPCDetId> rollsForThisDT = dtMap->
getRolls(theindex);
172 std::cout <<
"DT \t \t Number of rolls for this DT = " << rollsForThisDT.size() << std::endl;
174 assert(!rollsForThisDT.empty());
177 std::cout <<
"DT \t \t Loop over all the rolls asociated to this DT" << std::endl;
178 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin(); iteraRoll != rollsForThisDT.end();
180 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
188 std::cout <<
"DT \t \t \t RollName: " << nameRoll << std::endl;
190 std::cout <<
"DT \t \t \t Doing the extrapolation to this roll" << std::endl;
192 std::cout <<
"DT \t \t \t DT Segment Direction in DTLocal " << segmentDirection << std::endl;
194 std::cout <<
"DT \t \t \t DT Segment Point in DTLocal " << segmentPosition << std::endl;
198 LocalPoint CenterRollinDTFrame = DTSurface.toLocal(CenterPointRollGlobal);
201 std::cout <<
"DT \t \t \t Center (0,0,0) Roll In DTLocal" << CenterRollinDTFrame << std::endl;
203 std::cout <<
"DT \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal << std::endl;
205 float D = CenterRollinDTFrame.
z();
207 float X = Xo +
dx *
D /
dz;
208 float Y = Yo +
dy *
D /
dz;
212 dynamic_cast<const RectangularStripTopology*>(&(rollasociated->
topology()));
215 std::cout <<
"DT \t \t \t xmin of this Roll " <<
xmin <<
"cm" << std::endl;
218 std::cout <<
"DT \t \t \t xmax of this Roll " <<
xmax <<
"cm" << std::endl;
219 float rsize = fabs(
xmax.x() -
xmin.x());
221 std::cout <<
"DT \t \t \t Roll Size " << rsize <<
"cm" << std::endl;
224 float stripw = top_->
pitch();
227 std::cout <<
"DT \t \t \t Strip Lenght " << stripl <<
"cm" << std::endl;
229 std::cout <<
"DT \t \t \t Strip Width " << stripw <<
"cm" << std::endl;
231 std::cout <<
"DT \t \t \t X Predicted in DTLocal= " <<
X <<
"cm" << std::endl;
233 std::cout <<
"DT \t \t \t Y Predicted in DTLocal= " <<
Y <<
"cm" << std::endl;
235 std::cout <<
"DT \t \t \t Z Predicted in DTLocal= " <<
Z <<
"cm" << std::endl;
237 float extrapolatedDistance =
sqrt((
X - Xo) * (
X - Xo) + (
Y - Yo) * (
Y - Yo) + (
Z - Zo) * (
Z - Zo));
240 std::cout <<
"DT \t \t \t Is the distance of extrapolation less than MaxD? =" << extrapolatedDistance
242 <<
"MaxD=" <<
MaxD <<
"cm" << std::endl;
244 if (extrapolatedDistance <=
MaxD) {
246 std::cout <<
"DT \t \t \t yes" << std::endl;
249 std::cout <<
"DT \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
250 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
253 std::cout <<
"DT \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
255 std::cout <<
"DT \t \t \t Corner of the Roll = (" << rsize * eyr <<
"," << stripl * eyr <<
")"
258 std::cout <<
"DT \t \t \t Info About the Point Extrapolated in X Abs ("
259 << fabs(PointExtrapolatedRPCFrame.
x()) <<
"," << fabs(PointExtrapolatedRPCFrame.
y()) <<
","
260 << fabs(PointExtrapolatedRPCFrame.
z()) <<
")" << std::endl;
262 std::cout <<
"DT \t \t \t Does the extrapolation go inside this roll?" << std::endl;
264 if (fabs(PointExtrapolatedRPCFrame.
z()) < 1. && fabs(PointExtrapolatedRPCFrame.
x()) < rsize * eyr &&
265 fabs(PointExtrapolatedRPCFrame.
y()) < stripl * eyr) {
267 std::cout <<
"DT \t \t \t \t yes" << std::endl;
269 std::cout <<
"DT \t \t \t \t Creating the RecHit" << std::endl;
270 RPCRecHit RPCPoint(rpcId, 0, PointExtrapolatedRPCFrame);
272 std::cout <<
"DT \t \t \t \t Clearing the vector" << std::endl;
273 RPCPointVector.
clear();
275 std::cout <<
"DT \t \t \t \t Pushing back" << std::endl;
278 std::cout <<
"DT \t \t \t \t Putting the vector" << std::endl;
279 _ThePoints->put(rpcId, RPCPointVector.
begin(), RPCPointVector.
end());
282 std::cout <<
"DT \t \t \t \t Filling container with " << nameRoll
283 <<
" Point.x=" << PointExtrapolatedRPCFrame.
x()
284 <<
" Point.y=" << PointExtrapolatedRPCFrame.
y() <<
" size=" << RPCPointVector.
size()
289 std::cout <<
"DT \t \t \t \t No the prediction is outside of this roll" << std::endl;
293 std::cout <<
"DT \t \t \t No, Exrtrapolation too long!, canceled" << std::endl;
300 if (all4DSegments->size() > 0) {
302 std::cout <<
"MB4 \t \t Loop Over all4DSegments " << all4DSegments->size() << std::endl;
303 extrapolatedRolls.clear();
304 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
308 std::cout <<
"MB4 \t \t This Segment is in Chamber id: " << DTId << std::endl;
310 std::cout <<
"MB4 \t \t Number of segments in this DT = " << DTSegmentCounter[DTId] << std::endl;
312 std::cout <<
"MB4 \t \t \t Is the only one in this DT? and is in the Station 4?" << std::endl;
314 if (DTSegmentCounter[DTId] == 1 && DTId.
station() == 4) {
316 std::cout <<
"MB4 \t \t \t yes" << std::endl;
317 int dtWheel = DTId.
wheel();
318 int dtStation = DTId.
station();
319 int dtSector = DTId.
sector();
321 LocalPoint segmentPosition = segment->localPosition();
322 LocalVector segmentDirection = segment->localDirection();
325 std::cout <<
"MB4 \t \t \t \t The Segment in MB4 is 2D?" << std::endl;
326 if (segment->dimension() == 2) {
328 std::cout <<
"MB4 \t \t \t \t yes" << std::endl;
329 const LocalVector& segmentDirectionMB4 = segmentDirection;
330 const LocalPoint& segmentPositionMB4 = segmentPosition;
337 std::cout <<
"MB4 \t \t \t \t Loop on segments in =sector && MB3 && adjacent sectors && y dim=4"
339 for (segMB3 = all4DSegments->begin(); segMB3 != all4DSegments->end(); ++segMB3) {
343 std::cout <<
"MB4 \t \t \t \t Segment in Chamber =" << dtid3 << std::endl;
349 && dtid3.
station() == 3 && DTSegmentCounter[dtid3] == 1 && segMB3->dimension() == 4) {
357 const BoundPlane& DTSurface3 = gdet3->surface();
359 LocalVector segmentDirectionMB3 = segMB3->localDirection();
360 GlobalPoint segmentPositionMB3inGlobal = DTSurface3.toGlobal(segMB3->localPosition());
361 GlobalPoint segmentPositionMB4inGlobal = DTSurface4.toGlobal(segmentPosition);
364 LocalVector segDirMB3inMB4Frame = DTSurface4.toLocal(DTSurface3.toGlobal(segmentDirectionMB3));
366 GlobalVector segDirMB4inGlobalFrame = DTSurface4.toGlobal(segmentDirectionMB4);
367 GlobalVector segDirMB3inGlobalFrame = DTSurface3.toGlobal(segmentDirectionMB3);
369 float dx = segDirMB4inGlobalFrame.
x();
370 float dy = segDirMB4inGlobalFrame.
y();
372 float dx3 = segDirMB3inGlobalFrame.
x();
373 float dy3 = segDirMB3inGlobalFrame.
y();
375 double cosAng = fabs(
dx * dx3 +
dy * dy3 /
sqrt((dx3 * dx3 + dy3 * dy3) * (
dx *
dx +
dy *
dy)));
378 std::cout <<
"MB4 \t \t \t \t cosAng" << cosAng <<
"Beetween " << dtid3 <<
" and " << DTId
382 std::cout <<
"MB4 \t \t \t \t dx=" <<
dx <<
" dy=" <<
dy << std::endl;
383 std::cout <<
"MB4 \t \t \t \t dx3=" << dx3 <<
" dy3=" <<
dy << std::endl;
384 std::cout <<
"MB4 \t \t \t \t cosAng=" << cosAng << std::endl;
387 float DistanceBetweenSegments = ((segmentPositionMB3inGlobal) - (segmentPositionMB4inGlobal)).
mag();
391 std::cout <<
"MB4 \t \t \t \t Distance between segments=" << DistanceBetweenSegments << std::endl;
394 std::cout <<
"MB4 \t \t We found compatible Segments (similar direction and close enough) in "
395 << dtid3 <<
" and " << DTId << std::endl;
397 if (dtSector == 13) {
400 if (dtSector == 14) {
405 std::cout <<
"Creating the DTIndex" << std::endl;
408 std::cout <<
"Getting the Rolls for the given index" << std::endl;
409 std::set<RPCDetId> rollsForThisDT = dtMap->
getRolls(theindex);
412 std::cout <<
"MB4 \t \t Number of rolls for this DT = " << rollsForThisDT.size() << std::endl;
414 assert(!rollsForThisDT.empty());
417 std::cout <<
"MB4 \t \t Loop over all the rolls asociated to this DT" << std::endl;
418 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();
419 iteraRoll != rollsForThisDT.end();
421 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
429 std::cout <<
"MB4 \t \t \t RollName: " << nameRoll << std::endl;
431 std::cout <<
"MB4 \t \t \t Doing the extrapolation to this roll" << std::endl;
434 LocalPoint CenterRollinMB4Frame = DTSurface4.toLocal(CenterPointRollGlobal);
436 DTSurface4.toLocal(segmentPositionMB3inGlobal);
438 LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.toLocal(segDirMB3inGlobalFrame);
441 float Dxz = CenterRollinMB4Frame.
z();
442 float Xo4 = segmentPositionMB4.
x();
443 float dxl = segmentDirectionMB4.
x();
444 float dzl = segmentDirectionMB4.
z();
446 float X = Xo4 + dxl * Dxz / dzl;
450 float Yo34 = segmentPositionMB3inMB4Frame.
y();
451 float dy34 = segmentDirectionMB3inMB4Frame.
y();
452 float dz34 = segmentDirectionMB3inMB4Frame.
z();
455 (segmentPositionMB3inMB4Frame.
z());
458 std::cout <<
"MB4 \t \t \t The distance to extrapolate in Y from MB3 is " <<
Dy <<
"cm"
461 float Y = Yo34 + dy34 *
Dy / dz34;
467 float rsize = fabs(
xmax.x() -
xmin.x());
469 float stripw = top_->
pitch();
472 std::cout <<
"MB4 \t \t \t Strip Lenght " << stripl <<
"cm" << std::endl;
474 std::cout <<
"MB4 \t \t \t Strip Width " << stripw <<
"cm" << std::endl;
477 std::cout <<
"MB4 \t \t \t X Predicted in MB4DTLocal= " <<
X <<
"cm" << std::endl;
479 std::cout <<
"MB4 \t \t \t Y Predicted in MB4DTLocal= " <<
Y <<
"cm" << std::endl;
481 std::cout <<
"MB4 \t \t \t Z Predicted in MB4DTLocal= " <<
Z <<
"cm" << std::endl;
483 float extrapolatedDistance =
sqrt((
Y - Yo34) * (
Y - Yo34) +
Dy *
Dy);
486 std::cout <<
"MB4 \t \t \t segmentPositionMB3inMB4Frame" << segmentPositionMB3inMB4Frame
489 std::cout <<
"MB4 \t \t \t segmentPositionMB4inMB4Frame" << segmentPosition << std::endl;
492 std::cout <<
"MB4 \t \t \t segmentDirMB3inMB4Frame" << segDirMB3inMB4Frame << std::endl;
494 std::cout <<
"MB4 \t \t \t segmentDirMB4inMB4Frame" << segmentDirectionMB4 << std::endl;
497 std::cout <<
"MB4 \t \t \t CenterRB4PositioninMB4Frame" << CenterRollinMB4Frame << std::endl;
500 std::cout <<
"MB4 \t \t \t Is the extrapolation distance =" << extrapolatedDistance
501 <<
"less than " <<
MaxDrb4 << std::endl;
503 if (extrapolatedDistance <=
MaxDrb4) {
505 std::cout <<
"MB4 \t \t \t yes" << std::endl;
510 std::cout <<
"MB4 \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated
513 LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.toLocal(GlobalPointExtrapolated);
516 std::cout <<
"MB4 \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame
519 std::cout <<
"MB4 \t \t \t Corner of the Roll = (" << rsize * eyr <<
"," << stripl * eyr
522 std::cout <<
"MB4 \t \t \t Info About the Point Extrapolated in X Abs ("
523 << fabs(PointExtrapolatedRPCFrame.
x()) <<
"," << fabs(PointExtrapolatedRPCFrame.
y())
524 <<
"," << fabs(PointExtrapolatedRPCFrame.
z()) <<
")" << std::endl;
527 std::cout <<
"MB4 \t \t \t Does the extrapolation go inside this roll?" << std::endl;
529 if (fabs(PointExtrapolatedRPCFrame.
z()) < 5. &&
530 fabs(PointExtrapolatedRPCFrame.
x()) < rsize * eyr &&
531 fabs(PointExtrapolatedRPCFrame.
y()) < stripl * eyr) {
533 std::cout <<
"MB4 \t \t \t \t yes" << std::endl;
535 std::cout <<
"MB4 \t \t \t \t Creating the RecHit" << std::endl;
536 RPCRecHit RPCPointMB4(rpcId, 0, PointExtrapolatedRPCFrame);
538 std::cout <<
"MB4 \t \t \t \t Clearing the RPCPointVector" << std::endl;
539 RPCPointVector.
clear();
541 std::cout <<
"MB4 \t \t \t \t Pushing Back" << std::endl;
544 std::cout <<
"MB4 \t \t \t \t Putting for " << rpcId << std::endl;
546 std::cout <<
"MB4 \t \t \t \t Filling container with " << nameRoll
547 <<
" Point.x=" << PointExtrapolatedRPCFrame.
x()
548 <<
" Point.y=" << PointExtrapolatedRPCFrame.
y()
549 <<
" size=" << RPCPointVector.
size() << std::endl;
551 std::cout <<
"MB4 \t \t \t \t Number of rolls already extrapolated in RB4 = "
552 << extrapolatedRolls.size() << std::endl;
553 if (
find(extrapolatedRolls.begin(), extrapolatedRolls.end(), rpcId.
rawId()) ==
554 extrapolatedRolls.end()) {
555 extrapolatedRolls.push_back(rpcId.
rawId());
556 _ThePoints->put(rpcId, RPCPointVector.
begin(), RPCPointVector.
end());
559 std::cout <<
"MB4 \t \t \t \t roll already extrapolated " << rpcId << std::endl;
562 std::cout <<
"MB4 \t \t \t \t Extrapolations done after this point = "
563 << extrapolatedRolls.size() << std::endl;
565 for (uint32_t
m = 0;
m < extrapolatedRolls.size();
m++)
566 std::cout <<
"MB4 \t \t \t \t" << extrapolatedRolls.at(
m) << std::endl;
569 std::cout <<
"MB4 \t \t \t \t No the prediction is outside of this roll" << std::endl;
574 std::cout <<
"MB4 \t \t \t No, Exrtrapolation too long!, canceled" << std::endl;
579 std::cout <<
"MB4 \t \t \t \t I found segments in MB4 and MB3 adjacent wheel and/or sector but "
580 "not compatibles, Diferent Directions"
585 std::cout <<
"MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D"
591 std::cout <<
"MB4 \t \t \t Is NOT a 2D Segment" << std::endl;
595 std::cout <<
"MB4 \t \t \t \t There is not just one segment or is not in station 4" << std::endl;
600 std::cout <<
"MB4 \t This event doesn't have 4D Segment" << std::endl;