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  * \author A. Vilela Pereira
5  */
6 
12 
16 
17 #include <string>
18 #include <sstream>
19 
20 using namespace std;
21 using namespace edm;
22 
23 namespace dtCalibration {
24 
25 DTT0FillChamberFromDB::DTT0FillChamberFromDB(const ParameterSet& pset):
26  dbLabelRef_( pset.getParameter<string>("dbLabelRef") ),
27  chamberRef_( pset.getParameter<string>("chamberId") ) {
28 
29  //DTChamberId chosenChamberId;
30  if( chamberRef_ != "" && 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 }
41 
43 }
44 
46  // Get t0 record from DB
47  ESHandle<DTT0> t0H;
48  setup.get<DTT0Rcd>().get(t0H);
49  t0Map_ = &*t0H;
50  LogVerbatim("Calibration") << "[DTT0FillChamberFromDB] T0 version: " << t0H->version();
51 
52  // Get reference t0 DB
53  ESHandle<DTT0> t0RefH;
54  setup.get<DTT0Rcd>().get(dbLabelRef_,t0RefH);
55  t0MapRef_ = &*t0RefH;
56  LogVerbatim("Calibration") << "[DTT0FillChamberFromDB] Reference T0 version: " << t0RefH->version();
57 
58 }
59 
61  // If wire belongs to chosen chamber, use t0 value from reference DB
62  // Otherwise use value from default DB
63 
64  DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
65 
66  if( chamberRef_ != "" && chamberRef_ != "None" && chamberId == chosenChamberId_ ){
67  // Access reference DB
68  float t0MeanRef,t0RMSRef;
69  int statusRef = t0MapRef_->get(wireId,t0MeanRef,t0RMSRef,DTTimeUnits::counts);
70  if(!statusRef){
71  return DTT0Data(t0MeanRef,t0RMSRef);
72  } else{
73  //...
74  throw cms::Exception("[DTT0FillChamberFromDB]") << "Could not find t0 entry in reference DB for"
75  << wireId << endl;
76  }
77  } else{
78  // Access default DB
79  float t0Mean,t0RMS;
80  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
81  if(!status){
82  return DTT0Data(t0Mean,t0RMS);
83  } else{
84  //...
85  throw cms::Exception("[DTT0FillChamberFromDB]") << "Could not find t0 entry in DB for"
86  << wireId << endl;
87  }
88  }
89 }
90 
91 } // namespace
virtual DTT0Data correction(const DTWireId &)
DTChamberId chamberId() const
Return the corresponding ChamberId.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
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:67
const T & get() const
Definition: EventSetup.h:55
Definition: DTT0Rcd.h:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
virtual void setES(const edm::EventSetup &setup)
HLT enums.
const std::string & version() const
access version
Definition: DTT0.cc:118