CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalNoiseRates.cc
Go to the documentation of this file.
1 //
2 // HcalNoiseRates.cc
3 //
4 // description: Calculation for single particle response corrections
5 //
6 // author: K. Hatakeyama, H. Liu, Baylor
7 //
8 //
9 
12 
13 //
14 // constructors and destructor
15 //
16 
18 {
19  // DQM ROOT output
20  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile","myfile.root");
21 
22 
23  // set parameters
24  rbxCollName_ = iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName");
25  tok_rbx_ = consumes<reco::HcalNoiseRBXCollection>(rbxCollName_);
26  minRBXEnergy_ = iConfig.getUntrackedParameter<double>("minRBXEnergy");
27  minHitEnergy_ = iConfig.getUntrackedParameter<double>("minHitEnergy");
28 
29  useAllHistos_ = iConfig.getUntrackedParameter<bool>("useAllHistos", false);
30 }
31 
32  void HcalNoiseRates::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & /* iRun*/, edm::EventSetup const & /* iSetup */)
33 
34 {
35 
36 
37  ibooker.setCurrentFolder("HcalNoiseRatesD/HcalNoiseRatesTask");
38 
39  Char_t histo[100];
40 
41  // book histograms
42 
43  //Lumi block is not drawn; the rest are
44  if (useAllHistos_){
45  sprintf (histo, "hLumiBlockCount" );
46  hLumiBlockCount_ = ibooker.book1D(histo, histo, 1, -0.5, 0.5);
47  }
48 
49  sprintf (histo, "hRBXEnergy" );
50  hRBXEnergy_ = ibooker.book1D(histo, histo, 300, 0, 3000);
51 
52  sprintf (histo, "hRBXEnergyType1" );
53  hRBXEnergyType1_ = ibooker.book1D(histo, histo, 300, 0, 3000);
54 
55  sprintf (histo, "hRBXEnergyType2" );
56  hRBXEnergyType2_ = ibooker.book1D(histo, histo, 300, 0, 3000);
57 
58  sprintf (histo, "hRBXEnergyType3" );
59  hRBXEnergyType3_ = ibooker.book1D(histo, histo, 300, 0, 3000);
60 
61  sprintf (histo, "hRBXNHits" );
62  hRBXNHits_ = ibooker.book1D(histo, histo, 73,-0.5,72.5);
63 
64 }
65 
66 
68 {
69 }
70 
71 
72 //
73 // member functions
74 //
75 
76 // ------------ method called to for each event ------------
77 void
79 {
80 
81  // get the lumi section
82  int lumiSection = iEvent.luminosityBlock();
83  lumiCountMap_[lumiSection]++;
84 
85  // get the RBX Noise collection
87  iEvent.getByToken(tok_rbx_,handle);
88  if(!handle.isValid()) {
90  << " could not find HcalNoiseRBXCollection named " << rbxCollName_ << ".\n";
91  return;
92  }
93 
94  // loop over the RBXs and fill the histograms
95  for(reco::HcalNoiseRBXCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
96  const reco::HcalNoiseRBX &rbx=(*it);
97 
98  double energy = rbx.recHitEnergy(minHitEnergy_);
99 
100  int nhits = rbx.numRecHits(minHitEnergy_);
101 
102  if(energy < minRBXEnergy_) continue;
103 
104  hRBXEnergy_->Fill(energy);
105 
106  if (nhits <= 9) hRBXEnergyType1_->Fill(energy);
107  else if (nhits <= 18) hRBXEnergyType2_->Fill(energy);
108  else hRBXEnergyType3_->Fill(energy);
109 
110  hRBXNHits_->Fill(nhits);
111 
112  } // done looping over RBXs
113 
114 }
115 
116 
117 // ------------ method called once each job just before starting event loop ------------
118 void
120 
121 // ------------ method called once each job just after ending the event loop ------------
122 void
124 
125  if (useAllHistos_) hLumiBlockCount_->Fill(0.0, lumiCountMap_.size());
126 
127 }
128 
129 
130 //define this as a plug-in
virtual void endJob()
T getUntrackedParameter(std::string const &, T const &) const
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
HcalNoiseRates(const edm::ParameterSet &)
virtual void beginJob()
edm::InputTag rbxCollName_
MonitorElement * hRBXEnergyType1_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int numRecHits(double threshold=1.5) const
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
MonitorElement * hRBXEnergy_
MonitorElement * hRBXEnergyType2_
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
tuple handle
Definition: patZpeak.py:22
bool isValid() const
Definition: HandleBase.h:76
edm::EDGetTokenT< reco::HcalNoiseRBXCollection > tok_rbx_
std::string outputFile_
MonitorElement * hRBXEnergyType3_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
virtual void analyze(const edm::Event &, const edm::EventSetup &)
double minHitEnergy_
MonitorElement * hLumiBlockCount_
std::map< int, int > lumiCountMap_
double minRBXEnergy_
MonitorElement * hRBXNHits_
Definition: Run.h:41