CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTT0AbsoluteReferenceCorrection.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 
20 
21 #include <string>
22 #include <sstream>
23 
24 using namespace std;
25 using namespace edm;
26 
27 namespace dtCalibration {
28 
29 DTT0AbsoluteReferenceCorrection::DTT0AbsoluteReferenceCorrection(const ParameterSet& pset):
30  calibChamber_( pset.getParameter<string>("calibChamber") ),
31  reference_( pset.getParameter<double>("reference") ) {
32 
33  //DTChamberId chosenChamberId;
34  if( calibChamber_ != "" && calibChamber_ != "None" && calibChamber_ != "All" ){
35  stringstream linestr;
36  int selWheel, selStation, selSector;
37  linestr << calibChamber_;
38  linestr >> selWheel >> selStation >> selSector;
39  chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
40  LogVerbatim("Calibration") << "[DTT0AbsoluteReferenceCorrection] Chosen chamber: " << chosenChamberId_ << endl;
41  }
42  //FIXME: Check if chosen chamber is valid.
43 }
44 
46 }
47 
49  // Get t0 record from DB
50  ESHandle<DTT0> t0H;
51  setup.get<DTT0Rcd>().get(t0H);
52  t0Map_ = &*t0H;
53  LogVerbatim("Calibration") << "[DTT0AbsoluteReferenceCorrection] T0 version: " << t0H->version();
54 }
55 
57  // Compute for selected chamber (or All) correction using as reference chamber mean
58 
59  DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
60 
61  if( calibChamber_ == "" || calibChamber_ == "None" ) return defaultT0(wireId);
62  if( calibChamber_ != "All" && chamberId != chosenChamberId_ ) return defaultT0(wireId);
63 
64  // Access DB
65  float t0Mean,t0RMS;
66  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
67  if(status != 0)
68  throw cms::Exception("[DTT0AbsoluteReferenceCorrection]") << "Could not find t0 entry in DB for"
69  << wireId << endl;
70 
71  float t0MeanNew = t0Mean - reference_;
72  float t0RMSNew = t0RMS;
73  return DTT0Data(t0MeanNew,t0RMSNew);
74 }
75 
77  // Access default DB
78  float t0Mean,t0RMS;
79  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
80  if(!status){
81  return DTT0Data(t0Mean,t0RMS);
82  } else{
83  //...
84  throw cms::Exception("[DTT0AbsoluteReferenceCorrection]") << "Could not find t0 entry in DB for"
85  << wireId << endl;
86  }
87 }
88 
89 } // namespace
DTChamberId chamberId() const
Return the corresponding ChamberId.
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:56
virtual void setES(const edm::EventSetup &setup)
Definition: DTT0Rcd.h:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
tuple status
Definition: ntuplemaker.py:245
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")