File indexing completed on 2024-09-11 04:32:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "DQM/SiPixelMonitorCluster/interface/SiPixelClusterSource.h"
0021
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 #include "FWCore/ServiceRegistry/interface/Service.h"
0024 #include "FWCore/Framework/interface/MakerMacros.h"
0025
0026 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
0027 #include "DQMServices/Core/interface/DQMStore.h"
0028
0029 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0030 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0031
0032 #include "DataFormats/DetId/interface/DetId.h"
0033 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0034 #include "DataFormats/SiPixelDetId/interface/PixelBarrelNameUpgrade.h"
0035 #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h"
0036 #include "DataFormats/SiPixelDetId/interface/PixelEndcapNameUpgrade.h"
0037 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0038
0039 #include <cstdlib>
0040 #include <string>
0041
0042 using namespace std;
0043 using namespace edm;
0044
0045 SiPixelClusterSource::SiPixelClusterSource(const edm::ParameterSet &iConfig)
0046 : conf_(iConfig),
0047 src_(conf_.getParameter<edm::InputTag>("src")),
0048 digisrc_(conf_.getParameter<edm::InputTag>("digisrc")),
0049 saveFile(conf_.getUntrackedParameter<bool>("saveFile", false)),
0050 isPIB(conf_.getUntrackedParameter<bool>("isPIB", false)),
0051 slowDown(conf_.getUntrackedParameter<bool>("slowDown", false)),
0052 modOn(conf_.getUntrackedParameter<bool>("modOn", true)),
0053 twoDimOn(conf_.getUntrackedParameter<bool>("twoDimOn", true)),
0054 reducedSet(conf_.getUntrackedParameter<bool>("reducedSet", false)),
0055 ladOn(conf_.getUntrackedParameter<bool>("ladOn", false)),
0056 layOn(conf_.getUntrackedParameter<bool>("layOn", false)),
0057 phiOn(conf_.getUntrackedParameter<bool>("phiOn", false)),
0058 ringOn(conf_.getUntrackedParameter<bool>("ringOn", false)),
0059 bladeOn(conf_.getUntrackedParameter<bool>("bladeOn", false)),
0060 diskOn(conf_.getUntrackedParameter<bool>("diskOn", false)),
0061 smileyOn(conf_.getUntrackedParameter<bool>("smileyOn", false)),
0062 bigEventSize(conf_.getUntrackedParameter<int>("bigEventSize", 100)),
0063 isUpgrade(conf_.getUntrackedParameter<bool>("isUpgrade", false)),
0064 noOfLayers(0),
0065 noOfDisks(0) {
0066 LogInfo("PixelDQM") << "SiPixelClusterSource::SiPixelClusterSource: Got DQM BackEnd interface" << endl;
0067
0068
0069 srcToken_ = consumes<edmNew::DetSetVector<SiPixelCluster>>(conf_.getParameter<edm::InputTag>("src"));
0070 digisrcToken_ = consumes<edm::DetSetVector<PixelDigi>>(conf_.getParameter<edm::InputTag>("digisrc"));
0071
0072 trackerTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>();
0073 trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
0074 trackerTopoTokenBeginRun_ = esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>();
0075 trackerGeomTokenBeginRun_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>();
0076
0077 firstRun = true;
0078 topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
0079 }
0080
0081 SiPixelClusterSource::~SiPixelClusterSource() {
0082
0083
0084 LogInfo("PixelDQM") << "SiPixelClusterSource::~SiPixelClusterSource: Destructor" << endl;
0085
0086 std::map<uint32_t, SiPixelClusterModule *>::iterator struct_iter;
0087 for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
0088 delete struct_iter->second;
0089 struct_iter->second = nullptr;
0090 }
0091 }
0092
0093 void SiPixelClusterSource::dqmBeginRun(const edm::Run &r, const edm::EventSetup &iSetup) {
0094 LogInfo("PixelDQM") << " SiPixelClusterSource::beginJob - Initialisation ... " << std::endl;
0095 LogInfo("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/" << layOn << "/" << phiOn << std::endl;
0096 LogInfo("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/" << ringOn << std::endl;
0097 LogInfo("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
0098 LogInfo("PixelDQM") << "Smiley (Cluster sizeY vs. Cluster eta) is " << smileyOn << "\n";
0099
0100 if (firstRun) {
0101 eventNo = 0;
0102 lumSec = 0;
0103 nLumiSecs = 0;
0104 nBigEvents = 0;
0105
0106 buildStructure(iSetup);
0107
0108 firstRun = false;
0109 }
0110 }
0111
0112 void SiPixelClusterSource::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, const edm::EventSetup &iSetup) {
0113 bookMEs(iBooker, iSetup);
0114
0115 iBooker.setCurrentFolder(topFolderName_ + "/Clusters/OffTrack");
0116
0117 std::stringstream ss1, ss2;
0118 for (int i = 1; i <= noOfLayers; i++) {
0119 ss1.str(std::string());
0120 ss1 << "position_siPixelClusters_Layer_" << i;
0121 ss2.str(std::string());
0122 ss2 << "Clusters Layer" << i << ";Global Z (cm);Global #phi";
0123 meClPosLayer.push_back(iBooker.book2D(ss1.str(), ss2.str(), 200, -30., 30., 128, -3.2, 3.2));
0124 }
0125 for (int i = 1; i <= noOfDisks; i++) {
0126 ss1.str(std::string());
0127 ss1 << "position_siPixelClusters_pz_Disk_" << i;
0128 ss2.str(std::string());
0129 ss2 << "Clusters +Z Disk" << i << ";Global X (cm);Global Y (cm)";
0130 meClPosDiskpz.push_back(iBooker.book2D(ss1.str(), ss2.str(), 80, -20., 20., 80, -20., 20.));
0131 ss1.str(std::string());
0132 ss1 << "position_siPixelClusters_mz_Disk_" << i;
0133 ss2.str(std::string());
0134 ss2 << "Clusters -Z Disk" << i << ";Global X (cm);Global Y (cm)";
0135 meClPosDiskmz.push_back(iBooker.book2D(ss1.str(), ss2.str(), 80, -20., 20., 80, -20., 20.));
0136 }
0137
0138
0139
0140 iBooker.setCurrentFolder(topFolderName_ + "/Barrel");
0141 ss1.str(std::string());
0142 ss1 << "totalNumberOfClustersProfile_siPixelClusters_Barrel";
0143 ss2.str(std::string());
0144 ss2 << "Total number of barrel clusters profile;Lumisection;";
0145 meClusBarrelProf = iBooker.bookProfile(ss1.str(), ss2.str(), 2400, 0., 150, 0, 0, "");
0146 meClusBarrelProf->getTH1()->SetCanExtend(TH1::kAllAxes);
0147
0148 iBooker.setCurrentFolder(topFolderName_ + "/Endcap");
0149
0150 ss1.str(std::string());
0151 ss1 << "totalNumberOfClustersProfile_siPixelClusters_FPIX+";
0152 ss2.str(std::string());
0153 ss2 << "Total number of FPIX+ clusters profile;Lumisection;";
0154 meClusFpixPProf = iBooker.bookProfile(ss1.str(), ss2.str(), 2400, 0., 150, 0, 0, "");
0155 meClusFpixPProf->getTH1()->SetCanExtend(TH1::kAllAxes);
0156
0157 ss1.str(std::string());
0158 ss1 << "totalNumberOfClustersProfile_siPixelClusters_FPIX-";
0159 ss2.str(std::string());
0160 ss2 << "Total number of FPIX- clusters profile;Lumisection;";
0161 meClusFpixMProf = iBooker.bookProfile(ss1.str(), ss2.str(), 2400, 0., 150, 0, 0, "");
0162 meClusFpixMProf->getTH1()->SetCanExtend(TH1::kAllAxes);
0163
0164 iBooker.setCurrentFolder(topFolderName_ + "/Barrel");
0165 for (int i = 1; i <= noOfLayers; i++) {
0166 int ybins = -1;
0167 float ymin = 0.;
0168 float ymax = 0.;
0169 if (i == 1) {
0170 ybins = 42;
0171 ymin = -10.5;
0172 ymax = 10.5;
0173 }
0174 if (i == 2) {
0175 ybins = 66;
0176 ymin = -16.5;
0177 ymax = 16.5;
0178 }
0179 if (i == 3) {
0180 ybins = 90;
0181 ymin = -22.5;
0182 ymax = 22.5;
0183 }
0184 if (i == 4) {
0185 ybins = 130;
0186 ymin = -32.5;
0187 ymax = 32.5;
0188 }
0189 ss1.str(std::string());
0190 ss1 << "pix_bar Occ_roc_online_" + digisrc_.label() + "_layer_" << i;
0191 ss2.str(std::string());
0192 ss2 << "Pixel Barrel Occupancy, ROC level (Online): Layer " << i;
0193 meZeroRocBPIX.push_back(iBooker.book2D(ss1.str(), ss2.str(), 72, -4.5, 4.5, ybins, ymin, ymax));
0194 meZeroRocBPIX.at(i - 1)->setAxisTitle("ROC / Module", 1);
0195 meZeroRocBPIX.at(i - 1)->setAxisTitle("ROC / Ladder", 2);
0196 }
0197
0198 iBooker.setCurrentFolder(topFolderName_ + "/Endcap");
0199 meZeroRocFPIX = iBooker.book2D(
0200 "ROC_endcap_occupancy", "Pixel Endcap Occupancy, ROC level (Online)", 72, -4.5, 4.5, 288, -12.5, 12.5);
0201 meZeroRocFPIX->setBinLabel(1, "Disk-2 Pnl2", 1);
0202 meZeroRocFPIX->setBinLabel(9, "Disk-2 Pnl1", 1);
0203 meZeroRocFPIX->setBinLabel(19, "Disk-1 Pnl2", 1);
0204 meZeroRocFPIX->setBinLabel(27, "Disk-1 Pnl1", 1);
0205 meZeroRocFPIX->setBinLabel(41, "Disk+1 Pnl1", 1);
0206 meZeroRocFPIX->setBinLabel(49, "Disk+1 Pnl2", 1);
0207 meZeroRocFPIX->setBinLabel(59, "Disk+2 Pnl1", 1);
0208 meZeroRocFPIX->setBinLabel(67, "Disk+2 Pnl2", 1);
0209 meZeroRocFPIX->setAxisTitle("Blades in Inner (>0) / Outer(<) Halves", 2);
0210 meZeroRocFPIX->setAxisTitle("ROC occupancy", 3);
0211 }
0212
0213
0214
0215
0216 void SiPixelClusterSource::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0217 eventNo++;
0218
0219 if (meClPosLayer.at(0) && meClPosLayer.at(0)->getEntries() > 150000) {
0220 for (int i = 0; i < noOfLayers; i++) {
0221 meClPosLayer.at(i)->Reset();
0222 }
0223 for (int i = 0; i < noOfDisks; i++) {
0224 meClPosDiskpz.at(i)->Reset();
0225 meClPosDiskmz.at(i)->Reset();
0226 }
0227 }
0228
0229
0230 edm::Handle<edmNew::DetSetVector<SiPixelCluster>> input;
0231 iEvent.getByToken(srcToken_, input);
0232 auto const &clustColl = *(input.product());
0233
0234 edm::ESHandle<TrackerGeometry> pDD = iSetup.getHandle(trackerGeomToken_);
0235 const TrackerGeometry *tracker = &(*pDD);
0236
0237 edm::Handle<edm::DetSetVector<PixelDigi>> digiinput;
0238 iEvent.getByToken(digisrcToken_, digiinput);
0239 const edm::DetSetVector<PixelDigi> diginp = *(digiinput.product());
0240
0241 edm::ESHandle<TrackerTopology> tTopoHandle = iSetup.getHandle(trackerTopoToken_);
0242 const TrackerTopology *pTT = tTopoHandle.product();
0243
0244 int lumiSection = (int)iEvent.luminosityBlock();
0245 int nEventFpixClusters = 0;
0246
0247 int nEventsBarrel = 0;
0248 int nEventsFPIXm = 0;
0249 int nEventsFPIXp = 0;
0250
0251 std::map<uint32_t, SiPixelClusterModule *>::iterator struct_iter;
0252 for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
0253 int numberOfFpixClusters = (*struct_iter)
0254 .second->fill(*input,
0255 pTT,
0256 tracker,
0257 &nEventsBarrel,
0258 &nEventsFPIXp,
0259 &nEventsFPIXm,
0260 meClPosLayer,
0261 meClPosDiskpz,
0262 meClPosDiskmz,
0263 modOn,
0264 ladOn,
0265 layOn,
0266 phiOn,
0267 bladeOn,
0268 diskOn,
0269 ringOn,
0270 twoDimOn,
0271 reducedSet,
0272 smileyOn,
0273 isUpgrade);
0274 nEventFpixClusters = nEventFpixClusters + numberOfFpixClusters;
0275 }
0276
0277 if (nEventFpixClusters > bigEventSize) {
0278 if (bigFpixClusterEventRate) {
0279 bigFpixClusterEventRate->Fill(lumiSection, 1. / 23.);
0280 }
0281 }
0282
0283 float trendVar = iEvent.orbitNumber() / 262144.0;
0284
0285 meClusBarrelProf->Fill(trendVar, nEventsBarrel);
0286 meClusFpixPProf->Fill(trendVar, nEventsFPIXp);
0287 meClusFpixMProf->Fill(trendVar, nEventsFPIXm);
0288
0289
0290
0291
0292 for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
0293 DetId detId = (*it)->geographicalId();
0294
0295
0296 if (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
0297 getrococcupancy(detId, diginp, pTT, meZeroRocBPIX);
0298 }
0299
0300
0301 if (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
0302 getrococcupancye(detId, clustColl, pTT, pDD, meZeroRocFPIX);
0303 }
0304 }
0305
0306
0307 if (slowDown)
0308 usleep(10000);
0309 }
0310
0311
0312
0313
0314 void SiPixelClusterSource::buildStructure(const edm::EventSetup &iSetup) {
0315 LogInfo("PixelDQM") << " SiPixelClusterSource::buildStructure";
0316 edm::ESHandle<TrackerGeometry> pDD = iSetup.getHandle(trackerGeomTokenBeginRun_);
0317
0318 edm::ESHandle<TrackerTopology> tTopoHandle = iSetup.getHandle(trackerTopoTokenBeginRun_);
0319 const TrackerTopology *pTT = tTopoHandle.product();
0320
0321 LogVerbatim("PixelDQM") << " *** Geometry node for TrackerGeom is " << &(*pDD) << std::endl;
0322 LogVerbatim("PixelDQM") << " *** I have " << pDD->dets().size() << " detectors" << std::endl;
0323 LogVerbatim("PixelDQM") << " *** I have " << pDD->detTypes().size() << " types" << std::endl;
0324
0325 for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
0326 if (dynamic_cast<PixelGeomDetUnit const *>((*it)) != nullptr) {
0327 DetId detId = (*it)->geographicalId();
0328 const GeomDetUnit *geoUnit = pDD->idToDetUnit(detId);
0329 const PixelGeomDetUnit *pixDet = dynamic_cast<const PixelGeomDetUnit *>(geoUnit);
0330 int nrows = (pixDet->specificTopology()).nrows();
0331 int ncols = (pixDet->specificTopology()).ncolumns();
0332
0333 if ((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
0334 (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))) {
0335 uint32_t id = detId();
0336 if (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
0337 if (isPIB)
0338 continue;
0339 LogDebug("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
0340 int layer = PixelBarrelName(DetId(id), pTT, isUpgrade).layerName();
0341 if (layer > noOfLayers)
0342 noOfLayers = layer;
0343 SiPixelClusterModule *theModule = new SiPixelClusterModule(id, ncols, nrows);
0344 thePixelStructure.insert(pair<uint32_t, SiPixelClusterModule *>(id, theModule));
0345 } else if (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
0346 LogDebug("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
0347 PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(id), pTT, isUpgrade).halfCylinder();
0348 int disk = PixelEndcapName(DetId(id), pTT, isUpgrade).diskName();
0349 if (disk > noOfDisks)
0350 noOfDisks = disk;
0351 int blade = PixelEndcapName(DetId(id), pTT, isUpgrade).bladeName();
0352 int panel = PixelEndcapName(DetId(id), pTT, isUpgrade).pannelName();
0353 int module = PixelEndcapName(DetId(id), pTT, isUpgrade).plaquetteName();
0354 char sside[80];
0355 sprintf(sside, "HalfCylinder_%i", side);
0356 char sdisk[80];
0357 sprintf(sdisk, "Disk_%i", disk);
0358 char sblade[80];
0359 sprintf(sblade, "Blade_%02i", blade);
0360 char spanel[80];
0361 sprintf(spanel, "Panel_%i", panel);
0362 char smodule[80];
0363 sprintf(smodule, "Module_%i", module);
0364 std::string side_str = sside;
0365 std::string disk_str = sdisk;
0366 bool mask = side_str.find("HalfCylinder_1") != string::npos ||
0367 side_str.find("HalfCylinder_2") != string::npos ||
0368 side_str.find("HalfCylinder_4") != string::npos || disk_str.find("Disk_2") != string::npos;
0369
0370 mask = false;
0371 if (isPIB && mask)
0372 continue;
0373 SiPixelClusterModule *theModule = new SiPixelClusterModule(id, ncols, nrows);
0374 thePixelStructure.insert(pair<uint32_t, SiPixelClusterModule *>(id, theModule));
0375 }
0376 }
0377 }
0378 }
0379 LogInfo("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
0380 }
0381
0382
0383
0384 void SiPixelClusterSource::bookMEs(DQMStore::IBooker &iBooker, const edm::EventSetup &iSetup) {
0385
0386 iBooker.setCurrentFolder(topFolderName_);
0387 char title[256];
0388 snprintf(title,
0389 256,
0390 "Rate of events with >%i FPIX clusters;LumiSection;Rate of large "
0391 "FPIX events per LS [Hz]",
0392 bigEventSize);
0393 bigFpixClusterEventRate = iBooker.book1D("bigFpixClusterEventRate", title, 5000, 0., 5000.);
0394
0395 std::map<uint32_t, SiPixelClusterModule *>::iterator struct_iter;
0396
0397 SiPixelFolderOrganizer theSiPixelFolder(false);
0398
0399 edm::ESHandle<TrackerTopology> tTopoHandle = iSetup.getHandle(trackerTopoTokenBeginRun_);
0400 const TrackerTopology *pTT = tTopoHandle.product();
0401
0402 for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
0403
0404 if (modOn) {
0405 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 0, isUpgrade)) {
0406 (*struct_iter).second->book(conf_, pTT, iBooker, 0, twoDimOn, reducedSet, isUpgrade);
0407 } else {
0408 if (!isPIB)
0409 throw cms::Exception("LogicError") << "[SiPixelClusterSource::bookMEs] Creation of DQM folder "
0410 "failed";
0411 }
0412 }
0413 if (ladOn) {
0414 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 1, isUpgrade)) {
0415 (*struct_iter).second->book(conf_, pTT, iBooker, 1, twoDimOn, reducedSet, isUpgrade);
0416 } else {
0417 LogDebug("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
0418 }
0419 }
0420 if (layOn) {
0421 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 2, isUpgrade)) {
0422 (*struct_iter).second->book(conf_, pTT, iBooker, 2, twoDimOn, reducedSet, isUpgrade);
0423 } else {
0424 LogDebug("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
0425 }
0426 }
0427 if (phiOn) {
0428 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 3, isUpgrade)) {
0429 (*struct_iter).second->book(conf_, pTT, iBooker, 3, twoDimOn, reducedSet, isUpgrade);
0430 } else {
0431 LogDebug("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
0432 }
0433 }
0434 if (bladeOn) {
0435 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 4, isUpgrade)) {
0436 (*struct_iter).second->book(conf_, pTT, iBooker, 4, twoDimOn, reducedSet, isUpgrade);
0437 } else {
0438 LogDebug("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
0439 }
0440 }
0441 if (diskOn) {
0442 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 5, isUpgrade)) {
0443 (*struct_iter).second->book(conf_, pTT, iBooker, 5, twoDimOn, reducedSet, isUpgrade);
0444 } else {
0445 LogDebug("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
0446 }
0447 }
0448 if (ringOn) {
0449 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 6, isUpgrade)) {
0450 (*struct_iter).second->book(conf_, pTT, iBooker, 6, twoDimOn, reducedSet, isUpgrade);
0451 } else {
0452 LogDebug("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
0453 }
0454 }
0455 if (smileyOn) {
0456 if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 7, isUpgrade)) {
0457 (*struct_iter).second->book(conf_, pTT, iBooker, 7, twoDimOn, reducedSet, isUpgrade);
0458 } else {
0459 LogDebug("PixelDQM") << "PROBLEM WITH BARREL-FOLDER\n";
0460 }
0461 }
0462 }
0463 }
0464
0465 void SiPixelClusterSource::getrococcupancy(DetId detId,
0466 const edm::DetSetVector<PixelDigi> &diginp,
0467 const TrackerTopology *const tTopo,
0468 std::vector<MonitorElement *> const &meinput) {
0469 edm::DetSetVector<PixelDigi>::const_iterator ipxsearch = diginp.find(detId);
0470 if (ipxsearch != diginp.end()) {
0471
0472 edm::DetSet<PixelDigi>::const_iterator pxdi;
0473 for (pxdi = ipxsearch->begin(); pxdi != ipxsearch->end(); pxdi++) {
0474 bool isHalfModule = PixelBarrelName(DetId(detId), tTopo, isUpgrade).isHalfModule();
0475 int DBlayer = PixelBarrelName(DetId(detId), tTopo, isUpgrade).layerName();
0476 int DBmodule = PixelBarrelName(DetId(detId), tTopo, isUpgrade).moduleName();
0477 int DBladder = PixelBarrelName(DetId(detId), tTopo, isUpgrade).ladderName();
0478 int DBshell = PixelBarrelName(DetId(detId), tTopo, isUpgrade).shell();
0479
0480
0481 if (DBshell == 1 || DBshell == 2) {
0482 DBmodule = -DBmodule;
0483 }
0484 if (DBshell == 1 || DBshell == 3) {
0485 DBladder = -DBladder;
0486 }
0487
0488 int col = pxdi->column();
0489 int row = pxdi->row();
0490
0491 float modsign = (float)DBmodule / (abs((float)DBmodule));
0492 float ladsign = (float)DBladder / (abs((float)DBladder));
0493 float rocx = ((float)col / (52. * 8.)) * modsign + ((float)DBmodule - (modsign) * 0.5);
0494 float rocy = ((float)row / (80. * 2.)) * ladsign + ((float)DBladder - (ladsign) * 0.5);
0495
0496
0497 bool flip = false;
0498 if ((DBladder % 2 == 0) && (!isHalfModule)) {
0499 flip = true;
0500 }
0501 if ((flip) && (DBladder > 0)) {
0502 if ((((float)DBladder - (ladsign) * 0.5) <= rocy) && (rocy < (float)DBladder)) {
0503 rocy = rocy + ladsign * 0.5;
0504 } else if ((((float)DBladder) <= rocy) && (rocy < ((float)DBladder + (ladsign) * 0.5))) {
0505 rocy = rocy - ladsign * 0.5;
0506 }
0507 }
0508
0509
0510 if (modsign < 0) {
0511 rocx = rocx - 0.0001;
0512 }
0513 if (ladsign < 0) {
0514 rocy = rocy - 0.0001;
0515 } else {
0516 rocy = rocy + 0.0001;
0517 }
0518 if (abs(DBladder) == 1) {
0519 rocy = rocy + ladsign * 0.5;
0520 }
0521 meinput[DBlayer - 1]->Fill(rocx, rocy);
0522 }
0523 }
0524 }
0525
0526 void SiPixelClusterSource::getrococcupancye(DetId detId,
0527 const edmNew::DetSetVector<SiPixelCluster> &clustColl,
0528 const TrackerTopology *const pTT,
0529 edm::ESHandle<TrackerGeometry> pDD,
0530 MonitorElement *meinput) {
0531 edmNew::DetSetVector<SiPixelCluster>::const_iterator ipxsearch = clustColl.find(detId);
0532 if (ipxsearch != clustColl.end()) {
0533
0534 edmNew::DetSet<SiPixelCluster>::const_iterator pxclust;
0535 for (pxclust = ipxsearch->begin(); pxclust != ipxsearch->end(); pxclust++) {
0536 const GeomDetUnit *geoUnit = pDD->idToDetUnit(detId);
0537 const PixelGeomDetUnit *pixDet = dynamic_cast<const PixelGeomDetUnit *>(geoUnit);
0538 const PixelTopology *topol = &(pixDet->specificTopology());
0539 LocalPoint clustlp = topol->localPosition(MeasurementPoint(pxclust->x(), pxclust->y()));
0540 GlobalPoint clustgp = geoUnit->surface().toGlobal(clustlp);
0541
0542 float xclust = pxclust->x();
0543 float yclust = pxclust->y();
0544 float z = clustgp.z();
0545
0546 int pxfside = PixelEndcapName(detId, pTT, isUpgrade).halfCylinder();
0547 int pxfpanel = PixelEndcapName(detId, pTT, isUpgrade).pannelName();
0548 int pxfmodule = PixelEndcapName(detId, pTT, isUpgrade).plaquetteName();
0549 int pxfdisk = PixelEndcapName(detId, pTT, isUpgrade).diskName();
0550 int pxfblade = PixelEndcapName(detId, pTT, isUpgrade).bladeName();
0551
0552 if ((pxfside == 1) || (pxfside == 3)) {
0553 pxfblade = -1. * pxfblade;
0554 }
0555
0556 if (z < 0.) {
0557 pxfdisk = -1. * pxfdisk;
0558 }
0559
0560 int clu_sdpx = ((pxfdisk > 0) ? 1 : -1) * (2 * (abs(pxfdisk) - 1) + pxfpanel);
0561 int binselx = (pxfpanel == 1 && (pxfmodule == 1 || pxfmodule == 4))
0562 ? (pxfmodule == 1)
0563 : ((pxfpanel == 1 && xclust < 80.0) || (pxfpanel == 2 && xclust >= 80.0));
0564 int nperpan = 2 * pxfmodule + pxfpanel - 1 + binselx;
0565 int clu_roc_binx =
0566 ((pxfdisk > 0) ? nperpan : 9 - nperpan) + (clu_sdpx + 4) * 8 - 2 * ((abs(pxfdisk) == 1) ? pxfdisk : 0);
0567
0568 int clu_roc_biny = -99.;
0569 int nrocly = pxfmodule + pxfpanel;
0570 for (int i = 0; i < nrocly; i++) {
0571 int j = (pxfdisk < 0) ? i : nrocly - 1 - i;
0572 if (yclust >= (j * 52.0) && yclust < ((j + 1) * 52.0))
0573 clu_roc_biny = 6 - nrocly + 2 * i + ((pxfblade > 0) ? pxfblade - 1 : pxfblade + 12) * 12 + 1;
0574 }
0575 if (pxfblade > 0) {
0576 clu_roc_biny = clu_roc_biny + 144;
0577 }
0578
0579 meinput->setBinContent(clu_roc_binx, clu_roc_biny, meinput->getBinContent(clu_roc_binx, clu_roc_biny) + 1);
0580 meinput->setBinContent(
0581 clu_roc_binx, clu_roc_biny + 1, meinput->getBinContent(clu_roc_binx, clu_roc_biny + 1) + 1);
0582 }
0583 }
0584 }
0585
0586
0587 DEFINE_FWK_MODULE(SiPixelClusterSource);