233 std::stringstream meIdRPC, meIdDT, meIdCSC;
235 LogDebug(
"rpcefficiency") <<
"\t Getting the RPC RecHits";
242 LogDebug(
"rpcefficiency")<<
"\t Getting the DT Segments";
249 if(all4DSegments->size()>0){
253 LogDebug(
"rpcefficiency")<<
"\t Number of DT Segments in this event = "<<all4DSegments->size();
255 std::map<DTChamberId,int> DTSegmentCounter;
258 for (segment = all4DSegments->begin();segment!=all4DSegments->end(); ++segment){
259 DTSegmentCounter[segment->chamberId()]++;
264 LogDebug(
"rpcefficiency")<<
"\t Loop over all the 4D Segments";
265 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
270 if(DTSegmentCounter[DTId]==1 && DTId.
station()!=4){
272 int dtWheel = DTId.
wheel();
273 int dtStation = DTId.
station();
274 int dtSector = DTId.
sector();
276 LocalPoint segmentPosition= segment->localPosition();
277 LocalVector segmentDirection=segment->localDirection();
284 if(segment->dimension()==4){
286 float Xo=segmentPosition.
x();
287 float Yo=segmentPosition.
y();
288 float Zo=segmentPosition.
z();
289 float dx=segmentDirection.
x();
290 float dy=segmentDirection.
y();
291 float dz=segmentDirection.
z();
295 LogDebug(
"rpcefficiency")<<
"DT \t \t Loop over all the rolls asociated to this DT";
296 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
297 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
303 LocalPoint CenterRollinDTFrame = DTSurface.toLocal(CenterPointRollGlobal);
305 float D=CenterRollinDTFrame.
z();
313 LogDebug(
"rpcefficiency")<<
"DT \t \t \t xmin of this Roll "<<xmin<<
"cm";
315 LogDebug(
"rpcefficiency")<<
"DT \t \t \t xmax of this Roll "<<xmax<<
"cm";
316 float rsize = fabs( xmax.
x()-xmin.
x() );
317 LogDebug(
"rpcefficiency")<<
"DT \t \t \t Roll Size "<<rsize<<
"cm";
319 float stripw = top_->
pitch();
321 float extrapolatedDistance =
sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
323 if(extrapolatedDistance<=
MaxD){
326 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
328 if(fabs(PointExtrapolatedRPCFrame.
z()) < 10. &&
329 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*0.5 &&
330 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*0.5){
335 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t The RPCName is "<<nameRoll;
336 const float stripPredicted =
337 rollasociated->
strip(
LocalPoint(PointExtrapolatedRPCFrame.
x(),PointExtrapolatedRPCFrame.
y(),0.));
339 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t Candidate (from DT Segment) STRIP---> "<<stripPredicted<< std::endl;
344 meIdDT<<
"ExpectedOccupancyFromDT_"<<rollId.
rawId();
345 meMap[meIdDT.str()]->Fill(stripPredicted);
350 int countRecHits = 0;
352 float minres = 3000.;
354 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
355 rangeRecHits recHitCollection = rpcHits->get(rollasociated->
id());
358 for (recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++) {
362 float res=PointExtrapolatedRPCFrame.
x()- recHitPos.
x();
363 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t \t Found Rec Hit at "<<res<<
"cm of the prediction.";
364 if(fabs(res)<fabs(minres)){
366 cluSize = recHit->clusterSize();
367 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t \t \t New Min Res "<<res<<
"cm.";
372 LogDebug(
"rpcefficiency") <<
"DT \t \t \t \t \t THIS ROLL DOESN'T HAVE ANY RECHIT";
374 assert(minres!=3000);
376 if(fabs(minres)<=(
rangestrips+cluSize*0.5)*stripw){
377 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t \t \t True!";
401 meIdRPC<<
"RPCDataOccupancyFromDT_"<<rollId.
rawId();
402 meMap[meIdRPC.str()]->Fill(stripPredicted);
406 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t No the prediction is outside of this roll";
409 LogDebug(
"rpcefficiency")<<
"DT \t \t \t No, Exrtrapolation too long!, canceled";
414 LogDebug(
"rpcefficiency")<<
"DT \t \t More than one segment in this chamber, or we are in Station 4";
418 LogDebug(
"rpcefficiency")<<
"DT This Event doesn't have any DT4DDSegment";
427 if(all4DSegments.
isValid() && all4DSegments->size()>0){
429 std::map<DTChamberId,int> DTSegmentCounter;
432 for (segment = all4DSegments->begin();segment!=all4DSegments->end(); ++segment){
433 DTSegmentCounter[segment->chamberId()]++;
436 LogDebug(
"rpcefficiency")<<
"MB4 \t \t Loop Over all4DSegments";
437 for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
441 if(DTSegmentCounter[DTId] == 1 && DTId.
station()==4){
442 int dtWheel = DTId.
wheel();
443 int dtStation = DTId.
station();
444 int dtSector = DTId.
sector();
446 LocalPoint segmentPosition= segment->localPosition();
447 LocalVector segmentDirection=segment->localDirection();
451 if(segment->dimension()==2){
452 const LocalVector& segmentDirectionMB4=segmentDirection;
453 const LocalPoint& segmentPositionMB4=segmentPosition;
460 for(segMB3=all4DSegments->begin();segMB3!=all4DSegments->end();++segMB3){
467 && DTSegmentCounter[dtid3] == 1
468 && segMB3->dimension()==4){
473 LocalVector segmentDirectionMB3 = segMB3->localDirection();
474 GlobalPoint segmentPositionMB3inGlobal = DTSurface3.toGlobal(segMB3->localPosition());
476 GlobalVector segDirMB4inGlobalFrame=DTSurface4.toGlobal(segmentDirectionMB4);
477 GlobalVector segDirMB3inGlobalFrame=DTSurface3.toGlobal(segmentDirectionMB3);
479 float dx=segDirMB4inGlobalFrame.
x();
480 float dy=segDirMB4inGlobalFrame.
y();
483 float dx3=segDirMB3inGlobalFrame.
x();
484 float dy3=segDirMB3inGlobalFrame.
y();
487 double cosAng=fabs(dx*dx3+dy*dy3/
sqrt((dx3*dx3+dy3*dy3)*(dx*dx+dy*dy)));
499 assert(!rollsForThisDT.empty());
501 for (std::set<RPCDetId>::iterator iteraRoll=rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
502 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
509 LocalPoint CenterRollinMB4Frame = DTSurface4.toLocal(CenterPointRollGlobal);
510 LocalPoint segmentPositionMB3inMB4Frame = DTSurface4.toLocal(segmentPositionMB3inGlobal);
511 LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.toLocal(segDirMB3inGlobalFrame);
514 float Dxz=CenterRollinMB4Frame.
z();
515 float Xo4=segmentPositionMB4.
x();
516 float dxl=segmentDirectionMB4.
x();
517 float dzl=segmentDirectionMB4.
z();
519 float X=Xo4+dxl*Dxz/dzl;
523 float Yo34=segmentPositionMB3inMB4Frame.
y();
524 float dy34 = segmentDirectionMB3inMB4Frame.
y();
525 float dz34 = segmentDirectionMB3inMB4Frame.
z();
526 float Dy=Dxz-(segmentPositionMB3inMB4Frame.
z());
528 float Y=Yo34+dy34*Dy/dz34;
534 float rsize = fabs( xmax.
x()-xmin.
x() );
536 float stripw = top_->
pitch();
538 float extrapolatedDistance =
sqrt((Y-Yo34)*(Y-Yo34)+Dy*Dy);
540 if(extrapolatedDistance<=
MaxDrb4){
543 LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.toLocal(GlobalPointExtrapolated);
545 if(fabs(PointExtrapolatedRPCFrame.
z()) < 5. &&
546 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*0.5 &&
547 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*0.5){
550 const float stripPredicted=rollasociated->
strip(
LocalPoint(PointExtrapolatedRPCFrame.
x(),PointExtrapolatedRPCFrame.
y(),0.));
552 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t \t Candidate (from DT Segment) STRIP---> "<<stripPredicted<< std::endl;
557 meIdDT<<
"ExpectedOccupancyFromDT_"<<rollId.
rawId();
558 meMap[meIdDT.str()]->Fill(stripPredicted);
561 int countRecHits = 0;
563 float minres = 3000.;
565 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t \t Getting RecHits in Roll Asociated";
566 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
567 rangeRecHits recHitCollection = rpcHits->get(rollasociated->
id());
570 for (recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++) {
573 float res=PointExtrapolatedRPCFrame.
x()- recHitPos.
x();
574 LogDebug(
"rpcefficiency")<<
"DT \t \t \t \t \t Found Rec Hit at "<<res<<
"cm of the prediction.";
575 if(fabs(res)<fabs(minres)){
577 cluSize = recHit->clusterSize();
582 LogDebug(
"rpcefficiency") <<
"MB4 \t \t \t \t \t \t THIS ROLL DOESN'T HAVE ANY RECHIT";
584 assert(minres!=3000);
586 if(fabs(minres)<=(
rangestrips+cluSize*0.5)*stripw){
593 meIdRPC<<
"RPCDataOccupancyFromDT_"<<rollId.
rawId();
594 meMap[meIdRPC.str()]->Fill(stripPredicted);
598 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t \t No the prediction is outside of this roll";
602 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t No, Exrtrapolation too long!, canceled";
606 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t \t I found segments in MB4 and MB3 adjacent or same wheel and sector but not compatibles Diferent Directions";
609 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D";
613 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t Is NOT a 2D Segment";
616 LogDebug(
"rpcefficiency")<<
"MB4 \t \t \t \t There is not just one segment or is not in station 4";
620 LogDebug(
"rpcefficiency")<<
"MB4 \t This event doesn't have 4D Segment";
626 LogDebug(
"rpcefficiency") <<
"\t Getting the CSC Segments";
632 if(allCSCSegments->size()>0){
635 LogDebug(
"rpcefficiency")<<
"CSC \t Number of CSC Segments in this event = "<<allCSCSegments->size();
637 std::map<CSCDetId,int> CSCSegmentsCounter;
640 int segmentsInThisEventInTheEndcap=0;
642 for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
643 CSCSegmentsCounter[segment->cscDetId()]++;
644 segmentsInThisEventInTheEndcap++;
649 LogDebug(
"rpcefficiency")<<
"CSC \t loop over all the CSCSegments ";
650 for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
651 CSCDetId CSCId = segment->cscDetId();
653 if(CSCSegmentsCounter[CSCId]==1 && CSCId.
ring()!=1 && allCSCSegments->size()>=2){
654 LogDebug(
"rpcefficiency")<<
"CSC \t \t yes";
655 int cscEndCap = CSCId.
endcap();
656 int cscStation = CSCId.
station();
657 int cscRing = CSCId.
ring();
659 int rpcRegion = 1;
if(cscEndCap==2) rpcRegion= -1;
660 int rpcRing = cscRing;
661 if(cscRing==4)rpcRing =1;
662 int rpcStation = cscStation;
663 int rpcSegment = CSCId.
chamber();
665 LocalPoint segmentPosition= segment->localPosition();
666 LocalVector segmentDirection=segment->localDirection();
667 float dz=segmentDirection.
z();
669 LogDebug(
"rpcefficiency")<<
"CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < "<<acos(dz)*180/3.1415926<<
" < 135? ";
671 if(segment->dimension()==4 && (segment->nRecHits()<=10 && segment->nRecHits()>=4)&& acos(dz)*180/3.1415926 > 45. && acos(dz)*180/3.1415926 < 160. ){
673 float Xo=segmentPosition.
x();
674 float Yo=segmentPosition.
y();
675 float Zo=segmentPosition.
z();
676 float dx=segmentDirection.
x();
677 float dy=segmentDirection.
y();
678 float dz=segmentDirection.
z();
681 LogDebug(
"rpcefficiency")<<
"CSC \t \t Getting chamber from Geometry";
683 LogDebug(
"rpcefficiency")<<
"CSC \t \t Getting ID from Chamber";
685 LogDebug(
"rpcefficiency")<<
"CSC \t \t Printing The Id"<<TheId;
687 LogDebug(
"rpcefficiency")<<
"CSC \t \t Number of rolls for this CSC = "<<rollsForThisCSC.size();
692 for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++){
694 const RPCRoll* rollasociated = rpcGeo->
roll(*iteraRoll);
702 float D=CenterRollinCSCFrame.
z();
710 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t xmin of this Roll "<<xmin<<
"cm";
712 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t xmax of this Roll "<<xmax<<
"cm";
713 float rsize = fabs( xmax.
x()-xmin.
x() );
714 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t Roll Size "<<rsize<<
"cm";
716 float stripw = top_->
pitch();
719 float extrapolatedDistance =
sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
722 if(extrapolatedDistance<=
MaxD){
725 LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
728 if(fabs(PointExtrapolatedRPCFrame.
z()) < 10. &&
729 fabs(PointExtrapolatedRPCFrame.
x()) < rsize*0.5 &&
730 fabs(PointExtrapolatedRPCFrame.
y()) < stripl*0.5){
736 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t The RPCName is "<<nameRoll;
738 const float stripPredicted =
739 rollasociated->
strip(
LocalPoint(PointExtrapolatedRPCFrame.
x(),PointExtrapolatedRPCFrame.
y(),0.));
741 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t \t Candidate"<<rollId<<
" "<<
"(from CSC Segment) STRIP---> "<<stripPredicted<< std::endl;
746 meIdCSC<<
"ExpectedOccupancyFromCSC_"<<rollId.
rawId();
747 meMap[meIdCSC.str()]->Fill(stripPredicted);
753 int countRecHits = 0;
754 float minres = 3000.;
756 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t \t Getting RecHits in Roll Asociated";
757 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
758 rangeRecHits recHitCollection = rpcHits->get(rollasociated->
id());
761 for (recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++) {
765 float res=PointExtrapolatedRPCFrame.
x()- recHitPos.
x();
766 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t \t \t Found Rec Hit at "<<res<<
"cm of the prediction.";
767 if(fabs(res)<fabs(minres)){
769 cluSize = recHit->clusterSize();
770 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t \t \t \t New Min Res "<<res<<
"cm.";
775 LogDebug(
"rpcefficiency") <<
"CSC \t \t \t \t \t THIS ROLL DOESN'T HAVE ANY RECHIT";
777 assert(minres!=3000);
779 if(fabs(minres)<=(
rangestrips+cluSize*0.5)*stripw){
780 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t \t \t True!";
782 if(rollId.
ring()==2&&rollId.
roll()==1){
787 else if(rollId.
ring()==2&&rollId.
roll()==2){
792 else if(rollId.
ring()==2&&rollId.
roll()==3){
797 else if(rollId.
ring()==3&&rollId.
roll()==1){
802 else if(rollId.
ring()==3&&rollId.
roll()==2){
807 else if(rollId.
ring()==3&&rollId.
roll()==3){
813 meIdRPC<<
"RPCDataOccupancyFromCSC_"<<rollId.
rawId();
814 meMap[meIdRPC.str()]->Fill(stripPredicted);
819 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t \t No the prediction is outside of this roll";
822 LogDebug(
"rpcefficiency")<<
"CSC \t \t \t No, Exrtrapolation too long!, canceled";
828 LogDebug(
"rpcefficiency")<<
"CSC \t \t More than one segment in this chamber, or we are in Station Ring 1 or in Station 4";
832 LogDebug(
"rpcefficiency")<<
"CSC This Event doesn't have any CSCSegment";
float strip(const LocalPoint &lp) const
Point3DBase< Scalar, LocalTag > LocalPoint
LocalPoint localPosition(float strip) const override
int distsector_tmp(int sector1, int sector2)
MonitorElement * hGlobalResClu1R2A
bool getByToken(EDGetToken token, Handle< PROD > &result) const
CSCDetId id() const
Get the (concrete) DetId.
MonitorElement * hGlobalResClu1R3A
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
MonitorElement * hGlobalResClu3R2C
MonitorElement * hGlobalResClu2La[6]
constexpr uint32_t rawId() const
get the raw id
LocalPoint localPosition(float strip) const override
MonitorElement * hGlobalResClu3R3C
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
std::map< int, std::map< std::string, MonitorElement * > > meCollection
const Topology & topology() const override
const Plane & surface() const
The nominal surface of the GeomDet.
C::const_iterator const_iterator
constant access iterator type
float pitch() const override
float pitch() const override
edm::EDGetTokenT< RPCRecHitCollection > RPCRecHitLabel_
MonitorElement * hGlobalResClu3La[6]
MonitorElement * hGlobalResClu3R2A
MonitorElement * hGlobalResClu1R3B
float stripLength() const override
det heigth (strip length in the middle)
MonitorElement * hGlobalResClu1R2C
MonitorElement * hGlobalResClu2R3C
MonitorElement * hGlobalResClu3R3A
std::map< CSCStationIndex, std::set< RPCDetId > > rollstoreCSC
MonitorElement * statistics
edm::EDGetTokenT< CSCSegmentCollection > cscSegments
std::map< DTStationIndex, std::set< RPCDetId > > rollstoreDT
edm::EDGetTokenT< DTRecSegment4DCollection > dt4DSegments
MonitorElement * hGlobalResClu2R2A
DecomposeProduct< arg, typename Div::arg > D
MonitorElement * hGlobalResClu2R3A
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
MonitorElement * hGlobalResClu1La[6]
const GeomDet * idToDet(DetId) const override
MonitorElement * hGlobalResClu1R3C
MonitorElement * hGlobalResClu2R2B
int station() const
Return the station number.
MonitorElement * hGlobalResClu3R3B
int wheel() const
Return the wheel number.
MonitorElement * hGlobalResClu3R2B
MonitorElement * hGlobalResClu2R3B
MonitorElement * hGlobalResClu1R2B
MonitorElement * hGlobalResClu2R2C
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
float stripLength() const override