00001 #ifndef DTCalibration_DTCalibrationMap_H 00002 #define DTCalibration_DTCalibrationMap_H 00003 00016 #include "DataFormats/MuonDetId/interface/DTWireId.h" 00017 00018 00019 #include <string> 00020 #include <map> 00021 #include <vector> 00022 00023 00024 00025 namespace edm { 00026 class ParameterSet; 00027 } 00028 00029 class DTCalibrationMap { 00030 public: 00032 DTCalibrationMap(const edm::ParameterSet& pset); 00033 00035 virtual ~DTCalibrationMap(); 00036 00037 // Operations 00038 00040 float tTrig(DTWireId wireId) const; 00041 00043 float sigma_tTrig(DTWireId wireId) const; 00044 00046 float meanVDrift(DTWireId wireId) const; 00047 00049 float sigma_meanVDrift(DTWireId wireId) const; 00050 00051 typedef std::vector<float> CalibConsts; 00052 typedef DTWireId Key; 00053 typedef std::map<Key, CalibConsts>::const_iterator const_iterator; 00054 00055 // Clean the map 00056 void cleanTheConsts() { 00057 theMap.clear(); 00058 } 00059 00060 // Get a particular number (field) between all the calibration 00061 // constants available for a particluar wire 00062 float getField(DTWireId wireId, int field) const; 00063 00064 // Get from the map the calibration constants for a particular wire 00065 const CalibConsts* getConsts(DTWireId wireId) const; 00066 00067 00068 // Add to the map the calibration consts for a given key 00069 void addCell(Key wireId, const CalibConsts& calibConst); 00070 00071 // Write the calibration consts to a file 00072 void writeConsts(const std::string& outputFileName) const; 00073 00074 // Get a key to read calibration constants for a particular wire 00075 // with the given granularity 00076 Key getKey(DTWireId wireId) const; 00077 00078 const_iterator keyAndConsts_begin() const { 00079 return theMap.begin(); 00080 } 00081 00082 const_iterator keyAndConsts_end() const { 00083 return theMap.end(); 00084 } 00085 00086 00087 protected: 00088 00089 private: 00090 00091 // Specify the granularity for the calibration constants 00092 enum CalibGranularity {byChamber,bySL,byLayer,byWire}; 00093 CalibGranularity theGranularity; 00094 00095 00096 // Read the calibration consts from a file 00097 void readConsts(const std::string& inputFileName); 00098 00099 00100 // Check the consistency of a given key with the selected granularity 00101 bool checkGranularity(Key aKey) const; 00102 00103 00104 // The number of fields (calibration numbers) to be read from file 00105 unsigned int nFields; 00106 00107 // The name of the file containing the calibration constants 00108 std::string calibConstFileName; 00109 00110 // Define the granularity to be used for t0 00111 std::string calibConstGranularity; 00112 00113 // The map between the Key and the calibration constants 00114 std::map<Key, CalibConsts> theMap; 00115 00116 }; 00117 00118 #endif 00119