CMS 3D CMS Logo

DTT0AbsoluteReferenceCorrection.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  */
4 
10 
14 
18 
19 #include <string>
20 #include <sstream>
21 
22 using namespace std;
23 using namespace edm;
24 
25 namespace dtCalibration {
26 
27 DTT0AbsoluteReferenceCorrection::DTT0AbsoluteReferenceCorrection(const ParameterSet& pset):
28  calibChamber_( pset.getParameter<string>("calibChamber") ),
29  reference_( pset.getParameter<double>("reference") ) {
30 
31  //DTChamberId chosenChamberId;
32  if( calibChamber_ != "" && calibChamber_ != "None" && calibChamber_ != "All" ){
33  stringstream linestr;
34  int selWheel, selStation, selSector;
35  linestr << calibChamber_;
36  linestr >> selWheel >> selStation >> selSector;
37  chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
38  LogVerbatim("Calibration") << "[DTT0AbsoluteReferenceCorrection] Chosen chamber: " << chosenChamberId_ << endl;
39  }
40  //FIXME: Check if chosen chamber is valid.
41 }
42 
44 }
45 
47  // Get t0 record from DB
48  ESHandle<DTT0> t0H;
49  setup.get<DTT0Rcd>().get(t0H);
50  t0Map_ = &*t0H;
51  LogVerbatim("Calibration") << "[DTT0AbsoluteReferenceCorrection] T0 version: " << t0H->version();
52 }
53 
55  // Compute for selected chamber (or All) correction using as reference chamber mean
56 
57  DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
58 
59  if( calibChamber_ == "" || calibChamber_ == "None" ) return defaultT0(wireId);
60  if( calibChamber_ != "All" && chamberId != chosenChamberId_ ) return defaultT0(wireId);
61 
62  // Access DB
63  float t0Mean,t0RMS;
64  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
65  if(status != 0)
66  throw cms::Exception("[DTT0AbsoluteReferenceCorrection]") << "Could not find t0 entry in DB for"
67  << wireId << endl;
68 
69  float t0MeanNew = t0Mean - reference_;
70  float t0RMSNew = t0RMS;
71  return DTT0Data(t0MeanNew,t0RMSNew);
72 }
73 
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("[DTT0AbsoluteReferenceCorrection]") << "Could not find t0 entry in DB for"
83  << wireId << endl;
84  }
85 }
86 
87 } // namespace
DTChamberId chamberId() const
Return the corresponding ChamberId.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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
void setES(const edm::EventSetup &setup) override
Definition: DTT0Rcd.h:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
HLT enums.
T get() const
Definition: EventSetup.h:71
const std::string & version() const
access version
Definition: DTT0.cc:118