CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CalibMuon/DTCalibration/plugins/DTCalibrationMap.h

Go to the documentation of this file.
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 kFactor(DTWireId wireId) const;
00047 
00049   float meanVDrift(DTWireId wireId) const;
00050 
00052   float sigma_meanVDrift(DTWireId wireId) const;
00053 
00054   typedef std::vector<float> CalibConsts;
00055   typedef DTWireId Key;
00056   typedef std::map<Key, CalibConsts>::const_iterator const_iterator;
00057 
00058   // Clean the map
00059   void cleanTheConsts() {
00060     theMap.clear();
00061   }
00062 
00063   // Get a particular number (field) between all the calibration
00064   // constants available for a particluar wire
00065   float getField(DTWireId wireId, int field) const;
00066 
00067   // Get from the map the calibration constants for a particular wire
00068   const CalibConsts* getConsts(DTWireId wireId) const;
00069 
00070 
00071   // Add to the map the calibration consts for a given key 
00072   void addCell(Key wireId, const CalibConsts& calibConst);
00073   
00074   // Write the calibration consts to a file 
00075   void writeConsts(const std::string& outputFileName) const;
00076 
00077   // Get a key to read calibration constants for a particular wire
00078   // with the given granularity
00079   Key getKey(DTWireId wireId) const;
00080 
00081   const_iterator keyAndConsts_begin() const {
00082     return theMap.begin();
00083   }
00084 
00085   const_iterator keyAndConsts_end() const {
00086     return theMap.end();
00087   }
00088 
00089 
00090 protected:
00091 
00092 private:
00093 
00094   // Specify the granularity for the calibration constants
00095   enum CalibGranularity {byChamber,bySL,byLayer,byWire};
00096   CalibGranularity theGranularity;
00097 
00098 
00099   // Read the calibration consts from a file 
00100   void readConsts(const std::string& inputFileName);
00101 
00102 
00103   // Check the consistency of a given key with the selected granularity
00104   bool checkGranularity(Key aKey) const;
00105 
00106 
00107   // The number of fields (calibration numbers) to be read from file
00108   unsigned int nFields;
00109 
00110   // The name of the file containing the calibration constants
00111   std::string calibConstFileName;
00112 
00113   // Define the granularity to be used for t0
00114   std::string calibConstGranularity;
00115 
00116   // The map between the Key and the calibration constants
00117   std::map<Key, CalibConsts> theMap;
00118   
00119 };
00120 
00121 #endif
00122