CMS 3D CMS Logo

PPSDiamondSampicTimingCalibrationPCLWorker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibPPS/TimingCalibration/PPSDiamondSampicTimingCalibrationPCLWorker
4 // Class: PPSDiamondSampicTimingCalibrationPCLWorker
5 //
13 //
14 // Original Author: Christopher Misan
15 // Created: Mon, 26 Jul 2021 07:37:13 GMT
16 //
17 //
18 
19 #include <string>
20 
23 
26 
28 
31 
37 
38 //------------------------------------------------------------------------------
39 
41  std::unordered_map<uint32_t, dqm::reco::MonitorElement*> timeHisto;
42  std::unordered_map<uint32_t, dqm::reco::MonitorElement*> db;
43  std::unordered_map<uint32_t, dqm::reco::MonitorElement*> sampic;
44  std::unordered_map<uint32_t, dqm::reco::MonitorElement*> channel;
45 };
46 
48  : public DQMGlobalEDAnalyzer<Histograms_PPSDiamondSampicTimingCalibrationPCLWorker> {
49 public:
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
57  edm::Run const&,
58  edm::EventSetup const&,
60 
61  void dqmAnalyze(edm::Event const&,
62  edm::EventSetup const&,
64 
65  template <typename T>
67  const std::vector<edm::EDGetTokenT<T>>& tokens,
68  const std::vector<edm::InputTag>& tags,
69  edm::Handle<T>& handle) const;
70 
71  // ------------ member data ------------
72  const std::vector<edm::InputTag> digiTags_;
73  const std::vector<edm::InputTag> RecHitTags_;
74 
75  std::vector<edm::EDGetTokenT<edm::DetSetVector<TotemTimingDigi>>> totemTimingDigiTokens_;
76  std::vector<edm::EDGetTokenT<edm::DetSetVector<TotemTimingRecHit>>> totemTimingRecHitTokens_;
77 
80 };
81 
82 //------------------------------------------------------------------------------
83 
85  : digiTags_(iConfig.getParameter<std::vector<edm::InputTag>>("totemTimingDigiTags")),
86  RecHitTags_(iConfig.getParameter<std::vector<edm::InputTag>>("totemTimingRecHitTags")),
87  geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
88  folder_(iConfig.getParameter<std::string>("folder")) {
89  for (auto& tag : digiTags_)
91  for (auto& tag : RecHitTags_)
93 }
94 
96 
97 //------------------------------------------------------------------------------
98 
100  edm::Event const& iEvent,
101  edm::EventSetup const& iSetup,
105 
108 
109  if (timingRecHit->empty()) {
110  edm::LogWarning("PPSDiamondSampicTimingCalibrationPCLWorker:dqmAnalyze")
111  << "No rechits retrieved from the event content.";
112  return;
113  }
114 
115  for (const auto& digis : *timingDigi) {
116  const CTPPSDiamondDetId detId(digis.detId());
117  for (const auto& digi : digis) {
118  histos.db.at(detId.rawId())->Fill(digi.hardwareBoardId());
119  histos.sampic.at(detId.rawId())->Fill(digi.hardwareSampicId());
120  histos.channel.at(detId.rawId())->Fill(digi.hardwareChannelId());
121  }
122  }
123 
124  for (const auto& recHits : *timingRecHit) {
125  const CTPPSDiamondDetId detId(recHits.detId());
126  for (const auto& recHit : recHits)
127  histos.timeHisto.at(detId.rawId())->Fill(recHit.time());
128  }
129 }
130 
131 //------------------------------------------------------------------------------
132 
134  DQMStore::IBooker& ibook,
135  edm::Run const& run,
136  edm::EventSetup const& iSetup,
138  ibook.setCurrentFolder(folder_);
139  std::string ch_name;
140  const auto& geom = iSetup.getData(geomEsToken_);
141  for (auto it = geom.beginSensor(); it != geom.endSensor(); ++it) {
142  if (!CTPPSDiamondDetId::check(it->first))
143  continue;
144  const CTPPSDiamondDetId detid(it->first);
145 
148  detid.channelName(ch_name);
149  histos.timeHisto[detid.rawId()] = ibook.book1D(path + "/" + ch_name, ch_name, 500, -25, 25);
150  histos.db[detid.rawId()] = ibook.bookInt(path + "/" + ch_name + "db");
151  histos.sampic[detid.rawId()] = ibook.bookInt(path + "/" + ch_name + "sampic");
152  histos.channel[detid.rawId()] = ibook.bookInt(path + "/" + ch_name + "channel");
153  }
154 }
155 
156 //------------------------------------------------------------------------------
157 
160  desc.add<std::vector<edm::InputTag>>("totemTimingDigiTags", {edm::InputTag("totemTimingRawToDigi", "TotemTiming")})
161  ->setComment("input tag for the PPS diamond detectors digi");
162  desc.add<std::vector<edm::InputTag>>("totemTimingRecHitTags", {edm::InputTag("totemTimingRecHits")})
163  ->setComment("input tag for the PPS diamond detectors rechits");
164  desc.add<std::string>("folder", "AlCaReco/PPSDiamondSampicTimingCalibrationPCL")
165  ->setComment("output path for the various DQM plots");
166  descriptions.add("PPSDiamondSampicTimingCalibrationPCLWorker", desc);
167 }
168 
169 //------------------------------------------------------------------------------
170 
171 template <typename T>
173  const std::vector<edm::EDGetTokenT<T>>& tokens,
174  const std::vector<edm::InputTag>& tags,
175  edm::Handle<T>& handle) const {
176  bool foundProduct = false;
177  for (unsigned int i = 0; i < tokens.size(); i++)
178  if (auto h = iEvent.getHandle(tokens[i])) {
179  handle = h;
180  foundProduct = true;
181  edm::LogInfo("searchForProduct") << "Found a product with " << tags[i];
182  break;
183  }
184 
185  if (!foundProduct)
186  throw edm::Exception(edm::errors::ProductNotFound) << "Could not find a product with any of the selected labels.";
187 
188  return foundProduct;
189 }
190 
bool searchForProduct(edm::Event const &iEvent, const std::vector< edm::EDGetTokenT< T >> &tokens, const std::vector< edm::InputTag > &tags, edm::Handle< T > &handle) const
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::string folder_
std::unordered_map< uint32_t, dqm::reco::MonitorElement * > timeHisto
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unordered_map< uint32_t, dqm::reco::MonitorElement * > db
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unordered_map< uint32_t, dqm::reco::MonitorElement * > channel
std::vector< edm::EDGetTokenT< edm::DetSetVector< TotemTimingDigi > > > totemTimingDigiTokens_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Transition
Definition: Transition.h:12
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void channelName(std::string &name, NameFlag flag=nFull) const
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
Log< level::Info, false > LogInfo
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms_PPSDiamondSampicTimingCalibrationPCLWorker const &) const override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
void add(std::string const &label, ParameterSetDescription const &psetDescription)
histos
Definition: combine.py:4
const edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > geomEsToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms_PPSDiamondSampicTimingCalibrationPCLWorker &) const override
HLT enums.
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
std::unordered_map< uint32_t, dqm::reco::MonitorElement * > sampic
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< edm::EDGetTokenT< edm::DetSetVector< TotemTimingRecHit > > > totemTimingRecHitTokens_
Definition: Run.h:45