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 // $Id: EcalBxOrbitNumberGrapher.cc,v 1.3 2011/10/10 09:05:21 eulisse Exp $
17 //
18 //
19 
21 
22 using namespace cms;
23 using namespace edm;
24 using namespace std;
25 
26 //
27 // constants, enums and typedefs
28 //
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38  digiProducer_(iConfig.getParameter<std::string>("RawDigis")),
39  runNum_(-1),
40  fileName_ (iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalURechHitHists")))
41 {
42 
43 
44 }
45 
46 
48 {
49 }
50 
51 
52 //
53 // member functions
54 //
55 
56 // ------------ method called to for each event ------------
57 void
59 {
60  using namespace edm;
61  using namespace cms;
62  //int ievt = iEvent.id().event();
63  int orbit = -100;
64  int bx = -100;
65  int numorbiterrors = 0;
66  bool orbiterror = false;
67 
68 
70  iEvent.getByLabel(digiProducer_, DCCHeaders);
71  if (!DCCHeaders.isValid()) {
72  edm::LogError("BxOrbitNumber") << "can't get the product for EcalRawDataCollection";
73  }
74 
75  //-----------------BX STuff here
76  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin();headerItr != DCCHeaders->end();
77  ++headerItr ) {
78  headerItr->getEventSettings();
79  int myorbit = headerItr->getOrbit();
80  int mybx = headerItr->getBX();
81 
82  if ( orbit == -100 )
83  {
84  orbit = myorbit;
85  }
86  else if (orbit != myorbit)
87  {
88  std::cout << " NOOOO This header has a conflicting orbit OTHER " << orbit << " new " << myorbit << std::endl;
89  orbiterror = true;
90  numorbiterrors++;
91  orbitErrorBxDiffPlot_->Fill(myorbit - orbit);
92  }
93 
94  if ( bx == -100 )
95  {
96  bx = mybx;
97  }
98  else if (bx != mybx)
99  {
100  std::cout << " NOOOO This header has a conflicting bx OTHER " << bx << " new " << mybx << std::endl;
101  }
102  //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.
103  }
104 
105  if ( (bx != -100) & ( orbit != -100) )
106  {
107  std::cout << " Interesting event Orbit " << orbit << " BX " << bx << std::endl;
108  bxnumberPlot_->Fill(bx);
109  if (orbiterror)
110  {
111  orbitErrorPlot_->Fill(bx);
112  }
113  }
114  numberofOrbitDiffPlot_->Fill(numorbiterrors);
115 
116 
117  if(runNum_==-1)
118  {
119  runNum_ = iEvent.id().run();
120  }
121 }
122 
123 
124 // insert the hist map into the map keyed by FED number
126 {
127 
128 
129 }
130 
131 // ------------ method called once each job just before starting event loop ------------
132 void
134 {
135  bxnumberPlot_ = new TH1F("bxnumber", "BX number of interexting events",3600, 0., 3600.);
136  orbitErrorPlot_ = new TH1F("bxOfOrbitDiffs", "BX number of interexting events with orbit changes",3600, 0., 3600.);
137  orbitErrorBxDiffPlot_ = new TH1F("orbitErrorDiffPlot","Orbit Difference of those HEADERS that have a difference",20,-10.,10.);
138  numberofOrbitDiffPlot_ = new TH1F("numberOfOrbitDiffsPlot","Number of Orbit Differences",54,0., 54.);
139 }
140 
141 // ------------ method called once each job just after ending the event loop ------------
142 void
144 {
145  using namespace std;
146  fileName_ += ".bx.root";
147 
148  TFile root_file_(fileName_.c_str() , "RECREATE");
149 
150  bxnumberPlot_->Write();
151  orbitErrorPlot_->Write();
152  numberofOrbitDiffPlot_->Write();
153  orbitErrorBxDiffPlot_->Write();
154  root_file_.Close();
155 
156 }
157 
158 
159 
RunNumber_t run() const
Definition: EventID.h:42
std::vector< T >::const_iterator const_iterator
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
EcalBxOrbitNumberGrapher(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:121