00001 #include "Validation/HcalHits/interface/SimHitsValidationHcal.h"
00002 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00003
00004
00005
00006 SimHitsValidationHcal::SimHitsValidationHcal(const edm::ParameterSet& ps) {
00007
00008 g4Label = ps.getUntrackedParameter<std::string>("moduleLabel","g4SimHits");
00009 hcalHits = ps.getUntrackedParameter<std::string>("HitCollection","HcalHits");
00010 verbose_ = ps.getUntrackedParameter<bool>("Verbose", false);
00011
00012 edm::LogInfo("HitsValidationHcal") << "Module Label: " << g4Label << " Hits: "
00013 << hcalHits;
00014
00015 dbe_ = edm::Service<DQMStore>().operator->();
00016 if (dbe_) {
00017 if (verbose_) {
00018 dbe_->setVerbose(1);
00019 sleep (3);
00020 dbe_->showDirStructure();
00021 } else {
00022 dbe_->setVerbose(0);
00023 }
00024 }
00025 }
00026
00027 SimHitsValidationHcal::~SimHitsValidationHcal() {}
00028
00029 void SimHitsValidationHcal::beginJob() {
00030
00031 if (dbe_) {
00032 std::cout << "Histograms booked\n";
00033 dbe_->setCurrentFolder("HcalHitsV/SimHitsValidationHcal");
00034
00035
00036 std::string divisions[25]={"HB0","HB1","HE0+z","HE1+z","HE2+z","HE0-z","HE1-z",
00037 "HE2-z","HO0","HFL0+z","HFS0+z","HFL1+z","HFS1+z",
00038 "HFL2+z","HFS2+z","HFL3+z","HFS3+z","HFL0-z","HFS0-z",
00039 "HFL1-z","HFS1-z","HFL2-z","HFS2-z","HFL3-z","HFS3-z"};
00040 double etaLow[25]={-16,-16,16,16,16,-29,-29,-29,-15,29,29,29,29,29,29,29,29,
00041 -41,-41,-41,-41,-41,-41,-41,-41};
00042 double etaHigh[25]={16,16,30,30,30,-30,-30,-30,15,41,41,41,41,41,41,41,41,
00043 -29,-29,-29,-29,-29,-29,-29,-29};
00044 int etaBins[25]={32,32,14,14,14,14,14,14,30,12,12,12,12,12,12,12,12,
00045 12,12,12,12,12,12,12,12};
00046 char name[40], title[100];
00047 for (int i=0; i<25; ++i) {
00048 sprintf (name, "HcalHitEta%s", divisions[i].c_str());
00049 sprintf (name, "Hit energy as a function of eta tower index in %s", divisions[i].c_str());
00050 meHcalHitEta_[i] = dbe_->book1D(name, title, etaBins[i], etaLow[i], etaHigh[i]);
00051 }
00052 }
00053 }
00054
00055 void SimHitsValidationHcal::endJob() {}
00056
00057 void SimHitsValidationHcal::analyze(const edm::Event& e, const edm::EventSetup& ) {
00058
00059 LogDebug("HitsValidationHcal") << "Run = " << e.id().run() << " Event = "
00060 << e.id().event();
00061
00062 std::vector<PCaloHit> caloHits;
00063 edm::Handle<edm::PCaloHitContainer> hitsHcal;
00064
00065 bool getHits = false;
00066 e.getByLabel(g4Label,hcalHits,hitsHcal);
00067 if (hitsHcal.isValid()) getHits = true;
00068
00069 LogDebug("HitsValidationHcal") << "HcalValidation: Input flags Hits " << getHits;
00070
00071 if (getHits) {
00072 caloHits.insert(caloHits.end(),hitsHcal->begin(),hitsHcal->end());
00073 LogDebug("HitsValidationHcal") << "HcalValidation: Hit buffer "
00074 << caloHits.size();
00075 analyzeHits (caloHits);
00076 }
00077 }
00078
00079 void SimHitsValidationHcal::analyzeHits (std::vector<PCaloHit>& hits) {
00080
00081 int nHit = hits.size();
00082 double entotHB = 0, entotHE = 0, entotHF = 0, entotHO = 0;
00083 int nHB=0, nHE=0, nHO=0, nHF=0;
00084
00085 for (int i=0; i<nHit; i++) {
00086 double energy = hits[i].energy();
00087 double time = hits[i].time();
00088 unsigned int id_ = hits[i].id();
00089 HcalDetId id = HcalDetId(id_);
00090 int det = id.det();
00091 int subdet = id.subdet();
00092 int depth = id.depth();
00093 int eta = id.ieta();
00094 int phi = id.iphi();
00095 unsigned int dep = hits[i].depth();
00096 int type =-1;
00097 if (subdet == static_cast<int>(HcalBarrel)) {
00098 entotHB += energy;
00099 nHB++;
00100 type = depth-1;
00101 } else if (subdet == static_cast<int>(HcalEndcap)) {
00102 entotHE += energy;
00103 nHE++;
00104 type = depth+2;
00105 if (eta < 0) type += 3;
00106 } else if (subdet == static_cast<int>(HcalOuter)) {
00107 entotHO += energy;
00108 nHO++;
00109 type = 8;
00110 } else if (subdet == static_cast<int>(HcalForward)) {
00111 entotHF += energy;
00112 nHF++;
00113 type = depth+8+2*dep;
00114 if (eta < 0) type += 8;
00115 }
00116 LogDebug("HitsValidationHcal") << "Hit[" << i << "] ID " << std::hex << id_
00117 << std::dec << " Det " << det << " Sub "
00118 << subdet << " depth " << depth << " depthX "
00119 << dep << " Eta " << eta << " Phi " << phi
00120 << " E " << energy << " time " << time
00121 << " type " << type;
00122 double etax = eta - 0.5;
00123 if (eta < 0) etax += 1;
00124 if (dbe_ && type >= 0) {
00125 meHcalHitEta_[type]->Fill(etax,energy);
00126 }
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 LogDebug("HitsValidationHcal") << "SimHitsValidationHcal::analyzeHits: HB " << nHB
00143 << " HE " << nHE << " HO " << nHO << " HF " << nHF
00144 << " All " << nHit;
00145
00146 }
00147