CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 {
19 
20  // DQM ROOT output
21  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile","myfile.root");
22 
23  // set parameters
24  rbxCollName_ = iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName");
25  minRBXEnergy_ = iConfig.getUntrackedParameter<double>("minRBXEnergy");
26  minHitEnergy_ = iConfig.getUntrackedParameter<double>("minHitEnergy");
27 
28  tok_rbx_ = consumes<reco::HcalNoiseRBXCollection>(rbxCollName_);
29 
30  useAllHistos_ = iConfig.getUntrackedParameter<bool>("useAllHistos", false);
31 
32 }
33 
34 
36 {
37 }
38 
39 
40 //
41 // member functions
42 //
43 
45 {
46 
47  ib.setCurrentFolder("NoiseRatesV/NoiseRatesTask");
48 
49  // book histograms
50  Char_t histo[100];
51 
52  //Lumi block is not drawn; the rest are
53  if (useAllHistos_){
54  sprintf (histo, "hLumiBlockCount" );
55  hLumiBlockCount_ = ib.book1D(histo, histo, 1, -0.5, 0.5);
56  }
57 
58  sprintf (histo, "hRBXEnergy" );
59  hRBXEnergy_ = ib.book1D(histo, histo, 300, 0, 3000);
60 
61  sprintf (histo, "hRBXEnergyType1" );
62  hRBXEnergyType1_ = ib.book1D(histo, histo, 300, 0, 3000);
63 
64  sprintf (histo, "hRBXEnergyType2" );
65  hRBXEnergyType2_ = ib.book1D(histo, histo, 300, 0, 3000);
66 
67  sprintf (histo, "hRBXEnergyType3" );
68  hRBXEnergyType3_ = ib.book1D(histo, histo, 300, 0, 3000);
69 
70  sprintf (histo, "hRBXNHits" );
71  hRBXNHits_ = ib.book1D(histo, histo, 73,-0.5,72.5);
72 
73 }
74 
75 // ------------ method called to for each event ------------
76 void
78 {
79 
80  // get the lumi section
81  int lumiSection = iEvent.luminosityBlock();
82  lumiCountMap_[lumiSection]++;
83 
84  // get the RBX Noise collection
86  iEvent.getByToken(tok_rbx_,handle);
87  if(!handle.isValid()) {
89  << " could not find HcalNoiseRBXCollection named " << rbxCollName_ << ".\n";
90  return;
91  }
92 
93  // loop over the RBXs and fill the histograms
94  for(reco::HcalNoiseRBXCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
95  const reco::HcalNoiseRBX &rbx=(*it);
96 
97  double energy = rbx.recHitEnergy(minHitEnergy_);
98 
99  int nhits = rbx.numRecHits(minHitEnergy_);
100 
101  if(energy < minRBXEnergy_) continue;
102 
103  hRBXEnergy_->Fill(energy);
104 
105  if (nhits <= 9) hRBXEnergyType1_->Fill(energy);
106  else if (nhits <= 18) hRBXEnergyType2_->Fill(energy);
107  else hRBXEnergyType3_->Fill(energy);
108 
109  hRBXNHits_->Fill(nhits);
110 
111  } // done looping over RBXs
112 
113 }
114 
115 
116 //define this as a plug-in
MonitorElement * hRBXEnergy_
Definition: NoiseRates.h:60
T getUntrackedParameter(std::string const &, T const &) const
int ib
Definition: cuy.py:660
std::string outputFile_
Definition: NoiseRates.h:50
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool useAllHistos_
Definition: NoiseRates.h:57
int numRecHits(double threshold=1.5) const
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
MonitorElement * hRBXEnergyType3_
Definition: NoiseRates.h:63
MonitorElement * hLumiBlockCount_
Definition: NoiseRates.h:59
MonitorElement * hRBXNHits_
Definition: NoiseRates.h:64
std::map< int, int > lumiCountMap_
Definition: NoiseRates.h:67
void Fill(long long x)
double minRBXEnergy_
Definition: NoiseRates.h:55
int iEvent
Definition: GenABIO.cc:230
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
tuple handle
Definition: patZpeak.py:22
MonitorElement * hRBXEnergyType2_
Definition: NoiseRates.h:62
bool isValid() const
Definition: HandleBase.h:76
NoiseRates(const edm::ParameterSet &)
Definition: NoiseRates.cc:17
edm::InputTag rbxCollName_
Definition: NoiseRates.h:53
MonitorElement * hRBXEnergyType1_
Definition: NoiseRates.h:61
double minHitEnergy_
Definition: NoiseRates.h:56
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: NoiseRates.cc:44
edm::EDGetTokenT< reco::HcalNoiseRBXCollection > tok_rbx_
Definition: NoiseRates.h:54
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: NoiseRates.cc:77
Definition: Run.h:41