CMS 3D CMS Logo

OnlineBeamSpotESProducer.cc
Go to the documentation of this file.
14 
19 #include <memory>
20 #include <iostream>
21 #include <string>
22 
23 using namespace edm;
24 
26 public:
28  std::shared_ptr<const BeamSpotObjects> produce(const BeamSpotTransientObjectsRcd&);
30 
31 private:
32  const BeamSpotOnlineObjects* compareBS(const BeamSpotOnlineObjects* bs1, const BeamSpotOnlineObjects* bs2);
34 
38 };
40  auto cc = setWhatProduced(this);
41 
42  fakeBS_.SetBeamWidthX(0.1);
43  fakeBS_.SetBeamWidthY(0.1);
44  fakeBS_.SetSigmaZ(15.);
45  fakeBS_.SetPosition(0., 0., 0.);
46  fakeBS_.SetType(-1);
47 
48  bsHLTToken_ = cc.consumesFrom<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd>();
49  bsLegacyToken_ = cc.consumesFrom<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd>();
50 }
51 
54  desc.addWithDefaultLabel(dsc);
55 }
56 
58  const BeamSpotOnlineObjects* bs2) {
59  //Random logic so far ...
60  if (bs1->GetSigmaZ() - 0.0001 < bs2->GetSigmaZ()) { //just temporary for debugging
61  if (bs1->GetSigmaZ() > 5.) {
62  return bs1;
63  } else {
64  return bs2;
65  }
66 
67  } else {
68  if (bs2->GetSigmaZ() > 5.) {
69  return bs2;
70  } else {
71  return bs1;
72  }
73  }
74 }
75 
76 std::shared_ptr<const BeamSpotObjects> OnlineBeamSpotESProducer::produce(const BeamSpotTransientObjectsRcd& iRecord) {
77  auto legacyRec = iRecord.tryToGetRecord<BeamSpotOnlineLegacyObjectsRcd>();
78  auto hltRec = iRecord.tryToGetRecord<BeamSpotOnlineHLTObjectsRcd>();
79  if (not legacyRec and not hltRec) {
80  return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
81  }
82 
83  const BeamSpotOnlineObjects* best;
84  if (legacyRec and hltRec) {
85  best = compareBS(&legacyRec->get(bsLegacyToken_), &hltRec->get(bsHLTToken_));
86  } else if (legacyRec) {
87  best = &legacyRec->get(bsLegacyToken_);
88  } else {
89  best = &hltRec->get(bsHLTToken_);
90  }
91  return std::shared_ptr<const BeamSpotObjects>(best, edm::do_nothing_deleter());
92 };
93 
ConfigurationDescriptions.h
BeamSpotOnlineHLTObjectsRcd
Definition: BeamSpotOnlineHLTObjectsRcd.h:24
OnlineBeamSpotESProducer::bsLegacyToken_
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
Definition: OnlineBeamSpotESProducer.cc:37
ESHandle.h
BeamSpotTransientObjectsRcd
Definition: BeamSpotTransientObjectsRcd.h:27
BeamSpotObjects::GetSigmaZ
double GetSigmaZ() const
get sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:73
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::do_nothing_deleter
Definition: do_nothing_deleter.h:34
OnlineBeamSpotESProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &desc)
Definition: OnlineBeamSpotESProducer.cc:52
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
BeamSpotOnlineLegacyObjectsRcd.h
cc
ReusableObjectHolder.h
BeamSpotObjectsRcd.h
BeamSpot.h
OnlineBeamSpotESProducer::produce
std::shared_ptr< const BeamSpotObjects > produce(const BeamSpotTransientObjectsRcd &)
Definition: OnlineBeamSpotESProducer.cc:76
OnlineBeamSpotESProducer::fakeBS_
BeamSpotObjects fakeBS_
Definition: OnlineBeamSpotESProducer.cc:33
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
BeamSpotOnlineLegacyObjectsRcd
Definition: BeamSpotOnlineLegacyObjectsRcd.h:24
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
OnlineBeamSpotESProducer
Definition: OnlineBeamSpotESProducer.cc:25
edm::ParameterSet
Definition: ParameterSet.h:47
BeamSpotTransientObjectsRcd.h
OnlineBeamSpotESProducer::OnlineBeamSpotESProducer
OnlineBeamSpotESProducer(const edm::ParameterSet &p)
Definition: OnlineBeamSpotESProducer.cc:39
BeamSpotObjects
Definition: BeamSpotObjects.h:20
edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd >
BeamSpotOnlineHLTObjectsRcd.h
ModuleFactory.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::eventsetup::DependentRecordImplementation::tryToGetRecord
std::optional< DepRecordT > tryToGetRecord() const
Definition: DependentRecordImplementation.h:68
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
OnlineBeamSpotESProducer::bsToken_
const edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > bsToken_
Definition: OnlineBeamSpotESProducer.cc:35
BeamSpotOnlineObjects
Definition: BeamSpotOnlineObjects.h:25
OnlineBeamSpotESProducer::bsHLTToken_
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
Definition: OnlineBeamSpotESProducer.cc:36
EventSetup.h
OnlineBeamSpotESProducer::compareBS
const BeamSpotOnlineObjects * compareBS(const BeamSpotOnlineObjects *bs1, const BeamSpotOnlineObjects *bs2)
Definition: OnlineBeamSpotESProducer.cc:57
edm::ESProducer
Definition: ESProducer.h:104
ESProductHost.h
BeamSpotOnlineObjects.h
ParameterSet.h
do_nothing_deleter.h