File indexing completed on 2024-04-06 12:14:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "Geometry/CaloEventSetup/plugins/EcalTrigTowerConstituentsMapBuilder.h"
0019 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
0020 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0021
0022 #include <fstream>
0023
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025
0026 EcalTrigTowerConstituentsMapBuilder::EcalTrigTowerConstituentsMapBuilder(const edm::ParameterSet& iConfig)
0027 : mapFile_(iConfig.getUntrackedParameter<std::string>("MapFile", "")) {
0028 setWhatProduced(this);
0029 }
0030
0031 EcalTrigTowerConstituentsMapBuilder::~EcalTrigTowerConstituentsMapBuilder() {}
0032
0033 EcalTrigTowerConstituentsMapBuilder::ReturnType EcalTrigTowerConstituentsMapBuilder::produce(
0034 const IdealGeometryRecord& iRecord) {
0035 auto prod = std::make_unique<EcalTrigTowerConstituentsMap>();
0036
0037 if (!mapFile_.empty()) {
0038 parseTextMap(mapFile_, *prod);
0039 }
0040 return prod;
0041 }
0042
0043 void EcalTrigTowerConstituentsMapBuilder::parseTextMap(const std::string& filename,
0044 EcalTrigTowerConstituentsMap& theMap) {
0045 edm::FileInPath eff(filename);
0046
0047 std::ifstream f(eff.fullPath().c_str());
0048 if (!f.good())
0049 return;
0050
0051 int ietaTower, iphiTower;
0052 int ix, iy, iz;
0053 char line[80];
0054 char ch;
0055 while ((ch = f.peek()) != '-') {
0056 f.get(line, 80, '\n');
0057 f.get(ch);
0058
0059
0060 int nread = sscanf(line, " %d %d %d %d %d", &ix, &iy, &iz, &ietaTower, &iphiTower);
0061 if (nread == 5) {
0062 EEDetId eeid(ix, iy, iz, 0);
0063 EcalTrigTowerDetId etid(iz, EcalEndcap, ietaTower, iphiTower);
0064 theMap.assign(DetId(eeid), etid);
0065 }
0066 }
0067
0068 f.get(line, 80, '\n');
0069 f.get(ch);
0070
0071 f.get(line, 80, '\n');
0072 f.get(ch);
0073 f.close();
0074 return;
0075 }