Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-30 22:38:35

0001 // -*- C++ -*-
0002 //
0003 // Package:   EcalBxOrbitNumberGrapher
0004 // Class:     EcalBxOrbitNumberGrapher
0005 //
0006 /**\class EcalBxOrbitNumberGrapher EcalBxOrbitNumberGrapher.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Seth COOPER
0015 //         Created:  Th Nov 22 5:46:22 CEST 2007
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 // constants, enums and typedefs
0029 //
0030 
0031 //
0032 // static data member definitions
0033 //
0034 
0035 //
0036 // constructors and destructor
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 // member functions
0047 //
0048 
0049 // ------------ method called to for each event  ------------
0050 void EcalBxOrbitNumberGrapher::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0051   using namespace cms;
0052   //int ievt = iEvent.id().event();
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   //-----------------BX STuff here
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 // insert the hist map into the map keyed by FED number
0102 void EcalBxOrbitNumberGrapher::initHists(int FED) {}
0103 
0104 // ------------ method called once each job just before starting event loop  ------------
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 // ------------ method called once each job just after ending the event loop  ------------
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 }