Skip to content

Commit

Permalink
Merge pull request #31152 from bsunanda/Phase2-hgx259
Browse files Browse the repository at this point in the history
Phase2-hgx259 Change the validation code for HGCal to make it work for DDD as well as for DD4hep
  • Loading branch information
cmsbuild committed Aug 17, 2020
2 parents 5352497 + 0e9f59c commit 037cd49
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Validation/HGCalValidation/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/L1THGCal"/>
<use name="DetectorDescription/Core"/>
<use name="DetectorDescription/DDCMS"/>
<use name="DQMServices/Core"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
Expand All @@ -30,6 +31,7 @@
<use name="RecoLocalCalo/HGCalRecAlgos"/>
<use name="Validation/HGCalValidation"/>
<use name="geant4core"/>
<use name="dd4hep"/>
<use name="clhep"/>
<use name="hepmc"/>
<flags EDM_PLUGIN="1"/>
1 change: 0 additions & 1 deletion Validation/HGCalValidation/plugins/HGCalDigiClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "DQMServices/Core/interface/DQMEDHarvester.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
#include "Geometry/Records/interface/HcalRecNumberingRecord.h"
Expand Down
2 changes: 0 additions & 2 deletions Validation/HGCalValidation/plugins/HGCalDigiValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

Expand Down
2 changes: 0 additions & 2 deletions Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "DataFormats/DetId/interface/DetId.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

Expand Down
2 changes: 0 additions & 2 deletions Validation/HGCalValidation/plugins/HGCalRecHitsClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Math/interface/LorentzVector.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"

#include "DQMServices/Core/interface/DQMEDHarvester.h"
#include "DQMServices/Core/interface/DQMStore.h"

