Skip to content

Commit

Permalink
Merge pull request #37165 from bsunanda/Run3-hcx330
Browse files Browse the repository at this point in the history
Run3-hcx330 Cleanup some of the codes in Validation/HcalHits
  • Loading branch information
cmsbuild authored Mar 10, 2022
2 parents 90abdab + 54463d8 commit e941f53
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 281 deletions.
8 changes: 4 additions & 4 deletions Validation/HcalHits/interface/HcalSimHitsClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ class HcalSimHitsClient : public DQMEDHarvester {
int SimHitsEndjob(const std::vector<MonitorElement *> &hcalMEs);
std::vector<std::string> getHistogramTypes();

std::string dirName_;
bool verbose_;
edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
const std::string dirName_;
const bool verbose_;
const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
static const int nTime = 4;
static const int nType1 = 4;
const HcalDDDRecConstants *hcons;
int maxDepthHB_, maxDepthHE_, maxDepthHO_, maxDepthHF_;

public:
explicit HcalSimHitsClient(const edm::ParameterSet &);
~HcalSimHitsClient() override;
~HcalSimHitsClient() override = default;

void beginRun(edm::Run const &run, edm::EventSetup const &c) override;
virtual void runClient_(DQMStore::IBooker &, DQMStore::IGetter &);
Expand Down
32 changes: 16 additions & 16 deletions Validation/HcalHits/interface/HcalSimHitsValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
class HcalSimHitsValidation : public DQMOneEDAnalyzer<> {
public:
HcalSimHitsValidation(edm::ParameterSet const &conf);
~HcalSimHitsValidation() override;
~HcalSimHitsValidation() override = default;

void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;

Expand All @@ -54,24 +54,28 @@ class HcalSimHitsValidation : public DQMOneEDAnalyzer<> {
double phi12(double phi1, double en1, double phi2, double en2);
double dPhiWsign(double phi1, double phi2);

std::string outputFile_;
std::string g4Label_, hcalHits_, ebHits_, eeHits_;
const std::string g4Label_, hcalHits_, ebHits_, eeHits_;

edm::EDGetTokenT<edm::HepMCProduct> tok_evt_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_hcal_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_ecalEB_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_ecalEE_;
edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
// sampling factors
const double hf1_;
const double hf2_;

const std::string outputFile_;
const bool testNumber_;
const bool auxPlots_;

const edm::EDGetTokenT<edm::HepMCProduct> tok_evt_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_hcal_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_ecalEB_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_ecalEE_;
const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;

const HcalDDDRecConstants *hcons_;
const CaloGeometry *geometry_;
int maxDepthHB_, maxDepthHE_;
int maxDepthHO_, maxDepthHF_;

bool testNumber_;
bool auxPlots_;

// Hits counters
std::vector<MonitorElement *> Nhb;
std::vector<MonitorElement *> Nhe;
Expand Down Expand Up @@ -106,10 +110,6 @@ class HcalSimHitsValidation : public DQMOneEDAnalyzer<> {

// counter
int nevtot;

// sampling factors
double hf1_;
double hf2_;
};

#endif
2 changes: 1 addition & 1 deletion Validation/HcalHits/interface/SimG4HcalHitCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class SimG4HcalHitCluster {
public:
SimG4HcalHitCluster();
virtual ~SimG4HcalHitCluster();
~SimG4HcalHitCluster() = default;

double e() const { return ec; }
double eta() const { return etac; }
Expand Down
10 changes: 5 additions & 5 deletions Validation/HcalHits/interface/SimHitsValidationHcal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class SimHitsValidationHcal : public DQMEDAnalyzer {
public:
SimHitsValidationHcal(const edm::ParameterSet &ps);
~SimHitsValidationHcal() override;
~SimHitsValidationHcal() override = default;
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

protected:
Expand Down Expand Up @@ -78,12 +78,12 @@ class SimHitsValidationHcal : public DQMEDAnalyzer {
std::pair<int, int> histId(int subdet, int eta, int depth, unsigned int dep);

bool initialized;
std::string g4Label_, hcalHits_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
const std::string g4Label_, hcalHits_;
const bool verbose_, testNumber_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
const HcalDDDRecConstants *hcons;
std::vector<idType> types;
bool verbose_, testNumber_;
int maxDepthHB_, maxDepthHE_;
int maxDepthHO_, maxDepthHF_;

Expand Down
19 changes: 8 additions & 11 deletions Validation/HcalHits/plugins/HcalGeomCheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HcalGeomCheck : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one:
};

explicit HcalGeomCheck(const edm::ParameterSet&);
~HcalGeomCheck() override {}
~HcalGeomCheck() override = default;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

protected:
Expand All @@ -62,9 +62,9 @@ class HcalGeomCheck : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one:
const int ietaMin_, ietaMax_, depthMax_;
const double rmin_, rmax_, zmin_, zmax_;
const int nbinR_, nbinZ_, verbosity_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;
const HcalDDDRecConstants* hcons_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> tok_HRNDC_;

//histogram related stuff
TH2D* h_RZ_;
Expand All @@ -74,9 +74,7 @@ class HcalGeomCheck : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one:
};

HcalGeomCheck::HcalGeomCheck(const edm::ParameterSet& iConfig)
:

caloHitSource_(iConfig.getParameter<std::string>("caloHitSource")),
: caloHitSource_(iConfig.getParameter<std::string>("caloHitSource")),
ietaMin_(iConfig.getUntrackedParameter<int>("ietaMin", -41)),
ietaMax_(iConfig.getUntrackedParameter<int>("ietaMax", 41)),
depthMax_(iConfig.getUntrackedParameter<int>("depthMax", 7)),
Expand All @@ -86,10 +84,10 @@ HcalGeomCheck::HcalGeomCheck(const edm::ParameterSet& iConfig)
zmax_(iConfig.getUntrackedParameter<double>("zMax", 12500.0)),
nbinR_(iConfig.getUntrackedParameter<int>("nBinR", 550)),
nbinZ_(iConfig.getUntrackedParameter<int>("nBinZ", 2500)),
verbosity_(iConfig.getUntrackedParameter<int>("verbosity", 0)) {
verbosity_(iConfig.getUntrackedParameter<int>("verbosity", 0)),
tok_hits_(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", caloHitSource_))),
tok_HRNDC_(esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>()) {
usesResource(TFileService::kSharedResource);
tok_hits_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", caloHitSource_));
tok_HRNDC_ = esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>();
}

void HcalGeomCheck::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand All @@ -110,8 +108,7 @@ void HcalGeomCheck::fillDescriptions(edm::ConfigurationDescriptions& description

void HcalGeomCheck::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
//Now the hits
edm::Handle<edm::PCaloHitContainer> theCaloHitContainer;
iEvent.getByToken(tok_hits_, theCaloHitContainer);
const edm::Handle<edm::PCaloHitContainer>& theCaloHitContainer = iEvent.getHandle(tok_hits_);
if (theCaloHitContainer.isValid()) {
if (verbosity_ > 0)
edm::LogVerbatim("HcalValidation") << " PcalohitItr = " << theCaloHitContainer->size();
Expand Down
122 changes: 55 additions & 67 deletions Validation/HcalHits/plugins/HcalHitValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
class HcalHitValidation : public DQMEDAnalyzer {
public:
HcalHitValidation(const edm::ParameterSet &ps);
~HcalHitValidation() override;
~HcalHitValidation() override = default;

protected:
void analyze(const edm::Event &e, const edm::EventSetup &c) override;
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;

void analyzeHits(std::vector<PCaloHit> &);
void analyzeLayer(edm::Handle<PHcalValidInfoLayer> &);
void analyzeNxN(edm::Handle<PHcalValidInfoNxN> &);
void analyzeJets(edm::Handle<PHcalValidInfoJets> &);
void analyzeLayer(const edm::Handle<PHcalValidInfoLayer> &);
void analyzeNxN(const edm::Handle<PHcalValidInfoNxN> &);
void analyzeJets(const edm::Handle<PHcalValidInfoJets> &);

private:
std::string g4Label, hcalHits, layerInfo, nxNInfo, jetsInfo;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_hh_;
edm::EDGetTokenT<PHcalValidInfoLayer> tok_iL_;
edm::EDGetTokenT<PHcalValidInfoNxN> tok_iN_;
edm::EDGetTokenT<PHcalValidInfoJets> tok_iJ_;
std::string outFile_;
bool verbose_, scheme_;
bool checkHit_, checkLay_, checkNxN_, checkJet_;
const std::string g4Label, hcalHits, layerInfo, nxNInfo, jetsInfo;
const std::string outFile_;
const bool verbose_, scheme_;
const bool checkHit_, checkLay_, checkNxN_, checkJet_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_hh_;
const edm::EDGetTokenT<PHcalValidInfoLayer> tok_iL_;
const edm::EDGetTokenT<PHcalValidInfoNxN> tok_iN_;
const edm::EDGetTokenT<PHcalValidInfoJets> tok_iJ_;

MonitorElement *meAllNHit_, *meBadDetHit_, *meBadSubHit_, *meBadIdHit_;
MonitorElement *meHBNHit_, *meHENHit_, *meHONHit_, *meHFNHit_;
Expand Down Expand Up @@ -78,34 +78,29 @@ class HcalHitValidation : public DQMEDAnalyzer {
MonitorElement *meEneJet_, *meEtaJet_, *mePhiJet_;
};

HcalHitValidation::HcalHitValidation(const edm::ParameterSet &ps) {
g4Label = ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits");
hcalHits = ps.getUntrackedParameter<std::string>("HitCollection", "HcalHits");
layerInfo = ps.getUntrackedParameter<std::string>("LayerInfo", "PHcalValidInfoLayer");
nxNInfo = ps.getUntrackedParameter<std::string>("NxNInfo", "PHcalValidInfoNxN");
jetsInfo = ps.getUntrackedParameter<std::string>("JetsInfo", "PHcalValidInfoJets");
outFile_ = ps.getUntrackedParameter<std::string>("outputFile", "hcValid.root");
verbose_ = ps.getUntrackedParameter<bool>("Verbose", false);
scheme_ = ps.getUntrackedParameter<bool>("TestNumbering", true);
checkHit_ = ps.getUntrackedParameter<bool>("CheckHits", true);
checkLay_ = ps.getUntrackedParameter<bool>("CheckLayer", true);
checkNxN_ = ps.getUntrackedParameter<bool>("CheckNxN", true);
checkJet_ = ps.getUntrackedParameter<bool>("CheckJets", true);

// register for data access
tok_hh_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, hcalHits));
tok_iL_ = consumes<PHcalValidInfoLayer>(edm::InputTag(g4Label, layerInfo));
tok_iN_ = consumes<PHcalValidInfoNxN>(edm::InputTag(g4Label, nxNInfo));
tok_iJ_ = consumes<PHcalValidInfoJets>(edm::InputTag(g4Label, jetsInfo));

edm::LogInfo("HcalHitValid") << "Module Label: " << g4Label << " Hits: " << hcalHits << " / " << checkHit_
<< " LayerInfo: " << layerInfo << " / " << checkLay_ << " NxNInfo: " << nxNInfo
<< " / " << checkNxN_ << " jetsInfo: " << jetsInfo << " / " << checkJet_
<< " Output: " << outFile_ << " Usage of TestNumberingScheme " << scheme_;
HcalHitValidation::HcalHitValidation(const edm::ParameterSet &ps)
: g4Label(ps.getUntrackedParameter<std::string>("moduleLabel", "g4SimHits")),
hcalHits(ps.getUntrackedParameter<std::string>("HitCollection", "HcalHits")),
layerInfo(ps.getUntrackedParameter<std::string>("LayerInfo", "PHcalValidInfoLayer")),
nxNInfo(ps.getUntrackedParameter<std::string>("NxNInfo", "PHcalValidInfoNxN")),
jetsInfo(ps.getUntrackedParameter<std::string>("JetsInfo", "PHcalValidInfoJets")),
outFile_(ps.getUntrackedParameter<std::string>("outputFile", "hcValid.root")),
verbose_(ps.getUntrackedParameter<bool>("Verbose", false)),
scheme_(ps.getUntrackedParameter<bool>("TestNumbering", true)),
checkHit_(ps.getUntrackedParameter<bool>("CheckHits", true)),
checkLay_(ps.getUntrackedParameter<bool>("CheckLayer", true)),
checkNxN_(ps.getUntrackedParameter<bool>("CheckNxN", true)),
checkJet_(ps.getUntrackedParameter<bool>("CheckJets", true)),
tok_hh_(consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label, hcalHits))),
tok_iL_(consumes<PHcalValidInfoLayer>(edm::InputTag(g4Label, layerInfo))),
tok_iN_(consumes<PHcalValidInfoNxN>(edm::InputTag(g4Label, nxNInfo))),
tok_iJ_(consumes<PHcalValidInfoJets>(edm::InputTag(g4Label, jetsInfo))) {
edm::LogVerbatim("HcalHitValid") << "Module Label: " << g4Label << " Hits: " << hcalHits << " / " << checkHit_
<< " LayerInfo: " << layerInfo << " / " << checkLay_ << " NxNInfo: " << nxNInfo
<< " / " << checkNxN_ << " jetsInfo: " << jetsInfo << " / " << checkJet_
<< " Output: " << outFile_ << " Usage of TestNumberingScheme " << scheme_;
}

HcalHitValidation::~HcalHitValidation() {}

void HcalHitValidation::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) {
ibooker.setCurrentFolder("HcalHitValidation");

Expand Down Expand Up @@ -237,55 +232,48 @@ void HcalHitValidation::bookHistograms(DQMStore::IBooker &ibooker, edm::Run cons
void HcalHitValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
edm::LogVerbatim("HcalHitValid") << "Run = " << e.id().run() << " Event = " << e.id().event();

std::vector<PCaloHit> caloHits;
edm::Handle<edm::PCaloHitContainer> hitsHcal;
edm::Handle<PHcalValidInfoLayer> infoLayer;
edm::Handle<PHcalValidInfoNxN> infoNxN;
edm::Handle<PHcalValidInfoJets> infoJets;

bool getHits = false;
if (checkHit_) {
e.getByToken(tok_hh_, hitsHcal);
const edm::Handle<edm::PCaloHitContainer> &hitsHcal = e.getHandle(tok_hh_);
if (hitsHcal.isValid())
getHits = true;
if (getHits) {
std::vector<PCaloHit> caloHits;
caloHits.insert(caloHits.end(), hitsHcal->begin(), hitsHcal->end());
edm::LogVerbatim("HcalHitValid") << "HcalValidation: Hit buffer " << caloHits.size();
analyzeHits(caloHits);
}
}

bool getLayer = false;
if (checkLay_) {
e.getByToken(tok_iL_, infoLayer);
if (infoLayer.isValid())
const edm::Handle<PHcalValidInfoLayer> &infoLayer = e.getHandle(tok_iL_);
if (infoLayer.isValid()) {
getLayer = true;
analyzeLayer(infoLayer);
}
}

bool getNxN = false;
if (checkNxN_) {
e.getByToken(tok_iN_, infoNxN);
if (infoNxN.isValid())
const edm::Handle<PHcalValidInfoNxN> &infoNxN = e.getHandle(tok_iN_);
if (infoNxN.isValid()) {
getNxN = true;
analyzeNxN(infoNxN);
}
}

bool getJets = false;
if (checkJet_) {
e.getByToken(tok_iJ_, infoJets);
if (infoJets.isValid())
const edm::Handle<PHcalValidInfoJets> &infoJets = e.getHandle(tok_iJ_);
if (infoJets.isValid()) {
getJets = true;
analyzeJets(infoJets);
}
}

edm::LogVerbatim("HcalHitValid") << "HcalValidation: Input flags Hits " << getHits << ", Layer " << getLayer
<< ", NxN " << getNxN << ", Jets " << getJets;

if (getHits) {
caloHits.insert(caloHits.end(), hitsHcal->begin(), hitsHcal->end());
edm::LogVerbatim("HcalHitValid") << "HcalValidation: Hit buffer " << caloHits.size();
analyzeHits(caloHits);
}

if (getLayer)
analyzeLayer(infoLayer);
if (getNxN)
analyzeNxN(infoNxN);
if (getJets)
analyzeJets(infoJets);
}

void HcalHitValidation::analyzeHits(std::vector<PCaloHit> &hits) {
Expand Down Expand Up @@ -397,7 +385,7 @@ void HcalHitValidation::analyzeHits(std::vector<PCaloHit> &hits) {
<< " HF " << nHF << " PMT " << nPMT << " Bad " << nBad << " All " << nHit;
}

void HcalHitValidation::analyzeLayer(edm::Handle<PHcalValidInfoLayer> &infoLayer) {
void HcalHitValidation::analyzeLayer(const edm::Handle<PHcalValidInfoLayer> &infoLayer) {
// CaloHits from PHcalValidInfoLayer
int nHits = infoLayer->nHit();
std::vector<float> idHits = infoLayer->idHit();
Expand Down Expand Up @@ -474,7 +462,7 @@ void HcalHitValidation::analyzeLayer(edm::Handle<PHcalValidInfoLayer> &infoLayer
<< " eEcalHF = " << eEcalHF << " eHcalHF = " << eHcalHF;
}

void HcalHitValidation::analyzeNxN(edm::Handle<PHcalValidInfoNxN> &infoNxN) {
void HcalHitValidation::analyzeNxN(const edm::Handle<PHcalValidInfoNxN> &infoNxN) {
// NxN quantities
double ecalNxNr = infoNxN->ecalnxnr();
double hcalNxNr = infoNxN->hcalnxnr();
Expand Down Expand Up @@ -512,7 +500,7 @@ void HcalHitValidation::analyzeNxN(edm::Handle<PHcalValidInfoNxN> &infoNxN) {
<< " hits in NxN analysis; Total Energy " << etotNxN << "/" << etotNxNr;
}

void HcalHitValidation::analyzeJets(edm::Handle<PHcalValidInfoJets> &infoJets) {
void HcalHitValidation::analyzeJets(const edm::Handle<PHcalValidInfoJets> &infoJets) {
// -- Leading Jet
int nJetHits = infoJets->njethit();

Expand Down
Loading

0 comments on commit e941f53

Please sign in to comment.