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 
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("HcalNoiseRatesD/HcalNoiseRatesTask");
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
virtual void endJob()
T getUntrackedParameter(std::string const &, T const &) const
HcalNoiseRates(const edm::ParameterSet &)
virtual void beginJob()
edm::InputTag rbxCollName_
MonitorElement * hRBXEnergyType1_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
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:243
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
tuple handle
Definition: patZpeak.py:22
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::string outputFile_
MonitorElement * hRBXEnergyType3_
virtual void analyze(const edm::Event &, const edm::EventSetup &)
double minHitEnergy_
DQMStore * dbe_
MonitorElement * hLumiBlockCount_
std::map< int, int > lumiCountMap_
double minRBXEnergy_
MonitorElement * hRBXNHits_