Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-17 23:10:39

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiPixelMonitorDigi
0004 // Class:      SiPixelDigiSource
0005 //
0006 /**\class 
0007 
0008  Description: Pixel DQM source for Digis
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Vincenzo Chiochia
0015 //         Created:
0016 //
0017 //
0018 #include "DQM/SiPixelMonitorDigi/interface/SiPixelDigiSource.h"
0019 // Framework
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/ServiceRegistry/interface/Service.h"
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "FWCore/Framework/interface/LuminosityBlock.h"
0025 // DQM Framework
0026 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
0027 #include "DQMServices/Core/interface/DQMStore.h"
0028 // Geometry
0029 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0030 // DataFormats
0031 #include "DataFormats/DetId/interface/DetId.h"
0032 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.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 //
0038 #include <string>
0039 #include <cstdlib>
0040 #include <iostream>
0041 #include <fstream>
0042 
0043 using namespace std;
0044 using namespace edm;
0045 
0046 SiPixelDigiSource::SiPixelDigiSource(const edm::ParameterSet& iConfig)
0047     : conf_(iConfig),
0048       src_(conf_.getParameter<edm::InputTag>("src")),
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       perLSsaving(conf_.getUntrackedParameter<bool>("perLSsaving", false)),
0054       twoDimOn(conf_.getUntrackedParameter<bool>("twoDimOn", true)),
0055       twoDimModOn(conf_.getUntrackedParameter<bool>("twoDimModOn", true)),
0056       twoDimOnlyLayDisk(conf_.getUntrackedParameter<bool>("twoDimOnlyLayDisk", false)),
0057       hiRes(conf_.getUntrackedParameter<bool>("hiRes", false)),
0058       reducedSet(conf_.getUntrackedParameter<bool>("reducedSet", false)),
0059       ladOn(conf_.getUntrackedParameter<bool>("ladOn", false)),
0060       layOn(conf_.getUntrackedParameter<bool>("layOn", false)),
0061       phiOn(conf_.getUntrackedParameter<bool>("phiOn", false)),
0062       ringOn(conf_.getUntrackedParameter<bool>("ringOn", false)),
0063       bladeOn(conf_.getUntrackedParameter<bool>("bladeOn", false)),
0064       diskOn(conf_.getUntrackedParameter<bool>("diskOn", false)),
0065       bigEventSize(conf_.getUntrackedParameter<int>("bigEventSize", 1000)),
0066       isUpgrade(conf_.getUntrackedParameter<bool>("isUpgrade", false)),
0067       noOfLayers(0),
0068       noOfDisks(0) {
0069   //set Token(-s)
0070   srcToken_ = consumes<edm::DetSetVector<PixelDigi> >(conf_.getParameter<edm::InputTag>("src"));
0071 
0072   trackerTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>();
0073   trackerTopoTokenBeginRun_ = esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>();
0074   trackerGeomTokenBeginRun_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>();
0075 
0076   topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
0077 
0078   firstRun = true;
0079   // find a FED# for the current detId:
0080   ifstream infile(edm::FileInPath("DQM/SiPixelMonitorClient/test/detId.dat").fullPath().c_str(), ios::in);
0081   int nModsInFile = 0;
0082   assert(!infile.fail());
0083   int nTOTmodules;
0084   if (isUpgrade) {
0085     nTOTmodules = 1856;
0086   } else {
0087     nTOTmodules = 1440;
0088   }
0089   while (!infile.eof() && nModsInFile < nTOTmodules) {
0090     infile >> I_name[nModsInFile] >> I_detId[nModsInFile] >> I_fedId[nModsInFile] >> I_linkId1[nModsInFile] >>
0091         I_linkId2[nModsInFile];
0092     nModsInFile++;
0093   }
0094   infile.close();
0095 
0096   LogInfo("PixelDQM") << "SiPixelDigiSource::SiPixelDigiSource: Got DQM BackEnd interface" << endl;
0097 }
0098 
0099 SiPixelDigiSource::~SiPixelDigiSource() {
0100   // do anything here that needs to be done at desctruction time
0101   // (e.g. close files, deallocate resources etc.)
0102   LogInfo("PixelDQM") << "SiPixelDigiSource::~SiPixelDigiSource: Destructor" << endl;
0103 }
0104 
0105 std::shared_ptr<bool> SiPixelDigiSource::globalBeginLuminosityBlock(const edm::LuminosityBlock& lumi,
0106                                                                     const edm::EventSetup& iSetup) const {
0107   unsigned int currentLS = lumi.id().luminosityBlock();
0108   bool resetCounters = (currentLS % 10 == 0) ? true : false;
0109   return std::make_shared<bool>(resetCounters);
0110 }
0111 
0112 void SiPixelDigiSource::globalEndLuminosityBlock(const edm::LuminosityBlock& lb, edm::EventSetup const&) {
0113   int thisls = lb.id().luminosityBlock();
0114   const bool resetCounters = luminosityBlockCache(lb.index());
0115 
0116   float averageBPIXFed = float(nBPIXDigis) / 32.;
0117   float averageFPIXFed = float(nFPIXDigis) / 8.;
0118 
0119   if (averageDigiOccupancy) {
0120     for (int i = 0; i != 40; i++) {
0121       float averageOcc = 0.;
0122       if (i < 32) {
0123         if (averageBPIXFed > 0.)
0124           averageOcc = nDigisPerFed[i] / averageBPIXFed;
0125       } else {
0126         if (averageFPIXFed > 0.)
0127           averageOcc = nDigisPerFed[i] / averageFPIXFed;
0128       }
0129       if (!modOn) {
0130         averageDigiOccupancy->Fill(
0131             i,
0132             nDigisPerFed[i]);  //In offline we fill all digis and normalise at the end of the run for thread safe behaviour.
0133         avgfedDigiOccvsLumi->setBinContent(thisls, i + 1, nDigisPerFed[i]);  //Same plot vs lumi section
0134       }
0135       if (modOn) {
0136         if (thisls % 10 == 0)
0137           averageDigiOccupancy->Fill(
0138               i,
0139               averageOcc);  // "modOn" basically mean Online DQM, in this case fill histos with actual value of digi fraction per fed for each ten lumisections
0140         if (avgfedDigiOccvsLumi && thisls % 5 == 0) {
0141           avgfedDigiOccvsLumi->setBinContent(
0142               int(thisls / 5),
0143               i + 1,
0144               averageOcc);  //fill with the mean over 5 lumisections, previous code was filling this histo only with last event of each 10th lumisection
0145         }
0146       }
0147     }
0148 
0149     if (modOn && thisls % 10 == 0) {
0150       avgBarrelFedOccvsLumi->setBinContent(
0151           int(thisls / 10), averageBPIXFed);  //<NDigis> vs lumisection for barrel, filled every 10 lumi sections
0152       avgEndcapFedOccvsLumi->setBinContent(
0153           int(thisls / 10), averageFPIXFed);  //<NDigis> vs lumisection for endcap, filled every 10 lumi sections
0154     }
0155   }
0156 
0157   //reset counters
0158 
0159   if (modOn && resetCounters && averageDigiOccupancy) {
0160     nBPIXDigis = 0;
0161     nFPIXDigis = 0;
0162     for (int i = 0; i != 40; i++)
0163       nDigisPerFed[i] = 0;
0164   }
0165 
0166   if (!modOn && averageDigiOccupancy) {
0167     nBPIXDigis = 0;
0168     nFPIXDigis = 0;
0169     for (int i = 0; i != 40; i++)
0170       nDigisPerFed[i] = 0;
0171   }
0172 
0173   if (modOn && resetCounters) {
0174     ROCMapToReset = true;  //the ROC map is reset each 10 lumisections
0175 
0176     for (int i = 0; i < 2; i++)
0177       NzeroROCs[i] = 0;
0178     for (int i = 0; i < 2; i++)
0179       NloEffROCs[i] = 0;  //resetting also Zero and low eff. ROC counters
0180 
0181     NzeroROCs[1] = -672;
0182     NloEffROCs[1] =
0183         -672;  //this magic number derives by the way the endcap occupancy is filled, there are always 672 empty bins by construction
0184 
0185     //these bools are needed to count zero occupancy plots in the substructure only once each 10 LS
0186     DoZeroRocsBMO1 = true;
0187     DoZeroRocsBMO2 = true;
0188     DoZeroRocsBMO3 = true;
0189 
0190     DoZeroRocsBMI1 = true;
0191     DoZeroRocsBMI2 = true;
0192     DoZeroRocsBMI3 = true;
0193 
0194     DoZeroRocsBPO1 = true;
0195     DoZeroRocsBPO2 = true;
0196     DoZeroRocsBPO3 = true;
0197 
0198     DoZeroRocsBPI1 = true;
0199     DoZeroRocsBPI2 = true;
0200     DoZeroRocsBPI3 = true;
0201 
0202     DoZeroRocsFPO1 = true;
0203     DoZeroRocsFPO2 = true;
0204 
0205     DoZeroRocsFMO1 = true;
0206     DoZeroRocsFMO2 = true;
0207 
0208     DoZeroRocsFPI1 = true;
0209     DoZeroRocsFPI2 = true;
0210 
0211     DoZeroRocsFMI1 = true;
0212     DoZeroRocsFMI2 = true;
0213   }
0214 }
0215 
0216 void SiPixelDigiSource::dqmBeginRun(const edm::Run& r, const edm::EventSetup& iSetup) {
0217   LogInfo("PixelDQM") << " SiPixelDigiSource::beginJob - Initialisation ... " << std::endl;
0218   LogInfo("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/" << layOn << "/" << phiOn << std::endl;
0219   LogInfo("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/" << ringOn << std::endl;
0220   LogInfo("PixelDQM") << "2DIM IS " << twoDimOn << " and set to high resolution? " << hiRes << "\n";
0221 
0222   if (firstRun) {
0223     nBigEvents = 0;
0224     nBPIXDigis = 0;
0225     nFPIXDigis = 0;
0226     for (int i = 0; i != 40; i++)
0227       nDigisPerFed[i] = 0;
0228     for (int i = 0; i != 4; i++)
0229       nDigisPerDisk[i] = 0;
0230     nDP1P1M1 = 0;
0231     nDP1P1M2 = 0;
0232     nDP1P1M3 = 0;
0233     nDP1P1M4 = 0;
0234     nDP1P2M1 = 0;
0235     nDP1P2M2 = 0;
0236     nDP1P2M3 = 0;
0237     nDP2P1M1 = 0;
0238     nDP2P1M2 = 0;
0239     nDP2P1M3 = 0;
0240     nDP2P1M4 = 0;
0241     nDP2P2M1 = 0;
0242     nDP2P2M2 = 0;
0243     nDP2P2M3 = 0;
0244     nDP3P1M1 = 0;
0245     nDP3P2M1 = 0;
0246     nDM1P1M1 = 0;
0247     nDM1P1M2 = 0;
0248     nDM1P1M3 = 0;
0249     nDM1P1M4 = 0;
0250     nDM1P2M1 = 0;
0251     nDM1P2M2 = 0;
0252     nDM1P2M3 = 0;
0253     nDM2P1M1 = 0;
0254     nDM2P1M2 = 0;
0255     nDM2P1M3 = 0;
0256     nDM2P1M4 = 0;
0257     nDM2P2M1 = 0;
0258     nDM2P2M2 = 0;
0259     nDM2P2M3 = 0;
0260     nDM3P1M1 = 0;
0261     nDM3P2M1 = 0;
0262     nL1M1 = 0;
0263     nL1M2 = 0;
0264     nL1M3 = 0;
0265     nL1M4 = 0;
0266     nL2M1 = 0;
0267     nL2M2 = 0;
0268     nL2M3 = 0;
0269     nL2M4 = 0;
0270     nL3M1 = 0;
0271     nL3M2 = 0;
0272     nL3M3 = 0;
0273     nL3M4 = 0;
0274     nL4M1 = 0;
0275     nL4M2 = 0;
0276     nL4M3 = 0;
0277     nL4M4 = 0;
0278 
0279     ROCMapToReset = false;
0280 
0281     DoZeroRocsBMO1 = false;
0282     DoZeroRocsBMO2 = false;
0283     DoZeroRocsBMO3 = false;
0284 
0285     DoZeroRocsBMI1 = false;
0286     DoZeroRocsBMI2 = false;
0287     DoZeroRocsBMI3 = false;
0288 
0289     DoZeroRocsBPO1 = false;
0290     DoZeroRocsBPO2 = false;
0291     DoZeroRocsBPO3 = false;
0292 
0293     DoZeroRocsBPI1 = false;
0294     DoZeroRocsBPI2 = false;
0295     DoZeroRocsBPI3 = false;
0296 
0297     DoZeroRocsFPO1 = false;
0298     DoZeroRocsFPO2 = false;
0299 
0300     DoZeroRocsFMO1 = false;
0301     DoZeroRocsFMO2 = false;
0302 
0303     DoZeroRocsFPI1 = false;
0304     DoZeroRocsFPI2 = false;
0305 
0306     DoZeroRocsFMI1 = false;
0307     DoZeroRocsFMI2 = false;
0308 
0309     for (int i = 0; i < 2; i++)
0310       NzeroROCs[i] = 0;
0311     for (int i = 0; i < 2; i++)
0312       NloEffROCs[i] = 0;
0313 
0314     // Build map
0315     buildStructure(iSetup);
0316     // Book Monitoring Elements
0317     firstRun = false;
0318   }
0319 }
0320 
0321 void SiPixelDigiSource::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&, const edm::EventSetup& iSetup) {
0322   bookMEs(iBooker, iSetup);
0323 }
0324 
0325 //------------------------------------------------------------------
0326 // Method called for every event
0327 //------------------------------------------------------------------
0328 void SiPixelDigiSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0329   edm::ESHandle<TrackerTopology> tTopoHandle = iSetup.getHandle(trackerTopoToken_);
0330   const TrackerTopology* pTT = tTopoHandle.product();
0331 
0332   // get input data
0333   edm::Handle<edm::DetSetVector<PixelDigi> > input;
0334   iEvent.getByToken(srcToken_, input);
0335   if (!input.isValid())
0336     return;
0337 
0338   int bx = iEvent.bunchCrossing();
0339 
0340   int lumiSection = (int)iEvent.luminosityBlock();
0341   int nEventDigis = 0;
0342   int nActiveModules = 0;
0343 
0344   std::map<uint32_t, SiPixelDigiModule*>::iterator struct_iter;
0345   for (int i = 0; i != 192; i++)
0346     numberOfDigis[i] = 0;
0347   for (int i = 0; i != 1152; i++)
0348     nDigisPerChan[i] = 0;
0349   for (int i = 0; i != 4; i++)
0350     nDigisPerDisk[i] = 0;
0351 
0352   for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
0353     int numberOfDigisMod = (*struct_iter)
0354                                .second->fill(*input,
0355                                              pTT,
0356                                              meNDigisCOMBBarrel_,
0357                                              meNDigisCHANBarrel_,
0358                                              meNDigisCHANBarrelLs_,
0359                                              meNDigisCOMBEndcap_,
0360                                              modOn,
0361                                              ladOn,
0362                                              layOn,
0363                                              phiOn,
0364                                              bladeOn,
0365                                              diskOn,
0366                                              ringOn,
0367                                              twoDimOn,
0368                                              reducedSet,
0369                                              twoDimModOn,
0370                                              twoDimOnlyLayDisk,
0371                                              nDigisA,
0372                                              nDigisB,
0373                                              isUpgrade);
0374 
0375     bool barrel = DetId((*struct_iter).first).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
0376     bool endcap = DetId((*struct_iter).first).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
0377 
0378     if (numberOfDigisMod > 0) {
0379       nEventDigis = nEventDigis + numberOfDigisMod;
0380       nActiveModules++;
0381       int nBPiXmodules;
0382       int nTOTmodules;
0383       if (isUpgrade) {
0384         nBPiXmodules = 1184;
0385         nTOTmodules = 1856;
0386       } else {
0387         nBPiXmodules = 768;
0388         nTOTmodules = 1440;
0389       }
0390       if (barrel) {  // Barrel
0391         int layer = PixelBarrelName(DetId((*struct_iter).first), pTT, isUpgrade).layerName();
0392         PixelBarrelName::Shell shell = PixelBarrelName(DetId((*struct_iter).first), pTT, isUpgrade).shell();
0393 
0394         //Count Zero Occ Rocs in Barrel in the first event after each 10 Ls
0395         if (ROCMapToReset && shell == PixelBarrelName::mO && twoDimOnlyLayDisk) {
0396           if (DoZeroRocsBMO1 && layer == 1)
0397             CountZeroROCsInSubstructure(barrel, DoZeroRocsBMO1, (*struct_iter).second);
0398           if (DoZeroRocsBMO2 && layer == 2)
0399             CountZeroROCsInSubstructure(barrel, DoZeroRocsBMO2, (*struct_iter).second);
0400           if (DoZeroRocsBMO3 && layer == 3)
0401             CountZeroROCsInSubstructure(barrel, DoZeroRocsBMO3, (*struct_iter).second);
0402         } else if (ROCMapToReset && shell == PixelBarrelName::mI && twoDimOnlyLayDisk) {
0403           if (DoZeroRocsBMI1 && layer == 1)
0404             CountZeroROCsInSubstructure(barrel, DoZeroRocsBMI1, (*struct_iter).second);
0405           if (DoZeroRocsBMI2 && layer == 2)
0406             CountZeroROCsInSubstructure(barrel, DoZeroRocsBMI2, (*struct_iter).second);
0407           if (DoZeroRocsBMI3 && layer == 3)
0408             CountZeroROCsInSubstructure(barrel, DoZeroRocsBMI3, (*struct_iter).second);
0409         } else if (ROCMapToReset && shell == PixelBarrelName::pO && twoDimOnlyLayDisk) {
0410           if (DoZeroRocsBPO1 && layer == 1)
0411             CountZeroROCsInSubstructure(barrel, DoZeroRocsBPO1, (*struct_iter).second);
0412           if (DoZeroRocsBPO2 && layer == 2)
0413             CountZeroROCsInSubstructure(barrel, DoZeroRocsBPO2, (*struct_iter).second);
0414           if (DoZeroRocsBPO3 && layer == 3)
0415             CountZeroROCsInSubstructure(barrel, DoZeroRocsBPO3, (*struct_iter).second);
0416         } else if (ROCMapToReset && shell == PixelBarrelName::pI && twoDimOnlyLayDisk) {
0417           if (DoZeroRocsBPI1 && layer == 1)
0418             CountZeroROCsInSubstructure(barrel, DoZeroRocsBPI1, (*struct_iter).second);
0419           if (DoZeroRocsBPI2 && layer == 2)
0420             CountZeroROCsInSubstructure(barrel, DoZeroRocsBPI2, (*struct_iter).second);
0421           if (DoZeroRocsBPI3 && layer == 3)
0422             CountZeroROCsInSubstructure(barrel, DoZeroRocsBPI3, (*struct_iter).second);
0423         }
0424 
0425         nBPIXDigis = nBPIXDigis + numberOfDigisMod;
0426         for (int i = 0; i != nBPiXmodules; ++i) {
0427           if ((*struct_iter).first == I_detId[i]) {
0428             nDigisPerFed[I_fedId[i]] = nDigisPerFed[I_fedId[i]] + numberOfDigisMod;
0429             int index1 = 0;
0430             int index2 = 0;
0431             if (I_linkId1[i] > 0)
0432               index1 = I_fedId[i] * 36 + (I_linkId1[i] - 1);
0433             if (I_linkId2[i] > 0)
0434               index2 = I_fedId[i] * 36 + (I_linkId2[i] - 1);
0435             if (nDigisA > 0 && I_linkId1[i] > 0)
0436               nDigisPerChan[index1] = nDigisPerChan[index1] + nDigisA;
0437             if (nDigisB > 0 && I_linkId2[i] > 0)
0438               nDigisPerChan[index2] = nDigisPerChan[index2] + nDigisB;
0439             i = (nBPiXmodules - 1);
0440           }
0441         }
0442       } else if (endcap && !isUpgrade) {  // Endcap
0443         nFPIXDigis = nFPIXDigis + numberOfDigisMod;
0444         PixelEndcapName::HalfCylinder side =
0445             PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).halfCylinder();
0446         int disk = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).diskName();
0447         int blade = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).bladeName();
0448         int panel = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).pannelName();
0449         int module = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).plaquetteName();
0450         int iter = 0;
0451         int i = 0;
0452 
0453         //count Zero Occupancy ROCs in Endcap in the first event after each 10 Ls
0454         if (ROCMapToReset && side == PixelEndcapName::mO && twoDimOnlyLayDisk) {
0455           if (DoZeroRocsFMO1 && disk == 1)
0456             CountZeroROCsInSubstructure(barrel, DoZeroRocsFMO1, (*struct_iter).second);
0457           if (DoZeroRocsFMO2 && disk == 2)
0458             CountZeroROCsInSubstructure(barrel, DoZeroRocsFMO2, (*struct_iter).second);
0459         } else if (ROCMapToReset && side == PixelEndcapName::mI && twoDimOnlyLayDisk) {
0460           if (DoZeroRocsFMI1 && disk == 1)
0461             CountZeroROCsInSubstructure(barrel, DoZeroRocsFMI1, (*struct_iter).second);
0462           if (DoZeroRocsFMI2 && disk == 2)
0463             CountZeroROCsInSubstructure(barrel, DoZeroRocsFMI2, (*struct_iter).second);
0464         } else if (ROCMapToReset && side == PixelEndcapName::pO && twoDimOnlyLayDisk) {
0465           if (DoZeroRocsFPO1 && disk == 1)
0466             CountZeroROCsInSubstructure(barrel, DoZeroRocsFPO1, (*struct_iter).second);
0467           if (DoZeroRocsFPO2 && disk == 2)
0468             CountZeroROCsInSubstructure(barrel, DoZeroRocsFPO2, (*struct_iter).second);
0469         } else if (ROCMapToReset && side == PixelEndcapName::pI && twoDimOnlyLayDisk) {
0470           if (DoZeroRocsFPI1 && disk == 1)
0471             CountZeroROCsInSubstructure(barrel, DoZeroRocsFPI1, (*struct_iter).second);
0472           if (DoZeroRocsFPI2 && disk == 2)
0473             CountZeroROCsInSubstructure(barrel, DoZeroRocsFPI2, (*struct_iter).second);
0474         }
0475 
0476         if (side == PixelEndcapName::mI) {
0477           if (disk == 1) {
0478             i = 0;
0479             if (panel == 1) {
0480               if (module == 1)
0481                 nDM1P1M1 += numberOfDigisMod;
0482               else if (module == 2)
0483                 nDM1P1M2 += numberOfDigisMod;
0484               else if (module == 3)
0485                 nDM1P1M3 += numberOfDigisMod;
0486               else if (module == 4)
0487                 nDM1P1M4 += numberOfDigisMod;
0488             } else if (panel == 2) {
0489               if (module == 1)
0490                 nDM1P2M1 += numberOfDigisMod;
0491               else if (module == 2)
0492                 nDM1P2M2 += numberOfDigisMod;
0493               else if (module == 3)
0494                 nDM1P2M3 += numberOfDigisMod;
0495             }
0496             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0497               iter = i + 2 * (blade - 1) + (panel - 1);
0498           } else if (disk == 2) {
0499             i = 24;
0500             if (panel == 1) {
0501               if (module == 1)
0502                 nDM2P1M1 += numberOfDigisMod;
0503               else if (module == 2)
0504                 nDM2P1M2 += numberOfDigisMod;
0505               else if (module == 3)
0506                 nDM2P1M3 += numberOfDigisMod;
0507               else if (module == 4)
0508                 nDM2P1M4 += numberOfDigisMod;
0509             } else if (panel == 2) {
0510               if (module == 1)
0511                 nDM2P2M1 += numberOfDigisMod;
0512               else if (module == 2)
0513                 nDM2P2M2 += numberOfDigisMod;
0514               else if (module == 3)
0515                 nDM2P2M3 += numberOfDigisMod;
0516             }
0517             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0518               iter = i + 2 * (blade - 1) + (panel - 1);
0519           }
0520         } else if (side == PixelEndcapName::mO) {
0521           if (disk == 1) {
0522             i = 48;
0523             if (panel == 1) {
0524               if (module == 1)
0525                 nDM1P1M1 += numberOfDigisMod;
0526               else if (module == 2)
0527                 nDM1P1M2 += numberOfDigisMod;
0528               else if (module == 3)
0529                 nDM1P1M3 += numberOfDigisMod;
0530               else if (module == 4)
0531                 nDM1P1M4 += numberOfDigisMod;
0532             } else if (panel == 2) {
0533               if (module == 1)
0534                 nDM1P2M1 += numberOfDigisMod;
0535               else if (module == 2)
0536                 nDM1P2M2 += numberOfDigisMod;
0537               else if (module == 3)
0538                 nDM1P2M3 += numberOfDigisMod;
0539             }
0540             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0541               iter = i + 2 * (blade - 1) + (panel - 1);
0542           } else if (disk == 2) {
0543             i = 72;
0544             if (panel == 1) {
0545               if (module == 1)
0546                 nDM2P1M1 += numberOfDigisMod;
0547               else if (module == 2)
0548                 nDM2P1M2 += numberOfDigisMod;
0549               else if (module == 3)
0550                 nDM2P1M3 += numberOfDigisMod;
0551               else if (module == 4)
0552                 nDM2P1M4 += numberOfDigisMod;
0553             } else if (panel == 2) {
0554               if (module == 1)
0555                 nDM2P2M1 += numberOfDigisMod;
0556               else if (module == 2)
0557                 nDM2P2M2 += numberOfDigisMod;
0558               else if (module == 3)
0559                 nDM2P2M3 += numberOfDigisMod;
0560             }
0561             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0562               iter = i + 2 * (blade - 1) + (panel - 1);
0563           }
0564         } else if (side == PixelEndcapName::pI) {
0565           if (disk == 1) {
0566             i = 96;
0567             if (panel == 1) {
0568               if (module == 1)
0569                 nDP1P1M1 += numberOfDigisMod;
0570               else if (module == 2)
0571                 nDP1P1M2 += numberOfDigisMod;
0572               else if (module == 3)
0573                 nDP1P1M3 += numberOfDigisMod;
0574               else if (module == 4)
0575                 nDP1P1M4 += numberOfDigisMod;
0576             } else if (panel == 2) {
0577               if (module == 1)
0578                 nDP1P2M1 += numberOfDigisMod;
0579               else if (module == 2)
0580                 nDP1P2M2 += numberOfDigisMod;
0581               else if (module == 3)
0582                 nDP1P2M3 += numberOfDigisMod;
0583             }
0584             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0585               iter = i + 2 * (blade - 1) + (panel - 1);
0586           } else if (disk == 2) {
0587             i = 120;
0588             if (panel == 1) {
0589               if (module == 1)
0590                 nDP2P1M1 += numberOfDigisMod;
0591               else if (module == 2)
0592                 nDP2P1M2 += numberOfDigisMod;
0593               else if (module == 3)
0594                 nDP2P1M3 += numberOfDigisMod;
0595               else if (module == 4)
0596                 nDP2P1M4 += numberOfDigisMod;
0597             } else if (panel == 2) {
0598               if (module == 1)
0599                 nDP2P2M1 += numberOfDigisMod;
0600               else if (module == 2)
0601                 nDP2P2M2 += numberOfDigisMod;
0602               else if (module == 3)
0603                 nDP2P2M3 += numberOfDigisMod;
0604             }
0605             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0606               iter = i + 2 * (blade - 1) + (panel - 1);
0607           }
0608         } else if (side == PixelEndcapName::pO) {
0609           if (disk == 1) {
0610             i = 144;
0611             if (panel == 1) {
0612               if (module == 1)
0613                 nDP1P1M1 += numberOfDigisMod;
0614               else if (module == 2)
0615                 nDP1P1M2 += numberOfDigisMod;
0616               else if (module == 3)
0617                 nDP1P1M3 += numberOfDigisMod;
0618               else if (module == 4)
0619                 nDP1P1M4 += numberOfDigisMod;
0620             } else if (panel == 2) {
0621               if (module == 1)
0622                 nDP1P2M1 += numberOfDigisMod;
0623               else if (module == 2)
0624                 nDP1P2M2 += numberOfDigisMod;
0625               else if (module == 3)
0626                 nDP1P2M3 += numberOfDigisMod;
0627             }
0628             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0629               iter = i + 2 * (blade - 1) + (panel - 1);
0630           } else if (disk == 2) {
0631             i = 168;
0632             if (panel == 1) {
0633               if (module == 1)
0634                 nDP2P1M1 += numberOfDigisMod;
0635               else if (module == 2)
0636                 nDP2P1M2 += numberOfDigisMod;
0637               else if (module == 3)
0638                 nDP2P1M3 += numberOfDigisMod;
0639               else if (module == 4)
0640                 nDP2P1M4 += numberOfDigisMod;
0641             } else if (panel == 2) {
0642               if (module == 1)
0643                 nDP2P2M1 += numberOfDigisMod;
0644               else if (module == 2)
0645                 nDP2P2M2 += numberOfDigisMod;
0646               else if (module == 3)
0647                 nDP2P2M3 += numberOfDigisMod;
0648             }
0649             if (blade < 13 && blade > 0 && (panel == 1 || panel == 2))
0650               iter = i + 2 * (blade - 1) + (panel - 1);
0651           }
0652         }
0653         numberOfDigis[iter] = numberOfDigis[iter] + numberOfDigisMod;
0654 
0655         for (int i = nBPiXmodules; i != nTOTmodules; i++) {
0656           if ((*struct_iter).first == I_detId[i]) {
0657             nDigisPerFed[I_fedId[i]] = nDigisPerFed[I_fedId[i]] + numberOfDigisMod;
0658             i = nTOTmodules - 1;
0659           }
0660         }
0661       }  //endif Barrel/(Endcap && !isUpgrade)
0662       else if (endcap && isUpgrade) {
0663         nFPIXDigis = nFPIXDigis + numberOfDigisMod;
0664         PixelEndcapName::HalfCylinder side =
0665             PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).halfCylinder();
0666         int disk = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).diskName();
0667         int blade = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).bladeName();
0668         int panel = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).pannelName();
0669         int module = PixelEndcapName(DetId((*struct_iter).first), pTT, isUpgrade).plaquetteName();
0670 
0671         int iter = 0;
0672         int i = 0;
0673         if (side == PixelEndcapName::mI) {
0674           if (disk == 1) {
0675             i = 0;
0676             if (panel == 1) {
0677               if (module == 1)
0678                 nDM1P1M1 += numberOfDigisMod;
0679             } else if (panel == 2) {
0680               if (module == 1)
0681                 nDM1P2M1 += numberOfDigisMod;
0682             }
0683             if (blade < 12 && blade > 0 && (panel == 1 || panel == 2))
0684               iter = i + 2 * (blade - 1) + (panel - 1);
0685           } else if (disk == 2) {
0686             i = 22;
0687             if (panel == 1) {
0688               if (module == 1)
0689                 nDM2P1M1 += numberOfDigisMod;
0690             } else if (panel == 2) {
0691               if (module == 1)
0692                 nDM2P2M1 += numberOfDigisMod;
0693             }
0694             if (blade < 12 && blade > 0 && (panel == 1 || panel == 2))
0695               iter = i + 2 * (blade - 1) + (panel - 1);
0696           } else if (disk == 3) {
0697             i = 44;
0698             if (panel == 1) {
0699               if (module == 1)
0700                 nDM3P1M1 += numberOfDigisMod;
0701             } else if (panel == 2) {
0702               if (module == 1)
0703                 nDM3P2M1 += numberOfDigisMod;
0704             }
0705             if (blade < 12 && blade > 0 && (panel == 1 || panel == 2))
0706               iter = i + 2 * (blade - 1) + (panel - 1);
0707           }
0708         } else if (side == PixelEndcapName::mO) {
0709           if (disk == 1) {
0710             i = 66;
0711             if (panel == 1) {
0712               if (module == 1)
0713                 nDM1P1M1 += numberOfDigisMod;
0714             } else if (panel == 2) {
0715               if (module == 1)
0716                 nDM1P2M1 += numberOfDigisMod;
0717             }
0718             if (blade < 18 && blade > 0 && (panel == 1 || panel == 2))
0719               iter = i + 2 * (blade - 1) + (panel - 1);
0720           } else if (disk == 2) {
0721             i = 100;
0722             if (panel == 1) {
0723               if (module == 1)
0724                 nDM2P1M1 += numberOfDigisMod;
0725             } else if (panel == 2) {
0726               if (module == 1)
0727                 nDM2P2M1 += numberOfDigisMod;
0728             }
0729             if (blade < 18 && blade > 0 && (panel == 1 || panel == 2))
0730               iter = i + 2 * (blade - 1) + (panel - 1);
0731           } else if (disk == 3) {
0732             i = 134;
0733             if (panel == 1) {
0734               if (module == 1)
0735                 nDM3P1M1 += numberOfDigisMod;
0736             } else if (panel == 2) {
0737               if (module == 1)
0738                 nDM3P2M1 += numberOfDigisMod;
0739             }
0740             if (blade < 18 && blade > 0 && (panel == 1 || panel == 2))
0741               iter = i + 2 * (blade - 1) + (panel - 1);
0742           }
0743         } else if (side == PixelEndcapName::pI) {
0744           if (disk == 1) {
0745             i = 168;
0746             if (panel == 1) {
0747               if (module == 1)
0748                 nDP1P1M1 += numberOfDigisMod;
0749             } else if (panel == 2) {
0750               if (module == 1)
0751                 nDP1P2M1 += numberOfDigisMod;
0752             }
0753             if (blade < 12 && blade > 0 && (panel == 1 || panel == 2))
0754               iter = i + 2 * (blade - 1) + (panel - 1);
0755           } else if (disk == 2) {
0756             i = 190;
0757             if (panel == 1) {
0758               if (module == 1)
0759                 nDP2P1M1 += numberOfDigisMod;
0760             } else if (panel == 2) {
0761               if (module == 1)
0762                 nDP2P2M1 += numberOfDigisMod;
0763             }
0764             if (blade < 12 && blade > 0 && (panel == 1 || panel == 2))
0765               iter = i + 2 * (blade - 1) + (panel - 1);
0766           } else if (disk == 3) {
0767             i = 212;
0768             if (panel == 1) {
0769               if (module == 1)
0770                 nDP3P1M1 += numberOfDigisMod;
0771             } else if (panel == 2) {
0772               if (module == 1)
0773                 nDP3P2M1 += numberOfDigisMod;
0774             }
0775             if (blade < 12 && blade > 0 && (panel == 1 || panel == 2))
0776               iter = i + 2 * (blade - 1) + (panel - 1);
0777           }
0778         } else if (side == PixelEndcapName::pO) {
0779           if (disk == 1) {
0780             i = 234;
0781             if (panel == 1) {
0782               if (module == 1)
0783                 nDP1P1M1 += numberOfDigisMod;
0784             } else if (panel == 2) {
0785               if (module == 1)
0786                 nDP1P2M1 += numberOfDigisMod;
0787             }
0788             if (blade < 18 && blade > 0 && (panel == 1 || panel == 2))
0789               iter = i + 2 * (blade - 1) + (panel - 1);
0790           } else if (disk == 2) {
0791             i = 268;
0792             if (panel == 1) {
0793               if (module == 1)
0794                 nDP2P1M1 += numberOfDigisMod;
0795             } else if (panel == 2) {
0796               if (module == 1)
0797                 nDP2P2M1 += numberOfDigisMod;
0798             }
0799             if (blade < 18 && blade > 0 && (panel == 1 || panel == 2))
0800               iter = i + 2 * (blade - 1) + (panel - 1);
0801           } else if (disk == 3) {
0802             i = 302;
0803             if (panel == 1) {
0804               if (module == 1)
0805                 nDP3P1M1 += numberOfDigisMod;
0806             } else if (panel == 2) {
0807               if (module == 1)
0808                 nDP3P2M1 += numberOfDigisMod;
0809             }
0810             if (blade < 18 && blade > 0 && (panel == 1 || panel == 2))
0811               iter = i + 2 * (blade - 1) + (panel - 1);
0812           }
0813         }
0814         numberOfDigis[iter] = numberOfDigis[iter] + numberOfDigisMod;
0815         for (int i = nBPiXmodules; i != nTOTmodules; i++) {
0816           if ((*struct_iter).first == I_detId[i]) {
0817             nDigisPerFed[I_fedId[i]] = nDigisPerFed[I_fedId[i]] + numberOfDigisMod;
0818             i = nTOTmodules - 1;
0819           }
0820         }
0821       }  //endif(Endcap && isUpgrade)
0822     }    // endif any digis in this module
0823   }      // endfor loop over all modules
0824 
0825   if (lumiSection % 10 == 0 && ROCMapToReset) {
0826     for (int i = 0; i < 2; ++i)
0827       NloEffROCs[i] = NloEffROCs[i] - NzeroROCs[i];
0828     if (noOccROCsBarrel)
0829       noOccROCsBarrel->setBinContent(lumiSection / 10, NzeroROCs[0]);
0830     if (loOccROCsBarrel)
0831       loOccROCsBarrel->setBinContent(lumiSection / 10, NloEffROCs[0]);
0832     if (noOccROCsEndcap)
0833       noOccROCsEndcap->setBinContent(lumiSection / 10, NzeroROCs[1]);
0834     if (loOccROCsEndcap)
0835       loOccROCsEndcap->setBinContent(lumiSection / 10, NloEffROCs[1]);
0836     ROCMapToReset =
0837         false;  // in this way the ROC maps are reset for one event only (the first event in LS multiple of 10
0838   }
0839 
0840   if (noOfDisks == 2) {  // if (!isUpgrade)
0841     if (meNDigisCHANEndcap_) {
0842       for (int j = 0; j != 192; j++)
0843         if (numberOfDigis[j] > 0)
0844           meNDigisCHANEndcap_->Fill((float)numberOfDigis[j]);
0845     }
0846     if (meNDigisCHANEndcapDms_.at(0)) {
0847       for (int j = 0; j != 72; j++)
0848         if ((j < 24 || j > 47) && numberOfDigis[j] > 0)
0849           meNDigisCHANEndcapDms_.at(0)->Fill((float)numberOfDigis[j]);
0850     }
0851     if (meNDigisCHANEndcapDms_.at(1)) {
0852       for (int j = 24; j != 96; j++)
0853         if ((j < 48 || j > 71) && numberOfDigis[j] > 0)
0854           meNDigisCHANEndcapDms_.at(1)->Fill((float)numberOfDigis[j]);
0855     }
0856     if (meNDigisCHANEndcapDps_.at(0)) {
0857       for (int j = 96; j != 168; j++)
0858         if ((j < 120 || j > 143) && numberOfDigis[j] > 0)
0859           meNDigisCHANEndcapDps_.at(0)->Fill((float)numberOfDigis[j]);
0860     }
0861     if (meNDigisCHANEndcapDps_.at(1)) {
0862       for (int j = 120; j != 192; j++)
0863         if ((j < 144 || j > 167) && numberOfDigis[j] > 0)
0864           meNDigisCHANEndcapDps_.at(1)->Fill((float)numberOfDigis[j]);
0865     }
0866   } else if (noOfDisks == 3) {  // else if (isUpgrade)
0867     if (meNDigisCHANEndcap_) {
0868       for (int j = 0; j != 336; j++)
0869         if (numberOfDigis[j] > 0)
0870           meNDigisCHANEndcap_->Fill((float)numberOfDigis[j]);
0871     }
0872     if (meNDigisCHANEndcapDms_.at(0)) {
0873       for (int j = 0; j != 100; j++)
0874         if ((j < 22 || j > 65) && numberOfDigis[j] > 0)
0875           meNDigisCHANEndcapDms_.at(0)->Fill((float)numberOfDigis[j]);
0876     }
0877     if (meNDigisCHANEndcapDms_.at(1)) {
0878       for (int j = 22; j != 134; j++)
0879         if ((j < 44 || j > 99) && numberOfDigis[j] > 0)
0880           meNDigisCHANEndcapDms_.at(1)->Fill((float)numberOfDigis[j]);
0881     }
0882     if (meNDigisCHANEndcapDms_.at(2)) {
0883       for (int j = 44; j != 168; j++)
0884         if ((j < 66 || j > 133) && numberOfDigis[j] > 0)
0885           meNDigisCHANEndcapDms_.at(2)->Fill((float)numberOfDigis[j]);
0886     }
0887     if (meNDigisCHANEndcapDps_.at(0)) {
0888       for (int j = 168; j != 268; j++)
0889         if ((j < 190 || j > 233) && numberOfDigis[j] > 0)
0890           meNDigisCHANEndcapDps_.at(0)->Fill((float)numberOfDigis[j]);
0891     }
0892     if (meNDigisCHANEndcapDps_.at(1)) {
0893       for (int j = 190; j != 302; j++)
0894         if ((j < 212 || j > 267) && numberOfDigis[j] > 0)
0895           meNDigisCHANEndcapDps_.at(1)->Fill((float)numberOfDigis[j]);
0896     }
0897     if (meNDigisCHANEndcapDps_.at(2)) {
0898       for (int j = 212; j != 336; j++)
0899         if ((j < 234 || j > 301) && numberOfDigis[j] > 0)
0900           meNDigisCHANEndcapDps_.at(2)->Fill((float)numberOfDigis[j]);
0901     }
0902   }
0903 
0904   if (meNDigisCHANBarrelCh1_) {
0905     for (int i = 0; i != 32; i++)
0906       if (nDigisPerChan[i * 36 + 0] > 0)
0907         meNDigisCHANBarrelCh1_->Fill((float)nDigisPerChan[i * 36 + 0]);
0908   }
0909   if (meNDigisCHANBarrelCh2_) {
0910     for (int i = 0; i != 32; i++)
0911       if (nDigisPerChan[i * 36 + 1] > 0)
0912         meNDigisCHANBarrelCh2_->Fill((float)nDigisPerChan[i * 36 + 1]);
0913   }
0914   if (meNDigisCHANBarrelCh3_) {
0915     for (int i = 0; i != 32; i++)
0916       if (nDigisPerChan[i * 36 + 2] > 0)
0917         meNDigisCHANBarrelCh3_->Fill((float)nDigisPerChan[i * 36 + 2]);
0918   }
0919   if (meNDigisCHANBarrelCh4_) {
0920     for (int i = 0; i != 32; i++)
0921       if (nDigisPerChan[i * 36 + 3] > 0)
0922         meNDigisCHANBarrelCh4_->Fill((float)nDigisPerChan[i * 36 + 3]);
0923   }
0924   if (meNDigisCHANBarrelCh5_) {
0925     for (int i = 0; i != 32; i++)
0926       if (nDigisPerChan[i * 36 + 4] > 0)
0927         meNDigisCHANBarrelCh5_->Fill((float)nDigisPerChan[i * 36 + 4]);
0928   }
0929   if (meNDigisCHANBarrelCh6_) {
0930     for (int i = 0; i != 32; i++)
0931       if (nDigisPerChan[i * 36 + 5] > 0)
0932         meNDigisCHANBarrelCh6_->Fill((float)nDigisPerChan[i * 36 + 5]);
0933   }
0934   if (meNDigisCHANBarrelCh7_) {
0935     for (int i = 0; i != 32; i++)
0936       if (nDigisPerChan[i * 36 + 6] > 0)
0937         meNDigisCHANBarrelCh7_->Fill((float)nDigisPerChan[i * 36 + 6]);
0938   }
0939   if (meNDigisCHANBarrelCh8_) {
0940     for (int i = 0; i != 32; i++)
0941       if (nDigisPerChan[i * 36 + 7] > 0)
0942         meNDigisCHANBarrelCh8_->Fill((float)nDigisPerChan[i * 36 + 7]);
0943   }
0944   if (meNDigisCHANBarrelCh9_) {
0945     for (int i = 0; i != 32; i++)
0946       if (nDigisPerChan[i * 36 + 8] > 0)
0947         meNDigisCHANBarrelCh9_->Fill((float)nDigisPerChan[i * 36 + 8]);
0948   }
0949   if (meNDigisCHANBarrelCh10_) {
0950     for (int i = 0; i != 32; i++)
0951       if (nDigisPerChan[i * 36 + 9] > 0)
0952         meNDigisCHANBarrelCh10_->Fill((float)nDigisPerChan[i * 36 + 9]);
0953   }
0954   if (meNDigisCHANBarrelCh11_) {
0955     for (int i = 0; i != 32; i++)
0956       if (nDigisPerChan[i * 36 + 10] > 0)
0957         meNDigisCHANBarrelCh11_->Fill((float)nDigisPerChan[i * 36 + 10]);
0958   }
0959   if (meNDigisCHANBarrelCh12_) {
0960     for (int i = 0; i != 32; i++)
0961       if (nDigisPerChan[i * 36 + 11] > 0)
0962         meNDigisCHANBarrelCh12_->Fill((float)nDigisPerChan[i * 36 + 11]);
0963   }
0964   if (meNDigisCHANBarrelCh13_) {
0965     for (int i = 0; i != 32; i++)
0966       if (nDigisPerChan[i * 36 + 12] > 0)
0967         meNDigisCHANBarrelCh13_->Fill((float)nDigisPerChan[i * 36 + 12]);
0968   }
0969   if (meNDigisCHANBarrelCh14_) {
0970     for (int i = 0; i != 32; i++)
0971       if (nDigisPerChan[i * 36 + 13] > 0)
0972         meNDigisCHANBarrelCh14_->Fill((float)nDigisPerChan[i * 36 + 13]);
0973   }
0974   if (meNDigisCHANBarrelCh15_) {
0975     for (int i = 0; i != 32; i++)
0976       if (nDigisPerChan[i * 36 + 14] > 0)
0977         meNDigisCHANBarrelCh15_->Fill((float)nDigisPerChan[i * 36 + 14]);
0978   }
0979   if (meNDigisCHANBarrelCh16_) {
0980     for (int i = 0; i != 32; i++)
0981       if (nDigisPerChan[i * 36 + 15] > 0)
0982         meNDigisCHANBarrelCh16_->Fill((float)nDigisPerChan[i * 36 + 15]);
0983   }
0984   if (meNDigisCHANBarrelCh17_) {
0985     for (int i = 0; i != 32; i++)
0986       if (nDigisPerChan[i * 36 + 16] > 0)
0987         meNDigisCHANBarrelCh17_->Fill((float)nDigisPerChan[i * 36 + 16]);
0988   }
0989   if (meNDigisCHANBarrelCh18_) {
0990     for (int i = 0; i != 32; i++)
0991       if (nDigisPerChan[i * 36 + 17] > 0)
0992         meNDigisCHANBarrelCh18_->Fill((float)nDigisPerChan[i * 36 + 17]);
0993   }
0994   if (meNDigisCHANBarrelCh19_) {
0995     for (int i = 0; i != 32; i++)
0996       if (nDigisPerChan[i * 36 + 18] > 0)
0997         meNDigisCHANBarrelCh19_->Fill((float)nDigisPerChan[i * 36 + 18]);
0998   }
0999   if (meNDigisCHANBarrelCh20_) {
1000     for (int i = 0; i != 32; i++)
1001       if (nDigisPerChan[i * 36 + 19] > 0)
1002         meNDigisCHANBarrelCh20_->Fill((float)nDigisPerChan[i * 36 + 19]);
1003   }
1004   if (meNDigisCHANBarrelCh21_) {
1005     for (int i = 0; i != 32; i++)
1006       if (nDigisPerChan[i * 36 + 20] > 0)
1007         meNDigisCHANBarrelCh21_->Fill((float)nDigisPerChan[i * 36 + 20]);
1008   }
1009   if (meNDigisCHANBarrelCh22_) {
1010     for (int i = 0; i != 32; i++)
1011       if (nDigisPerChan[i * 36 + 21] > 0)
1012         meNDigisCHANBarrelCh22_->Fill((float)nDigisPerChan[i * 36 + 21]);
1013   }
1014   if (meNDigisCHANBarrelCh23_) {
1015     for (int i = 0; i != 32; i++)
1016       if (nDigisPerChan[i * 36 + 22] > 0)
1017         meNDigisCHANBarrelCh23_->Fill((float)nDigisPerChan[i * 36 + 22]);
1018   }
1019   if (meNDigisCHANBarrelCh24_) {
1020     for (int i = 0; i != 32; i++)
1021       if (nDigisPerChan[i * 36 + 23] > 0)
1022         meNDigisCHANBarrelCh24_->Fill((float)nDigisPerChan[i * 36 + 23]);
1023   }
1024   if (meNDigisCHANBarrelCh25_) {
1025     for (int i = 0; i != 32; i++)
1026       if (nDigisPerChan[i * 36 + 24] > 0)
1027         meNDigisCHANBarrelCh25_->Fill((float)nDigisPerChan[i * 36 + 24]);
1028   }
1029   if (meNDigisCHANBarrelCh26_) {
1030     for (int i = 0; i != 32; i++)
1031       if (nDigisPerChan[i * 36 + 25] > 0)
1032         meNDigisCHANBarrelCh26_->Fill((float)nDigisPerChan[i * 36 + 25]);
1033   }
1034   if (meNDigisCHANBarrelCh27_) {
1035     for (int i = 0; i != 32; i++)
1036       if (nDigisPerChan[i * 36 + 26] > 0)
1037         meNDigisCHANBarrelCh27_->Fill((float)nDigisPerChan[i * 36 + 26]);
1038   }
1039   if (meNDigisCHANBarrelCh28_) {
1040     for (int i = 0; i != 32; i++)
1041       if (nDigisPerChan[i * 36 + 27] > 0)
1042         meNDigisCHANBarrelCh28_->Fill((float)nDigisPerChan[i * 36 + 27]);
1043   }
1044   if (meNDigisCHANBarrelCh29_) {
1045     for (int i = 0; i != 32; i++)
1046       if (nDigisPerChan[i * 36 + 28] > 0)
1047         meNDigisCHANBarrelCh29_->Fill((float)nDigisPerChan[i * 36 + 28]);
1048   }
1049   if (meNDigisCHANBarrelCh30_) {
1050     for (int i = 0; i != 32; i++)
1051       if (nDigisPerChan[i * 36 + 29] > 0)
1052         meNDigisCHANBarrelCh30_->Fill((float)nDigisPerChan[i * 36 + 29]);
1053   }
1054   if (meNDigisCHANBarrelCh31_) {
1055     for (int i = 0; i != 32; i++)
1056       if (nDigisPerChan[i * 36 + 30] > 0)
1057         meNDigisCHANBarrelCh31_->Fill((float)nDigisPerChan[i * 36 + 30]);
1058   }
1059   if (meNDigisCHANBarrelCh32_) {
1060     for (int i = 0; i != 32; i++)
1061       if (nDigisPerChan[i * 36 + 31] > 0)
1062         meNDigisCHANBarrelCh32_->Fill((float)nDigisPerChan[i * 36 + 31]);
1063   }
1064   if (meNDigisCHANBarrelCh33_) {
1065     for (int i = 0; i != 32; i++)
1066       if (nDigisPerChan[i * 36 + 32] > 0)
1067         meNDigisCHANBarrelCh33_->Fill((float)nDigisPerChan[i * 36 + 32]);
1068   }
1069   if (meNDigisCHANBarrelCh34_) {
1070     for (int i = 0; i != 32; i++)
1071       if (nDigisPerChan[i * 36 + 33] > 0)
1072         meNDigisCHANBarrelCh34_->Fill((float)nDigisPerChan[i * 36 + 33]);
1073   }
1074   if (meNDigisCHANBarrelCh35_) {
1075     for (int i = 0; i != 32; i++)
1076       if (nDigisPerChan[i * 36 + 34] > 0)
1077         meNDigisCHANBarrelCh35_->Fill((float)nDigisPerChan[i * 36 + 34]);
1078   }
1079   if (meNDigisCHANBarrelCh36_) {
1080     for (int i = 0; i != 32; i++)
1081       if (nDigisPerChan[i * 36 + 35] > 0)
1082         meNDigisCHANBarrelCh36_->Fill((float)nDigisPerChan[i * 36 + 35]);
1083   }
1084 
1085   // Rate of events with >N digis:
1086   if (nEventDigis > bigEventSize) {
1087     if (bigEventRate)
1088       bigEventRate->Fill(lumiSection, 1. / 23.);
1089   }
1090 
1091   // Rate of pixel events and total number of pixel events per BX:
1092   if (nActiveModules >= 4) {
1093     if (pixEvtsPerBX)
1094       pixEvtsPerBX->Fill(float(bx));
1095     if (pixEventRate)
1096       pixEventRate->Fill(lumiSection, 1. / 23.);
1097   }
1098 
1099   if (slowDown)
1100     usleep(10000);
1101 }
1102 
1103 //------------------------------------------------------------------
1104 // Build data structure
1105 //------------------------------------------------------------------
1106 void SiPixelDigiSource::buildStructure(const edm::EventSetup& iSetup) {
1107   edm::ESHandle<TrackerTopology> tTopoHandle = iSetup.getHandle(trackerTopoTokenBeginRun_);
1108   const TrackerTopology* pTT = tTopoHandle.product();
1109 
1110   LogInfo("PixelDQM") << " SiPixelDigiSource::buildStructure";
1111   edm::ESHandle<TrackerGeometry> pDD = iSetup.getHandle(trackerGeomTokenBeginRun_);
1112 
1113   LogVerbatim("PixelDQM") << " *** Geometry node for TrackerGeom is  " << &(*pDD) << std::endl;
1114   LogVerbatim("PixelDQM") << " *** I have " << pDD->dets().size() << " detectors" << std::endl;
1115   LogVerbatim("PixelDQM") << " *** I have " << pDD->detTypes().size() << " types" << std::endl;
1116 
1117   for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
1118     if (dynamic_cast<PixelGeomDetUnit const*>((*it)) != nullptr) {
1119       DetId detId = (*it)->geographicalId();
1120       const GeomDetUnit* geoUnit = pDD->idToDetUnit(detId);
1121       const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
1122       int nrows = (pixDet->specificTopology()).nrows();
1123       int ncols = (pixDet->specificTopology()).ncolumns();
1124 
1125       if (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
1126         if (isPIB)
1127           continue;
1128         LogDebug("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
1129         uint32_t id = detId();
1130         int layer = PixelBarrelName(DetId(id), pTT, isUpgrade).layerName();
1131         if (layer > noOfLayers)
1132           noOfLayers = layer;
1133         SiPixelDigiModule* theModule = new SiPixelDigiModule(id, ncols, nrows);
1134         thePixelStructure.insert(pair<uint32_t, SiPixelDigiModule*>(id, theModule));
1135 
1136       } else if ((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade)) {
1137         LogDebug("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
1138         uint32_t id = detId();
1139         SiPixelDigiModule* theModule = new SiPixelDigiModule(id, ncols, nrows);
1140 
1141         PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(id), pTT, isUpgrade).halfCylinder();
1142         int disk = PixelEndcapName(DetId(id), pTT, isUpgrade).diskName();
1143         if (disk > noOfDisks)
1144           noOfDisks = disk;
1145         int blade = PixelEndcapName(DetId(id), pTT, isUpgrade).bladeName();
1146         int panel = PixelEndcapName(DetId(id), pTT, isUpgrade).pannelName();
1147         int module = PixelEndcapName(DetId(id), pTT, isUpgrade).plaquetteName();
1148 
1149         char sside[80];
1150         sprintf(sside, "HalfCylinder_%i", side);
1151         char sdisk[80];
1152         sprintf(sdisk, "Disk_%i", disk);
1153         char sblade[80];
1154         sprintf(sblade, "Blade_%02i", blade);
1155         char spanel[80];
1156         sprintf(spanel, "Panel_%i", panel);
1157         char smodule[80];
1158         sprintf(smodule, "Module_%i", module);
1159         std::string side_str = sside;
1160         std::string disk_str = sdisk;
1161         bool mask = side_str.find("HalfCylinder_1") != string::npos ||
1162                     side_str.find("HalfCylinder_2") != string::npos ||
1163                     side_str.find("HalfCylinder_4") != string::npos || disk_str.find("Disk_2") != string::npos;
1164         // clutch to take all of FPIX, but no BPIX:
1165         mask = false;
1166         if (isPIB && mask)
1167           continue;
1168 
1169         thePixelStructure.insert(pair<uint32_t, SiPixelDigiModule*>(id, theModule));
1170       } else if ((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade)) {
1171         LogDebug("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
1172         uint32_t id = detId();
1173         SiPixelDigiModule* theModule = new SiPixelDigiModule(id, ncols, nrows);
1174 
1175         PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(id), pTT, isUpgrade).halfCylinder();
1176         int disk = PixelEndcapName(DetId(id), pTT, isUpgrade).diskName();
1177         if (disk > noOfDisks)
1178           noOfDisks = disk;
1179         int blade = PixelEndcapName(DetId(id), pTT, isUpgrade).bladeName();
1180         int panel = PixelEndcapName(DetId(id), pTT, isUpgrade).pannelName();
1181         int module = PixelEndcapName(DetId(id), pTT, isUpgrade).plaquetteName();
1182 
1183         char sside[80];
1184         sprintf(sside, "HalfCylinder_%i", side);
1185         char sdisk[80];
1186         sprintf(sdisk, "Disk_%i", disk);
1187         char sblade[80];
1188         sprintf(sblade, "Blade_%02i", blade);
1189         char spanel[80];
1190         sprintf(spanel, "Panel_%i", panel);
1191         char smodule[80];
1192         sprintf(smodule, "Module_%i", module);
1193         std::string side_str = sside;
1194         std::string disk_str = sdisk;
1195         bool mask = side_str.find("HalfCylinder_1") != string::npos ||
1196                     side_str.find("HalfCylinder_2") != string::npos ||
1197                     side_str.find("HalfCylinder_4") != string::npos || disk_str.find("Disk_2") != string::npos;
1198         // clutch to take all of FPIX, but no BPIX:
1199         mask = false;
1200         if (isPIB && mask)
1201           continue;
1202 
1203         thePixelStructure.insert(pair<uint32_t, SiPixelDigiModule*>(id, theModule));
1204       }  //end_elseif(isUpgrade)
1205     }
1206   }
1207   LogInfo("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
1208 }
1209 //------------------------------------------------------------------
1210 // Book MEs
1211 //------------------------------------------------------------------
1212 void SiPixelDigiSource::bookMEs(DQMStore::IBooker& iBooker, const edm::EventSetup& iSetup) {
1213   // Get DQM interface
1214   iBooker.setCurrentFolder(topFolderName_);
1215   char title[80];
1216   sprintf(title, "Rate of events with >%i digis;LumiSection;Rate [Hz]", bigEventSize);
1217   bigEventRate = iBooker.book1D("bigEventRate", title, 5000, 0., 5000.);
1218   char title1[80];
1219   sprintf(title1, "Pixel events vs. BX;BX;# events");
1220   pixEvtsPerBX = iBooker.book1D("pixEvtsPerBX", title1, 3565, 0., 3565.);
1221   char title2[80];
1222   sprintf(title2, "Rate of Pixel events;LumiSection;Rate [Hz]");
1223   pixEventRate = iBooker.book1D("pixEventRate", title2, 5000, 0., 5000.);
1224   char title3[80];
1225   sprintf(title3, "Number of Zero-Occupancy Barrel ROCs;LumiSection;N_{ZERO-OCCUPANCY} Barrel ROCs");
1226   noOccROCsBarrel = iBooker.book1D("noOccROCsBarrel", title3, 500, 0., 5000.);
1227   char title4[80];
1228   sprintf(title4, "Number of Low-Efficiency Barrel ROCs;LumiSection;N_{LO EFF} Barrel ROCs");
1229   loOccROCsBarrel = iBooker.book1D("loOccROCsBarrel", title4, 500, 0., 5000.);
1230   char title5[80];
1231   sprintf(title5, "Number of Zero-Occupancy Endcap ROCs;LumiSection;N_{ZERO-OCCUPANCY} Endcap ROCs");
1232   noOccROCsEndcap = iBooker.book1D("noOccROCsEndcap", title5, 500, 0., 5000.);
1233   char title6[80];
1234   sprintf(title6, "Number of Low-Efficiency Endcap ROCs;LumiSection;N_{LO EFF} Endcap ROCs");
1235   loOccROCsEndcap = iBooker.book1D("loOccROCsEndcap", title6, 500, 0., 5000.);
1236   char title7[80];
1237   sprintf(title7, "Average digi occupancy per FED;FED;NDigis/<NDigis>");
1238   char title8[80];
1239   sprintf(title8, "FED Digi Occupancy (NDigis/<NDigis>) vs LumiSections;Lumi Section;FED");
1240   if (modOn) {
1241     {
1242       auto scope = DQMStore::IBooker::UseLumiScope(iBooker);
1243       averageDigiOccupancy = iBooker.bookProfile("averageDigiOccupancy", title7, 40, -0.5, 39.5, 0., 3.);
1244     }
1245     avgfedDigiOccvsLumi = iBooker.book2D("avgfedDigiOccvsLumi", title8, 640, 0., 3200., 40, -0.5, 39.5);
1246     avgBarrelFedOccvsLumi = iBooker.book1D(
1247         "avgBarrelFedOccvsLumi",
1248         "Average Barrel FED digi occupancy (<NDigis>) vs LumiSections;Lumi Section;Average digi occupancy per FED",
1249         320,
1250         0.,
1251         3200.);
1252     avgEndcapFedOccvsLumi = iBooker.book1D(
1253         "avgEndcapFedOccvsLumi",
1254         "Average Endcap FED digi occupancy (<NDigis>) vs LumiSections;Lumi Section;Average digi occupancy per FED",
1255         320,
1256         0.,
1257         3200.);
1258   }
1259   if (!modOn && !perLSsaving) {
1260     averageDigiOccupancy = iBooker.book1D(
1261         "averageDigiOccupancy", title7, 40, -0.5, 39.5);  //Book as TH1 for offline to ensure thread-safe behaviour
1262     avgfedDigiOccvsLumi = iBooker.book2D("avgfedDigiOccvsLumi", title8, 3200, 0., 3200., 40, -0.5, 39.5);
1263   }
1264   std::map<uint32_t, SiPixelDigiModule*>::iterator struct_iter;
1265 
1266   SiPixelFolderOrganizer theSiPixelFolder(false);
1267 
1268   edm::ESHandle<TrackerTopology> tTopoHandle = iSetup.getHandle(trackerTopoTokenBeginRun_);
1269   const TrackerTopology* pTT = tTopoHandle.product();
1270 
1271   for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
1272     /// Create folder tree and book histograms
1273     if (modOn) {
1274       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 0, isUpgrade)) {
1275         (*struct_iter).second->book(conf_, pTT, iBooker, 0, twoDimOn, hiRes, reducedSet, twoDimModOn, isUpgrade);
1276       } else {
1277         if (!isPIB)
1278           throw cms::Exception("LogicError") << "[SiPixelDigiSource::bookMEs] Creation of DQM folder failed";
1279       }
1280     }
1281     if (ladOn) {
1282       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 1, isUpgrade)) {
1283         (*struct_iter).second->book(conf_, pTT, iBooker, 1, twoDimOn, hiRes, reducedSet, isUpgrade);
1284       } else {
1285         LogDebug("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
1286       }
1287     }
1288     if (layOn || twoDimOnlyLayDisk) {
1289       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 2, isUpgrade)) {
1290         (*struct_iter).second->book(conf_, pTT, iBooker, 2, twoDimOn, hiRes, reducedSet, twoDimOnlyLayDisk, isUpgrade);
1291       } else {
1292         LogDebug("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
1293       }
1294     }
1295 
1296     if (phiOn) {
1297       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 3, isUpgrade)) {
1298         (*struct_iter).second->book(conf_, pTT, iBooker, 3, twoDimOn, hiRes, reducedSet, isUpgrade);
1299       } else {
1300         LogDebug("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
1301       }
1302     }
1303     if (bladeOn) {
1304       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 4, isUpgrade)) {
1305         (*struct_iter).second->book(conf_, pTT, iBooker, 4, twoDimOn, hiRes, reducedSet, isUpgrade);
1306       } else {
1307         LogDebug("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
1308       }
1309     }
1310     if (diskOn || twoDimOnlyLayDisk) {
1311       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 5, isUpgrade)) {
1312         (*struct_iter).second->book(conf_, pTT, iBooker, 5, twoDimOn, hiRes, reducedSet, twoDimOnlyLayDisk, isUpgrade);
1313       } else {
1314         LogDebug("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
1315       }
1316     }
1317     if (ringOn) {
1318       if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 6, isUpgrade)) {
1319         (*struct_iter).second->book(conf_, pTT, iBooker, 6, twoDimOn, hiRes, reducedSet, isUpgrade);
1320       } else {
1321         LogDebug("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
1322       }
1323     }
1324   }
1325   iBooker.cd(topFolderName_ + "/Barrel");
1326   meNDigisCOMBBarrel_ = iBooker.book1D("ALLMODS_ndigisCOMB_Barrel", "Number of Digis", 200, 0., 400.);
1327   meNDigisCOMBBarrel_->setAxisTitle("Number of digis per module per event", 1);
1328   meNDigisCHANBarrel_ = iBooker.book1D("ALLMODS_ndigisCHAN_Barrel", "Number of Digis", 100, 0., 1000.);
1329   meNDigisCHANBarrel_->setAxisTitle("Number of digis per FED channel per event", 1);
1330   std::stringstream ss1, ss2;
1331   for (int i = 1; i <= noOfLayers; i++) {
1332     ss1.str(std::string());
1333     ss1 << "ALLMODS_ndigisCHAN_BarrelL" << i;
1334     ss2.str(std::string());
1335     ss2 << "Number of Digis L" << i;
1336     meNDigisCHANBarrelLs_.push_back(iBooker.book1D(ss1.str(), ss2.str(), 100, 0., 1000.));
1337     meNDigisCHANBarrelLs_.at(i - 1)->setAxisTitle("Number of digis per FED channel per event", 1);
1338   }
1339   meNDigisCHANBarrelCh1_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh1", "Number of Digis Ch1", 100, 0., 1000.);
1340   meNDigisCHANBarrelCh1_->setAxisTitle("Number of digis per FED channel per event", 1);
1341   meNDigisCHANBarrelCh2_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh2", "Number of Digis Ch2", 100, 0., 1000.);
1342   meNDigisCHANBarrelCh2_->setAxisTitle("Number of digis per FED channel per event", 1);
1343   meNDigisCHANBarrelCh3_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh3", "Number of Digis Ch3", 100, 0., 1000.);
1344   meNDigisCHANBarrelCh3_->setAxisTitle("Number of digis per FED channel per event", 1);
1345   meNDigisCHANBarrelCh4_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh4", "Number of Digis Ch4", 100, 0., 1000.);
1346   meNDigisCHANBarrelCh4_->setAxisTitle("Number of digis per FED channel per event", 1);
1347   meNDigisCHANBarrelCh5_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh5", "Number of Digis Ch5", 100, 0., 1000.);
1348   meNDigisCHANBarrelCh5_->setAxisTitle("Number of digis per FED channel per event", 1);
1349   meNDigisCHANBarrelCh6_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh6", "Number of Digis Ch6", 100, 0., 1000.);
1350   meNDigisCHANBarrelCh6_->setAxisTitle("Number of digis per FED channel per event", 1);
1351   meNDigisCHANBarrelCh7_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh7", "Number of Digis Ch7", 100, 0., 1000.);
1352   meNDigisCHANBarrelCh7_->setAxisTitle("Number of digis per FED channel per event", 1);
1353   meNDigisCHANBarrelCh8_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh8", "Number of Digis Ch8", 100, 0., 1000.);
1354   meNDigisCHANBarrelCh8_->setAxisTitle("Number of digis per FED channel per event", 1);
1355   meNDigisCHANBarrelCh9_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh9", "Number of Digis Ch9", 100, 0., 1000.);
1356   meNDigisCHANBarrelCh9_->setAxisTitle("Number of digis per FED channel per event", 1);
1357   meNDigisCHANBarrelCh10_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh10", "Number of Digis Ch10", 100, 0., 1000.);
1358   meNDigisCHANBarrelCh10_->setAxisTitle("Number of digis per FED channel per event", 1);
1359   meNDigisCHANBarrelCh11_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh11", "Number of Digis Ch11", 100, 0., 1000.);
1360   meNDigisCHANBarrelCh11_->setAxisTitle("Number of digis per FED channel per event", 1);
1361   meNDigisCHANBarrelCh12_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh12", "Number of Digis Ch12", 100, 0., 1000.);
1362   meNDigisCHANBarrelCh12_->setAxisTitle("Number of digis per FED channel per event", 1);
1363   meNDigisCHANBarrelCh13_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh13", "Number of Digis Ch13", 100, 0., 1000.);
1364   meNDigisCHANBarrelCh13_->setAxisTitle("Number of digis per FED channel per event", 1);
1365   meNDigisCHANBarrelCh14_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh14", "Number of Digis Ch14", 100, 0., 1000.);
1366   meNDigisCHANBarrelCh14_->setAxisTitle("Number of digis per FED channel per event", 1);
1367   meNDigisCHANBarrelCh15_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh15", "Number of Digis Ch15", 100, 0., 1000.);
1368   meNDigisCHANBarrelCh15_->setAxisTitle("Number of digis per FED channel per event", 1);
1369   meNDigisCHANBarrelCh16_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh16", "Number of Digis Ch16", 100, 0., 1000.);
1370   meNDigisCHANBarrelCh16_->setAxisTitle("Number of digis per FED channel per event", 1);
1371   meNDigisCHANBarrelCh17_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh17", "Number of Digis Ch17", 100, 0., 1000.);
1372   meNDigisCHANBarrelCh17_->setAxisTitle("Number of digis per FED channel per event", 1);
1373   meNDigisCHANBarrelCh18_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh18", "Number of Digis Ch18", 100, 0., 1000.);
1374   meNDigisCHANBarrelCh18_->setAxisTitle("Number of digis per FED channel per event", 1);
1375   meNDigisCHANBarrelCh19_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh19", "Number of Digis Ch19", 100, 0., 1000.);
1376   meNDigisCHANBarrelCh19_->setAxisTitle("Number of digis per FED channel per event", 1);
1377   meNDigisCHANBarrelCh20_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh20", "Number of Digis Ch20", 100, 0., 1000.);
1378   meNDigisCHANBarrelCh20_->setAxisTitle("Number of digis per FED channel per event", 1);
1379   meNDigisCHANBarrelCh21_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh21", "Number of Digis Ch21", 100, 0., 1000.);
1380   meNDigisCHANBarrelCh21_->setAxisTitle("Number of digis per FED channel per event", 1);
1381   meNDigisCHANBarrelCh22_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh22", "Number of Digis Ch22", 100, 0., 1000.);
1382   meNDigisCHANBarrelCh22_->setAxisTitle("Number of digis per FED channel per event", 1);
1383   meNDigisCHANBarrelCh23_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh23", "Number of Digis Ch23", 100, 0., 1000.);
1384   meNDigisCHANBarrelCh23_->setAxisTitle("Number of digis per FED channel per event", 1);
1385   meNDigisCHANBarrelCh24_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh24", "Number of Digis Ch24", 100, 0., 1000.);
1386   meNDigisCHANBarrelCh24_->setAxisTitle("Number of digis per FED channel per event", 1);
1387   meNDigisCHANBarrelCh25_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh25", "Number of Digis Ch25", 100, 0., 1000.);
1388   meNDigisCHANBarrelCh25_->setAxisTitle("Number of digis per FED channel per event", 1);
1389   meNDigisCHANBarrelCh26_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh26", "Number of Digis Ch26", 100, 0., 1000.);
1390   meNDigisCHANBarrelCh26_->setAxisTitle("Number of digis per FED channel per event", 1);
1391   meNDigisCHANBarrelCh27_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh27", "Number of Digis Ch27", 100, 0., 1000.);
1392   meNDigisCHANBarrelCh27_->setAxisTitle("Number of digis per FED channel per event", 1);
1393   meNDigisCHANBarrelCh28_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh28", "Number of Digis Ch28", 100, 0., 1000.);
1394   meNDigisCHANBarrelCh28_->setAxisTitle("Number of digis per FED channel per event", 1);
1395   meNDigisCHANBarrelCh29_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh29", "Number of Digis Ch29", 100, 0., 1000.);
1396   meNDigisCHANBarrelCh29_->setAxisTitle("Number of digis per FED channel per event", 1);
1397   meNDigisCHANBarrelCh30_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh30", "Number of Digis Ch30", 100, 0., 1000.);
1398   meNDigisCHANBarrelCh30_->setAxisTitle("Number of digis per FED channel per event", 1);
1399   meNDigisCHANBarrelCh31_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh31", "Number of Digis Ch31", 100, 0., 1000.);
1400   meNDigisCHANBarrelCh31_->setAxisTitle("Number of digis per FED channel per event", 1);
1401   meNDigisCHANBarrelCh32_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh32", "Number of Digis Ch32", 100, 0., 1000.);
1402   meNDigisCHANBarrelCh32_->setAxisTitle("Number of digis per FED channel per event", 1);
1403   meNDigisCHANBarrelCh33_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh33", "Number of Digis Ch33", 100, 0., 1000.);
1404   meNDigisCHANBarrelCh33_->setAxisTitle("Number of digis per FED channel per event", 1);
1405   meNDigisCHANBarrelCh34_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh34", "Number of Digis Ch34", 100, 0., 1000.);
1406   meNDigisCHANBarrelCh34_->setAxisTitle("Number of digis per FED channel per event", 1);
1407   meNDigisCHANBarrelCh35_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh35", "Number of Digis Ch35", 100, 0., 1000.);
1408   meNDigisCHANBarrelCh35_->setAxisTitle("Number of digis per FED channel per event", 1);
1409   meNDigisCHANBarrelCh36_ = iBooker.book1D("ALLMODS_ndigisCHAN_BarrelCh36", "Number of Digis Ch36", 100, 0., 1000.);
1410   meNDigisCHANBarrelCh36_->setAxisTitle("Number of digis per FED channel per event", 1);
1411   iBooker.cd(topFolderName_ + "/Endcap");
1412   meNDigisCOMBEndcap_ = iBooker.book1D("ALLMODS_ndigisCOMB_Endcap", "Number of Digis", 200, 0., 400.);
1413   meNDigisCOMBEndcap_->setAxisTitle("Number of digis per module per event", 1);
1414   meNDigisCHANEndcap_ = iBooker.book1D("ALLMODS_ndigisCHAN_Endcap", "Number of Digis", 100, 0., 1000.);
1415   meNDigisCHANEndcap_->setAxisTitle("Number of digis per FED channel per event", 1);
1416   for (int i = 1; i <= noOfDisks; i++) {
1417     ss1.str(std::string());
1418     ss1 << "ALLMODS_ndigisCHAN_EndcapDp" << i;
1419     ss2.str(std::string());
1420     ss2 << "Number of Digis Disk p" << i;
1421     meNDigisCHANEndcapDps_.push_back(iBooker.book1D(ss1.str(), ss2.str(), 100, 0., 1000.));
1422     meNDigisCHANEndcapDps_.at(i - 1)->setAxisTitle("Number of digis per FED channel per event", 1);
1423   }
1424   for (int i = 1; i <= noOfDisks; i++) {
1425     ss1.str(std::string());
1426     ss1 << "ALLMODS_ndigisCHAN_EndcapDm" << i;
1427     ss2.str(std::string());
1428     ss2 << "Number of Digis Disk m" << i;
1429     meNDigisCHANEndcapDms_.push_back(iBooker.book1D(ss1.str(), ss2.str(), 100, 0., 1000.));
1430     meNDigisCHANEndcapDms_.at(i - 1)->setAxisTitle("Number of digis per FED channel per event", 1);
1431   }
1432   iBooker.cd(topFolderName_);
1433 }
1434 
1435 void SiPixelDigiSource::CountZeroROCsInSubstructure(bool barrel, bool& DoZeroRocs, SiPixelDigiModule* mod) {
1436   std::pair<int, int> tempPair = mod->getZeroLoEffROCs();
1437 
1438   if (barrel) {
1439     NzeroROCs[0] += tempPair.first;
1440     NloEffROCs[0] += tempPair.second;
1441   } else {
1442     NzeroROCs[1] += tempPair.first;
1443     NloEffROCs[1] += tempPair.second;
1444   }
1445 
1446   DoZeroRocs = false;
1447   mod->resetRocMap();  //once got the number of ZeroOccupancy Rocs, reset the ROC map of the corresponding Pixel substructure
1448 }
1449 
1450 //define this as a plug-in
1451 DEFINE_FWK_MODULE(SiPixelDigiSource);