66 if(all4DSegments->size()>8){
67 if(
debug)
std::cout<<
"Too many segments in this event we are not doing the extrapolation"<<std::endl;
87 std::map<DTChamberId,int> DTSegmentCounter;
90 for (segment = all4DSegments->begin();segment!=all4DSegments->end(); ++segment){
91 DTSegmentCounter[segment->chamberId()]++;
106 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
110 if(
debug)
std::cout<<
"DT \t \t This Segment is in Chamber id: "<<DTId<<std::endl;
111 if(
debug)
std::cout<<
"DT \t \t Number of segments in this DT = "<<DTSegmentCounter[DTId]<<std::endl;
112 if(
debug)
std::cout<<
"DT \t \t Is the only one in this DT? and is not in the 4th Station?"<<std::endl;
114 if(DTSegmentCounter[DTId]!=1 || DTId.
station()==4){
115 if(
debug)
std::cout<<
"DT \t \t More than one segment in this chamber, or we are in Station 4"<<std::endl;
119 int dtWheel = DTId.
wheel();
120 int dtStation = DTId.
station();
121 int dtSector = DTId.
sector();
123 LocalPoint segmentPosition= segment->localPosition();
124 LocalVector segmentDirection=segment->localDirection();
126 const GeomDet* gdet=dtGeo->idToDet(segment->geographicalId());
133 if(segment->dimension()!=4){
139 if(
debug)
std::cout<<
"DT \t \t DT Segment Dimension "<<segment->dimension()<<std::endl;
141 float Xo=segmentPosition.
x();
142 float Yo=segmentPosition.
y();
143 float Zo=segmentPosition.
z();
144 float dx=segmentDirection.
x();
145 float dy=segmentDirection.
y();
146 float dz=segmentDirection.
z();
150 if(
debug)
std::cout<<
"Getting the Rolls for the given index"<<std::endl;
151 std::set<RPCDetId> rollsForThisDT = dtMap->getRolls(theindex);
153 if(
debug)
std::cout<<
"DT \t \t Number of rolls for this DT = "<<rollsForThisDT.size()<<std::endl;
155 assert(rollsForThisDT.size()>=1);
157 if(
debug)
std::cout<<
"DT \t \t Loop over all the rolls asociated to this DT"<<std::endl;
158 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
159 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
166 if(
debug)
std::cout<<
"DT \t \t \t RollName: "<<nameRoll<<std::endl;
167 if(
debug)
std::cout<<
"DT \t \t \t Doing the extrapolation to this roll"<<std::endl;
168 if(
debug)
std::cout<<
"DT \t \t \t DT Segment Direction in DTLocal "<<segmentDirection<<std::endl;
169 if(
debug)
std::cout<<
"DT \t \t \t DT Segment Point in DTLocal "<<segmentPosition<<std::endl;
173 LocalPoint CenterRollinDTFrame = DTSurface.toLocal(CenterPointRollGlobal);
175 if(
debug)
std::cout<<
"DT \t \t \t Center (0,0,0) Roll In DTLocal"<<CenterRollinDTFrame<<std::endl;
176 if(
debug)
std::cout<<
"DT \t \t \t Center (0,0,0) of the Roll in Global"<<CenterPointRollGlobal<<std::endl;
178 float D=CenterRollinDTFrame.
z();
186 if(
debug)
std::cout<<
"DT \t \t \t xmin of this Roll "<<xmin<<
"cm"<<std::endl;
188 if(
debug)
std::cout<<
"DT \t \t \t xmax of this Roll "<<xmax<<
"cm"<<std::endl;
189 float rsize = fabs( xmax.
x()-xmin.
x() );
190 if(
debug)
std::cout<<
"DT \t \t \t Roll Size "<<rsize<<
"cm"<<std::endl;
193 float stripw = top_->
pitch();
195 if(
debug)
std::cout<<
"DT \t \t \t Strip Lenght "<<stripl<<
"cm"<<std::endl;
196 if(
debug)
std::cout<<
"DT \t \t \t Strip Width "<<stripw<<
"cm"<<std::endl;
197 if(
debug)
std::cout<<
"DT \t \t \t X Predicted in DTLocal= "<<X<<
"cm"<<std::endl;
198 if(
debug)
std::cout<<
"DT \t \t \t Y Predicted in DTLocal= "<<Y<<
"cm"<<std::endl;
199 if(
debug)
std::cout<<
"DT \t \t \t Z Predicted in DTLocal= "<<Z<<
"cm"<<std::endl;
201 float extrapolatedDistance =
sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
203 if(
debug)
std::cout<<
"DT \t \t \t Is the distance of extrapolation less than MaxD? ="<<extrapolatedDistance<<
"cm"<<
"MaxD="<<
MaxD<<
"cm"<<std::endl;
205 if(extrapolatedDistance<=
MaxD){
208 if(
debug)
std::cout<<
"DT \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
209 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
211 if(
debug)
std::cout<<
"DT \t \t \t Point Extrapolated in RPCLocal"<<PointExtrapolatedRPCFrame<< std::endl;
212 if(
debug)
std::cout<<
"DT \t \t \t Corner of the Roll = ("<<rsize*eyr<<
","<<stripl*eyr<<
")"<<std::endl;
213 if(
debug)
std::cout<<
"DT \t \t \t Info About the Point Extrapolated in X Abs ("<<fabs(PointExtrapolatedRPCFrame.
x())<<
","
214 <<fabs(PointExtrapolatedRPCFrame.
y())<<
","<<fabs(PointExtrapolatedRPCFrame.
z())<<
")"<<std::endl;
215 if(
debug)
std::cout<<
"DT \t \t \t Does the extrapolation go inside this roll?"<<std::endl;
217 if(fabs(PointExtrapolatedRPCFrame.
z()) < 1. &&
218 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*eyr &&
219 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*eyr){
221 if(
debug)
std::cout<<
"DT \t \t \t \t Creating the RecHit"<<std::endl;
222 RPCRecHit RPCPoint(rpcId,0,PointExtrapolatedRPCFrame);
223 if(
debug)
std::cout<<
"DT \t \t \t \t Clearing the vector"<<std::endl;
227 if(
debug)
std::cout<<
"DT \t \t \t \t Putting the vector"<<std::endl;
230 if(
debug)
std::cout<<
"DT \t \t \t \t Filling container with "<<nameRoll
231 <<
" Point.x="<<PointExtrapolatedRPCFrame.
x()<<
" Point.y="<<PointExtrapolatedRPCFrame.
y()<<
" size="<<
RPCPointVector.
size()<<std::endl;
234 if(
debug)
std::cout<<
"DT \t \t \t \t No the prediction is outside of this roll"<<std::endl;
237 if(
debug)
std::cout<<
"DT \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
244 if(all4DSegments->size()>0){
245 if(
debug)
std::cout<<
"MB4 \t \t Loop Over all4DSegments "<<all4DSegments->size()<<std::endl;
247 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
251 if(
debug)
std::cout<<
"MB4 \t \t This Segment is in Chamber id: "<<DTId<<std::endl;
252 if(
debug)
std::cout<<
"MB4 \t \t Number of segments in this DT = "<<DTSegmentCounter[DTId]<<std::endl;
253 if(
debug)
std::cout<<
"MB4 \t \t \t Is the only one in this DT? and is in the Station 4?"<<std::endl;
255 if(DTSegmentCounter[DTId] == 1 && DTId.
station()==4){
258 int dtWheel = DTId.
wheel();
259 int dtStation = DTId.
station();
260 int dtSector = DTId.
sector();
262 LocalPoint segmentPosition= segment->localPosition();
263 LocalVector segmentDirection=segment->localDirection();
265 if(
debug)
std::cout<<
"MB4 \t \t \t \t The Segment in MB4 is 2D?"<<std::endl;
266 if(segment->dimension()==2){
269 LocalPoint segmentPositionMB4=segmentPosition;
271 const BoundPlane& DTSurface4 = dtGeo->idToDet(DTId)->surface();
275 if(
debug)
std::cout<<
"MB4 \t \t \t \t Loop on segments in =sector && MB3 && adjacent sectors && y dim=4"<<std::endl;
276 for(segMB3=all4DSegments->begin();segMB3!=all4DSegments->end();++segMB3){
280 if(
debug)
std::cout<<
"MB4 \t \t \t \t Segment in Chamber ="<<dtid3<<std::endl;
286 && DTSegmentCounter[dtid3] == 1
287 && segMB3->dimension()==4){
292 const GeomDet* gdet3=dtGeo->idToDet(segMB3->geographicalId());
293 const BoundPlane & DTSurface3 = gdet3->surface();
295 LocalVector segmentDirectionMB3 = segMB3->localDirection();
296 GlobalPoint segmentPositionMB3inGlobal = DTSurface3.toGlobal(segMB3->localPosition());
297 GlobalPoint segmentPositionMB4inGlobal = DTSurface4.toGlobal(segmentPosition);
300 LocalVector segDirMB3inMB4Frame=DTSurface4.toLocal(DTSurface3.toGlobal(segmentDirectionMB3));
302 GlobalVector segDirMB4inGlobalFrame=DTSurface4.toGlobal(segmentDirectionMB4);
303 GlobalVector segDirMB3inGlobalFrame=DTSurface3.toGlobal(segmentDirectionMB3);
305 float dx=segDirMB4inGlobalFrame.
x();
306 float dy=segDirMB4inGlobalFrame.
y();
308 float dx3=segDirMB3inGlobalFrame.
x();
309 float dy3=segDirMB3inGlobalFrame.
y();
311 double cosAng=fabs(dx*dx3+dy*dy3/
sqrt((dx3*dx3+dy3*dy3)*(dx*dx+dy*dy)));
313 if(
debug)
std::cout<<
"MB4 \t \t \t \t cosAng"<<cosAng<<
"Beetween "<<dtid3<<
" and "<<DTId<<std::endl;
316 std::cout<<
"MB4 \t \t \t \t dx="<<dx<<
" dy="<<dy<<std::endl;
317 std::cout<<
"MB4 \t \t \t \t dx3="<<dx3<<
" dy3="<<dy<<std::endl;
318 std::cout<<
"MB4 \t \t \t \t cosAng="<<cosAng<<std::endl;
321 float DistanceBetweenSegments = ((segmentPositionMB3inGlobal) - (segmentPositionMB4inGlobal)).
mag();
325 if(
debug)
std::cout<<
"MB4 \t \t \t \t Distance between segments="<<DistanceBetweenSegments<<std::endl;
327 if(
debug)
std::cout<<
"MB4 \t \t We found compatible Segments (similar direction and close enough) in "<<dtid3<<
" and "<<DTId<<std::endl;
338 if(
debug)
std::cout<<
"Getting the Rolls for the given index"<<std::endl;
339 std::set<RPCDetId> rollsForThisDT = dtMap->getRolls(theindex);
341 if(
debug)
std::cout<<
"MB4 \t \t Number of rolls for this DT = "<<rollsForThisDT.size()<<std::endl;
343 assert(rollsForThisDT.size()>=1);
345 if(
debug)
std::cout<<
"MB4 \t \t Loop over all the rolls asociated to this DT"<<std::endl;
346 for (std::set<RPCDetId>::iterator iteraRoll=rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
347 const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
354 if(
debug)
std::cout<<
"MB4 \t \t \t RollName: "<<nameRoll<<std::endl;
355 if(
debug)
std::cout<<
"MB4 \t \t \t Doing the extrapolation to this roll"<<std::endl;
358 LocalPoint CenterRollinMB4Frame = DTSurface4.toLocal(CenterPointRollGlobal);
359 LocalPoint segmentPositionMB3inMB4Frame = DTSurface4.toLocal(segmentPositionMB3inGlobal);
361 LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.toLocal(segDirMB3inGlobalFrame);
364 float Dxz=CenterRollinMB4Frame.
z();
365 float Xo4=segmentPositionMB4.
x();
366 float dxl=segmentDirectionMB4.
x();
367 float dzl=segmentDirectionMB4.
z();
369 float X=Xo4+dxl*Dxz/dzl;
373 float Yo34 = segmentPositionMB3inMB4Frame.
y();
374 float dy34 = segmentDirectionMB3inMB4Frame.
y();
375 float dz34 = segmentDirectionMB3inMB4Frame.
z();
376 float Dy=Dxz-(segmentPositionMB3inMB4Frame.
z());
378 if(
debug)
std::cout<<
"MB4 \t \t \t The distance to extrapolate in Y from MB3 is "<<Dy<<
"cm"<<std::endl;
380 float Y=Yo34+dy34*Dy/dz34;
386 float rsize = fabs( xmax.
x()-xmin.
x() );
388 float stripw = top_->
pitch();
391 if(
debug)
std::cout<<
"MB4 \t \t \t Strip Lenght "<<stripl<<
"cm"<<std::endl;
392 if(
debug)
std::cout<<
"MB4 \t \t \t Strip Width "<<stripw<<
"cm"<<std::endl;
394 if(
debug)
std::cout<<
"MB4 \t \t \t X Predicted in MB4DTLocal= "<<X<<
"cm"<<std::endl;
395 if(
debug)
std::cout<<
"MB4 \t \t \t Y Predicted in MB4DTLocal= "<<Y<<
"cm"<<std::endl;
396 if(
debug)
std::cout<<
"MB4 \t \t \t Z Predicted in MB4DTLocal= "<<Z<<
"cm"<<std::endl;
398 float extrapolatedDistance =
sqrt((Y-Yo34)*(Y-Yo34)+Dy*Dy);
400 if(
debug)
std::cout<<
"MB4 \t \t \t segmentPositionMB3inMB4Frame"<<segmentPositionMB3inMB4Frame<<std::endl;
401 if(
debug)
std::cout<<
"MB4 \t \t \t segmentPositionMB4inMB4Frame"<<segmentPosition<<std::endl;
403 if(
debug)
std::cout<<
"MB4 \t \t \t segmentDirMB3inMB4Frame"<<segDirMB3inMB4Frame<<std::endl;
404 if(
debug)
std::cout<<
"MB4 \t \t \t segmentDirMB4inMB4Frame"<<segmentDirectionMB4<<std::endl;
406 if(
debug)
std::cout<<
"MB4 \t \t \t CenterRB4PositioninMB4Frame"<<CenterRollinMB4Frame<<std::endl;
408 if(
debug)
std::cout<<
"MB4 \t \t \t Is the extrapolation distance ="<<extrapolatedDistance<<
"less than "<<
MaxDrb4<<std::endl;
411 if(extrapolatedDistance<=
MaxDrb4){
416 if(
debug)
std::cout<<
"MB4 \t \t \t Point ExtraPolated in Global"<<GlobalPointExtrapolated<< std::endl;
418 LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.toLocal(GlobalPointExtrapolated);
420 if(
debug)
std::cout<<
"MB4 \t \t \t Point Extrapolated in RPCLocal"<<PointExtrapolatedRPCFrame<< std::endl;
421 if(
debug)
std::cout<<
"MB4 \t \t \t Corner of the Roll = ("<<rsize*eyr<<
","<<stripl*eyr<<
")"<<std::endl;
422 if(
debug)
std::cout<<
"MB4 \t \t \t Info About the Point Extrapolated in X Abs ("<<fabs(PointExtrapolatedRPCFrame.
x())<<
","
423 <<fabs(PointExtrapolatedRPCFrame.
y())<<
","<<fabs(PointExtrapolatedRPCFrame.
z())<<
")"<<std::endl;
425 if(
debug)
std::cout<<
"MB4 \t \t \t Does the extrapolation go inside this roll?"<<std::endl;
427 if(fabs(PointExtrapolatedRPCFrame.
z()) < 5. &&
428 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*eyr &&
429 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*eyr){
431 if(
debug)
std::cout<<
"MB4 \t \t \t \t Creating the RecHit"<<std::endl;
432 RPCRecHit RPCPointMB4(rpcId,0,PointExtrapolatedRPCFrame);
433 if(
debug)
std::cout<<
"MB4 \t \t \t \t Clearing the RPCPointVector"<<std::endl;
437 if(
debug)
std::cout<<
"MB4 \t \t \t \t Putting for "<<rpcId<<std::endl;
438 if(
debug)
std::cout<<
"MB4 \t \t \t \t Filling container with "<<nameRoll
439 <<
" Point.x="<<PointExtrapolatedRPCFrame.
x()<<
" Point.y="<<PointExtrapolatedRPCFrame.
y()<<
" size="<<
RPCPointVector.
size()<<std::endl;
445 if(
debug)
std::cout<<
"MB4 \t \t \t \t roll already extrapolated "<<rpcId<<std::endl;
450 if(
debug)
std::cout<<
"MB4 \t \t \t \t No the prediction is outside of this roll"<<std::endl;
454 if(
debug)
std::cout<<
"MB4 \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
458 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;
461 if(
debug)
std::cout<<
"MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D"<<std::endl;
465 if(
debug)
std::cout<<
"MB4 \t \t \t Is NOT a 2D Segment"<<std::endl;
468 if(
debug)
std::cout<<
"MB4 \t \t \t \t There is not just one segment or is not in station 4"<<std::endl;
472 if(
debug)
std::cout<<
"MB4 \t This event doesn't have 4D Segment"<<std::endl;
const double Z[kNumberCalorimeter]
double MaxDistanceBetweenSegments
const Topology & topology() const
virtual float stripLength() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int distsector(int sector1, int sector2)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::OwnVector< RPCRecHit > RPCPointVector
const Plane & surface() const
The nominal surface of the GeomDet.
uint32_t rawId() const
get the raw id
std::vector< uint32_t > extrapolatedRolls
std::unique_ptr< RPCRecHitCollection > _ThePoints
edm::RangeMap< RPCDetId, edm::OwnVector< RPCRecHit, edm::ClonePolicy< RPCRecHit > >, edm::ClonePolicy< RPCRecHit > > RPCRecHitCollection
DecomposeProduct< arg, typename Div::arg > D
int distwheel(int wheel1, int wheel2)
virtual float pitch() const
virtual LocalPoint localPosition(float strip) const
int station() const
Return the station number.
int wheel() const
Return the wheel number.