Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run4-hgx285 Update some of the remaining validation classes in Validation/HGCalValidation #33614

Merged
merged 6 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Validation/Configuration/python/hgcalSimValid_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from Validation.HGCalValidation.simhitValidation_cff import *
from Validation.HGCalValidation.digiValidation_cff import *
from Validation.HGCalValidation.rechitValidation_cff import *
from Validation.HGCalValidation.hgcalHitValidation_cfi import *
from Validation.HGCalValidation.hgcalHitValidation_cff import *
from RecoHGCal.TICL.SimTracksters_cff import *

from Validation.HGCalValidation.HGCalValidator_cfi import hgcalValidator
Expand Down
169 changes: 51 additions & 118 deletions Validation/HGCalValidation/plugins/HGCalBHValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

// user include files
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "CondFormats/GeometryObjects/interface/HcalParameters.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand All @@ -21,10 +18,8 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "Geometry/Records/interface/HcalParametersRcd.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
#include "DataFormats/HcalDetId/interface/HcalTestNumbering.h"
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"

// Root objects
Expand All @@ -51,15 +46,13 @@ class HGCalBHValidation : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::

private:
edm::Service<TFileService> fs_;
const std::string g4Label_, hcalHits_;
const edm::InputTag hcalDigis_;
const int iSample_, geomType_;
const std::string g4Label_, hits_;
const edm::InputTag digis_;
const int iSample_;
const double threshold_;
const bool ifHCAL_;
const edm::ESGetToken<HcalParameters, HcalParametersRcd> parToken_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
edm::EDGetToken tok_hbhe_;
int etaMax_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
const edm::EDGetToken tok_digi_;
const int etaMax_;

TH1D *hsimE1_, *hsimE2_, *hsimTm_;
TH1D *hsimLn_, *hdigEn_, *hdigLn_;
Expand All @@ -68,46 +61,32 @@ class HGCalBHValidation : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::
};

HGCalBHValidation::HGCalBHValidation(const edm::ParameterSet& ps)
: g4Label_(ps.getUntrackedParameter<std::string>("ModuleLabel", "g4SimHits")),
hcalHits_((ps.getUntrackedParameter<std::string>("HitCollection", "HcalHits"))),
hcalDigis_(ps.getUntrackedParameter<edm::InputTag>("DigiCollection")),
iSample_(ps.getUntrackedParameter<int>("Sample", 5)),
geomType_(ps.getUntrackedParameter<int>("GeometryType", 0)),
threshold_(ps.getUntrackedParameter<double>("Threshold", 12.0)),
ifHCAL_(ps.getUntrackedParameter<bool>("ifHCAL", false)),
parToken_(esConsumes<HcalParameters, HcalParametersRcd, edm::Transition::BeginRun>(edm::ESInputTag{})),
: g4Label_(ps.getParameter<std::string>("ModuleLabel")),
hits_((ps.getParameter<std::string>("HitCollection"))),
digis_(ps.getParameter<edm::InputTag>("DigiCollection")),
iSample_(ps.getParameter<int>("Sample")),
threshold_(ps.getParameter<double>("Threshold")),
tok_hits_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hits_))),
tok_digi_(consumes<HGCalDigiCollection>(digis_)),
etaMax_(100) {
usesResource(TFileService::kSharedResource);

tok_hits_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_, hcalHits_));
if (ifHCAL_)
tok_hbhe_ = consumes<QIE11DigiCollection>(hcalDigis_);
else
tok_hbhe_ = consumes<HGCalDigiCollection>(hcalDigis_);
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation::Input for SimHit:" << edm::InputTag(g4Label_, hcalHits_)
<< " Digits:" << hcalDigis_ << " Sample: " << iSample_ << " Threshold "
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation::Input for SimHit:" << edm::InputTag(g4Label_, hits_)
<< " Digits:" << digis_ << " Sample: " << iSample_ << " Threshold "
<< threshold_;
}

