CMS 3D CMS Logo

PPSTimingCalibrationPCLWorker.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of PPS offline software.
4  * Authors:
5  * Edoardo Bossini
6  * Piotr Maciej Cwiklicki
7  * Laurent Forthomme
8  *
9  ****************************************************************************/
10 
13 
18 
21 
25 
27 
28 //------------------------------------------------------------------------------
29 
30 class PPSTimingCalibrationPCLWorker : public DQMGlobalEDAnalyzer<TimingCalibrationHistograms> {
31 public:
33 
34  void dqmAnalyze(const edm::Event&, const edm::EventSetup&, const TimingCalibrationHistograms&) const override;
35 
37 
38 private:
40  const edm::Run&,
41  const edm::EventSetup&,
42  TimingCalibrationHistograms&) const override;
43 
44  template <typename T>
46  const std::vector<edm::EDGetTokenT<T>>& tokens,
47  const std::vector<edm::InputTag>& tags,
48  edm::Handle<T>& handle) const;
49 
50  const std::vector<edm::InputTag> RecHitTags_;
51  std::vector<edm::EDGetTokenT<edm::DetSetVector<CTPPSDiamondRecHit>>> diamondRecHitTokens_;
53 
55 };
56 
57 //------------------------------------------------------------------------------
58 
60  : RecHitTags_(iConfig.getParameter<std::vector<edm::InputTag>>("diamondRecHitTags")),
61  geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
62  dqmDir_(iConfig.getParameter<std::string>("dqmDir")) {
63  for (auto& tag : RecHitTags_)
65 }
66 
67 //------------------------------------------------------------------------------
68 
70  const edm::Run& iRun,
71  const edm::EventSetup& iSetup,
72  TimingCalibrationHistograms& iHists) const {
73  iBooker.cd();
74  iBooker.setCurrentFolder(dqmDir_);
75  std::string ch_name;
76 
77  const auto& geom = iSetup.getData(geomEsToken_);
78  for (auto it = geom.beginSensor(); it != geom.endSensor(); ++it) {
79  if (!CTPPSDiamondDetId::check(it->first))
80  continue;
81  const CTPPSDiamondDetId detid(it->first);
82 
83  detid.channelName(ch_name);
84  iHists.leadingTime[detid.rawId()] = iBooker.book1D("t_" + ch_name, ch_name + ";t (ns);Entries", 1200, -60., 60.);
85  iHists.toT[detid.rawId()] = iBooker.book1D("tot_" + ch_name, ch_name + ";ToT (ns);Entries", 100, -20., 20.);
86  iHists.leadingTimeVsToT[detid.rawId()] =
87  iBooker.book2D("tvstot_" + ch_name, ch_name + ";ToT (ns);t (ns)", 240, 0., 60., 450, -20., 25.);
88  }
89 }
90 
91 //------------------------------------------------------------------------------
92 
94  const edm::EventSetup& iSetup,
95  const TimingCalibrationHistograms& iHists) const {
97  // then extract the rechits information for later processing
99 
100  // ensure timing detectors rechits are found in the event content
101  if (dsv_rechits->empty()) {
102  edm::LogWarning("PPSTimingCalibrationPCLWorker:dqmAnalyze") << "No rechits retrieved from the event content.";
103  return;
104  }
105  for (const auto& ds_rechits : *dsv_rechits) {
106  const CTPPSDiamondDetId detid(ds_rechits.detId());
107  if (iHists.leadingTimeVsToT.count(detid.rawId()) == 0) {
108  edm::LogWarning("PPSTimingCalibrationPCLWorker:dqmAnalyze")
109  << "Pad with detId=" << detid << " is not set to be monitored.";
110  continue;
111  }
112  for (const auto& rechit : ds_rechits) {
113  // skip invalid rechits
114  if (rechit.time() == 0. || rechit.toT() < 0.)
115  continue;
116  iHists.leadingTime.at(detid.rawId())->Fill(rechit.time());
117  iHists.toT.at(detid.rawId())->Fill(rechit.toT());
118  iHists.leadingTimeVsToT.at(detid.rawId())->Fill(rechit.toT(), rechit.time());
119  }
120  }
121 }
122 
123 //------------------------------------------------------------------------------
124 
127  desc.add<std::vector<edm::InputTag>>("diamondRecHitTags", {edm::InputTag("ctppsDiamondRecHits")})
128  ->setComment("input tag for the PPS diamond detectors rechits");
129  desc.add<std::string>("dqmDir", "AlCaReco/PPSTimingCalibrationPCL")
130  ->setComment("output path for the various DQM plots");
131 
132  descriptions.addWithDefaultLabel(desc);
133 }
134 
135 template <typename T>
137  const std::vector<edm::EDGetTokenT<T>>& tokens,
138  const std::vector<edm::InputTag>& tags,
139  edm::Handle<T>& handle) const {
140  bool foundProduct = false;
141  for (unsigned int i = 0; i < tokens.size(); i++)
142  if (auto h = iEvent.getHandle(tokens[i])) {
143  handle = h;
144  foundProduct = true;
145  edm::LogInfo("searchForProduct") << "Found a product with " << tags[i];
146  break;
147  }
148 
149  if (!foundProduct)
150  throw edm::Exception(edm::errors::ProductNotFound) << "Could not find a product with any of the selected labels.";
151 
152  return foundProduct;
153 }
154 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
bool searchForProduct(edm::Event const &iEvent, const std::vector< edm::EDGetTokenT< T >> &tokens, const std::vector< edm::InputTag > &tags, edm::Handle< T > &handle) const
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::vector< edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondRecHit > > > diamondRecHitTokens_
static void fillDescriptions(edm::ConfigurationDescriptions &)
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void channelName(std::string &name, NameFlag flag=nFull) const
const edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > geomEsToken_
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
const std::vector< edm::InputTag > RecHitTags_
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:221
PPSTimingCalibrationPCLWorker(const edm::ParameterSet &)
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &, TimingCalibrationHistograms &) const override
HLT enums.
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
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
void dqmAnalyze(const edm::Event &, const edm::EventSetup &, const TimingCalibrationHistograms &) const override
Definition: Run.h:45