Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-07-08 02:28:43

0001 #include "DQM/HcalTasks/interface/ZDCQIE10Task.h"
0002 using namespace std;
0003 using namespace hcaldqm;
0004 using namespace hcaldqm::constants;
0005 using namespace hcaldqm::filter;
0006 
0007 ZDCQIE10Task::ZDCQIE10Task(edm::ParameterSet const& ps)
0008 
0009     : DQTask(ps), hcalDbServiceToken_(esConsumes<HcalDbService, HcalDbRecord, edm::Transition::BeginRun>()) {
0010   //tags
0011   _tagQIE10 = ps.getUntrackedParameter<edm::InputTag>("tagQIE10", edm::InputTag("hcalDigis", "ZDC"));
0012   _tokQIE10 = consumes<QIE10DigiCollection>(_tagQIE10);
0013 
0014   sumTag = ps.getUntrackedParameter<edm::InputTag>("etSumTag", edm::InputTag("etSumZdcProducer", ""));
0015   sumToken_ = consumes<l1t::EtSumBxCollection>(sumTag);
0016 
0017   htopoToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
0018   paramsToken_ = esConsumes<HcalLongRecoParams, HcalLongRecoParamsRcd>();
0019 }
0020 
0021 /* virtual */ void ZDCQIE10Task::bookHistograms(DQMStore::IBooker& ib, edm::Run const& r, edm::EventSetup const& es) {
0022   DQTask::bookHistograms(ib, r, es);
0023   ib.cd();
0024   edm::ESHandle<HcalDbService> dbs = es.getHandle(hcalDbServiceToken_);
0025   _emap = dbs->getHcalMapping();
0026   // Book LED calibration channels from emap
0027   std::vector<HcalElectronicsId> eids = _emap->allElectronicsId();
0028   _ehashmap.initialize(_emap, electronicsmap::fD2EHashMap);
0029 
0030   //    BOOK HISTOGRAMS
0031   std::string histoname;
0032   histoname = "Crate28";
0033   ib.setCurrentFolder("Hcal/ZDCQIE10Task/DigiSize");
0034   _cDigiSize_Crate[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 21, -0.5, 20.5);
0035   _cDigiSize_Crate[0]->setAxisTitle("DigiSize", 1);
0036   _cDigiSize_Crate[0]->setAxisTitle("N", 2);
0037 
0038   histoname = "FED1136";
0039   ib.setCurrentFolder("Hcal/ZDCQIE10Task/DigiSize");
0040   _cDigiSize_FED[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 21, -0.5, 20.5);
0041   _cDigiSize_FED[0]->setAxisTitle("DigiSize", 1);
0042   _cDigiSize_FED[0]->setAxisTitle("N", 2);
0043 
0044   histoname = "ZDCM";
0045   ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC");
0046   _cADC_PM[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0047   _cADC_PM[0]->setAxisTitle("ADC", 1);
0048   _cADC_PM[0]->setAxisTitle("N", 2);
0049 
0050   histoname = "ZDCP";
0051   ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC");
0052   _cADC_PM[1] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0053   _cADC_PM[1]->setAxisTitle("ADC", 1);
0054   _cADC_PM[1]->setAxisTitle("N", 2);
0055 
0056   histoname = "ZDCM";
0057   ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADCvsTS");
0058   _cADC_vs_TS_PM[0] = ib.book2DD(histoname.c_str(), histoname.c_str(), 6, 0, 6, 256, 0, 256);
0059   _cADC_vs_TS_PM[0]->setAxisTitle("TS", 1);
0060   _cADC_vs_TS_PM[0]->setAxisTitle("ADC", 2);
0061 
0062   histoname = "ZDCP";
0063   ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADCvsTS");
0064   _cADC_vs_TS_PM[1] = ib.book2DD(histoname.c_str(), histoname.c_str(), 6, 0, 6, 256, 0, 256);
0065   _cADC_vs_TS_PM[1]->setAxisTitle("TS", 1);
0066   _cADC_vs_TS_PM[1]->setAxisTitle("ADC", 2);
0067 
0068   histoname = "Crate28";
0069   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Occupancy/Crate");
0070   _cOccupancy_Crate[0] = ib.book2DD(histoname.c_str(), histoname.c_str(), 12, 0, 12, 144, 0, 144);
0071   _cOccupancy_Crate[0]->setAxisTitle("SlotuTCA", 1);
0072   _cOccupancy_Crate[0]->setAxisTitle("FiberuTCAFiberCh", 2);
0073 
0074   histoname = "Crate28S3";
0075   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Occupancy/CrateSlote");
0076   _cOccupancy_CrateSlot[0] = ib.book2DD(histoname.c_str(), histoname.c_str(), 24, 0, 24, 6, 0, 6);
0077   _cOccupancy_CrateSlot[0]->setAxisTitle("SlotuTCA", 1);
0078   _cOccupancy_CrateSlot[0]->setAxisTitle("FiberCh", 2);
0079 
0080   histoname = "uTCA_for_FED1136";
0081   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Occupancy/Electronics");
0082   _cOccupancy_ElectronicsuTCA[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 12, 0, 12);
0083   _cOccupancy_ElectronicsuTCA[0]->setAxisTitle("N", 1);
0084   _cOccupancy_ElectronicsuTCA[0]->setAxisTitle("SlotuTCA", 1);
0085 
0086   histoname = "ZDCP_Sum";
0087   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Sums");
0088   _cZDC_SUMS[1] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, -1, 5000);
0089   _cZDC_SUMS[1]->setAxisTitle("GeV", 1);
0090   _cZDC_SUMS[1]->setAxisTitle("N", 2);
0091 
0092   histoname = "ZDCM_Sum";
0093   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Sums");
0094   _cZDC_SUMS[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, -1, 5000);
0095   _cZDC_SUMS[0]->setAxisTitle("GeV", 1);
0096   _cZDC_SUMS[0]->setAxisTitle("N", 2);
0097 
0098   histoname = "ZDCM_SumBX";
0099   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Sums");
0100   _cZDC_BXSUMS[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 3500, 0, 3500);
0101   _cZDC_BXSUMS[0]->setAxisTitle("globalBX", 1);
0102   _cZDC_BXSUMS[0]->setAxisTitle("GeV", 2);
0103 
0104   histoname = "ZDCP_SumBX";
0105   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Sums");
0106   _cZDC_BXSUMS[1] = ib.book1DD(histoname.c_str(), histoname.c_str(), 3500, 0, 3500);
0107   _cZDC_BXSUMS[1]->setAxisTitle("globalBX", 1);
0108   _cZDC_BXSUMS[1]->setAxisTitle("GeV", 2);
0109 
0110   histoname = "ZDCM_EmuSumBX";
0111   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Sums");
0112   _cZDC_BX_EmuSUMS[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 3500, 0, 3500);
0113   _cZDC_BX_EmuSUMS[0]->setAxisTitle("globalBX", 1);
0114   _cZDC_BX_EmuSUMS[0]->setAxisTitle("0-255 weighted output", 2);
0115 
0116   histoname = "ZDCP_EmuSumBX";
0117   ib.setCurrentFolder("Hcal/ZDCQIE10Task/Sums");
0118   _cZDC_BX_EmuSUMS[1] = ib.book1DD(histoname.c_str(), histoname.c_str(), 3500, 0, 3500);
0119   _cZDC_BX_EmuSUMS[1]->setAxisTitle("globalBX", 1);
0120   _cZDC_BX_EmuSUMS[1]->setAxisTitle("0-255 weighted output", 2);
0121 
0122   histoname = "CapIDs";
0123   ib.setCurrentFolder("Hcal/ZDCQIE10Task");
0124   _cZDC_CapIDS[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 4, 0, 4);
0125   _cZDC_CapIDS[0]->setAxisTitle("CapID", 1);
0126   _cZDC_CapIDS[0]->setAxisTitle("N", 2);
0127 
0128   histoname = "EM_M_Timings";
0129   ib.setCurrentFolder("Hcal/ZDCQIE10Task");
0130   _cZDC_EM_TM[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 10, 1, 11);
0131   _cZDC_EM_TM[0]->setAxisTitle("Channel", 1);
0132   _cZDC_EM_TM[0]->setAxisTitle("N", 2);
0133   _cZDC_EM_TM[0]->setBinLabel(1, "EM_M_1 good timing");
0134   _cZDC_EM_TM[0]->setBinLabel(2, "EM_M_1 bad timing");
0135   _cZDC_EM_TM[0]->setBinLabel(3, "EM_M_2 good timing");
0136   _cZDC_EM_TM[0]->setBinLabel(4, "EM_M_2 bad timing");
0137   _cZDC_EM_TM[0]->setBinLabel(5, "EM_M_3 good timing");
0138   _cZDC_EM_TM[0]->setBinLabel(6, "EM_M_3 bad timing");
0139   _cZDC_EM_TM[0]->setBinLabel(7, "EM_M_4 good timing");
0140   _cZDC_EM_TM[0]->setBinLabel(8, "EM_M_4 bad timing");
0141   _cZDC_EM_TM[0]->setBinLabel(9, "EM_M_5 good timing");
0142   _cZDC_EM_TM[0]->setBinLabel(10, "EM_M_5 bad timing");
0143 
0144   histoname = "EM_P_Timings";
0145   ib.setCurrentFolder("Hcal/ZDCQIE10Task");
0146   _cZDC_EM_TM[1] = ib.book1DD(histoname.c_str(), histoname.c_str(), 10, 1, 11);
0147   _cZDC_EM_TM[1]->setAxisTitle("Channel", 1);
0148   _cZDC_EM_TM[1]->setAxisTitle("N", 2);
0149   _cZDC_EM_TM[1]->setBinLabel(1, "EM_P_1 good timing");
0150   _cZDC_EM_TM[1]->setBinLabel(2, "EM_P_1 bad timing");
0151   _cZDC_EM_TM[1]->setBinLabel(3, "EM_P_2 good timing");
0152   _cZDC_EM_TM[1]->setBinLabel(4, "EM_P_2 bad timing");
0153   _cZDC_EM_TM[1]->setBinLabel(5, "EM_P_3 good timing");
0154   _cZDC_EM_TM[1]->setBinLabel(6, "EM_P_3 bad timing");
0155   _cZDC_EM_TM[1]->setBinLabel(7, "EM_P_4 good timing");
0156   _cZDC_EM_TM[1]->setBinLabel(8, "EM_P_4 bad timing");
0157   _cZDC_EM_TM[1]->setBinLabel(9, "EM_P_5 good timing");
0158   _cZDC_EM_TM[1]->setBinLabel(10, "EM_P_5 bad timing");
0159 
0160   histoname = "HAD_M_Timings";
0161   ib.setCurrentFolder("Hcal/ZDCQIE10Task");
0162   _cZDC_HAD_TM[0] = ib.book1DD(histoname.c_str(), histoname.c_str(), 8, 1, 9);
0163   _cZDC_HAD_TM[0]->setAxisTitle("Channel", 1);
0164   _cZDC_HAD_TM[0]->setAxisTitle("N", 2);
0165   _cZDC_HAD_TM[0]->setBinLabel(1, "HAD_M_1 good timing");
0166   _cZDC_HAD_TM[0]->setBinLabel(2, "HAD_M_1 bad timing");
0167   _cZDC_HAD_TM[0]->setBinLabel(3, "HAD_M_2 good timing");
0168   _cZDC_HAD_TM[0]->setBinLabel(4, "HAD_M_2 bad timing");
0169   _cZDC_HAD_TM[0]->setBinLabel(5, "HAD_M_3 good timing");
0170   _cZDC_HAD_TM[0]->setBinLabel(6, "HAD_M_3 bad timing");
0171   _cZDC_HAD_TM[0]->setBinLabel(7, "HAD_M_4 good timing");
0172   _cZDC_HAD_TM[0]->setBinLabel(8, "HAD_M_4 bad timing");
0173 
0174   histoname = "HAD_P_Timings";
0175   ib.setCurrentFolder("Hcal/ZDCQIE10Task");
0176   _cZDC_HAD_TM[1] = ib.book1DD(histoname.c_str(), histoname.c_str(), 8, 1, 9);
0177   _cZDC_HAD_TM[1]->setAxisTitle("Channel", 1);
0178   _cZDC_HAD_TM[1]->setAxisTitle("N", 2);
0179   _cZDC_HAD_TM[1]->setBinLabel(1, "HAD_P_1 good timing");
0180   _cZDC_HAD_TM[1]->setBinLabel(2, "HAD_P_1 bad timing");
0181   _cZDC_HAD_TM[1]->setBinLabel(3, "HAD_P_2 good timing");
0182   _cZDC_HAD_TM[1]->setBinLabel(4, "HAD_P_2 bad timing");
0183   _cZDC_HAD_TM[1]->setBinLabel(5, "HAD_P_3 good timing");
0184   _cZDC_HAD_TM[1]->setBinLabel(6, "HAD_P_3 bad timing");
0185   _cZDC_HAD_TM[1]->setBinLabel(7, "HAD_P_4 good timing");
0186   _cZDC_HAD_TM[1]->setBinLabel(8, "HAD_P_4 bad timing");
0187 
0188   //book histos per channel
0189   //std::string histoname;
0190   for (int channel = 1; channel < 6; channel++) {
0191     // EM Pos
0192     HcalZDCDetId didp(HcalZDCDetId::EM, true, channel);
0193 
0194     histoname = "EM_P_" + std::to_string(channel);
0195     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0196     _cADC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0197     _cADC_EChannel[didp()]->setAxisTitle("ADC", 1);
0198     _cADC_EChannel[didp()]->setAxisTitle("N", 2);
0199     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0200     _cADC_vs_TS_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0201     _cADC_vs_TS_EChannel[didp()]->setAxisTitle("TS", 1);
0202     _cADC_vs_TS_EChannel[didp()]->setAxisTitle("sum ADC", 2);
0203 
0204     histoname = "EM_P_" + std::to_string(channel);
0205     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0206     _cfC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0207     _cfC_EChannel[didp()]->setAxisTitle("fC", 1);
0208     _cfC_EChannel[didp()]->setAxisTitle("N", 2);
0209     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0210     _cfC_vs_TS_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0211     _cfC_vs_TS_EChannel[didp()]->setAxisTitle("TS", 1);
0212     _cfC_vs_TS_EChannel[didp()]->setAxisTitle("sum fC", 2);
0213 
0214     histoname = "EM_P_" + std::to_string(channel);
0215     _cTDC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0216     _cTDC_EChannel[didp()]->setAxisTitle("TDC", 1);
0217     _cTDC_EChannel[didp()]->setAxisTitle("N", 2);
0218 
0219     // EM Minus
0220     HcalZDCDetId didm(HcalZDCDetId::EM, false, channel);
0221 
0222     histoname = "EM_M_" + std::to_string(channel);
0223     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0224     _cADC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0225     _cADC_EChannel[didm()]->setAxisTitle("ADC", 1);
0226     _cADC_EChannel[didm()]->setAxisTitle("N", 2);
0227     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0228     _cADC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0229     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0230     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("sum ADC", 2);
0231 
0232     histoname = "EM_M_" + std::to_string(channel);
0233     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0234     _cfC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0235     _cfC_EChannel[didm()]->setAxisTitle("fC", 1);
0236     _cfC_EChannel[didm()]->setAxisTitle("N", 2);
0237     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0238     _cfC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0239     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0240     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("sum fC", 2);
0241 
0242     histoname = "EM_M_" + std::to_string(channel);
0243     _cTDC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0244     _cTDC_EChannel[didm()]->setAxisTitle("TDC", 1);
0245     _cTDC_EChannel[didm()]->setAxisTitle("N", 2);
0246   }
0247 
0248   // adding 6 FSC channels on z- side (labeled as EM7_minus - EM12_minus)
0249   for (int channel = 7; channel < 13; channel++) {
0250     // EM Minus
0251     HcalZDCDetId didm(HcalZDCDetId::EM, false, channel);
0252 
0253     histoname = "EM_M_" + std::to_string(channel);
0254     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0255     _cADC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0256     _cADC_EChannel[didm()]->setAxisTitle("ADC", 1);
0257     _cADC_EChannel[didm()]->setAxisTitle("N", 2);
0258     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0259     _cADC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0260     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0261     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("sum ADC", 2);
0262 
0263     histoname = "EM_M_" + std::to_string(channel);
0264     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0265     _cfC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0266     _cfC_EChannel[didm()]->setAxisTitle("fC", 1);
0267     _cfC_EChannel[didm()]->setAxisTitle("N", 2);
0268     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0269     _cfC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0270     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0271     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("sum fC", 2);
0272 
0273     histoname = "EM_M_" + std::to_string(channel);
0274     _cTDC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0275     _cTDC_EChannel[didm()]->setAxisTitle("TDC", 1);
0276     _cTDC_EChannel[didm()]->setAxisTitle("N", 2);
0277   }
0278 
0279   for (int channel = 1; channel < 5; channel++) {
0280     // HAD Pos
0281     HcalZDCDetId didp(HcalZDCDetId::HAD, true, channel);
0282 
0283     histoname = "HAD_P_" + std::to_string(channel);
0284     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0285     _cADC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0286     _cADC_EChannel[didp()]->setAxisTitle("ADC", 1);
0287     _cADC_EChannel[didp()]->setAxisTitle("N", 2);
0288     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0289     _cADC_vs_TS_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0290     _cADC_vs_TS_EChannel[didp()]->setAxisTitle("TS", 1);
0291     _cADC_vs_TS_EChannel[didp()]->setAxisTitle("sum ADC", 2);
0292 
0293     histoname = "HAD_P_" + std::to_string(channel);
0294     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0295     _cfC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0296     _cfC_EChannel[didp()]->setAxisTitle("fC", 1);
0297     _cfC_EChannel[didp()]->setAxisTitle("N", 2);
0298     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0299     _cfC_vs_TS_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0300     _cfC_vs_TS_EChannel[didp()]->setAxisTitle("TS", 1);
0301     _cfC_vs_TS_EChannel[didp()]->setAxisTitle("sum fC", 2);
0302 
0303     histoname = "HAD_P_" + std::to_string(channel);
0304     _cTDC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0305     _cTDC_EChannel[didp()]->setAxisTitle("TDC", 1);
0306     _cTDC_EChannel[didp()]->setAxisTitle("N", 2);
0307 
0308     // HAD Minus
0309     HcalZDCDetId didm(HcalZDCDetId::HAD, false, channel);
0310 
0311     histoname = "HAD_M_" + std::to_string(channel);
0312     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0313     _cADC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0314     _cADC_EChannel[didm()]->setAxisTitle("ADC", 1);
0315     _cADC_EChannel[didm()]->setAxisTitle("N", 2);
0316     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0317     _cADC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0318     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0319     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("sum ADC", 2);
0320 
0321     histoname = "HAD_M_" + std::to_string(channel);
0322     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0323     _cfC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0324     _cfC_EChannel[didm()]->setAxisTitle("fC", 1);
0325     _cfC_EChannel[didm()]->setAxisTitle("N", 2);
0326     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0327     _cfC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0328     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0329     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("sum fC", 2);
0330 
0331     histoname = "HAD_M_" + std::to_string(channel);
0332     _cTDC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0333     _cTDC_EChannel[didm()]->setAxisTitle("TDC", 1);
0334     _cTDC_EChannel[didm()]->setAxisTitle("N", 2);
0335   }
0336 
0337   for (int channel = 1; channel < 17; channel++) {
0338     // RPD Pos
0339     HcalZDCDetId didp(HcalZDCDetId::RPD, true, channel);
0340 
0341     histoname = "RPD_P_" + std::to_string(channel);
0342     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0343     _cADC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0344     _cADC_EChannel[didp()]->setAxisTitle("ADC", 1);
0345     _cADC_EChannel[didp()]->setAxisTitle("N", 2);
0346     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0347     _cADC_vs_TS_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0348     _cADC_vs_TS_EChannel[didp()]->setAxisTitle("TS", 1);
0349     _cADC_vs_TS_EChannel[didp()]->setAxisTitle("sum ADC", 2);
0350 
0351     histoname = "RPD_P_" + std::to_string(channel);
0352     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0353     _cfC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0354     _cfC_EChannel[didp()]->setAxisTitle("fC", 1);
0355     _cfC_EChannel[didp()]->setAxisTitle("N", 2);
0356     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0357     _cfC_vs_TS_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0358     _cfC_vs_TS_EChannel[didp()]->setAxisTitle("TS", 1);
0359     _cfC_vs_TS_EChannel[didp()]->setAxisTitle("sum fC", 2);
0360 
0361     histoname = "RPD_P_" + std::to_string(channel);
0362     _cTDC_EChannel[didp()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0363     _cTDC_EChannel[didp()]->setAxisTitle("TDC", 1);
0364     _cTDC_EChannel[didp()]->setAxisTitle("N", 2);
0365 
0366     // RPD Minus
0367     HcalZDCDetId didm(HcalZDCDetId::RPD, false, channel);
0368     histoname = "RPD_M_" + std::to_string(channel);
0369 
0370     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_perChannel");
0371     _cADC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 256, 0, 256);
0372     _cADC_EChannel[didm()]->setAxisTitle("ADC", 1);
0373     _cADC_EChannel[didm()]->setAxisTitle("N", 2);
0374     ib.setCurrentFolder("Hcal/ZDCQIE10Task/ADC_vs_TS_perChannel");
0375     _cADC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0376     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0377     _cADC_vs_TS_EChannel[didm()]->setAxisTitle("sum ADC", 2);
0378 
0379     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_perChannel");
0380     _cfC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 100, 0, 8000);
0381     _cfC_EChannel[didm()]->setAxisTitle("fC", 1);
0382     _cfC_EChannel[didm()]->setAxisTitle("N", 2);
0383     ib.setCurrentFolder("Hcal/ZDCQIE10Task/fC_vs_TS_perChannel");
0384     _cfC_vs_TS_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 6, 0, 6);
0385     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("TS", 1);
0386     _cfC_vs_TS_EChannel[didm()]->setAxisTitle("sum fC", 2);
0387 
0388     histoname = "RPD_M_" + std::to_string(channel);
0389     _cTDC_EChannel[didm()] = ib.book1DD(histoname.c_str(), histoname.c_str(), 50, 1, 50);
0390     _cTDC_EChannel[didm()]->setAxisTitle("TDC", 1);
0391     _cTDC_EChannel[didm()]->setAxisTitle("N", 2);
0392   }
0393 }
0394 
0395 /* virtual */
0396 void ZDCQIE10Task::_process(edm::Event const& e, edm::EventSetup const& es) {
0397   const HcalTopology& htopo = es.getData(htopoToken_);
0398   const HcalLongRecoParams& p = es.getData(paramsToken_);
0399   longRecoParams_ = std::make_unique<HcalLongRecoParams>(p);
0400   longRecoParams_->setTopo(&htopo);
0401 
0402   int bx = e.bunchCrossing();
0403 
0404   edm::Handle<BXVector<l1t::EtSum> > sums;
0405   e.getByToken(sumToken_, sums);
0406 
0407   int startBX = sums->getFirstBX();
0408 
0409   for (int ibx = startBX; ibx <= sums->getLastBX(); ++ibx) {
0410     for (auto itr = sums->begin(ibx); itr != sums->end(ibx); ++itr) {
0411       l1t::EtSum::EtSumType type = itr->getType();
0412 
0413       if (type == l1t::EtSum::EtSumType::kZDCP) {
0414         if (ibx == 0)
0415           _cZDC_BX_EmuSUMS[1]->Fill(bx, itr->hwPt());
0416       }
0417       if (type == l1t::EtSum::EtSumType::kZDCM) {
0418         if (ibx == 0)
0419           _cZDC_BX_EmuSUMS[0]->Fill(bx, itr->hwPt());
0420       }
0421     }
0422   }
0423 
0424   edm::Handle<QIE10DigiCollection> digis;
0425   if (!e.getByToken(_tokQIE10, digis))
0426     edm::LogError("Collection QIE10DigiCollection for ZDC isn't available" + _tagQIE10.label() + " " +
0427                   _tagQIE10.instance());
0428 
0429   double HADM_sum = 0, HADP_sum = 0, EMM_sum = 0, EMP_sum = 0;
0430   double HADM_tot_sum = 0, HADP_tot_sum = 0, EMM_tot_sum = 0, EMP_tot_sum = 0;
0431 
0432   for (auto it = digis->begin(); it != digis->end(); it++) {
0433     const QIE10DataFrame digi = static_cast<const QIE10DataFrame>(*it);
0434 
0435     HcalZDCDetId const& did = digi.detid();
0436     bool isFSC = (did.zside() < 0 && did.section() == 1 && did.channel() > 6);
0437 
0438     uint32_t rawid = _ehashmap.lookup(did);
0439     if (rawid == 0) {
0440       continue;
0441     }
0442     HcalElectronicsId const& eid(rawid);
0443 
0444     _cDigiSize_Crate[0]->Fill(digi.samples());
0445 
0446     if (_ptype != fOffline) {  // hidefed2crate
0447 
0448       _cDigiSize_FED[0]->Fill(digi.samples());
0449 
0450       _cOccupancy_ElectronicsuTCA[0]->Fill(eid.slot());
0451     }
0452     if (_ptype == fOnline || _ptype == fLocal) {
0453       _cOccupancy_Crate[0]->Fill(eid.slot(), eid.fiberIndex());
0454       _cOccupancy_CrateSlot[0]->Fill(eid.slot(), eid.fiberChanId());
0455     }
0456 
0457     double sample_ZDCm_TS1 = 0, sample_ZDCp_TS1 = 0, sample_ZDCm_TS2 = 0, sample_ZDCp_TS2 = 0;
0458     double sample[2][6] = {{0}};
0459 
0460     for (int i = 0; i < digi.samples(); i++) {
0461       // ZDC Plus
0462       if (did.zside() > 0) {
0463         _cADC_PM[1]->Fill(digi[i].adc());
0464         _cADC_vs_TS_PM[1]->Fill(i, digi[i].adc());
0465         sample[1][i] = constants::adc2fC[digi[i].adc()];
0466         if (i == 1) {
0467           sample_ZDCp_TS1 = constants::adc2fC[digi[i].adc()];
0468         }
0469         if (i == 2) {
0470           sample_ZDCp_TS2 = constants::adc2fC[digi[i].adc()];
0471         }
0472 
0473       }
0474       // ZDC Minus (exclude FSC)
0475       else if (!isFSC) {
0476         _cADC_PM[0]->Fill(digi[i].adc());
0477         _cADC_vs_TS_PM[0]->Fill(i, digi[i].adc());
0478         sample[0][i] = constants::adc2fC[digi[i].adc()];
0479         if (i == 1) {
0480           sample_ZDCm_TS1 = constants::adc2fC[digi[i].adc()];
0481         }
0482         if (i == 2) {
0483           sample_ZDCm_TS2 = constants::adc2fC[digi[i].adc()];
0484         }
0485       }
0486 
0487       // iter over all samples
0488       if (_cADC_EChannel.find(did()) != _cADC_EChannel.end()) {
0489         _cADC_EChannel[did()]->Fill(digi[i].adc());
0490         _cfC_EChannel[did()]->Fill(constants::adc2fC[digi[i].adc()]);
0491         _cTDC_EChannel[did()]->Fill(digi[i].le_tdc());
0492       }
0493       if (_cADC_vs_TS_EChannel.find(did()) != _cADC_vs_TS_EChannel.end()) {
0494         _cADC_vs_TS_EChannel[did()]->Fill(i, digi[i].adc());
0495         _cfC_vs_TS_EChannel[did()]->Fill(i, constants::adc2fC[digi[i].adc()]);
0496       }
0497       _cZDC_CapIDS[0]->Fill(digi[i].capid());
0498     }
0499 
0500     if (did.section() == 1) {
0501       if ((did.channel() > 0) && (did.channel() < 6)) {
0502         EMM_sum += (sample_ZDCm_TS2 - sample_ZDCm_TS1);
0503         EMP_sum += (sample_ZDCp_TS2 - sample_ZDCp_TS1);
0504         for (int k = 0; k < 6; k++) {
0505           EMP_tot_sum += sample[1][k];
0506           EMM_tot_sum += sample[0][k];
0507         }
0508         if (did.zside() == -1) {
0509           if (sample[0][2] > (0.0 * EMM_tot_sum)) {
0510             _cZDC_EM_TM[0]->Fill((did.channel() * 2) - 1);
0511           } else {
0512             _cZDC_EM_TM[0]->Fill((did.channel() * 2));
0513           }
0514         }
0515         if (did.zside() == 1) {
0516           if (sample[1][2] > (0.0 * EMP_tot_sum)) {
0517             _cZDC_EM_TM[1]->Fill((did.channel() * 2) - 1);
0518           } else {
0519             _cZDC_EM_TM[1]->Fill((did.channel() * 2));
0520           }
0521         }
0522       }
0523     }
0524     if (did.section() == 2) {
0525       if ((did.channel() > 0) && (did.channel() < 5)) {
0526         HADP_sum += (sample_ZDCp_TS2 - sample_ZDCp_TS1);
0527         HADM_sum += (sample_ZDCm_TS2 - sample_ZDCm_TS1);
0528         for (int k = 0; k < 6; k++) {
0529           HADP_tot_sum += sample[1][k];
0530           HADM_tot_sum += sample[0][k];
0531         }
0532         if (did.zside() == -1) {
0533           if (sample[0][2] > (0.0 * HADM_tot_sum)) {
0534             _cZDC_HAD_TM[0]->Fill((did.channel() * 2) - 1);
0535           } else {
0536             _cZDC_HAD_TM[0]->Fill((did.channel() * 2));
0537           }
0538         }
0539         if (did.zside() == 1) {
0540           if (sample[1][2] > (0.0 * HADP_tot_sum)) {
0541             _cZDC_HAD_TM[1]->Fill((did.channel() * 2) - 1);
0542           } else {
0543             _cZDC_HAD_TM[1]->Fill((did.channel() * 2));
0544           }
0545         }
0546       }
0547     }
0548   }
0549 
0550   // Hardcoded callibrations currently
0551   _cZDC_SUMS[0]->Fill(((EMM_sum * 0.1) + HADM_sum) * 0.5031);
0552   _cZDC_SUMS[1]->Fill(((EMP_sum * 0.12) + HADP_sum) * 0.9397);
0553   _cZDC_BXSUMS[0]->Fill(bx, ((EMM_sum * 0.1) + HADM_sum) * 0.5031);
0554   _cZDC_BXSUMS[1]->Fill(bx, ((EMP_sum * 0.12) + HADP_sum) * 0.9397);
0555 }
0556 
0557 DEFINE_FWK_MODULE(ZDCQIE10Task);