CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTSegtoRPC.cc
Go to the documentation of this file.
11 #include "DTSegtoRPC.h"
12 #include "DTObjectMap.h"
13 #include "DTStationIndex.h"
14 
15 #include <ctime>
16 
17 int distsector(int sector1, int sector2) {
18  if (sector1 == 13)
19  sector1 = 4;
20  if (sector1 == 14)
21  sector1 = 10;
22 
23  if (sector2 == 13)
24  sector2 = 4;
25  if (sector2 == 14)
26  sector2 = 10;
27 
28  int distance = std::abs(sector1 - sector2);
29  if (distance > 6)
30  distance = 12 - distance;
31  return distance;
32 }
33 
34 int distwheel(int wheel1, int wheel2) {
35  int distance = std::abs(wheel1 - wheel2);
36  return distance;
37 }
38 
40  : rpcGeoToken_(iC.esConsumes()), dtGeoToken_(iC.esConsumes()), dtMapToken_(iC.esConsumes()) {
41  /*
42  MinCosAng=iConfig.getUntrackedParameter<double>("MinCosAng",0.95);
43  MaxD=iConfig.getUntrackedParameter<double>("MaxD",80.);
44  MaxDrb4=iConfig.getUntrackedParameter<double>("MaxDrb4",150.);
45  */
46  incldt = true;
47  incldtMB4 = true;
48 
49  //By now hard coded parameters
50  MinCosAng = 0.85;
51  MaxD = 80.;
52  MaxDrb4 = 150.;
54  /*
55 
56  //These should be always true expect for debuggin porpouses
57  incldt=true;
58  incldtMB4=true;
59  */
60 }
61 
62 std::unique_ptr<RPCRecHitCollection> DTSegtoRPC::thePoints(const DTRecSegment4DCollection* all4DSegments,
63  const edm::EventSetup& iSetup,
64  bool debug,
65  double eyr) {
66  /*
67  struct timespec start_time, stop_time;
68  time_t fs;
69  time_t fn;
70  time_t ls;
71  time_t ln;
72  clock_gettime(CLOCK_REALTIME, &start_time);
73  */
74 
75  auto _ThePoints = std::make_unique<RPCRecHitCollection>();
76  edm::OwnVector<RPCRecHit> RPCPointVector;
77  std::vector<uint32_t> extrapolatedRolls;
78 
79  if (all4DSegments->size() > 8) {
80  if (debug)
81  std::cout << "Too many segments in this event we are not doing the extrapolation" << std::endl;
82  } else {
86 
87  /*
88  clock_gettime(CLOCK_REALTIME, &stop_time);
89  fs=start_time.tv_sec;
90  fn=start_time.tv_nsec;
91  ls=stop_time.tv_sec;
92  ln=stop_time.tv_nsec;
93  std::cout <<" =================|| "<<ls-fs<<" sec "<<ln-fn<<" us"<<std::endl;
94  clock_gettime(CLOCK_REALTIME, &start_time);
95  */
96 
97  std::map<DTChamberId, int> DTSegmentCounter;
99 
100  for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
101  DTSegmentCounter[segment->chamberId()]++;
102  }
103 
104  /*
105  clock_gettime(CLOCK_REALTIME, &stop_time);
106  fs=start_time.tv_sec;
107  fn=start_time.tv_nsec;
108  ls=stop_time.tv_sec;
109  ln=stop_time.tv_nsec;
110  if(debug) std::cout <<" =================||| "<<ls-fs<<" sec "<<ln-fn<<" us"<<std::endl;
111  clock_gettime(CLOCK_REALTIME, &start_time);
112  */
113 
114  if (incldt) {
115  for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment) {
116  DTChamberId DTId = segment->chamberId();
117 
118  if (debug)
119  std::cout << "DT \t \t This Segment is in Chamber id: " << DTId << std::endl;
120  if (debug)
121  std::cout << "DT \t \t Number of segments in this DT = " << DTSegmentCounter[DTId] << std::endl;
122  if (debug)
123  std::cout << "DT \t \t Is the only one in this DT? and is not in the 4th Station?" << std::endl;
124 
125  if (DTSegmentCounter[DTId] != 1 || DTId.station() == 4) {
126  if (debug)
127  std::cout << "DT \t \t More than one segment in this chamber, or we are in Station 4" << std::endl;
128  continue;
129  }
130 
131  int dtWheel = DTId.wheel();
132  int dtStation = DTId.station();
133  int dtSector = DTId.sector();
134 
135  LocalPoint segmentPosition = segment->localPosition();
136  LocalVector segmentDirection = segment->localDirection();
137 
138  const GeomDet* gdet = dtGeo->idToDet(segment->geographicalId());
139  const BoundPlane& DTSurface = gdet->surface();
140 
141  //check if the dimension of the segment is 4
142 
143  if (debug)
144  std::cout << "DT \t \t Is the segment 4D?" << std::endl;
145 
146  if (segment->dimension() != 4) {
147  if (debug)
148  std::cout << "DT \t \t no" << std::endl;
149  continue;
150  }
151 
152  if (debug)
153  std::cout << "DT \t \t yes" << std::endl;
154  if (debug)
155  std::cout << "DT \t \t DT Segment Dimension " << segment->dimension() << std::endl;
156 
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();
163 
164  if (debug)
165  std::cout << "Creating the DTIndex" << std::endl;
166  DTStationIndex theindex(0, dtWheel, dtSector, dtStation);
167  if (debug)
168  std::cout << "Getting the Rolls for the given index" << std::endl;
169  std::set<RPCDetId> rollsForThisDT = dtMap->getRolls(theindex);
170 
171  if (debug)
172  std::cout << "DT \t \t Number of rolls for this DT = " << rollsForThisDT.size() << std::endl;
173 
174  assert(!rollsForThisDT.empty());
175 
176  if (debug)
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();
179  iteraRoll++) {
180  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
181  RPCDetId rpcId = rollasociated->id();
182  const BoundPlane& RPCSurface = rollasociated->surface();
183 
184  RPCGeomServ rpcsrv(rpcId);
185  std::string nameRoll = rpcsrv.name();
186 
187  if (debug)
188  std::cout << "DT \t \t \t RollName: " << nameRoll << std::endl;
189  if (debug)
190  std::cout << "DT \t \t \t Doing the extrapolation to this roll" << std::endl;
191  if (debug)
192  std::cout << "DT \t \t \t DT Segment Direction in DTLocal " << segmentDirection << std::endl;
193  if (debug)
194  std::cout << "DT \t \t \t DT Segment Point in DTLocal " << segmentPosition << std::endl;
195 
196  GlobalPoint CenterPointRollGlobal = RPCSurface.toGlobal(LocalPoint(0, 0, 0));
197 
198  LocalPoint CenterRollinDTFrame = DTSurface.toLocal(CenterPointRollGlobal);
199 
200  if (debug)
201  std::cout << "DT \t \t \t Center (0,0,0) Roll In DTLocal" << CenterRollinDTFrame << std::endl;
202  if (debug)
203  std::cout << "DT \t \t \t Center (0,0,0) of the Roll in Global" << CenterPointRollGlobal << std::endl;
204 
205  float D = CenterRollinDTFrame.z();
206 
207  float X = Xo + dx * D / dz;
208  float Y = Yo + dy * D / dz;
209  float Z = D;
210 
211  const RectangularStripTopology* top_ =
212  dynamic_cast<const RectangularStripTopology*>(&(rollasociated->topology()));
213  LocalPoint xmin = top_->localPosition(0.);
214  if (debug)
215  std::cout << "DT \t \t \t xmin of this Roll " << xmin << "cm" << std::endl;
216  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
217  if (debug)
218  std::cout << "DT \t \t \t xmax of this Roll " << xmax << "cm" << std::endl;
219  float rsize = fabs(xmax.x() - xmin.x());
220  if (debug)
221  std::cout << "DT \t \t \t Roll Size " << rsize << "cm" << std::endl;
222  float stripl = top_->stripLength();
223 
224  float stripw = top_->pitch();
225 
226  if (debug)
227  std::cout << "DT \t \t \t Strip Lenght " << stripl << "cm" << std::endl;
228  if (debug)
229  std::cout << "DT \t \t \t Strip Width " << stripw << "cm" << std::endl;
230  if (debug)
231  std::cout << "DT \t \t \t X Predicted in DTLocal= " << X << "cm" << std::endl;
232  if (debug)
233  std::cout << "DT \t \t \t Y Predicted in DTLocal= " << Y << "cm" << std::endl;
234  if (debug)
235  std::cout << "DT \t \t \t Z Predicted in DTLocal= " << Z << "cm" << std::endl;
236 
237  float extrapolatedDistance = sqrt((X - Xo) * (X - Xo) + (Y - Yo) * (Y - Yo) + (Z - Zo) * (Z - Zo));
238 
239  if (debug)
240  std::cout << "DT \t \t \t Is the distance of extrapolation less than MaxD? =" << extrapolatedDistance
241  << "cm"
242  << "MaxD=" << MaxD << "cm" << std::endl;
243 
244  if (extrapolatedDistance <= MaxD) {
245  if (debug)
246  std::cout << "DT \t \t \t yes" << std::endl;
247  GlobalPoint GlobalPointExtrapolated = DTSurface.toGlobal(LocalPoint(X, Y, Z));
248  if (debug)
249  std::cout << "DT \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated << std::endl;
250  LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
251 
252  if (debug)
253  std::cout << "DT \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame << std::endl;
254  if (debug)
255  std::cout << "DT \t \t \t Corner of the Roll = (" << rsize * eyr << "," << stripl * eyr << ")"
256  << std::endl;
257  if (debug)
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;
261  if (debug)
262  std::cout << "DT \t \t \t Does the extrapolation go inside this roll?" << std::endl;
263 
264  if (fabs(PointExtrapolatedRPCFrame.z()) < 1. && fabs(PointExtrapolatedRPCFrame.x()) < rsize * eyr &&
265  fabs(PointExtrapolatedRPCFrame.y()) < stripl * eyr) {
266  if (debug)
267  std::cout << "DT \t \t \t \t yes" << std::endl;
268  if (debug)
269  std::cout << "DT \t \t \t \t Creating the RecHit" << std::endl;
270  RPCRecHit RPCPoint(rpcId, 0, PointExtrapolatedRPCFrame);
271  if (debug)
272  std::cout << "DT \t \t \t \t Clearing the vector" << std::endl;
273  RPCPointVector.clear();
274  if (debug)
275  std::cout << "DT \t \t \t \t Pushing back" << std::endl;
276  RPCPointVector.push_back(RPCPoint);
277  if (debug)
278  std::cout << "DT \t \t \t \t Putting the vector" << std::endl;
279  _ThePoints->put(rpcId, RPCPointVector.begin(), RPCPointVector.end());
280 
281  if (debug)
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()
285  << std::endl;
286 
287  } else {
288  if (debug)
289  std::cout << "DT \t \t \t \t No the prediction is outside of this roll" << std::endl;
290  } //Condition for the right match
291  } else {
292  if (debug)
293  std::cout << "DT \t \t \t No, Exrtrapolation too long!, canceled" << std::endl;
294  } //D so big
295  } //loop over all the rolls asociated
296  }
297  }
298 
299  if (incldtMB4) {
300  if (all4DSegments->size() > 0) {
301  if (debug)
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) {
305  DTChamberId DTId = segment->chamberId();
306 
307  if (debug)
308  std::cout << "MB4 \t \t This Segment is in Chamber id: " << DTId << std::endl;
309  if (debug)
310  std::cout << "MB4 \t \t Number of segments in this DT = " << DTSegmentCounter[DTId] << std::endl;
311  if (debug)
312  std::cout << "MB4 \t \t \t Is the only one in this DT? and is in the Station 4?" << std::endl;
313 
314  if (DTSegmentCounter[DTId] == 1 && DTId.station() == 4) {
315  if (debug)
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();
320 
321  LocalPoint segmentPosition = segment->localPosition();
322  LocalVector segmentDirection = segment->localDirection();
323 
324  if (debug)
325  std::cout << "MB4 \t \t \t \t The Segment in MB4 is 2D?" << std::endl;
326  if (segment->dimension() == 2) {
327  if (debug)
328  std::cout << "MB4 \t \t \t \t yes" << std::endl;
329  const LocalVector& segmentDirectionMB4 = segmentDirection;
330  const LocalPoint& segmentPositionMB4 = segmentPosition;
331 
332  const BoundPlane& DTSurface4 = dtGeo->idToDet(DTId)->surface();
333 
335 
336  if (debug)
337  std::cout << "MB4 \t \t \t \t Loop on segments in =sector && MB3 && adjacent sectors && y dim=4"
338  << std::endl;
339  for (segMB3 = all4DSegments->begin(); segMB3 != all4DSegments->end(); ++segMB3) {
340  DTChamberId dtid3 = segMB3->chamberId();
341 
342  if (debug)
343  std::cout << "MB4 \t \t \t \t Segment in Chamber =" << dtid3 << std::endl;
344 
345  if (distsector(dtid3.sector(), DTId.sector()) <=
346  1 //The DT sector could be 13 or 14 and because is corrected in the calculation of the distance.
347  && distwheel(dtid3.wheel(), DTId.wheel()) <=
348  1 //The we could have segments in neighbohr wheels in pp collisions
349  && dtid3.station() == 3 && DTSegmentCounter[dtid3] == 1 && segMB3->dimension() == 4) {
350  if (debug)
351  std::cout << "MB4 \t \t \t \t distsector =" << distsector(dtid3.sector(), DTId.sector())
352  << std::endl;
353  if (debug)
354  std::cout << "MB4 \t \t \t \t distwheel =" << distwheel(dtid3.wheel(), DTId.wheel()) << std::endl;
355 
356  const GeomDet* gdet3 = dtGeo->idToDet(segMB3->geographicalId());
357  const BoundPlane& DTSurface3 = gdet3->surface();
358 
359  LocalVector segmentDirectionMB3 = segMB3->localDirection();
360  GlobalPoint segmentPositionMB3inGlobal = DTSurface3.toGlobal(segMB3->localPosition());
361  GlobalPoint segmentPositionMB4inGlobal = DTSurface4.toGlobal(segmentPosition);
362 
363  //LocalVector segDirMB4inMB3Frame=DTSurface3.toLocal(DTSurface4.toGlobal(segmentDirectionMB4));
364  LocalVector segDirMB3inMB4Frame = DTSurface4.toLocal(DTSurface3.toGlobal(segmentDirectionMB3));
365 
366  GlobalVector segDirMB4inGlobalFrame = DTSurface4.toGlobal(segmentDirectionMB4);
367  GlobalVector segDirMB3inGlobalFrame = DTSurface3.toGlobal(segmentDirectionMB3);
368 
369  float dx = segDirMB4inGlobalFrame.x();
370  float dy = segDirMB4inGlobalFrame.y();
371 
372  float dx3 = segDirMB3inGlobalFrame.x();
373  float dy3 = segDirMB3inGlobalFrame.y();
374 
375  double cosAng = fabs(dx * dx3 + dy * dy3 / sqrt((dx3 * dx3 + dy3 * dy3) * (dx * dx + dy * dy)));
376 
377  if (debug)
378  std::cout << "MB4 \t \t \t \t cosAng" << cosAng << "Beetween " << dtid3 << " and " << DTId
379  << std::endl;
380 
381  if (debug) {
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;
385  }
386 
387  float DistanceBetweenSegments = ((segmentPositionMB3inGlobal) - (segmentPositionMB4inGlobal)).mag();
388 
389  if (cosAng > MinCosAng && DistanceBetweenSegments < MaxDistanceBetweenSegments) {
390  if (debug)
391  std::cout << "MB4 \t \t \t \t Distance between segments=" << DistanceBetweenSegments << std::endl;
392 
393  if (debug)
394  std::cout << "MB4 \t \t We found compatible Segments (similar direction and close enough) in "
395  << dtid3 << " and " << DTId << std::endl;
396 
397  if (dtSector == 13) {
398  dtSector = 4;
399  }
400  if (dtSector == 14) {
401  dtSector = 10;
402  }
403 
404  if (debug)
405  std::cout << "Creating the DTIndex" << std::endl;
406  DTStationIndex theindex(0, dtWheel, dtSector, dtStation);
407  if (debug)
408  std::cout << "Getting the Rolls for the given index" << std::endl;
409  std::set<RPCDetId> rollsForThisDT = dtMap->getRolls(theindex);
410 
411  if (debug)
412  std::cout << "MB4 \t \t Number of rolls for this DT = " << rollsForThisDT.size() << std::endl;
413 
414  assert(!rollsForThisDT.empty());
415 
416  if (debug)
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();
420  iteraRoll++) {
421  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll); //roll asociado a MB4
422  RPCDetId rpcId = rollasociated->id();
423  const BoundPlane& RPCSurfaceRB4 = rollasociated->surface(); //surface MB4
424 
425  RPCGeomServ rpcsrv(rpcId);
426  std::string nameRoll = rpcsrv.name();
427 
428  if (debug)
429  std::cout << "MB4 \t \t \t RollName: " << nameRoll << std::endl;
430  if (debug)
431  std::cout << "MB4 \t \t \t Doing the extrapolation to this roll" << std::endl;
432 
433  GlobalPoint CenterPointRollGlobal = RPCSurfaceRB4.toGlobal(LocalPoint(0, 0, 0));
434  LocalPoint CenterRollinMB4Frame = DTSurface4.toLocal(CenterPointRollGlobal); //In MB4
435  LocalPoint segmentPositionMB3inMB4Frame =
436  DTSurface4.toLocal(segmentPositionMB3inGlobal); //In MB4
437  //LocalPoint segmentPositionMB3inRB4Frame = RPCSurfaceRB4.toLocal(segmentPositionMB3inGlobal); //In MB4
438  LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.toLocal(segDirMB3inGlobalFrame); //In MB4
439 
440  //The exptrapolation is done in MB4 frame. for local x and z is done from MB4,
441  float Dxz = CenterRollinMB4Frame.z();
442  float Xo4 = segmentPositionMB4.x();
443  float dxl = segmentDirectionMB4.x(); //dx local for MB4 segment in MB4 Frame
444  float dzl = segmentDirectionMB4.z(); //dx local for MB4 segment in MB4 Frame
445 
446  float X = Xo4 + dxl * Dxz / dzl; //In MB4 frame
447  float Z = Dxz; //In MB4 frame
448 
449  //for local y is done from MB3
450  float Yo34 = segmentPositionMB3inMB4Frame.y();
451  float dy34 = segmentDirectionMB3inMB4Frame.y();
452  float dz34 = segmentDirectionMB3inMB4Frame.z();
453  float Dy =
454  Dxz -
455  (segmentPositionMB3inMB4Frame.z()); //Distance beetween the segment in MB3 and the RB4 surface
456 
457  if (debug)
458  std::cout << "MB4 \t \t \t The distance to extrapolate in Y from MB3 is " << Dy << "cm"
459  << std::endl;
460 
461  float Y = Yo34 + dy34 * Dy / dz34; //In MB4 Frame
462 
463  const RectangularStripTopology* top_ = dynamic_cast<const RectangularStripTopology*>(
464  &(rollasociated->topology())); //Topology roll asociated MB4
465  LocalPoint xmin = top_->localPosition(0.);
466  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
467  float rsize = fabs(xmax.x() - xmin.x());
468  float stripl = top_->stripLength();
469  float stripw = top_->pitch();
470 
471  if (debug)
472  std::cout << "MB4 \t \t \t Strip Lenght " << stripl << "cm" << std::endl;
473  if (debug)
474  std::cout << "MB4 \t \t \t Strip Width " << stripw << "cm" << std::endl;
475 
476  if (debug)
477  std::cout << "MB4 \t \t \t X Predicted in MB4DTLocal= " << X << "cm" << std::endl;
478  if (debug)
479  std::cout << "MB4 \t \t \t Y Predicted in MB4DTLocal= " << Y << "cm" << std::endl;
480  if (debug)
481  std::cout << "MB4 \t \t \t Z Predicted in MB4DTLocal= " << Z << "cm" << std::endl;
482 
483  float extrapolatedDistance = sqrt((Y - Yo34) * (Y - Yo34) + Dy * Dy);
484 
485  if (debug)
486  std::cout << "MB4 \t \t \t segmentPositionMB3inMB4Frame" << segmentPositionMB3inMB4Frame
487  << std::endl;
488  if (debug)
489  std::cout << "MB4 \t \t \t segmentPositionMB4inMB4Frame" << segmentPosition << std::endl;
490 
491  if (debug)
492  std::cout << "MB4 \t \t \t segmentDirMB3inMB4Frame" << segDirMB3inMB4Frame << std::endl;
493  if (debug)
494  std::cout << "MB4 \t \t \t segmentDirMB4inMB4Frame" << segmentDirectionMB4 << std::endl;
495 
496  if (debug)
497  std::cout << "MB4 \t \t \t CenterRB4PositioninMB4Frame" << CenterRollinMB4Frame << std::endl;
498 
499  if (debug)
500  std::cout << "MB4 \t \t \t Is the extrapolation distance =" << extrapolatedDistance
501  << "less than " << MaxDrb4 << std::endl;
502 
503  if (extrapolatedDistance <= MaxDrb4) {
504  if (debug)
505  std::cout << "MB4 \t \t \t yes" << std::endl;
506 
507  GlobalPoint GlobalPointExtrapolated = DTSurface4.toGlobal(LocalPoint(X, Y, Z));
508 
509  if (debug)
510  std::cout << "MB4 \t \t \t Point ExtraPolated in Global" << GlobalPointExtrapolated
511  << std::endl;
512 
513  LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.toLocal(GlobalPointExtrapolated);
514 
515  if (debug)
516  std::cout << "MB4 \t \t \t Point Extrapolated in RPCLocal" << PointExtrapolatedRPCFrame
517  << std::endl;
518  if (debug)
519  std::cout << "MB4 \t \t \t Corner of the Roll = (" << rsize * eyr << "," << stripl * eyr
520  << ")" << std::endl;
521  if (debug)
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;
525 
526  if (debug)
527  std::cout << "MB4 \t \t \t Does the extrapolation go inside this roll?" << std::endl;
528 
529  if (fabs(PointExtrapolatedRPCFrame.z()) < 5. &&
530  fabs(PointExtrapolatedRPCFrame.x()) < rsize * eyr &&
531  fabs(PointExtrapolatedRPCFrame.y()) < stripl * eyr) {
532  if (debug)
533  std::cout << "MB4 \t \t \t \t yes" << std::endl;
534  if (debug)
535  std::cout << "MB4 \t \t \t \t Creating the RecHit" << std::endl;
536  RPCRecHit RPCPointMB4(rpcId, 0, PointExtrapolatedRPCFrame);
537  if (debug)
538  std::cout << "MB4 \t \t \t \t Clearing the RPCPointVector" << std::endl;
539  RPCPointVector.clear();
540  if (debug)
541  std::cout << "MB4 \t \t \t \t Pushing Back" << std::endl;
542  RPCPointVector.push_back(RPCPointMB4);
543  if (debug)
544  std::cout << "MB4 \t \t \t \t Putting for " << rpcId << std::endl;
545  if (debug)
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;
550  if (debug)
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());
557  } else {
558  if (debug)
559  std::cout << "MB4 \t \t \t \t roll already extrapolated " << rpcId << std::endl;
560  }
561  if (debug)
562  std::cout << "MB4 \t \t \t \t Extrapolations done after this point = "
563  << extrapolatedRolls.size() << std::endl;
564  if (debug)
565  for (uint32_t m = 0; m < extrapolatedRolls.size(); m++)
566  std::cout << "MB4 \t \t \t \t" << extrapolatedRolls.at(m) << std::endl;
567  } else {
568  if (debug)
569  std::cout << "MB4 \t \t \t \t No the prediction is outside of this roll" << std::endl;
570  }
571  } //Condition for the right match
572  else {
573  if (debug)
574  std::cout << "MB4 \t \t \t No, Exrtrapolation too long!, canceled" << std::endl;
575  }
576  } //loop over all the rollsasociated
577  } else {
578  if (debug)
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"
581  << std::endl;
582  }
583  } else { //if dtid3.station()==3&&dtid3.sector()==DTId.sector()&&dtid3.wheel()==DTId.wheel()&&segMB3->dim()==4
584  if (debug)
585  std::cout << "MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D"
586  << std::endl;
587  }
588  } //loop over all the segments looking for one in MB3
589  } else {
590  if (debug)
591  std::cout << "MB4 \t \t \t Is NOT a 2D Segment" << std::endl;
592  }
593  } else {
594  if (debug)
595  std::cout << "MB4 \t \t \t \t There is not just one segment or is not in station 4" << std::endl;
596  } //De aca para abajo esta en dtpart.inl
597  }
598  } else {
599  if (debug)
600  std::cout << "MB4 \t This event doesn't have 4D Segment" << std::endl;
601  }
602  }
603  }
604 
605  /*
606  clock_gettime(CLOCK_REALTIME, &stop_time);
607  fs=start_time.tv_sec;
608  fn=start_time.tv_nsec;
609  ls=stop_time.tv_sec;
610  ln=stop_time.tv_nsec;
611  std::cout <<" =================|||| "<<ls-fs<<" sec "<<ln-fn<<" us"<<std::endl;
612  */
613 
614  return _ThePoints;
615 }
double MaxDistanceBetweenSegments
Definition: DTSegtoRPC.h:35
LocalPoint localPosition(float strip) const override
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int distsector(int sector1, int sector2)
Definition: DTSegtoRPC.cc:17
int nstrips() const
Definition: RPCRoll.cc:24
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
#define X(str)
Definition: MuonsGrabber.cc:38
float pitch() const override
edm::ESGetToken< DTObjectMap, MuonGeometryRecord > dtMapToken_
Definition: DTSegtoRPC.h:28
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
assert(be >=bs)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
float stripLength() const override
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
RPCDetId id() const
Definition: RPCRoll.cc:16
virtual std::string name()
Definition: RPCGeomServ.cc:11
double MaxD
Definition: DTSegtoRPC.h:33
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeoToken_
Definition: DTSegtoRPC.h:27
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double MaxDrb4
Definition: DTSegtoRPC.h:34
#define debug
Definition: HDRShower.cc:19
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
std::unique_ptr< RPCRecHitCollection > thePoints(DTRecSegment4DCollection const *all4DSegments, edm::EventSetup const &iSetup, bool debug, double eyr)
Definition: DTSegtoRPC.cc:62
bool incldtMB4
Definition: DTSegtoRPC.h:31
bool incldt
Definition: DTSegtoRPC.h:30
int distwheel(int wheel1, int wheel2)
Definition: DTSegtoRPC.cc:34
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeoToken_
Definition: DTSegtoRPC.h:26
int sector() const
Definition: DTChamberId.h:49
const Topology & topology() const override
Definition: RPCRoll.cc:18
tuple cout
Definition: gather_cfg.py:144
double MinCosAng
Definition: DTSegtoRPC.h:32
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
T x() const
Definition: PV3DBase.h:59
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
DTSegtoRPC(edm::ConsumesCollector iC)
Definition: DTSegtoRPC.cc:39