CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/CalibMuon/CSCCalibration/interface/CSCConditions.h

Go to the documentation of this file.
00001 #ifndef CSCCalibration_CSCConditions_h
00002 #define CSCCalibration_CSCConditions_h
00003 
00004 #include "FWCore/Framework/interface/ESWatcher.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00008 #include "CondFormats/CSCObjects/interface/CSCDBNoiseMatrix.h"
00009 #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h"
00010 #include "CondFormats/DataRecord/interface/CSCBadStripsRcd.h"
00011 #include "CondFormats/DataRecord/interface/CSCBadWiresRcd.h"
00012 #include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"
00013 #include "CondFormats/DataRecord/interface/CSCDBChipSpeedCorrectionRcd.h"
00014 #include "CondFormats/DataRecord/interface/CSCChamberTimeCorrectionsRcd.h"
00015 #include "CondFormats/DataRecord/interface/CSCDBGasGainCorrectionRcd.h"
00016 #include <vector>
00017 #include <bitset>
00018 
00019 class CSCDBGains;
00020 class CSCDBPedestals;
00021 class CSCDBCrosstalk;
00022 class CSCBadStrips;
00023 class CSCBadWires;
00024 class CSCBadChambers;
00025 class CSCDBChipSpeedCorrection;
00026 class CSCChamberTimeCorrections;
00027 class CSCDBGasGainCorrection;
00028 
00035 class CSCConditions
00036 {
00037 public:
00038   explicit CSCConditions( const edm::ParameterSet& ps );
00039   ~CSCConditions();
00040 
00042   void initializeEvent(const edm::EventSetup & es);
00043 
00045   float gain(const CSCDetId & detId, int channel) const;
00047   float gainSigma(const CSCDetId & detId, int channel) const {return 0.005;}
00048 
00050   float pedestal(const CSCDetId & detId, int channel) const;
00051   float pedestalSigma(const CSCDetId & detId, int channel) const;
00052 
00053   float crosstalkSlope(const CSCDetId & detId, int channel, bool leftRight) const;
00054   float crosstalkIntercept(const CSCDetId & detId, int channel, bool leftRight) const;
00055 
00057   const CSCDBNoiseMatrix::Item & noiseMatrix(const CSCDetId & detId, int channel) const;
00058 
00060   void noiseMatrixElements( const CSCDetId& id, int channel, std::vector<float>& me ) const;
00061 
00063   void crossTalk( const CSCDetId& id, int channel, std::vector<float>& ct ) const;
00064 
00065   // returns chip speed correction in ns given detId (w/layer) and strip channel
00066   float chipCorrection( const CSCDetId & detId, int channel ) const;
00067 
00068   //return chamber timing correction in ns given detId of chamber 
00069   float chamberTimingCorrection( const CSCDetId & detId) const;
00070 
00071   //return anode bx offset in bx given detId of chamber 
00072   float anodeBXoffset( const CSCDetId & detId) const;
00073 
00075   const std::bitset<80>& badStripWord( const CSCDetId& id ) const;
00076   const std::bitset<112>& badWireWord( const CSCDetId& id ) const;
00077 
00078   void print() const;
00079 
00081   bool isInBadChamber( const CSCDetId& id ) const;
00082 
00084   bool readBadChannels() const { return readBadChannels_; }
00085 
00087   bool readBadChambers() const { return readBadChambers_; }
00088 
00090   bool useTimingCorrections() const { return useTimingCorrections_; }
00091 
00093   void fillBadStripWords();
00094   void fillBadWireWords();
00095 
00097   float averageGain() const;
00098 
00100   float gasGainCorrection( const CSCDetId & detId, int strip, int wire ) const;
00101 
00103   bool useGasGainCorrections() const { return useGasGainCorrections_; }
00104 
00105 private:
00106 
00107   edm::ESHandle<CSCDBGains> theGains;
00108   edm::ESHandle<CSCDBCrosstalk> theCrosstalk;
00109   edm::ESHandle<CSCDBPedestals> thePedestals;
00110   edm::ESHandle<CSCDBNoiseMatrix> theNoiseMatrix;
00111   edm::ESHandle<CSCBadStrips> theBadStrips;
00112   edm::ESHandle<CSCBadWires> theBadWires;
00113   edm::ESHandle<CSCBadChambers> theBadChambers;
00114   edm::ESHandle<CSCDBChipSpeedCorrection> theChipCorrections;
00115   edm::ESHandle<CSCChamberTimeCorrections> theChamberTimingCorrections;
00116   edm::ESHandle<CSCDBGasGainCorrection> theGasGainCorrections;
00117 
00118   bool readBadChannels_; // flag whether or not to even attempt reading bad channel info from db
00119   bool readBadChambers_; // flag whether or not to even attempt reading bad chamber info from db
00120   bool useTimingCorrections_; // flag whether or not to even attempt reading timing correction info from db
00121   bool useGasGainCorrections_; // flag whether or not to even attempt reading gas-gain correction info from db
00122 
00123   // cache bad channel words once created
00124   std::vector< std::bitset<80> > badStripWords;
00125   std::vector< std::bitset<112> > badWireWords;
00126 
00127   mutable float theAverageGain; // average over entire system, subject to some constraints!
00128 
00129   edm::ESWatcher<CSCDBGainsRcd> gainsWatcher_; 
00130   //@@ remove until we have real information to use
00131   //  edm::ESWatcher<CSCBadStripsRcd> badStripsWatcher_; 
00132   //  edm::ESWatcher<CSCBadWiresRcd> badWiresWatcher_; 
00133 
00134   // Total number of CSC layers in the system, with full ME42 installed.
00135   enum elayers{ MAX_LAYERS = 3240 };
00136 };
00137 
00138 #endif
00139 
00140