CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  if (detid.station() != 1)
83  continue;
84  detid.channelName(ch_name);
85  iHists.leadingTime[detid.rawId()] = iBooker.book1D("t_" + ch_name, ch_name + ";t (ns);Entries", 1200, -60., 60.);
86  iHists.toT[detid.rawId()] = iBooker.book1D("tot_" + ch_name, ch_name + ";ToT (ns);Entries", 100, -20., 20.);
87  iHists.leadingTimeVsToT[detid.rawId()] =
88  iBooker.book2D("tvstot_" + ch_name, ch_name + ";ToT (ns);t (ns)", 240, 0., 60., 450, -20., 25.);
89  }
90 }
91 
92 //------------------------------------------------------------------------------
93 
95  const edm::EventSetup& iSetup,
96  const TimingCalibrationHistograms& iHists) const {
98  // then extract the rechits information for later processing
99  searchForProduct(iEvent, diamondRecHitTokens_, RecHitTags_, dsv_rechits);
100 
101  // ensure timing detectors rechits are found in the event content
102  if (dsv_rechits->empty()) {
103  edm::LogWarning("PPSTimingCalibrationPCLWorker:dqmAnalyze") << "No rechits retrieved from the event content.";
104  return;
105  }
106  for (const auto& ds_rechits : *dsv_rechits) {
107  const CTPPSDiamondDetId detid(ds_rechits.detId());
108  if (iHists.leadingTimeVsToT.count(detid.rawId()) == 0) {
109  edm::LogWarning("PPSTimingCalibrationPCLWorker:dqmAnalyze")
110  << "Pad with detId=" << detid << " is not set to be monitored.";
111  continue;
112  }
113  for (const auto& rechit : ds_rechits) {
114  // skip invalid rechits
115  if (rechit.time() == 0. || rechit.toT() < 0.)
116  continue;
117  iHists.leadingTime.at(detid.rawId())->Fill(rechit.time());
118  iHists.toT.at(detid.rawId())->Fill(rechit.toT());
119  iHists.leadingTimeVsToT.at(detid.rawId())->Fill(rechit.toT(), rechit.time());
120  }
121  }
122 }
123 
124 //------------------------------------------------------------------------------
125 
128  desc.add<std::vector<edm::InputTag>>("diamondRecHitTags", {edm::InputTag("ctppsDiamondRecHits")})
129  ->setComment("input tag for the PPS diamond detectors rechits");
130  desc.add<std::string>("dqmDir", "AlCaReco/PPSTimingCalibrationPCL")
131  ->setComment("output path for the various DQM plots");
132 
133  descriptions.addWithDefaultLabel(desc);
134 }
135 
136 template <typename T>
138  const std::vector<edm::EDGetTokenT<T>>& tokens,
139  const std::vector<edm::InputTag>& tags,
140  edm::Handle<T>& handle) const {
141  bool foundProduct = false;
142  for (unsigned int i = 0; i < tokens.size(); i++)
143  if (auto h = iEvent.getHandle(tokens[i])) {
144  handle = h;
145  foundProduct = true;
146  edm::LogInfo("searchForProduct") << "Found a product with " << tags[i];
147  break;
148  }
149 
150  if (!foundProduct)
151  throw edm::Exception(edm::errors::ProductNotFound) << "Could not find a product with any of the selected labels.";
152 
153  return foundProduct;
154 }
155 
uint32_t station() const
Definition: CTPPSDetId.h:58
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool searchForProduct(edm::Event const &iEvent, const std::vector< edm::EDGetTokenT< T >> &tokens, const std::vector< edm::InputTag > &tags, edm::Handle< T > &handle) const
void channelName(std::string &name, NameFlag flag=nFull) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondRecHit > > > diamondRecHitTokens_
static void fillDescriptions(edm::ConfigurationDescriptions &)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
int iEvent
Definition: GenABIO.cc:224
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
tuple handle
Definition: patZpeak.py:25
Transition
Definition: Transition.h:12
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
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:177
PPSTimingCalibrationPCLWorker(const edm::ParameterSet &)
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &, TimingCalibrationHistograms &) const override
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
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Definition: Run.h:45