Skip to content

Commit 220d0b5

Browse files
author
Sunanda
committed
Make a test code to study properties of a wafer
1 parent d8b9d39 commit 220d0b5

File tree

3 files changed

+141
-1
lines changed

3 files changed

+141
-1
lines changed

Geometry/HGCalCommonData/src/HGCalDDDConstants.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ void HGCalDDDConstants::waferFromPosition(const double x,
18811881
<< hexside;
18821882
}
18831883
}
1884-
edm::LogVerbatim("HGCalGeomX") << "Input x:y:layer " << x << ":" << y << ":" << layer << " Wafer " << waferU << ":"
1884+
edm::LogVerbatim("HGCalGeom") << "Input x:y:layer " << x << ":" << y << ":" << layer << " Wafer " << waferU << ":"
18851885
<< waferV << " Cell " << cellU << ":" << cellV << ":" << celltype << " wt " << wt;
18861886
}
18871887

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
2+
#include "FWCore/Framework/interface/EventSetup.h"
3+
#include "FWCore/Framework/interface/MakerMacros.h"
4+
#include "FWCore/MessageLogger/interface/MessageLogger.h"
5+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
6+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
7+
#include "Geometry/Records/interface/IdealGeometryRecord.h"
8+
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
9+
#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h"
10+
#include "Geometry/HGCalCommonData/interface/HGCalWaferType.h"
11+
#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
12+
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
13+
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
14+
#include <iostream>
15+
16+
class HGCalWaferSimWt : public edm::one::EDAnalyzer<> {
17+
public:
18+
explicit HGCalWaferSimWt(const edm::ParameterSet&);
19+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20+
21+
void beginJob() override {}
22+
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
23+
void endJob() override {}
24+
25+
private:
26+
const std::vector<std::string> names_;
27+
std::vector<edm::ESGetToken<HGCalGeometry, IdealGeometryRecord>> geomTokens_;
28+
};
29+
30+
HGCalWaferSimWt::HGCalWaferSimWt(const edm::ParameterSet& iC)
31+
: names_(iC.getParameter<std::vector<std::string>>("detectorNames")) {
32+
for (unsigned int k = 0; k < names_.size(); ++k) {
33+
edm::LogVerbatim("HGCalGeomX") << "Study detector [" << k << "] " << names_[k] << std::endl;
34+
geomTokens_.emplace_back(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", names_[k]}));
35+
}
36+
}
37+
38+
void HGCalWaferSimWt::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
39+
edm::ParameterSetDescription desc;
40+
std::vector<std::string> names = {"HGCalEESensitive", "HGCalHESiliconSensitive"};
41+
desc.add<std::vector<std::string>>("detectorNames", names);
42+
descriptions.add("hgcalWaferSimWt", desc);
43+
}
44+
45+
void HGCalWaferSimWt::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
46+
std::vector<std::string> parType = {"Full", "Five", "ChopTwo", "ChopTwoM", "Half", "Semi", "Semi2", "Three", "Half2", "Five2", "JK10", "LDTop", "LDBottom", "LDLeft", "LDRight", "LDFive", "LDThree", "JK17", "JK18", "JK19", "JK20", "HDTop", "HDBottom", "HDLeft", "HDRight", "HDFive"};
47+
std::vector<std::string> detType = {"HD120", "LD200", "LD300", "HD200"};
48+
for (unsigned int k = 0; k < names_.size(); ++k) {
49+
const auto& geomR = iSetup.getData(geomTokens_[k]);
50+
const HGCalGeometry* geom = &geomR;
51+
const std::vector<DetId>& ids = geom->getValidDetIds();
52+
edm::LogVerbatim("HGCalGeomX") << ids.size() << " valid Ids for detector " << names_[k] << std::endl;
53+
int nall(0), ntypes(0);
54+
std::vector<int> idxs;
55+
for (auto id : ids) {
56+
++nall;
57+
auto cell = geom->getGeometry(id);
58+
HGCSiliconDetId hid(id);
59+
int type = hid.type();
60+
int part = geom->topology().dddConstants().partialWaferType(hid.layer(), hid.waferU(), hid.waferV());
61+
int idx = part*10 + type;
62+
if (std::find(idxs.begin(), idxs.end(), idx) == idxs.end()) {
63+
++ntypes;
64+
idxs.push_back(idx);
65+
double xpos = 10.0 * (cell->getPosition().x());
66+
double ypos = 10.0 * (cell->getPosition().y());
67+
int waferU, waferV, cellU, cellV, cellType;
68+
double wt;
69+
geom->topology().dddConstants().waferFromPosition(xpos, ypos, hid.zside(), hid.layer(), waferU, waferV, cellU, cellV, cellType, wt, false, true);
70+
std::string stype = (type >= 0 && type <= 3) ? detType[type] : ("JK" + std::to_string(type));
71+
std::string spart = (part >= 0 && part <= 25) ? parType[part] : ("JK" + std::to_string(part));
72+
int index = HGCalWaferIndex::waferIndex(hid.layer(), waferU, waferV);
73+
int celltypeX = HGCalWaferType::getType(index, geom->topology().dddConstants().getParameter()->waferInfoMap_);
74+
edm::LogVerbatim("HGCalGeomX") << "[" << ntypes << "] " << stype << " " << spart << " wt " << wt << " for " << hid << " at " << xpos << ":" << ypos << " Wafer " << waferU << ":" << waferV << " cell " << cellU << ":" << cellV << " Type " << cellType << ":" << celltypeX;
75+
}
76+
}
77+
edm::LogVerbatim("HGCalGeomX") << "\n\nFinds " << idxs.size() << " different wafer types among " << nall << " cells of the detector\n";
78+
}
79+
}
80+
81+
DEFINE_FWK_MODULE(HGCalWaferSimWt);
82+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
###############################################################################
2+
# Way to use this:
3+
# cmsRun testHGCalWaferSimWt_cfg.py geometry=D110
4+
#
5+
# Options for geometry D95, D96, D98, D99, D100, D101, D102, D103, D104,
6+
# D105, D106, D107, D108, D109, D110, D111, D112, D113,
7+
# D114, D115, D116, D117, D118, D119, D120
8+
#
9+
###############################################################################
10+
import FWCore.ParameterSet.Config as cms
11+
import os, sys, importlib, re
12+
import FWCore.ParameterSet.VarParsing as VarParsing
13+
14+
####################################################################
15+
### SETUP OPTIONS
16+
options = VarParsing.VarParsing('standard')
17+
options.register('geometry',
18+
"D110",
19+
VarParsing.VarParsing.multiplicity.singleton,
20+
VarParsing.VarParsing.varType.string,
21+
"geometry of operations: D95, D96, D98, D99, D100, D101, D102, D103, D104, D105, D106, D107, D108, D109, D110, D111, D112, D113, D114, D115, D116, D117, D118, D119, D120")
22+
23+
### get and parse the command line arguments
24+
options.parseArguments()
25+
26+
print(options)
27+
28+
29+
####################################################################
30+
# Use the options
31+
32+
geomName = "Run4" + options.geometry
33+
geomFile = "Configuration.Geometry.GeometryExtended" + geomName + "Reco_cff"
34+
import Configuration.Geometry.defaultPhase2ConditionsEra_cff as _settings
35+
GLOBAL_TAG, ERA = _settings.get_era_and_conditions(geomName)
36+
37+
print("Geometry Name: ", geomName)
38+
print("Geom file Name: ", geomFile)
39+
print("Global Tag Name: ", GLOBAL_TAG)
40+
print("Era Name: ", ERA)
41+
42+
process = cms.Process('PROD',ERA)
43+
44+
process.load(geomFile)
45+
process.load("Geometry.HGCalGeometry.hgcalWaferSimWt_cfi")
46+
process.load('FWCore.MessageService.MessageLogger_cfi')
47+
48+
if hasattr(process,'MessageLogger'):
49+
process.MessageLogger.HGCalGeomX=dict()
50+
# process.MessageLogger.HGCalGeom=dict()
51+
52+
process.source = cms.Source("EmptySource")
53+
process.maxEvents = cms.untracked.PSet(
54+
input = cms.untracked.int32(1)
55+
)
56+
process.Timing = cms.Service("Timing")
57+
58+
process.p1 = cms.Path(process.hgcalWaferSimWt)

0 commit comments

Comments
 (0)