Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:40

0001 #include "FWCore/Framework/interface/ESWatcher.h"
0002 #include "Validation/SiTrackerPhase2V/interface/Phase2ITValidateRecHitBase.h"
0003 #include "Validation/SiTrackerPhase2V/interface/TrackerPhase2ValidationUtil.h"
0004 #include "DQM/SiTrackerPhase2/interface/TrackerPhase2DQMUtil.h"
0005 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0008 #include "Geometry/CommonDetUnit/interface/TrackerGeomDet.h"
0009 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0010 #include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
0011 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0012 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0013 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0014 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0015 
0016 Phase2ITValidateRecHitBase::~Phase2ITValidateRecHitBase() = default;
0017 
0018 Phase2ITValidateRecHitBase::Phase2ITValidateRecHitBase(const edm::ParameterSet& iConfig)
0019     : config_(iConfig),
0020       geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
0021       topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()) {
0022   edm::LogInfo("Phase2ITValidateRecHitBase") << ">>> Construct Phase2ITValidateRecHitBase ";
0023 }
0024 
0025 void Phase2ITValidateRecHitBase::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
0026   tkGeom_ = &iSetup.getData(geomToken_);
0027   tTopo_ = &iSetup.getData(topoToken_);
0028 }
0029 //
0030 // -- Book Histograms
0031 //
0032 void Phase2ITValidateRecHitBase::bookHistograms(DQMStore::IBooker& ibooker,
0033                                                 edm::Run const& iRun,
0034                                                 edm::EventSetup const& iSetup) {
0035   std::string top_folder = config_.getParameter<std::string>("TopFolderName");
0036   edm::LogInfo("Phase2ITValidateRecHitBase") << " Booking Histograms in : " << top_folder;
0037   edm::ESWatcher<TrackerDigiGeometryRecord> theTkDigiGeomWatcher;
0038   if (theTkDigiGeomWatcher.check(iSetup)) {
0039     for (auto const& det_u : tkGeom_->detUnits()) {
0040       //Always check TrackerNumberingBuilder before changing this part
0041       if (!(det_u->subDetector() == GeomDetEnumerators::SubDetector::P2PXB ||
0042             det_u->subDetector() == GeomDetEnumerators::SubDetector::P2PXEC))
0043         continue;
0044       unsigned int detId_raw = det_u->geographicalId().rawId();
0045       bookLayerHistos(ibooker, detId_raw, top_folder);
0046     }
0047   }
0048 }
0049 
0050 //
0051 void Phase2ITValidateRecHitBase::bookLayerHistos(DQMStore::IBooker& ibooker, unsigned int det_id, std::string& subdir) {
0052   ibooker.cd();
0053   std::string key = phase2tkutil::getITHistoId(det_id, tTopo_);
0054   if (key.empty())
0055     return;
0056   if (layerMEs_.find(key) == layerMEs_.end()) {
0057     ibooker.cd();
0058     RecHitME local_histos;
0059     ibooker.setCurrentFolder(subdir + "/" + key);
0060     edm::LogInfo("Phase2ITValidateRecHit") << " Booking Histograms in : " << (subdir + "/" + key);
0061 
0062     local_histos.deltaX = phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaX"), ibooker);
0063 
0064     local_histos.deltaY = phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY"), ibooker);
0065 
0066     local_histos.pullX = phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("PullX"), ibooker);
0067 
0068     local_histos.pullY = phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("PullY"), ibooker);
0069 
0070     local_histos.deltaX_eta =
0071         phase2tkutil::book2DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaX_eta"), ibooker);
0072 
0073     local_histos.deltaX_phi =
0074         phase2tkutil::book2DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaX_phi"), ibooker);
0075 
0076     local_histos.deltaY_eta =
0077         phase2tkutil::book2DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY_eta"), ibooker);
0078 
0079     local_histos.deltaY_phi =
0080         phase2tkutil::book2DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY_phi"), ibooker);
0081 
0082     local_histos.deltaX_clsizex =
0083         phase2tkutil::bookProfile1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaX_clsizex"), ibooker);
0084 
0085     local_histos.deltaX_clsizey =
0086         phase2tkutil::bookProfile1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaX_clsizey"), ibooker);
0087 
0088     local_histos.deltaY_clsizex =
0089         phase2tkutil::bookProfile1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY_clsizex"), ibooker);
0090 
0091     local_histos.deltaY_clsizey =
0092         phase2tkutil::bookProfile1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY_clsizey"), ibooker);
0093 
0094     local_histos.deltaYvsdeltaX =
0095         phase2tkutil::book2DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY_vs_DeltaX"), ibooker);
0096 
0097     local_histos.pullX_eta =
0098         phase2tkutil::bookProfile1DFromPSet(config_.getParameter<edm::ParameterSet>("PullX_eta"), ibooker);
0099 
0100     local_histos.pullY_eta =
0101         phase2tkutil::bookProfile1DFromPSet(config_.getParameter<edm::ParameterSet>("PullY_eta"), ibooker);
0102     ibooker.setCurrentFolder(subdir + "/" + key + "/PrimarySimHits");
0103     //all histos for Primary particles
0104     local_histos.numberRecHitsprimary =
0105         phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("nRecHits_primary"), ibooker);
0106 
0107     local_histos.deltaX_primary =
0108         phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaX_primary"), ibooker);
0109 
0110     local_histos.deltaY_primary =
0111         phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("DeltaY_primary"), ibooker);
0112 
0113     local_histos.pullX_primary =
0114         phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("PullX_primary"), ibooker);
0115 
0116     local_histos.pullY_primary =
0117         phase2tkutil::book1DFromPSet(config_.getParameter<edm::ParameterSet>("PullY_primary"), ibooker);
0118 
0119     layerMEs_.emplace(key, local_histos);
0120   }
0121 }
0122 
0123 void Phase2ITValidateRecHitBase::fillRechitHistos(const PSimHit* simhitClosest,
0124                                                   const SiPixelRecHit* rechit,
0125                                                   const std::map<unsigned int, SimTrack>& selectedSimTrackMap,
0126                                                   std::map<std::string, unsigned int>& nrechitLayerMap_primary) {
0127   auto id = rechit->geographicalId();
0128   std::string key = phase2tkutil::getITHistoId(id.rawId(), tTopo_);
0129   const GeomDetUnit* geomDetunit(tkGeom_->idToDetUnit(id));
0130   if (!geomDetunit)
0131     return;
0132 
0133   LocalPoint lp = rechit->localPosition();
0134   auto simTrackIt(selectedSimTrackMap.find(simhitClosest->trackId()));
0135   bool isPrimary = false;
0136   //check if simhit is primary
0137   if (simTrackIt != selectedSimTrackMap.end())
0138     isPrimary = phase2tkutil::isPrimary(simTrackIt->second, simhitClosest);
0139 
0140   Local3DPoint simlp(simhitClosest->localPosition());
0141   const LocalError& lperr = rechit->localPositionError();
0142   double dx = phase2tkutil::cmtomicron * (lp.x() - simlp.x());
0143   double dy = phase2tkutil::cmtomicron * (lp.y() - simlp.y());
0144   double pullx = 999.;
0145   double pully = 999.;
0146   if (lperr.xx())
0147     pullx = (lp.x() - simlp.x()) / std::sqrt(lperr.xx());
0148   if (lperr.yy())
0149     pully = (lp.y() - simlp.y()) / std::sqrt(lperr.yy());
0150   float eta = geomDetunit->surface().toGlobal(lp).eta();
0151   float phi = geomDetunit->surface().toGlobal(lp).phi();
0152   layerMEs_[key].deltaX->Fill(dx);
0153   layerMEs_[key].deltaY->Fill(dy);
0154   layerMEs_[key].pullX->Fill(pullx);
0155   layerMEs_[key].pullY->Fill(pully);
0156 
0157   layerMEs_[key].deltaX_eta->Fill(std::abs(eta), dx);
0158   layerMEs_[key].deltaY_eta->Fill(std::abs(eta), dy);
0159   layerMEs_[key].deltaX_phi->Fill(phi, dx);
0160   layerMEs_[key].deltaY_phi->Fill(phi, dy);
0161 
0162   layerMEs_[key].deltaX_clsizex->Fill(rechit->cluster()->sizeX(), dx);
0163   layerMEs_[key].deltaX_clsizey->Fill(rechit->cluster()->sizeY(), dx);
0164   layerMEs_[key].deltaY_clsizex->Fill(rechit->cluster()->sizeX(), dy);
0165   layerMEs_[key].deltaY_clsizey->Fill(rechit->cluster()->sizeY(), dy);
0166   layerMEs_[key].deltaYvsdeltaX->Fill(dx, dy);
0167   layerMEs_[key].pullX_eta->Fill(eta, pullx);
0168   layerMEs_[key].pullY_eta->Fill(eta, pully);
0169   if (isPrimary) {
0170     layerMEs_[key].deltaX_primary->Fill(dx);
0171     layerMEs_[key].deltaY_primary->Fill(dy);
0172     layerMEs_[key].pullX_primary->Fill(pullx);
0173     layerMEs_[key].pullY_primary->Fill(pully);
0174   } else {
0175     nrechitLayerMap_primary[key]--;
0176   }
0177 }
0178 
0179 void Phase2ITValidateRecHitBase::fillPSetDescription(edm::ParameterSetDescription& desc) {
0180   edm::ParameterSetDescription psd0;
0181   psd0.add<std::string>("name", "Delta_X");
0182   psd0.add<std::string>("title", "Delta_X;RecHit resolution X coordinate [#mum]");
0183   psd0.add<bool>("switch", true);
0184   psd0.add<double>("xmin", -100.0);
0185   psd0.add<double>("xmax", 100.0);
0186   psd0.add<int>("NxBins", 100);
0187   desc.add<edm::ParameterSetDescription>("DeltaX", psd0);
0188 
0189   edm::ParameterSetDescription psd1;
0190   psd1.add<std::string>("name", "Delta_Y");
0191   psd1.add<std::string>("title", "Delta_Y;RecHit resolution Y coordinate [#mum];");
0192   psd1.add<bool>("switch", true);
0193   psd1.add<double>("xmin", -100.0);
0194   psd1.add<double>("xmax", 100.0);
0195   psd1.add<int>("NxBins", 100);
0196   desc.add<edm::ParameterSetDescription>("DeltaY", psd1);
0197 
0198   edm::ParameterSetDescription psd2;
0199   psd2.add<std::string>("name", "Pull_X");
0200   psd2.add<std::string>("title", "Pull_X;pull x;");
0201   psd2.add<double>("xmin", -4.0);
0202   psd2.add<bool>("switch", true);
0203   psd2.add<double>("xmax", 4.0);
0204   psd2.add<int>("NxBins", 100);
0205   desc.add<edm::ParameterSetDescription>("PullX", psd2);
0206 
0207   edm::ParameterSetDescription psd3;
0208   psd3.add<std::string>("name", "Pull_Y");
0209   psd3.add<std::string>("title", "Pull_Y;pull y;");
0210   psd3.add<double>("xmin", -4.0);
0211   psd3.add<bool>("switch", true);
0212   psd3.add<double>("xmax", 4.0);
0213   psd3.add<int>("NxBins", 100);
0214   desc.add<edm::ParameterSetDescription>("PullY", psd3);
0215 
0216   edm::ParameterSetDescription psd4;
0217   psd4.add<std::string>("name", "Delta_X_vs_Eta");
0218   psd4.add<std::string>("title", "Delta_X_vs_Eta;|#eta|;#Delta x [#mum]");
0219   psd4.add<int>("NyBins", 100);
0220   psd4.add<double>("ymin", -100.0);
0221   psd4.add<double>("ymax", 100.0);
0222   psd4.add<int>("NxBins", 41);
0223   psd4.add<bool>("switch", true);
0224   psd4.add<double>("xmax", 4.1);
0225   psd4.add<double>("xmin", 0.);
0226   desc.add<edm::ParameterSetDescription>("DeltaX_eta", psd4);
0227 
0228   edm::ParameterSetDescription psd4_y;
0229   psd4_y.add<std::string>("name", "Delta_X_vs_Phi");
0230   ;
0231   psd4_y.add<std::string>("title", "Delta_X_vs_Phi;#phi;#Delta x [#mum]");
0232   psd4_y.add<int>("NyBins", 100);
0233   psd4_y.add<double>("ymin", -100.0);
0234   psd4_y.add<double>("ymax", 100.0);
0235   psd4_y.add<int>("NxBins", 36);
0236   psd4_y.add<bool>("switch", true);
0237   psd4_y.add<double>("xmax", M_PI);
0238   psd4_y.add<double>("xmin", -M_PI);
0239   desc.add<edm::ParameterSetDescription>("DeltaX_phi", psd4_y);
0240 
0241   edm::ParameterSetDescription psd5;
0242   psd5.add<std::string>("name", "Delta_Y_vs_Eta");
0243   psd5.add<std::string>("title", "Delta_Y_vs_Eta;|#eta|;#Delta y [#mum]");
0244   psd5.add<int>("NyBins", 100);
0245   psd5.add<double>("ymin", -100.0);
0246   psd5.add<double>("ymax", 100.0);
0247   psd5.add<int>("NxBins", 41);
0248   psd5.add<bool>("switch", true);
0249   psd5.add<double>("xmax", 4.1);
0250   psd5.add<double>("xmin", 0.);
0251   desc.add<edm::ParameterSetDescription>("DeltaY_eta", psd5);
0252 
0253   edm::ParameterSetDescription psd5_y;
0254   psd5_y.add<std::string>("name", "Delta_Y_vs_Phi");
0255   psd5_y.add<std::string>("title", "Delta_Y_vs_Phi;#phi;#Delta y [#mum]");
0256   psd5_y.add<int>("NyBins", 100);
0257   psd5_y.add<double>("ymin", -100.0);
0258   psd5_y.add<double>("ymax", 100.0);
0259   psd5_y.add<int>("NxBins", 36);
0260   psd5_y.add<bool>("switch", true);
0261   psd5_y.add<double>("xmax", M_PI);
0262   psd5_y.add<double>("xmin", -M_PI);
0263   desc.add<edm::ParameterSetDescription>("DeltaY_phi", psd5_y);
0264 
0265   edm::ParameterSetDescription psd6;
0266   psd6.add<std::string>("name", "Delta_X_vs_ClusterSizeX");
0267   psd6.add<std::string>("title", ";Cluster size X;#Delta x [#mum]");
0268   psd6.add<double>("ymin", -100.0);
0269   psd6.add<double>("ymax", 100.0);
0270   psd6.add<int>("NxBins", 21);
0271   psd6.add<bool>("switch", true);
0272   psd6.add<double>("xmax", 20.5);
0273   psd6.add<double>("xmin", -0.5);
0274   desc.add<edm::ParameterSetDescription>("DeltaX_clsizex", psd6);
0275 
0276   edm::ParameterSetDescription psd7;
0277   psd7.add<std::string>("name", "Delta_X_vs_ClusterSizeY");
0278   psd7.add<std::string>("title", ";Cluster size Y;#Delta x [#mum]");
0279   psd7.add<double>("ymin", -100.0);
0280   psd7.add<double>("ymax", 100.0);
0281   psd7.add<int>("NxBins", 21);
0282   psd7.add<bool>("switch", true);
0283   psd7.add<double>("xmax", 20.5);
0284   psd7.add<double>("xmin", -0.5);
0285   desc.add<edm::ParameterSetDescription>("DeltaX_clsizey", psd7);
0286 
0287   edm::ParameterSetDescription psd8;
0288   psd8.add<std::string>("name", "Delta_Y_vs_ClusterSizeX");
0289   psd8.add<std::string>("title", ";Cluster size X;#Delta y [#mum]");
0290   psd8.add<double>("ymin", -100.0);
0291   psd8.add<double>("ymax", 100.0);
0292   psd8.add<int>("NxBins", 21);
0293   psd8.add<bool>("switch", true);
0294   psd8.add<double>("xmax", 20.5);
0295   psd8.add<double>("xmin", -0.5);
0296   desc.add<edm::ParameterSetDescription>("DeltaY_clsizex", psd8);
0297 
0298   edm::ParameterSetDescription psd9;
0299   psd9.add<std::string>("name", "Delta_Y_vs_ClusterSizeY");
0300   psd9.add<std::string>("title", ";Cluster size Y;#Delta y [#mum]");
0301   psd9.add<double>("ymin", -100.0);
0302   psd9.add<double>("ymax", 100.0);
0303   psd9.add<int>("NxBins", 21);
0304   psd9.add<bool>("switch", true);
0305   psd9.add<double>("xmax", 20.5);
0306   psd9.add<double>("xmin", -0.5);
0307   desc.add<edm::ParameterSetDescription>("DeltaY_clsizey", psd9);
0308 
0309   edm::ParameterSetDescription psd10;
0310   psd10.add<std::string>("name", "Delta_Y_vs_DeltaX");
0311   psd10.add<std::string>("title", ";#Delta x[#mum];#Delta y[#mum]");
0312   psd10.add<bool>("switch", true);
0313   psd10.add<double>("ymin", -100.0);
0314   psd10.add<double>("ymax", 100.0);
0315   psd10.add<int>("NyBins", 100);
0316   psd10.add<double>("xmax", 100.);
0317   psd10.add<double>("xmin", -100.);
0318   psd10.add<int>("NxBins", 100);
0319   desc.add<edm::ParameterSetDescription>("DeltaY_vs_DeltaX", psd10);
0320 
0321   edm::ParameterSetDescription psd11;
0322   psd11.add<std::string>("name", "Pull_X_vs_Eta");
0323   psd11.add<std::string>("title", "Pull_X_vs_Eta;#eta;pull x");
0324   psd11.add<double>("ymax", 4.0);
0325   psd11.add<int>("NxBins", 82);
0326   psd11.add<bool>("switch", true);
0327   psd11.add<double>("xmax", 4.1);
0328   psd11.add<double>("xmin", -4.1);
0329   psd11.add<double>("ymin", -4.0);
0330   desc.add<edm::ParameterSetDescription>("PullX_eta", psd11);
0331 
0332   edm::ParameterSetDescription psd12;
0333   psd12.add<std::string>("name", "Pull_Y_vs_Eta");
0334   psd12.add<std::string>("title", "Pull_Y_vs_Eta;#eta;pull y");
0335   psd12.add<double>("ymax", 4.0);
0336   psd12.add<int>("NxBins", 82);
0337   psd12.add<bool>("switch", true);
0338   psd12.add<double>("xmax", 4.1);
0339   psd12.add<double>("xmin", -4.1);
0340   psd12.add<double>("ymin", -4.0);
0341   desc.add<edm::ParameterSetDescription>("PullY_eta", psd12);
0342 
0343   //simhits primary
0344 
0345   edm::ParameterSetDescription psd13;
0346   psd13.add<std::string>("name", "Number_RecHits_matched_PrimarySimTrack");
0347   psd13.add<std::string>("title", "Number of RecHits matched to primary SimTrack;;");
0348   psd13.add<double>("xmin", 0.0);
0349   psd13.add<bool>("switch", true);
0350   psd13.add<double>("xmax", 0.0);
0351   psd13.add<int>("NxBins", 100);
0352   desc.add<edm::ParameterSetDescription>("nRecHits_primary", psd13);
0353 
0354   edm::ParameterSetDescription psd14;
0355   psd14.add<std::string>("name", "Delta_X_SimHitPrimary");
0356   psd14.add<std::string>("title", "Delta_X_SimHitPrimary;#delta x [#mum];");
0357   psd14.add<double>("xmin", -100.0);
0358   psd14.add<bool>("switch", true);
0359   psd14.add<double>("xmax", 100.0);
0360   psd14.add<int>("NxBins", 100);
0361   desc.add<edm::ParameterSetDescription>("DeltaX_primary", psd14);
0362 
0363   edm::ParameterSetDescription psd15;
0364   psd15.add<std::string>("name", "Delta_Y_SimHitPrimary");
0365   psd15.add<std::string>("title", "Delta_Y_SimHitPrimary;#Delta y [#mum];");
0366   psd15.add<double>("xmin", -100.0);
0367   psd15.add<bool>("switch", true);
0368   psd15.add<double>("xmax", 100.0);
0369   psd15.add<int>("NxBins", 100);
0370   desc.add<edm::ParameterSetDescription>("DeltaY_primary", psd15);
0371 
0372   edm::ParameterSetDescription psd16;
0373   psd16.add<std::string>("name", "Pull_X_SimHitPrimary");
0374   psd16.add<std::string>("title", "Pull_X_SimHitPrimary;pull x;");
0375   psd16.add<double>("ymax", 4.0);
0376   psd16.add<int>("NxBins", 82);
0377   psd16.add<bool>("switch", true);
0378   psd16.add<double>("xmax", 4.1);
0379   psd16.add<double>("xmin", -4.1);
0380   psd16.add<double>("ymin", -4.0);
0381   desc.add<edm::ParameterSetDescription>("PullX_primary", psd16);
0382 
0383   edm::ParameterSetDescription psd17;
0384   psd17.add<std::string>("name", "Pull_Y_SimHitPrimary");
0385   psd17.add<std::string>("title", "Pull_Y_SimHitPrimary;pull y;");
0386   psd17.add<double>("ymax", 4.0);
0387   psd17.add<int>("NxBins", 82);
0388   psd17.add<bool>("switch", true);
0389   psd17.add<double>("xmax", 4.1);
0390   psd17.add<double>("xmin", -4.1);
0391   psd17.add<double>("ymin", -4.0);
0392   desc.add<edm::ParameterSetDescription>("PullY_primary", psd17);
0393 }