102 if(all4DSegments->size()>8){
103 if(
debug)
std::cout<<
"Too many segments in this event we are not doing the extrapolation"<<std::endl;
121 std::map<DTChamberId,int> DTSegmentCounter;
124 for (segment = all4DSegments->begin();segment!=all4DSegments->end(); ++segment){
125 DTSegmentCounter[segment->chamberId()]++;
140 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
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;
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;
153 int dtWheel = DTId.
wheel();
154 int dtStation = DTId.
station();
155 int dtSector = DTId.
sector();
157 LocalPoint segmentPosition= segment->localPosition();
158 LocalVector segmentDirection=segment->localDirection();
160 const GeomDet* gdet=dtGeo->idToDet(segment->geographicalId());
167 if(segment->dimension()!=4){
173 if(
debug)
std::cout<<
"DT \t \t DT Segment Dimension "<<segment->dimension()<<std::endl;
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();
186 if(
debug)
std::cout<<
"Getting the Rolls for the given index"<<std::endl;
190 if(
debug)
std::cout<<
"DT \t \t Number of rolls for this DT = "<<rollsForThisDT.size()<<std::endl;
192 assert(rollsForThisDT.size()>=1);
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);
201 std::string nameRoll = rpcsrv.name();
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;
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;
215 float D=CenterRollinDTFrame.
z();
223 if(
debug)
std::cout<<
"DT \t \t \t xmin of this Roll "<<xmin<<
"cm"<<std::endl;
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;
230 float stripw = top_->
pitch();
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;
238 float extrapolatedDistance =
sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
240 if(
debug)
std::cout<<
"DT \t \t \t Is the distance of extrapolation less than MaxD? ="<<extrapolatedDistance<<
"cm"<<
"MaxD="<<
MaxD<<
"cm"<<std::endl;
242 if(extrapolatedDistance<=
MaxD){
245 if(
debug)
std::cout<<
"DT \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
246 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.
toLocal(GlobalPointExtrapolated);
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;
254 if(fabs(PointExtrapolatedRPCFrame.
z()) < 1. &&
255 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*eyr &&
256 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*eyr){
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;
264 if(
debug)
std::cout<<
"DT \t \t \t \t Putting the vector"<<std::endl;
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;
271 if(
debug)
std::cout<<
"DT \t \t \t \t No the prediction is outside of this roll"<<std::endl;
274 if(
debug)
std::cout<<
"DT \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
281 if(all4DSegments->size()>0){
282 if(
debug)
std::cout<<
"MB4 \t \t Loop Over all4DSegments "<<all4DSegments->size()<<std::endl;
284 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
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;
292 if(DTSegmentCounter[DTId] == 1 && DTId.
station()==4){
295 int dtWheel = DTId.
wheel();
296 int dtStation = DTId.
station();
297 int dtSector = DTId.
sector();
299 LocalPoint segmentPosition= segment->localPosition();
300 LocalVector segmentDirection=segment->localDirection();
302 if(
debug)
std::cout<<
"MB4 \t \t \t \t The Segment in MB4 is 2D?"<<std::endl;
303 if(segment->dimension()==2){
306 LocalPoint segmentPositionMB4=segmentPosition;
308 bool compatiblesegments=
false;
310 const BoundPlane& DTSurface4 = dtGeo->idToDet(DTId)->surface();
314 if(
debug)
std::cout<<
"MB4 \t \t \t \t Loop on segments in =sector && MB3 && adjacent sectors && y dim=4"<<std::endl;
315 for(segMB3=all4DSegments->begin();segMB3!=all4DSegments->end();++segMB3){
319 if(
debug)
std::cout<<
"MB4 \t \t \t \t Segment in Chamber ="<<dtid3<<std::endl;
325 && DTSegmentCounter[dtid3] == 1
326 && segMB3->dimension()==4){
331 const GeomDet* gdet3=dtGeo->idToDet(segMB3->geographicalId());
332 const BoundPlane & DTSurface3 = gdet3->surface();
334 LocalVector segmentDirectionMB3 = segMB3->localDirection();
344 float dx=segDirMB4inGlobalFrame.
x();
345 float dy=segDirMB4inGlobalFrame.
y();
347 float dx3=segDirMB3inGlobalFrame.
x();
348 float dy3=segDirMB3inGlobalFrame.
y();
350 double cosAng=fabs(dx*dx3+dy*dy3/
sqrt((dx3*dx3+dy3*dy3)*(dx*dx+dy*dy)));
352 if(
debug)
std::cout<<
"MB4 \t \t \t \t cosAng"<<cosAng<<
"Beetween "<<dtid3<<
" and "<<DTId<<std::endl;
355 std::cout<<
"MB4 \t \t \t \t dx="<<dx<<
" dy="<<dy<<std::endl;
356 std::cout<<
"MB4 \t \t \t \t dx3="<<dx3<<
" dy3="<<dy<<std::endl;
357 std::cout<<
"MB4 \t \t \t \t cosAng="<<cosAng<<std::endl;
360 float DistanceBetweenSegments = ((segmentPositionMB3inGlobal) - (segmentPositionMB4inGlobal)).
mag();
364 if(
debug)
std::cout<<
"MB4 \t \t \t \t Distance between segments="<<DistanceBetweenSegments<<std::endl;
366 compatiblesegments=
true;
368 if(
debug)
std::cout<<
"MB4 \t \t We found compatible Segments (similar direction and close enough) in "<<dtid3<<
" and "<<DTId<<std::endl;
381 if(
debug)
std::cout<<
"Getting the Rolls for the given index"<<std::endl;
385 if(
debug)
std::cout<<
"MB4 \t \t Number of rolls for this DT = "<<rollsForThisDT.size()<<std::endl;
387 assert(rollsForThisDT.size()>=1);
389 if(
debug)
std::cout<<
"MB4 \t \t Loop over all the rolls asociated to this DT"<<std::endl;
390 for (std::set<RPCDetId>::iterator iteraRoll=rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
391 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
396 std::string nameRoll = rpcsrv.name();
398 if(
debug)
std::cout<<
"MB4 \t \t \t RollName: "<<nameRoll<<std::endl;
399 if(
debug)
std::cout<<
"MB4 \t \t \t Doing the extrapolation to this roll"<<std::endl;
403 LocalPoint segmentPositionMB3inMB4Frame = DTSurface4.
toLocal(segmentPositionMB3inGlobal);
404 LocalPoint segmentPositionMB3inRB4Frame = RPCSurfaceRB4.
toLocal(segmentPositionMB3inGlobal);
405 LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.
toLocal(segDirMB3inGlobalFrame);
408 float Dxz=CenterRollinMB4Frame.
z();
409 float Xo4=segmentPositionMB4.
x();
410 float dxl=segmentDirectionMB4.
x();
411 float dzl=segmentDirectionMB4.
z();
413 float X=Xo4+dxl*Dxz/dzl;
417 float Yo34 = segmentPositionMB3inMB4Frame.
y();
418 float dy34 = segmentDirectionMB3inMB4Frame.
y();
419 float dz34 = segmentDirectionMB3inMB4Frame.
z();
420 float Dy=Dxz-(segmentPositionMB3inMB4Frame.
z());
422 if(
debug)
std::cout<<
"MB4 \t \t \t The distance to extrapolate in Y from MB3 is "<<Dy<<
"cm"<<std::endl;
424 float Y=Yo34+dy34*Dy/dz34;
430 float rsize = fabs( xmax.
x()-xmin.
x() );
432 float stripw = top_->
pitch();
435 if(
debug)
std::cout<<
"MB4 \t \t \t Strip Lenght "<<stripl<<
"cm"<<std::endl;
436 if(
debug)
std::cout<<
"MB4 \t \t \t Strip Width "<<stripw<<
"cm"<<std::endl;
438 if(
debug)
std::cout<<
"MB4 \t \t \t X Predicted in MB4DTLocal= "<<X<<
"cm"<<std::endl;
439 if(
debug)
std::cout<<
"MB4 \t \t \t Y Predicted in MB4DTLocal= "<<Y<<
"cm"<<std::endl;
440 if(
debug)
std::cout<<
"MB4 \t \t \t Z Predicted in MB4DTLocal= "<<Z<<
"cm"<<std::endl;
442 float extrapolatedDistance =
sqrt((Y-Yo34)*(Y-Yo34)+Dy*Dy);
444 if(
debug)
std::cout<<
"MB4 \t \t \t segmentPositionMB3inMB4Frame"<<segmentPositionMB3inMB4Frame<<std::endl;
445 if(
debug)
std::cout<<
"MB4 \t \t \t segmentPositionMB4inMB4Frame"<<segmentPosition<<std::endl;
447 if(
debug)
std::cout<<
"MB4 \t \t \t segmentDirMB3inMB4Frame"<<segDirMB3inMB4Frame<<std::endl;
448 if(
debug)
std::cout<<
"MB4 \t \t \t segmentDirMB4inMB4Frame"<<segmentDirectionMB4<<std::endl;
450 if(
debug)
std::cout<<
"MB4 \t \t \t CenterRB4PositioninMB4Frame"<<CenterRollinMB4Frame<<std::endl;
452 if(
debug)
std::cout<<
"MB4 \t \t \t Is the extrapolation distance ="<<extrapolatedDistance<<
"less than "<<
MaxDrb4<<std::endl;
455 if(extrapolatedDistance<=
MaxDrb4){
460 if(
debug)
std::cout<<
"MB4 \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
462 LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.
toLocal(GlobalPointExtrapolated);
464 if(
debug)
std::cout<<
"MB4 \t \t \t Point Extrapolated in RPCLocal"<<PointExtrapolatedRPCFrame<< std::endl;
465 if(
debug)
std::cout<<
"MB4 \t \t \t Corner of the Roll = ("<<rsize*eyr<<
","<<stripl*eyr<<
")"<<std::endl;
466 if(
debug)
std::cout<<
"MB4 \t \t \t Info About the Point Extrapolated in X Abs ("<<fabs(PointExtrapolatedRPCFrame.
x())<<
","
467 <<fabs(PointExtrapolatedRPCFrame.
y())<<
","<<fabs(PointExtrapolatedRPCFrame.
z())<<
")"<<std::endl;
469 if(
debug)
std::cout<<
"MB4 \t \t \t Does the extrapolation go inside this roll?"<<std::endl;
471 if(fabs(PointExtrapolatedRPCFrame.
z()) < 5. &&
472 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*eyr &&
473 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*eyr){
475 if(
debug)
std::cout<<
"MB4 \t \t \t \t Creating the RecHit"<<std::endl;
476 RPCRecHit RPCPointMB4(rpcId,0,PointExtrapolatedRPCFrame);
477 if(
debug)
std::cout<<
"MB4 \t \t \t \t Clearing the RPCPointVector"<<std::endl;
481 if(
debug)
std::cout<<
"MB4 \t \t \t \t Putting for "<<rpcId<<std::endl;
482 if(
debug)
std::cout<<
"MB4 \t \t \t \t Filling container with "<<nameRoll
483 <<
" Point.x="<<PointExtrapolatedRPCFrame.
x()<<
" Point.y="<<PointExtrapolatedRPCFrame.
y()<<
" size="<<
RPCPointVector.
size()<<std::endl;
489 if(
debug)
std::cout<<
"MB4 \t \t \t \t roll already extrapolated "<<rpcId<<std::endl;
494 if(
debug)
std::cout<<
"MB4 \t \t \t \t No the prediction is outside of this roll"<<std::endl;
498 if(
debug)
std::cout<<
"MB4 \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
502 compatiblesegments=
false;
503 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;
506 if(
debug)
std::cout<<
"MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D"<<std::endl;
510 if(
debug)
std::cout<<
"MB4 \t \t \t Is NOT a 2D Segment"<<std::endl;
513 if(
debug)
std::cout<<
"MB4 \t \t \t \t There is not just one segment or is not in station 4"<<std::endl;
517 if(
debug)
std::cout<<
"MB4 \t This event doesn't have 4D Segment"<<std::endl;
const double Z[kNumberCalorimeter]
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
double MaxDistanceBetweenSegments
const Topology & topology() const
virtual float stripLength() const
std::set< RPCDetId > GetRolls(DTStationIndex dtstationindex)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int distsector(int sector1, int sector2)
virtual float pitch() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::OwnVector< RPCRecHit > RPCPointVector
uint32_t rawId() const
get the raw id
C::const_iterator const_iterator
constant access iterator type
LocalPoint toLocal(const GlobalPoint &gp) const
std::vector< uint32_t > extrapolatedRolls
static ObjectMap * GetInstance(const edm::EventSetup &iSetup)
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
int distwheel(int wheel1, int wheel2)
virtual LocalPoint localPosition(float strip) const
int station() const
Return the station number.
int wheel() const
Return the wheel number.
RPCRecHitCollection * _ThePoints
DecomposeProduct< arg, typename Div::arg > D
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.