File indexing completed on 2024-04-06 12:26:46
0001 #include "RecoMET/METProducers/interface/BeamHaloSummaryProducer.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003
0004
0005
0006
0007
0008
0009
0010
0011 using namespace edm;
0012 using namespace std;
0013 using namespace reco;
0014
0015 BeamHaloSummaryProducer::BeamHaloSummaryProducer(const edm::ParameterSet& iConfig) {
0016 IT_CSCHaloData = iConfig.getParameter<edm::InputTag>("CSCHaloDataLabel");
0017 IT_EcalHaloData = iConfig.getParameter<edm::InputTag>("EcalHaloDataLabel");
0018 IT_HcalHaloData = iConfig.getParameter<edm::InputTag>("HcalHaloDataLabel");
0019 IT_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
0020
0021 L_EcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("l_EcalPhiWedgeEnergy");
0022 L_EcalPhiWedgeConstituents = iConfig.getParameter<int>("l_EcalPhiWedgeConstituents");
0023 L_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_EcalPhiWedgeToF");
0024 L_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_EcalPhiWedgeConfidence");
0025 L_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("l_EcalShowerShapesRoundness");
0026 L_EcalShowerShapesAngle = (float)iConfig.getParameter<double>("l_EcalShowerShapesAngle");
0027 L_EcalSuperClusterSize = (int)iConfig.getParameter<int>("l_EcalSuperClusterSize");
0028 L_EcalSuperClusterEnergy = (float)iConfig.getParameter<double>("l_EcalSuperClusterEnergy");
0029
0030 T_EcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_EcalPhiWedgeEnergy");
0031 T_EcalPhiWedgeConstituents = iConfig.getParameter<int>("t_EcalPhiWedgeConstituents");
0032 T_EcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_EcalPhiWedgeToF");
0033 T_EcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_EcalPhiWedgeConfidence");
0034 T_EcalShowerShapesRoundness = (float)iConfig.getParameter<double>("t_EcalShowerShapesRoundness");
0035 T_EcalShowerShapesAngle = (float)iConfig.getParameter<double>("t_EcalShowerShapesAngle");
0036 T_EcalSuperClusterSize = (int)iConfig.getParameter<int>("t_EcalSuperClusterSize");
0037 T_EcalSuperClusterEnergy = (float)iConfig.getParameter<double>("t_EcalSuperClusterEnergy");
0038
0039 L_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("l_HcalPhiWedgeEnergy");
0040 L_HcalPhiWedgeConstituents = iConfig.getParameter<int>("l_HcalPhiWedgeConstituents");
0041 L_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("l_HcalPhiWedgeToF");
0042 L_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("l_HcalPhiWedgeConfidence");
0043
0044 T_HcalPhiWedgeEnergy = (float)iConfig.getParameter<double>("t_HcalPhiWedgeEnergy");
0045 T_HcalPhiWedgeConstituents = iConfig.getParameter<int>("t_HcalPhiWedgeConstituents");
0046 T_HcalPhiWedgeToF = (float)iConfig.getParameter<double>("t_HcalPhiWedgeToF");
0047 T_HcalPhiWedgeConfidence = (float)iConfig.getParameter<double>("t_HcalPhiWedgeConfidence");
0048
0049 problematicStripMinLength = (int)iConfig.getParameter<int>("problematicStripMinLength");
0050
0051 cschalodata_token_ = consumes<CSCHaloData>(IT_CSCHaloData);
0052 ecalhalodata_token_ = consumes<EcalHaloData>(IT_EcalHaloData);
0053 hcalhalodata_token_ = consumes<HcalHaloData>(IT_HcalHaloData);
0054 globalhalodata_token_ = consumes<GlobalHaloData>(IT_GlobalHaloData);
0055
0056 produces<BeamHaloSummary>();
0057 }
0058
0059 void BeamHaloSummaryProducer::produce(Event& iEvent, const EventSetup& iSetup) {
0060
0061 auto TheBeamHaloSummary = std::make_unique<BeamHaloSummary>();
0062
0063
0064 Handle<CSCHaloData> TheCSCHaloData;
0065
0066 iEvent.getByToken(cschalodata_token_, TheCSCHaloData);
0067
0068 const CSCHaloData CSCData = (*TheCSCHaloData.product());
0069
0070
0071 if (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() ||
0072 (CSCData.NOutOfTimeHits() > 10 && CSCData.NFlatHaloSegments() > 2) || CSCData.GetSegmentsInBothEndcaps() ||
0073 CSCData.NTracksSmalldT())
0074 TheBeamHaloSummary->GetCSCHaloReport()[0] = 1;
0075
0076
0077 if ((CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
0078 (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers()) ||
0079 (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks()) || CSCData.GetSegmentsInBothEndcaps() ||
0080 (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks()) ||
0081 (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks())))
0082 TheBeamHaloSummary->GetCSCHaloReport()[1] = 1;
0083
0084
0085 if (CSCData.NumberOfHaloTriggers() || CSCData.NumberOfHaloTracks() || CSCData.NumberOfOutOfTimeTriggers())
0086 TheBeamHaloSummary->GetCSCHaloReport()[2] = 1;
0087
0088
0089 if ((CSCData.NumberOfHaloTriggers() && CSCData.NumberOfHaloTracks()) ||
0090 (CSCData.NumberOfHaloTriggers() && CSCData.NumberOfOutOfTimeTriggers()) ||
0091 (CSCData.NumberOfHaloTracks() && CSCData.NumberOfOutOfTimeTriggers()))
0092 TheBeamHaloSummary->GetCSCHaloReport()[3] = 1;
0093
0094
0095 if ((CSCData.NumberOfHaloTriggers_TrkMuUnVeto() && CSCData.NumberOfHaloTracks()) ||
0096 (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTriggers_TrkMuUnVeto()) ||
0097 (CSCData.NOutOfTimeHits() > 10 && CSCData.NumberOfHaloTracks()) ||
0098 CSCData.GetSegmentsInBothEndcaps_Loose_TrkMuUnVeto() ||
0099 (CSCData.NTracksSmalldT() && CSCData.NumberOfHaloTracks()) ||
0100 (CSCData.NFlatHaloSegments() > 3 && (CSCData.NumberOfHaloTriggers_TrkMuUnVeto() || CSCData.NumberOfHaloTracks())))
0101 TheBeamHaloSummary->GetCSCHaloReport()[4] = 1;
0102
0103
0104 if ((CSCData.NumberOfHaloTriggers_TrkMuUnVeto() && CSCData.NFlatHaloSegments_TrkMuUnVeto()) ||
0105 CSCData.GetSegmentsInBothEndcaps_Loose_dTcut_TrkMuUnVeto() || CSCData.GetSegmentIsCaloMatched())
0106 TheBeamHaloSummary->GetCSCHaloReport()[5] = 1;
0107
0108
0109 Handle<EcalHaloData> TheEcalHaloData;
0110
0111 iEvent.getByToken(ecalhalodata_token_, TheEcalHaloData);
0112
0113 const EcalHaloData EcalData = (*TheEcalHaloData.product());
0114
0115 bool EcalLooseId = false, EcalTightId = false;
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
0151 edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
0152
0153
0154 for (unsigned int n = 0; n < EcalData.GetSuperClusters().size(); n++) {
0155 edm::Ref<SuperClusterCollection> cluster(EcalData.GetSuperClusters()[n]);
0156
0157 float angle = vm_Angle[cluster];
0158 float roundness = vm_Roundness[cluster];
0159
0160
0161 if ((angle > 0. && angle < L_EcalShowerShapesAngle) &&
0162 (roundness > 0. && roundness < L_EcalShowerShapesRoundness)) {
0163 if (cluster->energy() > L_EcalSuperClusterEnergy && cluster->size() > (unsigned int)L_EcalSuperClusterSize)
0164 EcalLooseId = true;
0165 }
0166
0167
0168 if ((angle > 0. && angle < T_EcalShowerShapesAngle) &&
0169 (roundness > 0. && roundness < T_EcalShowerShapesRoundness)) {
0170 if (cluster->energy() > T_EcalSuperClusterEnergy && cluster->size() > (unsigned int)T_EcalSuperClusterSize)
0171 EcalTightId = true;
0172 }
0173 }
0174
0175 if (EcalLooseId)
0176 TheBeamHaloSummary->GetEcalHaloReport()[0] = 1;
0177 if (EcalTightId)
0178 TheBeamHaloSummary->GetEcalHaloReport()[1] = 1;
0179
0180
0181 Handle<HcalHaloData> TheHcalHaloData;
0182
0183 iEvent.getByToken(hcalhalodata_token_, TheHcalHaloData);
0184
0185 const HcalHaloData HcalData = (*TheHcalHaloData.product());
0186 const std::vector<PhiWedge>& HcalWedges = HcalData.GetPhiWedges();
0187 bool HcalLooseId = false, HcalTightId = false;
0188 for (std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin(); iWedge != HcalWedges.end(); iWedge++) {
0189 bool HcaliPhi = false;
0190
0191 if (iWedge->Energy() > L_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > L_HcalPhiWedgeConstituents &&
0192 std::abs(iWedge->ZDirectionConfidence()) > L_HcalPhiWedgeConfidence) {
0193 HcalLooseId = true;
0194 HcaliPhi = true;
0195 }
0196
0197
0198 if (iWedge->Energy() > T_HcalPhiWedgeEnergy && iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents &&
0199 std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence) {
0200 HcalTightId = true;
0201 HcaliPhi = true;
0202 }
0203
0204 for (unsigned int i = 0; i < TheBeamHaloSummary->GetHcaliPhiSuspects().size(); i++) {
0205 if (iWedge->iPhi() == TheBeamHaloSummary->GetHcaliPhiSuspects()[i]) {
0206 HcaliPhi = false;
0207 continue;
0208 }
0209 }
0210 if (HcaliPhi)
0211 TheBeamHaloSummary->GetHcaliPhiSuspects().push_back(iWedge->iPhi());
0212 }
0213
0214 if (HcalLooseId)
0215 TheBeamHaloSummary->GetHcalHaloReport()[0] = 1;
0216 if (HcalTightId)
0217 TheBeamHaloSummary->GetHcalHaloReport()[1] = 1;
0218
0219 for (unsigned int i = 0; i < HcalData.getProblematicStrips().size(); i++) {
0220 auto const& problematicStrip = HcalData.getProblematicStrips()[i];
0221 if (problematicStrip.cellTowerIds.size() < (unsigned int)problematicStripMinLength)
0222 continue;
0223
0224 TheBeamHaloSummary->getProblematicStrips().push_back(problematicStrip);
0225 }
0226
0227
0228 Handle<GlobalHaloData> TheGlobalHaloData;
0229
0230 iEvent.getByToken(globalhalodata_token_, TheGlobalHaloData);
0231
0232 bool GlobalLooseId = false;
0233 bool GlobalTightId = false;
0234 const GlobalHaloData GlobalData = (*TheGlobalHaloData.product());
0235 const std::vector<PhiWedge>& MatchedHcalWedges = GlobalData.GetMatchedHcalPhiWedges();
0236 const std::vector<PhiWedge>& MatchedEcalWedges = GlobalData.GetMatchedEcalPhiWedges();
0237
0238
0239 if (!MatchedEcalWedges.empty() || !MatchedHcalWedges.empty())
0240 GlobalLooseId = true;
0241
0242
0243 for (std::vector<PhiWedge>::const_iterator iWedge = MatchedEcalWedges.begin(); iWedge != MatchedEcalWedges.end();
0244 iWedge++) {
0245 if (iWedge->NumberOfConstituents() > T_EcalPhiWedgeConstituents)
0246 GlobalTightId = true;
0247 if (std::abs(iWedge->ZDirectionConfidence()) > T_EcalPhiWedgeConfidence)
0248 GlobalTightId = true;
0249 }
0250
0251 for (std::vector<PhiWedge>::const_iterator iWedge = MatchedHcalWedges.begin(); iWedge != MatchedHcalWedges.end();
0252 iWedge++) {
0253 if (iWedge->NumberOfConstituents() > T_HcalPhiWedgeConstituents)
0254 GlobalTightId = true;
0255 if (std::abs(iWedge->ZDirectionConfidence()) > T_HcalPhiWedgeConfidence)
0256 GlobalTightId = true;
0257 }
0258
0259 if (GlobalLooseId)
0260 TheBeamHaloSummary->GetGlobalHaloReport()[0] = 1;
0261 if (GlobalTightId)
0262 TheBeamHaloSummary->GetGlobalHaloReport()[1] = 1;
0263
0264
0265 if ((GlobalData.GetSegmentIsEBCaloMatched() || GlobalData.GetHaloPatternFoundEB()) ||
0266 (GlobalData.GetSegmentIsEECaloMatched() || GlobalData.GetHaloPatternFoundEE()) ||
0267 (GlobalData.GetSegmentIsHBCaloMatched() || GlobalData.GetHaloPatternFoundHB()) ||
0268 (GlobalData.GetSegmentIsHECaloMatched() || GlobalData.GetHaloPatternFoundHE()))
0269 TheBeamHaloSummary->GetGlobalHaloReport()[2] = 1;
0270
0271
0272 if ((GlobalData.GetSegmentIsEBCaloMatched() && GlobalData.GetHaloPatternFoundEB()) ||
0273 (GlobalData.GetSegmentIsEECaloMatched() && GlobalData.GetHaloPatternFoundEE()) ||
0274 (GlobalData.GetSegmentIsHBCaloMatched() && GlobalData.GetHaloPatternFoundHB()) ||
0275 (GlobalData.GetSegmentIsHECaloMatched() && GlobalData.GetHaloPatternFoundHE()))
0276 TheBeamHaloSummary->GetGlobalHaloReport()[3] = 1;
0277
0278 iEvent.put(std::move(TheBeamHaloSummary));
0279 return;
0280 }
0281
0282 BeamHaloSummaryProducer::~BeamHaloSummaryProducer() {}