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 ---------------------------
63  float m_value;
64 };
65 
66 //
67 // constructors and destructor
68 //
70  : topoToken_(esConsumes()),
71  geomToken_(esConsumes()),
72  m_record(iConfig.getParameter<std::string>("record")),
73  m_tag(iConfig.getParameter<std::string>("tag")),
74  m_value(iConfig.getParameter<double>("value")) {}
75 
77  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
78  << "SiPhase2OuterTrackerLorentzAngleWriter::~SiPhase2OuterTrackerLorentzAngleWriter" << std::endl;
79 }
80 
81 //
82 // member functions
83 //
84 
85 // ------------ method called for each event ------------
88  using namespace edm;
89  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
90  << "SiPhase2OuterTrackerLorentzAngleWriter::analyze " << std::endl;
91 
92  // Database services (write)
94  if (!mydbservice.isAvailable()) {
95  edm::LogWarning("SiPhase2OuterTrackerLorentzAngleWriter") << "Service is unavailable" << std::endl;
96  return;
97  }
98 
99  std::string tag = mydbservice->tag(m_record);
100  unsigned int irun = iEvent.id().run();
101  edm::LogVerbatim("SiPhase2OuterTrackerLorentzAngleWriter") << "Writing on tag : " << tag << std::endl;
102  edm::LogVerbatim("SiPhase2OuterTrackerLorentzAngleWriter") << "Usinng as IOV run : " << irun << std::endl;
103 
104  // map to be filled
105  std::unordered_map<unsigned int, float> detsLAtoDB;
106 
107  // Retrieve tracker topology from geometry
108  const TrackerTopology* const tTopo = &iSetup.getData(topoToken_);
109 
110  // Retrieve old style tracker geometry from geometry
111  const TrackerGeometry* pDD = &iSetup.getData(geomToken_);
112  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
113  << " There are " << pDD->detUnits().size() << " modules in this geometry." << std::endl;
114 
115  for (auto const& det_u : pDD->detUnits()) {
116  const DetId detid = det_u->geographicalId();
117  uint32_t rawId = detid.rawId();
118  int subid = detid.subdetId();
119  if (detid.det() == DetId::Detector::Tracker) {
120  const Phase2TrackerGeomDetUnit* pixdet = dynamic_cast<const Phase2TrackerGeomDetUnit*>(det_u);
121  assert(pixdet);
122  LogDebug("SiPhase2OuterTrackerLorentzAngleWriter") << rawId << " is a " << subid << " det" << std::endl;
123  if (subid == StripSubdetector::TOB || subid == StripSubdetector::TID) {
124  LogDebug("SiPhase2OuterTrackerLorentzAngleWriter")
125  << "subdetector ID:" << subid << " layer:" << tTopo->layer(detid) << std::endl;
126  detsLAtoDB[rawId] = m_value;
127  }
128  }
129  }
130 
131  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter")
132  << " There are " << detsLAtoDB.size() << " OT Lorentz Angle values assigned" << std::endl;
133 
134  // SiStripLorentzAngle object
135 
136  auto lorentzAngle = std::make_unique<SiPhase2OuterTrackerLorentzAngle>();
137  lorentzAngle->putLorentzAngles(detsLAtoDB);
138  edm::LogInfo("SiPhase2OuterTrackerLorentzAngleWriter") << "currentTime " << mydbservice->currentTime() << std::endl;
139  mydbservice->writeOne(lorentzAngle.get(), mydbservice->currentTime(), m_record);
140 }
141 
142 // ------------ method called once each job just before starting event loop ------------
144 
145 // ------------ method called once each job just after ending the event loop ------------
147 
148 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
151  desc.add<std::string>("record", "SiPhase2OuterTrackerLorentzAngleRcd");
152  desc.add<std::string>("tag", "SiPhase2OuterTrackerLorentzAngle");
153  desc.add<double>("value", 0.07);
154  descriptions.addDefault(desc);
155 }
156 
157 //define this as a plug-in
SiPhase2OuterTrackerLorentzAngleWriter::m_record
std::string m_record
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:61
SiPhase2OuterTrackerLorentzAngleWriter::SiPhase2OuterTrackerLorentzAngleWriter
SiPhase2OuterTrackerLorentzAngleWriter(const edm::ParameterSet &)
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:69
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:124
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
SiPhase2OuterTrackerLorentzAngleWriter::geomToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:60
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:143
DetId
Definition: DetId.h:17
MakerMacros.h
PoolDBOutputService.h
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:63
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:146
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
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:76
TrackerDigiGeometryRecord.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
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:58
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd >
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
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:63
SiPhase2OuterTrackerLorentzAngleWriter::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:149
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:86
SiPhase2OuterTrackerLorentzAngleWriter::topoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: SiPhase2OuterTrackerLorentzAngleWriter.cc:59
ParameterSet.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
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:62
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
TrackerGeometry
Definition: TrackerGeometry.h:14