Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:17

0001 // system includes
0002 #include <map>
0003 #include <vector>
0004 #include <algorithm>
0005 
0006 // user includes
0007 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0008 #include "CommonTools/Utils/interface/TFileDirectory.h"
0009 #include "DataFormats/Common/interface/DetSetVector.h"
0010 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0011 #include "DataFormats/Common/interface/Handle.h"
0012 #include "DataFormats/DetId/interface/DetId.h"
0013 #include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h"
0014 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0015 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0016 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
0017 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/Frameworkfwd.h"
0021 #include "FWCore/Framework/interface/MakerMacros.h"
0022 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0023 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0026 #include "FWCore/ServiceRegistry/interface/Service.h"
0027 #include "FWCore/ServiceRegistry/interface/Service.h"
0028 #include "FWCore/Utilities/interface/InputTag.h"
0029 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0030 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0031 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0032 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0033 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0034 #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h"
0035 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0036 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0037 
0038 // ROOT includes
0039 #include <TGraph.h>
0040 #include <TH1F.h>
0041 #include <THStack.h>
0042 #include <TTree.h>
0043 
0044 struct ClusterHistos {
0045   THStack* numberClustersMixed;
0046   TH1F* numberClusterPixel;
0047   TH1F* numberClusterStrip;
0048 
0049   THStack* clustersSizeMixed;
0050   TH1F* clusterSizePixel;
0051   TH1F* clusterSizeStrip;
0052 
0053   TGraph* globalPosXY[3];
0054   TGraph* localPosXY[3];
0055 
0056   TH1F* deltaXClusterSimHits[3];
0057   TH1F* deltaYClusterSimHits[3];
0058 
0059   TH1F* deltaXClusterSimHits_P[3];
0060   TH1F* deltaYClusterSimHits_P[3];
0061 
0062   TH1F* digiEfficiency[3];
0063 
0064   TH1F* primarySimHits;
0065   TH1F* otherSimHits;
0066 };
0067 
0068 class Phase2TrackerClusterizerValidationTGraph : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0069 public:
0070   typedef std::map<unsigned int, std::vector<PSimHit> > SimHitsMap;
0071   typedef std::map<unsigned int, SimTrack> SimTracksMap;
0072 
0073   explicit Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet&);
0074   ~Phase2TrackerClusterizerValidationTGraph();
0075   void beginJob();
0076   void analyze(const edm::Event&, const edm::EventSetup&);
0077   static void fillDescriptions(edm::ConfigurationDescriptions&);
0078 
0079 private:
0080   std::map<unsigned int, ClusterHistos>::iterator createLayerHistograms(unsigned int);
0081   unsigned int getLayerNumber(const DetId&, const TrackerTopology*);
0082   unsigned int getModuleNumber(const DetId&, const TrackerTopology*);
0083   unsigned int getSimTrackId(const edm::Handle<edm::DetSetVector<PixelDigiSimLink> >&, const DetId&, unsigned int);
0084 
0085   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> esTokenGeom_;
0086   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> esTokenTopo_;
0087   const edm::EDGetTokenT<edmNew::DetSetVector<Phase2TrackerCluster1D> > srcClu_;
0088   const edm::EDGetTokenT<edm::DetSetVector<PixelDigiSimLink> > siphase2OTSimLinksToken_;
0089   const edm::EDGetTokenT<edm::PSimHitContainer> simHitsToken_;
0090   const edm::EDGetTokenT<edm::SimTrackContainer> simTracksToken_;
0091   const edm::EDGetTokenT<edm::SimVertexContainer> simVerticesToken_;
0092   const TrackerGeometry* tkGeom_;
0093   const TrackerTopology* tkTopo_;
0094 
0095   TTree* tree_;
0096   TGraph* trackerLayout_[3];
0097   TGraph* trackerLayoutXY_[3];
0098   TGraph* trackerLayoutXYBar_;
0099   TGraph* trackerLayoutXYEC_;
0100 
0101   std::map<unsigned int, ClusterHistos> histograms_;
0102 };
0103 
0104 Phase2TrackerClusterizerValidationTGraph::Phase2TrackerClusterizerValidationTGraph(const edm::ParameterSet& conf)
0105     : esTokenGeom_(esConsumes()),
0106       esTokenTopo_(esConsumes()),
0107       srcClu_(consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(
0108           edm::InputTag(conf.getParameter<std::string>("src")))),
0109       siphase2OTSimLinksToken_(
0110           consumes<edm::DetSetVector<PixelDigiSimLink> >(conf.getParameter<edm::InputTag>("links"))),
0111       simHitsToken_(consumes<edm::PSimHitContainer>(edm::InputTag("g4SimHits", "TrackerHitsPixelBarrelLowTof"))),
0112       simTracksToken_(consumes<edm::SimTrackContainer>(edm::InputTag("g4SimHits"))),
0113       simVerticesToken_(consumes<edm::SimVertexContainer>(edm::InputTag("g4SimHits"))) {
0114   usesResource(TFileService::kSharedResource);
0115 }
0116 
0117 Phase2TrackerClusterizerValidationTGraph::~Phase2TrackerClusterizerValidationTGraph() = default;
0118 
0119 void Phase2TrackerClusterizerValidationTGraph::beginJob() {
0120   edm::Service<TFileService> fs;
0121   fs->file().cd("/");
0122   TFileDirectory td = fs->mkdir("Common");
0123   //Create common ntuple
0124   tree_ = td.make<TTree>("Phase2TrackerClusters", "Phase2TrackerClusters");
0125   // Create common histograms
0126   trackerLayout_[0] = td.make<TGraph>();
0127   trackerLayout_[0]->SetName("RVsZ_Mixed");
0128   trackerLayout_[1] = td.make<TGraph>();
0129   trackerLayout_[1]->SetName("RVsZ_Pixel");
0130   trackerLayout_[2] = td.make<TGraph>();
0131   trackerLayout_[2]->SetName("RVsZ_Strip");
0132   trackerLayoutXY_[0] = td.make<TGraph>();
0133   trackerLayoutXY_[0]->SetName("YVsX_Mixed");
0134   trackerLayoutXY_[1] = td.make<TGraph>();
0135   trackerLayoutXY_[1]->SetName("YVsX_Pixel");
0136   trackerLayoutXY_[2] = td.make<TGraph>();
0137   trackerLayoutXY_[2]->SetName("YVsX_Strip");
0138   trackerLayoutXYBar_ = td.make<TGraph>();
0139   trackerLayoutXYBar_->SetName("YVsXBar");
0140   trackerLayoutXYEC_ = td.make<TGraph>();
0141   trackerLayoutXYEC_->SetName("YVsXEC");
0142 }
0143 
0144 void Phase2TrackerClusterizerValidationTGraph::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
0145   // Get the needed objects
0146 
0147   // Get the clusters
0148   edm::Handle<Phase2TrackerCluster1DCollectionNew> clusters;
0149   event.getByToken(srcClu_, clusters);
0150 
0151   // Get the Phase2 DigiSimLink
0152   edm::Handle<edm::DetSetVector<PixelDigiSimLink> > siphase2SimLinks;
0153   event.getByToken(siphase2OTSimLinksToken_, siphase2SimLinks);
0154 
0155   // Get the SimHits
0156   edm::Handle<edm::PSimHitContainer> simHitsRaw;
0157   event.getByToken(simHitsToken_, simHitsRaw);
0158 
0159   // Get the SimTracks
0160   edm::Handle<edm::SimTrackContainer> simTracksRaw;
0161   event.getByToken(simTracksToken_, simTracksRaw);
0162 
0163   // Get the SimVertex
0164   edm::Handle<edm::SimVertexContainer> simVertices;
0165   event.getByToken(simVerticesToken_, simVertices);
0166 
0167   // Get the geometry
0168   tkGeom_ = &eventSetup.getData(esTokenGeom_);
0169   tkTopo_ = &eventSetup.getData(esTokenTopo_);
0170 
0171   //set up for tree
0172   int layer_number;
0173   int module_id;
0174   int module_number;
0175   int module_type;  //1: pixel, 2: strip
0176   float x_global, y_global, z_global;
0177   float x_local, y_local, z_local;
0178 
0179   tree_->Branch("layer_number", &layer_number, "layer_number/I");
0180   tree_->Branch("module_id", &module_id, "module_id/I");
0181   tree_->Branch("module_type", &module_type, "module_type/I");
0182   tree_->Branch("module_number", &module_number, "module_number/I");
0183   tree_->Branch("x_global", &x_global, "x_global/F");
0184   tree_->Branch("y_global", &y_global, "y_global/F");
0185   tree_->Branch("z_global", &z_global, "z_global/F");
0186   tree_->Branch("x_local", &x_local, "x_local/F");
0187   tree_->Branch("y_local", &y_local, "y_local/F");
0188   tree_->Branch("z_local", &z_local, "z_local/F");
0189 
0190   // Rearrange the simTracks for ease of use <simTrackID, simTrack>
0191   SimTracksMap simTracks;
0192   for (const auto& simTrackIt : *simTracksRaw)
0193     simTracks.emplace(std::pair<unsigned int, SimTrack>(simTrackIt.trackId(), simTrackIt));
0194 
0195   // Rearrange the simHits by detUnit
0196 
0197   // Rearrange the simHits for ease of use
0198   SimHitsMap simHitsDetUnit;
0199   SimHitsMap simHitsTrackId;
0200   for (const auto& simHitIt : *simHitsRaw) {
0201     SimHitsMap::iterator simHitsDetUnitIt(simHitsDetUnit.find(simHitIt.detUnitId()));
0202     if (simHitsDetUnitIt == simHitsDetUnit.end()) {
0203       std::pair<SimHitsMap::iterator, bool> newIt(simHitsDetUnit.insert(
0204           std::pair<unsigned int, std::vector<PSimHit> >(simHitIt.detUnitId(), std::vector<PSimHit>())));
0205       simHitsDetUnitIt = newIt.first;
0206     }
0207     simHitsDetUnitIt->second.push_back(simHitIt);
0208     SimHitsMap::iterator simHitsTrackIdIt(simHitsTrackId.find(simHitIt.trackId()));
0209     if (simHitsTrackIdIt == simHitsTrackId.end()) {
0210       std::pair<SimHitsMap::iterator, bool> newIt(simHitsTrackId.insert(
0211           std::pair<unsigned int, std::vector<PSimHit> >(simHitIt.trackId(), std::vector<PSimHit>())));
0212       simHitsTrackIdIt = newIt.first;
0213     }
0214     simHitsTrackIdIt->second.push_back(simHitIt);
0215   }
0216 
0217   // ValidationTGraph
0218   unsigned int nClustersTot(0), nClustersPixelTot(0), nClustersStripTot(0);
0219 
0220   // Loop over modules
0221   for (const auto& DSViter : *clusters) {
0222     // Get the detector unit's id
0223     unsigned int rawid(DSViter.detId());
0224     module_id = rawid;
0225     DetId detId(rawid);
0226 
0227     layer_number = getLayerNumber(detId, tkTopo_);
0228     module_number = getModuleNumber(detId, tkTopo_);
0229     unsigned int layer(getLayerNumber(detId, tkTopo_));
0230 
0231     // Get the geometry of the tracker
0232     const GeomDetUnit* geomDetUnit(tkGeom_->idToDetUnit(detId));
0233     const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(geomDetUnit);
0234     const PixelTopology& topol = theGeomDet->specificTopology();
0235 
0236     if (!geomDetUnit)
0237       break;
0238 
0239     // Create histograms for the layer if they do not yet exist
0240     std::map<unsigned int, ClusterHistos>::iterator histogramLayer(histograms_.find(layer));
0241     if (histogramLayer == histograms_.end())
0242       histogramLayer = createLayerHistograms(layer);
0243 
0244     // Number of clusters
0245     unsigned int nClustersPixel(0), nClustersStrip(0);
0246 
0247     // Loop over the clusters in the detector unit
0248     for (const auto& clustIt : DSViter) {
0249       // Cluster related variables
0250       MeasurementPoint mpClu(clustIt.center(), clustIt.column() + 0.5);
0251       Local3DPoint localPosClu = geomDetUnit->topology().localPosition(mpClu);
0252       x_local = localPosClu.x();
0253       y_local = localPosClu.y();
0254       z_local = localPosClu.z();
0255 
0256       Global3DPoint globalPosClu = geomDetUnit->surface().toGlobal(localPosClu);
0257       x_global = globalPosClu.x();
0258       y_global = globalPosClu.y();
0259       z_global = globalPosClu.z();
0260 
0261       // Fill the position histograms
0262       trackerLayout_[0]->SetPoint(nClustersTot, globalPosClu.z(), globalPosClu.perp());
0263       trackerLayoutXY_[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y());
0264 
0265       if (layer < 100)
0266         trackerLayoutXYBar_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y());
0267       else
0268         trackerLayoutXYEC_->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y());
0269 
0270       histogramLayer->second.localPosXY[0]->SetPoint(nClustersTot, localPosClu.x(), localPosClu.y());
0271       histogramLayer->second.globalPosXY[0]->SetPoint(nClustersTot, globalPosClu.x(), globalPosClu.y());
0272 
0273       // Pixel module
0274       if (topol.ncolumns() == 32) {
0275         module_type = 1;
0276         trackerLayout_[1]->SetPoint(nClustersPixelTot, globalPosClu.z(), globalPosClu.perp());
0277         trackerLayoutXY_[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y());
0278 
0279         histogramLayer->second.localPosXY[1]->SetPoint(nClustersPixelTot, localPosClu.x(), localPosClu.y());
0280         histogramLayer->second.globalPosXY[1]->SetPoint(nClustersPixelTot, globalPosClu.x(), globalPosClu.y());
0281         histogramLayer->second.clusterSizePixel->Fill(clustIt.size());
0282         ++nClustersPixel;
0283         ++nClustersPixelTot;
0284       }
0285       // Strip module
0286       else if (topol.ncolumns() == 2) {
0287         module_type = 2;
0288         trackerLayout_[2]->SetPoint(nClustersStripTot, globalPosClu.z(), globalPosClu.perp());
0289         trackerLayoutXY_[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y());
0290 
0291         histogramLayer->second.localPosXY[2]->SetPoint(nClustersStripTot, localPosClu.x(), localPosClu.y());
0292         histogramLayer->second.globalPosXY[2]->SetPoint(nClustersStripTot, globalPosClu.x(), globalPosClu.y());
0293         histogramLayer->second.clusterSizeStrip->Fill(clustIt.size());
0294         ++nClustersStrip;
0295         ++nClustersStripTot;
0296       }
0297 
0298       // * Digis related variables
0299 
0300       std::vector<unsigned int> clusterSimTrackIds;
0301 
0302       // Get all the simTracks that form the cluster
0303       for (unsigned int i(0); i < clustIt.size(); ++i) {
0304         unsigned int channel(PixelDigi::pixelToChannel(
0305             clustIt.firstRow() + i,
0306             clustIt
0307                 .column()));  // Here we have to use the old pixelToChannel function (not Phase2TrackerDigi but PixelDigi), change this when using new Digis
0308         unsigned int simTrackId(getSimTrackId(siphase2SimLinks, detId, channel));
0309         clusterSimTrackIds.push_back(simTrackId);
0310       }
0311     }
0312 
0313     if (nClustersPixel)
0314       histogramLayer->second.numberClusterPixel->Fill(nClustersPixel);
0315     if (nClustersStrip)
0316       histogramLayer->second.numberClusterStrip->Fill(nClustersStrip);
0317     nClustersTot++;
0318     tree_->Fill();
0319   }
0320 }
0321 
0322 // Create the histograms
0323 std::map<unsigned int, ClusterHistos>::iterator Phase2TrackerClusterizerValidationTGraph::createLayerHistograms(
0324     unsigned int ival) {
0325   std::ostringstream fname1, fname2;
0326 
0327   edm::Service<TFileService> fs;
0328   fs->file().cd("/");
0329 
0330   std::string tag;
0331   unsigned int id;
0332   if (ival < 100) {
0333     id = ival;
0334     fname1 << "Barrel";
0335     fname2 << "Layer_" << id;
0336     tag = "_layer_";
0337   } else {
0338     int side = ival / 100;
0339     id = ival - side * 100;
0340     fname1 << "EndCap_Side_" << side;
0341     fname2 << "Disc_" << id;
0342     tag = "_disc_";
0343   }
0344 
0345   TFileDirectory td1 = fs->mkdir(fname1.str().c_str());
0346   TFileDirectory td = td1.mkdir(fname2.str().c_str());
0347 
0348   ClusterHistos local_histos;
0349 
0350   std::ostringstream histoName;
0351 
0352   /*
0353      * Number of clusters
0354      */
0355 
0356   histoName.str("");
0357   histoName << "Number_Clusters_Pixel" << tag.c_str() << id;
0358   local_histos.numberClusterPixel = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.);
0359   local_histos.numberClusterPixel->SetFillColor(kAzure + 7);
0360 
0361   histoName.str("");
0362   histoName << "Number_Clusters_Strip" << tag.c_str() << id;
0363   local_histos.numberClusterStrip = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 20, 0., 20.);
0364   local_histos.numberClusterStrip->SetFillColor(kOrange - 3);
0365 
0366   histoName.str("");
0367   histoName << "Number_Clusters_Mixed" << tag.c_str() << id;
0368   local_histos.numberClustersMixed = td.make<THStack>(histoName.str().c_str(), histoName.str().c_str());
0369   local_histos.numberClustersMixed->Add(local_histos.numberClusterPixel);
0370   local_histos.numberClustersMixed->Add(local_histos.numberClusterStrip);
0371 
0372   /*
0373      * Cluster size
0374      */
0375 
0376   histoName.str("");
0377   histoName << "Cluster_Size_Pixel" << tag.c_str() << id;
0378   local_histos.clusterSizePixel = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.);
0379   local_histos.clusterSizePixel->SetFillColor(kAzure + 7);
0380 
0381   histoName.str("");
0382   histoName << "Cluster_Size_Strip" << tag.c_str() << id;
0383   local_histos.clusterSizeStrip = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.);
0384   local_histos.clusterSizeStrip->SetFillColor(kOrange - 3);
0385 
0386   histoName.str("");
0387   histoName << "Cluster_Size_Mixed" << tag.c_str() << id;
0388   local_histos.clustersSizeMixed = td.make<THStack>(histoName.str().c_str(), histoName.str().c_str());
0389   local_histos.clustersSizeMixed->Add(local_histos.clusterSizePixel);
0390   local_histos.clustersSizeMixed->Add(local_histos.clusterSizeStrip);
0391 
0392   /*
0393      * Local and Global positions
0394      */
0395 
0396   histoName.str("");
0397   histoName << "Local_Position_XY_Mixed" << tag.c_str() << id;
0398   local_histos.localPosXY[0] = td.make<TGraph>();
0399   local_histos.localPosXY[0]->SetName(histoName.str().c_str());
0400 
0401   histoName.str("");
0402   histoName << "Local_Position_XY_Pixel" << tag.c_str() << id;
0403   local_histos.localPosXY[1] = td.make<TGraph>();
0404   local_histos.localPosXY[1]->SetName(histoName.str().c_str());
0405 
0406   histoName.str("");
0407   histoName << "Local_Position_XY_Strip" << tag.c_str() << id;
0408   local_histos.localPosXY[2] = td.make<TGraph>();
0409   local_histos.localPosXY[2]->SetName(histoName.str().c_str());
0410 
0411   histoName.str("");
0412   histoName << "Global_Position_XY_Mixed" << tag.c_str() << id;
0413   local_histos.globalPosXY[0] = td.make<TGraph>();
0414   local_histos.globalPosXY[0]->SetName(histoName.str().c_str());
0415 
0416   histoName.str("");
0417   histoName << "Global_Position_XY_Pixel" << tag.c_str() << id;
0418   local_histos.globalPosXY[1] = td.make<TGraph>();
0419   local_histos.globalPosXY[1]->SetName(histoName.str().c_str());
0420 
0421   histoName.str("");
0422   histoName << "Global_Position_XY_Strip" << tag.c_str() << id;
0423   local_histos.globalPosXY[2] = td.make<TGraph>();
0424   local_histos.globalPosXY[2]->SetName(histoName.str().c_str());
0425 
0426   /*
0427      * Delta positions with SimHits
0428      */
0429 
0430   histoName.str("");
0431   histoName << "Delta_X_Cluster_SimHits_Mixed" << tag.c_str() << id;
0432   local_histos.deltaXClusterSimHits[0] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0433 
0434   histoName.str("");
0435   histoName << "Delta_X_Cluster_SimHits_Pixel" << tag.c_str() << id;
0436   local_histos.deltaXClusterSimHits[1] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0437 
0438   histoName.str("");
0439   histoName << "Delta_X_Cluster_SimHits_Strip" << tag.c_str() << id;
0440   local_histos.deltaXClusterSimHits[2] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0441 
0442   histoName.str("");
0443   histoName << "Delta_Y_Cluster_SimHits_Mixed" << tag.c_str() << id;
0444   local_histos.deltaYClusterSimHits[0] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0445 
0446   histoName.str("");
0447   histoName << "Delta_Y_Cluster_SimHits_Pixel" << tag.c_str() << id;
0448   local_histos.deltaYClusterSimHits[1] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0449 
0450   histoName.str("");
0451   histoName << "Delta_Y_Cluster_SimHits_Strip" << tag.c_str() << id;
0452   local_histos.deltaYClusterSimHits[2] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0453 
0454   /*
0455      * Delta position with simHits for primary tracks only
0456      */
0457 
0458   histoName.str("");
0459   histoName << "Delta_X_Cluster_SimHits_Mixed_P" << tag.c_str() << id;
0460   local_histos.deltaXClusterSimHits_P[0] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0461 
0462   histoName.str("");
0463   histoName << "Delta_X_Cluster_SimHits_Pixel_P" << tag.c_str() << id;
0464   local_histos.deltaXClusterSimHits_P[1] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0465 
0466   histoName.str("");
0467   histoName << "Delta_X_Cluster_SimHits_Strip_P" << tag.c_str() << id;
0468   local_histos.deltaXClusterSimHits_P[2] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0469 
0470   histoName.str("");
0471   histoName << "Delta_Y_Cluster_SimHits_Mixed_P" << tag.c_str() << id;
0472   local_histos.deltaYClusterSimHits_P[0] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0473 
0474   histoName.str("");
0475   histoName << "Delta_Y_Cluster_SimHits_Pixel_P" << tag.c_str() << id;
0476   local_histos.deltaYClusterSimHits_P[1] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0477 
0478   histoName.str("");
0479   histoName << "Delta_Y_Cluster_SimHits_Strip_P" << tag.c_str() << id;
0480   local_histos.deltaYClusterSimHits_P[2] = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 100, 0., 0.);
0481 
0482   /*
0483      * Information on the Digis per cluster
0484      */
0485 
0486   histoName.str("");
0487   histoName << "Primary_Digis" << tag.c_str() << id;
0488   local_histos.primarySimHits = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.);
0489 
0490   histoName.str("");
0491   histoName << "Other_Digis" << tag.c_str() << id;
0492   local_histos.otherSimHits = td.make<TH1F>(histoName.str().c_str(), histoName.str().c_str(), 10, 0., 10.);
0493 
0494   /*
0495      * End
0496      */
0497 
0498   std::pair<std::map<unsigned int, ClusterHistos>::iterator, bool> insertedIt(
0499       histograms_.insert(std::make_pair(ival, local_histos)));
0500   fs->file().cd("/");
0501 
0502   return insertedIt.first;
0503 }
0504 
0505 unsigned int Phase2TrackerClusterizerValidationTGraph::getLayerNumber(const DetId& detid, const TrackerTopology* topo) {
0506   if (detid.det() == DetId::Tracker) {
0507     if (detid.subdetId() == PixelSubdetector::PixelBarrel)
0508       return (topo->pxbLayer(detid));
0509     else if (detid.subdetId() == PixelSubdetector::PixelEndcap)
0510       return (100 * topo->pxfSide(detid) + topo->pxfDisk(detid));
0511   }
0512   return 999;
0513 }
0514 
0515 unsigned int Phase2TrackerClusterizerValidationTGraph::getModuleNumber(const DetId& detid,
0516                                                                        const TrackerTopology* topo) {
0517   if (detid.det() == DetId::Tracker) {
0518     if (detid.subdetId() == PixelSubdetector::PixelBarrel) {
0519       return (topo->pxbModule(detid));
0520     } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) {
0521       return (topo->pxfModule(detid));
0522     } else
0523       return 999;
0524   }
0525   return 999;
0526 }
0527 
0528 unsigned int Phase2TrackerClusterizerValidationTGraph::getSimTrackId(
0529     const edm::Handle<edm::DetSetVector<PixelDigiSimLink> >& siphase2SimLinks,
0530     const DetId& detId,
0531     unsigned int channel) {
0532   edm::DetSetVector<PixelDigiSimLink>::const_iterator DSViter(siphase2SimLinks->find(detId));
0533   if (DSViter == siphase2SimLinks->end())
0534     return 0;
0535   for (const auto& it : DSViter->data) {
0536     if (channel == it.channel())
0537       return it.SimTrackId();
0538   }
0539   return 0;
0540 }
0541 
0542 void Phase2TrackerClusterizerValidationTGraph::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0543   edm::ParameterSetDescription desc;
0544   desc.add<std::string>("src", "siPhase2Clusters");
0545   desc.add<edm::InputTag>("links", edm::InputTag("simSiPixelDigis", "Tracker"));
0546   descriptions.add("phase2TrackerClusterizerValidationTGraph", desc);
0547 }
0548 
0549 DEFINE_FWK_MODULE(Phase2TrackerClusterizerValidationTGraph);