void HGCalBHValidation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<std::string>("ModuleLabel", "g4SimHits");
desc.addUntracked<std::string>("HitCollection", "HGCHitsHEback");
desc.addUntracked<edm::InputTag>("DigiCollection", edm::InputTag("simHGCalUnsuppressedDigis", "HEback"));
desc.addUntracked<int>("Sample", 5);
desc.addUntracked<int>("GeometryType", 1);
desc.addUntracked<double>("Threshold", 15.0);
desc.addUntracked<bool>("ifHCAL", false);
desc.add<std::string>("ModuleLabel", "g4SimHits");
desc.add<std::string>("HitCollection", "HGCHitsHEback");
desc.add<edm::InputTag>("DigiCollection", edm::InputTag("simHGCalUnsuppressedDigis", "HEback"));
desc.add<int>("Sample", 5);
desc.add<double>("Threshold", 15.0);
descriptions.add("hgcalBHAnalysis", desc);
}

void HGCalBHValidation::beginRun(edm::Run const&, edm::EventSetup const& es) {
if (geomType_ == 0) {
std::string label;
const HcalParameters* hpar = &es.getData(parToken_);
const std::vector<int> etaM = hpar->etaMax;
etaMax_ = etaM[1];
}
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation::Maximum Number of"
<< " eta sectors:" << etaMax_ << "\nHitsValidationHcal::Booking the Histograms";

Expand All @@ -131,38 +110,28 @@ void HGCalBHValidation::analyze(const edm::Event& e, const edm::EventSetup&) {
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation:Run = " << e.id().run() << " Event = " << e.id().event();

//SimHits
edm::Handle<edm::PCaloHitContainer> hitsHcal;
e.getByToken(tok_hits_, hitsHcal);
edm::Handle<edm::PCaloHitContainer> hitsHE;
e.getByToken(tok_hits_, hitsHE);
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation.: PCaloHitContainer"
<< " obtained with flag " << hitsHcal.isValid();
if (hitsHcal.isValid()) {
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: PCaloHit buffer " << hitsHcal->size();
<< " obtained with flag " << hitsHE.isValid();
if (hitsHE.isValid()) {
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: PCaloHit buffer " << hitsHE->size();
unsigned i(0);
std::map<unsigned int, double> map_try;
for (edm::PCaloHitContainer::const_iterator it = hitsHcal->begin(); it != hitsHcal->end(); ++it) {
for (edm::PCaloHitContainer::const_iterator it = hitsHE->begin(); it != hitsHE->end(); ++it) {
double energy = it->energy();
double time = it->time();
unsigned int id = it->id();
int subdet(0), z(0), depth(0), eta(0), phi(0), lay(0);
bool hbhe(false), bh(false);
if (geomType_ == 0) {
HcalTestNumbering::unpackHcalIndex(id, subdet, z, depth, eta, phi, lay);
if (z == 0)
eta = -eta;
hbhe = ((subdet == static_cast<int>(HcalEndcap)) || (subdet == static_cast<int>(HcalBarrel)));
bh = (subdet == static_cast<int>(HcalEndcap));
} else {
hbhe = bh = (DetId(id).det() == DetId::HGCalHSc);
if (bh) {
eta = HGCScintillatorDetId(id).ieta();
phi = HGCScintillatorDetId(id).iphi();
lay = HGCScintillatorDetId(id).layer();
}
int eta(0), phi(0), lay(0);
bool bh = (DetId(id).det() == DetId::HGCalHSc);
if (bh) {
eta = HGCScintillatorDetId(id).ieta();
phi = HGCScintillatorDetId(id).iphi();
lay = HGCScintillatorDetId(id).layer();
}
double eta1 = (eta >= 0) ? (eta + 0.1) : (eta - 0.1);
if (hbhe)
hsi2Oc_->Fill(eta1, (phi - 0.1), energy);
if (bh) {
hsi2Oc_->Fill(eta1, (phi - 0.1), energy);
hsimE1_->Fill(energy);
hsimTm_->Fill(time, energy);
hsimOc_->Fill(eta1, (phi - 0.1), energy);
Expand All @@ -174,9 +143,8 @@ void HGCalBHValidation::analyze(const edm::Event& e, const edm::EventSetup&) {
ensum += energy;
map_try[id] = ensum;
++i;
edm::LogVerbatim("HGCalValidation")
<< "HGCalBHHit[" << i << "] ID " << std::hex << " " << id << std::dec << " SubDet " << subdet << " depth "
<< depth << " Eta " << eta << " Phi " << phi << " layer " << lay << " E " << energy << " time " << time;
edm::LogVerbatim("HGCalValidation") << "HGCalBHHit[" << i << "] ID " << std::hex << " " << id << std::dec << " "
<< HGCScintillatorDetId(id) << " E " << energy << " time " << time;
}
}
for (std::map<unsigned int, double>::iterator itr = map_try.begin(); itr != map_try.end(); ++itr) {
Expand All @@ -186,57 +154,22 @@ void HGCalBHValidation::analyze(const edm::Event& e, const edm::EventSetup&) {

//Digits
unsigned int kount(0);
if ((geomType_ == 0) && ifHCAL_) {
edm::Handle<QIE11DigiCollection> hbhecoll;
e.getByToken(tok_hbhe_, hbhecoll);
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation.: "
<< "HBHEQIE11DigiCollection obtained "
<< "with flag " << hbhecoll.isValid();
if (hbhecoll.isValid()) {
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: HBHEDigit "
<< "buffer " << hbhecoll->size();
for (QIE11DigiCollection::const_iterator it = hbhecoll->begin(); it != hbhecoll->end(); ++it) {
QIE11DataFrame df(*it);
HcalDetId cell(df.id());
bool hbhe =
((cell.subdetId() == static_cast<int>(HcalEndcap)) || (cell.subdetId() == static_cast<int>(HcalBarrel)));
if (hbhe) {
bool bh = (cell.subdetId() == static_cast<int>(HcalEndcap));
int depth = cell.depth();
double energy = df[iSample_].adc();
analyzeDigi(cell, energy, bh, depth, kount);
}
}
}
} else {
edm::Handle<HGCalDigiCollection> hbhecoll;
e.getByToken(tok_hbhe_, hbhecoll);
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation.: "
<< "HGCalDigiCollection obtained with"
<< " flag " << hbhecoll.isValid();
if (hbhecoll.isValid()) {
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: HGCalDigi "
<< "buffer " << hbhecoll->size();
for (HGCalDigiCollection::const_iterator it = hbhecoll->begin(); it != hbhecoll->end(); ++it) {
HGCalDataFrame df(*it);
double energy = df[iSample_].data();
if (geomType_ == 0) {
HcalDetId cell(df.id());
bool hbhe =
((cell.subdetId() == static_cast<int>(HcalEndcap)) || (cell.subdetId() == static_cast<int>(HcalBarrel)));
if (hbhe) {
bool bh = (cell.subdetId() == static_cast<int>(HcalEndcap));
int depth = cell.depth();
analyzeDigi(cell, energy, bh, depth, kount);
}
} else {
bool bh = (DetId(df.id()).det() == DetId::HGCalHSc);
if (bh) {
HGCScintillatorDetId cell(df.id());
int depth = cell.layer();
analyzeDigi(cell, energy, bh, depth, kount);
}
}
edm::Handle<HGCalDigiCollection> hecoll;
e.getByToken(tok_digi_, hecoll);
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation.: "
<< "HGCalDigiCollection obtained with"
<< " flag " << hecoll.isValid();
if (hecoll.isValid()) {
edm::LogVerbatim("HGCalValidation") << "HGCalBHValidation: HGCalDigi "
<< "buffer " << hecoll->size();
for (HGCalDigiCollection::const_iterator it = hecoll->begin(); it != hecoll->end(); ++it) {
HGCalDataFrame df(*it);
double energy = df[iSample_].data();
bool bh = (DetId(df.id()).det() == DetId::HGCalHSc);
if (bh) {
HGCScintillatorDetId cell(df.id());
int depth = cell.layer();
analyzeDigi(cell, energy, bh, depth, kount);
}
}
}
Expand Down
Loading