CMS 3D CMS Logo

DTT0FillChamberFromDB.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2012/03/21 13:48:46 $
5  * $Revision: 1.2 $
6  * \author A. Vilela Pereira
7  */
8 
14 
18 
19 #include <string>
20 #include <sstream>
21 
22 using namespace std;
23 using namespace edm;
24 
25 namespace dtCalibration {
26 
27  DTT0FillChamberFromDB::DTT0FillChamberFromDB(const ParameterSet& pset)
28  : dbLabelRef_(pset.getParameter<string>("dbLabelRef")), chamberRef_(pset.getParameter<string>("chamberId")) {
29  //DTChamberId chosenChamberId;
30  if (!chamberRef_.empty() && chamberRef_ != "None") {
31  stringstream linestr;
32  int selWheel, selStation, selSector;
33  linestr << chamberRef_;
34  linestr >> selWheel >> selStation >> selSector;
35  chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
36  LogVerbatim("Calibration") << "[DTT0FillChamberFromDB] Chosen chamber: " << chosenChamberId_ << endl;
37  }
38  //FIXME: Check if chosen chamber is valid.
39  }
40 
42 
44  // Get t0 record from DB
45  ESHandle<DTT0> t0H;
46  setup.get<DTT0Rcd>().get(t0H);
47  t0Map_ = &*t0H;
48  LogVerbatim("Calibration") << "[DTT0FillChamberFromDB] T0 version: " << t0H->version();
49 
50  // Get reference t0 DB
51  ESHandle<DTT0> t0RefH;
52  setup.get<DTT0Rcd>().get(dbLabelRef_, t0RefH);
53  t0MapRef_ = &*t0RefH;
54  LogVerbatim("Calibration") << "[DTT0FillChamberFromDB] Reference T0 version: " << t0RefH->version();
55  }
56 
58  // If wire belongs to chosen chamber, use t0 value from reference DB
59  // Otherwise use value from default DB
60 
61  DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
62 
63  if (!chamberRef_.empty() && chamberRef_ != "None" && chamberId == chosenChamberId_) {
64  // Access reference DB
65  float t0MeanRef, t0RMSRef;
66  int statusRef = t0MapRef_->get(wireId, t0MeanRef, t0RMSRef, DTTimeUnits::counts);
67  if (!statusRef) {
68  return DTT0Data(t0MeanRef, t0RMSRef);
69  } else {
70  //...
71  throw cms::Exception("[DTT0FillChamberFromDB]")
72  << "Could not find t0 entry in reference DB for" << wireId << endl;
73  }
74  } else {
75  // Access default DB
76  float t0Mean, t0RMS;
77  int status = t0Map_->get(wireId, t0Mean, t0RMS, DTTimeUnits::counts);
78  if (!status) {
79  return DTT0Data(t0Mean, t0RMS);
80  } else {
81  //...
82  throw cms::Exception("[DTT0FillChamberFromDB]") << "Could not find t0 entry in DB for" << wireId << endl;
83  }
84  }
85  }
86 
87 } // namespace dtCalibration
DTT0Data correction(const DTWireId &) override
DTChamberId chamberId() const
Return the corresponding ChamberId.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
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
Definition: DTT0Rcd.h:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
HLT enums.
T get() const
Definition: EventSetup.h:73
const std::string & version() const
access version
Definition: DTT0.cc:82
void setES(const edm::EventSetup &setup) override