File indexing completed on 2024-04-06 12:32:02
0001 #include "Validation/EcalClusters/interface/EgammaSuperClusters.h"
0002
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0009 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0010 #include "DataFormats/Math/interface/deltaPhi.h"
0011
0012 #include "DQMServices/Core/interface/DQMStore.h"
0013
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015
0016 EgammaSuperClusters::EgammaSuperClusters(const edm::ParameterSet &ps)
0017 : MCTruthCollectionToken_(consumes<edm::HepMCProduct>(ps.getParameter<edm::InputTag>("MCTruthCollection"))),
0018 barrelRawSuperClusterCollectionToken_(
0019 consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("barrelRawSuperClusterCollection"))),
0020 barrelCorSuperClusterCollectionToken_(
0021 consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("barrelCorSuperClusterCollection"))),
0022 endcapRawSuperClusterCollectionToken_(
0023 consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapRawSuperClusterCollection"))),
0024 endcapPreSuperClusterCollectionToken_(
0025 consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapPreSuperClusterCollection"))),
0026 endcapCorSuperClusterCollectionToken_(
0027 consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapCorSuperClusterCollection"))),
0028 barrelRecHitCollectionToken_(
0029 consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelRecHitCollection"))),
0030 endcapRecHitCollectionToken_(
0031 consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapRecHitCollection"))),
0032 ecalClusterToolsESGetTokens_{consumesCollector()},
0033 hsSize_(ps, "Size"),
0034 hsNumBC_(ps, "NumBC"),
0035 hsET_(ps, "ET"),
0036 hsEta_(ps, "Eta"),
0037 hsPhi_(ps, "Phi"),
0038 hsS1toS9_(ps, "S1toS9"),
0039 hsS25toE_(ps, "S25toE"),
0040 hsEoverTruth_(ps, "EoverTruth"),
0041 hsdeltaR_(ps, "deltaR"),
0042 hsphiWidth_(ps, "phiWidth"),
0043 hsetaWidth_(ps, "etaWidth"),
0044 hspreshowerE_(ps, "preshowerE"),
0045 hsR_(ps, "R"),
0046 hist_EB_RawSC_Size_(nullptr),
0047 hist_EE_RawSC_Size_(nullptr),
0048 hist_EB_CorSC_Size_(nullptr),
0049 hist_EE_CorSC_Size_(nullptr),
0050 hist_EE_PreSC_Size_(nullptr),
0051 hist_EB_RawSC_NumBC_(nullptr),
0052 hist_EE_RawSC_NumBC_(nullptr),
0053 hist_EB_CorSC_NumBC_(nullptr),
0054 hist_EE_CorSC_NumBC_(nullptr),
0055 hist_EE_PreSC_NumBC_(nullptr),
0056 hist_EB_RawSC_ET_(nullptr),
0057 hist_EE_RawSC_ET_(nullptr),
0058 hist_EB_CorSC_ET_(nullptr),
0059 hist_EE_CorSC_ET_(nullptr),
0060 hist_EE_PreSC_ET_(nullptr),
0061 hist_EB_RawSC_Eta_(nullptr),
0062 hist_EE_RawSC_Eta_(nullptr),
0063 hist_EB_CorSC_Eta_(nullptr),
0064 hist_EE_CorSC_Eta_(nullptr),
0065 hist_EE_PreSC_Eta_(nullptr),
0066 hist_EB_RawSC_Phi_(nullptr),
0067 hist_EE_RawSC_Phi_(nullptr),
0068 hist_EB_CorSC_Phi_(nullptr),
0069 hist_EE_CorSC_Phi_(nullptr),
0070 hist_EE_PreSC_Phi_(nullptr),
0071 hist_EB_RawSC_S1toS9_(nullptr),
0072 hist_EE_RawSC_S1toS9_(nullptr),
0073 hist_EB_CorSC_S1toS9_(nullptr),
0074 hist_EE_CorSC_S1toS9_(nullptr),
0075 hist_EE_PreSC_S1toS9_(nullptr),
0076 hist_EB_RawSC_S25toE_(nullptr),
0077 hist_EE_RawSC_S25toE_(nullptr),
0078 hist_EB_CorSC_S25toE_(nullptr),
0079 hist_EE_CorSC_S25toE_(nullptr),
0080 hist_EE_PreSC_S25toE_(nullptr),
0081 hist_EB_RawSC_EoverTruth_(nullptr),
0082 hist_EE_RawSC_EoverTruth_(nullptr),
0083 hist_EB_CorSC_EoverTruth_(nullptr),
0084 hist_EE_CorSC_EoverTruth_(nullptr),
0085 hist_EE_PreSC_EoverTruth_(nullptr),
0086 hist_EB_RawSC_deltaR_(nullptr),
0087 hist_EE_RawSC_deltaR_(nullptr),
0088 hist_EB_CorSC_deltaR_(nullptr),
0089 hist_EE_CorSC_deltaR_(nullptr),
0090 hist_EE_PreSC_deltaR_(nullptr),
0091 hist_EE_PreSC_preshowerE_(nullptr),
0092 hist_EE_CorSC_preshowerE_(nullptr),
0093 hist_EE_CorSC_phiWidth_(nullptr),
0094 hist_EB_CorSC_phiWidth_(nullptr),
0095 hist_EE_CorSC_etaWidth_(nullptr),
0096 hist_EB_CorSC_etaWidth_(nullptr),
0097 hist_EB_CorSC_ET_vs_Eta_(nullptr),
0098 hist_EB_CorSC_ET_vs_Phi_(nullptr),
0099 hist_EE_CorSC_ET_vs_Eta_(nullptr),
0100 hist_EE_CorSC_ET_vs_Phi_(nullptr),
0101 hist_EE_CorSC_ET_vs_R_(nullptr) {}
0102
0103 EgammaSuperClusters::~EgammaSuperClusters() {}
0104
0105 void EgammaSuperClusters::bookHistograms(DQMStore::IBooker &_ibooker, edm::Run const &, edm::EventSetup const &) {
0106 _ibooker.setCurrentFolder("EcalClusterV/EcalSuperClusters/");
0107
0108
0109
0110 hist_EB_RawSC_Size_ =
0111 _ibooker.book1D("hist_EB_RawSC_Size_", "# Raw SuperClusters in Barrel", hsSize_.bins, hsSize_.min, hsSize_.max);
0112 hist_EE_RawSC_Size_ =
0113 _ibooker.book1D("hist_EE_RawSC_Size_", "# Raw SuperClusters in Endcap", hsSize_.bins, hsSize_.min, hsSize_.max);
0114 hist_EB_CorSC_Size_ = _ibooker.book1D(
0115 "hist_EB_CorSC_Size_", "# Corrected SuperClusters in Barrel", hsSize_.bins, hsSize_.min, hsSize_.max);
0116 hist_EE_CorSC_Size_ = _ibooker.book1D(
0117 "hist_EE_CorSC_Size_", "# Corrected SuperClusters in Endcap", hsSize_.bins, hsSize_.min, hsSize_.max);
0118 hist_EE_PreSC_Size_ = _ibooker.book1D(
0119 "hist_EE_PreSC_Size_", "# SuperClusters with Preshower in Endcap", hsSize_.bins, hsSize_.min, hsSize_.max);
0120
0121
0122
0123 hist_EB_RawSC_NumBC_ = _ibooker.book1D("hist_EB_RawSC_NumBC_",
0124 "# of Basic Clusters in Raw Super Clusters in Barrel",
0125 hsNumBC_.bins,
0126 hsNumBC_.min,
0127 hsNumBC_.max);
0128 hist_EE_RawSC_NumBC_ = _ibooker.book1D("hist_EE_RawSC_NumBC_",
0129 "# of Basic Clusters in Raw Super Clusters in Endcap",
0130 hsNumBC_.bins,
0131 hsNumBC_.min,
0132 hsNumBC_.max);
0133 hist_EB_CorSC_NumBC_ = _ibooker.book1D("hist_EB_CorSC_NumBC_",
0134 "# of Basic Clusters in Corrected SuperClusters in Barrel",
0135 hsNumBC_.bins,
0136 hsNumBC_.min,
0137 hsNumBC_.max);
0138 hist_EE_CorSC_NumBC_ = _ibooker.book1D("hist_EE_CorSC_NumBC_",
0139 "# of Basic Clusters in Corrected SuperClusters in Endcap",
0140 hsNumBC_.bins,
0141 hsNumBC_.min,
0142 hsNumBC_.max);
0143 hist_EE_PreSC_NumBC_ = _ibooker.book1D("hist_EE_PreSC_NumBC_",
0144 "# of Basic Clusters in SuperClusters with Preshower in Endcap",
0145 hsNumBC_.bins,
0146 hsNumBC_.min,
0147 hsNumBC_.max);
0148
0149
0150
0151 hist_EB_RawSC_ET_ =
0152 _ibooker.book1D("hist_EB_RawSC_ET_", "ET of Raw SuperClusters in Barrel", hsET_.bins, hsET_.min, hsET_.max);
0153 hist_EE_RawSC_ET_ =
0154 _ibooker.book1D("hist_EE_RawSC_ET_", "ET of Raw SuperClusters in Endcap", hsET_.bins, hsET_.min, hsET_.max);
0155 hist_EB_CorSC_ET_ =
0156 _ibooker.book1D("hist_EB_CorSC_ET_", "ET of Corrected SuperClusters in Barrel", hsET_.bins, hsET_.min, hsET_.max);
0157 hist_EE_CorSC_ET_ =
0158 _ibooker.book1D("hist_EE_CorSC_ET_", "ET of Corrected SuperClusters in Endcap", hsET_.bins, hsET_.min, hsET_.max);
0159 hist_EE_PreSC_ET_ = _ibooker.book1D(
0160 "hist_EE_PreSC_ET_", "ET of SuperClusters with Preshower in Endcap", hsET_.bins, hsET_.min, hsET_.max);
0161
0162
0163
0164 hist_EB_RawSC_Eta_ =
0165 _ibooker.book1D("hist_EB_RawSC_Eta_", "Eta of Raw SuperClusters in Barrel", hsEta_.bins, hsEta_.min, hsEta_.max);
0166 hist_EE_RawSC_Eta_ =
0167 _ibooker.book1D("hist_EE_RawSC_Eta_", "Eta of Raw SuperClusters in Endcap", hsEta_.bins, hsEta_.min, hsEta_.max);
0168 hist_EB_CorSC_Eta_ = _ibooker.book1D(
0169 "hist_EB_CorSC_Eta_", "Eta of Corrected SuperClusters in Barrel", hsEta_.bins, hsEta_.min, hsEta_.max);
0170 hist_EE_CorSC_Eta_ = _ibooker.book1D(
0171 "hist_EE_CorSC_Eta_", "Eta of Corrected SuperClusters in Endcap", hsEta_.bins, hsEta_.min, hsEta_.max);
0172 hist_EE_PreSC_Eta_ = _ibooker.book1D(
0173 "hist_EE_PreSC_Eta_", "Eta of SuperClusters with Preshower in Endcap", hsEta_.bins, hsEta_.min, hsEta_.max);
0174
0175
0176
0177 hist_EB_RawSC_Phi_ =
0178 _ibooker.book1D("hist_EB_RawSC_Phi_", "Phi of Raw SuperClusters in Barrel", hsPhi_.bins, hsPhi_.min, hsPhi_.max);
0179 hist_EE_RawSC_Phi_ =
0180 _ibooker.book1D("hist_EE_RawSC_Phi_", "Phi of Raw SuperClusters in Endcap", hsPhi_.bins, hsPhi_.min, hsPhi_.max);
0181 hist_EB_CorSC_Phi_ = _ibooker.book1D(
0182 "hist_EB_CorSC_Phi_", "Phi of Corrected SuperClusters in Barrel", hsPhi_.bins, hsPhi_.min, hsPhi_.max);
0183 hist_EE_CorSC_Phi_ = _ibooker.book1D(
0184 "hist_EE_CorSC_Phi_", "Phi of Corrected SuperClusters in Endcap", hsPhi_.bins, hsPhi_.min, hsPhi_.max);
0185 hist_EE_PreSC_Phi_ = _ibooker.book1D(
0186 "hist_EE_PreSC_Phi_", "Phi of SuperClusters with Preshower in Endcap", hsPhi_.bins, hsPhi_.min, hsPhi_.max);
0187
0188
0189
0190 hist_EB_RawSC_S1toS9_ = _ibooker.book1D(
0191 "hist_EB_RawSC_S1toS9_", "S1/S9 of Raw Super Clusters in Barrel", hsS1toS9_.bins, hsS1toS9_.min, hsS1toS9_.max);
0192 hist_EE_RawSC_S1toS9_ = _ibooker.book1D(
0193 "hist_EE_RawSC_S1toS9_", "S1/S9 of Raw Super Clusters in Endcap", hsS1toS9_.bins, hsS1toS9_.min, hsS1toS9_.max);
0194 hist_EB_CorSC_S1toS9_ = _ibooker.book1D("hist_EB_CorSC_S1toS9_",
0195 "S1/S9 of Corrected SuperClusters in Barrel",
0196 hsS1toS9_.bins,
0197 hsS1toS9_.min,
0198 hsS1toS9_.max);
0199 hist_EE_CorSC_S1toS9_ = _ibooker.book1D("hist_EE_CorSC_S1toS9_",
0200 "S1/S9 of Corrected SuperClusters in Endcap",
0201 hsS1toS9_.bins,
0202 hsS1toS9_.min,
0203 hsS1toS9_.max);
0204 hist_EE_PreSC_S1toS9_ = _ibooker.book1D("hist_EE_PreSC_S1toS9_",
0205 "S1/S9 of SuperClusters with Preshower in Endcap",
0206 hsS1toS9_.bins,
0207 hsS1toS9_.min,
0208 hsS1toS9_.max);
0209
0210
0211
0212 hist_EB_RawSC_S25toE_ = _ibooker.book1D(
0213 "hist_EB_RawSC_S25toE_", "S25/E of Raw Super Clusters in Barrel", hsS25toE_.bins, hsS25toE_.min, hsS25toE_.max);
0214 hist_EE_RawSC_S25toE_ = _ibooker.book1D(
0215 "hist_EE_RawSC_S25toE_", "S25/E of Raw Super Clusters in Endcap", hsS25toE_.bins, hsS25toE_.min, hsS25toE_.max);
0216 hist_EB_CorSC_S25toE_ = _ibooker.book1D("hist_EB_CorSC_S25toE_",
0217 "S25/E of Corrected SuperClusters in Barrel",
0218 hsS25toE_.bins,
0219 hsS25toE_.min,
0220 hsS25toE_.max);
0221 hist_EE_CorSC_S25toE_ = _ibooker.book1D("hist_EE_CorSC_S25toE_",
0222 "S25/E of Corrected SuperClusters in Endcap",
0223 hsS25toE_.bins,
0224 hsS25toE_.min,
0225 hsS25toE_.max);
0226 hist_EE_PreSC_S25toE_ = _ibooker.book1D("hist_EE_PreSC_S25toE_",
0227 "S25/E of SuperClusters with Preshower in Endcap",
0228 hsS25toE_.bins,
0229 hsS25toE_.min,
0230 hsS25toE_.max);
0231
0232
0233
0234 hist_EB_RawSC_EoverTruth_ = _ibooker.book1D("hist_EB_RawSC_EoverTruth_",
0235 "E/True E of Raw SuperClusters in Barrel",
0236 hsEoverTruth_.bins,
0237 hsEoverTruth_.min,
0238 hsEoverTruth_.max);
0239 hist_EE_RawSC_EoverTruth_ = _ibooker.book1D("hist_EE_RawSC_EoverTruth_",
0240 "E/True E of Raw SuperClusters in Endcap",
0241 hsEoverTruth_.bins,
0242 hsEoverTruth_.min,
0243 hsEoverTruth_.max);
0244 hist_EB_CorSC_EoverTruth_ = _ibooker.book1D("hist_EB_CorSC_EoverTruth_",
0245 "E/True E of Corrected SuperClusters in Barrel",
0246 hsEoverTruth_.bins,
0247 hsEoverTruth_.min,
0248 hsEoverTruth_.max);
0249 hist_EE_CorSC_EoverTruth_ = _ibooker.book1D("hist_EE_CorSC_EoverTruth_",
0250 "E/True E of Corrected SuperClusters in Endcap",
0251 hsEoverTruth_.bins,
0252 hsEoverTruth_.min,
0253 hsEoverTruth_.max);
0254 hist_EE_PreSC_EoverTruth_ = _ibooker.book1D("hist_EE_PreSC_EoverTruth_",
0255 "E/True E of SuperClusters with Preshower in Endcap",
0256 hsEoverTruth_.bins,
0257 hsEoverTruth_.min,
0258 hsEoverTruth_.max);
0259
0260
0261
0262 hist_EB_RawSC_deltaR_ = _ibooker.book1D("hist_EB_RawSC_deltaR_",
0263 "dR to MC truth of Raw Super Clusters in Barrel",
0264 hsdeltaR_.bins,
0265 hsdeltaR_.min,
0266 hsdeltaR_.max);
0267 hist_EE_RawSC_deltaR_ = _ibooker.book1D("hist_EE_RawSC_deltaR_",
0268 "dR to MC truth of Raw Super Clusters in Endcap",
0269 hsdeltaR_.bins,
0270 hsdeltaR_.min,
0271 hsdeltaR_.max);
0272 hist_EB_CorSC_deltaR_ = _ibooker.book1D("hist_EB_CorSC_deltaR_",
0273 "dR to MC truth of Corrected SuperClusters in Barrel",
0274 hsdeltaR_.bins,
0275 hsdeltaR_.min,
0276 hsdeltaR_.max);
0277 hist_EE_CorSC_deltaR_ = _ibooker.book1D("hist_EE_CorSC_deltaR_",
0278 "dR to MC truth of Corrected SuperClusters in Endcap",
0279 hsdeltaR_.bins,
0280 hsdeltaR_.min,
0281 hsdeltaR_.max);
0282 hist_EE_PreSC_deltaR_ = _ibooker.book1D("hist_EE_PreSC_deltaR_",
0283 "dR to MC truth of SuperClusters with Preshower in Endcap",
0284 hsdeltaR_.bins,
0285 hsdeltaR_.min,
0286 hsdeltaR_.max);
0287
0288
0289 hist_EB_CorSC_phiWidth_ = _ibooker.book1D("hist_EB_CorSC_phiWidth_",
0290 "phiWidth of Corrected Super Clusters in Barrel",
0291 hsphiWidth_.bins,
0292 hsphiWidth_.min,
0293 hsphiWidth_.max);
0294 hist_EE_CorSC_phiWidth_ = _ibooker.book1D("hist_EE_CorSC_phiWidth_",
0295 "phiWidth of Corrected Super Clusters in Endcap",
0296 hsphiWidth_.bins,
0297 hsphiWidth_.min,
0298 hsphiWidth_.max);
0299
0300
0301 hist_EB_CorSC_etaWidth_ = _ibooker.book1D("hist_EB_CorSC_etaWidth_",
0302 "etaWidth of Corrected Super Clusters in Barrel",
0303 hsetaWidth_.bins,
0304 hsetaWidth_.min,
0305 hsetaWidth_.max);
0306 hist_EE_CorSC_etaWidth_ = _ibooker.book1D("hist_EE_CorSC_etaWidth_",
0307 "etaWidth of Corrected Super Clusters in Endcap",
0308 hsetaWidth_.bins,
0309 hsetaWidth_.min,
0310 hsetaWidth_.max);
0311
0312
0313 hist_EE_PreSC_preshowerE_ = _ibooker.book1D("hist_EE_PreSC_preshowerE_",
0314 "preshower energy in Super Clusters with Preshower in Endcap",
0315 hspreshowerE_.bins,
0316 hspreshowerE_.min,
0317 hspreshowerE_.max);
0318 hist_EE_CorSC_preshowerE_ = _ibooker.book1D("hist_EE_CorSC_preshowerE_",
0319 "preshower energy in Corrected Super Clusters with Preshower in Endcap",
0320 hspreshowerE_.bins,
0321 hspreshowerE_.min,
0322 hspreshowerE_.max);
0323
0324
0325 hist_EB_CorSC_ET_vs_Eta_ = _ibooker.book2D("hist_EB_CorSC_ET_vs_Eta_",
0326 "Corr Super Cluster ET versus Eta in Barrel",
0327 hsET_.bins,
0328 hsET_.min,
0329 hsET_.max,
0330 hsEta_.bins,
0331 hsEta_.min,
0332 hsEta_.max);
0333
0334 hist_EB_CorSC_ET_vs_Phi_ = _ibooker.book2D("hist_EB_CorSC_ET_vs_Phi_",
0335 "Corr Super Cluster ET versus Phi in Barrel",
0336 hsET_.bins,
0337 hsET_.min,
0338 hsET_.max,
0339 hsPhi_.bins,
0340 hsPhi_.min,
0341 hsPhi_.max);
0342
0343 hist_EE_CorSC_ET_vs_Eta_ = _ibooker.book2D("hist_EE_CorSC_ET_vs_Eta_",
0344 "Corr Super Cluster ET versus Eta in Endcap",
0345 hsET_.bins,
0346 hsET_.min,
0347 hsET_.max,
0348 hsEta_.bins,
0349 hsEta_.min,
0350 hsEta_.max);
0351
0352 hist_EE_CorSC_ET_vs_Phi_ = _ibooker.book2D("hist_EE_CorSC_ET_vs_Phi_",
0353 "Corr Super Cluster ET versus Phi in Endcap",
0354 hsET_.bins,
0355 hsET_.min,
0356 hsET_.max,
0357 hsPhi_.bins,
0358 hsPhi_.min,
0359 hsPhi_.max);
0360
0361 hist_EE_CorSC_ET_vs_R_ = _ibooker.book2D("hist_EE_CorSC_ET_vs_R_",
0362 "Corr Super Cluster ET versus Radius in Endcap",
0363 hsET_.bins,
0364 hsET_.min,
0365 hsET_.max,
0366 hsR_.bins,
0367 hsR_.min,
0368 hsR_.max);
0369 }
0370
0371 void EgammaSuperClusters::analyze(const edm::Event &evt, const edm::EventSetup &es) {
0372 bool skipMC = false;
0373 bool skipBarrel = false;
0374 bool skipEndcap = false;
0375
0376
0377
0378
0379 edm::Handle<edm::HepMCProduct> pMCTruth;
0380 evt.getByToken(MCTruthCollectionToken_, pMCTruth);
0381 if (!pMCTruth.isValid()) {
0382 edm::LogError("EgammaSuperClusters") << "Error! can't get MC collection ";
0383 skipMC = true;
0384 }
0385 const HepMC::GenEvent *genEvent = pMCTruth->GetEvent();
0386
0387 if (skipMC)
0388 return;
0389
0390
0391
0392
0393 edm::Handle<reco::SuperClusterCollection> pBarrelRawSuperClusters;
0394 evt.getByToken(barrelRawSuperClusterCollectionToken_, pBarrelRawSuperClusters);
0395 if (!pBarrelRawSuperClusters.isValid()) {
0396 edm::LogError("EgammaSuperClusters") << "Error! can't get collection Raw SC";
0397 skipBarrel = true;
0398 }
0399
0400 edm::Handle<reco::SuperClusterCollection> pBarrelCorSuperClusters;
0401 evt.getByToken(barrelCorSuperClusterCollectionToken_, pBarrelCorSuperClusters);
0402 if (!pBarrelCorSuperClusters.isValid()) {
0403 edm::LogError("EgammaSuperClusters") << "Error! can't get collection Cor SC";
0404 skipBarrel = true;
0405 }
0406
0407 edm::Handle<EBRecHitCollection> pBarrelRecHitCollection;
0408 evt.getByToken(barrelRecHitCollectionToken_, pBarrelRecHitCollection);
0409 if (!pBarrelRecHitCollection.isValid()) {
0410 skipBarrel = true;
0411 }
0412 edm::Handle<EERecHitCollection> pEndcapRecHitCollection;
0413 evt.getByToken(endcapRecHitCollectionToken_, pEndcapRecHitCollection);
0414 if (!pEndcapRecHitCollection.isValid()) {
0415 skipEndcap = true;
0416 }
0417
0418 if (skipBarrel || skipEndcap)
0419 return;
0420
0421 EcalClusterLazyTools lazyTool(
0422 evt, ecalClusterToolsESGetTokens_.get(es), barrelRecHitCollectionToken_, endcapRecHitCollectionToken_);
0423
0424
0425 const reco::SuperClusterCollection *barrelRawSuperClusters = pBarrelRawSuperClusters.product();
0426 const reco::SuperClusterCollection *barrelCorSuperClusters = pBarrelCorSuperClusters.product();
0427
0428
0429 hist_EB_RawSC_Size_->Fill(barrelRawSuperClusters->size());
0430 hist_EB_CorSC_Size_->Fill(barrelCorSuperClusters->size());
0431
0432
0433 for (reco::SuperClusterCollection::const_iterator aClus = barrelRawSuperClusters->begin();
0434 aClus != barrelRawSuperClusters->end();
0435 aClus++) {
0436
0437 hist_EB_RawSC_NumBC_->Fill(aClus->clustersSize());
0438 hist_EB_RawSC_ET_->Fill(aClus->energy() / std::cosh(aClus->position().eta()));
0439 hist_EB_RawSC_Eta_->Fill(aClus->position().eta());
0440 hist_EB_RawSC_Phi_->Fill(aClus->position().phi());
0441
0442
0443 const reco::CaloClusterPtr seed = aClus->seed();
0444 hist_EB_RawSC_S1toS9_->Fill(lazyTool.eMax(*seed) / lazyTool.e3x3(*seed));
0445 hist_EB_RawSC_S25toE_->Fill(lazyTool.e5x5(*seed) / aClus->energy());
0446
0447
0448 double dRClosest = 999.9;
0449 double energyClosest = 0;
0450 closestMCParticle(genEvent, *aClus, dRClosest, energyClosest);
0451
0452 if (dRClosest < 0.1) {
0453 hist_EB_RawSC_EoverTruth_->Fill(aClus->energy() / energyClosest);
0454 hist_EB_RawSC_deltaR_->Fill(dRClosest);
0455 }
0456 }
0457
0458
0459 for (reco::SuperClusterCollection::const_iterator aClus = barrelCorSuperClusters->begin();
0460 aClus != barrelCorSuperClusters->end();
0461 aClus++) {
0462
0463 hist_EB_CorSC_NumBC_->Fill(aClus->clustersSize());
0464 hist_EB_CorSC_ET_->Fill(aClus->energy() / std::cosh(aClus->position().eta()));
0465 hist_EB_CorSC_Eta_->Fill(aClus->position().eta());
0466 hist_EB_CorSC_Phi_->Fill(aClus->position().phi());
0467
0468 hist_EB_CorSC_ET_vs_Eta_->Fill(aClus->energy() / std::cosh(aClus->position().eta()), aClus->eta());
0469 hist_EB_CorSC_ET_vs_Phi_->Fill(aClus->energy() / std::cosh(aClus->position().eta()), aClus->phi());
0470
0471
0472 const reco::CaloClusterPtr seed = aClus->seed();
0473 hist_EB_CorSC_S1toS9_->Fill(lazyTool.eMax(*seed) / lazyTool.e3x3(*seed));
0474 hist_EB_CorSC_S25toE_->Fill(lazyTool.e5x5(*seed) / aClus->energy());
0475
0476
0477 hist_EB_CorSC_phiWidth_->Fill(aClus->phiWidth());
0478 hist_EB_CorSC_etaWidth_->Fill(aClus->etaWidth());
0479
0480
0481 double dRClosest = 999.9;
0482 double energyClosest = 0;
0483 closestMCParticle(genEvent, *aClus, dRClosest, energyClosest);
0484
0485 if (dRClosest < 0.1) {
0486 hist_EB_CorSC_EoverTruth_->Fill(aClus->energy() / energyClosest);
0487 hist_EB_CorSC_deltaR_->Fill(dRClosest);
0488 }
0489 }
0490
0491
0492
0493
0494 edm::Handle<reco::SuperClusterCollection> pEndcapRawSuperClusters;
0495 evt.getByToken(endcapRawSuperClusterCollectionToken_, pEndcapRawSuperClusters);
0496 if (!pEndcapRawSuperClusters.isValid()) {
0497 edm::LogError("EgammaSuperClusters") << "Error! can't get collection Raw EE SC";
0498 }
0499
0500 edm::Handle<reco::SuperClusterCollection> pEndcapPreSuperClusters;
0501 evt.getByToken(endcapPreSuperClusterCollectionToken_, pEndcapPreSuperClusters);
0502 if (!pEndcapPreSuperClusters.isValid()) {
0503 edm::LogError("EgammaSuperClusters") << "Error! can't get collection Pre EE SC";
0504 }
0505
0506 edm::Handle<reco::SuperClusterCollection> pEndcapCorSuperClusters;
0507 evt.getByToken(endcapCorSuperClusterCollectionToken_, pEndcapCorSuperClusters);
0508 if (!pEndcapCorSuperClusters.isValid()) {
0509 edm::LogError("EgammaSuperClusters") << "Error! can't get collection Cor EE SC";
0510 }
0511
0512
0513 const reco::SuperClusterCollection *endcapRawSuperClusters = pEndcapRawSuperClusters.product();
0514 const reco::SuperClusterCollection *endcapPreSuperClusters = pEndcapPreSuperClusters.product();
0515 const reco::SuperClusterCollection *endcapCorSuperClusters = pEndcapCorSuperClusters.product();
0516
0517
0518 hist_EE_RawSC_Size_->Fill(endcapRawSuperClusters->size());
0519 hist_EE_PreSC_Size_->Fill(endcapPreSuperClusters->size());
0520 hist_EE_CorSC_Size_->Fill(endcapCorSuperClusters->size());
0521
0522
0523 for (reco::SuperClusterCollection::const_iterator aClus = endcapRawSuperClusters->begin();
0524 aClus != endcapRawSuperClusters->end();
0525 aClus++) {
0526 hist_EE_RawSC_NumBC_->Fill(aClus->clustersSize());
0527 hist_EE_RawSC_ET_->Fill(aClus->energy() / std::cosh(aClus->position().eta()));
0528 hist_EE_RawSC_Eta_->Fill(aClus->position().eta());
0529 hist_EE_RawSC_Phi_->Fill(aClus->position().phi());
0530
0531 const reco::CaloClusterPtr seed = aClus->seed();
0532 hist_EE_RawSC_S1toS9_->Fill(lazyTool.eMax(*seed) / lazyTool.e3x3(*seed));
0533 hist_EE_RawSC_S25toE_->Fill(lazyTool.e5x5(*seed) / aClus->energy());
0534
0535
0536 double dRClosest = 999.9;
0537 double energyClosest = 0;
0538 closestMCParticle(genEvent, *aClus, dRClosest, energyClosest);
0539
0540 if (dRClosest < 0.1) {
0541 hist_EE_RawSC_EoverTruth_->Fill(aClus->energy() / energyClosest);
0542 hist_EE_RawSC_deltaR_->Fill(dRClosest);
0543 }
0544 }
0545
0546
0547 for (reco::SuperClusterCollection::const_iterator aClus = endcapPreSuperClusters->begin();
0548 aClus != endcapPreSuperClusters->end();
0549 aClus++) {
0550 hist_EE_PreSC_NumBC_->Fill(aClus->clustersSize());
0551 hist_EE_PreSC_ET_->Fill(aClus->energy() / std::cosh(aClus->position().eta()));
0552 hist_EE_PreSC_Eta_->Fill(aClus->position().eta());
0553 hist_EE_PreSC_Phi_->Fill(aClus->position().phi());
0554 hist_EE_PreSC_preshowerE_->Fill(aClus->preshowerEnergy());
0555
0556 const reco::CaloClusterPtr seed = aClus->seed();
0557 hist_EE_PreSC_S1toS9_->Fill(lazyTool.eMax(*seed) / lazyTool.e3x3(*seed));
0558 hist_EE_PreSC_S25toE_->Fill(lazyTool.e5x5(*seed) / aClus->energy());
0559
0560
0561 double dRClosest = 999.9;
0562 double energyClosest = 0;
0563 closestMCParticle(genEvent, *aClus, dRClosest, energyClosest);
0564
0565 if (dRClosest < 0.1) {
0566 hist_EE_PreSC_EoverTruth_->Fill(aClus->energy() / energyClosest);
0567 hist_EE_PreSC_deltaR_->Fill(dRClosest);
0568 }
0569 }
0570
0571
0572 for (reco::SuperClusterCollection::const_iterator aClus = endcapCorSuperClusters->begin();
0573 aClus != endcapCorSuperClusters->end();
0574 aClus++) {
0575 hist_EE_CorSC_NumBC_->Fill(aClus->clustersSize());
0576 hist_EE_CorSC_ET_->Fill(aClus->energy() / std::cosh(aClus->position().eta()));
0577 hist_EE_CorSC_Eta_->Fill(aClus->position().eta());
0578 hist_EE_CorSC_Phi_->Fill(aClus->position().phi());
0579 hist_EE_CorSC_preshowerE_->Fill(aClus->preshowerEnergy());
0580
0581 hist_EE_CorSC_ET_vs_Eta_->Fill(aClus->energy() / std::cosh(aClus->position().eta()), aClus->eta());
0582 hist_EE_CorSC_ET_vs_Phi_->Fill(aClus->energy() / std::cosh(aClus->position().eta()), aClus->phi());
0583 hist_EE_CorSC_ET_vs_R_->Fill(aClus->energy() / std::cosh(aClus->position().eta()),
0584 std::sqrt(std::pow(aClus->x(), 2) + std::pow(aClus->y(), 2)));
0585
0586
0587 hist_EE_CorSC_phiWidth_->Fill(aClus->phiWidth());
0588 hist_EE_CorSC_etaWidth_->Fill(aClus->etaWidth());
0589
0590 const reco::CaloClusterPtr seed = aClus->seed();
0591 hist_EE_CorSC_S1toS9_->Fill(lazyTool.eMax(*seed) / lazyTool.e3x3(*seed));
0592 hist_EE_CorSC_S25toE_->Fill(lazyTool.e5x5(*seed) / aClus->energy());
0593
0594
0595 double dRClosest = 999.9;
0596 double energyClosest = 0;
0597 closestMCParticle(genEvent, *aClus, dRClosest, energyClosest);
0598
0599 if (dRClosest < 0.1) {
0600 hist_EE_CorSC_EoverTruth_->Fill(aClus->energy() / energyClosest);
0601 hist_EE_CorSC_deltaR_->Fill(dRClosest);
0602 }
0603 }
0604 }
0605
0606
0607
0608
0609 void EgammaSuperClusters::closestMCParticle(const HepMC::GenEvent *genEvent,
0610 const reco::SuperCluster &sc,
0611 double &dRClosest,
0612 double &energyClosest) const {
0613
0614 double scEta = sc.eta();
0615 double scPhi = sc.phi();
0616
0617
0618 dRClosest = 999.9;
0619
0620
0621
0622 for (HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin();
0623 currentParticle != genEvent->particles_end();
0624 currentParticle++) {
0625 if ((*currentParticle)->status() == 1) {
0626
0627 HepMC::FourVector vtx = (*currentParticle)->production_vertex()->position();
0628 double phiTrue = (*currentParticle)->momentum().phi();
0629 double etaTrue = ecalEta((*currentParticle)->momentum().eta(), vtx.z() / 10., vtx.perp() / 10.);
0630
0631 double dPhi = reco::deltaPhi(phiTrue, scPhi);
0632 double dEta = scEta - etaTrue;
0633 double deltaR = std::sqrt(dPhi * dPhi + dEta * dEta);
0634
0635 if (deltaR < dRClosest) {
0636 dRClosest = deltaR;
0637 energyClosest = (*currentParticle)->momentum().e();
0638 }
0639
0640 }
0641
0642 }
0643 }
0644
0645
0646
0647
0648 float EgammaSuperClusters::ecalEta(float EtaParticle, float Zvertex, float plane_Radius) const {
0649 const float R_ECAL = 136.5;
0650 const float Z_Endcap = 328.0;
0651 const float etaBarrelEndcap = 1.479;
0652
0653 if (EtaParticle != 0.) {
0654 float Theta = 0.0;
0655 float ZEcal = (R_ECAL - plane_Radius) * sinh(EtaParticle) + Zvertex;
0656
0657 if (ZEcal != 0.0)
0658 Theta = atan(R_ECAL / ZEcal);
0659 if (Theta < 0.0)
0660 Theta = Theta + Geom::pi();
0661
0662 float ETA = -log(tan(0.5 * Theta));
0663
0664 if (fabs(ETA) > etaBarrelEndcap) {
0665 float Zend = Z_Endcap;
0666 if (EtaParticle < 0.0)
0667 Zend = -Zend;
0668 float Zlen = Zend - Zvertex;
0669 float RR = Zlen / sinh(EtaParticle);
0670 Theta = atan((RR + plane_Radius) / Zend);
0671 if (Theta < 0.0)
0672 Theta = Theta + Geom::pi();
0673 ETA = -log(tan(0.5 * Theta));
0674 }
0675
0676 return ETA;
0677 } else {
0678 edm::LogWarning("") << "[EgammaSuperClusters::ecalEta] Warning: Eta equals "
0679 "to zero, not correcting";
0680 return EtaParticle;
0681 }
0682 }