CMS 3D CMS Logo

EventTimeDistribution.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: EventTimeDistribution
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Tue Jul 19 11:56:00 CEST 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
23 #include <string>
24 #include <vector>
25 
26 #include "TH1F.h"
27 #include "TH2F.h"
28 
31 
35 
37 
39 
42 
44 
47 
49 //
50 // class decleration
51 //
52 
54 public:
56  ~EventTimeDistribution() override;
57 
58 private:
59  void beginJob() override;
60  void beginRun(const edm::Run&, const edm::EventSetup&) override;
61  void endRun(const edm::Run&, const edm::EventSetup&) override;
62  void analyze(const edm::Event&, const edm::EventSetup&) override;
63  void endJob() override;
64 
65  // ----------member data ---------------------------
66 
70  const bool _wantdbxvsbxincycle;
71  const bool _wantdbxvsbx;
72  const bool _wantbxincyclevsbx;
74  unsigned int _nevents;
75  const unsigned int m_maxLS;
76  const unsigned int m_LSfrac;
77  const bool m_ewhdepthHisto;
78 
80 
81  TH1F** _dbx;
82  std::vector<TH1F**> m_dbxhistos;
83  std::vector<std::pair<unsigned int, unsigned int> > m_dbxindices;
84  TH1F** _bx;
85  TH1F** _bxincycle;
86  TH1F** _orbit;
88  TH2F** _dbxvsbx;
91  TH1F** m_ewhdepth;
92 };
93 
94 //
95 // constants, enums and typedefs
96 //
97 
98 //
99 // static data member definitions
100 //
101 
102 //
103 // constructors and destructor
104 //
106  : _historyProductToken(consumes<EventWithHistory>(iConfig.getParameter<edm::InputTag>("historyProduct"))),
107  _apvphasecollToken(consumes<APVCyclePhaseCollection>(iConfig.getParameter<edm::InputTag>("apvPhaseCollection"))),
108  _phasepart(iConfig.getUntrackedParameter<std::string>("phasePartition", "None")),
109  _wantdbxvsbxincycle(iConfig.getUntrackedParameter<bool>("wantDBXvsBXincycle", false)),
110  _wantdbxvsbx(iConfig.getUntrackedParameter<bool>("wantDBXvsBX", false)),
111  _wantbxincyclevsbx(iConfig.getUntrackedParameter<bool>("wantBXincyclevsBX", false)),
112  _wantorbitvsbxincycle(iConfig.getUntrackedParameter<bool>("wantOrbitvsBXincycle", false)),
113  _nevents(0),
114  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin", 100)),
115  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction", 4)),
116  m_ewhdepthHisto(iConfig.getUntrackedParameter<bool>("wantEWHDepthHisto", false)),
117  _rhm(consumesCollector()),
118  _dbxvsbxincycle(nullptr),
119  _dbxvsbx(nullptr),
120  _bxincyclevsbx(nullptr),
121  _orbitvsbxincycle(nullptr),
122  m_ewhdepth(nullptr) {
123  //now do what ever initialization is needed
124 
125  std::vector<edm::ParameterSet> dbxhistoparams(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(
126  "dbxHistosParams", std::vector<edm::ParameterSet>()));
127 
128  for (std::vector<edm::ParameterSet>::const_iterator params = dbxhistoparams.begin(); params != dbxhistoparams.end();
129  ++params) {
130  m_dbxindices.push_back(std::pair<unsigned int, unsigned int>(params->getParameter<unsigned int>("firstEvent"),
131  params->getParameter<unsigned int>("secondEvent")));
132  char hname[300];
133  sprintf(hname,
134  "dbx_%d_%d",
135  params->getParameter<unsigned int>("firstEvent"),
136  params->getParameter<unsigned int>("secondEvent"));
137  char htitle[300];
138  sprintf(htitle,
139  "dbx(%d,%d)",
140  params->getParameter<unsigned int>("firstEvent"),
141  params->getParameter<unsigned int>("secondEvent"));
142 
143  m_dbxhistos.push_back(_rhm.makeTH1F(hname,
144  htitle,
145  params->getParameter<int>("nbins"),
146  params->getParameter<double>("min"),
147  params->getParameter<double>("max")));
148  LogDebug("DBXHistoPreBooking") << "Booked DBX histo named " << hname << " untitled " << htitle;
149  }
150 
151  _dbx = _rhm.makeTH1F("dbx", "dbx", 1000, -0.5, 999.5);
152  _bx = _rhm.makeTH1F("bx", "BX number", 3564, -0.5, 3563.5);
153  _bxincycle = _rhm.makeTH1F("bxcycle", "bxcycle", 70, -0.5, 69.5);
154  _orbit = _rhm.makeTH1F("orbit", "orbit", m_LSfrac * m_maxLS, 0, m_maxLS * 262144);
156  _dbxvsbxincycle = _rhm.makeTH2F("dbxvsbxincycle", "dbxvsbxincycle", 70, -0.5, 69.5, 1000, -0.5, 999.5);
157  if (_wantdbxvsbx)
158  _dbxvsbx = _rhm.makeTH2F("dbxvsbx", "dbxvsbx", 3564, -0.5, 3563.5, 1000, -0.5, 999.5);
159  if (_wantbxincyclevsbx)
160  _bxincyclevsbx = _rhm.makeTH2F("bxincyclevsbx", "bxincyclevsbx", 3564, -0.5, 3563.5, 70, -0.5, 69.5);
163  _rhm.makeTH2F("orbitvsbxincycle", "orbitvsbxincycle", 70, -0.5, 69.5, m_maxLS, 0, m_maxLS * 262144);
164  if (m_ewhdepthHisto)
165  m_ewhdepth = _rhm.makeTH1F("ewhdepth", "EventWithHistory Depth", 11, -0.5, 10.5);
166 
167  edm::LogInfo("UsedAPVCyclePhaseCollection")
168  << " APVCyclePhaseCollection " << iConfig.getParameter<edm::InputTag>("apvPhaseCollection") << " used";
169 }
170 
172  // do anything here that needs to be done at desctruction time
173  // (e.g. close files, deallocate resources etc.)
174 }
175 
176 //
177 // member functions
178 //
179 
180 // ------------ method called to for each event ------------
182  using namespace edm;
183 
184  _nevents++;
185 
187  iEvent.getByToken(_historyProductToken, he);
188 
189  // improve the matchin between default and actual partitions
190 
191  (*_dbx)->Fill(he->deltaBX());
192  std::vector<std::pair<unsigned int, unsigned int> >::const_iterator indices = m_dbxindices.begin();
193  for (std::vector<TH1F**>::const_iterator dbxhist = m_dbxhistos.begin(); dbxhist != m_dbxhistos.end();
194  ++dbxhist, ++indices) {
195  (*(*dbxhist))->Fill(he->deltaBX(indices->first, indices->second));
196  }
197 
198  (*_bx)->Fill(iEvent.bunchCrossing() % 3564);
199  (*_orbit)->Fill(iEvent.orbitNumber());
200  if (_dbxvsbx && *_dbxvsbx)
201  (*_dbxvsbx)->Fill(iEvent.bunchCrossing() % 3564, he->deltaBX());
202  if (m_ewhdepth && *m_ewhdepth)
203  (*m_ewhdepth)->Fill(he->depth());
204 
206  iEvent.getByToken(_apvphasecollToken, apvphase);
207 
208  long long tbx = he->absoluteBX();
209  if (apvphase.isValid() && !apvphase.failedToGet()) {
210  const int thephase = apvphase->getPhase(_phasepart);
213  tbx -= thephase;
214  (*_bxincycle)->Fill(tbx % 70);
216  (*_dbxvsbxincycle)->Fill(tbx % 70, he->deltaBX());
218  (*_bxincyclevsbx)->Fill(iEvent.bunchCrossing() % 3564, tbx % 70);
220  (*_orbitvsbxincycle)->Fill(tbx % 70, iEvent.orbitNumber());
221 
222  } else {
223  LogDebug("InvalidPhase") << "Invalid APVCyclePhase value : " << _phasepart << " " << thephase;
224  }
225  }
226 }
227 
229  _rhm.beginRun(iRun);
230 
231  if (*_dbx) {
232  (*_dbx)->GetXaxis()->SetTitle("#DeltaBX");
233  }
234 
235  LogDebug("NomberOfHistos") << m_dbxhistos.size();
236  for (std::vector<TH1F**>::const_iterator dbxhist = m_dbxhistos.begin(); dbxhist != m_dbxhistos.end(); ++dbxhist) {
237  LogDebug("HistoPointer") << *dbxhist;
238  if (*(*dbxhist)) {
239  (*(*dbxhist))->GetXaxis()->SetTitle("#DeltaBX");
240  }
241  }
242  LogDebug("LabelDone") << "all labels set";
243 
244  if (*_bx) {
245  (*_bx)->GetXaxis()->SetTitle("BX");
246  }
247 
248  if (*_bxincycle) {
249  (*_bxincycle)->GetXaxis()->SetTitle("Event BX mod(70)");
250  }
251 
252  if (*_orbit) {
253  (*_orbit)->SetCanExtend(TH1::kXaxis);
254  (*_orbit)->GetXaxis()->SetTitle("time [Orb#]");
255  }
256 
257  LogDebug("StdPlotsDone") << "all labels in std plots set";
258 
260  (*_dbxvsbxincycle)->GetXaxis()->SetTitle("Event BX mod(70)");
261  (*_dbxvsbxincycle)->GetYaxis()->SetTitle("#DeltaBX");
262  }
263 
264  if (_dbxvsbx && *_dbxvsbx) {
265  (*_dbxvsbx)->GetXaxis()->SetTitle("BX");
266  (*_dbxvsbx)->GetYaxis()->SetTitle("#DeltaBX");
267  }
268 
269  if (_bxincyclevsbx && *_bxincyclevsbx) {
270  (*_bxincyclevsbx)->GetXaxis()->SetTitle("BX");
271  (*_bxincyclevsbx)->GetYaxis()->SetTitle("Event BX mod(70)");
272  }
273 
275  (*_orbitvsbxincycle)->SetCanExtend(TH1::kYaxis);
276  (*_orbitvsbxincycle)->GetXaxis()->SetTitle("Event BX mod(70)");
277  (*_orbitvsbxincycle)->GetYaxis()->SetTitle("time [Orb#]");
278  }
279 
280  if (m_ewhdepth && *m_ewhdepth) {
281  (*m_ewhdepth)->GetXaxis()->SetTitle("Depth");
282  }
283 }
284 
286 
287 // ------------ method called once each job just before starting event loop ------------
289 
290 // ------------ method called once each job just after ending the event loop ------------
291 void EventTimeDistribution::endJob() { edm::LogInfo("EndOfJob") << _nevents << " analyzed events"; }
292 
293 //define this as a plug-in
EventTimeDistribution::_wantorbitvsbxincycle
const bool _wantorbitvsbxincycle
Definition: EventTimeDistribution.cc:73
EventTimeDistribution::_dbx
TH1F ** _dbx
Definition: EventTimeDistribution.cc:81
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
EventTimeDistribution::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: EventTimeDistribution.cc:228
electrons_cff.bool
bool
Definition: electrons_cff.py:393
EventTimeDistribution::_orbitvsbxincycle
TH2F ** _orbitvsbxincycle
Definition: EventTimeDistribution.cc:90
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
EventTimeDistribution::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EventTimeDistribution.cc:181
APVCyclePhaseCollection::multiphase
Definition: APVCyclePhaseCollection.h:21
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::Run
Definition: Run.h:45
EventTimeDistribution::beginJob
void beginJob() override
Definition: EventTimeDistribution.cc:288
edm::EDGetTokenT< EventWithHistory >
RunHistogramManager::makeTH2F
TH2F ** makeTH2F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax)
Definition: RunHistogramManager.cc:64
edm
HLT enums.
Definition: AlignableModifier.h:19
APVCyclePhaseCollection::invalid
Definition: APVCyclePhaseCollection.h:21
EventTimeDistribution::m_LSfrac
const unsigned int m_LSfrac
Definition: EventTimeDistribution.cc:76
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
EventTimeDistribution::_wantdbxvsbxincycle
const bool _wantdbxvsbxincycle
Definition: EventTimeDistribution.cc:70
EventTimeDistribution::_dbxvsbxincycle
TH2F ** _dbxvsbxincycle
Definition: EventTimeDistribution.cc:87
EventWithHistory.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
EventTimeDistribution::_bx
TH1F ** _bx
Definition: EventTimeDistribution.cc:84
edm::Handle
Definition: AssociativeIterator.h:50
EventTimeDistribution::m_dbxindices
std::vector< std::pair< unsigned int, unsigned int > > m_dbxindices
Definition: EventTimeDistribution.cc:83
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
EventTimeDistribution::_rhm
RunHistogramManager _rhm
Definition: EventTimeDistribution.cc:79
EventTimeDistribution::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: EventTimeDistribution.cc:285
MakerMacros.h
RunHistogramManager
Definition: RunHistogramManager.h:210
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
EventTimeDistribution::_bxincycle
TH1F ** _bxincycle
Definition: EventTimeDistribution.cc:85
RunHistogramManager.h
APVCyclePhaseCollection
Definition: APVCyclePhaseCollection.h:8
Run.h
EventTimeDistribution::_nevents
unsigned int _nevents
Definition: EventTimeDistribution.cc:74
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EventTimeDistribution::m_ewhdepth
TH1F ** m_ewhdepth
Definition: EventTimeDistribution.cc:91
TFileService.h
RunHistogramManager::makeTH1F
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:33
EventTimeDistribution::_orbit
TH1F ** _orbit
Definition: EventTimeDistribution.cc:86
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EventTimeDistribution::_phasepart
const std::string _phasepart
Definition: EventTimeDistribution.cc:69
EventTimeDistribution::m_ewhdepthHisto
const bool m_ewhdepthHisto
Definition: EventTimeDistribution.cc:77
RunHistogramManager::beginRun
void beginRun(const edm::Run &iRun)
Definition: RunHistogramManager.cc:101
EventTimeDistribution::_wantbxincyclevsbx
const bool _wantbxincyclevsbx
Definition: EventTimeDistribution.cc:72
APVCyclePhaseCollection.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
EventWithHistory
Definition: EventWithHistory.h:17
EventTimeDistribution::_historyProductToken
edm::EDGetTokenT< EventWithHistory > _historyProductToken
Definition: EventTimeDistribution.cc:67
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
EventTimeDistribution::EventTimeDistribution
EventTimeDistribution(const edm::ParameterSet &)
Definition: EventTimeDistribution.cc:105
InputTag.h
EventTimeDistribution::_dbxvsbx
TH2F ** _dbxvsbx
Definition: EventTimeDistribution.cc:88
EventTimeDistribution
Definition: EventTimeDistribution.cc:53
EventTimeDistribution::_bxincyclevsbx
TH2F ** _bxincyclevsbx
Definition: EventTimeDistribution.cc:89
std
Definition: JetResolutionObject.h:76
EventTimeDistribution::_wantdbxvsbx
const bool _wantdbxvsbx
Definition: EventTimeDistribution.cc:71
hcalSimParameters_cfi.he
he
Definition: hcalSimParameters_cfi.py:79
Frameworkfwd.h
APVCyclePhaseCollection::getPhase
const int getPhase(const std::string partition) const
Definition: APVCyclePhaseCollection.cc:5
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EventTimeDistribution::endJob
void endJob() override
Definition: EventTimeDistribution.cc:291
EventTimeDistribution::m_dbxhistos
std::vector< TH1F ** > m_dbxhistos
Definition: EventTimeDistribution.cc:82
EventTimeDistribution::~EventTimeDistribution
~EventTimeDistribution() override
Definition: EventTimeDistribution.cc:171
ParameterSet.h
APVCyclePhaseCollection::nopartition
Definition: APVCyclePhaseCollection.h:21
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
EventTimeDistribution::m_maxLS
const unsigned int m_maxLS
Definition: EventTimeDistribution.cc:75
edm::InputTag
Definition: InputTag.h:15
EventTimeDistribution::_apvphasecollToken
edm::EDGetTokenT< APVCyclePhaseCollection > _apvphasecollToken
Definition: EventTimeDistribution.cc:68