00001 #include <memory>
00002 #include <fstream>
00003 #include <iostream>
00004
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "FWCore/Framework/interface/MakerMacros.h"
00008 #include "FWCore/Framework/interface/Frameworkfwd.h"
00009 #include "FWCore/ParameterSet/interface/FileInPath.h"
00010 #include "DataFormats/DetId/interface/DetId.h"
00011 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00012 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00013 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00014 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00015 #include "DQMServices/Core/interface/MonitorElement.h"
00016 #include "DQMServices/Core/interface/DQMStore.h"
00017 #include "DQM/EcalPreshowerMonitorModule/interface/ESOccupancyTask.h"
00018
00019 #include "TStyle.h"
00020 #include "TH2F.h"
00021
00022 using namespace cms;
00023 using namespace edm;
00024 using namespace std;
00025
00026 ESOccupancyTask::ESOccupancyTask(const edm::ParameterSet& ps) {
00027
00028 rechitlabel_ = ps.getParameter<InputTag>("RecHitLabel");
00029 digilabel_ = ps.getParameter<InputTag>("DigiLabel");
00030 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
00031
00032 dqmStore_ = Service<DQMStore>().operator->();
00033 eCount_ = 0;
00034
00035
00036 for (int i = 0; i < 2; ++i)
00037 for (int j = 0; j < 2; ++j) {
00038 hRecOCC_[i][j] = 0;
00039 hRecNHit_[i][j] = 0;
00040 hEng_[i][j] = 0;
00041 hEvEng_[i][j] = 0;
00042 hEnDensity_[i][i] = 0;
00043 hDigiNHit_[i][j] = 0;
00044
00045 hSelEng_[i][j] = 0;
00046 hSelOCC_[i][j] = 0;
00047 hSelEnDensity_[i][j] = 0;
00048 }
00049
00050 for (int i = 0; i<2; ++i)
00051 hE1E2_[i]=0;
00052
00053 dqmStore_->setCurrentFolder(prefixME_ + "/ESOccupancyTask");
00054
00055
00056
00057 char histo[200];
00058 for (int i=0 ; i<2; ++i)
00059 for (int j=0 ; j<2; ++j) {
00060 int iz = (i==0)? 1:-1;
00061 sprintf(histo, "ES RecHit 2D Occupancy Z %d P %d", iz, j+1);
00062 hRecOCC_[i][j] = dqmStore_->book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
00063 hRecOCC_[i][j]->setAxisTitle("Si X", 1);
00064 hRecOCC_[i][j]->setAxisTitle("Si Y", 2);
00065
00066
00067 sprintf(histo, "ES Energy Density Z %d P %d", iz, j+1);
00068 hEnDensity_[i][j] = dqmStore_->book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
00069 hEnDensity_[i][j]->setAxisTitle("Si X", 1);
00070 hEnDensity_[i][j]->setAxisTitle("Si Y", 2);
00071
00072 sprintf(histo, "ES Num of RecHits Z %d P %d", iz, j+1);
00073 hRecNHit_[i][j] = dqmStore_->book1DD(histo, histo, 60, 0, 1920);
00074 hRecNHit_[i][j]->setAxisTitle("# of RecHits", 1);
00075 hRecNHit_[i][j]->setAxisTitle("Num of Events", 2);
00076
00077 sprintf(histo, "ES Num of Good RecHits Z %d P %d", iz, j+1);
00078 hDigiNHit_[i][j] = dqmStore_->book1DD(histo, histo, 60, 0, 1920);
00079 hDigiNHit_[i][j]->setAxisTitle("# of good RecHits", 1);
00080 hDigiNHit_[i][j]->setAxisTitle("Num of Events", 2);
00081
00082 sprintf(histo, "ES RecHit Energy Z %d P %d", iz, j+1);
00083 hEng_[i][j] = dqmStore_->book1DD(histo, histo, 50, 0, 0.001);
00084 hEng_[i][j]->setAxisTitle("RecHit Energy", 1);
00085 hEng_[i][j]->setAxisTitle("Num of ReHits", 2);
00086
00087 sprintf(histo, "ES Event Energy Z %d P %d", iz, j+1);
00088 hEvEng_[i][j] = dqmStore_->book1DD(histo, histo, 50, 0, 0.1);
00089 hEvEng_[i][j]->setAxisTitle("Event Energy", 1);
00090 hEvEng_[i][j]->setAxisTitle("Num of Events", 2);
00091
00092
00093 sprintf(histo, "ES RecHit Energy with selected hits Z %d P %d", iz, j+1);
00094 hSelEng_[i][j] = dqmStore_->book1DD(histo, histo, 50, 0, 0.001);
00095 hSelEng_[i][j]->setAxisTitle("RecHit Energy", 1);
00096 hSelEng_[i][j]->setAxisTitle("Num of ReHits", 2);
00097
00098 sprintf(histo, "ES Occupancy with selected hits Z %d P %d", iz, j+1);
00099 hSelOCC_[i][j] = dqmStore_->book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
00100 hSelOCC_[i][j]->setAxisTitle("Si X", 1);
00101 hSelOCC_[i][j]->setAxisTitle("Si Y", 2);
00102
00103 sprintf(histo, "ES Energy Density with selected hits Z %d P %d", iz, j+1);
00104 hSelEnDensity_[i][j] = dqmStore_->book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
00105 hSelEnDensity_[i][j]->setAxisTitle("Si X", 1);
00106 hSelEnDensity_[i][j]->setAxisTitle("Si Y", 2);
00107 }
00108
00109 hE1E2_[0] = dqmStore_->book2D("ES+ EP1 vs EP2", "ES+ EP1 vs EP2", 50, 0, 0.1, 50, 0, 0.1);
00110 hE1E2_[1] = dqmStore_->book2D("ES- EP1 vs EP2", "ES- EP1 vs EP2", 50, 0, 0.1, 50, 0, 0.1);
00111
00112 }
00113
00114 ESOccupancyTask::~ESOccupancyTask() {
00115 }
00116
00117 void ESOccupancyTask::beginJob(void) {
00118 }
00119
00120 void ESOccupancyTask::endJob() {
00121 }
00122
00123 void ESOccupancyTask::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
00124
00125 runNum_ = e.id().run();
00126 eCount_++;
00127
00128
00129 int zside, plane, ix, iy, strip;
00130 int sum_RecHits[2][2], sum_DigiHits[2][2], sum_SelHits[2][2];
00131 float sum_Energy[2][2];
00132
00133 for (int i = 0; i < 2; ++i)
00134 for (int j = 0; j < 2; ++j) {
00135 sum_RecHits[i][j] = 0;
00136 sum_DigiHits[i][j] = 0;
00137 sum_Energy[i][j] = 0;
00138 sum_SelHits[i][j] = 0;
00139 }
00140
00141 Handle<ESRecHitCollection> ESRecHit;
00142 if ( e.getByLabel(rechitlabel_, ESRecHit) ) {
00143
00144 for (ESRecHitCollection::const_iterator hitItr = ESRecHit->begin(); hitItr != ESRecHit->end(); ++hitItr) {
00145
00146 ESDetId id = ESDetId(hitItr->id());
00147
00148 zside = id.zside();
00149 plane = id.plane();
00150 ix = id.six();
00151 iy = id.siy();
00152 strip = id.strip();
00153
00154 int i = (zside==1)? 0:1;
00155 int j = plane-1;
00156
00157 sum_RecHits[i][j]++;
00158 sum_Energy[i][j] += hitItr->energy();
00159 hRecOCC_[i][j]->Fill(ix, iy);
00160 if (hitItr->energy() != 0) {
00161 hEng_[i][j]->Fill(hitItr->energy());
00162 hEnDensity_[i][j]->Fill(ix, iy, hitItr->energy());
00163
00164 if (hitItr->recoFlag()==14 || hitItr->recoFlag()==1 || (hitItr->recoFlag()<=10 && hitItr->recoFlag()>=5)) continue;
00165 hSelEng_[i][j]->Fill(hitItr->energy());
00166 hSelEnDensity_[i][j]->Fill(ix, iy, hitItr->energy());
00167 hSelOCC_[i][j]->Fill(ix, iy);
00168 }
00169
00170 }
00171 } else {
00172 LogWarning("ESOccupancyTask") << rechitlabel_ << " not available";
00173 }
00174
00175
00176 for (int i = 0; i < 2; ++i)
00177 for (int j = 0; j < 2; ++j) {
00178
00179 hRecNHit_[i][j]->Fill(sum_RecHits[i][j]);
00180 hDigiNHit_[i][j]->Fill(sum_DigiHits[i][j]);
00181 hEvEng_[i][j]->Fill(sum_Energy[i][j]);
00182
00183
00184 hRecOCC_[i][j]->setBinContent(40,40,eCount_);
00185 hEnDensity_[i][j]->setBinContent(40,40,eCount_);
00186
00187 hSelOCC_[i][j]->setBinContent(40,40,eCount_);
00188 hSelEnDensity_[i][j]->setBinContent(40,40,eCount_);
00189 }
00190
00191 hE1E2_[0]->Fill(sum_Energy[0][0], sum_Energy[0][1]);
00192 hE1E2_[1]->Fill(sum_Energy[1][0], sum_Energy[1][1]);
00193
00194 }
00195
00196
00197 DEFINE_FWK_MODULE(ESOccupancyTask);