Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:42

0001 #include "CondFormats/CSCObjects/interface/CSCChannelTranslator.h"
0002 #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
0003 #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h"
0004 #include "CondFormats/DataRecord/interface/CSCDBNoiseMatrixRcd.h"
0005 #include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
0006 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 #include "SimMuon/CSCDigitizer/src/CSCDbStripConditions.h"
0009 
0010 CSCDbStripConditions::CSCDbStripConditions(const edm::ParameterSet &pset, edm::ConsumesCollector cc)
0011     : CSCStripConditions(),
0012       theConditions(pset, cc),
0013       theCapacitiveCrosstalk(pset.getParameter<double>("capacativeCrosstalk")),
0014       theResistiveCrosstalkScaling(pset.getParameter<double>("resistiveCrosstalkScaling")),
0015       theGainsConstant(pset.getParameter<double>("gainsConstant")),
0016       doCorrelatedNoise_(pset.getParameter<bool>("doCorrelatedNoise")) {
0017   //  theCapacitiveCrosstalk = = 1/maxslope/maxsignal) = 1/ (0.00231/0.143);
0018   // Howoever, need a bit more.  Maybe the slope gets smeared?
0019 }
0020 
0021 CSCDbStripConditions::~CSCDbStripConditions() {
0022   if (theNoisifier != nullptr)
0023     delete theNoisifier;
0024 }
0025 
0026 void CSCDbStripConditions::initializeEvent(const edm::EventSetup &es) { theConditions.initializeEvent(es); }
0027 
0028 float CSCDbStripConditions::gain(const CSCDetId &id, int channel) const {
0029   return theConditions.gain(id, channel) * theGainsConstant;
0030 }
0031 
0032 float CSCDbStripConditions::pedestal(const CSCDetId &id, int channel) const {
0033   return theConditions.pedestal(id, channel);
0034 }
0035 
0036 float CSCDbStripConditions::pedestalSigma(const CSCDetId &id, int channel) const {
0037   return theConditions.pedestalSigma(id, channel);
0038 }
0039 
0040 void CSCDbStripConditions::crosstalk(
0041     const CSCDetId &id, int channel, double stripLength, bool leftRight, float &capacitive, float &resistive) const {
0042   resistive = theConditions.crosstalkIntercept(id, channel, leftRight) * theResistiveCrosstalkScaling;
0043   float slope = theConditions.crosstalkSlope(id, channel, leftRight);
0044   // ns before the peak where slope is max
0045   float maxSlopeTime = 60.;
0046   // some confusion about +/-
0047   float capacitiveFraction = fabs(slope) * maxSlopeTime;
0048   // theCapacitiveCrosstalk is the number needed for 100% xtalk, so
0049   capacitive = theCapacitiveCrosstalk * capacitiveFraction;
0050 }
0051 
0052 void CSCDbStripConditions::fetchNoisifier(const CSCDetId &id, int istrip) {
0053   std::vector<float> me(12);                          // buffer for matrix elements
0054   theConditions.noiseMatrixElements(id, istrip, me);  // fill it
0055 
0056   CSCCorrelatedNoiseMatrix matrix;
0057   // TODO get the pedestals right
0058   matrix(2, 2) = me[0];   // item.elem33;
0059   matrix(3, 3) = me[3];   // item.elem44;
0060   matrix(4, 4) = me[6];   // item.elem55;
0061   matrix(5, 5) = me[9];   // item.elem66;
0062   matrix(6, 6) = me[11];  // item.elem77;
0063 
0064   if (doCorrelatedNoise_) {
0065     matrix(2, 3) = me[1];   // item.elem34;
0066     matrix(2, 4) = me[2];   // item.elem35;
0067     matrix(3, 4) = me[4];   // item.elem45;
0068     matrix(3, 5) = me[5];   // item.elem46;
0069     matrix(4, 5) = me[7];   // item.elem56;
0070     matrix(4, 6) = me[8];   // item.elem57;
0071     matrix(5, 6) = me[10];  // item.elem67;
0072   }
0073 
0074   // the other diagonal elements can just come from the pedestal sigma
0075   float sigma = pedestalSigma(id, istrip);
0076   //@@  float scaVariance = 2 * sigma * sigma;
0077   //@@ The '2 *' IS strictly correct, but currently the value in the cond db is
0078   // 2x too large since
0079   //@@ it is the rms of the distribution of pedestals of all 8 time samples
0080   // rather than the rms of
0081   //@@ the average of the first two time samples
0082   float scaVariance = sigma * sigma;
0083   matrix(0, 0) = matrix(1, 1) = matrix(7, 7) = scaVariance;
0084 
0085   // unknown neighbors can be the average of the known neighbors
0086   // float avgNeighbor = (matrix(2,3)+matrix(3,4)+matrix(4,5)+matrix(5,6))/4.;
0087   // float avg2away = (matrix(2,4)+matrix(3,5)+matrix(4,6))/3.;
0088   // matrix(0,1) = matrix(1,2) = matrix(6,7) = avgNeighbor;
0089   // matrix(0,2) = matrix(1,3) = matrix(5,7) = avg2away;
0090 
0091   if (theNoisifier != nullptr)
0092     delete theNoisifier;
0093   theNoisifier = new CSCCorrelatedNoisifier(matrix);
0094 }
0095 
0096 bool CSCDbStripConditions::isInBadChamber(const CSCDetId &id) const { return theConditions.isInBadChamber(id); }