CMS 3D CMS Logo

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