Expand Down
65 changes: 59 additions & 6 deletions Validation/HGCalValidation/plugins/HGCalSimHitValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
#include "DataFormats/HcalDetId/interface/HcalDetId.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Core/interface/DDSpecifics.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDFilter.h"
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
#include "DetectorDescription/DDCMS/interface/DDFilteredView.h"

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
Expand Down Expand Up @@ -86,14 +87,15 @@ class HGCalSimHitValidation : public DQMEDAnalyzer {
void fillOccupancyMap(std::map<int, int>& OccupancyMap, int layer);
void fillHitsInfo(std::pair<hitsinfo, energysum> hit_, unsigned int itimeslice, double esum);
bool defineGeometry(edm::ESTransientHandle<DDCompactView>& ddViewH);
bool defineGeometry(edm::ESTransientHandle<cms::DDCompactView>& ddViewH);

// ----------member data ---------------------------
std::string nameDetector_, caloHitSource_;
const HGCalDDDConstants* hgcons_;
const HcalDDDRecConstants* hcons_;
std::vector<double> times_;
int verbosity_;
bool heRebuild_, testNumber_, symmDet_;
bool heRebuild_, testNumber_, symmDet_, fromDDD_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_hits_;
edm::EDGetTokenT<edm::HepMCProduct> tok_hepMC_;
unsigned int layers_;
Expand All @@ -115,6 +117,7 @@ HGCalSimHitValidation::HGCalSimHitValidation(const edm::ParameterSet& iConfig)
verbosity_(iConfig.getUntrackedParameter<int>("Verbosity", 0)),
testNumber_(iConfig.getUntrackedParameter<bool>("TestNumber", true)),
symmDet_(true),
fromDDD_(iConfig.getUntrackedParameter<bool>("fromDDD", true)),
firstLayer_(1) {
heRebuild_ = (nameDetector_ == "HCal") ? true : false;
tok_hepMC_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
Expand All @@ -130,6 +133,7 @@ void HGCalSimHitValidation::fillDescriptions(edm::ConfigurationDescriptions& des
desc.add<std::vector<double> >("TimeSlices", times);
desc.addUntracked<int>("Verbosity", 0);
desc.addUntracked<bool>("TestNumber", true);
desc.addUntracked<bool>("fromDDD", true);
descriptions.add("hgcalSimHitValidationEE", desc);
}

Expand Down Expand Up @@ -363,7 +367,8 @@ void HGCalSimHitValidation::fillHitsInfo(std::pair<hitsinfo, energysum> hits, un

bool HGCalSimHitValidation::defineGeometry(edm::ESTransientHandle<DDCompactView>& ddViewH) {
if (verbosity_ > 0)
edm::LogVerbatim("HGCalValidation") << "Initialize HGCalDDDConstants for " << nameDetector_ << " : " << hgcons_;
edm::LogVerbatim("HGCalValidation") << "Initialize HGCalDDDConstants (DDD) for " << nameDetector_ << " : "
<< hgcons_;

if (hgcons_->geomMode() == HGCalGeometryMode::Square) {
const DDCompactView& cview = *ddViewH;
Expand Down Expand Up @@ -408,6 +413,48 @@ bool HGCalSimHitValidation::defineGeometry(edm::ESTransientHandle<DDCompactView>
return true;
}

bool HGCalSimHitValidation::defineGeometry(edm::ESTransientHandle<cms::DDCompactView>& ddViewH) {
if (verbosity_ > 0)
edm::LogVerbatim("HGCalValidation") << "Initialize HGCalDDDConstants (DD4hep) for " << nameDetector_ << " : "
<< hgcons_;

if (hgcons_->geomMode() == HGCalGeometryMode::Square) {
const cms::DDCompactView& cview = *ddViewH;
const cms::DDFilter filter("Volume", nameDetector_);
cms::DDFilteredView fv(cview, filter);

while (fv.firstChild()) {
const auto& name = fv.name();
int isd = (name.find(nameDetector_) == std::string::npos) ? -1 : 1;
if (isd > 0) {
const auto& copy = fv.copyNos();
int nsiz = static_cast<int>(copy.size());
int lay = (nsiz > 0) ? copy[0] : -1;
int sec = (nsiz > 1) ? copy[1] : -1;
int zp = (nsiz > 3) ? copy[3] : -1;
if (zp != 1)
zp = -1;
const auto& pars = fv.parameters();
int subs = (pars[6] > 0 ? 1 : 0);
symmDet_ = (pars[6] == 0 ? true : false);
uint32_t id = HGCalTestNumbering::packSquareIndex(zp, lay, sec, subs, 0);
DD3Vector x, y, z;
fv.rotation().GetComponents(x, y, z);
const CLHEP::HepRep3x3 rotation(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
const CLHEP::HepRotation hr(rotation);
const CLHEP::Hep3Vector h3v(fv.translation().X(), fv.translation().Y(), fv.translation().Z());
const HepGeom::Transform3D ht3d(hr, h3v);
transMap_.insert(std::make_pair(id, ht3d));
if (verbosity_ > 2)
edm::LogVerbatim("HGCalValidation") << HGCalDetId(id) << " Transform using " << h3v << " and " << hr;
}
}
if (verbosity_ > 0)
edm::LogVerbatim("HGCalValidation") << "Finds " << transMap_.size() << " elements and SymmDet_ = " << symmDet_;
}
return true;
}

// ------------ method called when starting to processes a run ------------
void HGCalSimHitValidation::dqmBeginRun(const edm::Run&, const edm::EventSetup& iSetup) {
if (heRebuild_) {
Expand All @@ -421,9 +468,15 @@ void HGCalSimHitValidation::dqmBeginRun(const edm::Run&, const edm::EventSetup&
hgcons_ = &(*pHGDC);
layers_ = hgcons_->layers(false);
firstLayer_ = hgcons_->firstLayer();
edm::ESTransientHandle<DDCompactView> pDD;
iSetup.get<IdealGeometryRecord>().get(pDD);
defineGeometry(pDD);
if (fromDDD_) {
edm::ESTransientHandle<DDCompactView> pDD;
iSetup.get<IdealGeometryRecord>().get(pDD);
defineGeometry(pDD);
} else {
edm::ESTransientHandle<cms::DDCompactView> pDD;
iSetup.get<IdealGeometryRecord>().get(pDD);
defineGeometry(pDD);
}
}
if (verbosity_ > 0)
edm::LogVerbatim("HGCalValidation") << nameDetector_ << " defined with " << layers_ << " Layers with first at "
Expand Down
2 changes: 0 additions & 2 deletions Validation/HGCalValidation/plugins/HGCalSimHitsClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/Math/interface/LorentzVector.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"

#include "DQMServices/Core/interface/DQMEDHarvester.h"
#include "DQMServices/Core/interface/DQMStore.h"

Expand Down
3 changes: 3 additions & 0 deletions Validation/HGCalValidation/python/simhitValidation_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from Validation.HGCalValidation.hgcalSimHitValidationEE_cfi import *

from Configuration.ProcessModifiers.dd4hep_cff import dd4hep
dd4hep.toModify( hgcalSimHitValidationEE, fromDDD = False )

hgcalSimHitValidationHEF = hgcalSimHitValidationEE.clone(
DetectorName = cms.string("HGCalHESiliconSensitive"),
CaloHitSource = cms.string("HGCHitsHEfront"))
Expand Down
1 change: 0 additions & 1 deletion Validation/HGCalValidation/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<use name="CalibFormats/HcalObjects"/>
<use name="DataFormats/ForwardDetId"/>
<use name="DataFormats/HcalDetId"/>
<use name="DetectorDescription/Core"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/MessageLogger"/>
Expand Down
2 changes: 0 additions & 2 deletions Validation/HGCalValidation/test/HGCalDigiStudy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESTransientHandle.h"
Expand Down
1 change: 0 additions & 1 deletion Validation/HGCalValidation/test/HGCalRecHitStudy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"

#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
#include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
Expand Down

0 comments on commit 037cd49

Please sign in to comment.