File indexing completed on 2024-04-06 12:25:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <memory>
0022
0023
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Utilities/interface/InputTag.h"
0032
0033 #include "FWCore/ServiceRegistry/interface/Service.h"
0034
0035 #include "DataFormats/PatCandidates/interface/Photon.h"
0036
0037 #include "DataFormats/Common/interface/View.h"
0038 #include "DataFormats/Common/interface/ValueMap.h"
0039 #include "DataFormats/Common/interface/OwnVector.h"
0040
0041 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0042
0043 #include <string>
0044 #include "TNtuple.h"
0045
0046 namespace edm {
0047 using ::std::advance;
0048 }
0049
0050
0051
0052
0053
0054 class PATHIPhotonTestModule : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0055 public:
0056 explicit PATHIPhotonTestModule(const edm::ParameterSet&);
0057
0058 private:
0059 void beginJob() override;
0060 void analyze(const edm::Event&, const edm::EventSetup&) override;
0061 void endJob() override;
0062
0063
0064 edm::InputTag photons_;
0065 std::string label_;
0066 enum TestMode { TestRead, TestWrite, TestExternal };
0067 TestMode mode_;
0068 TNtuple* datatemp;
0069 };
0070
0071
0072
0073
0074 PATHIPhotonTestModule::PATHIPhotonTestModule(const edm::ParameterSet& iConfig)
0075 : photons_(iConfig.getParameter<edm::InputTag>("photons")) {
0076 usesResource(TFileService::kSharedResource);
0077 }
0078
0079
0080 void PATHIPhotonTestModule::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0081 using namespace edm;
0082
0083 edm::Handle<edm::View<pat::Photon>> photons;
0084 iEvent.getByLabel(photons_, photons);
0085
0086 auto output = std::make_unique<std::vector<pat::Photon>>();
0087
0088 for (edm::View<pat::Photon>::const_iterator photon = photons->begin(), end = photons->end(); photon != end;
0089 ++photon) {
0090 Float_t var[100];
0091
0092 int idx = 0;
0093 var[idx] = photon->et();
0094 idx++;
0095
0096 for (int i = 1; i < 6; i++) {
0097 var[idx] = photon->userFloat(Form("isoCC%d", i));
0098 idx++;
0099 }
0100
0101 for (int i = 1; i < 6; i++) {
0102 var[idx] = photon->userFloat(Form("isoCR%d", i));
0103 idx++;
0104 }
0105
0106 for (int i = 1; i < 5; i++) {
0107 for (int j = 1; j < 5; j++) {
0108 var[idx] = photon->userFloat(Form("isoT%d%d", i, j));
0109 idx++;
0110 }
0111 }
0112
0113 for (int i = 1; i < 5; i++) {
0114 for (int j = 1; j < 5; j++) {
0115 var[idx] = photon->userFloat(Form("isoDR%d%d", i, j));
0116 idx++;
0117 }
0118 }
0119
0120 var[idx] = photon->e3x3();
0121 idx++;
0122 var[idx] = photon->e5x5();
0123 idx++;
0124
0125 datatemp->Fill(var);
0126 }
0127 }
0128
0129
0130 void PATHIPhotonTestModule::beginJob() {
0131 edm::Service<TFileService> fs;
0132 datatemp = fs->make<TNtuple>("gammas",
0133 "photon candidate info",
0134 "et:"
0135 "cC1:cC2:cC3:cC4:cC5:cR1:cR2:cR3:cR4:cR5:"
0136 "T11:T12:T13:T14:"
0137 "T21:T22:T23:T24:"
0138 "T31:T32:T33:T34:"
0139 "T41:T42:T43:T44:"
0140 "dR11:dR12:dR13:dR14:"
0141 "dR21:dR22:dR23:dR24:"
0142 "dR31:dR32:dR33:dR34:"
0143 "dR41:dR42:dR43:dR44");
0144 }
0145
0146
0147 void PATHIPhotonTestModule::endJob() {}
0148
0149
0150 DEFINE_FWK_MODULE(PATHIPhotonTestModule);