CMS 3D CMS Logo

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