From 0451806b8de40811820f8b8458bb552e5f4c008d Mon Sep 17 00:00:00 2001 From: Francesco Fiori Date: Fri, 25 Sep 2015 10:45:50 +0200 Subject: [PATCH 1/2] fix bpix efficiency 76x --- .../src/SiPixelHitEfficiencySource.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc b/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc index 27e66d22a6b6f..3083fbcf8c387 100644 --- a/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc +++ b/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc @@ -468,31 +468,36 @@ float y=predTrajState.globalPosition().y(); if(layer==1){ if(fabs(trackref->dxy(bestVtx->position()))>0.01 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; - if(!(L2hits>0&&L3hits>0&&L4hits>0) && !(L2hits>0&&D1hits>0&&D2hits) && !(D1hits>0&&D2hits>0&&D3hits>0)) continue; + if(!(L2hits>0&&L3hits>0) && !(L2hits>0&&D1hits>0) && !(D1hits>0&&D2hits>0)) continue; + //if(!(L2hits>0&&L3hits>0&&L4hits>0) && !(L2hits>0&&D1hits>0&&D2hits) && !(D1hits>0&&D2hits>0&&D3hits>0)) continue; }else if(layer==2){ if(fabs(trackref->dxy(bestVtx->position()))>0.02 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; - if(!(L1hits>0&&L3hits>0&&L4hits>0) && !(L1hits>0&&L3hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D2hits>0)) continue; + if(!(L1hits>0&&L3hits>0) && !(L1hits>0&&D1hits>0)) continue; + //if(!(L1hits>0&&L3hits>0&&L4hits>0) && !(L1hits>0&&L3hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D2hits>0)) continue; }else if(layer==3){ if(fabs(trackref->dxy(bestVtx->position()))>0.02 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; - if(!(L1hits>0&&L2hits>0&&L4hits>0) && !(L1hits>0&&L2hits>0&&D1hits>0)) continue; + if(!(L1hits>0&&L2hits>0)) continue; + //if(!(L1hits>0&&L2hits>0&&L4hits>0) && !(L1hits>0&&L2hits>0&&D1hits>0)) continue; }else if(layer==4){ if(fabs(trackref->dxy(bestVtx->position()))>0.02 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; - if(!(L1hits>0&&L2hits>0&&L3hits>0)) continue; + //if(!(L1hits>0&&L2hits>0&&L3hits>0)) continue; }else if(disk==1){ if(fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; - if(!(L1hits>0&&L2hits>0&&D2hits>0) && !(L1hits>0&&D2hits>0&&D3hits>0) && !(L2hits>0&&D2hits>0&&D3hits>0)) continue; + if(!(L1hits>0&&D2hits>0) && !(L2hits>0&&D2hits>0)) continue; + //if(!(L1hits>0&&L2hits>0&&D2hits>0) && !(L1hits>0&&D2hits>0&&D3hits>0) && !(L2hits>0&&D2hits>0&&D3hits>0)) continue; }else if(disk==2){ if(fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; - if(!(L1hits>0&&L2hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D3hits>0) && !(L2hits>0&&D1hits>0&&D3hits>0)) continue; + if(!(L1hits>0&&D1hits>0)) continue; + //if(!(L1hits>0&&L2hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D3hits>0) && !(L2hits>0&&D1hits>0&&D3hits>0)) continue; }else if(disk==3){ if(fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; - if(!(L1hits>0&&D1hits>0&&D2hits>0) && !(L2hits>0&&D1hits>0&&D2hits>0)) continue; + //if(!(L1hits>0&&D1hits>0&&D2hits>0) && !(L2hits>0&&D1hits>0&&D2hits>0)) continue; } //check whether hit is valid or missing using track algo flag From ebcb5cfbb468e3fb920e043dfd4fb5ae8952afdf Mon Sep 17 00:00:00 2001 From: Francesco Fiori Date: Tue, 29 Sep 2015 19:21:38 +0200 Subject: [PATCH 2/2] Bpix efficiency fix plus Pixel cluster probability histos 76x --- .../interface/SiPixelHitEfficiencySource.h | 18 ++ .../src/SiPixelHitEfficiencySource.cc | 214 ++++++++++++------ 2 files changed, 165 insertions(+), 67 deletions(-) diff --git a/DQM/SiPixelMonitorTrack/interface/SiPixelHitEfficiencySource.h b/DQM/SiPixelMonitorTrack/interface/SiPixelHitEfficiencySource.h index 06e5a2cb63417..d6d0ac27c5ec8 100644 --- a/DQM/SiPixelMonitorTrack/interface/SiPixelHitEfficiencySource.h +++ b/DQM/SiPixelMonitorTrack/interface/SiPixelHitEfficiencySource.h @@ -32,6 +32,7 @@ #include "Alignment/TrackerAlignment/interface/TrackerAlignableId.h" #include "Alignment/OfflineValidation/interface/TrackerValidationVariables.h" #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" +#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h" #include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h" #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" #include "DataFormats/SiPixelDetId/interface/PixelBarrelNameUpgrade.h" @@ -48,6 +49,7 @@ class SiPixelHitEfficiencySource : public DQMEDAnalyzer { virtual void dqmBeginRun(const edm::Run& r, edm::EventSetup const& iSetup); virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void fillClusterProbability(int , int, bool, double ); private: edm::ParameterSet pSet_; @@ -86,6 +88,22 @@ class SiPixelHitEfficiencySource : public DQMEDAnalyzer { bool isUpgrade; + //MEs for cluster probability + MonitorElement* meClusterProbabilityL1_Plus_; + MonitorElement* meClusterProbabilityL1_Minus_; + + MonitorElement* meClusterProbabilityL2_Plus_; + MonitorElement* meClusterProbabilityL2_Minus_; + + MonitorElement* meClusterProbabilityL3_Plus_; + MonitorElement* meClusterProbabilityL3_Minus_; + + MonitorElement* meClusterProbabilityD1_Plus_; + MonitorElement* meClusterProbabilityD1_Minus_; + + MonitorElement* meClusterProbabilityD2_Plus_; + MonitorElement* meClusterProbabilityD2_Minus_; + }; #endif diff --git a/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc b/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc index 3083fbcf8c387..e47a3e664e95b 100644 --- a/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc +++ b/DQM/SiPixelMonitorTrack/src/SiPixelHitEfficiencySource.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -80,7 +81,7 @@ SiPixelHitEfficiencySource::SiPixelHitEfficiencySource(const edm::ParameterSet& diskOn( pSet.getUntrackedParameter("diskOn",false) ), isUpgrade( pSet.getUntrackedParameter("isUpgrade",false) ) //updateEfficiencies( pSet.getUntrackedParameter("updateEfficiencies",false) ) - { +{ pSet_ = pSet; debug_ = pSet_.getUntrackedParameter("debug", false); applyEdgeCut_ = pSet_.getUntrackedParameter("applyEdgeCut"); @@ -111,17 +112,52 @@ SiPixelHitEfficiencySource::~SiPixelHitEfficiencySource() { } } +void SiPixelHitEfficiencySource::fillClusterProbability(int layer, int disk, bool plus, double probability){ + + //barrel + if (layer!=0){ + if (layer==1){ + if (plus) meClusterProbabilityL1_Plus_->Fill(probability); + else meClusterProbabilityL1_Minus_->Fill(probability); + } + + else if (layer==2){ + if (plus) meClusterProbabilityL2_Plus_->Fill(probability); + else meClusterProbabilityL2_Minus_->Fill(probability); + } + + else if (layer==3){ + if (plus) meClusterProbabilityL3_Plus_->Fill(probability); + else meClusterProbabilityL3_Minus_->Fill(probability); + } + } + //Endcap + if (disk!=0){ + if (disk==1){ + if (plus) meClusterProbabilityD1_Plus_->Fill(probability); + else meClusterProbabilityD1_Minus_->Fill(probability); + } + if (disk==2){ + if (plus) meClusterProbabilityD2_Plus_->Fill(probability); + else meClusterProbabilityD2_Minus_->Fill(probability); + } + } +} + + + + void SiPixelHitEfficiencySource::dqmBeginRun(const edm::Run& r, edm::EventSetup const& iSetup) { LogInfo("PixelDQM") << "SiPixelHitEfficiencySource beginRun()" << endl; if(firstRun){ - // retrieve TrackerGeometry for pixel dets + // retrieve TrackerGeometry for pixel dets - nvalid=0; - nmissing=0; + nvalid=0; + nmissing=0; - firstRun = false; + firstRun = false; } edm::ESHandle TG; @@ -144,7 +180,7 @@ void SiPixelHitEfficiencySource::dqmBeginRun(const edm::Run& r, edm::EventSetup } } LogInfo("PixelDQM") << "SiPixelStructure size is " << theSiPixelStructure.size() << endl; - + } void SiPixelHitEfficiencySource::bookHistograms(DQMStore::IBooker & iBooker, edm::Run const & iRun, edm::EventSetup const & iSetup){ @@ -184,6 +220,40 @@ void SiPixelHitEfficiencySource::bookHistograms(DQMStore::IBooker & iBooker, edm } } + //book cluster probability histos for Barrel and Endcap + iBooker.setCurrentFolder("Pixel/Barrel"); + + meClusterProbabilityL1_Plus_ = iBooker.book1D("ClusterProbabilityXY_Layer1_Plus","ClusterProbabilityXY_Layer1_Plus",250,-5,0.1); + meClusterProbabilityL1_Plus_->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityL1_Minus_ = iBooker.book1D("ClusterProbabilityXY_Layer1_Minus","ClusterProbabilityXY_Layer1_Minus",250,-5,0.1); + meClusterProbabilityL1_Minus_->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityL2_Plus_ = iBooker.book1D("ClusterProbabilityXY_Layer2_Plus","ClusterProbabilityXY_Layer2_Plus",250,-5,0.1); + meClusterProbabilityL2_Plus_ ->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityL2_Minus_ = iBooker.book1D("ClusterProbabilityXY_Layer2_Minus","ClusterProbabilityXY_Layer2_Minus",250,-5,0.1); + meClusterProbabilityL2_Minus_ ->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityL3_Plus_ = iBooker.book1D("ClusterProbabilityXY_Layer3_Plus","ClusterProbabilityXY_Layer3_Plus",250,-5,0.1); + meClusterProbabilityL3_Plus_->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityL3_Minus_ = iBooker.book1D("ClusterProbabilityXY_Layer3_Minus","ClusterProbabilityXY_Layer3_Minus",250,-5,0.1); + meClusterProbabilityL3_Minus_->setAxisTitle("Log(ClusterProbability)",1); + + iBooker.setCurrentFolder("Pixel/Endcap"); + + meClusterProbabilityD1_Plus_ = iBooker.book1D("ClusterProbabilityXY_Disk1_Plus","ClusterProbabilityXY_Disk1_Plus",250,-5,0.1); + meClusterProbabilityD1_Plus_ ->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityD1_Minus_ = iBooker.book1D("ClusterProbabilityXY_Disk1_Minus","ClusterProbabilityXY_Disk1_Minus",250,-5,0.1); + meClusterProbabilityD1_Minus_->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityD2_Plus_ = iBooker.book1D("ClusterProbabilityXY_Disk2_Plus","ClusterProbabilityXY_Disk2_Plus",250,-5,0.1); + meClusterProbabilityD2_Plus_ ->setAxisTitle("Log(ClusterProbability)",1); + + meClusterProbabilityD2_Minus_ = iBooker.book1D("ClusterProbabilityXY_Disk2_Minus","ClusterProbabilityXY_Disk2_Minus",250,-5,0.1); + meClusterProbabilityD2_Minus_->setAxisTitle("Log(ClusterProbability)",1); } @@ -368,64 +438,62 @@ void SiPixelHitEfficiencySource::analyze(const edm::Event& iEvent, const edm::Ev continue; } - TrajectoryStateOnSurface predTrajState=expTrajMeasurements[iexp].updatedState(); - float x=predTrajState.globalPosition().x(); -float y=predTrajState.globalPosition().y(); - float z=predTrajState.globalPosition().z(); - float dxyz=sqrt((chkx-x)*(chkx-x)+(chky-y)*(chky-y)+(chkz-z)*(chkz-z)); - - if (dxyz<=glmatch) { - glmatch=dxyz; - imatch=iexp; - imatches.push_back(int(imatch)); - } - - } // found the propagated traj best matching the hit in data - - float lxmatch = 9999.0; - float lymatch = 9999.0; - if(!expTrajMeasurements.empty()){ - if (glmatch<9999.) { // if there is any propagated trajectory for this hit - const DetId & matchhit_detId = expTrajMeasurements[imatch].recHit()->geographicalId(); + TrajectoryStateOnSurface predTrajState=expTrajMeasurements[iexp].updatedState(); + float x=predTrajState.globalPosition().x(); + float y=predTrajState.globalPosition().y(); + float z=predTrajState.globalPosition().z(); + float dxyz=sqrt((chkx-x)*(chkx-x)+(chky-y)*(chky-y)+(chkz-z)*(chkz-z)); + + if (dxyz<=glmatch) { + glmatch=dxyz; + imatch=iexp; + imatches.push_back(int(imatch)); + } + + } // found the propagated traj best matching the hit in data + + float lxmatch = 9999.0; + float lymatch = 9999.0; + if(!expTrajMeasurements.empty()){ + if (glmatch<9999.) { // if there is any propagated trajectory for this hit + const DetId & matchhit_detId = expTrajMeasurements[imatch].recHit()->geographicalId(); - int matchhit_ladder = PXBDetId(matchhit_detId).ladder(); - int dladder = abs(matchhit_ladder-hit_ladder); - if (dladder > 10) dladder = 20 - dladder; - LocalPoint lp = expTrajMeasurements[imatch].updatedState().localPosition(); - lxmatch=fabs(lp.x() - chklp.x()); - lymatch=fabs(lp.y() - chklp.y()); - } - if (lxmatch < maxlxmatch_ && lymatch < maxlymatch_) { + int matchhit_ladder = PXBDetId(matchhit_detId).ladder(); + int dladder = abs(matchhit_ladder-hit_ladder); + if (dladder > 10) dladder = 20 - dladder; + LocalPoint lp = expTrajMeasurements[imatch].updatedState().localPosition(); + lxmatch=fabs(lp.x() - chklp.x()); + lymatch=fabs(lp.y() - chklp.y()); + } + if (lxmatch < maxlxmatch_ && lymatch < maxlymatch_) { - if (testhit->getType()!=TrackingRecHit::missing || keepOriginalMissingHit_) { - expTrajMeasurements.erase(expTrajMeasurements.begin()+imatch); + if (testhit->getType()!=TrackingRecHit::missing || keepOriginalMissingHit_) { + expTrajMeasurements.erase(expTrajMeasurements.begin()+imatch); + } + + } + + } //expected trajectory measurment not empty } - - } - - } //expected trajectory measurment not empty - } }//loop on trajectory measurments tmeasColl //if an extrapolated hit was found but not matched to an exisitng L1 hit then push the hit back into the collection - //now keep the first one that is left - if(!expTrajMeasurements.empty()){ - for (size_t f=0; fgetType()==TrackingRecHit::missing){ - tmeasColl.push_back(AddHit); - isBpixtrack = true; + //now keep the first one that is left + if(!expTrajMeasurements.empty()){ + for (size_t f=0; fgetType()==TrackingRecHit::missing){ + tmeasColl.push_back(AddHit); + isBpixtrack = true; - } + } - } - - - + } } + if(isBpixtrack || isFpixtrack){ if(trackref->pt()<0.6 || - nStripHits<11 || + nStripHits<8 || fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; @@ -443,7 +511,7 @@ float y=predTrajState.globalPosition().y(); continue; else { -// //residual + // //residual const DetId & hit_detId = hit->geographicalId(); //uint IntRawDetID = (hit_detId.rawId()); uint IntSubDetID = (hit_detId.subdetId()); @@ -456,48 +524,59 @@ float y=predTrajState.globalPosition().y(); continue; int disk=0; int layer=0; int panel=0; int module=0; bool isHalfModule=false; + + const SiPixelRecHit* pixhit = dynamic_cast(hit->hit()); + if(IntSubDetID==PixelSubdetector::PixelBarrel){ // it's a BPIX hit layer = PixelBarrelName(hit_detId,pTT,isUpgrade).layerName(); isHalfModule = PixelBarrelName(hit_detId,pTT,isUpgrade).isHalfModule(); + + if (hit->isValid()){ //fill the cluster probability in barrel + bool plus=true; + if ((PixelBarrelName(hit_detId,pTT,isUpgrade).shell()== PixelBarrelName::Shell::mO) || (PixelBarrelName(hit_detId,pTT,isUpgrade).shell()==PixelBarrelName::Shell::mI)) plus=false; + double clusterProbability= pixhit->clusterProbability(0); + if (clusterProbability!=0) fillClusterProbability(layer,0,plus,log10(clusterProbability)); + } + }else if(IntSubDetID==PixelSubdetector::PixelEndcap){ // it's an FPIX hit disk = PixelEndcapName(hit_detId,pTT,isUpgrade).diskName(); panel = PixelEndcapName(hit_detId,pTT,isUpgrade).pannelName(); module = PixelEndcapName(hit_detId,pTT,isUpgrade).plaquetteName(); + + if (hit->isValid()){ + bool plus=true; + if ((PixelEndcapName(hit_detId,pTT,isUpgrade).halfCylinder()== PixelEndcapName::HalfCylinder::mO) || (PixelEndcapName(hit_detId,pTT,isUpgrade).halfCylinder()==PixelEndcapName::HalfCylinder::mI)) plus=false; + double clusterProbability= pixhit->clusterProbability(0); + if (clusterProbability!=0) fillClusterProbability(0,disk,plus,log10(clusterProbability)); + } } - + if(layer==1){ if(fabs(trackref->dxy(bestVtx->position()))>0.01 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; if(!(L2hits>0&&L3hits>0) && !(L2hits>0&&D1hits>0) && !(D1hits>0&&D2hits>0)) continue; - //if(!(L2hits>0&&L3hits>0&&L4hits>0) && !(L2hits>0&&D1hits>0&&D2hits) && !(D1hits>0&&D2hits>0&&D3hits>0)) continue; }else if(layer==2){ if(fabs(trackref->dxy(bestVtx->position()))>0.02 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; if(!(L1hits>0&&L3hits>0) && !(L1hits>0&&D1hits>0)) continue; - //if(!(L1hits>0&&L3hits>0&&L4hits>0) && !(L1hits>0&&L3hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D2hits>0)) continue; }else if(layer==3){ if(fabs(trackref->dxy(bestVtx->position()))>0.02 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; if(!(L1hits>0&&L2hits>0)) continue; - //if(!(L1hits>0&&L2hits>0&&L4hits>0) && !(L1hits>0&&L2hits>0&&D1hits>0)) continue; }else if(layer==4){ if(fabs(trackref->dxy(bestVtx->position()))>0.02 || fabs(trackref->dz(bestVtx->position()))>0.1) continue; - //if(!(L1hits>0&&L2hits>0&&L3hits>0)) continue; }else if(disk==1){ if(fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; if(!(L1hits>0&&D2hits>0) && !(L2hits>0&&D2hits>0)) continue; - //if(!(L1hits>0&&L2hits>0&&D2hits>0) && !(L1hits>0&&D2hits>0&&D3hits>0) && !(L2hits>0&&D2hits>0&&D3hits>0)) continue; }else if(disk==2){ if(fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; if(!(L1hits>0&&D1hits>0)) continue; - //if(!(L1hits>0&&L2hits>0&&D1hits>0) && !(L1hits>0&&D1hits>0&&D3hits>0) && !(L2hits>0&&D1hits>0&&D3hits>0)) continue; }else if(disk==3){ if(fabs(trackref->dxy(bestVtx->position()))>0.05 || fabs(trackref->dz(bestVtx->position()))>0.5) continue; - //if(!(L1hits>0&&D1hits>0&&D2hits>0) && !(L2hits>0&&D1hits>0&&D2hits>0)) continue; } //check whether hit is valid or missing using track algo flag @@ -519,6 +598,7 @@ float y=predTrajState.globalPosition().y(); if(fabs(lx)>0.55 || fabs(ly)>3.0) continue; bool passedFiducial=true; + // Module fiducials: if(IntSubDetID==PixelSubdetector::PixelBarrel && fabs(ly)>=3.1) passedFiducial=false; if(IntSubDetID==PixelSubdetector::PixelEndcap && @@ -628,8 +708,7 @@ float y=predTrajState.globalPosition().y(); float d_cl[2]; d_cl[0]=d_cl[1]=-9999.; if(dx_cl[0]!=-9999. && dy_cl[0]!=-9999.) d_cl[0]=sqrt(dx_cl[0]*dx_cl[0]+dy_cl[0]*dy_cl[0]); if(dx_cl[1]!=-9999. && dy_cl[1]!=-9999.) d_cl[1]=sqrt(dx_cl[1]*dx_cl[1]+dy_cl[1]*dy_cl[1]); - if(isHitMissing && (d_cl[0]<0.05 || d_cl[1]<0.05)){ isHitMissing=0; isHitValid=1; } - + if(isHitMissing && (d_cl[0]<0.05 || d_cl[1]<0.05)){ isHitMissing=0; isHitValid=1; } if(debug_){ std::cout << "Ready to add hit in histogram:\n"; @@ -637,9 +716,10 @@ float y=predTrajState.globalPosition().y(); std::cout << "isHitValid: "<