CMS 3D CMS Logo

EcalBxOrbitNumberGrapher.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalBxOrbitNumberGrapher
4 // Class: EcalBxOrbitNumberGrapher
5 //
13 //
14 // Original Author: Seth COOPER
15 // Created: Th Nov 22 5:46:22 CEST 2007
16 //
17 //
18 
20 
21 using namespace cms;
22 using namespace edm;
23 using namespace std;
24 
25 #include <iostream>
26 
27 //
28 // constants, enums and typedefs
29 //
30 
31 //
32 // static data member definitions
33 //
34 
35 //
36 // constructors and destructor
37 //
39  : digiProducer_(consumes<EcalRawDataCollection>(iConfig.getParameter<std::string>("RawDigis"))),
40  runNum_(-1),
41  fileName_(iConfig.getUntrackedParameter<std::string>("fileName", "ecalURechHitHists")) {}
42 
44 
45 //
46 // member functions
47 //
48 
49 // ------------ method called to for each event ------------
51  using namespace cms;
52  //int ievt = iEvent.id().event();
53  int orbit = -100;
54  int bx = -100;
55  int numorbiterrors = 0;
56  bool orbiterror = false;
57 
58  const edm::Handle<EcalRawDataCollection>& DCCHeaders = iEvent.getHandle(digiProducer_);
59  if (!DCCHeaders.isValid()) {
60  edm::LogError("BxOrbitNumber") << "can't get the product for EcalRawDataCollection";
61  }
62 
63  //-----------------BX STuff here
64  for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
65  ++headerItr) {
66  headerItr->getEventSettings();
67  int myorbit = headerItr->getOrbit();
68  int mybx = headerItr->getBX();
69 
70  if (orbit == -100) {
71  orbit = myorbit;
72  } else if (orbit != myorbit) {
73  edm::LogVerbatim("EcalTools") << " NOOOO This header has a conflicting orbit OTHER " << orbit << " new "
74  << myorbit;
75  orbiterror = true;
76  numorbiterrors++;
77  orbitErrorBxDiffPlot_->Fill(myorbit - orbit);
78  }
79 
80  if (bx == -100) {
81  bx = mybx;
82  } else if (bx != mybx) {
83  edm::LogVerbatim("EcalTools") << " NOOOO This header has a conflicting bx OTHER " << bx << " new " << mybx;
84  }
85  }
86 
87  if ((bx != -100) & (orbit != -100)) {
88  edm::LogVerbatim("EcalTools") << " Interesting event Orbit " << orbit << " BX " << bx;
89  bxnumberPlot_->Fill(bx);
90  if (orbiterror) {
91  orbitErrorPlot_->Fill(bx);
92  }
93  }
94  numberofOrbitDiffPlot_->Fill(numorbiterrors);
95 
96  if (runNum_ == -1) {
97  runNum_ = iEvent.id().run();
98  }
99 }
100 
101 // insert the hist map into the map keyed by FED number
103 
104 // ------------ method called once each job just before starting event loop ------------
106  bxnumberPlot_ = new TH1F("bxnumber", "BX number of interexting events", 3600, 0., 3600.);
107  orbitErrorPlot_ = new TH1F("bxOfOrbitDiffs", "BX number of interexting events with orbit changes", 3600, 0., 3600.);
109  new TH1F("orbitErrorDiffPlot", "Orbit Difference of those HEADERS that have a difference", 20, -10., 10.);
110  numberofOrbitDiffPlot_ = new TH1F("numberOfOrbitDiffsPlot", "Number of Orbit Differences", 54, 0., 54.);
111 }
112 
113 // ------------ method called once each job just after ending the event loop ------------
115  using namespace std;
116  fileName_ += ".bx.root";
117 
118  TFile root_file_(fileName_.c_str(), "RECREATE");
119 
120  bxnumberPlot_->Write();
121  orbitErrorPlot_->Write();
122  numberofOrbitDiffPlot_->Write();
123  orbitErrorBxDiffPlot_->Write();
124  root_file_.Close();
125 }
Log< level::Info, true > LogVerbatim
std::vector< T >::const_iterator const_iterator
void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< EcalRawDataCollection > digiProducer_
Log< level::Error, false > LogError
int iEvent
Definition: GenABIO.cc:224
EcalBxOrbitNumberGrapher(const edm::ParameterSet &)
const_iterator begin() const
Namespace of DDCMS conversion namespace.
const_iterator end() const
bool isValid() const
Definition: HandleBase.h:70
HLT enums.