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 
13 
14 //
15 // constructors and destructor
16 //
17 
19 {
20 
21  // DQM ROOT output
22  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile","myfile.root");
23 
24  dbe_ = 0;
25  // get hold of back-end interface
26  dbe_ = edm::Service<DQMStore>().operator->();
27 
28  Char_t histo[100];
29 
30  if ( dbe_ ) {
31  dbe_->setCurrentFolder("NoiseRatesV/NoiseRatesTask");
32  }
33 
34  // set parameters
35  rbxCollName_ = iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName");
36  minRBXEnergy_ = iConfig.getUntrackedParameter<double>("minRBXEnergy");
37  minHitEnergy_ = iConfig.getUntrackedParameter<double>("minHitEnergy");
38 
39  useAllHistos_ = iConfig.getUntrackedParameter<bool>("useAllHistos", false);
40 
41  // book histograms
42 
43  //Lumi block is not drawn; the rest are
44  if (useAllHistos_){
45  sprintf (histo, "hLumiBlockCount" );
46  hLumiBlockCount_ = dbe_->book1D(histo, histo, 1, -0.5, 0.5);
47  }
48 
49  sprintf (histo, "hRBXEnergy" );
50  hRBXEnergy_ = dbe_->book1D(histo, histo, 300, 0, 3000);
51 
52  sprintf (histo, "hRBXEnergyType1" );
53  hRBXEnergyType1_ = dbe_->book1D(histo, histo, 300, 0, 3000);
54 
55  sprintf (histo, "hRBXEnergyType2" );
56  hRBXEnergyType2_ = dbe_->book1D(histo, histo, 300, 0, 3000);
57 
58  sprintf (histo, "hRBXEnergyType3" );
59  hRBXEnergyType3_ = dbe_->book1D(histo, histo, 300, 0, 3000);
60 
61  sprintf (histo, "hRBXNHits" );
62  hRBXNHits_ = dbe_->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.getByLabel(rbxCollName_,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  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
128 */
129 }
130 
131 
132 //define this as a plug-in
MonitorElement * hRBXEnergy_
Definition: NoiseRates.h:60
T getUntrackedParameter(std::string const &, T const &) const
std::string outputFile_
Definition: NoiseRates.h:51
#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:243
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
tuple handle
Definition: patZpeak.py:22
MonitorElement * hRBXEnergyType2_
Definition: NoiseRates.h:62
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
NoiseRates(const edm::ParameterSet &)
Definition: NoiseRates.cc:18
edm::InputTag rbxCollName_
Definition: NoiseRates.h:54
MonitorElement * hRBXEnergyType1_
Definition: NoiseRates.h:61
double minHitEnergy_
Definition: NoiseRates.h:56
DQMStore * dbe_
Definition: NoiseRates.h:50
virtual void endJob()
Definition: NoiseRates.cc:123
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: NoiseRates.cc:78
virtual void beginJob()
Definition: NoiseRates.cc:119