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  dbe_ = 0;
24  // get hold of back-end interface
25  dbe_ = edm::Service<DQMStore>().operator->();
26 
27  Char_t histo[100];
28 
29  if ( dbe_ ) {
30  dbe_->setCurrentFolder("NoiseRatesV/NoiseRatesTask");
31  }
32 
33  // set parameters
34  rbxCollName_ = iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName");
35  minRBXEnergy_ = iConfig.getUntrackedParameter<double>("minRBXEnergy");
36  minHitEnergy_ = iConfig.getUntrackedParameter<double>("minHitEnergy");
37 
38  tok_rbx_ = consumes<reco::HcalNoiseRBXCollection>(rbxCollName_);
39 
40  useAllHistos_ = iConfig.getUntrackedParameter<bool>("useAllHistos", false);
41 
42  // book histograms
43 
44  //Lumi block is not drawn; the rest are
45  if (useAllHistos_){
46  sprintf (histo, "hLumiBlockCount" );
47  hLumiBlockCount_ = dbe_->book1D(histo, histo, 1, -0.5, 0.5);
48  }
49 
50  sprintf (histo, "hRBXEnergy" );
51  hRBXEnergy_ = dbe_->book1D(histo, histo, 300, 0, 3000);
52 
53  sprintf (histo, "hRBXEnergyType1" );
54  hRBXEnergyType1_ = dbe_->book1D(histo, histo, 300, 0, 3000);
55 
56  sprintf (histo, "hRBXEnergyType2" );
57  hRBXEnergyType2_ = dbe_->book1D(histo, histo, 300, 0, 3000);
58 
59  sprintf (histo, "hRBXEnergyType3" );
60  hRBXEnergyType3_ = dbe_->book1D(histo, histo, 300, 0, 3000);
61 
62  sprintf (histo, "hRBXNHits" );
63  hRBXNHits_ = dbe_->book1D(histo, histo, 73,-0.5,72.5);
64 
65 }
66 
67 
69 {
70 }
71 
72 
73 //
74 // member functions
75 //
76 
77 // ------------ method called to for each event ------------
78 void
80 {
81 
82  // get the lumi section
83  int lumiSection = iEvent.luminosityBlock();
84  lumiCountMap_[lumiSection]++;
85 
86  // get the RBX Noise collection
88  iEvent.getByToken(tok_rbx_,handle);
89  if(!handle.isValid()) {
91  << " could not find HcalNoiseRBXCollection named " << rbxCollName_ << ".\n";
92  return;
93  }
94 
95  // loop over the RBXs and fill the histograms
96  for(reco::HcalNoiseRBXCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
97  const reco::HcalNoiseRBX &rbx=(*it);
98 
99  double energy = rbx.recHitEnergy(minHitEnergy_);
100 
101  int nhits = rbx.numRecHits(minHitEnergy_);
102 
103  if(energy < minRBXEnergy_) continue;
104 
105  hRBXEnergy_->Fill(energy);
106 
107  if (nhits <= 9) hRBXEnergyType1_->Fill(energy);
108  else if (nhits <= 18) hRBXEnergyType2_->Fill(energy);
109  else hRBXEnergyType3_->Fill(energy);
110 
111  hRBXNHits_->Fill(nhits);
112 
113  } // done looping over RBXs
114 
115 }
116 
117 
118 // ------------ method called once each job just before starting event loop ------------
119 void
121 
122 // ------------ method called once each job just after ending the event loop ------------
123 void
125 /*
126  if (useAllHistos_) hLumiBlockCount_->Fill(0.0, lumiCountMap_.size());
127 
128  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
129 */
130 }
131 
132 
133 //define this as a plug-in
MonitorElement * hRBXEnergy_
Definition: NoiseRates.h:62
T getUntrackedParameter(std::string const &, T const &) const
std::string outputFile_
Definition: NoiseRates.h:52
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool useAllHistos_
Definition: NoiseRates.h:59
int numRecHits(double threshold=1.5) const
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
MonitorElement * hRBXEnergyType3_
Definition: NoiseRates.h:65
MonitorElement * hLumiBlockCount_
Definition: NoiseRates.h:61
MonitorElement * hRBXNHits_
Definition: NoiseRates.h:66
std::map< int, int > lumiCountMap_
Definition: NoiseRates.h:69
void Fill(long long x)
double minRBXEnergy_
Definition: NoiseRates.h:57
int iEvent
Definition: GenABIO.cc:230
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
tuple handle
Definition: patZpeak.py:22
MonitorElement * hRBXEnergyType2_
Definition: NoiseRates.h:64
bool isValid() const
Definition: HandleBase.h:76
NoiseRates(const edm::ParameterSet &)
Definition: NoiseRates.cc:17
edm::InputTag rbxCollName_
Definition: NoiseRates.h:55
MonitorElement * hRBXEnergyType1_
Definition: NoiseRates.h:63
double minHitEnergy_
Definition: NoiseRates.h:58
DQMStore * dbe_
Definition: NoiseRates.h:51
virtual void endJob()
Definition: NoiseRates.cc:124
edm::EDGetTokenT< reco::HcalNoiseRBXCollection > tok_rbx_
Definition: NoiseRates.h:56
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: NoiseRates.cc:79
virtual void beginJob()
Definition: NoiseRates.cc:120