File indexing completed on 2024-04-06 12:00:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "CaloOnlineTools/EcalTools/plugins/EcalBxOrbitNumberGrapher.h"
0020
0021 using namespace cms;
0022 using namespace edm;
0023 using namespace std;
0024
0025 #include <iostream>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 EcalBxOrbitNumberGrapher::EcalBxOrbitNumberGrapher(const edm::ParameterSet& iConfig)
0039 : digiProducer_(consumes<EcalRawDataCollection>(iConfig.getParameter<std::string>("RawDigis"))),
0040 runNum_(-1),
0041 fileName_(iConfig.getUntrackedParameter<std::string>("fileName", "ecalURechHitHists")) {}
0042
0043 EcalBxOrbitNumberGrapher::~EcalBxOrbitNumberGrapher() {}
0044
0045
0046
0047
0048
0049
0050 void EcalBxOrbitNumberGrapher::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0051 using namespace cms;
0052
0053 int orbit = -100;
0054 int bx = -100;
0055 int numorbiterrors = 0;
0056 bool orbiterror = false;
0057
0058 const edm::Handle<EcalRawDataCollection>& DCCHeaders = iEvent.getHandle(digiProducer_);
0059 if (!DCCHeaders.isValid()) {
0060 edm::LogError("BxOrbitNumber") << "can't get the product for EcalRawDataCollection";
0061 }
0062
0063
0064 for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
0065 ++headerItr) {
0066 headerItr->getEventSettings();
0067 int myorbit = headerItr->getOrbit();
0068 int mybx = headerItr->getBX();
0069
0070 if (orbit == -100) {
0071 orbit = myorbit;
0072 } else if (orbit != myorbit) {
0073 edm::LogVerbatim("EcalTools") << " NOOOO This header has a conflicting orbit OTHER " << orbit << " new "
0074 << myorbit;
0075 orbiterror = true;
0076 numorbiterrors++;
0077 orbitErrorBxDiffPlot_->Fill(myorbit - orbit);
0078 }
0079
0080 if (bx == -100) {
0081 bx = mybx;
0082 } else if (bx != mybx) {
0083 edm::LogVerbatim("EcalTools") << " NOOOO This header has a conflicting bx OTHER " << bx << " new " << mybx;
0084 }
0085 }
0086
0087 if ((bx != -100) & (orbit != -100)) {
0088 edm::LogVerbatim("EcalTools") << " Interesting event Orbit " << orbit << " BX " << bx;
0089 bxnumberPlot_->Fill(bx);
0090 if (orbiterror) {
0091 orbitErrorPlot_->Fill(bx);
0092 }
0093 }
0094 numberofOrbitDiffPlot_->Fill(numorbiterrors);
0095
0096 if (runNum_ == -1) {
0097 runNum_ = iEvent.id().run();
0098 }
0099 }
0100
0101
0102 void EcalBxOrbitNumberGrapher::initHists(int FED) {}
0103
0104
0105 void EcalBxOrbitNumberGrapher::beginJob() {
0106 bxnumberPlot_ = new TH1F("bxnumber", "BX number of interexting events", 3600, 0., 3600.);
0107 orbitErrorPlot_ = new TH1F("bxOfOrbitDiffs", "BX number of interexting events with orbit changes", 3600, 0., 3600.);
0108 orbitErrorBxDiffPlot_ =
0109 new TH1F("orbitErrorDiffPlot", "Orbit Difference of those HEADERS that have a difference", 20, -10., 10.);
0110 numberofOrbitDiffPlot_ = new TH1F("numberOfOrbitDiffsPlot", "Number of Orbit Differences", 54, 0., 54.);
0111 }
0112
0113
0114 void EcalBxOrbitNumberGrapher::endJob() {
0115 using namespace std;
0116 fileName_ += ".bx.root";
0117
0118 TFile root_file_(fileName_.c_str(), "RECREATE");
0119
0120 bxnumberPlot_->Write();
0121 orbitErrorPlot_->Write();
0122 numberofOrbitDiffPlot_->Write();
0123 orbitErrorBxDiffPlot_->Write();
0124 root_file_.Close();
0125 }