CMS 3D CMS Logo

CaloTowerConstituentsMapBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CaloTowerConstituentsMapBuilder
4 // Class: CaloTowerConstituentsMapBuilder
5 //
13 //
14 // Original Author: Jeremiah Mans
15 // Created: Mon Oct 3 11:35:27 CDT 2005
16 //
17 //
18 
26 #include <zlib.h>
27 #include <strings.h>
28 
29 //
30 // constructors and destructor
31 //
33  : mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile", "")),
34  mapAuto_(iConfig.getUntrackedParameter<bool>("MapAuto", false)),
35  skipHE_(iConfig.getUntrackedParameter<bool>("SkipHE", false)) {
36  //the following line is needed to tell the framework what
37  // data is being produced
38  auto cc = setWhatProduced(this);
39 
43 
44  //now do what ever other initialization is needed
45 }
46 
48 
49 //
50 // member functions
51 //
52 
55  desc.addUntracked<std::string>("MapFile", "");
56  desc.addUntracked<bool>("MapAuto", false);
57  desc.addUntracked<bool>("SkipHE", false);
58  descriptions.add("caloTowerConstituents", desc);
59 }
60 
61 // ------------ method called to produce the data ------------
63  const auto& hcaltopo = iRecord.get(hcaltopoToken_);
64  const auto& cttopo = iRecord.get(cttopoToken_);
65 
66  auto prod = std::make_unique<CaloTowerConstituentsMap>(&hcaltopo, &cttopo);
67 
68  //auto prod = std::make_unique<CaloTowerConstituentsMap>( &hcaltopo );
69 
70  //keep geometry pointer as member for alternate EE->HE mapping
71  const CaloGeometry& geometry = iRecord.get(geometryToken_);
72 
73  prod->useStandardHB(true);
74  if (!skipHE_)
75  prod->useStandardHE(true);
76  prod->useStandardHF(true);
77  prod->useStandardHO(true);
78  prod->useStandardEB(true);
79 
80  if (!mapFile_.empty()) {
82  } else if (mapAuto_ && !skipHE_) {
83  assignEEtoHE(&geometry, *prod, &cttopo);
84  }
85  prod->sort();
86 
87  return prod;
88 }
89 
92 
93  gzFile gzed = gzopen(eff.fullPath().c_str(), "rb");
94 
95  while (!gzeof(gzed)) {
96  char line[1024];
97  int ieta, iphi, rawid;
98  if (nullptr != gzgets(gzed, line, 1023)) {
99  if (index(line, '#') != nullptr)
100  *(index(line, '#')) = 0;
101  int ct = sscanf(line, "%i %d %d", &rawid, &ieta, &iphi);
102  if (ct == 3) {
103  DetId detid(rawid);
104  CaloTowerDetId tid(ieta, iphi);
105  theMap.assign(detid, tid);
106  }
107  }
108  }
109  gzclose(gzed);
110 }
111 
112 //algorithm to assign EE cells to HE towers if no text map is provided
114  CaloTowerConstituentsMap& theMap,
115  const CaloTowerTopology* cttopo) {
116  //get EE and HE geometries
117  const CaloSubdetectorGeometry* geomEE = geometry->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
118  if (geomEE == nullptr)
119  return; // if no EE is defined don't know where it is used
120 
121  const CaloSubdetectorGeometry* geomHE = geometry->getSubdetectorGeometry(DetId::Hcal, HcalEndcap);
122 
123  //get list of EE detids
124  const std::vector<DetId>& vec(geomEE->getValidDetIds());
125  //loop over EE detids
126  for (auto detId_itr : vec) {
127  //get detid position
128  auto cellGeometry = geomEE->getGeometry(detId_itr);
129  const GlobalPoint& gp(cellGeometry->getPosition());
130 
131  //find closest HE cell
132  HcalDetId closestCell(geomHE->getClosestCell(gp));
133 
134  //assign to appropriate CaloTower
135  CaloTowerDetId tid(cttopo->convertHcaltoCT(closestCell.ietaAbs(), closestCell.subdet()) * closestCell.zside(),
136  closestCell.iphi());
137  theMap.assign(detId_itr, tid);
138  }
139 }
ConfigurationDescriptions.h
CaloTowerConstituentsMapBuilder::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CaloTowerConstituentsMapBuilder.cc:53
CaloTowerConstituentsMapBuilder::parseTextMap
void parseTextMap(const std::string &filename, CaloTowerConstituentsMap &theMap)
Definition: CaloTowerConstituentsMapBuilder.cc:90
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
funct::false
false
Definition: Factorize.h:29
CaloTowerConstituentsMapBuilder::CaloTowerConstituentsMapBuilder
CaloTowerConstituentsMapBuilder(const edm::ParameterSet &)
Definition: CaloTowerConstituentsMapBuilder.cc:32
CaloTowerConstituentsMap::assign
void assign(const DetId &cell, const CaloTowerDetId &tower)
set the association between a DetId and a tower
Definition: CaloTowerConstituentsMap.cc:53
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
geometry
Definition: geometry.py:1
HcalTopology
Definition: HcalTopology.h:26
EEDetId.h
DetId::Hcal
Definition: DetId.h:28
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CaloTowerTopology
Definition: CaloTowerTopology.h:13
CaloTowerConstituentsMapBuilder::geometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
Definition: CaloTowerConstituentsMapBuilder.h:57
CaloTowerConstituentsMapBuilder::assignEEtoHE
void assignEEtoHE(const CaloGeometry *geometry, CaloTowerConstituentsMap &theMap, const CaloTowerTopology *cttopo)
Definition: CaloTowerConstituentsMapBuilder.cc:113
CaloTowerConstituentsMapBuilder.h
CaloTowerConstituentsMapBuilder::cttopoToken_
edm::ESGetToken< CaloTowerTopology, HcalRecNumberingRecord > cttopoToken_
Definition: CaloTowerConstituentsMapBuilder.h:56
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:61
CaloGeometry
Definition: CaloGeometry.h:21
CaloTowerTopology::convertHcaltoCT
int convertHcaltoCT(int hcal_ieta, HcalSubdetector subdet) const
Definition: CaloTowerTopology.cc:79
CaloTowerConstituentsMapBuilder::mapFile_
std::string mapFile_
Definition: CaloTowerConstituentsMapBuilder.h:58
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CaloTowerConstituentsMapBuilder::ReturnType
std::unique_ptr< CaloTowerConstituentsMap > ReturnType
Definition: CaloTowerConstituentsMapBuilder.h:47
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
CaloTowerConstituentsMap
Definition: CaloTowerConstituentsMap.h:18
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
Point3DBase< float, GlobalTag >
ParameterSetDescription.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
CaloSubdetectorGeometry::getValidDetIds
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
Definition: CaloSubdetectorGeometry.cc:32
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
EcalEndcap
Definition: EcalSubdetector.h:10
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
HcalDetId.h
HcalDetId
Definition: HcalDetId.h:12
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
CaloSubdetectorGeometry::getClosestCell
virtual DetId getClosestCell(const GlobalPoint &r) const
Definition: CaloSubdetectorGeometry.cc:44
DetId::Ecal
Definition: DetId.h:27
cc
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CaloCellGeometry.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
CaloTowerConstituentsMapBuilder::mapAuto_
bool mapAuto_
Definition: CaloTowerConstituentsMapBuilder.h:59
HcalEndcap
Definition: HcalAssistant.h:34
CaloTowerConstituentsMapBuilder::hcaltopoToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcaltopoToken_
Definition: CaloTowerConstituentsMapBuilder.h:55
CaloTowerConstituentsMapBuilder::produce
ReturnType produce(const CaloGeometryRecord &)
Definition: CaloTowerConstituentsMapBuilder.cc:62
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CaloTowerConstituentsMapBuilder::~CaloTowerConstituentsMapBuilder
~CaloTowerConstituentsMapBuilder() override
Definition: CaloTowerConstituentsMapBuilder.cc:47
CaloTowerConstituentsMapBuilder::skipHE_
bool skipHE_
Definition: CaloTowerConstituentsMapBuilder.h:59
mps_splice.line
line
Definition: mps_splice.py:76
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
CaloTowerDetId
Definition: CaloTowerDetId.h:12