CMS 3D CMS Logo

SiPhase2OuterTrackerLorentzAngleWriter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CondTools/SiPhase2Tracker
4 // Class: SiPhase2OuterTrackerLorentzAngleWriter
5 //
14 //
15 // Original Author: Marco Musich
16 // Created: Mon, 18 May 2020 18:00:00 GMT
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 #include <iostream>
23 #include <string>
24 #include <unordered_map>
25 
26 // user include files
41 
42 //
43 // class declaration
44 //
45 
47 public:
50 
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54  void beginJob() override;
55  void analyze(const edm::Event&, const edm::EventSetup&) override;
56  void endJob() override;
57 
58  // ----------member data ---------------------------
61  float m_value;
62 };
63 
64 //
65 // constructors and destructor
66 //
68  : m_record(iConfig.getParameter<std::string>("record")),
69  m_tag(iConfig.getParameter<std::string>("tag")),
70  m_value(iConfig.getParameter<double>("value")) {}
71 
73  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
74  << "SiPhase2OuterTrackerLorentzAngleWriter::~SiPhase2OuterTrackerLorentzAngleWriter" << std::endl;
75 }
76 
77 //
78 // member functions
79 //
80 
81 // ------------ method called for each event ------------
84  using namespace edm;
85  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
86  << "SiPhase2OuterTrackerLorentzAngleWriter::analyze " << std::endl;
87 
88  // Database services (write)
90  if (!mydbservice.isAvailable()) {
91  edm::LogWarning("SiPhase2OuterTrackerLorentzAngleWriter") << "Service is unavailable" << std::endl;
92  return;
93  }
94 
95  std::string tag = mydbservice->tag(m_record);
96  unsigned int irun = iEvent.id().run();
97  edm::LogVerbatim("SiPhase2OuterTrackerLorentzAngleWriter") << "Writing on tag : " << tag << std::endl;
98  edm::LogVerbatim("SiPhase2OuterTrackerLorentzAngleWriter") << "Usinng as IOV run : " << irun << std::endl;
99 
100  // map to be filled
101  std::unordered_map<unsigned int, float> detsLAtoDB;
102 
103  // Retrieve tracker topology from geometry
104  edm::ESHandle<TrackerTopology> tTopoHandle;
105  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
106  const TrackerTopology* const tTopo = tTopoHandle.product();
107 
108  // Retrieve old style tracker geometry from geometry
110  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
111  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
112  << " There are " << pDD->detUnits().size() << " modules in this geometry." << std::endl;
113 
114  for (auto const& det_u : pDD->detUnits()) {
115  const DetId detid = det_u->geographicalId();
116  uint32_t rawId = detid.rawId();
117  int subid = detid.subdetId();
118  if (detid.det() == DetId::Detector::Tracker) {
119  const Phase2TrackerGeomDetUnit* pixdet = dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u);
120  assert(pixdet);
121  LogDebug("SiPhase2OuterTrackerLorentzAngleWriter") << rawId << " is a " << subid << " det" << std::endl;
122  if (subid == StripSubdetector::TOB || subid == StripSubdetector::TID) {
123  LogDebug("SiPhase2OuterTrackerLorentzAngleWriter")
124  << "subdetector ID:" << subid << " layer:" << tTopo->layer(detid) << std::endl;
125  detsLAtoDB[rawId] = m_value;
126  }
127  }
128  }
129 
130  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
131  << " There are " << detsLAtoDB.size() << " OT Lorentz Angle values assigned" << std::endl;
132 
133  // SiStripLorentzAngle object
134 
135  auto lorentzAngle = std::make_unique<SiPhase2OuterTrackerLorentzAngle>();
136  lorentzAngle->putLorentzAngles(detsLAtoDB);
137  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter") << "currentTime " << mydbservice->currentTime() << std::endl;
138  mydbservice->writeOne(lorentzAngle.get(), mydbservice->currentTime(), m_record);
139 }
140 
141 // ------------ method called once each job just before starting event loop ------------
143 
144 // ------------ method called once each job just after ending the event loop ------------
146 
147 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
150  desc.add<std::string>("record", "SiPhase2OuterTrackerLorentzAngleRcd");
151  desc.add<std::string>("tag", "SiPhase2OuterTrackerLorentzAngle");
152  desc.add<double>("value", 0.07);
153  descriptions.addDefault(desc);
154 }
155 
156 //define this as a plug-in
SiPhase2OuterTrackerLorentzAngleWriter::m_record
std::string m_record
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:59
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SiPhase2OuterTrackerLorentzAngleWriter::SiPhase2OuterTrackerLorentzAngleWriter
SiPhase2OuterTrackerLorentzAngleWriter(const edm::ParameterSet &)
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:67
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:96
EDAnalyzer.h
TrackerGeometry.h
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SiPhase2OuterTrackerLorentzAngleRcd.h
align::Tracker
Definition: StructureType.h:70
SiPhase2OuterTrackerLorentzAngleWriter::beginJob
void beginJob() override
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:142
DetId
Definition: DetId.h:17
MakerMacros.h
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
SiPhase2OuterTrackerLorentzAngleWriter::m_value
float m_value
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:61
TrackerGeometry::detUnits
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: TrackerGeometry.h:61
Service.h
SiPhase2OuterTrackerLorentzAngleWriter::endJob
void endJob() override
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:145
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerTopology >
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPhase2OuterTrackerLorentzAngleWriter::~SiPhase2OuterTrackerLorentzAngleWriter
~SiPhase2OuterTrackerLorentzAngleWriter() override
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:72
TrackerDigiGeometryRecord.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
SiPhase2OuterTrackerLorentzAngleWriter
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:46
edm::Service< cond::service::PoolDBOutputService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
InputTag.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:57
SiPhase2OuterTrackerLorentzAngleWriter::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:148
PixelGeomDetUnit.h
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
SiPhase2OuterTrackerLorentzAngleWriter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:82
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
StripSubdetector.h
SiPhase2OuterTrackerLorentzAngle.h
SiPhase2OuterTrackerLorentzAngleWriter::m_tag
std::string m_tag
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:60
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:189
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17