CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NoiseRates.cc
Go to the documentation of this file.
1 //
2 // NoiseRates.cc
3 //
4 // description: Calculation for single particle response corrections
5 //
6 // author: J.P. Chou, Brown
7 //
8 //
9 
12 
13 //
14 // constructors and destructor
15 //
16 
18  // DQM ROOT output
19  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");
20 
21  // set parameters
22  rbxCollName_ = iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName");
23  minRBXEnergy_ = iConfig.getUntrackedParameter<double>("minRBXEnergy");
24  minHitEnergy_ = iConfig.getUntrackedParameter<double>("minHitEnergy");
25 
26  tok_rbx_ = consumes<reco::HcalNoiseRBXCollection>(rbxCollName_);
27 
28  useAllHistos_ = iConfig.getUntrackedParameter<bool>("useAllHistos", false);
29 
30  // Hcal Noise Summary
31  noisetoken_ = consumes<HcalNoiseSummary>(iConfig.getParameter<edm::InputTag>("noiselabel"));
32 }
33 
35 
36 //
37 // member functions
38 //
39 
41  ib.setCurrentFolder("NoiseRatesV/NoiseRatesTask");
42 
43  // book histograms
44  Char_t histo[100];
45 
46  // Lumi block is not drawn; the rest are
47  if (useAllHistos_) {
48  sprintf(histo, "hLumiBlockCount");
49  hLumiBlockCount_ = ib.book1D(histo, histo, 1, -0.5, 0.5);
50  }
51 
52  sprintf(histo, "hRBXEnergy");
53  hRBXEnergy_ = ib.book1D(histo, histo, 300, 0, 3000);
54 
55  sprintf(histo, "hRBXEnergyType1");
56  hRBXEnergyType1_ = ib.book1D(histo, histo, 300, 0, 3000);
57 
58  sprintf(histo, "hRBXEnergyType2");
59  hRBXEnergyType2_ = ib.book1D(histo, histo, 300, 0, 3000);
60 
61  sprintf(histo, "hRBXEnergyType3");
62  hRBXEnergyType3_ = ib.book1D(histo, histo, 300, 0, 3000);
63 
64  sprintf(histo, "hRBXNHits");
65  hRBXNHits_ = ib.book1D(histo, histo, 73, -0.5, 72.5);
66 
67  // HcalNoiseSummary
68 
69  sprintf(histo, "nNNumChannels");
70  nNNumChannels_ = ib.book1D(histo, histo, 100, 0, 100);
71  sprintf(histo, "nNSumE");
72  nNSumE_ = ib.book1D(histo, histo, 100, 0, 5000);
73  sprintf(histo, "nNSumEt");
74  nNSumEt_ = ib.book1D(histo, histo, 100, 0, 2000);
75 
76  sprintf(histo, "sNNumChannels");
77  sNNumChannels_ = ib.book1D(histo, histo, 100, 0, 100);
78  sprintf(histo, "sNSumE");
79  sNSumE_ = ib.book1D(histo, histo, 100, 0, 5000);
80  sprintf(histo, "sNSumEt");
81  sNSumEt_ = ib.book1D(histo, histo, 100, 0, 2000);
82 
83  sprintf(histo, "iNNumChannels");
84  iNNumChannels_ = ib.book1D(histo, histo, 100, 0, 100);
85  sprintf(histo, "iNSumE");
86  iNSumE_ = ib.book1D(histo, histo, 100, 0, 5000);
87  sprintf(histo, "iNSumEt");
88  iNSumEt_ = ib.book1D(histo, histo, 100, 0, 2000);
89 
90  sprintf(histo, "hNoise_maxZeros");
91  hNoise_maxZeros_ = ib.book1D(histo, histo, 80, 0, 80);
92  sprintf(histo, "hNoise_maxHPDHits");
93  hNoise_maxHPDHits_ = ib.book1D(histo, histo, 20, 0, 20);
94  sprintf(histo, "hNoise_maxHPDNoOtherHits");
95  hNoise_maxHPDNoOtherHits_ = ib.book1D(histo, histo, 20, 0, 20);
96 }
97 
98 // ------------ method called to for each event ------------
99 void NoiseRates::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
100  // get the lumi section
101  int lumiSection = iEvent.luminosityBlock();
102  lumiCountMap_[lumiSection]++;
103 
104  // get the RBX Noise collection
106  iEvent.getByToken(tok_rbx_, handle);
107  if (!handle.isValid()) {
109  << " could not find HcalNoiseRBXCollection named " << rbxCollName_ << ".\n";
110  return;
111  }
112 
113  // get the Noise summary object
115  iEvent.getByToken(noisetoken_, summary_h);
116  if (!summary_h.isValid()) {
117  throw edm::Exception(edm::errors::ProductNotFound) << " could not find HcalNoiseSummary.\n";
118  return;
119  }
120  const HcalNoiseSummary summary = *summary_h;
121 
122  // Fill the Noise Summary histograms
124  nNSumE_->Fill(summary.NegativeNoiseSumE());
125  nNSumEt_->Fill(summary.NegativeNoiseSumEt());
126 
128  sNSumE_->Fill(summary.spikeNoiseSumE());
129  sNSumEt_->Fill(summary.spikeNoiseSumEt());
130 
132  iNSumE_->Fill(summary.isolatedNoiseSumE());
133  iNSumEt_->Fill(summary.isolatedNoiseSumEt());
134 
135  hNoise_maxZeros_->Fill(summary.maxZeros());
136  hNoise_maxHPDHits_->Fill(summary.maxHPDHits());
138 
139  // loop over the RBXs and fill the histograms
140  for (reco::HcalNoiseRBXCollection::const_iterator it = handle->begin(); it != handle->end(); ++it) {
141  const reco::HcalNoiseRBX &rbx = (*it);
142 
143  double energy = rbx.recHitEnergy(minHitEnergy_);
144 
145  int nhits = rbx.numRecHits(minHitEnergy_);
146 
147  if (energy < minRBXEnergy_)
148  continue;
149 
150  hRBXEnergy_->Fill(energy);
151 
152  if (nhits <= 9)
153  hRBXEnergyType1_->Fill(energy);
154  else if (nhits <= 18)
155  hRBXEnergyType2_->Fill(energy);
156  else
157  hRBXEnergyType3_->Fill(energy);
158 
159  hRBXNHits_->Fill(nhits);
160 
161  } // done looping over RBXs
162 }
163 
164 // define this as a plug-in
float NegativeNoiseSumEt(void) const
int numSpikeNoiseChannels(void) const
MonitorElement * sNNumChannels_
Definition: NoiseRates.h:77
MonitorElement * hRBXEnergy_
Definition: NoiseRates.h:65
T getUntrackedParameter(std::string const &, T const &) const
int ib
Definition: cuy.py:661
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
~NoiseRates() override
Definition: NoiseRates.cc:34
MonitorElement * hNoise_maxHPDNoOtherHits_
Definition: NoiseRates.h:87
std::string outputFile_
Definition: NoiseRates.h:51
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int numIsolatedNoiseChannels(void) const
float spikeNoiseSumE(void) const
edm::EDGetTokenT< HcalNoiseSummary > noisetoken_
Definition: NoiseRates.h:62
bool useAllHistos_
Definition: NoiseRates.h:59
int numRecHits(double threshold=1.5) const
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
MonitorElement * hRBXEnergyType3_
Definition: NoiseRates.h:68
MonitorElement * hLumiBlockCount_
Definition: NoiseRates.h:64
MonitorElement * hRBXNHits_
Definition: NoiseRates.h:69
MonitorElement * nNNumChannels_
Definition: NoiseRates.h:73
float spikeNoiseSumEt(void) const
std::map< int, int > lumiCountMap_
Definition: NoiseRates.h:90
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: NoiseRates.cc:40
double minRBXEnergy_
Definition: NoiseRates.h:56
void Fill(long long x)
int numNegativeNoiseChannels(void) const
float isolatedNoiseSumEt(void) const
int iEvent
Definition: GenABIO.cc:224
MonitorElement * hNoise_maxZeros_
Definition: NoiseRates.h:85
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:76
MonitorElement * iNNumChannels_
Definition: NoiseRates.h:81
tuple handle
Definition: patZpeak.py:23
MonitorElement * hRBXEnergyType2_
Definition: NoiseRates.h:67
bool isValid() const
Definition: HandleBase.h:70
NoiseRates(const edm::ParameterSet &)
Definition: NoiseRates.cc:17
MonitorElement * hNoise_maxHPDHits_
Definition: NoiseRates.h:86
edm::InputTag rbxCollName_
Definition: NoiseRates.h:54
MonitorElement * iNSumEt_
Definition: NoiseRates.h:83
MonitorElement * sNSumEt_
Definition: NoiseRates.h:79
MonitorElement * hRBXEnergyType1_
Definition: NoiseRates.h:66
MonitorElement * nNSumEt_
Definition: NoiseRates.h:75
double minHitEnergy_
Definition: NoiseRates.h:57
MonitorElement * iNSumE_
Definition: NoiseRates.h:82
float NegativeNoiseSumE(void) const
MonitorElement * nNSumE_
Definition: NoiseRates.h:74
MonitorElement * sNSumE_
Definition: NoiseRates.h:78
int maxZeros(void) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
float isolatedNoiseSumE(void) const
int maxHPDNoOtherHits(void) const
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: NoiseRates.cc:99
edm::EDGetTokenT< reco::HcalNoiseRBXCollection > tok_rbx_
Definition: NoiseRates.h:55
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
int maxHPDHits(void) const
Definition: Run.h:45