File indexing completed on 2024-04-06 12:07:36
0001 #include "DQM/HcalTasks/interface/RecoRunSummary.h"
0002
0003 namespace hcaldqm {
0004 using namespace constants;
0005
0006 RecoRunSummary::RecoRunSummary(std::string const& name,
0007 std::string const& taskname,
0008 edm::ParameterSet const& ps,
0009 edm::ConsumesCollector& iC)
0010 : DQClient(name, taskname, ps, iC) {
0011 _thresh_unihf = ps.getUntrackedParameter<double>("thresh_unihf", 0.2);
0012 _thresh_tcds = ps.getUntrackedParameter<double>("thresh_tcds", 1.5);
0013 }
0014
0015 void RecoRunSummary::beginRun(edm::Run const& r, edm::EventSetup const& es) {
0016 DQClient::beginRun(r, es);
0017 }
0018
0019
0020
0021
0022 void RecoRunSummary::endLuminosityBlock(DQMStore::IBooker& ib,
0023 DQMStore::IGetter& ig,
0024 edm::LuminosityBlock const& lb,
0025 edm::EventSetup const& es) {
0026 DQClient::endLuminosityBlock(ib, ig, lb, es);
0027 }
0028
0029
0030
0031
0032 std::vector<flag::Flag> RecoRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
0033 if (_ptype != fOffline)
0034 return std::vector<flag::Flag>();
0035
0036
0037 std::vector<uint32_t> vhashCrateHF;
0038 vhashCrateHF.push_back(HcalElectronicsId(22, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0039 vhashCrateHF.push_back(HcalElectronicsId(29, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0040 vhashCrateHF.push_back(HcalElectronicsId(32, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0041 filter::HashFilter filter_CrateHF;
0042 filter_CrateHF.initialize(filter::fPreserver, hashfunctions::fCrate,
0043 vhashCrateHF);
0044 electronicsmap::ElectronicsMap ehashmap;
0045 ehashmap.initialize(_emap, electronicsmap::fD2EHashMap);
0046 bool tcdsshift = false;
0047 std::vector<flag::Flag> vflags;
0048 vflags.resize(nRecoFlag);
0049 vflags[fUniSlotHF] = flag::Flag("UniSlotHF");
0050 vflags[fTCDS] = flag::Flag("TCDS");
0051
0052
0053 Container2D cOccupancy_depth, cOccupancyCut_depth;
0054 ContainerSingle2D cSummary;
0055 Container1D cTimingCut_HBHEPartition;
0056 ContainerXXX<double> xUniHF, xUni;
0057 xUni.initialize(hashfunctions::fCrate);
0058 xUniHF.initialize(hashfunctions::fCrateSlot);
0059 cOccupancy_depth.initialize(_taskname,
0060 "Occupancy",
0061 hashfunctions::fdepth,
0062 new quantity::DetectorQuantity(quantity::fieta),
0063 new quantity::DetectorQuantity(quantity::fiphi),
0064 new quantity::ValueQuantity(quantity::fN),
0065 0);
0066 cOccupancyCut_depth.initialize(_taskname,
0067 "OccupancyCut",
0068 hashfunctions::fdepth,
0069 new quantity::DetectorQuantity(quantity::fieta),
0070 new quantity::DetectorQuantity(quantity::fiphi),
0071 new quantity::ValueQuantity(quantity::fN),
0072 0);
0073 cTimingCut_HBHEPartition.initialize(_taskname,
0074 "TimingCut",
0075 hashfunctions::fHBHEPartition,
0076 new quantity::ValueQuantity(quantity::fTiming_ns),
0077 new quantity::ValueQuantity(quantity::fN),
0078 0);
0079
0080 cSummary.initialize(_name,
0081 "Summary",
0082 new quantity::CrateQuantity(_emap),
0083 new quantity::FlagQuantity(vflags),
0084 new quantity::ValueQuantity(quantity::fState),
0085 0);
0086
0087
0088 xUniHF.book(_emap, filter_CrateHF);
0089
0090
0091 cOccupancy_depth.load(ig, _emap, _subsystem);
0092 cOccupancyCut_depth.load(ig, _emap, _subsystem);
0093 cTimingCut_HBHEPartition.book(ib, _emap, _subsystem);
0094 cSummary.book(ib, _subsystem);
0095
0096
0097 std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
0098 for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
0099 if (!it->isHcalDetId())
0100 continue;
0101
0102 HcalDetId did(it->rawId());
0103 HcalElectronicsId eid = HcalElectronicsId(ehashmap.lookup(did));
0104
0105 if (did.subdet() == HcalForward)
0106 xUniHF.get(eid) += cOccupancyCut_depth.getBinContent(did);
0107 }
0108
0109
0110 for (doubleCompactMap::const_iterator it = xUniHF.begin(); it != xUniHF.end(); ++it) {
0111 uint32_t hash1 = it->first;
0112 HcalElectronicsId eid1(hash1);
0113 double x1 = it->second;
0114 for (doubleCompactMap::const_iterator jt = xUniHF.begin(); jt != xUniHF.end(); ++jt) {
0115 if (jt == it)
0116 continue;
0117
0118 double x2 = jt->second;
0119 if (x2 == 0)
0120 continue;
0121 if (x1 / x2 < _thresh_unihf)
0122 xUni.get(eid1)++;
0123 }
0124 }
0125
0126
0127 double a = cTimingCut_HBHEPartition.getMean(HcalDetId(HcalBarrel, 1, 5, 1));
0128 double b = cTimingCut_HBHEPartition.getMean(HcalDetId(HcalBarrel, 1, 30, 1));
0129 double c = cTimingCut_HBHEPartition.getMean(HcalDetId(HcalBarrel, 1, 55, 1));
0130 double dab = fabs(a - b);
0131 double dac = fabs(a - c);
0132 double dbc = fabs(b - c);
0133 if (dab >= _thresh_tcds || dac >= _thresh_tcds || dbc >= _thresh_tcds)
0134 tcdsshift = true;
0135
0136
0137 std::vector<flag::Flag> sumflags;
0138 for (std::vector<uint32_t>::const_iterator it = _vhashCrates.begin(); it != _vhashCrates.end(); ++it) {
0139 flag::Flag fSum("RECO");
0140 HcalElectronicsId eid(*it);
0141
0142
0143 if (HcalGenericDetId(_emap->lookup(eid)).isHcalZDCDetId()) {
0144 sumflags.push_back(fSum);
0145 continue;
0146 }
0147
0148 HcalDetId did = HcalDetId(_emap->lookup(eid));
0149
0150
0151 if (did.subdet() == HcalBarrel || did.subdet() == HcalEndcap) {
0152 if (tcdsshift)
0153 vflags[fTCDS]._state = flag::fBAD;
0154 else
0155 vflags[fTCDS]._state = flag::fGOOD;
0156 }
0157 if (did.subdet() == HcalForward) {
0158 if (xUni.get(eid) > 0)
0159 vflags[fUniSlotHF]._state = flag::fBAD;
0160 else
0161 vflags[fUniSlotHF]._state = flag::fGOOD;
0162 }
0163
0164
0165 int iflag = 0;
0166 for (std::vector<flag::Flag>::iterator ft = vflags.begin(); ft != vflags.end(); ++ft) {
0167 cSummary.setBinContent(eid, iflag, ft->_state);
0168 fSum += (*ft);
0169 iflag++;
0170 ft->reset();
0171 }
0172 sumflags.push_back(fSum);
0173 }
0174
0175 return sumflags;
0176 }
0177 }