CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_(iConfig.getParameter<std::string>("RawDigis")),
40  runNum_(-1),
41  fileName_ (iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalURechHitHists")))
42 {
43 
44 
45 }
46 
47 
49 {
50 }
51 
52 
53 //
54 // member functions
55 //
56 
57 // ------------ method called to for each event ------------
58 void
60 {
61  using namespace edm;
62  using namespace cms;
63  //int ievt = iEvent.id().event();
64  int orbit = -100;
65  int bx = -100;
66  int numorbiterrors = 0;
67  bool orbiterror = false;
68 
69 
71  iEvent.getByLabel(digiProducer_, DCCHeaders);
72  if (!DCCHeaders.isValid()) {
73  edm::LogError("BxOrbitNumber") << "can't get the product for EcalRawDataCollection";
74  }
75 
76  //-----------------BX STuff here
77  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin();headerItr != DCCHeaders->end();
78  ++headerItr ) {
79  headerItr->getEventSettings();
80  int myorbit = headerItr->getOrbit();
81  int mybx = headerItr->getBX();
82 
83  if ( orbit == -100 )
84  {
85  orbit = myorbit;
86  }
87  else if (orbit != myorbit)
88  {
89  std::cout << " NOOOO This header has a conflicting orbit OTHER " << orbit << " new " << myorbit << std::endl;
90  orbiterror = true;
91  numorbiterrors++;
92  orbitErrorBxDiffPlot_->Fill(myorbit - orbit);
93  }
94 
95  if ( bx == -100 )
96  {
97  bx = mybx;
98  }
99  else if (bx != mybx)
100  {
101  std::cout << " NOOOO This header has a conflicting bx OTHER " << bx << " new " << mybx << std::endl;
102  }
103  //LogDebug("EcalTimingCosmic") << " Lambda " << lambda; //hmm... this isn't good, I should keep a record of the wavelength in the headers as an inactive SM might have a different wavelength for this field and make this not go through.
104  }
105 
106  if ( (bx != -100) & ( orbit != -100) )
107  {
108  std::cout << " Interesting event Orbit " << orbit << " BX " << bx << std::endl;
109  bxnumberPlot_->Fill(bx);
110  if (orbiterror)
111  {
112  orbitErrorPlot_->Fill(bx);
113  }
114  }
115  numberofOrbitDiffPlot_->Fill(numorbiterrors);
116 
117 
118  if(runNum_==-1)
119  {
120  runNum_ = iEvent.id().run();
121  }
122 }
123 
124 
125 // insert the hist map into the map keyed by FED number
127 {
128 
129 
130 }
131 
132 // ------------ method called once each job just before starting event loop ------------
133 void
135 {
136  bxnumberPlot_ = new TH1F("bxnumber", "BX number of interexting events",3600, 0., 3600.);
137  orbitErrorPlot_ = new TH1F("bxOfOrbitDiffs", "BX number of interexting events with orbit changes",3600, 0., 3600.);
138  orbitErrorBxDiffPlot_ = new TH1F("orbitErrorDiffPlot","Orbit Difference of those HEADERS that have a difference",20,-10.,10.);
139  numberofOrbitDiffPlot_ = new TH1F("numberOfOrbitDiffsPlot","Number of Orbit Differences",54,0., 54.);
140 }
141 
142 // ------------ method called once each job just after ending the event loop ------------
143 void
145 {
146  using namespace std;
147  fileName_ += ".bx.root";
148 
149  TFile root_file_(fileName_.c_str() , "RECREATE");
150 
151  bxnumberPlot_->Write();
152  orbitErrorPlot_->Write();
153  numberofOrbitDiffPlot_->Write();
154  orbitErrorBxDiffPlot_->Write();
155  root_file_.Close();
156 
157 }
158 
159 
160 
RunNumber_t run() const
Definition: EventID.h:39
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
EcalBxOrbitNumberGrapher(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
edm::EventID id() const
Definition: EventBase.h:59
tuple cout
Definition: gather_cfg.py:145