File indexing completed on 2024-04-06 12:07:22
0001 #include "DQM/EcalMonitorTasks/interface/RecoSummaryTask.h"
0002
0003 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0004 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
0005 #include "DataFormats/EcalDetId/interface/EcalDetIdCollections.h"
0006 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0007
0008 #include "RecoEcal/EgammaCoreTools/interface/EcalTools.h"
0009 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
0010
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012
0013 namespace ecaldqm {
0014 RecoSummaryTask::RecoSummaryTask()
0015 : DQWorkerTask(),
0016 rechitThresholdEB_(0.),
0017 rechitThresholdEE_(0.),
0018 ebHits_(nullptr),
0019 eeHits_(nullptr),
0020 fillRecoFlagReduced_(true) {}
0021
0022 void RecoSummaryTask::setParams(edm::ParameterSet const& _params) {
0023 rechitThresholdEB_ = _params.getUntrackedParameter<double>("rechitThresholdEB");
0024 rechitThresholdEE_ = _params.getUntrackedParameter<double>("rechitThresholdEE");
0025 fillRecoFlagReduced_ = _params.getUntrackedParameter<bool>("fillRecoFlagReduced");
0026 if (!fillRecoFlagReduced_) {
0027 MEs_.erase(std::string("RecoFlagReduced"));
0028 }
0029 }
0030
0031 void RecoSummaryTask::addDependencies(DependencySet& _dependencies) {
0032 _dependencies.push_back(Dependency(kEBBasicCluster, kEBRecHit));
0033 _dependencies.push_back(Dependency(kEEBasicCluster, kEERecHit));
0034 }
0035
0036 bool RecoSummaryTask::filterRunType(short const* _runType) {
0037 for (unsigned iFED(0); iFED != ecaldqm::nDCC; iFED++) {
0038 if (_runType[iFED] == EcalDCCHeaderBlock::COSMIC || _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
0039 _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
0040 _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL || _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
0041 _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL)
0042 return true;
0043 }
0044
0045 return false;
0046 }
0047
0048 void RecoSummaryTask::endEvent(edm::Event const&, edm::EventSetup const&) {
0049 ebHits_ = nullptr;
0050 eeHits_ = nullptr;
0051 }
0052
0053 void RecoSummaryTask::runOnRecHits(EcalRecHitCollection const& _hits, Collections _collection) {
0054 bool isBarrel(_collection == kEBRecHit);
0055
0056 MESet& meEnergyMax(MEs_.at("EnergyMax"));
0057 MESet& meChi2(MEs_.at("Chi2"));
0058 MESet& meTime(MEs_.at("Time"));
0059 MESet* meSwissCross(isBarrel ? &MEs_.at("SwissCross") : nullptr);
0060 MESet& meRecoFlag(MEs_.at("RecoFlagAll"));
0061
0062 double maxE[2] = {-1., -1};
0063 int subdet(isBarrel ? EcalBarrel : EcalEndcap);
0064
0065 for (EcalRecHitCollection::const_iterator hitItr(_hits.begin()); hitItr != _hits.end(); ++hitItr) {
0066 meRecoFlag.fill(getEcalDQMSetupObjects(), subdet, hitItr->recoFlag());
0067 float energy(hitItr->energy());
0068
0069 int signedSubdet;
0070 float rechitThreshold;
0071
0072 if (isBarrel) {
0073 signedSubdet = EcalBarrel;
0074 rechitThreshold = rechitThresholdEB_;
0075
0076 if (energy > 3.) {
0077 EBDetId ebId(hitItr->id());
0078 if (ebId.ieta() != 85)
0079 meSwissCross->fill(getEcalDQMSetupObjects(), EcalTools::swissCross(ebId, _hits, 0.));
0080 }
0081
0082 if (energy > maxE[0])
0083 maxE[0] = energy;
0084 } else {
0085 rechitThreshold = rechitThresholdEE_;
0086
0087 EEDetId eeId(hitItr->id());
0088 if (eeId.zside() < 0) {
0089 signedSubdet = -EcalEndcap;
0090 if (energy > maxE[0])
0091 maxE[0] = energy;
0092 } else {
0093 signedSubdet = EcalEndcap;
0094 if (energy > maxE[1])
0095 maxE[1] = energy;
0096 }
0097 }
0098
0099 if (energy > rechitThreshold) {
0100 meChi2.fill(getEcalDQMSetupObjects(), signedSubdet, hitItr->chi2());
0101 meTime.fill(getEcalDQMSetupObjects(), signedSubdet, hitItr->time());
0102 }
0103 }
0104
0105 if (isBarrel) {
0106 meEnergyMax.fill(getEcalDQMSetupObjects(), EcalBarrel, maxE[0]);
0107
0108 ebHits_ = &_hits;
0109 } else {
0110 meEnergyMax.fill(getEcalDQMSetupObjects(), -EcalEndcap, maxE[0]);
0111 meEnergyMax.fill(getEcalDQMSetupObjects(), EcalEndcap, maxE[1]);
0112
0113 eeHits_ = &_hits;
0114 }
0115 }
0116
0117 void RecoSummaryTask::runOnReducedRecHits(EcalRecHitCollection const& _hits, Collections _collections) {
0118 MESet& meRecoFlag(MEs_.at("RecoFlagReduced"));
0119
0120 int subdet(_collections == kEBReducedRecHit ? EcalBarrel : EcalEndcap);
0121
0122 for (EcalRecHitCollection::const_iterator hitItr(_hits.begin()); hitItr != _hits.end(); ++hitItr)
0123 meRecoFlag.fill(getEcalDQMSetupObjects(), subdet, hitItr->recoFlag());
0124 }
0125
0126 void RecoSummaryTask::runOnBasicClusters(edm::View<reco::CaloCluster> const& _bcs, Collections _collection) {
0127 bool isBarrel(_collection == kEBBasicCluster);
0128
0129 MESet& meRecoFlag(MEs_.at("RecoFlagBasicCluster"));
0130
0131 EcalRecHitCollection const* hitCol(isBarrel ? ebHits_ : eeHits_);
0132 int subdet(isBarrel ? EcalBarrel : EcalEndcap);
0133
0134 for (edm::View<reco::CaloCluster>::const_iterator bcItr(_bcs.begin()); bcItr != _bcs.end(); ++bcItr) {
0135 if (bcItr->caloID().detectors() != 0) {
0136 if (isBarrel && !bcItr->caloID().detector(reco::CaloID::DET_ECAL_BARREL))
0137 continue;
0138 if (!isBarrel && !bcItr->caloID().detector(reco::CaloID::DET_ECAL_ENDCAP))
0139 continue;
0140 }
0141
0142 std::vector<std::pair<DetId, float> > const& haf(bcItr->hitsAndFractions());
0143 for (unsigned iH(0); iH != haf.size(); ++iH) {
0144 if (isBarrel && haf[iH].first.subdetId() != EcalBarrel)
0145 continue;
0146 if (!isBarrel && haf[iH].first.subdetId() != EcalEndcap)
0147 continue;
0148 EcalRecHitCollection::const_iterator hItr(hitCol->find(haf[iH].first));
0149 if (hItr == hitCol->end())
0150 continue;
0151 meRecoFlag.fill(getEcalDQMSetupObjects(), subdet, hItr->recoFlag());
0152 }
0153 }
0154 }
0155
0156 DEFINE_ECALDQM_WORKER(RecoSummaryTask);
0157 }