CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTT0FillDefaultFromDB.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  */
4 
10 
14 
15 #include <string>
16 
17 using namespace std;
18 using namespace edm;
19 
20 namespace dtCalibration {
21 
22  DTT0FillDefaultFromDB::DTT0FillDefaultFromDB(const ParameterSet& pset, edm::ConsumesCollector cc)
23  : t0Token_(cc.esConsumes<edm::Transition::BeginRun>()),
24  t0RefToken_(
25  cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getParameter<string>("dbLabelRef")))) {}
26 
28 
30  // Get t0 record from DB
31  ESHandle<DTT0> t0H = setup.getHandle(t0Token_);
32  t0Map_ = &*t0H;
33  LogVerbatim("Calibration") << "[DTT0FillDefaultFromDB] T0 version: " << t0H->version();
34 
35  // Get reference t0 DB
36  ESHandle<DTT0> t0RefH = setup.getHandle(t0RefToken_);
37  t0MapRef_ = &*t0RefH;
38  LogVerbatim("Calibration") << "[DTT0FillDefaultFromDB] Reference T0 version: " << t0RefH->version();
39  }
40 
42  // Try to access value in default DB
43  // If it does not exist return value from reference DB
44  // If it does not exist in reference DB, throw exception
45  // Could also set to default zero value
46  float t0Mean, t0RMS;
47  int status = t0Map_->get(wireId, t0Mean, t0RMS, DTTimeUnits::counts);
48  if (!status) {
49  return DTT0Data(t0Mean, t0RMS);
50  } else {
51  // Now access reference DB
52  float t0MeanRef, t0RMSRef;
53  int statusRef = t0MapRef_->get(wireId, t0MeanRef, t0RMSRef, DTTimeUnits::counts);
54  if (!statusRef) {
55  return DTT0Data(t0MeanRef, t0RMSRef);
56  } else {
57  //...
58  throw cms::Exception("[DTT0FillDefaultFromDB]")
59  << "Could not find t0 entry in reference DB for" << wireId << endl;
60  }
61  }
62  }
63 
64 } // namespace dtCalibration
Log< level::Info, true > LogVerbatim
edm::ESGetToken< DTT0, DTT0Rcd > t0RefToken_
list status
Definition: mps_update.py:107
void setES(const edm::EventSetup &setup) override
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
Definition: DTT0.cc:48
Transition
Definition: Transition.h:12
DTT0Data correction(const DTWireId &) override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< DTT0, DTT0Rcd > t0Token_