File indexing completed on 2023-03-17 11:27:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <memory>
0020
0021
0022 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0027
0028 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030
0031 #include <string>
0032 #include <vector>
0033
0034 #include "TFile.h"
0035 #include "TH1I.h"
0036
0037 using namespace edm;
0038 using namespace std;
0039
0040
0041
0042
0043
0044 class TPGCheck : public edm::one::EDAnalyzer<> {
0045 public:
0046 explicit TPGCheck(const edm::ParameterSet &);
0047 ~TPGCheck() override;
0048
0049 private:
0050 void beginJob() override;
0051 void analyze(const edm::Event &, const edm::EventSetup &) override;
0052 void endJob() override;
0053
0054
0055 TH1I *ecal_et_[2];
0056 TH1I *ecal_tt_[2];
0057 TH1I *ecal_fgvb_[2];
0058
0059 TFile *histFile_;
0060 std::string label_;
0061 std::string producer_;
0062 std::vector<std::string> ecal_parts_;
0063
0064 edm::EDGetTokenT<EcalTrigPrimDigiCollection> ecal_tp_token_;
0065 };
0066
0067
0068
0069
0070 TPGCheck::TPGCheck(const edm::ParameterSet &iConfig) {
0071
0072
0073 ecal_parts_.push_back("Barrel");
0074 ecal_parts_.push_back("Endcap");
0075
0076 histFile_ = new TFile("histos.root", "RECREATE");
0077 for (unsigned int i = 0; i < 2; ++i) {
0078
0079 char t[30];
0080 sprintf(t, "%s_energy", ecal_parts_[i].c_str());
0081 ecal_et_[i] = new TH1I(t, "Et", 255, 0, 255);
0082
0083
0084 char titleTTF[30];
0085 sprintf(titleTTF, "%s_ttf", ecal_parts_[i].c_str());
0086 ecal_tt_[i] = new TH1I(titleTTF, "TTF", 10, 0, 10);
0087
0088
0089 char titleFG[30];
0090 sprintf(titleFG, "%s_fgvb", ecal_parts_[i].c_str());
0091 ecal_fgvb_[i] = new TH1I(titleFG, "FGVB", 10, 0, 10);
0092 }
0093
0094 label_ = iConfig.getParameter<std::string>("Label");
0095 producer_ = iConfig.getParameter<std::string>("Producer");
0096 ecal_tp_token_ = consumes<EcalTrigPrimDigiCollection>(edm::InputTag(label_, producer_));
0097 }
0098
0099 TPGCheck::~TPGCheck() {
0100
0101
0102
0103 histFile_->Write();
0104 histFile_->Close();
0105 }
0106
0107
0108
0109
0110
0111
0112 void TPGCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0113
0114 edm::Handle<EcalTrigPrimDigiCollection> tp;
0115 iEvent.getByToken(ecal_tp_token_, tp);
0116 for (unsigned int i = 0; i < tp.product()->size(); i++) {
0117 EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
0118 int subdet = d.id().subDet() - 1;
0119
0120
0121 if (subdet == 0) {
0122 ecal_et_[subdet]->Fill(d.compressedEt());
0123 } else {
0124 if (d.id().ietaAbs() == 27 || d.id().ietaAbs() == 28) {
0125 if (i % 2)
0126 ecal_et_[subdet]->Fill(d.compressedEt() * 2.);
0127 } else
0128 ecal_et_[subdet]->Fill(d.compressedEt());
0129 }
0130 ecal_tt_[subdet]->Fill(d.ttFlag());
0131 ecal_fgvb_[subdet]->Fill(d.fineGrain());
0132 }
0133 }
0134
0135
0136
0137 void TPGCheck::beginJob() {}
0138
0139
0140
0141 void TPGCheck::endJob() {
0142 for (unsigned int i = 0; i < 2; ++i) {
0143 ecal_et_[i]->Write();
0144 ecal_tt_[i]->Write();
0145 ecal_fgvb_[i]->Write();
0146 }
0147 }
0148
0149
0150 DEFINE_FWK_MODULE(TPGCheck);